Browse Source

add set_own_key(me, fpr) to Basic API

PYADPT-55
heck 6 years ago
parent
commit
0ca729dd2a
  1. 24
      src/basic_api.cc
  2. 2
      src/basic_api.hh
  3. 19
      src/pEpmodule.cc

24
src/basic_api.cc

@ -49,7 +49,7 @@ namespace pEp {
_throw_status(status);
return words;
}
void trust_personal_key(Identity ident)
{
if (ident.fpr() == "")
@ -82,7 +82,7 @@ namespace pEp {
PEP_STATUS status = unset_identity_flags(adapter.session(), ident, flags);
_throw_status(status);
}
void key_reset_trust(Identity ident)
{
if (ident.fpr() == "")
@ -96,6 +96,8 @@ namespace pEp {
_throw_status(status);
}
boost::python::list import_key(string key_data)
{
::identity_list *private_keys = NULL;
@ -116,6 +118,22 @@ namespace pEp {
free_identity_list(private_keys);
return result;
}
void set_own_key(Identity& ident, string fpr)
{
if (ident.address() == "")
throw invalid_argument("address needed");
if (ident.username() == "")
throw invalid_argument("username needed");
if (ident.user_id() == "")
throw invalid_argument("user_id needed");
if (fpr == "")
throw invalid_argument("fpr needed");
const char* fpr_c = fpr.c_str();
PEP_STATUS status = set_own_key(adapter.session(), ident, fpr_c);
_throw_status(status);
}
}
}

2
src/basic_api.hh

@ -18,6 +18,6 @@ namespace pEp {
void key_reset_trust(Identity ident);
boost::python::list import_key(string key_data);
void set_own_key(Identity& ident, string fpr);
}
}

19
src/pEpmodule.cc

@ -138,7 +138,7 @@ BOOST_PYTHON_MODULE(pEp)
scope().attr("per_machine_directory") = per_machine_directory();
scope().attr("engine_version") = get_engine_version();
scope().attr("protocol_version") = get_protocol_version();
def("passive_mode", pEp::PythonAdapter::config_passive_mode,
"do not attach pub keys to all messages");
@ -227,7 +227,7 @@ BOOST_PYTHON_MODULE(pEp)
.def("__deepcopy__", &pEp::PythonAdapter::Identity::deepcopy)
.def("update", &pEp::PythonAdapter::Identity::update, "update Identity")
.def("__copy__", &pEp::PythonAdapter::Identity::copy);
identity_class.attr("PEP_OWN_USERID") = "pEp_own_userId";
auto blob_class = class_<Message::Blob>("Blob",
@ -425,6 +425,21 @@ BOOST_PYTHON_MODULE(pEp)
"import key(s) from key_data\n"
);
def("set_own_key", &pEp::PythonAdapter::set_own_key,
"set_own_key(me, fpr)\n"
"\n"
"mark a key as an own key, and make it the default key\n"
"\n"
"me Own identity for which to add the existing key\n"
"fpr The fingerprint of the key to be added\n"
"\n"
"me->address, me->user_id and me->username must be set to valid data\n"
"myself() is called by set_own_key() without key generation\n"
"me->flags are ignored\n"
"me->address must not be an alias\n"
"me->fpr will be ignored and replaced by fpr\n"
);
// message API
enum_<PEP_rating>("PEP_rating")

Loading…
Cancel
Save