COM-76: Provide is_pep_user to apps
authorMarkus Schaber <markus@pep-security.net>
Thu, 22 Feb 2018 18:28:10 +0100
changeset 274b4f390f0a123
parent 273 30be98685afa
child 277 6d26da1671b3
COM-76: Provide is_pep_user to apps
CpEpEngine.cpp
CpEpEngine.h
pEpCOMServerAdapter.idl
     1.1 --- a/CpEpEngine.cpp	Wed Feb 07 20:23:32 2018 +0100
     1.2 +++ b/CpEpEngine.cpp	Thu Feb 22 18:28:10 2018 +0100
     1.3 @@ -620,6 +620,41 @@
     1.4      return S_OK;
     1.5  }
     1.6  
     1.7 +STDMETHODIMP CpEpEngine::IsPepUser(/* [in] */ struct pEpIdentity *ident, /* [retval][out] */ VARIANT_BOOL *ispEp) 
     1.8 +{
     1.9 +    ::pEp_identity *_ident;
    1.10 +
    1.11 +    assert(ident);
    1.12 +    if (!ident)
    1.13 +        return E_INVALIDARG;
    1.14 +
    1.15 +    try {
    1.16 +        _ident = new_identity(ident);
    1.17 +    }
    1.18 +    catch (bad_alloc&) {
    1.19 +        return E_OUTOFMEMORY;
    1.20 +    }
    1.21 +    catch (exception& ex) {
    1.22 +        return FAIL(ex.what());;
    1.23 +    }
    1.24 +
    1.25 +    bool is_pep = FALSE;
    1.26 +    PEP_STATUS status = ::is_pep_user(get_session(), _ident, &is_pep);
    1.27 +
    1.28 +    *ispEp = is_pep;
    1.29 +
    1.30 +    if (status == PEP_CANNOT_FIND_PERSON)
    1.31 +        return FAIL(L"Cannot find identity!", status);
    1.32 +
    1.33 +    if (status == PEP_ILLEGAL_VALUE)
    1.34 +        return E_INVALIDARG;
    1.35 +
    1.36 +    if (status != ::PEP_STATUS_OK)
    1.37 +        return FAIL(L"Engine is_pep_user returned error", status);
    1.38 +
    1.39 +    return S_OK;
    1.40 +}
    1.41 +
    1.42  STDMETHODIMP CpEpEngine::KeyResetTrust(struct pEpIdentity *ident)
    1.43  {
    1.44      ::pEp_identity *_ident;
     2.1 --- a/CpEpEngine.h	Wed Feb 07 20:23:32 2018 +0100
     2.2 +++ b/CpEpEngine.h	Thu Feb 22 18:28:10 2018 +0100
     2.3 @@ -218,6 +218,12 @@
     2.4      STDMETHOD(TrustPersonalKey)(struct pEpIdentity *ident, struct pEpIdentity *result);
     2.5      STDMETHOD(OwnIdentitiesRetrieve)(LPSAFEARRAY* ownIdentities);
     2.6  
     2.7 +    STDMETHOD(UndoLastMistrust)(); 
     2.8 +    
     2.9 +    STDMETHOD(IsPepUser)(
    2.10 +        /* [in] */ struct pEpIdentity *ident,
    2.11 +        /* [retval][out] */ VARIANT_BOOL *ispEp);
    2.12 +
    2.13      // Blacklist API
    2.14  
    2.15      STDMETHOD(BlacklistAdd)(BSTR fpr);
    2.16 @@ -255,7 +261,6 @@
    2.17      // PGP compatibility functions
    2.18      STDMETHOD(OpenPGPListKeyinfo)(BSTR search_pattern, LPSAFEARRAY* keyinfo_list);
    2.19  
    2.20 -    STDMETHOD(UndoLastMistrust)();
    2.21  
    2.22  protected:
    2.23      HRESULT Fire_MessageToSend(
     3.1 --- a/pEpCOMServerAdapter.idl	Wed Feb 07 20:23:32 2018 +0100
     3.2 +++ b/pEpCOMServerAdapter.idl	Thu Feb 22 18:28:10 2018 +0100
     3.3 @@ -257,17 +257,18 @@
     3.4      [id(19)] HRESULT TrustPersonalKey([in] struct pEpIdentity *ident, [out, retval] struct pEpIdentity *result);
     3.5      [id(20)] HRESULT OwnIdentitiesRetrieve([out, retval] SAFEARRAY(struct pEpIdentity)* ownIdentities);
     3.6      [id(21)] HRESULT UndoLastMistrust();
     3.7 +    [id(22)] HRESULT IsPepUser([in] struct pEpIdentity *ident, [out, retval] VARIANT_BOOL *ispEp);
     3.8  
     3.9      // Blacklist API
    3.10  
    3.11 -    [id(22)] HRESULT BlacklistAdd([in] BSTR fpr);
    3.12 -    [id(23)] HRESULT BlacklistDelete([in] BSTR fpr);
    3.13 -    [id(24)] HRESULT BlacklistIsListed([in] BSTR fpr, [out, retval] VARIANT_BOOL *listed);
    3.14 -    [id(25)] HRESULT BlacklistRetrieve([out, retval] SAFEARRAY(BSTR) *blacklist);
    3.15 +    [id(23)] HRESULT BlacklistAdd([in] BSTR fpr);
    3.16 +    [id(24)] HRESULT BlacklistDelete([in] BSTR fpr);
    3.17 +    [id(25)] HRESULT BlacklistIsListed([in] BSTR fpr, [out, retval] VARIANT_BOOL *listed);
    3.18 +    [id(26)] HRESULT BlacklistRetrieve([out, retval] SAFEARRAY(BSTR) *blacklist);
    3.19  
    3.20      // PGP compatibility functions
    3.21  
    3.22 -    [id(26)] HRESULT OpenPGPListKeyinfo([in] BSTR searchPattern, [out, retval] SAFEARRAY(struct StringPair)* keyinfoList);
    3.23 +    [id(27)] HRESULT OpenPGPListKeyinfo([in] BSTR searchPattern, [out, retval] SAFEARRAY(struct StringPair)* keyinfoList);
    3.24  
    3.25      // Message API
    3.26  
    3.27 @@ -362,7 +363,7 @@
    3.28          SAFEARRAY(struct StringPair) OptFields;
    3.29      };
    3.30  
    3.31 -    [id(27)] HRESULT EncryptMessage(
    3.32 +    [id(28)] HRESULT EncryptMessage(
    3.33          [in] struct TextMessage *src,
    3.34          [out] struct TextMessage * dst,
    3.35          [in] SAFEARRAY(BSTR) extra,
    3.36 @@ -372,18 +373,18 @@
    3.37          // for compatibility and not intended for normal use.
    3.38          [in, defaultvalue(pEpEncPep)] pEpEncFormat encFormat);
    3.39  
    3.40 -    [id(28)] HRESULT DecryptMessage(
    3.41 +    [id(29)] HRESULT DecryptMessage(
    3.42          [in] struct TextMessage *src,
    3.43          [out] struct TextMessage * dst,
    3.44          [out] SAFEARRAY(BSTR) *keylist,
    3.45          [out] pEpDecryptFlags* flags,
    3.46          [out, retval] pEpRating *rating);
    3.47  
    3.48 -    [id(29)] HRESULT OutgoingMessageRating([in] struct TextMessage *msg, [out, retval] pEpRating * pVal);
    3.49 -    [id(30)] HRESULT IdentityRating([in] struct pEpIdentity * ident, [out, retval] pEpRating * pVal);
    3.50 -    [id(31)] HRESULT ColorFromRating([in] pEpRating rating, [out, retval] pEpColor* pVal);
    3.51 +    [id(30)] HRESULT OutgoingMessageRating([in] struct TextMessage *msg, [out, retval] pEpRating * pVal);
    3.52 +    [id(31)] HRESULT IdentityRating([in] struct pEpIdentity * ident, [out, retval] pEpRating * pVal);
    3.53 +    [id(32)] HRESULT ColorFromRating([in] pEpRating rating, [out, retval] pEpColor* pVal);
    3.54  
    3.55 -    [id(32)] HRESULT GetMessageTrustwords(
    3.56 +    [id(33)] HRESULT GetMessageTrustwords(
    3.57          [in] struct TextMessage *msg,
    3.58          [in] struct pEpIdentity * receivedBy,
    3.59          [in] SAFEARRAY(BSTR) keylist,
    3.60 @@ -392,14 +393,14 @@
    3.61          [out, retval] BSTR * words
    3.62      );
    3.63  
    3.64 -    [id(33)] HRESULT EncryptMessageForSelf(
    3.65 +    [id(34)] HRESULT EncryptMessageForSelf(
    3.66          [in] struct pEpIdentity* targetId,
    3.67          [in] struct TextMessage* src,
    3.68          [out] struct TextMessage* dst,
    3.69          [in, defaultvalue(pEpEncryptFlagDefault)] pEpEncryptFlags flags
    3.70      );
    3.71  
    3.72 -    [id(34)] HRESULT ReEvaluateMessageRating(
    3.73 +    [id(35)] HRESULT ReEvaluateMessageRating(
    3.74          [in] struct TextMessage *src,
    3.75          [in] SAFEARRAY(BSTR) x_KeyList, // referring to X-KeyList mail header
    3.76          [in] pEpRating x_EncStatus, // referring to X-EncStatus mail header
    3.77 @@ -407,8 +408,8 @@
    3.78      );
    3.79  
    3.80      // callback / keysync API
    3.81 -    [id(35)] HRESULT RegisterCallbacks([in] IpEpEngineCallbacks* newCallback);
    3.82 -    [id(36)] HRESULT UnregisterCallbacks();
    3.83 +    [id(36)] HRESULT RegisterCallbacks([in] IpEpEngineCallbacks* newCallback);
    3.84 +    [id(37)] HRESULT UnregisterCallbacks();
    3.85  };
    3.86  
    3.87  [