Merge with COM-74
authorMarkus Schaber <markus@pep-security.net>
Wed, 07 Feb 2018 20:23:32 +0100
changeset 27330be98685afa
parent 269 26c8597fe860
parent 272 0cd9b4cde17c
child 274 b4f390f0a123
Merge with COM-74
CpEpEngine.cpp
CpEpEngine.h
pEpCOMServerAdapter.idl
     1.1 --- a/CpEpEngine.cpp	Fri Feb 02 22:03:16 2018 +0100
     1.2 +++ b/CpEpEngine.cpp	Wed Feb 07 20:23:32 2018 +0100
     1.3 @@ -19,7 +19,6 @@
     1.4      static const IID* const arr[] =
     1.5      {
     1.6          &IID_IpEpEngine,
     1.7 -        &IID_IpEpEngine2,
     1.8      };
     1.9  
    1.10      for (int i = 0; i < sizeof(arr) / sizeof(arr[0]); i++)
    1.11 @@ -552,12 +551,11 @@
    1.12      PEP_STATUS status = ::update_identity(get_session(), _ident);
    1.13  
    1.14      if (status == PEP_STATUS_OK) {
    1.15 -        assert(_ident->fpr); // Guaranteed not NULL, but possibly empty string.
    1.16          copy_identity(result, _ident);
    1.17          ::free_identity(_ident);
    1.18          return S_OK;
    1.19      }
    1.20 -    else if (status == PEP_GET_KEY_FAILED) {
    1.21 +    else if (status == PEP_GET_KEY_FAILED || status == PEP_KEY_NOT_FOUND) {
    1.22          if (_ident->fpr) {
    1.23              pEp_free(_ident->fpr);
    1.24              _ident->fpr = NULL;
    1.25 @@ -833,7 +831,7 @@
    1.26      return MAKE_HRESULT(1, FACILITY_ITF, (0xFFFF & status));
    1.27  }
    1.28  
    1.29 -STDMETHODIMP CpEpEngine::EncryptMessage(TextMessage * src, TextMessage * dst, SAFEARRAY * extra, pEpEncryptFlags flags)
    1.30 +STDMETHODIMP CpEpEngine::EncryptMessage(TextMessage * src, TextMessage * dst, SAFEARRAY * extra, pEpEncryptFlags flags, pEpEncFormat encFormat)
    1.31  {
    1.32      assert(src);
    1.33      assert(dst);
    1.34 @@ -843,16 +841,19 @@
    1.35  
    1.36      ::message *_src = text_message_to_C(src);
    1.37  
    1.38 +    _PEP_enc_format _encFormat = (_PEP_enc_format)encFormat;
    1.39 +
    1.40      // COM-19: Initialize msg_dst to NULL, or we end up calling
    1.41      // free_message() below with a pointer to random garbage in
    1.42      // case of an error in encrypt_message().
    1.43      ::message *msg_dst = NULL;
    1.44      ::stringlist_t *_extra = new_stringlist(extra); // can cope with NULL
    1.45  
    1.46 -    // _PEP_enc_format is intentionally hardcoded to PEP_enc_PEP:
    1.47 -    // 2016-10-02 14:10 < fdik> schabi: actually, all adapters now must use PEP_enc_PEP
    1.48 +    // _PEP_enc_format used to be intentionally hardcoded to PEP_enc_PEP:
    1.49 +    // Since COM-74, this has been changed to an explicit parameter, to allow the engine to attach
    1.50 +    // the keys and headers to outgoing, unencrypted messages.
    1.51      PEP_encrypt_flags_t engineFlags = (PEP_encrypt_flags_t)flags;
    1.52 -    PEP_STATUS status = ::encrypt_message(get_session(), _src, _extra, &msg_dst, PEP_enc_PEP, engineFlags);
    1.53 +    PEP_STATUS status = ::encrypt_message(get_session(), _src, _extra, &msg_dst, _encFormat, engineFlags);
    1.54      ::free_stringlist(_extra);
    1.55  
    1.56      if (status == PEP_STATUS_OK)
    1.57 @@ -1200,21 +1201,12 @@
    1.58      self->client_last_signalled_polling_state = false;
    1.59      self->client_callbacks_on_sync_thread = static_cast<IpEpEngineCallbacks*>(vp);
    1.60  
    1.61 -    res = self->client_callbacks_on_sync_thread->QueryInterface(
    1.62 -        &self->client_callbacks2_on_sync_thread);
    1.63 -    if (res != S_OK)
    1.64 -        self->client_callbacks2_on_sync_thread = NULL;
    1.65 -
    1.66      ::do_sync_protocol(self->keysync_session, self);
    1.67  
    1.68      self->client_callbacks_on_sync_thread->Release();
    1.69  
    1.70      self->client_callbacks_on_sync_thread = NULL;
    1.71  
    1.72 -    if (self->client_callbacks2_on_sync_thread)
    1.73 -        self->client_callbacks2_on_sync_thread->Release();
    1.74 -    self->client_callbacks2_on_sync_thread = NULL;
    1.75 -
    1.76      CoUninitialize();
    1.77  }
    1.78  
    1.79 @@ -1291,17 +1283,17 @@
    1.80      CpEpEngine* me = (CpEpEngine*)management;
    1.81  
    1.82      if ((timeout && *timeout)
    1.83 -        && me->client_callbacks2_on_sync_thread
    1.84 +        && me->client_callbacks_on_sync_thread
    1.85          && me->client_last_signalled_polling_state == false)
    1.86      {
    1.87 -        me->client_callbacks2_on_sync_thread->NeedFastPolling(VARIANT_TRUE);
    1.88 +        me->client_callbacks_on_sync_thread->NeedFastPolling(VARIANT_TRUE);
    1.89          me->client_last_signalled_polling_state = true;
    1.90      }
    1.91      else if (!(timeout && *timeout)
    1.92 -        && me->client_callbacks2_on_sync_thread
    1.93 +        && me->client_callbacks_on_sync_thread
    1.94          && me->client_last_signalled_polling_state == true)
    1.95      {
    1.96 -        me->client_callbacks2_on_sync_thread->NeedFastPolling(VARIANT_FALSE);
    1.97 +        me->client_callbacks_on_sync_thread->NeedFastPolling(VARIANT_FALSE);
    1.98          me->client_last_signalled_polling_state = false;
    1.99      }
   1.100  
     2.1 --- a/CpEpEngine.h	Fri Feb 02 22:03:16 2018 +0100
     2.2 +++ b/CpEpEngine.h	Wed Feb 07 20:23:32 2018 +0100
     2.3 @@ -24,7 +24,7 @@
     2.4      public CComObjectRootEx<CComObjectThreadModel>,
     2.5      public CComCoClass<CpEpEngine, &CLSID_pEpEngine>,
     2.6      public ISupportErrorInfo,
     2.7 -    public IpEpEngine2
     2.8 +    public IpEpEngine
     2.9  {
    2.10  
    2.11  protected:
    2.12 @@ -55,7 +55,6 @@
    2.13  
    2.14      BEGIN_COM_MAP(CpEpEngine)
    2.15          COM_INTERFACE_ENTRY(IpEpEngine)
    2.16 -        COM_INTERFACE_ENTRY(IpEpEngine2)
    2.17          COM_INTERFACE_ENTRY(ISupportErrorInfo)
    2.18      END_COM_MAP()
    2.19  
    2.20 @@ -147,7 +146,6 @@
    2.21  
    2.22      IpEpEngineCallbacks* client_callbacks = NULL;
    2.23      IpEpEngineCallbacks* client_callbacks_on_sync_thread = NULL;
    2.24 -    IpEpEngineCallbacks2* client_callbacks2_on_sync_thread = NULL;
    2.25      bool client_last_signalled_polling_state = true;
    2.26  
    2.27      // Keysync members
    2.28 @@ -229,7 +227,13 @@
    2.29  
    2.30      // Message API
    2.31  
    2.32 -    STDMETHOD(EncryptMessage)(TextMessage * src, TextMessage * dst, SAFEARRAY * extra, pEpEncryptFlags flags);
    2.33 +    STDMETHOD(EncryptMessage)(
    2.34 +        /* [in] */ struct TextMessage *src,
    2.35 +        /* [out] */ struct TextMessage *dst,
    2.36 +        /* [in] */ SAFEARRAY * extra,
    2.37 +        /* [defaultvalue][in] */ pEpEncryptFlags flags = pEpEncryptFlagDefault,
    2.38 +        /* [defaultvalue][in] */ pEpEncFormat encFormat = pEpEncPep);
    2.39 +
    2.40      STDMETHOD(DecryptMessage)(TextMessage * src, TextMessage * dst, SAFEARRAY ** keylist, pEpDecryptFlags* flags, pEpRating *rating);
    2.41      STDMETHOD(ReEvaluateMessageRating)(TextMessage * msg, SAFEARRAY * x_KeyList, pEpRating x_EncStatus, pEpRating *rating);
    2.42      STDMETHOD(OutgoingMessageRating)(TextMessage *msg, pEpRating * pVal);
     3.1 --- a/pEpCOMServerAdapter.idl	Fri Feb 02 22:03:16 2018 +0100
     3.2 +++ b/pEpCOMServerAdapter.idl	Wed Feb 07 20:23:32 2018 +0100
     3.3 @@ -1,437 +1,429 @@
     3.4 -// pEpCOMServerAdapter.idl : IDL source for pEpCOMServerAdapter
     3.5 -//
     3.6 -
     3.7 -// This file will be processed by the MIDL tool to
     3.8 -// produce the type library (pEpCOMServerAdapter.tlb) and marshalling code.
     3.9 -
    3.10 -import "oaidl.idl";
    3.11 -import "ocidl.idl";
    3.12 -
    3.13 -[
    3.14 -    object,
    3.15 -    uuid(4DA92647-A858-448E-B01F-BE4DCB8C86A1),
    3.16 -    oleautomation,
    3.17 -    nonextensible,
    3.18 -    pointer_default(unique)
    3.19 -]
    3.20 -interface IpEpEngineCallbacks : IUnknown {
    3.21 -    typedef [v1_enum] enum SyncHandshakeSignal {
    3.22 -        SyncNotifyUndefined = 0,
    3.23 -
    3.24 -        // request show handshake dialog
    3.25 -        SyncNotifyInitAddOurDevice = 1,
    3.26 -        SyncNotifyInitAddOtherDevice = 2,
    3.27 -        SyncNotifyInitFormGroup = 3,
    3.28 -        SyncNotifyInitMoveOurDevice = 4,
    3.29 -
    3.30 -        // handshake process timed out
    3.31 -        SyncNotifyTimeout = 5,
    3.32 -
    3.33 -        // handshake accepted by user
    3.34 -        SyncNotifyAcceptedDeviceAdded = 6,
    3.35 -        SyncNotifyAcceptedGroupCreated = 7,
    3.36 -        SyncNotifyAcceptedDeviceMoved = 8,
    3.37 -
    3.38 -        // handshake dialog must be closed
    3.39 -        SyncNotifyOvertaken = 9,
    3.40 -    } SyncHandshakeSignal;
    3.41 -
    3.42 -    typedef [v1_enum] enum SyncHandshakeResult {
    3.43 -        SyncHandshakeCancel = -1,
    3.44 -        SyncHandshakeAccepted = 0,
    3.45 -        SyncHandshakeRejected = 1
    3.46 -    } SyncHandshakeResult;
    3.47 -
    3.48 -    [id(1)] HRESULT MessageToSend([in] struct TextMessage * msg);
    3.49 -    [id(2)] HRESULT NotifyHandshake([in] struct pEpIdentity * self, [in] struct pEpIdentity * partner, [in] SyncHandshakeSignal signal, [out, retval] SyncHandshakeResult * result);
    3.50 -};
    3.51 -
    3.52 -[
    3.53 -    object,
    3.54 -    uuid(64E964B2-880A-4E92-B0B5-66FF4286A3B3),
    3.55 -    oleautomation,
    3.56 -    nonextensible,
    3.57 -    pointer_default(unique)
    3.58 -]
    3.59 -interface IpEpEngineCallbacks2 : IpEpEngineCallbacks
    3.60 -{
    3.61 -    [id(3)] HRESULT NeedFastPolling([in] VARIANT_BOOL enableFastPolling);
    3.62 -};
    3.63 -
    3.64 -[
    3.65 -    object,
    3.66 -    uuid(045E49AF-0975-4876-A53B-8CA5AB28C0F8),
    3.67 -    oleautomation,
    3.68 -    nonextensible,
    3.69 -    pointer_default(unique)
    3.70 -]
    3.71 -interface IpEpEngine : IUnknown {
    3.72 -
    3.73 -    // runtime config of the adapter
    3.74 -
    3.75 -    HRESULT VerboseLogging([in] VARIANT_BOOL enable);
    3.76 -
    3.77 -    // runtime config of the engine
    3.78 -
    3.79 -    HRESULT PassiveMode([in] VARIANT_BOOL enable);
    3.80 -    HRESULT UnencryptedSubject([in] VARIANT_BOOL enable);
    3.81 -
    3.82 -    // basic API
    3.83 -
    3.84 -    HRESULT ExportKey([in] BSTR fpr, [out, retval] BSTR * keyData);
    3.85 -    HRESULT Log([in] BSTR title, [in] BSTR entity, [in, defaultvalue("")] BSTR description, [in, defaultvalue("")] BSTR comment);
    3.86 -    HRESULT Trustwords([in] BSTR fpr, [in, defaultvalue("en")] BSTR lang, [in, defaultvalue(0)] LONG maxWords, [out, retval] BSTR * words);
    3.87 -    HRESULT GetTrustwords([in] struct pEpIdentity * id1, [in] struct pEpIdentity * id2, [in, defaultvalue("en")] BSTR lang, [in, defaultvalue(0)] VARIANT_BOOL full, [out, retval] BSTR * words);
    3.88 -    HRESULT GetCrashdumpLog([in, defaultvalue(0)] LONG maxlines, [out, retval] BSTR * log);
    3.89 -    HRESULT GetEngineVersion([out, retval] BSTR * engineVersion);
    3.90 -    HRESULT GetLanguageList([out, retval] BSTR * languages);
    3.91 -
    3.92 -    typedef [v1_enum] enum pEpComType {
    3.93 -        pEpCtUnknown = 0,
    3.94 -
    3.95 -        // range 0x01 to 0x09: no encryption, 0x0a to 0x0e: nothing reasonable
    3.96 -
    3.97 -        pEpCtNoEncryption = 0x01,                // generic
    3.98 -        pEpCtNoEncryptedChannel = 0x02,
    3.99 -        pEpCtKeyNotFound = 0x03,
   3.100 -        pEpCtKeyExpired = 0x04,
   3.101 -        pEpCtKeyRevoked = 0x05,
   3.102 -        pEpCtKeyB0rken = 0x06,
   3.103 -        pEpCtMyKeyNotIncluded = 0x09,
   3.104 -
   3.105 -        pEpCtSecurityByObscurity = 0x0a,
   3.106 -        pEpCtB0rkenCrypto = 0x0b,
   3.107 -        pEpCtKeyTooShort = 0x0c,
   3.108 -
   3.109 -        pEpCtCompromised = 0x0e,                 // known compromized connection
   3.110 -        pEpCtMistrusted = 0x0f,                  // known mistrusted key
   3.111 -
   3.112 -        // range 0x10 to 0x3f: unconfirmed encryption
   3.113 -
   3.114 -        pEpCtUnconfirmedEncryption = 0x10,       // generic
   3.115 -        pEpCtOpenPGPWeakUnconfirmed = 0x11,      // RSA 1024 is weak
   3.116 -
   3.117 -        pEpCtToBeChecked = 0x20,                 // generic
   3.118 -        pEpCtSMIMEUnconfirmed = 0x21,
   3.119 -        pEpCtCMSUnconfirmed = 0x22,
   3.120 -
   3.121 -        pEpCtStrongButUnconfirmed = 0x30,        // generic
   3.122 -        pEpCtOpenPGPUnconfirmed = 0x38,          // key at least 2048 bit RSA or EC
   3.123 -        pEpCtOTRUnconfirmed = 0x3a,
   3.124 -
   3.125 -        // range 0x40 to 0x7f: unconfirmed encryption and anonymization
   3.126 -
   3.127 -        pEpCtUnconfirmedEncAnon = 0x40,          // generic
   3.128 -        pEpCtpEpUnconfirmed = 0x7f,
   3.129 -
   3.130 -        pEpCtConfirmed = 0x80,                   // this bit decides if trust is confirmed
   3.131 -
   3.132 -        // range 0x81 to 0x8f: reserved
   3.133 -        // range 0x90 to 0xbf: confirmed encryption
   3.134 -
   3.135 -        pEpCtConfirmedEncryption = 0x90,         // generic
   3.136 -        pEpCtOpenPGPWeak = 0x91,                 // RSA 1024 is weak
   3.137 -
   3.138 -        pEpCtToBeCheckedConfirmed = 0xa0,        // generic
   3.139 -        pEpCtSMIME = 0xa1,
   3.140 -        pEpCtCMS = 0xa2,
   3.141 -
   3.142 -        pEpCtStrongEncryption = 0xb0,            // generic
   3.143 -        pEpCtOpenPGP = 0xb8,                     // key at least 2048 bit RSA or EC
   3.144 -        pEpCtOTR = 0xba,
   3.145 -
   3.146 -        // range 0xc0 to 0xff: confirmed encryption and anonymization
   3.147 -
   3.148 -        pEpCtConfirmedEncAnon = 0xc0,            // generic
   3.149 -        pEpCtpEp = 0xff
   3.150 -    } pEpComType;
   3.151 -
   3.152 -    typedef enum pEpStatus {
   3.153 -        pEpStatusOk = 0,
   3.154 -
   3.155 -        pEpInitCannotLoadGpgme = 0x0110,
   3.156 -        pEpInitGpgmeInitFailed = 0x0111,
   3.157 -        pEpInitNoGpgHome = 0x0112,
   3.158 -        pEpInitNetpgpInitFailed = 0x0113,
   3.159 -        pEpInitCannotDetermineGpgVersion = 0x0114,
   3.160 -        pEpInitUnsupportedGpgVersion = 0x0115,
   3.161 -        pEpInitCannotConfigGpgAgent = 0x0116,
   3.162 -
   3.163 -        pEpInitSqlite3WithoutMutex = 0x0120,
   3.164 -        pEpInitCannotOpenDb = 0x0121,
   3.165 -        pEpInitCannotOpenSystemDb = 0x0122,
   3.166 -
   3.167 -        pEpKeyNotFound = 0x0201,
   3.168 -        pEpKeyHasAmbigName = 0x0202,
   3.169 -        pEpGetKeyFailed = 0x0203,
   3.170 -        pEpCannotExportKey = 0x0204,
   3.171 -        pEpCannotEditKey = 0x0205,
   3.172 -        pEpKeyUnsuitable = 0x0206,
   3.173 -
   3.174 -        pEpCannotFindIdentity = 0x0301,
   3.175 -        pEpCannotSetPerson = 0x0381,
   3.176 -        pEpCannotSetPgpKeypair = 0x0382,
   3.177 -        pEpCannotSetIdentity = 0x0383,
   3.178 -        pEpCannotSetTrust = 0x0384,
   3.179 -        pEpKeyBlacklisted = 0x0385,
   3.180 -        pEpCannotFindPerson = 0x0386,
   3.181 -
   3.182 -        pEpCannotFindAlias = 0x0391,
   3.183 -        pEpCannotSetAlias = 0x0392,
   3.184 -
   3.185 -        pEpUnencrypted = 0x0400,
   3.186 -        pEpVerified = 0x0401,
   3.187 -        pEpDecrypted = 0x0402,
   3.188 -        pEpDecryptedAndVerified = 0x0403,
   3.189 -        pEpDecryptWrongFormat = 0x0404,
   3.190 -        pEpDecryptNoKey = 0x0405,
   3.191 -        pEpDecryptSignatureDoesNotMatch = 0x0406,
   3.192 -        pEpVerifyNoKey = 0x0407,
   3.193 -        pEpVerifiedAndTrusted = 0x0408,
   3.194 -        pEpCannotDecryptUnknown = 0x04ff,
   3.195 -
   3.196 -        pEpTrustwordNotFound = 0x0501,
   3.197 -        pEpTrustwordsFprWrongLength = 0x0502,
   3.198 -        pEpTrustwordsDuplicateFpr = 0x0503,
   3.199 -
   3.200 -        pEpCannotCreateKey = 0x0601,
   3.201 -        pEpCannotSendKey = 0x0602,
   3.202 -
   3.203 -        pEpPhraseNotFound = 0x0701,
   3.204 -
   3.205 -        pEpSendFunctionNotRegistered = 0x0801,
   3.206 -        pEpContraintsViolated = 0x0802,
   3.207 -        pEpCannotEncode = 0x0803,
   3.208 -
   3.209 -        pEpSyncNoNotifyCallback = 0x0901,
   3.210 -        pEpSyncIllegalMessage = 0x0902,
   3.211 -        pEpSyncNoInjectCallback = 0x0903,
   3.212 -
   3.213 -        pEpSequenceViolated = 0x0970,
   3.214 -        pEpCannotIncreaseSequence = 0x0971,
   3.215 -        pEpCannotSetSequenceValue = 0x0972,
   3.216 -        pEpOwnSequence = 0x097f,
   3.217 -
   3.218 -        pEpSyncStatemachineError = 0x0980,
   3.219 -        pEpSyncNoTrust = 0x0981,
   3.220 -        pEpStatemachineInvalidState = 0x0982,
   3.221 -        pEpStatemachineInvalidEvent = 0x0983,
   3.222 -        pEpStatemachineInvalidCondition = 0x0984,
   3.223 -        pEpStatemachineInvalidAction = 0x0985,
   3.224 -        pEpStatemachineInhibitedEvent = 0x0986,
   3.225 -
   3.226 -        pEpCommitFailed = 0xff01,
   3.227 -        pEpMessageConsume = 0xff02,
   3.228 -        pEpMessageIgnore = 0xff03,
   3.229 -
   3.230 -        pEpRecordNotFound = -6,
   3.231 -        pEpCannotCreateTempFile = -5,
   3.232 -        pEpIllegalValue = -4,
   3.233 -        pEpBufferTooSmall = -3,
   3.234 -        pEpOutOfMemory = -2,
   3.235 -        pEpUnknownError = -1,
   3.236 -
   3.237 -        pEpVersionMismatch = -7,
   3.238 -    } pEpStatus;
   3.239 -
   3.240 -    typedef [v1_enum] enum pEpIdentityFlags {
   3.241 -        pEpIdfNone = 0,
   3.242 -        pEpIdfNotForSync = 0x0001,
   3.243 -        pEpIdfList = 0x0002,
   3.244 -        pEpIdfDevicegroup = 0x0100
   3.245 -    } pEpIdentityFlags;
   3.246 -
   3.247 -    [uuid(C3A3814E-567F-4D1C-9F44-9B1DA3957A89)] struct pEpIdentity {
   3.248 -        BSTR Address;
   3.249 -        BSTR Fpr;
   3.250 -        BSTR UserId;
   3.251 -        BSTR UserName;
   3.252 -        pEpComType CommType;
   3.253 -        BSTR Lang;
   3.254 -        pEpIdentityFlags Flags;
   3.255 -    };
   3.256 -
   3.257 -    HRESULT SetIdentityFlags([in] struct pEpIdentity *identity, [in] pEpIdentityFlags flags);
   3.258 -    HRESULT UnsetIdentityFlags([in] struct pEpIdentity *identity, [in] pEpIdentityFlags flags);
   3.259 -
   3.260 -    // Keymanagement API
   3.261 -
   3.262 -    HRESULT StartKeyserverLookup();
   3.263 -    HRESULT StopKeyserverLookup();
   3.264 -
   3.265 -    HRESULT Myself([in] struct pEpIdentity *ident, [out, retval] struct pEpIdentity *result);
   3.266 -    HRESULT UpdateIdentity([in] struct pEpIdentity *ident, [out, retval] struct pEpIdentity *result);
   3.267 -    HRESULT KeyMistrusted([in] struct pEpIdentity *ident);
   3.268 -    HRESULT KeyResetTrust([in] struct pEpIdentity *ident);
   3.269 -    HRESULT TrustPersonalKey([in] struct pEpIdentity *ident, [out, retval] struct pEpIdentity *result);
   3.270 -    HRESULT OwnIdentitiesRetrieve([out, retval] SAFEARRAY(struct pEpIdentity)* ownIdentities);
   3.271 -
   3.272 -    // Blacklist API
   3.273 -
   3.274 -    HRESULT BlacklistAdd([in] BSTR fpr);
   3.275 -    HRESULT BlacklistDelete([in] BSTR fpr);
   3.276 -    HRESULT BlacklistIsListed([in] BSTR fpr, [out, retval] VARIANT_BOOL *listed);
   3.277 -    HRESULT BlacklistRetrieve([out, retval] SAFEARRAY(BSTR) *blacklist);
   3.278 -
   3.279 -    // PGP compatibility functions
   3.280 -
   3.281 -    HRESULT OpenPGPListKeyinfo([in] BSTR searchPattern, [out, retval] SAFEARRAY(struct StringPair)* keyinfoList);
   3.282 -
   3.283 -    // Message API
   3.284 -
   3.285 -    typedef [v1_enum] enum pEpRating {
   3.286 -        pEpRatingUndefined = 0,
   3.287 -        pEpRatingCannotDecrypt,
   3.288 -        pEpRatingHaveNoKey,
   3.289 -        pEpRatingUnencrypted,
   3.290 -        pEpRatingUnencryptedForSome,
   3.291 -        pEpRatingUnreliable,
   3.292 -        pEpRatingReliable,
   3.293 -        pEpRatingTrusted,
   3.294 -        pEpRatingTrustedAndAnonymized,
   3.295 -        pEpRatingFullyAnonymous,
   3.296 -
   3.297 -        pEpRatingMistrust = -1,
   3.298 -        pEpRatingB0rken = -2,
   3.299 -        pEpRatingUnderAttack = -3
   3.300 -    } pEpRating;
   3.301 -
   3.302 -    typedef [v1_enum] enum pEpColor {
   3.303 -        pEpColorNoColor = 0,
   3.304 -        pEpColorYellow,
   3.305 -        pEpColorGreen,
   3.306 -        pEpColorRed = -1,
   3.307 -    } pEpColor;
   3.308 -
   3.309 -    typedef [v1_enum] enum pEpEncryptFlags {
   3.310 -        pEpEncryptFlagDefault = 0,
   3.311 -        pEpEncryptFlagForceEncryption = 0x1,
   3.312 -
   3.313 -        // This flag is for special uses and should not be used
   3.314 -        // by normal pEp clients!
   3.315 -        pEpEncryptFlagForceUnsigned = 0x2,
   3.316 -
   3.317 -        // This flag is for special uses and should not be used
   3.318 -        // by normal pEp clients!
   3.319 -        pEpEncryptFlagForceNoAttachedKey = 0x4,
   3.320 -
   3.321 -    } pEpEncryptFlags;
   3.322 -
   3.323 -    typedef [v1_enum] enum pEpDecryptFlags {
   3.324 -        pEpDecryptFlagsNone = 0,
   3.325 -        pEpDecryptFlagOwnPrivateKey = 0x1,
   3.326 -        pEpDecryptFlagConsume = 0x2,
   3.327 -        pEpDecryptFlagIgnore = 0x4
   3.328 -    } pEpDecryptFlags;
   3.329 -
   3.330 -    typedef [v1_enum] enum pEpMsgDirection {
   3.331 -        pEpDirIncoming = 0,
   3.332 -        pEpDirOutgoing
   3.333 -    } pEpMsgDirection;
   3.334 -
   3.335 -    [uuid(47FB0795-6B64-455C-BB0E-54998CAB8ACB)] struct StringPair {
   3.336 -        BSTR Name;
   3.337 -        BSTR Value;
   3.338 -    };
   3.339 -
   3.340 -    [uuid(634EB7CE-99AA-460D-BDF8-F7CDA7232CA6)] struct Blob {
   3.341 -        SAFEARRAY(BYTE) value;
   3.342 -        BSTR MimeType;
   3.343 -        BSTR Filename;
   3.344 -    };
   3.345 -
   3.346 -    [uuid(B6F40887-E761-4A47-B204-A0193EE0284D)] struct TextMessage {
   3.347 -        pEpMsgDirection Dir;
   3.348 -        BSTR Id;
   3.349 -        BSTR ShortMsg;
   3.350 -        BSTR LongMsg;
   3.351 -        BSTR LongMsgFormatted;
   3.352 -        SAFEARRAY(struct Blob) Attachments;
   3.353 -        hyper Sent; // Timestamp: 64 Bit time_t from mktime(), seconds since January 1, 1970, 0:00 UTC.
   3.354 -        hyper Recv; // Timestamp: 64 Bit time_t from mktime(), seconds since January 1, 1970, 0:00 UTC.
   3.355 -        struct pEpIdentity From;
   3.356 -        SAFEARRAY(struct pEpIdentity) To;
   3.357 -        struct pEpIdentity RecvBy;
   3.358 -        SAFEARRAY(struct pEpIdentity) Cc;
   3.359 -        SAFEARRAY(struct pEpIdentity) Bcc;
   3.360 -        SAFEARRAY(struct pEpIdentity) ReplyTo;
   3.361 -        SAFEARRAY(BSTR) References;
   3.362 -        SAFEARRAY(BSTR) Keywords;
   3.363 -        BSTR Comments;
   3.364 -        SAFEARRAY(struct StringPair) OptFields;
   3.365 -    };
   3.366 -
   3.367 -    HRESULT EncryptMessage(
   3.368 -        [in] struct TextMessage *src,
   3.369 -        [out] struct TextMessage * dst,
   3.370 -        [in] SAFEARRAY(BSTR) extra,
   3.371 -        [in, defaultvalue(pEpEncryptFlagDefault)] pEpEncryptFlags flags);
   3.372 -
   3.373 -    HRESULT DecryptMessage(
   3.374 -        [in] struct TextMessage *src,
   3.375 -        [out] struct TextMessage * dst,
   3.376 -        [out] SAFEARRAY(BSTR) *keylist,
   3.377 -        [out] pEpDecryptFlags* flags,
   3.378 -        [out, retval] pEpRating *rating);
   3.379 -
   3.380 -    HRESULT OutgoingMessageRating([in] struct TextMessage *msg, [out, retval] pEpRating * pVal);
   3.381 -    HRESULT IdentityRating([in] struct pEpIdentity * ident, [out, retval] pEpRating * pVal);
   3.382 -    HRESULT ColorFromRating([in] pEpRating rating, [out, retval] pEpColor* pVal);
   3.383 -
   3.384 -    // callback / keysync API
   3.385 -    HRESULT RegisterCallbacks([in] IpEpEngineCallbacks* newCallback);
   3.386 -    HRESULT UnregisterCallbacks();
   3.387 -};
   3.388 -
   3.389 -[
   3.390 -    object,
   3.391 -    uuid(8A042123-D433-4DEA-ADA2-2E5E61A00292),
   3.392 -    oleautomation,
   3.393 -    nonextensible,
   3.394 -    pointer_default(unique)
   3.395 -]
   3.396 -interface IpEpEngine2 : IpEpEngine
   3.397 -{
   3.398 -    HRESULT GetMessageTrustwords(
   3.399 -        [in] struct TextMessage *msg,
   3.400 -        [in] struct pEpIdentity * receivedBy,
   3.401 -        [in] SAFEARRAY(BSTR) keylist,
   3.402 -        [in, defaultvalue("en")] BSTR lang,
   3.403 -        [in, defaultvalue(0)] VARIANT_BOOL full,
   3.404 -        [out, retval] BSTR * words
   3.405 -    );
   3.406 -
   3.407 -    HRESULT EncryptMessageForSelf(
   3.408 -        [in] struct pEpIdentity* targetId,
   3.409 -        [in] struct TextMessage* src,
   3.410 -        [out] struct TextMessage* dst,
   3.411 -        [in, defaultvalue(pEpEncryptFlagDefault)] pEpEncryptFlags flags
   3.412 -    );
   3.413 -
   3.414 -    HRESULT ReEvaluateMessageRating(
   3.415 -        [in] struct TextMessage *src,
   3.416 -        [in] SAFEARRAY(BSTR) x_KeyList, // referring to X-KeyList mail header
   3.417 -        [in] pEpRating x_EncStatus, // referring to X-EncStatus mail header
   3.418 -        [out, retval] pEpRating *rating
   3.419 -    );
   3.420 -
   3.421 -    HRESULT UndoLastMistrust();
   3.422 -};
   3.423 -
   3.424 -[
   3.425 -    uuid(564A4350-419E-47F1-B0DF-6FCCF0CD0BBC),
   3.426 -    version(1.0),
   3.427 -]
   3.428 -library pEpCOMServerAdapterLib
   3.429 -{
   3.430 -    importlib("stdole2.tlb");
   3.431 -
   3.432 -    [
   3.433 -        uuid(5FF6682B-727B-4DFE-A68D-28982874C0C7)
   3.434 -    ]
   3.435 -    coclass pEpEngine {
   3.436 -        [default] interface IpEpEngine2;
   3.437 -        interface IpEpEngine;
   3.438 -        interface IpEpEngineCallbacks2;
   3.439 -    };
   3.440 -};
   3.441 +// pEpCOMServerAdapter.idl : IDL source for pEpCOMServerAdapter
   3.442 +//
   3.443 +
   3.444 +// This file will be processed by the MIDL tool to
   3.445 +// produce the type library (pEpCOMServerAdapter.tlb) and marshalling code.
   3.446 +
   3.447 +import "oaidl.idl";
   3.448 +import "ocidl.idl";
   3.449 +
   3.450 +[
   3.451 +    object,
   3.452 +    uuid(4DA92647-A858-448E-B01F-BE4DCB8C86A1),
   3.453 +    oleautomation,
   3.454 +    nonextensible,
   3.455 +    pointer_default(unique)
   3.456 +]
   3.457 +interface IpEpEngineCallbacks : IUnknown {
   3.458 +    typedef [v1_enum] enum SyncHandshakeSignal {
   3.459 +        SyncNotifyUndefined = 0,
   3.460 +
   3.461 +        // request show handshake dialog
   3.462 +        SyncNotifyInitAddOurDevice = 1,
   3.463 +        SyncNotifyInitAddOtherDevice = 2,
   3.464 +        SyncNotifyInitFormGroup = 3,
   3.465 +        SyncNotifyInitMoveOurDevice = 4,
   3.466 +
   3.467 +        // handshake process timed out
   3.468 +        SyncNotifyTimeout = 5,
   3.469 +
   3.470 +        // handshake accepted by user
   3.471 +        SyncNotifyAcceptedDeviceAdded = 6,
   3.472 +        SyncNotifyAcceptedGroupCreated = 7,
   3.473 +        SyncNotifyAcceptedDeviceMoved = 8,
   3.474 +
   3.475 +        // handshake dialog must be closed
   3.476 +        SyncNotifyOvertaken = 9,
   3.477 +    } SyncHandshakeSignal;
   3.478 +
   3.479 +    typedef [v1_enum] enum SyncHandshakeResult {
   3.480 +        SyncHandshakeCancel = -1,
   3.481 +        SyncHandshakeAccepted = 0,
   3.482 +        SyncHandshakeRejected = 1
   3.483 +    } SyncHandshakeResult;
   3.484 +
   3.485 +    [id(1)] HRESULT MessageToSend([in] struct TextMessage * msg);
   3.486 +
   3.487 +    [id(2)] HRESULT NotifyHandshake([in] struct pEpIdentity * self, [in] struct pEpIdentity * partner, [in] SyncHandshakeSignal signal, [out, retval] SyncHandshakeResult * result);
   3.488 +
   3.489 +    [id(3)] HRESULT NeedFastPolling([in] VARIANT_BOOL enableFastPolling);
   3.490 +};
   3.491 +
   3.492 +[
   3.493 +    object,
   3.494 +    uuid(045E49AF-0975-4876-A53B-8CA5AB28C0F8),
   3.495 +    oleautomation,
   3.496 +    nonextensible,
   3.497 +    pointer_default(unique)
   3.498 +]
   3.499 +interface IpEpEngine : IUnknown {
   3.500 +
   3.501 +    // runtime config of the adapter
   3.502 +
   3.503 +    [id(1)] HRESULT VerboseLogging([in] VARIANT_BOOL enable);
   3.504 +
   3.505 +    // runtime config of the engine
   3.506 +
   3.507 +    [id(2)] HRESULT PassiveMode([in] VARIANT_BOOL enable);
   3.508 +    [id(3)] HRESULT UnencryptedSubject([in] VARIANT_BOOL enable);
   3.509 +
   3.510 +    // basic API
   3.511 +
   3.512 +    [id(4)] HRESULT ExportKey([in] BSTR fpr, [out, retval] BSTR * keyData);
   3.513 +    [id(5)] HRESULT Log([in] BSTR title, [in] BSTR entity, [in, defaultvalue("")] BSTR description, [in, defaultvalue("")] BSTR comment);
   3.514 +    [id(6)] HRESULT Trustwords([in] BSTR fpr, [in, defaultvalue("en")] BSTR lang, [in, defaultvalue(0)] LONG maxWords, [out, retval] BSTR * words);
   3.515 +    [id(7)] HRESULT GetTrustwords([in] struct pEpIdentity * id1, [in] struct pEpIdentity * id2, [in, defaultvalue("en")] BSTR lang, [in, defaultvalue(0)] VARIANT_BOOL full, [out, retval] BSTR * words);
   3.516 +    [id(8)] HRESULT GetCrashdumpLog([in, defaultvalue(0)] LONG maxlines, [out, retval] BSTR * log);
   3.517 +    [id(9)] HRESULT GetEngineVersion([out, retval] BSTR * engineVersion);
   3.518 +    [id(10)] HRESULT GetLanguageList([out, retval] BSTR * languages);
   3.519 +
   3.520 +    typedef [v1_enum] enum pEpComType {
   3.521 +        pEpCtUnknown = 0,
   3.522 +
   3.523 +        // range 0x01 to 0x09: no encryption, 0x0a to 0x0e: nothing reasonable
   3.524 +
   3.525 +        pEpCtNoEncryption = 0x01,                // generic
   3.526 +        pEpCtNoEncryptedChannel = 0x02,
   3.527 +        pEpCtKeyNotFound = 0x03,
   3.528 +        pEpCtKeyExpired = 0x04,
   3.529 +        pEpCtKeyRevoked = 0x05,
   3.530 +        pEpCtKeyB0rken = 0x06,
   3.531 +        pEpCtMyKeyNotIncluded = 0x09,
   3.532 +
   3.533 +        pEpCtSecurityByObscurity = 0x0a,
   3.534 +        pEpCtB0rkenCrypto = 0x0b,
   3.535 +        pEpCtKeyTooShort = 0x0c,
   3.536 +
   3.537 +        pEpCtCompromised = 0x0e,                 // known compromized connection
   3.538 +        pEpCtMistrusted = 0x0f,                  // known mistrusted key
   3.539 +
   3.540 +        // range 0x10 to 0x3f: unconfirmed encryption
   3.541 +
   3.542 +        pEpCtUnconfirmedEncryption = 0x10,       // generic
   3.543 +        pEpCtOpenPGPWeakUnconfirmed = 0x11,      // RSA 1024 is weak
   3.544 +
   3.545 +        pEpCtToBeChecked = 0x20,                 // generic
   3.546 +        pEpCtSMIMEUnconfirmed = 0x21,
   3.547 +        pEpCtCMSUnconfirmed = 0x22,
   3.548 +
   3.549 +        pEpCtStrongButUnconfirmed = 0x30,        // generic
   3.550 +        pEpCtOpenPGPUnconfirmed = 0x38,          // key at least 2048 bit RSA or EC
   3.551 +        pEpCtOTRUnconfirmed = 0x3a,
   3.552 +
   3.553 +        // range 0x40 to 0x7f: unconfirmed encryption and anonymization
   3.554 +
   3.555 +        pEpCtUnconfirmedEncAnon = 0x40,          // generic
   3.556 +        pEpCtpEpUnconfirmed = 0x7f,
   3.557 +
   3.558 +        pEpCtConfirmed = 0x80,                   // this bit decides if trust is confirmed
   3.559 +
   3.560 +        // range 0x81 to 0x8f: reserved
   3.561 +        // range 0x90 to 0xbf: confirmed encryption
   3.562 +
   3.563 +        pEpCtConfirmedEncryption = 0x90,         // generic
   3.564 +        pEpCtOpenPGPWeak = 0x91,                 // RSA 1024 is weak
   3.565 +
   3.566 +        pEpCtToBeCheckedConfirmed = 0xa0,        // generic
   3.567 +        pEpCtSMIME = 0xa1,
   3.568 +        pEpCtCMS = 0xa2,
   3.569 +
   3.570 +        pEpCtStrongEncryption = 0xb0,            // generic
   3.571 +        pEpCtOpenPGP = 0xb8,                     // key at least 2048 bit RSA or EC
   3.572 +        pEpCtOTR = 0xba,
   3.573 +
   3.574 +        // range 0xc0 to 0xff: confirmed encryption and anonymization
   3.575 +
   3.576 +        pEpCtConfirmedEncAnon = 0xc0,            // generic
   3.577 +        pEpCtpEp = 0xff
   3.578 +    } pEpComType;
   3.579 +
   3.580 +    typedef enum pEpStatus {
   3.581 +        pEpStatusOk = 0,
   3.582 +
   3.583 +        pEpInitCannotLoadGpgme = 0x0110,
   3.584 +        pEpInitGpgmeInitFailed = 0x0111,
   3.585 +        pEpInitNoGpgHome = 0x0112,
   3.586 +        pEpInitNetpgpInitFailed = 0x0113,
   3.587 +        pEpInitCannotDetermineGpgVersion = 0x0114,
   3.588 +        pEpInitUnsupportedGpgVersion = 0x0115,
   3.589 +        pEpInitCannotConfigGpgAgent = 0x0116,
   3.590 +
   3.591 +        pEpInitSqlite3WithoutMutex = 0x0120,
   3.592 +        pEpInitCannotOpenDb = 0x0121,
   3.593 +        pEpInitCannotOpenSystemDb = 0x0122,
   3.594 +
   3.595 +        pEpKeyNotFound = 0x0201,
   3.596 +        pEpKeyHasAmbigName = 0x0202,
   3.597 +        pEpGetKeyFailed = 0x0203,
   3.598 +        pEpCannotExportKey = 0x0204,
   3.599 +        pEpCannotEditKey = 0x0205,
   3.600 +        pEpKeyUnsuitable = 0x0206,
   3.601 +
   3.602 +        pEpCannotFindIdentity = 0x0301,
   3.603 +        pEpCannotSetPerson = 0x0381,
   3.604 +        pEpCannotSetPgpKeypair = 0x0382,
   3.605 +        pEpCannotSetIdentity = 0x0383,
   3.606 +        pEpCannotSetTrust = 0x0384,
   3.607 +        pEpKeyBlacklisted = 0x0385,
   3.608 +        pEpCannotFindPerson = 0x0386,
   3.609 +
   3.610 +        pEpCannotFindAlias = 0x0391,
   3.611 +        pEpCannotSetAlias = 0x0392,
   3.612 +
   3.613 +        pEpUnencrypted = 0x0400,
   3.614 +        pEpVerified = 0x0401,
   3.615 +        pEpDecrypted = 0x0402,
   3.616 +        pEpDecryptedAndVerified = 0x0403,
   3.617 +        pEpDecryptWrongFormat = 0x0404,
   3.618 +        pEpDecryptNoKey = 0x0405,
   3.619 +        pEpDecryptSignatureDoesNotMatch = 0x0406,
   3.620 +        pEpVerifyNoKey = 0x0407,
   3.621 +        pEpVerifiedAndTrusted = 0x0408,
   3.622 +        pEpCannotDecryptUnknown = 0x04ff,
   3.623 +
   3.624 +        pEpTrustwordNotFound = 0x0501,
   3.625 +        pEpTrustwordsFprWrongLength = 0x0502,
   3.626 +        pEpTrustwordsDuplicateFpr = 0x0503,
   3.627 +
   3.628 +        pEpCannotCreateKey = 0x0601,
   3.629 +        pEpCannotSendKey = 0x0602,
   3.630 +
   3.631 +        pEpPhraseNotFound = 0x0701,
   3.632 +
   3.633 +        pEpSendFunctionNotRegistered = 0x0801,
   3.634 +        pEpContraintsViolated = 0x0802,
   3.635 +        pEpCannotEncode = 0x0803,
   3.636 +
   3.637 +        pEpSyncNoNotifyCallback = 0x0901,
   3.638 +        pEpSyncIllegalMessage = 0x0902,
   3.639 +        pEpSyncNoInjectCallback = 0x0903,
   3.640 +
   3.641 +        pEpSequenceViolated = 0x0970,
   3.642 +        pEpCannotIncreaseSequence = 0x0971,
   3.643 +        pEpCannotSetSequenceValue = 0x0972,
   3.644 +        pEpOwnSequence = 0x097f,
   3.645 +
   3.646 +        pEpSyncStatemachineError = 0x0980,
   3.647 +        pEpSyncNoTrust = 0x0981,
   3.648 +        pEpStatemachineInvalidState = 0x0982,
   3.649 +        pEpStatemachineInvalidEvent = 0x0983,
   3.650 +        pEpStatemachineInvalidCondition = 0x0984,
   3.651 +        pEpStatemachineInvalidAction = 0x0985,
   3.652 +        pEpStatemachineInhibitedEvent = 0x0986,
   3.653 +
   3.654 +        pEpCommitFailed = 0xff01,
   3.655 +        pEpMessageConsume = 0xff02,
   3.656 +        pEpMessageIgnore = 0xff03,
   3.657 +
   3.658 +        pEpRecordNotFound = -6,
   3.659 +        pEpCannotCreateTempFile = -5,
   3.660 +        pEpIllegalValue = -4,
   3.661 +        pEpBufferTooSmall = -3,
   3.662 +        pEpOutOfMemory = -2,
   3.663 +        pEpUnknownError = -1,
   3.664 +
   3.665 +        pEpVersionMismatch = -7,
   3.666 +    } pEpStatus;
   3.667 +
   3.668 +    typedef [v1_enum] enum pEpIdentityFlags {
   3.669 +        pEpIdfNone = 0,
   3.670 +        pEpIdfNotForSync = 0x0001,
   3.671 +        pEpIdfList = 0x0002,
   3.672 +        pEpIdfDevicegroup = 0x0100
   3.673 +    } pEpIdentityFlags;
   3.674 +
   3.675 +    [uuid(C3A3814E-567F-4D1C-9F44-9B1DA3957A89)] struct pEpIdentity {
   3.676 +        BSTR Address;
   3.677 +        BSTR Fpr;
   3.678 +        BSTR UserId;
   3.679 +        BSTR UserName;
   3.680 +        pEpComType CommType;
   3.681 +        BSTR Lang;
   3.682 +        pEpIdentityFlags Flags;
   3.683 +    };
   3.684 +
   3.685 +    [id(11)] HRESULT SetIdentityFlags([in] struct pEpIdentity *identity, [in] pEpIdentityFlags flags);
   3.686 +    [id(12)] HRESULT UnsetIdentityFlags([in] struct pEpIdentity *identity, [in] pEpIdentityFlags flags);
   3.687 +
   3.688 +    // Keymanagement API
   3.689 +
   3.690 +    [id(13)] HRESULT StartKeyserverLookup();
   3.691 +    [id(14)] HRESULT StopKeyserverLookup();
   3.692 +
   3.693 +    [id(15)] HRESULT Myself([in] struct pEpIdentity *ident, [out, retval] struct pEpIdentity *result);
   3.694 +    [id(16)] HRESULT UpdateIdentity([in] struct pEpIdentity *ident, [out, retval] struct pEpIdentity *result);
   3.695 +    [id(17)] HRESULT KeyMistrusted([in] struct pEpIdentity *ident);
   3.696 +    [id(18)] HRESULT KeyResetTrust([in] struct pEpIdentity *ident);
   3.697 +    [id(19)] HRESULT TrustPersonalKey([in] struct pEpIdentity *ident, [out, retval] struct pEpIdentity *result);
   3.698 +    [id(20)] HRESULT OwnIdentitiesRetrieve([out, retval] SAFEARRAY(struct pEpIdentity)* ownIdentities);
   3.699 +    [id(21)] HRESULT UndoLastMistrust();
   3.700 +
   3.701 +    // Blacklist API
   3.702 +
   3.703 +    [id(22)] HRESULT BlacklistAdd([in] BSTR fpr);
   3.704 +    [id(23)] HRESULT BlacklistDelete([in] BSTR fpr);
   3.705 +    [id(24)] HRESULT BlacklistIsListed([in] BSTR fpr, [out, retval] VARIANT_BOOL *listed);
   3.706 +    [id(25)] HRESULT BlacklistRetrieve([out, retval] SAFEARRAY(BSTR) *blacklist);
   3.707 +
   3.708 +    // PGP compatibility functions
   3.709 +
   3.710 +    [id(26)] HRESULT OpenPGPListKeyinfo([in] BSTR searchPattern, [out, retval] SAFEARRAY(struct StringPair)* keyinfoList);
   3.711 +
   3.712 +    // Message API
   3.713 +
   3.714 +    typedef [v1_enum] enum pEpRating {
   3.715 +        pEpRatingUndefined = 0,
   3.716 +        pEpRatingCannotDecrypt,
   3.717 +        pEpRatingHaveNoKey,
   3.718 +        pEpRatingUnencrypted,
   3.719 +        pEpRatingUnencryptedForSome,
   3.720 +        pEpRatingUnreliable,
   3.721 +        pEpRatingReliable,
   3.722 +        pEpRatingTrusted,
   3.723 +        pEpRatingTrustedAndAnonymized,
   3.724 +        pEpRatingFullyAnonymous,
   3.725 +
   3.726 +        pEpRatingMistrust = -1,
   3.727 +        pEpRatingB0rken = -2,
   3.728 +        pEpRatingUnderAttack = -3
   3.729 +    } pEpRating;
   3.730 +
   3.731 +    typedef [v1_enum] enum pEpColor {
   3.732 +        pEpColorNoColor = 0,
   3.733 +        pEpColorYellow,
   3.734 +        pEpColorGreen,
   3.735 +        pEpColorRed = -1,
   3.736 +    } pEpColor;
   3.737 +
   3.738 +    typedef [v1_enum] enum pEpEncryptFlags {
   3.739 +        pEpEncryptFlagDefault = 0,
   3.740 +        pEpEncryptFlagForceEncryption = 0x1,
   3.741 +
   3.742 +        // This flag is for special uses and should not be used
   3.743 +        // by normal pEp clients!
   3.744 +        pEpEncryptFlagForceUnsigned = 0x2,
   3.745 +
   3.746 +        // This flag is for special uses and should not be used
   3.747 +        // by normal pEp clients!
   3.748 +        pEpEncryptFlagForceNoAttachedKey = 0x4,
   3.749 +
   3.750 +    } pEpEncryptFlags;
   3.751 +
   3.752 +    typedef [v1_enum] enum pEpDecryptFlags {
   3.753 +        pEpDecryptFlagsNone = 0,
   3.754 +        pEpDecryptFlagOwnPrivateKey = 0x1,
   3.755 +        pEpDecryptFlagConsume = 0x2,
   3.756 +        pEpDecryptFlagIgnore = 0x4
   3.757 +    } pEpDecryptFlags;
   3.758 +
   3.759 +    typedef [v1_enum] enum pEpMsgDirection {
   3.760 +        pEpDirIncoming = 0,
   3.761 +        pEpDirOutgoing
   3.762 +    } pEpMsgDirection;
   3.763 +
   3.764 +    typedef [v1_enum] enum pEpEncFormat {
   3.765 +        pEpEncNone = 0,                       // message is not encrypted
   3.766 +        pEpEncPieces,                         // inline PGP + PGP extensions
   3.767 +        pEpEncSMime,                          // RFC5751
   3.768 +        pEpEncPgpMime,                        // RFC3156
   3.769 +        pEpEncPep,                            // pEp encryption format
   3.770 +        pEpEncPgpMimeOutlook1                 // Message B0rken by Outlook type 1
   3.771 +    } pEpEncFormat;
   3.772 +
   3.773 +    [uuid(47FB0795-6B64-455C-BB0E-54998CAB8ACB)] struct StringPair {
   3.774 +        BSTR Name;
   3.775 +        BSTR Value;
   3.776 +    };
   3.777 +
   3.778 +    [uuid(634EB7CE-99AA-460D-BDF8-F7CDA7232CA6)] struct Blob {
   3.779 +        SAFEARRAY(BYTE) value;
   3.780 +        BSTR MimeType;
   3.781 +        BSTR Filename;
   3.782 +    };
   3.783 +
   3.784 +    [uuid(B6F40887-E761-4A47-B204-A0193EE0284D)] struct TextMessage {
   3.785 +        pEpMsgDirection Dir;
   3.786 +        BSTR Id;
   3.787 +        BSTR ShortMsg;
   3.788 +        BSTR LongMsg;
   3.789 +        BSTR LongMsgFormatted;
   3.790 +        SAFEARRAY(struct Blob) Attachments;
   3.791 +        hyper Sent; // Timestamp: 64 Bit time_t from mktime(), seconds since January 1, 1970, 0:00 UTC.
   3.792 +        hyper Recv; // Timestamp: 64 Bit time_t from mktime(), seconds since January 1, 1970, 0:00 UTC.
   3.793 +        struct pEpIdentity From;
   3.794 +        SAFEARRAY(struct pEpIdentity) To;
   3.795 +        struct pEpIdentity RecvBy;
   3.796 +        SAFEARRAY(struct pEpIdentity) Cc;
   3.797 +        SAFEARRAY(struct pEpIdentity) Bcc;
   3.798 +        SAFEARRAY(struct pEpIdentity) ReplyTo;
   3.799 +        SAFEARRAY(BSTR) References;
   3.800 +        SAFEARRAY(BSTR) Keywords;
   3.801 +        BSTR Comments;
   3.802 +        SAFEARRAY(struct StringPair) OptFields;
   3.803 +    };
   3.804 +
   3.805 +    [id(27)] HRESULT EncryptMessage(
   3.806 +        [in] struct TextMessage *src,
   3.807 +        [out] struct TextMessage * dst,
   3.808 +        [in] SAFEARRAY(BSTR) extra,
   3.809 +        [in, defaultvalue(pEpEncryptFlagDefault)] pEpEncryptFlags flags,
   3.810 +        // Use pEpEncFormat.pEpEncNone for unencrypted, outgoing messages.
   3.811 +        // Default is pEpEncFormat.pEpEncPep, all other formats are only 
   3.812 +        // for compatibility and not intended for normal use.
   3.813 +        [in, defaultvalue(pEpEncPep)] pEpEncFormat encFormat);
   3.814 +
   3.815 +    [id(28)] HRESULT DecryptMessage(
   3.816 +        [in] struct TextMessage *src,
   3.817 +        [out] struct TextMessage * dst,
   3.818 +        [out] SAFEARRAY(BSTR) *keylist,
   3.819 +        [out] pEpDecryptFlags* flags,
   3.820 +        [out, retval] pEpRating *rating);
   3.821 +
   3.822 +    [id(29)] HRESULT OutgoingMessageRating([in] struct TextMessage *msg, [out, retval] pEpRating * pVal);
   3.823 +    [id(30)] HRESULT IdentityRating([in] struct pEpIdentity * ident, [out, retval] pEpRating * pVal);
   3.824 +    [id(31)] HRESULT ColorFromRating([in] pEpRating rating, [out, retval] pEpColor* pVal);
   3.825 +
   3.826 +    [id(32)] HRESULT GetMessageTrustwords(
   3.827 +        [in] struct TextMessage *msg,
   3.828 +        [in] struct pEpIdentity * receivedBy,
   3.829 +        [in] SAFEARRAY(BSTR) keylist,
   3.830 +        [in, defaultvalue("en")] BSTR lang,
   3.831 +        [in, defaultvalue(0)] VARIANT_BOOL full,
   3.832 +        [out, retval] BSTR * words
   3.833 +    );
   3.834 +
   3.835 +    [id(33)] HRESULT EncryptMessageForSelf(
   3.836 +        [in] struct pEpIdentity* targetId,
   3.837 +        [in] struct TextMessage* src,
   3.838 +        [out] struct TextMessage* dst,
   3.839 +        [in, defaultvalue(pEpEncryptFlagDefault)] pEpEncryptFlags flags
   3.840 +    );
   3.841 +
   3.842 +    [id(34)] HRESULT ReEvaluateMessageRating(
   3.843 +        [in] struct TextMessage *src,
   3.844 +        [in] SAFEARRAY(BSTR) x_KeyList, // referring to X-KeyList mail header
   3.845 +        [in] pEpRating x_EncStatus, // referring to X-EncStatus mail header
   3.846 +        [out, retval] pEpRating *rating
   3.847 +    );
   3.848 +
   3.849 +    // callback / keysync API
   3.850 +    [id(35)] HRESULT RegisterCallbacks([in] IpEpEngineCallbacks* newCallback);
   3.851 +    [id(36)] HRESULT UnregisterCallbacks();
   3.852 +};
   3.853 +
   3.854 +[
   3.855 +    uuid(564A4350-419E-47F1-B0DF-6FCCF0CD0BBC),
   3.856 +    version(1.0),
   3.857 +]
   3.858 +library pEpCOMServerAdapterLib
   3.859 +{
   3.860 +    importlib("stdole2.tlb");
   3.861 +
   3.862 +    [
   3.863 +        uuid(5FF6682B-727B-4DFE-A68D-28982874C0C7)
   3.864 +    ]
   3.865 +    coclass pEpEngine {
   3.866 +        [default] interface IpEpEngine;
   3.867 +        interface IpEpEngineCallbacks;
   3.868 +    };
   3.869 +};