Browse Source

...

COM-121
Volker Birk 7 years ago
parent
commit
fa5c8d2be6
6 changed files with 74 additions and 31 deletions
  1. +4
    -0
      CpEpEngine.cpp
  2. +4
    -4
      pEpCOMServerAdapter.idl
  3. +1
    -1
      pEpCOMServerAdapter_i.c
  4. +1
    -1
      pEpCOMServerAdapter_i.h
  5. +2
    -2
      pEp_utility.h
  6. +62
    -23
      pEp_utitlity.cpp

+ 4
- 0
CpEpEngine.cpp View File

@ -899,6 +899,7 @@ STDMETHODIMP CpEpEngine::decrypt_message(text_message * src, text_message * dst,
assert(rating);
*keylist = NULL;
*rating = pEp_rating_undefined;
::message *_src = text_message_to_C(src);
::message *msg_dst = NULL;
@ -912,6 +913,9 @@ STDMETHODIMP CpEpEngine::decrypt_message(text_message * src, text_message * dst,
text_message_from_C(dst, msg_dst);
::free_message(msg_dst);
}
else {
text_message_from_C(dst, _src);
}
if (_keylist) {
*keylist = string_array(_keylist);


+ 4
- 4
pEpCOMServerAdapter.idl View File

@ -15,7 +15,7 @@ import "ocidl.idl";
pointer_default(unique)
]
interface IpEpEngine : IUnknown {
typedef enum _pEp_STATUS {
typedef enum _pEp_STATUS {
pEp_STATUS_OK = 0,
pEp_KEY_NOT_FOUND = 0x0201,
@ -147,18 +147,18 @@ interface IpEpEngine : IUnknown {
pEp_text_format_other = 0xff
} pEp_text_format;
typedef enum _pEp_msg_direction {
typedef enum _pEp_msg_direction {
pEp_dir_incoming = 0,
pEp_dir_outgoing
} pEp_msg_direction;
typedef enum _pEp_MIME_format {
typedef enum _pEp_MIME_format {
pEp_MIME_none = 0, // message is not MIME encoded
pEp_MIME_fields_omitted, // message content but no fields
pEp_MIME // message is fully MIME encoded
} pEp_MIME_format;
typedef enum _pEp_enc_format {
typedef enum _pEp_enc_format {
pEp_enc_none = 0, // message is not encrypted
pEp_enc_pieces, // inline PGP + PGP extensions
pEp_enc_S_MIME, // RFC5751


+ 1
- 1
pEpCOMServerAdapter_i.c View File

@ -6,7 +6,7 @@
/* File created by MIDL compiler version 8.00.0603 */
/* at Sun May 31 17:28:45 2015
/* at Sun May 31 21:59:38 2015
*/
/* Compiler settings for pEpCOMServerAdapter.idl:
Oicf, W1, Zp8, env=Win32 (32b run), target_arch=X86 8.00.0603


+ 1
- 1
pEpCOMServerAdapter_i.h View File

@ -4,7 +4,7 @@
/* File created by MIDL compiler version 8.00.0603 */
/* at Sun May 31 17:28:45 2015
/* at Sun May 31 21:59:38 2015
*/
/* Compiler settings for pEpCOMServerAdapter.idl:
Oicf, W1, Zp8, env=Win32 (32b run), target_arch=X86 8.00.0603


+ 2
- 2
pEp_utility.h View File

@ -52,12 +52,12 @@ namespace pEp {
assert(pTypelib);
HRESULT hr = pTypelib->GetTypeInfoOfGuid(__uuidof(UDType), &pTypeInfo);
GUID guid = __uuidof(UDType);
HRESULT hr = pTypelib->GetTypeInfoOfGuid(guid, &pTypeInfo);
assert(SUCCEEDED(hr) && pTypeInfo);
hr = GetRecordInfoFromTypeInfo(pTypeInfo, &pRecInfo);
assert(SUCCEEDED(hr) && pRecInfo);
pTypeInfo->Release();
pTypelib->Release();
return pRecInfo;
}


+ 62
- 23
pEp_utitlity.cpp View File

@ -154,7 +154,7 @@ namespace pEp {
template< class T2, class T > T2 from_C(T *tl);
template<> BSTR from_C< BSTR, char >(char *s)
BSTR bstr(char *s)
{
if (s)
return utf16_bstr(s);
@ -162,11 +162,6 @@ namespace pEp {
return _bstr_t(L"").Detach();
}
inline BSTR bstr(char *s)
{
return from_C< BSTR, char >(s);
}
template<> blob *from_C< blob *, bloblist_t >(bloblist_t *tl)
{
assert(tl && tl->value);
@ -206,9 +201,22 @@ namespace pEp {
return sa;
}
void clear_identity_s(pEp_identity_s& ident)
{
SysFreeString(ident.address);
SysFreeString(ident.fpr);
SysFreeString(ident.lang);
SysFreeString(ident.username);
SysFreeString(ident.user_id);
memset(&ident, 0, sizeof(pEp_identity_s));
}
template<> pEp_identity_s from_C< pEp_identity_s, pEp_identity >(pEp_identity *tl)
{
pEp_identity_s _ident;
memset(&_ident, 0, sizeof(_ident));
if (tl)
copy_identity(&_ident, tl);
return _ident;
@ -222,6 +230,8 @@ namespace pEp {
template<> pEp_identity_s *from_C< pEp_identity_s *, identity_list >(identity_list *il)
{
pEp_identity_s *ident = new pEp_identity_s();
memset(ident, 0, sizeof(pEp_identity_s));
if (il)
copy_identity(ident, il->ident);
return ident;
@ -252,11 +262,34 @@ namespace pEp {
return stringpair_list_length(tl);
}
void clear_text_message(text_message *msg)
{
SysFreeString(msg->id);
SysFreeString(msg->shortmsg);
SysFreeString(msg->longmsg);
SysFreeString(msg->longmsg_formatted);
SafeArrayDestroy(msg->attachments);
clear_identity_s(msg->from);
SafeArrayDestroy(msg->to);
clear_identity_s(msg->recv_by);
SafeArrayDestroy(msg->cc);
SafeArrayDestroy(msg->bcc);
SafeArrayDestroy(msg->reply_to);
SafeArrayDestroy(msg->references);
SafeArrayDestroy(msg->keywords);
SysFreeString(msg->comments);
SafeArrayDestroy(msg->opt_fields);
memset(msg, 0, sizeof(text_message));
}
void text_message_from_C(text_message *msg2, ::message *msg)
{
assert(msg2);
assert(msg);
clear_text_message(msg2);
msg2->dir = (pEp_msg_direction) msg->dir;
msg2->id = bstr(msg->id);
msg2->shortmsg = bstr(msg->shortmsg);
@ -289,6 +322,14 @@ namespace pEp {
return _s;
}
void clear_blob(blob& b)
{
SysFreeString(b.filename);
SysFreeString(b.mime_type);
SafeArrayDestroy(b.value);
memset(&b, 0, sizeof(blob));
}
bloblist_t *bloblist(SAFEARRAY *sa)
{
if (sa == NULL)
@ -326,19 +367,16 @@ namespace pEp {
SafeArrayAccessData(b.value, (void **) &data);
memcpy(buffer, data, size);
SafeArrayUnaccessData(sa);
free(buffer);
_bl = bloblist_add(_bl, buffer, size, str(b.mime_type), str(b.filename));
if (_bl == NULL) {
IRecordInfo *ri = getRecordInfo<blob>();
ri->RecordClear(&b);
clear_blob(b);
free_bloblist(bl);
free(buffer);
throw bad_alloc();
}
IRecordInfo *ri = getRecordInfo<blob>();
ri->RecordClear(&b);
clear_blob(b);
}
return bl;
@ -362,7 +400,7 @@ namespace pEp {
identity_list *_il = il;
for (LONG i = lbound; i <= ubound; i++) {
pEp_identity_s s;
memset(&s, 0, sizeof(s));
memset(&s, 0, sizeof(pEp_identity_s));
SafeArrayGetElement(sa, &i, &s);
pEp_identity *ident;
@ -370,14 +408,11 @@ namespace pEp {
ident = new_identity(&s);
}
catch (bad_alloc&) {
IRecordInfo *ri = getRecordInfo<pEp_identity_s>();
ri->RecordClear(&s);
clear_identity_s(s);
throw bad_alloc();
}
IRecordInfo *ri = getRecordInfo<pEp_identity_s>();
ri->RecordClear(&s);
clear_identity_s(s);
_il = identity_list_add(_il, ident);
if (_il == NULL) {
@ -398,6 +433,13 @@ namespace pEp {
return pair;
}
void clear_opt_field(opt_field& f)
{
SysFreeString(f.name);
SysFreeString(f.value);
memset(&f, 0, sizeof(opt_field));
}
stringpair_list_t *stringpair_list(SAFEARRAY * sa)
{
if (sa == NULL)
@ -424,14 +466,11 @@ namespace pEp {
pair = new_stringpair(&s);
}
catch (bad_alloc&) {
IRecordInfo *ri = getRecordInfo<opt_field>();
ri->RecordClear(&s);
clear_opt_field(s);
throw bad_alloc();
}
IRecordInfo *ri = getRecordInfo<opt_field>();
ri->RecordClear(&s);
clear_opt_field(s);
_il = stringpair_list_add(_il, pair);
if (_il == NULL) {


Loading…
Cancel
Save