Browse Source

remove unnecessary namespace identifier pEp::

PYADPT-81
heck 2 years ago
parent
commit
3d42d9a7d5
9 changed files with 72 additions and 71 deletions
  1. +1
    -2
      setup.py
  2. +2
    -1
      src/pEp/__init__.py
  3. +11
    -11
      src/pEp/native_pEp/basic_api.cc
  4. +8
    -8
      src/pEp/native_pEp/identity.cc
  5. +4
    -4
      src/pEp/native_pEp/message.cc
  6. +2
    -2
      src/pEp/native_pEp/message_api.cc
  7. +34
    -33
      src/pEp/native_pEp/pEpmodule.cc
  8. +10
    -8
      src/pEp/native_pEp/user_interface.cc
  9. +0
    -2
      src/pEp/native_pEp/user_interface.hh

+ 1
- 2
setup.py View File

@ -168,7 +168,6 @@ class BuildExtCommand(build_ext):
# Append prefix-dir
if self.prefix:
pEpLog("using prefix=",self.prefix)
prefix_include=[ join(self.prefix, 'include') ]
prefix_libdirs=[ join(self.prefix, 'lib') ]
includes += prefix_include
@ -219,7 +218,7 @@ module_pEp = Extension(
'src/pEp/native_pEp/message.cc',
'src/pEp/native_pEp/message_api.cc',
'src/pEp/native_pEp/str_attr.cc',
# 'src/user_interface.cc',
'src/pEp/native_pEp/user_interface.cc',
# 'src/adapter.cc'
],
)


+ 2
- 1
src/pEp/__init__.py View File

@ -6,7 +6,8 @@
# Import all symbols EXCEPT the ones beginning with underscore into the current namespace
from native_pEp import *
# TODO: inter-pkg ref to make sure which native_pEp in sys.path gets loaded
# like: pEp.native_pEp
# import the module
import native_pEp


+ 11
- 11
src/pEp/native_pEp/basic_api.cc View File

@ -24,7 +24,7 @@ void update_identity(Identity& ident)
throw runtime_error("update_identity: '" PEP_OWN_USERID
"' may only be used for own identities");
PEP_STATUS status = update_identity(pEp::Adapter::session(), ident);
PEP_STATUS status = update_identity(Adapter::session(), ident);
_throw_status(status);
}
@ -38,7 +38,7 @@ void myself(Identity& ident)
if (ident.user_id() == "")
ident.user_id(ident.address());
PEP_STATUS status = myself(pEp::Adapter::session(), ident);
PEP_STATUS status = myself(Adapter::session(), ident);
_throw_status(status);
}
@ -52,7 +52,7 @@ string _trustwords(Identity me, Identity partner, string lang, bool full)
char *words = NULL;
size_t size = 0;
PEP_STATUS status = get_trustwords(pEp::Adapter::session(), me, partner,
PEP_STATUS status = get_trustwords(Adapter::session(), me, partner,
lang.c_str(),&words, &size, full);
_throw_status(status);
return words;
@ -65,7 +65,7 @@ void trust_personal_key(Identity ident)
if (ident.user_id() == "")
throw invalid_argument("user_id must be provided");
PEP_STATUS status = trust_personal_key(pEp::Adapter::session(), ident);
PEP_STATUS status = trust_personal_key(Adapter::session(), ident);
_throw_status(status);
}
@ -76,7 +76,7 @@ void set_identity_flags(Identity ident, identity_flags_t flags)
if (ident.user_id() == "")
throw invalid_argument("user_id needed");
PEP_STATUS status = set_identity_flags(pEp::Adapter::session(), ident, flags);
PEP_STATUS status = set_identity_flags(Adapter::session(), ident, flags);
_throw_status(status);
}
@ -87,7 +87,7 @@ void unset_identity_flags(Identity ident, identity_flags_t flags)
if (ident.user_id() == "")
throw invalid_argument("user_id needed");
PEP_STATUS status = unset_identity_flags(pEp::Adapter::session(), ident, flags);
PEP_STATUS status = unset_identity_flags(Adapter::session(), ident, flags);
_throw_status(status);
}
@ -100,7 +100,7 @@ void key_reset_trust(Identity ident)
if (ident.user_id() == "")
throw invalid_argument("user_id needed");
PEP_STATUS status = key_reset_trust(pEp::Adapter::session(), ident);
PEP_STATUS status = key_reset_trust(Adapter::session(), ident);
_throw_status(status);
}
@ -109,7 +109,7 @@ void key_reset_trust(Identity ident)
boost::python::list import_key(string key_data)
{
::identity_list *private_keys = NULL;
PEP_STATUS status = ::import_key(pEp::Adapter::session(), key_data.c_str(), key_data.size(), &private_keys);
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);
@ -132,7 +132,7 @@ string export_key(Identity ident)
PEP_STATUS status = PEP_STATUS_OK;
char* key_data = NULL;
size_t size;
status = ::export_key(pEp::Adapter::session(), ident.fpr().c_str(), &key_data, &size);
status = ::export_key(Adapter::session(), ident.fpr().c_str(), &key_data, &size);
_throw_status(status);
return key_data;
@ -143,7 +143,7 @@ string export_secret_key(Identity ident)
PEP_STATUS status = PEP_STATUS_OK;
char* key_data = NULL;
size_t size;
status = ::export_secret_key(pEp::Adapter::session(), ident.fpr().c_str(), &key_data, &size);
status = ::export_secret_key(Adapter::session(), ident.fpr().c_str(), &key_data, &size);
_throw_status(status);
return key_data;
@ -162,7 +162,7 @@ void set_own_key(Identity& ident, string fpr)
const char* fpr_c = fpr.c_str();
PEP_STATUS status = set_own_key(pEp::Adapter::session(), ident, fpr_c);
PEP_STATUS status = set_own_key(Adapter::session(), ident, fpr_c);
_throw_status(status);
}


+ 8
- 8
src/pEp/native_pEp/identity.cc View File

@ -124,7 +124,7 @@ int Identity::rating()
throw invalid_argument("address must be given");
PEP_rating rating = PEP_rating_undefined;
PEP_STATUS status = ::identity_rating(pEp::Adapter::session(), _ident.get(), &rating);
PEP_STATUS status = ::identity_rating(Adapter::session(), _ident.get(), &rating);
_throw_status(status);
return (int) rating;
@ -156,34 +156,34 @@ void Identity::update()
void Identity::key_reset(string fpr)
{
PEP_STATUS status = ::key_reset_identity(pEp::Adapter::session(), *this,
PEP_STATUS status = ::key_reset_identity(Adapter::session(), *this,
fpr != "" ? fpr.c_str() : nullptr);
_throw_status(status);
}
void Identity::key_mistrusted()
{
PEP_STATUS status = ::key_mistrusted(pEp::Adapter::session(), *this);
PEP_STATUS status = ::key_mistrusted(Adapter::session(), *this);
_throw_status(status);
}
bool Identity::is_pEp_user()
{
bool result;
PEP_STATUS status = ::is_pEp_user(pEp::Adapter::session(), *this, &result);
PEP_STATUS status = ::is_pEp_user(Adapter::session(), *this, &result);
_throw_status(status);
return result;
}
void Identity::enable_for_sync()
{
PEP_STATUS status = ::enable_identity_for_sync(pEp::Adapter::session(), *this);
PEP_STATUS status = ::enable_identity_for_sync(Adapter::session(), *this);
_throw_status(status);
}
void Identity::disable_for_sync()
{
PEP_STATUS status = ::disable_identity_for_sync(pEp::Adapter::session(), *this);
PEP_STATUS status = ::disable_identity_for_sync(Adapter::session(), *this);
_throw_status(status);
}
@ -226,7 +226,7 @@ void identity_attr(pEp_identity *&ident, object value)
pEp_identity *_dup = ::identity_dup(_ident);
if (!_dup)
throw bad_alloc();
PEP_STATUS status = update_identity(pEp::Adapter::session(), _dup);
PEP_STATUS status = update_identity(Adapter::session(), _dup);
_throw_status(status);
free_identity(ident);
ident = _dup;
@ -264,7 +264,7 @@ void identitylist_attr(identity_list *&il, boost::python::list value)
free_identity_list(_il);
throw bad_alloc();
}
PEP_STATUS status = update_identity(pEp::Adapter::session(), _dup);
PEP_STATUS status = update_identity(Adapter::session(), _dup);
if (status != PEP_STATUS_OK) {
free_identity_list(_il);
_throw_status(status);


+ 4
- 4
src/pEp/native_pEp/message.cc View File

@ -332,11 +332,11 @@ PEP_rating Message::outgoing_rating()
if (len(to()) + len(cc()) == 0)
throw invalid_argument("either to or cc needed");
PEP_STATUS status = myself(pEp::Adapter::session(), _msg->from);
PEP_STATUS status = myself(Adapter::session(), _msg->from);
_throw_status(status);
PEP_rating rating = PEP_rating_undefined;
status = outgoing_message_rating(pEp::Adapter::session(), *this, &rating);
status = outgoing_message_rating(Adapter::session(), *this, &rating);
_throw_status(status);
return rating;
@ -365,7 +365,7 @@ Message outgoing_message(Identity me)
if (me.address().empty() || me.user_id().empty())
throw runtime_error("at least address and user_id of own user needed");
::myself(pEp::Adapter::session(), me);
::myself(Adapter::session(), me);
auto m = Message(PEP_dir_outgoing, &me);
return m;
}
@ -374,7 +374,7 @@ static object update(Identity ident)
{
if (ident.address().empty())
throw runtime_error("at least address needed");
update_identity(pEp::Adapter::session(), ident);
update_identity(Adapter::session(), ident);
return object(ident);
}


+ 2
- 2
src/pEp/native_pEp/message_api.cc View File

@ -35,7 +35,7 @@ Message encrypt_message(Message src, boost::python::list extra, int enc_format,
message *_dst = NULL;
message *_src = src;
PEP_STATUS status = encrypt_message(pEp::Adapter::session(), _src, _extra, &_dst,
PEP_STATUS status = encrypt_message(Adapter::session(), _src, _extra, &_dst,
_enc_format, _flags);
free_stringlist(_extra);
_throw_status(status);
@ -54,7 +54,7 @@ boost::python::tuple decrypt_message(Message src, int flags)
PEP_decrypt_flags_t _flags = (PEP_decrypt_flags_t) flags;
message *_src = src;
PEP_STATUS status = ::decrypt_message(pEp::Adapter::session(), _src, &_dst, &_keylist,
PEP_STATUS status = ::decrypt_message(Adapter::session(), _src, &_dst, &_keylist,
&_rating, &_flags);
_throw_status(status);


+ 34
- 33
src/pEp/native_pEp/pEpmodule.cc View File

@ -37,16 +37,17 @@ static const char *version_string = "p≡p Python adapter version 0.3";
void _init() {
pEpLog("called");
callback_dispatcher.add(_messageToSend, nullptr, nullptr, nullptr);
Adapter::_messageToSend = CallbackDispatcher::messageToSend;
}
void config_passive_mode(bool enable)
{
::config_passive_mode(pEp::Adapter::session(), enable);
::config_passive_mode(Adapter::session(), enable);
}
void config_unencrypted_subject(bool enable)
{
::config_unencrypted_subject(pEp::Adapter::session(), enable);
::config_unencrypted_subject(Adapter::session(), enable);
}
void key_reset_user(string user_id, string fpr)
@ -54,7 +55,7 @@ void key_reset_user(string user_id, string fpr)
if (user_id == "")
throw invalid_argument("user_id required");
PEP_STATUS status = ::key_reset_user(pEp::Adapter::session(),
PEP_STATUS status = ::key_reset_user(Adapter::session(),
user_id.c_str(), fpr != "" ? fpr.c_str() : nullptr);
_throw_status(status);
}
@ -66,7 +67,7 @@ void key_reset_user2(string user_id)
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(Adapter::session());
_throw_status(status);
}
@ -123,22 +124,22 @@ void messageToSend(Message msg) {
// void do_sync_protocol()
// {
// ::do_sync_protocol(pEp::Adapter::session(), nullptr);
// ::do_sync_protocol(Adapter::session(), nullptr);
// }
void shutdown_sync()
{
pEp::Adapter::shutdown();
Adapter::shutdown();
}
void debug_color(int ansi_color)
{
::set_debug_color(pEp::Adapter::session(), ansi_color);
::set_debug_color(Adapter::session(), ansi_color);
}
void leave_device_group()
{
::leave_device_group(pEp::Adapter::session());
::leave_device_group(Adapter::session());
}
// void script_is_implementing_sync() {
@ -147,7 +148,7 @@ void leave_device_group()
bool is_sync_active()
{
return pEp::Adapter::is_sync_running();
return Adapter::is_sync_running();
}
BOOST_PYTHON_MODULE(native_pEp)
@ -565,30 +566,30 @@ BOOST_PYTHON_MODULE(native_pEp)
.value("SYNC_NOTIFY_SOLE" , SYNC_NOTIFY_SOLE)
.value("SYNC_NOTIFY_IN_GROUP" , SYNC_NOTIFY_IN_GROUP);
// auto user_interface_class = class_<UserInterface, UserInterface_callback, boost::noncopyable>(
// "UserInterface",
// "class MyUserInterface(UserInterface):\n"
// " def notifyHandshake(self, me, partner):\n"
// " ...\n"
// "\n"
// "p≡p User Interface class\n"
// "To be used as a mixin\n"
// )
// .def("notifyHandshake", &UserInterface::notifyHandshake,
// "notifyHandshake(self, me, partner)\n"
// "\n"
// " me own identity\n"
// " partner identity of communication partner\n"
// "\n"
// "overwrite this method with an implementation of a handshake dialog")
// .def("deliverHandshakeResult", &UserInterface::deliverHandshakeResult,
// boost::python::arg("identities")=object(),
// "deliverHandshakeResult(self, result, identities=None)\n"
// "\n"
// " 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");
auto user_interface_class = class_<UserInterface, UserInterface_callback, boost::noncopyable>(
"UserInterface",
"class MyUserInterface(UserInterface):\n"
" def notifyHandshake(self, me, partner):\n"
" ...\n"
"\n"
"p≡p User Interface class\n"
"To be used as a mixin\n"
)
.def("notifyHandshake", &UserInterface::notifyHandshake,
"notifyHandshake(self, me, partner)\n"
"\n"
" me own identity\n"
" partner identity of communication partner\n"
"\n"
"overwrite this method with an implementation of a handshake dialog")
.def("deliverHandshakeResult", &UserInterface::deliverHandshakeResult,
boost::python::arg("identities")=object(),
"deliverHandshakeResult(self, result, identities=None)\n"
"\n"
" 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");
// TODO: Replace with start_sync()


+ 10
- 8
src/pEp/native_pEp/user_interface.cc View File

@ -9,6 +9,8 @@
namespace pEp {
namespace PythonAdapter {
using namespace std;
using namespace boost::python;
UserInterface *UserInterface::_ui = nullptr;
@ -28,16 +30,16 @@ UserInterface_callback::UserInterface_callback(PyObject *self) :
UserInterface(), _self(self)
{
// adapter.ui_object(self);
PEP_STATUS status = ::register_sync_callbacks(pEp::Adapter::session(),
(void *) this, _notifyHandshake, retrieve_next_sync_event);
assert(status == PEP_STATUS_OK);
if (status)
_throw_status(status);
// PEP_STATUS status = ::register_sync_callbacks(Adapter::session(),
// (void *) this, _notifyHandshake, retrieve_next_sync_event);
// assert(status == PEP_STATUS_OK);
// if (status)
// _throw_status(status);
}
UserInterface_callback::~UserInterface_callback()
{
::unregister_sync_callbacks(pEp::Adapter::session());
// ::unregister_sync_callbacks(Adapter::session());
}
PEP_STATUS UserInterface::_notifyHandshake(
@ -78,7 +80,7 @@ void UserInterface::deliverHandshakeResult(int result, object identities)
}
}
PEP_STATUS status = ::deliverHandshakeResult(pEp::Adapter::session(),
PEP_STATUS status = ::deliverHandshakeResult(Adapter::session(),
(sync_handshake_result) result, shared_identities);
free_identity_list(shared_identities);
_throw_status(status);
@ -88,7 +90,7 @@ PEP_rating UserInterface::get_key_rating_for_user(string user_id, string fpr)
{
PEP_rating result;
PEP_STATUS status =
::get_key_rating_for_user(pEp::Adapter::session(),
::get_key_rating_for_user(Adapter::session(),
user_id.c_str(), fpr.c_str(), &result);
_throw_status(status);
return result;


+ 0
- 2
src/pEp/native_pEp/user_interface.hh View File

@ -18,7 +18,6 @@ namespace pEp {
namespace PythonAdapter {
class UserInterface {
private:
static UserInterface *_ui;
public:
UserInterface();
@ -42,7 +41,6 @@ protected:
};
class UserInterface_callback : public UserInterface {
private:
PyObject *_self;
public:
UserInterface_callback(PyObject *self);


Loading…
Cancel
Save