implementing COM-45
authorVolker Birk <vb@pep-project.org>
Wed, 23 Nov 2016 22:05:36 +0100
changeset 22092489901bb81
parent 219 03531c4d3fda
child 221 d9cda05e4fce
implementing COM-45
CpEpEngine.cpp
pEp_utility.h
     1.1 --- a/CpEpEngine.cpp	Wed Nov 23 20:22:17 2016 +0100
     1.2 +++ b/CpEpEngine.cpp	Wed Nov 23 22:05:36 2016 +0100
     1.3 @@ -911,7 +911,37 @@
     1.4  	if (!own_identities)
     1.5  		return E_INVALIDARG;
     1.6  
     1.7 +	*own_identities = nullptr;
     1.8  
     1.9 +	::identity_list *il = nullptr;
    1.10 +	PEP_STATUS status = ::own_identities_retrieve(get_session(), &il);
    1.11 +	if (status == PEP_OUT_OF_MEMORY) {
    1.12 +		return E_OUTOFMEMORY;
    1.13 +	}
    1.14 +	else if (status != PEP_STATUS_OK)
    1.15 +	{
    1.16 +		return FAIL(_T("OwnIdentitiesRetrieve"), status);
    1.17 +	}
    1.18 +
    1.19 +	SAFEARRAY * _own_identities = nullptr;
    1.20 +	try {
    1.21 +		_own_identities = array_from_C<pEpIdentity, identity_list>(il);
    1.22 +	}
    1.23 +	catch (exception& ex)
    1.24 +	{
    1.25 +		::free_identity_list(il);
    1.26 +		try {
    1.27 +			dynamic_cast<bad_alloc&>(ex);
    1.28 +		}
    1.29 +		catch (bad_cast&)
    1.30 +		{
    1.31 +			return FAIL(ex.what());
    1.32 +		}
    1.33 +		return E_OUTOFMEMORY;
    1.34 +	}
    1.35 +	free_identity_list(il);
    1.36 +
    1.37 +	*own_identities = _own_identities;
    1.38  	return S_OK;
    1.39  }
    1.40  
     2.1 --- a/pEp_utility.h	Wed Nov 23 20:22:17 2016 +0100
     2.2 +++ b/pEp_utility.h	Wed Nov 23 22:05:36 2016 +0100
     2.3 @@ -44,6 +44,7 @@
     2.4  
     2.5  		void opt_field_array_from_C(stringpair_list_t* spair_list, LPSAFEARRAY* pair_list_out);
     2.6  		void clear_opt_field_array(LPSAFEARRAY* pair_list);
     2.7 +		template< class T2, class T > SAFEARRAY * array_from_C(T *tl);
     2.8  
     2.9          static LPTYPELIB pTypelib = NULL;
    2.10