Browse Source

COM-30 COM-24: Refactorings

Adapt naming convention for Methods, Types and Enum members
Remove obsolete methods
Also defined new GUIDs for all types, which is also necessary for COM-29.
COM-121
Markus Schaber 5 years ago
parent
commit
74a5df7c1e
8 changed files with 395 additions and 398 deletions
  1. +61
    -61
      CpEpEngine.cpp
  2. +91
    -47
      CpEpEngine.h
  3. +0
    -40
      _IpEpEngineEvents_CP.h
  4. +195
    -204
      pEpCOMServerAdapter.idl
  5. +1
    -0
      pEpCOMServerAdapter.vcxproj
  6. +1
    -0
      pEpCOMServerAdapter.vcxproj.filters
  7. +35
    -35
      pEp_utility.cpp
  8. +11
    -11
      pEp_utility.h

+ 61
- 61
CpEpEngine.cpp View File

@ -25,19 +25,19 @@ STDMETHODIMP CpEpEngine::InterfaceSupportsErrorInfo(REFIID riid)
#define FAIL(msg) error(msg)
STDMETHODIMP CpEpEngine::verbose_logging(VARIANT_BOOL enable)
STDMETHODIMP CpEpEngine::VerboseLogging(VARIANT_BOOL enable)
{
verbose_mode = enable != VARIANT_FALSE;
return S_OK;
}
STDMETHODIMP CpEpEngine::passive_mode(VARIANT_BOOL enable)
STDMETHODIMP CpEpEngine::PassiveMode(VARIANT_BOOL enable)
{
::config_passive_mode(get_session(), enable != VARIANT_FALSE);
return S_OK;
}
STDMETHODIMP CpEpEngine::unencrypted_subject(VARIANT_BOOL enable)
STDMETHODIMP CpEpEngine::UnencryptedSubject(VARIANT_BOOL enable)
{
::config_unencrypted_subject(get_session(), enable != VARIANT_FALSE);
return S_OK;
@ -81,7 +81,7 @@ STDMETHODIMP CpEpEngine::log(BSTR title, BSTR entity, BSTR description, BSTR com
}
STDMETHODIMP CpEpEngine::decrypt(BSTR ctext, BSTR * ptext, LPSAFEARRAY * key_list, pEp_STATUS * status)
STDMETHODIMP CpEpEngine::decrypt(BSTR ctext, BSTR * ptext, LPSAFEARRAY * key_list, pEpStatus * status)
{
assert(ctext);
assert(ptext);
@ -110,7 +110,7 @@ STDMETHODIMP CpEpEngine::decrypt(BSTR ctext, BSTR * ptext, LPSAFEARRAY * key_lis
if (_status == PEP_OUT_OF_MEMORY)
return E_OUTOFMEMORY;
*status = (pEp_STATUS)_status;
*status = (pEpStatus)_status;
if (_ptext == NULL) {
if (_keylist) {
string msg;
@ -145,7 +145,7 @@ STDMETHODIMP CpEpEngine::decrypt(BSTR ctext, BSTR * ptext, LPSAFEARRAY * key_lis
return S_OK;
}
STDMETHODIMP CpEpEngine::decrypt_b(BSTR ctext, LPSAFEARRAY * ptext, LPSAFEARRAY * key_list, pEp_STATUS * status)
STDMETHODIMP CpEpEngine::decrypt_b(BSTR ctext, LPSAFEARRAY * ptext, LPSAFEARRAY * key_list, pEpStatus * status)
{
assert(ctext);
assert(ptext);
@ -185,7 +185,7 @@ STDMETHODIMP CpEpEngine::decrypt_b(BSTR ctext, LPSAFEARRAY * ptext, LPSAFEARRAY
::free_stringlist(_keylist);
return E_OUTOFMEMORY;
}
*status = (pEp_STATUS)_status;
*status = (pEpStatus)_status;
if (_ptext == NULL) {
::free_stringlist(_keylist);
@ -220,7 +220,7 @@ STDMETHODIMP CpEpEngine::decrypt_b(BSTR ctext, LPSAFEARRAY * ptext, LPSAFEARRAY
return S_OK;
}
STDMETHODIMP CpEpEngine::verify(BSTR text, BSTR signature, LPSAFEARRAY * key_list, pEp_STATUS * verify_status)
STDMETHODIMP CpEpEngine::verify(BSTR text, BSTR signature, LPSAFEARRAY * key_list, pEpStatus * verify_status)
{
assert(text);
assert(signature);
@ -241,7 +241,7 @@ STDMETHODIMP CpEpEngine::verify(BSTR text, BSTR signature, LPSAFEARRAY * key_lis
if (_status == PEP_DECRYPT_WRONG_FORMAT || _status == PEP_UNKNOWN_ERROR)
return FAIL(L"verify_text");
*verify_status = (pEp_STATUS)_status;
*verify_status = (pEpStatus)_status;
if (_keylist && _keylist->value)
*key_list = string_array(_keylist);
@ -252,7 +252,7 @@ STDMETHODIMP CpEpEngine::verify(BSTR text, BSTR signature, LPSAFEARRAY * key_lis
return S_OK;
}
STDMETHODIMP CpEpEngine::encrypt(SAFEARRAY * key_list, BSTR ptext, BSTR * ctext, pEp_STATUS * status)
STDMETHODIMP CpEpEngine::encrypt(SAFEARRAY * key_list, BSTR ptext, BSTR * ctext, pEpStatus * status)
{
assert(key_list);
assert(ptext);
@ -282,7 +282,7 @@ STDMETHODIMP CpEpEngine::encrypt(SAFEARRAY * key_list, BSTR ptext, BSTR * ctext,
::free_stringlist(_keylist);
if (_status == PEP_OUT_OF_MEMORY)
return E_OUTOFMEMORY;
*status = (pEp_STATUS)_status;
*status = (pEpStatus)_status;
if (_ctext == NULL)
return FAIL(L"encrypt_and_sign");
@ -293,7 +293,7 @@ STDMETHODIMP CpEpEngine::encrypt(SAFEARRAY * key_list, BSTR ptext, BSTR * ctext,
return S_OK;
}
STDMETHODIMP CpEpEngine::encrypt_b(SAFEARRAY * key_list, SAFEARRAY * ptext, BSTR * ctext, pEp_STATUS * status)
STDMETHODIMP CpEpEngine::encrypt_b(SAFEARRAY * key_list, SAFEARRAY * ptext, BSTR * ctext, pEpStatus * status)
{
assert(key_list);
assert(ptext);
@ -321,12 +321,12 @@ STDMETHODIMP CpEpEngine::encrypt_b(SAFEARRAY * key_list, SAFEARRAY * ptext, BSTR
::free_stringlist(_keylist);
if (_status == PEP_OUT_OF_MEMORY)
return E_OUTOFMEMORY;
*status = (pEp_STATUS)_status;
*status = (pEpStatus)_status;
if (_ctext == NULL)
return FAIL(L"encrypt_and_sign");
*status = (pEp_STATUS)_status;
*status = (pEpStatus)_status;
wchar_t *w_ctext = NULL;
int w_csize = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, _ctext, _csize, NULL, 0);
if (w_csize) {
@ -389,7 +389,7 @@ STDMETHODIMP CpEpEngine::trustword(LONG value, BSTR lang, BSTR * word)
}
}
STDMETHODIMP CpEpEngine::trustwords(BSTR fpr, BSTR lang, LONG max_words, BSTR * words)
STDMETHODIMP CpEpEngine::TrustWords(BSTR fpr, BSTR lang, LONG max_words, BSTR * words)
{
assert(fpr);
assert(max_words >= 0);
@ -435,7 +435,7 @@ STDMETHODIMP CpEpEngine::trustwords(BSTR fpr, BSTR lang, LONG max_words, BSTR *
if (_words == NULL) {
*words = NULL;
return FAIL(L"trustwords");
return FAIL(L"TrustWords");
}
else {
*words = utf16_bstr(_words);
@ -444,7 +444,7 @@ STDMETHODIMP CpEpEngine::trustwords(BSTR fpr, BSTR lang, LONG max_words, BSTR *
}
}
STDMETHODIMP CpEpEngine::get_crashdump_log(LONG maxlines, BSTR * log)
STDMETHODIMP CpEpEngine::GetCrashdumpLog(LONG maxlines, BSTR * log)
{
assert(maxlines >= 0);
assert(log);
@ -458,14 +458,14 @@ STDMETHODIMP CpEpEngine::get_crashdump_log(LONG maxlines, BSTR * log)
if (status == PEP_OUT_OF_MEMORY)
return E_OUTOFMEMORY;
if (status != PEP_STATUS_OK || _log == NULL)
return FAIL(L"get_crashdump_log");
return FAIL(L"GetCrashdumpLog");
*log = utf16_bstr(_log);
pEp_free(_log);
return S_OK;
}
STDMETHODIMP CpEpEngine::get_engine_version(BSTR * engine_version)
STDMETHODIMP CpEpEngine::GetEngineVersion(BSTR * engine_version)
{
assert(engine_version);
@ -475,14 +475,14 @@ STDMETHODIMP CpEpEngine::get_engine_version(BSTR * engine_version)
const char *_enginge_version = ::get_engine_version();
if (_enginge_version == NULL)
return FAIL(L"get_engine_version");
return FAIL(L"GetEngineVersion");
*engine_version = utf16_bstr(_enginge_version);
return S_OK;
}
STDMETHODIMP CpEpEngine::get_languagelist(BSTR * languages)
STDMETHODIMP CpEpEngine::GetLanguagelist(BSTR * languages)
{
assert(languages);
@ -495,7 +495,7 @@ STDMETHODIMP CpEpEngine::get_languagelist(BSTR * languages)
if (status == PEP_OUT_OF_MEMORY)
return E_OUTOFMEMORY;
if (status != PEP_STATUS_OK || _languages == NULL)
return FAIL(L"get_languagelist");
return FAIL(L"GetLanguagelist");
*languages = utf16_bstr(_languages);
pEp_free(_languages);
@ -527,7 +527,7 @@ STDMETHODIMP CpEpEngine::get_phrase(BSTR lang, LONG phrase_id, BSTR * phrase)
return S_OK;
}
STDMETHODIMP CpEpEngine::get_identity(BSTR address, BSTR user_id, pEp_identity_s * ident)
STDMETHODIMP CpEpEngine::get_identity(BSTR address, BSTR user_id, pEpIdentity * ident)
{
assert(address);
assert(user_id);
@ -559,7 +559,7 @@ STDMETHODIMP CpEpEngine::get_identity(BSTR address, BSTR user_id, pEp_identity_s
return S_OK;
}
STDMETHODIMP CpEpEngine::set_identity(pEp_identity_s * ident)
STDMETHODIMP CpEpEngine::set_identity(pEpIdentity * ident)
{
assert(ident);
assert(ident->address);
@ -581,7 +581,7 @@ STDMETHODIMP CpEpEngine::set_identity(pEp_identity_s * ident)
return S_OK;
}
STDMETHODIMP CpEpEngine::generate_keypair(pEp_identity_s * ident, BSTR * fpr)
STDMETHODIMP CpEpEngine::generate_keypair(pEpIdentity * ident, BSTR * fpr)
{
assert(ident);
assert(ident->address);
@ -647,7 +647,7 @@ STDMETHODIMP CpEpEngine::import_key(BSTR key_data)
if (status == PEP_OUT_OF_MEMORY)
return E_OUTOFMEMORY;
if (status != pEp_STATUS_OK)
if (status != pEpStatusOK)
return FAIL(L"import_key");
else
return S_OK;
@ -766,7 +766,7 @@ STDMETHODIMP CpEpEngine::send_key(BSTR pattern)
return S_OK;
}
STDMETHODIMP CpEpEngine::start_keyserver_lookup()
STDMETHODIMP CpEpEngine::StartKeyserverLookup()
{
if (identity_queue.load())
return S_OK;
@ -777,7 +777,7 @@ STDMETHODIMP CpEpEngine::start_keyserver_lookup()
return S_OK;
}
STDMETHODIMP CpEpEngine::stop_keyserver_lookup()
STDMETHODIMP CpEpEngine::StopKeyserverLookup()
{
if (identity_queue.load() == NULL)
return S_OK;
@ -797,7 +797,7 @@ STDMETHODIMP CpEpEngine::stop_keyserver_lookup()
return S_OK;
}
STDMETHODIMP CpEpEngine::examine_identity(pEp_identity_s * ident)
STDMETHODIMP CpEpEngine::examine_identity(pEpIdentity * ident)
{
assert(ident);
if (ident == NULL)
@ -815,7 +815,7 @@ STDMETHODIMP CpEpEngine::examine_identity(pEp_identity_s * ident)
return S_OK;
}
STDMETHODIMP CpEpEngine::myself(struct pEp_identity_s *ident, struct pEp_identity_s *result)
STDMETHODIMP CpEpEngine::Myself(struct pEpIdentity *ident, struct pEpIdentity *result)
{
assert(ident);
assert(result);
@ -829,7 +829,7 @@ STDMETHODIMP CpEpEngine::myself(struct pEp_identity_s *ident, struct pEp_identit
return E_OUTOFMEMORY;
// DEBUG CODE - REMOVE BEFORE RELEASE!
// sync_handshake_result_s handshakeResult;
// SyncHandshakeResult handshakeResult;
//
// HRESULT res = Fire_ShowHandshake(ident, result, &handshakeResult);
//
@ -852,7 +852,7 @@ STDMETHODIMP CpEpEngine::myself(struct pEp_identity_s *ident, struct pEp_identit
}
}
STDMETHODIMP CpEpEngine::update_identity(struct pEp_identity_s *ident, struct pEp_identity_s *result)
STDMETHODIMP CpEpEngine::UpdateIdentity(struct pEpIdentity *ident, struct pEpIdentity *result)
{
assert(ident);
assert(result);
@ -878,11 +878,11 @@ STDMETHODIMP CpEpEngine::update_identity(struct pEp_identity_s *ident, struct pE
if (status == PEP_OUT_OF_MEMORY)
return E_OUTOFMEMORY;
else
return FAIL(L"update_identity");
return FAIL(L"UpdateIdentity");
}
}
STDMETHODIMP CpEpEngine::key_mistrusted(struct pEp_identity_s *ident)
STDMETHODIMP CpEpEngine::KeyMistrusted(struct pEpIdentity *ident)
{
::pEp_identity *_ident;
@ -913,7 +913,7 @@ STDMETHODIMP CpEpEngine::key_mistrusted(struct pEp_identity_s *ident)
return S_OK;
}
STDMETHODIMP CpEpEngine::key_reset_trust(struct pEp_identity_s *ident)
STDMETHODIMP CpEpEngine::KeyResetTrust(struct pEpIdentity *ident)
{
::pEp_identity *_ident;
@ -995,8 +995,8 @@ PEP_STATUS CpEpEngine::messageToSend(void * obj, message *msg)
if (msg == NULL)
return PEP_ILLEGAL_VALUE;
text_message _msg;
memset(&_msg, 0, sizeof(text_message));
TextMessage _msg;
memset(&_msg, 0, sizeof(TextMessage));
text_message_from_C(&_msg, msg);
CpEpEngine *me = (CpEpEngine *)obj;
@ -1017,12 +1017,12 @@ PEP_STATUS CpEpEngine::showHandshake(void * obj, pEp_identity *self, pEp_identit
if (!(self && partner))
return PEP_ILLEGAL_VALUE;
pEp_identity_s _self;
pEpIdentity _self;
copy_identity(&_self, self);
pEp_identity_s _partner;
pEpIdentity _partner;
copy_identity(&_partner, partner);
CpEpEngine *me = (CpEpEngine *)obj;
sync_handshake_result_s _result;
SyncHandshakeResult _result;
HRESULT r = me->Fire_ShowHandshake(&_self, &_partner, &_result);
assert(r == S_OK);
clear_identity_s(_self);
@ -1036,7 +1036,7 @@ PEP_STATUS CpEpEngine::showHandshake(void * obj, pEp_identity *self, pEp_identit
return status;
}
STDMETHODIMP CpEpEngine::blacklist_add(BSTR fpr)
STDMETHODIMP CpEpEngine::BlacklistAdd(BSTR fpr)
{
assert(fpr);
@ -1049,7 +1049,7 @@ STDMETHODIMP CpEpEngine::blacklist_add(BSTR fpr)
return S_OK;
}
STDMETHODIMP CpEpEngine::blacklist_delete(BSTR fpr)
STDMETHODIMP CpEpEngine::BlacklistDelete(BSTR fpr)
{
assert(fpr);
@ -1062,7 +1062,7 @@ STDMETHODIMP CpEpEngine::blacklist_delete(BSTR fpr)
return S_OK;
}
STDMETHODIMP CpEpEngine::blacklist_is_listed(BSTR fpr, VARIANT_BOOL *listed)
STDMETHODIMP CpEpEngine::BlacklistIsListed(BSTR fpr, VARIANT_BOOL *listed)
{
assert(fpr);
assert(listed);
@ -1078,7 +1078,7 @@ STDMETHODIMP CpEpEngine::blacklist_is_listed(BSTR fpr, VARIANT_BOOL *listed)
return S_OK;
}
STDMETHODIMP CpEpEngine::blacklist_retrieve(SAFEARRAY **blacklist)
STDMETHODIMP CpEpEngine::BlacklistRetreive(SAFEARRAY **blacklist)
{
assert(blacklist);
@ -1116,7 +1116,7 @@ HRESULT CpEpEngine::error(_bstr_t msg)
return E_FAIL;
}
STDMETHODIMP CpEpEngine::encrypt_message(text_message * src, text_message * dst, SAFEARRAY * extra, pEpEncryptFlags flags)
STDMETHODIMP CpEpEngine::EncryptMessage(TextMessage * src, TextMessage * dst, SAFEARRAY * extra, pEpEncryptFlags flags)
{
assert(src);
assert(dst);
@ -1145,7 +1145,7 @@ STDMETHODIMP CpEpEngine::encrypt_message(text_message * src, text_message * dst,
return S_OK;
}
STDMETHODIMP CpEpEngine::decrypt_message(text_message * src, text_message * dst, SAFEARRAY ** keylist, pEpDecryptFlags *flags, pEp_rating *rating)
STDMETHODIMP CpEpEngine::DecryptMessage(TextMessage * src, TextMessage * dst, SAFEARRAY ** keylist, pEpDecryptFlags *flags, pEpRating *rating)
{
assert(src);
assert(dst);
@ -1153,7 +1153,7 @@ STDMETHODIMP CpEpEngine::decrypt_message(text_message * src, text_message * dst,
assert(rating);
*keylist = NULL;
*rating = pEp_rating_undefined;
*rating = pEpRatingUndefined;
::message *_src = text_message_to_C(src);
::message *msg_dst = NULL;
@ -1176,12 +1176,12 @@ STDMETHODIMP CpEpEngine::decrypt_message(text_message * src, text_message * dst,
free_stringlist(_keylist);
}
*rating = (pEp_rating)_rating;
*rating = (pEpRating)_rating;
return S_OK;
}
STDMETHODIMP CpEpEngine::outgoing_message_rating(text_message *msg, pEp_rating * pVal)
STDMETHODIMP CpEpEngine::OutgoingMessageRating(TextMessage *msg, pEpRating * pVal)
{
assert(msg);
assert(pVal);
@ -1193,11 +1193,11 @@ STDMETHODIMP CpEpEngine::outgoing_message_rating(text_message *msg, pEp_rating *
if (status != PEP_STATUS_OK)
return FAIL(L"cannot get message rating");
*pVal = (pEp_rating)_rating;
*pVal = (pEpRating)_rating;
return S_OK;
}
STDMETHODIMP CpEpEngine::identity_rating(struct pEp_identity_s *ident, pEp_rating * pVal)
STDMETHODIMP CpEpEngine::IdentityRating(struct pEpIdentity *ident, pEpRating * pVal)
{
::pEp_identity *_ident;
@ -1220,23 +1220,23 @@ STDMETHODIMP CpEpEngine::identity_rating(struct pEp_identity_s *ident, pEp_ratin
if (status != PEP_STATUS_OK)
return FAIL(L"cannot get message color");
*pVal = (pEp_rating)_rating;
*pVal = (pEpRating)_rating;
return S_OK;
}
STDMETHODIMP CpEpEngine::color_from_rating(pEp_rating rating, pEp_color * pVal)
STDMETHODIMP CpEpEngine::ColorFromRating(pEpRating rating, pEpColor * pVal)
{
assert(pVal);
PEP_rating engineRating = (PEP_rating)rating;
PEP_color _color = ::color_from_rating(engineRating);
*pVal = (pEp_color)_color;
*pVal = (pEpColor)_color;
return S_OK;
}
STDMETHODIMP CpEpEngine::trust_personal_key(struct pEp_identity_s *ident, struct pEp_identity_s *result)
STDMETHODIMP CpEpEngine::TrustPersonalKey(struct pEpIdentity *ident, struct pEpIdentity *result)
{
::pEp_identity *_ident;
@ -1255,7 +1255,7 @@ STDMETHODIMP CpEpEngine::trust_personal_key(struct pEp_identity_s *ident, struct
if (verbose_mode) {
stringstream ss;
ss << "trust_personal_key called with ";
ss << "TrustPersonalKey called with ";
ss << utf8_string(ident->address);
ss << L": ";
ss << ident->comm_type;
@ -1282,7 +1282,7 @@ STDMETHODIMP CpEpEngine::trust_personal_key(struct pEp_identity_s *ident, struct
if (status == PEP_OUT_OF_MEMORY)
return E_OUTOFMEMORY;
else if (status != PEP_STATUS_OK)
return FAIL(L"failure while executing trust_personal_key()");
return FAIL(L"failure while executing TrustPersonalKey()");
return S_OK;
}
@ -1426,7 +1426,7 @@ void * CpEpEngine::retreive_next_sync_msg(void * management)
// Event callbacks
STDMETHODIMP CpEpEngine::register_callbacks(IpEpEngineCallbacks* new_callbacks)
STDMETHODIMP CpEpEngine::RegisterCallbacks(IpEpEngineCallbacks* new_callbacks)
{
callbacks cbs = get_callbacks();
vector<IpEpEngineCallbacks*>& vec = cbs;
@ -1438,7 +1438,7 @@ STDMETHODIMP CpEpEngine::register_callbacks(IpEpEngineCallbacks* new_callbacks)
return S_OK;
}
STDMETHODIMP CpEpEngine::unregister_callbacks(IpEpEngineCallbacks* obsolete_callbacks)
STDMETHODIMP CpEpEngine::UnregisterCallbacks(IpEpEngineCallbacks* obsolete_callbacks)
{
callbacks cbs = get_callbacks();
vector<IpEpEngineCallbacks*>& vec = cbs;
@ -1488,7 +1488,7 @@ STDMETHODIMP CpEpEngine::OpenPGP_list_keyinfo(BSTR search_pattern, LPSAFEARRAY*
}
HRESULT CpEpEngine::Fire_MessageToSend(text_message * msg)
HRESULT CpEpEngine::Fire_MessageToSend(TextMessage * msg)
{
callbacks cbs = get_callbacks();
vector<IpEpEngineCallbacks*>& vec = cbs;
@ -1504,7 +1504,7 @@ HRESULT CpEpEngine::Fire_MessageToSend(text_message * msg)
return S_OK;
}
HRESULT CpEpEngine::Fire_ShowHandshake(pEp_identity_s * self, pEp_identity_s * partner, sync_handshake_result_s * result)
HRESULT CpEpEngine::Fire_ShowHandshake(pEpIdentity * self, pEpIdentity * partner, SyncHandshakeResult * result)
{
callbacks cbs = get_callbacks();
vector<IpEpEngineCallbacks*>& vec = cbs;


+ 91
- 47
CpEpEngine.h View File

@ -4,13 +4,11 @@
#include "resource.h" // main symbols
#include "pEpComServerAdapter_i.h"
#include "_IpEpEngineEvents_CP.h"
#include "locked_queue.hh"
#include "utf8_helper.h"
#include "pEp_utility.h"
#include <queue>
#if defined(_WIN32_WCE) && !defined(_CE_DCOM) && !defined(_CE_ALLOW_SINGLE_THREADED_OBJECTS_IN_MTA)
#error "Single-threaded COM objects are not properly supported on Windows CE platform, such as the Windows Mobile platforms that do not include full DCOM support. Define _CE_ALLOW_SINGLE_THREADED_OBJECTS_IN_MTA to force ATL to support creating single-thread COM object's and allow use of it's single-threaded COM object implementations. The threading model in your rgs file was set to 'Free' as that is the only threading model supported in non DCOM Windows CE platforms."
#endif
@ -19,14 +17,64 @@ using namespace ATL;
using namespace utility;
using namespace pEp::utility;
// TODO: Remove this enum, it is not needed in the interface, but it currently is still used in the code which is
// not removed / reworked yet...
typedef enum pEpStatus {
pEpStatusOK = 0,
pEp_INIT_CANNOT_LOAD_GPGME = 0x0110,
pEp_INIT_GPGME_INIT_FAILED = 0x0111,
pEp_INIT_NO_GPG_HOME = 0x0112,
pEp_INIT_NETPGP_INIT_FAILED = 0x0113,
pEp_INIT_SQLITE3_WITHOUT_MUTEX = 0x0120,
pEp_INIT_CANNOT_OPEN_DB = 0x0121,
pEp_INIT_CANNOT_OPEN_SYSTEM_DB = 0x0122,
pEp_KEY_NOT_FOUND = 0x0201,
pEp_KEY_HAS_AMBIG_NAME = 0x0202,
pEp_GET_KEY_FAILED = 0x0203,
pEp_CANNOT_FIND_IDENTITY = 0x0301,
pEp_CANNOT_SET_PERSON = 0x0381,
pEp_CANNOT_SET_PGP_KEYPAIR = 0x0382,
pEp_CANNOT_SET_IDENTITY = 0x0383,
pEp_CANNOT_SET_TRUST = 0x0384,
pEp_UNENCRYPTED = 0x0400,
pEp_VERIFIED = 0x0401,
pEp_DECRYPTED = 0x0402,
pEp_DECRYPTED_AND_VERIFIED = 0x0403,
pEp_DECRYPT_WRONG_FORMAT = 0x0404,
pEp_DECRYPT_NO_KEY = 0x0405,
pEp_DECRYPT_SIGNATURE_DOES_NOT_MATCH = 0x0406,
pEp_VERIFY_NO_KEY = 0x0407,
pEp_VERIFIED_AND_TRUSTED = 0x0408,
pEp_CANNOT_DECRYPT_UNKNOWN = 0x04ff,
pEp_TRUSTWORD_NOT_FOUND = 0x0501,
pEp_CANNOT_CREATE_KEY = 0x0601,
pEp_CANNOT_SEND_KEY = 0x0602,
pEp_PHRASE_NOT_FOUND = 0x0701,
pEp_COMMIT_FAILED = 0xff01,
pEp_CANNOT_CREATE_TEMP_FILE = -5,
pEp_ILLEGAL_VALUE = -4,
pEp_BUFFER_TOO_SMALL = -3,
pEp_OUT_OF_MEMORY = -2,
pEp_UNKNOWN_ERROR = -1
} pEpStatus;
// CpEpEngine
class ATL_NO_VTABLE CpEpEngine :
public CComObjectRootEx<CComObjectThreadModel>,
public CComCoClass<CpEpEngine, &CLSID_pEpEngine>,
public ISupportErrorInfo,
public IConnectionPointContainerImpl<CpEpEngine>,
public CProxy_IpEpEngineEvents<CpEpEngine>,
public IpEpEngine
{
protected:
@ -45,7 +93,7 @@ public:
~CpEpEngine()
{
stop_keysync();
stop_keyserver_lookup();
StopKeyserverLookup();
::unregister_sync_callbacks(m_session);
::log_event(m_session, "Shutdown", "pEp COM Adapter", NULL, NULL);
::release(m_session);
@ -58,12 +106,8 @@ DECLARE_NOT_AGGREGATABLE(CpEpEngine)
BEGIN_COM_MAP(CpEpEngine)
COM_INTERFACE_ENTRY(IpEpEngine)
COM_INTERFACE_ENTRY(ISupportErrorInfo)
COM_INTERFACE_ENTRY(IConnectionPointContainer)
END_COM_MAP()
BEGIN_CONNECTION_POINT_MAP(CpEpEngine)
CONNECTION_POINT_ENTRY(__uuidof(_IpEpEngineEvents))
END_CONNECTION_POINT_MAP()
// ISupportsErrorInfo
STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid);
@ -181,25 +225,25 @@ private:
public:
// runtime config of the adapter
STDMETHOD(verbose_logging)(VARIANT_BOOL enable);
STDMETHOD(VerboseLogging)(VARIANT_BOOL enable);
// runtime config of the engine
STDMETHOD(passive_mode)(VARIANT_BOOL enable);
STDMETHOD(unencrypted_subject)(VARIANT_BOOL enable);
STDMETHOD(PassiveMode)(VARIANT_BOOL enable);
STDMETHOD(UnencryptedSubject)(VARIANT_BOOL enable);
// basic API
STDMETHOD(log)(BSTR title, BSTR entity, BSTR description, BSTR comment);
STDMETHOD(decrypt)(BSTR ctext, BSTR * ptext, LPSAFEARRAY * key_list, pEp_STATUS * decrypt_status);
STDMETHOD(decrypt_b)(BSTR ctext, LPSAFEARRAY * ptext, LPSAFEARRAY * key_list, pEp_STATUS * decrypt_status);
STDMETHOD(encrypt)(SAFEARRAY * key_list, BSTR ptext, BSTR * ctext, pEp_STATUS * status);
STDMETHOD(encrypt_b)(SAFEARRAY * key_list, SAFEARRAY * ptext, BSTR * ctext, pEp_STATUS * status);
STDMETHOD(decrypt)(BSTR ctext, BSTR * ptext, LPSAFEARRAY * key_list, pEpStatus * decrypt_status);
STDMETHOD(decrypt_b)(BSTR ctext, LPSAFEARRAY * ptext, LPSAFEARRAY * key_list, pEpStatus * decrypt_status);
STDMETHOD(encrypt)(SAFEARRAY * key_list, BSTR ptext, BSTR * ctext, pEpStatus * status);
STDMETHOD(encrypt_b)(SAFEARRAY * key_list, SAFEARRAY * ptext, BSTR * ctext, pEpStatus * status);
STDMETHOD(trustword)(LONG value, BSTR lang, BSTR * word);
STDMETHOD(trustwords)(BSTR fpr, BSTR lang, LONG max_words, BSTR * words);
STDMETHOD(get_identity)(BSTR address, BSTR user_id, pEp_identity_s * ident);
STDMETHOD(set_identity)(pEp_identity_s * ident);
STDMETHOD(generate_keypair)(pEp_identity_s * ident, BSTR * fpr);
STDMETHOD(TrustWords)(BSTR fpr, BSTR lang, LONG max_words, BSTR * words);
STDMETHOD(get_identity)(BSTR address, BSTR user_id, pEpIdentity * ident);
STDMETHOD(set_identity)(pEpIdentity * ident);
STDMETHOD(generate_keypair)(pEpIdentity * ident, BSTR * fpr);
STDMETHOD(delete_keypair)(BSTR fpr);
STDMETHOD(import_key)(BSTR key_data);
STDMETHOD(import_key_b)(SAFEARRAY * key_data);
@ -207,56 +251,56 @@ public:
STDMETHOD(recv_key)(BSTR pattern);
STDMETHOD(find_keys)(BSTR pattern, LPSAFEARRAY * key_list);
STDMETHOD(send_key)(BSTR pattern);
STDMETHOD(get_crashdump_log)(LONG maxlines, BSTR * log);
STDMETHOD(get_engine_version)(BSTR * engine_version);
STDMETHOD(get_languagelist)(BSTR * languages);
STDMETHOD(GetCrashdumpLog)(LONG maxlines, BSTR * log);
STDMETHOD(GetEngineVersion)(BSTR * engine_version);
STDMETHOD(GetLanguagelist)(BSTR * languages);
STDMETHOD(get_phrase)(BSTR lang, LONG phrase_id, BSTR * phrase);
// keymanagement API
STDMETHOD(start_keyserver_lookup)();
STDMETHOD(stop_keyserver_lookup)();
STDMETHOD(StartKeyserverLookup)();
STDMETHOD(StopKeyserverLookup)();
STDMETHOD(examine_identity)(pEp_identity_s * ident);
STDMETHOD(verify)(BSTR text, BSTR signature, LPSAFEARRAY * key_list, pEp_STATUS * verify_status);
STDMETHOD(myself)(struct pEp_identity_s *ident, struct pEp_identity_s *result);
STDMETHOD(update_identity)(struct pEp_identity_s *ident, struct pEp_identity_s *result);
STDMETHOD(key_mistrusted)(struct pEp_identity_s *ident);
STDMETHOD(key_reset_trust)(struct pEp_identity_s *ident);
STDMETHOD(trust_personal_key)(struct pEp_identity_s *ident, struct pEp_identity_s *result);
STDMETHOD(examine_identity)(pEpIdentity * ident);
STDMETHOD(verify)(BSTR text, BSTR signature, LPSAFEARRAY * key_list, pEpStatus * verify_status);
STDMETHOD(Myself)(struct pEpIdentity *ident, struct pEpIdentity *result);
STDMETHOD(UpdateIdentity)(struct pEpIdentity *ident, struct pEpIdentity *result);
STDMETHOD(KeyMistrusted)(struct pEpIdentity *ident);
STDMETHOD(KeyResetTrust)(struct pEpIdentity *ident);
STDMETHOD(TrustPersonalKey)(struct pEpIdentity *ident, struct pEpIdentity *result);
// Blacklist API
STDMETHOD(blacklist_add)(BSTR fpr);
STDMETHOD(blacklist_delete)(BSTR fpr);
STDMETHOD(blacklist_is_listed)(BSTR fpr, VARIANT_BOOL *listed);
STDMETHOD(blacklist_retrieve)(SAFEARRAY **blacklist);
STDMETHOD(BlacklistAdd)(BSTR fpr);
STDMETHOD(BlacklistDelete)(BSTR fpr);
STDMETHOD(BlacklistIsListed)(BSTR fpr, VARIANT_BOOL *listed);
STDMETHOD(BlacklistRetreive)(SAFEARRAY **blacklist);
// Message API
STDMETHOD(encrypt_message)(text_message * src, text_message * dst, SAFEARRAY * extra, pEpEncryptFlags flags);
STDMETHOD(decrypt_message)(text_message * src, text_message * dst, SAFEARRAY ** keylist, pEpDecryptFlags* flags, pEp_rating *rating);
STDMETHOD(outgoing_message_rating)(text_message *msg, pEp_rating * pVal);
STDMETHOD(identity_rating)(pEp_identity_s * ident, pEp_rating * pVal);
STDMETHOD(color_from_rating)(pEp_rating rating, pEp_color * pVal);
STDMETHOD(EncryptMessage)(TextMessage * src, TextMessage * dst, SAFEARRAY * extra, pEpEncryptFlags flags);
STDMETHOD(DecryptMessage)(TextMessage * src, TextMessage * dst, SAFEARRAY ** keylist, pEpDecryptFlags* flags, pEpRating *rating);
STDMETHOD(OutgoingMessageRating)(TextMessage *msg, pEpRating * pVal);
STDMETHOD(IdentityRating)(pEpIdentity * ident, pEpRating * pVal);
STDMETHOD(ColorFromRating)(pEpRating rating, pEpColor * pVal);
// Event callbacks
STDMETHOD(register_callbacks)(IpEpEngineCallbacks *new_callback);
STDMETHOD(unregister_callbacks)(IpEpEngineCallbacks *obsolete_callback);
STDMETHOD(RegisterCallbacks)(IpEpEngineCallbacks *new_callback);
STDMETHOD(UnregisterCallbacks)(IpEpEngineCallbacks *obsolete_callback);
// PGP compatibility functions
STDMETHOD(OpenPGP_list_keyinfo)(BSTR search_pattern, LPSAFEARRAY* keyinfo_list);
protected:
HRESULT Fire_MessageToSend(
/* [in] */ struct text_message *msg);
/* [in] */ struct TextMessage *msg);
HRESULT Fire_ShowHandshake(
/* [in] */ struct pEp_identity_s *self,
/* [in] */ struct pEp_identity_s *partner,
/* [retval][out] */ sync_handshake_result_s *result);
/* [in] */ struct pEpIdentity *self,
/* [in] */ struct pEpIdentity *partner,
/* [retval][out] */ SyncHandshakeResult *result);
};
OBJECT_ENTRY_AUTO(__uuidof(pEpEngine), CpEpEngine)

+ 0
- 40
_IpEpEngineEvents_CP.h View File

@ -1,40 +0,0 @@
#pragma once
template<class T>
class CProxy_IpEpEngineEvents :
public ATL::IConnectionPointImpl<T, &__uuidof(_IpEpEngineEvents)>
{
public:
/* Test code - remove before shipping
HRESULT Fire_TestEvent(LONG test, BSTR testtest)
{
HRESULT hr = S_OK;
T * pThis = static_cast<T *>(this);
int cConnections = m_vec.GetSize();
for (int iConnection = 0; iConnection < cConnections; iConnection++)
{
pThis->Lock();
CComPtr<IUnknown> punkConnection = m_vec.GetAt(iConnection);
pThis->Unlock();
IDispatch * pConnection = static_cast<IDispatch *>(punkConnection.p);
if (pConnection)
{
CComVariant avarParams[2];
avarParams[1] = test;
avarParams[1].vt = VT_I4;
avarParams[0] = testtest;
avarParams[0].vt = VT_BSTR;
CComVariant varResult;
DISPPARAMS params = { avarParams, NULL, 2, 0 };
hr = pConnection->Invoke(1, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &params, &varResult, NULL, NULL);
}
}
return hr;
}*/
};

+ 195
- 204
pEpCOMServerAdapter.idl View File

@ -7,29 +7,29 @@
import "oaidl.idl";
import "ocidl.idl";
typedef enum _sync_handshake_result_s {
SYNC_HANDSHAKE_CANCEL_S = -1,
SYNC_HANDSHAKE_ACCEPTED_S = 0,
SYNC_HANDSHAKE_REJECTED_S = 1
} sync_handshake_result_s;
[
object,
uuid(3BA1B15B-27EF-433C-B780-0D08F46B0FF3),
uuid(4DA92647-A858-448E-B01F-BE4DCB8C86A1),
oleautomation,
nonextensible,
pointer_default(unique)
]
interface IpEpEngineCallbacks : IUnknown {
[id(1)] HRESULT MessageToSend([in] struct text_message * msg);
[id(2)] HRESULT ShowHandshake([in] struct pEp_identity_s * self, [in] struct pEp_identity_s * partner, [out, retval] sync_handshake_result_s * result);
typedef [v1_enum] enum SyncHandshakeResult {
SyncHandshakeCancel = -1,
SyncHandshakeAccepted = 0,
SyncHandshakeRejected = 1
} SyncHandshakeResult;
[id(1)] HRESULT MessageToSend([in] struct TextMessage * msg);
[id(2)] HRESULT ShowHandshake([in] struct pEpIdentity * self, [in] struct pEpIdentity * partner, [out, retval] SyncHandshakeResult * result);
};
[
object,
uuid(9A9F4422-CF0A-45D7-90CD-1D1B7B2A4540),
uuid(045E49AF-0975-4876-A53B-8CA5AB28C0F8),
oleautomation,
nonextensible,
pointer_default(unique)
@ -37,202 +37,203 @@ interface IpEpEngineCallbacks : IUnknown {
interface IpEpEngine : IUnknown {
// runtime config of the adapter
HRESULT verbose_logging([in] VARIANT_BOOL enable);
HRESULT VerboseLogging([in] VARIANT_BOOL enable);
// runtime config of the engine
HRESULT passive_mode([in] VARIANT_BOOL enable);
HRESULT unencrypted_subject([in] VARIANT_BOOL enable);
HRESULT PassiveMode([in] VARIANT_BOOL enable);
HRESULT UnencryptedSubject([in] VARIANT_BOOL enable);
// basic API
typedef enum _pEp_STATUS {
pEp_STATUS_OK = 0,
pEp_INIT_CANNOT_LOAD_GPGME = 0x0110,
pEp_INIT_GPGME_INIT_FAILED = 0x0111,
pEp_INIT_NO_GPG_HOME = 0x0112,
pEp_INIT_NETPGP_INIT_FAILED = 0x0113,
pEp_INIT_SQLITE3_WITHOUT_MUTEX = 0x0120,
pEp_INIT_CANNOT_OPEN_DB = 0x0121,
pEp_INIT_CANNOT_OPEN_SYSTEM_DB = 0x0122,
pEp_KEY_NOT_FOUND = 0x0201,
pEp_KEY_HAS_AMBIG_NAME = 0x0202,
pEp_GET_KEY_FAILED = 0x0203,
pEp_CANNOT_FIND_IDENTITY = 0x0301,
pEp_CANNOT_SET_PERSON = 0x0381,
pEp_CANNOT_SET_PGP_KEYPAIR = 0x0382,
pEp_CANNOT_SET_IDENTITY = 0x0383,
pEp_CANNOT_SET_TRUST = 0x0384,
pEp_UNENCRYPTED = 0x0400,
pEp_VERIFIED = 0x0401,
pEp_DECRYPTED = 0x0402,
pEp_DECRYPTED_AND_VERIFIED = 0x0403,
pEp_DECRYPT_WRONG_FORMAT = 0x0404,
pEp_DECRYPT_NO_KEY = 0x0405,
pEp_DECRYPT_SIGNATURE_DOES_NOT_MATCH = 0x0406,
pEp_VERIFY_NO_KEY = 0x0407,
pEp_VERIFIED_AND_TRUSTED = 0x0408,
pEp_CANNOT_DECRYPT_UNKNOWN = 0x04ff,
pEp_TRUSTWORD_NOT_FOUND = 0x0501,
pEp_CANNOT_CREATE_KEY = 0x0601,
pEp_CANNOT_SEND_KEY = 0x0602,
pEp_PHRASE_NOT_FOUND = 0x0701,
pEp_COMMIT_FAILED = 0xff01,
pEp_CANNOT_CREATE_TEMP_FILE = -5,
pEp_ILLEGAL_VALUE = -4,
pEp_BUFFER_TOO_SMALL = -3,
pEp_OUT_OF_MEMORY = -2,
pEp_UNKNOWN_ERROR = -1
} pEp_STATUS;
HRESULT log([in] BSTR title, [in] BSTR entity, [in, defaultvalue("")] BSTR description, [in, defaultvalue("")] BSTR comment);
HRESULT decrypt([in] BSTR ctext, [out] BSTR * ptext, [out] SAFEARRAY(BSTR) * key_list, [out, retval] pEp_STATUS * decrypt_status);
HRESULT decrypt_b([in] BSTR ctext, [out] SAFEARRAY(BYTE) * ptext, [out] SAFEARRAY(BSTR) * key_list, [out, retval] pEp_STATUS * decrypt_status);
HRESULT encrypt([in] SAFEARRAY(BSTR) key_list, [in] BSTR ptext, [out] BSTR * ctext, [out, retval] pEp_STATUS * status);
HRESULT encrypt_b([in] SAFEARRAY(BSTR) key_list, [in] SAFEARRAY(BYTE) ptext, [out] BSTR * ctext, [out, retval] pEp_STATUS * status);
HRESULT verify([in] BSTR text, [in] BSTR signature, [out] SAFEARRAY(BSTR) * key_list, [out, retval] pEp_STATUS * verify_status);
HRESULT trustword([in] LONG value, [in, defaultvalue("en")] BSTR lang, [out, retval] BSTR * word);
HRESULT trustwords([in] BSTR fpr, [in, defaultvalue("en")] BSTR lang, [in, defaultvalue(0)] LONG max_words, [out, retval] BSTR * words);
HRESULT get_crashdump_log([in, defaultvalue(0)] LONG maxlines, [out, retval] BSTR * log);
HRESULT get_engine_version([out, retval] BSTR * engine_version);
HRESULT get_languagelist([out, retval] BSTR * languages);
HRESULT get_phrase([in] BSTR lang, [in] LONG phrase_id, [out, retval] BSTR * phrase);
typedef enum _pEp_comm_type {
pEp_ct_unknown = 0,
// // TODO: Remove this enum, it is not needed in the interface, but it currently is still used in the code...
//typedef [v1_enum] enum pEpStatus {
// pEpStatusOK = 0,
// pEp_INIT_CANNOT_LOAD_GPGME = 0x0110,
// pEp_INIT_GPGME_INIT_FAILED = 0x0111,
// pEp_INIT_NO_GPG_HOME = 0x0112,
// pEp_INIT_NETPGP_INIT_FAILED = 0x0113,
// pEp_INIT_SQLITE3_WITHOUT_MUTEX = 0x0120,
// pEp_INIT_CANNOT_OPEN_DB = 0x0121,
// pEp_INIT_CANNOT_OPEN_SYSTEM_DB = 0x0122,
// pEp_KEY_NOT_FOUND = 0x0201,
// pEp_KEY_HAS_AMBIG_NAME = 0x0202,
// pEp_GET_KEY_FAILED = 0x0203,
// pEp_CANNOT_FIND_IDENTITY = 0x0301,
// pEp_CANNOT_SET_PERSON = 0x0381,
// pEp_CANNOT_SET_PGP_KEYPAIR = 0x0382,
// pEp_CANNOT_SET_IDENTITY = 0x0383,
// pEp_CANNOT_SET_TRUST = 0x0384,
// pEp_UNENCRYPTED = 0x0400,
// pEp_VERIFIED = 0x0401,
// pEp_DECRYPTED = 0x0402,
// pEp_DECRYPTED_AND_VERIFIED = 0x0403,
// pEp_DECRYPT_WRONG_FORMAT = 0x0404,
// pEp_DECRYPT_NO_KEY = 0x0405,
// pEp_DECRYPT_SIGNATURE_DOES_NOT_MATCH = 0x0406,
// pEp_VERIFY_NO_KEY = 0x0407,
// pEp_VERIFIED_AND_TRUSTED = 0x0408,
// pEp_CANNOT_DECRYPT_UNKNOWN = 0x04ff,
// pEp_TRUSTWORD_NOT_FOUND = 0x0501,
// pEp_CANNOT_CREATE_KEY = 0x0601,
// pEp_CANNOT_SEND_KEY = 0x0602,
// pEp_PHRASE_NOT_FOUND = 0x0701,
// pEp_COMMIT_FAILED = 0xff01,
// pEp_CANNOT_CREATE_TEMP_FILE = -5,
// pEp_ILLEGAL_VALUE = -4,
// pEp_BUFFER_TOO_SMALL = -3,
// pEp_OUT_OF_MEMORY = -2,
// pEp_UNKNOWN_ERROR = -1
// } pEpStatus;
// HRESULT log([in] BSTR title, [in] BSTR entity, [in, defaultvalue("")] BSTR description, [in, defaultvalue("")] BSTR comment);
// HRESULT decrypt([in] BSTR ctext, [out] BSTR * ptext, [out] SAFEARRAY(BSTR) * key_list, [out, retval] pEpStatus * decrypt_status);
// HRESULT decrypt_b([in] BSTR ctext, [out] SAFEARRAY(BYTE) * ptext, [out] SAFEARRAY(BSTR) * key_list, [out, retval] pEpStatus * decrypt_status);
// HRESULT encrypt([in] SAFEARRAY(BSTR) key_list, [in] BSTR ptext, [out] BSTR * ctext, [out, retval] pEpStatus * status);
// HRESULT encrypt_b([in] SAFEARRAY(BSTR) key_list, [in] SAFEARRAY(BYTE) ptext, [out] BSTR * ctext, [out, retval] pEpStatus * status);
// HRESULT verify([in] BSTR text, [in] BSTR signature, [out] SAFEARRAY(BSTR) * key_list, [out, retval] pEpStatus * verify_status);
// HRESULT trustword([in] LONG value, [in, defaultvalue("en")] BSTR lang, [out, retval] BSTR * word);
HRESULT TrustWords([in] BSTR fpr, [in, defaultvalue("en")] BSTR lang, [in, defaultvalue(0)] LONG max_words, [out, retval] BSTR * words);
HRESULT GetCrashdumpLog([in, defaultvalue(0)] LONG maxlines, [out, retval] BSTR * log);
HRESULT GetEngineVersion([out, retval] BSTR * engine_version);
HRESULT GetLanguagelist([out, retval] BSTR * languages);
// HRESULT get_phrase([in] BSTR lang, [in] LONG phrase_id, [out, retval] BSTR * phrase);
typedef [v1_enum] enum pEpComType {
pEpCtUnknown = 0,
// range 0x01 to 0x09: no encryption, 0x0a to 0x0e: nothing reasonable
pEp_ct_no_encryption = 0x01, // generic
pEp_ct_no_encrypted_channel = 0x02,
pEp_ct_key_not_found = 0x03,
pEp_ct_key_expired = 0x04,
pEp_ct_key_revoked = 0x05,
pEp_ct_key_b0rken = 0x06,
pEp_ct_my_key_not_included = 0x09,
pEpCtNoEncryption = 0x01, // generic
pEpCtNoEncryptedChannel = 0x02,
pEpCtKeyNotFound = 0x03,
pEpCtKeyExpired = 0x04,
pEpCtKeyRevoked = 0x05,
pEpCtKeyB0rken = 0x06,
pEpCtMyKeyNotIncluded = 0x09,
pEp_ct_security_by_obscurity = 0x0a,
pEp_ct_b0rken_crypto = 0x0b,
pEp_ct_key_too_short = 0x0c,
pEpCtSecurityByObscurity = 0x0a,
pEpCtB0rkenCrypto = 0x0b,
pEpCtKeyTooShort = 0x0c,
pEp_ct_compromized = 0x0e, // known compromized connection
pEp_ct_mistrusted = 0x0f, // known mistrusted key
pEpCtCompromised = 0x0e, // known compromized connection
pEpCtMistrusted = 0x0f, // known mistrusted key
// range 0x10 to 0x3f: unconfirmed encryption
pEp_ct_unconfirmed_encryption = 0x10, // generic
pEp_ct_OpenPGP_weak_unconfirmed = 0x11, // RSA 1024 is weak
pEpCtUnconfirmedEncryption = 0x10, // generic
pEpCtOpenPGPWeakUnconfirmed = 0x11, // RSA 1024 is weak
pEp_ct_to_be_checked = 0x20, // generic
pEp_ct_SMIME_unconfirmed = 0x21,
pEp_ct_CMS_unconfirmed = 0x22,
pEpCtToBeChecked = 0x20, // generic
pEpCtSMIMEUnconfirmed = 0x21,
pEpCtCMSUnconfirmed = 0x22,
pEp_ct_strong_but_unconfirmed = 0x30, // generic
pEp_ct_OpenPGP_unconfirmed = 0x38, // key at least 2048 bit RSA or EC
pEp_ct_OTR_unconfirmed = 0x3a,
pEpCtStrongButUnconfirmed = 0x30, // generic
pEpCtOpenPGPUnconfirmed = 0x38, // key at least 2048 bit RSA or EC
pEpCtOTRUnconfirmed = 0x3a,
// range 0x40 to 0x7f: unconfirmed encryption and anonymization
pEp_ct_unconfirmed_enc_anon = 0x40, // generic
pEp_ct_pEp_unconfirmed = 0x7f,
pEpCtUnconfirmedEncAnon = 0x40, // generic
pEpCtpEpUnconfirmed = 0x7f,
pEp_ct_confirmed = 0x80, // this bit decides if trust is confirmed
pEpCtConfirmed = 0x80, // this bit decides if trust is confirmed
// range 0x81 to 0x8f: reserved
// range 0x90 to 0xbf: confirmed encryption
pEp_ct_confirmed_encryption = 0x90, // generic
pEp_ct_OpenPGP_weak = 0x91, // RSA 1024 is weak
pEpCtConfirmedEncryption = 0x90, // generic
pEpCtOpenPGPWeak = 0x91, // RSA 1024 is weak
pEp_ct_to_be_checked_confirmed = 0xa0, //generic
pEp_ct_SMIME = 0xa1,
pEp_ct_CMS = 0xa2,
pEpCtToBeCheckedConfirmed = 0xa0, //generic
pEpCtSMIME = 0xa1,
pEpCtCMS = 0xa2,
pEp_ct_strong_encryption = 0xb0, // generic
pEp_ct_OpenPGP = 0xb8, // key at least 2048 bit RSA or EC
pEp_ct_OTR = 0xba,
pEpCtStrongEncryption = 0xb0, // generic
pEpCtOpenPGP = 0xb8, // key at least 2048 bit RSA or EC
pEpCtOTR = 0xba,
// range 0xc0 to 0xff: confirmed encryption and anonymization
pEp_ct_confirmed_enc_anon = 0xc0, // generic
pEp_ct_pEp = 0xff
} pEp_comm_type;
pEpCtConfirmedEncAnon = 0xc0, // generic
pEpCtpEp = 0xff
} pEpComType;
[uuid(0CB90E62-8A6A-4CA0-99D7-481704051FF0)] struct pEp_identity_s {
[uuid(0CB90E62-8A6A-4CA0-99D7-481704051FF0)] struct pEpIdentity {
BSTR address;
BSTR fpr;
BSTR user_id;
BSTR username;
pEp_comm_type comm_type;
pEpComType comm_type;
BSTR lang;
};
HRESULT get_identity([in] BSTR address, [in] BSTR user_id, [out, retval] struct pEp_identity_s * ident);
HRESULT set_identity([in] struct pEp_identity_s * ident);
HRESULT generate_keypair([in] struct pEp_identity_s * ident, [out, retval] BSTR * fpr);
HRESULT delete_keypair([in] BSTR fpr);
HRESULT import_key([in] BSTR key_data);
HRESULT import_key_b([in] SAFEARRAY(BYTE) key_data);
HRESULT export_key([in] BSTR fpr, [out, retval] BSTR * key_data);
HRESULT recv_key([in] BSTR pattern);
HRESULT find_keys([in] BSTR pattern, [out, retval] SAFEARRAY(BSTR) * key_list);
HRESULT send_key([in] BSTR pattern);
HRESULT start_keyserver_lookup();
HRESULT stop_keyserver_lookup();
HRESULT examine_identity([in] struct pEp_identity_s * ident);
HRESULT myself([in] struct pEp_identity_s *ident, [out, retval] struct pEp_identity_s *result);
HRESULT update_identity([in] struct pEp_identity_s *ident, [out, retval] struct pEp_identity_s *result);
HRESULT key_mistrusted([in] struct pEp_identity_s *ident);
HRESULT key_reset_trust([in] struct pEp_identity_s *ident);
HRESULT trust_personal_key([in] struct pEp_identity_s *ident, [out, retval] struct pEp_identity_s *result);
//HRESULT get_identity([in] BSTR address, [in] BSTR user_id, [out, retval] struct pEpIdentity * ident);
//HRESULT set_identity([in] struct pEpIdentity * ident);
//HRESULT generate_keypair([in] struct pEpIdentity * ident, [out, retval] BSTR * fpr);
//HRESULT delete_keypair([in] BSTR fpr);
//HRESULT import_key([in] BSTR key_data);
//HRESULT import_key_b([in] SAFEARRAY(BYTE) key_data);
//HRESULT export_key([in] BSTR fpr, [out, retval] BSTR * key_data);
//HRESULT recv_key([in] BSTR pattern);
//HRESULT find_keys([in] BSTR pattern, [out, retval] SAFEARRAY(BSTR) * key_list);
//HRESULT send_key([in] BSTR pattern);
HRESULT StartKeyserverLookup();
HRESULT StopKeyserverLookup();
//HRESULT examine_identity([in] struct pEpIdentity * ident);
HRESULT Myself([in] struct pEpIdentity *ident, [out, retval] struct pEpIdentity *result);
HRESULT UpdateIdentity([in] struct pEpIdentity *ident, [out, retval] struct pEpIdentity *result);
HRESULT KeyMistrusted([in] struct pEpIdentity *ident);
HRESULT KeyResetTrust([in] struct pEpIdentity *ident);
HRESULT TrustPersonalKey([in] struct pEpIdentity *ident, [out, retval] struct pEpIdentity *result);
// Blacklist API
HRESULT blacklist_add([in] BSTR fpr);
HRESULT blacklist_delete([in] BSTR fpr);
HRESULT blacklist_is_listed([in] BSTR fpr, [out, retval] VARIANT_BOOL *listed);
HRESULT blacklist_retrieve([out, retval] SAFEARRAY(BSTR) *blacklist);
HRESULT BlacklistAdd([in] BSTR fpr);
HRESULT BlacklistDelete([in] BSTR fpr);
HRESULT BlacklistIsListed([in] BSTR fpr, [out, retval] VARIANT_BOOL *listed);
HRESULT BlacklistRetreive([out, retval] SAFEARRAY(BSTR) *blacklist);
// PGP compatibility functions
HRESULT OpenPGP_list_keyinfo([in] BSTR search_pattern, [out, retval] SAFEARRAY(struct StringPair)* keyinfo_list);
// Message API
typedef enum _pEp_rating {
pEp_rating_undefined = 0,
pEp_rating_cannot_decrypt,
pEp_rating_have_no_key,
pEp_rating_unencrypted,
pEp_rating_unencrypted_for_some,
pEp_rating_unreliable,
pEp_rating_reliable,
pEp_rating_trusted,
pEp_rating_trusted_and_anonymized,
pEp_rating_fully_anonymous,
pEp_rating_mistrust = -1,
pEp_rating_b0rken = -2,
pEp_rating_under_attack = -3
} pEp_rating;
typedef enum _pEp_color {
pEp_color_no_color = 0,
pEp_color_yellow,
pEp_color_green,
pEp_color_red = -1,
} pEp_color;
typedef [v1_enum] enum pEpRating {
pEpRatingUndefined = 0,
pEpRatingCannotDecrypt,
pEpRatingHaveNoKey,
pEpRatingUnencrypted,
pEpRatingUnencryptedForSome,
pEpRatingUnreliable,
pEpRatingReliable,
pEpRatingTrusted,
pEpRatingTrustedAndAnonymized,
pEpRatingFullyAnonymous,
pEpRatingMistrust = -1,
pEpRatingB0rken = -2,
pEpRatingUnderAttack = -3
} pEpRating;
typedef [v1_enum] enum pEpColor {
pEpColorNoColor = 0,
pEpColorYellow,
pEpColorGreen,
pEpColorRed = -1,
} pEpColor;
typedef [v1_enum] enum pEpEncryptFlags {
pEpEncryptFlagsNone = 0,
@ -244,84 +245,74 @@ interface IpEpEngine : IUnknown {
pEpDecryptFlagOwnPrivateKey = 0x1
} pEpDecryptFlags;
typedef enum _pEp_msg_direction {
pEp_dir_incoming = 0,
pEp_dir_outgoing
} pEp_msg_direction;
typedef [v1_enum] enum pEpMsgDirection {
pEpDirIncoming = 0,
pEpDirOutgoing
} pEpMsgDirection;
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
pEp_enc_PGP_MIME, // RFC3156
pEp_enc_pEp // pEp encryption format
} 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
// pEp_enc_PGP_MIME, // RFC3156
// pEp_enc_pEp // pEp encryption format
//} pEp_enc_format;
[uuid(3A8A4F13-3402-4C4C-94AB-598D87869380)] struct StringPair {
BSTR name;
BSTR value;
};
[uuid(61DA7AD4-192E-4616-8678-B19AEFB45B45)] struct blob {
[uuid(61DA7AD4-192E-4616-8678-B19AEFB45B45)] struct Blob {
SAFEARRAY(BYTE) value;
BSTR mime_type;
BSTR filename;
};
[uuid(D763A8F3-BA23-4229-A037-1BB7BDC3E0C8)] struct text_message {
pEp_msg_direction dir;
[uuid(D763A8F3-BA23-4229-A037-1BB7BDC3E0C8)] struct TextMessage {
pEpMsgDirection dir;
BSTR id;
BSTR shortmsg;
BSTR longmsg;
BSTR longmsg_formatted;
SAFEARRAY(struct blob) attachments;
hyper sent;
hyper recv;
struct pEp_identity_s from;
SAFEARRAY(struct pEp_identity_s) to;
struct pEp_identity_s recv_by;
SAFEARRAY(struct pEp_identity_s) cc;
SAFEARRAY(struct pEp_identity_s) bcc;
SAFEARRAY(struct pEp_identity_s) reply_to;
SAFEARRAY(struct Blob) attachments;
hyper sent; // Timestamp: 64 Bit time_t from mktime(), seconds since January 1, 1970, 0:00 UTC.
hyper recv; // Timestamp: 64 Bit time_t from mktime(), seconds since January 1, 1970, 0:00 UTC.
struct pEpIdentity from;
SAFEARRAY(struct pEpIdentity) to;
struct pEpIdentity recv_by;
SAFEARRAY(struct pEpIdentity) cc;
SAFEARRAY(struct pEpIdentity) bcc;
SAFEARRAY(struct pEpIdentity) reply_to;
SAFEARRAY(BSTR) references;
SAFEARRAY(BSTR) keywords;
BSTR comments;
SAFEARRAY(struct StringPair) opt_fields;
};
HRESULT encrypt_message([in] struct text_message *src, [out] struct text_message * dst, [in] SAFEARRAY(BSTR) extra, [in, defaultvalue(pEpEncryptFlagsNone)] pEpEncryptFlags flags);
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);
HRESULT outgoing_message_rating([in] struct text_message *msg, [out, retval] pEp_rating * pVal);
HRESULT identity_rating([in] struct pEp_identity_s * ident, [out, retval] pEp_rating * pVal);
HRESULT color_from_rating([in] pEp_rating rating, [out, retval] pEp_color* pVal);
HRESULT EncryptMessage([in] struct TextMessage *src, [out] struct TextMessage * dst, [in] SAFEARRAY(BSTR) extra, [in, defaultvalue(pEpEncryptFlagsNone)] pEpEncryptFlags flags);
HRESULT DecryptMessage([in] struct TextMessage *src, [out] struct TextMessage * dst, [out] SAFEARRAY(BSTR) *keylist, [out] pEpDecryptFlags* flags, [out, retval] pEpRating *rating);
HRESULT OutgoingMessageRating([in] struct TextMessage *msg, [out, retval] pEpRating * pVal);
HRESULT IdentityRating([in] struct pEpIdentity * ident, [out, retval] pEpRating * pVal);
HRESULT ColorFromRating([in] pEpRating rating, [out, retval] pEpColor* pVal);
HRESULT register_callbacks([in] IpEpEngineCallbacks* new_callback);
HRESULT RegisterCallbacks([in] IpEpEngineCallbacks* new_callback);
HRESULT unregister_callbacks([in] IpEpEngineCallbacks* obsolete_callback);
HRESULT UnregisterCallbacks([in] IpEpEngineCallbacks* obsolete_callback);
};
[
uuid(3EC2E1A4-40E8-48E4-A7B0-1876D34F9462),
uuid(564A4350-419E-47F1-B0DF-6FCCF0CD0BBC),
version(1.0),
]
library pEpCOMServerAdapterLib
{
importlib("stdole2.tlb");
[
uuid(B6BC9B8E-D9E2-4419-A3A4-7B4B58175549)
]
dispinterface _IpEpEngineEvents
{
properties:
methods:
// test code - remove before shipping
// [id(1)] HRESULT TestEvent([in] LONG test,[in] BSTR testtest);
};
[
uuid(EF1B073D-5058-4E0E-829E-B4D22CA21EA2)
uuid(5FF6682B-727B-4DFE-A68D-28982874C0C7)
]
coclass pEpEngine {
[default] interface IpEpEngine;
[default, source] dispinterface _IpEpEngineEvents;
};
};

+ 1
- 0
pEpCOMServerAdapter.vcxproj View File

@ -169,6 +169,7 @@ xcopy /y "..\Dependencies\zlib\zlib1.dll" "$(OutDir)"
<ResourceCompile Include="pEpCOMServerAdapter.rc" />
</ItemGroup>
<ItemGroup>
<Text Include="LICENSE.txt" />
<Text Include="ReadMe.txt" />
</ItemGroup>
<ItemGroup>


+ 1
- 0
pEpCOMServerAdapter.vcxproj.filters View File

@ -86,6 +86,7 @@
</ItemGroup>
<ItemGroup>
<Text Include="ReadMe.txt" />
<Text Include="LICENSE.txt" />
</ItemGroup>
<ItemGroup>
<None Include="pEpCOMServerAdapter.rgs">


+ 35
- 35
pEp_utility.cpp View File

@ -16,11 +16,11 @@ namespace pEp {
user_id = _ident->user_id;
if (_ident->username)
username = _ident->username;
comm_type = (pEp_comm_type) _ident->comm_type;
comm_type = (pEpComType) _ident->comm_type;
lang = _ident->lang;
}
pEp_identity_cpp::pEp_identity_cpp(const pEp_identity_s *_ident)
pEp_identity_cpp::pEp_identity_cpp(const pEpIdentity *_ident)
: me(false)
{
if (_ident->address)
@ -56,9 +56,9 @@ namespace pEp {
return _ident;
}
pEp_identity_s * pEp_identity_cpp::to_pEp_identity_s()
pEpIdentity * pEp_identity_cpp::to_pEp_identity_s()
{
pEp_identity_s *_ident = (pEp_identity_s *) calloc(1, sizeof(pEp_identity_s));
pEpIdentity *_ident = (pEpIdentity *) calloc(1, sizeof(pEpIdentity));
assert(_ident);
if (_ident == NULL)
throw bad_alloc();
@ -73,11 +73,11 @@ namespace pEp {
return _ident;
}
void copy_identity(pEp_identity_s * ident_s, const pEp_identity * ident)
void copy_identity(pEpIdentity * ident_s, const pEp_identity * ident)
{
assert(ident_s);
::memset(ident_s, 0, sizeof(pEp_identity_s));
::memset(ident_s, 0, sizeof(pEpIdentity));
if (ident) {
if (ident->address)
ident_s->address = utf16_bstr(ident->address);
@ -87,13 +87,13 @@ namespace pEp {
ident_s->user_id = utf16_bstr(ident->user_id);
if (ident->username)
ident_s->username = utf16_bstr(ident->username);
ident_s->comm_type = (pEp_comm_type) ident->comm_type;
ident_s->comm_type = (pEpComType) ident->comm_type;
if (ident->lang)
ident_s->lang = utf16_bstr(ident->lang);
}
}
::pEp_identity *new_identity(const pEp_identity_s * ident)
::pEp_identity *new_identity(const pEpIdentity * ident)
{
if (ident == NULL)
return NULL;
@ -162,7 +162,7 @@ namespace pEp {
return utf16_bstr(s);
}
template<> blob *from_C< blob *, bloblist_t >(bloblist_t *tl)
template<> Blob *from_C< Blob *, bloblist_t >(bloblist_t *tl)
{
CComSafeArray<BYTE> sa;
sa.Create(tl->size);
@ -174,7 +174,7 @@ namespace pEp {
SafeArrayUnaccessData(sa);
}
blob *_blob = new blob();
Blob *_blob = new Blob();
_blob->value = sa.Detach();
_blob->mime_type = bstr(tl->mime_type);
@ -204,7 +204,7 @@ namespace pEp {
return sa;
}
void clear_identity_s(pEp_identity_s& ident)
void clear_identity_s(pEpIdentity& ident)
{
SysFreeString(ident.address);
SysFreeString(ident.fpr);
@ -212,12 +212,12 @@ namespace pEp {
SysFreeString(ident.username);
SysFreeString(ident.user_id);
memset(&ident, 0, sizeof(pEp_identity_s));
memset(&ident, 0, sizeof(pEpIdentity));
}
template<> pEp_identity_s from_C< pEp_identity_s, pEp_identity >(pEp_identity *tl)
template<> pEpIdentity from_C< pEpIdentity, pEp_identity >(pEp_identity *tl)
{
pEp_identity_s _ident;
pEpIdentity _ident;
memset(&_ident, 0, sizeof(_ident));
if (tl)
@ -225,15 +225,15 @@ namespace pEp {
return _ident;
}
pEp_identity_s identity_s(pEp_identity *ident)
pEpIdentity identity_s(pEp_identity *ident)
{
return from_C< pEp_identity_s, pEp_identity >(ident);
return from_C< pEpIdentity, pEp_identity >(ident);
}
template<> pEp_identity_s *from_C< pEp_identity_s *, identity_list >(identity_list *il)
template<> pEpIdentity *from_C< pEpIdentity *, identity_list >(identity_list *il)
{
pEp_identity_s *ident = new pEp_identity_s();
memset(ident, 0, sizeof(pEp_identity_s));
pEpIdentity *ident = new pEpIdentity();
memset(ident, 0, sizeof(pEpIdentity));
if (il)
copy_identity(ident, il->ident);
@ -265,7 +265,7 @@ namespace pEp {
return stringpair_list_length(tl);
}
void clear_text_message(text_message *msg)
void clear_text_message(TextMessage *msg)
{
SysFreeString(msg->id);
SysFreeString(msg->shortmsg);
@ -283,32 +283,32 @@ namespace pEp {
SysFreeString(msg->comments);
SafeArrayDestroy(msg->opt_fields);
memset(msg, 0, sizeof(text_message));
memset(msg, 0, sizeof(TextMessage));
}
void text_message_from_C(text_message *msg2, const ::message *msg)
void text_message_from_C(TextMessage *msg2, const ::message *msg)
{
assert(msg2);
assert(msg);
clear_text_message(msg2);
msg2->dir = (pEp_msg_direction) msg->dir;
msg2->dir = (pEpMsgDirection) msg->dir;
msg2->id = bstr(msg->id);
msg2->shortmsg = bstr(msg->shortmsg);
msg2->longmsg = bstr(msg->longmsg);
msg2->longmsg_formatted = bstr(msg->longmsg_formatted);
msg2->attachments = array_from_C<blob, bloblist_t>(msg->attachments);
msg2->attachments = array_from_C<Blob, bloblist_t>(msg->attachments);
if (msg->sent)
msg2->sent = mktime(msg->sent);
if (msg->recv)
msg2->recv = mktime(msg->recv);
msg2->from = identity_s(msg->from);
msg2->to = array_from_C<pEp_identity_s, identity_list>(msg->to);
msg2->to = array_from_C<pEpIdentity, identity_list>(msg->to);
msg2->recv_by = identity_s(msg->recv_by);
msg2->cc = array_from_C<pEp_identity_s, identity_list>(msg->cc);
msg2->bcc = array_from_C<pEp_identity_s, identity_list>(msg->bcc);
msg2->reply_to = array_from_C<pEp_identity_s, identity_list>(msg->reply_to);
msg2->cc = array_from_C<pEpIdentity, identity_list>(msg->cc);
msg2->bcc = array_from_C<pEpIdentity, identity_list>(msg->bcc);
msg2->reply_to = array_from_C<pEpIdentity, identity_list>(msg->reply_to);
msg2->references = string_array(msg->references);
msg2->keywords = string_array(msg->keywords);
msg2->comments = bstr(msg->comments);
@ -325,12 +325,12 @@ namespace pEp {
return _s;
}
void clear_blob(blob& b)
void clear_blob(Blob& b)
{
SysFreeString(b.filename);
SysFreeString(b.mime_type);
SafeArrayDestroy(b.value);
memset(&b, 0, sizeof(blob));
memset(&b, 0, sizeof(Blob));
}
bloblist_t *bloblist(SAFEARRAY *sa)
@ -352,8 +352,8 @@ namespace pEp {
bloblist_t *_bl = bl;
for (LONG i = lbound; i <= ubound; i++) {
blob b;
memset(&b, 0, sizeof(blob));
Blob b;
memset(&b, 0, sizeof(Blob));
SafeArrayGetElement(sa, &i, &b);
LONG _lbound, _ubound;