Browse Source

make _inject_sync_event using flag_sync_enabled

PYADPT-55
Volker Birk 6 years ago
parent
commit
63664c52ea
  1. 6
      src/adapter.cc
  2. 3
      src/adapter.hh
  3. 3
      test/sync_handshake.py

6
src/adapter.cc

@ -7,7 +7,7 @@
namespace pEp { namespace pEp {
namespace PythonAdapter { namespace PythonAdapter {
Adapter::Adapter(bool unregister_this) Adapter::Adapter(bool unregister_this)
: flag_unregister(unregister_this), flag_sync_enabled(false) : flag_unregister(unregister_this)
{ {
session(init); session(init);
} }
@ -56,6 +56,7 @@ namespace pEp {
} }
::utility::locked_queue< SYNC_EVENT > * Adapter::q = nullptr; ::utility::locked_queue< SYNC_EVENT > * Adapter::q = nullptr;
bool Adapter::flag_sync_enabled = false;
void Adapter::shutdown_sync() void Adapter::shutdown_sync()
{ {
@ -75,6 +76,9 @@ namespace pEp {
int Adapter::_inject_sync_event(SYNC_EVENT ev, void *management) int Adapter::_inject_sync_event(SYNC_EVENT ev, void *management)
{ {
if (!flag_sync_enabled)
return 1;
if (is_sync_thread(adapter.session())) { if (is_sync_thread(adapter.session())) {
PEP_STATUS status = do_sync_protocol_step(adapter.session(), adapter.ui_object(), ev); PEP_STATUS status = do_sync_protocol_step(adapter.session(), adapter.ui_object(), ev);
return status == PEP_STATUS_OK ? 0 : 1; return status == PEP_STATUS_OK ? 0 : 1;

3
src/adapter.hh

@ -14,7 +14,6 @@ namespace pEp {
class Adapter { class Adapter {
bool flag_unregister; bool flag_unregister;
bool flag_sync_enabled;
public: public:
Adapter(bool unregister_this = false); Adapter(bool unregister_this = false);
@ -42,6 +41,8 @@ namespace pEp {
static int _inject_sync_event(SYNC_EVENT ev, void *management); static int _inject_sync_event(SYNC_EVENT ev, void *management);
static ::utility::locked_queue< SYNC_EVENT > *q; static ::utility::locked_queue< SYNC_EVENT > *q;
static bool flag_sync_enabled;
bool queue_active() { return !!q; } bool queue_active() { return !!q; }
private: private:

3
test/sync_handshake.py

@ -193,6 +193,7 @@ def run(name, color=None, imap=False, own_ident=1, leave=False):
sync = Thread(target=sync_thread) sync = Thread(target=sync_thread)
sync.start() sync.start()
else: else:
pEp.script_is_implementing_sync()
sync = None sync = None
ui = UserInterface() ui = UserInterface()
@ -201,6 +202,8 @@ def run(name, color=None, imap=False, own_ident=1, leave=False):
pEp.leave_device_group() pEp.leave_device_group()
while not the_end: while not the_end:
if pEp.is_sync_active():
pass # we could react on this
if imap: if imap:
l = miniimap.recv_all() l = miniimap.recv_all()
else: else:

Loading…
Cancel
Save