Implementing settings dialog. Necessary before a pull request makes sense.

This commit is contained in:
Chuck 2013-07-04 16:51:24 +07:00
parent 02ec955790
commit 6abad093ef
8 changed files with 835 additions and 282 deletions

View File

@ -736,12 +736,9 @@ if __name__ == "__main__":
singleCleanerThread.start()
# Start the SMTP and POP3 server if necessary
smtpServer = None
pop3Server = None
try:
if shared.config.get('bitmessagesettings', 'smtppop3enable') == 'true':
smtpServer = bitmessageSMTPServer()
pop3Server = bitmessagePOP3Server()
if shared.config.getboolean('bitmessagesettings', 'smtppop3enable'):
shared.startSMTPPOP3Servers()
except NoOptionError:
pass

View File

@ -1741,6 +1741,26 @@ class MyForm(QtGui.QMainWindow):
self.settingsDialogInstance.ui.checkBoxShowTrayNotifications.isChecked()))
shared.config.set('bitmessagesettings', 'startintray', str(
self.settingsDialogInstance.ui.checkBoxStartInTray.isChecked()))
shared.config.set('bitmessagesettings', 'smtppop3enable', str(
self.settingsDialogInstance.ui.checkBoxEnableSMTPPOP3Servers.isChecked()))
shared.config.set('bitmessagesettings', 'smtpport', str(
self.settingsDialogInstance.ui.lineEditSMTPPort.text()))
shared.config.set('bitmessagesettings', 'smtpssl', str(
self.settingsDialogInstance.ui.checkBoxEnableSMTPSSL.isChecked()))
shared.config.set('bitmessagesettings', 'pop3port', str(
self.settingsDialogInstance.ui.lineEditPOP3Port.text()))
shared.config.set('bitmessagesettings', 'pop3ssl', str(
self.settingsDialogInstance.ui.checkBoxEnablePOP3SSL.isChecked()))
if self.settingsDialogInstance.sslCertFile is None:
shared.config.remove_option('bitmessagesettings', 'certfile')
else:
shared.config.set('bitmessagesettings', 'certfile', str(
self.settingsDialogInstance.sslCertFile))
if self.settingsDialogInstance.sslKeyFile is None:
shared.config.remove_option('bitmessagesettings', 'keyfile')
else:
shared.config.set('bitmessagesettings', 'keyfile', str(
self.settingsDialogInstance.sslKeyFile))
if int(shared.config.get('bitmessagesettings', 'port')) != int(self.settingsDialogInstance.ui.lineEditTCPPort.text()):
QMessageBox.about(self, _translate("MainWindow", "Restart"), _translate(
"MainWindow", "You must restart Bitmessage for the port number change to take effect."))
@ -1837,6 +1857,11 @@ class MyForm(QtGui.QMainWindow):
os.remove('keys.dat')
os.remove('knownnodes.dat')
# We'll always restart the servers just in case ports/keys/etc changed.
shared.stopSMTPOP3Servers()
if self.settingsDialogInstance.ui.checkBoxEnableSMTPPOP3Servers.isChecked():
shared.startSMTPPOP3Servers()
def click_radioButtonBlacklist(self):
if shared.config.get('bitmessagesettings', 'blackwhitelist') == 'white':
shared.config.set('bitmessagesettings', 'blackwhitelist', 'black')
@ -2745,8 +2770,158 @@ class settingsDialog(QtGui.QDialog):
else:
self.ui.comboBoxMaxCores.setCurrentIndex(5)"""
# SMTP & POP3 tab
self.ui.checkBoxEnableSMTPPOP3Servers.setChecked(
shared.config.getboolean('bitmessagesettings', 'smtppop3enable'))
try:
self.ui.lineEditSMTPPort.setText(
str(shared.config.getint('bitmessagesettings', 'smtpport')))
self.ui.checkBoxEnableSMTPSSL.setChecked(
shared.config.getboolean('bitmessagesettings', 'smtpssl'))
except:
self.ui.lineEditSMTPPort.setText('10025')
self.ui.checkBoxEnableSMTPSSL.setChecked(False)
try:
self.ui.lineEditPOP3Port.setText(
str(shared.config.getint('bitmessagesettings', 'pop3port')))
self.ui.checkBoxEnablePOP3SSL.setChecked(
shared.config.getboolean('bitmessagesettings', 'pop3ssl'))
except:
self.ui.lineEditPOP3Port.setText('10110')
self.ui.checkBoxEnablePOP3SSL.setChecked(False)
try:
fn = shared.config.get('bitmessagesettings', 'certfile')
self.configurePushButtonFindSSLCerficiate(fn)
except:
self.configurePushButtonFindSSLCerficiate(None)
try:
fn = shared.config.get('bitmessagesettings', 'keyfile')
self.configurePushButtonFindSSLKeyfile(fn)
except:
self.configurePushButtonFindSSLKeyfile(None)
configSections = shared.config.sections()
for addressInKeysFile in configSections:
if addressInKeysFile != 'bitmessagesettings':
status, addressVersionNumber, streamNumber, hash = decodeAddress(
addressInKeysFile)
if status != 'success':
continue
isEnabled = shared.config.getboolean(
addressInKeysFile, 'enabled')
if not isEnabled:
continue
self.ui.comboBoxEmailIdentities.insertItem(0, unicode(shared.config.get(
addressInKeysFile, 'label'), 'utf-8'), addressInKeysFile)
self.ui.comboBoxEmailIdentities.setCurrentIndex(0)
self.comboBoxEmailIdentitiesChanged(0)
QtCore.QObject.connect(self.ui.comboBoxEmailIdentities, QtCore.SIGNAL(
"currentIndexChanged(int)"), self.comboBoxEmailIdentitiesChanged)
QtCore.QObject.connect(self.ui.pushButtonClearPassword, QtCore.SIGNAL(
"clicked()"), self.click_ClearPassword)
QtCore.QObject.connect(self.ui.pushButtonSetPassword, QtCore.SIGNAL(
"clicked()"), self.click_SetPassword)
QtCore.QObject.connect(self.ui.pushButtonFindSSLCertificate, QtCore.SIGNAL(
"clicked()"), self.click_FindSSLCertificate)
QtCore.QObject.connect(self.ui.pushButtonFindSSLKeyfile, QtCore.SIGNAL(
"clicked()"), self.click_FindSSLKeyfile)
QtGui.QWidget.resize(self, QtGui.QWidget.sizeHint(self))
def accept(self):
if self.areSSLFilesOK():
QtGui.QDialog.accept(self)
else:
QtGui.QMessageBox.information(self, 'SSL Files', _translate(
"Settings", "Because you have enabled SSL on either SMTP or POP3 servers, you must specify valid SSL Certificate and Key files before continuing."), QMessageBox.Ok)
def configurePushButtonFindSSLCerficiate(self, fn):
self.ui.pushButtonFindSSLCertificate.setText('Find SSL Certificate...')
try:
self.sslCertFile = fn
if fn is not None and os.path.exists(fn):
self.ui.pushButtonFindSSLCertificate.setText('SSL Certificate: {} ...'.format(fn))
except:
pass
def configurePushButtonFindSSLKeyfile(self, fn):
self.ui.pushButtonFindSSLKeyfile.setText('Find SSL Keyfile...')
try:
self.sslKeyFile = fn
if fn is not None and os.path.exists(fn):
self.ui.pushButtonFindSSLKeyfile.setText('SSL Keyfile: {} ...'.format(fn))
except:
pass
def areSSLFilesOK(self):
if not self.ui.checkBoxEnableSMTPPOP3Servers.isChecked():
return True
if not self.ui.checkBoxEnablePOP3SSL.isChecked() and not self.ui.checkBoxEnableSMTPSSL.isChecked():
return True
if self.sslCertFile is not None and self.sslKeyFile is not None and os.path.exists(self.sslCertFile) and os.path.exists(self.sslKeyFile):
return True
return False
def comboBoxEmailIdentitiesChanged(self, comboBoxIndex):
address = str(self.ui.comboBoxEmailIdentities.itemData(comboBoxIndex).toPyObject())
self.ui.labelEmailIdentity.setText(address)
try:
shared.config.get(address, 'smtppop3password')
self.ui.pushButtonClearPassword.setEnabled(True)
self.ui.labelAccountStatus.setText('Password set.')
except:
self.ui.labelAccountStatus.setText('Account inaccessible via SMTP/POP3. Set a password to grant access.')
self.ui.pushButtonClearPassword.setEnabled(False)
def click_ClearPassword(self):
comboBoxIndex = self.ui.comboBoxEmailIdentities.currentIndex()
address = str(self.ui.comboBoxEmailIdentities.itemData(comboBoxIndex).toPyObject())
try:
shared.config.remove_option(address, 'smtppop3password')
except:
pass
self.comboBoxEmailIdentitiesChanged(comboBoxIndex)
def click_SetPassword(self):
comboBoxIndex = self.ui.comboBoxEmailIdentities.currentIndex()
address = str(self.ui.comboBoxEmailIdentities.itemData(comboBoxIndex).toPyObject())
text, response = QtGui.QInputDialog.getText(self, "Set Password", "Enter password:", QtGui.QLineEdit.Password)
if response:
try:
shared.config.set(address, 'smtppop3password', str(text))
except:
import traceback
traceback.print_exc()
pass
self.comboBoxEmailIdentitiesChanged(comboBoxIndex)
def click_FindSSLCertificate(self):
text = QtGui.QFileDialog.getOpenFileName(self, "Open SSL Certificate", os.getcwd(), "Certificate files (*.crt *.pem)")
if os.path.exists(text):
text = os.path.normpath(str(text))
else:
text = None
self.configurePushButtonFindSSLCerficiate(text)
def click_FindSSLKeyfile(self):
text = QtGui.QFileDialog.getOpenFileName(self, "Open SSL Key file", os.getcwd(), "Key files (*.key *.pem)")
if os.path.exists(text):
text = os.path.normpath(str(text))
else:
text = None
self.configurePushButtonFindSSLKeyfile(text)
def comboBoxProxyTypeChanged(self, comboBoxIndex):
if comboBoxIndex == 0:
self.ui.lineEditSocksHostname.setEnabled(False)

View File

@ -2,8 +2,8 @@
# Form implementation generated from reading ui file 'settings.ui'
#
# Created: Mon Jun 10 11:31:56 2013
# by: PyQt4 UI code generator 4.9.4
# Created: Thu Jul 04 16:15:21 2013
# by: PyQt4 UI code generator 4.10.1
#
# WARNING! All changes made in this file will be lost!
@ -12,12 +12,21 @@ from PyQt4 import QtCore, QtGui
try:
_fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:
_fromUtf8 = lambda s: s
def _fromUtf8(s):
return s
try:
_encoding = QtGui.QApplication.UnicodeUTF8
def _translate(context, text, disambig):
return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
def _translate(context, text, disambig):
return QtGui.QApplication.translate(context, text, disambig)
class Ui_settingsDialog(object):
def setupUi(self, settingsDialog):
settingsDialog.setObjectName(_fromUtf8("settingsDialog"))
settingsDialog.resize(445, 343)
settingsDialog.resize(623, 343)
self.gridLayout = QtGui.QGridLayout(settingsDialog)
self.gridLayout.setObjectName(_fromUtf8("gridLayout"))
self.buttonBox = QtGui.QDialogButtonBox(settingsDialog)
@ -215,10 +224,103 @@ class Ui_settingsDialog(object):
spacerItem7 = QtGui.QSpacerItem(20, 147, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
self.gridLayout_7.addItem(spacerItem7, 3, 1, 1, 1)
self.tabWidgetSettings.addTab(self.tab_2, _fromUtf8(""))
self.tab_3 = QtGui.QWidget()
self.tab_3.setObjectName(_fromUtf8("tab_3"))
self.gridLayout_8 = QtGui.QGridLayout(self.tab_3)
self.gridLayout_8.setObjectName(_fromUtf8("gridLayout_8"))
self.horizontalLayout_3 = QtGui.QHBoxLayout()
self.horizontalLayout_3.setObjectName(_fromUtf8("horizontalLayout_3"))
spacerItem8 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
self.horizontalLayout_3.addItem(spacerItem8)
self.pushButtonFindSSLCertificate = QtGui.QPushButton(self.tab_3)
self.pushButtonFindSSLCertificate.setObjectName(_fromUtf8("pushButtonFindSSLCertificate"))
self.horizontalLayout_3.addWidget(self.pushButtonFindSSLCertificate)
self.gridLayout_8.addLayout(self.horizontalLayout_3, 3, 0, 1, 4)
self.groupBox_3 = QtGui.QGroupBox(self.tab_3)
self.groupBox_3.setObjectName(_fromUtf8("groupBox_3"))
self.gridLayout_9 = QtGui.QGridLayout(self.groupBox_3)
self.gridLayout_9.setObjectName(_fromUtf8("gridLayout_9"))
self.horizontalLayout_2 = QtGui.QHBoxLayout()
self.horizontalLayout_2.setObjectName(_fromUtf8("horizontalLayout_2"))
self.pushButtonSetPassword = QtGui.QPushButton(self.groupBox_3)
self.pushButtonSetPassword.setObjectName(_fromUtf8("pushButtonSetPassword"))
self.horizontalLayout_2.addWidget(self.pushButtonSetPassword)
self.pushButtonClearPassword = QtGui.QPushButton(self.groupBox_3)
self.pushButtonClearPassword.setObjectName(_fromUtf8("pushButtonClearPassword"))
self.horizontalLayout_2.addWidget(self.pushButtonClearPassword)
spacerItem9 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
self.horizontalLayout_2.addItem(spacerItem9)
self.labelAccountStatus = QtGui.QLabel(self.groupBox_3)
self.labelAccountStatus.setObjectName(_fromUtf8("labelAccountStatus"))
self.horizontalLayout_2.addWidget(self.labelAccountStatus)
self.gridLayout_9.addLayout(self.horizontalLayout_2, 1, 0, 1, 3)
spacerItem10 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
self.gridLayout_9.addItem(spacerItem10, 0, 2, 1, 1)
self.labelEmailIdentity = QtGui.QLabel(self.groupBox_3)
self.labelEmailIdentity.setObjectName(_fromUtf8("labelEmailIdentity"))
self.gridLayout_9.addWidget(self.labelEmailIdentity, 0, 1, 1, 1)
self.comboBoxEmailIdentities = QtGui.QComboBox(self.groupBox_3)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.comboBoxEmailIdentities.sizePolicy().hasHeightForWidth())
self.comboBoxEmailIdentities.setSizePolicy(sizePolicy)
self.comboBoxEmailIdentities.setObjectName(_fromUtf8("comboBoxEmailIdentities"))
self.gridLayout_9.addWidget(self.comboBoxEmailIdentities, 0, 0, 1, 1)
self.gridLayout_8.addWidget(self.groupBox_3, 7, 0, 1, 4)
self.label_17 = QtGui.QLabel(self.tab_3)
self.label_17.setObjectName(_fromUtf8("label_17"))
self.gridLayout_8.addWidget(self.label_17, 2, 1, 1, 1)
self.label_16 = QtGui.QLabel(self.tab_3)
self.label_16.setObjectName(_fromUtf8("label_16"))
self.gridLayout_8.addWidget(self.label_16, 1, 1, 1, 1)
self.checkBoxEnablePOP3SSL = QtGui.QCheckBox(self.tab_3)
self.checkBoxEnablePOP3SSL.setObjectName(_fromUtf8("checkBoxEnablePOP3SSL"))
self.gridLayout_8.addWidget(self.checkBoxEnablePOP3SSL, 2, 3, 1, 1)
self.lineEditPOP3Port = QtGui.QLineEdit(self.tab_3)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.lineEditPOP3Port.sizePolicy().hasHeightForWidth())
self.lineEditPOP3Port.setSizePolicy(sizePolicy)
self.lineEditPOP3Port.setMaximumSize(QtCore.QSize(70, 16777215))
self.lineEditPOP3Port.setObjectName(_fromUtf8("lineEditPOP3Port"))
self.gridLayout_8.addWidget(self.lineEditPOP3Port, 2, 2, 1, 1)
spacerItem11 = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
self.gridLayout_8.addItem(spacerItem11, 8, 0, 1, 4)
spacerItem12 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
self.gridLayout_8.addItem(spacerItem12, 2, 0, 1, 1)
self.checkBoxEnableSMTPSSL = QtGui.QCheckBox(self.tab_3)
self.checkBoxEnableSMTPSSL.setObjectName(_fromUtf8("checkBoxEnableSMTPSSL"))
self.gridLayout_8.addWidget(self.checkBoxEnableSMTPSSL, 1, 3, 1, 1)
self.lineEditSMTPPort = QtGui.QLineEdit(self.tab_3)
self.lineEditSMTPPort.setEnabled(True)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.lineEditSMTPPort.sizePolicy().hasHeightForWidth())
self.lineEditSMTPPort.setSizePolicy(sizePolicy)
self.lineEditSMTPPort.setMaximumSize(QtCore.QSize(70, 16777215))
self.lineEditSMTPPort.setObjectName(_fromUtf8("lineEditSMTPPort"))
self.gridLayout_8.addWidget(self.lineEditSMTPPort, 1, 2, 1, 1)
spacerItem13 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
self.gridLayout_8.addItem(spacerItem13, 1, 0, 1, 1)
self.checkBoxEnableSMTPPOP3Servers = QtGui.QCheckBox(self.tab_3)
self.checkBoxEnableSMTPPOP3Servers.setObjectName(_fromUtf8("checkBoxEnableSMTPPOP3Servers"))
self.gridLayout_8.addWidget(self.checkBoxEnableSMTPPOP3Servers, 0, 0, 1, 1)
self.horizontalLayout_4 = QtGui.QHBoxLayout()
self.horizontalLayout_4.setObjectName(_fromUtf8("horizontalLayout_4"))
spacerItem14 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
self.horizontalLayout_4.addItem(spacerItem14)
self.pushButtonFindSSLKeyfile = QtGui.QPushButton(self.tab_3)
self.pushButtonFindSSLKeyfile.setObjectName(_fromUtf8("pushButtonFindSSLKeyfile"))
self.horizontalLayout_4.addWidget(self.pushButtonFindSSLKeyfile)
self.gridLayout_8.addLayout(self.horizontalLayout_4, 4, 0, 1, 4)
self.tabWidgetSettings.addTab(self.tab_3, _fromUtf8(""))
self.gridLayout.addWidget(self.tabWidgetSettings, 0, 0, 1, 1)
self.retranslateUi(settingsDialog)
self.tabWidgetSettings.setCurrentIndex(0)
self.tabWidgetSettings.setCurrentIndex(4)
QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("accepted()")), settingsDialog.accept)
QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("rejected()")), settingsDialog.reject)
QtCore.QObject.connect(self.checkBoxAuthentication, QtCore.SIGNAL(_fromUtf8("toggled(bool)")), self.lineEditSocksUsername.setEnabled)
@ -238,35 +340,48 @@ class Ui_settingsDialog(object):
settingsDialog.setTabOrder(self.lineEditSocksPassword, self.buttonBox)
def retranslateUi(self, settingsDialog):
settingsDialog.setWindowTitle(QtGui.QApplication.translate("settingsDialog", "Settings", None, QtGui.QApplication.UnicodeUTF8))
self.checkBoxStartOnLogon.setText(QtGui.QApplication.translate("settingsDialog", "Start Bitmessage on user login", None, QtGui.QApplication.UnicodeUTF8))
self.checkBoxStartInTray.setText(QtGui.QApplication.translate("settingsDialog", "Start Bitmessage in the tray (don\'t show main window)", None, QtGui.QApplication.UnicodeUTF8))
self.checkBoxMinimizeToTray.setText(QtGui.QApplication.translate("settingsDialog", "Minimize to tray", None, QtGui.QApplication.UnicodeUTF8))
self.checkBoxShowTrayNotifications.setText(QtGui.QApplication.translate("settingsDialog", "Show notification when message received", None, QtGui.QApplication.UnicodeUTF8))
self.checkBoxPortableMode.setText(QtGui.QApplication.translate("settingsDialog", "Run in Portable Mode", None, QtGui.QApplication.UnicodeUTF8))
self.label_7.setText(QtGui.QApplication.translate("settingsDialog", "In Portable Mode, messages and config files are stored in the same directory as the program rather than the normal application-data folder. This makes it convenient to run Bitmessage from a USB thumb drive.", None, QtGui.QApplication.UnicodeUTF8))
self.tabWidgetSettings.setTabText(self.tabWidgetSettings.indexOf(self.tabUserInterface), QtGui.QApplication.translate("settingsDialog", "User Interface", None, QtGui.QApplication.UnicodeUTF8))
self.groupBox.setTitle(QtGui.QApplication.translate("settingsDialog", "Listening port", None, QtGui.QApplication.UnicodeUTF8))
self.label.setText(QtGui.QApplication.translate("settingsDialog", "Listen for connections on port:", None, QtGui.QApplication.UnicodeUTF8))
self.groupBox_2.setTitle(QtGui.QApplication.translate("settingsDialog", "Proxy server / Tor", None, QtGui.QApplication.UnicodeUTF8))
self.label_2.setText(QtGui.QApplication.translate("settingsDialog", "Type:", None, QtGui.QApplication.UnicodeUTF8))
self.comboBoxProxyType.setItemText(0, QtGui.QApplication.translate("settingsDialog", "none", None, QtGui.QApplication.UnicodeUTF8))
self.comboBoxProxyType.setItemText(1, QtGui.QApplication.translate("settingsDialog", "SOCKS4a", None, QtGui.QApplication.UnicodeUTF8))
self.comboBoxProxyType.setItemText(2, QtGui.QApplication.translate("settingsDialog", "SOCKS5", None, QtGui.QApplication.UnicodeUTF8))
self.label_3.setText(QtGui.QApplication.translate("settingsDialog", "Server hostname:", None, QtGui.QApplication.UnicodeUTF8))
self.label_4.setText(QtGui.QApplication.translate("settingsDialog", "Port:", None, QtGui.QApplication.UnicodeUTF8))
self.checkBoxAuthentication.setText(QtGui.QApplication.translate("settingsDialog", "Authentication", None, QtGui.QApplication.UnicodeUTF8))
self.label_5.setText(QtGui.QApplication.translate("settingsDialog", "Username:", None, QtGui.QApplication.UnicodeUTF8))
self.label_6.setText(QtGui.QApplication.translate("settingsDialog", "Pass:", None, QtGui.QApplication.UnicodeUTF8))
self.tabWidgetSettings.setTabText(self.tabWidgetSettings.indexOf(self.tabNetworkSettings), QtGui.QApplication.translate("settingsDialog", "Network Settings", None, QtGui.QApplication.UnicodeUTF8))
self.label_8.setText(QtGui.QApplication.translate("settingsDialog", "When someone sends you a message, their computer must first complete some work. The difficulty of this work, by default, is 1. You may raise this default for new addresses you create by changing the values here. Any new addresses you create will require senders to meet the higher difficulty. There is one exception: if you add a friend or acquaintance to your address book, Bitmessage will automatically notify them when you next send a message that they need only complete the minimum amount of work: difficulty 1. ", None, QtGui.QApplication.UnicodeUTF8))
self.label_9.setText(QtGui.QApplication.translate("settingsDialog", "Total difficulty:", None, QtGui.QApplication.UnicodeUTF8))
self.label_11.setText(QtGui.QApplication.translate("settingsDialog", "Small message difficulty:", None, QtGui.QApplication.UnicodeUTF8))
self.label_12.setText(QtGui.QApplication.translate("settingsDialog", "The \'Small message difficulty\' mostly only affects the difficulty of sending small messages. Doubling this value makes it almost twice as difficult to send a small message but doesn\'t really affect large messages.", None, QtGui.QApplication.UnicodeUTF8))
self.label_10.setText(QtGui.QApplication.translate("settingsDialog", "The \'Total difficulty\' affects the absolute amount of work the sender must complete. Doubling this value doubles the amount of work.", None, QtGui.QApplication.UnicodeUTF8))
self.tabWidgetSettings.setTabText(self.tabWidgetSettings.indexOf(self.tab), QtGui.QApplication.translate("settingsDialog", "Demanded difficulty", None, QtGui.QApplication.UnicodeUTF8))
self.label_15.setText(QtGui.QApplication.translate("settingsDialog", "Here you may set the maximum amount of work you are willing to do to send a message to another person. Setting these values to 0 means that any value is acceptable.", None, QtGui.QApplication.UnicodeUTF8))
self.label_13.setText(QtGui.QApplication.translate("settingsDialog", "Maximum acceptable total difficulty:", None, QtGui.QApplication.UnicodeUTF8))
self.label_14.setText(QtGui.QApplication.translate("settingsDialog", "Maximum acceptable small message difficulty:", None, QtGui.QApplication.UnicodeUTF8))
self.tabWidgetSettings.setTabText(self.tabWidgetSettings.indexOf(self.tab_2), QtGui.QApplication.translate("settingsDialog", "Max acceptable difficulty", None, QtGui.QApplication.UnicodeUTF8))
settingsDialog.setWindowTitle(_translate("settingsDialog", "Settings", None))
self.checkBoxStartOnLogon.setText(_translate("settingsDialog", "Start Bitmessage on user login", None))
self.checkBoxStartInTray.setText(_translate("settingsDialog", "Start Bitmessage in the tray (don\'t show main window)", None))
self.checkBoxMinimizeToTray.setText(_translate("settingsDialog", "Minimize to tray", None))
self.checkBoxShowTrayNotifications.setText(_translate("settingsDialog", "Show notification when message received", None))
self.checkBoxPortableMode.setText(_translate("settingsDialog", "Run in Portable Mode", None))
self.label_7.setText(_translate("settingsDialog", "In Portable Mode, messages and config files are stored in the same directory as the program rather than the normal application-data folder. This makes it convenient to run Bitmessage from a USB thumb drive.", None))
self.tabWidgetSettings.setTabText(self.tabWidgetSettings.indexOf(self.tabUserInterface), _translate("settingsDialog", "User Interface", None))
self.groupBox.setTitle(_translate("settingsDialog", "Listening port", None))
self.label.setText(_translate("settingsDialog", "Listen for connections on port:", None))
self.groupBox_2.setTitle(_translate("settingsDialog", "Proxy server / Tor", None))
self.label_2.setText(_translate("settingsDialog", "Type:", None))
self.comboBoxProxyType.setItemText(0, _translate("settingsDialog", "none", None))
self.comboBoxProxyType.setItemText(1, _translate("settingsDialog", "SOCKS4a", None))
self.comboBoxProxyType.setItemText(2, _translate("settingsDialog", "SOCKS5", None))
self.label_3.setText(_translate("settingsDialog", "Server hostname:", None))
self.label_4.setText(_translate("settingsDialog", "Port:", None))
self.checkBoxAuthentication.setText(_translate("settingsDialog", "Authentication", None))
self.label_5.setText(_translate("settingsDialog", "Username:", None))
self.label_6.setText(_translate("settingsDialog", "Pass:", None))
self.tabWidgetSettings.setTabText(self.tabWidgetSettings.indexOf(self.tabNetworkSettings), _translate("settingsDialog", "Network Settings", None))
self.label_8.setText(_translate("settingsDialog", "When someone sends you a message, their computer must first complete some work. The difficulty of this work, by default, is 1. You may raise this default for new addresses you create by changing the values here. Any new addresses you create will require senders to meet the higher difficulty. There is one exception: if you add a friend or acquaintance to your address book, Bitmessage will automatically notify them when you next send a message that they need only complete the minimum amount of work: difficulty 1. ", None))
self.label_9.setText(_translate("settingsDialog", "Total difficulty:", None))
self.label_11.setText(_translate("settingsDialog", "Small message difficulty:", None))
self.label_12.setText(_translate("settingsDialog", "The \'Small message difficulty\' mostly only affects the difficulty of sending small messages. Doubling this value makes it almost twice as difficult to send a small message but doesn\'t really affect large messages.", None))
self.label_10.setText(_translate("settingsDialog", "The \'Total difficulty\' affects the absolute amount of work the sender must complete. Doubling this value doubles the amount of work.", None))
self.tabWidgetSettings.setTabText(self.tabWidgetSettings.indexOf(self.tab), _translate("settingsDialog", "Demanded difficulty", None))
self.label_15.setText(_translate("settingsDialog", "Here you may set the maximum amount of work you are willing to do to send a message to another person. Setting these values to 0 means that any value is acceptable.", None))
self.label_13.setText(_translate("settingsDialog", "Maximum acceptable total difficulty:", None))
self.label_14.setText(_translate("settingsDialog", "Maximum acceptable small message difficulty:", None))
self.tabWidgetSettings.setTabText(self.tabWidgetSettings.indexOf(self.tab_2), _translate("settingsDialog", "Max acceptable difficulty", None))
self.pushButtonFindSSLCertificate.setText(_translate("settingsDialog", "Find SSL Certificate...", None))
self.groupBox_3.setTitle(_translate("settingsDialog", "Identities", None))
self.pushButtonSetPassword.setText(_translate("settingsDialog", "Set Password...", None))
self.pushButtonClearPassword.setText(_translate("settingsDialog", "Clear Password", None))
self.labelAccountStatus.setText(_translate("settingsDialog", "Account Inaccessible via SMTP/POP3. Set a password to allow access.", None))
self.labelEmailIdentity.setText(_translate("settingsDialog", "TextLabel", None))
self.label_17.setText(_translate("settingsDialog", "POP3 Port", None))
self.label_16.setText(_translate("settingsDialog", "SMTP Port:", None))
self.checkBoxEnablePOP3SSL.setText(_translate("settingsDialog", "SSL", None))
self.checkBoxEnableSMTPSSL.setText(_translate("settingsDialog", "SSL", None))
self.checkBoxEnableSMTPPOP3Servers.setText(_translate("settingsDialog", "Enable SMTP && POP3 Servers", None))
self.pushButtonFindSSLKeyfile.setText(_translate("settingsDialog", "Find SSL Keyfile...", None))
self.tabWidgetSettings.setTabText(self.tabWidgetSettings.indexOf(self.tab_3), _translate("settingsDialog", "SMTP && POP3", None))

View File

@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>445</width>
<width>623</width>
<height>343</height>
</rect>
</property>
@ -27,7 +27,7 @@
<item row="0" column="0">
<widget class="QTabWidget" name="tabWidgetSettings">
<property name="currentIndex">
<number>0</number>
<number>4</number>
</property>
<widget class="QWidget" name="tabUserInterface">
<property name="enabled">
@ -491,6 +491,247 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_3">
<attribute name="title">
<string>SMTP &amp;&amp; POP3</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_8">
<item row="3" column="0" colspan="4">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<spacer name="horizontalSpacer_10">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="pushButtonFindSSLCertificate">
<property name="text">
<string>Find SSL Certificate...</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="7" column="0" colspan="4">
<widget class="QGroupBox" name="groupBox_3">
<property name="title">
<string>Identities</string>
</property>
<layout class="QGridLayout" name="gridLayout_9">
<item row="1" column="0" colspan="3">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QPushButton" name="pushButtonSetPassword">
<property name="text">
<string>Set Password...</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButtonClearPassword">
<property name="text">
<string>Clear Password</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_9">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="labelAccountStatus">
<property name="text">
<string>Account Inaccessible via SMTP/POP3. Set a password to allow access.</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="2">
<spacer name="horizontalSpacer_8">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="1">
<widget class="QLabel" name="labelEmailIdentity">
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QComboBox" name="comboBoxEmailIdentities">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="2" column="1">
<widget class="QLabel" name="label_17">
<property name="text">
<string>POP3 Port</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="label_16">
<property name="text">
<string>SMTP Port:</string>
</property>
</widget>
</item>
<item row="2" column="3">
<widget class="QCheckBox" name="checkBoxEnablePOP3SSL">
<property name="text">
<string>SSL</string>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QLineEdit" name="lineEditPOP3Port">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>70</width>
<height>16777215</height>
</size>
</property>
</widget>
</item>
<item row="8" column="0" colspan="4">
<spacer name="verticalSpacer_4">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="0">
<spacer name="horizontalSpacer_7">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="3">
<widget class="QCheckBox" name="checkBoxEnableSMTPSSL">
<property name="text">
<string>SSL</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QLineEdit" name="lineEditSMTPPort">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>70</width>
<height>16777215</height>
</size>
</property>
</widget>
</item>
<item row="1" column="0">
<spacer name="horizontalSpacer_6">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="0">
<widget class="QCheckBox" name="checkBoxEnableSMTPPOP3Servers">
<property name="text">
<string>Enable SMTP &amp;&amp; POP3 Servers</string>
</property>
</widget>
</item>
<item row="4" column="0" colspan="4">
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<spacer name="horizontalSpacer_11">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="pushButtonFindSSLKeyfile">
<property name="text">
<string>Find SSL Keyfile...</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
</item>
</layout>

View File

@ -12,4 +12,8 @@ class asyncoreThread(threading.Thread):
print "Asyncore thread started"
shared.printLock.release()
while True:
asyncore.loop(timeout=1) # Despite the horrible parameter name, this function will not timeout until all channels are closed.
shared.printLock.acquire()
print("all asyncore modules dead!")
shared.printLock.release()

View File

@ -267,7 +267,7 @@ class bitmessagePOP3Server(asyncore.dispatcher):
self.listen(10)
shared.printLock.acquire()
print "POP3 server started"
print "POP3 server started: SSL enabled={}".format(str(self.ssl))
shared.printLock.release()
def handle_accept(self):

View File

@ -130,6 +130,7 @@ class bitmessageSMTPChannel(asynchat.async_chat):
self.push('501 encoding not understood')
self.close_when_done()
return
z, self.address, pw = base64.b64decode(pw).split('\x00')
if z != '':
self.push('501 encoding not understood')
@ -274,7 +275,7 @@ class bitmessageSMTPServer(smtpd.SMTPServer):
smtpd.SMTPServer.__init__(self, ('127.0.0.1', smtpport), None)
shared.printLock.acquire()
print "SMTP server started"
print "SMTP server started: SSL enabled={}".format(str(self.ssl))
shared.printLock.release()
def handle_accept(self):

View File

@ -62,7 +62,27 @@ ackdataForWhichImWatching = {}
networkDefaultProofOfWorkNonceTrialsPerByte = 320 #The amount of work that should be performed (and demanded) per byte of the payload. Double this number to double the work.
networkDefaultPayloadLengthExtraBytes = 14000 #To make sending short messages a little more difficult, this value is added to the payload length for use in calculating the proof of work target.
#Global access to these running servers.
smtpServer = None
pop3Server = None
def startSMTPPOP3Servers():
global smtpServer
global pop3Server
if smtpServer is None:
from class_smtpServer import bitmessageSMTPServer
from class_pop3Server import bitmessagePOP3Server
smtpServer = bitmessageSMTPServer()
pop3Server = bitmessagePOP3Server()
def stopSMTPOP3Servers():
global smtpServer
global pop3Server
if smtpServer is not None:
smtpServer.close()
smtpServer = None
pop3Server.close()
pop3Server = None
def isInSqlInventory(hash):
t = (hash,)