Browse Source

decrypt_message() return values

COM-121
Volker Birk 7 years ago
parent
commit
e7fe58e983
5 changed files with 64 additions and 45 deletions
  1. +48
    -31
      CpEpEngine.cpp
  2. +2
    -2
      CpEpEngine.h
  3. +2
    -2
      pEpCOMServerAdapter.idl
  4. +1
    -1
      pEpCOMServerAdapter_i.c
  5. +11
    -9
      pEpCOMServerAdapter_i.h

+ 48
- 31
CpEpEngine.cpp View File

@ -888,11 +888,12 @@ STDMETHODIMP CpEpEngine::encrypt_message(ITextMessage * src, ITextMessage ** dst
return S_OK;
}
STDMETHODIMP CpEpEngine::decrypt_message(ITextMessage * src, ITextMessage ** dst, SAFEARRAY ** keylist)
STDMETHODIMP CpEpEngine::decrypt_message(ITextMessage * src, ITextMessage ** dst, SAFEARRAY ** keylist, pEp_color *rating)
{
assert(src);
assert(dst);
assert(keylist);
assert(rating);
CTextMessage *_src = dynamic_cast<CTextMessage *>(src);
assert(_src);
@ -902,45 +903,58 @@ STDMETHODIMP CpEpEngine::decrypt_message(ITextMessage * src, ITextMessage ** dst
::message *msg_dst;
::stringlist_t *_keylist;
PEP_STATUS status = ::decrypt_message(get_session(), _src->msg, PEP_MIME_none, &msg_dst, &_keylist);
if (status != PEP_STATUS_OK)
FAIL(L"cannot decrypt message");
::PEP_color _rating;
assert(msg_dst);
PEP_STATUS status = ::decrypt_message(get_session(), _src->msg, PEP_MIME_none, &msg_dst, &_keylist, &_rating);
if (status != PEP_STATUS_OK && (status < PEP_UNENCRYPTED || status > PEP_CANNOT_DECRYPT_UNKNOWN))
return FAIL(L"decrypt message failed");
ITextMessage *i_dst;
HRESULT hr = CTextMessage::CreateInstance(&i_dst);
assert(hr == S_OK);
if (msg_dst) {
ITextMessage *i_dst;
HRESULT hr = CTextMessage::CreateInstance(&i_dst);
assert(hr == S_OK);
if (hr != S_OK) {
::free_message(msg_dst);
::free_stringlist(_keylist);
return hr;
}
if (hr != S_OK) {
::free_message(msg_dst);
::free_stringlist(_keylist);
return hr;
}
CTextMessage *_dst = dynamic_cast<CTextMessage *>(i_dst);
assert(_dst);
CTextMessage *_dst = dynamic_cast<CTextMessage *>(i_dst);
assert(_dst);
::free_message(_dst->msg);
_dst->msg = msg_dst;
::free_message(_dst->msg);
_dst->msg = msg_dst;
ULONG len = ::stringlist_length(_keylist);
CComSafeArray<BSTR> sa;
sa.Create(len);
*dst = i_dst;
}
else {
*dst = NULL;
}
::stringlist_t *_kl;
ULONG i;
for (_kl = _keylist, i = 0; _kl && _kl->value; _kl = _kl->next, i++)
sa.SetAt(i, utf16_bstr(_kl->value).Detach(), false);
::free_stringlist(_keylist);
if (_keylist) {
ULONG len = ::stringlist_length(_keylist);
CComSafeArray<BSTR> sa;
sa.Create(len);
*dst = i_dst;
*keylist = sa.Detach();
::stringlist_t *_kl;
ULONG i;
for (_kl = _keylist, i = 0; _kl && _kl->value; _kl = _kl->next, i++)
sa.SetAt(i, utf16_bstr(_kl->value).Detach(), false);
::free_stringlist(_keylist);
*keylist = sa.Detach();
}
else {
*keylist = NULL;
}
*rating = (pEp_color) _rating;
return S_OK;
}
STDMETHODIMP CpEpEngine::message_color(ITextMessage *msg, pEp_color * pVal)
STDMETHODIMP CpEpEngine::outgoing_message_color(ITextMessage *msg, pEp_color * pVal)
{
assert(msg);
assert(pVal);
@ -948,10 +962,13 @@ STDMETHODIMP CpEpEngine::message_color(ITextMessage *msg, pEp_color * pVal)
CTextMessage *_msg = dynamic_cast<CTextMessage *>(msg);
assert(_msg);
if (_msg->msg->dir != PEP_dir_outgoing)
return E_INVALIDARG;
PEP_color _color;
PEP_STATUS status = ::message_color(get_session(), _msg->msg, &_color);
PEP_STATUS status = ::outgoing_message_color(get_session(), _msg->msg, &_color);
if (status != PEP_STATUS_OK)
FAIL(L"cannot get message color");
return FAIL(L"cannot get message color");
*pVal = (pEp_color) _color;
return S_OK;
@ -978,7 +995,7 @@ STDMETHODIMP CpEpEngine::identity_color(struct pEp_identity_s *ident, pEp_color
PEP_STATUS status = ::identity_color(get_session(), _ident, &_color);
free_identity(_ident);
if (status != PEP_STATUS_OK)
FAIL(L"cannot get message color");
return FAIL(L"cannot get message color");
*pVal = (pEp_color) _color;
return S_OK;


+ 2
- 2
CpEpEngine.h View File

@ -147,8 +147,8 @@ public:
// Message API
STDMETHOD(encrypt_message)(ITextMessage * src, ITextMessage ** dst, SAFEARRAY * extra);
STDMETHOD(decrypt_message)(ITextMessage * src, ITextMessage ** dst, SAFEARRAY ** keylist);
STDMETHOD(message_color)(ITextMessage *msg, pEp_color * pVal);
STDMETHOD(decrypt_message)(ITextMessage * src, ITextMessage ** dst, SAFEARRAY ** keylist, pEp_color *rating);
STDMETHOD(outgoing_message_color)(ITextMessage *msg, pEp_color * pVal);
STDMETHOD(identity_color)(pEp_identity_s * ident, pEp_color * pVal);
};


+ 2
- 2
pEpCOMServerAdapter.idl View File

@ -226,8 +226,8 @@ interface IpEpEngine : IUnknown {
} pEp_color;
HRESULT encrypt_message([in] ITextMessage *src, [out] ITextMessage ** dst, [in, optional] SAFEARRAY(BSTR) extra);
HRESULT decrypt_message([in] ITextMessage *src, [out] ITextMessage ** dst, [out] SAFEARRAY(BSTR) *keylist);
HRESULT message_color([in] ITextMessage *msg, [out, retval] pEp_color * pVal);
HRESULT decrypt_message([in] ITextMessage *src, [out] ITextMessage ** dst, [out] SAFEARRAY(BSTR) *keylist, [out] pEp_color *rating);
HRESULT outgoing_message_color([in] ITextMessage *msg, [out, retval] pEp_color * pVal);
HRESULT identity_color([in] struct pEp_identity_s * ident, [out, retval] pEp_color * pVal);
};


+ 1
- 1
pEpCOMServerAdapter_i.c View File

@ -6,7 +6,7 @@
/* File created by MIDL compiler version 8.00.0603 */
/* at Tue May 05 10:27:03 2015
/* at Wed May 06 20:19:27 2015
*/
/* Compiler settings for pEpCOMServerAdapter.idl:
Oicf, W1, Zp8, env=Win32 (32b run), target_arch=X86 8.00.0603


+ 11
- 9
pEpCOMServerAdapter_i.h View File

@ -4,7 +4,7 @@
/* File created by MIDL compiler version 8.00.0603 */
/* at Tue May 05 10:27:03 2015
/* at Wed May 06 20:19:27 2015
*/
/* Compiler settings for pEpCOMServerAdapter.idl:
Oicf, W1, Zp8, env=Win32 (32b run), target_arch=X86 8.00.0603
@ -767,9 +767,10 @@ EXTERN_C const IID IID_IpEpEngine;
virtual HRESULT STDMETHODCALLTYPE decrypt_message(
/* [in] */ ITextMessage *src,
/* [out] */ ITextMessage **dst,
/* [out] */ SAFEARRAY * *keylist) = 0;
/* [out] */ SAFEARRAY * *keylist,
/* [out] */ pEp_color *rating) = 0;
virtual HRESULT STDMETHODCALLTYPE message_color(
virtual HRESULT STDMETHODCALLTYPE outgoing_message_color(
/* [in] */ ITextMessage *msg,
/* [retval][out] */ pEp_color *pVal) = 0;
@ -929,9 +930,10 @@ EXTERN_C const IID IID_IpEpEngine;
IpEpEngine * This,
/* [in] */ ITextMessage *src,
/* [out] */ ITextMessage **dst,
/* [out] */ SAFEARRAY * *keylist);
/* [out] */ SAFEARRAY * *keylist,
/* [out] */ pEp_color *rating);
HRESULT ( STDMETHODCALLTYPE *message_color )(
HRESULT ( STDMETHODCALLTYPE *outgoing_message_color )(
IpEpEngine * This,
/* [in] */ ITextMessage *msg,
/* [retval][out] */ pEp_color *pVal);
@ -1036,11 +1038,11 @@ EXTERN_C const IID IID_IpEpEngine;
#define IpEpEngine_encrypt_message(This,src,dst,extra) \
( (This)->lpVtbl -> encrypt_message(This,src,dst,extra) )
#define IpEpEngine_decrypt_message(This,src,dst,keylist) \
( (This)->lpVtbl -> decrypt_message(This,src,dst,keylist) )
#define IpEpEngine_decrypt_message(This,src,dst,keylist,rating) \
( (This)->lpVtbl -> decrypt_message(This,src,dst,keylist,rating) )
#define IpEpEngine_message_color(This,msg,pVal) \
( (This)->lpVtbl -> message_color(This,msg,pVal) )
#define IpEpEngine_outgoing_message_color(This,msg,pVal) \
( (This)->lpVtbl -> outgoing_message_color(This,msg,pVal) )
#define IpEpEngine_identity_color(This,ident,pVal) \
( (This)->lpVtbl -> identity_color(This,ident,pVal) )


Loading…
Cancel
Save