Browse Source

Includes/namespace/using cleanup

PYADPT-81
heck 5 years ago
parent
commit
50ebe60221
  1. 2
      src/pEp/__init__.py
  2. 12
      src/pEp/native_pEp/basic_api.cc
  3. 6
      src/pEp/native_pEp/basic_api.hh
  4. 10
      src/pEp/native_pEp/identity.cc
  5. 15
      src/pEp/native_pEp/identity.hh
  6. 11
      src/pEp/native_pEp/message.cc
  7. 15
      src/pEp/native_pEp/message.hh
  8. 13
      src/pEp/native_pEp/message_api.cc
  9. 15
      src/pEp/native_pEp/message_api.hh
  10. 155
      src/pEp/native_pEp/pEpmodule.cc
  11. 9
      src/pEp/native_pEp/pEpmodule.hh
  12. 12
      src/pEp/native_pEp/str_attr.cc
  13. 14
      src/pEp/native_pEp/str_attr.hh
  14. 9
      src/pEp/native_pEp/user_interface.cc
  15. 25
      src/pEp/native_pEp/user_interface.hh
  16. 1
      test/pyadpt-81.py

2
src/pEp/__init__.py

@ -17,7 +17,7 @@ import native_pEp
# Executed on module import
def init():
print("init() called")
# native_pEp._init()
native_pEp._init()
# Executed when run as script
def main():

12
src/pEp/native_pEp/basic_api.cc

@ -1,16 +1,21 @@
// This file is under GNU Affero General Public License 3.0
// see LICENSE.txt
// System
#include <sstream>
// Engine
#include <pEp/keymanagement.h>
#include <pEp/message_api.h>
#include <pEp/Adapter.hh>
// local
#include "basic_api.hh"
namespace pEp {
namespace PythonAdapter {
using namespace std;
void update_identity(Identity& ident)
{
if (ident.address() == "")
@ -160,5 +165,8 @@ namespace pEp {
PEP_STATUS status = set_own_key(pEp::Adapter::session(), ident, fpr_c);
_throw_status(status);
}
}
}
} // namespace PythonAdapter
} // namespace pEp {

6
src/pEp/native_pEp/basic_api.hh

@ -7,6 +7,7 @@
namespace pEp {
namespace PythonAdapter {
void update_identity(Identity& ident);
void myself(Identity& ident);
string _trustwords(Identity me, Identity partner, string lang, bool full);
@ -21,5 +22,6 @@ namespace pEp {
string export_key(Identity ident);
string export_secret_key(Identity ident);
void set_own_key(Identity& ident, string fpr);
}
}
} // namespace PythonAdapter
} // namespace pEp {

10
src/pEp/native_pEp/identity.cc

@ -1,13 +1,16 @@
// This file is under GNU Affero General Public License 3.0
// see LICENSE.txt
// System
#include <typeinfo>
#include <sstream>
// Engine
#include <pEp/identity_list.h>
#include <pEp/keymanagement.h>
#include <pEp/key_reset.h>
// local
#include "identity.hh"
#include "pEpmodule.hh"
#include "basic_api.hh"
@ -15,6 +18,8 @@
namespace pEp {
namespace PythonAdapter {
using namespace std;
using namespace boost::python;
Identity::Identity(string address, string username, string user_id,
string fpr, int comm_type, string lang, identity_flags_t flags)
@ -274,6 +279,7 @@ namespace pEp {
free_identity_list(il);
il = _il;
}
}
}
} // namespace PythonAdapter
} // namespace pEp {

15
src/pEp/native_pEp/identity.hh

@ -3,21 +3,27 @@
#pragma once
// System
#include <boost/python.hpp>
#include <string>
#include <memory>
#include <cstddef>
// Engine
#include <pEp/pEpEngine.h>
#include <pEp/message_api.h>
//libpEpAdapter
#include "pEp/Adapter.hh"
// local
#include "str_attr.hh"
namespace pEp {
namespace PythonAdapter {
using namespace utility;
using namespace std;
using std::string;
using std::shared_ptr;
// Identity is owning a pEp_identity
@ -88,6 +94,7 @@ namespace pEp {
boost::python::list identitylist_attr(identity_list *&il);
void identitylist_attr(identity_list *&il, boost::python::list value);
}
}
} // namespace PythonAdapter
} // namespace pEp {

