|
@ -1,200 +1,37 @@ |
|
|
// 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/locale.hpp> |
|
|
|
|
|
#include <string> |
|
|
|
|
|
#include <sstream> |
|
|
|
|
|
#include <iomanip> |
|
|
|
|
|
#include <mutex> |
|
|
|
|
|
|
|
|
|
|
|
// Engine
|
|
|
|
|
|
#include <pEp/key_reset.h> |
|
|
|
|
|
#include <pEp/message_api.h> |
|
|
|
|
|
#include <pEp/sync_api.h> |
|
|
|
|
|
#include <pEp/status_to_string.h> |
|
|
|
|
|
|
|
|
|
|
|
// libpEpAdapter
|
|
|
|
|
|
#include <pEp/Adapter.hh> |
|
|
|
|
|
#include <pEp/callback_dispatcher.hh> |
|
|
|
|
|
#include <pEp/pEpLog.hh> |
|
|
|
|
|
|
|
|
|
|
|
// local
|
|
|
// local
|
|
|
#include "pEpmodule.hh" |
|
|
#include "adapter_main.hh" |
|
|
#include "basic_api.hh" |
|
|
#include "basic_api.hh" |
|
|
|
|
|
#include "message.hh" |
|
|
#include "message_api.hh" |
|
|
#include "message_api.hh" |
|
|
//#include "user_interface.hh"
|
|
|
|
|
|
|
|
|
|
|
|
namespace pEp { |
|
|
namespace pEp { |
|
|
namespace PythonAdapter { |
|
|
namespace PythonAdapter { |
|
|
using namespace std; |
|
|
|
|
|
using namespace boost::python; |
|
|
|
|
|
|
|
|
|
|
|
static const char *version_string = "p≡p Python adapter version 0.3"; |
|
|
|
|
|
|
|
|
|
|
|
void init_before_main_module() { |
|
|
|
|
|
pEpLog("called"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// hidden init function, wrapped by hello_world.init()
|
|
|
|
|
|
void _init_after_main_module() { |
|
|
|
|
|
pEpLog("called"); |
|
|
|
|
|
callback_dispatcher.add(_messageToSend, notifyHandshake, nullptr, nullptr); |
|
|
|
|
|
Adapter::_messageToSend = CallbackDispatcher::messageToSend; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void config_passive_mode(bool enable) { |
|
|
|
|
|
::config_passive_mode(Adapter::session(), enable); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void config_unencrypted_subject(bool enable) { |
|
|
|
|
|
::config_unencrypted_subject(Adapter::session(), enable); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void key_reset_user(string user_id, string fpr) { |
|
|
|
|
|
if (user_id == "") |
|
|
|
|
|
throw invalid_argument("user_id required"); |
|
|
|
|
|
|
|
|
|
|
|
PEP_STATUS status = ::key_reset_user(Adapter::session(), |
|
|
|
|
|
user_id.c_str(), fpr != "" ? fpr.c_str() : nullptr); |
|
|
|
|
|
_throw_status(status); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void key_reset_user2(string user_id) { |
|
|
|
|
|
key_reset_user(user_id, ""); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void key_reset_all_own_keys() { |
|
|
|
|
|
PEP_STATUS status = ::key_reset_all_own_keys(Adapter::session()); |
|
|
|
|
|
_throw_status(status); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static string about() { |
|
|
|
|
|
string version = string(version_string) + "\np≡p version " |
|
|
|
|
|
+ PEP_VERSION + "\n"; |
|
|
|
|
|
return version; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void _throw_status(PEP_STATUS status) { |
|
|
|
|
|
if (status == PEP_STATUS_OK) |
|
|
|
|
|
return; |
|
|
|
|
|
if (status >= 0x400 && status <= 0x4ff) |
|
|
|
|
|
return; |
|
|
|
|
|
if (status == PEP_OUT_OF_MEMORY) |
|
|
|
|
|
throw bad_alloc(); |
|
|
|
|
|
if (status == PEP_ILLEGAL_VALUE) |
|
|
|
|
|
throw invalid_argument("illegal value"); |
|
|
|
|
|
|
|
|
|
|
|
if (string(pEp_status_to_string(status)) == "unknown status code") { |
|
|
|
|
|
stringstream build; |
|
|
|
|
|
build << setfill('0') << "p≡p 0x" << setw(4) << hex << status; |
|
|
|
|
|
throw runtime_error(build.str()); |
|
|
|
|
|
} else { |
|
|
|
|
|
throw runtime_error(pEp_status_to_string(status)); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
PEP_STATUS _messageToSend(::message *msg) { |
|
|
|
|
|
pEpLog("called"); |
|
|
|
|
|
try { |
|
|
|
|
|
PyGILState_STATE gil = PyGILState_Ensure(); |
|
|
|
|
|
pEpLog("GIL Aquired"); |
|
|
|
|
|
object modref = import("pEp"); |
|
|
|
|
|
object funcref = modref.attr("message_to_send"); |
|
|
|
|
|
call<void>(funcref.ptr(), Message()); |
|
|
|
|
|
PyGILState_Release(gil); |
|
|
|
|
|
pEpLog("GIL released"); |
|
|
|
|
|
} catch (exception &e) {} |
|
|
|
|
|
|
|
|
|
|
|
return PEP_STATUS_OK; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
PEP_STATUS notifyHandshake(pEp_identity *me, pEp_identity *partner, sync_handshake_signal signal) { |
|
|
|
|
|
pEpLog("called"); |
|
|
|
|
|
try { |
|
|
|
|
|
PyGILState_STATE gil = PyGILState_Ensure(); |
|
|
|
|
|
pEpLog("GIL Aquired"); |
|
|
|
|
|
object modref = import("pEp"); |
|
|
|
|
|
object funcref = modref.attr("notify_handshake"); |
|
|
|
|
|
call<void>(funcref.ptr(), me, partner, signal); |
|
|
|
|
|
PyGILState_Release(gil); |
|
|
|
|
|
pEpLog("GIL released"); |
|
|
|
|
|
} catch (exception &e) {} |
|
|
|
|
|
|
|
|
|
|
|
return PEP_STATUS_OK; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void start_sync() { |
|
|
|
|
|
CallbackDispatcher::start_sync(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void shutdown_sync() { |
|
|
|
|
|
CallbackDispatcher::stop_sync(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void debug_color(int ansi_color) { |
|
|
|
|
|
::set_debug_color(Adapter::session(), ansi_color); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void leave_device_group() { |
|
|
|
|
|
::leave_device_group(Adapter::session()); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bool is_sync_active() { |
|
|
|
|
|
return Adapter::is_sync_running(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void testfunc() { |
|
|
|
|
|
_messageToSend(NULL); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void deliverHandshakeResult(int result, object identities) { |
|
|
|
|
|
identity_list *shared_identities = nullptr; |
|
|
|
|
|
if (identities != boost::python::api::object() && boost::python::len(identities)) { |
|
|
|
|
|
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, shared_identities); |
|
|
|
|
|
free_identity_list(shared_identities); |
|
|
|
|
|
_throw_status(status); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
BOOST_PYTHON_MODULE(_pEp) { |
|
|
BOOST_PYTHON_MODULE(_pEp) { |
|
|
|
|
|
using boost::python::def; |
|
|
|
|
|
using boost::python::class_; |
|
|
|
|
|
using boost::python::enum_; |
|
|
init_before_main_module(); |
|
|
init_before_main_module(); |
|
|
|
|
|
|
|
|
// Module init function called by pEp.init()
|
|
|
// Module init function called by pEp.init()
|
|
|
def("_init_after_main_module", _init_after_main_module); |
|
|
def("_init_after_main_module", _init_after_main_module); |
|
|
def("testfunc", &testfunc); |
|
|
def("testfunc", &testfunc); |
|
|
|
|
|
|
|
|
docstring_options doc_options(true, false, false); |
|
|
bp::docstring_options doc_options(true, false, false); |
|
|
boost::locale::generator gen; |
|
|
bl::generator gen; |
|
|
std::locale::global(gen("")); |
|
|
std::locale::global(gen("")); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
scope().attr("about") = about(); |
|
|
bp::scope().attr("about") = about(); |
|
|
scope().attr("per_user_directory") = per_user_directory(); |
|
|
bp::scope().attr("per_user_directory") = ::per_user_directory(); |
|
|
scope().attr("per_machine_directory") = per_machine_directory(); |
|
|
bp::scope().attr("per_machine_directory") = ::per_machine_directory(); |
|
|
scope().attr("engine_version") = get_engine_version(); |
|
|
bp::scope().attr("engine_version") = ::get_engine_version(); |
|
|
scope().attr("protocol_version") = get_protocol_version(); |
|
|
bp::scope().attr("protocol_version") = ::get_protocol_version(); |
|
|
|
|
|
|
|
|
def("passive_mode", 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"); |
|
@ -236,19 +73,19 @@ namespace pEp { |
|
|
" lang ISO 639-1 language code for language being preferred\n" |
|
|
" lang ISO 639-1 language code for language being preferred\n" |
|
|
" on this communication channel\n" |
|
|
" on this communication channel\n" |
|
|
) |
|
|
) |
|
|
.def(boost::python::init<string>()) |
|
|
.def(bp::init<string>()) |
|
|
.def(boost::python::init<string, string>()) |
|
|
.def(bp::init<string, string>()) |
|
|
.def(boost::python::init<string, string, string>()) |
|
|
.def(bp::init<string, string, string>()) |
|
|
.def(boost::python::init<string, string, string, string>()) |
|
|
.def(bp::init<string, string, string, string>()) |
|
|
.def(boost::python::init<string, string, string, string, int>()) |
|
|
.def(bp::init<string, string, string, string, int>()) |
|
|
.def(boost::python::init<string, string, string, string, int, string>()) |
|
|
.def(bp::init<string, string, string, string, int, string>()) |
|
|
.def("__repr__", &Identity::_repr) |
|
|
.def("__repr__", &Identity::_repr) |
|
|
.def("__str__", &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", &Identity::key_reset, |
|
|
.def("key_reset", &Identity::key_reset, |
|
|
boost::python::arg("fpr")=object(""), |
|
|
bp::arg("fpr")=bp::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" |
|
|
"new one, and communicate the reset to recently contacted pEp partners for this\n" |
|
|
"new one, and communicate the reset to recently contacted pEp partners for this\n" |
|
@ -256,7 +93,7 @@ namespace pEp { |
|
|
"completely fresh on next contact from the partner.") |
|
|
"completely fresh on next contact from the partner.") |
|
|
|
|
|
|
|
|
.def("key_mistrusted", &Identity::key_mistrusted, |
|
|
.def("key_mistrusted", &Identity::key_mistrusted, |
|
|
boost::python::arg("fpr")=object(""), |
|
|
bp::arg("fpr")=bp::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." |
|
|
"N.B. If you are calling this on a key that is the identity or user default," |
|
|
"N.B. If you are calling this on a key that is the identity or user default," |
|
@ -287,13 +124,13 @@ namespace pEp { |
|
|
.add_property("comm_type", (int(Identity::*)()) |
|
|
.add_property("comm_type", (int(Identity::*)()) |
|
|
(PEP_comm_type(Identity::*)()) &Identity::comm_type, |
|
|
(PEP_comm_type(Identity::*)()) &Identity::comm_type, |
|
|
(void(Identity::*)(int)) |
|
|
(void(Identity::*)(int)) |
|
|
(void(Identity::*)(PEP_comm_type)) &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(Identity::*)()) &Identity::lang, |
|
|
.add_property("lang", (string(Identity::*)()) &Identity::lang, |
|
|
(void(Identity::*)(string)) &Identity::lang, |
|
|
(void(Identity::*)(string)) &Identity::lang, |
|
|
"ISO 639-1 language code") |
|
|
"ISO 639-1 language code") |
|
|
.add_property("flags", (identity_flags_t(Identity::*)()) &Identity::flags, |
|
|
.add_property("flags", (identity_flags_t(Identity::*)()) &Identity::flags, |
|
|
(void(Identity::*)(identity_flags_t)) &Identity::flags, |
|
|
(void(Identity::*)(::identity_flags_t)) &Identity::flags, |
|
|
"flags (p≡p internal)") |
|
|
"flags (p≡p internal)") |
|
|
.add_property("rating", &Identity::rating, "rating of Identity") |
|
|
.add_property("rating", &Identity::rating, "rating of Identity") |
|
|
.add_property("color", &Identity::color, "color of Identity as PEP_color") |
|
|
.add_property("color", &Identity::color, "color of Identity as PEP_color") |
|
@ -312,9 +149,9 @@ namespace pEp { |
|
|
" data bytes-like object\n" |
|
|
" data bytes-like object\n" |
|
|
" mime_type MIME type for the data\n" |
|
|
" mime_type MIME type for the data\n" |
|
|
" filename filename to store the data\n", |
|
|
" filename filename to store the data\n", |
|
|
boost::python::init< object, char const*, char const* >(args("data", "mime_type", "filename"))) |
|
|
bp::init< bp::object, char const*, char const* >(bp::args("data", "mime_type", "filename"))) |
|
|
.def(boost::python::init<object, string>()) |
|
|
.def(bp::init<bp::object, string>()) |
|
|
.def(boost::python::init<object>()) |
|
|
.def(bp::init<bp::object>()) |
|
|
.def("__repr__", &Message::Blob::_repr) |
|
|
.def("__repr__", &Message::Blob::_repr) |
|
|
.def("__len__", &Message::Blob::size, "size of Blob data in bytes") |
|
|
.def("__len__", &Message::Blob::size, "size of Blob data in bytes") |
|
|
.def("decode", (string(Message::Blob::*)()) &Message::Blob::decode) |
|
|
.def("decode", (string(Message::Blob::*)()) &Message::Blob::decode) |
|
@ -350,9 +187,9 @@ namespace pEp { |
|
|
"\n" |
|
|
"\n" |
|
|
" 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(bp::init<int>()) |
|
|
.def(boost::python::init<int, Identity *>()) |
|
|
.def(bp::init<int, Identity *>()) |
|
|
.def(boost::python::init<string>()) |
|
|
.def(bp::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" |
|
|
) |
|
|
) |
|
@ -360,7 +197,7 @@ namespace pEp { |
|
|
.add_property("dir", (int(Message::*)()) |
|
|
.add_property("dir", (int(Message::*)()) |
|
|
(PEP_msg_direction(Message::*)()) &Message::dir, |
|
|
(PEP_msg_direction(Message::*)()) &Message::dir, |
|
|
(void(Message::*)(int)) |
|
|
(void(Message::*)(int)) |
|
|
(void(Message::*)(PEP_msg_direction)) &Message::dir, |
|
|
(void(Message::*)(::PEP_msg_direction)) &Message::dir, |
|
|
"0: incoming, 1: outgoing message") |
|
|
"0: incoming, 1: outgoing message") |
|
|
.add_property("id", (string(Message::*)()) &Message::id, |
|
|
.add_property("id", (string(Message::*)()) &Message::id, |
|
|
(void(Message::*)(string)) &Message::id, |
|
|
(void(Message::*)(string)) &Message::id, |
|
@ -374,8 +211,8 @@ namespace pEp { |
|
|
.add_property("longmsg_formatted", (string(Message::*)()) &Message::longmsg_formatted, |
|
|
.add_property("longmsg_formatted", (string(Message::*)()) &Message::longmsg_formatted, |
|
|
(void(Message::*)(string)) &Message::longmsg_formatted, |
|
|
(void(Message::*)(string)) &Message::longmsg_formatted, |
|
|
"HTML body or fromatted long version of message") |
|
|
"HTML body or fromatted long version of message") |
|
|
.add_property("attachments", (boost::python::tuple(Message::*)()) &Message::attachments, |
|
|
.add_property("attachments", (bp::tuple(Message::*)()) &Message::attachments, |
|
|
(void(Message::*)(boost::python::list)) &Message::attachments, |
|
|
(void(Message::*)(bp::list)) &Message::attachments, |
|
|
"tuple of Blobs with attachments; setting moves Blobs to attachment tuple") |
|
|
"tuple of Blobs with attachments; setting moves Blobs to attachment tuple") |
|
|
.add_property("sent", (time_t(Message::*)()) &Message::sent, |
|
|
.add_property("sent", (time_t(Message::*)()) &Message::sent, |
|
|
(void(Message::*)(time_t)) &Message::sent, |
|
|
(void(Message::*)(time_t)) &Message::sent, |
|
@ -384,47 +221,47 @@ namespace pEp { |
|
|
(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_", (Identity(Message::*)()) &Message::from, |
|
|
.add_property("from_", (Identity(Message::*)()) &Message::from, |
|
|
(void(Message::*)(object)) &Message::from, |
|
|
(void(Message::*)(bp::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", (bp::list(Message::*)()) &Message::to, |
|
|
(void(Message::*)(boost::python::list)) &Message::to, |
|
|
(void(Message::*)(bp::list)) &Message::to, |
|
|
"list of identities message is going to") |
|
|
"list of identities message is going to") |
|
|
.add_property("recv_by", (Identity(Message::*)()) &Message::recv_by, |
|
|
.add_property("recv_by", (Identity(Message::*)()) &Message::recv_by, |
|
|
(void(Message::*)(object)) &Message::recv_by, |
|
|
(void(Message::*)(bp::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", (bp::list(Message::*)()) &Message::cc, |
|
|
(void(Message::*)(boost::python::list)) &Message::cc, |
|
|
(void(Message::*)(bp::list)) &Message::cc, |
|
|
"list of identities message is going cc") |
|
|
"list of identities message is going cc") |
|
|
.add_property("bcc", (boost::python::list(Message::*)()) &Message::bcc, |
|
|
.add_property("bcc", (bp::list(Message::*)()) &Message::bcc, |
|
|
(void(Message::*)(boost::python::list)) &Message::bcc, |
|
|
(void(Message::*)(bp::list)) &Message::bcc, |
|
|
"list of identities message is going bcc") |
|
|
"list of identities message is going bcc") |
|
|
.add_property("reply_to", (boost::python::list(Message::*)()) &Message::reply_to, |
|
|
.add_property("reply_to", (bp::list(Message::*)()) &Message::reply_to, |
|
|
(void(Message::*)(boost::python::list)) &Message::reply_to, |
|
|
(void(Message::*)(bp::list)) &Message::reply_to, |
|
|
"list of identities where message will be replied to") |
|
|
"list of identities where message will be replied to") |
|
|
.add_property("in_reply_to", (boost::python::list(Message::*)()) &Message::in_reply_to, |
|
|
.add_property("in_reply_to", (bp::list(Message::*)()) &Message::in_reply_to, |
|
|
(void(Message::*)(boost::python::list)) &Message::in_reply_to, |
|
|
(void(Message::*)(bp::list)) &Message::in_reply_to, |
|
|
"in_reply_to list") |
|
|
"in_reply_to list") |
|
|
.add_property("references", (boost::python::list(Message::*)()) &Message::references, |
|
|
.add_property("references", (bp::list(Message::*)()) &Message::references, |
|
|
(void(Message::*)(boost::python::list)) &Message::references, |
|
|
(void(Message::*)(bp::list)) &Message::references, |
|
|
"message IDs of messages this one is referring to") |
|
|
"message IDs of messages this one is referring to") |
|
|
.add_property("keywords", (boost::python::list(Message::*)()) &Message::keywords, |
|
|
.add_property("keywords", (bp::list(Message::*)()) &Message::keywords, |
|
|
(void(Message::*)(boost::python::list)) &Message::keywords, |
|
|
(void(Message::*)(bp::list)) &Message::keywords, |
|
|
"keywords this message should be stored under") |
|
|
"keywords this message should be stored under") |
|
|
.add_property("comments", (string(Message::*)()) &Message::comments, |
|
|
.add_property("comments", (string(Message::*)()) &Message::comments, |
|
|
(void(Message::*)(string)) &Message::comments, |
|
|
(void(Message::*)(string)) &Message::comments, |
|
|
"comments added to message") |
|
|
"comments added to message") |
|
|
.add_property("opt_fields", (dict(Message::*)()) &Message::opt_fields, |
|
|
.add_property("opt_fields", (bp::dict(Message::*)()) &Message::opt_fields, |
|
|
(void(Message::*)(dict)) &Message::opt_fields, |
|
|
(void(Message::*)(bp::dict)) &Message::opt_fields, |
|
|
"opt_fields of message") |
|
|
"opt_fields of message") |
|
|
.add_property("enc_format", (int(Message::*)()) |
|
|
.add_property("enc_format", (int(Message::*)()) |
|
|
(PEP_enc_format(Message::*)()) &Message::enc_format, |
|
|
(PEP_enc_format(Message::*)()) &Message::enc_format, |
|
|
(void(Message::*)(int)) |
|
|
(void(Message::*)(int)) |
|
|
(void(Message::*)(PEP_enc_format)) &Message::enc_format, |
|
|
(void(Message::*)(::PEP_enc_format)) &Message::enc_format, |
|
|
"0: unencrypted, 1: inline PGP, 2: S/MIME, 3: PGP/MIME, 4: p≡p format") |
|
|
"0: unencrypted, 1: inline PGP, 2: S/MIME, 3: PGP/MIME, 4: p≡p format") |
|
|
.def("encrypt", (Message(Message::*)())&Message::encrypt) |
|
|
.def("encrypt", (Message(Message::*)())&Message::encrypt) |
|
|
.def("encrypt", (Message(Message::*)(boost::python::list))&Message::_encrypt) |
|
|
.def("encrypt", (Message(Message::*)(bp::list))&Message::_encrypt) |
|
|
.def("encrypt", (Message(Message::*)(boost::python::list, int))&Message::_encrypt) |
|
|
.def("encrypt", (Message(Message::*)(bp::list, int))&Message::_encrypt) |
|
|
.def("encrypt", (Message(Message::*)(boost::python::list, int, int))&Message::_encrypt, |
|
|
.def("encrypt", (Message(Message::*)(bp::list, int, int))&Message::_encrypt, |
|
|
"msg2 = msg1.encrypt(extra_keys=[], enc_format='pEp', flags=0)\n" |
|
|
"msg2 = msg1.encrypt(extra_keys=[], enc_format='pEp', flags=0)\n" |
|
|
"\n" |
|
|
"\n" |
|
|
"encrypts a p≡p message and returns the encrypted message\n" |
|
|
"encrypts a p≡p message and returns the encrypted message\n" |
|
@ -435,7 +272,7 @@ namespace pEp { |
|
|
" 3 for PGP/MIME, 4 for pEp\n" |
|
|
" 3 for PGP/MIME, 4 for pEp\n" |
|
|
" flags 1 is force encryption\n" |
|
|
" flags 1 is force encryption\n" |
|
|
) |
|
|
) |
|
|
.def("decrypt", &Message::decrypt, boost::python::arg("flags")=0, |
|
|
.def("decrypt", &Message::decrypt, bp::arg("flags")=0, |
|
|
"msg2, keys, rating, flags = msg1.decrypt()\n" |
|
|
"msg2, keys, rating, flags = msg1.decrypt()\n" |
|
|
"\n" |
|
|
"\n" |
|
|
"decrypts a p≡p message and returns a tuple with data\n" |
|
|
"decrypts a p≡p message and returns a tuple with data\n" |
|
@ -470,10 +307,10 @@ namespace pEp { |
|
|
"mark a key as trusted with a person\n" |
|
|
"mark a key as trusted with a person\n" |
|
|
); |
|
|
); |
|
|
|
|
|
|
|
|
enum_<identity_flags>("identity_flags") |
|
|
enum_<::identity_flags>("identity_flags") |
|
|
.value("PEP_idf_not_for_sync", PEP_idf_not_for_sync) |
|
|
.value("PEP_idf_not_for_sync", ::PEP_idf_not_for_sync) |
|
|
.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", &set_identity_flags, |
|
|
def("set_identity_flags", &set_identity_flags, |
|
|
"set_identity_flags(ident, flags)\n" |
|
|
"set_identity_flags(ident, flags)\n" |
|
@ -529,25 +366,25 @@ namespace pEp { |
|
|
|
|
|
|
|
|
// message API
|
|
|
// message API
|
|
|
|
|
|
|
|
|
enum_<PEP_rating>("rating") |
|
|
enum_<::PEP_rating>("rating") |
|
|
.value("_undefined", PEP_rating_undefined) |
|
|
.value("_undefined", ::PEP_rating_undefined) |
|
|
.value("cannot_decrypt", PEP_rating_cannot_decrypt) |
|
|
.value("cannot_decrypt", ::PEP_rating_cannot_decrypt) |
|
|
.value("have_no_key", PEP_rating_have_no_key) |
|
|
.value("have_no_key", ::PEP_rating_have_no_key) |
|
|
.value("unencrypted", PEP_rating_unencrypted) |
|
|
.value("unencrypted", ::PEP_rating_unencrypted) |
|
|
.value("unreliable", PEP_rating_unreliable) |
|
|
.value("unreliable", ::PEP_rating_unreliable) |
|
|
.value("reliable", PEP_rating_reliable) |
|
|
.value("reliable", ::PEP_rating_reliable) |
|
|
.value("trusted", PEP_rating_trusted) |
|
|
.value("trusted", ::PEP_rating_trusted) |
|
|
.value("trusted_and_anonymized", PEP_rating_trusted_and_anonymized) |
|
|
.value("trusted_and_anonymized", ::PEP_rating_trusted_and_anonymized) |
|
|
.value("fully_anonymous", PEP_rating_fully_anonymous) |
|
|
.value("fully_anonymous", ::PEP_rating_fully_anonymous) |
|
|
.value("mistrust", PEP_rating_mistrust) |
|
|
.value("mistrust", ::PEP_rating_mistrust) |
|
|
.value("b0rken", PEP_rating_b0rken) |
|
|
.value("b0rken", ::PEP_rating_b0rken) |
|
|
.value("under_attack", PEP_rating_under_attack); |
|
|
.value("under_attack", ::PEP_rating_under_attack); |
|
|
|
|
|
|
|
|
enum_<PEP_color>("colorvalue") |
|
|
enum_<::PEP_color>("colorvalue") |
|
|
.value("no_color", PEP_color_no_color) |
|
|
.value("no_color", ::PEP_color_no_color) |
|
|
.value("yellow", PEP_color_yellow) |
|
|
.value("yellow", ::PEP_color_yellow) |
|
|
.value("green", PEP_color_green) |
|
|
.value("green", ::PEP_color_green) |
|
|
.value("red", PEP_color_red); |
|
|
.value("red", ::PEP_color_red); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def("incoming_message", &incoming_message, |
|
|
def("incoming_message", &incoming_message, |
|
@ -572,17 +409,17 @@ namespace pEp { |
|
|
|
|
|
|
|
|
// Sync API
|
|
|
// Sync API
|
|
|
|
|
|
|
|
|
enum_<sync_handshake_signal>("sync_handshake_signal") |
|
|
enum_<::sync_handshake_signal>("sync_handshake_signal") |
|
|
.value("SYNC_NOTIFY_UNDEFINED", SYNC_NOTIFY_UNDEFINED) |
|
|
.value("SYNC_NOTIFY_UNDEFINED", ::SYNC_NOTIFY_UNDEFINED) |
|
|
.value("SYNC_NOTIFY_INIT_ADD_OUR_DEVICE", SYNC_NOTIFY_INIT_ADD_OUR_DEVICE) |
|
|
.value("SYNC_NOTIFY_INIT_ADD_OUR_DEVICE", ::SYNC_NOTIFY_INIT_ADD_OUR_DEVICE) |
|
|
.value("SYNC_NOTIFY_INIT_ADD_OTHER_DEVICE", SYNC_NOTIFY_INIT_ADD_OTHER_DEVICE) |
|
|
.value("SYNC_NOTIFY_INIT_ADD_OTHER_DEVICE", ::SYNC_NOTIFY_INIT_ADD_OTHER_DEVICE) |
|
|
.value("SYNC_NOTIFY_INIT_FORM_GROUP", SYNC_NOTIFY_INIT_FORM_GROUP) |
|
|
.value("SYNC_NOTIFY_INIT_FORM_GROUP", ::SYNC_NOTIFY_INIT_FORM_GROUP) |
|
|
.value("SYNC_NOTIFY_TIMEOUT", SYNC_NOTIFY_TIMEOUT) |
|
|
.value("SYNC_NOTIFY_TIMEOUT", ::SYNC_NOTIFY_TIMEOUT) |
|
|
.value("SYNC_NOTIFY_ACCEPTED_DEVICE_ADDED", SYNC_NOTIFY_ACCEPTED_DEVICE_ADDED) |
|
|
.value("SYNC_NOTIFY_ACCEPTED_DEVICE_ADDED", ::SYNC_NOTIFY_ACCEPTED_DEVICE_ADDED) |
|
|
.value("SYNC_NOTIFY_ACCEPTED_GROUP_CREATED", SYNC_NOTIFY_ACCEPTED_GROUP_CREATED) |
|
|
.value("SYNC_NOTIFY_ACCEPTED_GROUP_CREATED", ::SYNC_NOTIFY_ACCEPTED_GROUP_CREATED) |
|
|
.value("SYNC_NOTIFY_ACCEPTED_DEVICE_ACCEPTED", SYNC_NOTIFY_ACCEPTED_DEVICE_ACCEPTED) |
|
|
.value("SYNC_NOTIFY_ACCEPTED_DEVICE_ACCEPTED", ::SYNC_NOTIFY_ACCEPTED_DEVICE_ACCEPTED) |
|
|
.value("SYNC_NOTIFY_SOLE", SYNC_NOTIFY_SOLE) |
|
|
.value("SYNC_NOTIFY_SOLE", ::SYNC_NOTIFY_SOLE) |
|
|
.value("SYNC_NOTIFY_IN_GROUP", SYNC_NOTIFY_IN_GROUP); |
|
|
.value("SYNC_NOTIFY_IN_GROUP", ::SYNC_NOTIFY_IN_GROUP); |
|
|
|
|
|
|
|
|
// auto user_interface_class = class_<UserInterface, UserInterface_callback, boost::noncopyable>(
|
|
|
// auto user_interface_class = class_<UserInterface, UserInterface_callback, boost::noncopyable>(
|
|
|
// "UserInterface",
|
|
|
// "UserInterface",
|
|
@ -601,7 +438,7 @@ namespace pEp { |
|
|
// "\n"
|
|
|
// "\n"
|
|
|
// "overwrite this method with an implementation of a handshake dialog")
|
|
|
// "overwrite this method with an implementation of a handshake dialog")
|
|
|
// .def("deliverHandshakeResult", &UserInterface::deliverHandshakeResult,
|
|
|
// .def("deliverHandshakeResult", &UserInterface::deliverHandshakeResult,
|
|
|
// boost::python::arg("identities")=object(),
|
|
|
// bp::arg("identities")=object(),
|
|
|
// "deliverHandshakeResult(self, result, identities=None)\n"
|
|
|
// "deliverHandshakeResult(self, result, identities=None)\n"
|
|
|
// "\n"
|
|
|
// "\n"
|
|
|
// " result -1: cancel, 0: accepted, 1: rejected\n"
|
|
|
// " result -1: cancel, 0: accepted, 1: rejected\n"
|
|
@ -610,7 +447,7 @@ namespace pEp { |
|
|
// "call to deliver the handshake result of the handshake dialog"
|
|
|
// "call to deliver the handshake result of the handshake dialog"
|
|
|
// );
|
|
|
// );
|
|
|
|
|
|
|
|
|
def("deliver_handshake_result", &deliverHandshakeResult, boost::python::arg("identities")=object(), |
|
|
def("deliver_handshake_result", &deliverHandshakeResult, bp::arg("identities")=bp::object(), |
|
|
"deliverHandshakeResult(self, result, identities=None)\n" |
|
|
"deliverHandshakeResult(self, result, identities=None)\n" |
|
|
"\n" |
|
|
"\n" |
|
|
" result -1: cancel, 0: accepted, 1: rejected\n" |
|
|
" result -1: cancel, 0: accepted, 1: rejected\n" |
|
@ -648,9 +485,8 @@ namespace pEp { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// codecs
|
|
|
// codecs
|
|
|
call< object >(((object)(import("codecs").attr("register"))).ptr(), make_function(sync_search)); |
|
|
bp::call< bp::object >(((bp::object)(bp::import("codecs").attr("register"))).ptr(), make_function(sync_search)); |
|
|
call< object >(((object)(import("codecs").attr("register"))).ptr(), make_function(distribution_search)); |
|
|
bp::call< bp::object >(((bp::object)(bp::import("codecs").attr("register"))).ptr(), make_function(distribution_search)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} // namespace PythonAdapter
|
|
|
} // namespace PythonAdapter
|
|
|
} // namespace pEp
|
|
|
} // namespace pEp
|
|
|