simplify sync
authorVolker Birk <vb@pep.foundation>
Mon, 22 Oct 2018 17:54:28 +0200
branchsync
changeset 307eb5012d87405
parent 306 68a6adf189f8
child 308 0017f25f860d
simplify
CpEpEngine.cpp
CpEpEngine.h
     1.1 --- a/CpEpEngine.cpp	Mon Oct 22 10:59:28 2018 +0200
     1.2 +++ b/CpEpEngine.cpp	Mon Oct 22 17:54:28 2018 +0200
     1.3 @@ -736,12 +736,14 @@
     1.4      return _ident;
     1.5  }
     1.6  
     1.7 -PEP_STATUS CpEpEngine::_messageToSend(message *msg, bool in_sync)
     1.8 +PEP_STATUS CpEpEngine::messageToSend(message *msg)
     1.9  {
    1.10      assert(msg);
    1.11      if (!msg)
    1.12          return PEP_ILLEGAL_VALUE;
    1.13  
    1.14 +    bool in_sync = on_sync_thread();
    1.15 +
    1.16      for (auto p = sync_callbacks.begin(); p != sync_callbacks.end(); ++p) {
    1.17          IpEpEngineCallbacks *cb;
    1.18          if (in_sync)
    1.19 @@ -767,22 +769,14 @@
    1.20      return PEP_STATUS_OK;
    1.21  }
    1.22  
    1.23 -PEP_STATUS CpEpEngine::messageToSend(message *msg)
    1.24 -{
    1.25 -    return _messageToSend(msg);
    1.26 -}
    1.27 -
    1.28 -PEP_STATUS CpEpEngine::messageToSend_sync(message *msg)
    1.29 -{
    1.30 -    return _messageToSend(msg, true);
    1.31 -}
    1.32 -
    1.33 -PEP_STATUS CpEpEngine::_notifyHandshake(::pEp_identity *self, ::pEp_identity *partner, sync_handshake_signal signal, bool in_sync)
    1.34 +PEP_STATUS CpEpEngine::notifyHandshake(::pEp_identity *self, ::pEp_identity *partner, sync_handshake_signal signal)
    1.35  {
    1.36      assert(self && partner);
    1.37      if (!(self && partner))
    1.38          return PEP_ILLEGAL_VALUE;
    1.39  
    1.40 +    bool in_sync = on_sync_thread();
    1.41 +
    1.42      // fire all of them
    1.43      for (auto p = sync_callbacks.begin(); p != sync_callbacks.end(); ++p) {
    1.44          IpEpEngineCallbacks *cb;
    1.45 @@ -811,16 +805,6 @@
    1.46      return PEP_STATUS_OK;
    1.47  }
    1.48  
    1.49 -PEP_STATUS CpEpEngine::notifyHandshake(::pEp_identity *self, ::pEp_identity *partner, sync_handshake_signal signal)
    1.50 -{
    1.51 -    return _notifyHandshake(self, partner, signal);
    1.52 -}
    1.53 -
    1.54 -PEP_STATUS CpEpEngine::notifyHandshake_sync(::pEp_identity *self, ::pEp_identity *partner, sync_handshake_signal signal)
    1.55 -{
    1.56 -    return _notifyHandshake(self, partner, signal, true);
    1.57 -}
    1.58 -
    1.59  STDMETHODIMP CpEpEngine::BlacklistAdd(BSTR fpr)
    1.60  {
    1.61      assert(fpr);
     2.1 --- a/CpEpEngine.h	Mon Oct 22 10:59:28 2018 +0200
     2.2 +++ b/CpEpEngine.h	Mon Oct 22 17:54:28 2018 +0200
     2.3 @@ -87,7 +87,7 @@
     2.4          ::register_examine_function(session(), CpEpEngine::examine_identity, (void *)this);
     2.5          ::log_event(session(), "Startup", "pEp COM Adapter", NULL, NULL);
     2.6  
     2.7 -        startup<CpEpEngine>(messageToSend, notifyHandshake, messageToSend_sync, notifyHandshake_sync, this, &CpEpEngine::Startup_sync);
     2.8 +        startup<CpEpEngine>(messageToSend, notifyHandshake, this, &CpEpEngine::Startup_sync);
     2.9  
    2.10          return S_OK;
    2.11      }
    2.12 @@ -100,15 +100,9 @@
    2.13      typedef locked_queue<pEp_identity_cpp> identity_queue_t;
    2.14      static ::pEp_identity * retrieve_next_identity(void *management);
    2.15  
    2.16 -    static PEP_STATUS _messageToSend(message *msg, bool in_sync = false);
    2.17 -    static PEP_STATUS _notifyHandshake(pEp_identity *self, pEp_identity *partner, sync_handshake_signal signal, bool in_sync = false);
    2.18 -
    2.19      static PEP_STATUS messageToSend(message *msg);
    2.20      static PEP_STATUS notifyHandshake(pEp_identity *self, pEp_identity *partner, sync_handshake_signal signal);
    2.21  
    2.22 -    static PEP_STATUS messageToSend_sync(message *msg);
    2.23 -    static PEP_STATUS notifyHandshake_sync(pEp_identity *self, pEp_identity *partner, sync_handshake_signal signal);
    2.24 -
    2.25      HRESULT error(_bstr_t msg);
    2.26      HRESULT error(_bstr_t msg, PEP_STATUS errorcode);
    2.27