COM-86: Adapt to ENGINE-416: added argument for extra key fprs to
authorMarkus Schaber <markus@pep-security.net>
Sun, 08 Apr 2018 20:14:29 +0200
changeset 2804f2813b98b81
parent 279 79c90923f384
child 281 08164979a405
child 283 24204d8f422e
COM-86: Adapt to ENGINE-416: added argument for extra key fprs to
encrypt_message_for_self and MIME_encrypt_message_for_self
CpEpEngine.cpp
CpEpEngine.h
pEpCOMServerAdapter.idl
     1.1 --- a/CpEpEngine.cpp	Tue Apr 03 11:45:04 2018 +0200
     1.2 +++ b/CpEpEngine.cpp	Sun Apr 08 20:14:29 2018 +0200
     1.3 @@ -917,8 +917,8 @@
     1.4      return S_OK;
     1.5  }
     1.6  
     1.7 -
     1.8 -STDMETHODIMP CpEpEngine::EncryptMessageForSelf(pEpIdentity * targetId, TextMessage * src, TextMessage * dst, pEpEncryptFlags flags)
     1.9 +STDMETHODIMP CpEpEngine::EncryptMessageForSelf(pEpIdentity * targetId, TextMessage * src,
    1.10 +    /* [in] */ SAFEARRAY *extra, TextMessage * dst, pEpEncryptFlags flags)
    1.11  {
    1.12      assert(targetId);
    1.13      assert(src);
    1.14 @@ -932,21 +932,37 @@
    1.15      ::pEp_identity *_target_id = new_identity(targetId);
    1.16  
    1.17      ::message *_src = text_message_to_C(src);
    1.18 +
    1.19 +    ::stringlist_t* _extra = NULL;
    1.20 +    HRESULT result = S_OK;
    1.21 +    ::message *msg_dst = NULL;
    1.22 +    PEP_STATUS status = PEP_STATUS_OK;
    1.23  
    1.24 -    // COM-19: Initialize msg_dst to NULL, or we end up calling
    1.25 -    // free_message() below with a pointer to random garbage in
    1.26 -    // case of an error in encrypt_message_for_self().
    1.27 -    ::message *msg_dst = NULL;
    1.28 -    PEP_STATUS status = ::encrypt_message_for_self(get_session(), _target_id, _src, &msg_dst, PEP_enc_PEP, engineFlags);
    1.29 +    try {
    1.30 +        if (extra) {
    1.31 +            _extra = new_stringlist(extra);
    1.32 +        }
    1.33  
    1.34 -    if (status == PEP_STATUS_OK)
    1.35 -        text_message_from_C(dst, msg_dst);
    1.36 -    else
    1.37 -        text_message_from_C(dst, _src);
    1.38 +        // COM-19: Initialize msg_dst to NULL, or we end up calling
    1.39 +        // free_message() below with a pointer to random garbage in
    1.40 +        // case of an error in encrypt_message_for_self().
    1.41 +        status = ::encrypt_message_for_self(get_session(), _target_id, _src, _extra, &msg_dst, PEP_enc_PEP, engineFlags);
    1.42 +
    1.43 +        if (status == PEP_STATUS_OK)
    1.44 +            text_message_from_C(dst, msg_dst);
    1.45 +        else
    1.46 +            text_message_from_C(dst, _src);
    1.47 +    } catch (bad_alloc&) {
    1.48 +        result = E_OUTOFMEMORY;
    1.49 +    }
    1.50 +    catch (exception& ex) {
    1.51 +        result = FAIL(ex.what());
    1.52 +    }
    1.53  
    1.54      ::free_message(msg_dst);
    1.55      ::free_message(_src);
    1.56      ::free_identity(_target_id);
    1.57 +    ::free_stringlist(_extra);
    1.58  
    1.59      if (status == PEP_OUT_OF_MEMORY)
    1.60          return E_OUTOFMEMORY;
    1.61 @@ -956,7 +972,7 @@
    1.62      if (status != PEP_STATUS_OK)
    1.63          return FAIL("Failure to encrypt message", status);
    1.64  
    1.65 -    return S_OK;
    1.66 +    return result;
    1.67  }
    1.68  
    1.69  STDMETHODIMP CpEpEngine::DecryptMessage(TextMessage * src, TextMessage * dst, SAFEARRAY ** keylist, pEpDecryptFlags *flags, pEpRating *rating)
     2.1 --- a/CpEpEngine.h	Tue Apr 03 11:45:04 2018 +0200
     2.2 +++ b/CpEpEngine.h	Sun Apr 08 20:14:29 2018 +0200
     2.3 @@ -249,6 +249,7 @@
     2.4      STDMETHOD(EncryptMessageForSelf)(
     2.5          pEpIdentity * targetId,
     2.6          TextMessage* src,
     2.7 +        /* [in] */ SAFEARRAY *extra,
     2.8          TextMessage *dst,
     2.9          pEpEncryptFlags flags
    2.10          );
     3.1 --- a/pEpCOMServerAdapter.idl	Tue Apr 03 11:45:04 2018 +0200
     3.2 +++ b/pEpCOMServerAdapter.idl	Sun Apr 08 20:14:29 2018 +0200
     3.3 @@ -396,6 +396,7 @@
     3.4      [id(34)] HRESULT EncryptMessageForSelf(
     3.5          [in] struct pEpIdentity* targetId,
     3.6          [in] struct TextMessage* src,
     3.7 +        [in] SAFEARRAY(BSTR) extra,
     3.8          [out] struct TextMessage* dst,
     3.9          [in, defaultvalue(pEpEncryptFlagDefault)] pEpEncryptFlags flags
    3.10      );