From e49e9a60b0c556b372c2190a033a815ca69acc64 Mon Sep 17 00:00:00 2001 From: "jordan@hall05.co.uk" <1337One> Date: Thu, 20 Jun 2013 13:04:34 +0000 Subject: [PATCH 1/3] New API command getSentMessageByAckData and modified the getAllSentMessages and getSentMessageById commands to return ackData --- src/bitmessagemain.py | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/src/bitmessagemain.py b/src/bitmessagemain.py index 798841ff..f1fa80bc 100644 --- a/src/bitmessagemain.py +++ b/src/bitmessagemain.py @@ -4401,18 +4401,18 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler): return data elif method == 'getAllSentMessages': shared.sqlLock.acquire() - shared.sqlSubmitQueue.put('''SELECT msgid, toaddress, fromaddress, subject, lastactiontime, message, encodingtype, status FROM sent where folder='sent' ORDER BY lastactiontime''') + shared.sqlSubmitQueue.put('''SELECT msgid, toaddress, fromaddress, subject, lastactiontime, message, encodingtype, status, ackdata FROM sent where folder='sent' ORDER BY lastactiontime''') shared.sqlSubmitQueue.put('') queryreturn = shared.sqlReturnQueue.get() shared.sqlLock.release() data = '{"sentMessages":[' for row in queryreturn: - msgid, toAddress, fromAddress, subject, lastactiontime, message, encodingtype, status = row + msgid, toAddress, fromAddress, subject, lastactiontime, message, encodingtype, status, ackdata = row subject = shared.fixPotentiallyInvalidUTF8Data(subject) message = shared.fixPotentiallyInvalidUTF8Data(message) if len(data) > 25: data += ',' - data += json.dumps({'msgid':msgid.encode('hex'),'toAddress':toAddress,'fromAddress':fromAddress,'subject':subject.encode('base64'),'message':message.encode('base64'),'encodingType':encodingtype,'lastActionTime':lastactiontime,'status':status},indent=4, separators=(',', ': ')) + data += json.dumps({'msgid':msgid.encode('hex'),'toAddress':toAddress,'fromAddress':fromAddress,'subject':subject.encode('base64'),'message':message.encode('base64'),'encodingType':encodingtype,'lastActionTime':lastactiontime,'status':status,'ackData':ackdata.encode('hex')},indent=4, separators=(',', ': ')) data += ']}' return data elif method == 'getInboxMessagesByAddress': @@ -4439,16 +4439,34 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler): msgid = params[0].decode('hex') v = (msgid,) shared.sqlLock.acquire() - shared.sqlSubmitQueue.put('''SELECT msgid, toaddress, fromaddress, subject, lastactiontime, message, encodingtype, status FROM sent WHERE msgid=?''') + shared.sqlSubmitQueue.put('''SELECT msgid, toaddress, fromaddress, subject, lastactiontime, message, encodingtype, status, ackdata FROM sent WHERE msgid=?''') shared.sqlSubmitQueue.put(v) queryreturn = shared.sqlReturnQueue.get() shared.sqlLock.release() data = '{"sentMessage":[' for row in queryreturn: - msgid, toAddress, fromAddress, subject, lastactiontime, message, encodingtype, status = row + msgid, toAddress, fromAddress, subject, lastactiontime, message, encodingtype, status, ackdata = row subject = shared.fixPotentiallyInvalidUTF8Data(subject) message = shared.fixPotentiallyInvalidUTF8Data(message) - data += json.dumps({'msgid':msgid.encode('hex'),'toAddress':toAddress,'fromAddress':fromAddress,'subject':subject.encode('base64'),'message':message.encode('base64'),'encodingType':encodingtype,'lastActionTime':lastactiontime,'status':status},indent=4, separators=(',', ': ')) + data += json.dumps({'msgid':msgid.encode('hex'),'toAddress':toAddress,'fromAddress':fromAddress,'subject':subject.encode('base64'),'message':message.encode('base64'),'encodingType':encodingtype,'lastActionTime':lastactiontime,'status':status,'ackData':ackdata.encode('hex')},indent=4, separators=(',', ': ')) + data += ']}' + return data + elif method == 'getSentMessageByAckData': + if len(params) == 0: + return 'API Error 0000: I need parameters!' + ackData = params[0].decode('hex') + v = (ackData,) + shared.sqlLock.acquire() + shared.sqlSubmitQueue.put('''SELECT msgid, toaddress, fromaddress, subject, lastactiontime, message, encodingtype, status, ackdata FROM sent WHERE ackdata=?''') + shared.sqlSubmitQueue.put(v) + queryreturn = shared.sqlReturnQueue.get() + shared.sqlLock.release() + data = '{"sentMessage":[' + for row in queryreturn: + msgid, toAddress, fromAddress, subject, lastactiontime, message, encodingtype, status, ackdata = row + subject = shared.fixPotentiallyInvalidUTF8Data(subject) + message = shared.fixPotentiallyInvalidUTF8Data(message) + data += json.dumps({'msgid':msgid.encode('hex'),'toAddress':toAddress,'fromAddress':fromAddress,'subject':subject.encode('base64'),'message':message.encode('base64'),'encodingType':encodingtype,'lastActionTime':lastactiontime,'status':status,'ackData':ackdata.encode('hex')},indent=4, separators=(',', ': ')) data += ']}' return data elif (method == 'trashMessage') or (method == 'trashInboxMessage'): From a6c9ff288ebce62cdade84557f3e5638159a5263 Mon Sep 17 00:00:00 2001 From: Jonathan Warren Date: Thu, 20 Jun 2013 16:04:50 -0400 Subject: [PATCH 2/3] manuall merge github issue #229 --- src/pyelliptic/openssl.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pyelliptic/openssl.py b/src/pyelliptic/openssl.py index de073fab..09df5ca4 100644 --- a/src/pyelliptic/openssl.py +++ b/src/pyelliptic/openssl.py @@ -427,7 +427,7 @@ except: lib_path = path.join(sys._MEIPASS, "libeay32.dll") OpenSSL = _OpenSSL(lib_path) except: - if 'linux' in sys.platform or 'darwin' in sys.platform: + if 'linux' in sys.platform or 'darwin' in sys.platform or 'freebsd' in sys.platform: try: from ctypes.util import find_library OpenSSL = _OpenSSL(find_library('ssl')) From 936369da0ab79fb15c17be4823e8a2871136aee4 Mon Sep 17 00:00:00 2001 From: Jonathan Warren Date: Thu, 20 Jun 2013 16:41:14 -0400 Subject: [PATCH 3/3] manual implement Github issue #223 --- src/bitmessagemain.py | 7 +++++-- src/bitmessageqt/__init__.py | 12 ++++++------ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/bitmessagemain.py b/src/bitmessagemain.py index 798841ff..8f018337 100644 --- a/src/bitmessagemain.py +++ b/src/bitmessagemain.py @@ -68,14 +68,17 @@ class outgoingSynSender(threading.Thread): if shared.shutdown: break random.seed() + shared.knownNodesLock.acquire() HOST, = random.sample(shared.knownNodes[self.streamNumber], 1) + shared.knownNodesLock.release() alreadyAttemptedConnectionsListLock.acquire() while HOST in alreadyAttemptedConnectionsList or HOST in shared.connectedHostsList: alreadyAttemptedConnectionsListLock.release() # print 'choosing new sample' random.seed() - HOST, = random.sample(shared.knownNodes[ - self.streamNumber], 1) + shared.knownNodesLock.acquire() + HOST, = random.sample(shared.knownNodes[self.streamNumber], 1) + shared.knownNodesLock.release() time.sleep(1) # Clear out the alreadyAttemptedConnectionsList every half # hour so that this program will again attempt a connection diff --git a/src/bitmessageqt/__init__.py b/src/bitmessageqt/__init__.py index 22f957e3..3f0c7e6f 100644 --- a/src/bitmessageqt/__init__.py +++ b/src/bitmessageqt/__init__.py @@ -1076,8 +1076,8 @@ class MyForm(QtGui.QMainWindow): shared.statusIconColor = 'red' # if the connection is lost then show a notification if self.connected: - self.notifierShow('Bitmessage', _translate( - "MainWindow", "Connection lost")) + self.notifierShow('Bitmessage', unicode(_translate( + "MainWindow", "Connection lost").toUtf8(),'utf-8')) self.connected = False if self.actionStatus is not None: @@ -1109,8 +1109,8 @@ class MyForm(QtGui.QMainWindow): QIcon(":/newPrefix/images/greenicon.png")) shared.statusIconColor = 'green' if not self.connected: - self.notifierShow('Bitmessage', _translate( - "MainWindow", "Connected")) + self.notifierShow('Bitmessage', unicode(_translate( + "MainWindow", "Connected").toUtf8(),'utf-8')) self.connected = True if self.actionStatus is not None: @@ -1582,12 +1582,12 @@ class MyForm(QtGui.QMainWindow): newItem = QtGui.QTableWidgetItem(unicode(fromAddress, 'utf-8')) newItem.setToolTip(unicode(fromAddress, 'utf-8')) if shared.config.getboolean('bitmessagesettings', 'showtraynotifications'): - self.notifierShow('New Message', 'From ' + fromAddress) + self.notifierShow(unicode(_translate("MainWindow",'New Message').toUtf8(),'utf-8'), unicode(_translate("MainWindow",'From ').toUtf8(),'utf-8') + unicode(fromAddress, 'utf-8')) else: newItem = QtGui.QTableWidgetItem(unicode(fromLabel, 'utf-8')) newItem.setToolTip(unicode(unicode(fromLabel, 'utf-8'))) if shared.config.getboolean('bitmessagesettings', 'showtraynotifications'): - self.notifierShow('New Message', 'From ' + fromLabel) + self.notifierShow(unicode(_translate("MainWindow",'New Message').toUtf8(),'utf-8'), unicode(_translate("MainWindow",'From ').toUtf8(),'utf-8') + unicode(fromLabel, 'utf-8')) newItem.setData(Qt.UserRole, str(fromAddress)) newItem.setFont(font) self.ui.tableWidgetInbox.setItem(0, 1, newItem)