Merged in COM-28
authorKrista Grothoff <krista@pep-project.org>
Thu, 08 Sep 2016 11:25:54 +0200
changeset 161efff4dee3daf
parent 153 aecfde0414f7
parent 160 9b97e91f4ad0
child 162 38cdf441c2cb
Merged in COM-28
     1.1 --- a/CpEpEngine.cpp	Mon Aug 29 12:25:21 2016 +0200
     1.2 +++ b/CpEpEngine.cpp	Thu Sep 08 11:25:54 2016 +0200
     1.3 @@ -1300,6 +1300,38 @@
     1.4  	return S_FALSE;
     1.5  }
     1.6  
     1.7 +STDMETHODIMP CpEpEngine::OpenPGP_list_keyinfo(BSTR search_pattern, LPSAFEARRAY* keyinfo_list) {
     1.8 +    assert(keyinfo_list);
     1.9 +    
    1.10 +    if (keyinfo_list == NULL)
    1.11 +        return E_INVALIDARG;
    1.12 +
    1.13 +    string _pattern = "";
    1.14 +    if (search_pattern)
    1.15 +        _pattern = utf8_string(search_pattern);
    1.16 +    ::stringpair_list_t* _keyinfo_list = NULL;
    1.17 +
    1.18 +    PEP_STATUS status = ::OpenPGP_list_keyinfo(get_session(), _pattern.c_str(), &_keyinfo_list);
    1.19 +    assert(status != PEP_OUT_OF_MEMORY);
    1.20 +    if (status == PEP_OUT_OF_MEMORY)
    1.21 +        return E_OUTOFMEMORY;
    1.22 +
    1.23 +    if (status != ::PEP_STATUS_OK)
    1.24 +        return FAIL(L"OpenPGP_list_keyinfo");
    1.25 +
    1.26 +    if (_keyinfo_list && _keyinfo_list->value) {
    1.27 +        ::opt_field_array_from_C(_keyinfo_list, keyinfo_list);
    1.28 +    }
    1.29 +    else {
    1.30 +        ::free_stringpair_list(_keyinfo_list);
    1.31 +        return FAIL(L"OpenPGP_list_keyinfo: no keys found");
    1.32 +    }
    1.33 +
    1.34 +    ::free_stringpair_list(_keyinfo_list);
    1.35 +    return S_OK;
    1.36 +    
    1.37 +}
    1.38 +
    1.39  HRESULT CpEpEngine::Fire_MessageToSend(text_message * msg)
    1.40  {
    1.41  	callbacks cbs = get_callbacks();
     2.1 --- a/CpEpEngine.h	Mon Aug 29 12:25:21 2016 +0200
     2.2 +++ b/CpEpEngine.h	Thu Sep 08 11:25:54 2016 +0200
     2.3 @@ -226,6 +226,9 @@
     2.4  
     2.5  	STDMETHOD(register_callbacks)(IpEpEngineCallbacks *new_callback);
     2.6  	STDMETHOD(unregister_callbacks)(IpEpEngineCallbacks *obsolete_callback);
     2.7 +    
     2.8 +    // PGP compatibility functions
     2.9 +    STDMETHOD(OpenPGP_list_keyinfo)(BSTR search_pattern, LPSAFEARRAY* keyinfo_list);
    2.10  
    2.11  protected:
    2.12  	HRESULT Fire_MessageToSend(
     3.1 --- a/pEpCOMServerAdapter.idl	Mon Aug 29 12:25:21 2016 +0200
     3.2 +++ b/pEpCOMServerAdapter.idl	Thu Sep 08 11:25:54 2016 +0200
     3.3 @@ -205,6 +205,9 @@
     3.4      HRESULT blacklist_is_listed([in] BSTR fpr, [out, retval] VARIANT_BOOL *listed);
     3.5      HRESULT blacklist_retrieve([out, retval] SAFEARRAY(BSTR) *blacklist);
     3.6  
     3.7 +	// PGP compatibility functions
     3.8 +	HRESULT OpenPGP_list_keyinfo([in] BSTR search_pattern, [out, retval] SAFEARRAY(struct opt_field)* keyinfo_list);
     3.9 +
    3.10      // Message API
    3.11  
    3.12      typedef enum _pEp_color {
     4.1 --- a/pEp_utility.cpp	Mon Aug 29 12:25:21 2016 +0200
     4.2 +++ b/pEp_utility.cpp	Thu Sep 08 11:25:54 2016 +0200
     4.3 @@ -521,5 +521,19 @@
     4.4  
     4.5              return msg2;
     4.6          }
     4.7 +		void opt_field_array_from_C(stringpair_list_t* spair_list, LPSAFEARRAY* pair_list_out) {
     4.8 +			assert(spair_list);
     4.9 +			assert(pair_list_out);
    4.10 +			
    4.11 +			if (!spair_list)
    4.12 +				return;
    4.13 +
    4.14 +			*pair_list_out = array_from_C<opt_field, stringpair_list_t>(spair_list);
    4.15 +		}
    4.16 +		void clear_opt_field_array(LPSAFEARRAY* opt_field_array) {
    4.17 +			SafeArrayDestroy(*opt_field_array);
    4.18 +			//memset(*opt_field_array, 0, sizeof(SAFEARRAY*));
    4.19 +			*opt_field_array = NULL;
    4.20 +		}
    4.21      }
    4.22  }
     5.1 --- a/pEp_utility.h	Mon Aug 29 12:25:21 2016 +0200
     5.2 +++ b/pEp_utility.h	Thu Sep 08 11:25:54 2016 +0200
     5.3 @@ -41,6 +41,9 @@
     5.4          void clear_text_message(text_message *msg);
     5.5          ::pEp_identity *new_identity(const pEp_identity_s * ident);
     5.6  
     5.7 +		void opt_field_array_from_C(stringpair_list_t* spair_list, LPSAFEARRAY* pair_list_out);
     5.8 +		void clear_opt_field_array(LPSAFEARRAY* pair_list);
     5.9 +
    5.10          static LPTYPELIB pTypelib = NULL;
    5.11  
    5.12          template< class UDType > static IRecordInfo *getRecordInfo()
     6.1 --- a/stdafx.h	Mon Aug 29 12:25:21 2016 +0200
     6.2 +++ b/stdafx.h	Thu Sep 08 11:25:54 2016 +0200
     6.3 @@ -49,4 +49,5 @@
     6.4  #include "../pEpEngine/src/message_api.h"
     6.5  #include "../pEpEngine/src/stringpair.h"
     6.6  #include "../pEpEngine/src/blacklist.h"
     6.7 -#include "../pEpEngine/src/sync.h"
     6.8 \ No newline at end of file
     6.9 +#include "../pEpEngine/src/sync.h"
    6.10 +#include "../pEpEngine/src/openpgp_compat.h"
    6.11 \ No newline at end of file