From 50293860001a7b0030551e61d6f78cc507f0f3a1 Mon Sep 17 00:00:00 2001 From: Peter Surda Date: Sun, 14 Feb 2016 21:37:53 +0100 Subject: [PATCH] Email gateway updates - settings option available - reduce max TTL to 2 days --- src/bitmessageqt/__init__.py | 14 ++++++++++ src/bitmessageqt/account.py | 47 +++++++++++++++++++++++++++++++- src/bitmessageqt/emailgateway.py | 9 ++++-- 3 files changed, 67 insertions(+), 3 deletions(-) diff --git a/src/bitmessageqt/__init__.py b/src/bitmessageqt/__init__.py index b15e44fc..9a8606f3 100644 --- a/src/bitmessageqt/__init__.py +++ b/src/bitmessageqt/__init__.py @@ -2737,6 +2737,20 @@ class MyForm(settingsmixin.SMainWindow): acct.status() self.statusBar().showMessage(_translate( "MainWindow", "Sending email gateway status request")) + 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(0) + self.ui.tabWidget.setCurrentIndex(1) + self.ui.textEditMessage.setFocus() elif self.dialog.ui.radioButtonRegister.isChecked(): email = str(self.dialog.ui.lineEditEmail.text().toUtf8()) acct = MailchuckAccount(addressAtCurrentRow) diff --git a/src/bitmessageqt/account.py b/src/bitmessageqt/account.py index 0c3e95c6..7bf897cf 100644 --- a/src/bitmessageqt/account.py +++ b/src/bitmessageqt/account.py @@ -161,7 +161,7 @@ class GatewayAccount(BMAccount): 0, # retryNumber 'sent', # folder 2, # encodingtype - shared.config.getint('bitmessagesettings', 'ttl') + min(shared.config.getint('bitmessagesettings', 'ttl'), 86400 * 2) # not necessary to have a TTL higher than 2 days ) shared.workerQueue.put(('sendmessage', self.toAddress)) @@ -207,6 +207,51 @@ class MailchuckAccount(GatewayAccount): self.fromAddress = self.address self.send() + def settings(self): + self.toAddress = self.registrationAddress + self.subject = "config" + self.message = QtGui.QApplication.translate("Mailchuck", """# You can use this to configure your email gateway account +# Uncomment the setting you want to use +# Here are the options: +# +# pgp: server +# The email gateway will create and maintain PGP keys for you and sign, verify, +# encrypt and decrypt on your behalf. When you want to use PGP but are lazy, +# use this. Requires subscription. +# +# pgp: local +# The email gateway will not conduct PGP operations on your behalf. You can +# either not use PGP at all, or use it locally. +# +# attachments: yes +# Incoming attachments in the email will be uploaded to MEGA.nz, and you can +# download them from there by following the link. Requires a subscription. +# +# attachments: no +# Attachments will be ignored. +# +# archive: yes +# Your incoming emails will be archived on the server. Use this if you need +# help with debugging problems or you need a third party proof of emails. This +# however means that the operator of the service will be able to read your +# emails even after they have been delivered to you. +# +# archive: no +# Incoming emails will be deleted from the server as soon as they are relayed +# to you. +# +# masterpubkey_btc: BIP44 xpub key or electrum v1 public seed +# offset_btc: integer (defaults to 0) +# feeamount: number with up to 8 decimal places +# feecurrency: BTC, XBT, USD, EUR or GBP +# Use these if you want to charge people who send you emails. If this is on and +# an unknown person sends you an email, they will be requested to pay the fee +# specified. As this scheme uses deterministic public keys, you will receive +# the money directly. To turn it off again, set "feeamount" to 0. Requires +# subscription. +""") + self.fromAddress = self.address + def parseMessage(self, toAddress, fromAddress, subject, message): super(GatewayAccount, self).parseMessage(toAddress, fromAddress, subject, message) if fromAddress == self.relayAddress: diff --git a/src/bitmessageqt/emailgateway.py b/src/bitmessageqt/emailgateway.py index 61b4a7f5..7fd478ad 100644 --- a/src/bitmessageqt/emailgateway.py +++ b/src/bitmessageqt/emailgateway.py @@ -27,9 +27,12 @@ class Ui_EmailGatewayDialog(object): 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, 5, 0, 1, 1) + self.gridLayout.addWidget(self.radioButtonUnregister, 6, 0, 1, 1) self.label = QtGui.QLabel(EmailGatewayDialog) self.label.setWordWrap(True) self.label.setObjectName(_fromUtf8("label")) @@ -46,13 +49,14 @@ class Ui_EmailGatewayDialog(object): 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, 6, 0, 1, 1) + 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) @@ -63,6 +67,7 @@ class Ui_EmailGatewayDialog(object): 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))