11
src/pEp/native_pEp/message.cc

@ -1,23 +1,27 @@
// This file is under GNU Affero General Public License 3.0
// see LICENSE.txt
#include <Python.h>
// System
#include <cstdlib>
#include <cstring>
#include <stdexcept>
#include <sstream>
#include <vector>
#include <Python.h>
// Engine
#include <pEp/mime.h>
#include <pEp/keymanagement.h>
#include <pEp/message_api.h>
// local
#include "message.hh"
#include "message_api.hh"
namespace pEp {
namespace PythonAdapter {
using namespace std;
using namespace boost::python;
Message::Blob::Blob(bloblist_t *bl, bool chained) :
_bl(bl), part_of_chain(chained)
@ -404,5 +408,6 @@ namespace pEp {
return m;
}
}
}
} // namespace PythonAdapter
} // namespace pEp {

15
src/pEp/native_pEp/message.hh

@ -3,20 +3,24 @@
#pragma once
// System
#include <string>
#include <boost/python.hpp>
#include <boost/lexical_cast.hpp>
#include <string>
// Engine
#include <pEp/message.h>
#include <pEp/message_api.h>
// local
#include "str_attr.hh"
#include "identity.hh"
namespace pEp {
namespace PythonAdapter {
using namespace std;
using namespace boost::python;
using std::string;
using std::runtime_error;
using std::invalid_argument;
using boost::lexical_cast;
// Message is owning a message struct
@ -142,6 +146,7 @@ namespace pEp {
Message outgoing_message(Identity me);
Message incoming_message(string mime_text);
}
}
} // namespace PythonAdapter
} // namespace pEp {

13
src/pEp/native_pEp/message_api.cc

@ -1,19 +1,24 @@
// This file is under GNU Affero General Public License 3.0
// see LICENSE.txt
// Engine
#include <pEp/pEpEngine.h>
#include <pEp/message_api.h>
#include <pEp/sync_api.h>
#include <pEp/sync_codec.h>
#include <pEp/distribution_codec.h>
// local
#include "message_api.hh"
#include "basic_api.hh"
namespace pEp {
namespace PythonAdapter {
Message encrypt_message(Message src, boost::python::list extra, int enc_format,
int flags)
using namespace std;
using namespace boost::python;
Message encrypt_message(Message src, boost::python::list extra, int enc_format, int flags)
{
Identity _from = src.from();
if (_from.address() == "")
@ -164,5 +169,5 @@ namespace pEp {
}
}
}
}
} // namespace PythonAdapter
} // namespace pEp {

15
src/pEp/native_pEp/message_api.hh

@ -7,11 +7,18 @@
namespace pEp {
namespace PythonAdapter {
Message encrypt_message(Message src, boost::python::list extra = boost::python::list(),
int enc_format = 4, int flags = 0);
Message encrypt_message(
Message src,
boost::python::list extra = boost::python::list(),
int enc_format = 4,
int flags = 0
);
boost::python::tuple decrypt_message(Message src, int flags=0);
PEP_color _color(int rating);
object sync_search(string name);
object distribution_search(string name);
}
}
} // namespace PythonAdapter
} // namespace pEp {

155
src/pEp/native_pEp/pEpmodule.cc

