diff --git a/bitmessagemain.py b/bitmessagemain.py index 5cd53c22..e8aeb818 100644 --- a/bitmessagemain.py +++ b/bitmessagemain.py @@ -5,7 +5,7 @@ #Right now, PyBitmessage only support connecting to stream 1. It doesn't yet contain logic to expand into further streams. -softwareVersion = '0.1.1' +softwareVersion = '0.1.0' verbose = 2 maximumAgeOfAnObjectThatIAmWillingToAccept = 216000 #Equals two days and 12 hours. lengthOfTimeToLeaveObjectsInInventory = 237600 #Equals two days and 18 hours. This should be longer than maximumAgeOfAnObjectThatIAmWillingToAccept so that we don't process messages twice. @@ -2188,11 +2188,11 @@ class MyForm(QtGui.QMainWindow): #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.actionReply = self.ui.inboxContextMenuToolbar.addAction("Reply", self.on_action_Reply) + self.actionAddSenderToAddressBook = self.ui.inboxContextMenuToolbar.addAction("Add sender to your Address Book", self.on_action_addSenderToAddressBook) self.actionTrashInboxMessage = self.ui.inboxContextMenuToolbar.addAction("Move to Trash", self.on_action_InboxTrash) - #self.actionDisable = self.ui.inboxContextMenuToolbar.addAction("Disable", self.on_action_YourIdentitiesDisable) - #self.actionClipboard = self.ui.inboxContextMenuToolbar.addAction("Copy address to clipboard", self.on_action_YourIdentitiesClipboard) + #self.actionDisable = self.ui.inboxContextMenuToolbar.addAction("Disable", self.on_action_disable) + #self.actionClipboard = self.ui.inboxContextMenuToolbar.addAction("Copy address to clipboard", self.on_action_clipboard) 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 ) @@ -2205,10 +2205,10 @@ class MyForm(QtGui.QMainWindow): #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.actionNew = self.ui.addressContextMenuToolbar.addAction("New", self.on_action_new) + self.actionEnable = self.ui.addressContextMenuToolbar.addAction("Enable", self.on_action_enable) + self.actionDisable = self.ui.addressContextMenuToolbar.addAction("Disable", self.on_action_disable) + self.actionClipboard = self.ui.addressContextMenuToolbar.addAction("Copy address to clipboard", self.on_action_clipboard) 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 ) @@ -2311,23 +2311,19 @@ class MyForm(QtGui.QMainWindow): self.ui.tableWidgetInbox.insertRow(0) newItem = QtGui.QTableWidgetItem(unicode(toLabel,'utf-8')) - newItem.setFlags( QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled ) newItem.setData(Qt.UserRole,str(toAddress)) 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 ) 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 ) self.ui.tableWidgetInbox.setItem(0,2,newItem) newItem = QtGui.QTableWidgetItem(strftime(config.get('bitmessagesettings', 'timeformat'),localtime(int(received)))) newItem.setData(Qt.UserRole,QByteArray(msgid)) - newItem.setFlags( QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled ) self.ui.tableWidgetInbox.setItem(0,3,newItem) #self.ui.textEditInboxMessage.setText(self.ui.tableWidgetInbox.item(0,2).data(Qt.UserRole).toPyObject()) @@ -2360,18 +2356,15 @@ class MyForm(QtGui.QMainWindow): 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 = QtGui.QTableWidgetItem('Waiting on their public key. Will request it again soon.') @@ -2388,7 +2381,6 @@ class MyForm(QtGui.QMainWindow): else: newItem = QtGui.QTableWidgetItem('Unknown status. ' + strftime(config.get('bitmessagesettings', 'timeformat'),localtime(int(lastactiontime)))) newItem.setData(Qt.UserRole,ackdata) - newItem.setFlags( QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled ) self.ui.tableWidgetSent.setItem(0,3,newItem) #Initialize the address book @@ -3143,7 +3135,7 @@ class MyForm(QtGui.QMainWindow): raise SystemExit - def on_action_InboxReply(self): + def on_action_Reply(self): currentInboxRow = self.ui.tableWidgetInbox.currentRow() toAddressAtCurrentInboxRow = str(self.ui.tableWidgetInbox.item(currentInboxRow,0).data(Qt.UserRole).toPyObject()) fromAddressAtCurrentInboxRow = str(self.ui.tableWidgetInbox.item(currentInboxRow,1).data(Qt.UserRole).toPyObject()) @@ -3153,15 +3145,9 @@ class MyForm(QtGui.QMainWindow): self.ui.lineEditTo.setText(str(fromAddressAtCurrentInboxRow)) self.ui.labelFrom.setText(toAddressAtCurrentInboxRow) 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()) - if str(self.ui.tableWidgetInbox.item(currentInboxRow,2).text())[0:3] == 'Re:': - self.ui.lineEditSubject.setText(str(self.ui.tableWidgetInbox.item(currentInboxRow,2).text())) - else: - self.ui.lineEditSubject.setText('Re: '+str(self.ui.tableWidgetInbox.item(currentInboxRow,2).text())) - self.ui.radioButtonSpecific.setChecked(True) self.ui.tabWidget.setCurrentIndex(1) - def on_action_InboxAddSenderToAddressBook(self): + def on_action_addSenderToAddressBook(self): currentInboxRow = self.ui.tableWidgetInbox.currentRow() #self.ui.tableWidgetInbox.item(currentRow,1).data(Qt.UserRole).toPyObject() addressAtCurrentInboxRow = str(self.ui.tableWidgetInbox.item(currentInboxRow,1).data(Qt.UserRole).toPyObject()) @@ -3264,9 +3250,9 @@ class MyForm(QtGui.QMainWindow): #Group of functions for the Your Identities dialog box - def on_action_YourIdentitiesNew(self): + def on_action_new(self): self.click_NewAddressDialog() - def on_action_YourIdentitiesEnable(self): + def on_action_enable(self): currentRow = self.ui.tableWidgetYourIdentities.currentRow() addressAtCurrentRow = self.ui.tableWidgetYourIdentities.item(currentRow,1).text() config.set(str(addressAtCurrentRow),'enabled','true') @@ -3276,7 +3262,7 @@ class MyForm(QtGui.QMainWindow): self.ui.tableWidgetYourIdentities.item(currentRow,1).setTextColor(QtGui.QColor(0,0,0)) self.ui.tableWidgetYourIdentities.item(currentRow,2).setTextColor(QtGui.QColor(0,0,0)) self.reloadMyAddressHashes() - def on_action_YourIdentitiesDisable(self): + def on_action_disable(self): currentRow = self.ui.tableWidgetYourIdentities.currentRow() addressAtCurrentRow = self.ui.tableWidgetYourIdentities.item(currentRow,1).text() config.set(str(addressAtCurrentRow),'enabled','false') @@ -3286,7 +3272,7 @@ class MyForm(QtGui.QMainWindow): with open(appdata + 'keys.dat', 'wb') as configfile: config.write(configfile) self.reloadMyAddressHashes() - def on_action_YourIdentitiesClipboard(self): + def on_action_clipboard(self): currentRow = self.ui.tableWidgetYourIdentities.currentRow() addressAtCurrentRow = self.ui.tableWidgetYourIdentities.item(currentRow,1).text() clipboard = QtGui.QApplication.clipboard() @@ -3420,21 +3406,21 @@ averageProofOfWorkNonceTrialsPerByte = 320 #The amount of work that should be pe payloadLengthExtraBytes = 14000 #To make sending short messages a little more difficult, this value is added to the payload length for use in calculating the proof of work target. if __name__ == "__main__": - #sqlite_version = sqlite3.sqlite_version_info + sqlite_version = sqlite3.sqlite_version_info # Check the Major version, the first element in the array - if sqlite3.sqlite_version_info[0] < 3: + if sqlite_version[0] < 3: print 'This program requires sqlite version 3 or higher because 2 and lower cannot store NULL values. I see version:', sqlite3.sqlite_version_info sys.exit() APPNAME = "PyBitmessage" from os import path, environ if sys.platform == 'darwin': - from AppKit import NSSearchPathForDirectoriesInDomains - # http://developer.apple.com/DOCUMENTATION/Cocoa/Reference/Foundation/Miscellaneous/Foundation_Functions/Reference/reference.html#//apple_ref/c/func/NSSearchPathForDirectoriesInDomains - # NSApplicationSupportDirectory = 14 - # NSUserDomainMask = 1 - # True for expanding the tilde into a fully qualified path - appdata = path.join(NSSearchPathForDirectoriesInDomains(14, 1, True)[0], APPNAME) + '/' + if "HOME" in environ: + appdata = path.join(os.environ["HOME"], "Library/Application support/", APPNAME) + '/' + else: + print 'Could not find home folder, please report this message and your OS X version to the BitMessage Github.' + sys.exit() + elif 'win' in sys.platform: appdata = path.join(environ['APPDATA'], APPNAME) + '\\' else: