From 21ec1de7ca58bd700705bd4a862b0f0040d1d613 Mon Sep 17 00:00:00 2001 From: Jordan Hall Date: Wed, 19 Jun 2013 23:02:36 +0100 Subject: [PATCH] Created API commands: 'trashInboxMessage' and 'trashSentMessage'. Also, identation fix caused by accidental tabs instead of spaces. --- src/bitmessagemain.py | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/bitmessagemain.py b/src/bitmessagemain.py index fc7ce7fe..2335540a 100755 --- a/src/bitmessagemain.py +++ b/src/bitmessagemain.py @@ -3697,7 +3697,7 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler): data += ']}' return data elif method == 'getInboxMessageById': - if len(params) == 0: + if len(params) == 0: return 'API Error 0000: I need parameters!' msgid = params[0].decode('hex') v = (msgid,) @@ -3731,7 +3731,7 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler): data += ']}' return data elif method == 'getSentMessageById': - if len(params) == 0: + if len(params) == 0: return 'API Error 0000: I need parameters!' msgid = params[0].decode('hex') v = (msgid,) @@ -3748,7 +3748,7 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler): data += json.dumps({'msgid':msgid.encode('hex'),'toAddress':toAddress,'fromAddress':fromAddress,'subject':subject.encode('base64'),'message':message.encode('base64'),'encodingType':2,'lastActionTime':lastactiontime},indent=4, separators=(',', ': ')) data += ']}' return data - elif method == 'trashMessage': + elif (method == 'trashMessage') or (method == 'trashInboxMessage'): if len(params) == 0: return 'API Error 0000: I need parameters!' msgid = params[0].decode('hex') @@ -3760,7 +3760,20 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler): shared.sqlSubmitQueue.put('commit') shared.sqlLock.release() shared.UISignalQueue.put(('removeInboxRowByMsgid',msgid)) - return 'Trashed message (assuming message existed).' + return 'Trashed inbox message (assuming message existed).' + elif method == 'trashSentMessage': + if len(params) == 0: + return 'API Error 0000: I need parameters!' + msgid = params[0].decode('hex') + t = (msgid,) + shared.sqlLock.acquire() + shared.sqlSubmitQueue.put('''UPDATE sent SET folder='trash' WHERE msgid=?''') + shared.sqlSubmitQueue.put(t) + shared.sqlReturnQueue.get() + shared.sqlSubmitQueue.put('commit') + shared.sqlLock.release() + shared.UISignalQueue.put(('removeSentRowByMsgid',msgid)) + return 'Trashed sent message (assuming message existed).' elif method == 'sendMessage': if len(params) == 0: return 'API Error 0000: I need parameters!'