From 04cb6575bd2b6ac2b6ff8da0db618107aaba2ecd Mon Sep 17 00:00:00 2001 From: "Grant T. Olson" Date: Wed, 31 Jul 2013 07:59:09 -0400 Subject: [PATCH] getInboxMessageIds and getSentMessageIds --- src/bitmessagemain.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/bitmessagemain.py b/src/bitmessagemain.py index 8168fd52..16a11c6f 100644 --- a/src/bitmessagemain.py +++ b/src/bitmessagemain.py @@ -325,6 +325,21 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler): 'base64'), 'message': message.encode('base64'), 'encodingType': encodingtype, 'receivedTime': received, 'read': read}, indent=4, separators=(',', ': ')) data += ']}' return data + elif method == 'getAllInboxMessageIds': + shared.sqlLock.acquire() + shared.sqlSubmitQueue.put( + '''SELECT msgid FROM inbox where folder='inbox' ORDER BY received''') + shared.sqlSubmitQueue.put('') + queryreturn = shared.sqlReturnQueue.get() + shared.sqlLock.release() + data = '{"inboxMessageIds":[' + for row in queryreturn: + msgid = row[0] + if len(data) > 25: + data += ',' + data += json.dumps({'msgid': msgid.encode('hex')}, indent=4, separators=(',', ': ')) + data += ']}' + return data elif method == 'getInboxMessageById' or method == 'getInboxMessageByID': if len(params) == 0: return 'API Error 0000: I need parameters!' @@ -359,6 +374,20 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler): 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 == 'getAllSentMessageIds': + shared.sqlLock.acquire() + shared.sqlSubmitQueue.put('''SELECT msgid FROM sent where folder='sent' ORDER BY lastactiontime''') + shared.sqlSubmitQueue.put('') + queryreturn = shared.sqlReturnQueue.get() + shared.sqlLock.release() + data = '{"sentMessageIds":[' + for row in queryreturn: + msgid = row[0] + if len(data) > 25: + data += ',' + data += json.dumps({'msgid':msgid.encode('hex')}, indent=4, separators=(',', ': ')) + data += ']}' + return data elif method == 'getInboxMessagesByAddress': if len(params) == 0: return 'API Error 0000: I need parameters!'