Browse Source

make _inject_sync_event using flag_sync_enabled

PYADPT-55
Volker Birk 2 years ago
parent
commit
63664c52ea
3 changed files with 10 additions and 2 deletions
  1. +5
    -1
      src/adapter.cc
  2. +2
    -1
      src/adapter.hh
  3. +3
    -0
      test/sync_handshake.py

+ 5
- 1
src/adapter.cc View File

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


+ 2
- 1
src/adapter.hh View File

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


+ 3
- 0
test/sync_handshake.py View File

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


Loading…
Cancel
Save