diff --git a/src/pEpmodule.cc b/src/pEpmodule.cc index c7b11fd..b950b21 100644 --- a/src/pEpmodule.cc +++ b/src/pEpmodule.cc @@ -405,9 +405,11 @@ BOOST_PYTHON_MODULE(pEp) "\n" "overwrite this method with an implementation of a handshake dialog") .def("deliverHandshakeResult", &UserInterface::deliverHandshakeResult, - "deliverHandshakeResult(self, result)\n" + boost::python::arg("identities")=object(), + "deliverHandshakeResult(self, result, identities=None)\n" "\n" " result -1: cancel, 0: accepted, 1: rejected\n" + " identities list of identities to share or None for all\n" "\n" "call to deliver the handshake result of the handshake dialog") ; diff --git a/src/user_interface.cc b/src/user_interface.cc index 75d30fa..78d37a5 100644 --- a/src/user_interface.cc +++ b/src/user_interface.cc @@ -51,10 +51,32 @@ namespace pEp { return PEP_STATUS_OK; } - void UserInterface::deliverHandshakeResult(int result) + void UserInterface::deliverHandshakeResult(int result, object identities) { + identity_list *shared_identities = nullptr; + if (identities != boost::python::api::object()) { + shared_identities = new_identity_list(nullptr); + if (!shared_identities) + throw bad_alloc(); + + try { + identity_list *si = shared_identities; + for (int i=0; i < boost::python::len(identities); ++i) { + Identity ident = extract< Identity >(identities[i]); + si = identity_list_add(si, ident); + if (!si) + throw bad_alloc(); + } + } + catch (exception& ex) { + free_identity_list(shared_identities); + throw ex; + } + } + PEP_STATUS status = ::deliverHandshakeResult(adapter.session(), - (sync_handshake_result) result); + (sync_handshake_result) result, shared_identities); + free_identity_list(shared_identities); _throw_status(status); } diff --git a/src/user_interface.hh b/src/user_interface.hh index 260d855..dfacc6f 100644 --- a/src/user_interface.hh +++ b/src/user_interface.hh @@ -24,7 +24,7 @@ namespace pEp { throw runtime_error("override this method"); } - virtual void deliverHandshakeResult(int result); + virtual void deliverHandshakeResult(int result, object identities); PEP_rating get_key_rating_for_user(string user_id, string fpr);