Everything compiles again against the "keysync" branch of the engine, including keysync
authorMarkus Schaber <markus@pep-security.net>
Fri, 30 Sep 2016 22:21:09 +0200
branchkeysync
changeset 1641971112a0cc0
parent 163 3e032265f02b
child 165 77dfd1defafa
Everything compiles again against the "keysync" branch of the engine, including
COM-36 adaption for ENGINE-96

Warning: Code not tested yet.

This code does not actually implement any keysyncing yet, it's just adaption
to the name and interface changes.
CpEpEngine.cpp
CpEpEngine.h
pEpCOMServerAdapter.idl
     1.1 --- a/CpEpEngine.cpp	Wed Sep 28 11:34:40 2016 +0200
     1.2 +++ b/CpEpEngine.cpp	Fri Sep 30 22:21:09 2016 +0200
     1.3 @@ -882,7 +882,7 @@
     1.4      }
     1.5  }
     1.6  
     1.7 -STDMETHODIMP CpEpEngine::key_compromized(struct pEp_identity_s *ident)
     1.8 +STDMETHODIMP CpEpEngine::key_mistrusted(struct pEp_identity_s *ident)
     1.9  {
    1.10      ::pEp_identity *_ident;
    1.11  
    1.12 @@ -898,7 +898,7 @@
    1.13          return E_FAIL;
    1.14      }
    1.15  
    1.16 -    PEP_STATUS status = ::key_compromized(get_session(), _ident);
    1.17 +    PEP_STATUS status = ::key_mistrusted(get_session(), _ident);
    1.18      free_identity(_ident);
    1.19  
    1.20      if (status == PEP_OUT_OF_MEMORY)
    1.21 @@ -989,7 +989,7 @@
    1.22      return _ident;
    1.23  }
    1.24  
    1.25 -PEP_STATUS CpEpEngine::messageToSend(void * obj, const message *msg)
    1.26 +PEP_STATUS CpEpEngine::messageToSend(void * obj, message *msg)
    1.27  {
    1.28      assert(msg);
    1.29      if (msg == NULL)
    1.30 @@ -1011,7 +1011,7 @@
    1.31      return PEP_STATUS_OK;
    1.32  }
    1.33  
    1.34 -PEP_STATUS CpEpEngine::showHandshake(void * obj, const pEp_identity *self, const pEp_identity *partner)
    1.35 +PEP_STATUS CpEpEngine::showHandshake(void * obj, pEp_identity *self, pEp_identity *partner)
    1.36  {
    1.37      assert(self && partner);
    1.38      if (!(self && partner))
    1.39 @@ -1032,7 +1032,7 @@
    1.40      if (r != S_OK)
    1.41          return PEP_UNKNOWN_ERROR;
    1.42  
    1.43 -    PEP_STATUS status = deliverHandshakeResult(me->get_session(), (sync_handshake_result) (int) _result);
    1.44 +    PEP_STATUS status = deliverHandshakeResult(me->get_session(), partner, (sync_handshake_result) (int) _result);
    1.45      return status;
    1.46  }
    1.47  
    1.48 @@ -1125,7 +1125,10 @@
    1.49      ::message *msg_dst;
    1.50      ::stringlist_t *_extra = new_stringlist(extra);
    1.51  
    1.52 -    PEP_STATUS status = ::encrypt_message(get_session(), _src, _extra, &msg_dst, PEP_enc_PGP_MIME);
    1.53 +	// TODO: Check whether we should pass any of the encryption flags as last parameter, or expose
    1.54 +	// it to the client. (_PEP_enc_format is intentionally hidden for now...)
    1.55 +	PEP_encrypt_flags_t flags = 0;
    1.56 +    PEP_STATUS status = ::encrypt_message(get_session(), _src, _extra, &msg_dst, PEP_enc_PGP_MIME, flags);
    1.57      ::free_stringlist(_extra);
    1.58  
    1.59      if (status == PEP_STATUS_OK)
    1.60 @@ -1142,7 +1145,7 @@
    1.61      return S_OK;
    1.62  }
    1.63  
    1.64 -STDMETHODIMP CpEpEngine::decrypt_message(text_message * src, text_message * dst, SAFEARRAY ** keylist, pEp_color *rating)
    1.65 +STDMETHODIMP CpEpEngine::decrypt_message(text_message * src, text_message * dst, SAFEARRAY ** keylist, pEp_rating *rating)
    1.66  {
    1.67      assert(src);
    1.68      assert(dst);
    1.69 @@ -1155,7 +1158,7 @@
    1.70      ::message *_src = text_message_to_C(src);
    1.71      ::message *msg_dst = NULL;
    1.72      ::stringlist_t *_keylist;
    1.73 -    ::PEP_color _rating;
    1.74 +    ::PEP_rating _rating;
    1.75  
    1.76      PEP_decrypt_flags_t flags = 0; 
    1.77      PEP_STATUS status = ::decrypt_message(get_session(), _src, &msg_dst, &_keylist, &_rating, &flags);
    1.78 @@ -1172,28 +1175,28 @@
    1.79          free_stringlist(_keylist);
    1.80      }
    1.81  
    1.82 -    *rating = (pEp_color) _rating;
    1.83 +    *rating = (pEp_rating) _rating;
    1.84  
    1.85      return S_OK;
    1.86  }
    1.87  
    1.88 -STDMETHODIMP CpEpEngine::outgoing_message_color(text_message *msg, pEp_color * pVal)
    1.89 +STDMETHODIMP CpEpEngine::outgoing_message_rating(text_message *msg, pEp_rating * pVal)
    1.90  {
    1.91      assert(msg);
    1.92      assert(pVal);
    1.93  
    1.94      ::message *_msg = text_message_to_C(msg);
    1.95  
    1.96 -    PEP_color _color;
    1.97 -    PEP_STATUS status = ::outgoing_message_color(get_session(), _msg, &_color);
    1.98 +    PEP_rating _rating;
    1.99 +    PEP_STATUS status = ::outgoing_message_rating(get_session(), _msg, &_rating);
   1.100      if (status != PEP_STATUS_OK)
   1.101 -        return FAIL(L"cannot get message color");
   1.102 +        return FAIL(L"cannot get message rating");
   1.103  
   1.104 -    *pVal = (pEp_color) _color;
   1.105 +    *pVal = (pEp_rating) _rating;
   1.106      return S_OK;
   1.107  }
   1.108  
   1.109 -STDMETHODIMP CpEpEngine::identity_color(struct pEp_identity_s *ident, pEp_color * pVal)
   1.110 +STDMETHODIMP CpEpEngine::identity_rating(struct pEp_identity_s *ident, pEp_rating * pVal)
   1.111  {
   1.112      ::pEp_identity *_ident;
   1.113  
   1.114 @@ -1210,16 +1213,28 @@
   1.115          return E_FAIL;
   1.116      }
   1.117  
   1.118 -    PEP_color _color;
   1.119 -    PEP_STATUS status = ::identity_color(get_session(), _ident, &_color);
   1.120 +    PEP_rating _rating;
   1.121 +    PEP_STATUS status = ::identity_rating(get_session(), _ident, &_rating);
   1.122      free_identity(_ident);
   1.123      if (status != PEP_STATUS_OK)
   1.124          return FAIL(L"cannot get message color");
   1.125  
   1.126 -    *pVal = (pEp_color) _color;
   1.127 +    *pVal = (pEp_rating) _rating;
   1.128      return S_OK;
   1.129  }
   1.130  
   1.131 +STDMETHODIMP CpEpEngine::color_from_rating(pEp_rating rating, pEp_color * pVal) 
   1.132 +{
   1.133 +	assert(pVal);
   1.134 +
   1.135 +	PEP_rating engineRating = (PEP_rating)rating;
   1.136 +	PEP_color _color = ::color_from_rating(engineRating);
   1.137 +
   1.138 +	*pVal = (pEp_color)_color;
   1.139 +
   1.140 +	return S_OK;
   1.141 +}
   1.142 +
   1.143  STDMETHODIMP CpEpEngine::trust_personal_key(struct pEp_identity_s *ident, struct pEp_identity_s *result)
   1.144  {
   1.145      ::pEp_identity *_ident;
     2.1 --- a/CpEpEngine.h	Wed Sep 28 11:34:40 2016 +0200
     2.2 +++ b/CpEpEngine.h	Fri Sep 30 22:21:09 2016 +0200
     2.3 @@ -37,7 +37,7 @@
     2.4          PEP_STATUS status = ::init(&m_session);
     2.5          assert(status == PEP_STATUS_OK);
     2.6          ::register_examine_function(m_session, CpEpEngine::examine_identity, (void *)this);
     2.7 -        ::register_sync_callbacks(m_session, (void*)this, messageToSend, showHandshake);
     2.8 +        ::register_sync_callbacks(m_session, (void*)this, messageToSend, showHandshake, NULL, NULL);
     2.9          ::log_event(m_session, "Startup", "pEp COM Adapter", NULL, NULL);
    2.10      }
    2.11  
    2.12 @@ -137,8 +137,8 @@
    2.13  
    2.14      typedef locked_queue<pEp_identity_cpp> identity_queue_t;
    2.15      static ::pEp_identity * retrieve_next_identity(void *management);
    2.16 -    static PEP_STATUS messageToSend(void *obj, const message *msg);
    2.17 -    static PEP_STATUS showHandshake(void * obj, const pEp_identity *self, const pEp_identity *partner);
    2.18 +    static PEP_STATUS messageToSend(void *obj, message *msg);
    2.19 +    static PEP_STATUS showHandshake(void * obj, pEp_identity *self, pEp_identity *partner);
    2.20  
    2.21      HRESULT error(_bstr_t msg);
    2.22  
    2.23 @@ -204,7 +204,7 @@
    2.24      STDMETHOD(verify)(BSTR text, BSTR signature, LPSAFEARRAY * key_list, pEp_STATUS * verify_status);
    2.25      STDMETHOD(myself)(struct pEp_identity_s *ident, struct pEp_identity_s *result);
    2.26      STDMETHOD(update_identity)(struct pEp_identity_s *ident, struct pEp_identity_s *result);
    2.27 -    STDMETHOD(key_compromized)(struct pEp_identity_s *ident);
    2.28 +    STDMETHOD(key_mistrusted)(struct pEp_identity_s *ident);
    2.29      STDMETHOD(key_reset_trust)(struct pEp_identity_s *ident);
    2.30      STDMETHOD(trust_personal_key)(struct pEp_identity_s *ident, struct pEp_identity_s *result);
    2.31  
    2.32 @@ -218,9 +218,10 @@
    2.33      // Message API
    2.34  
    2.35      STDMETHOD(encrypt_message)(text_message * src, text_message * dst, SAFEARRAY * extra);
    2.36 -    STDMETHOD(decrypt_message)(text_message * src, text_message * dst, SAFEARRAY ** keylist, pEp_color *rating);
    2.37 -    STDMETHOD(outgoing_message_color)(text_message *msg, pEp_color * pVal);
    2.38 -    STDMETHOD(identity_color)(pEp_identity_s * ident, pEp_color * pVal);
    2.39 +    STDMETHOD(decrypt_message)(text_message * src, text_message * dst, SAFEARRAY ** keylist, pEp_rating *rating);
    2.40 +    STDMETHOD(outgoing_message_rating)(text_message *msg, pEp_rating * pVal);
    2.41 +    STDMETHOD(identity_rating)(pEp_identity_s * ident, pEp_rating * pVal);
    2.42 +	STDMETHOD(color_from_rating)(pEp_rating rating, pEp_color * pVal);
    2.43  
    2.44  	// Event callbacks
    2.45  
     3.1 --- a/pEpCOMServerAdapter.idl	Wed Sep 28 11:34:40 2016 +0200
     3.2 +++ b/pEpCOMServerAdapter.idl	Fri Sep 30 22:21:09 2016 +0200
     3.3 @@ -194,7 +194,7 @@
     3.4      HRESULT examine_identity([in] struct pEp_identity_s * ident);
     3.5      HRESULT myself([in] struct pEp_identity_s *ident, [out, retval] struct pEp_identity_s *result);
     3.6      HRESULT update_identity([in] struct pEp_identity_s *ident, [out, retval] struct pEp_identity_s *result);
     3.7 -    HRESULT key_compromized([in] struct pEp_identity_s *ident);
     3.8 +    HRESULT key_mistrusted([in] struct pEp_identity_s *ident);
     3.9      HRESULT key_reset_trust([in] struct pEp_identity_s *ident);
    3.10      HRESULT trust_personal_key([in] struct pEp_identity_s *ident, [out, retval] struct pEp_identity_s *result);
    3.11  
    3.12 @@ -210,31 +210,29 @@
    3.13  
    3.14      // Message API
    3.15  
    3.16 -    typedef enum _pEp_color {
    3.17 -        pEp_rating_undefined = 0,
    3.18 -        pEp_rating_cannot_decrypt,
    3.19 -        pEp_rating_have_no_key,
    3.20 -        pEp_rating_unencrypted,
    3.21 -        pEp_rating_unencrypted_for_some,
    3.22 -        pEp_rating_unreliable,
    3.23 -        pEp_rating_reliable,
    3.24 -        pEp_rating_yellow = pEp_rating_reliable,
    3.25 -        pEp_rating_trusted,
    3.26 -        pEp_rating_green = pEp_rating_trusted,
    3.27 -        pEp_rating_trusted_and_anonymized,
    3.28 -        pEp_rating_fully_anonymous,
    3.29 -
    3.30 -        pEp_rating_mistrust = -1,
    3.31 -        pEp_rating_red = pEp_rating_mistrust,
    3.32 -        pEp_rating_b0rken = -2,
    3.33 -        pEp_rating_under_attack = -3
    3.34 -    } pEp_color;
    3.35 -
    3.36 -    typedef enum _pEp_text_format {
    3.37 -        pEp_text_format_plain = 0,
    3.38 -        pEp_text_format_html,
    3.39 -        pEp_text_format_other = 0xff
    3.40 -    } pEp_text_format;
    3.41 +	typedef enum _pEp_rating {
    3.42 +		pEp_rating_undefined = 0,
    3.43 +		pEp_rating_cannot_decrypt,
    3.44 +		pEp_rating_have_no_key,
    3.45 +		pEp_rating_unencrypted,
    3.46 +		pEp_rating_unencrypted_for_some,
    3.47 +		pEp_rating_unreliable,
    3.48 +		pEp_rating_reliable,
    3.49 +		pEp_rating_trusted,
    3.50 +		pEp_rating_trusted_and_anonymized,
    3.51 +		pEp_rating_fully_anonymous,
    3.52 +
    3.53 +		pEp_rating_mistrust = -1,
    3.54 +		pEp_rating_b0rken = -2,
    3.55 +		pEp_rating_under_attack = -3
    3.56 +	} pEp_rating;
    3.57 +
    3.58 +	typedef enum _pEp_color {
    3.59 +		pEp_color_no_color = 0,
    3.60 +		pEp_color_yellow,
    3.61 +		pEp_color_green,
    3.62 +		pEp_color_red = -1,
    3.63 +	} pEp_color;
    3.64  
    3.65      typedef  enum _pEp_msg_direction {
    3.66          pEp_dir_incoming = 0,
    3.67 @@ -282,10 +280,10 @@
    3.68      };
    3.69  
    3.70      HRESULT encrypt_message([in] struct text_message *src, [out] struct text_message * dst, [in] SAFEARRAY(BSTR) extra);
    3.71 -    HRESULT decrypt_message([in] struct text_message *src, [out] struct text_message * dst, [out] SAFEARRAY(BSTR) *keylist, [out, retval] pEp_color *rating);
    3.72 -    HRESULT outgoing_message_color([in] struct text_message *msg, [out, retval] pEp_color * pVal);
    3.73 -    HRESULT identity_color([in] struct pEp_identity_s * ident, [out, retval] pEp_color * pVal);
    3.74 -
    3.75 +    HRESULT decrypt_message([in] struct text_message *src, [out] struct text_message * dst, [out] SAFEARRAY(BSTR) *keylist, [out, retval] pEp_rating *rating);
    3.76 +    HRESULT outgoing_message_rating([in] struct text_message *msg, [out, retval] pEp_rating * pVal);
    3.77 +    HRESULT identity_rating([in] struct pEp_identity_s * ident, [out, retval] pEp_rating * pVal);
    3.78 +	HRESULT color_from_rating([in] pEp_rating rating, [out, retval] pEp_color* pVal);
    3.79  
    3.80  	HRESULT register_callbacks([in] IpEpEngineCallbacks* new_callback);
    3.81