'unnecessary' sync
authorVolker Birk <vb@pep.foundation>
Mon, 15 Oct 2018 22:15:24 +0200
branchsync
changeset 295f55ec2fd694f
parent 294 b2fe2bac2db0
child 296 43d9e57b6561
'unnecessary'
CpEpEngine.cpp
CpEpEngine.h
locked_queue.hh
pEpCOMServerAdapter.idl
pEpCOMServerAdapter.vcxproj
pEpCOMServerAdapter.vcxproj.filters
stdafx.h
     1.1 --- a/CpEpEngine.cpp	Fri Oct 05 14:32:36 2018 +0200
     1.2 +++ b/CpEpEngine.cpp	Mon Oct 15 22:15:24 2018 +0200
     1.3 @@ -4,17 +4,23 @@
     1.4  #include "CpEpEngine.h"
     1.5  #include <mutex>
     1.6  #include "GateKeeper.h"
     1.7 +#include "..\libpEpAdapter\Adapter.hh"
     1.8  
     1.9  using namespace std;
    1.10  using namespace pEp::utility;
    1.11 +using namespace pEp::Adapter;
    1.12  
    1.13  // CpEpEngine
    1.14  
    1.15  // the init_mutex protects our initialization and destruction
    1.16  // against a running keysync thread, and it ensures that the
    1.17  // keysync thread actually has finished before we're destructed.
    1.18 +
    1.19  std::mutex CpEpEngine::init_mutex;
    1.20  
    1.21 +std::list< IpEpEngineCallbacks * > CpEpEngine::all_callbacks;
    1.22 +std::mutex CpEpEngine::callbacks_mutex;
    1.23 +
    1.24  STDMETHODIMP CpEpEngine::InterfaceSupportsErrorInfo(REFIID riid)
    1.25  {
    1.26      static const IID* const arr[] =
    1.27 @@ -41,13 +47,13 @@
    1.28  
    1.29  STDMETHODIMP CpEpEngine::PassiveMode(VARIANT_BOOL enable)
    1.30  {
    1.31 -    ::config_passive_mode(get_session(), enable != VARIANT_FALSE);
    1.32 +    ::config_passive_mode(session(), enable != VARIANT_FALSE);
    1.33      return S_OK;
    1.34  }
    1.35  
    1.36  STDMETHODIMP CpEpEngine::UnencryptedSubject(VARIANT_BOOL enable)
    1.37  {
    1.38 -    ::config_unencrypted_subject(get_session(), enable != VARIANT_FALSE);
    1.39 +    ::config_unencrypted_subject(session(), enable != VARIANT_FALSE);
    1.40      return S_OK;
    1.41  }
    1.42  
    1.43 @@ -63,12 +69,12 @@
    1.44      char *_key_data = NULL;
    1.45      size_t _size = 0;
    1.46  
    1.47 -    ::PEP_STATUS status = ::export_key(get_session(), _fpr.c_str(), &_key_data, &_size);
    1.48 +    PEP_STATUS status = ::export_key(session(), _fpr.c_str(), &_key_data, &_size);
    1.49      assert(status != ::PEP_OUT_OF_MEMORY);
    1.50      if (status == ::PEP_OUT_OF_MEMORY)
    1.51          return E_OUTOFMEMORY;
    1.52  
    1.53 -    if (status != ::PEP_STATUS_OK)
    1.54 +    if (status != PEP_STATUS_OK)
    1.55          return FAIL(L"export_key", status);
    1.56  
    1.57      _bstr_t b_key_data(utf16_string(_key_data).c_str());
    1.58 @@ -107,7 +113,7 @@
    1.59      if (result != S_OK)
    1.60          return result;
    1.61  
    1.62 -    PEP_STATUS _status = ::log_event(get_session(), _title.c_str(), _entity.c_str(), _description.c_str(), _comment.c_str());
    1.63 +    PEP_STATUS _status = ::log_event(session(), _title.c_str(), _entity.c_str(), _description.c_str(), _comment.c_str());
    1.64      assert(_status == PEP_STATUS_OK);
    1.65      if (_status != PEP_STATUS_OK)
    1.66          return FAIL(L"log_event", _status);
    1.67 @@ -154,7 +160,7 @@
    1.68      char *_words = NULL;
    1.69      size_t _wsize = 0;
    1.70  
    1.71 -    PEP_STATUS status = ::trustwords(get_session(), _fpr.c_str(), _lang.c_str(), &_words, &_wsize, max_words);
    1.72 +    PEP_STATUS status = ::trustwords(session(), _fpr.c_str(), _lang.c_str(), &_words, &_wsize, max_words);
    1.73      assert(status != PEP_OUT_OF_MEMORY);
    1.74      if (status == PEP_OUT_OF_MEMORY)
    1.75          return E_OUTOFMEMORY;
    1.76 @@ -215,7 +221,7 @@
    1.77      char* _words;
    1.78      size_t _size;
    1.79      if (result == S_OK) {
    1.80 -        auto status = ::get_trustwords(get_session(), _id1, _id2, _lang.c_str(), &_words, &_size, full != 0 /* convert variant bool to C bool */);
    1.81 +        auto status = ::get_trustwords(session(), _id1, _id2, _lang.c_str(), &_words, &_size, full != 0 /* convert variant bool to C bool */);
    1.82  
    1.83          if (status == PEP_OUT_OF_MEMORY) {
    1.84              result = E_OUTOFMEMORY;
    1.85 @@ -293,7 +299,7 @@
    1.86      char* _words = NULL;
    1.87      if (result == S_OK) {
    1.88          auto status = ::get_message_trustwords(
    1.89 -            get_session(),
    1.90 +            session(),
    1.91              _msg,
    1.92              _keylist,
    1.93              _received_by,
    1.94 @@ -336,7 +342,7 @@
    1.95          return E_INVALIDARG;
    1.96  
    1.97      char *_log;
    1.98 -    PEP_STATUS status = ::get_crashdump_log(get_session(), (int)maxlines, &_log);
    1.99 +    PEP_STATUS status = ::get_crashdump_log(session(), (int)maxlines, &_log);
   1.100      assert(status == PEP_STATUS_OK);
   1.101      if (status == PEP_OUT_OF_MEMORY)
   1.102          return E_OUTOFMEMORY;
   1.103 @@ -375,7 +381,7 @@
   1.104          return E_INVALIDARG;
   1.105  
   1.106      char *_languages;
   1.107 -    PEP_STATUS status = ::get_languagelist(get_session(), &_languages);
   1.108 +    PEP_STATUS status = ::get_languagelist(session(), &_languages);
   1.109      assert(status == PEP_STATUS_OK);
   1.110      if (status == PEP_OUT_OF_MEMORY)
   1.111          return E_OUTOFMEMORY;
   1.112 @@ -410,7 +416,7 @@
   1.113          return FAIL(ex.what());;
   1.114      }
   1.115  
   1.116 -    PEP_STATUS status = ::set_identity_flags(get_session(), _ident, (identity_flags_t)flags);
   1.117 +    PEP_STATUS status = ::set_identity_flags(session(), _ident, (identity_flags_t)flags);
   1.118      ::free_identity(_ident);
   1.119      if (status != PEP_STATUS_OK)
   1.120          return FAIL(_T("SetIdentityFlags"), status);
   1.121 @@ -439,7 +445,7 @@
   1.122          return FAIL(ex.what());;
   1.123      }
   1.124  
   1.125 -    PEP_STATUS status = ::unset_identity_flags(get_session(), _ident, (identity_flags_t)flags);
   1.126 +    PEP_STATUS status = ::unset_identity_flags(session(), _ident, (identity_flags_t)flags);
   1.127      ::free_identity(_ident);
   1.128      if (status != PEP_STATUS_OK)
   1.129          return FAIL(_T("UnsetIdentityFlags"), status);
   1.130 @@ -509,7 +515,7 @@
   1.131      // 
   1.132      // HRESULT res2 = Fire_TestEvent(15, _bstr_t( "hallo"));
   1.133  
   1.134 -    PEP_STATUS status = ::myself(get_session(), _ident);
   1.135 +    PEP_STATUS status = ::myself(session(), _ident);
   1.136  
   1.137      if (status == PEP_STATUS_OK) {
   1.138          assert(_ident->fpr);
   1.139 @@ -549,7 +555,7 @@
   1.140      if (_ident == NULL)
   1.141          return E_OUTOFMEMORY;
   1.142  
   1.143 -    PEP_STATUS status = ::update_identity(get_session(), _ident);
   1.144 +    PEP_STATUS status = ::update_identity(session(), _ident);
   1.145  
   1.146      if (status == PEP_STATUS_OK) {
   1.147          copy_identity(result, _ident);
   1.148 @@ -593,7 +599,7 @@
   1.149          return FAIL(ex.what());;
   1.150      }
   1.151  
   1.152 -    PEP_STATUS status = ::key_mistrusted(get_session(), _ident);
   1.153 +    PEP_STATUS status = ::key_mistrusted(session(), _ident);
   1.154      free_identity(_ident);
   1.155  
   1.156      if (status == PEP_OUT_OF_MEMORY)
   1.157 @@ -602,26 +608,18 @@
   1.158      if (status == PEP_KEY_NOT_FOUND)
   1.159          return FAIL(L"key not found");
   1.160  
   1.161 -    if (status != ::PEP_STATUS_OK)
   1.162 +    if (status != PEP_STATUS_OK)
   1.163          return FAIL(L"cannot revoke compromized key", status);
   1.164  
   1.165      return S_OK;
   1.166  }
   1.167  
   1.168 -STDMETHODIMP CpEpEngine::UndoLastMistrust()
   1.169 -{
   1.170 -    PEP_STATUS status = ::undo_last_mistrust(get_session());
   1.171 +//STDMETHODIMP CpEpEngine::UndoLastMistrust()
   1.172 +//{
   1.173 +//    return FAIL(L"function UndoLastMistrust() not available any more - use KeyResetTrust() instead!", PEP_ILLEGAL_VALUE);
   1.174 +//}
   1.175  
   1.176 -    if (status == PEP_CANNOT_FIND_IDENTITY)
   1.177 -        return FAIL(L"Cannot find identity!", status);
   1.178 -
   1.179 -    if (status != ::PEP_STATUS_OK)
   1.180 -        return FAIL(L"cannot revoke compromized key", status);
   1.181 -
   1.182 -    return S_OK;
   1.183 -}
   1.184 -
   1.185 -STDMETHODIMP CpEpEngine::IsPepUser(/* [in] */ struct pEpIdentity *ident, /* [retval][out] */ VARIANT_BOOL *ispEp) 
   1.186 +STDMETHODIMP CpEpEngine::IspEpUser(/* [in] */ struct pEpIdentity *ident, /* [retval][out] */ VARIANT_BOOL *ispEp) 
   1.187  {
   1.188      ::pEp_identity *_ident;
   1.189  
   1.190 @@ -640,7 +638,7 @@
   1.191      }
   1.192  
   1.193      bool is_pep = FALSE;
   1.194 -    PEP_STATUS status = ::is_pep_user(get_session(), _ident, &is_pep);
   1.195 +    PEP_STATUS status = ::is_pEp_user(session(), _ident, &is_pep);
   1.196  
   1.197      *ispEp = is_pep;
   1.198  
   1.199 @@ -650,8 +648,8 @@
   1.200      if (status == PEP_ILLEGAL_VALUE)
   1.201          return E_INVALIDARG;
   1.202  
   1.203 -    if (status != ::PEP_STATUS_OK)
   1.204 -        return FAIL(L"Engine is_pep_user returned error", status);
   1.205 +    if (status != PEP_STATUS_OK)
   1.206 +        return FAIL(L"Engine is_pEp_user returned error", status);
   1.207  
   1.208      return S_OK;
   1.209  }
   1.210 @@ -675,7 +673,7 @@
   1.211          return FAIL(ex.what());;
   1.212      }
   1.213  
   1.214 -    PEP_STATUS status = ::key_reset_trust(get_session(), _ident);
   1.215 +    PEP_STATUS status = ::key_reset_trust(session(), _ident);
   1.216      free_identity(_ident);
   1.217  
   1.218      if (status == PEP_OUT_OF_MEMORY)
   1.219 @@ -684,7 +682,7 @@
   1.220      if (status == PEP_KEY_NOT_FOUND)
   1.221          return FAIL(L"key not found");
   1.222  
   1.223 -    if (status != ::PEP_STATUS_OK)
   1.224 +    if (status != PEP_STATUS_OK)
   1.225          return FAIL(L"cannot reset trust", status);
   1.226  
   1.227      return S_OK;
   1.228 @@ -738,19 +736,22 @@
   1.229      return _ident;
   1.230  }
   1.231  
   1.232 -PEP_STATUS CpEpEngine::messageToSend(void * obj, message *msg)
   1.233 +PEP_STATUS CpEpEngine::messageToSend(message *msg)
   1.234  {
   1.235      assert(msg);
   1.236 -    assert(obj);
   1.237 -    if (!(msg && obj))
   1.238 +    if (!msg)
   1.239          return PEP_ILLEGAL_VALUE;
   1.240  
   1.241 +    lock_guard< mutex > lock(callbacks_mutex);
   1.242 +
   1.243 +    // use the first one
   1.244 +    IpEpEngineCallbacks *cb = all_callbacks.front();
   1.245 +
   1.246      TextMessage _msg;
   1.247      memset(&_msg, 0, sizeof(TextMessage));
   1.248  
   1.249      text_message_from_C(&_msg, msg);
   1.250 -    CpEpEngine *me = (CpEpEngine *)obj;
   1.251 -    HRESULT r = me->Fire_MessageToSend(&_msg);
   1.252 +    HRESULT r = cb->MessageToSend(&_msg);
   1.253      assert(r == S_OK);
   1.254      clear_text_message(&_msg);
   1.255      if (r == E_OUTOFMEMORY)
   1.256 @@ -761,6 +762,39 @@
   1.257      return PEP_STATUS_OK;
   1.258  }
   1.259  
   1.260 +PEP_STATUS CpEpEngine::notifyHandshake(::pEp_identity *self, ::pEp_identity *partner, sync_handshake_signal signal)
   1.261 +{
   1.262 +    assert(self && partner);
   1.263 +    if (!(self && partner))
   1.264 +        return PEP_ILLEGAL_VALUE;
   1.265 +
   1.266 +    lock_guard< mutex > lock(callbacks_mutex);
   1.267 +    
   1.268 +    if (all_callbacks.size() == 0)
   1.269 +        return PEP_SYNC_NO_NOTIFY_CALLBACK;
   1.270 +
   1.271 +    // fire all of them
   1.272 +    for (auto i = all_callbacks.begin(); i != all_callbacks.end(); ++i) {
   1.273 +        IpEpEngineCallbacks *cb = *i;
   1.274 +
   1.275 +        pEpIdentity _self;
   1.276 +        copy_identity(&_self, self);
   1.277 +        pEpIdentity _partner;
   1.278 +        copy_identity(&_partner, partner);
   1.279 +
   1.280 +        SyncHandshakeSignal _signal = (SyncHandshakeSignal) signal;
   1.281 +        SyncHandshakeResult result;
   1.282 +        HRESULT r = cb->NotifyHandshake(&_self, &_partner, _signal, &result);
   1.283 +        assert(r == S_OK);
   1.284 +        clear_identity_s(_self);
   1.285 +        clear_identity_s(_partner);
   1.286 +        if (r == E_OUTOFMEMORY)
   1.287 +            return PEP_OUT_OF_MEMORY;
   1.288 +    }
   1.289 +
   1.290 +    return PEP_STATUS_OK;
   1.291 +}
   1.292 +
   1.293  STDMETHODIMP CpEpEngine::BlacklistAdd(BSTR fpr)
   1.294  {
   1.295      assert(fpr);
   1.296 @@ -768,7 +802,7 @@
   1.297          return E_INVALIDARG;
   1.298  
   1.299      string _fpr = utf8_string(fpr);
   1.300 -    PEP_STATUS status = ::blacklist_add(get_session(), _fpr.c_str());
   1.301 +    PEP_STATUS status = ::blacklist_add(session(), _fpr.c_str());
   1.302      assert(status == PEP_STATUS_OK);
   1.303      if (status != PEP_STATUS_OK)
   1.304          return FAIL(L"blacklist_add failed in pEp engine", status);
   1.305 @@ -783,7 +817,7 @@
   1.306          return E_INVALIDARG;
   1.307  
   1.308      string _fpr = utf8_string(fpr);
   1.309 -    PEP_STATUS status = ::blacklist_delete(get_session(), _fpr.c_str());
   1.310 +    PEP_STATUS status = ::blacklist_delete(session(), _fpr.c_str());
   1.311      assert(status == PEP_STATUS_OK);
   1.312      if (status != PEP_STATUS_OK)
   1.313          return FAIL(L"blacklist_delete failed in pEp engine", status);
   1.314 @@ -801,7 +835,7 @@
   1.315  
   1.316      string _fpr = utf8_string(fpr);
   1.317      bool result;
   1.318 -    PEP_STATUS status = ::blacklist_is_listed(get_session(), _fpr.c_str(), &result);
   1.319 +    PEP_STATUS status = ::blacklist_is_listed(session(), _fpr.c_str(), &result);
   1.320      assert(status == PEP_STATUS_OK);
   1.321      if (status != PEP_STATUS_OK)
   1.322          return FAIL(L"blacklist_is_listed failed in pEp engine", status);
   1.323 @@ -818,7 +852,7 @@
   1.324          return E_INVALIDARG;
   1.325  
   1.326      ::stringlist_t *_blacklist = NULL;
   1.327 -    PEP_STATUS status = ::blacklist_retrieve(get_session(), &_blacklist);
   1.328 +    PEP_STATUS status = ::blacklist_retrieve(session(), &_blacklist);
   1.329      assert(status == PEP_STATUS_OK);
   1.330      if (status != PEP_STATUS_OK)
   1.331          return FAIL(L"blacklist_retrieve failed in pEp engine", status);
   1.332 @@ -889,7 +923,7 @@
   1.333      // Since COM-74, this has been changed to an explicit parameter, to allow the engine to attach
   1.334      // the keys and headers to outgoing, unencrypted messages.
   1.335      PEP_encrypt_flags_t engineFlags = (PEP_encrypt_flags_t)flags;
   1.336 -    PEP_STATUS status = ::encrypt_message(get_session(), _src, _extra, &msg_dst, _encFormat, engineFlags);
   1.337 +    PEP_STATUS status = ::encrypt_message(session(), _src, _extra, &msg_dst, _encFormat, engineFlags);
   1.338      ::free_stringlist(_extra);
   1.339  
   1.340      if (status == PEP_STATUS_OK)
   1.341 @@ -941,7 +975,7 @@
   1.342                                                      // Since COM-74, this has been changed to an explicit parameter, to allow the engine to attach
   1.343                                                      // the keys and headers to outgoing, unencrypted messages.
   1.344      PEP_encrypt_flags_t engineFlags = (PEP_encrypt_flags_t)flags;
   1.345 -    PEP_STATUS status = ::encrypt_message_and_add_priv_key(get_session(), _src, &msg_dst, _to_fpr.c_str(), _encFormat, engineFlags);
   1.346 +    PEP_STATUS status = ::encrypt_message_and_add_priv_key(session(), _src, &msg_dst, _to_fpr.c_str(), _encFormat, engineFlags);
   1.347  
   1.348      if (status == PEP_STATUS_OK)
   1.349          text_message_from_C(dst, msg_dst);
   1.350 @@ -998,7 +1032,7 @@
   1.351          // COM-19: Initialize msg_dst to NULL, or we end up calling
   1.352          // free_message() below with a pointer to random garbage in
   1.353          // case of an error in encrypt_message_for_self().
   1.354 -        status = ::encrypt_message_for_self(get_session(), _target_id, _src, _extra, &msg_dst, PEP_enc_PEP, engineFlags);
   1.355 +        status = ::encrypt_message_for_self(session(), _target_id, _src, _extra, &msg_dst, PEP_enc_PEP, engineFlags);
   1.356  
   1.357          if (status == PEP_STATUS_OK)
   1.358              text_message_from_C(dst, msg_dst);
   1.359 @@ -1046,7 +1080,7 @@
   1.360      ::PEP_rating _rating;
   1.361  
   1.362      PEP_decrypt_flags_t engineflags = (PEP_decrypt_flags_t) *flags;
   1.363 -    PEP_STATUS status = ::decrypt_message(get_session(), _src, &msg_dst, &_keylist, &_rating, &engineflags);
   1.364 +    PEP_STATUS status = ::decrypt_message(session(), _src, &msg_dst, &_keylist, &_rating, &engineflags);
   1.365  
   1.366      *flags = (pEpDecryptFlags)engineflags;
   1.367  
   1.368 @@ -1084,7 +1118,7 @@
   1.369      ::stringlist_t *_keylist = new_stringlist(x_KeyList);
   1.370      ::PEP_rating _rating = PEP_rating_undefined;
   1.371  
   1.372 -    PEP_STATUS status = ::re_evaluate_message_rating(get_session(), _msg, _keylist, (PEP_rating)x_EncStatus, &_rating);
   1.373 +    PEP_STATUS status = ::re_evaluate_message_rating(session(), _msg, _keylist, (PEP_rating)x_EncStatus, &_rating);
   1.374  
   1.375      ::free_stringlist(_keylist);
   1.376      ::free_message(_msg);
   1.377 @@ -1105,7 +1139,7 @@
   1.378      ::message *_msg = text_message_to_C(msg);
   1.379  
   1.380      PEP_rating _rating;
   1.381 -    PEP_STATUS status = ::outgoing_message_rating(get_session(), _msg, &_rating);
   1.382 +    PEP_STATUS status = ::outgoing_message_rating(session(), _msg, &_rating);
   1.383      if (status != PEP_STATUS_OK)
   1.384          return FAIL(L"cannot get message rating", status);
   1.385  
   1.386 @@ -1124,7 +1158,7 @@
   1.387  	::message *_msg = text_message_to_C(msg);
   1.388  
   1.389  	PEP_rating _rating;
   1.390 -	PEP_STATUS status = ::outgoing_message_rating_preview(get_session(), _msg, &_rating);
   1.391 +	PEP_STATUS status = ::outgoing_message_rating_preview(session(), _msg, &_rating);
   1.392  	if (status != PEP_STATUS_OK)
   1.393  		return FAIL(L"cannot get message rating", status);
   1.394  
   1.395 @@ -1153,7 +1187,7 @@
   1.396      }
   1.397  
   1.398      PEP_rating _rating;
   1.399 -    PEP_STATUS status = ::identity_rating(get_session(), _ident, &_rating);
   1.400 +    PEP_STATUS status = ::identity_rating(session(), _ident, &_rating);
   1.401      free_identity(_ident);
   1.402  
   1.403      if (status != PEP_STATUS_OK)
   1.404 @@ -1187,7 +1221,7 @@
   1.405      *ownIdentities = nullptr;
   1.406  
   1.407      ::identity_list *il = nullptr;
   1.408 -    PEP_STATUS status = ::own_identities_retrieve(get_session(), &il);
   1.409 +    PEP_STATUS status = ::own_identities_retrieve(session(), &il);
   1.410      if (status == PEP_OUT_OF_MEMORY) {
   1.411          return E_OUTOFMEMORY;
   1.412      }
   1.413 @@ -1247,7 +1281,7 @@
   1.414          verbose(ss.str());
   1.415      }
   1.416  
   1.417 -    PEP_STATUS status = ::trust_personal_key(get_session(), _ident);
   1.418 +    PEP_STATUS status = ::trust_personal_key(session(), _ident);
   1.419  
   1.420      if (verbose_mode) {
   1.421          stringstream ss;
   1.422 @@ -1285,6 +1319,8 @@
   1.423      catch (exception& ex) {
   1.424          return FAIL(ex.what());;
   1.425      }
   1.426 +
   1.427 +    return S_OK;
   1.428  }
   1.429  
   1.430  // Event callbacks
   1.431 @@ -1302,6 +1338,11 @@
   1.432      this->client_callbacks = new_callbacks;
   1.433      new_callbacks->AddRef();
   1.434  
   1.435 +    {
   1.436 +        lock_guard< mutex > lock(callbacks_mutex);
   1.437 +        all_callbacks.push_back(this->client_callbacks);
   1.438 +    }
   1.439 +
   1.440      return S_OK;
   1.441  }
   1.442  
   1.443 @@ -1312,6 +1353,16 @@
   1.444      if (!this->client_callbacks)
   1.445          return S_FALSE;
   1.446  
   1.447 +    {
   1.448 +        lock_guard< mutex > lock(callbacks_mutex);
   1.449 +        for (auto i = all_callbacks.begin(); i != all_callbacks.end(); ++i) {
   1.450 +            if (*i == this->client_callbacks) {
   1.451 +                all_callbacks.erase(i);
   1.452 +                break;
   1.453 +            }
   1.454 +        }
   1.455 +    }
   1.456 +
   1.457      this->client_callbacks->Release();
   1.458      this->client_callbacks = NULL;
   1.459  
   1.460 @@ -1329,12 +1380,12 @@
   1.461          _pattern = utf8_string(search_pattern);
   1.462      ::stringpair_list_t* _keyinfo_list = NULL;
   1.463  
   1.464 -    PEP_STATUS status = ::OpenPGP_list_keyinfo(get_session(), _pattern.c_str(), &_keyinfo_list);
   1.465 +    PEP_STATUS status = ::OpenPGP_list_keyinfo(session(), _pattern.c_str(), &_keyinfo_list);
   1.466      assert(status != PEP_OUT_OF_MEMORY);
   1.467      if (status == PEP_OUT_OF_MEMORY)
   1.468          return E_OUTOFMEMORY;
   1.469  
   1.470 -    if (status != ::PEP_STATUS_OK)
   1.471 +    if (status != PEP_STATUS_OK)
   1.472          return FAIL(L"OpenPGP_list_keyinfo", status);
   1.473  
   1.474      if (_keyinfo_list && _keyinfo_list->value) {
   1.475 @@ -1375,7 +1426,7 @@
   1.476  		return E_OUTOFMEMORY;
   1.477  
   1.478  	string _fpr = utf8_string(fpr);
   1.479 -	PEP_STATUS status = ::set_own_key(get_session(), _ident, _fpr.c_str());
   1.480 +	PEP_STATUS status = ::set_own_key(session(), _ident, _fpr.c_str());
   1.481  
   1.482  	if (status == PEP_STATUS_OK) {
   1.483  		copy_identity(result, _ident);
   1.484 @@ -1392,218 +1443,3 @@
   1.485  
   1.486  	return S_OK;
   1.487  }
   1.488 -
   1.489 -HRESULT CpEpEngine::Fire_MessageToSend(TextMessage * msg)
   1.490 -{
   1.491 -    assert(msg);
   1.492 -    assert(this->client_callbacks_on_sync_thread);
   1.493 -
   1.494 -    if (!msg)
   1.495 -        return E_INVALIDARG;
   1.496 -
   1.497 -    if (!this->client_callbacks_on_sync_thread)
   1.498 -        return E_ILLEGAL_METHOD_CALL;
   1.499 -
   1.500 -    auto result = this->client_callbacks_on_sync_thread->MessageToSend(msg);
   1.501 -
   1.502 -    return result;
   1.503 -}
   1.504 -
   1.505 -// This method is called from the keysync thread, and dispatches
   1.506 -// the handshake asynchroneously to a background thread,
   1.507 -// so the engine can continue working.
   1.508 -PEP_STATUS CpEpEngine::notifyHandshake(void * obj, pEp_identity *self, pEp_identity *partner, sync_handshake_signal signal)
   1.509 -{
   1.510 -    assert(self && partner);
   1.511 -    if (!(self && partner))
   1.512 -        return PEP_ILLEGAL_VALUE;
   1.513 -
   1.514 -    CpEpEngine *me = (CpEpEngine *)obj;
   1.515 -
   1.516 -    if (me->notify_handshake_active) {
   1.517 -        // We don't support concurrent handshakes currently, 
   1.518 -        // with the exception of an abort of the handshake, 
   1.519 -        // which we deliver synchroneously (as it's non-blocking).
   1.520 -        if (signal == SYNC_NOTIFY_TIMEOUT) {
   1.521 -            pEpIdentity timeout_self;
   1.522 -            pEpIdentity timeout_partner;
   1.523 -            SyncHandshakeSignal timeout_signal = (SyncHandshakeSignal)signal;
   1.524 -            copy_identity(&timeout_self, self);
   1.525 -            copy_identity(&timeout_partner, partner);
   1.526 -            SyncHandshakeResult result;
   1.527 -            auto res = me->client_callbacks_on_sync_thread->NotifyHandshake(&timeout_self, &timeout_partner, timeout_signal, &result);
   1.528 -
   1.529 -            clear_identity_s(timeout_self);
   1.530 -            clear_identity_s(timeout_partner);
   1.531 -
   1.532 -            if (FAILED(res)) {
   1.533 -                IErrorInfo* errorInfo = NULL;
   1.534 -                if (FAILED(GetErrorInfo(0, &errorInfo)))
   1.535 -                    errorInfo = NULL;
   1.536 -
   1.537 -                // The _com_error takes ownership of the errorInfo
   1.538 -                // and will Release() it. It can also cope with
   1.539 -                // NULL errorInfos.
   1.540 -                _com_error error(res, errorInfo);
   1.541 -
   1.542 -                string _description = utf8_string(
   1.543 -                    error.ErrorMessage());
   1.544 -
   1.545 -                string _comment = utf8_string(error.Description());
   1.546 -
   1.547 -                auto source = error.Source();
   1.548 -                if (source.length() > 0) {
   1.549 -                    _comment += "\r\nSource: ";
   1.550 -                    _comment += utf8_string(source);
   1.551 -                }
   1.552 -
   1.553 -                ::log_event(me->keysync_session,
   1.554 -                    "Error on NotifyHandshakeTimeout",
   1.555 -                    "pEp COM Adapter",
   1.556 -                    _description.c_str(),
   1.557 -                    _comment.c_str());
   1.558 -
   1.559 -                return PEP_UNKNOWN_ERROR;
   1.560 -            }
   1.561 -
   1.562 -            if (res != S_OK)
   1.563 -
   1.564 -                return PEP_STATUS_OK;
   1.565 -        }
   1.566 -
   1.567 -        ::log_event(me->keysync_session, "Reentrant notify_handshake call!", "pEp COM Adapter", NULL, NULL);
   1.568 -        return PEP_UNKNOWN_ERROR;
   1.569 -    }
   1.570 -
   1.571 -    assert(!(me->notify_handshake_active
   1.572 -        || me->notify_handshake_finished
   1.573 -        || me->notify_handshake_thread));
   1.574 -
   1.575 -    me->notify_handshake_active = true;
   1.576 -
   1.577 -    copy_identity(&me->notify_handshake_self, self);
   1.578 -    copy_identity(&me->notify_handshake_partner, partner);
   1.579 -    me->notify_handshake_signal = (SyncHandshakeSignal)signal;
   1.580 -
   1.581 -    // We need to marshal the callbacks to the keysync thread
   1.582 -    LPSTREAM marshaled_callbacks;
   1.583 -
   1.584 -    auto result = CoMarshalInterThreadInterfaceInStream(IID_IpEpEngineCallbacks, me->client_callbacks_on_sync_thread, &marshaled_callbacks);
   1.585 -    assert(result == S_OK);
   1.586 -
   1.587 -    me->notify_handshake_thread = new thread(notify_handshake_background_thread, me, marshaled_callbacks);
   1.588 -
   1.589 -    return PEP_STATUS_OK;
   1.590 -}
   1.591 -
   1.592 -// This method also runs in the keysync thread, called by
   1.593 -// retrieve_next_sync_msg() to deliver back the results
   1.594 -// of the sync into the engine.
   1.595 -void CpEpEngine::notify_handshake_deliver_result()
   1.596 -{
   1.597 -    assert(notify_handshake_active
   1.598 -        && notify_handshake_finished);
   1.599 -    if (!(notify_handshake_active
   1.600 -        && notify_handshake_finished))
   1.601 -        return;
   1.602 -
   1.603 -    notify_handshake_thread->join();
   1.604 -    notify_handshake_thread = NULL;
   1.605 -
   1.606 -    Identity partner = new_identity(&notify_handshake_partner);
   1.607 -
   1.608 -    if (FAILED(notify_handshake_error))
   1.609 -    {
   1.610 -        IErrorInfo *errorInfo = NULL;
   1.611 -
   1.612 -        if (notify_handshake_error_info) {
   1.613 -            LPVOID lp = NULL;
   1.614 -            auto res = CoGetInterfaceAndReleaseStream(notify_handshake_error_info, IID_IErrorInfo, &lp);
   1.615 -
   1.616 -            if (SUCCEEDED(res) && lp)
   1.617 -                errorInfo = static_cast<IErrorInfo*>(lp);
   1.618 -        }
   1.619 -
   1.620 -        // The _com_error takes ownership of the errorInfo
   1.621 -        // and will Release() it. It can also cope with
   1.622 -        // NULL errorInfos.
   1.623 -        _com_error error(notify_handshake_error, errorInfo);
   1.624 -
   1.625 -        string _description = utf8_string(
   1.626 -            error.ErrorMessage());
   1.627 -
   1.628 -        string _comment = utf8_string(error.Description());
   1.629 -
   1.630 -        auto source = error.Source();
   1.631 -        if (source.length() > 0) {
   1.632 -            _comment += "\r\nSource: ";
   1.633 -            _comment += utf8_string(source);
   1.634 -        }
   1.635 -
   1.636 -        ::log_event(keysync_session,
   1.637 -            "Notify Handshake Failed!",
   1.638 -            "pEp COM Adapter",
   1.639 -            _description.c_str(),
   1.640 -            _comment.c_str());
   1.641 -
   1.642 -        ::deliverHandshakeResult(keysync_session, partner, SYNC_HANDSHAKE_CANCEL);
   1.643 -    }
   1.644 -    else {
   1.645 -        ::deliverHandshakeResult(
   1.646 -            keysync_session,
   1.647 -            partner,
   1.648 -            (sync_handshake_result)notify_handshake_result);
   1.649 -    }
   1.650 -    notify_handshake_error_info = NULL;
   1.651 -
   1.652 -    clear_identity_s(notify_handshake_self);
   1.653 -    clear_identity_s(notify_handshake_partner);
   1.654 -    notify_handshake_active = false;
   1.655 -    notify_handshake_finished = false;
   1.656 -}
   1.657 -
   1.658 -// Method on the background thread, calling into Outlook to
   1.659 -// trigger the Handshake notification, and then scheduling
   1.660 -// the result back to the main thread.
   1.661 -void CpEpEngine::notify_handshake_background_thread(CpEpEngine* self, LPSTREAM marshaled_callbacks)
   1.662 -{
   1.663 -    assert(self);
   1.664 -
   1.665 -    // We need to initialize COM here for successfull delivery of the callbacks.
   1.666 -    // As we don't create any COM instances in our thread, the COMINIT value is
   1.667 -    // currently irrelevant, so we go with the safest value.
   1.668 -    auto res = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
   1.669 -    assert(res == S_OK);
   1.670 -
   1.671 -    LPVOID vp;
   1.672 -
   1.673 -    res = CoGetInterfaceAndReleaseStream(marshaled_callbacks, IID_IpEpEngineCallbacks, &vp);
   1.674 -    assert(SUCCEEDED(res));
   1.675 -
   1.676 -    auto client_callbacks_on_sync_thread = static_cast<IpEpEngineCallbacks*>(vp);
   1.677 -
   1.678 -    self->notify_handshake_error = client_callbacks_on_sync_thread->NotifyHandshake(
   1.679 -        &self->notify_handshake_self,
   1.680 -        &self->notify_handshake_partner,
   1.681 -        self->notify_handshake_signal,
   1.682 -        &self->notify_handshake_result);
   1.683 -
   1.684 -    if (FAILED(self->notify_handshake_error)) {
   1.685 -        IErrorInfo* errorInfo = NULL;
   1.686 -
   1.687 -        res = GetErrorInfo(0, &errorInfo);
   1.688 -
   1.689 -        if (res = S_OK && errorInfo != NULL) {
   1.690 -            res = CoMarshalInterThreadInterfaceInStream(
   1.691 -                IID_IErrorInfo,
   1.692 -                errorInfo,
   1.693 -                &self->notify_handshake_error_info);
   1.694 -
   1.695 -            errorInfo->Release();
   1.696 -        }
   1.697 -    }
   1.698 -
   1.699 -    // notify the keysync thread.
   1.700 -    self->notify_handshake_finished = true;
   1.701 -    self->keysync_condition.notify_all();
   1.702 -}
     2.1 --- a/CpEpEngine.h	Fri Oct 05 14:32:36 2018 +0200
     2.2 +++ b/CpEpEngine.h	Mon Oct 15 22:15:24 2018 +0200
     2.3 @@ -4,11 +4,13 @@
     2.4  #include "resource.h"       // main symbols
     2.5  
     2.6  #include "pEpComServerAdapter_i.h"
     2.7 -#include "locked_queue.hh"
     2.8 +#include "..\libpEpAdapter\locked_queue.hh"
     2.9  #include "utf8_helper.h"
    2.10  #include "pEp_utility.h"
    2.11 +#include "..\libpEpAdapter\Adapter.hh"
    2.12  #include <queue>
    2.13  #include <mutex>
    2.14 +#include <vector>
    2.15  
    2.16  #if defined(_WIN32_WCE) && !defined(_CE_DCOM) && !defined(_CE_ALLOW_SINGLE_THREADED_OBJECTS_IN_MTA)
    2.17  #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."
    2.18 @@ -17,6 +19,7 @@
    2.19  using namespace ATL;
    2.20  using namespace utility;
    2.21  using namespace pEp::utility;
    2.22 +using namespace pEp::Adapter;
    2.23  
    2.24  // CpEpEngine
    2.25  
    2.26 @@ -40,12 +43,8 @@
    2.27      ~CpEpEngine()
    2.28      {
    2.29          StopKeyserverLookup();
    2.30 -        if (m_session) // may be zero when FinalConstruct failed to initialize the engine
    2.31 -        {
    2.32 -            ::log_event(m_session, "Shutdown", "pEp COM Adapter", NULL, NULL);
    2.33 -            std::lock_guard<std::mutex> lock(init_mutex);
    2.34 -            ::release(m_session);
    2.35 -        }
    2.36 +        ::log_event(session(), "Shutdown", "pEp COM Adapter", NULL, NULL);
    2.37 +        session(pEp::Adapter::release);
    2.38      }
    2.39  
    2.40      DECLARE_REGISTRY_RESOURCEID(IDR_PEPENGINE)
    2.41 @@ -71,15 +70,16 @@
    2.42      HRESULT FinalConstruct()
    2.43      {
    2.44          std::lock_guard<std::mutex> lock(init_mutex);
    2.45 -        PEP_STATUS status = ::init(&m_session);
    2.46 -        assert(status == PEP_STATUS_OK);
    2.47 -        if (status != PEP_STATUS_OK) {
    2.48 -            HRESULT res = MAKE_HRESULT(1, FACILITY_ITF, (0xFFFF & status));
    2.49 +        try {
    2.50 +            session();
    2.51 +        }
    2.52 +        catch (pEp::RuntimeError& e) {
    2.53 +            HRESULT res = MAKE_HRESULT(1, FACILITY_ITF, (0xFFFF & e.status));
    2.54              return res;
    2.55          }
    2.56  
    2.57 -        ::register_examine_function(m_session, CpEpEngine::examine_identity, (void *)this);
    2.58 -        ::log_event(m_session, "Startup", "pEp COM Adapter", NULL, NULL);
    2.59 +        ::register_examine_function(session(), CpEpEngine::examine_identity, (void *)this);
    2.60 +        ::log_event(session(), "Startup", "pEp COM Adapter", NULL, NULL);
    2.61          return S_OK;
    2.62      }
    2.63  
    2.64 @@ -89,39 +89,10 @@
    2.65  
    2.66  
    2.67  protected:
    2.68 -    class session
    2.69 -    {
    2.70 -    private:
    2.71 -        CpEpEngine *me;
    2.72 -
    2.73 -    public:
    2.74 -        session(CpEpEngine *myself)
    2.75 -        {
    2.76 -            me = myself;
    2.77 -            me->session_mutex.lock();
    2.78 -        }
    2.79 -
    2.80 -        ~session()
    2.81 -        {
    2.82 -            me->session_mutex.unlock();
    2.83 -        }
    2.84 -
    2.85 -        operator PEP_SESSION const ()
    2.86 -        {
    2.87 -            return me->m_session;
    2.88 -        }
    2.89 -    };
    2.90 -
    2.91 -    session get_session()
    2.92 -    {
    2.93 -        return session(this);
    2.94 -    }
    2.95 -
    2.96      typedef locked_queue<pEp_identity_cpp> identity_queue_t;
    2.97      static ::pEp_identity * retrieve_next_identity(void *management);
    2.98 -    static PEP_STATUS messageToSend(void * obj, message *msg);
    2.99 -    static PEP_STATUS notifyHandshake(void * obj, pEp_identity *self, pEp_identity *partner, sync_handshake_signal signal);
   2.100 -
   2.101 +    static PEP_STATUS messageToSend(message *msg);
   2.102 +    static PEP_STATUS notifyHandshake(pEp_identity *self, pEp_identity *partner, sync_handshake_signal signal);
   2.103  
   2.104      HRESULT error(_bstr_t msg);
   2.105      HRESULT error(_bstr_t msg, PEP_STATUS errorcode);
   2.106 @@ -131,43 +102,22 @@
   2.107          if (verbose_mode) {
   2.108              stringstream ss;
   2.109              ss << __FILE__ << ":" << __LINE__ << " " << text;
   2.110 -            ::log_event(get_session(), "verbose", "pEp COM Server Adapter", ss.str().c_str(), NULL);
   2.111 +            ::log_event(session(), "verbose", "pEp COM Server Adapter", ss.str().c_str(), NULL);
   2.112          }
   2.113      }
   2.114  
   2.115  private:
   2.116 -    PEP_SESSION m_session;
   2.117 -    mutex session_mutex;
   2.118      atomic< identity_queue_t * > identity_queue;
   2.119      thread *keymanagement_thread;
   2.120      bool verbose_mode;
   2.121  
   2.122 -
   2.123      IpEpEngineCallbacks* client_callbacks = NULL;
   2.124 -    IpEpEngineCallbacks* client_callbacks_on_sync_thread = NULL;
   2.125      bool client_last_signalled_polling_state = true;
   2.126  
   2.127      static std::mutex init_mutex;
   2.128  
   2.129 -    std::recursive_mutex keysync_mutex;
   2.130 -    std::condition_variable_any keysync_condition;
   2.131 -    std::thread *keysync_thread = NULL;
   2.132 -    std::queue<void*> keysync_queue;
   2.133 -    bool keysync_abort_requested = false;
   2.134 -    PEP_SESSION keysync_session;
   2.135 -
   2.136 -    // Members used for handshake notification dispatch to the background thread.
   2.137 -    static void notify_handshake_background_thread(CpEpEngine* self, LPSTREAM marshaled_callbacks);
   2.138 -    void notify_handshake_deliver_result();
   2.139 -    bool notify_handshake_active = false;
   2.140 -    bool notify_handshake_finished = false;
   2.141 -    std::thread *notify_handshake_thread = NULL;
   2.142 -    pEpIdentity notify_handshake_self;
   2.143 -    pEpIdentity notify_handshake_partner;
   2.144 -    SyncHandshakeSignal notify_handshake_signal;
   2.145 -    SyncHandshakeResult notify_handshake_result;
   2.146 -    LPSTREAM notify_handshake_error_info = NULL;
   2.147 -    HRESULT notify_handshake_error;
   2.148 +    static std::list< IpEpEngineCallbacks * > all_callbacks;
   2.149 +    static std::mutex callbacks_mutex;
   2.150  
   2.151  public:
   2.152      // runtime config of the adapter
   2.153 @@ -210,9 +160,9 @@
   2.154      STDMETHOD(TrustPersonalKey)(struct pEpIdentity *ident, struct pEpIdentity *result);
   2.155      STDMETHOD(OwnIdentitiesRetrieve)(LPSAFEARRAY* ownIdentities);
   2.156  
   2.157 -    STDMETHOD(UndoLastMistrust)(); 
   2.158 +    // STDMETHOD(UndoLastMistrust)(); 
   2.159      
   2.160 -    STDMETHOD(IsPepUser)(
   2.161 +    STDMETHOD(IspEpUser)(
   2.162          /* [in] */ struct pEpIdentity *ident,
   2.163          /* [retval][out] */ VARIANT_BOOL *ispEp);
   2.164  
   2.165 @@ -265,9 +215,6 @@
   2.166  
   2.167      // Trigger an immediate update
   2.168      STDMETHOD(UpdateNow)();
   2.169 -protected:
   2.170 -    HRESULT Fire_MessageToSend(
   2.171 -        /* [in] */ struct TextMessage *msg);
   2.172  };
   2.173  
   2.174  OBJECT_ENTRY_AUTO(__uuidof(pEpEngine), CpEpEngine)
     3.1 --- a/locked_queue.hh	Fri Oct 05 14:32:36 2018 +0200
     3.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.3 @@ -1,52 +0,0 @@
     3.4 -#pragma once
     3.5 -
     3.6 -#include <list>
     3.7 -#include <mutex>
     3.8 -
     3.9 -namespace utility
    3.10 -{
    3.11 -    using namespace std;
    3.12 -
    3.13 -    template<class T> class locked_queue
    3.14 -    {
    3.15 -        mutex _mtx;
    3.16 -        list<T> _q;
    3.17 -
    3.18 -    public:
    3.19 -        T& back()
    3.20 -        {
    3.21 -            lock_guard<mutex> lg(_mtx);
    3.22 -            return _q.back();
    3.23 -        }
    3.24 -        T& front()
    3.25 -        {
    3.26 -            lock_guard<mutex> lg(_mtx);
    3.27 -            return _q.front();
    3.28 -        }
    3.29 -        void pop_back()
    3.30 -        {
    3.31 -            lock_guard<mutex> lg(_mtx);
    3.32 -            _q.pop_back();
    3.33 -        }
    3.34 -        void pop_front()
    3.35 -        {
    3.36 -            lock_guard<mutex> lg(_mtx);
    3.37 -            _q.pop_front();
    3.38 -        }
    3.39 -        void push_back(const T& data)
    3.40 -        {
    3.41 -            lock_guard<mutex> lg(_mtx);
    3.42 -            _q.push_back(data);
    3.43 -        }
    3.44 -        void push_front(const T& data)
    3.45 -        {
    3.46 -            lock_guard<mutex> lg(_mtx);
    3.47 -            _q.push_front(data);
    3.48 -        }
    3.49 -        size_t size()
    3.50 -        {
    3.51 -            lock_guard<mutex> lg(_mtx);
    3.52 -            return _q.size();
    3.53 -        }
    3.54 -    };
    3.55 -};
     4.1 --- a/pEpCOMServerAdapter.idl	Fri Oct 05 14:32:36 2018 +0200
     4.2 +++ b/pEpCOMServerAdapter.idl	Mon Oct 15 22:15:24 2018 +0200
     4.3 @@ -256,8 +256,8 @@
     4.4      [id(18)] HRESULT KeyResetTrust([in] struct pEpIdentity *ident);
     4.5      [id(19)] HRESULT TrustPersonalKey([in] struct pEpIdentity *ident, [out, retval] struct pEpIdentity *result);
     4.6      [id(20)] HRESULT OwnIdentitiesRetrieve([out, retval] SAFEARRAY(struct pEpIdentity)* ownIdentities);
     4.7 -    [id(21)] HRESULT UndoLastMistrust();
     4.8 -    [id(22)] HRESULT IsPepUser([in] struct pEpIdentity *ident, [out, retval] VARIANT_BOOL *ispEp);
     4.9 +    // [id(21)] HRESULT UndoLastMistrust(); NOT IMPLEMENTED ANY MORE - USE KeyResetTrust() instead
    4.10 +    [id(22)] HRESULT IspEpUser([in] struct pEpIdentity *ident, [out, retval] VARIANT_BOOL *ispEp);
    4.11  
    4.12      // Blacklist API
    4.13  
     5.1 --- a/pEpCOMServerAdapter.vcxproj	Fri Oct 05 14:32:36 2018 +0200
     5.2 +++ b/pEpCOMServerAdapter.vcxproj	Mon Oct 15 22:15:24 2018 +0200
     5.3 @@ -41,10 +41,12 @@
     5.4    <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
     5.5      <IgnoreImportLibrary>true</IgnoreImportLibrary>
     5.6      <LinkIncremental>true</LinkIncremental>
     5.7 +    <IncludePath>C:\Users\vb\Documents\Visual Studio 2015\Projects\pEp_for_Outlook_Solution;C:\Users\vb\Documents\Visual Studio 2015\Projects\pEp_for_Outlook_Solution\pEpEngine\src;$(IncludePath)</IncludePath>
     5.8    </PropertyGroup>
     5.9    <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
    5.10      <IgnoreImportLibrary>true</IgnoreImportLibrary>
    5.11      <LinkIncremental>false</LinkIncremental>
    5.12 +    <IncludePath>C:\Users\vb\Documents\Visual Studio 2015\Projects\pEp_for_Outlook_Solution;C:\Users\vb\Documents\Visual Studio 2015\Projects\pEp_for_Outlook_Solution\pEpEngine\src;$(IncludePath)</IncludePath>
    5.13    </PropertyGroup>
    5.14    <ItemDefinitionGroup Condition="'$(Platform)'=='Win32'">
    5.15      <PostBuildEvent>
    5.16 @@ -156,7 +158,6 @@
    5.17    <ItemGroup>
    5.18      <ClInclude Include="CpEpEngine.h" />
    5.19      <ClInclude Include="GateKeeper.h" />
    5.20 -    <ClInclude Include="locked_queue.hh" />
    5.21      <ClInclude Include="pEpCOMServerAdapter.h" />
    5.22      <ClInclude Include="pEpCOMServerAdapter_i.h" />
    5.23      <ClInclude Include="pEp_utility.h" />
    5.24 @@ -183,6 +184,9 @@
    5.25      <Midl Include="pEpCOMServerAdapter.idl" />
    5.26    </ItemGroup>
    5.27    <ItemGroup>
    5.28 +    <ProjectReference Include="..\libpEpAdapter\libpEpAdapter\libpEpAdapter.vcxproj">
    5.29 +      <Project>{ec44fec9-2f3a-4a0c-b60e-0f22aa43ef58}</Project>
    5.30 +    </ProjectReference>
    5.31      <ProjectReference Include="..\pEpEngine\build-windows\pEpEngine.vcxproj">
    5.32        <Project>{146e69f8-e1da-456a-b048-6dd29d9acf6b}</Project>
    5.33      </ProjectReference>
     6.1 --- a/pEpCOMServerAdapter.vcxproj.filters	Fri Oct 05 14:32:36 2018 +0200
     6.2 +++ b/pEpCOMServerAdapter.vcxproj.filters	Mon Oct 15 22:15:24 2018 +0200
     6.3 @@ -63,9 +63,6 @@
     6.4      <ClInclude Include="CpEpEngine.h">
     6.5        <Filter>Header Files</Filter>
     6.6      </ClInclude>
     6.7 -    <ClInclude Include="locked_queue.hh">
     6.8 -      <Filter>Header Files</Filter>
     6.9 -    </ClInclude>
    6.10      <ClInclude Include="utf8_helper.h">
    6.11        <Filter>Header Files</Filter>
    6.12      </ClInclude>
     7.1 --- a/stdafx.h	Fri Oct 05 14:32:36 2018 +0200
     7.2 +++ b/stdafx.h	Mon Oct 15 22:15:24 2018 +0200
     7.3 @@ -46,10 +46,10 @@
     7.4  
     7.5  #include <assert.h>
     7.6  
     7.7 -#include "../pEpEngine/src/pEpEngine.h"
     7.8 -#include "../pEpEngine/src/keymanagement.h"
     7.9 -#include "../pEpEngine/src/message_api.h"
    7.10 -#include "../pEpEngine/src/stringpair.h"
    7.11 -#include "../pEpEngine/src/blacklist.h"
    7.12 -#include "../pEpEngine/src/sync.h"
    7.13 -#include "../pEpEngine/src/openpgp_compat.h"
    7.14 \ No newline at end of file
    7.15 +#include <pEp/pEpEngine.h>
    7.16 +#include <pEp/keymanagement.h>
    7.17 +#include <pEp/message_api.h>
    7.18 +#include <pEp/stringpair.h>
    7.19 +#include <pEp/blacklist.h>
    7.20 +#include <pEp/sync_api.h>
    7.21 +#include <pEp/openpgp_compat.h>