try: from PyQt4.QtCore import * from PyQt4.QtGui import * except Exception, 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 'Error message:', err sys.exit() from addresses import * import shared from bitmessageui import * from newaddressdialog import * from newsubscriptiondialog import * from regenerateaddresses import * from specialaddressbehavior import * from settings import * from about import * from help import * from iconglossary import * import sys from time import strftime, localtime, gmtime import time import os from pyelliptic.openssl import OpenSSL class MyForm(QtGui.QMainWindow): def __init__(self, parent=None): QtGui.QWidget.__init__(self, parent) self.ui = Ui_MainWindow() self.ui.setupUi(self) #Ask the user if we may delete their old version 1 addresses if they have any. configSections = shared.config.sections() for addressInKeysFile in configSections: if addressInKeysFile <> 'bitmessagesettings': status,addressVersionNumber,streamNumber,hash = decodeAddress(addressInKeysFile) 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?" reply = QtGui.QMessageBox.question(self, 'Message',displayMsg, QtGui.QMessageBox.Yes, QtGui.QMessageBox.No) if reply == QtGui.QMessageBox.Yes: shared.config.remove_section(addressInKeysFile) with open(shared.appdata + 'keys.dat', 'wb') as configfile: shared.config.write(configfile) #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: #Auto-startup for Windows RUN_PATH = "HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Run" 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. if shared.config.getboolean('bitmessagesettings', 'startonlogon'): self.settings.setValue("PyBitmessage",sys.argv[0]) elif 'darwin' in sys.platform: #startup for mac pass elif 'linux' in sys.platform: #startup for linux pass self.trayIcon = QtGui.QSystemTrayIcon(self) self.trayIcon.setIcon( QtGui.QIcon(':/newPrefix/images/can-icon-16px.png') ) traySignal = "activated(QSystemTrayIcon::ActivationReason)" QtCore.QObject.connect(self.trayIcon, QtCore.SIGNAL(traySignal), self.__icon_activated) menu = QtGui.QMenu() self.exitAction = menu.addAction("Exit", self.close) self.trayIcon.setContextMenu(menu) #I'm currently under the impression that Mac users have different expectations for the tray icon. They don't necessairly expect it to open the main window when clicked and they still expect a program showing a tray icon to also be in the dock. if 'darwin' in sys.platform: self.trayIcon.show() self.ui.labelSendBroadcastWarning.setVisible(False) #FILE MENU and other buttons QtCore.QObject.connect(self.ui.actionExit, QtCore.SIGNAL("triggered()"), self.close) QtCore.QObject.connect(self.ui.actionManageKeys, QtCore.SIGNAL("triggered()"), self.click_actionManageKeys) QtCore.QObject.connect(self.ui.actionRegenerateDeterministicAddresses, QtCore.SIGNAL("triggered()"), self.click_actionRegenerateDeterministicAddresses) QtCore.QObject.connect(self.ui.pushButtonNewAddress, QtCore.SIGNAL("clicked()"), self.click_NewAddressDialog) QtCore.QObject.connect(self.ui.comboBoxSendFrom, QtCore.SIGNAL("activated(int)"),self.redrawLabelFrom) QtCore.QObject.connect(self.ui.pushButtonAddAddressBook, QtCore.SIGNAL("clicked()"), self.click_pushButtonAddAddressBook) QtCore.QObject.connect(self.ui.pushButtonAddSubscription, QtCore.SIGNAL("clicked()"), self.click_pushButtonAddSubscription) 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 self.ui.inboxContextMenuToolbar = QtGui.QToolBar() # Actions self.actionReply = self.ui.inboxContextMenuToolbar.addAction("Reply", self.on_action_InboxReply) self.actionAddSenderToAddressBook = self.ui.inboxContextMenuToolbar.addAction("Add sender to your Address Book", self.on_action_InboxAddSenderToAddressBook) self.actionTrashInboxMessage = self.ui.inboxContextMenuToolbar.addAction("Move to Trash", self.on_action_InboxTrash) self.actionForceHtml = self.ui.inboxContextMenuToolbar.addAction("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.addAction( self.actionReply ) self.popMenuInbox.addAction( self.actionAddSenderToAddressBook ) self.popMenuInbox.addSeparator() self.popMenuInbox.addAction( self.actionTrashInboxMessage ) #Popup menu for the Your Identities tab self.ui.addressContextMenuToolbar = QtGui.QToolBar() # Actions self.actionNew = self.ui.addressContextMenuToolbar.addAction("New", self.on_action_YourIdentitiesNew) self.actionEnable = self.ui.addressContextMenuToolbar.addAction("Enable", self.on_action_YourIdentitiesEnable) self.actionDisable = self.ui.addressContextMenuToolbar.addAction("Disable", self.on_action_YourIdentitiesDisable) self.actionClipboard = self.ui.addressContextMenuToolbar.addAction("Copy address to clipboard", self.on_action_YourIdentitiesClipboard) self.actionSpecialAddressBehavior = self.ui.addressContextMenuToolbar.addAction("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.addAction( self.actionClipboard ) self.popMenu.addSeparator() self.popMenu.addAction( self.actionEnable ) self.popMenu.addAction( self.actionDisable ) self.popMenu.addAction( self.actionSpecialAddressBehavior ) #Popup menu for the Address Book page self.ui.addressBookContextMenuToolbar = QtGui.QToolBar() # Actions self.actionAddressBookSend = self.ui.addressBookContextMenuToolbar.addAction("Send message to this address", self.on_action_AddressBookSend) self.actionAddressBookClipboard = self.ui.addressBookContextMenuToolbar.addAction("Copy address to clipboard", self.on_action_AddressBookClipboard) self.actionAddressBookNew = self.ui.addressBookContextMenuToolbar.addAction("Add New Address", self.on_action_AddressBookNew) self.actionAddressBookDelete = self.ui.addressBookContextMenuToolbar.addAction("Delete", self.on_action_AddressBookDelete) 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.addAction( self.actionAddressBookNew ) self.popMenuAddressBook.addAction( self.actionAddressBookDelete ) #Popup menu for the Subscriptions page self.ui.subscriptionsContextMenuToolbar = QtGui.QToolBar() # Actions self.actionsubscriptionsNew = self.ui.subscriptionsContextMenuToolbar.addAction("New", self.on_action_SubscriptionsNew) self.actionsubscriptionsDelete = self.ui.subscriptionsContextMenuToolbar.addAction("Delete", self.on_action_SubscriptionsDelete) self.actionsubscriptionsClipboard = self.ui.subscriptionsContextMenuToolbar.addAction("Copy address to clipboard", self.on_action_SubscriptionsClipboard) self.actionsubscriptionsEnable = self.ui.subscriptionsContextMenuToolbar.addAction("Enable", self.on_action_SubscriptionsEnable) self.actionsubscriptionsDisable = self.ui.subscriptionsContextMenuToolbar.addAction("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.addAction( self.actionsubscriptionsEnable ) self.popMenuSubscriptions.addAction( self.actionsubscriptionsDisable ) self.popMenuSubscriptions.addSeparator() self.popMenuSubscriptions.addAction( self.actionsubscriptionsClipboard ) #Popup menu for the Sent page self.ui.sentContextMenuToolbar = QtGui.QToolBar() # Actions self.actionTrashSentMessage = self.ui.sentContextMenuToolbar.addAction("Move to Trash", self.on_action_SentTrash) self.actionSentClipboard = self.ui.sentContextMenuToolbar.addAction("Copy destination address to clipboard", self.on_action_SentClipboard) self.ui.tableWidgetSent.setContextMenuPolicy( 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 self.ui.blacklistContextMenuToolbar = QtGui.QToolBar() # Actions self.actionBlacklistNew = self.ui.blacklistContextMenuToolbar.addAction("Add new entry", self.on_action_BlacklistNew) self.actionBlacklistDelete = self.ui.blacklistContextMenuToolbar.addAction("Delete", self.on_action_BlacklistDelete) self.actionBlacklistClipboard = self.ui.blacklistContextMenuToolbar.addAction("Copy address to clipboard", self.on_action_BlacklistClipboard) self.actionBlacklistEnable = self.ui.blacklistContextMenuToolbar.addAction("Enable", self.on_action_BlacklistEnable) self.actionBlacklistDisable = self.ui.blacklistContextMenuToolbar.addAction("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.addAction( self.actionBlacklistClipboard ) self.popMenuBlacklist.addSeparator() self.popMenuBlacklist.addAction( self.actionBlacklistEnable ) self.popMenuBlacklist.addAction( self.actionBlacklistDisable ) #Initialize the user's list of addresses on the 'Your Identities' tab. configSections = shared.config.sections() for addressInKeysFile in configSections: if addressInKeysFile <> 'bitmessagesettings': isEnabled = shared.config.getboolean(addressInKeysFile, 'enabled') newItem = QtGui.QTableWidgetItem(unicode(shared.config.get(addressInKeysFile, 'label'),'utf-8)')) if not isEnabled: newItem.setTextColor(QtGui.QColor(128,128,128)) self.ui.tableWidgetYourIdentities.insertRow(0) self.ui.tableWidgetYourIdentities.setItem(0, 0, newItem) newItem = QtGui.QTableWidgetItem(addressInKeysFile) newItem.setFlags( QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled ) if not isEnabled: newItem.setTextColor(QtGui.QColor(128,128,128)) if shared.safeConfigGetBoolean(addressInKeysFile,'mailinglist'): newItem.setTextColor(QtGui.QColor(137,04,177))#magenta self.ui.tableWidgetYourIdentities.setItem(0, 1, newItem) newItem = QtGui.QTableWidgetItem(str(addressStream(addressInKeysFile))) newItem.setFlags( QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled ) if not isEnabled: newItem.setTextColor(QtGui.QColor(128,128,128)) self.ui.tableWidgetYourIdentities.setItem(0, 2, newItem) if isEnabled: status,addressVersionNumber,streamNumber,hash = decodeAddress(addressInKeysFile) #self.sqlLookup = sqlThread() #self.sqlLookup.start() self.ui.tableWidgetSent.keyPressEvent = self.tableWidgetSentKeyPressEvent font = QFont() font.setBold(True) #Load inbox from messages database file 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('') queryreturn = shared.sqlReturnQueue.get() shared.sqlLock.release() for row in queryreturn: msgid, toAddress, fromAddress, subject, received, message, read = row try: if toAddress == '[Broadcast subscribers]': toLabel = '[Broadcast subscribers]' else: toLabel = shared.config.get(toAddress, 'label') except: toLabel = '' if toLabel == '': toLabel = toAddress fromLabel = '' t = (fromAddress,) shared.sqlLock.acquire() shared.sqlSubmitQueue.put('''select label from addressbook where address=?''') shared.sqlSubmitQueue.put(t) queryreturn = shared.sqlReturnQueue.get() shared.sqlLock.release() if queryreturn <> []: for row in queryreturn: fromLabel, = row if fromLabel == '': #If this address wasn't in our address book.. t = (fromAddress,) shared.sqlLock.acquire() shared.sqlSubmitQueue.put('''select label from subscriptions where address=?''') shared.sqlSubmitQueue.put(t) queryreturn = shared.sqlReturnQueue.get() shared.sqlLock.release() if queryreturn <> []: for row in queryreturn: fromLabel, = row self.ui.tableWidgetInbox.insertRow(0) newItem = QtGui.QTableWidgetItem(unicode(toLabel,'utf-8')) newItem.setFlags( QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled ) if not read: newItem.setFont(font) newItem.setData(Qt.UserRole,str(toAddress)) if shared.safeConfigGetBoolean(toAddress,'mailinglist'): newItem.setTextColor(QtGui.QColor(137,04,177)) self.ui.tableWidgetInbox.setItem(0,0,newItem) if fromLabel == '': newItem = QtGui.QTableWidgetItem(unicode(fromAddress,'utf-8')) else: newItem = QtGui.QTableWidgetItem(unicode(fromLabel,'utf-8')) newItem.setFlags( QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled ) if not read: newItem.setFont(font) newItem.setData(Qt.UserRole,str(fromAddress)) self.ui.tableWidgetInbox.setItem(0,1,newItem) newItem = QtGui.QTableWidgetItem(unicode(subject,'utf-8')) newItem.setData(Qt.UserRole,unicode(message,'utf-8)')) newItem.setFlags( QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled ) if not read: newItem.setFont(font) self.ui.tableWidgetInbox.setItem(0,2,newItem) newItem = myTableWidgetItem(unicode(strftime(shared.config.get('bitmessagesettings', 'timeformat'),localtime(int(received))),'utf-8')) newItem.setData(Qt.UserRole,QByteArray(msgid)) newItem.setData(33,int(received)) newItem.setFlags( QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled ) if not read: newItem.setFont(font) self.ui.tableWidgetInbox.setItem(0,3,newItem) self.ui.tableWidgetInbox.sortItems(3,Qt.DescendingOrder) self.ui.tableWidgetInbox.keyPressEvent = self.tableWidgetInboxKeyPressEvent #Load Sent items from database 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('') queryreturn = shared.sqlReturnQueue.get() shared.sqlLock.release() for row in queryreturn: toAddress, fromAddress, subject, message, status, ackdata, lastactiontime = row try: fromLabel = shared.config.get(fromAddress, 'label') except: fromLabel = '' if fromLabel == '': fromLabel = fromAddress toLabel = '' t = (toAddress,) shared.sqlLock.acquire() shared.sqlSubmitQueue.put('''select label from addressbook where address=?''') shared.sqlSubmitQueue.put(t) queryreturn = shared.sqlReturnQueue.get() shared.sqlLock.release() if queryreturn <> []: for row in queryreturn: toLabel, = row self.ui.tableWidgetSent.insertRow(0) if toLabel == '': newItem = QtGui.QTableWidgetItem(unicode(toAddress,'utf-8')) else: newItem = QtGui.QTableWidgetItem(unicode(toLabel,'utf-8')) newItem.setData(Qt.UserRole,str(toAddress)) newItem.setFlags( QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled ) self.ui.tableWidgetSent.setItem(0,0,newItem) if fromLabel == '': newItem = QtGui.QTableWidgetItem(unicode(fromAddress,'utf-8')) else: newItem = QtGui.QTableWidgetItem(unicode(fromLabel,'utf-8')) newItem.setData(Qt.UserRole,str(fromAddress)) newItem.setFlags( QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled ) self.ui.tableWidgetSent.setItem(0,1,newItem) newItem = QtGui.QTableWidgetItem(unicode(subject,'utf-8')) newItem.setData(Qt.UserRole,unicode(message,'utf-8)')) newItem.setFlags( QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled ) self.ui.tableWidgetSent.setItem(0,2,newItem) if status == 'findingpubkey': newItem = myTableWidgetItem('Waiting on their public key. Will request it again soon.') elif status == 'sentmessage': newItem = myTableWidgetItem('Message sent. Waiting on acknowledgement. Sent at ' + unicode(strftime(shared.config.get('bitmessagesettings', 'timeformat'),localtime(lastactiontime)),'utf-8')) elif status == 'doingpow': newItem = myTableWidgetItem('Need to do work to send message. Work is queued.') elif status == 'ackreceived': newItem = myTableWidgetItem('Acknowledgement of the message received ' + unicode(strftime(shared.config.get('bitmessagesettings', 'timeformat'),localtime(int(lastactiontime))),'utf-8')) elif status == 'broadcastpending': newItem = myTableWidgetItem('Doing the work necessary to send broadcast...') elif status == 'broadcastsent': newItem = myTableWidgetItem('Broadcast on ' + unicode(strftime(shared.config.get('bitmessagesettings', 'timeformat'),localtime(int(lastactiontime))),'utf-8')) else: newItem = myTableWidgetItem('Unknown status. ' + unicode(strftime(shared.config.get('bitmessagesettings', 'timeformat'),localtime(int(lastactiontime))),'utf-8')) newItem.setData(Qt.UserRole,QByteArray(ackdata)) newItem.setData(33,int(lastactiontime)) newItem.setFlags( QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled ) self.ui.tableWidgetSent.setItem(0,3,newItem) self.ui.tableWidgetSent.sortItems(3,Qt.DescendingOrder) #Initialize the address book shared.sqlLock.acquire() shared.sqlSubmitQueue.put('SELECT * FROM addressbook') shared.sqlSubmitQueue.put('') queryreturn = shared.sqlReturnQueue.get() shared.sqlLock.release() for row in queryreturn: label, address = row self.ui.tableWidgetAddressBook.insertRow(0) newItem = QtGui.QTableWidgetItem(unicode(label,'utf-8')) self.ui.tableWidgetAddressBook.setItem(0,0,newItem) newItem = QtGui.QTableWidgetItem(address) newItem.setFlags( QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled ) self.ui.tableWidgetAddressBook.setItem(0,1,newItem) #Initialize the Subscriptions shared.sqlLock.acquire() shared.sqlSubmitQueue.put('SELECT label, address, enabled FROM subscriptions') shared.sqlSubmitQueue.put('') queryreturn = shared.sqlReturnQueue.get() shared.sqlLock.release() for row in queryreturn: label, address, enabled = row self.ui.tableWidgetSubscriptions.insertRow(0) newItem = QtGui.QTableWidgetItem(unicode(label,'utf-8')) if not enabled: newItem.setTextColor(QtGui.QColor(128,128,128)) self.ui.tableWidgetSubscriptions.setItem(0,0,newItem) newItem = QtGui.QTableWidgetItem(address) newItem.setFlags( QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled ) if not enabled: newItem.setTextColor(QtGui.QColor(128,128,128)) self.ui.tableWidgetSubscriptions.setItem(0,1,newItem) #Initialize the Blacklist or Whitelist if shared.config.get('bitmessagesettings', 'blackwhitelist') == 'black': self.loadBlackWhiteList() else: self.ui.tabWidget.setTabText(6,'Whitelist') self.ui.radioButtonWhitelist.click() 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) #Put the colored icon on the status bar #self.ui.pushButtonStatusIcon.setIcon(QIcon(":/newPrefix/images/yellowicon.png")) self.statusbar = self.statusBar() self.statusbar.insertPermanentWidget(0,self.ui.pushButtonStatusIcon) self.ui.labelStartupTime.setText('Since startup on ' + unicode(strftime(shared.config.get('bitmessagesettings', 'timeformat'),localtime(int(time.time()))),'utf-8')) self.numberOfMessagesProcessed = 0 self.numberOfBroadcastsProcessed = 0 self.numberOfPubkeysProcessed = 0 #Below this point, it would be good if all of the necessary global data structures were initialized. self.rerenderComboBoxSendFrom() 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("updateStatusBar(PyQt_PyObject)"), self.updateStatusBar) QtCore.QObject.connect(self.UISignalThread, QtCore.SIGNAL("updateSentItemStatusByHash(PyQt_PyObject,PyQt_PyObject)"), self.updateSentItemStatusByHash) QtCore.QObject.connect(self.UISignalThread, QtCore.SIGNAL("updateSentItemStatusByAckdata(PyQt_PyObject,PyQt_PyObject)"), self.updateSentItemStatusByAckdata) 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("displayNewSentMessage(PyQt_PyObject,PyQt_PyObject,PyQt_PyObject,PyQt_PyObject,PyQt_PyObject,PyQt_PyObject)"), self.displayNewSentMessage) QtCore.QObject.connect(self.UISignalThread, QtCore.SIGNAL("updateNetworkStatusTab(PyQt_PyObject,PyQt_PyObject)"), 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) self.UISignalThread.start() #self.connectToStream(1) #self.singleListenerThread = singleListener() #self.singleListenerThread.start() #QtCore.QObject.connect(self.singleListenerThread, QtCore.SIGNAL("passObjectThrough(PyQt_PyObject)"), self.connectObjectToSignals) #self.singleCleanerThread = singleCleaner() #self.singleCleanerThread.start() #QtCore.QObject.connect(self.singleCleanerThread, QtCore.SIGNAL("updateSentItemStatusByHash(PyQt_PyObject,PyQt_PyObject)"), self.updateSentItemStatusByHash) #QtCore.QObject.connect(self.singleCleanerThread, QtCore.SIGNAL("updateStatusBar(PyQt_PyObject)"), self.updateStatusBar) #self.workerThread = singleWorker() #self.workerThread.start() #QtCore.QObject.connect(self.workerThread, QtCore.SIGNAL("updateSentItemStatusByHash(PyQt_PyObject,PyQt_PyObject)"), self.updateSentItemStatusByHash) #QtCore.QObject.connect(self.workerThread, QtCore.SIGNAL("updateSentItemStatusByAckdata(PyQt_PyObject,PyQt_PyObject)"), self.updateSentItemStatusByAckdata) #QtCore.QObject.connect(self.workerThread, QtCore.SIGNAL("updateStatusBar(PyQt_PyObject)"), self.updateStatusBar) def tableWidgetInboxKeyPressEvent(self,event): if event.key() == QtCore.Qt.Key_Delete: self.on_action_InboxTrash() return QtGui.QTableWidget.keyPressEvent(self.ui.tableWidgetInbox, event) def tableWidgetSentKeyPressEvent(self,event): if event.key() == QtCore.Qt.Key_Delete: self.on_action_SentTrash() return QtGui.QTableWidget.keyPressEvent(self.ui.tableWidgetSent, event) def click_actionManageKeys(self): if 'darwin' in sys.platform or 'linux' in sys.platform: 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) else: QtGui.QMessageBox.information(self, 'keys.dat?','You may manage your keys by editing the keys.dat file stored in\n' + shared.appdata + '\nIt is important that you back up this file.', QMessageBox.Ok) elif sys.platform == 'win32' or sys.platform == 'win64': if shared.appdata == '': reply = QtGui.QMessageBox.question(self, 'Open 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. Would you like to open the file now? (Be sure to close Bitmessage before making any changes.)', QtGui.QMessageBox.Yes, QtGui.QMessageBox.No) else: reply = QtGui.QMessageBox.question(self, 'Open keys.dat?','You may manage your keys by editing the keys.dat file stored in\n' + shared.appdata + '\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.)', QtGui.QMessageBox.Yes, QtGui.QMessageBox.No) if reply == QtGui.QMessageBox.Yes: self.openKeysFile() def click_actionRegenerateDeterministicAddresses(self): self.regenerateAddressesDialogInstance = regenerateAddressesDialog(self) if self.regenerateAddressesDialogInstance.exec_(): if self.regenerateAddressesDialogInstance.ui.lineEditPassphrase.text() == "": QMessageBox.about(self, "bad passphrase", "You must type your passphrase. If you don\'t have one then this is not the form for you.") else: streamNumberForAddress = int(self.regenerateAddressesDialogInstance.ui.lineEditStreamNumber.text()) addressVersionNumber = int(self.regenerateAddressesDialogInstance.ui.lineEditAddressVersionNumber.text()) #self.addressGenerator = addressGenerator() #self.addressGenerator.setup(addressVersionNumber,streamNumberForAddress,"unused address",self.regenerateAddressesDialogInstance.ui.spinBoxNumberOfAddressesToMake.value(),self.regenerateAddressesDialogInstance.ui.lineEditPassphrase.text().toUtf8(),self.regenerateAddressesDialogInstance.ui.checkBoxEighteenByteRipe.isChecked()) #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) #self.addressGenerator.start() shared.addressGeneratorQueue.put((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) def openKeysFile(self): if 'linux' in sys.platform: subprocess.call(["xdg-open", shared.appdata + 'keys.dat']) else: os.startfile(shared.appdata + 'keys.dat') def changeEvent(self, event): if shared.config.getboolean('bitmessagesettings', 'minimizetotray') and not 'darwin' in sys.platform: if event.type() == QtCore.QEvent.WindowStateChange: if self.windowState() & QtCore.Qt.WindowMinimized: self.hide() self.trayIcon.show() #self.hidden = True if 'win32' in sys.platform or 'win64' in sys.platform: self.setWindowFlags(Qt.ToolTip) elif event.oldState() & QtCore.Qt.WindowMinimized: #The window state has just been changed to Normal/Maximised/FullScreen pass #QtGui.QWidget.changeEvent(self, event) def __icon_activated(self, reason): if reason == QtGui.QSystemTrayIcon.Trigger: if 'linux' in sys.platform: self.trayIcon.hide() self.setWindowFlags(Qt.Window) self.show() elif 'win32' in sys.platform or 'win64' in sys.platform: self.trayIcon.hide() self.setWindowFlags(Qt.Window) self.show() self.setWindowState(self.windowState() & ~QtCore.Qt.WindowMinimized | QtCore.Qt.WindowActive) self.activateWindow() elif 'darwin' in sys.platform: #self.trayIcon.hide() #this line causes a segmentation fault #self.setWindowFlags(Qt.Window) #self.show() self.setWindowState(self.windowState() & ~QtCore.Qt.WindowMinimized | QtCore.Qt.WindowActive) self.activateWindow() def incrementNumberOfMessagesProcessed(self): self.numberOfMessagesProcessed += 1 self.ui.labelMessageCount.setText('Processed ' + str(self.numberOfMessagesProcessed) + ' person-to-person messages.') def incrementNumberOfBroadcastsProcessed(self): self.numberOfBroadcastsProcessed += 1 self.ui.labelBroadcastCount.setText('Processed ' + str(self.numberOfBroadcastsProcessed) + ' broadcast messages.') def incrementNumberOfPubkeysProcessed(self): self.numberOfPubkeysProcessed += 1 self.ui.labelPubkeyCount.setText('Processed ' + str(self.numberOfPubkeysProcessed) + ' public keys.') def updateNetworkStatusTab(self,streamNumber,connectionCount): #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). foundTheRowThatNeedsUpdating = False for currentRow in range(self.ui.tableWidgetConnectionCount.rowCount()): rowStreamNumber = int(self.ui.tableWidgetConnectionCount.item(currentRow,0).text()) if streamNumber == rowStreamNumber: foundTheRowThatNeedsUpdating = True self.ui.tableWidgetConnectionCount.item(currentRow,1).setText(str(connectionCount)) totalNumberOfConnectionsFromAllStreams += connectionCount if foundTheRowThatNeedsUpdating == False: #Add a line to the table for this stream number and update its count with the current connection count. self.ui.tableWidgetConnectionCount.insertRow(0) newItem = QtGui.QTableWidgetItem(str(streamNumber)) newItem.setFlags( QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled ) self.ui.tableWidgetConnectionCount.setItem(0,0,newItem) newItem = QtGui.QTableWidgetItem(str(connectionCount)) newItem.setFlags( QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled ) self.ui.tableWidgetConnectionCount.setItem(0,1,newItem) totalNumberOfConnectionsFromAllStreams += connectionCount self.ui.labelTotalConnections.setText('Total Connections: ' + str(totalNumberOfConnectionsFromAllStreams)) if totalNumberOfConnectionsFromAllStreams > 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') elif totalNumberOfConnectionsFromAllStreams == 0: self.setStatusIcon('red') def setStatusIcon(self,color): #print 'setting status icon color' if color == 'red': self.ui.pushButtonStatusIcon.setIcon(QIcon(":/newPrefix/images/redicon.png")) shared.statusIconColor = 'red' 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.': self.statusBar().showMessage('') self.ui.pushButtonStatusIcon.setIcon(QIcon(":/newPrefix/images/yellowicon.png")) shared.statusIconColor = 'yellow' 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.': self.statusBar().showMessage('') self.ui.pushButtonStatusIcon.setIcon(QIcon(":/newPrefix/images/greenicon.png")) shared.statusIconColor = 'green' def updateSentItemStatusByHash(self,toRipe,textToDisplay): for i in range(self.ui.tableWidgetSent.rowCount()): toAddress = str(self.ui.tableWidgetSent.item(i,0).data(Qt.UserRole).toPyObject()) status,addressVersionNumber,streamNumber,ripe = decodeAddress(toAddress) if ripe == toRipe: #self.ui.tableWidgetSent.item(i,3).setText(unicode(textToDisplay,'utf-8')) self.ui.tableWidgetSent.item(i,3).setText(textToDisplay) def updateSentItemStatusByAckdata(self,ackdata,textToDisplay): for i in range(self.ui.tableWidgetSent.rowCount()): toAddress = str(self.ui.tableWidgetSent.item(i,0).data(Qt.UserRole).toPyObject()) tableAckdata = self.ui.tableWidgetSent.item(i,3).data(Qt.UserRole).toPyObject() status,addressVersionNumber,streamNumber,ripe = decodeAddress(toAddress) if ackdata == tableAckdata: #self.ui.tableWidgetSent.item(i,3).setText(unicode(textToDisplay,'utf-8')) self.ui.tableWidgetSent.item(i,3).setText(textToDisplay) def rerenderInboxFromLabels(self): for i in range(self.ui.tableWidgetInbox.rowCount()): addressToLookup = str(self.ui.tableWidgetInbox.item(i,1).data(Qt.UserRole).toPyObject()) fromLabel = '' t = (addressToLookup,) shared.sqlLock.acquire() shared.sqlSubmitQueue.put('''select label from addressbook where address=?''') shared.sqlSubmitQueue.put(t) queryreturn = shared.sqlReturnQueue.get() shared.sqlLock.release() if queryreturn <> []: for row in queryreturn: fromLabel, = row self.ui.tableWidgetInbox.item(i,1).setText(unicode(fromLabel,'utf-8')) else: #It might be a broadcast message. We should check for that label. shared.sqlLock.acquire() shared.sqlSubmitQueue.put('''select label from subscriptions where address=?''') shared.sqlSubmitQueue.put(t) queryreturn = shared.sqlReturnQueue.get() shared.sqlLock.release() if queryreturn <> []: for row in queryreturn: fromLabel, = row self.ui.tableWidgetInbox.item(i,1).setText(unicode(fromLabel,'utf-8')) def rerenderInboxToLabels(self): for i in range(self.ui.tableWidgetInbox.rowCount()): toAddress = str(self.ui.tableWidgetInbox.item(i,0).data(Qt.UserRole).toPyObject()) try: toLabel = shared.config.get(toAddress, 'label') except: toLabel = '' if toLabel == '': toLabel = toAddress self.ui.tableWidgetInbox.item(i,0).setText(unicode(toLabel,'utf-8')) #Set the color according to whether it is the address of a mailing list or not. if shared.safeConfigGetBoolean(toAddress,'mailinglist'): self.ui.tableWidgetInbox.item(i,0).setTextColor(QtGui.QColor(137,04,177)) else: self.ui.tableWidgetInbox.item(i,0).setTextColor(QtGui.QColor(0,0,0)) def rerenderSentFromLabels(self): for i in range(self.ui.tableWidgetSent.rowCount()): fromAddress = str(self.ui.tableWidgetSent.item(i,1).data(Qt.UserRole).toPyObject()) try: fromLabel = shared.config.get(fromAddress, 'label') except: fromLabel = '' if fromLabel == '': fromLabel = fromAddress self.ui.tableWidgetSent.item(i,1).setText(unicode(fromLabel,'utf-8')) def rerenderSentToLabels(self): for i in range(self.ui.tableWidgetSent.rowCount()): addressToLookup = str(self.ui.tableWidgetSent.item(i,0).data(Qt.UserRole).toPyObject()) toLabel = '' t = (addressToLookup,) shared.sqlLock.acquire() shared.sqlSubmitQueue.put('''select label from addressbook where address=?''') shared.sqlSubmitQueue.put(t) queryreturn = shared.sqlReturnQueue.get() shared.sqlLock.release() if queryreturn <> []: for row in queryreturn: toLabel, = row self.ui.tableWidgetSent.item(i,0).setText(unicode(toLabel,'utf-8')) def click_pushButtonSend(self): self.statusBar().showMessage('') toAddresses = str(self.ui.lineEditTo.text()) fromAddress = str(self.ui.labelFrom.text()) subject = str(self.ui.lineEditSubject.text().toUtf8()) message = str(self.ui.textEditMessage.document().toPlainText().toUtf8()) if self.ui.radioButtonSpecific.isChecked(): #To send a message to specific people (rather than broadcast) 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: if toAddress <> '': status,addressVersionNumber,streamNumber,ripe = decodeAddress(toAddress) if status <> 'success': shared.printLock.acquire() print 'Error: Could not decode', toAddress, ':', status shared.printLock.release() if status == 'missingbm': self.statusBar().showMessage('Error: Bitmessage addresses start with BM- Please check ' + toAddress) elif status == 'checksumfailed': self.statusBar().showMessage('Error: The address ' + toAddress+' is not typed or copied correctly. Please check it.') elif status == 'invalidcharacters': self.statusBar().showMessage('Error: The address '+ toAddress+ ' contains invalid characters. Please check it.') elif status == 'versiontoohigh': self.statusBar().showMessage('Error: The address version in '+ toAddress+ ' is too high. Either you need to upgrade your Bitmessage software or your acquaintance is being clever.') elif status == 'ripetooshort': self.statusBar().showMessage('Error: Some data encoded in the address '+ toAddress+ ' is too short. There might be something wrong with the software of your acquaintance.') elif status == 'ripetoolong': self.statusBar().showMessage('Error: Some data encoded in the address '+ toAddress+ ' is too long. There might be something wrong with the software of your acquaintance.') else: self.statusBar().showMessage('Error: Something is wrong with the address '+ toAddress+ '.') elif fromAddress == '': self.statusBar().showMessage('Error: You must specify a From address. If you don\'t have one, go to the \'Your Identities\' tab.') else: toAddress = addBMIfNotPresent(toAddress) try: shared.config.get(toAddress, 'enabled') #The toAddress is one owned by me. We cannot send messages to ourselves without significant changes to the codebase. QMessageBox.about(self, "Sending to your address", "Error: One of the addresses to which you are sending a message, "+toAddress+", 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.") continue except: pass if addressVersionNumber > 3 or addressVersionNumber == 0: QMessageBox.about(self, "Address version number", "Concerning the address "+toAddress+", Bitmessage cannot understand address version numbers of "+str(addressVersionNumber)+". Perhaps upgrade Bitmessage to the latest version.") continue if streamNumber > 1 or streamNumber == 0: QMessageBox.about(self, "Stream number", "Concerning the address "+toAddress+", Bitmessage cannot handle stream numbers of "+str(streamNumber)+". Perhaps upgrade Bitmessage to the latest version.") continue self.statusBar().showMessage('') if shared.statusIconColor == 'red': self.statusBar().showMessage('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) shared.sqlLock.acquire() t = ('',toAddress,ripe,fromAddress,subject,message,ackdata,int(time.time()),'findingpubkey',1,1,'sent',2) shared.sqlSubmitQueue.put('''INSERT INTO sent VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?)''') shared.sqlSubmitQueue.put(t) shared.sqlReturnQueue.get() shared.sqlSubmitQueue.put('commit') shared.sqlLock.release() toLabel = '' t = (toAddress,) shared.sqlLock.acquire() shared.sqlSubmitQueue.put('''select label from addressbook where address=?''') shared.sqlSubmitQueue.put(t) queryreturn = shared.sqlReturnQueue.get() shared.sqlLock.release() if queryreturn <> []: for row in queryreturn: toLabel, = row self.displayNewSentMessage(toAddress,toLabel,fromAddress, subject, message, ackdata) shared.workerQueue.put(('sendmessage',toAddress)) self.ui.comboBoxSendFrom.setCurrentIndex(0) self.ui.labelFrom.setText('') self.ui.lineEditTo.setText('') self.ui.lineEditSubject.setText('') self.ui.textEditMessage.setText('') self.ui.tabWidget.setCurrentIndex(2) self.ui.tableWidgetSent.setCurrentCell(0,0) else: self.statusBar().showMessage('Your \'To\' field is empty.') else: #User selected 'Broadcast' if fromAddress == '': self.statusBar().showMessage('Error: You must specify a From address. If you don\'t have one, go to the \'Your Identities\' tab.') else: 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. ackdata = OpenSSL.rand(32) toAddress = '[Broadcast subscribers]' ripe = '' shared.sqlLock.acquire() t = ('',toAddress,ripe,fromAddress,subject,message,ackdata,int(time.time()),'broadcastpending',1,1,'sent',2) shared.sqlSubmitQueue.put('''INSERT INTO sent VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?)''') shared.sqlSubmitQueue.put(t) shared.sqlReturnQueue.get() shared.sqlSubmitQueue.put('commit') shared.sqlLock.release() shared.workerQueue.put(('sendbroadcast',(fromAddress,subject,message))) try: fromLabel = shared.config.get(fromAddress, 'label') except: fromLabel = '' if fromLabel == '': fromLabel = fromAddress toLabel = '[Broadcast subscribers]' self.ui.tableWidgetSent.insertRow(0) newItem = QtGui.QTableWidgetItem(unicode(toLabel,'utf-8')) newItem.setData(Qt.UserRole,str(toAddress)) self.ui.tableWidgetSent.setItem(0,0,newItem) if fromLabel == '': newItem = QtGui.QTableWidgetItem(unicode(fromAddress,'utf-8')) else: newItem = QtGui.QTableWidgetItem(unicode(fromLabel,'utf-8')) newItem.setData(Qt.UserRole,str(fromAddress)) self.ui.tableWidgetSent.setItem(0,1,newItem) newItem = QtGui.QTableWidgetItem(unicode(subject,'utf-8)')) newItem.setData(Qt.UserRole,unicode(message,'utf-8)')) self.ui.tableWidgetSent.setItem(0,2,newItem) #newItem = QtGui.QTableWidgetItem('Doing work necessary to send broadcast...'+ unicode(strftime(config.get('bitmessagesettings', '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.comboBoxSendFrom.setCurrentIndex(0) self.ui.labelFrom.setText('') self.ui.lineEditTo.setText('') self.ui.lineEditSubject.setText('') self.ui.textEditMessage.setText('') self.ui.tabWidget.setCurrentIndex(2) self.ui.tableWidgetSent.setCurrentCell(0,0) def click_pushButtonLoadFromAddressBook(self): self.ui.tabWidget.setCurrentIndex(5) for i in range(4): time.sleep(0.1) self.statusBar().showMessage('') time.sleep(0.1) self.statusBar().showMessage('Right click one or more entries in your address book and select \'Send message to this address\'.') def redrawLabelFrom(self,index): self.ui.labelFrom.setText(self.ui.comboBoxSendFrom.itemData(index).toPyObject()) def rerenderComboBoxSendFrom(self): self.ui.comboBoxSendFrom.clear() self.ui.labelFrom.setText('') configSections = shared.config.sections() for addressInKeysFile in configSections: 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. if isEnabled: self.ui.comboBoxSendFrom.insertItem(0,unicode(shared.config.get(addressInKeysFile, 'label'),'utf-8'),addressInKeysFile) self.ui.comboBoxSendFrom.insertItem(0,'','') if(self.ui.comboBoxSendFrom.count() == 2): self.ui.comboBoxSendFrom.setCurrentIndex(1) self.redrawLabelFrom(self.ui.comboBoxSendFrom.currentIndex()) else: self.ui.comboBoxSendFrom.setCurrentIndex(0) def connectObjectToSignals(self,object): QtCore.QObject.connect(object, QtCore.SIGNAL("updateStatusBar(PyQt_PyObject)"), self.updateStatusBar) QtCore.QObject.connect(object, QtCore.SIGNAL("displayNewInboxMessage(PyQt_PyObject,PyQt_PyObject,PyQt_PyObject,PyQt_PyObject,PyQt_PyObject)"), self.displayNewInboxMessage) QtCore.QObject.connect(object, QtCore.SIGNAL("displayNewSentMessage(PyQt_PyObject,PyQt_PyObject,PyQt_PyObject,PyQt_PyObject,PyQt_PyObject,PyQt_PyObject)"), self.displayNewSentMessage) QtCore.QObject.connect(object, QtCore.SIGNAL("updateSentItemStatusByHash(PyQt_PyObject,PyQt_PyObject)"), self.updateSentItemStatusByHash) QtCore.QObject.connect(object, QtCore.SIGNAL("updateSentItemStatusByAckdata(PyQt_PyObject,PyQt_PyObject)"), self.updateSentItemStatusByAckdata) QtCore.QObject.connect(object, QtCore.SIGNAL("updateNetworkStatusTab(PyQt_PyObject,PyQt_PyObject)"), self.updateNetworkStatusTab) QtCore.QObject.connect(object, QtCore.SIGNAL("incrementNumberOfMessagesProcessed()"), self.incrementNumberOfMessagesProcessed) QtCore.QObject.connect(object, QtCore.SIGNAL("incrementNumberOfPubkeysProcessed()"), self.incrementNumberOfPubkeysProcessed) QtCore.QObject.connect(object, QtCore.SIGNAL("incrementNumberOfBroadcastsProcessed()"), self.incrementNumberOfBroadcastsProcessed) QtCore.QObject.connect(object, QtCore.SIGNAL("setStatusIcon(PyQt_PyObject)"), self.setStatusIcon) #This function exists because of the API. The API thread starts an address generator thread and must somehow connect the address generator's signals to the QApplication thread. This function is used to connect the slots and signals. def connectObjectToAddressGeneratorSignals(self,object): QtCore.QObject.connect(object, SIGNAL("writeNewAddressToTable(PyQt_PyObject,PyQt_PyObject,PyQt_PyObject)"), self.writeNewAddressToTable) QtCore.QObject.connect(object, QtCore.SIGNAL("updateStatusBar(PyQt_PyObject)"), self.updateStatusBar) #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. def displayNewSentMessage(self,toAddress,toLabel,fromAddress,subject,message,ackdata): try: fromLabel = shared.config.get(fromAddress, 'label') except: fromLabel = '' if fromLabel == '': fromLabel = fromAddress self.ui.tableWidgetSent.setSortingEnabled(False) self.ui.tableWidgetSent.insertRow(0) if toLabel == '': newItem = QtGui.QTableWidgetItem(unicode(toAddress,'utf-8')) else: newItem = QtGui.QTableWidgetItem(unicode(toLabel,'utf-8')) newItem.setData(Qt.UserRole,str(toAddress)) self.ui.tableWidgetSent.setItem(0,0,newItem) if fromLabel == '': newItem = QtGui.QTableWidgetItem(unicode(fromAddress,'utf-8')) else: newItem = QtGui.QTableWidgetItem(unicode(fromLabel,'utf-8')) newItem.setData(Qt.UserRole,str(fromAddress)) self.ui.tableWidgetSent.setItem(0,1,newItem) newItem = QtGui.QTableWidgetItem(unicode(subject,'utf-8)')) newItem.setData(Qt.UserRole,unicode(message,'utf-8)')) 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 = myTableWidgetItem('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) def displayNewInboxMessage(self,inventoryHash,toAddress,fromAddress,subject,message): '''print 'test signals displayNewInboxMessage' print 'toAddress', toAddress print 'fromAddress', fromAddress print 'message', message''' fromLabel = '' shared.sqlLock.acquire() t = (fromAddress,) shared.sqlSubmitQueue.put('''select label from addressbook where address=?''') shared.sqlSubmitQueue.put(t) queryreturn = shared.sqlReturnQueue.get() shared.sqlLock.release() if queryreturn <> []: for row in queryreturn: fromLabel, = row else: #There might be a label in the subscriptions table shared.sqlLock.acquire() t = (fromAddress,) shared.sqlSubmitQueue.put('''select label from subscriptions where address=?''') shared.sqlSubmitQueue.put(t) queryreturn = shared.sqlReturnQueue.get() shared.sqlLock.release() if queryreturn <> []: for row in queryreturn: fromLabel, = row try: if toAddress == '[Broadcast subscribers]': toLabel = '[Broadcast subscribers]' else: toLabel = shared.config.get(toAddress, 'label') except: toLabel = '' if toLabel == '': toLabel = toAddress font = QFont() font.setBold(True) self.ui.tableWidgetInbox.setSortingEnabled(False) newItem = QtGui.QTableWidgetItem(unicode(toLabel,'utf-8')) newItem.setFont(font) newItem.setData(Qt.UserRole,str(toAddress)) if shared.safeConfigGetBoolean(str(toAddress),'mailinglist'): newItem.setTextColor(QtGui.QColor(137,04,177)) self.ui.tableWidgetInbox.insertRow(0) self.ui.tableWidgetInbox.setItem(0,0,newItem) if fromLabel == '': newItem = QtGui.QTableWidgetItem(unicode(fromAddress,'utf-8')) if shared.config.getboolean('bitmessagesettings', 'showtraynotifications'): self.trayIcon.showMessage('New Message', 'New message from '+ fromAddress, 1, 2000) else: newItem = QtGui.QTableWidgetItem(unicode(fromLabel,'utf-8')) if shared.config.getboolean('bitmessagesettings', 'showtraynotifications'): self.trayIcon.showMessage('New Message', 'New message from '+fromLabel, 1, 2000) newItem.setData(Qt.UserRole,str(fromAddress)) newItem.setFont(font) self.ui.tableWidgetInbox.setItem(0,1,newItem) newItem = QtGui.QTableWidgetItem(unicode(subject,'utf-8)')) newItem.setData(Qt.UserRole,unicode(message,'utf-8)')) newItem.setFont(font) self.ui.tableWidgetInbox.setItem(0,2,newItem) newItem = myTableWidgetItem(unicode(strftime(shared.config.get('bitmessagesettings', 'timeformat'),localtime(int(time.time()))),'utf-8')) newItem.setData(Qt.UserRole,QByteArray(inventoryHash)) newItem.setData(33,int(time.time())) newItem.setFont(font) self.ui.tableWidgetInbox.setItem(0,3,newItem) """#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): self.ui.textEditInboxMessage.setText(self.ui.tableWidgetInbox.item(0,2).data(Qt.UserRole).toPyObject()) else: self.ui.textEditInboxMessage.setPlainText(self.ui.tableWidgetInbox.item(0,2).data(Qt.UserRole).toPyObject())""" self.ui.tableWidgetInbox.setSortingEnabled(True) def click_pushButtonAddAddressBook(self): self.NewSubscriptionDialogInstance = NewSubscriptionDialog(self) if self.NewSubscriptionDialogInstance.exec_(): 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. shared.sqlLock.acquire() t = (addBMIfNotPresent(str(self.NewSubscriptionDialogInstance.ui.lineEditSubscriptionAddress.text())),) shared.sqlSubmitQueue.put('''select * from addressbook where address=?''') shared.sqlSubmitQueue.put(t) queryreturn = shared.sqlReturnQueue.get() shared.sqlLock.release() if queryreturn == []: self.ui.tableWidgetAddressBook.setSortingEnabled(False) self.ui.tableWidgetAddressBook.insertRow(0) newItem = QtGui.QTableWidgetItem(unicode(self.NewSubscriptionDialogInstance.ui.newsubscriptionlabel.text().toUtf8(),'utf-8')) self.ui.tableWidgetAddressBook.setItem(0,0,newItem) newItem = QtGui.QTableWidgetItem(addBMIfNotPresent(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) t = (str(self.NewSubscriptionDialogInstance.ui.newsubscriptionlabel.text().toUtf8()),addBMIfNotPresent(str(self.NewSubscriptionDialogInstance.ui.lineEditSubscriptionAddress.text()))) shared.sqlLock.acquire() shared.sqlSubmitQueue.put('''INSERT INTO addressbook VALUES (?,?)''') shared.sqlSubmitQueue.put(t) queryreturn = shared.sqlReturnQueue.get() shared.sqlSubmitQueue.put('commit') shared.sqlLock.release() self.rerenderInboxFromLabels() self.rerenderSentToLabels() else: self.statusBar().showMessage('Error: You cannot add the same address to your address book twice. Try renaming the existing one if you want.') else: self.statusBar().showMessage('The address you entered was invalid. Ignoring it.') def click_pushButtonAddSubscription(self): self.NewSubscriptionDialogInstance = NewSubscriptionDialog(self) if self.NewSubscriptionDialogInstance.exec_(): 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. shared.sqlLock.acquire() t = (addBMIfNotPresent(str(self.NewSubscriptionDialogInstance.ui.lineEditSubscriptionAddress.text())),) shared.sqlSubmitQueue.put('''select * from subscriptions where address=?''') shared.sqlSubmitQueue.put(t) queryreturn = shared.sqlReturnQueue.get() shared.sqlLock.release() if queryreturn == []: self.ui.tableWidgetSubscriptions.setSortingEnabled(False) self.ui.tableWidgetSubscriptions.insertRow(0) newItem = QtGui.QTableWidgetItem(unicode(self.NewSubscriptionDialogInstance.ui.newsubscriptionlabel.text().toUtf8(),'utf-8')) self.ui.tableWidgetSubscriptions.setItem(0,0,newItem) newItem = QtGui.QTableWidgetItem(addBMIfNotPresent(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) t = (str(self.NewSubscriptionDialogInstance.ui.newsubscriptionlabel.text().toUtf8()),addBMIfNotPresent(str(self.NewSubscriptionDialogInstance.ui.lineEditSubscriptionAddress.text())),True) shared.sqlLock.acquire() shared.sqlSubmitQueue.put('''INSERT INTO subscriptions VALUES (?,?,?)''') shared.sqlSubmitQueue.put(t) queryreturn = shared.sqlReturnQueue.get() shared.sqlSubmitQueue.put('commit') shared.sqlLock.release() self.rerenderInboxFromLabels() shared.reloadBroadcastSendersForWhichImWatching() else: self.statusBar().showMessage('Error: You cannot add the same address to your subsciptions twice. Perhaps rename the existing one if you want.') else: self.statusBar().showMessage('The address you entered was invalid. Ignoring it.') def loadBlackWhiteList(self): #Initialize the Blacklist or Whitelist table listType = shared.config.get('bitmessagesettings', 'blackwhitelist') shared.sqlLock.acquire() if listType == 'black': shared.sqlSubmitQueue.put('''SELECT label, address, enabled FROM blacklist''') else: shared.sqlSubmitQueue.put('''SELECT label, address, enabled FROM whitelist''') shared.sqlSubmitQueue.put('') queryreturn = shared.sqlReturnQueue.get() shared.sqlLock.release() for row in queryreturn: label, address, enabled = row self.ui.tableWidgetBlacklist.insertRow(0) newItem = QtGui.QTableWidgetItem(unicode(label,'utf-8')) if not enabled: newItem.setTextColor(QtGui.QColor(128,128,128)) self.ui.tableWidgetBlacklist.setItem(0,0,newItem) newItem = QtGui.QTableWidgetItem(address) newItem.setFlags( QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled ) if not enabled: newItem.setTextColor(QtGui.QColor(128,128,128)) self.ui.tableWidgetBlacklist.setItem(0,1,newItem) def click_pushButtonStatusIcon(self): print 'click_pushButtonStatusIcon' self.iconGlossaryInstance = iconGlossaryDialog(self) if self.iconGlossaryInstance.exec_(): pass def click_actionHelp(self): self.helpDialogInstance = helpDialog(self) self.helpDialogInstance.exec_() def click_actionAbout(self): self.aboutDialogInstance = aboutDialog(self) self.aboutDialogInstance.exec_() def click_actionSettings(self): self.settingsDialogInstance = settingsDialog(self) if self.settingsDialogInstance.exec_(): shared.config.set('bitmessagesettings', 'startonlogon', str(self.settingsDialogInstance.ui.checkBoxStartOnLogon.isChecked())) shared.config.set('bitmessagesettings', 'minimizetotray', str(self.settingsDialogInstance.ui.checkBoxMinimizeToTray.isChecked())) shared.config.set('bitmessagesettings', 'showtraynotifications', str(self.settingsDialogInstance.ui.checkBoxShowTrayNotifications.isChecked())) 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, "Restart", "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.statusIconColor != 'red': QMessageBox.about(self, "Restart", "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': self.statusBar().showMessage('') shared.config.set('bitmessagesettings', 'socksproxytype', str(self.settingsDialogInstance.ui.comboBoxProxyType.currentText())) shared.config.set('bitmessagesettings', 'socksauthentication', str(self.settingsDialogInstance.ui.checkBoxAuthentication.isChecked())) shared.config.set('bitmessagesettings', 'sockshostname', str(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: shared.config.set('bitmessagesettings', 'defaultnoncetrialsperbyte',str(int(float(self.settingsDialogInstance.ui.lineEditTotalDifficulty.text())*shared.networkDefaultProofOfWorkNonceTrialsPerByte))) if float(self.settingsDialogInstance.ui.lineEditSmallMessageDifficulty.text()) >= 1: shared.config.set('bitmessagesettings', 'defaultpayloadlengthextrabytes',str(int(float(self.settingsDialogInstance.ui.lineEditSmallMessageDifficulty.text())*shared.networkDefaultPayloadLengthExtraBytes))) with open(shared.appdata + 'keys.dat', 'wb') as configfile: shared.config.write(configfile) if 'win32' in sys.platform or 'win64' in sys.platform: #Auto-startup for Windows RUN_PATH = "HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Run" self.settings = QSettings(RUN_PATH, QSettings.NativeFormat) if shared.config.getboolean('bitmessagesettings', 'startonlogon'): self.settings.setValue("PyBitmessage",sys.argv[0]) else: self.settings.remove("PyBitmessage") elif 'darwin' in sys.platform: #startup for mac pass elif 'linux' in sys.platform: #startup for linux 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... shared.config.set('bitmessagesettings','movemessagstoprog','true') #Tells bitmessage to move the messages.dat file to the program directory the next time the program starts. #Write the keys.dat file to disk in the new location with open('keys.dat', 'wb') as configfile: shared.config.write(configfile) #Write the knownnodes.dat file to disk in the new location shared.knownNodesLock.acquire() output = open('knownnodes.dat', 'wb') pickle.dump(shared.knownNodes, output) output.close() shared.knownNodesLock.release() os.remove(shared.appdata + 'keys.dat') os.remove(shared.appdata + 'knownnodes.dat') shared.appdata = '' QMessageBox.about(self, "Restart", "Bitmessage has moved most of your config files to the program directory but you must restart Bitmessage to move the last file (the file which holds messages).") 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() if not os.path.exists(shared.appdata): os.makedirs(shared.appdata) shared.config.set('bitmessagesettings','movemessagstoappdata','true') #Tells bitmessage to move the messages.dat file to the appdata directory the next time the program starts. #Write the keys.dat file to disk in the new location with open(shared.appdata + 'keys.dat', 'wb') as configfile: shared.config.write(configfile) #Write the knownnodes.dat file to disk in the new location shared.knownNodesLock.acquire() output = open(shared.appdata + 'knownnodes.dat', 'wb') pickle.dump(shared.knownNodes, output) output.close() shared.knownNodesLock.release() os.remove('keys.dat') os.remove('knownnodes.dat') QMessageBox.about(self, "Restart", "Bitmessage has moved most of your config files to the application data directory but you must restart Bitmessage to move the last file (the file which holds messages).") def click_radioButtonBlacklist(self): if shared.config.get('bitmessagesettings', 'blackwhitelist') == 'white': shared.config.set('bitmessagesettings','blackwhitelist','black') with open(shared.appdata + 'keys.dat', 'wb') as configfile: shared.config.write(configfile) #self.ui.tableWidgetBlacklist.clearContents() self.ui.tableWidgetBlacklist.setRowCount(0) self.loadBlackWhiteList() self.ui.tabWidget.setTabText(6,'Blacklist') def click_radioButtonWhitelist(self): if shared.config.get('bitmessagesettings', 'blackwhitelist') == 'black': shared.config.set('bitmessagesettings','blackwhitelist','white') with open(shared.appdata + 'keys.dat', 'wb') as configfile: shared.config.write(configfile) #self.ui.tableWidgetBlacklist.clearContents() self.ui.tableWidgetBlacklist.setRowCount(0) self.loadBlackWhiteList() self.ui.tabWidget.setTabText(6,'Whitelist') def click_pushButtonAddBlacklist(self): self.NewBlacklistDialogInstance = NewSubscriptionDialog(self) if self.NewBlacklistDialogInstance.exec_(): 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. shared.sqlLock.acquire() t = (addBMIfNotPresent(str(self.NewBlacklistDialogInstance.ui.lineEditSubscriptionAddress.text())),) if shared.config.get('bitmessagesettings', 'blackwhitelist') == 'black': shared.sqlSubmitQueue.put('''select * from blacklist where address=?''') else: shared.sqlSubmitQueue.put('''select * from whitelist where address=?''') shared.sqlSubmitQueue.put(t) queryreturn = shared.sqlReturnQueue.get() shared.sqlLock.release() if queryreturn == []: self.ui.tableWidgetBlacklist.setSortingEnabled(False) self.ui.tableWidgetBlacklist.insertRow(0) newItem = QtGui.QTableWidgetItem(unicode(self.NewBlacklistDialogInstance.ui.newsubscriptionlabel.text().toUtf8(),'utf-8')) self.ui.tableWidgetBlacklist.setItem(0,0,newItem) newItem = QtGui.QTableWidgetItem(addBMIfNotPresent(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) t = (str(self.NewBlacklistDialogInstance.ui.newsubscriptionlabel.text().toUtf8()),addBMIfNotPresent(str(self.NewBlacklistDialogInstance.ui.lineEditSubscriptionAddress.text())),True) shared.sqlLock.acquire() if shared.config.get('bitmessagesettings', 'blackwhitelist') == 'black': shared.sqlSubmitQueue.put('''INSERT INTO blacklist VALUES (?,?,?)''') else: shared.sqlSubmitQueue.put('''INSERT INTO whitelist VALUES (?,?,?)''') shared.sqlSubmitQueue.put(t) queryreturn = shared.sqlReturnQueue.get() shared.sqlSubmitQueue.put('commit') shared.sqlLock.release() else: self.statusBar().showMessage('Error: You cannot add the same address to your list twice. Perhaps rename the existing one if you want.') else: self.statusBar().showMessage('The address you entered was invalid. Ignoring it.') def on_action_SpecialAddressBehaviorDialog(self): self.dialog = SpecialAddressBehaviorDialog(self) # For Modal dialogs if self.dialog.exec_(): currentRow = self.ui.tableWidgetYourIdentities.currentRow() addressAtCurrentRow = str(self.ui.tableWidgetYourIdentities.item(currentRow,1).text()) if self.dialog.ui.radioButtonBehaveNormalAddress.isChecked(): shared.config.set(str(addressAtCurrentRow),'mailinglist','false') #Set the color to either black or grey if shared.config.getboolean(addressAtCurrentRow,'enabled'): self.ui.tableWidgetYourIdentities.item(currentRow,1).setTextColor(QtGui.QColor(0,0,0)) else: self.ui.tableWidgetYourIdentities.item(currentRow,1).setTextColor(QtGui.QColor(128,128,128)) else: shared.config.set(str(addressAtCurrentRow),'mailinglist','true') 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: shared.config.write(configfile) self.rerenderInboxToLabels() def click_NewAddressDialog(self): self.dialog = NewAddressDialog(self) # For Modal dialogs if self.dialog.exec_(): #self.dialog.ui.buttonBox.enabled = False if self.dialog.ui.radioButtonRandomAddress.isChecked(): if self.dialog.ui.radioButtonMostAvailable.isChecked(): streamNumberForAddress = 1 else: #User selected 'Use the same stream as an existing address.' streamNumberForAddress = addressStream(self.dialog.ui.comboBoxExisting.currentText()) #self.addressGenerator = addressGenerator() #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, QtCore.SIGNAL("updateStatusBar(PyQt_PyObject)"), self.updateStatusBar) #self.addressGenerator.start() shared.addressGeneratorQueue.put((3,streamNumberForAddress,str(self.dialog.ui.newaddresslabel.text().toUtf8()),1,"",self.dialog.ui.checkBoxEighteenByteRipe.isChecked())) else: if self.dialog.ui.lineEditPassphrase.text() != self.dialog.ui.lineEditPassphraseAgain.text(): QMessageBox.about(self, "Passphrase mismatch", "The passphrase you entered twice doesn\'t match. Try again.") elif self.dialog.ui.lineEditPassphrase.text() == "": QMessageBox.about(self, "Choose a passphrase", "You really do need a passphrase.") else: streamNumberForAddress = 1 #this will eventually have to be replaced by logic to determine the most available stream number. #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()) #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) #self.addressGenerator.start() shared.addressGeneratorQueue.put((3,streamNumberForAddress,"unused deterministic address",self.dialog.ui.spinBoxNumberOfAddressesToMake.value(),self.dialog.ui.lineEditPassphrase.text().toUtf8(),self.dialog.ui.checkBoxEighteenByteRipe.isChecked())) else: print 'new address dialog box rejected' def closeEvent(self, event): '''quit_msg = "Are you sure you want to exit Bitmessage?" reply = QtGui.QMessageBox.question(self, 'Message', quit_msg, QtGui.QMessageBox.Yes, QtGui.QMessageBox.No) if reply == QtGui.QMessageBox.Yes: event.accept() else: event.ignore()''' shared.doCleanShutdown() self.trayIcon.hide() self.statusBar().showMessage('All done. Closing user interface...') event.accept() print 'Done. (passed event.accept())' os._exit(0) def on_action_InboxMessageForceHtml(self): currentInboxRow = self.ui.tableWidgetInbox.currentRow() lines = self.ui.tableWidgetInbox.item(currentInboxRow,2).data(Qt.UserRole).toPyObject().split('\n') for i in xrange(len(lines)): if lines[i].contains('Message ostensibly from '): lines[i] = '
%s
' % (lines[i]) elif lines[i] == '------------------------------------------------------': lines[i] = '