|
@ -1,6 +1,7 @@ |
|
|
// This file is under GNU Affero General Public License 3.0
|
|
|
// This file is under GNU Affero General Public License 3.0
|
|
|
// see LICENSE.txt
|
|
|
// see LICENSE.txt
|
|
|
|
|
|
|
|
|
|
|
|
// System
|
|
|
#include <boost/python.hpp> |
|
|
#include <boost/python.hpp> |
|
|
#include <boost/locale.hpp> |
|
|
#include <boost/locale.hpp> |
|
|
#include <string> |
|
|
#include <string> |
|
@ -8,67 +9,76 @@ |
|
|
#include <iomanip> |
|
|
#include <iomanip> |
|
|
#include <mutex> |
|
|
#include <mutex> |
|
|
|
|
|
|
|
|
#include <pEp/Adapter.hh> |
|
|
// Engine
|
|
|
#include <pEp/key_reset.h> |
|
|
#include <pEp/key_reset.h> |
|
|
#include <pEp/message_api.h> |
|
|
#include <pEp/message_api.h> |
|
|
#include <pEp/sync_api.h> |
|
|
#include <pEp/sync_api.h> |
|
|
#include <pEp/status_to_string.h> |
|
|
#include <pEp/status_to_string.h> |
|
|
|
|
|
|
|
|
|
|
|
// libpEpAdapter
|
|
|
|
|
|
#include <pEp/Adapter.hh> |
|
|
|
|
|
#include <pEp/callback_dispatcher.hh> |
|
|
|
|
|
#include <pEp/pEpLog.hh> |
|
|
|
|
|
|
|
|
|
|
|
// local
|
|
|
#include "pEpmodule.hh" |
|
|
#include "pEpmodule.hh" |
|
|
#include "basic_api.hh" |
|
|
#include "basic_api.hh" |
|
|
#include "message_api.hh" |
|
|
#include "message_api.hh" |
|
|
#include "user_interface.hh" |
|
|
#include "user_interface.hh" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace pEp { |
|
|
namespace pEp { |
|
|
namespace PythonAdapter { |
|
|
namespace PythonAdapter { |
|
|
using namespace std; |
|
|
using namespace std; |
|
|
|
|
|
using namespace boost::python; |
|
|
|
|
|
|
|
|
// Adapter adapter(true);
|
|
|
scope *_scope = NULL; |
|
|
|
|
|
static const char *version_string = "p≡p Python adapter version 0.3"; |
|
|
|
|
|
|
|
|
void config_passive_mode(bool enable) |
|
|
void _init() { |
|
|
{ |
|
|
pEpLog("called"); |
|
|
|
|
|
callback_dispatcher.add(_messageToSend, nullptr, nullptr, nullptr); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void config_passive_mode(bool enable) |
|
|
|
|
|
{ |
|
|
::config_passive_mode(pEp::Adapter::session(), enable); |
|
|
::config_passive_mode(pEp::Adapter::session(), enable); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void config_unencrypted_subject(bool enable) |
|
|
void config_unencrypted_subject(bool enable) |
|
|
{ |
|
|
{ |
|
|
::config_unencrypted_subject(pEp::Adapter::session(), enable); |
|
|
::config_unencrypted_subject(pEp::Adapter::session(), enable); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void key_reset_user(string user_id, string fpr) |
|
|
void key_reset_user(string user_id, string fpr) |
|
|
{ |
|
|
{ |
|
|
if (user_id == "") |
|
|
if (user_id == "") |
|
|
throw invalid_argument("user_id required"); |
|
|
throw invalid_argument("user_id required"); |
|
|
|
|
|
|
|
|
PEP_STATUS status = ::key_reset_user(pEp::Adapter::session(), |
|
|
PEP_STATUS status = ::key_reset_user(pEp::Adapter::session(), |
|
|
user_id.c_str(), fpr != "" ? fpr.c_str() : nullptr); |
|
|
user_id.c_str(), fpr != "" ? fpr.c_str() : nullptr); |
|
|
_throw_status(status); |
|
|
_throw_status(status); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void key_reset_user2(string user_id) |
|
|
void key_reset_user2(string user_id) |
|
|
{ |
|
|
{ |
|
|
key_reset_user(user_id, ""); |
|
|
key_reset_user(user_id, ""); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void key_reset_all_own_keys() |
|
|
void key_reset_all_own_keys() |
|
|
{ |
|
|
{ |
|
|
PEP_STATUS status = ::key_reset_all_own_keys(pEp::Adapter::session()); |
|
|
PEP_STATUS status = ::key_reset_all_own_keys(pEp::Adapter::session()); |
|
|
_throw_status(status); |
|
|
_throw_status(status); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
scope *_scope = NULL; |
|
|
|
|
|
|
|
|
|
|
|
static const char *version_string = "p≡p Python adapter version 0.3"; |
|
|
static string about() |
|
|
static string about() |
|
|
{ |
|
|
{ |
|
|
|
|
|
string version = string(version_string) + "\np≡p version " |
|
|
string version = string(version_string) + "\np≡p version " |
|
|
+ PEP_VERSION + "\n"; |
|
|
+ PEP_VERSION + "\n"; |
|
|
return version; |
|
|
return version; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void _throw_status(PEP_STATUS status) |
|
|
void _throw_status(PEP_STATUS status) |
|
|
{ |
|
|
{ |
|
|
if (status == PEP_STATUS_OK) |
|
|
if (status == PEP_STATUS_OK) |
|
|
return; |
|
|
return; |
|
|
if (status >= 0x400 && status <= 0x4ff) |
|
|
if (status >= 0x400 && status <= 0x4ff) |
|
@ -86,15 +96,15 @@ namespace pEp { |
|
|
else { |
|
|
else { |
|
|
throw runtime_error(pEp_status_to_string(status)); |
|
|
throw runtime_error(pEp_status_to_string(status)); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
PEP_STATUS _ensure_passphrase(PEP_SESSION session, const char *fpr) |
|
|
PEP_STATUS _ensure_passphrase(PEP_SESSION session, const char *fpr) |
|
|
{ |
|
|
{ |
|
|
return PEP_STATUS_OK; |
|
|
return PEP_STATUS_OK; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
PEP_STATUS _messageToSend(::message *msg) |
|
|
PEP_STATUS _messageToSend(::message *msg) |
|
|
{ |
|
|
{ |
|
|
if (!_scope) |
|
|
if (!_scope) |
|
|
return PEP_SEND_FUNCTION_NOT_REGISTERED; |
|
|
return PEP_SEND_FUNCTION_NOT_REGISTERED; |
|
|
|
|
|
|
|
@ -105,83 +115,84 @@ namespace pEp { |
|
|
catch (exception& e) { } |
|
|
catch (exception& e) { } |
|
|
|
|
|
|
|
|
return PEP_STATUS_OK; |
|
|
return PEP_STATUS_OK; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void messageToSend(Message msg) { |
|
|
void messageToSend(Message msg) { |
|
|
throw runtime_error("implement pEp.messageToSend(msg)"); |
|
|
throw runtime_error("implement pEp.messageToSend(msg)"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// void do_sync_protocol()
|
|
|
// void do_sync_protocol()
|
|
|
// {
|
|
|
// {
|
|
|
// ::do_sync_protocol(pEp::Adapter::session(), nullptr);
|
|
|
// ::do_sync_protocol(pEp::Adapter::session(), nullptr);
|
|
|
// }
|
|
|
// }
|
|
|
|
|
|
|
|
|
void shutdown_sync() |
|
|
void shutdown_sync() |
|
|
{ |
|
|
{ |
|
|
pEp::Adapter::shutdown(); |
|
|
pEp::Adapter::shutdown(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void debug_color(int ansi_color) |
|
|
void debug_color(int ansi_color) |
|
|
{ |
|
|
{ |
|
|
::set_debug_color(pEp::Adapter::session(), ansi_color); |
|
|
::set_debug_color(pEp::Adapter::session(), ansi_color); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void leave_device_group() { |
|
|
void leave_device_group() |
|
|
|
|
|
{ |
|
|
::leave_device_group(pEp::Adapter::session()); |
|
|
::leave_device_group(pEp::Adapter::session()); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// void script_is_implementing_sync() {
|
|
|
// void script_is_implementing_sync() {
|
|
|
// adapter.script_is_implementing_sync();
|
|
|
// adapter.script_is_implementing_sync();
|
|
|
// }
|
|
|
// }
|
|
|
|
|
|
|
|
|
bool is_sync_active() { |
|
|
bool is_sync_active() |
|
|
|
|
|
{ |
|
|
return pEp::Adapter::is_sync_running(); |
|
|
return pEp::Adapter::is_sync_running(); |
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
BOOST_PYTHON_MODULE(native_pEp) |
|
|
BOOST_PYTHON_MODULE(native_pEp) |
|
|
{ |
|
|
{ |
|
|
using namespace boost::python; |
|
|
|
|
|
using namespace boost::locale; |
|
|
|
|
|
using namespace pEp::PythonAdapter; |
|
|
|
|
|
|
|
|
|
|
|
docstring_options doc_options(true, false, false); |
|
|
docstring_options doc_options(true, false, false); |
|
|
|
|
|
|
|
|
generator gen; |
|
|
boost::locale::generator gen; |
|
|
std::locale::global(gen("")); |
|
|
std::locale::global(gen("")); |
|
|
_scope = new scope(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Module init function called by pEp.init()
|
|
|
|
|
|
def("_init", _init); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_scope = new scope(); |
|
|
scope().attr("about") = about(); |
|
|
scope().attr("about") = about(); |
|
|
scope().attr("per_user_directory") = per_user_directory(); |
|
|
scope().attr("per_user_directory") = per_user_directory(); |
|
|
scope().attr("per_machine_directory") = per_machine_directory(); |
|
|
scope().attr("per_machine_directory") = per_machine_directory(); |
|
|
scope().attr("engine_version") = get_engine_version(); |
|
|
scope().attr("engine_version") = get_engine_version(); |
|
|
scope().attr("protocol_version") = get_protocol_version(); |
|
|
scope().attr("protocol_version") = get_protocol_version(); |
|
|
|
|
|
|
|
|
def("passive_mode", pEp::PythonAdapter::config_passive_mode, |
|
|
def("passive_mode", config_passive_mode, |
|
|
"do not attach pub keys to all messages"); |
|
|
"do not attach pub keys to all messages"); |
|
|
|
|
|
|
|
|
def("unencrypted_subject", pEp::PythonAdapter::config_unencrypted_subject, |
|
|
def("unencrypted_subject", config_unencrypted_subject, |
|
|
"do not encrypt the subject of messages"); |
|
|
"do not encrypt the subject of messages"); |
|
|
|
|
|
|
|
|
def("key_reset", pEp::PythonAdapter::key_reset_user, |
|
|
def("key_reset", key_reset_user, |
|
|
"reset the default database status for the user / keypair provided\n" |
|
|
"reset the default database status for the user / keypair provided\n" |
|
|
"This will effectively perform key_reset on each identity\n" |
|
|
"This will effectively perform key_reset on each identity\n" |
|
|
"associated with the key and user_id, if a key is provided, and for\n" |
|
|
"associated with the key and user_id, if a key is provided, and for\n" |
|
|
"each key (and all of their identities) if an fpr is not."); |
|
|
"each key (and all of their identities) if an fpr is not."); |
|
|
|
|
|
|
|
|
def("key_reset", pEp::PythonAdapter::key_reset_user2, |
|
|
def("key_reset", key_reset_user2, |
|
|
"reset the default database status for the user / keypair provided\n" |
|
|
"reset the default database status for the user / keypair provided\n" |
|
|
"This will effectively perform key_reset on each identity\n" |
|
|
"This will effectively perform key_reset on each identity\n" |
|
|
"associated with the key and user_id, if a key is provided, and for\n" |
|
|
"associated with the key and user_id, if a key is provided, and for\n" |
|
|
"each key (and all of their identities) if an fpr is not."); |
|
|
"each key (and all of their identities) if an fpr is not."); |
|
|
|
|
|
|
|
|
def("key_reset_all_own_keys", pEp::PythonAdapter::key_reset_all_own_keys, |
|
|
def("key_reset_all_own_keys", key_reset_all_own_keys, |
|
|
"revoke and mistrust all own keys, generate new keys for all\n" |
|
|
"revoke and mistrust all own keys, generate new keys for all\n" |
|
|
"own identities, and opportunistically communicate key reset\n" |
|
|
"own identities, and opportunistically communicate key reset\n" |
|
|
"information to people we have recently contacted."); |
|
|
"information to people we have recently contacted."); |
|
|
|
|
|
|
|
|
auto identity_class = class_<pEp::PythonAdapter::Identity>("Identity", |
|
|
auto identity_class = class_<Identity>("Identity", |
|
|
"Identity(address, username, user_id='', fpr='', comm_type=0, lang='en')\n" |
|
|
"Identity(address, username, user_id='', fpr='', comm_type=0, lang='en')\n" |
|
|
"\n" |
|
|
"\n" |
|
|
"represents a p≡p identity\n" |
|
|
"represents a p≡p identity\n" |
|
@ -204,12 +215,12 @@ BOOST_PYTHON_MODULE(native_pEp) |
|
|
.def(boost::python::init<string, string, string, string>()) |
|
|
.def(boost::python::init<string, string, string, string>()) |
|
|
.def(boost::python::init<string, string, string, string, int>()) |
|
|
.def(boost::python::init<string, string, string, string, int>()) |
|
|
.def(boost::python::init<string, string, string, string, int, string>()) |
|
|
.def(boost::python::init<string, string, string, string, int, string>()) |
|
|
.def("__repr__", &pEp::PythonAdapter::Identity::_repr) |
|
|
.def("__repr__", &Identity::_repr) |
|
|
.def("__str__", &pEp::PythonAdapter::Identity::_str, |
|
|
.def("__str__", &Identity::_str, |
|
|
"string representation of this identity\n" |
|
|
"string representation of this identity\n" |
|
|
"following the pattern 'username < address >'\n" |
|
|
"following the pattern 'username < address >'\n" |
|
|
) |
|
|
) |
|
|
.def("key_reset", &pEp::PythonAdapter::Identity::key_reset, |
|
|
.def("key_reset", &Identity::key_reset, |
|
|
boost::python::arg("fpr")=object(""), |
|
|
boost::python::arg("fpr")=object(""), |
|
|
"reset the default database status for the identity / keypair provided. If this\n" |
|
|
"reset the default database status for the identity / keypair provided. If this\n" |
|
|
"corresponds to the own user and a private key, also revoke the key, generate a\n" |
|
|
"corresponds to the own user and a private key, also revoke the key, generate a\n" |
|
@ -217,7 +228,7 @@ BOOST_PYTHON_MODULE(native_pEp) |
|
|
"identity. If it does not, remove the key from the keyring; the key's status is\n" |
|
|
"identity. If it does not, remove the key from the keyring; the key's status is\n" |
|
|
"completely fresh on next contact from the partner.") |
|
|
"completely fresh on next contact from the partner.") |
|
|
|
|
|
|
|
|
.def("key_mistrusted", &pEp::PythonAdapter::Identity::key_mistrusted, |
|
|
.def("key_mistrusted", &Identity::key_mistrusted, |
|
|
boost::python::arg("fpr")=object(""), |
|
|
boost::python::arg("fpr")=object(""), |
|
|
"If you want updated trust on the identity, you ll have" |
|
|
"If you want updated trust on the identity, you ll have" |
|
|
"to call update_identity or myself respectively after this." |
|
|
"to call update_identity or myself respectively after this." |
|
@ -227,42 +238,42 @@ BOOST_PYTHON_MODULE(native_pEp) |
|
|
"will only undo the current identity's / it's user's default, not any" |
|
|
"will only undo the current identity's / it's user's default, not any" |
|
|
"other identities which may be impacted (this will not affect most use cases)") |
|
|
"other identities which may be impacted (this will not affect most use cases)") |
|
|
|
|
|
|
|
|
.def("enable_for_sync", &pEp::PythonAdapter::Identity::enable_for_sync, |
|
|
.def("enable_for_sync", &Identity::enable_for_sync, |
|
|
"Enable own identity for p≡p sync.\n\n" |
|
|
"Enable own identity for p≡p sync.\n\n" |
|
|
"Only use this on own identities, which are used as accounts.\n") |
|
|
"Only use this on own identities, which are used as accounts.\n") |
|
|
.def("disable_for_sync", &pEp::PythonAdapter::Identity::disable_for_sync, |
|
|
.def("disable_for_sync", &Identity::disable_for_sync, |
|
|
"Disable own identity for p≡p sync.\n\n" |
|
|
"Disable own identity for p≡p sync.\n\n" |
|
|
"Only use this on own identities, which are used as accounts.\n") |
|
|
"Only use this on own identities, which are used as accounts.\n") |
|
|
|
|
|
|
|
|
.add_property("address", (string(pEp::PythonAdapter::Identity::*)()) &pEp::PythonAdapter::Identity::address, |
|
|
.add_property("address", (string(Identity::*)()) &Identity::address, |
|
|
(void(pEp::PythonAdapter::Identity::*)(string)) &pEp::PythonAdapter::Identity::address, |
|
|
(void(Identity::*)(string)) &Identity::address, |
|
|
"email address or URI") |
|
|
"email address or URI") |
|
|
.add_property("fpr", (string(pEp::PythonAdapter::Identity::*)()) &pEp::PythonAdapter::Identity::fpr, |
|
|
.add_property("fpr", (string(Identity::*)()) &Identity::fpr, |
|
|
(void(pEp::PythonAdapter::Identity::*)(string)) &pEp::PythonAdapter::Identity::fpr, |
|
|
(void(Identity::*)(string)) &Identity::fpr, |
|
|
"key ID (full fingerprint, hex encoded)") |
|
|
"key ID (full fingerprint, hex encoded)") |
|
|
.add_property("user_id", (string(pEp::PythonAdapter::Identity::*)()) &pEp::PythonAdapter::Identity::user_id, |
|
|
.add_property("user_id", (string(Identity::*)()) &Identity::user_id, |
|
|
(void(pEp::PythonAdapter::Identity::*)(string)) &pEp::PythonAdapter::Identity::user_id, |
|
|
(void(Identity::*)(string)) &Identity::user_id, |
|
|
"ID of person associated or 'pEp_own_userId' if own identity") |
|
|
"ID of person associated or 'pEp_own_userId' if own identity") |
|
|
.add_property("username", (string(pEp::PythonAdapter::Identity::*)()) &pEp::PythonAdapter::Identity::username, |
|
|
.add_property("username", (string(Identity::*)()) &Identity::username, |
|
|
(void(pEp::PythonAdapter::Identity::*)(string)) &pEp::PythonAdapter::Identity::username, |
|
|
(void(Identity::*)(string)) &Identity::username, |
|
|
"name in full of person associated") |
|
|
"name in full of person associated") |
|
|
.add_property("comm_type", (int(pEp::PythonAdapter::Identity::*)()) |
|
|
.add_property("comm_type", (int(Identity::*)()) |
|
|
(PEP_comm_type(pEp::PythonAdapter::Identity::*)()) &pEp::PythonAdapter::Identity::comm_type, |
|
|
(PEP_comm_type(Identity::*)()) &Identity::comm_type, |
|
|
(void(pEp::PythonAdapter::Identity::*)(int)) |
|
|
(void(Identity::*)(int)) |
|
|
(void(pEp::PythonAdapter::Identity::*)(PEP_comm_type)) &pEp::PythonAdapter::Identity::comm_type, |
|
|
(void(Identity::*)(PEP_comm_type)) &Identity::comm_type, |
|
|
"communication type, first rating level (p≡p internal)") |
|
|
"communication type, first rating level (p≡p internal)") |
|
|
.add_property("lang", (string(pEp::PythonAdapter::Identity::*)()) &pEp::PythonAdapter::Identity::lang, |
|
|
.add_property("lang", (string(Identity::*)()) &Identity::lang, |
|
|
(void(pEp::PythonAdapter::Identity::*)(string)) &pEp::PythonAdapter::Identity::lang, |
|
|
(void(Identity::*)(string)) &Identity::lang, |
|
|
"ISO 639-1 language code") |
|
|
"ISO 639-1 language code") |
|
|
.add_property("flags", (identity_flags_t(pEp::PythonAdapter::Identity::*)()) &pEp::PythonAdapter::Identity::flags, |
|
|
.add_property("flags", (identity_flags_t(Identity::*)()) &Identity::flags, |
|
|
(void(pEp::PythonAdapter::Identity::*)(identity_flags_t)) &pEp::PythonAdapter::Identity::flags, |
|
|
(void(Identity::*)(identity_flags_t)) &Identity::flags, |
|
|
"flags (p≡p internal)") |
|
|
"flags (p≡p internal)") |
|
|
.add_property("rating", &pEp::PythonAdapter::Identity::rating, "rating of Identity") |
|
|
.add_property("rating", &Identity::rating, "rating of Identity") |
|
|
.add_property("color", &pEp::PythonAdapter::Identity::color, "color of Identity as PEP_color") |
|
|
.add_property("color", &Identity::color, "color of Identity as PEP_color") |
|
|
.add_property("is_pEp_user", &pEp::PythonAdapter::Identity::is_pEp_user, "True if this is an identity of a pEp user") |
|
|
.add_property("is_pEp_user", &Identity::is_pEp_user, "True if this is an identity of a pEp user") |
|
|
.def("__deepcopy__", &pEp::PythonAdapter::Identity::deepcopy) |
|
|
.def("__deepcopy__", &Identity::deepcopy) |
|
|
.def("update", &pEp::PythonAdapter::Identity::update, "update Identity") |
|
|
.def("update", &Identity::update, "update Identity") |
|
|
.def("__copy__", &pEp::PythonAdapter::Identity::copy); |
|
|
.def("__copy__", &Identity::copy); |
|
|
|
|
|
|
|
|
identity_class.attr("PEP_OWN_USERID") = "pEp_own_userId"; |
|
|
identity_class.attr("PEP_OWN_USERID") = "pEp_own_userId"; |
|
|
|
|
|
|
|
@ -313,7 +324,7 @@ BOOST_PYTHON_MODULE(native_pEp) |
|
|
" mime_text text in Multipurpose Internet Mail Extensions format\n" |
|
|
" mime_text text in Multipurpose Internet Mail Extensions format\n" |
|
|
) |
|
|
) |
|
|
.def(boost::python::init<int>()) |
|
|
.def(boost::python::init<int>()) |
|
|
.def(boost::python::init<int, pEp::PythonAdapter::Identity *>()) |
|
|
.def(boost::python::init<int, Identity *>()) |
|
|
.def(boost::python::init<string>()) |
|
|
.def(boost::python::init<string>()) |
|
|
.def("__str__", &Message::_str, |
|
|
.def("__str__", &Message::_str, |
|
|
"the string representation of a Message is it's MIME text" |
|
|
"the string representation of a Message is it's MIME text" |
|
@ -345,13 +356,13 @@ BOOST_PYTHON_MODULE(native_pEp) |
|
|
.add_property("recv", (time_t(Message::*)()) &Message::recv, |
|
|
.add_property("recv", (time_t(Message::*)()) &Message::recv, |
|
|
(void(Message::*)(time_t)) &Message::recv, |
|
|
(void(Message::*)(time_t)) &Message::recv, |
|
|
"time when message was received in UTC seconds since epoch") |
|
|
"time when message was received in UTC seconds since epoch") |
|
|
.add_property("from_", (pEp::PythonAdapter::Identity(Message::*)()) &Message::from, |
|
|
.add_property("from_", (Identity(Message::*)()) &Message::from, |
|
|
(void(Message::*)(object)) &Message::from, |
|
|
(void(Message::*)(object)) &Message::from, |
|
|
"identity where message is from") |
|
|
"identity where message is from") |
|
|
.add_property("to", (boost::python::list(Message::*)()) &Message::to, |
|
|
.add_property("to", (boost::python::list(Message::*)()) &Message::to, |
|
|
(void(Message::*)(boost::python::list)) &Message::to, |
|
|
(void(Message::*)(boost::python::list)) &Message::to, |
|
|
"list of identities message is going to") |
|
|
"list of identities message is going to") |
|
|
.add_property("recv_by", (pEp::PythonAdapter::Identity(Message::*)()) &Message::recv_by, |
|
|
.add_property("recv_by", (Identity(Message::*)()) &Message::recv_by, |
|
|
(void(Message::*)(object)) &Message::recv_by, |
|
|
(void(Message::*)(object)) &Message::recv_by, |
|
|
"identity where message was received by") |
|
|
"identity where message was received by") |
|
|
.add_property("cc", (boost::python::list(Message::*)()) &Message::cc, |
|
|
.add_property("cc", (boost::python::list(Message::*)()) &Message::cc, |
|
@ -414,19 +425,19 @@ BOOST_PYTHON_MODULE(native_pEp) |
|
|
|
|
|
|
|
|
// basic API and key management API
|
|
|
// basic API and key management API
|
|
|
|
|
|
|
|
|
def("update_identity", &pEp::PythonAdapter::update_identity, |
|
|
def("update_identity", &update_identity, |
|
|
"update_identity(ident)\n" |
|
|
"update_identity(ident)\n" |
|
|
"\n" |
|
|
"\n" |
|
|
"update identity information\n" |
|
|
"update identity information\n" |
|
|
"call this to complete identity information when you at least have an address\n" |
|
|
"call this to complete identity information when you at least have an address\n" |
|
|
); |
|
|
); |
|
|
def("myself", &pEp::PythonAdapter::myself, |
|
|
def("myself", &myself, |
|
|
"myself(ident)\n" |
|
|
"myself(ident)\n" |
|
|
"\n" |
|
|
"\n" |
|
|
"ensures that the own identity is being complete\n" |
|
|
"ensures that the own identity is being complete\n" |
|
|
"supply ident.address and ident.username\n" |
|
|
"supply ident.address and ident.username\n" |
|
|
); |
|
|
); |
|
|
def("trust_personal_key", &pEp::PythonAdapter::trust_personal_key, |
|
|
def("trust_personal_key", &trust_personal_key, |
|
|
"trust_personal_key(ident)\n" |
|
|
"trust_personal_key(ident)\n" |
|
|
"\n" |
|
|
"\n" |
|
|
"mark a key as trusted with a person\n" |
|
|
"mark a key as trusted with a person\n" |
|
@ -437,44 +448,44 @@ BOOST_PYTHON_MODULE(native_pEp) |
|
|
.value("PEP_idf_list", PEP_idf_list) |
|
|
.value("PEP_idf_list", PEP_idf_list) |
|
|
.value("PEP_idf_devicegroup", PEP_idf_devicegroup); |
|
|
.value("PEP_idf_devicegroup", PEP_idf_devicegroup); |
|
|
|
|
|
|
|
|
def("set_identity_flags", &pEp::PythonAdapter::set_identity_flags, |
|
|
def("set_identity_flags", &set_identity_flags, |
|
|
"set_identity_flags(ident, flags)\n" |
|
|
"set_identity_flags(ident, flags)\n" |
|
|
"\n" |
|
|
"\n" |
|
|
"set identity flags\n" |
|
|
"set identity flags\n" |
|
|
); |
|
|
); |
|
|
|
|
|
|
|
|
def("unset_identity_flags", &pEp::PythonAdapter::unset_identity_flags, |
|
|
def("unset_identity_flags", &unset_identity_flags, |
|
|
"unset_identity_flags(ident, flags)\n" |
|
|
"unset_identity_flags(ident, flags)\n" |
|
|
"\n" |
|
|
"\n" |
|
|
"unset identity flags\n" |
|
|
"unset identity flags\n" |
|
|
); |
|
|
); |
|
|
|
|
|
|
|
|
def("key_reset_trust", &pEp::PythonAdapter::key_reset_trust, |
|
|
def("key_reset_trust", &key_reset_trust, |
|
|
"key_reset_trust(ident)\n" |
|
|
"key_reset_trust(ident)\n" |
|
|
"\n" |
|
|
"\n" |
|
|
"reset trust bit or explicitly mistrusted status for an identity and " |
|
|
"reset trust bit or explicitly mistrusted status for an identity and " |
|
|
"its accompanying key/user_id pair\n" |
|
|
"its accompanying key/user_id pair\n" |
|
|
); |
|
|
); |
|
|
|
|
|
|
|
|
def("import_key", &pEp::PythonAdapter::import_key, |
|
|
def("import_key", &import_key, |
|
|
"private_key_list = import_key(key_data)\n" |
|
|
"private_key_list = import_key(key_data)\n" |
|
|
"\n" |
|
|
"\n" |
|
|
"import key(s) from key_data\n" |
|
|
"import key(s) from key_data\n" |
|
|
); |
|
|
); |
|
|
|
|
|
|
|
|
def("export_key", &pEp::PythonAdapter::export_key, |
|
|
def("export_key", &export_key, |
|
|
"key_data = export_key(identity)\n" |
|
|
"key_data = export_key(identity)\n" |
|
|
"\n" |
|
|
"\n" |
|
|
"export key(s) of identity\n" |
|
|
"export key(s) of identity\n" |
|
|
); |
|
|
); |
|
|
|
|
|
|
|
|
def("export_secret_key", &pEp::PythonAdapter::export_secret_key, |
|
|
def("export_secret_key", &export_secret_key, |
|
|
"key_data = export_seret_key(identity)\n" |
|
|
"key_data = export_seret_key(identity)\n" |
|
|
"\n" |
|
|
"\n" |
|
|
"export secret key(s) of identity\n" |
|
|
"export secret key(s) of identity\n" |
|
|
); |
|
|
); |
|
|
|
|
|
|
|
|
def("set_own_key", &pEp::PythonAdapter::set_own_key, |
|
|
def("set_own_key", &set_own_key, |
|
|
"set_own_key(me, fpr)\n" |
|
|
"set_own_key(me, fpr)\n" |
|
|
"\n" |
|
|
"\n" |
|
|
"mark a key as an own key, and make it the default key\n" |
|
|
"mark a key as an own key, and make it the default key\n" |
|
@ -534,7 +545,7 @@ BOOST_PYTHON_MODULE(native_pEp) |
|
|
|
|
|
|
|
|
// messageToSend()
|
|
|
// messageToSend()
|
|
|
|
|
|
|
|
|
def("messageToSend", &pEp::PythonAdapter::messageToSend, |
|
|
def("messageToSend", &messageToSend, |
|
|
"messageToSend(msg)\n" |
|
|
"messageToSend(msg)\n" |
|
|
"\n" |
|
|
"\n" |
|
|
"override pEp.messageToSend(msg) with your own implementation\n" |
|
|
"override pEp.messageToSend(msg) with your own implementation\n" |
|
@ -577,41 +588,40 @@ BOOST_PYTHON_MODULE(native_pEp) |
|
|
// " result -1: cancel, 0: accepted, 1: rejected\n"
|
|
|
// " result -1: cancel, 0: accepted, 1: rejected\n"
|
|
|
// " identities list of identities to share or None for all\n"
|
|
|
// " identities list of identities to share or None for all\n"
|
|
|
// "\n"
|
|
|
// "\n"
|
|
|
// "call to deliver the handshake result of the handshake dialog")
|
|
|
// "call to deliver the handshake result of the handshake dialog");
|
|
|
// ;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: Replace with start_sync()
|
|
|
// TODO: Replace with start_sync()
|
|
|
// def("do_sync_protocol", &pEp::PythonAdapter::do_sync_protocol,
|
|
|
// def("do_sync_protocol", &do_sync_protocol,
|
|
|
// "do_sync_protocol()\n"
|
|
|
// "do_sync_protocol()\n"
|
|
|
// "\n"
|
|
|
// "\n"
|
|
|
// "in case of an explicit sync thread instead of a single threaded\n"
|
|
|
// "in case of an explicit sync thread instead of a single threaded\n"
|
|
|
// "implementation call this function in your sync thread\n"
|
|
|
// "implementation call this function in your sync thread\n"
|
|
|
// );
|
|
|
// );
|
|
|
|
|
|
|
|
|
def("shutdown_sync", &pEp::PythonAdapter::shutdown_sync, |
|
|
def("shutdown_sync", &shutdown_sync, |
|
|
"shutdown_sync()\n" |
|
|
"shutdown_sync()\n" |
|
|
"\n" |
|
|
"\n" |
|
|
"call this from another thread to shut down the sync thread\n" |
|
|
"call this from another thread to shut down the sync thread\n" |
|
|
); |
|
|
); |
|
|
|
|
|
|
|
|
def("debug_color", &pEp::PythonAdapter::debug_color, |
|
|
def("debug_color", &debug_color, |
|
|
"for debug builds set ANSI color value"); |
|
|
"for debug builds set ANSI color value"); |
|
|
|
|
|
|
|
|
def("leave_device_group", &pEp::PythonAdapter::leave_device_group, |
|
|
def("leave_device_group", &leave_device_group, |
|
|
"leave_device_group()\n" |
|
|
"leave_device_group()\n" |
|
|
"\n" |
|
|
"\n" |
|
|
"call this for a grouped device, which should leave\n" |
|
|
"call this for a grouped device, which should leave\n" |
|
|
); |
|
|
); |
|
|
|
|
|
|
|
|
// def("script_is_implementing_sync", &pEp::PythonAdapter::script_is_implementing_sync,
|
|
|
// def("script_is_implementing_sync", &script_is_implementing_sync,
|
|
|
// "script_is_implementing_sync()\n"
|
|
|
// "script_is_implementing_sync()\n"
|
|
|
// "\n"
|
|
|
// "\n"
|
|
|
// "call this in case the Python script is implementing sync to make\n"
|
|
|
// "call this in case the Python script is implementing sync to make\n"
|
|
|
// "is_sync_active() working\n"
|
|
|
// "is_sync_active() working\n"
|
|
|
// );
|
|
|
// );
|
|
|
|
|
|
|
|
|
def("is_sync_active", &pEp::PythonAdapter::is_sync_active, |
|
|
def("is_sync_active", &is_sync_active, |
|
|
"is_sync_active()\n" |
|
|
"is_sync_active()\n" |
|
|
"\n" |
|
|
"\n" |
|
|
"True if sync is active, False otherwise\n" |
|
|
"True if sync is active, False otherwise\n" |
|
@ -622,3 +632,6 @@ BOOST_PYTHON_MODULE(native_pEp) |
|
|
call< object >(((object)(import("codecs").attr("register"))).ptr(), make_function(sync_search)); |
|
|
call< object >(((object)(import("codecs").attr("register"))).ptr(), make_function(sync_search)); |
|
|
call< object >(((object)(import("codecs").attr("register"))).ptr(), make_function(distribution_search)); |
|
|
call< object >(((object)(import("codecs").attr("register"))).ptr(), make_function(distribution_search)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} // namespace PythonAdapter
|
|
|
|
|
|
} // namespace pEp
|
|
|