Added CpEpEngine::attach_own_key (untested)
authorEdouard Tisserant
Wed, 27 Apr 2016 19:46:51 +0200
changeset 676e53205493ef
parent 66 b27aa367761c
child 68 8ae7aacc250e
Added CpEpEngine::attach_own_key (untested)
CpEpEngine.cpp
CpEpEngine.h
pEpCOMServerAdapter.idl
     1.1 --- a/CpEpEngine.cpp	Wed Apr 27 08:27:32 2016 +0200
     1.2 +++ b/CpEpEngine.cpp	Wed Apr 27 19:46:51 2016 +0200
     1.3 @@ -1041,6 +1041,37 @@
     1.4      return E_FAIL;
     1.5  }
     1.6  
     1.7 +STDMETHODIMP CpEpEngine::attach_own_key(text_message * src, text_message * dst)
     1.8 +{
     1.9 +    assert(src);
    1.10 +    assert(dst);
    1.11 +
    1.12 +    ::message *_src = text_message_to_C(src);
    1.13 +    ::message *msg_dst;
    1.14 +
    1.15 +    PEP_STATUS status = ::encrypt_message(get_session(), _src, NULL, &msg_dst, PEP_enc_none);
    1.16 +
    1.17 +    if (status == PEP_UNENCRYPTED)
    1.18 +        text_message_from_C(dst, _src);
    1.19 +
    1.20 +    ::free_message(msg_dst);
    1.21 +    ::free_message(_src);
    1.22 +
    1.23 +    if (status == PEP_OUT_OF_MEMORY) {
    1.24 +        return E_OUTOFMEMORY;
    1.25 +    }
    1.26 +
    1.27 +    if (status == PEP_UNENCRYPTED)
    1.28 +    {
    1.29 +        return S_OK;
    1.30 +    }
    1.31 +    else
    1.32 +    {
    1.33 +        return FAIL(L"cannot attach own key");
    1.34 +    }
    1.35 +}
    1.36 +
    1.37 +
    1.38  STDMETHODIMP CpEpEngine::encrypt_message(text_message * src, text_message * dst, SAFEARRAY * extra)
    1.39  {
    1.40      assert(src);
     2.1 --- a/CpEpEngine.h	Wed Apr 27 08:27:32 2016 +0200
     2.2 +++ b/CpEpEngine.h	Wed Apr 27 19:46:51 2016 +0200
     2.3 @@ -180,6 +180,7 @@
     2.4  
     2.5      // Message API
     2.6  
     2.7 +    STDMETHOD(attach_own_key)(text_message * src, text_message * dst);
     2.8      STDMETHOD(encrypt_message)(text_message * src, text_message * dst, SAFEARRAY * extra);
     2.9      STDMETHOD(decrypt_message)(text_message * src, text_message * dst, SAFEARRAY ** keylist, pEp_color *rating);
    2.10      STDMETHOD(outgoing_message_color)(text_message *msg, pEp_color * pVal);
     3.1 --- a/pEpCOMServerAdapter.idl	Wed Apr 27 08:27:32 2016 +0200
     3.2 +++ b/pEpCOMServerAdapter.idl	Wed Apr 27 19:46:51 2016 +0200
     3.3 @@ -257,6 +257,7 @@
     3.4          SAFEARRAY(struct opt_field) opt_fields;
     3.5      };
     3.6  
     3.7 +    HRESULT attach_own_key([in] struct text_message *src, [out] struct text_message * dst);
     3.8      HRESULT encrypt_message([in] struct text_message *src, [out] struct text_message * dst, [in] SAFEARRAY(BSTR) extra);
     3.9      HRESULT decrypt_message([in] struct text_message *src, [out] struct text_message * dst, [out] SAFEARRAY(BSTR) *keylist, [out, retval] pEp_color *rating);
    3.10      HRESULT outgoing_message_color([in] struct text_message *msg, [out, retval] pEp_color * pVal);