diff --git a/src/bitmessageqt/__init__.py b/src/bitmessageqt/__init__.py
index 2b9daa57..197d9d21 100644
--- a/src/bitmessageqt/__init__.py
+++ b/src/bitmessageqt/__init__.py
@@ -29,7 +29,6 @@ from migrationwizard import *
from foldertree import *
from newchandialog import *
from safehtmlparser import *
-from emailgateway import *
from settings import *
import settingsmixin
import support
@@ -2155,20 +2154,22 @@ class MyForm(settingsmixin.SMainWindow):
# whether it's in current message list or not
self.indicatorUpdate(True, to_label=acct.toLabel)
# cannot find item to pass here ):
- if hasattr(acct, "feedback") and acct.feedback != GatewayAccount.ALL_OK:
+ if hasattr(acct, "feedback") \
+ and acct.feedback != GatewayAccount.ALL_OK:
if acct.feedback == GatewayAccount.REGISTRATION_DENIED:
- self.dialog = EmailGatewayRegistrationDialog(self, _translate("EmailGatewayRegistrationDialog", "Registration failed:"),
- _translate("EmailGatewayRegistrationDialog", "The requested email address is not available, please try a new one. Fill out the new desired email address (including @mailchuck.com) below:")
- )
- if self.dialog.exec_():
- email = str(self.dialog.ui.lineEditEmail.text().toUtf8())
- # register resets address variables
- acct.register(email)
- BMConfigParser().set(acct.fromAddress, 'label', email)
- BMConfigParser().set(acct.fromAddress, 'gateway', 'mailchuck')
- BMConfigParser().save()
- self.statusBar().showMessage(_translate(
- "MainWindow", "Sending email gateway registration request"), 10000)
+ dialog = dialogs.EmailGatewayDialog(
+ self,
+ _translate(
+ "EmailGatewayRegistrationDialog",
+ "Registration failed:"),
+ _translate(
+ "EmailGatewayRegistrationDialog",
+ "The requested email address is not available,"
+ " please try a new one."),
+ config=BMConfigParser()
+ )
+ if dialog.exec_():
+ dialog.register(acct)
def click_pushButtonAddAddressBook(self, dialog=None):
if not dialog:
@@ -2488,56 +2489,31 @@ class MyForm(settingsmixin.SMainWindow):
dialogs.SpecialAddressBehaviorDialog(self, BMConfigParser())
def on_action_EmailGatewayDialog(self):
- self.dialog = EmailGatewayDialog(self)
+ dialog = dialogs.EmailGatewayDialog(self, config=BMConfigParser())
# For Modal dialogs
- if self.dialog.exec_():
- addressAtCurrentRow = self.getCurrentAccount()
- acct = accountClass(addressAtCurrentRow)
- # no chans / mailinglists
- if acct.type != AccountMixin.NORMAL:
- return
- if self.dialog.ui.radioButtonUnregister.isChecked() and isinstance(acct, GatewayAccount):
- acct.unregister()
- BMConfigParser().remove_option(addressAtCurrentRow, 'gateway')
- BMConfigParser().save()
- self.statusBar().showMessage(_translate(
- "MainWindow", "Sending email gateway unregistration request"), 10000)
- elif self.dialog.ui.radioButtonStatus.isChecked() and isinstance(acct, GatewayAccount):
- acct.status()
- self.statusBar().showMessage(_translate(
- "MainWindow", "Sending email gateway status request"), 10000)
- elif self.dialog.ui.radioButtonSettings.isChecked() and isinstance(acct, GatewayAccount):
- acct.settings()
- listOfAddressesInComboBoxSendFrom = [str(self.ui.comboBoxSendFrom.itemData(i).toPyObject()) for i in range(self.ui.comboBoxSendFrom.count())]
- if acct.fromAddress in listOfAddressesInComboBoxSendFrom:
- currentIndex = listOfAddressesInComboBoxSendFrom.index(acct.fromAddress)
- self.ui.comboBoxSendFrom.setCurrentIndex(currentIndex)
- else:
- self.ui.comboBoxSendFrom.setCurrentIndex(0)
- self.ui.lineEditTo.setText(acct.toAddress)
- self.ui.lineEditSubject.setText(acct.subject)
- self.ui.textEditMessage.setText(acct.message)
- self.ui.tabWidgetSend.setCurrentIndex(
- self.ui.tabWidgetSend.indexOf(self.ui.sendDirect)
- )
- self.ui.tabWidget.setCurrentIndex(
- self.ui.tabWidget.indexOf(self.ui.send)
- )
- self.ui.textEditMessage.setFocus()
- elif self.dialog.ui.radioButtonRegister.isChecked():
- email = str(self.dialog.ui.lineEditEmail.text().toUtf8())
- acct = MailchuckAccount(addressAtCurrentRow)
- acct.register(email)
- BMConfigParser().set(addressAtCurrentRow, 'label', email)
- BMConfigParser().set(addressAtCurrentRow, 'gateway', 'mailchuck')
- BMConfigParser().save()
- self.statusBar().showMessage(_translate(
- "MainWindow", "Sending email gateway registration request"), 10000)
+ acct = dialog.exec_()
+
+ # Only settings ramain here
+ if acct:
+ acct.settings()
+ for i in range(self.ui.comboBoxSendFrom.count()):
+ if str(self.ui.comboBoxSendFrom.itemData(i).toPyObject()) \
+ == acct.fromAddress:
+ self.ui.comboBoxSendFrom.setCurrentIndex(i)
+ break
else:
- pass
- #print "well nothing"
-# shared.writeKeysFile()
-# self.rerenderInboxToLabels()
+ self.ui.comboBoxSendFrom.setCurrentIndex(0)
+
+ self.ui.lineEditTo.setText(acct.toAddress)
+ self.ui.lineEditSubject.setText(acct.subject)
+ self.ui.textEditMessage.setText(acct.message)
+ self.ui.tabWidgetSend.setCurrentIndex(
+ self.ui.tabWidgetSend.indexOf(self.ui.sendDirect)
+ )
+ self.ui.tabWidget.setCurrentIndex(
+ self.ui.tabWidget.indexOf(self.ui.send)
+ )
+ self.ui.textEditMessage.setFocus()
def on_action_MarkAllRead(self):
if QtGui.QMessageBox.question(
@@ -4210,44 +4186,6 @@ class settingsDialog(QtGui.QDialog):
self.parent.ui.pushButtonFetchNamecoinID.show()
-class EmailGatewayDialog(QtGui.QDialog):
-
- def __init__(self, parent):
- QtGui.QWidget.__init__(self, parent)
- self.ui = Ui_EmailGatewayDialog()
- self.ui.setupUi(self)
- self.parent = parent
- addressAtCurrentRow = parent.getCurrentAccount()
- acct = accountClass(addressAtCurrentRow)
- if isinstance(acct, GatewayAccount):
- self.ui.radioButtonUnregister.setEnabled(True)
- self.ui.radioButtonStatus.setEnabled(True)
- self.ui.radioButtonStatus.setChecked(True)
- self.ui.radioButtonSettings.setEnabled(True)
- else:
- self.ui.radioButtonStatus.setEnabled(False)
- self.ui.radioButtonSettings.setEnabled(False)
- self.ui.radioButtonUnregister.setEnabled(False)
- label = BMConfigParser().get(addressAtCurrentRow, 'label')
- if label.find("@mailchuck.com") > -1:
- self.ui.lineEditEmail.setText(label)
-
- QtGui.QWidget.resize(self, QtGui.QWidget.sizeHint(self))
-
-
-class EmailGatewayRegistrationDialog(QtGui.QDialog):
-
- def __init__(self, parent, title, label):
- QtGui.QWidget.__init__(self, parent)
- self.ui = Ui_EmailGatewayRegistrationDialog()
- self.ui.setupUi(self)
- self.parent = parent
- self.setWindowTitle(title)
- self.ui.label.setText(label)
-
- QtGui.QWidget.resize(self, QtGui.QWidget.sizeHint(self))
-
-
class NewAddressDialog(QtGui.QDialog):
def __init__(self, parent):
diff --git a/src/bitmessageqt/dialogs.py b/src/bitmessageqt/dialogs.py
index 58003f3a..c6fee734 100644
--- a/src/bitmessageqt/dialogs.py
+++ b/src/bitmessageqt/dialogs.py
@@ -1,5 +1,6 @@
from PyQt4 import QtCore, QtGui
from addresses import decodeAddress, encodeVarint
+from account import GatewayAccount, MailchuckAccount, AccountMixin, accountClass
from tr import _translate
from retranslateui import RetranslateMixin
import widgets
@@ -235,3 +236,79 @@ class SpecialAddressBehaviorDialog(QtGui.QDialog, RetranslateMixin):
self.parent.rerenderComboBoxSendFromBroadcast()
self.config.save()
self.parent.rerenderMessagelistToLabels()
+
+
+class EmailGatewayDialog(QtGui.QDialog, RetranslateMixin):
+ def __init__(self, parent, title=None, label=None, config=None):
+ super(EmailGatewayDialog, self).__init__(parent)
+ widgets.load('emailgateway.ui', self)
+ self.parent = parent
+ self.config = config
+ if title and label:
+ self.setWindowTitle(title)
+ self.label.setText(label)
+ self.radioButtonRegister.hide()
+ self.radioButtonStatus.hide()
+ self.radioButtonSettings.hide()
+ self.radioButtonUnregister.hide()
+ else:
+ address = parent.getCurrentAccount()
+ self.acct = accountClass(address)
+ try:
+ label = config.get(address, 'label')
+ except AttributeError:
+ pass
+ else:
+ if "@" in label:
+ self.lineEditEmail.setText(label)
+ if isinstance(self.acct, GatewayAccount):
+ self.radioButtonUnregister.setEnabled(True)
+ self.radioButtonStatus.setEnabled(True)
+ self.radioButtonStatus.setChecked(True)
+ self.radioButtonSettings.setEnabled(True)
+ self.lineEditEmail.setEnabled(False)
+ else:
+ self.acct = MailchuckAccount(address)
+ self.lineEditEmail.setFocus()
+ QtGui.QWidget.resize(self, QtGui.QWidget.sizeHint(self))
+
+ def register(self, acct=None):
+ email = str(self.lineEditEmail.text().toUtf8())
+ if acct is None:
+ acct = self.acct
+ acct.register(email)
+ self.config.set(acct.fromAddress, 'label', email)
+ self.config.set(acct.fromAddress, 'gateway', 'mailchuck')
+ self.config.save()
+ self.parent.statusBar().showMessage(_translate(
+ "MainWindow",
+ "Sending email gateway registration request"
+ ), 10000)
+
+ def accept(self):
+ self.hide()
+ # no chans / mailinglists
+ if self.acct.type != AccountMixin.NORMAL:
+ return
+
+ if not isinstance(self.acct, GatewayAccount):
+ return
+
+ if self.radioButtonRegister.isChecked():
+ self.register()
+ elif self.radioButtonUnregister.isChecked():
+ self.acct.unregister()
+ self.config.remove_option(self.acct.fromAddress, 'gateway')
+ self.config.save()
+ self.parent.statusBar().showMessage(_translate(
+ "MainWindow",
+ "Sending email gateway unregistration request"
+ ), 10000)
+ elif self.radioButtonStatus.isChecked():
+ self.acct.status()
+ self.parent.statusBar().showMessage(_translate(
+ "MainWindow",
+ "Sending email gateway status request"
+ ), 10000)
+ elif self.radioButtonSettings.isChecked():
+ return self.acct
diff --git a/src/bitmessageqt/emailgateway.py b/src/bitmessageqt/emailgateway.py
deleted file mode 100644
index 54ca4529..00000000
--- a/src/bitmessageqt/emailgateway.py
+++ /dev/null
@@ -1,103 +0,0 @@
-# -*- coding: utf-8 -*-
-
-# Form implementation generated from reading ui file 'emailgateway.ui'
-#
-# Created: Fri Apr 26 17:43:31 2013
-# by: PyQt4 UI code generator 4.9.4
-#
-# WARNING! All changes made in this file will be lost!
-
-from PyQt4 import QtCore, QtGui
-
-try:
- _fromUtf8 = QtCore.QString.fromUtf8
-except AttributeError:
- _fromUtf8 = lambda s: s
-
-class Ui_EmailGatewayDialog(object):
- def setupUi(self, EmailGatewayDialog):
- EmailGatewayDialog.setObjectName(_fromUtf8("EmailGatewayDialog"))
- EmailGatewayDialog.resize(386, 172)
- self.gridLayout = QtGui.QGridLayout(EmailGatewayDialog)
- self.gridLayout.setObjectName(_fromUtf8("gridLayout"))
- self.radioButtonRegister = QtGui.QRadioButton(EmailGatewayDialog)
- self.radioButtonRegister.setChecked(True)
- self.radioButtonRegister.setObjectName(_fromUtf8("radioButtonRegister"))
- self.gridLayout.addWidget(self.radioButtonRegister, 1, 0, 1, 1)
- self.radioButtonStatus = QtGui.QRadioButton(EmailGatewayDialog)
- self.radioButtonStatus.setObjectName(_fromUtf8("radioButtonStatus"))
- self.gridLayout.addWidget(self.radioButtonStatus, 4, 0, 1, 1)
- self.radioButtonSettings = QtGui.QRadioButton(EmailGatewayDialog)
- self.radioButtonSettings.setObjectName(_fromUtf8("radioButtonSettings"))
- self.gridLayout.addWidget(self.radioButtonSettings, 5, 0, 1, 1)
- self.radioButtonUnregister = QtGui.QRadioButton(EmailGatewayDialog)
- self.radioButtonUnregister.setObjectName(_fromUtf8("radioButtonUnregister"))
- self.gridLayout.addWidget(self.radioButtonUnregister, 6, 0, 1, 1)
- self.label = QtGui.QLabel(EmailGatewayDialog)
- self.label.setWordWrap(True)
- self.label.setObjectName(_fromUtf8("label"))
- self.gridLayout.addWidget(self.label, 0, 0, 1, 1)
- self.label_2 = QtGui.QLabel(EmailGatewayDialog)
- self.label_2.setObjectName(_fromUtf8("label_2"))
- self.gridLayout.addWidget(self.label_2, 2, 0, 1, 1)
- self.lineEditEmail = QtGui.QLineEdit(EmailGatewayDialog)
- self.lineEditEmail.setEnabled(True)
- self.lineEditEmail.setObjectName(_fromUtf8("lineEditEmail"))
- self.gridLayout.addWidget(self.lineEditEmail, 3, 0, 1, 1)
- self.buttonBox = QtGui.QDialogButtonBox(EmailGatewayDialog)
- self.buttonBox.setMinimumSize(QtCore.QSize(368, 0))
- self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
- self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Ok)
- self.buttonBox.setObjectName(_fromUtf8("buttonBox"))
- self.gridLayout.addWidget(self.buttonBox, 7, 0, 1, 1)
-
- self.retranslateUi(EmailGatewayDialog)
- QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("accepted()")), EmailGatewayDialog.accept)
- QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("rejected()")), EmailGatewayDialog.reject)
- QtCore.QObject.connect(self.radioButtonRegister, QtCore.SIGNAL(_fromUtf8("clicked(bool)")), self.lineEditEmail.setEnabled)
- QtCore.QObject.connect(self.radioButtonStatus, QtCore.SIGNAL(_fromUtf8("clicked(bool)")), self.lineEditEmail.setDisabled)
- QtCore.QObject.connect(self.radioButtonSettings, QtCore.SIGNAL(_fromUtf8("clicked(bool)")), self.lineEditEmail.setDisabled)
- QtCore.QObject.connect(self.radioButtonUnregister, QtCore.SIGNAL(_fromUtf8("clicked(bool)")), self.lineEditEmail.setDisabled)
- QtCore.QMetaObject.connectSlotsByName(EmailGatewayDialog)
- EmailGatewayDialog.setTabOrder(self.radioButtonRegister, self.lineEditEmail)
- EmailGatewayDialog.setTabOrder(self.lineEditEmail, self.radioButtonUnregister)
- EmailGatewayDialog.setTabOrder(self.radioButtonUnregister, self.buttonBox)
-
- def retranslateUi(self, EmailGatewayDialog):
- EmailGatewayDialog.setWindowTitle(QtGui.QApplication.translate("EmailGatewayDialog", "Email gateway", None, QtGui.QApplication.UnicodeUTF8))
- self.radioButtonRegister.setText(QtGui.QApplication.translate("EmailGatewayDialog", "Register on email gateway", None, QtGui.QApplication.UnicodeUTF8))
- self.radioButtonStatus.setText(QtGui.QApplication.translate("EmailGatewayDialog", "Account status at email gateway", None, QtGui.QApplication.UnicodeUTF8))
- self.radioButtonSettings.setText(QtGui.QApplication.translate("EmailGatewayDialog", "Change account settings at email gateway", None, QtGui.QApplication.UnicodeUTF8))
- self.radioButtonUnregister.setText(QtGui.QApplication.translate("EmailGatewayDialog", "Unregister from email gateway", None, QtGui.QApplication.UnicodeUTF8))
- self.label.setText(QtGui.QApplication.translate("EmailGatewayDialog", "Email gateway allows you to communicate with email users. Currently, only the Mailchuck email gateway (@mailchuck.com) is available.", None, QtGui.QApplication.UnicodeUTF8))
- self.label_2.setText(QtGui.QApplication.translate("EmailGatewayDialog", "Desired email address (including @mailchuck.com):", None, QtGui.QApplication.UnicodeUTF8))
-
-
-class Ui_EmailGatewayRegistrationDialog(object):
- def setupUi(self, EmailGatewayRegistrationDialog):
- EmailGatewayRegistrationDialog.setObjectName(_fromUtf8("EmailGatewayRegistrationDialog"))
- EmailGatewayRegistrationDialog.resize(386, 172)
- self.gridLayout = QtGui.QGridLayout(EmailGatewayRegistrationDialog)
- self.gridLayout.setObjectName(_fromUtf8("gridLayout"))
- self.label = QtGui.QLabel(EmailGatewayRegistrationDialog)
- self.label.setWordWrap(True)
- self.label.setObjectName(_fromUtf8("label"))
- self.gridLayout.addWidget(self.label, 0, 0, 1, 1)
- self.lineEditEmail = QtGui.QLineEdit(EmailGatewayRegistrationDialog)
- self.lineEditEmail.setObjectName(_fromUtf8("lineEditEmail"))
- self.gridLayout.addWidget(self.lineEditEmail, 1, 0, 1, 1)
- self.buttonBox = QtGui.QDialogButtonBox(EmailGatewayRegistrationDialog)
- self.buttonBox.setMinimumSize(QtCore.QSize(368, 0))
- self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
- self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Ok)
- self.buttonBox.setObjectName(_fromUtf8("buttonBox"))
- self.gridLayout.addWidget(self.buttonBox, 7, 0, 1, 1)
-
- self.retranslateUi(EmailGatewayRegistrationDialog)
- QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("accepted()")), EmailGatewayRegistrationDialog.accept)
- QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("rejected()")), EmailGatewayRegistrationDialog.reject)
- QtCore.QMetaObject.connectSlotsByName(EmailGatewayRegistrationDialog)
-
- def retranslateUi(self, EmailGatewayRegistrationDialog):
- EmailGatewayRegistrationDialog.setWindowTitle(QtGui.QApplication.translate("EmailGatewayRegistrationDialog", "Email gateway registration", None, QtGui.QApplication.UnicodeUTF8))
- self.label.setText(QtGui.QApplication.translate("EmailGatewayRegistrationDialog", "Email gateway allows you to communicate with email users. Currently, only the Mailchuck email gateway (@mailchuck.com) is available.\nPlease type the desired email address (including @mailchuck.com) below:", None, QtGui.QApplication.UnicodeUTF8))
diff --git a/src/bitmessageqt/emailgateway.ui b/src/bitmessageqt/emailgateway.ui
index 927df46a..77a66dec 100644
--- a/src/bitmessageqt/emailgateway.ui
+++ b/src/bitmessageqt/emailgateway.ui
@@ -7,20 +7,20 @@
0
0
386
- 172
+ 240
Email gateway
- -
+
-
true
- Desired email address (including @mailchuck.com)
+ Desired email address (including @mailchuck.com):
@@ -50,28 +50,60 @@
- -
-
+
-
+
true
@mailchuck.com
+
+ 0
+
-
- Email gateway alows you to communicate with email users. Currently, only the Mailchuck email gateway (@mailchuck.com) is available.
+ Email gateway allows you to communicate with email users. Currently, only the Mailchuck email gateway (@mailchuck.com) is available.
true
+ -
+
+
+ false
+
+
+ Account status at email gateway
+
+
+ false
+
+
+
+ -
+
+
+ false
+
+
+ Change account settings at email gateway
+
+
+ false
+
+
+
-
+
+ false
+
Unregister from email gateway
@@ -84,7 +116,10 @@
radioButtonRegister
- lineEditEmailAddress
+ lineEditEmail
+ radioButtonStatus
+ radioButtonSettings
+ radioButtonUnregister
buttonBox
@@ -124,7 +159,7 @@
radioButtonRegister
clicked(bool)
- lineEditEmailAddress
+ lineEditEmail
setEnabled(bool)
@@ -140,7 +175,7 @@
radioButtonUnregister
clicked(bool)
- lineEditEmailAddress
+ lineEditEmail
setDisabled(bool)
@@ -153,5 +188,37 @@
+
+ radioButtonStatus
+ clicked(bool)
+ lineEditEmail
+ setDisabled(bool)
+
+
+ 20
+ 20
+
+
+ 20
+ 20
+
+
+
+
+ radioButtonSettings
+ clicked(bool)
+ lineEditEmail
+ setDisabled(bool)
+
+
+ 20
+ 20
+
+
+ 20
+ 20
+
+
+