From 911ecab116a9133602fd8bbaac3deb3fe471be98 Mon Sep 17 00:00:00 2001 From: Volker Birk Date: Fri, 22 Mar 2019 12:51:39 +0100 Subject: [PATCH] adding DONT_TRIGGER_SYNC flag --- src/message.cc | 4 ++-- src/message.hh | 2 +- src/message_api.cc | 9 +++------ src/message_api.hh | 2 +- src/pEpmodule.cc | 2 +- test/sync_handshake.py | 7 +++++-- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/message.cc b/src/message.cc index 2505fe5..8c186c3 100644 --- a/src/message.cc +++ b/src/message.cc @@ -305,8 +305,8 @@ namespace pEp { return encrypt_message(*this, extra, enc_format, flags); } - boost::python::tuple Message::decrypt() { - return decrypt_message(*this); + boost::python::tuple Message::decrypt(int flags) { + return decrypt_message(*this, flags); } int Message::outgoing_rating() diff --git a/src/message.hh b/src/message.hh index 79c75f2..7dec7bf 100644 --- a/src/message.hh +++ b/src/message.hh @@ -130,7 +130,7 @@ namespace pEp { Message encrypt(); Message _encrypt(boost::python::list extra, int enc_format=4, int flags=0); - boost::python::tuple decrypt(); + boost::python::tuple decrypt(int flags=0); int outgoing_rating(); int outgoing_color(); Message deepcopy(dict& memo); diff --git a/src/message_api.cc b/src/message_api.cc index 9228b1c..6f87bb8 100644 --- a/src/message_api.cc +++ b/src/message_api.cc @@ -39,12 +39,12 @@ namespace pEp { return Message(_dst); } - boost::python::tuple decrypt_message(Message src) + boost::python::tuple decrypt_message(Message src, int flags) { message *_dst = NULL; stringlist_t *_keylist = NULL; PEP_rating _rating = PEP_rating_undefined; - PEP_decrypt_flags_t _flags = 0; + PEP_decrypt_flags_t _flags = (PEP_decrypt_flags_t) flags; message *_src = src; PEP_STATUS status = decrypt_message(adapter.session(), _src, &_dst, &_keylist, @@ -57,11 +57,8 @@ namespace pEp { free_stringlist(_keylist); } - int rating = (int) _rating; - int flags = (int) _flags; - Message dst = _dst ? Message(_dst) : Message(src); - return boost::python::make_tuple(dst, keylist, rating, flags); + return boost::python::make_tuple(dst, keylist, _rating, _flags); } int _color(int rating) diff --git a/src/message_api.hh b/src/message_api.hh index 98daee7..83c75ac 100644 --- a/src/message_api.hh +++ b/src/message_api.hh @@ -9,7 +9,7 @@ namespace pEp { namespace PythonAdapter { Message encrypt_message(Message src, boost::python::list extra = boost::python::list(), int enc_format = 4, int flags = 0); - boost::python::tuple decrypt_message(Message src); + boost::python::tuple decrypt_message(Message src, int flags=0); int _color(int rating); void _config_keep_sync_msg(bool enabled); object sync_search(string name); diff --git a/src/pEpmodule.cc b/src/pEpmodule.cc index 62bf1f8..6cbdfa7 100644 --- a/src/pEpmodule.cc +++ b/src/pEpmodule.cc @@ -270,7 +270,7 @@ BOOST_PYTHON_MODULE(pEp) " 3 for PGP/MIME, 4 for pEp\n" " flags 1 is force encryption\n" ) - .def("decrypt", &Message::decrypt, + .def("decrypt", &Message::decrypt, boost::python::arg("flags")=0, "msg2, keys, rating, flags = msg1.decrypt()\n" "\n" "decrypts a p≡p message and returns a tuple with data\n" diff --git a/test/sync_handshake.py b/test/sync_handshake.py index 29ba468..38f11fe 100644 --- a/test/sync_handshake.py +++ b/test/sync_handshake.py @@ -19,6 +19,7 @@ $ cd $DEV && HOME=$PWD lldb python3 -- ../sync_handshake.py -e $DEV import pathlib import os +import sys import pEp import minimail @@ -32,10 +33,12 @@ inbox = pathlib.Path("..") / "TestInbox" device_name = "" output = print +DONT_TRIGGER_SYNC = 0x200 + def messageToSend(msg): if msg.enc_format: - m, keys, rating, flags = msg.decrypt() + m, keys, rating, flags = msg.decrypt(DONT_TRIGGER_SYNC) else: m = msg output("\n" + m.attachments[0].decode()) @@ -81,7 +84,7 @@ if __name__=="__main__": dest="exec_for", help="execute for name of simulated device " + "(default: name of actual directory)") optParser.add_option("--color", action="store", type="string", - desct="color", help="print debug output in this color") + dest="color", help="print debug output in this color", default=None) options, args = optParser.parse_args() if not options.exec_for: