Browse Source

after discussing with heck, export both imported_keys and import_key_with_fpr_return with the same semantics of the C API

positron-nkls-mixnet
Luca Saiu 2 years ago
parent
commit
f2dc51e676
  1. 27
      src/pEp/_pEp/basic_api.cc
  2. 4
      src/pEp/_pEp/basic_api.hh
  3. 11
      src/pEp/_pEp/pEpmodule.cc

27
src/pEp/_pEp/basic_api.cc

@ -110,7 +110,32 @@ namespace pEp {
_throw_status(status);
}
boost::python::tuple import_key(string key_data)
boost::python::list import_key(string key_data)
{
::identity_list *private_keys = NULL;
PEP_STATUS status = ::import_key(
Adapter::session(),
key_data.c_str(),
key_data.size(),
&private_keys);
if (status && status != PEP_KEY_IMPORTED)
_throw_status(status);
auto result = boost::python::list();
for (::identity_list *il = private_keys; il && il->ident; il = il->next) {
::pEp_identity *ident = ::identity_dup(il->ident);
if (!ident) {
free_identity_list(private_keys);
throw std::bad_alloc();
}
result.append(Identity(ident));
}
free_identity_list(private_keys);
return result;
}
boost::python::tuple import_key_with_fpr_return(string key_data)
{
::identity_list *private_keys = NULL;
::stringlist_t *imported_keys = NULL;

4
src/pEp/_pEp/basic_api.hh

@ -23,7 +23,9 @@ namespace pEp {
void key_reset_trust(Identity ident);
boost::python::tuple import_key(string key_data);
boost::python::list import_key(string key_data);
boost::python::tuple import_key_with_fpr_return(string key_data);
string export_key(Identity ident);

11
src/pEp/_pEp/pEpmodule.cc

@ -650,10 +650,19 @@ namespace pEp {
def("import_key",
&import_key,
"imported_keys, affected_own_identities = import_key(key_data)\n"
"private_key_list = import_key(key_data)\n"
"\n"
"import key(s) from key_data\n");
def("import_key_with_fpr_return",
&import_key_with_fpr_return,
"imported_keys, affected_own_identities = import_key_with_fpr_return(key_data)\n"
"\n"
"import key(s) from key_data\n"
"\n"
"imported_keys a list of FPRs\n"
"affected_own_identities the list of modified own identities\n");
def("export_key",
&export_key,
"key_data = export_key(identity)\n"

Loading…
Cancel
Save