launched autopep8 --in-place --recursive --jobs=0 -aaaaa __init__.py

This commit is contained in:
Gatien Bovyn 2013-06-12 23:12:32 +02:00
parent a5dd8c9187
commit 4f3b6751b3

View File

@ -6,7 +6,7 @@ except:
try: try:
from PyQt4.QtCore import * from PyQt4.QtCore import *
from PyQt4.QtGui import * from PyQt4.QtGui import *
except Exception, err: except Exception as err:
print 'PyBitmessage requires PyQt. You can download it from http://www.riverbankcomputing.com/software/pyqt/download or by searching Google for \'PyQt Download\' (without quotes).' print 'PyBitmessage requires PyQt. You can download it from http://www.riverbankcomputing.com/software/pyqt/download or by searching Google for \'PyQt Download\' (without quotes).'
print 'Error message:', err print 'Error message:', err
sys.exit() sys.exit()
@ -39,6 +39,7 @@ import pickle
import platform import platform
import string import string
class MyForm(QtGui.QMainWindow): class MyForm(QtGui.QMainWindow):
str_broadcast_subscribers = '[Broadcast subscribers]' str_broadcast_subscribers = '[Broadcast subscribers]'
@ -48,189 +49,256 @@ class MyForm(QtGui.QMainWindow):
self.ui = Ui_MainWindow() self.ui = Ui_MainWindow()
self.ui.setupUi(self) self.ui.setupUi(self)
#Ask the user if we may delete their old version 1 addresses if they have any. # Ask the user if we may delete their old version 1 addresses if they
# have any.
configSections = shared.config.sections() configSections = shared.config.sections()
for addressInKeysFile in configSections: for addressInKeysFile in configSections:
if addressInKeysFile <> 'bitmessagesettings': if addressInKeysFile != 'bitmessagesettings':
status,addressVersionNumber,streamNumber,hash = decodeAddress(addressInKeysFile) status, addressVersionNumber, streamNumber, hash = decodeAddress(
addressInKeysFile)
if addressVersionNumber == 1: if addressVersionNumber == 1:
displayMsg = "One of your addresses, "+addressInKeysFile+", is an old version 1 address. Version 1 addresses are no longer supported. May we delete it now?" displayMsg = QtGui.QApplication.translate(
reply = QtGui.QMessageBox.question(self, 'Message',displayMsg, QtGui.QMessageBox.Yes, QtGui.QMessageBox.No) "MainWindow", "One of your addresses, %1, is an old version 1 address. Version 1 addresses are no longer supported. "
+ "May we delete it now?").arg(addressInKeysFile)
reply = QtGui.QMessageBox.question(
self, 'Message', displayMsg, QtGui.QMessageBox.Yes, QtGui.QMessageBox.No)
if reply == QtGui.QMessageBox.Yes: if reply == QtGui.QMessageBox.Yes:
shared.config.remove_section(addressInKeysFile) shared.config.remove_section(addressInKeysFile)
with open(shared.appdata + 'keys.dat', 'wb') as configfile: with open(shared.appdata + 'keys.dat', 'wb') as configfile:
shared.config.write(configfile) shared.config.write(configfile)
#Configure Bitmessage to start on startup (or remove the configuration) based on the setting in the keys.dat file # Configure Bitmessage to start on startup (or remove the
# configuration) based on the setting in the keys.dat file
if 'win32' in sys.platform or 'win64' in sys.platform: if 'win32' in sys.platform or 'win64' in sys.platform:
#Auto-startup for Windows # Auto-startup for Windows
RUN_PATH = "HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Run" RUN_PATH = "HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Run"
self.settings = QSettings(RUN_PATH, QSettings.NativeFormat) self.settings = QSettings(RUN_PATH, QSettings.NativeFormat)
self.settings.remove("PyBitmessage") #In case the user moves the program and the registry entry is no longer valid, this will delete the old registry entry. self.settings.remove(
"PyBitmessage") # In case the user moves the program and the registry entry is no longer valid, this will delete the old registry entry.
if shared.config.getboolean('bitmessagesettings', 'startonlogon'): if shared.config.getboolean('bitmessagesettings', 'startonlogon'):
self.settings.setValue("PyBitmessage",sys.argv[0]) self.settings.setValue("PyBitmessage", sys.argv[0])
elif 'darwin' in sys.platform: elif 'darwin' in sys.platform:
#startup for mac # startup for mac
pass pass
elif 'linux' in sys.platform: elif 'linux' in sys.platform:
#startup for linux # startup for linux
pass pass
self.ui.labelSendBroadcastWarning.setVisible(False) self.ui.labelSendBroadcastWarning.setVisible(False)
#FILE MENU and other buttons # FILE MENU and other buttons
QtCore.QObject.connect(self.ui.actionExit, QtCore.SIGNAL("triggered()"), self.quit) QtCore.QObject.connect(self.ui.actionExit, QtCore.SIGNAL(
QtCore.QObject.connect(self.ui.actionManageKeys, QtCore.SIGNAL("triggered()"), self.click_actionManageKeys) "triggered()"), self.quit)
QtCore.QObject.connect(self.ui.actionDeleteAllTrashedMessages, QtCore.SIGNAL("triggered()"), self.click_actionDeleteAllTrashedMessages) QtCore.QObject.connect(self.ui.actionManageKeys, QtCore.SIGNAL(
QtCore.QObject.connect(self.ui.actionRegenerateDeterministicAddresses, QtCore.SIGNAL("triggered()"), self.click_actionRegenerateDeterministicAddresses) "triggered()"), self.click_actionManageKeys)
QtCore.QObject.connect(self.ui.pushButtonNewAddress, QtCore.SIGNAL("clicked()"), self.click_NewAddressDialog) QtCore.QObject.connect(self.ui.actionDeleteAllTrashedMessages, QtCore.SIGNAL(
QtCore.QObject.connect(self.ui.comboBoxSendFrom, QtCore.SIGNAL("activated(int)"),self.redrawLabelFrom) "triggered()"), self.click_actionDeleteAllTrashedMessages)
QtCore.QObject.connect(self.ui.pushButtonAddAddressBook, QtCore.SIGNAL("clicked()"), self.click_pushButtonAddAddressBook) QtCore.QObject.connect(self.ui.actionRegenerateDeterministicAddresses, QtCore.SIGNAL(
QtCore.QObject.connect(self.ui.pushButtonAddSubscription, QtCore.SIGNAL("clicked()"), self.click_pushButtonAddSubscription) "triggered()"), self.click_actionRegenerateDeterministicAddresses)
QtCore.QObject.connect(self.ui.pushButtonAddBlacklist, QtCore.SIGNAL("clicked()"), self.click_pushButtonAddBlacklist) QtCore.QObject.connect(self.ui.pushButtonNewAddress, QtCore.SIGNAL(
QtCore.QObject.connect(self.ui.pushButtonSend, QtCore.SIGNAL("clicked()"), self.click_pushButtonSend) "clicked()"), self.click_NewAddressDialog)
QtCore.QObject.connect(self.ui.pushButtonLoadFromAddressBook, QtCore.SIGNAL("clicked()"), self.click_pushButtonLoadFromAddressBook) QtCore.QObject.connect(self.ui.comboBoxSendFrom, QtCore.SIGNAL(
QtCore.QObject.connect(self.ui.radioButtonBlacklist, QtCore.SIGNAL("clicked()"), self.click_radioButtonBlacklist) "activated(int)"), self.redrawLabelFrom)
QtCore.QObject.connect(self.ui.radioButtonWhitelist, QtCore.SIGNAL("clicked()"), self.click_radioButtonWhitelist) QtCore.QObject.connect(self.ui.pushButtonAddAddressBook, QtCore.SIGNAL(
QtCore.QObject.connect(self.ui.pushButtonStatusIcon, QtCore.SIGNAL("clicked()"), self.click_pushButtonStatusIcon) "clicked()"), self.click_pushButtonAddAddressBook)
QtCore.QObject.connect(self.ui.actionSettings, QtCore.SIGNAL("triggered()"), self.click_actionSettings) QtCore.QObject.connect(self.ui.pushButtonAddSubscription, QtCore.SIGNAL(
QtCore.QObject.connect(self.ui.actionAbout, QtCore.SIGNAL("triggered()"), self.click_actionAbout) "clicked()"), self.click_pushButtonAddSubscription)
QtCore.QObject.connect(self.ui.actionHelp, QtCore.SIGNAL("triggered()"), self.click_actionHelp) QtCore.QObject.connect(self.ui.pushButtonAddBlacklist, QtCore.SIGNAL(
"clicked()"), self.click_pushButtonAddBlacklist)
QtCore.QObject.connect(self.ui.pushButtonSend, QtCore.SIGNAL(
"clicked()"), self.click_pushButtonSend)
QtCore.QObject.connect(self.ui.pushButtonLoadFromAddressBook, QtCore.SIGNAL(
"clicked()"), self.click_pushButtonLoadFromAddressBook)
QtCore.QObject.connect(self.ui.radioButtonBlacklist, QtCore.SIGNAL(
"clicked()"), self.click_radioButtonBlacklist)
QtCore.QObject.connect(self.ui.radioButtonWhitelist, QtCore.SIGNAL(
"clicked()"), self.click_radioButtonWhitelist)
QtCore.QObject.connect(self.ui.pushButtonStatusIcon, QtCore.SIGNAL(
"clicked()"), self.click_pushButtonStatusIcon)
QtCore.QObject.connect(self.ui.actionSettings, QtCore.SIGNAL(
"triggered()"), self.click_actionSettings)
QtCore.QObject.connect(self.ui.actionAbout, QtCore.SIGNAL(
"triggered()"), self.click_actionAbout)
QtCore.QObject.connect(self.ui.actionHelp, QtCore.SIGNAL(
"triggered()"), self.click_actionHelp)
#Popup menu for the Inbox tab # Popup menu for the Inbox tab
self.ui.inboxContextMenuToolbar = QtGui.QToolBar() self.ui.inboxContextMenuToolbar = QtGui.QToolBar()
# Actions # Actions
self.actionReply = self.ui.inboxContextMenuToolbar.addAction("Reply", self.on_action_InboxReply) self.actionReply = self.ui.inboxContextMenuToolbar.addAction(
self.actionAddSenderToAddressBook = self.ui.inboxContextMenuToolbar.addAction(QtGui.QApplication.translate("MainWindow", "Add sender to your Address Book"), self.on_action_InboxAddSenderToAddressBook) "Reply", self.on_action_InboxReply)
self.actionTrashInboxMessage = self.ui.inboxContextMenuToolbar.addAction(QtGui.QApplication.translate("MainWindow", "Move to Trash"), self.on_action_InboxTrash) self.actionAddSenderToAddressBook = self.ui.inboxContextMenuToolbar.addAction(QtGui.QApplication.translate(
self.actionForceHtml = self.ui.inboxContextMenuToolbar.addAction(QtGui.QApplication.translate("MainWindow", "View HTML code as formatted text"), self.on_action_InboxMessageForceHtml) "MainWindow", "Add sender to your Address Book"), self.on_action_InboxAddSenderToAddressBook)
self.ui.tableWidgetInbox.setContextMenuPolicy( QtCore.Qt.CustomContextMenu ) self.actionTrashInboxMessage = self.ui.inboxContextMenuToolbar.addAction(
self.connect(self.ui.tableWidgetInbox, QtCore.SIGNAL('customContextMenuRequested(const QPoint&)'), self.on_context_menuInbox) QtGui.QApplication.translate("MainWindow", "Move to Trash"), self.on_action_InboxTrash)
self.popMenuInbox = QtGui.QMenu( self ) self.actionForceHtml = self.ui.inboxContextMenuToolbar.addAction(QtGui.QApplication.translate(
self.popMenuInbox.addAction( self.actionForceHtml ) "MainWindow", "View HTML code as formatted text"), self.on_action_InboxMessageForceHtml)
self.ui.tableWidgetInbox.setContextMenuPolicy(
QtCore.Qt.CustomContextMenu)
self.connect(self.ui.tableWidgetInbox, QtCore.SIGNAL(
'customContextMenuRequested(const QPoint&)'), self.on_context_menuInbox)
self.popMenuInbox = QtGui.QMenu(self)
self.popMenuInbox.addAction(self.actionForceHtml)
self.popMenuInbox.addSeparator() self.popMenuInbox.addSeparator()
self.popMenuInbox.addAction( self.actionReply ) self.popMenuInbox.addAction(self.actionReply)
self.popMenuInbox.addAction( self.actionAddSenderToAddressBook ) self.popMenuInbox.addAction(self.actionAddSenderToAddressBook)
self.popMenuInbox.addSeparator() self.popMenuInbox.addSeparator()
self.popMenuInbox.addAction( self.actionTrashInboxMessage ) self.popMenuInbox.addAction(self.actionTrashInboxMessage)
# Popup menu for the Your Identities tab
#Popup menu for the Your Identities tab
self.ui.addressContextMenuToolbar = QtGui.QToolBar() self.ui.addressContextMenuToolbar = QtGui.QToolBar()
# Actions # Actions
self.actionNew = self.ui.addressContextMenuToolbar.addAction(QtGui.QApplication.translate("MainWindow", "New"), self.on_action_YourIdentitiesNew) self.actionNew = self.ui.addressContextMenuToolbar.addAction(QtGui.QApplication.translate(
self.actionEnable = self.ui.addressContextMenuToolbar.addAction(QtGui.QApplication.translate("MainWindow", "Enable"), self.on_action_YourIdentitiesEnable) "MainWindow", "New"), self.on_action_YourIdentitiesNew)
self.actionDisable = self.ui.addressContextMenuToolbar.addAction(QtGui.QApplication.translate("MainWindow", "Disable"), self.on_action_YourIdentitiesDisable) self.actionEnable = self.ui.addressContextMenuToolbar.addAction(QtGui.QApplication.translate(
self.actionClipboard = self.ui.addressContextMenuToolbar.addAction(QtGui.QApplication.translate("MainWindow", "Copy address to clipboard"), self.on_action_YourIdentitiesClipboard) "MainWindow", "Enable"), self.on_action_YourIdentitiesEnable)
self.actionSpecialAddressBehavior = self.ui.addressContextMenuToolbar.addAction(QtGui.QApplication.translate("MainWindow", "Special address behavior..."), self.on_action_SpecialAddressBehaviorDialog) self.actionDisable = self.ui.addressContextMenuToolbar.addAction(QtGui.QApplication.translate(
self.ui.tableWidgetYourIdentities.setContextMenuPolicy( QtCore.Qt.CustomContextMenu ) "MainWindow", "Disable"), self.on_action_YourIdentitiesDisable)
self.connect(self.ui.tableWidgetYourIdentities, QtCore.SIGNAL('customContextMenuRequested(const QPoint&)'), self.on_context_menuYourIdentities) self.actionClipboard = self.ui.addressContextMenuToolbar.addAction(QtGui.QApplication.translate(
self.popMenu = QtGui.QMenu( self ) "MainWindow", "Copy address to clipboard"), self.on_action_YourIdentitiesClipboard)
self.popMenu.addAction( self.actionNew ) self.actionSpecialAddressBehavior = self.ui.addressContextMenuToolbar.addAction(QtGui.QApplication.translate(
"MainWindow", "Special address behavior..."), self.on_action_SpecialAddressBehaviorDialog)
self.ui.tableWidgetYourIdentities.setContextMenuPolicy(
QtCore.Qt.CustomContextMenu)
self.connect(self.ui.tableWidgetYourIdentities, QtCore.SIGNAL(
'customContextMenuRequested(const QPoint&)'), self.on_context_menuYourIdentities)
self.popMenu = QtGui.QMenu(self)
self.popMenu.addAction(self.actionNew)
self.popMenu.addSeparator() self.popMenu.addSeparator()
self.popMenu.addAction( self.actionClipboard ) self.popMenu.addAction(self.actionClipboard)
self.popMenu.addSeparator() self.popMenu.addSeparator()
self.popMenu.addAction( self.actionEnable ) self.popMenu.addAction(self.actionEnable)
self.popMenu.addAction( self.actionDisable ) self.popMenu.addAction(self.actionDisable)
self.popMenu.addAction( self.actionSpecialAddressBehavior ) self.popMenu.addAction(self.actionSpecialAddressBehavior)
#Popup menu for the Address Book page # Popup menu for the Address Book page
self.ui.addressBookContextMenuToolbar = QtGui.QToolBar() self.ui.addressBookContextMenuToolbar = QtGui.QToolBar()
# Actions # Actions
self.actionAddressBookSend = self.ui.addressBookContextMenuToolbar.addAction(QtGui.QApplication.translate("MainWindow", "Send message to this address"), self.on_action_AddressBookSend) self.actionAddressBookSend = self.ui.addressBookContextMenuToolbar.addAction(QtGui.QApplication.translate(
self.actionAddressBookClipboard = self.ui.addressBookContextMenuToolbar.addAction(QtGui.QApplication.translate("MainWindow", "Copy address to clipboard"), self.on_action_AddressBookClipboard) "MainWindow", "Send message to this address"), self.on_action_AddressBookSend)
self.actionAddressBookNew = self.ui.addressBookContextMenuToolbar.addAction(QtGui.QApplication.translate("MainWindow", "Add New Address"), self.on_action_AddressBookNew) self.actionAddressBookClipboard = self.ui.addressBookContextMenuToolbar.addAction(QtGui.QApplication.translate(
self.actionAddressBookDelete = self.ui.addressBookContextMenuToolbar.addAction(QtGui.QApplication.translate("MainWindow", "Delete"), self.on_action_AddressBookDelete) "MainWindow", "Copy address to clipboard"), self.on_action_AddressBookClipboard)
self.ui.tableWidgetAddressBook.setContextMenuPolicy( QtCore.Qt.CustomContextMenu ) self.actionAddressBookNew = self.ui.addressBookContextMenuToolbar.addAction(QtGui.QApplication.translate(
self.connect(self.ui.tableWidgetAddressBook, QtCore.SIGNAL('customContextMenuRequested(const QPoint&)'), self.on_context_menuAddressBook) "MainWindow", "Add New Address"), self.on_action_AddressBookNew)
self.popMenuAddressBook = QtGui.QMenu( self ) self.actionAddressBookDelete = self.ui.addressBookContextMenuToolbar.addAction(QtGui.QApplication.translate(
self.popMenuAddressBook.addAction( self.actionAddressBookSend ) "MainWindow", "Delete"), self.on_action_AddressBookDelete)
self.popMenuAddressBook.addAction( self.actionAddressBookClipboard ) self.ui.tableWidgetAddressBook.setContextMenuPolicy(
QtCore.Qt.CustomContextMenu)
self.connect(self.ui.tableWidgetAddressBook, QtCore.SIGNAL(
'customContextMenuRequested(const QPoint&)'), self.on_context_menuAddressBook)
self.popMenuAddressBook = QtGui.QMenu(self)
self.popMenuAddressBook.addAction(self.actionAddressBookSend)
self.popMenuAddressBook.addAction(self.actionAddressBookClipboard)
self.popMenuAddressBook.addSeparator() self.popMenuAddressBook.addSeparator()
self.popMenuAddressBook.addAction( self.actionAddressBookNew ) self.popMenuAddressBook.addAction(self.actionAddressBookNew)
self.popMenuAddressBook.addAction( self.actionAddressBookDelete ) self.popMenuAddressBook.addAction(self.actionAddressBookDelete)
#Popup menu for the Subscriptions page # Popup menu for the Subscriptions page
self.ui.subscriptionsContextMenuToolbar = QtGui.QToolBar() self.ui.subscriptionsContextMenuToolbar = QtGui.QToolBar()
# Actions # Actions
self.actionsubscriptionsNew = self.ui.subscriptionsContextMenuToolbar.addAction(QtGui.QApplication.translate("MainWindow", "New"), self.on_action_SubscriptionsNew) self.actionsubscriptionsNew = self.ui.subscriptionsContextMenuToolbar.addAction(
self.actionsubscriptionsDelete = self.ui.subscriptionsContextMenuToolbar.addAction(QtGui.QApplication.translate("MainWindow", "Delete"), self.on_action_SubscriptionsDelete) QtGui.QApplication.translate("MainWindow", "New"), self.on_action_SubscriptionsNew)
self.actionsubscriptionsClipboard = self.ui.subscriptionsContextMenuToolbar.addAction(QtGui.QApplication.translate("MainWindow", "Copy address to clipboard"), self.on_action_SubscriptionsClipboard) self.actionsubscriptionsDelete = self.ui.subscriptionsContextMenuToolbar.addAction(
self.actionsubscriptionsEnable = self.ui.subscriptionsContextMenuToolbar.addAction(QtGui.QApplication.translate("MainWindow", "Enable"), self.on_action_SubscriptionsEnable) QtGui.QApplication.translate("MainWindow", "Delete"), self.on_action_SubscriptionsDelete)
self.actionsubscriptionsDisable = self.ui.subscriptionsContextMenuToolbar.addAction(QtGui.QApplication.translate("MainWindow", "Disable"), self.on_action_SubscriptionsDisable) self.actionsubscriptionsClipboard = self.ui.subscriptionsContextMenuToolbar.addAction(
self.ui.tableWidgetSubscriptions.setContextMenuPolicy( QtCore.Qt.CustomContextMenu ) QtGui.QApplication.translate("MainWindow", "Copy address to clipboard"), self.on_action_SubscriptionsClipboard)
self.connect(self.ui.tableWidgetSubscriptions, QtCore.SIGNAL('customContextMenuRequested(const QPoint&)'), self.on_context_menuSubscriptions) self.actionsubscriptionsEnable = self.ui.subscriptionsContextMenuToolbar.addAction(
self.popMenuSubscriptions = QtGui.QMenu( self ) QtGui.QApplication.translate("MainWindow", "Enable"), self.on_action_SubscriptionsEnable)
self.popMenuSubscriptions.addAction( self.actionsubscriptionsNew ) self.actionsubscriptionsDisable = self.ui.subscriptionsContextMenuToolbar.addAction(
self.popMenuSubscriptions.addAction( self.actionsubscriptionsDelete ) QtGui.QApplication.translate("MainWindow", "Disable"), self.on_action_SubscriptionsDisable)
self.ui.tableWidgetSubscriptions.setContextMenuPolicy(
QtCore.Qt.CustomContextMenu)
self.connect(self.ui.tableWidgetSubscriptions, QtCore.SIGNAL(
'customContextMenuRequested(const QPoint&)'), self.on_context_menuSubscriptions)
self.popMenuSubscriptions = QtGui.QMenu(self)
self.popMenuSubscriptions.addAction(self.actionsubscriptionsNew)
self.popMenuSubscriptions.addAction(self.actionsubscriptionsDelete)
self.popMenuSubscriptions.addSeparator() self.popMenuSubscriptions.addSeparator()
self.popMenuSubscriptions.addAction( self.actionsubscriptionsEnable ) self.popMenuSubscriptions.addAction(self.actionsubscriptionsEnable)
self.popMenuSubscriptions.addAction( self.actionsubscriptionsDisable ) self.popMenuSubscriptions.addAction(self.actionsubscriptionsDisable)
self.popMenuSubscriptions.addSeparator() self.popMenuSubscriptions.addSeparator()
self.popMenuSubscriptions.addAction( self.actionsubscriptionsClipboard ) self.popMenuSubscriptions.addAction(self.actionsubscriptionsClipboard)
#Popup menu for the Sent page # Popup menu for the Sent page
self.ui.sentContextMenuToolbar = QtGui.QToolBar() self.ui.sentContextMenuToolbar = QtGui.QToolBar()
# Actions # Actions
self.actionTrashSentMessage = self.ui.sentContextMenuToolbar.addAction(QtGui.QApplication.translate("MainWindow", "Move to Trash"), self.on_action_SentTrash) self.actionTrashSentMessage = self.ui.sentContextMenuToolbar.addAction(QtGui.QApplication.translate(
self.actionSentClipboard = self.ui.sentContextMenuToolbar.addAction(QtGui.QApplication.translate("MainWindow", "Copy destination address to clipboard"), self.on_action_SentClipboard) "MainWindow", "Move to Trash"), self.on_action_SentTrash)
self.actionForceSend = self.ui.sentContextMenuToolbar.addAction(QtGui.QApplication.translate("MainWindow", "Force send"), self.on_action_ForceSend) self.actionSentClipboard = self.ui.sentContextMenuToolbar.addAction(QtGui.QApplication.translate(
self.ui.tableWidgetSent.setContextMenuPolicy( QtCore.Qt.CustomContextMenu ) "MainWindow", "Copy destination address to clipboard"), self.on_action_SentClipboard)
self.connect(self.ui.tableWidgetSent, QtCore.SIGNAL('customContextMenuRequested(const QPoint&)'), self.on_context_menuSent) self.actionForceSend = self.ui.sentContextMenuToolbar.addAction(QtGui.QApplication.translate(
#self.popMenuSent = QtGui.QMenu( self ) "MainWindow", "Force send"), self.on_action_ForceSend)
#self.popMenuSent.addAction( self.actionSentClipboard ) self.ui.tableWidgetSent.setContextMenuPolicy(
#self.popMenuSent.addAction( self.actionTrashSentMessage ) QtCore.Qt.CustomContextMenu)
self.connect(self.ui.tableWidgetSent, QtCore.SIGNAL(
'customContextMenuRequested(const QPoint&)'), self.on_context_menuSent)
# self.popMenuSent = QtGui.QMenu( self )
# self.popMenuSent.addAction( self.actionSentClipboard )
# self.popMenuSent.addAction( self.actionTrashSentMessage )
# Popup menu for the Blacklist page
#Popup menu for the Blacklist page
self.ui.blacklistContextMenuToolbar = QtGui.QToolBar() self.ui.blacklistContextMenuToolbar = QtGui.QToolBar()
# Actions # Actions
self.actionBlacklistNew = self.ui.blacklistContextMenuToolbar.addAction(QtGui.QApplication.translate("MainWindow", "Add new entry"), self.on_action_BlacklistNew) self.actionBlacklistNew = self.ui.blacklistContextMenuToolbar.addAction(QtGui.QApplication.translate(
self.actionBlacklistDelete = self.ui.blacklistContextMenuToolbar.addAction(QtGui.QApplication.translate("MainWindow", "Delete"), self.on_action_BlacklistDelete) "MainWindow", "Add new entry"), self.on_action_BlacklistNew)
self.actionBlacklistClipboard = self.ui.blacklistContextMenuToolbar.addAction(QtGui.QApplication.translate("MainWindow", "Copy address to clipboard"), self.on_action_BlacklistClipboard) self.actionBlacklistDelete = self.ui.blacklistContextMenuToolbar.addAction(QtGui.QApplication.translate(
self.actionBlacklistEnable = self.ui.blacklistContextMenuToolbar.addAction(QtGui.QApplication.translate("MainWindow", "Enable"), self.on_action_BlacklistEnable) "MainWindow", "Delete"), self.on_action_BlacklistDelete)
self.actionBlacklistDisable = self.ui.blacklistContextMenuToolbar.addAction(QtGui.QApplication.translate("MainWindow", "Disable"), self.on_action_BlacklistDisable) self.actionBlacklistClipboard = self.ui.blacklistContextMenuToolbar.addAction(QtGui.QApplication.translate(
self.ui.tableWidgetBlacklist.setContextMenuPolicy( QtCore.Qt.CustomContextMenu ) "MainWindow", "Copy address to clipboard"), self.on_action_BlacklistClipboard)
self.connect(self.ui.tableWidgetBlacklist, QtCore.SIGNAL('customContextMenuRequested(const QPoint&)'), self.on_context_menuBlacklist) self.actionBlacklistEnable = self.ui.blacklistContextMenuToolbar.addAction(QtGui.QApplication.translate(
self.popMenuBlacklist = QtGui.QMenu( self ) "MainWindow", "Enable"), self.on_action_BlacklistEnable)
#self.popMenuBlacklist.addAction( self.actionBlacklistNew ) self.actionBlacklistDisable = self.ui.blacklistContextMenuToolbar.addAction(QtGui.QApplication.translate(
self.popMenuBlacklist.addAction( self.actionBlacklistDelete ) "MainWindow", "Disable"), self.on_action_BlacklistDisable)
self.ui.tableWidgetBlacklist.setContextMenuPolicy(
QtCore.Qt.CustomContextMenu)
self.connect(self.ui.tableWidgetBlacklist, QtCore.SIGNAL(
'customContextMenuRequested(const QPoint&)'), self.on_context_menuBlacklist)
self.popMenuBlacklist = QtGui.QMenu(self)
# self.popMenuBlacklist.addAction( self.actionBlacklistNew )
self.popMenuBlacklist.addAction(self.actionBlacklistDelete)
self.popMenuBlacklist.addSeparator() self.popMenuBlacklist.addSeparator()
self.popMenuBlacklist.addAction( self.actionBlacklistClipboard ) self.popMenuBlacklist.addAction(self.actionBlacklistClipboard)
self.popMenuBlacklist.addSeparator() self.popMenuBlacklist.addSeparator()
self.popMenuBlacklist.addAction( self.actionBlacklistEnable ) self.popMenuBlacklist.addAction(self.actionBlacklistEnable)
self.popMenuBlacklist.addAction( self.actionBlacklistDisable ) self.popMenuBlacklist.addAction(self.actionBlacklistDisable)
#Initialize the user's list of addresses on the 'Your Identities' tab. # Initialize the user's list of addresses on the 'Your Identities' tab.
configSections = shared.config.sections() configSections = shared.config.sections()
for addressInKeysFile in configSections: for addressInKeysFile in configSections:
if addressInKeysFile <> 'bitmessagesettings': if addressInKeysFile != 'bitmessagesettings':
isEnabled = shared.config.getboolean(addressInKeysFile, 'enabled') isEnabled = shared.config.getboolean(
newItem = QtGui.QTableWidgetItem(unicode(shared.config.get(addressInKeysFile, 'label'),'utf-8)')) addressInKeysFile, 'enabled')
newItem = QtGui.QTableWidgetItem(unicode(
shared.config.get(addressInKeysFile, 'label'), 'utf-8)'))
if not isEnabled: if not isEnabled:
newItem.setTextColor(QtGui.QColor(128,128,128)) newItem.setTextColor(QtGui.QColor(128, 128, 128))
self.ui.tableWidgetYourIdentities.insertRow(0) self.ui.tableWidgetYourIdentities.insertRow(0)
self.ui.tableWidgetYourIdentities.setItem(0, 0, newItem) self.ui.tableWidgetYourIdentities.setItem(0, 0, newItem)
newItem = QtGui.QTableWidgetItem(addressInKeysFile) newItem = QtGui.QTableWidgetItem(addressInKeysFile)
newItem.setFlags( QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled ) newItem.setFlags(
QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled)
if not isEnabled: if not isEnabled:
newItem.setTextColor(QtGui.QColor(128,128,128)) newItem.setTextColor(QtGui.QColor(128, 128, 128))
if shared.safeConfigGetBoolean(addressInKeysFile,'mailinglist'): if shared.safeConfigGetBoolean(addressInKeysFile, 'mailinglist'):
newItem.setTextColor(QtGui.QColor(137,04,177))#magenta newItem.setTextColor(QtGui.QColor(137, 04, 177)) # magenta
self.ui.tableWidgetYourIdentities.setItem(0, 1, newItem) self.ui.tableWidgetYourIdentities.setItem(0, 1, newItem)
newItem = QtGui.QTableWidgetItem(str(addressStream(addressInKeysFile))) newItem = QtGui.QTableWidgetItem(str(
newItem.setFlags( QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled ) addressStream(addressInKeysFile)))
newItem.setFlags(
QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled)
if not isEnabled: if not isEnabled:
newItem.setTextColor(QtGui.QColor(128,128,128)) newItem.setTextColor(QtGui.QColor(128, 128, 128))
self.ui.tableWidgetYourIdentities.setItem(0, 2, newItem) self.ui.tableWidgetYourIdentities.setItem(0, 2, newItem)
if isEnabled: if isEnabled:
status,addressVersionNumber,streamNumber,hash = decodeAddress(addressInKeysFile) status, addressVersionNumber, streamNumber, hash = decodeAddress(
addressInKeysFile)
#Load inbox from messages database file # Load inbox from messages database file
font = QFont() font = QFont()
font.setBold(True) font.setBold(True)
shared.sqlLock.acquire() shared.sqlLock.acquire()
shared.sqlSubmitQueue.put('''SELECT msgid, toaddress, fromaddress, subject, received, message, read FROM inbox where folder='inbox' ORDER BY received''') shared.sqlSubmitQueue.put(
'''SELECT msgid, toaddress, fromaddress, subject, received, message, read FROM inbox where folder='inbox' ORDER BY received''')
shared.sqlSubmitQueue.put('') shared.sqlSubmitQueue.put('')
queryreturn = shared.sqlReturnQueue.get() queryreturn = shared.sqlReturnQueue.get()
shared.sqlLock.release() shared.sqlLock.release()
@ -251,70 +319,80 @@ class MyForm(QtGui.QMainWindow):
fromLabel = '' fromLabel = ''
t = (fromAddress,) t = (fromAddress,)
shared.sqlLock.acquire() shared.sqlLock.acquire()
shared.sqlSubmitQueue.put('''select label from addressbook where address=?''') shared.sqlSubmitQueue.put(
'''select label from addressbook where address=?''')
shared.sqlSubmitQueue.put(t) shared.sqlSubmitQueue.put(t)
queryreturn = shared.sqlReturnQueue.get() queryreturn = shared.sqlReturnQueue.get()
shared.sqlLock.release() shared.sqlLock.release()
if queryreturn <> []: if queryreturn != []:
for row in queryreturn: for row in queryreturn:
fromLabel, = row fromLabel, = row
if fromLabel == '': #If this address wasn't in our address book.. if fromLabel == '': # If this address wasn't in our address book...
t = (fromAddress,) t = (fromAddress,)
shared.sqlLock.acquire() shared.sqlLock.acquire()
shared.sqlSubmitQueue.put('''select label from subscriptions where address=?''') shared.sqlSubmitQueue.put(
'''select label from subscriptions where address=?''')
shared.sqlSubmitQueue.put(t) shared.sqlSubmitQueue.put(t)
queryreturn = shared.sqlReturnQueue.get() queryreturn = shared.sqlReturnQueue.get()
shared.sqlLock.release() shared.sqlLock.release()
if queryreturn <> []: if queryreturn != []:
for row in queryreturn: for row in queryreturn:
fromLabel, = row fromLabel, = row
self.ui.tableWidgetInbox.insertRow(0) self.ui.tableWidgetInbox.insertRow(0)
newItem = QtGui.QTableWidgetItem(unicode(toLabel,'utf-8')) newItem = QtGui.QTableWidgetItem(unicode(toLabel, 'utf-8'))
newItem.setToolTip(unicode(toLabel,'utf-8')) newItem.setToolTip(unicode(toLabel, 'utf-8'))
newItem.setFlags( QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled ) newItem.setFlags(
QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled)
if not read: if not read:
newItem.setFont(font) newItem.setFont(font)
newItem.setData(Qt.UserRole,str(toAddress)) newItem.setData(Qt.UserRole, str(toAddress))
if shared.safeConfigGetBoolean(toAddress,'mailinglist'): if shared.safeConfigGetBoolean(toAddress, 'mailinglist'):
newItem.setTextColor(QtGui.QColor(137,04,177)) newItem.setTextColor(QtGui.QColor(137, 04, 177))
self.ui.tableWidgetInbox.setItem(0,0,newItem) self.ui.tableWidgetInbox.setItem(0, 0, newItem)
if fromLabel == '': if fromLabel == '':
newItem = QtGui.QTableWidgetItem(unicode(fromAddress,'utf-8')) newItem = QtGui.QTableWidgetItem(
newItem.setToolTip(unicode(fromAddress,'utf-8')) unicode(fromAddress, 'utf-8'))
newItem.setToolTip(unicode(fromAddress, 'utf-8'))
else: else:
newItem = QtGui.QTableWidgetItem(unicode(fromLabel,'utf-8')) newItem = QtGui.QTableWidgetItem(unicode(fromLabel, 'utf-8'))
newItem.setToolTip(unicode(fromLabel,'utf-8')) newItem.setToolTip(unicode(fromLabel, 'utf-8'))
newItem.setFlags( QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled ) newItem.setFlags(
QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled)
if not read: if not read:
newItem.setFont(font) newItem.setFont(font)
newItem.setData(Qt.UserRole,str(fromAddress)) newItem.setData(Qt.UserRole, str(fromAddress))
self.ui.tableWidgetInbox.setItem(0,1,newItem) self.ui.tableWidgetInbox.setItem(0, 1, newItem)
newItem = QtGui.QTableWidgetItem(unicode(subject,'utf-8')) newItem = QtGui.QTableWidgetItem(unicode(subject, 'utf-8'))
newItem.setToolTip(unicode(subject,'utf-8')) newItem.setToolTip(unicode(subject, 'utf-8'))
newItem.setData(Qt.UserRole,unicode(message,'utf-8)')) newItem.setData(Qt.UserRole, unicode(message, 'utf-8)'))
newItem.setFlags( QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled ) newItem.setFlags(
QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled)
if not read: if not read:
newItem.setFont(font) newItem.setFont(font)
self.ui.tableWidgetInbox.setItem(0,2,newItem) self.ui.tableWidgetInbox.setItem(0, 2, newItem)
newItem = myTableWidgetItem(unicode(strftime(shared.config.get('bitmessagesettings', 'timeformat'),localtime(int(received))),'utf-8')) newItem = myTableWidgetItem(unicode(strftime(shared.config.get(
newItem.setToolTip(unicode(strftime(shared.config.get('bitmessagesettings', 'timeformat'),localtime(int(received))),'utf-8')) 'bitmessagesettings', 'timeformat'), localtime(int(received))), 'utf-8'))
newItem.setData(Qt.UserRole,QByteArray(msgid)) newItem.setToolTip(unicode(strftime(shared.config.get(
newItem.setData(33,int(received)) 'bitmessagesettings', 'timeformat'), localtime(int(received))), 'utf-8'))
newItem.setFlags( QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled ) newItem.setData(Qt.UserRole, QByteArray(msgid))
newItem.setData(33, int(received))
newItem.setFlags(
QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled)
if not read: if not read:
newItem.setFont(font) newItem.setFont(font)
self.ui.tableWidgetInbox.setItem(0,3,newItem) self.ui.tableWidgetInbox.setItem(0, 3, newItem)
self.ui.tableWidgetInbox.sortItems(3,Qt.DescendingOrder) self.ui.tableWidgetInbox.sortItems(3, Qt.DescendingOrder)
self.ui.tableWidgetInbox.keyPressEvent = self.tableWidgetInboxKeyPressEvent self.ui.tableWidgetInbox.keyPressEvent = self.tableWidgetInboxKeyPressEvent
#Load Sent items from database # Load Sent items from database
shared.sqlLock.acquire() shared.sqlLock.acquire()
shared.sqlSubmitQueue.put('''SELECT toaddress, fromaddress, subject, message, status, ackdata, lastactiontime FROM sent where folder = 'sent' ORDER BY lastactiontime''') shared.sqlSubmitQueue.put(
'''SELECT toaddress, fromaddress, subject, message, status, ackdata, lastactiontime FROM sent where folder = 'sent' ORDER BY lastactiontime''')
shared.sqlSubmitQueue.put('') shared.sqlSubmitQueue.put('')
queryreturn = shared.sqlReturnQueue.get() queryreturn = shared.sqlReturnQueue.get()
shared.sqlLock.release() shared.sqlLock.release()
@ -332,71 +410,88 @@ class MyForm(QtGui.QMainWindow):
toLabel = '' toLabel = ''
t = (toAddress,) t = (toAddress,)
shared.sqlLock.acquire() shared.sqlLock.acquire()
shared.sqlSubmitQueue.put('''select label from addressbook where address=?''') shared.sqlSubmitQueue.put(
'''select label from addressbook where address=?''')
shared.sqlSubmitQueue.put(t) shared.sqlSubmitQueue.put(t)
queryreturn = shared.sqlReturnQueue.get() queryreturn = shared.sqlReturnQueue.get()
shared.sqlLock.release() shared.sqlLock.release()
if queryreturn <> []: if queryreturn != []:
for row in queryreturn: for row in queryreturn:
toLabel, = row toLabel, = row
self.ui.tableWidgetSent.insertRow(0) self.ui.tableWidgetSent.insertRow(0)
if toLabel == '': if toLabel == '':
newItem = QtGui.QTableWidgetItem(unicode(toAddress,'utf-8')) newItem = QtGui.QTableWidgetItem(unicode(toAddress, 'utf-8'))
newItem.setToolTip(unicode(toAddress,'utf-8')) newItem.setToolTip(unicode(toAddress, 'utf-8'))
else: else:
newItem = QtGui.QTableWidgetItem(unicode(toLabel,'utf-8')) newItem = QtGui.QTableWidgetItem(unicode(toLabel, 'utf-8'))
newItem.setToolTip(unicode(toLabel,'utf-8')) newItem.setToolTip(unicode(toLabel, 'utf-8'))
newItem.setData(Qt.UserRole,str(toAddress)) newItem.setData(Qt.UserRole, str(toAddress))
newItem.setFlags( QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled ) newItem.setFlags(
self.ui.tableWidgetSent.setItem(0,0,newItem) QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled)
self.ui.tableWidgetSent.setItem(0, 0, newItem)
if fromLabel == '': if fromLabel == '':
newItem = QtGui.QTableWidgetItem(unicode(fromAddress,'utf-8')) newItem = QtGui.QTableWidgetItem(
newItem.setToolTip(unicode(fromAddress,'utf-8')) unicode(fromAddress, 'utf-8'))
newItem.setToolTip(unicode(fromAddress, 'utf-8'))
else: else:
newItem = QtGui.QTableWidgetItem(unicode(fromLabel,'utf-8')) newItem = QtGui.QTableWidgetItem(unicode(fromLabel, 'utf-8'))
newItem.setToolTip(unicode(fromLabel,'utf-8')) newItem.setToolTip(unicode(fromLabel, 'utf-8'))
newItem.setData(Qt.UserRole,str(fromAddress)) newItem.setData(Qt.UserRole, str(fromAddress))
newItem.setFlags( QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled ) newItem.setFlags(
self.ui.tableWidgetSent.setItem(0,1,newItem) QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled)
newItem = QtGui.QTableWidgetItem(unicode(subject,'utf-8')) self.ui.tableWidgetSent.setItem(0, 1, newItem)
newItem.setToolTip(unicode(subject,'utf-8')) newItem = QtGui.QTableWidgetItem(unicode(subject, 'utf-8'))
newItem.setData(Qt.UserRole,unicode(message,'utf-8)')) newItem.setToolTip(unicode(subject, 'utf-8'))
newItem.setFlags( QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled ) newItem.setData(Qt.UserRole, unicode(message, 'utf-8)'))
self.ui.tableWidgetSent.setItem(0,2,newItem) newItem.setFlags(
QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled)
self.ui.tableWidgetSent.setItem(0, 2, newItem)
if status == 'awaitingpubkey': if status == 'awaitingpubkey':
statusText = QtGui.QApplication.translate("MainWindow", "Waiting on their encryption key. Will request it again soon.") statusText = QtGui.QApplication.translate(
"MainWindow", "Waiting on their encryption key. Will request it again soon.")
elif status == 'doingpowforpubkey': elif status == 'doingpowforpubkey':
statusText = QtGui.QApplication.translate("MainWindow", "Encryption key request queued.") statusText = QtGui.QApplication.translate(
"MainWindow", "Encryption key request queued.")
elif status == 'msgqueued': elif status == 'msgqueued':
statusText = QtGui.QApplication.translate("MainWindow", "Queued.") statusText = QtGui.QApplication.translate(
"MainWindow", "Queued.")
elif status == 'msgsent': elif status == 'msgsent':
statusText = QtGui.QApplication.translate("MainWindow", "Message sent. Waiting on acknowledgement. Sent at %1").arg(unicode(strftime(shared.config.get('bitmessagesettings', 'timeformat'),localtime(lastactiontime)))) statusText = QtGui.QApplication.translate("MainWindow", "Message sent. Waiting on acknowledgement. Sent at %1").arg(
unicode(strftime(shared.config.get('bitmessagesettings', 'timeformat'), localtime(lastactiontime))))
elif status == 'doingmsgpow': elif status == 'doingmsgpow':
statusText = QtGui.QApplication.translate("MainWindow", "Need to do work to send message. Work is queued.") statusText = QtGui.QApplication.translate(
"MainWindow", "Need to do work to send message. Work is queued.")
elif status == 'ackreceived': elif status == 'ackreceived':
statusText = QtGui.QApplication.translate("MainWindow", "Acknowledgement of the message received %1").arg(unicode(strftime(shared.config.get('bitmessagesettings', 'timeformat'),localtime(int(lastactiontime))))) statusText = QtGui.QApplication.translate("MainWindow", "Acknowledgement of the message received %1").arg(
unicode(strftime(shared.config.get('bitmessagesettings', 'timeformat'), localtime(int(lastactiontime)))))
elif status == 'broadcastqueued': elif status == 'broadcastqueued':
statusText = QtGui.QApplication.translate("MainWindow", "Broadcast queued.") statusText = QtGui.QApplication.translate(
"MainWindow", "Broadcast queued.")
elif status == 'broadcastsent': elif status == 'broadcastsent':
statusText = QtGui.QApplication.translate("MainWindow", "Broadcast on %1").arg(unicode(strftime(shared.config.get('bitmessagesettings', 'timeformat'),localtime(int(lastactiontime))))) statusText = QtGui.QApplication.translate("MainWindow", "Broadcast on %1").arg(unicode(strftime(
shared.config.get('bitmessagesettings', 'timeformat'), localtime(int(lastactiontime)))))
elif status == 'toodifficult': elif status == 'toodifficult':
statusText = QtGui.QApplication.translate("MainWindow", "Problem: The work demanded by the recipient is more difficult than you are willing to do. %1").arg(unicode(strftime(shared.config.get('bitmessagesettings', 'timeformat'),localtime(int(lastactiontime))))) statusText = QtGui.QApplication.translate("MainWindow", "Problem: The work demanded by the recipient is more difficult than you are willing to do. %1").arg(
unicode(strftime(shared.config.get('bitmessagesettings', 'timeformat'), localtime(int(lastactiontime)))))
elif status == 'forcepow': elif status == 'forcepow':
statusText = QtGui.QApplication.translate("MainWindow", "Forced difficulty override. Send should start soon.") statusText = QtGui.QApplication.translate(
"MainWindow", "Forced difficulty override. Send should start soon.")
else: else:
statusText = QtGui.QApplication.translate("Unknown status: %1 %2").arg(status).arg(unicode(strftime(shared.config.get('bitmessagesettings', 'timeformat'),localtime(int(lastactiontime))))) statusText = QtGui.QApplication.translate("MainWindow", "Unknown status: %1 %2").arg(status).arg(unicode(
newItem = myTableWidgetItem(statusText) strftime(shared.config.get('bitmessagesettings', 'timeformat'), localtime(int(lastactiontime)))))
newItem = myTableWidgetItem(statusText)
newItem.setToolTip(statusText) newItem.setToolTip(statusText)
newItem.setData(Qt.UserRole,QByteArray(ackdata)) newItem.setData(Qt.UserRole, QByteArray(ackdata))
newItem.setData(33,int(lastactiontime)) newItem.setData(33, int(lastactiontime))
newItem.setFlags( QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled ) newItem.setFlags(
self.ui.tableWidgetSent.setItem(0,3,newItem) QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled)
self.ui.tableWidgetSent.sortItems(3,Qt.DescendingOrder) self.ui.tableWidgetSent.setItem(0, 3, newItem)
self.ui.tableWidgetSent.sortItems(3, Qt.DescendingOrder)
self.ui.tableWidgetSent.keyPressEvent = self.tableWidgetSentKeyPressEvent self.ui.tableWidgetSent.keyPressEvent = self.tableWidgetSentKeyPressEvent
#Initialize the address book # Initialize the address book
shared.sqlLock.acquire() shared.sqlLock.acquire()
shared.sqlSubmitQueue.put('SELECT * FROM addressbook') shared.sqlSubmitQueue.put('SELECT * FROM addressbook')
shared.sqlSubmitQueue.put('') shared.sqlSubmitQueue.put('')
@ -405,77 +500,98 @@ class MyForm(QtGui.QMainWindow):
for row in queryreturn: for row in queryreturn:
label, address = row label, address = row
self.ui.tableWidgetAddressBook.insertRow(0) self.ui.tableWidgetAddressBook.insertRow(0)
newItem = QtGui.QTableWidgetItem(unicode(label,'utf-8')) newItem = QtGui.QTableWidgetItem(unicode(label, 'utf-8'))
self.ui.tableWidgetAddressBook.setItem(0,0,newItem) self.ui.tableWidgetAddressBook.setItem(0, 0, newItem)
newItem = QtGui.QTableWidgetItem(address) newItem = QtGui.QTableWidgetItem(address)
newItem.setFlags( QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled ) newItem.setFlags(
self.ui.tableWidgetAddressBook.setItem(0,1,newItem) QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled)
self.ui.tableWidgetAddressBook.setItem(0, 1, newItem)
#Initialize the Subscriptions # Initialize the Subscriptions
self.rerenderSubscriptions() self.rerenderSubscriptions()
#Initialize the Blacklist or Whitelist # Initialize the Blacklist or Whitelist
if shared.config.get('bitmessagesettings', 'blackwhitelist') == 'black': if shared.config.get('bitmessagesettings', 'blackwhitelist') == 'black':
self.loadBlackWhiteList() self.loadBlackWhiteList()
else: else:
self.ui.tabWidget.setTabText(6,'Whitelist') self.ui.tabWidget.setTabText(6, 'Whitelist')
self.ui.radioButtonWhitelist.click() self.ui.radioButtonWhitelist.click()
self.loadBlackWhiteList() self.loadBlackWhiteList()
QtCore.QObject.connect(self.ui.tableWidgetYourIdentities, QtCore.SIGNAL(
"itemChanged(QTableWidgetItem *)"), self.tableWidgetYourIdentitiesItemChanged)
QtCore.QObject.connect(self.ui.tableWidgetAddressBook, QtCore.SIGNAL(
"itemChanged(QTableWidgetItem *)"), self.tableWidgetAddressBookItemChanged)
QtCore.QObject.connect(self.ui.tableWidgetSubscriptions, QtCore.SIGNAL(
"itemChanged(QTableWidgetItem *)"), self.tableWidgetSubscriptionsItemChanged)
QtCore.QObject.connect(self.ui.tableWidgetInbox, QtCore.SIGNAL(
"itemSelectionChanged ()"), self.tableWidgetInboxItemClicked)
QtCore.QObject.connect(self.ui.tableWidgetSent, QtCore.SIGNAL(
"itemSelectionChanged ()"), self.tableWidgetSentItemClicked)
QtCore.QObject.connect(self.ui.tableWidgetYourIdentities, QtCore.SIGNAL("itemChanged(QTableWidgetItem *)"), self.tableWidgetYourIdentitiesItemChanged) # Put the colored icon on the status bar
QtCore.QObject.connect(self.ui.tableWidgetAddressBook, QtCore.SIGNAL("itemChanged(QTableWidgetItem *)"), self.tableWidgetAddressBookItemChanged) # self.ui.pushButtonStatusIcon.setIcon(QIcon(":/newPrefix/images/yellowicon.png"))
QtCore.QObject.connect(self.ui.tableWidgetSubscriptions, QtCore.SIGNAL("itemChanged(QTableWidgetItem *)"), self.tableWidgetSubscriptionsItemChanged)
QtCore.QObject.connect(self.ui.tableWidgetInbox, QtCore.SIGNAL("itemSelectionChanged ()"), self.tableWidgetInboxItemClicked)
QtCore.QObject.connect(self.ui.tableWidgetSent, QtCore.SIGNAL("itemSelectionChanged ()"), self.tableWidgetSentItemClicked)
#Put the colored icon on the status bar
#self.ui.pushButtonStatusIcon.setIcon(QIcon(":/newPrefix/images/yellowicon.png"))
self.statusbar = self.statusBar() self.statusbar = self.statusBar()
self.statusbar.insertPermanentWidget(0,self.ui.pushButtonStatusIcon) self.statusbar.insertPermanentWidget(0, self.ui.pushButtonStatusIcon)
self.ui.labelStartupTime.setText(QtGui.QApplication.translate("MainWindow", "Since startup on %1").arg(unicode(strftime(shared.config.get('bitmessagesettings', 'timeformat'),localtime(int(time.time())))))) self.ui.labelStartupTime.setText(QtGui.QApplication.translate("MainWindow", "Since startup on %1").arg(
unicode(strftime(shared.config.get('bitmessagesettings', 'timeformat'), localtime(int(time.time()))))))
self.numberOfMessagesProcessed = 0 self.numberOfMessagesProcessed = 0
self.numberOfBroadcastsProcessed = 0 self.numberOfBroadcastsProcessed = 0
self.numberOfPubkeysProcessed = 0 self.numberOfPubkeysProcessed = 0
self.UISignalThread = UISignaler() self.UISignalThread = UISignaler()
QtCore.QObject.connect(self.UISignalThread, QtCore.SIGNAL("writeNewAddressToTable(PyQt_PyObject,PyQt_PyObject,PyQt_PyObject)"), self.writeNewAddressToTable) QtCore.QObject.connect(self.UISignalThread, QtCore.SIGNAL(
QtCore.QObject.connect(self.UISignalThread, QtCore.SIGNAL("updateStatusBar(PyQt_PyObject)"), self.updateStatusBar) "writeNewAddressToTable(PyQt_PyObject,PyQt_PyObject,PyQt_PyObject)"), self.writeNewAddressToTable)
QtCore.QObject.connect(self.UISignalThread, QtCore.SIGNAL("updateSentItemStatusByHash(PyQt_PyObject,PyQt_PyObject)"), self.updateSentItemStatusByHash) QtCore.QObject.connect(self.UISignalThread, QtCore.SIGNAL(
QtCore.QObject.connect(self.UISignalThread, QtCore.SIGNAL("updateSentItemStatusByAckdata(PyQt_PyObject,PyQt_PyObject)"), self.updateSentItemStatusByAckdata) "updateStatusBar(PyQt_PyObject)"), self.updateStatusBar)
QtCore.QObject.connect(self.UISignalThread, QtCore.SIGNAL("displayNewInboxMessage(PyQt_PyObject,PyQt_PyObject,PyQt_PyObject,PyQt_PyObject,PyQt_PyObject)"), self.displayNewInboxMessage) QtCore.QObject.connect(self.UISignalThread, QtCore.SIGNAL(
QtCore.QObject.connect(self.UISignalThread, QtCore.SIGNAL("displayNewSentMessage(PyQt_PyObject,PyQt_PyObject,PyQt_PyObject,PyQt_PyObject,PyQt_PyObject,PyQt_PyObject)"), self.displayNewSentMessage) "updateSentItemStatusByHash(PyQt_PyObject,PyQt_PyObject)"), self.updateSentItemStatusByHash)
QtCore.QObject.connect(self.UISignalThread, QtCore.SIGNAL("updateNetworkStatusTab()"), self.updateNetworkStatusTab) QtCore.QObject.connect(self.UISignalThread, QtCore.SIGNAL(
QtCore.QObject.connect(self.UISignalThread, QtCore.SIGNAL("incrementNumberOfMessagesProcessed()"), self.incrementNumberOfMessagesProcessed) "updateSentItemStatusByAckdata(PyQt_PyObject,PyQt_PyObject)"), self.updateSentItemStatusByAckdata)
QtCore.QObject.connect(self.UISignalThread, QtCore.SIGNAL("incrementNumberOfPubkeysProcessed()"), self.incrementNumberOfPubkeysProcessed) QtCore.QObject.connect(self.UISignalThread, QtCore.SIGNAL(
QtCore.QObject.connect(self.UISignalThread, QtCore.SIGNAL("incrementNumberOfBroadcastsProcessed()"), self.incrementNumberOfBroadcastsProcessed) "displayNewInboxMessage(PyQt_PyObject,PyQt_PyObject,PyQt_PyObject,PyQt_PyObject,PyQt_PyObject)"), self.displayNewInboxMessage)
QtCore.QObject.connect(self.UISignalThread, QtCore.SIGNAL("setStatusIcon(PyQt_PyObject)"), self.setStatusIcon) QtCore.QObject.connect(self.UISignalThread, QtCore.SIGNAL(
QtCore.QObject.connect(self.UISignalThread, QtCore.SIGNAL("rerenderInboxFromLabels()"), self.rerenderInboxFromLabels) "displayNewSentMessage(PyQt_PyObject,PyQt_PyObject,PyQt_PyObject,PyQt_PyObject,PyQt_PyObject,PyQt_PyObject)"), self.displayNewSentMessage)
QtCore.QObject.connect(self.UISignalThread, QtCore.SIGNAL("rerenderSubscriptions()"), self.rerenderSubscriptions) QtCore.QObject.connect(self.UISignalThread, QtCore.SIGNAL(
QtCore.QObject.connect(self.UISignalThread, QtCore.SIGNAL("removeInboxRowByMsgid(PyQt_PyObject)"), self.removeInboxRowByMsgid) "updateNetworkStatusTab()"), self.updateNetworkStatusTab)
QtCore.QObject.connect(self.UISignalThread, QtCore.SIGNAL(
"incrementNumberOfMessagesProcessed()"), self.incrementNumberOfMessagesProcessed)
QtCore.QObject.connect(self.UISignalThread, QtCore.SIGNAL(
"incrementNumberOfPubkeysProcessed()"), self.incrementNumberOfPubkeysProcessed)
QtCore.QObject.connect(self.UISignalThread, QtCore.SIGNAL(
"incrementNumberOfBroadcastsProcessed()"), self.incrementNumberOfBroadcastsProcessed)
QtCore.QObject.connect(self.UISignalThread, QtCore.SIGNAL(
"setStatusIcon(PyQt_PyObject)"), self.setStatusIcon)
QtCore.QObject.connect(self.UISignalThread, QtCore.SIGNAL(
"rerenderInboxFromLabels()"), self.rerenderInboxFromLabels)
QtCore.QObject.connect(self.UISignalThread, QtCore.SIGNAL(
"rerenderSubscriptions()"), self.rerenderSubscriptions)
QtCore.QObject.connect(self.UISignalThread, QtCore.SIGNAL(
"removeInboxRowByMsgid(PyQt_PyObject)"), self.removeInboxRowByMsgid)
self.UISignalThread.start() self.UISignalThread.start()
#Below this point, it would be good if all of the necessary global data structures were initialized. # Below this point, it would be good if all of the necessary global data
# structures were initialized.
self.rerenderComboBoxSendFrom() self.rerenderComboBoxSendFrom()
#Show or hide the application window after clicking an item within the tray icon or, on Windows, the try icon itself. # Show or hide the application window after clicking an item within the
# tray icon or, on Windows, the try icon itself.
def appIndicatorShowOrHideWindow(self): def appIndicatorShowOrHideWindow(self):
if not self.actionShow.isChecked(): if not self.actionShow.isChecked():
self.hide() self.hide()
else: else:
if sys.platform[0:3] == 'win': if sys.platform[0:3] == 'win':
self.setWindowFlags(Qt.Window) self.setWindowFlags(Qt.Window)
#else: # else:
#self.showMaximized() # self.showMaximized()
self.show() self.show()
self.setWindowState(self.windowState() & ~QtCore.Qt.WindowMinimized | QtCore.Qt.WindowActive) self.setWindowState(
self.windowState() & ~QtCore.Qt.WindowMinimized | QtCore.Qt.WindowActive)
self.activateWindow() self.activateWindow()
# pointer to the application # pointer to the application
#app = None # app = None
# The most recent message # The most recent message
newMessageItem = None newMessageItem = None
@ -484,7 +600,7 @@ class MyForm(QtGui.QMainWindow):
# show the application window # show the application window
def appIndicatorShow(self): def appIndicatorShow(self):
if self.actionShow == None: if self.actionShow is None:
return return
if not self.actionShow.isChecked(): if not self.actionShow.isChecked():
self.actionShow.setChecked(True) self.actionShow.setChecked(True)
@ -492,7 +608,7 @@ class MyForm(QtGui.QMainWindow):
# unchecks the show item on the application indicator # unchecks the show item on the application indicator
def appIndicatorHide(self): def appIndicatorHide(self):
if self.actionShow == None: if self.actionShow is None:
return return
if self.actionShow.isChecked(): if self.actionShow.isChecked():
self.actionShow.setChecked(False) self.actionShow.setChecked(False)
@ -531,11 +647,11 @@ class MyForm(QtGui.QMainWindow):
try: try:
self.ui.tableWidgetInbox.setCurrentItem(selectedItem) self.ui.tableWidgetInbox.setCurrentItem(selectedItem)
except Exception: except Exception:
self.ui.tableWidgetInbox.setCurrentCell(0,0) self.ui.tableWidgetInbox.setCurrentCell(0, 0)
self.tableWidgetInboxItemClicked() self.tableWidgetInboxItemClicked()
else: else:
# just select the first item # just select the first item
self.ui.tableWidgetInbox.setCurrentCell(0,0) self.ui.tableWidgetInbox.setCurrentCell(0, 0)
self.tableWidgetInboxItemClicked() self.tableWidgetInboxItemClicked()
# Show the program window and select send tab # Show the program window and select send tab
@ -554,51 +670,60 @@ class MyForm(QtGui.QMainWindow):
self.ui.tabWidget.setCurrentIndex(5) self.ui.tabWidget.setCurrentIndex(5)
# create application indicator # create application indicator
def appIndicatorInit(self,app): def appIndicatorInit(self, app):
self.tray = QSystemTrayIcon(QtGui.QIcon(":/newPrefix/images/can-icon-24px-red.png"), app) self.tray = QSystemTrayIcon(QtGui.QIcon(
":/newPrefix/images/can-icon-24px-red.png"), app)
if sys.platform[0:3] == 'win': if sys.platform[0:3] == 'win':
traySignal = "activated(QSystemTrayIcon::ActivationReason)" traySignal = "activated(QSystemTrayIcon::ActivationReason)"
QtCore.QObject.connect(self.tray, QtCore.SIGNAL(traySignal), self.__icon_activated) QtCore.QObject.connect(self.tray, QtCore.SIGNAL(
traySignal), self.__icon_activated)
m = QMenu() m = QMenu()
self.actionStatus = QtGui.QAction(QtGui.QApplication.translate("MainWindow", "Not Connected"),m,checkable=False) self.actionStatus = QtGui.QAction(QtGui.QApplication.translate(
"MainWindow", "Not Connected"), m, checkable=False)
m.addAction(self.actionStatus) m.addAction(self.actionStatus)
# separator # separator
actionSeparator = QtGui.QAction('',m,checkable=False) actionSeparator = QtGui.QAction('', m, checkable=False)
actionSeparator.setSeparator(True) actionSeparator.setSeparator(True)
m.addAction(actionSeparator) m.addAction(actionSeparator)
# show bitmessage # show bitmessage
self.actionShow = QtGui.QAction(QtGui.QApplication.translate("MainWindow", "Show Bitmessage"),m,checkable=True) self.actionShow = QtGui.QAction(QtGui.QApplication.translate(
self.actionShow.setChecked(not shared.config.getboolean('bitmessagesettings', 'startintray')) "MainWindow", "Show Bitmessage"), m, checkable=True)
self.actionShow.setChecked(not shared.config.getboolean(
'bitmessagesettings', 'startintray'))
self.actionShow.triggered.connect(self.appIndicatorShowOrHideWindow) self.actionShow.triggered.connect(self.appIndicatorShowOrHideWindow)
if not sys.platform[0:3] == 'win': if not sys.platform[0:3] == 'win':
m.addAction(self.actionShow) m.addAction(self.actionShow)
# Send # Send
actionSend = QtGui.QAction(QtGui.QApplication.translate("MainWindow", "Send"),m,checkable=False) actionSend = QtGui.QAction(QtGui.QApplication.translate(
"MainWindow", "Send"), m, checkable=False)
actionSend.triggered.connect(self.appIndicatorSend) actionSend.triggered.connect(self.appIndicatorSend)
m.addAction(actionSend) m.addAction(actionSend)
# Subscribe # Subscribe
actionSubscribe = QtGui.QAction(QtGui.QApplication.translate("MainWindow", "Subscribe"),m,checkable=False) actionSubscribe = QtGui.QAction(QtGui.QApplication.translate(
"MainWindow", "Subscribe"), m, checkable=False)
actionSubscribe.triggered.connect(self.appIndicatorSubscribe) actionSubscribe.triggered.connect(self.appIndicatorSubscribe)
m.addAction(actionSubscribe) m.addAction(actionSubscribe)
# Address book # Address book
actionAddressBook = QtGui.QAction(QtGui.QApplication.translate("MainWindow", "Address Book"),m,checkable=False) actionAddressBook = QtGui.QAction(QtGui.QApplication.translate(
"MainWindow", "Address Book"), m, checkable=False)
actionAddressBook.triggered.connect(self.appIndicatorAddressBook) actionAddressBook.triggered.connect(self.appIndicatorAddressBook)
m.addAction(actionAddressBook) m.addAction(actionAddressBook)
# separator # separator
actionSeparator = QtGui.QAction('',m,checkable=False) actionSeparator = QtGui.QAction('', m, checkable=False)
actionSeparator.setSeparator(True) actionSeparator.setSeparator(True)
m.addAction(actionSeparator) m.addAction(actionSeparator)
# Quit # Quit
m.addAction(QtGui.QApplication.translate("MainWindow", "Quit"), self.quit) m.addAction(QtGui.QApplication.translate(
"MainWindow", "Quit"), self.quit)
self.tray.setContextMenu(m) self.tray.setContextMenu(m)
self.tray.show() self.tray.show()
@ -631,7 +756,8 @@ class MyForm(QtGui.QMainWindow):
return return
shared.sqlLock.acquire() shared.sqlLock.acquire()
shared.sqlSubmitQueue.put('''SELECT toaddress, read FROM inbox WHERE msgid=?''') shared.sqlSubmitQueue.put(
'''SELECT toaddress, read FROM inbox WHERE msgid=?''')
shared.sqlSubmitQueue.put(inventoryHash) shared.sqlSubmitQueue.put(inventoryHash)
queryreturn = shared.sqlReturnQueue.get() queryreturn = shared.sqlReturnQueue.get()
shared.sqlLock.release() shared.sqlLock.release()
@ -651,7 +777,8 @@ class MyForm(QtGui.QMainWindow):
unreadSubscriptions = 0 unreadSubscriptions = 0
shared.sqlLock.acquire() shared.sqlLock.acquire()
shared.sqlSubmitQueue.put('''SELECT msgid, toaddress, read FROM inbox where folder='inbox' ''') shared.sqlSubmitQueue.put(
'''SELECT msgid, toaddress, read FROM inbox where folder='inbox' ''')
shared.sqlSubmitQueue.put('') shared.sqlSubmitQueue.put('')
queryreturn = shared.sqlReturnQueue.get() queryreturn = shared.sqlReturnQueue.get()
shared.sqlLock.release() shared.sqlLock.release()
@ -677,18 +804,21 @@ class MyForm(QtGui.QMainWindow):
unreadMessages = unreadMessages + 1 unreadMessages = unreadMessages + 1
return unreadMessages, unreadSubscriptions return unreadMessages, unreadSubscriptions
# show the number of unread messages and subscriptions on the messaging menu # show the number of unread messages and subscriptions on the messaging
# menu
def ubuntuMessagingMenuUnread(self, drawAttention): def ubuntuMessagingMenuUnread(self, drawAttention):
unreadMessages, unreadSubscriptions = self.getUnread() unreadMessages, unreadSubscriptions = self.getUnread()
# unread messages # unread messages
if unreadMessages > 0: if unreadMessages > 0:
self.mmapp.append_source("Messages", None, "Messages (" + str(unreadMessages) + ")") self.mmapp.append_source(
"Messages", None, "Messages (" + str(unreadMessages) + ")")
if drawAttention: if drawAttention:
self.mmapp.draw_attention("Messages") self.mmapp.draw_attention("Messages")
# unread subscriptions # unread subscriptions
if unreadSubscriptions > 0: if unreadSubscriptions > 0:
self.mmapp.append_source("Subscriptions", None, "Subscriptions (" + str(unreadSubscriptions) + ")") self.mmapp.append_source("Subscriptions", None, "Subscriptions (" + str(
unreadSubscriptions) + ")")
if drawAttention: if drawAttention:
self.mmapp.draw_attention("Subscriptions") self.mmapp.draw_attention("Subscriptions")
@ -708,7 +838,8 @@ class MyForm(QtGui.QMainWindow):
# create the menu server # create the menu server
if withMessagingMenu: if withMessagingMenu:
try: try:
self.mmapp = MessagingMenu.App(desktop_id='pybitmessage.desktop') self.mmapp = MessagingMenu.App(
desktop_id='pybitmessage.desktop')
self.mmapp.register() self.mmapp.register()
self.mmapp.connect('activate-source', self.appIndicatorInbox) self.mmapp.connect('activate-source', self.appIndicatorInbox)
self.ubuntuMessagingMenuUnread(True) self.ubuntuMessagingMenuUnread(True)
@ -756,18 +887,19 @@ class MyForm(QtGui.QMainWindow):
def notifierShow(self, title, subtitle): def notifierShow(self, title, subtitle):
global withMessagingMenu global withMessagingMenu
if withMessagingMenu: if withMessagingMenu:
n = Notify.Notification.new(title, subtitle,'notification-message-email') n = Notify.Notification.new(
title, subtitle, 'notification-message-email')
n.show() n.show()
return return
else: else:
self.tray.showMessage(title, subtitle, 1, 2000) self.tray.showMessage(title, subtitle, 1, 2000)
def tableWidgetInboxKeyPressEvent(self,event): def tableWidgetInboxKeyPressEvent(self, event):
if event.key() == QtCore.Qt.Key_Delete: if event.key() == QtCore.Qt.Key_Delete:
self.on_action_InboxTrash() self.on_action_InboxTrash()
return QtGui.QTableWidget.keyPressEvent(self.ui.tableWidgetInbox, event) return QtGui.QTableWidget.keyPressEvent(self.ui.tableWidgetInbox, event)
def tableWidgetSentKeyPressEvent(self,event): def tableWidgetSentKeyPressEvent(self, event):
if event.key() == QtCore.Qt.Key_Delete: if event.key() == QtCore.Qt.Key_Delete:
self.on_action_SentTrash() self.on_action_SentTrash()
return QtGui.QTableWidget.keyPressEvent(self.ui.tableWidgetSent, event) return QtGui.QTableWidget.keyPressEvent(self.ui.tableWidgetSent, event)
@ -775,40 +907,52 @@ class MyForm(QtGui.QMainWindow):
def click_actionManageKeys(self): def click_actionManageKeys(self):
if 'darwin' in sys.platform or 'linux' in sys.platform: if 'darwin' in sys.platform or 'linux' in sys.platform:
if shared.appdata == '': if shared.appdata == '':
#reply = QtGui.QMessageBox.information(self, 'keys.dat?','You may manage your keys by editing the keys.dat file stored in the same directory as this program. It is important that you back up this file.', QMessageBox.Ok) # reply = QtGui.QMessageBox.information(self, 'keys.dat?','You
reply = QtGui.QMessageBox.information(self, 'keys.dat?',QtGui.QApplication.translate("MainWindow", "You may manage your keys by editing the keys.dat file stored in the same directory as this program. It is important that you back up this file."), QMessageBox.Ok) # may manage your keys by editing the keys.dat file stored in
# the same directory as this program. It is important that you
# back up this file.', QMessageBox.Ok)
reply = QtGui.QMessageBox.information(self, 'keys.dat?', QtGui.QApplication.translate(
"MainWindow", "You may manage your keys by editing the keys.dat file stored in the same directory as this program. It is important that you back up this file."), QMessageBox.Ok)
else: else:
QtGui.QMessageBox.information(self, 'keys.dat?',QtGui.QApplication.translate("MainWindow", "You may manage your keys by editing the keys.dat file stored in\n %1 \nIt is important that you back up this file.").arg(shared.appdata), QMessageBox.Ok) QtGui.QMessageBox.information(self, 'keys.dat?', QtGui.QApplication.translate(
"MainWindow", "You may manage your keys by editing the keys.dat file stored in\n %1 \nIt is important that you back up this file.").arg(shared.appdata), QMessageBox.Ok)
elif sys.platform == 'win32' or sys.platform == 'win64': elif sys.platform == 'win32' or sys.platform == 'win64':
if shared.appdata == '': if shared.appdata == '':
reply = QtGui.QMessageBox.question(self, QtGui.QApplication.translate("MainWindow", "Open keys.dat?"),QtGui.QApplication.translate("MainWindow", "You may manage your keys by editing the keys.dat file stored in the same directory as this program. It is important that you back up this file. Would you like to open the file now? (Be sure to close Bitmessage before making any changes.)"), QtGui.QMessageBox.Yes, QtGui.QMessageBox.No) reply = QtGui.QMessageBox.question(self, QtGui.QApplication.translate("MainWindow", "Open keys.dat?"), QtGui.QApplication.translate(
"MainWindow", "You may manage your keys by editing the keys.dat file stored in the same directory as this program. It is important that you back up this file. Would you like to open the file now? (Be sure to close Bitmessage before making any changes.)"), QtGui.QMessageBox.Yes, QtGui.QMessageBox.No)
else: else:
reply = QtGui.QMessageBox.question(self, QtGui.QApplication.translate("MainWindow", "Open keys.dat?"),QtGui.QApplication.translate("MainWindow", "You may manage your keys by editing the keys.dat file stored in\n %1 \nIt is important that you back up this file. Would you like to open the file now? (Be sure to close Bitmessage before making any changes.)").arg(shared.appdata), QtGui.QMessageBox.Yes, QtGui.QMessageBox.No) reply = QtGui.QMessageBox.question(self, QtGui.QApplication.translate("MainWindow", "Open keys.dat?"), QtGui.QApplication.translate(
"MainWindow", "You may manage your keys by editing the keys.dat file stored in\n %1 \nIt is important that you back up this file. Would you like to open the file now? (Be sure to close Bitmessage before making any changes.)").arg(shared.appdata), QtGui.QMessageBox.Yes, QtGui.QMessageBox.No)
if reply == QtGui.QMessageBox.Yes: if reply == QtGui.QMessageBox.Yes:
self.openKeysFile() self.openKeysFile()
def click_actionDeleteAllTrashedMessages(self): def click_actionDeleteAllTrashedMessages(self):
if QtGui.QMessageBox.question(self, QtGui.QApplication.translate("MainWindow", "Delete trash?"),QtGui.QApplication.translate("MainWindow", "Are you sure you want to delete all trashed messages?"), QtGui.QMessageBox.Yes, QtGui.QMessageBox.No) == QtGui.QMessageBox.No: if QtGui.QMessageBox.question(self, QtGui.QApplication.translate("MainWindow", "Delete trash?"), QtGui.QApplication.translate("MainWindow", "Are you sure you want to delete all trashed messages?"), QtGui.QMessageBox.Yes, QtGui.QMessageBox.No) == QtGui.QMessageBox.No:
return return
shared.sqlLock.acquire() shared.sqlLock.acquire()
shared.sqlSubmitQueue.put('deleteandvacuume') shared.sqlSubmitQueue.put('deleteandvacuume')
shared.sqlLock.release() shared.sqlLock.release()
def click_actionRegenerateDeterministicAddresses(self): def click_actionRegenerateDeterministicAddresses(self):
self.regenerateAddressesDialogInstance = regenerateAddressesDialog(self) self.regenerateAddressesDialogInstance = regenerateAddressesDialog(
self)
if self.regenerateAddressesDialogInstance.exec_(): if self.regenerateAddressesDialogInstance.exec_():
if self.regenerateAddressesDialogInstance.ui.lineEditPassphrase.text() == "": if self.regenerateAddressesDialogInstance.ui.lineEditPassphrase.text() == "":
QMessageBox.about(self, QtGui.QApplication.translate("MainWindow", "bad passphrase"), QtGui.QApplication.translate("MainWindow", "You must type your passphrase. If you don\'t have one then this is not the form for you.")) QMessageBox.about(self, QtGui.QApplication.translate("MainWindow", "bad passphrase"), QtGui.QApplication.translate(
"MainWindow", "You must type your passphrase. If you don\'t have one then this is not the form for you."))
else: else:
streamNumberForAddress = int(self.regenerateAddressesDialogInstance.ui.lineEditStreamNumber.text()) streamNumberForAddress = int(
addressVersionNumber = int(self.regenerateAddressesDialogInstance.ui.lineEditAddressVersionNumber.text()) self.regenerateAddressesDialogInstance.ui.lineEditStreamNumber.text())
#self.addressGenerator = addressGenerator() addressVersionNumber = int(
#self.addressGenerator.setup(addressVersionNumber,streamNumberForAddress,"unused address",self.regenerateAddressesDialogInstance.ui.spinBoxNumberOfAddressesToMake.value(),self.regenerateAddressesDialogInstance.ui.lineEditPassphrase.text().toUtf8(),self.regenerateAddressesDialogInstance.ui.checkBoxEighteenByteRipe.isChecked()) self.regenerateAddressesDialogInstance.ui.lineEditAddressVersionNumber.text())
#QtCore.QObject.connect(self.addressGenerator, SIGNAL("writeNewAddressToTable(PyQt_PyObject,PyQt_PyObject,PyQt_PyObject)"), self.writeNewAddressToTable) # self.addressGenerator = addressGenerator()
#QtCore.QObject.connect(self.addressGenerator, QtCore.SIGNAL("updateStatusBar(PyQt_PyObject)"), self.updateStatusBar) # self.addressGenerator.setup(addressVersionNumber,streamNumberForAddress,"unused address",self.regenerateAddressesDialogInstance.ui.spinBoxNumberOfAddressesToMake.value(),self.regenerateAddressesDialogInstance.ui.lineEditPassphrase.text().toUtf8(),self.regenerateAddressesDialogInstance.ui.checkBoxEighteenByteRipe.isChecked())
#self.addressGenerator.start() # QtCore.QObject.connect(self.addressGenerator, SIGNAL("writeNewAddressToTable(PyQt_PyObject,PyQt_PyObject,PyQt_PyObject)"), self.writeNewAddressToTable)
shared.addressGeneratorQueue.put(('createDeterministicAddresses',addressVersionNumber,streamNumberForAddress,"regenerated deterministic address",self.regenerateAddressesDialogInstance.ui.spinBoxNumberOfAddressesToMake.value(),self.regenerateAddressesDialogInstance.ui.lineEditPassphrase.text().toUtf8(),self.regenerateAddressesDialogInstance.ui.checkBoxEighteenByteRipe.isChecked())) # QtCore.QObject.connect(self.addressGenerator, QtCore.SIGNAL("updateStatusBar(PyQt_PyObject)"), self.updateStatusBar)
# self.addressGenerator.start()
shared.addressGeneratorQueue.put(('createDeterministicAddresses', addressVersionNumber, streamNumberForAddress, "regenerated deterministic address", self.regenerateAddressesDialogInstance.ui.spinBoxNumberOfAddressesToMake.value(
), self.regenerateAddressesDialogInstance.ui.lineEditPassphrase.text().toUtf8(), self.regenerateAddressesDialogInstance.ui.checkBoxEighteenByteRipe.isChecked()))
self.ui.tabWidget.setCurrentIndex(3) self.ui.tabWidget.setCurrentIndex(3)
def openKeysFile(self): def openKeysFile(self):
@ -828,9 +972,10 @@ class MyForm(QtGui.QMainWindow):
if 'win32' in sys.platform or 'win64' in sys.platform: if 'win32' in sys.platform or 'win64' in sys.platform:
self.setWindowFlags(Qt.ToolTip) self.setWindowFlags(Qt.ToolTip)
elif event.oldState() & QtCore.Qt.WindowMinimized: elif event.oldState() & QtCore.Qt.WindowMinimized:
#The window state has just been changed to Normal/Maximised/FullScreen # The window state has just been changed to
# Normal/Maximised/FullScreen
pass pass
#QtGui.QWidget.changeEvent(self, event) # QtGui.QWidget.changeEvent(self, event)
def __icon_activated(self, reason): def __icon_activated(self, reason):
if reason == QtGui.QSystemTrayIcon.Trigger: if reason == QtGui.QSystemTrayIcon.Trigger:
@ -839,19 +984,22 @@ class MyForm(QtGui.QMainWindow):
def incrementNumberOfMessagesProcessed(self): def incrementNumberOfMessagesProcessed(self):
self.numberOfMessagesProcessed += 1 self.numberOfMessagesProcessed += 1
self.ui.labelMessageCount.setText(QtGui.QApplication.translate("MainWindow", "Processed %1 person-to-person messages.").arg(str(self.numberOfMessagesProcessed))) self.ui.labelMessageCount.setText(QtGui.QApplication.translate(
"MainWindow", "Processed %1 person-to-person messages.").arg(str(self.numberOfMessagesProcessed)))
def incrementNumberOfBroadcastsProcessed(self): def incrementNumberOfBroadcastsProcessed(self):
self.numberOfBroadcastsProcessed += 1 self.numberOfBroadcastsProcessed += 1
self.ui.labelBroadcastCount.setText(QtGui.QApplication.translate("MainWindow", "Processed %1 broadcast messages.").arg(str(self.numberOfBroadcastsProcessed))) self.ui.labelBroadcastCount.setText(QtGui.QApplication.translate(
"MainWindow", "Processed %1 broadcast messages.").arg(str(self.numberOfBroadcastsProcessed)))
def incrementNumberOfPubkeysProcessed(self): def incrementNumberOfPubkeysProcessed(self):
self.numberOfPubkeysProcessed += 1 self.numberOfPubkeysProcessed += 1
self.ui.labelPubkeyCount.setText(QtGui.QApplication.translate("MainWindow", "Processed %1 public keys.").arg(str(self.numberOfPubkeysProcessed))) self.ui.labelPubkeyCount.setText(QtGui.QApplication.translate(
"MainWindow", "Processed %1 public keys.").arg(str(self.numberOfPubkeysProcessed)))
def updateNetworkStatusTab(self): def updateNetworkStatusTab(self):
#print 'updating network status tab' # print 'updating network status tab'
totalNumberOfConnectionsFromAllStreams = 0 #One would think we could use len(sendDataQueues) for this but the number doesn't always match: just because we have a sendDataThread running doesn't mean that the connection has been fully established (with the exchange of version messages). totalNumberOfConnectionsFromAllStreams = 0 # One would think we could use len(sendDataQueues) for this but the number doesn't always match: just because we have a sendDataThread running doesn't mean that the connection has been fully established (with the exchange of version messages).
streamNumberTotals = {} streamNumberTotals = {}
for host, streamNumber in shared.connectedHostsList.items(): for host, streamNumber in shared.connectedHostsList.items():
if not streamNumber in streamNumberTotals: if not streamNumber in streamNumberTotals:
@ -864,14 +1012,16 @@ class MyForm(QtGui.QMainWindow):
for streamNumber, connectionCount in streamNumberTotals.items(): for streamNumber, connectionCount in streamNumberTotals.items():
self.ui.tableWidgetConnectionCount.insertRow(0) self.ui.tableWidgetConnectionCount.insertRow(0)
if streamNumber == 0: if streamNumber == 0:
newItem = QtGui.QTableWidgetItem("?") newItem = QtGui.QTableWidgetItem("?")
else: else:
newItem = QtGui.QTableWidgetItem(str(streamNumber)) newItem = QtGui.QTableWidgetItem(str(streamNumber))
newItem.setFlags( QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled ) newItem.setFlags(
self.ui.tableWidgetConnectionCount.setItem(0,0,newItem) QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled)
newItem = QtGui.QTableWidgetItem(str(connectionCount)) self.ui.tableWidgetConnectionCount.setItem(0, 0, newItem)
newItem.setFlags( QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled ) newItem = QtGui.QTableWidgetItem(str(connectionCount))
self.ui.tableWidgetConnectionCount.setItem(0,1,newItem) newItem.setFlags(
QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled)
self.ui.tableWidgetConnectionCount.setItem(0, 1, newItem)
"""for currentRow in range(self.ui.tableWidgetConnectionCount.rowCount()): """for currentRow in range(self.ui.tableWidgetConnectionCount.rowCount()):
rowStreamNumber = int(self.ui.tableWidgetConnectionCount.item(currentRow,0).text()) rowStreamNumber = int(self.ui.tableWidgetConnectionCount.item(currentRow,0).text())
if streamNumber == rowStreamNumber: if streamNumber == rowStreamNumber:
@ -888,8 +1038,9 @@ class MyForm(QtGui.QMainWindow):
newItem.setFlags( QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled ) newItem.setFlags( QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled )
self.ui.tableWidgetConnectionCount.setItem(0,1,newItem) self.ui.tableWidgetConnectionCount.setItem(0,1,newItem)
totalNumberOfConnectionsFromAllStreams += connectionCount""" totalNumberOfConnectionsFromAllStreams += connectionCount"""
self.ui.labelTotalConnections.setText(QtGui.QApplication.translate("MainWindow", "Total Connections: %1").arg(str(len(shared.connectedHostsList)))) self.ui.labelTotalConnections.setText(QtGui.QApplication.translate(
if len(shared.connectedHostsList) > 0 and shared.statusIconColor == 'red': #FYI: The 'singlelistener' thread sets the icon color to green when it receives an incoming connection, meaning that the user's firewall is configured correctly. "MainWindow", "Total Connections: %1").arg(str(len(shared.connectedHostsList))))
if len(shared.connectedHostsList) > 0 and shared.statusIconColor == 'red': # FYI: The 'singlelistener' thread sets the icon color to green when it receives an incoming connection, meaning that the user's firewall is configured correctly.
self.setStatusIcon('yellow') self.setStatusIcon('yellow')
elif len(shared.connectedHostsList) == 0: elif len(shared.connectedHostsList) == 0:
self.setStatusIcon('red') self.setStatusIcon('red')
@ -897,225 +1048,280 @@ class MyForm(QtGui.QMainWindow):
# Indicates whether or not there is a connection to the Bitmessage network # Indicates whether or not there is a connection to the Bitmessage network
connected = False connected = False
def setStatusIcon(self,color): def setStatusIcon(self, color):
global withMessagingMenu global withMessagingMenu
#print 'setting status icon color' # print 'setting status icon color'
if color == 'red': if color == 'red':
self.ui.pushButtonStatusIcon.setIcon(QIcon(":/newPrefix/images/redicon.png")) self.ui.pushButtonStatusIcon.setIcon(
QIcon(":/newPrefix/images/redicon.png"))
shared.statusIconColor = 'red' shared.statusIconColor = 'red'
# if the connection is lost then show a notification # if the connection is lost then show a notification
if self.connected: if self.connected:
self.notifierShow('Bitmessage',QtGui.QApplication.translate("MainWindow", "Connection lost")) self.notifierShow('Bitmessage', QtGui.QApplication.translate(
"MainWindow", "Connection lost"))
self.connected = False self.connected = False
if self.actionStatus != None: if self.actionStatus is not None:
self.actionStatus.setText(QtGui.QApplication.translate("MainWindow", "Not Connected")) self.actionStatus.setText(QtGui.QApplication.translate(
self.tray.setIcon(QtGui.QIcon(":/newPrefix/images/can-icon-24px-red.png")) "MainWindow", "Not Connected"))
self.tray.setIcon(QtGui.QIcon(
":/newPrefix/images/can-icon-24px-red.png"))
if color == 'yellow': if color == 'yellow':
if self.statusBar().currentMessage() == 'Warning: You are currently not connected. Bitmessage will do the work necessary to send the message but it won\'t send until you connect.': if self.statusBar().currentMessage() == 'Warning: You are currently not connected. Bitmessage will do the work necessary to send the message but it won\'t send until you connect.':
self.statusBar().showMessage('') self.statusBar().showMessage('')
self.ui.pushButtonStatusIcon.setIcon(QIcon(":/newPrefix/images/yellowicon.png")) self.ui.pushButtonStatusIcon.setIcon(QIcon(
":/newPrefix/images/yellowicon.png"))
shared.statusIconColor = 'yellow' shared.statusIconColor = 'yellow'
# if a new connection has been established then show a notification # if a new connection has been established then show a notification
if not self.connected: if not self.connected:
self.notifierShow('Bitmessage',QtGui.QApplication.translate("MainWindow", "Connected")) self.notifierShow('Bitmessage', QtGui.QApplication.translate(
"MainWindow", "Connected"))
self.connected = True self.connected = True
if self.actionStatus != None: if self.actionStatus is not None:
self.actionStatus.setText(QtGui.QApplication.translate("MainWindow", "Connected")) self.actionStatus.setText(QtGui.QApplication.translate(
self.tray.setIcon(QtGui.QIcon(":/newPrefix/images/can-icon-24px-yellow.png")) "MainWindow", "Connected"))
self.tray.setIcon(QtGui.QIcon(
":/newPrefix/images/can-icon-24px-yellow.png"))
if color == 'green': if color == 'green':
if self.statusBar().currentMessage() == 'Warning: You are currently not connected. Bitmessage will do the work necessary to send the message but it won\'t send until you connect.': if self.statusBar().currentMessage() == 'Warning: You are currently not connected. Bitmessage will do the work necessary to send the message but it won\'t send until you connect.':
self.statusBar().showMessage('') self.statusBar().showMessage('')
self.ui.pushButtonStatusIcon.setIcon(QIcon(":/newPrefix/images/greenicon.png")) self.ui.pushButtonStatusIcon.setIcon(
QIcon(":/newPrefix/images/greenicon.png"))
shared.statusIconColor = 'green' shared.statusIconColor = 'green'
if not self.connected: if not self.connected:
self.notifierShow('Bitmessage',QtGui.QApplication.translate("MainWindow", "Connected")) self.notifierShow('Bitmessage', QtGui.QApplication.translate(
"MainWindow", "Connected"))
self.connected = True self.connected = True
if self.actionStatus != None: if self.actionStatus is not None:
self.actionStatus.setText(QtGui.QApplication.translate("MainWindow", "Connected")) self.actionStatus.setText(QtGui.QApplication.translate(
self.tray.setIcon(QtGui.QIcon(":/newPrefix/images/can-icon-24px-green.png")) "MainWindow", "Connected"))
self.tray.setIcon(QtGui.QIcon(
":/newPrefix/images/can-icon-24px-green.png"))
def updateSentItemStatusByHash(self,toRipe,textToDisplay): def updateSentItemStatusByHash(self, toRipe, textToDisplay):
for i in range(self.ui.tableWidgetSent.rowCount()): for i in range(self.ui.tableWidgetSent.rowCount()):
toAddress = str(self.ui.tableWidgetSent.item(i,0).data(Qt.UserRole).toPyObject()) toAddress = str(self.ui.tableWidgetSent.item(
status,addressVersionNumber,streamNumber,ripe = decodeAddress(toAddress) i, 0).data(Qt.UserRole).toPyObject())
status, addressVersionNumber, streamNumber, ripe = decodeAddress(
toAddress)
if ripe == toRipe: if ripe == toRipe:
self.ui.tableWidgetSent.item(i,3).setToolTip(textToDisplay) self.ui.tableWidgetSent.item(i, 3).setToolTip(textToDisplay)
parenPositionIndex = string.find(textToDisplay,'\n') parenPositionIndex = string.find(textToDisplay, '\n')
if parenPositionIndex > 1: if parenPositionIndex > 1:
self.ui.tableWidgetSent.item(i,3).setText(textToDisplay[:parenPositionIndex]) self.ui.tableWidgetSent.item(i, 3).setText(
textToDisplay[:parenPositionIndex])
else: else:
self.ui.tableWidgetSent.item(i,3).setText(textToDisplay) self.ui.tableWidgetSent.item(i, 3).setText(textToDisplay)
def updateSentItemStatusByAckdata(self, ackdata, textToDisplay):
def updateSentItemStatusByAckdata(self,ackdata,textToDisplay):
for i in range(self.ui.tableWidgetSent.rowCount()): for i in range(self.ui.tableWidgetSent.rowCount()):
toAddress = str(self.ui.tableWidgetSent.item(i,0).data(Qt.UserRole).toPyObject()) toAddress = str(self.ui.tableWidgetSent.item(
tableAckdata = self.ui.tableWidgetSent.item(i,3).data(Qt.UserRole).toPyObject() i, 0).data(Qt.UserRole).toPyObject())
status,addressVersionNumber,streamNumber,ripe = decodeAddress(toAddress) tableAckdata = self.ui.tableWidgetSent.item(
i, 3).data(Qt.UserRole).toPyObject()
status, addressVersionNumber, streamNumber, ripe = decodeAddress(
toAddress)
if ackdata == tableAckdata: if ackdata == tableAckdata:
self.ui.tableWidgetSent.item(i,3).setToolTip(textToDisplay) self.ui.tableWidgetSent.item(i, 3).setToolTip(textToDisplay)
parenPositionIndex = string.find(textToDisplay,'\n') parenPositionIndex = string.find(textToDisplay, '\n')
if parenPositionIndex > 1: if parenPositionIndex > 1:
self.ui.tableWidgetSent.item(i,3).setText(textToDisplay[:parenPositionIndex]) self.ui.tableWidgetSent.item(i, 3).setText(
textToDisplay[:parenPositionIndex])
else: else:
self.ui.tableWidgetSent.item(i,3).setText(textToDisplay) self.ui.tableWidgetSent.item(i, 3).setText(textToDisplay)
def removeInboxRowByMsgid(self,msgid):#msgid and inventoryHash are the same thing def removeInboxRowByMsgid(self, msgid): # msgid and inventoryHash are the same thing
for i in range(self.ui.tableWidgetInbox.rowCount()): for i in range(self.ui.tableWidgetInbox.rowCount()):
if msgid == str(self.ui.tableWidgetInbox.item(i,3).data(Qt.UserRole).toPyObject()): if msgid == str(self.ui.tableWidgetInbox.item(i, 3).data(Qt.UserRole).toPyObject()):
self.statusBar().showMessage(QtGui.QApplication.translate("MainWindow", "Message trashed")) self.statusBar().showMessage(QtGui.QApplication.translate(
"MainWindow", "Message trashed"))
self.ui.tableWidgetInbox.removeRow(i) self.ui.tableWidgetInbox.removeRow(i)
break break
def rerenderInboxFromLabels(self): def rerenderInboxFromLabels(self):
for i in range(self.ui.tableWidgetInbox.rowCount()): for i in range(self.ui.tableWidgetInbox.rowCount()):
addressToLookup = str(self.ui.tableWidgetInbox.item(i,1).data(Qt.UserRole).toPyObject()) addressToLookup = str(self.ui.tableWidgetInbox.item(
i, 1).data(Qt.UserRole).toPyObject())
fromLabel = '' fromLabel = ''
t = (addressToLookup,) t = (addressToLookup,)
shared.sqlLock.acquire() shared.sqlLock.acquire()
shared.sqlSubmitQueue.put('''select label from addressbook where address=?''') shared.sqlSubmitQueue.put(
'''select label from addressbook where address=?''')
shared.sqlSubmitQueue.put(t) shared.sqlSubmitQueue.put(t)
queryreturn = shared.sqlReturnQueue.get() queryreturn = shared.sqlReturnQueue.get()
shared.sqlLock.release() shared.sqlLock.release()
if queryreturn <> []: if queryreturn != []:
for row in queryreturn: for row in queryreturn:
fromLabel, = row fromLabel, = row
self.ui.tableWidgetInbox.item(i,1).setText(unicode(fromLabel,'utf-8')) self.ui.tableWidgetInbox.item(
i, 1).setText(unicode(fromLabel, 'utf-8'))
else: else:
#It might be a broadcast message. We should check for that label. # It might be a broadcast message. We should check for that
# label.
shared.sqlLock.acquire() shared.sqlLock.acquire()
shared.sqlSubmitQueue.put('''select label from subscriptions where address=?''') shared.sqlSubmitQueue.put(
'''select label from subscriptions where address=?''')
shared.sqlSubmitQueue.put(t) shared.sqlSubmitQueue.put(t)
queryreturn = shared.sqlReturnQueue.get() queryreturn = shared.sqlReturnQueue.get()
shared.sqlLock.release() shared.sqlLock.release()
if queryreturn <> []: if queryreturn != []:
for row in queryreturn: for row in queryreturn:
fromLabel, = row fromLabel, = row
self.ui.tableWidgetInbox.item(i,1).setText(unicode(fromLabel,'utf-8')) self.ui.tableWidgetInbox.item(
i, 1).setText(unicode(fromLabel, 'utf-8'))
def rerenderInboxToLabels(self): def rerenderInboxToLabels(self):
for i in range(self.ui.tableWidgetInbox.rowCount()): for i in range(self.ui.tableWidgetInbox.rowCount()):
toAddress = str(self.ui.tableWidgetInbox.item(i,0).data(Qt.UserRole).toPyObject()) toAddress = str(self.ui.tableWidgetInbox.item(
i, 0).data(Qt.UserRole).toPyObject())
try: try:
toLabel = shared.config.get(toAddress, 'label') toLabel = shared.config.get(toAddress, 'label')
except: except:
toLabel = '' toLabel = ''
if toLabel == '': if toLabel == '':
toLabel = toAddress toLabel = toAddress
self.ui.tableWidgetInbox.item(i,0).setText(unicode(toLabel,'utf-8')) self.ui.tableWidgetInbox.item(
#Set the color according to whether it is the address of a mailing list or not. i, 0).setText(unicode(toLabel, 'utf-8'))
if shared.safeConfigGetBoolean(toAddress,'mailinglist'): # Set the color according to whether it is the address of a mailing
self.ui.tableWidgetInbox.item(i,0).setTextColor(QtGui.QColor(137,04,177)) # list or not.
if shared.safeConfigGetBoolean(toAddress, 'mailinglist'):
self.ui.tableWidgetInbox.item(i, 0).setTextColor(QtGui.QColor(137, 04, 177))
else: else:
self.ui.tableWidgetInbox.item(i,0).setTextColor(QtGui.QColor(0,0,0)) self.ui.tableWidgetInbox.item(
i, 0).setTextColor(QtGui.QColor(0, 0, 0))
def rerenderSentFromLabels(self): def rerenderSentFromLabels(self):
for i in range(self.ui.tableWidgetSent.rowCount()): for i in range(self.ui.tableWidgetSent.rowCount()):
fromAddress = str(self.ui.tableWidgetSent.item(i,1).data(Qt.UserRole).toPyObject()) fromAddress = str(self.ui.tableWidgetSent.item(
i, 1).data(Qt.UserRole).toPyObject())
try: try:
fromLabel = shared.config.get(fromAddress, 'label') fromLabel = shared.config.get(fromAddress, 'label')
except: except:
fromLabel = '' fromLabel = ''
if fromLabel == '': if fromLabel == '':
fromLabel = fromAddress fromLabel = fromAddress
self.ui.tableWidgetSent.item(i,1).setText(unicode(fromLabel,'utf-8')) self.ui.tableWidgetSent.item(
i, 1).setText(unicode(fromLabel, 'utf-8'))
def rerenderSentToLabels(self): def rerenderSentToLabels(self):
for i in range(self.ui.tableWidgetSent.rowCount()): for i in range(self.ui.tableWidgetSent.rowCount()):
addressToLookup = str(self.ui.tableWidgetSent.item(i,0).data(Qt.UserRole).toPyObject()) addressToLookup = str(self.ui.tableWidgetSent.item(
i, 0).data(Qt.UserRole).toPyObject())
toLabel = '' toLabel = ''
t = (addressToLookup,) t = (addressToLookup,)
shared.sqlLock.acquire() shared.sqlLock.acquire()
shared.sqlSubmitQueue.put('''select label from addressbook where address=?''') shared.sqlSubmitQueue.put(
'''select label from addressbook where address=?''')
shared.sqlSubmitQueue.put(t) shared.sqlSubmitQueue.put(t)
queryreturn = shared.sqlReturnQueue.get() queryreturn = shared.sqlReturnQueue.get()
shared.sqlLock.release() shared.sqlLock.release()
if queryreturn <> []: if queryreturn != []:
for row in queryreturn: for row in queryreturn:
toLabel, = row toLabel, = row
self.ui.tableWidgetSent.item(i,0).setText(unicode(toLabel,'utf-8')) self.ui.tableWidgetSent.item(
i, 0).setText(unicode(toLabel, 'utf-8'))
def rerenderSubscriptions(self): def rerenderSubscriptions(self):
self.ui.tableWidgetSubscriptions.setRowCount(0) self.ui.tableWidgetSubscriptions.setRowCount(0)
shared.sqlLock.acquire() shared.sqlLock.acquire()
shared.sqlSubmitQueue.put('SELECT label, address, enabled FROM subscriptions') shared.sqlSubmitQueue.put(
'SELECT label, address, enabled FROM subscriptions')
shared.sqlSubmitQueue.put('') shared.sqlSubmitQueue.put('')
queryreturn = shared.sqlReturnQueue.get() queryreturn = shared.sqlReturnQueue.get()
shared.sqlLock.release() shared.sqlLock.release()
for row in queryreturn: for row in queryreturn:
label, address, enabled = row label, address, enabled = row
self.ui.tableWidgetSubscriptions.insertRow(0) self.ui.tableWidgetSubscriptions.insertRow(0)
newItem = QtGui.QTableWidgetItem(unicode(label,'utf-8')) newItem = QtGui.QTableWidgetItem(unicode(label, 'utf-8'))
if not enabled: if not enabled:
newItem.setTextColor(QtGui.QColor(128,128,128)) newItem.setTextColor(QtGui.QColor(128, 128, 128))
self.ui.tableWidgetSubscriptions.setItem(0,0,newItem) self.ui.tableWidgetSubscriptions.setItem(0, 0, newItem)
newItem = QtGui.QTableWidgetItem(address) newItem = QtGui.QTableWidgetItem(address)
newItem.setFlags( QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled ) newItem.setFlags(
QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled)
if not enabled: if not enabled:
newItem.setTextColor(QtGui.QColor(128,128,128)) newItem.setTextColor(QtGui.QColor(128, 128, 128))
self.ui.tableWidgetSubscriptions.setItem(0,1,newItem) self.ui.tableWidgetSubscriptions.setItem(0, 1, newItem)
def click_pushButtonSend(self): def click_pushButtonSend(self):
self.statusBar().showMessage('') self.statusBar().showMessage('')
toAddresses = str(self.ui.lineEditTo.text()) toAddresses = str(self.ui.lineEditTo.text())
fromAddress = str(self.ui.labelFrom.text()) fromAddress = str(self.ui.labelFrom.text())
subject = str(self.ui.lineEditSubject.text().toUtf8()) subject = str(self.ui.lineEditSubject.text().toUtf8())
message = str(self.ui.textEditMessage.document().toPlainText().toUtf8()) message = str(
if self.ui.radioButtonSpecific.isChecked(): #To send a message to specific people (rather than broadcast) self.ui.textEditMessage.document().toPlainText().toUtf8())
toAddressesList = [s.strip() for s in toAddresses.replace(',', ';').split(';')] if self.ui.radioButtonSpecific.isChecked(): # To send a message to specific people (rather than broadcast)
toAddressesList = list(set(toAddressesList)) #remove duplicate addresses. If the user has one address with a BM- and the same address without the BM-, this will not catch it. They'll send the message to the person twice. toAddressesList = [s.strip()
for s in toAddresses.replace(',', ';').split(';')]
toAddressesList = list(set(
toAddressesList)) # remove duplicate addresses. If the user has one address with a BM- and the same address without the BM-, this will not catch it. They'll send the message to the person twice.
for toAddress in toAddressesList: for toAddress in toAddressesList:
if toAddress <> '': if toAddress != '':
status,addressVersionNumber,streamNumber,ripe = decodeAddress(toAddress) status, addressVersionNumber, streamNumber, ripe = decodeAddress(
if status <> 'success': toAddress)
if status != 'success':
shared.printLock.acquire() shared.printLock.acquire()
print 'Error: Could not decode', toAddress, ':', status print 'Error: Could not decode', toAddress, ':', status
shared.printLock.release() shared.printLock.release()
if status == 'missingbm': if status == 'missingbm':
self.statusBar().showMessage(QtGui.QApplication.translate("MainWindow", "Error: Bitmessage addresses start with BM- Please check %1").arg(toAddress)) self.statusBar().showMessage(QtGui.QApplication.translate(
"MainWindow", "Error: Bitmessage addresses start with BM- Please check %1").arg(toAddress))
elif status == 'checksumfailed': elif status == 'checksumfailed':
self.statusBar().showMessage(QtGui.QApplication.translate("MainWindow", "Error: The address %1 is not typed or copied correctly. Please check it.").arg(toAddress)) self.statusBar().showMessage(QtGui.QApplication.translate(
"MainWindow", "Error: The address %1 is not typed or copied correctly. Please check it.").arg(toAddress))
elif status == 'invalidcharacters': elif status == 'invalidcharacters':
self.statusBar().showMessage(QtGui.QApplication.translate("MainWindow", "Error: The address %1 contains invalid characters. Please check it.").arg(toAddress)) self.statusBar().showMessage(QtGui.QApplication.translate(
"MainWindow", "Error: The address %1 contains invalid characters. Please check it.").arg(toAddress))
elif status == 'versiontoohigh': elif status == 'versiontoohigh':
self.statusBar().showMessage(QtGui.QApplication.translate("MainWindow", "Error: The address version in %1 is too high. Either you need to upgrade your Bitmessage software or your acquaintance is being clever.").arg(toAddress)) self.statusBar().showMessage(QtGui.QApplication.translate(
"MainWindow", "Error: The address version in %1 is too high. Either you need to upgrade your Bitmessage software or your acquaintance is being clever.").arg(toAddress))
elif status == 'ripetooshort': elif status == 'ripetooshort':
self.statusBar().showMessage(QtGui.QApplication.translate("MainWindow", "Error: Some data encoded in the address %1 is too short. There might be something wrong with the software of your acquaintance.").arg(toAddress)) self.statusBar().showMessage(QtGui.QApplication.translate(
"MainWindow", "Error: Some data encoded in the address %1 is too short. There might be something wrong with the software of your acquaintance.").arg(toAddress))
elif status == 'ripetoolong': elif status == 'ripetoolong':
self.statusBar().showMessage(QtGui.QApplication.translate("MainWindow", "Error: Some data encoded in the address %1 is too long. There might be something wrong with the software of your acquaintance.").arg(toAddress)) self.statusBar().showMessage(QtGui.QApplication.translate(
"MainWindow", "Error: Some data encoded in the address %1 is too long. There might be something wrong with the software of your acquaintance.").arg(toAddress))
else: else:
self.statusBar().showMessage(QtGui.QApplication.translate("MainWindow", "Error: Something is wrong with the address %1.").arg(toAddress)) self.statusBar().showMessage(QtGui.QApplication.translate(
"MainWindow", "Error: Something is wrong with the address %1.").arg(toAddress))
elif fromAddress == '': elif fromAddress == '':
self.statusBar().showMessage(QtGui.QApplication.translate("MainWindow", "Error: You must specify a From address. If you don\'t have one, go to the \'Your Identities\' tab.")) self.statusBar().showMessage(QtGui.QApplication.translate(
"MainWindow", "Error: You must specify a From address. If you don\'t have one, go to the \'Your Identities\' tab."))
else: else:
toAddress = addBMIfNotPresent(toAddress) toAddress = addBMIfNotPresent(toAddress)
try: try:
shared.config.get(toAddress, 'enabled') shared.config.get(toAddress, 'enabled')
#The toAddress is one owned by me. We cannot send messages to ourselves without significant changes to the codebase. # The toAddress is one owned by me. We cannot send
QMessageBox.about(self, QtGui.QApplication.translate("MainWindow", "Sending to your address"), QtGui.QApplication.translate("MainWindow", "Error: One of the addresses to which you are sending a message, %1, is yours. Unfortunately the Bitmessage client cannot process its own messages. Please try running a second client on a different computer or within a VM.").arg(toAddress)) # messages to ourselves without significant changes
# to the codebase.
QMessageBox.about(self, QtGui.QApplication.translate("MainWindow", "Sending to your address"), QtGui.QApplication.translate(
"MainWindow", "Error: One of the addresses to which you are sending a message, %1, is yours. Unfortunately the Bitmessage client cannot process its own messages. Please try running a second client on a different computer or within a VM.").arg(toAddress))
continue continue
except: except:
pass pass
if addressVersionNumber > 3 or addressVersionNumber <= 1: if addressVersionNumber > 3 or addressVersionNumber <= 1:
QMessageBox.about(self, QtGui.QApplication.translate("MainWindow", "Address version number"), QtGui.QApplication.translate("MainWindow", "Concerning the address %1, Bitmessage cannot understand address version numbers of %2. Perhaps upgrade Bitmessage to the latest version.").arg(toAddress).arg(str(addressVersionNumber))) QMessageBox.about(self, QtGui.QApplication.translate("MainWindow", "Address version number"), QtGui.QApplication.translate(
"MainWindow", "Concerning the address %1, Bitmessage cannot understand address version numbers of %2. Perhaps upgrade Bitmessage to the latest version.").arg(toAddress).arg(str(addressVersionNumber)))
continue continue
if streamNumber > 1 or streamNumber == 0: if streamNumber > 1 or streamNumber == 0:
QMessageBox.about(self, QtGui.QApplication.translate("MainWindow", "Stream number"), QtGui.QApplication.translate("MainWindow", "Concerning the address %1, Bitmessage cannot handle stream numbers of %2. Perhaps upgrade Bitmessage to the latest version.").arg(toAddress).arg(str(streamNumber))) QMessageBox.about(self, QtGui.QApplication.translate("MainWindow", "Stream number"), QtGui.QApplication.translate(
"MainWindow", "Concerning the address %1, Bitmessage cannot handle stream numbers of %2. Perhaps upgrade Bitmessage to the latest version.").arg(toAddress).arg(str(streamNumber)))
continue continue
self.statusBar().showMessage('') self.statusBar().showMessage('')
if shared.statusIconColor == 'red': if shared.statusIconColor == 'red':
self.statusBar().showMessage(QtGui.QApplication.translate("MainWindow", "Warning: You are currently not connected. Bitmessage will do the work necessary to send the message but it won\'t send until you connect.")) self.statusBar().showMessage(QtGui.QApplication.translate(
"MainWindow", "Warning: You are currently not connected. Bitmessage will do the work necessary to send the message but it won\'t send until you connect."))
ackdata = OpenSSL.rand(32) ackdata = OpenSSL.rand(32)
shared.sqlLock.acquire() shared.sqlLock.acquire()
t = ('',toAddress,ripe,fromAddress,subject,message,ackdata,int(time.time()),'msgqueued',1,1,'sent',2) t = ('', toAddress, ripe, fromAddress, subject, message, ackdata, int(
shared.sqlSubmitQueue.put('''INSERT INTO sent VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?)''') time.time()), 'msgqueued', 1, 1, 'sent', 2)
shared.sqlSubmitQueue.put(
'''INSERT INTO sent VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?)''')
shared.sqlSubmitQueue.put(t) shared.sqlSubmitQueue.put(t)
shared.sqlReturnQueue.get() shared.sqlReturnQueue.get()
shared.sqlSubmitQueue.put('commit') shared.sqlSubmitQueue.put('commit')
@ -1124,16 +1330,18 @@ class MyForm(QtGui.QMainWindow):
toLabel = '' toLabel = ''
t = (toAddress,) t = (toAddress,)
shared.sqlLock.acquire() shared.sqlLock.acquire()
shared.sqlSubmitQueue.put('''select label from addressbook where address=?''') shared.sqlSubmitQueue.put(
'''select label from addressbook where address=?''')
shared.sqlSubmitQueue.put(t) shared.sqlSubmitQueue.put(t)
queryreturn = shared.sqlReturnQueue.get() queryreturn = shared.sqlReturnQueue.get()
shared.sqlLock.release() shared.sqlLock.release()
if queryreturn <> []: if queryreturn != []:
for row in queryreturn: for row in queryreturn:
toLabel, = row toLabel, = row
self.displayNewSentMessage(toAddress,toLabel,fromAddress, subject, message, ackdata) self.displayNewSentMessage(
shared.workerQueue.put(('sendmessage',toAddress)) toAddress, toLabel, fromAddress, subject, message, ackdata)
shared.workerQueue.put(('sendmessage', toAddress))
self.ui.comboBoxSendFrom.setCurrentIndex(0) self.ui.comboBoxSendFrom.setCurrentIndex(0)
self.ui.labelFrom.setText('') self.ui.labelFrom.setText('')
@ -1141,27 +1349,33 @@ class MyForm(QtGui.QMainWindow):
self.ui.lineEditSubject.setText('') self.ui.lineEditSubject.setText('')
self.ui.textEditMessage.setText('') self.ui.textEditMessage.setText('')
self.ui.tabWidget.setCurrentIndex(2) self.ui.tabWidget.setCurrentIndex(2)
self.ui.tableWidgetSent.setCurrentCell(0,0) self.ui.tableWidgetSent.setCurrentCell(0, 0)
else: else:
self.statusBar().showMessage(QtGui.QApplication.translate("MainWindow", "Your \'To\' field is empty.")) self.statusBar().showMessage(QtGui.QApplication.translate(
else: #User selected 'Broadcast' "MainWindow", "Your \'To\' field is empty."))
else: # User selected 'Broadcast'
if fromAddress == '': if fromAddress == '':
self.statusBar().showMessage(QtGui.QApplication.translate("MainWindow", "Error: You must specify a From address. If you don\'t have one, go to the \'Your Identities\' tab.")) self.statusBar().showMessage(QtGui.QApplication.translate(
"MainWindow", "Error: You must specify a From address. If you don\'t have one, go to the \'Your Identities\' tab."))
else: else:
self.statusBar().showMessage('') self.statusBar().showMessage('')
#We don't actually need the ackdata for acknowledgement since this is a broadcast message, but we can use it to update the user interface when the POW is done generating. # We don't actually need the ackdata for acknowledgement since
# this is a broadcast message, but we can use it to update the
# user interface when the POW is done generating.
ackdata = OpenSSL.rand(32) ackdata = OpenSSL.rand(32)
toAddress = self.str_broadcast_subscribers toAddress = self.str_broadcast_subscribers
ripe = '' ripe = ''
shared.sqlLock.acquire() shared.sqlLock.acquire()
t = ('',toAddress,ripe,fromAddress,subject,message,ackdata,int(time.time()),'broadcastqueued',1,1,'sent',2) t = ('', toAddress, ripe, fromAddress, subject, message, ackdata, int(
shared.sqlSubmitQueue.put('''INSERT INTO sent VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?)''') time.time()), 'broadcastqueued', 1, 1, 'sent', 2)
shared.sqlSubmitQueue.put(
'''INSERT INTO sent VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?)''')
shared.sqlSubmitQueue.put(t) shared.sqlSubmitQueue.put(t)
shared.sqlReturnQueue.get() shared.sqlReturnQueue.get()
shared.sqlSubmitQueue.put('commit') shared.sqlSubmitQueue.put('commit')
shared.sqlLock.release() shared.sqlLock.release()
shared.workerQueue.put(('sendbroadcast','')) shared.workerQueue.put(('sendbroadcast', ''))
try: try:
fromLabel = shared.config.get(fromAddress, 'label') fromLabel = shared.config.get(fromAddress, 'label')
@ -1173,26 +1387,32 @@ class MyForm(QtGui.QMainWindow):
toLabel = self.str_broadcast_subscribers toLabel = self.str_broadcast_subscribers
self.ui.tableWidgetSent.insertRow(0) self.ui.tableWidgetSent.insertRow(0)
newItem = QtGui.QTableWidgetItem(unicode(toLabel,'utf-8')) newItem = QtGui.QTableWidgetItem(unicode(toLabel, 'utf-8'))
newItem.setData(Qt.UserRole,str(toAddress)) newItem.setData(Qt.UserRole, str(toAddress))
self.ui.tableWidgetSent.setItem(0,0,newItem) self.ui.tableWidgetSent.setItem(0, 0, newItem)
if fromLabel == '': if fromLabel == '':
newItem = QtGui.QTableWidgetItem(unicode(fromAddress,'utf-8')) newItem = QtGui.QTableWidgetItem(
unicode(fromAddress, 'utf-8'))
else: else:
newItem = QtGui.QTableWidgetItem(unicode(fromLabel,'utf-8')) newItem = QtGui.QTableWidgetItem(
newItem.setData(Qt.UserRole,str(fromAddress)) unicode(fromLabel, 'utf-8'))
self.ui.tableWidgetSent.setItem(0,1,newItem) newItem.setData(Qt.UserRole, str(fromAddress))
newItem = QtGui.QTableWidgetItem(unicode(subject,'utf-8)')) self.ui.tableWidgetSent.setItem(0, 1, newItem)
newItem.setData(Qt.UserRole,unicode(message,'utf-8)')) newItem = QtGui.QTableWidgetItem(unicode(subject, 'utf-8)'))
self.ui.tableWidgetSent.setItem(0,2,newItem) newItem.setData(Qt.UserRole, unicode(message, 'utf-8)'))
#newItem = QtGui.QTableWidgetItem('Doing work necessary to send broadcast...'+ unicode(strftime(config.get('bitmessagesettings', 'timeformat'),localtime(int(time.time()))),'utf-8')) self.ui.tableWidgetSent.setItem(0, 2, newItem)
newItem = myTableWidgetItem('Work is queued.') # newItem = QtGui.QTableWidgetItem('Doing work necessary to
newItem.setData(Qt.UserRole,QByteArray(ackdata)) # send broadcast...'+
newItem.setData(33,int(time.time())) # unicode(strftime(config.get('bitmessagesettings',
self.ui.tableWidgetSent.setItem(0,3,newItem) # 'timeformat'),localtime(int(time.time()))),'utf-8'))
newItem = myTableWidgetItem('Work is queued.')
newItem.setData(Qt.UserRole, QByteArray(ackdata))
newItem.setData(33, int(time.time()))
self.ui.tableWidgetSent.setItem(0, 3, newItem)
self.ui.textEditSentMessage.setPlainText(self.ui.tableWidgetSent.item(0,2).data(Qt.UserRole).toPyObject()) self.ui.textEditSentMessage.setPlainText(
self.ui.tableWidgetSent.item(0, 2).data(Qt.UserRole).toPyObject())
self.ui.comboBoxSendFrom.setCurrentIndex(0) self.ui.comboBoxSendFrom.setCurrentIndex(0)
self.ui.labelFrom.setText('') self.ui.labelFrom.setText('')
@ -1200,8 +1420,7 @@ class MyForm(QtGui.QMainWindow):
self.ui.lineEditSubject.setText('') self.ui.lineEditSubject.setText('')
self.ui.textEditMessage.setText('') self.ui.textEditMessage.setText('')
self.ui.tabWidget.setCurrentIndex(2) self.ui.tabWidget.setCurrentIndex(2)
self.ui.tableWidgetSent.setCurrentCell(0,0) self.ui.tableWidgetSent.setCurrentCell(0, 0)
def click_pushButtonLoadFromAddressBook(self): def click_pushButtonLoadFromAddressBook(self):
self.ui.tabWidget.setCurrentIndex(5) self.ui.tabWidget.setCurrentIndex(5)
@ -1209,30 +1428,36 @@ class MyForm(QtGui.QMainWindow):
time.sleep(0.1) time.sleep(0.1)
self.statusBar().showMessage('') self.statusBar().showMessage('')
time.sleep(0.1) time.sleep(0.1)
self.statusBar().showMessage(QtGui.QApplication.translate("MainWindow", "Right click one or more entries in your address book and select \'Send message to this address\'.")) self.statusBar().showMessage(QtGui.QApplication.translate(
"MainWindow", "Right click one or more entries in your address book and select \'Send message to this address\'."))
def redrawLabelFrom(self,index): def redrawLabelFrom(self, index):
self.ui.labelFrom.setText(self.ui.comboBoxSendFrom.itemData(index).toPyObject()) self.ui.labelFrom.setText(
self.ui.comboBoxSendFrom.itemData(index).toPyObject())
def rerenderComboBoxSendFrom(self): def rerenderComboBoxSendFrom(self):
self.ui.comboBoxSendFrom.clear() self.ui.comboBoxSendFrom.clear()
self.ui.labelFrom.setText('') self.ui.labelFrom.setText('')
configSections = shared.config.sections() configSections = shared.config.sections()
for addressInKeysFile in configSections: for addressInKeysFile in configSections:
if addressInKeysFile <> 'bitmessagesettings': if addressInKeysFile != 'bitmessagesettings':
isEnabled = shared.config.getboolean(addressInKeysFile, 'enabled') #I realize that this is poor programming practice but I don't care. It's easier for others to read. isEnabled = shared.config.getboolean(
addressInKeysFile, 'enabled') # I realize that this is poor programming practice but I don't care. It's easier for others to read.
if isEnabled: if isEnabled:
self.ui.comboBoxSendFrom.insertItem(0,unicode(shared.config.get(addressInKeysFile, 'label'),'utf-8'),addressInKeysFile) self.ui.comboBoxSendFrom.insertItem(0, unicode(shared.config.get(
self.ui.comboBoxSendFrom.insertItem(0,'','') addressInKeysFile, 'label'), 'utf-8'), addressInKeysFile)
self.ui.comboBoxSendFrom.insertItem(0, '', '')
if(self.ui.comboBoxSendFrom.count() == 2): if(self.ui.comboBoxSendFrom.count() == 2):
self.ui.comboBoxSendFrom.setCurrentIndex(1) self.ui.comboBoxSendFrom.setCurrentIndex(1)
self.redrawLabelFrom(self.ui.comboBoxSendFrom.currentIndex()) self.redrawLabelFrom(self.ui.comboBoxSendFrom.currentIndex())
else: else:
self.ui.comboBoxSendFrom.setCurrentIndex(0) self.ui.comboBoxSendFrom.setCurrentIndex(0)
# This function is called by the processmsg function when that function
#This function is called by the processmsg function when that function receives a message to an address that is acting as a pseudo-mailing-list. The message will be broadcast out. This function puts the message on the 'Sent' tab. # receives a message to an address that is acting as a
def displayNewSentMessage(self,toAddress,toLabel,fromAddress,subject,message,ackdata): # pseudo-mailing-list. The message will be broadcast out. This function
# puts the message on the 'Sent' tab.
def displayNewSentMessage(self, toAddress, toLabel, fromAddress, subject, message, ackdata):
subject = shared.fixPotentiallyInvalidUTF8Data(subject) subject = shared.fixPotentiallyInvalidUTF8Data(subject)
message = shared.fixPotentiallyInvalidUTF8Data(message) message = shared.fixPotentiallyInvalidUTF8Data(message)
try: try:
@ -1245,56 +1470,64 @@ class MyForm(QtGui.QMainWindow):
self.ui.tableWidgetSent.setSortingEnabled(False) self.ui.tableWidgetSent.setSortingEnabled(False)
self.ui.tableWidgetSent.insertRow(0) self.ui.tableWidgetSent.insertRow(0)
if toLabel == '': if toLabel == '':
newItem = QtGui.QTableWidgetItem(unicode(toAddress,'utf-8')) newItem = QtGui.QTableWidgetItem(unicode(toAddress, 'utf-8'))
newItem.setToolTip(unicode(toAddress,'utf-8')) newItem.setToolTip(unicode(toAddress, 'utf-8'))
else: else:
newItem = QtGui.QTableWidgetItem(unicode(toLabel,'utf-8')) newItem = QtGui.QTableWidgetItem(unicode(toLabel, 'utf-8'))
newItem.setToolTip(unicode(toLabel,'utf-8')) newItem.setToolTip(unicode(toLabel, 'utf-8'))
newItem.setData(Qt.UserRole,str(toAddress)) newItem.setData(Qt.UserRole, str(toAddress))
self.ui.tableWidgetSent.setItem(0,0,newItem) self.ui.tableWidgetSent.setItem(0, 0, newItem)
if fromLabel == '': if fromLabel == '':
newItem = QtGui.QTableWidgetItem(unicode(fromAddress,'utf-8')) newItem = QtGui.QTableWidgetItem(unicode(fromAddress, 'utf-8'))
newItem.setToolTip(unicode(fromAddress,'utf-8')) newItem.setToolTip(unicode(fromAddress, 'utf-8'))
else: else:
newItem = QtGui.QTableWidgetItem(unicode(fromLabel,'utf-8')) newItem = QtGui.QTableWidgetItem(unicode(fromLabel, 'utf-8'))
newItem.setToolTip(unicode(fromLabel,'utf-8')) newItem.setToolTip(unicode(fromLabel, 'utf-8'))
newItem.setData(Qt.UserRole,str(fromAddress)) newItem.setData(Qt.UserRole, str(fromAddress))
self.ui.tableWidgetSent.setItem(0,1,newItem) self.ui.tableWidgetSent.setItem(0, 1, newItem)
newItem = QtGui.QTableWidgetItem(unicode(subject,'utf-8)')) newItem = QtGui.QTableWidgetItem(unicode(subject, 'utf-8)'))
newItem.setToolTip(unicode(subject,'utf-8)')) newItem.setToolTip(unicode(subject, 'utf-8)'))
newItem.setData(Qt.UserRole,unicode(message,'utf-8)')) newItem.setData(Qt.UserRole, unicode(message, 'utf-8)'))
self.ui.tableWidgetSent.setItem(0,2,newItem) self.ui.tableWidgetSent.setItem(0, 2, newItem)
#newItem = QtGui.QTableWidgetItem('Doing work necessary to send broadcast...'+ unicode(strftime(shared.config.get('bitmessagesettings', 'timeformat'),localtime(int(time.time()))),'utf-8')) # newItem = QtGui.QTableWidgetItem('Doing work necessary to send
newItem = myTableWidgetItem('Work is queued. '+ unicode(strftime(shared.config.get('bitmessagesettings', 'timeformat'),localtime(int(time.time()))),'utf-8')) # broadcast...'+
newItem.setToolTip('Work is queued. '+ unicode(strftime(shared.config.get('bitmessagesettings', 'timeformat'),localtime(int(time.time()))),'utf-8')) # unicode(strftime(shared.config.get('bitmessagesettings',
newItem.setData(Qt.UserRole,QByteArray(ackdata)) # 'timeformat'),localtime(int(time.time()))),'utf-8'))
newItem.setData(33,int(time.time())) newItem = myTableWidgetItem('Work is queued. ' + unicode(strftime(shared.config.get(
self.ui.tableWidgetSent.setItem(0,3,newItem) 'bitmessagesettings', 'timeformat'), localtime(int(time.time()))), 'utf-8'))
self.ui.textEditSentMessage.setPlainText(self.ui.tableWidgetSent.item(0,2).data(Qt.UserRole).toPyObject()) newItem.setToolTip('Work is queued. ' + unicode(strftime(shared.config.get(
'bitmessagesettings', 'timeformat'), localtime(int(time.time()))), 'utf-8'))
newItem.setData(Qt.UserRole, QByteArray(ackdata))
newItem.setData(33, int(time.time()))
self.ui.tableWidgetSent.setItem(0, 3, newItem)
self.ui.textEditSentMessage.setPlainText(
self.ui.tableWidgetSent.item(0, 2).data(Qt.UserRole).toPyObject())
self.ui.tableWidgetSent.setSortingEnabled(True) self.ui.tableWidgetSent.setSortingEnabled(True)
def displayNewInboxMessage(self,inventoryHash,toAddress,fromAddress,subject,message): def displayNewInboxMessage(self, inventoryHash, toAddress, fromAddress, subject, message):
subject = shared.fixPotentiallyInvalidUTF8Data(subject) subject = shared.fixPotentiallyInvalidUTF8Data(subject)
message = shared.fixPotentiallyInvalidUTF8Data(message) message = shared.fixPotentiallyInvalidUTF8Data(message)
fromLabel = '' fromLabel = ''
shared.sqlLock.acquire() shared.sqlLock.acquire()
t = (fromAddress,) t = (fromAddress,)
shared.sqlSubmitQueue.put('''select label from addressbook where address=?''') shared.sqlSubmitQueue.put(
'''select label from addressbook where address=?''')
shared.sqlSubmitQueue.put(t) shared.sqlSubmitQueue.put(t)
queryreturn = shared.sqlReturnQueue.get() queryreturn = shared.sqlReturnQueue.get()
shared.sqlLock.release() shared.sqlLock.release()
if queryreturn <> []: if queryreturn != []:
for row in queryreturn: for row in queryreturn:
fromLabel, = row fromLabel, = row
else: else:
#There might be a label in the subscriptions table # There might be a label in the subscriptions table
shared.sqlLock.acquire() shared.sqlLock.acquire()
t = (fromAddress,) t = (fromAddress,)
shared.sqlSubmitQueue.put('''select label from subscriptions where address=?''') shared.sqlSubmitQueue.put(
'''select label from subscriptions where address=?''')
shared.sqlSubmitQueue.put(t) shared.sqlSubmitQueue.put(t)
queryreturn = shared.sqlReturnQueue.get() queryreturn = shared.sqlReturnQueue.get()
shared.sqlLock.release() shared.sqlLock.release()
if queryreturn <> []: if queryreturn != []:
for row in queryreturn: for row in queryreturn:
fromLabel, = row fromLabel, = row
@ -1311,39 +1544,41 @@ class MyForm(QtGui.QMainWindow):
font = QFont() font = QFont()
font.setBold(True) font.setBold(True)
self.ui.tableWidgetInbox.setSortingEnabled(False) self.ui.tableWidgetInbox.setSortingEnabled(False)
newItem = QtGui.QTableWidgetItem(unicode(toLabel,'utf-8')) newItem = QtGui.QTableWidgetItem(unicode(toLabel, 'utf-8'))
newItem.setToolTip(unicode(toLabel,'utf-8')) newItem.setToolTip(unicode(toLabel, 'utf-8'))
newItem.setFont(font) newItem.setFont(font)
newItem.setData(Qt.UserRole,str(toAddress)) newItem.setData(Qt.UserRole, str(toAddress))
if shared.safeConfigGetBoolean(str(toAddress),'mailinglist'): if shared.safeConfigGetBoolean(str(toAddress), 'mailinglist'):
newItem.setTextColor(QtGui.QColor(137,04,177)) newItem.setTextColor(QtGui.QColor(137, 04, 177))
self.ui.tableWidgetInbox.insertRow(0) self.ui.tableWidgetInbox.insertRow(0)
self.ui.tableWidgetInbox.setItem(0,0,newItem) self.ui.tableWidgetInbox.setItem(0, 0, newItem)
if fromLabel == '': if fromLabel == '':
newItem = QtGui.QTableWidgetItem(unicode(fromAddress,'utf-8')) newItem = QtGui.QTableWidgetItem(unicode(fromAddress, 'utf-8'))
newItem.setToolTip(unicode(fromAddress,'utf-8')) newItem.setToolTip(unicode(fromAddress, 'utf-8'))
if shared.config.getboolean('bitmessagesettings', 'showtraynotifications'): if shared.config.getboolean('bitmessagesettings', 'showtraynotifications'):
self.notifierShow('New Message', 'From '+ fromAddress) self.notifierShow('New Message', 'From ' + fromAddress)
else: else:
newItem = QtGui.QTableWidgetItem(unicode(fromLabel,'utf-8')) newItem = QtGui.QTableWidgetItem(unicode(fromLabel, 'utf-8'))
newItem.setToolTip(unicode(unicode(fromLabel,'utf-8'))) newItem.setToolTip(unicode(unicode(fromLabel, 'utf-8')))
if shared.config.getboolean('bitmessagesettings', 'showtraynotifications'): if shared.config.getboolean('bitmessagesettings', 'showtraynotifications'):
self.notifierShow('New Message', 'From ' + fromLabel) self.notifierShow('New Message', 'From ' + fromLabel)
newItem.setData(Qt.UserRole,str(fromAddress)) newItem.setData(Qt.UserRole, str(fromAddress))
newItem.setFont(font) newItem.setFont(font)
self.ui.tableWidgetInbox.setItem(0,1,newItem) self.ui.tableWidgetInbox.setItem(0, 1, newItem)
newItem = QtGui.QTableWidgetItem(unicode(subject,'utf-8)')) newItem = QtGui.QTableWidgetItem(unicode(subject, 'utf-8)'))
newItem.setToolTip(unicode(subject,'utf-8)')) newItem.setToolTip(unicode(subject, 'utf-8)'))
newItem.setData(Qt.UserRole,unicode(message,'utf-8)')) newItem.setData(Qt.UserRole, unicode(message, 'utf-8)'))
newItem.setFont(font) newItem.setFont(font)
self.ui.tableWidgetInbox.setItem(0,2,newItem) self.ui.tableWidgetInbox.setItem(0, 2, newItem)
newItem = myTableWidgetItem(unicode(strftime(shared.config.get('bitmessagesettings', 'timeformat'),localtime(int(time.time()))),'utf-8')) newItem = myTableWidgetItem(unicode(strftime(shared.config.get(
newItem.setToolTip(unicode(strftime(shared.config.get('bitmessagesettings', 'timeformat'),localtime(int(time.time()))),'utf-8')) 'bitmessagesettings', 'timeformat'), localtime(int(time.time()))), 'utf-8'))
newItem.setData(Qt.UserRole,QByteArray(inventoryHash)) newItem.setToolTip(unicode(strftime(shared.config.get(
newItem.setData(33,int(time.time())) 'bitmessagesettings', 'timeformat'), localtime(int(time.time()))), 'utf-8'))
newItem.setData(Qt.UserRole, QByteArray(inventoryHash))
newItem.setData(33, int(time.time()))
newItem.setFont(font) newItem.setFont(font)
self.ui.tableWidgetInbox.setItem(0,3,newItem) self.ui.tableWidgetInbox.setItem(0, 3, newItem)
self.ui.tableWidgetInbox.setSortingEnabled(True) self.ui.tableWidgetInbox.setSortingEnabled(True)
self.ubuntuMessagingMenuUpdate(True, newItem, toLabel) self.ubuntuMessagingMenuUpdate(True, newItem, toLabel)
@ -1351,25 +1586,34 @@ class MyForm(QtGui.QMainWindow):
self.NewSubscriptionDialogInstance = NewSubscriptionDialog(self) self.NewSubscriptionDialogInstance = NewSubscriptionDialog(self)
if self.NewSubscriptionDialogInstance.exec_(): if self.NewSubscriptionDialogInstance.exec_():
if self.NewSubscriptionDialogInstance.ui.labelSubscriptionAddressCheck.text() == 'Address is valid.': if self.NewSubscriptionDialogInstance.ui.labelSubscriptionAddressCheck.text() == 'Address is valid.':
#First we must check to see if the address is already in the address book. The user cannot add it again or else it will cause problems when updating and deleting the entry. # First we must check to see if the address is already in the
# address book. The user cannot add it again or else it will
# cause problems when updating and deleting the entry.
shared.sqlLock.acquire() shared.sqlLock.acquire()
t = (addBMIfNotPresent(str(self.NewSubscriptionDialogInstance.ui.lineEditSubscriptionAddress.text())),) t = (addBMIfNotPresent(str(
shared.sqlSubmitQueue.put('''select * from addressbook where address=?''') self.NewSubscriptionDialogInstance.ui.lineEditSubscriptionAddress.text())),)
shared.sqlSubmitQueue.put(
'''select * from addressbook where address=?''')
shared.sqlSubmitQueue.put(t) shared.sqlSubmitQueue.put(t)
queryreturn = shared.sqlReturnQueue.get() queryreturn = shared.sqlReturnQueue.get()
shared.sqlLock.release() shared.sqlLock.release()
if queryreturn == []: if queryreturn == []:
self.ui.tableWidgetAddressBook.setSortingEnabled(False) self.ui.tableWidgetAddressBook.setSortingEnabled(False)
self.ui.tableWidgetAddressBook.insertRow(0) self.ui.tableWidgetAddressBook.insertRow(0)
newItem = QtGui.QTableWidgetItem(unicode(self.NewSubscriptionDialogInstance.ui.newsubscriptionlabel.text().toUtf8(),'utf-8')) newItem = QtGui.QTableWidgetItem(unicode(
self.ui.tableWidgetAddressBook.setItem(0,0,newItem) self.NewSubscriptionDialogInstance.ui.newsubscriptionlabel.text().toUtf8(), 'utf-8'))
newItem = QtGui.QTableWidgetItem(addBMIfNotPresent(self.NewSubscriptionDialogInstance.ui.lineEditSubscriptionAddress.text())) self.ui.tableWidgetAddressBook.setItem(0, 0, newItem)
newItem.setFlags( QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled ) newItem = QtGui.QTableWidgetItem(addBMIfNotPresent(
self.ui.tableWidgetAddressBook.setItem(0,1,newItem) self.NewSubscriptionDialogInstance.ui.lineEditSubscriptionAddress.text()))
newItem.setFlags(
QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled)
self.ui.tableWidgetAddressBook.setItem(0, 1, newItem)
self.ui.tableWidgetAddressBook.setSortingEnabled(True) self.ui.tableWidgetAddressBook.setSortingEnabled(True)
t = (str(self.NewSubscriptionDialogInstance.ui.newsubscriptionlabel.text().toUtf8()),addBMIfNotPresent(str(self.NewSubscriptionDialogInstance.ui.lineEditSubscriptionAddress.text()))) t = (str(self.NewSubscriptionDialogInstance.ui.newsubscriptionlabel.text().toUtf8()), addBMIfNotPresent(
str(self.NewSubscriptionDialogInstance.ui.lineEditSubscriptionAddress.text())))
shared.sqlLock.acquire() shared.sqlLock.acquire()
shared.sqlSubmitQueue.put('''INSERT INTO addressbook VALUES (?,?)''') shared.sqlSubmitQueue.put(
'''INSERT INTO addressbook VALUES (?,?)''')
shared.sqlSubmitQueue.put(t) shared.sqlSubmitQueue.put(t)
queryreturn = shared.sqlReturnQueue.get() queryreturn = shared.sqlReturnQueue.get()
shared.sqlSubmitQueue.put('commit') shared.sqlSubmitQueue.put('commit')
@ -1377,34 +1621,45 @@ class MyForm(QtGui.QMainWindow):
self.rerenderInboxFromLabels() self.rerenderInboxFromLabels()
self.rerenderSentToLabels() self.rerenderSentToLabels()
else: else:
self.statusBar().showMessage(QtGui.QApplication.translate("MainWindow", "Error: You cannot add the same address to your address book twice. Try renaming the existing one if you want.")) self.statusBar().showMessage(QtGui.QApplication.translate(
"MainWindow", "Error: You cannot add the same address to your address book twice. Try renaming the existing one if you want."))
else: else:
self.statusBar().showMessage(QtGui.QApplication.translate("MainWindow", "The address you entered was invalid. Ignoring it.")) self.statusBar().showMessage(QtGui.QApplication.translate(
"MainWindow", "The address you entered was invalid. Ignoring it."))
def click_pushButtonAddSubscription(self): def click_pushButtonAddSubscription(self):
self.NewSubscriptionDialogInstance = NewSubscriptionDialog(self) self.NewSubscriptionDialogInstance = NewSubscriptionDialog(self)
if self.NewSubscriptionDialogInstance.exec_(): if self.NewSubscriptionDialogInstance.exec_():
if self.NewSubscriptionDialogInstance.ui.labelSubscriptionAddressCheck.text() == 'Address is valid.': if self.NewSubscriptionDialogInstance.ui.labelSubscriptionAddressCheck.text() == 'Address is valid.':
#First we must check to see if the address is already in the subscriptions list. The user cannot add it again or else it will cause problems when updating and deleting the entry. # First we must check to see if the address is already in the
# subscriptions list. The user cannot add it again or else it
# will cause problems when updating and deleting the entry.
shared.sqlLock.acquire() shared.sqlLock.acquire()
t = (addBMIfNotPresent(str(self.NewSubscriptionDialogInstance.ui.lineEditSubscriptionAddress.text())),) t = (addBMIfNotPresent(str(
shared.sqlSubmitQueue.put('''select * from subscriptions where address=?''') self.NewSubscriptionDialogInstance.ui.lineEditSubscriptionAddress.text())),)
shared.sqlSubmitQueue.put(
'''select * from subscriptions where address=?''')
shared.sqlSubmitQueue.put(t) shared.sqlSubmitQueue.put(t)
queryreturn = shared.sqlReturnQueue.get() queryreturn = shared.sqlReturnQueue.get()
shared.sqlLock.release() shared.sqlLock.release()
if queryreturn == []: if queryreturn == []:
self.ui.tableWidgetSubscriptions.setSortingEnabled(False) self.ui.tableWidgetSubscriptions.setSortingEnabled(False)
self.ui.tableWidgetSubscriptions.insertRow(0) self.ui.tableWidgetSubscriptions.insertRow(0)
newItem = QtGui.QTableWidgetItem(unicode(self.NewSubscriptionDialogInstance.ui.newsubscriptionlabel.text().toUtf8(),'utf-8')) newItem = QtGui.QTableWidgetItem(unicode(
self.ui.tableWidgetSubscriptions.setItem(0,0,newItem) self.NewSubscriptionDialogInstance.ui.newsubscriptionlabel.text().toUtf8(), 'utf-8'))
newItem = QtGui.QTableWidgetItem(addBMIfNotPresent(self.NewSubscriptionDialogInstance.ui.lineEditSubscriptionAddress.text())) self.ui.tableWidgetSubscriptions.setItem(0, 0, newItem)
newItem.setFlags( QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled ) newItem = QtGui.QTableWidgetItem(addBMIfNotPresent(
self.ui.tableWidgetSubscriptions.setItem(0,1,newItem) self.NewSubscriptionDialogInstance.ui.lineEditSubscriptionAddress.text()))
newItem.setFlags(
QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled)
self.ui.tableWidgetSubscriptions.setItem(0, 1, newItem)
self.ui.tableWidgetSubscriptions.setSortingEnabled(True) self.ui.tableWidgetSubscriptions.setSortingEnabled(True)
t = (str(self.NewSubscriptionDialogInstance.ui.newsubscriptionlabel.text().toUtf8()),addBMIfNotPresent(str(self.NewSubscriptionDialogInstance.ui.lineEditSubscriptionAddress.text())),True) t = (str(self.NewSubscriptionDialogInstance.ui.newsubscriptionlabel.text().toUtf8()), addBMIfNotPresent(
str(self.NewSubscriptionDialogInstance.ui.lineEditSubscriptionAddress.text())), True)
shared.sqlLock.acquire() shared.sqlLock.acquire()
shared.sqlSubmitQueue.put('''INSERT INTO subscriptions VALUES (?,?,?)''') shared.sqlSubmitQueue.put(
'''INSERT INTO subscriptions VALUES (?,?,?)''')
shared.sqlSubmitQueue.put(t) shared.sqlSubmitQueue.put(t)
queryreturn = shared.sqlReturnQueue.get() queryreturn = shared.sqlReturnQueue.get()
shared.sqlSubmitQueue.put('commit') shared.sqlSubmitQueue.put('commit')
@ -1412,33 +1667,38 @@ class MyForm(QtGui.QMainWindow):
self.rerenderInboxFromLabels() self.rerenderInboxFromLabels()
shared.reloadBroadcastSendersForWhichImWatching() shared.reloadBroadcastSendersForWhichImWatching()
else: else:
self.statusBar().showMessage(QtGui.QApplication.translate("MainWindow", "Error: You cannot add the same address to your subsciptions twice. Perhaps rename the existing one if you want.")) self.statusBar().showMessage(QtGui.QApplication.translate(
"MainWindow", "Error: You cannot add the same address to your subsciptions twice. Perhaps rename the existing one if you want."))
else: else:
self.statusBar().showMessage(QtGui.QApplication.translate("MainWindow", "The address you entered was invalid. Ignoring it.")) self.statusBar().showMessage(QtGui.QApplication.translate(
"MainWindow", "The address you entered was invalid. Ignoring it."))
def loadBlackWhiteList(self): def loadBlackWhiteList(self):
#Initialize the Blacklist or Whitelist table # Initialize the Blacklist or Whitelist table
listType = shared.config.get('bitmessagesettings', 'blackwhitelist') listType = shared.config.get('bitmessagesettings', 'blackwhitelist')
shared.sqlLock.acquire() shared.sqlLock.acquire()
if listType == 'black': if listType == 'black':
shared.sqlSubmitQueue.put('''SELECT label, address, enabled FROM blacklist''') shared.sqlSubmitQueue.put(
'''SELECT label, address, enabled FROM blacklist''')
else: else:
shared.sqlSubmitQueue.put('''SELECT label, address, enabled FROM whitelist''') shared.sqlSubmitQueue.put(
'''SELECT label, address, enabled FROM whitelist''')
shared.sqlSubmitQueue.put('') shared.sqlSubmitQueue.put('')
queryreturn = shared.sqlReturnQueue.get() queryreturn = shared.sqlReturnQueue.get()
shared.sqlLock.release() shared.sqlLock.release()
for row in queryreturn: for row in queryreturn:
label, address, enabled = row label, address, enabled = row
self.ui.tableWidgetBlacklist.insertRow(0) self.ui.tableWidgetBlacklist.insertRow(0)
newItem = QtGui.QTableWidgetItem(unicode(label,'utf-8')) newItem = QtGui.QTableWidgetItem(unicode(label, 'utf-8'))
if not enabled: if not enabled:
newItem.setTextColor(QtGui.QColor(128,128,128)) newItem.setTextColor(QtGui.QColor(128, 128, 128))
self.ui.tableWidgetBlacklist.setItem(0,0,newItem) self.ui.tableWidgetBlacklist.setItem(0, 0, newItem)
newItem = QtGui.QTableWidgetItem(address) newItem = QtGui.QTableWidgetItem(address)
newItem.setFlags( QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled ) newItem.setFlags(
QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled)
if not enabled: if not enabled:
newItem.setTextColor(QtGui.QColor(128,128,128)) newItem.setTextColor(QtGui.QColor(128, 128, 128))
self.ui.tableWidgetBlacklist.setItem(0,1,newItem) self.ui.tableWidgetBlacklist.setItem(0, 1, newItem)
def click_pushButtonStatusIcon(self): def click_pushButtonStatusIcon(self):
print 'click_pushButtonStatusIcon' print 'click_pushButtonStatusIcon'
@ -1457,64 +1717,82 @@ class MyForm(QtGui.QMainWindow):
def click_actionSettings(self): def click_actionSettings(self):
self.settingsDialogInstance = settingsDialog(self) self.settingsDialogInstance = settingsDialog(self)
if self.settingsDialogInstance.exec_(): if self.settingsDialogInstance.exec_():
shared.config.set('bitmessagesettings', 'startonlogon', str(self.settingsDialogInstance.ui.checkBoxStartOnLogon.isChecked())) shared.config.set('bitmessagesettings', 'startonlogon', str(
shared.config.set('bitmessagesettings', 'minimizetotray', str(self.settingsDialogInstance.ui.checkBoxMinimizeToTray.isChecked())) self.settingsDialogInstance.ui.checkBoxStartOnLogon.isChecked()))
shared.config.set('bitmessagesettings', 'showtraynotifications', str(self.settingsDialogInstance.ui.checkBoxShowTrayNotifications.isChecked())) shared.config.set('bitmessagesettings', 'minimizetotray', str(
shared.config.set('bitmessagesettings', 'startintray', str(self.settingsDialogInstance.ui.checkBoxStartInTray.isChecked())) self.settingsDialogInstance.ui.checkBoxMinimizeToTray.isChecked()))
if int(shared.config.get('bitmessagesettings','port')) != int(self.settingsDialogInstance.ui.lineEditTCPPort.text()): shared.config.set('bitmessagesettings', 'showtraynotifications', str(
QMessageBox.about(self, QtGui.QApplication.translate("MainWindow", "Restart"), QtGui.QApplication.translate("MainWindow", "You must restart Bitmessage for the port number change to take effect.")) self.settingsDialogInstance.ui.checkBoxShowTrayNotifications.isChecked()))
shared.config.set('bitmessagesettings', 'port', str(self.settingsDialogInstance.ui.lineEditTCPPort.text())) shared.config.set('bitmessagesettings', 'startintray', str(
self.settingsDialogInstance.ui.checkBoxStartInTray.isChecked()))
if int(shared.config.get('bitmessagesettings', 'port')) != int(self.settingsDialogInstance.ui.lineEditTCPPort.text()):
QMessageBox.about(self, QtGui.QApplication.translate("MainWindow", "Restart"), QtGui.QApplication.translate(
"MainWindow", "You must restart Bitmessage for the port number change to take effect."))
shared.config.set('bitmessagesettings', 'port', str(
self.settingsDialogInstance.ui.lineEditTCPPort.text()))
if shared.config.get('bitmessagesettings', 'socksproxytype') == 'none' and str(self.settingsDialogInstance.ui.comboBoxProxyType.currentText())[0:5] == 'SOCKS': if shared.config.get('bitmessagesettings', 'socksproxytype') == 'none' and str(self.settingsDialogInstance.ui.comboBoxProxyType.currentText())[0:5] == 'SOCKS':
if shared.statusIconColor != 'red': if shared.statusIconColor != 'red':
QMessageBox.about(self, QtGui.QApplication.translate("MainWindow", "Restart"), QtGui.QApplication.translate("MainWindow", "Bitmessage will use your proxy from now on now but you may want to manually restart Bitmessage now to close existing connections.")) QMessageBox.about(self, QtGui.QApplication.translate("MainWindow", "Restart"), QtGui.QApplication.translate(
"MainWindow", "Bitmessage will use your proxy from now on now but you may want to manually restart Bitmessage now to close existing connections."))
if shared.config.get('bitmessagesettings', 'socksproxytype')[0:5] == 'SOCKS' and str(self.settingsDialogInstance.ui.comboBoxProxyType.currentText()) == 'none': if shared.config.get('bitmessagesettings', 'socksproxytype')[0:5] == 'SOCKS' and str(self.settingsDialogInstance.ui.comboBoxProxyType.currentText()) == 'none':
self.statusBar().showMessage('') self.statusBar().showMessage('')
shared.config.set('bitmessagesettings', 'socksproxytype', str(self.settingsDialogInstance.ui.comboBoxProxyType.currentText())) shared.config.set('bitmessagesettings', 'socksproxytype', str(
shared.config.set('bitmessagesettings', 'socksauthentication', str(self.settingsDialogInstance.ui.checkBoxAuthentication.isChecked())) self.settingsDialogInstance.ui.comboBoxProxyType.currentText()))
shared.config.set('bitmessagesettings', 'sockshostname', str(self.settingsDialogInstance.ui.lineEditSocksHostname.text())) shared.config.set('bitmessagesettings', 'socksauthentication', str(
shared.config.set('bitmessagesettings', 'socksport', str(self.settingsDialogInstance.ui.lineEditSocksPort.text())) self.settingsDialogInstance.ui.checkBoxAuthentication.isChecked()))
shared.config.set('bitmessagesettings', 'socksusername', str(self.settingsDialogInstance.ui.lineEditSocksUsername.text())) shared.config.set('bitmessagesettings', 'sockshostname', str(
shared.config.set('bitmessagesettings', 'sockspassword', str(self.settingsDialogInstance.ui.lineEditSocksPassword.text())) self.settingsDialogInstance.ui.lineEditSocksHostname.text()))
shared.config.set('bitmessagesettings', 'socksport', str(
self.settingsDialogInstance.ui.lineEditSocksPort.text()))
shared.config.set('bitmessagesettings', 'socksusername', str(
self.settingsDialogInstance.ui.lineEditSocksUsername.text()))
shared.config.set('bitmessagesettings', 'sockspassword', str(
self.settingsDialogInstance.ui.lineEditSocksPassword.text()))
if float(self.settingsDialogInstance.ui.lineEditTotalDifficulty.text()) >= 1: if float(self.settingsDialogInstance.ui.lineEditTotalDifficulty.text()) >= 1:
shared.config.set('bitmessagesettings', 'defaultnoncetrialsperbyte',str(int(float(self.settingsDialogInstance.ui.lineEditTotalDifficulty.text())*shared.networkDefaultProofOfWorkNonceTrialsPerByte))) shared.config.set('bitmessagesettings', 'defaultnoncetrialsperbyte', str(int(float(
self.settingsDialogInstance.ui.lineEditTotalDifficulty.text()) * shared.networkDefaultProofOfWorkNonceTrialsPerByte)))
if float(self.settingsDialogInstance.ui.lineEditSmallMessageDifficulty.text()) >= 1: if float(self.settingsDialogInstance.ui.lineEditSmallMessageDifficulty.text()) >= 1:
shared.config.set('bitmessagesettings', 'defaultpayloadlengthextrabytes',str(int(float(self.settingsDialogInstance.ui.lineEditSmallMessageDifficulty.text())*shared.networkDefaultPayloadLengthExtraBytes))) shared.config.set('bitmessagesettings', 'defaultpayloadlengthextrabytes', str(int(float(
self.settingsDialogInstance.ui.lineEditSmallMessageDifficulty.text()) * shared.networkDefaultPayloadLengthExtraBytes)))
if float(self.settingsDialogInstance.ui.lineEditMaxAcceptableTotalDifficulty.text()) >= 1 or float(self.settingsDialogInstance.ui.lineEditMaxAcceptableTotalDifficulty.text()) == 0: if float(self.settingsDialogInstance.ui.lineEditMaxAcceptableTotalDifficulty.text()) >= 1 or float(self.settingsDialogInstance.ui.lineEditMaxAcceptableTotalDifficulty.text()) == 0:
shared.config.set('bitmessagesettings', 'maxacceptablenoncetrialsperbyte',str(int(float(self.settingsDialogInstance.ui.lineEditMaxAcceptableTotalDifficulty.text())*shared.networkDefaultProofOfWorkNonceTrialsPerByte))) shared.config.set('bitmessagesettings', 'maxacceptablenoncetrialsperbyte', str(int(float(
self.settingsDialogInstance.ui.lineEditMaxAcceptableTotalDifficulty.text()) * shared.networkDefaultProofOfWorkNonceTrialsPerByte)))
if float(self.settingsDialogInstance.ui.lineEditMaxAcceptableSmallMessageDifficulty.text()) >= 1 or float(self.settingsDialogInstance.ui.lineEditMaxAcceptableSmallMessageDifficulty.text()) == 0: if float(self.settingsDialogInstance.ui.lineEditMaxAcceptableSmallMessageDifficulty.text()) >= 1 or float(self.settingsDialogInstance.ui.lineEditMaxAcceptableSmallMessageDifficulty.text()) == 0:
shared.config.set('bitmessagesettings', 'maxacceptablepayloadlengthextrabytes',str(int(float(self.settingsDialogInstance.ui.lineEditMaxAcceptableSmallMessageDifficulty.text())*shared.networkDefaultPayloadLengthExtraBytes))) shared.config.set('bitmessagesettings', 'maxacceptablepayloadlengthextrabytes', str(int(float(
self.settingsDialogInstance.ui.lineEditMaxAcceptableSmallMessageDifficulty.text()) * shared.networkDefaultPayloadLengthExtraBytes)))
#if str(self.settingsDialogInstance.ui.comboBoxMaxCores.currentText()) == 'All': # if str(self.settingsDialogInstance.ui.comboBoxMaxCores.currentText()) == 'All':
# shared.config.set('bitmessagesettings', 'maxcores', '99999') # shared.config.set('bitmessagesettings', 'maxcores', '99999')
#else: # else:
# shared.config.set('bitmessagesettings', 'maxcores', str(self.settingsDialogInstance.ui.comboBoxMaxCores.currentText())) # shared.config.set('bitmessagesettings', 'maxcores',
# str(self.settingsDialogInstance.ui.comboBoxMaxCores.currentText()))
with open(shared.appdata + 'keys.dat', 'wb') as configfile: with open(shared.appdata + 'keys.dat', 'wb') as configfile:
shared.config.write(configfile) shared.config.write(configfile)
if 'win32' in sys.platform or 'win64' in sys.platform: if 'win32' in sys.platform or 'win64' in sys.platform:
#Auto-startup for Windows # Auto-startup for Windows
RUN_PATH = "HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Run" RUN_PATH = "HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Run"
self.settings = QSettings(RUN_PATH, QSettings.NativeFormat) self.settings = QSettings(RUN_PATH, QSettings.NativeFormat)
if shared.config.getboolean('bitmessagesettings', 'startonlogon'): if shared.config.getboolean('bitmessagesettings', 'startonlogon'):
self.settings.setValue("PyBitmessage",sys.argv[0]) self.settings.setValue("PyBitmessage", sys.argv[0])
else: else:
self.settings.remove("PyBitmessage") self.settings.remove("PyBitmessage")
elif 'darwin' in sys.platform: elif 'darwin' in sys.platform:
#startup for mac # startup for mac
pass pass
elif 'linux' in sys.platform: elif 'linux' in sys.platform:
#startup for linux # startup for linux
pass pass
if shared.appdata != '' and self.settingsDialogInstance.ui.checkBoxPortableMode.isChecked(): #If we are NOT using portable mode now but the user selected that we should... if shared.appdata != '' and self.settingsDialogInstance.ui.checkBoxPortableMode.isChecked(): # If we are NOT using portable mode now but the user selected that we should...
#Write the keys.dat file to disk in the new location # Write the keys.dat file to disk in the new location
shared.sqlLock.acquire() shared.sqlLock.acquire()
shared.sqlSubmitQueue.put('movemessagstoprog') shared.sqlSubmitQueue.put('movemessagstoprog')
shared.sqlLock.release() shared.sqlLock.release()
with open('keys.dat', 'wb') as configfile: with open('keys.dat', 'wb') as configfile:
shared.config.write(configfile) shared.config.write(configfile)
#Write the knownnodes.dat file to disk in the new location # Write the knownnodes.dat file to disk in the new location
shared.knownNodesLock.acquire() shared.knownNodesLock.acquire()
output = open('knownnodes.dat', 'wb') output = open('knownnodes.dat', 'wb')
pickle.dump(shared.knownNodes, output) pickle.dump(shared.knownNodes, output)
@ -1524,17 +1802,17 @@ class MyForm(QtGui.QMainWindow):
os.remove(shared.appdata + 'knownnodes.dat') os.remove(shared.appdata + 'knownnodes.dat')
shared.appdata = '' shared.appdata = ''
if shared.appdata == '' and not self.settingsDialogInstance.ui.checkBoxPortableMode.isChecked(): #If we ARE using portable mode now but the user selected that we shouldn't... if shared.appdata == '' and not self.settingsDialogInstance.ui.checkBoxPortableMode.isChecked(): # If we ARE using portable mode now but the user selected that we shouldn't...
shared.appdata = shared.lookupAppdataFolder() shared.appdata = shared.lookupAppdataFolder()
if not os.path.exists(shared.appdata): if not os.path.exists(shared.appdata):
os.makedirs(shared.appdata) os.makedirs(shared.appdata)
shared.sqlLock.acquire() shared.sqlLock.acquire()
shared.sqlSubmitQueue.put('movemessagstoappdata') shared.sqlSubmitQueue.put('movemessagstoappdata')
shared.sqlLock.release() shared.sqlLock.release()
#Write the keys.dat file to disk in the new location # Write the keys.dat file to disk in the new location
with open(shared.appdata + 'keys.dat', 'wb') as configfile: with open(shared.appdata + 'keys.dat', 'wb') as configfile:
shared.config.write(configfile) shared.config.write(configfile)
#Write the knownnodes.dat file to disk in the new location # Write the knownnodes.dat file to disk in the new location
shared.knownNodesLock.acquire() shared.knownNodesLock.acquire()
output = open(shared.appdata + 'knownnodes.dat', 'wb') output = open(shared.appdata + 'knownnodes.dat', 'wb')
pickle.dump(shared.knownNodes, output) pickle.dump(shared.knownNodes, output)
@ -1543,123 +1821,144 @@ class MyForm(QtGui.QMainWindow):
os.remove('keys.dat') os.remove('keys.dat')
os.remove('knownnodes.dat') os.remove('knownnodes.dat')
def click_radioButtonBlacklist(self): def click_radioButtonBlacklist(self):
if shared.config.get('bitmessagesettings', 'blackwhitelist') == 'white': if shared.config.get('bitmessagesettings', 'blackwhitelist') == 'white':
shared.config.set('bitmessagesettings','blackwhitelist','black') shared.config.set('bitmessagesettings', 'blackwhitelist', 'black')
with open(shared.appdata + 'keys.dat', 'wb') as configfile: with open(shared.appdata + 'keys.dat', 'wb') as configfile:
shared.config.write(configfile) shared.config.write(configfile)
#self.ui.tableWidgetBlacklist.clearContents() # self.ui.tableWidgetBlacklist.clearContents()
self.ui.tableWidgetBlacklist.setRowCount(0) self.ui.tableWidgetBlacklist.setRowCount(0)
self.loadBlackWhiteList() self.loadBlackWhiteList()
self.ui.tabWidget.setTabText(6,'Blacklist') self.ui.tabWidget.setTabText(6, 'Blacklist')
def click_radioButtonWhitelist(self): def click_radioButtonWhitelist(self):
if shared.config.get('bitmessagesettings', 'blackwhitelist') == 'black': if shared.config.get('bitmessagesettings', 'blackwhitelist') == 'black':
shared.config.set('bitmessagesettings','blackwhitelist','white') shared.config.set('bitmessagesettings', 'blackwhitelist', 'white')
with open(shared.appdata + 'keys.dat', 'wb') as configfile: with open(shared.appdata + 'keys.dat', 'wb') as configfile:
shared.config.write(configfile) shared.config.write(configfile)
#self.ui.tableWidgetBlacklist.clearContents() # self.ui.tableWidgetBlacklist.clearContents()
self.ui.tableWidgetBlacklist.setRowCount(0) self.ui.tableWidgetBlacklist.setRowCount(0)
self.loadBlackWhiteList() self.loadBlackWhiteList()
self.ui.tabWidget.setTabText(6,'Whitelist') self.ui.tabWidget.setTabText(6, 'Whitelist')
def click_pushButtonAddBlacklist(self): def click_pushButtonAddBlacklist(self):
self.NewBlacklistDialogInstance = NewSubscriptionDialog(self) self.NewBlacklistDialogInstance = NewSubscriptionDialog(self)
if self.NewBlacklistDialogInstance.exec_(): if self.NewBlacklistDialogInstance.exec_():
if self.NewBlacklistDialogInstance.ui.labelSubscriptionAddressCheck.text() == 'Address is valid.': if self.NewBlacklistDialogInstance.ui.labelSubscriptionAddressCheck.text() == 'Address is valid.':
#First we must check to see if the address is already in the address book. The user cannot add it again or else it will cause problems when updating and deleting the entry. # First we must check to see if the address is already in the
# address book. The user cannot add it again or else it will
# cause problems when updating and deleting the entry.
shared.sqlLock.acquire() shared.sqlLock.acquire()
t = (addBMIfNotPresent(str(self.NewBlacklistDialogInstance.ui.lineEditSubscriptionAddress.text())),) t = (addBMIfNotPresent(str(
self.NewBlacklistDialogInstance.ui.lineEditSubscriptionAddress.text())),)
if shared.config.get('bitmessagesettings', 'blackwhitelist') == 'black': if shared.config.get('bitmessagesettings', 'blackwhitelist') == 'black':
shared.sqlSubmitQueue.put('''select * from blacklist where address=?''') shared.sqlSubmitQueue.put(
'''select * from blacklist where address=?''')
else: else:
shared.sqlSubmitQueue.put('''select * from whitelist where address=?''') shared.sqlSubmitQueue.put(
'''select * from whitelist where address=?''')
shared.sqlSubmitQueue.put(t) shared.sqlSubmitQueue.put(t)
queryreturn = shared.sqlReturnQueue.get() queryreturn = shared.sqlReturnQueue.get()
shared.sqlLock.release() shared.sqlLock.release()
if queryreturn == []: if queryreturn == []:
self.ui.tableWidgetBlacklist.setSortingEnabled(False) self.ui.tableWidgetBlacklist.setSortingEnabled(False)
self.ui.tableWidgetBlacklist.insertRow(0) self.ui.tableWidgetBlacklist.insertRow(0)
newItem = QtGui.QTableWidgetItem(unicode(self.NewBlacklistDialogInstance.ui.newsubscriptionlabel.text().toUtf8(),'utf-8')) newItem = QtGui.QTableWidgetItem(unicode(
self.ui.tableWidgetBlacklist.setItem(0,0,newItem) self.NewBlacklistDialogInstance.ui.newsubscriptionlabel.text().toUtf8(), 'utf-8'))
newItem = QtGui.QTableWidgetItem(addBMIfNotPresent(self.NewBlacklistDialogInstance.ui.lineEditSubscriptionAddress.text())) self.ui.tableWidgetBlacklist.setItem(0, 0, newItem)
newItem.setFlags( QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled ) newItem = QtGui.QTableWidgetItem(addBMIfNotPresent(
self.ui.tableWidgetBlacklist.setItem(0,1,newItem) self.NewBlacklistDialogInstance.ui.lineEditSubscriptionAddress.text()))
newItem.setFlags(
QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled)
self.ui.tableWidgetBlacklist.setItem(0, 1, newItem)
self.ui.tableWidgetBlacklist.setSortingEnabled(True) self.ui.tableWidgetBlacklist.setSortingEnabled(True)
t = (str(self.NewBlacklistDialogInstance.ui.newsubscriptionlabel.text().toUtf8()),addBMIfNotPresent(str(self.NewBlacklistDialogInstance.ui.lineEditSubscriptionAddress.text())),True) t = (str(self.NewBlacklistDialogInstance.ui.newsubscriptionlabel.text().toUtf8()), addBMIfNotPresent(
str(self.NewBlacklistDialogInstance.ui.lineEditSubscriptionAddress.text())), True)
shared.sqlLock.acquire() shared.sqlLock.acquire()
if shared.config.get('bitmessagesettings', 'blackwhitelist') == 'black': if shared.config.get('bitmessagesettings', 'blackwhitelist') == 'black':
shared.sqlSubmitQueue.put('''INSERT INTO blacklist VALUES (?,?,?)''') shared.sqlSubmitQueue.put(
'''INSERT INTO blacklist VALUES (?,?,?)''')
else: else:
shared.sqlSubmitQueue.put('''INSERT INTO whitelist VALUES (?,?,?)''') shared.sqlSubmitQueue.put(
'''INSERT INTO whitelist VALUES (?,?,?)''')
shared.sqlSubmitQueue.put(t) shared.sqlSubmitQueue.put(t)
queryreturn = shared.sqlReturnQueue.get() queryreturn = shared.sqlReturnQueue.get()
shared.sqlSubmitQueue.put('commit') shared.sqlSubmitQueue.put('commit')
shared.sqlLock.release() shared.sqlLock.release()
else: else:
self.statusBar().showMessage(QtGui.QApplication.translate("MainWindow", "Error: You cannot add the same address to your list twice. Perhaps rename the existing one if you want.")) self.statusBar().showMessage(QtGui.QApplication.translate(
"MainWindow", "Error: You cannot add the same address to your list twice. Perhaps rename the existing one if you want."))
else: else:
self.statusBar().showMessage(QtGui.QApplication.translate("MainWindow", "The address you entered was invalid. Ignoring it.")) self.statusBar().showMessage(QtGui.QApplication.translate(
"MainWindow", "The address you entered was invalid. Ignoring it."))
def on_action_SpecialAddressBehaviorDialog(self): def on_action_SpecialAddressBehaviorDialog(self):
self.dialog = SpecialAddressBehaviorDialog(self) self.dialog = SpecialAddressBehaviorDialog(self)
# For Modal dialogs # For Modal dialogs
if self.dialog.exec_(): if self.dialog.exec_():
currentRow = self.ui.tableWidgetYourIdentities.currentRow() currentRow = self.ui.tableWidgetYourIdentities.currentRow()
addressAtCurrentRow = str(self.ui.tableWidgetYourIdentities.item(currentRow,1).text()) addressAtCurrentRow = str(
self.ui.tableWidgetYourIdentities.item(currentRow, 1).text())
if self.dialog.ui.radioButtonBehaveNormalAddress.isChecked(): if self.dialog.ui.radioButtonBehaveNormalAddress.isChecked():
shared.config.set(str(addressAtCurrentRow),'mailinglist','false') shared.config.set(str(
#Set the color to either black or grey addressAtCurrentRow), 'mailinglist', 'false')
if shared.config.getboolean(addressAtCurrentRow,'enabled'): # Set the color to either black or grey
self.ui.tableWidgetYourIdentities.item(currentRow,1).setTextColor(QtGui.QColor(0,0,0)) if shared.config.getboolean(addressAtCurrentRow, 'enabled'):
self.ui.tableWidgetYourIdentities.item(
currentRow, 1).setTextColor(QtGui.QColor(0, 0, 0))
else: else:
self.ui.tableWidgetYourIdentities.item(currentRow,1).setTextColor(QtGui.QColor(128,128,128)) self.ui.tableWidgetYourIdentities.item(
currentRow, 1).setTextColor(QtGui.QColor(128, 128, 128))
else: else:
shared.config.set(str(addressAtCurrentRow),'mailinglist','true') shared.config.set(str(
shared.config.set(str(addressAtCurrentRow),'mailinglistname',str(self.dialog.ui.lineEditMailingListName.text().toUtf8())) addressAtCurrentRow), 'mailinglist', 'true')
self.ui.tableWidgetYourIdentities.item(currentRow,1).setTextColor(QtGui.QColor(137,04,177)) shared.config.set(str(addressAtCurrentRow), 'mailinglistname', str(
self.dialog.ui.lineEditMailingListName.text().toUtf8()))
self.ui.tableWidgetYourIdentities.item(currentRow, 1).setTextColor(QtGui.QColor(137, 04, 177))
with open(shared.appdata + 'keys.dat', 'wb') as configfile: with open(shared.appdata + 'keys.dat', 'wb') as configfile:
shared.config.write(configfile) shared.config.write(configfile)
self.rerenderInboxToLabels() self.rerenderInboxToLabels()
def click_NewAddressDialog(self): def click_NewAddressDialog(self):
self.dialog = NewAddressDialog(self) self.dialog = NewAddressDialog(self)
# For Modal dialogs # For Modal dialogs
if self.dialog.exec_(): if self.dialog.exec_():
#self.dialog.ui.buttonBox.enabled = False # self.dialog.ui.buttonBox.enabled = False
if self.dialog.ui.radioButtonRandomAddress.isChecked(): if self.dialog.ui.radioButtonRandomAddress.isChecked():
if self.dialog.ui.radioButtonMostAvailable.isChecked(): if self.dialog.ui.radioButtonMostAvailable.isChecked():
streamNumberForAddress = 1 streamNumberForAddress = 1
else: else:
#User selected 'Use the same stream as an existing address.' # User selected 'Use the same stream as an existing
streamNumberForAddress = addressStream(self.dialog.ui.comboBoxExisting.currentText()) # address.'
streamNumberForAddress = addressStream(
self.dialog.ui.comboBoxExisting.currentText())
#self.addressGenerator = addressGenerator() # self.addressGenerator = addressGenerator()
#self.addressGenerator.setup(3,streamNumberForAddress,str(self.dialog.ui.newaddresslabel.text().toUtf8()),1,"",self.dialog.ui.checkBoxEighteenByteRipe.isChecked()) # self.addressGenerator.setup(3,streamNumberForAddress,str(self.dialog.ui.newaddresslabel.text().toUtf8()),1,"",self.dialog.ui.checkBoxEighteenByteRipe.isChecked())
#QtCore.QObject.connect(self.addressGenerator, SIGNAL("writeNewAddressToTable(PyQt_PyObject,PyQt_PyObject,PyQt_PyObject)"), self.writeNewAddressToTable) # QtCore.QObject.connect(self.addressGenerator, SIGNAL("writeNewAddressToTable(PyQt_PyObject,PyQt_PyObject,PyQt_PyObject)"), self.writeNewAddressToTable)
#QtCore.QObject.connect(self.addressGenerator, QtCore.SIGNAL("updateStatusBar(PyQt_PyObject)"), self.updateStatusBar) # QtCore.QObject.connect(self.addressGenerator, QtCore.SIGNAL("updateStatusBar(PyQt_PyObject)"), self.updateStatusBar)
#self.addressGenerator.start() # self.addressGenerator.start()
shared.addressGeneratorQueue.put(('createRandomAddress',3,streamNumberForAddress,str(self.dialog.ui.newaddresslabel.text().toUtf8()),1,"",self.dialog.ui.checkBoxEighteenByteRipe.isChecked())) shared.addressGeneratorQueue.put(('createRandomAddress', 3, streamNumberForAddress, str(
self.dialog.ui.newaddresslabel.text().toUtf8()), 1, "", self.dialog.ui.checkBoxEighteenByteRipe.isChecked()))
else: else:
if self.dialog.ui.lineEditPassphrase.text() != self.dialog.ui.lineEditPassphraseAgain.text(): if self.dialog.ui.lineEditPassphrase.text() != self.dialog.ui.lineEditPassphraseAgain.text():
QMessageBox.about(self, QtGui.QApplication.translate("MainWindow", "Passphrase mismatch"), QtGui.QApplication.translate("MainWindow", "The passphrase you entered twice doesn\'t match. Try again.")) QMessageBox.about(self, QtGui.QApplication.translate("MainWindow", "Passphrase mismatch"), QtGui.QApplication.translate(
"MainWindow", "The passphrase you entered twice doesn\'t match. Try again."))
elif self.dialog.ui.lineEditPassphrase.text() == "": elif self.dialog.ui.lineEditPassphrase.text() == "":
QMessageBox.about(self, QtGui.QApplication.translate("MainWindow", "Choose a passphrase"), QtGui.QApplication.translate("MainWindow", "You really do need a passphrase.")) QMessageBox.about(self, QtGui.QApplication.translate(
"MainWindow", "Choose a passphrase"), QtGui.QApplication.translate("MainWindow", "You really do need a passphrase."))
else: else:
streamNumberForAddress = 1 #this will eventually have to be replaced by logic to determine the most available stream number. streamNumberForAddress = 1 # this will eventually have to be replaced by logic to determine the most available stream number.
#self.addressGenerator = addressGenerator() # self.addressGenerator = addressGenerator()
#self.addressGenerator.setup(3,streamNumberForAddress,"unused address",self.dialog.ui.spinBoxNumberOfAddressesToMake.value(),self.dialog.ui.lineEditPassphrase.text().toUtf8(),self.dialog.ui.checkBoxEighteenByteRipe.isChecked()) # self.addressGenerator.setup(3,streamNumberForAddress,"unused address",self.dialog.ui.spinBoxNumberOfAddressesToMake.value(),self.dialog.ui.lineEditPassphrase.text().toUtf8(),self.dialog.ui.checkBoxEighteenByteRipe.isChecked())
#QtCore.QObject.connect(self.addressGenerator, SIGNAL("writeNewAddressToTable(PyQt_PyObject,PyQt_PyObject,PyQt_PyObject)"), self.writeNewAddressToTable) # QtCore.QObject.connect(self.addressGenerator, SIGNAL("writeNewAddressToTable(PyQt_PyObject,PyQt_PyObject,PyQt_PyObject)"), self.writeNewAddressToTable)
#QtCore.QObject.connect(self.addressGenerator, QtCore.SIGNAL("updateStatusBar(PyQt_PyObject)"), self.updateStatusBar) # QtCore.QObject.connect(self.addressGenerator, QtCore.SIGNAL("updateStatusBar(PyQt_PyObject)"), self.updateStatusBar)
#self.addressGenerator.start() # self.addressGenerator.start()
shared.addressGeneratorQueue.put(('createDeterministicAddresses',3,streamNumberForAddress,"unused deterministic address",self.dialog.ui.spinBoxNumberOfAddressesToMake.value(),self.dialog.ui.lineEditPassphrase.text().toUtf8(),self.dialog.ui.checkBoxEighteenByteRipe.isChecked())) shared.addressGeneratorQueue.put(('createDeterministicAddresses', 3, streamNumberForAddress, "unused deterministic address", self.dialog.ui.spinBoxNumberOfAddressesToMake.value(
), self.dialog.ui.lineEditPassphrase.text().toUtf8(), self.dialog.ui.checkBoxEighteenByteRipe.isChecked()))
else: else:
print 'new address dialog box rejected' print 'new address dialog box rejected'
# Quit selected from menu or application indicator # Quit selected from menu or application indicator
def quit(self): def quit(self):
'''quit_msg = "Are you sure you want to exit Bitmessage?" '''quit_msg = "Are you sure you want to exit Bitmessage?"
@ -1674,7 +1973,8 @@ class MyForm(QtGui.QMainWindow):
# unregister the messaging system # unregister the messaging system
if self.mmapp is not None: if self.mmapp is not None:
self.mmapp.unregister() self.mmapp.unregister()
self.statusBar().showMessage(QtGui.QApplication.translate("MainWindow", "All done. Closing user interface...")) self.statusBar().showMessage(QtGui.QApplication.translate(
"MainWindow", "All done. Closing user interface..."))
os._exit(0) os._exit(0)
# window close event # window close event
@ -1683,7 +1983,8 @@ class MyForm(QtGui.QMainWindow):
minimizeonclose = False minimizeonclose = False
try: try:
minimizeonclose = shared.config.getboolean('bitmessagesettings', 'minimizeonclose') minimizeonclose = shared.config.getboolean(
'bitmessagesettings', 'minimizeonclose')
except Exception: except Exception:
pass pass
@ -1697,10 +1998,12 @@ class MyForm(QtGui.QMainWindow):
def on_action_InboxMessageForceHtml(self): def on_action_InboxMessageForceHtml(self):
currentInboxRow = self.ui.tableWidgetInbox.currentRow() currentInboxRow = self.ui.tableWidgetInbox.currentRow()
lines = self.ui.tableWidgetInbox.item(currentInboxRow,2).data(Qt.UserRole).toPyObject().split('\n') lines = self.ui.tableWidgetInbox.item(
currentInboxRow, 2).data(Qt.UserRole).toPyObject().split('\n')
for i in xrange(len(lines)): for i in xrange(len(lines)):
if lines[i].contains('Message ostensibly from '): if lines[i].contains('Message ostensibly from '):
lines[i] = '<p style="font-size: 12px; color: grey;">%s</span></p>' % (lines[i]) lines[i] = '<p style="font-size: 12px; color: grey;">%s</span></p>' % (
lines[i])
elif lines[i] == '------------------------------------------------------': elif lines[i] == '------------------------------------------------------':
lines[i] = '<hr>' lines[i] = '<hr>'
content = '' content = ''
@ -1711,140 +2014,171 @@ class MyForm(QtGui.QMainWindow):
def on_action_InboxReply(self): def on_action_InboxReply(self):
currentInboxRow = self.ui.tableWidgetInbox.currentRow() currentInboxRow = self.ui.tableWidgetInbox.currentRow()
toAddressAtCurrentInboxRow = str(self.ui.tableWidgetInbox.item(currentInboxRow,0).data(Qt.UserRole).toPyObject()) toAddressAtCurrentInboxRow = str(self.ui.tableWidgetInbox.item(
fromAddressAtCurrentInboxRow = str(self.ui.tableWidgetInbox.item(currentInboxRow,1).data(Qt.UserRole).toPyObject()) currentInboxRow, 0).data(Qt.UserRole).toPyObject())
fromAddressAtCurrentInboxRow = str(self.ui.tableWidgetInbox.item(
currentInboxRow, 1).data(Qt.UserRole).toPyObject())
if toAddressAtCurrentInboxRow == self.str_broadcast_subscribers: if toAddressAtCurrentInboxRow == self.str_broadcast_subscribers:
self.ui.labelFrom.setText('') self.ui.labelFrom.setText('')
elif not shared.config.has_section(toAddressAtCurrentInboxRow): elif not shared.config.has_section(toAddressAtCurrentInboxRow):
QtGui.QMessageBox.information(self, QtGui.QApplication.translate("MainWindow", "Address is gone"),QtGui.QApplication.translate("MainWindow", "Bitmessage cannot find your address %1. Perhaps you removed it?").arg(toAddressAtCurrentInboxRow), QMessageBox.Ok) QtGui.QMessageBox.information(self, QtGui.QApplication.translate("MainWindow", "Address is gone"), QtGui.QApplication.translate(
"MainWindow", "Bitmessage cannot find your address %1. Perhaps you removed it?").arg(toAddressAtCurrentInboxRow), QMessageBox.Ok)
self.ui.labelFrom.setText('') self.ui.labelFrom.setText('')
elif not shared.config.getboolean(toAddressAtCurrentInboxRow,'enabled'): elif not shared.config.getboolean(toAddressAtCurrentInboxRow, 'enabled'):
QtGui.QMessageBox.information(self, QtGui.QApplication.translate("MainWindow", "Address disabled"),QtGui.QApplication.translate("MainWindow", "Error: The address from which you are trying to send is disabled. You\'ll have to enable it on the \'Your Identities\' tab before using it."), QMessageBox.Ok) QtGui.QMessageBox.information(self, QtGui.QApplication.translate("MainWindow", "Address disabled"), QtGui.QApplication.translate(
"MainWindow", "Error: The address from which you are trying to send is disabled. You\'ll have to enable it on the \'Your Identities\' tab before using it."), QMessageBox.Ok)
self.ui.labelFrom.setText('') self.ui.labelFrom.setText('')
else: else:
self.ui.labelFrom.setText(toAddressAtCurrentInboxRow) self.ui.labelFrom.setText(toAddressAtCurrentInboxRow)
self.ui.lineEditTo.setText(str(fromAddressAtCurrentInboxRow)) self.ui.lineEditTo.setText(str(fromAddressAtCurrentInboxRow))
self.ui.comboBoxSendFrom.setCurrentIndex(0) self.ui.comboBoxSendFrom.setCurrentIndex(0)
#self.ui.comboBoxSendFrom.setEditText(str(self.ui.tableWidgetInbox.item(currentInboxRow,0).text)) # self.ui.comboBoxSendFrom.setEditText(str(self.ui.tableWidgetInbox.item(currentInboxRow,0).text))
self.ui.textEditMessage.setText('\n\n------------------------------------------------------\n'+self.ui.tableWidgetInbox.item(currentInboxRow,2).data(Qt.UserRole).toPyObject()) self.ui.textEditMessage.setText('\n\n------------------------------------------------------\n' + self.ui.tableWidgetInbox.item(
if self.ui.tableWidgetInbox.item(currentInboxRow,2).text()[0:3] == 'Re:': currentInboxRow, 2).data(Qt.UserRole).toPyObject())
self.ui.lineEditSubject.setText(self.ui.tableWidgetInbox.item(currentInboxRow,2).text()) if self.ui.tableWidgetInbox.item(currentInboxRow, 2).text()[0:3] == 'Re:':
self.ui.lineEditSubject.setText(
self.ui.tableWidgetInbox.item(currentInboxRow, 2).text())
else: else:
self.ui.lineEditSubject.setText('Re: '+self.ui.tableWidgetInbox.item(currentInboxRow,2).text()) self.ui.lineEditSubject.setText(
'Re: ' + self.ui.tableWidgetInbox.item(currentInboxRow, 2).text())
self.ui.radioButtonSpecific.setChecked(True) self.ui.radioButtonSpecific.setChecked(True)
self.ui.tabWidget.setCurrentIndex(1) self.ui.tabWidget.setCurrentIndex(1)
def on_action_InboxAddSenderToAddressBook(self): def on_action_InboxAddSenderToAddressBook(self):
currentInboxRow = self.ui.tableWidgetInbox.currentRow() currentInboxRow = self.ui.tableWidgetInbox.currentRow()
#self.ui.tableWidgetInbox.item(currentRow,1).data(Qt.UserRole).toPyObject() # self.ui.tableWidgetInbox.item(currentRow,1).data(Qt.UserRole).toPyObject()
addressAtCurrentInboxRow = str(self.ui.tableWidgetInbox.item(currentInboxRow,1).data(Qt.UserRole).toPyObject()) addressAtCurrentInboxRow = str(self.ui.tableWidgetInbox.item(
#Let's make sure that it isn't already in the address book currentInboxRow, 1).data(Qt.UserRole).toPyObject())
# Let's make sure that it isn't already in the address book
shared.sqlLock.acquire() shared.sqlLock.acquire()
t = (addressAtCurrentInboxRow,) t = (addressAtCurrentInboxRow,)
shared.sqlSubmitQueue.put('''select * from addressbook where address=?''') shared.sqlSubmitQueue.put(
'''select * from addressbook where address=?''')
shared.sqlSubmitQueue.put(t) shared.sqlSubmitQueue.put(t)
queryreturn = shared.sqlReturnQueue.get() queryreturn = shared.sqlReturnQueue.get()
shared.sqlLock.release() shared.sqlLock.release()
if queryreturn == []: if queryreturn == []:
self.ui.tableWidgetAddressBook.insertRow(0) self.ui.tableWidgetAddressBook.insertRow(0)
newItem = QtGui.QTableWidgetItem('--New entry. Change label in Address Book.--') newItem = QtGui.QTableWidgetItem(
self.ui.tableWidgetAddressBook.setItem(0,0,newItem) '--New entry. Change label in Address Book.--')
newItem = QtGui.QTableWidgetItem(addressAtCurrentInboxRow) self.ui.tableWidgetAddressBook.setItem(0, 0, newItem)
newItem.setFlags( QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled ) newItem = QtGui.QTableWidgetItem(addressAtCurrentInboxRow)
self.ui.tableWidgetAddressBook.setItem(0,1,newItem) newItem.setFlags(
t = ('--New entry. Change label in Address Book.--',addressAtCurrentInboxRow) QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled)
self.ui.tableWidgetAddressBook.setItem(0, 1, newItem)
t = ('--New entry. Change label in Address Book.--',
addressAtCurrentInboxRow)
shared.sqlLock.acquire() shared.sqlLock.acquire()
shared.sqlSubmitQueue.put('''INSERT INTO addressbook VALUES (?,?)''') shared.sqlSubmitQueue.put(
'''INSERT INTO addressbook VALUES (?,?)''')
shared.sqlSubmitQueue.put(t) shared.sqlSubmitQueue.put(t)
queryreturn = shared.sqlReturnQueue.get() queryreturn = shared.sqlReturnQueue.get()
shared.sqlSubmitQueue.put('commit') shared.sqlSubmitQueue.put('commit')
shared.sqlLock.release() shared.sqlLock.release()
self.ui.tabWidget.setCurrentIndex(5) self.ui.tabWidget.setCurrentIndex(5)
self.ui.tableWidgetAddressBook.setCurrentCell(0,0) self.ui.tableWidgetAddressBook.setCurrentCell(0, 0)
self.statusBar().showMessage(QtGui.QApplication.translate("MainWindow", "Entry added to the Address Book. Edit the label to your liking.")) self.statusBar().showMessage(QtGui.QApplication.translate(
"MainWindow", "Entry added to the Address Book. Edit the label to your liking."))
else: else:
self.statusBar().showMessage(QtGui.QApplication.translate("MainWindow", "Error: You cannot add the same address to your address book twice. Try renaming the existing one if you want.")) self.statusBar().showMessage(QtGui.QApplication.translate(
"MainWindow", "Error: You cannot add the same address to your address book twice. Try renaming the existing one if you want."))
#Send item on the Inbox tab to trash # Send item on the Inbox tab to trash
def on_action_InboxTrash(self): def on_action_InboxTrash(self):
while self.ui.tableWidgetInbox.selectedIndexes() != []: while self.ui.tableWidgetInbox.selectedIndexes() != []:
currentRow = self.ui.tableWidgetInbox.selectedIndexes()[0].row() currentRow = self.ui.tableWidgetInbox.selectedIndexes()[0].row()
inventoryHashToTrash = str(self.ui.tableWidgetInbox.item(currentRow,3).data(Qt.UserRole).toPyObject()) inventoryHashToTrash = str(self.ui.tableWidgetInbox.item(
currentRow, 3).data(Qt.UserRole).toPyObject())
t = (inventoryHashToTrash,) t = (inventoryHashToTrash,)
shared.sqlLock.acquire() shared.sqlLock.acquire()
shared.sqlSubmitQueue.put('''UPDATE inbox SET folder='trash' WHERE msgid=?''') shared.sqlSubmitQueue.put(
'''UPDATE inbox SET folder='trash' WHERE msgid=?''')
shared.sqlSubmitQueue.put(t) shared.sqlSubmitQueue.put(t)
shared.sqlReturnQueue.get() shared.sqlReturnQueue.get()
shared.sqlLock.release() shared.sqlLock.release()
self.ui.textEditInboxMessage.setText("") self.ui.textEditInboxMessage.setText("")
self.ui.tableWidgetInbox.removeRow(currentRow) self.ui.tableWidgetInbox.removeRow(currentRow)
self.statusBar().showMessage(QtGui.QApplication.translate("MainWindow", "Moved items to trash. There is no user interface to view your trash, but it is still on disk if you are desperate to get it back.")) self.statusBar().showMessage(QtGui.QApplication.translate(
"MainWindow", "Moved items to trash. There is no user interface to view your trash, but it is still on disk if you are desperate to get it back."))
shared.sqlLock.acquire() shared.sqlLock.acquire()
shared.sqlSubmitQueue.put('commit') shared.sqlSubmitQueue.put('commit')
shared.sqlLock.release() shared.sqlLock.release()
if currentRow == 0: if currentRow == 0:
self.ui.tableWidgetInbox.selectRow(currentRow) self.ui.tableWidgetInbox.selectRow(currentRow)
else: else:
self.ui.tableWidgetInbox.selectRow(currentRow-1) self.ui.tableWidgetInbox.selectRow(currentRow - 1)
#Send item on the Sent tab to trash # Send item on the Sent tab to trash
def on_action_SentTrash(self): def on_action_SentTrash(self):
while self.ui.tableWidgetSent.selectedIndexes() != []: while self.ui.tableWidgetSent.selectedIndexes() != []:
currentRow = self.ui.tableWidgetSent.selectedIndexes()[0].row() currentRow = self.ui.tableWidgetSent.selectedIndexes()[0].row()
ackdataToTrash = str(self.ui.tableWidgetSent.item(currentRow,3).data(Qt.UserRole).toPyObject()) ackdataToTrash = str(self.ui.tableWidgetSent.item(
currentRow, 3).data(Qt.UserRole).toPyObject())
t = (ackdataToTrash,) t = (ackdataToTrash,)
shared.sqlLock.acquire() shared.sqlLock.acquire()
shared.sqlSubmitQueue.put('''UPDATE sent SET folder='trash' WHERE ackdata=?''') shared.sqlSubmitQueue.put(
'''UPDATE sent SET folder='trash' WHERE ackdata=?''')
shared.sqlSubmitQueue.put(t) shared.sqlSubmitQueue.put(t)
shared.sqlReturnQueue.get() shared.sqlReturnQueue.get()
shared.sqlLock.release() shared.sqlLock.release()
self.ui.textEditSentMessage.setPlainText("") self.ui.textEditSentMessage.setPlainText("")
self.ui.tableWidgetSent.removeRow(currentRow) self.ui.tableWidgetSent.removeRow(currentRow)
self.statusBar().showMessage(QtGui.QApplication.translate("MainWindow", "Moved items to trash. There is no user interface to view your trash, but it is still on disk if you are desperate to get it back.")) self.statusBar().showMessage(QtGui.QApplication.translate(
"MainWindow", "Moved items to trash. There is no user interface to view your trash, but it is still on disk if you are desperate to get it back."))
shared.sqlLock.acquire() shared.sqlLock.acquire()
shared.sqlSubmitQueue.put('commit') shared.sqlSubmitQueue.put('commit')
shared.sqlLock.release() shared.sqlLock.release()
if currentRow == 0: if currentRow == 0:
self.ui.tableWidgetSent.selectRow(currentRow) self.ui.tableWidgetSent.selectRow(currentRow)
else: else:
self.ui.tableWidgetSent.selectRow(currentRow-1) self.ui.tableWidgetSent.selectRow(currentRow - 1)
def on_action_ForceSend(self): def on_action_ForceSend(self):
currentRow = self.ui.tableWidgetSent.currentRow() currentRow = self.ui.tableWidgetSent.currentRow()
addressAtCurrentRow = str(self.ui.tableWidgetSent.item(currentRow,0).data(Qt.UserRole).toPyObject()) addressAtCurrentRow = str(self.ui.tableWidgetSent.item(
currentRow, 0).data(Qt.UserRole).toPyObject())
toRipe = decodeAddress(addressAtCurrentRow)[3] toRipe = decodeAddress(addressAtCurrentRow)[3]
t = (toRipe,) t = (toRipe,)
shared.sqlLock.acquire() shared.sqlLock.acquire()
shared.sqlSubmitQueue.put('''UPDATE sent SET status='forcepow' WHERE toripe=? AND status='toodifficult' and folder='sent' ''') shared.sqlSubmitQueue.put(
'''UPDATE sent SET status='forcepow' WHERE toripe=? AND status='toodifficult' and folder='sent' ''')
shared.sqlSubmitQueue.put(t) shared.sqlSubmitQueue.put(t)
shared.sqlReturnQueue.get() shared.sqlReturnQueue.get()
shared.sqlSubmitQueue.put('commit') shared.sqlSubmitQueue.put('commit')
shared.sqlSubmitQueue.put('''select ackdata FROM sent WHERE status='forcepow' ''') shared.sqlSubmitQueue.put(
'''select ackdata FROM sent WHERE status='forcepow' ''')
shared.sqlSubmitQueue.put('') shared.sqlSubmitQueue.put('')
queryreturn = shared.sqlReturnQueue.get() queryreturn = shared.sqlReturnQueue.get()
shared.sqlLock.release() shared.sqlLock.release()
for row in queryreturn: for row in queryreturn:
ackdata, = row ackdata, = row
shared.UISignalQueue.put(('updateSentItemStatusByAckdata',(ackdata,'Overriding maximum-difficulty setting. Work queued.'))) shared.UISignalQueue.put(('updateSentItemStatusByAckdata', (
shared.workerQueue.put(('sendmessage','')) ackdata, 'Overriding maximum-difficulty setting. Work queued.')))
shared.workerQueue.put(('sendmessage', ''))
def on_action_SentClipboard(self): def on_action_SentClipboard(self):
currentRow = self.ui.tableWidgetSent.currentRow() currentRow = self.ui.tableWidgetSent.currentRow()
addressAtCurrentRow = str(self.ui.tableWidgetSent.item(currentRow,0).data(Qt.UserRole).toPyObject()) addressAtCurrentRow = str(self.ui.tableWidgetSent.item(
currentRow, 0).data(Qt.UserRole).toPyObject())
clipboard = QtGui.QApplication.clipboard() clipboard = QtGui.QApplication.clipboard()
clipboard.setText(str(addressAtCurrentRow)) clipboard.setText(str(addressAtCurrentRow))
#Group of functions for the Address Book dialog box # Group of functions for the Address Book dialog box
def on_action_AddressBookNew(self): def on_action_AddressBookNew(self):
self.click_pushButtonAddAddressBook() self.click_pushButtonAddAddressBook()
def on_action_AddressBookDelete(self): def on_action_AddressBookDelete(self):
while self.ui.tableWidgetAddressBook.selectedIndexes() != []: while self.ui.tableWidgetAddressBook.selectedIndexes() != []:
currentRow = self.ui.tableWidgetAddressBook.selectedIndexes()[0].row() currentRow = self.ui.tableWidgetAddressBook.selectedIndexes()[
labelAtCurrentRow = self.ui.tableWidgetAddressBook.item(currentRow,0).text().toUtf8() 0].row()
addressAtCurrentRow = self.ui.tableWidgetAddressBook.item(currentRow,1).text() labelAtCurrentRow = self.ui.tableWidgetAddressBook.item(
t = (str(labelAtCurrentRow),str(addressAtCurrentRow)) currentRow, 0).text().toUtf8()
addressAtCurrentRow = self.ui.tableWidgetAddressBook.item(
currentRow, 1).text()
t = (str(labelAtCurrentRow), str(addressAtCurrentRow))
shared.sqlLock.acquire() shared.sqlLock.acquire()
shared.sqlSubmitQueue.put('''DELETE FROM addressbook WHERE label=? AND address=?''') shared.sqlSubmitQueue.put(
'''DELETE FROM addressbook WHERE label=? AND address=?''')
shared.sqlSubmitQueue.put(t) shared.sqlSubmitQueue.put(t)
queryreturn = shared.sqlReturnQueue.get() queryreturn = shared.sqlReturnQueue.get()
shared.sqlSubmitQueue.put('commit') shared.sqlSubmitQueue.put('commit')
@ -1852,49 +2186,62 @@ class MyForm(QtGui.QMainWindow):
self.ui.tableWidgetAddressBook.removeRow(currentRow) self.ui.tableWidgetAddressBook.removeRow(currentRow)
self.rerenderInboxFromLabels() self.rerenderInboxFromLabels()
self.rerenderSentToLabels() self.rerenderSentToLabels()
def on_action_AddressBookClipboard(self): def on_action_AddressBookClipboard(self):
fullStringOfAddresses = '' fullStringOfAddresses = ''
listOfSelectedRows = {} listOfSelectedRows = {}
for i in range(len(self.ui.tableWidgetAddressBook.selectedIndexes())): for i in range(len(self.ui.tableWidgetAddressBook.selectedIndexes())):
listOfSelectedRows[self.ui.tableWidgetAddressBook.selectedIndexes()[i].row()] = 0 listOfSelectedRows[
self.ui.tableWidgetAddressBook.selectedIndexes()[i].row()] = 0
for currentRow in listOfSelectedRows: for currentRow in listOfSelectedRows:
addressAtCurrentRow = self.ui.tableWidgetAddressBook.item(currentRow,1).text() addressAtCurrentRow = self.ui.tableWidgetAddressBook.item(
currentRow, 1).text()
if fullStringOfAddresses == '': if fullStringOfAddresses == '':
fullStringOfAddresses = addressAtCurrentRow fullStringOfAddresses = addressAtCurrentRow
else: else:
fullStringOfAddresses += ', '+ str(addressAtCurrentRow) fullStringOfAddresses += ', ' + str(addressAtCurrentRow)
clipboard = QtGui.QApplication.clipboard() clipboard = QtGui.QApplication.clipboard()
clipboard.setText(fullStringOfAddresses) clipboard.setText(fullStringOfAddresses)
def on_action_AddressBookSend(self): def on_action_AddressBookSend(self):
listOfSelectedRows = {} listOfSelectedRows = {}
for i in range(len(self.ui.tableWidgetAddressBook.selectedIndexes())): for i in range(len(self.ui.tableWidgetAddressBook.selectedIndexes())):
listOfSelectedRows[self.ui.tableWidgetAddressBook.selectedIndexes()[i].row()] = 0 listOfSelectedRows[
self.ui.tableWidgetAddressBook.selectedIndexes()[i].row()] = 0
for currentRow in listOfSelectedRows: for currentRow in listOfSelectedRows:
addressAtCurrentRow = self.ui.tableWidgetAddressBook.item(currentRow,1).text() addressAtCurrentRow = self.ui.tableWidgetAddressBook.item(
currentRow, 1).text()
if self.ui.lineEditTo.text() == '': if self.ui.lineEditTo.text() == '':
self.ui.lineEditTo.setText(str(addressAtCurrentRow)) self.ui.lineEditTo.setText(str(addressAtCurrentRow))
else: else:
self.ui.lineEditTo.setText(str(self.ui.lineEditTo.text()) + '; '+ str(addressAtCurrentRow)) self.ui.lineEditTo.setText(str(
self.ui.lineEditTo.text()) + '; ' + str(addressAtCurrentRow))
if listOfSelectedRows == {}: if listOfSelectedRows == {}:
self.statusBar().showMessage(QtGui.QApplication.translate("MainWindow", "No addresses selected.")) self.statusBar().showMessage(QtGui.QApplication.translate(
"MainWindow", "No addresses selected."))
else: else:
self.statusBar().showMessage('') self.statusBar().showMessage('')
self.ui.tabWidget.setCurrentIndex(1) self.ui.tabWidget.setCurrentIndex(1)
def on_context_menuAddressBook(self, point): def on_context_menuAddressBook(self, point):
self.popMenuAddressBook.exec_( self.ui.tableWidgetAddressBook.mapToGlobal(point) ) self.popMenuAddressBook.exec_(
self.ui.tableWidgetAddressBook.mapToGlobal(point))
# Group of functions for the Subscriptions dialog box
#Group of functions for the Subscriptions dialog box
def on_action_SubscriptionsNew(self): def on_action_SubscriptionsNew(self):
self.click_pushButtonAddSubscription() self.click_pushButtonAddSubscription()
def on_action_SubscriptionsDelete(self): def on_action_SubscriptionsDelete(self):
print 'clicked Delete' print 'clicked Delete'
currentRow = self.ui.tableWidgetSubscriptions.currentRow() currentRow = self.ui.tableWidgetSubscriptions.currentRow()
labelAtCurrentRow = self.ui.tableWidgetSubscriptions.item(currentRow,0).text().toUtf8() labelAtCurrentRow = self.ui.tableWidgetSubscriptions.item(
addressAtCurrentRow = self.ui.tableWidgetSubscriptions.item(currentRow,1).text() currentRow, 0).text().toUtf8()
t = (str(labelAtCurrentRow),str(addressAtCurrentRow)) addressAtCurrentRow = self.ui.tableWidgetSubscriptions.item(
currentRow, 1).text()
t = (str(labelAtCurrentRow), str(addressAtCurrentRow))
shared.sqlLock.acquire() shared.sqlLock.acquire()
shared.sqlSubmitQueue.put('''DELETE FROM subscriptions WHERE label=? AND address=?''') shared.sqlSubmitQueue.put(
'''DELETE FROM subscriptions WHERE label=? AND address=?''')
shared.sqlSubmitQueue.put(t) shared.sqlSubmitQueue.put(t)
shared.sqlReturnQueue.get() shared.sqlReturnQueue.get()
shared.sqlSubmitQueue.put('commit') shared.sqlSubmitQueue.put('commit')
@ -1902,187 +2249,251 @@ class MyForm(QtGui.QMainWindow):
self.ui.tableWidgetSubscriptions.removeRow(currentRow) self.ui.tableWidgetSubscriptions.removeRow(currentRow)
self.rerenderInboxFromLabels() self.rerenderInboxFromLabels()
shared.reloadBroadcastSendersForWhichImWatching() shared.reloadBroadcastSendersForWhichImWatching()
def on_action_SubscriptionsClipboard(self): def on_action_SubscriptionsClipboard(self):
currentRow = self.ui.tableWidgetSubscriptions.currentRow() currentRow = self.ui.tableWidgetSubscriptions.currentRow()
addressAtCurrentRow = self.ui.tableWidgetSubscriptions.item(currentRow,1).text() addressAtCurrentRow = self.ui.tableWidgetSubscriptions.item(
currentRow, 1).text()
clipboard = QtGui.QApplication.clipboard() clipboard = QtGui.QApplication.clipboard()
clipboard.setText(str(addressAtCurrentRow)) clipboard.setText(str(addressAtCurrentRow))
def on_action_SubscriptionsEnable(self): def on_action_SubscriptionsEnable(self):
currentRow = self.ui.tableWidgetSubscriptions.currentRow() currentRow = self.ui.tableWidgetSubscriptions.currentRow()
labelAtCurrentRow = self.ui.tableWidgetSubscriptions.item(currentRow,0).text().toUtf8() labelAtCurrentRow = self.ui.tableWidgetSubscriptions.item(
addressAtCurrentRow = self.ui.tableWidgetSubscriptions.item(currentRow,1).text() currentRow, 0).text().toUtf8()
t = (str(labelAtCurrentRow),str(addressAtCurrentRow)) addressAtCurrentRow = self.ui.tableWidgetSubscriptions.item(
currentRow, 1).text()
t = (str(labelAtCurrentRow), str(addressAtCurrentRow))
shared.sqlLock.acquire() shared.sqlLock.acquire()
shared.sqlSubmitQueue.put('''update subscriptions set enabled=1 WHERE label=? AND address=?''') shared.sqlSubmitQueue.put(
'''update subscriptions set enabled=1 WHERE label=? AND address=?''')
shared.sqlSubmitQueue.put(t) shared.sqlSubmitQueue.put(t)
shared.sqlReturnQueue.get() shared.sqlReturnQueue.get()
shared.sqlSubmitQueue.put('commit') shared.sqlSubmitQueue.put('commit')
shared.sqlLock.release() shared.sqlLock.release()
self.ui.tableWidgetSubscriptions.item(currentRow,0).setTextColor(QtGui.QColor(0,0,0)) self.ui.tableWidgetSubscriptions.item(
self.ui.tableWidgetSubscriptions.item(currentRow,1).setTextColor(QtGui.QColor(0,0,0)) currentRow, 0).setTextColor(QtGui.QColor(0, 0, 0))
self.ui.tableWidgetSubscriptions.item(
currentRow, 1).setTextColor(QtGui.QColor(0, 0, 0))
shared.reloadBroadcastSendersForWhichImWatching() shared.reloadBroadcastSendersForWhichImWatching()
def on_action_SubscriptionsDisable(self): def on_action_SubscriptionsDisable(self):
currentRow = self.ui.tableWidgetSubscriptions.currentRow() currentRow = self.ui.tableWidgetSubscriptions.currentRow()
labelAtCurrentRow = self.ui.tableWidgetSubscriptions.item(currentRow,0).text().toUtf8() labelAtCurrentRow = self.ui.tableWidgetSubscriptions.item(
addressAtCurrentRow = self.ui.tableWidgetSubscriptions.item(currentRow,1).text() currentRow, 0).text().toUtf8()
t = (str(labelAtCurrentRow),str(addressAtCurrentRow)) addressAtCurrentRow = self.ui.tableWidgetSubscriptions.item(
currentRow, 1).text()
t = (str(labelAtCurrentRow), str(addressAtCurrentRow))
shared.sqlLock.acquire() shared.sqlLock.acquire()
shared.sqlSubmitQueue.put('''update subscriptions set enabled=0 WHERE label=? AND address=?''') shared.sqlSubmitQueue.put(
'''update subscriptions set enabled=0 WHERE label=? AND address=?''')
shared.sqlSubmitQueue.put(t) shared.sqlSubmitQueue.put(t)
shared.sqlReturnQueue.get() shared.sqlReturnQueue.get()
shared.sqlSubmitQueue.put('commit') shared.sqlSubmitQueue.put('commit')
shared.sqlLock.release() shared.sqlLock.release()
self.ui.tableWidgetSubscriptions.item(currentRow,0).setTextColor(QtGui.QColor(128,128,128)) self.ui.tableWidgetSubscriptions.item(
self.ui.tableWidgetSubscriptions.item(currentRow,1).setTextColor(QtGui.QColor(128,128,128)) currentRow, 0).setTextColor(QtGui.QColor(128, 128, 128))
self.ui.tableWidgetSubscriptions.item(
currentRow, 1).setTextColor(QtGui.QColor(128, 128, 128))
shared.reloadBroadcastSendersForWhichImWatching() shared.reloadBroadcastSendersForWhichImWatching()
def on_context_menuSubscriptions(self, point):
self.popMenuSubscriptions.exec_( self.ui.tableWidgetSubscriptions.mapToGlobal(point) )
#Group of functions for the Blacklist dialog box def on_context_menuSubscriptions(self, point):
self.popMenuSubscriptions.exec_(
self.ui.tableWidgetSubscriptions.mapToGlobal(point))
# Group of functions for the Blacklist dialog box
def on_action_BlacklistNew(self): def on_action_BlacklistNew(self):
self.click_pushButtonAddBlacklist() self.click_pushButtonAddBlacklist()
def on_action_BlacklistDelete(self): def on_action_BlacklistDelete(self):
currentRow = self.ui.tableWidgetBlacklist.currentRow() currentRow = self.ui.tableWidgetBlacklist.currentRow()
labelAtCurrentRow = self.ui.tableWidgetBlacklist.item(currentRow,0).text().toUtf8() labelAtCurrentRow = self.ui.tableWidgetBlacklist.item(
addressAtCurrentRow = self.ui.tableWidgetBlacklist.item(currentRow,1).text() currentRow, 0).text().toUtf8()
t = (str(labelAtCurrentRow),str(addressAtCurrentRow)) addressAtCurrentRow = self.ui.tableWidgetBlacklist.item(
currentRow, 1).text()
t = (str(labelAtCurrentRow), str(addressAtCurrentRow))
shared.sqlLock.acquire() shared.sqlLock.acquire()
if shared.config.get('bitmessagesettings', 'blackwhitelist') == 'black': if shared.config.get('bitmessagesettings', 'blackwhitelist') == 'black':
shared.sqlSubmitQueue.put('''DELETE FROM blacklist WHERE label=? AND address=?''') shared.sqlSubmitQueue.put(
'''DELETE FROM blacklist WHERE label=? AND address=?''')
shared.sqlSubmitQueue.put(t) shared.sqlSubmitQueue.put(t)
shared.sqlReturnQueue.get() shared.sqlReturnQueue.get()
else: else:
shared.sqlSubmitQueue.put('''DELETE FROM whitelist WHERE label=? AND address=?''') shared.sqlSubmitQueue.put(
'''DELETE FROM whitelist WHERE label=? AND address=?''')
shared.sqlSubmitQueue.put(t) shared.sqlSubmitQueue.put(t)
shared.sqlReturnQueue.get() shared.sqlReturnQueue.get()
shared.sqlSubmitQueue.put('commit') shared.sqlSubmitQueue.put('commit')
shared.sqlLock.release() shared.sqlLock.release()
self.ui.tableWidgetBlacklist.removeRow(currentRow) self.ui.tableWidgetBlacklist.removeRow(currentRow)
def on_action_BlacklistClipboard(self): def on_action_BlacklistClipboard(self):
currentRow = self.ui.tableWidgetBlacklist.currentRow() currentRow = self.ui.tableWidgetBlacklist.currentRow()
addressAtCurrentRow = self.ui.tableWidgetBlacklist.item(currentRow,1).text() addressAtCurrentRow = self.ui.tableWidgetBlacklist.item(
currentRow, 1).text()
clipboard = QtGui.QApplication.clipboard() clipboard = QtGui.QApplication.clipboard()
clipboard.setText(str(addressAtCurrentRow)) clipboard.setText(str(addressAtCurrentRow))
def on_context_menuBlacklist(self, point): def on_context_menuBlacklist(self, point):
self.popMenuBlacklist.exec_( self.ui.tableWidgetBlacklist.mapToGlobal(point) ) self.popMenuBlacklist.exec_(
self.ui.tableWidgetBlacklist.mapToGlobal(point))
def on_action_BlacklistEnable(self): def on_action_BlacklistEnable(self):
currentRow = self.ui.tableWidgetBlacklist.currentRow() currentRow = self.ui.tableWidgetBlacklist.currentRow()
addressAtCurrentRow = self.ui.tableWidgetBlacklist.item(currentRow,1).text() addressAtCurrentRow = self.ui.tableWidgetBlacklist.item(
self.ui.tableWidgetBlacklist.item(currentRow,0).setTextColor(QtGui.QColor(0,0,0)) currentRow, 1).text()
self.ui.tableWidgetBlacklist.item(currentRow,1).setTextColor(QtGui.QColor(0,0,0)) self.ui.tableWidgetBlacklist.item(
currentRow, 0).setTextColor(QtGui.QColor(0, 0, 0))
self.ui.tableWidgetBlacklist.item(
currentRow, 1).setTextColor(QtGui.QColor(0, 0, 0))
t = (str(addressAtCurrentRow),) t = (str(addressAtCurrentRow),)
shared.sqlLock.acquire() shared.sqlLock.acquire()
if shared.config.get('bitmessagesettings', 'blackwhitelist') == 'black': if shared.config.get('bitmessagesettings', 'blackwhitelist') == 'black':
shared.sqlSubmitQueue.put('''UPDATE blacklist SET enabled=1 WHERE address=?''') shared.sqlSubmitQueue.put(
'''UPDATE blacklist SET enabled=1 WHERE address=?''')
shared.sqlSubmitQueue.put(t) shared.sqlSubmitQueue.put(t)
shared.sqlReturnQueue.get() shared.sqlReturnQueue.get()
else: else:
shared.sqlSubmitQueue.put('''UPDATE whitelist SET enabled=1 WHERE address=?''') shared.sqlSubmitQueue.put(
'''UPDATE whitelist SET enabled=1 WHERE address=?''')
shared.sqlSubmitQueue.put(t) shared.sqlSubmitQueue.put(t)
shared.sqlReturnQueue.get() shared.sqlReturnQueue.get()
shared.sqlSubmitQueue.put('commit') shared.sqlSubmitQueue.put('commit')
shared.sqlLock.release() shared.sqlLock.release()
def on_action_BlacklistDisable(self): def on_action_BlacklistDisable(self):
currentRow = self.ui.tableWidgetBlacklist.currentRow() currentRow = self.ui.tableWidgetBlacklist.currentRow()
addressAtCurrentRow = self.ui.tableWidgetBlacklist.item(currentRow,1).text() addressAtCurrentRow = self.ui.tableWidgetBlacklist.item(
self.ui.tableWidgetBlacklist.item(currentRow,0).setTextColor(QtGui.QColor(128,128,128)) currentRow, 1).text()
self.ui.tableWidgetBlacklist.item(currentRow,1).setTextColor(QtGui.QColor(128,128,128)) self.ui.tableWidgetBlacklist.item(
currentRow, 0).setTextColor(QtGui.QColor(128, 128, 128))
self.ui.tableWidgetBlacklist.item(
currentRow, 1).setTextColor(QtGui.QColor(128, 128, 128))
t = (str(addressAtCurrentRow),) t = (str(addressAtCurrentRow),)
shared.sqlLock.acquire() shared.sqlLock.acquire()
if shared.config.get('bitmessagesettings', 'blackwhitelist') == 'black': if shared.config.get('bitmessagesettings', 'blackwhitelist') == 'black':
shared.sqlSubmitQueue.put('''UPDATE blacklist SET enabled=0 WHERE address=?''') shared.sqlSubmitQueue.put(
'''UPDATE blacklist SET enabled=0 WHERE address=?''')
shared.sqlSubmitQueue.put(t) shared.sqlSubmitQueue.put(t)
shared.sqlReturnQueue.get() shared.sqlReturnQueue.get()
else: else:
shared.sqlSubmitQueue.put('''UPDATE whitelist SET enabled=0 WHERE address=?''') shared.sqlSubmitQueue.put(
'''UPDATE whitelist SET enabled=0 WHERE address=?''')
shared.sqlSubmitQueue.put(t) shared.sqlSubmitQueue.put(t)
shared.sqlReturnQueue.get() shared.sqlReturnQueue.get()
shared.sqlSubmitQueue.put('commit') shared.sqlSubmitQueue.put('commit')
shared.sqlLock.release() shared.sqlLock.release()
#Group of functions for the Your Identities dialog box # Group of functions for the Your Identities dialog box
def on_action_YourIdentitiesNew(self): def on_action_YourIdentitiesNew(self):
self.click_NewAddressDialog() self.click_NewAddressDialog()
def on_action_YourIdentitiesEnable(self): def on_action_YourIdentitiesEnable(self):
currentRow = self.ui.tableWidgetYourIdentities.currentRow() currentRow = self.ui.tableWidgetYourIdentities.currentRow()
addressAtCurrentRow = str(self.ui.tableWidgetYourIdentities.item(currentRow,1).text()) addressAtCurrentRow = str(
shared.config.set(addressAtCurrentRow,'enabled','true') self.ui.tableWidgetYourIdentities.item(currentRow, 1).text())
shared.config.set(addressAtCurrentRow, 'enabled', 'true')
with open(shared.appdata + 'keys.dat', 'wb') as configfile: with open(shared.appdata + 'keys.dat', 'wb') as configfile:
shared.config.write(configfile) shared.config.write(configfile)
self.ui.tableWidgetYourIdentities.item(currentRow,0).setTextColor(QtGui.QColor(0,0,0)) self.ui.tableWidgetYourIdentities.item(
self.ui.tableWidgetYourIdentities.item(currentRow,1).setTextColor(QtGui.QColor(0,0,0)) currentRow, 0).setTextColor(QtGui.QColor(0, 0, 0))
self.ui.tableWidgetYourIdentities.item(currentRow,2).setTextColor(QtGui.QColor(0,0,0)) self.ui.tableWidgetYourIdentities.item(
if shared.safeConfigGetBoolean(addressAtCurrentRow,'mailinglist'): currentRow, 1).setTextColor(QtGui.QColor(0, 0, 0))
self.ui.tableWidgetYourIdentities.item(currentRow,1).setTextColor(QtGui.QColor(137,04,177)) self.ui.tableWidgetYourIdentities.item(
currentRow, 2).setTextColor(QtGui.QColor(0, 0, 0))
if shared.safeConfigGetBoolean(addressAtCurrentRow, 'mailinglist'):
self.ui.tableWidgetYourIdentities.item(currentRow, 1).setTextColor(QtGui.QColor(137, 04, 177))
shared.reloadMyAddressHashes() shared.reloadMyAddressHashes()
def on_action_YourIdentitiesDisable(self): def on_action_YourIdentitiesDisable(self):
currentRow = self.ui.tableWidgetYourIdentities.currentRow() currentRow = self.ui.tableWidgetYourIdentities.currentRow()
addressAtCurrentRow = str(self.ui.tableWidgetYourIdentities.item(currentRow,1).text()) addressAtCurrentRow = str(
shared.config.set(str(addressAtCurrentRow),'enabled','false') self.ui.tableWidgetYourIdentities.item(currentRow, 1).text())
self.ui.tableWidgetYourIdentities.item(currentRow,0).setTextColor(QtGui.QColor(128,128,128)) shared.config.set(str(addressAtCurrentRow), 'enabled', 'false')
self.ui.tableWidgetYourIdentities.item(currentRow,1).setTextColor(QtGui.QColor(128,128,128)) self.ui.tableWidgetYourIdentities.item(
self.ui.tableWidgetYourIdentities.item(currentRow,2).setTextColor(QtGui.QColor(128,128,128)) currentRow, 0).setTextColor(QtGui.QColor(128, 128, 128))
if shared.safeConfigGetBoolean(addressAtCurrentRow,'mailinglist'): self.ui.tableWidgetYourIdentities.item(
self.ui.tableWidgetYourIdentities.item(currentRow,1).setTextColor(QtGui.QColor(137,04,177)) currentRow, 1).setTextColor(QtGui.QColor(128, 128, 128))
self.ui.tableWidgetYourIdentities.item(
currentRow, 2).setTextColor(QtGui.QColor(128, 128, 128))
if shared.safeConfigGetBoolean(addressAtCurrentRow, 'mailinglist'):
self.ui.tableWidgetYourIdentities.item(currentRow, 1).setTextColor(QtGui.QColor(137, 04, 177))
with open(shared.appdata + 'keys.dat', 'wb') as configfile: with open(shared.appdata + 'keys.dat', 'wb') as configfile:
shared.config.write(configfile) shared.config.write(configfile)
shared.reloadMyAddressHashes() shared.reloadMyAddressHashes()
def on_action_YourIdentitiesClipboard(self): def on_action_YourIdentitiesClipboard(self):
currentRow = self.ui.tableWidgetYourIdentities.currentRow() currentRow = self.ui.tableWidgetYourIdentities.currentRow()
addressAtCurrentRow = self.ui.tableWidgetYourIdentities.item(currentRow,1).text() addressAtCurrentRow = self.ui.tableWidgetYourIdentities.item(
currentRow, 1).text()
clipboard = QtGui.QApplication.clipboard() clipboard = QtGui.QApplication.clipboard()
clipboard.setText(str(addressAtCurrentRow)) clipboard.setText(str(addressAtCurrentRow))
def on_context_menuYourIdentities(self, point):
self.popMenu.exec_( self.ui.tableWidgetYourIdentities.mapToGlobal(point) )
def on_context_menuInbox(self, point):
self.popMenuInbox.exec_( self.ui.tableWidgetInbox.mapToGlobal(point) )
def on_context_menuSent(self, point):
self.popMenuSent = QtGui.QMenu( self )
self.popMenuSent.addAction( self.actionSentClipboard )
self.popMenuSent.addAction( self.actionTrashSentMessage )
#Check to see if this item is toodifficult and display an additional menu option (Force Send) if it is. def on_context_menuYourIdentities(self, point):
self.popMenu.exec_(
self.ui.tableWidgetYourIdentities.mapToGlobal(point))
def on_context_menuInbox(self, point):
self.popMenuInbox.exec_(self.ui.tableWidgetInbox.mapToGlobal(point))
def on_context_menuSent(self, point):
self.popMenuSent = QtGui.QMenu(self)
self.popMenuSent.addAction(self.actionSentClipboard)
self.popMenuSent.addAction(self.actionTrashSentMessage)
# Check to see if this item is toodifficult and display an additional
# menu option (Force Send) if it is.
currentRow = self.ui.tableWidgetSent.currentRow() currentRow = self.ui.tableWidgetSent.currentRow()
ackData = str(self.ui.tableWidgetSent.item(currentRow,3).data(Qt.UserRole).toPyObject()) ackData = str(self.ui.tableWidgetSent.item(
currentRow, 3).data(Qt.UserRole).toPyObject())
shared.sqlLock.acquire() shared.sqlLock.acquire()
shared.sqlSubmitQueue.put('''SELECT status FROM sent where ackdata=?''') shared.sqlSubmitQueue.put(
'''SELECT status FROM sent where ackdata=?''')
shared.sqlSubmitQueue.put((ackData,)) shared.sqlSubmitQueue.put((ackData,))
queryreturn = shared.sqlReturnQueue.get() queryreturn = shared.sqlReturnQueue.get()
shared.sqlLock.release() shared.sqlLock.release()
for row in queryreturn: for row in queryreturn:
status, = row status, = row
if status == 'toodifficult': if status == 'toodifficult':
self.popMenuSent.addAction( self.actionForceSend ) self.popMenuSent.addAction(self.actionForceSend)
self.popMenuSent.exec_( self.ui.tableWidgetSent.mapToGlobal(point) ) self.popMenuSent.exec_(self.ui.tableWidgetSent.mapToGlobal(point))
def tableWidgetInboxItemClicked(self): def tableWidgetInboxItemClicked(self):
currentRow = self.ui.tableWidgetInbox.currentRow() currentRow = self.ui.tableWidgetInbox.currentRow()
if currentRow >= 0: if currentRow >= 0:
fromAddress = str(self.ui.tableWidgetInbox.item(currentRow,1).data(Qt.UserRole).toPyObject()) fromAddress = str(self.ui.tableWidgetInbox.item(
#If we have received this message from either a broadcast address or from someone in our address book, display as HTML currentRow, 1).data(Qt.UserRole).toPyObject())
# If we have received this message from either a broadcast address
# or from someone in our address book, display as HTML
if decodeAddress(fromAddress)[3] in shared.broadcastSendersForWhichImWatching or shared.isAddressInMyAddressBook(fromAddress): if decodeAddress(fromAddress)[3] in shared.broadcastSendersForWhichImWatching or shared.isAddressInMyAddressBook(fromAddress):
if len(self.ui.tableWidgetInbox.item(currentRow,2).data(Qt.UserRole).toPyObject()) < 30000: if len(self.ui.tableWidgetInbox.item(currentRow, 2).data(Qt.UserRole).toPyObject()) < 30000:
self.ui.textEditInboxMessage.setText(self.ui.tableWidgetInbox.item(currentRow,2).data(Qt.UserRole).toPyObject())#Only show the first 30K characters self.ui.textEditInboxMessage.setText(self.ui.tableWidgetInbox.item(
currentRow, 2).data(Qt.UserRole).toPyObject()) # Only show the first 30K characters
else: else:
self.ui.textEditInboxMessage.setText(self.ui.tableWidgetInbox.item(currentRow,2).data(Qt.UserRole).toPyObject()[:30000]+'\n\nDisplay of the remainder of the message truncated because it is too long.')#Only show the first 30K characters self.ui.textEditInboxMessage.setText(self.ui.tableWidgetInbox.item(currentRow, 2).data(Qt.UserRole).toPyObject()[
:30000] + '\n\nDisplay of the remainder of the message truncated because it is too long.') # Only show the first 30K characters
else: else:
if len(self.ui.tableWidgetInbox.item(currentRow,2).data(Qt.UserRole).toPyObject()) < 30000: if len(self.ui.tableWidgetInbox.item(currentRow, 2).data(Qt.UserRole).toPyObject()) < 30000:
self.ui.textEditInboxMessage.setPlainText(self.ui.tableWidgetInbox.item(currentRow,2).data(Qt.UserRole).toPyObject())#Only show the first 30K characters self.ui.textEditInboxMessage.setPlainText(self.ui.tableWidgetInbox.item(
currentRow, 2).data(Qt.UserRole).toPyObject()) # Only show the first 30K characters
else: else:
self.ui.textEditInboxMessage.setPlainText(self.ui.tableWidgetInbox.item(currentRow,2).data(Qt.UserRole).toPyObject()[:30000]+'\n\nDisplay of the remainder of the message truncated because it is too long.')#Only show the first 30K characters self.ui.textEditInboxMessage.setPlainText(self.ui.tableWidgetInbox.item(currentRow, 2).data(Qt.UserRole).toPyObject()[
:30000] + '\n\nDisplay of the remainder of the message truncated because it is too long.') # Only show the first 30K characters
font = QFont() font = QFont()
font.setBold(False) font.setBold(False)
self.ui.tableWidgetInbox.item(currentRow,0).setFont(font) self.ui.tableWidgetInbox.item(currentRow, 0).setFont(font)
self.ui.tableWidgetInbox.item(currentRow,1).setFont(font) self.ui.tableWidgetInbox.item(currentRow, 1).setFont(font)
self.ui.tableWidgetInbox.item(currentRow,2).setFont(font) self.ui.tableWidgetInbox.item(currentRow, 2).setFont(font)
self.ui.tableWidgetInbox.item(currentRow,3).setFont(font) self.ui.tableWidgetInbox.item(currentRow, 3).setFont(font)
inventoryHash = str(self.ui.tableWidgetInbox.item(currentRow,3).data(Qt.UserRole).toPyObject()) inventoryHash = str(self.ui.tableWidgetInbox.item(
currentRow, 3).data(Qt.UserRole).toPyObject())
t = (inventoryHash,) t = (inventoryHash,)
self.ubuntuMessagingMenuClear(t) self.ubuntuMessagingMenuClear(t)
shared.sqlLock.acquire() shared.sqlLock.acquire()
shared.sqlSubmitQueue.put('''update inbox set read=1 WHERE msgid=?''') shared.sqlSubmitQueue.put(
'''update inbox set read=1 WHERE msgid=?''')
shared.sqlSubmitQueue.put(t) shared.sqlSubmitQueue.put(t)
shared.sqlReturnQueue.get() shared.sqlReturnQueue.get()
shared.sqlSubmitQueue.put('commit') shared.sqlSubmitQueue.put('commit')
@ -2091,28 +2502,34 @@ class MyForm(QtGui.QMainWindow):
def tableWidgetSentItemClicked(self): def tableWidgetSentItemClicked(self):
currentRow = self.ui.tableWidgetSent.currentRow() currentRow = self.ui.tableWidgetSent.currentRow()
if currentRow >= 0: if currentRow >= 0:
self.ui.textEditSentMessage.setPlainText(self.ui.tableWidgetSent.item(currentRow,2).data(Qt.UserRole).toPyObject()) self.ui.textEditSentMessage.setPlainText(self.ui.tableWidgetSent.item(
currentRow, 2).data(Qt.UserRole).toPyObject())
def tableWidgetYourIdentitiesItemChanged(self): def tableWidgetYourIdentitiesItemChanged(self):
currentRow = self.ui.tableWidgetYourIdentities.currentRow() currentRow = self.ui.tableWidgetYourIdentities.currentRow()
if currentRow >= 0: if currentRow >= 0:
addressAtCurrentRow = self.ui.tableWidgetYourIdentities.item(currentRow,1).text() addressAtCurrentRow = self.ui.tableWidgetYourIdentities.item(
shared.config.set(str(addressAtCurrentRow),'label',str(self.ui.tableWidgetYourIdentities.item(currentRow,0).text().toUtf8())) currentRow, 1).text()
shared.config.set(str(addressAtCurrentRow), 'label', str(
self.ui.tableWidgetYourIdentities.item(currentRow, 0).text().toUtf8()))
with open(shared.appdata + 'keys.dat', 'wb') as configfile: with open(shared.appdata + 'keys.dat', 'wb') as configfile:
shared.config.write(configfile) shared.config.write(configfile)
self.rerenderComboBoxSendFrom() self.rerenderComboBoxSendFrom()
#self.rerenderInboxFromLabels() # self.rerenderInboxFromLabels()
self.rerenderInboxToLabels() self.rerenderInboxToLabels()
self.rerenderSentFromLabels() self.rerenderSentFromLabels()
#self.rerenderSentToLabels() # self.rerenderSentToLabels()
def tableWidgetAddressBookItemChanged(self): def tableWidgetAddressBookItemChanged(self):
currentRow = self.ui.tableWidgetAddressBook.currentRow() currentRow = self.ui.tableWidgetAddressBook.currentRow()
shared.sqlLock.acquire() shared.sqlLock.acquire()
if currentRow >= 0: if currentRow >= 0:
addressAtCurrentRow = self.ui.tableWidgetAddressBook.item(currentRow,1).text() addressAtCurrentRow = self.ui.tableWidgetAddressBook.item(
t = (str(self.ui.tableWidgetAddressBook.item(currentRow,0).text().toUtf8()),str(addressAtCurrentRow)) currentRow, 1).text()
shared.sqlSubmitQueue.put('''UPDATE addressbook set label=? WHERE address=?''') t = (str(self.ui.tableWidgetAddressBook.item(
currentRow, 0).text().toUtf8()), str(addressAtCurrentRow))
shared.sqlSubmitQueue.put(
'''UPDATE addressbook set label=? WHERE address=?''')
shared.sqlSubmitQueue.put(t) shared.sqlSubmitQueue.put(t)
shared.sqlReturnQueue.get() shared.sqlReturnQueue.get()
shared.sqlSubmitQueue.put('commit') shared.sqlSubmitQueue.put('commit')
@ -2124,9 +2541,12 @@ class MyForm(QtGui.QMainWindow):
currentRow = self.ui.tableWidgetSubscriptions.currentRow() currentRow = self.ui.tableWidgetSubscriptions.currentRow()
shared.sqlLock.acquire() shared.sqlLock.acquire()
if currentRow >= 0: if currentRow >= 0:
addressAtCurrentRow = self.ui.tableWidgetSubscriptions.item(currentRow,1).text() addressAtCurrentRow = self.ui.tableWidgetSubscriptions.item(
t = (str(self.ui.tableWidgetSubscriptions.item(currentRow,0).text().toUtf8()),str(addressAtCurrentRow)) currentRow, 1).text()
shared.sqlSubmitQueue.put('''UPDATE subscriptions set label=? WHERE address=?''') t = (str(self.ui.tableWidgetSubscriptions.item(
currentRow, 0).text().toUtf8()), str(addressAtCurrentRow))
shared.sqlSubmitQueue.put(
'''UPDATE subscriptions set label=? WHERE address=?''')
shared.sqlSubmitQueue.put(t) shared.sqlSubmitQueue.put(t)
shared.sqlReturnQueue.get() shared.sqlReturnQueue.get()
shared.sqlSubmitQueue.put('commit') shared.sqlSubmitQueue.put('commit')
@ -2134,20 +2554,23 @@ class MyForm(QtGui.QMainWindow):
self.rerenderInboxFromLabels() self.rerenderInboxFromLabels()
self.rerenderSentToLabels() self.rerenderSentToLabels()
def writeNewAddressToTable(self,label,address,streamNumber): def writeNewAddressToTable(self, label, address, streamNumber):
self.ui.tableWidgetYourIdentities.setSortingEnabled(False) self.ui.tableWidgetYourIdentities.setSortingEnabled(False)
self.ui.tableWidgetYourIdentities.insertRow(0) self.ui.tableWidgetYourIdentities.insertRow(0)
self.ui.tableWidgetYourIdentities.setItem(0, 0, QtGui.QTableWidgetItem(unicode(label,'utf-8'))) self.ui.tableWidgetYourIdentities.setItem(
0, 0, QtGui.QTableWidgetItem(unicode(label, 'utf-8')))
newItem = QtGui.QTableWidgetItem(address) newItem = QtGui.QTableWidgetItem(address)
newItem.setFlags( QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled ) newItem.setFlags(
QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled)
self.ui.tableWidgetYourIdentities.setItem(0, 1, newItem) self.ui.tableWidgetYourIdentities.setItem(0, 1, newItem)
newItem = QtGui.QTableWidgetItem(streamNumber) newItem = QtGui.QTableWidgetItem(streamNumber)
newItem.setFlags( QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled ) newItem.setFlags(
QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled)
self.ui.tableWidgetYourIdentities.setItem(0, 2, newItem) self.ui.tableWidgetYourIdentities.setItem(0, 2, newItem)
#self.ui.tableWidgetYourIdentities.setSortingEnabled(True) # self.ui.tableWidgetYourIdentities.setSortingEnabled(True)
self.rerenderComboBoxSendFrom() self.rerenderComboBoxSendFrom()
def updateStatusBar(self,data): def updateStatusBar(self, data):
if data != "": if data != "":
shared.printLock.acquire() shared.printLock.acquire()
print 'Status bar:', data print 'Status bar:', data
@ -2155,58 +2578,70 @@ class MyForm(QtGui.QMainWindow):
self.statusBar().showMessage(data) self.statusBar().showMessage(data)
class helpDialog(QtGui.QDialog): class helpDialog(QtGui.QDialog):
def __init__(self,parent):
def __init__(self, parent):
QtGui.QWidget.__init__(self, parent) QtGui.QWidget.__init__(self, parent)
self.ui = Ui_helpDialog() self.ui = Ui_helpDialog()
self.ui.setupUi(self) self.ui.setupUi(self)
self.parent = parent self.parent = parent
self.ui.labelHelpURI.setOpenExternalLinks(True) self.ui.labelHelpURI.setOpenExternalLinks(True)
QtGui.QWidget.resize(self,QtGui.QWidget.sizeHint(self)) QtGui.QWidget.resize(self, QtGui.QWidget.sizeHint(self))
class aboutDialog(QtGui.QDialog): class aboutDialog(QtGui.QDialog):
def __init__(self,parent):
def __init__(self, parent):
QtGui.QWidget.__init__(self, parent) QtGui.QWidget.__init__(self, parent)
self.ui = Ui_aboutDialog() self.ui = Ui_aboutDialog()
self.ui.setupUi(self) self.ui.setupUi(self)
self.parent = parent self.parent = parent
self.ui.labelVersion.setText('version ' + shared.softwareVersion) self.ui.labelVersion.setText('version ' + shared.softwareVersion)
class regenerateAddressesDialog(QtGui.QDialog): class regenerateAddressesDialog(QtGui.QDialog):
def __init__(self,parent):
def __init__(self, parent):
QtGui.QWidget.__init__(self, parent) QtGui.QWidget.__init__(self, parent)
self.ui = Ui_regenerateAddressesDialog() self.ui = Ui_regenerateAddressesDialog()
self.ui.setupUi(self) self.ui.setupUi(self)
self.parent = parent self.parent = parent
QtGui.QWidget.resize(self,QtGui.QWidget.sizeHint(self)) QtGui.QWidget.resize(self, QtGui.QWidget.sizeHint(self))
class settingsDialog(QtGui.QDialog): class settingsDialog(QtGui.QDialog):
def __init__(self,parent):
def __init__(self, parent):
QtGui.QWidget.__init__(self, parent) QtGui.QWidget.__init__(self, parent)
self.ui = Ui_settingsDialog() self.ui = Ui_settingsDialog()
self.ui.setupUi(self) self.ui.setupUi(self)
self.parent = parent self.parent = parent
self.ui.checkBoxStartOnLogon.setChecked(shared.config.getboolean('bitmessagesettings', 'startonlogon')) self.ui.checkBoxStartOnLogon.setChecked(
self.ui.checkBoxMinimizeToTray.setChecked(shared.config.getboolean('bitmessagesettings', 'minimizetotray')) shared.config.getboolean('bitmessagesettings', 'startonlogon'))
self.ui.checkBoxShowTrayNotifications.setChecked(shared.config.getboolean('bitmessagesettings', 'showtraynotifications')) self.ui.checkBoxMinimizeToTray.setChecked(
self.ui.checkBoxStartInTray.setChecked(shared.config.getboolean('bitmessagesettings', 'startintray')) shared.config.getboolean('bitmessagesettings', 'minimizetotray'))
self.ui.checkBoxShowTrayNotifications.setChecked(
shared.config.getboolean('bitmessagesettings', 'showtraynotifications'))
self.ui.checkBoxStartInTray.setChecked(
shared.config.getboolean('bitmessagesettings', 'startintray'))
if shared.appdata == '': if shared.appdata == '':
self.ui.checkBoxPortableMode.setChecked(True) self.ui.checkBoxPortableMode.setChecked(True)
if 'darwin' in sys.platform: if 'darwin' in sys.platform:
self.ui.checkBoxStartOnLogon.setDisabled(True) self.ui.checkBoxStartOnLogon.setDisabled(True)
self.ui.checkBoxMinimizeToTray.setDisabled(True) self.ui.checkBoxMinimizeToTray.setDisabled(True)
self.ui.checkBoxShowTrayNotifications.setDisabled(True) self.ui.checkBoxShowTrayNotifications.setDisabled(True)
self.ui.labelSettingsNote.setText(QtGui.QApplication.translate("MainWindow", "Options have been disabled because they either aren\'t applicable or because they haven\'t yet been implimented for your operating system.")) self.ui.labelSettingsNote.setText(QtGui.QApplication.translate(
"MainWindow", "Options have been disabled because they either aren\'t applicable or because they haven\'t yet been implimented for your operating system."))
elif 'linux' in sys.platform: elif 'linux' in sys.platform:
self.ui.checkBoxStartOnLogon.setDisabled(True) self.ui.checkBoxStartOnLogon.setDisabled(True)
self.ui.checkBoxMinimizeToTray.setDisabled(True) self.ui.checkBoxMinimizeToTray.setDisabled(True)
self.ui.labelSettingsNote.setText(QtGui.QApplication.translate("MainWindow", "Options have been disabled because they either aren\'t applicable or because they haven\'t yet been implimented for your operating system.")) self.ui.labelSettingsNote.setText(QtGui.QApplication.translate(
#On the Network settings tab: "MainWindow", "Options have been disabled because they either aren\'t applicable or because they haven\'t yet been implimented for your operating system."))
self.ui.lineEditTCPPort.setText(str(shared.config.get('bitmessagesettings', 'port'))) # On the Network settings tab:
self.ui.checkBoxAuthentication.setChecked(shared.config.getboolean('bitmessagesettings', 'socksauthentication')) self.ui.lineEditTCPPort.setText(str(
shared.config.get('bitmessagesettings', 'port')))
self.ui.checkBoxAuthentication.setChecked(shared.config.getboolean(
'bitmessagesettings', 'socksauthentication'))
if str(shared.config.get('bitmessagesettings', 'socksproxytype')) == 'none': if str(shared.config.get('bitmessagesettings', 'socksproxytype')) == 'none':
self.ui.comboBoxProxyType.setCurrentIndex(0) self.ui.comboBoxProxyType.setCurrentIndex(0)
self.ui.lineEditSocksHostname.setEnabled(False) self.ui.lineEditSocksHostname.setEnabled(False)
@ -2221,18 +2656,27 @@ class settingsDialog(QtGui.QDialog):
self.ui.comboBoxProxyType.setCurrentIndex(2) self.ui.comboBoxProxyType.setCurrentIndex(2)
self.ui.lineEditTCPPort.setEnabled(False) self.ui.lineEditTCPPort.setEnabled(False)
self.ui.lineEditSocksHostname.setText(str(shared.config.get('bitmessagesettings', 'sockshostname'))) self.ui.lineEditSocksHostname.setText(str(
self.ui.lineEditSocksPort.setText(str(shared.config.get('bitmessagesettings', 'socksport'))) shared.config.get('bitmessagesettings', 'sockshostname')))
self.ui.lineEditSocksUsername.setText(str(shared.config.get('bitmessagesettings', 'socksusername'))) self.ui.lineEditSocksPort.setText(str(
self.ui.lineEditSocksPassword.setText(str(shared.config.get('bitmessagesettings', 'sockspassword'))) shared.config.get('bitmessagesettings', 'socksport')))
QtCore.QObject.connect(self.ui.comboBoxProxyType, QtCore.SIGNAL("currentIndexChanged(int)"), self.comboBoxProxyTypeChanged) self.ui.lineEditSocksUsername.setText(str(
shared.config.get('bitmessagesettings', 'socksusername')))
self.ui.lineEditSocksPassword.setText(str(
shared.config.get('bitmessagesettings', 'sockspassword')))
QtCore.QObject.connect(self.ui.comboBoxProxyType, QtCore.SIGNAL(
"currentIndexChanged(int)"), self.comboBoxProxyTypeChanged)
self.ui.lineEditTotalDifficulty.setText(str((float(shared.config.getint('bitmessagesettings', 'defaultnoncetrialsperbyte'))/shared.networkDefaultProofOfWorkNonceTrialsPerByte))) self.ui.lineEditTotalDifficulty.setText(str((float(shared.config.getint(
self.ui.lineEditSmallMessageDifficulty.setText(str((float(shared.config.getint('bitmessagesettings', 'defaultpayloadlengthextrabytes'))/shared.networkDefaultPayloadLengthExtraBytes))) 'bitmessagesettings', 'defaultnoncetrialsperbyte')) / shared.networkDefaultProofOfWorkNonceTrialsPerByte)))
self.ui.lineEditSmallMessageDifficulty.setText(str((float(shared.config.getint(
'bitmessagesettings', 'defaultpayloadlengthextrabytes')) / shared.networkDefaultPayloadLengthExtraBytes)))
#Max acceptable difficulty tab # Max acceptable difficulty tab
self.ui.lineEditMaxAcceptableTotalDifficulty.setText(str((float(shared.config.getint('bitmessagesettings', 'maxacceptablenoncetrialsperbyte'))/shared.networkDefaultProofOfWorkNonceTrialsPerByte))) self.ui.lineEditMaxAcceptableTotalDifficulty.setText(str((float(shared.config.getint(
self.ui.lineEditMaxAcceptableSmallMessageDifficulty.setText(str((float(shared.config.getint('bitmessagesettings', 'maxacceptablepayloadlengthextrabytes'))/shared.networkDefaultPayloadLengthExtraBytes))) 'bitmessagesettings', 'maxacceptablenoncetrialsperbyte')) / shared.networkDefaultProofOfWorkNonceTrialsPerByte)))
self.ui.lineEditMaxAcceptableSmallMessageDifficulty.setText(str((float(shared.config.getint(
'bitmessagesettings', 'maxacceptablepayloadlengthextrabytes')) / shared.networkDefaultPayloadLengthExtraBytes)))
#'System' tab removed for now. #'System' tab removed for now.
"""try: """try:
@ -2252,9 +2696,9 @@ class settingsDialog(QtGui.QDialog):
else: else:
self.ui.comboBoxMaxCores.setCurrentIndex(5)""" self.ui.comboBoxMaxCores.setCurrentIndex(5)"""
QtGui.QWidget.resize(self,QtGui.QWidget.sizeHint(self)) QtGui.QWidget.resize(self, QtGui.QWidget.sizeHint(self))
def comboBoxProxyTypeChanged(self,comboBoxIndex): def comboBoxProxyTypeChanged(self, comboBoxIndex):
if comboBoxIndex == 0: if comboBoxIndex == 0:
self.ui.lineEditSocksHostname.setEnabled(False) self.ui.lineEditSocksHostname.setEnabled(False)
self.ui.lineEditSocksPort.setEnabled(False) self.ui.lineEditSocksPort.setEnabled(False)
@ -2271,84 +2715,111 @@ class settingsDialog(QtGui.QDialog):
self.ui.lineEditSocksPassword.setEnabled(True) self.ui.lineEditSocksPassword.setEnabled(True)
self.ui.lineEditTCPPort.setEnabled(False) self.ui.lineEditTCPPort.setEnabled(False)
class SpecialAddressBehaviorDialog(QtGui.QDialog): class SpecialAddressBehaviorDialog(QtGui.QDialog):
def __init__(self,parent):
def __init__(self, parent):
QtGui.QWidget.__init__(self, parent) QtGui.QWidget.__init__(self, parent)
self.ui = Ui_SpecialAddressBehaviorDialog() self.ui = Ui_SpecialAddressBehaviorDialog()
self.ui.setupUi(self) self.ui.setupUi(self)
self.parent = parent self.parent = parent
currentRow = parent.ui.tableWidgetYourIdentities.currentRow() currentRow = parent.ui.tableWidgetYourIdentities.currentRow()
addressAtCurrentRow = str(parent.ui.tableWidgetYourIdentities.item(currentRow,1).text()) addressAtCurrentRow = str(
if shared.safeConfigGetBoolean(addressAtCurrentRow,'mailinglist'): parent.ui.tableWidgetYourIdentities.item(currentRow, 1).text())
if shared.safeConfigGetBoolean(addressAtCurrentRow, 'mailinglist'):
self.ui.radioButtonBehaviorMailingList.click() self.ui.radioButtonBehaviorMailingList.click()
else: else:
self.ui.radioButtonBehaveNormalAddress.click() self.ui.radioButtonBehaveNormalAddress.click()
try: try:
mailingListName = shared.config.get(addressAtCurrentRow, 'mailinglistname') mailingListName = shared.config.get(
addressAtCurrentRow, 'mailinglistname')
except: except:
mailingListName = '' mailingListName = ''
self.ui.lineEditMailingListName.setText(unicode(mailingListName,'utf-8')) self.ui.lineEditMailingListName.setText(
QtGui.QWidget.resize(self,QtGui.QWidget.sizeHint(self)) unicode(mailingListName, 'utf-8'))
QtGui.QWidget.resize(self, QtGui.QWidget.sizeHint(self))
class NewSubscriptionDialog(QtGui.QDialog): class NewSubscriptionDialog(QtGui.QDialog):
def __init__(self,parent):
def __init__(self, parent):
QtGui.QWidget.__init__(self, parent) QtGui.QWidget.__init__(self, parent)
self.ui = Ui_NewSubscriptionDialog() self.ui = Ui_NewSubscriptionDialog()
self.ui.setupUi(self) self.ui.setupUi(self)
self.parent = parent self.parent = parent
QtCore.QObject.connect(self.ui.lineEditSubscriptionAddress, QtCore.SIGNAL("textChanged(QString)"), self.subscriptionAddressChanged) QtCore.QObject.connect(self.ui.lineEditSubscriptionAddress, QtCore.SIGNAL(
"textChanged(QString)"), self.subscriptionAddressChanged)
def subscriptionAddressChanged(self,QString): def subscriptionAddressChanged(self, QString):
status,a,b,c = decodeAddress(str(QString)) status, a, b, c = decodeAddress(str(QString))
if status == 'missingbm': if status == 'missingbm':
self.ui.labelSubscriptionAddressCheck.setText(QtGui.QApplication.translate("MainWindow", "The address should start with ''BM-''")) self.ui.labelSubscriptionAddressCheck.setText(QtGui.QApplication.translate(
"MainWindow", "The address should start with ''BM-''"))
elif status == 'checksumfailed': elif status == 'checksumfailed':
self.ui.labelSubscriptionAddressCheck.setText(QtGui.QApplication.translate("MainWindow", "The address is not typed or copied correctly (the checksum failed).")) self.ui.labelSubscriptionAddressCheck.setText(QtGui.QApplication.translate(
"MainWindow", "The address is not typed or copied correctly (the checksum failed)."))
elif status == 'versiontoohigh': elif status == 'versiontoohigh':
self.ui.labelSubscriptionAddressCheck.setText(QtGui.QApplication.translate("MainWindow", "The version number of this address is higher than this software can support. Please upgrade Bitmessage.")) self.ui.labelSubscriptionAddressCheck.setText(QtGui.QApplication.translate(
"MainWindow", "The version number of this address is higher than this software can support. Please upgrade Bitmessage."))
elif status == 'invalidcharacters': elif status == 'invalidcharacters':
self.ui.labelSubscriptionAddressCheck.setText(QtGui.QApplication.translate("MainWindow", "The address contains invalid characters.")) self.ui.labelSubscriptionAddressCheck.setText(QtGui.QApplication.translate(
"MainWindow", "The address contains invalid characters."))
elif status == 'ripetooshort': elif status == 'ripetooshort':
self.ui.labelSubscriptionAddressCheck.setText(QtGui.QApplication.translate("MainWindow", "Some data encoded in the address is too short.")) self.ui.labelSubscriptionAddressCheck.setText(QtGui.QApplication.translate(
"MainWindow", "Some data encoded in the address is too short."))
elif status == 'ripetoolong': elif status == 'ripetoolong':
self.ui.labelSubscriptionAddressCheck.setText(QtGui.QApplication.translate("MainWindow", "Some data encoded in the address is too long.")) self.ui.labelSubscriptionAddressCheck.setText(QtGui.QApplication.translate(
"MainWindow", "Some data encoded in the address is too long."))
elif status == 'success': elif status == 'success':
self.ui.labelSubscriptionAddressCheck.setText(QtGui.QApplication.translate("MainWindow", "Address is valid.")) self.ui.labelSubscriptionAddressCheck.setText(
QtGui.QApplication.translate("MainWindow", "Address is valid."))
class NewAddressDialog(QtGui.QDialog): class NewAddressDialog(QtGui.QDialog):
def __init__(self, parent): def __init__(self, parent):
QtGui.QWidget.__init__(self, parent) QtGui.QWidget.__init__(self, parent)
self.ui = Ui_NewAddressDialog() self.ui = Ui_NewAddressDialog()
self.ui.setupUi(self) self.ui.setupUi(self)
self.parent = parent self.parent = parent
row = 1 row = 1
#Let's fill out the 'existing address' combo box with addresses from the 'Your Identities' tab. # Let's fill out the 'existing address' combo box with addresses from
while self.parent.ui.tableWidgetYourIdentities.item(row-1,1): # the 'Your Identities' tab.
while self.parent.ui.tableWidgetYourIdentities.item(row - 1, 1):
self.ui.radioButtonExisting.click() self.ui.radioButtonExisting.click()
#print self.parent.ui.tableWidgetYourIdentities.item(row-1,1).text() # print
self.ui.comboBoxExisting.addItem(self.parent.ui.tableWidgetYourIdentities.item(row-1,1).text()) # self.parent.ui.tableWidgetYourIdentities.item(row-1,1).text()
self.ui.comboBoxExisting.addItem(
self.parent.ui.tableWidgetYourIdentities.item(row - 1, 1).text())
row += 1 row += 1
self.ui.groupBoxDeterministic.setHidden(True) self.ui.groupBoxDeterministic.setHidden(True)
QtGui.QWidget.resize(self,QtGui.QWidget.sizeHint(self)) QtGui.QWidget.resize(self, QtGui.QWidget.sizeHint(self))
class iconGlossaryDialog(QtGui.QDialog): class iconGlossaryDialog(QtGui.QDialog):
def __init__(self,parent):
def __init__(self, parent):
QtGui.QWidget.__init__(self, parent) QtGui.QWidget.__init__(self, parent)
self.ui = Ui_iconGlossaryDialog() self.ui = Ui_iconGlossaryDialog()
self.ui.setupUi(self) self.ui.setupUi(self)
self.parent = parent self.parent = parent
self.ui.labelPortNumber.setText(QtGui.QApplication.translate("MainWindow", "You are using TCP port %1. (This can be changed in the settings).").arg(str(shared.config.getint('bitmessagesettings', 'port')))) self.ui.labelPortNumber.setText(QtGui.QApplication.translate(
QtGui.QWidget.resize(self,QtGui.QWidget.sizeHint(self)) "MainWindow", "You are using TCP port %1. (This can be changed in the settings).").arg(str(shared.config.getint('bitmessagesettings', 'port'))))
QtGui.QWidget.resize(self, QtGui.QWidget.sizeHint(self))
#In order for the time columns on the Inbox and Sent tabs to be sorted correctly (rather than alphabetically), we need to overload the < operator and use this class instead of QTableWidgetItem. # In order for the time columns on the Inbox and Sent tabs to be sorted
# correctly (rather than alphabetically), we need to overload the <
# operator and use this class instead of QTableWidgetItem.
class myTableWidgetItem(QTableWidgetItem): class myTableWidgetItem(QTableWidgetItem):
def __lt__(self,other):
def __lt__(self, other):
return int(self.data(33).toPyObject()) < int(other.data(33).toPyObject()) return int(self.data(33).toPyObject()) < int(other.data(33).toPyObject())
class UISignaler(QThread): class UISignaler(QThread):
def __init__(self, parent = None):
def __init__(self, parent=None):
QThread.__init__(self, parent) QThread.__init__(self, parent)
def run(self): def run(self):
@ -2356,21 +2827,28 @@ class UISignaler(QThread):
command, data = shared.UISignalQueue.get() command, data = shared.UISignalQueue.get()
if command == 'writeNewAddressToTable': if command == 'writeNewAddressToTable':
label, address, streamNumber = data label, address, streamNumber = data
self.emit(SIGNAL("writeNewAddressToTable(PyQt_PyObject,PyQt_PyObject,PyQt_PyObject)"),label,address,str(streamNumber)) self.emit(SIGNAL(
"writeNewAddressToTable(PyQt_PyObject,PyQt_PyObject,PyQt_PyObject)"), label, address, str(streamNumber))
elif command == 'updateStatusBar': elif command == 'updateStatusBar':
self.emit(SIGNAL("updateStatusBar(PyQt_PyObject)"),data) self.emit(SIGNAL("updateStatusBar(PyQt_PyObject)"), data)
elif command == 'updateSentItemStatusByHash': elif command == 'updateSentItemStatusByHash':
hash, message = data hash, message = data
self.emit(SIGNAL("updateSentItemStatusByHash(PyQt_PyObject,PyQt_PyObject)"),hash,message) self.emit(SIGNAL(
"updateSentItemStatusByHash(PyQt_PyObject,PyQt_PyObject)"), hash, message)
elif command == 'updateSentItemStatusByAckdata': elif command == 'updateSentItemStatusByAckdata':
ackData, message = data ackData, message = data
self.emit(SIGNAL("updateSentItemStatusByAckdata(PyQt_PyObject,PyQt_PyObject)"),ackData,message) self.emit(SIGNAL(
"updateSentItemStatusByAckdata(PyQt_PyObject,PyQt_PyObject)"), ackData, message)
elif command == 'displayNewInboxMessage': elif command == 'displayNewInboxMessage':
inventoryHash,toAddress,fromAddress,subject,body = data inventoryHash, toAddress, fromAddress, subject, body = data
self.emit(SIGNAL("displayNewInboxMessage(PyQt_PyObject,PyQt_PyObject,PyQt_PyObject,PyQt_PyObject,PyQt_PyObject)"),inventoryHash,toAddress,fromAddress,subject,body) self.emit(SIGNAL(
"displayNewInboxMessage(PyQt_PyObject,PyQt_PyObject,PyQt_PyObject,PyQt_PyObject,PyQt_PyObject)"),
inventoryHash, toAddress, fromAddress, subject, body)
elif command == 'displayNewSentMessage': elif command == 'displayNewSentMessage':
toAddress,fromLabel,fromAddress,subject,message,ackdata = data toAddress, fromLabel, fromAddress, subject, message, ackdata = data
self.emit(SIGNAL("displayNewSentMessage(PyQt_PyObject,PyQt_PyObject,PyQt_PyObject,PyQt_PyObject,PyQt_PyObject,PyQt_PyObject)"),toAddress,fromLabel,fromAddress,subject,message,ackdata) self.emit(SIGNAL(
"displayNewSentMessage(PyQt_PyObject,PyQt_PyObject,PyQt_PyObject,PyQt_PyObject,PyQt_PyObject,PyQt_PyObject)"),
toAddress, fromLabel, fromAddress, subject, message, ackdata)
elif command == 'updateNetworkStatusTab': elif command == 'updateNetworkStatusTab':
self.emit(SIGNAL("updateNetworkStatusTab()")) self.emit(SIGNAL("updateNetworkStatusTab()"))
elif command == 'incrementNumberOfMessagesProcessed': elif command == 'incrementNumberOfMessagesProcessed':
@ -2380,20 +2858,22 @@ class UISignaler(QThread):
elif command == 'incrementNumberOfBroadcastsProcessed': elif command == 'incrementNumberOfBroadcastsProcessed':
self.emit(SIGNAL("incrementNumberOfBroadcastsProcessed()")) self.emit(SIGNAL("incrementNumberOfBroadcastsProcessed()"))
elif command == 'setStatusIcon': elif command == 'setStatusIcon':
self.emit(SIGNAL("setStatusIcon(PyQt_PyObject)"),data) self.emit(SIGNAL("setStatusIcon(PyQt_PyObject)"), data)
elif command == 'rerenderInboxFromLabels': elif command == 'rerenderInboxFromLabels':
self.emit(SIGNAL("rerenderInboxFromLabels()")) self.emit(SIGNAL("rerenderInboxFromLabels()"))
elif command == 'rerenderSubscriptions': elif command == 'rerenderSubscriptions':
self.emit(SIGNAL("rerenderSubscriptions()")) self.emit(SIGNAL("rerenderSubscriptions()"))
elif command == 'removeInboxRowByMsgid': elif command == 'removeInboxRowByMsgid':
self.emit(SIGNAL("removeInboxRowByMsgid(PyQt_PyObject)"),data) self.emit(SIGNAL("removeInboxRowByMsgid(PyQt_PyObject)"), data)
else: else:
sys.stderr.write('Command sent to UISignaler not recognized: %s\n' % command) sys.stderr.write(
'Command sent to UISignaler not recognized: %s\n' % command)
def run(): def run():
app = QtGui.QApplication(sys.argv) app = QtGui.QApplication(sys.argv)
translator = QtCore.QTranslator() translator = QtCore.QTranslator()
translator.load("translations/bitmessage_"+str(locale.getlocale()[0])) translator.load("translations/bitmessage_" + str(locale.getlocale()[0]))
QtGui.QApplication.installTranslator(translator) QtGui.QApplication.installTranslator(translator)
app.setStyleSheet("QStatusBar::item { border: 0px solid black }") app.setStyleSheet("QStatusBar::item { border: 0px solid black }")
myapp = MyForm() myapp = MyForm()