CpEpEngine.h
branchkeysync
changeset 172 112b0fac353d
parent 169 d776268c12a7
child 175 9aabb2c9df08
     1.1 --- a/CpEpEngine.h	Mon Oct 03 19:15:35 2016 +0200
     1.2 +++ b/CpEpEngine.h	Mon Oct 03 22:06:35 2016 +0200
     1.3 @@ -4,13 +4,11 @@
     1.4  #include "resource.h"       // main symbols
     1.5  
     1.6  #include "pEpComServerAdapter_i.h"
     1.7 -#include "_IpEpEngineEvents_CP.h"
     1.8  #include "locked_queue.hh"
     1.9  #include "utf8_helper.h"
    1.10  #include "pEp_utility.h"
    1.11  #include <queue>
    1.12  
    1.13 -
    1.14  #if defined(_WIN32_WCE) && !defined(_CE_DCOM) && !defined(_CE_ALLOW_SINGLE_THREADED_OBJECTS_IN_MTA)
    1.15  #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."
    1.16  #endif
    1.17 @@ -19,14 +17,64 @@
    1.18  using namespace utility;
    1.19  using namespace pEp::utility;
    1.20  
    1.21 +
    1.22 +// TODO: Remove this enum, it is not needed in the interface, but it currently is still used in the code which is
    1.23 +// not removed / reworked yet...
    1.24 +typedef enum pEpStatus {
    1.25 +     pEpStatusOK = 0,
    1.26 +
    1.27 +     pEp_INIT_CANNOT_LOAD_GPGME = 0x0110,
    1.28 +     pEp_INIT_GPGME_INIT_FAILED = 0x0111,
    1.29 +     pEp_INIT_NO_GPG_HOME = 0x0112,
    1.30 +     pEp_INIT_NETPGP_INIT_FAILED = 0x0113,
    1.31 +
    1.32 +     pEp_INIT_SQLITE3_WITHOUT_MUTEX = 0x0120,
    1.33 +     pEp_INIT_CANNOT_OPEN_DB = 0x0121,
    1.34 +     pEp_INIT_CANNOT_OPEN_SYSTEM_DB = 0x0122,
    1.35 +
    1.36 +     pEp_KEY_NOT_FOUND = 0x0201,
    1.37 +     pEp_KEY_HAS_AMBIG_NAME = 0x0202,
    1.38 +     pEp_GET_KEY_FAILED = 0x0203,
    1.39 +
    1.40 +     pEp_CANNOT_FIND_IDENTITY = 0x0301,
    1.41 +     pEp_CANNOT_SET_PERSON = 0x0381,
    1.42 +     pEp_CANNOT_SET_PGP_KEYPAIR = 0x0382,
    1.43 +     pEp_CANNOT_SET_IDENTITY = 0x0383,
    1.44 +     pEp_CANNOT_SET_TRUST = 0x0384,
    1.45 +
    1.46 +     pEp_UNENCRYPTED = 0x0400,
    1.47 +     pEp_VERIFIED = 0x0401,
    1.48 +     pEp_DECRYPTED = 0x0402,
    1.49 +     pEp_DECRYPTED_AND_VERIFIED = 0x0403,
    1.50 +     pEp_DECRYPT_WRONG_FORMAT = 0x0404,
    1.51 +     pEp_DECRYPT_NO_KEY = 0x0405,
    1.52 +     pEp_DECRYPT_SIGNATURE_DOES_NOT_MATCH = 0x0406,
    1.53 +     pEp_VERIFY_NO_KEY = 0x0407,
    1.54 +     pEp_VERIFIED_AND_TRUSTED = 0x0408,
    1.55 +     pEp_CANNOT_DECRYPT_UNKNOWN = 0x04ff,
    1.56 +
    1.57 +     pEp_TRUSTWORD_NOT_FOUND = 0x0501,
    1.58 +
    1.59 +     pEp_CANNOT_CREATE_KEY = 0x0601,
    1.60 +     pEp_CANNOT_SEND_KEY = 0x0602,
    1.61 +
    1.62 +     pEp_PHRASE_NOT_FOUND = 0x0701,
    1.63 +
    1.64 +     pEp_COMMIT_FAILED = 0xff01,
    1.65 +
    1.66 +     pEp_CANNOT_CREATE_TEMP_FILE = -5,
    1.67 +     pEp_ILLEGAL_VALUE = -4,
    1.68 +     pEp_BUFFER_TOO_SMALL = -3,
    1.69 +     pEp_OUT_OF_MEMORY = -2,
    1.70 +     pEp_UNKNOWN_ERROR = -1
    1.71 + } pEpStatus;
    1.72 +
    1.73  // CpEpEngine
    1.74  
    1.75  class ATL_NO_VTABLE CpEpEngine :
    1.76      public CComObjectRootEx<CComObjectThreadModel>,
    1.77  	public CComCoClass<CpEpEngine, &CLSID_pEpEngine>,
    1.78  	public ISupportErrorInfo,
    1.79 -	public IConnectionPointContainerImpl<CpEpEngine>,
    1.80 -	public CProxy_IpEpEngineEvents<CpEpEngine>,
    1.81  	public IpEpEngine
    1.82  {
    1.83  protected:
    1.84 @@ -45,7 +93,7 @@
    1.85      ~CpEpEngine()
    1.86      {
    1.87          stop_keysync();
    1.88 -        stop_keyserver_lookup();
    1.89 +        StopKeyserverLookup();
    1.90          ::unregister_sync_callbacks(m_session);
    1.91          ::log_event(m_session, "Shutdown", "pEp COM Adapter", NULL, NULL);
    1.92          ::release(m_session);
    1.93 @@ -58,12 +106,8 @@
    1.94  BEGIN_COM_MAP(CpEpEngine)
    1.95      COM_INTERFACE_ENTRY(IpEpEngine)
    1.96      COM_INTERFACE_ENTRY(ISupportErrorInfo)
    1.97 -    COM_INTERFACE_ENTRY(IConnectionPointContainer)
    1.98  END_COM_MAP()
    1.99  
   1.100 -BEGIN_CONNECTION_POINT_MAP(CpEpEngine)
   1.101 -	CONNECTION_POINT_ENTRY(__uuidof(_IpEpEngineEvents))
   1.102 -END_CONNECTION_POINT_MAP()
   1.103  // ISupportsErrorInfo
   1.104  	STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid);
   1.105  
   1.106 @@ -181,25 +225,25 @@
   1.107  public:
   1.108      // runtime config of the adapter
   1.109  
   1.110 -    STDMETHOD(verbose_logging)(VARIANT_BOOL enable);
   1.111 +    STDMETHOD(VerboseLogging)(VARIANT_BOOL enable);
   1.112  
   1.113      // runtime config of the engine
   1.114  
   1.115 -    STDMETHOD(passive_mode)(VARIANT_BOOL enable);
   1.116 -    STDMETHOD(unencrypted_subject)(VARIANT_BOOL enable);
   1.117 +    STDMETHOD(PassiveMode)(VARIANT_BOOL enable);
   1.118 +    STDMETHOD(UnencryptedSubject)(VARIANT_BOOL enable);
   1.119  
   1.120      // basic API
   1.121  
   1.122      STDMETHOD(log)(BSTR title, BSTR entity, BSTR description, BSTR comment);
   1.123 -    STDMETHOD(decrypt)(BSTR ctext, BSTR * ptext, LPSAFEARRAY * key_list, pEp_STATUS * decrypt_status);
   1.124 -    STDMETHOD(decrypt_b)(BSTR ctext, LPSAFEARRAY * ptext, LPSAFEARRAY * key_list, pEp_STATUS * decrypt_status);
   1.125 -    STDMETHOD(encrypt)(SAFEARRAY * key_list, BSTR ptext, BSTR * ctext, pEp_STATUS * status);
   1.126 -    STDMETHOD(encrypt_b)(SAFEARRAY * key_list, SAFEARRAY * ptext, BSTR * ctext, pEp_STATUS * status);
   1.127 +    STDMETHOD(decrypt)(BSTR ctext, BSTR * ptext, LPSAFEARRAY * key_list, pEpStatus * decrypt_status);
   1.128 +    STDMETHOD(decrypt_b)(BSTR ctext, LPSAFEARRAY * ptext, LPSAFEARRAY * key_list, pEpStatus * decrypt_status);
   1.129 +    STDMETHOD(encrypt)(SAFEARRAY * key_list, BSTR ptext, BSTR * ctext, pEpStatus * status);
   1.130 +    STDMETHOD(encrypt_b)(SAFEARRAY * key_list, SAFEARRAY * ptext, BSTR * ctext, pEpStatus * status);
   1.131      STDMETHOD(trustword)(LONG value, BSTR lang, BSTR * word);
   1.132 -    STDMETHOD(trustwords)(BSTR fpr, BSTR lang, LONG max_words, BSTR * words);
   1.133 -    STDMETHOD(get_identity)(BSTR address, BSTR user_id, pEp_identity_s * ident);
   1.134 -    STDMETHOD(set_identity)(pEp_identity_s * ident);
   1.135 -    STDMETHOD(generate_keypair)(pEp_identity_s * ident, BSTR * fpr);
   1.136 +    STDMETHOD(TrustWords)(BSTR fpr, BSTR lang, LONG max_words, BSTR * words);
   1.137 +    STDMETHOD(get_identity)(BSTR address, BSTR user_id, pEpIdentity * ident);
   1.138 +    STDMETHOD(set_identity)(pEpIdentity * ident);
   1.139 +    STDMETHOD(generate_keypair)(pEpIdentity * ident, BSTR * fpr);
   1.140      STDMETHOD(delete_keypair)(BSTR fpr);
   1.141      STDMETHOD(import_key)(BSTR key_data);
   1.142      STDMETHOD(import_key_b)(SAFEARRAY * key_data);
   1.143 @@ -207,56 +251,56 @@
   1.144      STDMETHOD(recv_key)(BSTR pattern);
   1.145      STDMETHOD(find_keys)(BSTR pattern, LPSAFEARRAY * key_list);
   1.146      STDMETHOD(send_key)(BSTR pattern);
   1.147 -    STDMETHOD(get_crashdump_log)(LONG maxlines, BSTR * log);
   1.148 -    STDMETHOD(get_engine_version)(BSTR * engine_version);
   1.149 -    STDMETHOD(get_languagelist)(BSTR * languages);
   1.150 +    STDMETHOD(GetCrashdumpLog)(LONG maxlines, BSTR * log);
   1.151 +    STDMETHOD(GetEngineVersion)(BSTR * engine_version);
   1.152 +    STDMETHOD(GetLanguagelist)(BSTR * languages);
   1.153      STDMETHOD(get_phrase)(BSTR lang, LONG phrase_id, BSTR * phrase);
   1.154  
   1.155      // keymanagement API
   1.156  
   1.157 -    STDMETHOD(start_keyserver_lookup)();
   1.158 -    STDMETHOD(stop_keyserver_lookup)();
   1.159 +    STDMETHOD(StartKeyserverLookup)();
   1.160 +    STDMETHOD(StopKeyserverLookup)();
   1.161  
   1.162 -    STDMETHOD(examine_identity)(pEp_identity_s * ident);
   1.163 -    STDMETHOD(verify)(BSTR text, BSTR signature, LPSAFEARRAY * key_list, pEp_STATUS * verify_status);
   1.164 -    STDMETHOD(myself)(struct pEp_identity_s *ident, struct pEp_identity_s *result);
   1.165 -    STDMETHOD(update_identity)(struct pEp_identity_s *ident, struct pEp_identity_s *result);
   1.166 -    STDMETHOD(key_mistrusted)(struct pEp_identity_s *ident);
   1.167 -    STDMETHOD(key_reset_trust)(struct pEp_identity_s *ident);
   1.168 -    STDMETHOD(trust_personal_key)(struct pEp_identity_s *ident, struct pEp_identity_s *result);
   1.169 +    STDMETHOD(examine_identity)(pEpIdentity * ident);
   1.170 +    STDMETHOD(verify)(BSTR text, BSTR signature, LPSAFEARRAY * key_list, pEpStatus * verify_status);
   1.171 +    STDMETHOD(Myself)(struct pEpIdentity *ident, struct pEpIdentity *result);
   1.172 +    STDMETHOD(UpdateIdentity)(struct pEpIdentity *ident, struct pEpIdentity *result);
   1.173 +    STDMETHOD(KeyMistrusted)(struct pEpIdentity *ident);
   1.174 +    STDMETHOD(KeyResetTrust)(struct pEpIdentity *ident);
   1.175 +    STDMETHOD(TrustPersonalKey)(struct pEpIdentity *ident, struct pEpIdentity *result);
   1.176  
   1.177  
   1.178      // Blacklist API
   1.179  
   1.180 -    STDMETHOD(blacklist_add)(BSTR fpr);
   1.181 -    STDMETHOD(blacklist_delete)(BSTR fpr);
   1.182 -    STDMETHOD(blacklist_is_listed)(BSTR fpr, VARIANT_BOOL *listed);
   1.183 -    STDMETHOD(blacklist_retrieve)(SAFEARRAY **blacklist);
   1.184 +    STDMETHOD(BlacklistAdd)(BSTR fpr);
   1.185 +    STDMETHOD(BlacklistDelete)(BSTR fpr);
   1.186 +    STDMETHOD(BlacklistIsListed)(BSTR fpr, VARIANT_BOOL *listed);
   1.187 +    STDMETHOD(BlacklistRetreive)(SAFEARRAY **blacklist);
   1.188  
   1.189      // Message API
   1.190  
   1.191 -    STDMETHOD(encrypt_message)(text_message * src, text_message * dst, SAFEARRAY * extra, pEpEncryptFlags flags);
   1.192 -    STDMETHOD(decrypt_message)(text_message * src, text_message * dst, SAFEARRAY ** keylist, pEpDecryptFlags* flags, pEp_rating *rating);
   1.193 -    STDMETHOD(outgoing_message_rating)(text_message *msg, pEp_rating * pVal);
   1.194 -    STDMETHOD(identity_rating)(pEp_identity_s * ident, pEp_rating * pVal);
   1.195 -	STDMETHOD(color_from_rating)(pEp_rating rating, pEp_color * pVal);
   1.196 +    STDMETHOD(EncryptMessage)(TextMessage * src, TextMessage * dst, SAFEARRAY * extra, pEpEncryptFlags flags);
   1.197 +    STDMETHOD(DecryptMessage)(TextMessage * src, TextMessage * dst, SAFEARRAY ** keylist, pEpDecryptFlags* flags, pEpRating *rating);
   1.198 +    STDMETHOD(OutgoingMessageRating)(TextMessage *msg, pEpRating * pVal);
   1.199 +    STDMETHOD(IdentityRating)(pEpIdentity * ident, pEpRating * pVal);
   1.200 +	STDMETHOD(ColorFromRating)(pEpRating rating, pEpColor * pVal);
   1.201  
   1.202  	// Event callbacks
   1.203  
   1.204 -	STDMETHOD(register_callbacks)(IpEpEngineCallbacks *new_callback);
   1.205 -	STDMETHOD(unregister_callbacks)(IpEpEngineCallbacks *obsolete_callback);
   1.206 +	STDMETHOD(RegisterCallbacks)(IpEpEngineCallbacks *new_callback);
   1.207 +	STDMETHOD(UnregisterCallbacks)(IpEpEngineCallbacks *obsolete_callback);
   1.208  
   1.209      // PGP compatibility functions
   1.210      STDMETHOD(OpenPGP_list_keyinfo)(BSTR search_pattern, LPSAFEARRAY* keyinfo_list);
   1.211  
   1.212  protected:
   1.213  	HRESULT Fire_MessageToSend(
   1.214 -		/* [in] */ struct text_message *msg);
   1.215 +		/* [in] */ struct TextMessage *msg);
   1.216  
   1.217  	HRESULT Fire_ShowHandshake(
   1.218 -		/* [in] */ struct pEp_identity_s *self,
   1.219 -		/* [in] */ struct pEp_identity_s *partner,
   1.220 -		/* [retval][out] */ sync_handshake_result_s *result);
   1.221 +		/* [in] */ struct pEpIdentity *self,
   1.222 +		/* [in] */ struct pEpIdentity *partner,
   1.223 +		/* [retval][out] */ SyncHandshakeResult *result);
   1.224  };
   1.225  
   1.226  OBJECT_ENTRY_AUTO(__uuidof(pEpEngine), CpEpEngine)