Expose flags for en- and decryption keysync
authorMarkus Schaber <markus@pep-security.net>
Sun, 02 Oct 2016 15:38:37 +0200
branchkeysync
changeset 1679bdd481dd300
parent 166 1955a9c2609f
child 168 269a3bacc5d7
Expose flags for en- and decryption
CpEpEngine.cpp
CpEpEngine.h
pEpCOMServerAdapter.idl
     1.1 --- a/CpEpEngine.cpp	Sun Oct 02 11:17:27 2016 +0200
     1.2 +++ b/CpEpEngine.cpp	Sun Oct 02 15:38:37 2016 +0200
     1.3 @@ -1116,7 +1116,7 @@
     1.4  	return E_FAIL;
     1.5  }
     1.6  
     1.7 -STDMETHODIMP CpEpEngine::encrypt_message(text_message * src, text_message * dst, SAFEARRAY * extra)
     1.8 +STDMETHODIMP CpEpEngine::encrypt_message(text_message * src, text_message * dst, SAFEARRAY * extra, pEpEncryptFlags flags)
     1.9  {
    1.10  	assert(src);
    1.11  	assert(dst);
    1.12 @@ -1125,10 +1125,10 @@
    1.13  	::message *msg_dst;
    1.14  	::stringlist_t *_extra = new_stringlist(extra);
    1.15  
    1.16 -	// TODO: Check whether we should pass any of the encryption flags as last parameter, or expose
    1.17 -	// it to the client. (_PEP_enc_format is intentionally hidden for now...)
    1.18 -	PEP_encrypt_flags_t flags = 0;
    1.19 -	PEP_STATUS status = ::encrypt_message(get_session(), _src, _extra, &msg_dst, PEP_enc_PGP_MIME, flags);
    1.20 +	// _PEP_enc_format is intentionally hardcoded to PEP_enc_PEP:
    1.21 +	// 2016-10-02 14:10 < fdik> schabi: actually, all adapters now must use PEP_enc_PEP
    1.22 +	PEP_encrypt_flags_t engineFlags = (PEP_encrypt_flags_t) flags;
    1.23 +	PEP_STATUS status = ::encrypt_message(get_session(), _src, _extra, &msg_dst, PEP_enc_PEP, engineFlags);
    1.24  	::free_stringlist(_extra);
    1.25  
    1.26  	if (status == PEP_STATUS_OK)
    1.27 @@ -1145,7 +1145,7 @@
    1.28  	return S_OK;
    1.29  }
    1.30  
    1.31 -STDMETHODIMP CpEpEngine::decrypt_message(text_message * src, text_message * dst, SAFEARRAY ** keylist, pEp_rating *rating)
    1.32 +STDMETHODIMP CpEpEngine::decrypt_message(text_message * src, text_message * dst, SAFEARRAY ** keylist, pEpDecryptFlags *flags, pEp_rating *rating)
    1.33  {
    1.34  	assert(src);
    1.35  	assert(dst);
    1.36 @@ -1160,9 +1160,10 @@
    1.37  	::stringlist_t *_keylist;
    1.38  	::PEP_rating _rating;
    1.39  
    1.40 -	PEP_decrypt_flags_t flags = 0;
    1.41 -	PEP_STATUS status = ::decrypt_message(get_session(), _src, &msg_dst, &_keylist, &_rating, &flags);
    1.42 -	// TODO : output decrypt flags.
    1.43 +	PEP_decrypt_flags_t engineflags = 0;
    1.44 +	PEP_STATUS status = ::decrypt_message(get_session(), _src, &msg_dst, &_keylist, &_rating, &engineflags);
    1.45 +
    1.46 +	*flags = (pEpDecryptFlags)engineflags;
    1.47  
    1.48  	if (msg_dst)
    1.49  		text_message_from_C(dst, msg_dst);
    1.50 @@ -1403,7 +1404,7 @@
    1.51  	}
    1.52  
    1.53  	// we acknowledge that we're quitting...
    1.54 -	keysync_thread_running == false;
    1.55 +	keysync_thread_running = false;
    1.56  
    1.57  	// We signal the main thread that we got his signal
    1.58  	// so it can gain the mutex again and call join() on us.
     2.1 --- a/CpEpEngine.h	Sun Oct 02 11:17:27 2016 +0200
     2.2 +++ b/CpEpEngine.h	Sun Oct 02 15:38:37 2016 +0200
     2.3 @@ -234,8 +234,8 @@
     2.4  
     2.5      // Message API
     2.6  
     2.7 -    STDMETHOD(encrypt_message)(text_message * src, text_message * dst, SAFEARRAY * extra);
     2.8 -    STDMETHOD(decrypt_message)(text_message * src, text_message * dst, SAFEARRAY ** keylist, pEp_rating *rating);
     2.9 +    STDMETHOD(encrypt_message)(text_message * src, text_message * dst, SAFEARRAY * extra, pEpEncryptFlags flags);
    2.10 +    STDMETHOD(decrypt_message)(text_message * src, text_message * dst, SAFEARRAY ** keylist, pEpDecryptFlags* flags, pEp_rating *rating);
    2.11      STDMETHOD(outgoing_message_rating)(text_message *msg, pEp_rating * pVal);
    2.12      STDMETHOD(identity_rating)(pEp_identity_s * ident, pEp_rating * pVal);
    2.13  	STDMETHOD(color_from_rating)(pEp_rating rating, pEp_color * pVal);
     3.1 --- a/pEpCOMServerAdapter.idl	Sun Oct 02 11:17:27 2016 +0200
     3.2 +++ b/pEpCOMServerAdapter.idl	Sun Oct 02 15:38:37 2016 +0200
     3.3 @@ -236,6 +236,16 @@
     3.4  		pEp_color_red = -1,
     3.5  	} pEp_color;
     3.6  
     3.7 +	typedef [v1_enum] enum pEpEncryptFlags {
     3.8 +		pEpEncryptFlagsNone = 0,
     3.9 +		pEpEncryptFlagForceEncryption = 0x1,
    3.10 +	} pEpEncryptFlags;
    3.11 +
    3.12 +	typedef [v1_enum] enum pEpDecryptFlags {
    3.13 +		pEpDecryptFlagsNone = 0,
    3.14 +		pEpDecryptFlagOwnPrivateKey = 0x1
    3.15 +	} pEpDecryptFlags;
    3.16 +
    3.17      typedef  enum _pEp_msg_direction {
    3.18          pEp_dir_incoming = 0,
    3.19          pEp_dir_outgoing
    3.20 @@ -281,8 +291,8 @@
    3.21          SAFEARRAY(struct opt_field) opt_fields;
    3.22      };
    3.23  
    3.24 -    HRESULT encrypt_message([in] struct text_message *src, [out] struct text_message * dst, [in] SAFEARRAY(BSTR) extra);
    3.25 -    HRESULT decrypt_message([in] struct text_message *src, [out] struct text_message * dst, [out] SAFEARRAY(BSTR) *keylist, [out, retval] pEp_rating *rating);
    3.26 +    HRESULT encrypt_message([in] struct text_message *src, [out] struct text_message * dst, [in] SAFEARRAY(BSTR) extra, [in, optional, defaultvalue(pEpEncryptFlagsNone)] pEpEncryptFlags flags);
    3.27 +    HRESULT decrypt_message([in] struct text_message *src, [out] struct text_message * dst, [out] SAFEARRAY(BSTR) *keylist, [out] pEpDecryptFlags* flags, [out, retval] pEp_rating *rating);
    3.28      HRESULT outgoing_message_rating([in] struct text_message *msg, [out, retval] pEp_rating * pVal);
    3.29      HRESULT identity_rating([in] struct pEp_identity_s * ident, [out, retval] pEp_rating * pVal);
    3.30  	HRESULT color_from_rating([in] pEp_rating rating, [out, retval] pEp_color* pVal);