diff --git a/desktop/can-icon.svg b/desktop/can-icon.svg index 9b8a9ded..b4c2bd89 100644 --- a/desktop/can-icon.svg +++ b/desktop/can-icon.svg @@ -13,7 +13,7 @@ height="1052.3622047" id="svg2" version="1.1" - inkscape:version="0.48.3.1 r9886" + inkscape:version="0.48.4 r9939" sodipodi:docname="can-icon.svg"> @@ -26,15 +26,15 @@ inkscape:pageshadow="2" inkscape:zoom="0.70710678" inkscape:cx="334.69166" - inkscape:cy="680.44336" + inkscape:cy="669.88172" inkscape:document-units="px" inkscape:current-layer="layer1" showgrid="false" - inkscape:window-width="865" - inkscape:window-height="628" - inkscape:window-x="135" - inkscape:window-y="29" - inkscape:window-maximized="0" + inkscape:window-width="1301" + inkscape:window-height="744" + inkscape:window-x="65" + inkscape:window-y="24" + inkscape:window-maximized="1" showguides="true" inkscape:guide-bbox="true" /> + id="g3096" + transform="translate(9.8994953,147.07822)"> + d="M 320.96654,38.913858 51.9306,499.516" + style="fill:none;stroke:#000000;stroke-width:1.54755318px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" /> + d="M 673.80552,249.29044 425.59993,723.16952" + style="fill:none;stroke:#000000;stroke-width:1.50693178px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" /> + d="M 370.82523,26.309365 105.49275,476.8148" + style="fill:#808080;stroke:#000000;stroke-width:1.54387176px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:0.11949684" /> + d="M 181.18883,489.0675 437.71536,40.464131" + style="fill:none;stroke:#000000;stroke-width:1.55417168px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:0.06918239" /> + d="M 118.52909,457.95387 C 156.02362,394.72369 355.64326,55.091483 362.40403,43.025817 l 8.32966,-14.8656 13.15478,1.565404 c 12.59812,1.49917 50.83911,10.510248 51.00938,12.01982 0.045,0.399053 -46.10108,81.351889 -102.54685,179.895169 -56.44577,98.5433 -113.677,198.76894 -127.18051,222.72367 l -24.55187,43.55403 -13.06611,-3.54249 c -16.49443,-4.472 -37.21456,-8.12101 -49.62577,-8.73955 l -9.59943,-0.4784 10.20173,-17.20402 0,0 z" + style="fill:#ececec;stroke:#000000;stroke-width:1.56326485;stroke-opacity:0.06918239" /> + d="M 265.93611,524.57433 515.39415,72.865001" + style="fill:#b3b3b3;stroke:#000000;stroke-width:1.54755318px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:0.07547171" /> + d="M 218.42026,426.60319 C 253.61387,365.63298 417.60665,79.155333 431.09037,55.091497 l 7.00902,-12.508718 7.89951,2.823652 c 14.56271,5.205381 37.58149,15.185601 51.6594,22.397893 l 13.95467,7.149145 -25.45749,47.431901 c -14.00162,26.08755 -69.58873,127.10612 -123.52693,224.48572 l -98.06942,177.05381 -11.84131,-5.86061 c -17.92612,-8.87215 -44.42926,-20.43356 -56.45302,-24.62637 -5.90572,-2.05941 -11.32796,-4.09551 -12.04941,-4.52469 -0.83836,-0.49873 11.50512,-22.98451 34.20487,-62.31004 z" + style="fill:#e6e6e6;stroke:#000000;stroke-width:1.54755318;stroke-opacity:0.07547171" /> + d="M 79.671264,455.01075 C 90.532206,436.67436 149.69871,335.53924 211.15239,230.26602 331.88877,23.438608 323.76858,36.262419 336.84837,31.760491 c 5.93265,-2.041958 30.03993,-4.510628 30.32186,-3.105078 0.0821,0.409248 -58.80038,100.934397 -130.84993,223.389207 l -130.99918,222.64509 -5.04257,0.53642 c -12.217214,1.29964 -28.319524,5.66399 -34.08727,9.23897 l -6.267188,3.88453 19.747172,-33.33888 z" + style="fill:#e6e6e6;stroke:#000000;stroke-width:1.54755318;stroke-opacity:0.11949684" /> + d="M 414.69412,653.42954 657.84449,196.92693" + style="fill:none;stroke:#000000;stroke-width:1.54755318px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:0.21383649" /> + d="m 432.89205,699.31284 c 0.17105,-7.00112 -5.92592,-25.26221 -12.06513,-36.13638 l -5.18621,-9.18613 6.39957,-11.51258 c 7.57517,-13.6274 209.52877,-392.42011 225.13618,-422.27505 l 10.74842,-20.5603 3.78885,6.2232 c 5.34342,8.77662 10.631,24.86087 11.21936,34.12823 0.47079,7.41538 -0.0329,8.8489 -8.73578,24.86068 -5.07938,9.34538 -58.93099,111.94581 -119.67008,228.00102 -60.73907,116.0552 -110.73218,211.10533 -111.09578,211.22251 -0.3636,0.11718 -0.60636,-2.02717 -0.53946,-4.76523 l 0,0 z M 383.58623,615.47494 629.5772,157.12597" + style="fill:#b3b3b3;stroke:#000000;stroke-width:1.54755318;stroke-opacity:0.21383649" /> + d="m 408.26635,642.79453 c -2.77517,-3.91094 -9.09904,-11.83931 -14.05304,-17.6186 l -9.00726,-10.5078 11.06562,-19.93851 c 6.08602,-10.96623 60.695,-112.54525 121.35316,-225.73125 60.65817,-113.186 110.57207,-205.90346 110.91978,-206.03881 0.96223,-0.37455 11.55983,11.72618 19.91814,22.74327 l 7.46029,9.83339 -4.53134,9.80365 C 645.37692,218.35301 419.87091,640.72729 416.18164,645.8899 l -2.86948,4.01545 -5.04578,-7.1108 z" + style="fill:#cccccc;stroke:#000000;stroke-width:1.54755318;stroke-opacity:0.21383649" /> + + diff --git a/src/api client.py b/src/api client.py index b823a75a..474cd065 100644 --- a/src/api client.py +++ b/src/api client.py @@ -25,12 +25,12 @@ print jsonAddresses print 'Now that we have our address data in a nice Python data structure, let\'s look at the first address (index 0) and print its label:' print jsonAddresses['addresses'][0]['label'] -print 'Uncomment the next two lines to create a new random address with slightly a slightly higher difficulty setting than normal.' +print 'Uncomment the next two lines to create a new random address.' #addressLabel = 'new address label'.encode('base64') -#print api.createRandomAddress(addressLabel,False,1.05,1.1111) +#print api.createRandomAddress(addressLabel) print 'Uncomment these next four lines to create new deterministic addresses.' -#passphrase = 'asdfasdfqwser'.encode('base64') +#passphrase = 'asdfasdfqwer'.encode('base64') #jsonDeterministicAddresses = api.createDeterministicAddresses(passphrase, 2, 3, 1, False) #print jsonDeterministicAddresses #print json.loads(jsonDeterministicAddresses) diff --git a/src/bitmessagemain.py b/src/bitmessagemain.py index f91d2195..f781b774 100755 --- a/src/bitmessagemain.py +++ b/src/bitmessagemain.py @@ -210,20 +210,20 @@ class singleListener(threading.Thread): print 'incoming connection is from a host in shared.connectedHostsList (we are already connected to it). Ignoring it.' a.close() a,(HOST,PORT) = sock.accept()""" + rd = receiveDataThread() + rd.daemon = True # close the main program even if there are threads left + #self.emit(SIGNAL("passObjectThrough(PyQt_PyObject)"),rd) objectsOfWhichThisRemoteNodeIsAlreadyAware = {} + rd.setup(a,HOST,PORT,-1,objectsOfWhichThisRemoteNodeIsAlreadyAware) + shared.printLock.acquire() + print self, 'connected to', HOST,'during INCOMING request.' + shared.printLock.release() + rd.start() sd = sendDataThread() sd.setup(a,HOST,PORT,-1,objectsOfWhichThisRemoteNodeIsAlreadyAware) sd.start() - rd = receiveDataThread() - rd.daemon = True # close the main program even if there are threads left - rd.setup(a,HOST,PORT,-1,objectsOfWhichThisRemoteNodeIsAlreadyAware) - rd.start() - - shared.printLock.acquire() - print self, 'connected to', HOST,'during INCOMING request.' - shared.printLock.release() #This thread is created either by the synSenderThread(for outgoing connections) or the singleListenerThread(for incoming connectiosn). class receiveDataThread(threading.Thread): @@ -297,9 +297,7 @@ class receiveDataThread(threading.Thread): try: del shared.connectedHostsList[self.HOST] except Exception, err: - shared.printLock.acquire() print 'Could not delete', self.HOST, 'from shared.connectedHostsList.', err - shared.printLock.release() shared.UISignalQueue.put(('updateNetworkStatusTab','no data')) shared.printLock.acquire() print 'The size of the connectedHostsList is now:', len(shared.connectedHostsList) @@ -2048,6 +2046,7 @@ class sendDataThread(threading.Thread): shared.printLock.release() self.versionSent = 1 + def run(self): while True: deststream,command,data = self.mailbox.get() @@ -2223,11 +2222,8 @@ def signal_handler(signal, frame): def connectToStream(streamNumber): selfInitiatedConnections[streamNumber] = {} - if sys.platform[0:3] == 'win': - maximumNumberOfHalfOpenConnections = 9 - else: - maximumNumberOfHalfOpenConnections = 32 - for i in range(maximumNumberOfHalfOpenConnections): + + for i in range(32): a = outgoingSynSender() a.setup(streamNumber) a.start() @@ -3205,27 +3201,13 @@ class addressGenerator(threading.Thread): def run(self): while True: - queueValue = shared.addressGeneratorQueue.get() - nonceTrialsPerByte = 0 - payloadLengthExtraBytes = 0 - if len(queueValue) == 6: - addressVersionNumber,streamNumber,label,numberOfAddressesToMake,deterministicPassphrase,eighteenByteRipe = queueValue - elif len(queueValue) == 8: - addressVersionNumber,streamNumber,label,numberOfAddressesToMake,deterministicPassphrase,eighteenByteRipe,nonceTrialsPerByte,payloadLengthExtraBytes = queueValue - else: - sys.stderr.write('Programming error: A structure with the wrong number of values was passed into the addressGeneratorQueue. Here is the queueValue: %s\n' % queueValue) + addressVersionNumber,streamNumber,label,numberOfAddressesToMake,deterministicPassphrase,eighteenByteRipe = shared.addressGeneratorQueue.get() if addressVersionNumber < 3 or addressVersionNumber > 3: - sys.stderr.write('Program error: For some reason the address generator queue has been given a request to create at least one version %s address which it cannot do.\n' % addressVersionNumber) - if nonceTrialsPerByte == 0: - nonceTrialsPerByte = shared.config.getint('bitmessagesettings','defaultnoncetrialsperbyte') - if nonceTrialsPerByte < shared.networkDefaultProofOfWorkNonceTrialsPerByte: - nonceTrialsPerByte = shared.networkDefaultProofOfWorkNonceTrialsPerByte - if payloadLengthExtraBytes == 0: - payloadLengthExtraBytes = shared.config.getint('bitmessagesettings','defaultpayloadlengthextrabytes') - if payloadLengthExtraBytes < shared.networkDefaultPayloadLengthExtraBytes: - payloadLengthExtraBytes = shared.networkDefaultPayloadLengthExtraBytes - if addressVersionNumber == 3: #currently the only one supported. + sys.stderr.write('Program error: For some reason the address generator queue has been given a request to create version', addressVersionNumber,' addresses which it cannot do.\n') + if addressVersionNumber == 3: if deterministicPassphrase == "": + #statusbar = 'Generating one new address' + #self.emit(SIGNAL("updateStatusBar(PyQt_PyObject)"),statusbar) shared.UISignalQueue.put(('updateStatusBar','Generating one new address')) #This next section is a little bit strange. We're going to generate keys over and over until we #find one that starts with either \x00 or \x00\x00. Then when we pack them into a Bitmessage address, @@ -3254,6 +3236,7 @@ class addressGenerator(threading.Thread): print 'Generated address with ripe digest:', ripe.digest().encode('hex') print 'Address generator calculated', numberOfAddressesWeHadToMakeBeforeWeFoundOneWithTheCorrectRipePrefix, 'addresses at', numberOfAddressesWeHadToMakeBeforeWeFoundOneWithTheCorrectRipePrefix/(time.time()-startTime),'addresses per second before finding one with the correct ripe-prefix.' address = encodeAddress(3,streamNumber,ripe.digest()) + #self.emit(SIGNAL("updateStatusBar(PyQt_PyObject)"),'Finished generating address. Writing to keys.dat') #An excellent way for us to store our keys is in Wallet Import Format. Let us convert now. #https://en.bitcoin.it/wiki/Wallet_import_format @@ -3271,8 +3254,8 @@ class addressGenerator(threading.Thread): shared.config.set(address,'label',label) shared.config.set(address,'enabled','true') shared.config.set(address,'decoy','false') - shared.config.set(address,'noncetrialsperbyte',str(nonceTrialsPerByte)) - shared.config.set(address,'payloadlengthextrabytes',str(payloadLengthExtraBytes)) + shared.config.set(address,'noncetrialsperbyte',shared.config.get('bitmessagesettings','defaultnoncetrialsperbyte')) + shared.config.set(address,'payloadlengthextrabytes',shared.config.get('bitmessagesettings','defaultpayloadlengthextrabytes')) shared.config.set(address,'privSigningKey',privSigningKeyWIF) shared.config.set(address,'privEncryptionKey',privEncryptionKeyWIF) with open(shared.appdata + 'keys.dat', 'wb') as configfile: @@ -3345,8 +3328,8 @@ class addressGenerator(threading.Thread): shared.config.set(address,'label',label) shared.config.set(address,'enabled','true') shared.config.set(address,'decoy','false') - shared.config.set(address,'noncetrialsperbyte',str(nonceTrialsPerByte)) - shared.config.set(address,'payloadlengthextrabytes',str(payloadLengthExtraBytes)) + shared.config.set(address,'noncetrialsperbyte',shared.config.get('bitmessagesettings','defaultnoncetrialsperbyte')) + shared.config.set(address,'payloadlengthextrabytes',shared.config.get('bitmessagesettings','defaultpayloadlengthextrabytes')) shared.config.set(address,'privSigningKey',privSigningKeyWIF) shared.config.set(address,'privEncryptionKey',privEncryptionKeyWIF) with open(shared.appdata + 'keys.dat', 'wb') as configfile: @@ -3461,6 +3444,7 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler): return a+b elif method == 'statusBar': message, = params + #apiSignalQueue.put(('updateStatusBar',message)) shared.UISignalQueue.put(('updateStatusBar',message)) elif method == 'listAddresses': data = '{"addresses":[' @@ -3480,26 +3464,13 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler): elif len(params) == 1: label, = params eighteenByteRipe = False - nonceTrialsPerByte = shared.config.get('bitmessagesettings','defaultnoncetrialsperbyte') - payloadLengthExtraBytes = shared.config.get('bitmessagesettings','defaultpayloadlengthextrabytes') elif len(params) == 2: label, eighteenByteRipe = params - nonceTrialsPerByte = shared.config.get('bitmessagesettings','defaultnoncetrialsperbyte') - payloadLengthExtraBytes = shared.config.get('bitmessagesettings','defaultpayloadlengthextrabytes') - elif len(params) == 3: - label, eighteenByteRipe, totalDifficulty = params - nonceTrialsPerByte = int(shared.networkDefaultProofOfWorkNonceTrialsPerByte * totalDifficulty) - payloadLengthExtraBytes = shared.config.get('bitmessagesettings','defaultpayloadlengthextrabytes') - elif len(params) == 4: - label, eighteenByteRipe, totalDifficulty, smallMessageDifficulty = params - nonceTrialsPerByte = int(shared.networkDefaultProofOfWorkNonceTrialsPerByte * totalDifficulty) - payloadLengthExtraBytes = int(shared.networkDefaultPayloadLengthExtraBytes * smallMessageDifficulty) - else: - return 'API Error 0000: Too many parameters!' label = label.decode('base64') apiAddressGeneratorReturnQueue.queue.clear() streamNumberForAddress = 1 - shared.addressGeneratorQueue.put((3,streamNumberForAddress,label,1,"",eighteenByteRipe,nonceTrialsPerByte,payloadLengthExtraBytes)) + #apiSignalQueue.put(('createRandomAddress',(label, eighteenByteRipe))) #params should be a twopul which equals (eighteenByteRipe, label) + shared.addressGeneratorQueue.put((3,streamNumberForAddress,label,1,"",eighteenByteRipe)) return apiAddressGeneratorReturnQueue.get() elif method == 'createDeterministicAddresses': if len(params) == 0: @@ -3510,40 +3481,20 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler): addressVersionNumber = 0 streamNumber = 0 eighteenByteRipe = False - nonceTrialsPerByte = shared.config.get('bitmessagesettings','defaultnoncetrialsperbyte') - payloadLengthExtraBytes = shared.config.get('bitmessagesettings','defaultpayloadlengthextrabytes') elif len(params) == 2: passphrase, numberOfAddresses = params addressVersionNumber = 0 streamNumber = 0 eighteenByteRipe = False - nonceTrialsPerByte = shared.config.get('bitmessagesettings','defaultnoncetrialsperbyte') - payloadLengthExtraBytes = shared.config.get('bitmessagesettings','defaultpayloadlengthextrabytes') elif len(params) == 3: passphrase, numberOfAddresses, addressVersionNumber = params streamNumber = 0 eighteenByteRipe = False - nonceTrialsPerByte = shared.config.get('bitmessagesettings','defaultnoncetrialsperbyte') - payloadLengthExtraBytes = shared.config.get('bitmessagesettings','defaultpayloadlengthextrabytes') elif len(params) == 4: passphrase, numberOfAddresses, addressVersionNumber, streamNumber = params eighteenByteRipe = False - nonceTrialsPerByte = shared.config.get('bitmessagesettings','defaultnoncetrialsperbyte') - payloadLengthExtraBytes = shared.config.get('bitmessagesettings','defaultpayloadlengthextrabytes') elif len(params) == 5: passphrase, numberOfAddresses, addressVersionNumber, streamNumber, eighteenByteRipe = params - nonceTrialsPerByte = shared.config.get('bitmessagesettings','defaultnoncetrialsperbyte') - payloadLengthExtraBytes = shared.config.get('bitmessagesettings','defaultpayloadlengthextrabytes') - elif len(params) == 6: - passphrase, numberOfAddresses, addressVersionNumber, streamNumber, eighteenByteRipe, totalDifficulty = params - nonceTrialsPerByte = int(shared.networkDefaultProofOfWorkNonceTrialsPerByte * totalDifficulty) - payloadLengthExtraBytes = shared.config.get('bitmessagesettings','defaultpayloadlengthextrabytes') - elif len(params) == 7: - passphrase, numberOfAddresses, addressVersionNumber, streamNumber, eighteenByteRipe, totalDifficulty, smallMessageDifficulty = params - nonceTrialsPerByte = int(shared.networkDefaultProofOfWorkNonceTrialsPerByte * totalDifficulty) - payloadLengthExtraBytes = int(shared.networkDefaultPayloadLengthExtraBytes * smallMessageDifficulty) - else: - return 'API Error 0000: Too many parameters!' if len(passphrase) == 0: return 'API Error 0001: The specified passphrase is blank.' passphrase = passphrase.decode('base64') @@ -3561,7 +3512,8 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler): return 'API Error 0005: You have (accidentally?) specified too many addresses to make. Maximum 999. This check only exists to prevent mischief; if you really want to create more addresses than this, contact the Bitmessage developers and we can modify the check or you can do it yourself by searching the source code for this message.' apiAddressGeneratorReturnQueue.queue.clear() print 'Requesting that the addressGenerator create', numberOfAddresses, 'addresses.' - shared.addressGeneratorQueue.put((addressVersionNumber,streamNumber,'unused API address',numberOfAddresses,passphrase,eighteenByteRipe,nonceTrialsPerByte,payloadLengthExtraBytes)) + #apiSignalQueue.put(('createDeterministicAddresses',(passphrase, numberOfAddresses, addressVersionNumber, streamNumber, eighteenByteRipe))) + shared.addressGeneratorQueue.put((addressVersionNumber,streamNumber,'unused API address',numberOfAddresses,passphrase,eighteenByteRipe)) data = '{"addresses":[' queueReturn = apiAddressGeneratorReturnQueue.get() for item in queueReturn: @@ -3595,6 +3547,7 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler): shared.sqlReturnQueue.get() shared.sqlSubmitQueue.put('commit') shared.sqlLock.release() + #apiSignalQueue.put(('updateStatusBar','Per API: Trashed message (assuming message existed). UI not updated.')) shared.UISignalQueue.put(('updateStatusBar','Per API: Trashed message (assuming message existed). UI not updated.')) return 'Trashed message (assuming message existed). UI not updated. To double check, run getAllInboxMessages to see that the message disappeared, or restart Bitmessage and look in the normal Bitmessage GUI.' elif method == 'sendMessage': diff --git a/src/bitmessageqt/__init__.py b/src/bitmessageqt/__init__.py index f9bb9e5f..352f9091 100644 --- a/src/bitmessageqt/__init__.py +++ b/src/bitmessageqt/__init__.py @@ -424,6 +424,10 @@ class MyForm(QtGui.QMainWindow): 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) @@ -438,65 +442,67 @@ class MyForm(QtGui.QMainWindow): QtCore.QObject.connect(self.UISignalThread, QtCore.SIGNAL("setStatusIcon(PyQt_PyObject)"), self.setStatusIcon) self.UISignalThread.start() -#Below this point, it would be good if all of the necessary global data structures were initialized. + #self.connectToStream(1) - self.rerenderComboBoxSendFrom() + #self.singleListenerThread = singleListener() + #self.singleListenerThread.start() + #QtCore.QObject.connect(self.singleListenerThread, QtCore.SIGNAL("passObjectThrough(PyQt_PyObject)"), self.connectObjectToSignals) - #Show or hide the application window after clicking an item within the tray icon or, on Windows, the try icon itself. - def appIndicatorShowOrHideWindow(self): - if not self.actionShow.isChecked(): - self.hide() - else: - if sys.platform[0:3] == 'win': - self.setWindowFlags(Qt.Window) - self.show() - self.setWindowState(self.windowState() & ~QtCore.Qt.WindowMinimized | QtCore.Qt.WindowActive) - self.activateWindow() - else: - self.show() - self.setWindowState(self.windowState() & QtCore.Qt.WindowMaximized) - #Here is what I believe might be required for darwin: - #self.setWindowState(self.windowState() & ~QtCore.Qt.WindowMinimized | QtCore.Qt.WindowActive) - #self.activateWindow() - """# application indicator show or hide + #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) + + # an appindicator action which indicates the connection status + actionStatus = None + + # an appindicator action which shows of hides the program window + actionShow = None + + # show the application window + def appIndicatorShow(self): + if self.actionShow == None: + return + self.actionShow.setChecked(True) + self.show() + self.setWindowState(self.windowState() & QtCore.Qt.WindowMaximized) + + # application indicator show or hide def appIndicatorShowBitmessage(self): - #if self.actionShow == None: - # return - print self.actionShow.isChecked() + if self.actionShow == None: + return if not self.actionShow.isChecked(): self.hide() - #self.setWindowState(self.windowState() & QtCore.Qt.WindowMinimized) + self.setWindowState(self.windowState() & QtCore.Qt.WindowMinimized) else: - self.appIndicatorShowOrHideWindow()""" + self.show() + self.setWindowState(self.windowState() & QtCore.Qt.WindowMaximized) # Show the program window and select send tab def appIndicatorSend(self): - if not self.actionShow.isChecked(): - self.actionShow.setChecked(True) - self.appIndicatorShowOrHideWindow() + self.appIndicatorShow() self.ui.tabWidget.setCurrentIndex(1) # Show the program window and select subscriptions tab def appIndicatorSubscribe(self): - if not self.actionShow.isChecked(): - self.actionShow.setChecked(True) - self.appIndicatorShowOrHideWindow() + self.appIndicatorShow() self.ui.tabWidget.setCurrentIndex(4) # Show the program window and select the address book tab def appIndicatorAddressBook(self): - if not self.actionShow.isChecked(): - self.actionShow.setChecked(True) - self.appIndicatorShowOrHideWindow() + self.appIndicatorShow() self.ui.tabWidget.setCurrentIndex(5) # create application indicator def createAppIndicator(self,app): - self.tray = QSystemTrayIcon(QtGui.QIcon("images/can-icon-24px.png"), app) - if sys.platform[0:3] == 'win': - traySignal = "activated(QSystemTrayIcon::ActivationReason)" - QtCore.QObject.connect(self.tray, QtCore.SIGNAL(traySignal), self.__icon_activated) + app.tray = QSystemTrayIcon(QtGui.QIcon("images/can-icon-24px.png"), app) m = QMenu() self.actionStatus = QtGui.QAction('Not Connected',m,checkable=False) @@ -510,9 +516,8 @@ class MyForm(QtGui.QMainWindow): # show bitmessage self.actionShow = QtGui.QAction('Show Bitmessage',m,checkable=True) self.actionShow.setChecked(True) - self.actionShow.triggered.connect(self.appIndicatorShowOrHideWindow) - if not sys.platform[0:3] == 'win': - m.addAction(self.actionShow) + self.actionShow.triggered.connect(self.appIndicatorShowBitmessage) + m.addAction(self.actionShow) # Send actionSend = QtGui.QAction('Send',m,checkable=False) @@ -536,14 +541,8 @@ class MyForm(QtGui.QMainWindow): # Quit m.addAction("Quit", self.close) - self.tray.setContextMenu(m) - self.tray.show() - if shared.config.getboolean('bitmessagesettings', 'startintray'): - #myapp.trayIcon.show()#This option seems to have been obsoleted by https://github.com/Bitmessage/PyBitmessage/pull/133/files - self.actionShow.setChecked(False) - self.appIndicatorShowOrHideWindow() - #if sys.platform[0:3] == 'win': - # myapp.setWindowFlags(Qt.ToolTip) + app.tray.setContextMenu(m) + app.tray.show() def tableWidgetInboxKeyPressEvent(self,event): if event.key() == QtCore.Qt.Key_Delete: @@ -592,15 +591,11 @@ class MyForm(QtGui.QMainWindow): os.startfile(shared.appdata + 'keys.dat') def changeEvent(self, event): - if event.type() == QtCore.QEvent.WindowStateChange: - if self.windowState() & QtCore.Qt.WindowMinimized: - self.actionShow.setChecked(False) 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() #This may have been obsoleted by https://github.com/Bitmessage/PyBitmessage/issues/135 + self.trayIcon.show() #self.hidden = True if 'win32' in sys.platform or 'win64' in sys.platform: self.setWindowFlags(Qt.ToolTip) @@ -611,10 +606,7 @@ class MyForm(QtGui.QMainWindow): def __icon_activated(self, reason): if reason == QtGui.QSystemTrayIcon.Trigger: - self.actionShow.setChecked(not self.actionShow.isChecked()) - self.appIndicatorShowOrHideWindow() - - """if 'linux' in sys.platform: + if 'linux' in sys.platform: self.trayIcon.hide() self.setWindowFlags(Qt.Window) self.show() @@ -629,7 +621,7 @@ class MyForm(QtGui.QMainWindow): #self.setWindowFlags(Qt.Window) #self.show() self.setWindowState(self.windowState() & ~QtCore.Qt.WindowMinimized | QtCore.Qt.WindowActive) - self.activateWindow()""" + self.activateWindow() def incrementNumberOfMessagesProcessed(self): self.numberOfMessagesProcessed += 1 @@ -693,22 +685,22 @@ class MyForm(QtGui.QMainWindow): if color == 'red': self.ui.pushButtonStatusIcon.setIcon(QIcon(":/newPrefix/images/redicon.png")) shared.statusIconColor = 'red' - #if self.actionStatus != None: - self.actionStatus.setText('Not Connected') + if self.actionStatus != None: + self.actionStatus.setText('Not Connected') 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 self.actionStatus != None: - self.actionStatus.setText('Connected') + if self.actionStatus != None: + self.actionStatus.setText('Connection Ok') 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' - #if self.actionStatus != None: - self.actionStatus.setText('Connected') + if self.actionStatus != None: + self.actionStatus.setText('Connection Good') def updateSentItemStatusByHash(self,toRipe,textToDisplay): for i in range(self.ui.tableWidgetSent.rowCount()): @@ -1410,13 +1402,10 @@ class MyForm(QtGui.QMainWindow): else: event.ignore()''' shared.doCleanShutdown() - #self.trayIcon.hide() - self.tray.hide() + self.trayIcon.hide() self.statusBar().showMessage('All done. Closing user interface...') event.accept() - shared.printLock.acquire() print 'Done. (passed event.accept())' - shared.printLock.release() os._exit(0) def on_action_InboxMessageForceHtml(self): @@ -2046,11 +2035,20 @@ class UISignaler(QThread): sys.stderr.write('Command sent to UISignaler not recognized: %s\n' % command) + def run(): app = QtGui.QApplication(sys.argv) app.setStyleSheet("QStatusBar::item { border: 0px solid black }") myapp = MyForm() - if not shared.config.getboolean('bitmessagesettings', 'startintray'): - myapp.show() + myapp.show() + if shared.config.getboolean('bitmessagesettings', 'startintray'): + myapp.hide() + myapp.trayIcon.show() + #self.hidden = True + #self.setWindowState(self.windowState() & QtCore.Qt.WindowMinimized) + #self.hide() + if 'win32' in sys.platform or 'win64' in sys.platform: + myapp.setWindowFlags(Qt.ToolTip) myapp.createAppIndicator(app) + sys.exit(app.exec_()) diff --git a/src/shared.py b/src/shared.py index ed1baf22..0eb7fa18 100644 --- a/src/shared.py +++ b/src/shared.py @@ -149,9 +149,7 @@ def doCleanShutdown(): print 'Completed pickle.dump. Closing output...' output.close() knownNodesLock.release() - printLock.acquire() print 'Finished closing knownnodes.dat output file.' - printLock.release() UISignalQueue.put(('updateStatusBar','Done saving the knownNodes list of peers to disk.')) broadcastToSendDataQueues((0, 'shutdown', 'all')) @@ -167,10 +165,8 @@ def doCleanShutdown(): sqlSubmitQueue.put('SELECT address FROM subscriptions') sqlSubmitQueue.put('') sqlReturnQueue.get() - sqlLock.release() - printLock.acquire() + sqlLock.release() print 'Finished flushing inventory.' - printLock.release() sqlSubmitQueue.put('exit') if safeConfigGetBoolean('bitmessagesettings','daemon'):