COM-52: Expose Encrypt for Identity (Myself) function in COM api
authorMarkus Schaber <markus@pep-security.net>
Thu, 09 Mar 2017 22:52:01 +0100
changeset 240ea67031c573f
parent 239 1435b23368a6
child 241 03e471c3ec29
COM-52: Expose Encrypt for Identity (Myself) function in COM api
- Add the flags to allow enigmail compatibility.
CpEpEngine.cpp
CpEpEngine.h
pEpCOMServerAdapter.idl
     1.1 --- a/CpEpEngine.cpp	Mon Mar 06 21:41:29 2017 +0100
     1.2 +++ b/CpEpEngine.cpp	Thu Mar 09 22:52:01 2017 +0100
     1.3 @@ -863,7 +863,7 @@
     1.4  }
     1.5  
     1.6  
     1.7 -STDMETHODIMP CpEpEngine::EncryptMessageForSelf(pEpIdentity * target_id, TextMessage * src, TextMessage * dst)
     1.8 +STDMETHODIMP CpEpEngine::EncryptMessageForSelf(pEpIdentity * target_id, TextMessage * src, TextMessage * dst, pEpEncryptFlags flags)
     1.9  {
    1.10      assert(target_id);
    1.11      assert(src);
    1.12 @@ -872,6 +872,8 @@
    1.13      if (!(target_id && src && dst))
    1.14          return E_INVALIDARG;
    1.15  
    1.16 +    PEP_encrypt_flags_t engineFlags = (PEP_encrypt_flags_t)flags;
    1.17 +
    1.18      ::pEp_identity *_target_id = new_identity(target_id);
    1.19  
    1.20      ::message *_src = text_message_to_C(src);
    1.21 @@ -880,7 +882,7 @@
    1.22      // free_message() below with a pointer to random garbage in
    1.23      // case of an error in encrypt_message_for_self().
    1.24      ::message *msg_dst = NULL;
    1.25 -    PEP_STATUS status = ::encrypt_message_for_self(get_session(), _target_id, _src, &msg_dst, PEP_enc_PEP);
    1.26 +    PEP_STATUS status = ::encrypt_message_for_self(get_session(), _target_id, _src, &msg_dst, PEP_enc_PEP, engineFlags);
    1.27  
    1.28      if (status == PEP_STATUS_OK)
    1.29          text_message_from_C(dst, msg_dst);
     2.1 --- a/CpEpEngine.h	Mon Mar 06 21:41:29 2017 +0100
     2.2 +++ b/CpEpEngine.h	Thu Mar 09 22:52:01 2017 +0100
     2.3 @@ -214,7 +214,12 @@
     2.4      STDMETHOD(IdentityRating)(pEpIdentity * ident, pEpRating * pVal);
     2.5  	STDMETHOD(ColorFromRating)(pEpRating rating, pEpColor * pVal);
     2.6  
     2.7 -    STDMETHOD(EncryptMessageForSelf)(pEpIdentity * target_id, TextMessage* src, TextMessage *dst);
     2.8 +    STDMETHOD(EncryptMessageForSelf)(
     2.9 +        pEpIdentity * target_id, 
    2.10 +        TextMessage* src,
    2.11 +        TextMessage *dst,
    2.12 +        pEpEncryptFlags flags
    2.13 +        );
    2.14  
    2.15  	// Event callbacks
    2.16  
     3.1 --- a/pEpCOMServerAdapter.idl	Mon Mar 06 21:41:29 2017 +0100
     3.2 +++ b/pEpCOMServerAdapter.idl	Thu Mar 09 22:52:01 2017 +0100
     3.3 @@ -15,17 +15,17 @@
     3.4      pointer_default(unique)
     3.5  ]
     3.6  interface IpEpEngineCallbacks : IUnknown {
     3.7 -	typedef [v1_enum] enum SyncHandshakeSignal {
     3.8 -		SyncNotifyUndefined = 0,
     3.9 -		SyncNotifyInitAddOurDevice = 1,
    3.10 -		SyncNotifyInitAddOtherDevice = 2,
    3.11 -		SyncNotifyInitFormGroup = 3,
    3.12 -		SyncNotifyInitMoveOurDevice = 4,
    3.13 -		SyncNotifyTimeout = 5,
    3.14 -		SyncNotifyAcceptedDeviceAdded = 6,
    3.15 -		SyncNotifyAcceptedGroupCreated = 7,
    3.16 -		SyncNotifyAcceptedDeviceMoved = 8
    3.17 -	} SyncHandshakeSignal;
    3.18 +    typedef [v1_enum] enum SyncHandshakeSignal {
    3.19 +        SyncNotifyUndefined = 0,
    3.20 +        SyncNotifyInitAddOurDevice = 1,
    3.21 +        SyncNotifyInitAddOtherDevice = 2,
    3.22 +        SyncNotifyInitFormGroup = 3,
    3.23 +        SyncNotifyInitMoveOurDevice = 4,
    3.24 +        SyncNotifyTimeout = 5,
    3.25 +        SyncNotifyAcceptedDeviceAdded = 6,
    3.26 +        SyncNotifyAcceptedGroupCreated = 7,
    3.27 +        SyncNotifyAcceptedDeviceMoved = 8
    3.28 +    } SyncHandshakeSignal;
    3.29  
    3.30      typedef [v1_enum] enum SyncHandshakeResult {
    3.31          SyncHandshakeCancel = -1,
    3.32 @@ -137,12 +137,12 @@
    3.33          pEpCtpEp = 0xff
    3.34      } pEpComType;
    3.35  
    3.36 -	typedef [v1_enum] enum pEpIdentityFlags {
    3.37 -		pEpIdfNone = 0,
    3.38 -		pEpIdfNotForSync = 0x0001,
    3.39 -		pEpIdfList = 0x0002,
    3.40 -		pEpIdfDevicegroup = 0x0100
    3.41 -	} pEpIdentityFlags;
    3.42 +    typedef [v1_enum] enum pEpIdentityFlags {
    3.43 +        pEpIdfNone = 0,
    3.44 +        pEpIdfNotForSync = 0x0001,
    3.45 +        pEpIdfList = 0x0002,
    3.46 +        pEpIdfDevicegroup = 0x0100
    3.47 +    } pEpIdentityFlags;
    3.48  
    3.49      [uuid(C3A3814E-567F-4D1C-9F44-9B1DA3957A89)] struct pEpIdentity {
    3.50          BSTR Address;
    3.51 @@ -151,11 +151,11 @@
    3.52          BSTR UserName;
    3.53          pEpComType CommType;
    3.54          BSTR Lang;
    3.55 -		pEpIdentityFlags Flags;
    3.56 +        pEpIdentityFlags Flags;
    3.57      };
    3.58  
    3.59 -	HRESULT SetIdentityFlags([in] struct pEpIdentity *identity, [in] pEpIdentityFlags flags);
    3.60 -	HRESULT UnsetIdentityFlags([in] struct pEpIdentity *identity, [in] pEpIdentityFlags flags);
    3.61 +    HRESULT SetIdentityFlags([in] struct pEpIdentity *identity, [in] pEpIdentityFlags flags);
    3.62 +    HRESULT UnsetIdentityFlags([in] struct pEpIdentity *identity, [in] pEpIdentityFlags flags);
    3.63  
    3.64      // Keymanagement API
    3.65  
    3.66 @@ -167,7 +167,7 @@
    3.67      HRESULT KeyMistrusted([in] struct pEpIdentity *ident);
    3.68      HRESULT KeyResetTrust([in] struct pEpIdentity *ident);
    3.69      HRESULT TrustPersonalKey([in] struct pEpIdentity *ident, [out, retval] struct pEpIdentity *result);
    3.70 -	HRESULT OwnIdentitiesRetrieve([out, retval] SAFEARRAY(struct pEpIdentity)* own_identities);
    3.71 +    HRESULT OwnIdentitiesRetrieve([out, retval] SAFEARRAY(struct pEpIdentity)* own_identities);
    3.72  
    3.73      // Blacklist API
    3.74  
    3.75 @@ -209,6 +209,10 @@
    3.76      typedef [v1_enum] enum pEpEncryptFlags {
    3.77          pEpEncryptFlagsNone = 0,
    3.78          pEpEncryptFlagForceEncryption = 0x1,
    3.79 +
    3.80 +        // This flag is for special uses and should not be used
    3.81 +        // by normal pEp clients!
    3.82 +        pEpEncryptFlagsForceUnsigned = 0x2,
    3.83      } pEpEncryptFlags;
    3.84  
    3.85      typedef [v1_enum] enum pEpDecryptFlags {
    3.86 @@ -288,7 +292,8 @@
    3.87      HRESULT EncryptMessageForSelf(
    3.88          [in] struct pEpIdentity* target_id,
    3.89          [in] struct TextMessage* src, 
    3.90 -        [out] struct TextMessage* dst
    3.91 +        [out] struct TextMessage* dst,
    3.92 +        [in, defaultvalue(pEpEncryptFlagsNone)] pEpEncryptFlags flags
    3.93      );
    3.94  };
    3.95