@ -1,6 +1,7 @@
// This file is under GNU Affero General Public License 3.0
// see LICENSE.txt
// System
#include <boost/python.hpp>
#include <boost/locale.hpp>
#include <string>
@ -8,23 +9,35 @@
#include <iomanip>
#include <mutex>
#include <pEp/Adapter.hh>
// 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
#include "pEpmodule.hh"
#include "basic_api.hh"
#include "message_api.hh"
#include "user_interface.hh"
namespace pEp {
namespace PythonAdapter {
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 _init() {
pEpLog("called");
callback_dispatcher.add(_messageToSend, nullptr, nullptr, nullptr);
}
void config_passive_mode(bool enable)
{
@ -57,9 +70,6 @@ namespace pEp {
_throw_status(status);
}
scope *_scope = NULL;
static const char *version_string = "p≡p Python adapter version 0.3";
static string about()
{
string version = string(version_string) + "\np≡p version "
@ -126,7 +136,8 @@ namespace pEp {
::set_debug_color(pEp::Adapter::session(), ansi_color);
}
void leave_device_group() {
void leave_device_group()
{
::leave_device_group(pEp::Adapter::session());
}
@ -134,54 +145,54 @@ namespace pEp {
// adapter.script_is_implementing_sync();
// }
bool is_sync_active() {
bool is_sync_active()
{
return pEp::Adapter::is_sync_running();
}
}
}
BOOST_PYTHON_MODULE(native_pEp)
{
using namespace boost::python;
using namespace boost::locale;
using namespace pEp::PythonAdapter;
docstring_options doc_options(true, false, false);
generator gen;
boost::locale::generator 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("per_user_directory") = per_user_directory();
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,
def("passive_mode", config_passive_mode,
"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");
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"
"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"
"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"
"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"
"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"
"own identities, and opportunistically communicate key reset\n"
"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"
"\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, int>())
.def(boost::python::init<string, string, string, string, int, string>())
.def("__repr__", &pEp::PythonAdapter::Identity::_repr)
.def("__str__", &pEp::PythonAdapter::Identity::_str,
.def("__repr__", &Identity::_repr)
.def("__str__", &Identity::_str,
"string representation of this identity\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(""),
"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"
@ -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"
"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(""),
"If you want updated trust on the identity, you ll have"
"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"
"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"
"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"
"Only use this on own identities, which are used as accounts.\n")
.add_property("address", (string(pEp::PythonAdapter::Identity::*)()) &pEp::PythonAdapter::Identity::address,
(void(pEp::PythonAdapter::Identity::*)(string)) &pEp::PythonAdapter::Identity::address,
.add_property("address", (string(Identity::*)()) &Identity::address,
(void(Identity::*)(string)) &Identity::address,
"email address or URI")
.add_property("fpr", (string(pEp::PythonAdapter::Identity::*)()) &pEp::PythonAdapter::Identity::fpr,
(void(pEp::PythonAdapter::Identity::*)(string)) &pEp::PythonAdapter::Identity::fpr,
.add_property("fpr", (string(Identity::*)()) &Identity::fpr,
(void(Identity::*)(string)) &Identity::fpr,
"key ID (full fingerprint, hex encoded)")
.add_property("user_id", (string(pEp::PythonAdapter::Identity::*)()) &pEp::PythonAdapter::Identity::user_id,
(void(pEp::PythonAdapter::Identity::*)(string)) &pEp::PythonAdapter::Identity::user_id,
.add_property("user_id", (string(Identity::*)()) &Identity::user_id,
(void(Identity::*)(string)) &Identity::user_id,
"ID of person associated or 'pEp_own_userId' if own identity")
.add_property("username", (string(pEp::PythonAdapter::Identity::*)()) &pEp::PythonAdapter::Identity::username,
(void(pEp::PythonAdapter::Identity::*)(string)) &pEp::PythonAdapter::Identity::username,
.add_property("username", (string(Identity::*)()) &Identity::username,
(void(Identity::*)(string)) &Identity::username,
"name in full of person associated")
.add_property("comm_type", (int(pEp::PythonAdapter::Identity::*)())
(PEP_comm_type(pEp::PythonAdapter::Identity::*)()) &pEp::PythonAdapter::Identity::comm_type,
(void(pEp::PythonAdapter::Identity::*)(int))
(void(pEp::PythonAdapter::Identity::*)(PEP_comm_type)) &pEp::PythonAdapter::Identity::comm_type,
.add_property("comm_type", (int(Identity::*)())
(PEP_comm_type(Identity::*)()) &Identity::comm_type,
(void(Identity::*)(int))
(void(Identity::*)(PEP_comm_type)) &Identity::comm_type,
"communication type, first rating level (p≡p internal)")
.add_property("lang", (string(pEp::PythonAdapter::Identity::*)()) &pEp::PythonAdapter::Identity::lang,
(void(pEp::PythonAdapter::Identity::*)(string)) &pEp::PythonAdapter::Identity::lang,
.add_property("lang", (string(Identity::*)()) &Identity::lang,
(void(Identity::*)(string)) &Identity::lang,
"ISO 639-1 language code")
.add_property("flags", (identity_flags_t(pEp::PythonAdapter::Identity::*)()) &pEp::PythonAdapter::Identity::flags,
(void(pEp::PythonAdapter::Identity::*)(identity_flags_t)) &pEp::PythonAdapter::Identity::flags,
.add_property("flags", (identity_flags_t(Identity::*)()) &Identity::flags,
(void(Identity::*)(identity_flags_t)) &Identity::flags,
"flags (p≡p internal)")
.add_property("rating", &pEp::PythonAdapter::Identity::rating, "rating of Identity")
.add_property("color", &pEp::PythonAdapter::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")
.def("__deepcopy__", &pEp::PythonAdapter::Identity::deepcopy)
.def("update", &pEp::PythonAdapter::Identity::update, "update Identity")
.def("__copy__", &pEp::PythonAdapter::Identity::copy);
.add_property("rating", &Identity::rating, "rating of Identity")
.add_property("color", &Identity::color, "color of Identity as PEP_color")
.add_property("is_pEp_user", &Identity::is_pEp_user, "True if this is an identity of a pEp user")
.def("__deepcopy__", &Identity::deepcopy)
.def("update", &Identity::update, "update Identity")
.def("__copy__", &Identity::copy);
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"
)
.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("__str__", &Message::_str,
"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,
(void(Message::*)(time_t)) &Message::recv,
"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,
"identity where message is from")
.add_property("to", (boost::python::list(Message::*)()) &Message::to,
(void(Message::*)(boost::python::list)) &Message::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,
"identity where message was received by")
.add_property("cc", (boost::python::list(Message::*)()) &Message::cc,
@ -414,19 +425,19 @@ BOOST_PYTHON_MODULE(native_pEp)
// basic API and key management API
def("update_identity", &pEp::PythonAdapter::update_identity,
def("update_identity", &update_identity,
"update_identity(ident)\n"
"\n"
"update identity information\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"
"\n"
"ensures that the own identity is being complete\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"
"\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_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"
"\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"
"\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"
"\n"
"reset trust bit or explicitly mistrusted status for an identity and "
"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"
"\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"
"\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"
"\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"
"\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()
def("messageToSend", &pEp::PythonAdapter::messageToSend,
def("messageToSend", &messageToSend,
"messageToSend(msg)\n"
"\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"
// " identities list of identities to share or None for all\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()
// def("do_sync_protocol", &pEp::PythonAdapter::do_sync_protocol,
// def("do_sync_protocol", &do_sync_protocol,
// "do_sync_protocol()\n"
// "\n"
// "in case of an explicit sync thread instead of a single threaded\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"
"\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");
def("leave_device_group", &pEp::PythonAdapter::leave_device_group,
def("leave_device_group", &leave_device_group,
"leave_device_group()\n"
"\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"
// "\n"
// "call this in case the Python script is implementing sync to make\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"
"\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(distribution_search));
}
} // namespace PythonAdapter
} // namespace pEp

9
src/pEp/native_pEp/pEpmodule.hh

@ -1,10 +1,14 @@
#pragma once
// Engine
#include <pEp/pEpEngine.h>
// local
#include "message.hh"
namespace pEp {
namespace PythonAdapter {
extern string device_name;
void config_passive_mode(bool enable);
void config_unencrypted_subject(bool enable);
@ -16,6 +20,7 @@ namespace pEp {
PEP_STATUS _ensure_passphrase(PEP_SESSION session, const char *fpr);
// void do_sync_protocol();
// extern Adapter adapter;
}
}
} // namespace PythonAdapter
} // namespace pEp {

12
src/pEp/native_pEp/str_attr.cc

@ -1,15 +1,18 @@
// This file is under GNU Affero General Public License 3.0
// see LICENSE.txt
// System
#include <cstdlib>
#include <boost/python.hpp>
#include <boost/locale.hpp>
#include <cstdlib>
// local
#include "str_attr.hh"
namespace pEp {
namespace utility {
namespace PythonAdapter {
using namespace std;
using namespace boost::python;
using namespace boost::locale;
object repr(object s)
@ -175,6 +178,7 @@ namespace pEp {
}
return result;
}
}
}
} // namespace PythonAdapter
} // namespace pEp {

14
src/pEp/native_pEp/str_attr.hh

@ -3,17 +3,20 @@
#pragma once
// System
#include <string>
// Engine
#include <pEp/pEpEngine.h>
#include <pEp/timestamp.h>
#include <pEp/stringlist.h>
#include <pEp/stringpair.h>
namespace pEp {
namespace utility {
using namespace std;
using namespace boost::python;
namespace PythonAdapter {
using std::string;
using boost::python::object;
using boost::python::dict;
object repr(object s);
string repr(string s);
@ -32,6 +35,7 @@ namespace pEp {
stringlist_t *to_stringlist(boost::python::list l);
boost::python::list from_stringlist(const stringlist_t *sl);
}
}
} // namespace PythonAdapter
} // namespace pEp {

9
src/pEp/native_pEp/user_interface.cc

@ -1,11 +1,15 @@
// This file is under GNU Affero General Public License 3.0
// see LICENSE.txt
// System
#include <cassert>
// local
#include "user_interface.hh"
namespace pEp {
namespace PythonAdapter {
UserInterface *UserInterface::_ui = nullptr;
UserInterface::UserInterface()
@ -119,6 +123,7 @@ namespace pEp {
{
call_method< void >(_self, "notifyHandshake", me, partner, signal);
}
}
}
} // namespace PythonAdapter
} // namespace pEp {

25
src/pEp/native_pEp/user_interface.hh

@ -3,25 +3,30 @@
#pragma once
// System
#include <csetjmp>
// Engine
#include <pEp/sync_api.h>
#include <pEp/message_api.h>
// local
#include "pEpmodule.hh"
namespace pEp {
namespace PythonAdapter {
class UserInterface {
private:
static UserInterface *_ui;
public:
UserInterface();
virtual ~UserInterface();
virtual void notifyHandshake(
pEp::PythonAdapter::Identity me,
pEp::PythonAdapter::Identity partner,
Identity me,
Identity partner,
sync_handshake_signal signal)
{
throw runtime_error("override this method");
@ -32,22 +37,24 @@ namespace pEp {
PEP_rating get_key_rating_for_user(string user_id, string fpr);
protected:
static PEP_STATUS _notifyHandshake(pEp_identity *me,
pEp_identity *partner, sync_handshake_signal signal);
static PEP_STATUS _notifyHandshake(pEp_identity *me, pEp_identity *partner, sync_handshake_signal signal);
static SYNC_EVENT retrieve_next_sync_event(void *management, unsigned threshold);
};
class UserInterface_callback : public UserInterface {
private:
PyObject *_self;
public:
UserInterface_callback(PyObject *self);
~UserInterface_callback();
void notifyHandshake(
pEp::PythonAdapter::Identity me,
pEp::PythonAdapter::Identity partner,
sync_handshake_signal signal);
Identity me,
Identity partner,
sync_handshake_signal signal
);
};
}
}
} // namespace PythonAdapter
} // namespace pEp {

1
test/pyadpt-81.py

@ -3,4 +3,5 @@
import pEp
dir(pEp)
pEp.is_sync_active()
Loading…
Cancel
Save