add SetOwnKey()
authorVolker Birk <vb@pep.foundation>
Sat, 24 Feb 2018 21:19:56 +0100
changeset 278ae41fbcb1fd6
parent 277 6d26da1671b3
child 279 79c90923f384
add SetOwnKey()
CpEpEngine.cpp
CpEpEngine.h
pEpCOMServerAdapter.idl
     1.1 --- a/CpEpEngine.cpp	Sat Feb 24 21:04:09 2018 +0100
     1.2 +++ b/CpEpEngine.cpp	Sat Feb 24 21:19:56 2018 +0100
     1.3 @@ -1474,6 +1474,49 @@
     1.4  
     1.5  }
     1.6  
     1.7 +STDMETHODIMP CpEpEngine::SetOwnKey(pEpIdentity * ident, BSTR fpr, struct pEpIdentity *result)
     1.8 +{
     1.9 +	assert(ident);
    1.10 +	assert(result);
    1.11 +	assert(fpr);
    1.12 +
    1.13 +	if (!(ident && result))
    1.14 +		return E_INVALIDARG;
    1.15 +
    1.16 +	::pEp_identity *_ident;
    1.17 +	try {
    1.18 +		_ident = new_identity(ident);
    1.19 +	}
    1.20 +	catch (bad_alloc&) {
    1.21 +		return E_OUTOFMEMORY;
    1.22 +	}
    1.23 +	catch (exception& ex) {
    1.24 +		return FAIL(ex.what());
    1.25 +	}
    1.26 +
    1.27 +	assert(_ident);
    1.28 +	if (_ident == NULL)
    1.29 +		return E_OUTOFMEMORY;
    1.30 +
    1.31 +	string _fpr = utf8_string(fpr);
    1.32 +	PEP_STATUS status = ::set_own_key(get_session(), _ident, _fpr.c_str());
    1.33 +
    1.34 +	if (status == PEP_STATUS_OK) {
    1.35 +		copy_identity(result, _ident);
    1.36 +		::free_identity(_ident);
    1.37 +		return S_OK;
    1.38 +	}
    1.39 +	else {
    1.40 +		::free_identity(_ident);
    1.41 +		if (status == PEP_OUT_OF_MEMORY)
    1.42 +			return E_OUTOFMEMORY;
    1.43 +		else
    1.44 +			return FAIL(L"SetOwnKey", status);
    1.45 +	}
    1.46 +
    1.47 +	return S_OK;
    1.48 +}
    1.49 +
    1.50  HRESULT CpEpEngine::Fire_MessageToSend(TextMessage * msg)
    1.51  {
    1.52      assert(msg);
     2.1 --- a/CpEpEngine.h	Sat Feb 24 21:04:09 2018 +0100
     2.2 +++ b/CpEpEngine.h	Sat Feb 24 21:19:56 2018 +0100
     2.3 @@ -260,6 +260,7 @@
     2.4  
     2.5      // PGP compatibility functions
     2.6      STDMETHOD(OpenPGPListKeyinfo)(BSTR search_pattern, LPSAFEARRAY* keyinfo_list);
     2.7 +	STDMETHOD(SetOwnKey)(pEpIdentity * ident, BSTR fpr, struct pEpIdentity *result);
     2.8  
     2.9  
    2.10  protected:
     3.1 --- a/pEpCOMServerAdapter.idl	Sat Feb 24 21:04:09 2018 +0100
     3.2 +++ b/pEpCOMServerAdapter.idl	Sat Feb 24 21:19:56 2018 +0100
     3.3 @@ -410,6 +410,14 @@
     3.4      // callback / keysync API
     3.5      [id(36)] HRESULT RegisterCallbacks([in] IpEpEngineCallbacks* newCallback);
     3.6      [id(37)] HRESULT UnregisterCallbacks();
     3.7 +
     3.8 +	// mark imported keys as trusted
     3.9 +
    3.10 +	HRESULT SetOwnKey(
    3.11 +		[in] struct pEpIdentity * ident,
    3.12 +		[in] BSTR fpr,
    3.13 +		[out, retval] struct pEpIdentity * result
    3.14 +	);
    3.15  };
    3.16  
    3.17  [