CpEpEngine.h
branchsync
changeset 297 a48f0545e221
parent 296 43d9e57b6561
child 304 00916b0afaac
     1.1 --- a/CpEpEngine.h	Tue Oct 16 01:24:16 2018 +0200
     1.2 +++ b/CpEpEngine.h	Sat Oct 20 22:59:40 2018 +0200
     1.3 @@ -11,6 +11,7 @@
     1.4  #include <queue>
     1.5  #include <mutex>
     1.6  #include <vector>
     1.7 +#include "..\libpEpAdapter\pc_container.hh"
     1.8  
     1.9  #if defined(_WIN32_WCE) && !defined(_CE_DCOM) && !defined(_CE_ALLOW_SINGLE_THREADED_OBJECTS_IN_MTA)
    1.10  #error "Single-threaded COM objects are not properly supported on Windows CE platform, such as the Windows Mobile platforms that do not include full DCOM support. Define _CE_ALLOW_SINGLE_THREADED_OBJECTS_IN_MTA to force ATL to support creating single-thread COM object's and allow use of it's single-threaded COM object implementations. The threading model in your rgs file was set to 'Free' as that is the only threading model supported in non DCOM Windows CE platforms."
    1.11 @@ -85,7 +86,9 @@
    1.12  
    1.13          ::register_examine_function(session(), CpEpEngine::examine_identity, (void *)this);
    1.14          ::log_event(session(), "Startup", "pEp COM Adapter", NULL, NULL);
    1.15 -        startup(messageToSend, notifyHandshake);
    1.16 +
    1.17 +        startup<CpEpEngine>(messageToSend, notifyHandshake, messageToSend_sync, notifyHandshake_sync, this);
    1.18 +
    1.19          return S_OK;
    1.20      }
    1.21  
    1.22 @@ -93,13 +96,19 @@
    1.23      {
    1.24      }
    1.25  
    1.26 -
    1.27  protected:
    1.28      typedef locked_queue<pEp_identity_cpp> identity_queue_t;
    1.29      static ::pEp_identity * retrieve_next_identity(void *management);
    1.30 +
    1.31 +    static PEP_STATUS _messageToSend(message *msg, bool in_sync = false);
    1.32 +    static PEP_STATUS _notifyHandshake(pEp_identity *self, pEp_identity *partner, sync_handshake_signal signal, bool in_sync = false);
    1.33 +
    1.34      static PEP_STATUS messageToSend(message *msg);
    1.35      static PEP_STATUS notifyHandshake(pEp_identity *self, pEp_identity *partner, sync_handshake_signal signal);
    1.36  
    1.37 +    static PEP_STATUS messageToSend_sync(message *msg);
    1.38 +    static PEP_STATUS notifyHandshake_sync(pEp_identity *self, pEp_identity *partner, sync_handshake_signal signal);
    1.39 +
    1.40      HRESULT error(_bstr_t msg);
    1.41      HRESULT error(_bstr_t msg, PEP_STATUS errorcode);
    1.42  
    1.43 @@ -113,6 +122,14 @@
    1.44      }
    1.45  
    1.46  private:
    1.47 +    // callbacks for sync
    1.48 +    struct MarshaledCallbacks {
    1.49 +        IpEpEngineCallbacks *unmarshaled;
    1.50 +        LPSTREAM marshaled;
    1.51 +    };
    1.52 +
    1.53 +    static pEp::pc_container< MarshaledCallbacks, IpEpEngineCallbacks > sync_callbacks;
    1.54 +
    1.55      atomic< identity_queue_t * > identity_queue;
    1.56      thread *keymanagement_thread;
    1.57      bool verbose_mode;
    1.58 @@ -121,10 +138,6 @@
    1.59      bool client_last_signalled_polling_state = true;
    1.60  
    1.61      static std::mutex init_mutex;
    1.62 -
    1.63 -    static std::list< IpEpEngineCallbacks * > all_callbacks;
    1.64 -    static std::mutex callbacks_mutex;
    1.65 -
    1.66      static atomic< int > count;
    1.67  
    1.68  public: