Browse Source

Mark all symbols from the pEpEngine with explicit global namespace. (e.g: ::pEp_stuff).

master
heck 5 years ago
parent
commit
63e830040c
  1. 32
      src/pEp/_pEp/basic_api.cc
  2. 5
      src/pEp/_pEp/basic_api.hh
  3. 65
      src/pEp/_pEp/identity.cc
  4. 28
      src/pEp/_pEp/identity.hh
  5. 76
      src/pEp/_pEp/message.cc
  6. 24
      src/pEp/_pEp/message.hh
  7. 49
      src/pEp/_pEp/message_api.cc
  8. 2
      src/pEp/_pEp/message_api.hh
  9. 113
      src/pEp/_pEp/pEpmodule.cc
  10. 6
      src/pEp/_pEp/pEpmodule.hh
  11. 40
      src/pEp/_pEp/str_attr.cc
  12. 16
      src/pEp/_pEp/str_attr.hh
  13. 12
      src/pEp/_pEp/user_interface.cc
  14. 2
      src/pEp/_pEp/user_interface.hh

32
src/pEp/_pEp/basic_api.cc

@ -24,7 +24,7 @@ namespace pEp {
PEP_OWN_USERID
"' may only be used for own identities");
PEP_STATUS status = update_identity(Adapter::session(), ident);
::PEP_STATUS status = ::update_identity(Adapter::session(), ident);
_throw_status(status);
}
@ -37,7 +37,7 @@ namespace pEp {
if (ident.user_id() == "")
ident.user_id(ident.address());
PEP_STATUS status = myself(Adapter::session(), ident);
::PEP_STATUS status = ::myself(Adapter::session(), ident);
_throw_status(status);
}
@ -50,7 +50,7 @@ namespace pEp {
char *words = NULL;
size_t size = 0;
PEP_STATUS status = get_trustwords(Adapter::session(), me, partner,
::PEP_STATUS status = ::get_trustwords(Adapter::session(), me, partner,
lang.c_str(), &words, &size, full);
_throw_status(status);
return words;
@ -62,27 +62,27 @@ namespace pEp {
if (ident.user_id() == "")
throw invalid_argument("user_id must be provided");
PEP_STATUS status = trust_personal_key(Adapter::session(), ident);
::PEP_STATUS status = ::trust_personal_key(Adapter::session(), ident);
_throw_status(status);
}
void set_identity_flags(Identity ident, identity_flags_t flags) {
void set_identity_flags(Identity ident, ::identity_flags_t flags) {
if (ident.address() == "")
throw invalid_argument("address needed");
if (ident.user_id() == "")
throw invalid_argument("user_id needed");
PEP_STATUS status = set_identity_flags(Adapter::session(), ident, flags);
::PEP_STATUS status = ::set_identity_flags(Adapter::session(), ident, flags);
_throw_status(status);
}
void unset_identity_flags(Identity ident, identity_flags_t flags) {
void unset_identity_flags(Identity ident, ::identity_flags_t flags) {
if (ident.address() == "")
throw invalid_argument("address needed");
if (ident.user_id() == "")
throw invalid_argument("user_id needed");
PEP_STATUS status = unset_identity_flags(Adapter::session(), ident, flags);
::PEP_STATUS status = ::unset_identity_flags(Adapter::session(), ident, flags);
_throw_status(status);
}
@ -94,33 +94,33 @@ namespace pEp {
if (ident.user_id() == "")
throw invalid_argument("user_id needed");
PEP_STATUS status = key_reset_trust(Adapter::session(), ident);
::PEP_STATUS status = ::key_reset_trust(Adapter::session(), ident);
_throw_status(status);
}
boost::python::list import_key(string key_data) {
::identity_list *private_keys = NULL;
PEP_STATUS status = ::import_key(Adapter::session(), key_data.c_str(), key_data.size(), &private_keys);
if (status && status != PEP_KEY_IMPORTED)
::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);
auto result = boost::python::list();
for (::identity_list *il = private_keys; il && il->ident; il = il->next) {
::pEp_identity *ident = ::identity_dup(il->ident);
if (!ident) {
free_identity_list(private_keys);
::free_identity_list(private_keys);
throw bad_alloc();
}
result.append(Identity(ident));
}
free_identity_list(private_keys);
::free_identity_list(private_keys);
return result;
}
string export_key(Identity ident) {
PEP_STATUS status = PEP_STATUS_OK;
::PEP_STATUS status = ::PEP_STATUS_OK;
char *key_data = NULL;
size_t size;
status = ::export_key(Adapter::session(), ident.fpr().c_str(), &key_data, &size);
@ -130,7 +130,7 @@ namespace pEp {
}
string export_secret_key(Identity ident) {
PEP_STATUS status = PEP_STATUS_OK;
::PEP_STATUS status = ::PEP_STATUS_OK;
char *key_data = NULL;
size_t size;
status = ::export_secret_key(Adapter::session(), ident.fpr().c_str(), &key_data, &size);
@ -151,7 +151,7 @@ namespace pEp {
const char *fpr_c = fpr.c_str();
PEP_STATUS status = set_own_key(Adapter::session(), ident, fpr_c);
::PEP_STATUS status = ::set_own_key(Adapter::session(), ident, fpr_c);
_throw_status(status);
}

5
src/pEp/_pEp/basic_api.hh

@ -5,6 +5,7 @@
#define BASIC_API_HH
#include "pEpmodule.hh"
#include "identity.hh"
namespace pEp {
namespace PythonAdapter {
@ -17,9 +18,9 @@ namespace pEp {
void trust_personal_key(Identity ident);
void set_identity_flags(Identity ident, identity_flags_t flags);
void set_identity_flags(Identity ident, ::identity_flags_t flags);
void unset_identity_flags(Identity ident, identity_flags_t flags);
void unset_identity_flags(Identity ident, ::identity_flags_t flags);
void key_reset_trust(Identity ident);

65
src/pEp/_pEp/identity.cc

@ -22,13 +22,13 @@ namespace pEp {
using namespace boost::python;
Identity::Identity(string address, string username, string user_id,
string fpr, int comm_type, string lang, identity_flags_t flags)
: _ident(new_identity(address.c_str(), fpr.c_str(), user_id.c_str(),
string fpr, int comm_type, string lang, ::identity_flags_t flags)
: _ident(::new_identity(address.c_str(), fpr.c_str(), user_id.c_str(),
username.c_str()), &::free_identity) {
if (!_ident)
throw bad_alloc();
_ident->comm_type = (PEP_comm_type) comm_type;
_ident->flags = (identity_flags_t) flags;
_ident->comm_type = (::PEP_comm_type) comm_type;
_ident->flags = (::identity_flags_t) flags;
this->lang(lang);
}
@ -37,7 +37,7 @@ namespace pEp {
}
Identity::Identity(pEp_identity *ident)
Identity::Identity(::pEp_identity *ident)
: _ident(ident, &::free_identity) {
}
@ -46,11 +46,11 @@ namespace pEp {
}
Identity::operator pEp_identity *() {
Identity::operator ::pEp_identity *() {
return _ident.get();
}
Identity::operator const pEp_identity *() const {
Identity::operator const ::pEp_identity *() const {
return _ident.get();
}
@ -111,19 +111,19 @@ namespace pEp {
if (!(_ident->address))
throw invalid_argument("address must be given");
PEP_rating rating = PEP_rating_undefined;
PEP_STATUS status = ::identity_rating(Adapter::session(), _ident.get(), &rating);
::PEP_rating rating = ::PEP_rating_undefined;
::PEP_STATUS status = ::identity_rating(Adapter::session(), _ident.get(), &rating);
_throw_status(status);
return (int) rating;
}
PEP_color Identity::color() {
::PEP_color Identity::color() {
return _color(rating());
}
Identity Identity::copy() {
pEp_identity *dup = ::identity_dup(*this);
::pEp_identity *dup = ::identity_dup(*this);
if (!dup)
throw bad_alloc();
@ -139,30 +139,29 @@ namespace pEp {
}
void Identity::key_reset(string fpr) {
PEP_STATUS status = ::key_reset_identity(Adapter::session(), *this,
fpr != "" ? fpr.c_str() : nullptr);
::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(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(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(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(Adapter::session(), *this);
::PEP_STATUS status = ::disable_identity_for_sync(Adapter::session(), *this);
_throw_status(status);
}
@ -183,11 +182,11 @@ namespace pEp {
// pEp::PythonAdapter::myself(*this);
// }
Identity identity_attr(pEp_identity *&ident) {
Identity identity_attr(::pEp_identity *&ident) {
if (!ident)
throw out_of_range("no identity assigned");
pEp_identity *_dup = ::identity_dup(ident);
::pEp_identity *_dup = ::identity_dup(ident);
if (!_dup)
throw bad_alloc();
@ -195,22 +194,22 @@ namespace pEp {
return _ident;
}
void identity_attr(pEp_identity *&ident, object value) {
void identity_attr(::pEp_identity *&ident, object value) {
Identity &_ident = extract<Identity &>(value);
pEp_identity *_dup = ::identity_dup(_ident);
::pEp_identity *_dup = ::identity_dup(_ident);
if (!_dup)
throw bad_alloc();
PEP_STATUS status = ::update_identity(Adapter::session(), _dup);
::PEP_STATUS status = ::update_identity(Adapter::session(), _dup);
_throw_status(status);
::free_identity(ident);
ident = _dup;
}
boost::python::list identitylist_attr(identity_list *&il) {
boost::python::list identitylist_attr(::identity_list *&il) {
boost::python::list result;
for (identity_list *_il = il; _il && _il->ident; _il = _il->next) {
pEp_identity *ident = ::identity_dup(_il->ident);
for (::identity_list *_il = il; _il && _il->ident; _il = _il->next) {
::pEp_identity *ident = ::identity_dup(_il->ident);
if (!ident)
throw bad_alloc();
result.append(object(Identity(ident)));
@ -219,25 +218,25 @@ namespace pEp {
return result;
}
void identitylist_attr(identity_list *&il, boost::python::list value) {
identity_list *_il = ::new_identity_list(NULL);
void identitylist_attr(::identity_list *&il, boost::python::list value) {
::identity_list *_il = ::new_identity_list(NULL);
if (!_il)
throw bad_alloc();
identity_list *_i = _il;
::identity_list *_i = _il;
for (int i = 0; i < len(value); i++) {
extract < Identity & > extract_identity(value[i]);
if (!extract_identity.check()) {
free_identity_list(_il);
::free_identity_list(_il);
}
pEp_identity *_ident = extract_identity();
pEp_identity *_dup = ::identity_dup(_ident);
::pEp_identity *_ident = extract_identity();
::pEp_identity *_dup = ::identity_dup(_ident);
if (!_dup) {
::free_identity_list(_il);
throw bad_alloc();
}
PEP_STATUS status = ::update_identity(Adapter::session(), _dup);
if (status != PEP_STATUS_OK) {
::PEP_STATUS status = ::update_identity(Adapter::session(), _dup);
if (status != ::PEP_STATUS_OK) {
::free_identity_list(_il);
_throw_status(status);
}

28
src/pEp/_pEp/identity.hh

@ -30,22 +30,22 @@ namespace pEp {
class Identity {
protected:
shared_ptr <pEp_identity> _ident;
shared_ptr <::pEp_identity> _ident;
public:
Identity(string address = "", string username = "",
string user_id = "", string fpr = "", int comm_type = 0,
string lang = "", identity_flags_t flags = 0);
string lang = "", ::identity_flags_t flags = 0);
Identity(const Identity &second);
Identity(pEp_identity *ident);
Identity(::pEp_identity *ident);
virtual ~Identity();
operator pEp_identity *();
operator ::pEp_identity *();
operator const pEp_identity *() const;
operator const ::pEp_identity *() const;
string _repr();
@ -67,21 +67,21 @@ namespace pEp {
void username(string value);
PEP_comm_type comm_type() { return _ident->comm_type; }
::PEP_comm_type comm_type() { return _ident->comm_type; }
void comm_type(PEP_comm_type value) { _ident->comm_type = value; };
void comm_type(::PEP_comm_type value) { _ident->comm_type = value; };
std::string lang();
void lang(std::string value);
identity_flags_t flags() { return _ident->flags; }
::identity_flags_t flags() { return _ident->flags; }
void flags(identity_flags_t flags) { _ident->flags = flags; }
void flags(::identity_flags_t flags) { _ident->flags = flags; }
int rating();
PEP_color color();
::PEP_color color();
Identity copy();
@ -107,13 +107,13 @@ namespace pEp {
// virtual void update();
// };
Identity identity_attr(pEp_identity *&ident);
Identity identity_attr(::pEp_identity *&ident);
void identity_attr(pEp_identity *&ident, object value);
void identity_attr(::pEp_identity *&ident, object value);
boost::python::list identitylist_attr(identity_list *&il);
boost::python::list identitylist_attr(::identity_list *&il);
void identitylist_attr(identity_list *&il, boost::python::list value);
void identitylist_attr(::identity_list *&il, boost::python::list value);
} // namespace PythonAdapter
} // namespace pEp

76
src/pEp/_pEp/message.cc

@ -23,14 +23,14 @@ namespace pEp {
using namespace std;
using namespace boost::python;
Message::Blob::Blob(bloblist_t *bl, bool chained) :
Message::Blob::Blob(::bloblist_t *bl, bool chained) :
_bl(bl), part_of_chain(chained) {
if (!_bl)
throw bad_alloc();
}
Message::Blob::Blob(object data, string mime_type, string filename) :
_bl(new_bloblist(NULL, 0, NULL, NULL)), part_of_chain(false) {
_bl(::new_bloblist(NULL, 0, NULL, NULL)), part_of_chain(false) {
if (!_bl)
throw bad_alloc();
@ -89,7 +89,7 @@ namespace pEp {
}
int Message::Blob::getbuffer(PyObject *self, Py_buffer *view, int flags) {
bloblist_t *bl = NULL;
::bloblist_t *bl = NULL;
try {
Message::Blob &blob = extract<Message::Blob &>(self);
@ -130,7 +130,7 @@ namespace pEp {
PyBufferProcs Message::Blob::bp = {getbuffer, NULL};
Message::Message(int dir, Identity *from)
: _msg(new_message((PEP_msg_direction) dir), &free_message) {
: _msg(new_message((::PEP_msg_direction) dir), &::free_message) {
if (!_msg)
throw bad_alloc();
@ -138,35 +138,35 @@ namespace pEp {
_msg->from = ::identity_dup(*from);
if (!_msg->from)
throw bad_alloc();
_msg->dir = (PEP_msg_direction) dir;
_msg->dir = (::PEP_msg_direction) dir;
}
}
Message::Message(string mimetext)
: _msg(NULL, &free_message) {
: _msg(NULL, &::free_message) {
message *_cpy;
PEP_STATUS status = mime_decode_message(mimetext.c_str(),
::PEP_STATUS status = ::mime_decode_message(mimetext.c_str(),
mimetext.size(), &_cpy, NULL);
switch (status) {
case PEP_STATUS_OK:
case ::PEP_STATUS_OK:
if (_cpy)
_cpy->dir = PEP_dir_outgoing;
_cpy->dir = ::PEP_dir_outgoing;
else
_cpy = new_message(PEP_dir_outgoing);
_cpy = new_message(::PEP_dir_outgoing);
if (!_cpy)
throw bad_alloc();
_msg = shared_ptr<message>(_cpy);
_msg = shared_ptr<::message>(_cpy);
break;
case PEP_BUFFER_TOO_SMALL:
case ::PEP_BUFFER_TOO_SMALL:
throw runtime_error("mime_decode_message: buffer too small");
case PEP_CANNOT_CREATE_TEMP_FILE:
case ::PEP_CANNOT_CREATE_TEMP_FILE:
throw runtime_error("mime_decode_message: cannot create temp file");
case PEP_OUT_OF_MEMORY:
case ::PEP_OUT_OF_MEMORY:
throw bad_alloc();
default:
@ -182,8 +182,8 @@ namespace pEp {
throw bad_alloc();
}
Message::Message(message *msg)
: _msg(::message_dup(msg), &free_message) {
Message::Message(::message *msg)
: _msg(::message_dup(msg), &::free_message) {
}
@ -191,11 +191,11 @@ namespace pEp {
}
Message::operator message *() {
Message::operator ::message *() {
return _msg.get();
}
Message::operator const message *() const {
Message::operator const ::message *() const {
return _msg.get();
}
@ -206,20 +206,20 @@ namespace pEp {
char *mimetext;
string result;
PEP_STATUS status = mime_encode_message(*this, false, &mimetext, false);
::PEP_STATUS status = ::mime_encode_message(*this, false, &mimetext, false);
switch (status) {
case PEP_STATUS_OK:
case ::PEP_STATUS_OK:
result = mimetext;
free(mimetext);
break;
case PEP_BUFFER_TOO_SMALL:
case ::PEP_BUFFER_TOO_SMALL:
throw runtime_error("mime_encode_message: buffer too small");
case PEP_CANNOT_CREATE_TEMP_FILE:
case ::PEP_CANNOT_CREATE_TEMP_FILE:
throw runtime_error("mime_encode_message: cannot create temp file");
case PEP_OUT_OF_MEMORY:
case ::PEP_OUT_OF_MEMORY:
throw bad_alloc();
default:
@ -240,7 +240,7 @@ namespace pEp {
boost::python::tuple Message::attachments() {
boost::python::list l;
for (bloblist_t *bl = _msg->attachments; bl && bl->value; bl =
for (::bloblist_t *bl = _msg->attachments; bl && bl->value; bl =
bl->next) {
l.append(Blob(bl, true));
}
@ -249,11 +249,11 @@ namespace pEp {
}
void Message::attachments(boost::python::list value) {
bloblist_t *bl = new_bloblist(NULL, 0, NULL, NULL);
::bloblist_t *bl = ::new_bloblist(NULL, 0, NULL, NULL);
if (!bl)
throw bad_alloc();
bloblist_t *_l = bl;
::bloblist_t *_l = bl;
for (int i = 0; i < len(value); i++) {
Message::Blob &blob = extract<Message::Blob &>(value[i]);
_l = bloblist_add(_l, blob._bl->value, blob._bl->size,
@ -262,7 +262,7 @@ namespace pEp {
for (_l = bl; _l && _l->value;) {
free(_l->mime_type);
free(_l->filename);
bloblist_t *_ll = _l;
::bloblist_t *_ll = _l;
_l = _l->next;
free(_ll);
}
@ -286,12 +286,12 @@ namespace pEp {
Message Message::encrypt() {
boost::python::list extra;
return encrypt_message(*this, extra, PEP_enc_PGP_MIME, 0);
return encrypt_message(*this, extra, ::PEP_enc_PGP_MIME, 0);
}
Message Message::_encrypt(boost::python::list extra, int enc_format, int flags) {
if (!enc_format)
enc_format = PEP_enc_PGP_MIME;
enc_format = ::PEP_enc_PGP_MIME;
return encrypt_message(*this, extra, enc_format, flags);
}
@ -299,8 +299,8 @@ namespace pEp {
return pEp::PythonAdapter::decrypt_message(*this, flags);
}
PEP_rating Message::outgoing_rating() {
if (_msg->dir != PEP_dir_outgoing)
::PEP_rating Message::outgoing_rating() {
if (_msg->dir != ::PEP_dir_outgoing)
throw invalid_argument("Message.dir must be outgoing");
if (from().address() == "")
@ -311,22 +311,22 @@ namespace pEp {
if (len(to()) + len(cc()) == 0)
throw invalid_argument("either to or cc needed");
PEP_STATUS status = myself(Adapter::session(), _msg->from);
::PEP_STATUS status = myself(Adapter::session(), _msg->from);
_throw_status(status);
PEP_rating rating = PEP_rating_undefined;
::PEP_rating rating = ::PEP_rating_undefined;
status = outgoing_message_rating(Adapter::session(), *this, &rating);
_throw_status(status);
return rating;
}
PEP_color Message::outgoing_color() {
::PEP_color Message::outgoing_color() {
return _color(outgoing_rating());
}
Message Message::copy() {
message *dup = message_dup(*this);
::message *dup = ::message_dup(*this);
if (!dup)
throw bad_alloc();
return Message(dup);
@ -341,14 +341,14 @@ namespace pEp {
throw runtime_error("at least address and user_id of own user needed");
::myself(Adapter::session(), me);
auto m = Message(PEP_dir_outgoing, &me);
auto m = Message(::PEP_dir_outgoing, &me);
return m;
}
static object update(Identity ident) {
if (ident.address().empty())
throw runtime_error("at least address needed");
update_identity(Adapter::session(), ident);
::update_identity(Adapter::session(), ident);
return object(ident);
}
@ -362,7 +362,7 @@ namespace pEp {
Message incoming_message(string mime_text) {
auto m = Message(mime_text);
m.dir(PEP_dir_incoming);
m.dir(::PEP_dir_incoming);
try {
m.from(update(m.from()));

24
src/pEp/_pEp/message.hh

@ -34,11 +34,11 @@ namespace pEp {
// one depending on part_of_chain
class Blob {
bloblist_t *_bl;
::bloblist_t *_bl;
bool part_of_chain;
public:
Blob(bloblist_t *bl = new_bloblist(NULL, 0, NULL, NULL),
Blob(::bloblist_t *bl = ::new_bloblist(NULL, 0, NULL, NULL),
bool chained = false);
Blob(object data, string mime_type = "", string filename = "");
@ -71,27 +71,27 @@ namespace pEp {
static int getbuffer(PyObject *self, Py_buffer *view, int flags);
};
Message(int dir = PEP_dir_outgoing, Identity *from = NULL);
Message(int dir = ::PEP_dir_outgoing, Identity *from = NULL);
Message(string mimetext);
Message(const Message &second);
Message(message *msg);
Message(::message *msg);
~Message();
operator message *();
operator ::message *();
operator const message *() const;
operator const ::message *() const;
string _str();
string _repr();
PEP_msg_direction dir() { return _msg->dir; }
::PEP_msg_direction dir() { return _msg->dir; }
void dir(PEP_msg_direction value) { _msg->dir = value; }
void dir(::PEP_msg_direction value) { _msg->dir = value; }
string id() { return str_attr(_msg->id); }
@ -165,9 +165,9 @@ namespace pEp {
void opt_fields(dict value) { return strdict_attr(_msg->opt_fields, value); }
PEP_enc_format enc_format() { return _msg->enc_format; }
::PEP_enc_format enc_format() { return _msg->enc_format; }
void enc_format(PEP_enc_format value) { _msg->enc_format = value; }
void enc_format(::PEP_enc_format value) { _msg->enc_format = value; }
Message encrypt();
@ -175,9 +175,9 @@ namespace pEp {
boost::python::tuple decrypt(int flags = 0);
PEP_rating outgoing_rating();
::PEP_rating outgoing_rating();
PEP_color outgoing_color();
::PEP_color outgoing_color();
Message deepcopy(dict &memo);

49
src/pEp/_pEp/message_api.cc

@ -16,7 +16,7 @@ namespace pEp {
namespace PythonAdapter {
using namespace std;
using namespace boost::python;
// namespace bp = boost::python;
Message encrypt_message(Message src, boost::python::list extra, int enc_format, int flags) {
Identity _from = src.from();
if (_from.address() == "")
@ -27,56 +27,57 @@ namespace pEp {
if (_from.user_id() == "")
src.from().user_id(_from.address());
stringlist_t *_extra = to_stringlist(extra);
PEP_enc_format _enc_format = (PEP_enc_format) enc_format;
PEP_encrypt_flags_t _flags = (PEP_encrypt_flags_t) flags;
message *_dst = NULL;
::stringlist_t *_extra = to_stringlist(extra);
::PEP_enc_format _enc_format = (::PEP_enc_format) enc_format;
::PEP_encrypt_flags_t _flags = (::PEP_encrypt_flags_t) flags;
::message *_dst = NULL;
message *_src = src;
PEP_STATUS status = encrypt_message(Adapter::session(), _src, _extra, &_dst,
_enc_format, _flags);
free_stringlist(_extra);
::message *_src = src;
::PEP_STATUS status = ::encrypt_message(Adapter::session(), _src, _extra, &_dst, _enc_format, _flags);
::free_stringlist(_extra);
_throw_status(status);
if (!_dst || _dst == _src)
if (!_dst || _dst == _src) {
return Message(_src);
}
return Message(_dst);
}
boost::python::tuple decrypt_message(Message src, int flags) {
message *_dst = NULL;
stringlist_t *_keylist = NULL;
PEP_rating _rating = PEP_rating_undefined;
PEP_decrypt_flags_t _flags = (PEP_decrypt_flags_t) flags;
message *_src = src;
::message *_dst = NULL;
::stringlist_t *_keylist = NULL;
::PEP_rating _rating = ::PEP_rating_undefined;
::PEP_decrypt_flags_t _flags = (::PEP_decrypt_flags_t) flags;
::message *_src = src;
PEP_STATUS status = ::decrypt_message(Adapter::session(), _src, &_dst, &_keylist,
::PEP_STATUS status = ::decrypt_message(Adapter::session(), _src, &_dst, &_keylist,
&_rating, &_flags);
_throw_status(status);
boost::python::list keylist;
if (_keylist) {
keylist = from_stringlist(_keylist);
free_stringlist(_keylist);
::free_stringlist(_keylist);
}
Message dst = _dst ? Message(_dst) : Message(src);
return boost::python::make_tuple(dst, keylist, _rating, _flags);
}
PEP_color _color(int rating) {
return ::color_from_rating((PEP_rating) rating);
::PEP_color _color(int rating) {
return ::color_from_rating((::PEP_rating) rating);
}
boost::python::tuple sync_decode(object buffer) {
Py_buffer src;
int result = PyObject_GetBuffer(buffer.ptr(), &src, PyBUF_CONTIG_RO);
if (result)
if (result) {
throw invalid_argument("need a contiguous buffer to read");
}
char *dst = NULL;
PEP_STATUS status = PER_to_XER_Sync_msg((char *) src.buf, src.len, &dst);
::PEP_STATUS status = ::PER_to_XER_Sync_msg((char *) src.buf, src.len, &dst);
PyBuffer_Release(&src);
_throw_status(status);
@ -88,7 +89,7 @@ namespace pEp {
static boost::python::tuple sync_encode(string text) {
char *data = NULL;
size_t size = 0;
PEP_STATUS status = XER_to_PER_Sync_msg(text.c_str(), &data, &size);
::PEP_STATUS status = ::XER_to_PER_Sync_msg(text.c_str(), &data, &size);
_throw_status(status);
PyObject *ba = PyBytes_FromStringAndSize(data, size);
@ -106,7 +107,7 @@ namespace pEp {
throw invalid_argument("need a contiguous buffer to read");
char *dst = NULL;
PEP_STATUS status = PER_to_XER_Distribution_msg((char *) src.buf, src.len, &dst);
::PEP_STATUS status = ::PER_to_XER_Distribution_msg((char *) src.buf, src.len, &dst);
PyBuffer_Release(&src);
_throw_status(status);
@ -118,7 +119,7 @@ namespace pEp {
static boost::python::tuple Distribution_encode(string text) {
char *data = NULL;
size_t size = 0;
PEP_STATUS status = XER_to_PER_Distribution_msg(text.c_str(), &data, &size);
::PEP_STATUS status = ::XER_to_PER_Distribution_msg(text.c_str(), &data, &size);
_throw_status(status);
PyObject *ba = PyBytes_FromStringAndSize(data, size);

2
src/pEp/_pEp/message_api.hh

@ -18,7 +18,7 @@ namespace pEp {
boost::python::tuple decrypt_message(Message src, int flags = 0);
PEP_color _color(int rating);
::PEP_color _color(int rating);
object sync_search(string name);

113
src/pEp/_pEp/pEpmodule.cc

@ -57,8 +57,7 @@ namespace pEp {
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);
::PEP_STATUS status = ::key_reset_user(Adapter::session(), user_id.c_str(), fpr != "" ? fpr.c_str() : nullptr);
_throw_status(status);
}
@ -67,7 +66,7 @@ namespace pEp {
}
void key_reset_all_own_keys() {
PEP_STATUS status = ::key_reset_all_own_keys(Adapter::session());
::PEP_STATUS status = ::key_reset_all_own_keys(Adapter::session());
_throw_status(status);
}
@ -77,14 +76,14 @@ namespace pEp {
return version;
}
void _throw_status(PEP_STATUS status) {
if (status == PEP_STATUS_OK)
void _throw_status(::PEP_STATUS status) {
if (status == ::PEP_STATUS_OK)
return;
if (status >= 0x400 && status <= 0x4ff)
return;
if (status == PEP_OUT_OF_MEMORY)
if (status == ::PEP_OUT_OF_MEMORY)
throw bad_alloc();
if (status == PEP_ILLEGAL_VALUE)
if (status == ::PEP_ILLEGAL_VALUE)
throw invalid_argument("illegal value");
if (string(pEp_status_to_string(status)) == "unknown status code") {
@ -96,7 +95,7 @@ namespace pEp {
}
}
PEP_STATUS _messageToSend(::message *msg) {
::PEP_STATUS _messageToSend(::message *msg) {
pEpLog("called");
try {
PyGILState_STATE gil = PyGILState_Ensure();
@ -108,10 +107,10 @@ namespace pEp {
pEpLog("GIL released");
} catch (exception &e) {}
return PEP_STATUS_OK;
return ::PEP_STATUS_OK;
}
PEP_STATUS notifyHandshake(pEp_identity *me, pEp_identity *partner, sync_handshake_signal signal) {
::PEP_STATUS notifyHandshake(::pEp_identity *me, ::pEp_identity *partner, ::sync_handshake_signal signal) {
pEpLog("called");
try {
PyGILState_STATE gil = PyGILState_Ensure();
@ -123,7 +122,7 @@ namespace pEp {
pEpLog("GIL released");
} catch (exception &e) {}
return PEP_STATUS_OK;
return ::PEP_STATUS_OK;
}
@ -154,26 +153,26 @@ namespace pEp {
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);
shared_identities = ::new_identity_list(nullptr);
if (!shared_identities)
throw bad_alloc();
try {
identity_list *si = shared_identities;
::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);
si = ::identity_list_add(si, ident);
if (!si)
throw bad_alloc();
}
}
catch (exception &ex) {
free_identity_list(shared_identities);
::free_identity_list(shared_identities);
throw ex;
}
}
PEP_STATUS status = ::deliverHandshakeResult(Adapter::session(), (sync_handshake_result) result, shared_identities);
::PEP_STATUS status = ::deliverHandshakeResult(Adapter::session(), (::sync_handshake_result) result, shared_identities);
free_identity_list(shared_identities);
_throw_status(status);
}
@ -191,10 +190,10 @@ namespace pEp {
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();
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", config_passive_mode,
"do not attach pub keys to all messages");
@ -287,13 +286,13 @@ namespace pEp {
.add_property("comm_type", (int(Identity::*)())
(PEP_comm_type(Identity::*)()) &Identity::comm_type,
(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)")
.add_property("lang", (string(Identity::*)()) &Identity::lang,
(void(Identity::*)(string)) &Identity::lang,
"ISO 639-1 language code")
.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)")
.add_property("rating", &Identity::rating, "rating of Identity")
.add_property("color", &Identity::color, "color of Identity as PEP_color")
@ -419,7 +418,7 @@ namespace pEp {
.add_property("enc_format", (int(Message::*)())
(PEP_enc_format(Message::*)()) &Message::enc_format,
(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")
.def("encrypt", (Message(Message::*)())&Message::encrypt)
.def("encrypt", (Message(Message::*)(boost::python::list))&Message::_encrypt)
@ -470,10 +469,10 @@ namespace pEp {
"mark a key as trusted with a person\n"
);
enum_<identity_flags>("identity_flags")
.value("PEP_idf_not_for_sync", PEP_idf_not_for_sync)
.value("PEP_idf_list", PEP_idf_list)
.value("PEP_idf_devicegroup", PEP_idf_devicegroup);
enum_<::identity_flags>("identity_flags")
.value("PEP_idf_not_for_sync", ::PEP_idf_not_for_sync)
.value("PEP_idf_list", ::PEP_idf_list)
.value("PEP_idf_devicegroup", ::PEP_idf_devicegroup);
def("set_identity_flags", &set_identity_flags,
"set_identity_flags(ident, flags)\n"
@ -529,25 +528,25 @@ namespace pEp {
// message API
enum_<PEP_rating>("rating")
.value("_undefined", PEP_rating_undefined)
.value("cannot_decrypt", PEP_rating_cannot_decrypt)
.value("have_no_key", PEP_rating_have_no_key)
.value("unencrypted", PEP_rating_unencrypted)
.value("unreliable", PEP_rating_unreliable)
.value("reliable", PEP_rating_reliable)
.value("trusted", PEP_rating_trusted)
.value("trusted_and_anonymized", PEP_rating_trusted_and_anonymized)
.value("fully_anonymous", PEP_rating_fully_anonymous)
.value("mistrust", PEP_rating_mistrust)
.value("b0rken", PEP_rating_b0rken)
.value("under_attack", PEP_rating_under_attack);
enum_<PEP_color>("colorvalue")
.value("no_color", PEP_color_no_color)
.value("yellow", PEP_color_yellow)
.value("green", PEP_color_green)
.value("red", PEP_color_red);
enum_<::PEP_rating>("rating")
.value("_undefined", ::PEP_rating_undefined)
.value("cannot_decrypt", ::PEP_rating_cannot_decrypt)
.value("have_no_key", ::PEP_rating_have_no_key)
.value("unencrypted", ::PEP_rating_unencrypted)
.value("unreliable", ::PEP_rating_unreliable)
.value("reliable", ::PEP_rating_reliable)
.value("trusted", ::PEP_rating_trusted)
.value("trusted_and_anonymized", ::PEP_rating_trusted_and_anonymized)
.value("fully_anonymous", ::PEP_rating_fully_anonymous)
.value("mistrust", ::PEP_rating_mistrust)
.value("b0rken", ::PEP_rating_b0rken)
.value("under_attack", ::PEP_rating_under_attack);
enum_<::PEP_color>("colorvalue")
.value("no_color", ::PEP_color_no_color)
.value("yellow", ::PEP_color_yellow)
.value("green", ::PEP_color_green)
.value("red", ::PEP_color_red);
def("incoming_message", &incoming_message,
@ -572,17 +571,17 @@ namespace pEp {
// Sync API
enum_<sync_handshake_signal>("sync_handshake_signal")
.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_OTHER_DEVICE", SYNC_NOTIFY_INIT_ADD_OTHER_DEVICE)
.value("SYNC_NOTIFY_INIT_FORM_GROUP", SYNC_NOTIFY_INIT_FORM_GROUP)
.value("SYNC_NOTIFY_TIMEOUT", SYNC_NOTIFY_TIMEOUT)
.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_DEVICE_ACCEPTED", SYNC_NOTIFY_ACCEPTED_DEVICE_ACCEPTED)
.value("SYNC_NOTIFY_SOLE", SYNC_NOTIFY_SOLE)
.value("SYNC_NOTIFY_IN_GROUP", SYNC_NOTIFY_IN_GROUP);
enum_<::sync_handshake_signal>("sync_handshake_signal")
.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_OTHER_DEVICE", ::SYNC_NOTIFY_INIT_ADD_OTHER_DEVICE)
.value("SYNC_NOTIFY_INIT_FORM_GROUP", ::SYNC_NOTIFY_INIT_FORM_GROUP)
.value("SYNC_NOTIFY_TIMEOUT", ::SYNC_NOTIFY_TIMEOUT)
.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_DEVICE_ACCEPTED", ::SYNC_NOTIFY_ACCEPTED_DEVICE_ACCEPTED)
.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",

6
src/pEp/_pEp/pEpmodule.hh

@ -23,11 +23,11 @@ namespace pEp {
void key_reset_all_own_keys();
void _throw_status(PEP_STATUS status);
void _throw_status(::PEP_STATUS status);
PEP_STATUS _messageToSend(::message *msg);
::PEP_STATUS _messageToSend(::message *msg);
PEP_STATUS notifyHandshake(pEp_identity *me, pEp_identity *partner, sync_handshake_signal signal);
::PEP_STATUS notifyHandshake(::pEp_identity *me, ::pEp_identity *partner, ::sync_handshake_signal signal);
} /* namespace PythonAdapter */
} /* namespace pEp */

40
src/pEp/_pEp/str_attr.cc

@ -40,22 +40,22 @@ namespace pEp {
throw bad_alloc();
}
time_t timestamp_attr(timestamp *&ts) {
time_t timestamp_attr(::timestamp *&ts) {
if (!ts)
return 0;
return timegm(ts);
}
void timestamp_attr(timestamp *&ts, time_t value) {
void timestamp_attr(::timestamp *&ts, time_t value) {
free_timestamp(ts);
ts = new_timestamp(value);
ts = ::new_timestamp(value);
}
boost::python::list strlist_attr(stringlist_t *&sl) {
boost::python::list strlist_attr(::stringlist_t *&sl) {
boost::python::list result;
for (stringlist_t *_sl = sl; _sl && _sl->value; _sl = _sl->next) {
for (::stringlist_t *_sl = sl; _sl && _sl->value; _sl = _sl->next) {
string s(_sl->value);
result.append(object(s));
}
@ -63,12 +63,12 @@ namespace pEp {
return result;
}
void strlist_attr(stringlist_t *&sl, boost::python::list value) {
stringlist_t *_sl = new_stringlist(NULL);
void strlist_attr(::stringlist_t *&sl, boost::python::list value) {
::stringlist_t *_sl = ::new_stringlist(NULL);
if (!_sl)
throw bad_alloc();
stringlist_t *_s = _sl;
::stringlist_t *_s = _sl;
for (int i = 0; i < len(value); i++) {
extract <string> extract_string(value[i]);
if (!extract_string.check()) {
@ -87,12 +87,12 @@ namespace pEp {
sl = _sl;
}
dict strdict_attr(stringpair_list_t *&spl) {
dict strdict_attr(::stringpair_list_t *&spl) {
dict result;
for (stringpair_list_t *_spl = spl; _spl && _spl->value; _spl =
for (::stringpair_list_t *_spl = spl; _spl && _spl->value; _spl =
_spl->next) {
stringpair_t *p = _spl->value;
::stringpair_t *p = _spl->value;
if (p->key && p->value) {
string key(p->key);
string value(p->value);
@ -104,12 +104,12 @@ namespace pEp {
return result;
}
void strdict_attr(stringpair_list_t *&spl, dict value) {
stringpair_list_t *_spl = new_stringpair_list(NULL);
void strdict_attr(::stringpair_list_t *&spl, dict value) {
::stringpair_list_t *_spl = ::new_stringpair_list(NULL);
if (!_spl)
throw bad_alloc();
stringpair_list_t *_s = _spl;
::stringpair_list_t *_s = _spl;
for (int i = 0; i < len(value); i++) {
extract <string> extract_key(value.keys()[i]);
extract <string> extract_value(value.values()[i]);
@ -121,7 +121,7 @@ namespace pEp {
key = normalize(key, norm_nfc);
string _value = extract_value();
_value = normalize(_value, norm_nfc);
stringpair_t *pair = new_stringpair(key.c_str(), _value.c_str());
::stringpair_t *pair = ::new_stringpair(key.c_str(), _value.c_str());
if (!pair) {
free_stringpair_list(_spl);
throw bad_alloc();
@ -137,12 +137,12 @@ namespace pEp {
spl = _spl;
}
stringlist_t *to_stringlist(boost::python::list l) {
stringlist_t *result = new_stringlist(NULL);
::stringlist_t *to_stringlist(boost::python::list l) {
::stringlist_t *result = ::new_stringlist(NULL);
if (!result)
throw bad_alloc();
stringlist_t *_s = result;
::stringlist_t *_s = result;
for (int i = 0; i < len(l); i++) {
extract <string> extract_string(l[i]);
if (!extract_string.check())
@ -158,9 +158,9 @@ namespace pEp {
return result;
}
boost::python::list from_stringlist(const stringlist_t *sl) {
boost::python::list from_stringlist(const ::stringlist_t *sl) {
boost::python::list result;
for (const stringlist_t *_sl = sl; _sl && _sl->value; _sl = _sl->next) {
for (const ::stringlist_t *_sl = sl; _sl && _sl->value; _sl = _sl->next) {
string s = _sl->value;
result.append(s);
}

16
src/pEp/_pEp/str_attr.hh

@ -25,17 +25,17 @@ string repr(string s);
string str_attr(char *&str);
void str_attr(char *&str, string value);
time_t timestamp_attr(timestamp *&ts);
void timestamp_attr(timestamp *&ts, time_t value);
time_t timestamp_attr(::timestamp *&ts);
void timestamp_attr(::timestamp *&ts, time_t value);
boost::python::list strlist_attr(stringlist_t *&sl);
void strlist_attr(stringlist_t *&sl, boost::python::list value);
boost::python::list strlist_attr(::stringlist_t *&sl);
void strlist_attr(::stringlist_t *&sl, boost::python::list value);
dict strdict_attr(stringpair_list_t *&spl);
void strdict_attr(stringpair_list_t *&spl, dict value);
dict strdict_attr(::stringpair_list_t *&spl);
void strdict_attr(::stringpair_list_t *&spl, dict value);
stringlist_t *to_stringlist(boost::python::list l);
boost::python::list from_stringlist(const stringlist_t *sl);
::stringlist_t *to_stringlist(boost::python::list l);
boost::python::list from_stringlist(const ::stringlist_t *sl);
} /* namespace PythonAdapter */
} /* namespace pEp */

12
src/pEp/_pEp/user_interface.cc

@ -27,9 +27,9 @@ namespace pEp {
UserInterface_callback::UserInterface_callback(PyObject *self) :
UserInterface(), _self(self) {
// adapter.ui_object(self);
// PEP_STATUS status = ::register_sync_callbacks(Adapter::session(),
// ::PEP_STATUS status = ::register_sync_callbacks(Adapter::session(),
// (void *) this, _notifyHandshake, retrieve_next_sync_event);
// assert(status == PEP_STATUS_OK);
// assert(status == ::PEP_STATUS_OK);
// if (status)
// _throw_status(status);
}
@ -38,7 +38,7 @@ namespace pEp {
// ::unregister_sync_callbacks(Adapter::session());
}
PEP_STATUS UserInterface::_notifyHandshake(
::PEP_STATUS UserInterface::_notifyHandshake(
pEp_identity *me, pEp_identity *partner,
sync_handshake_signal signal
) {
@ -48,7 +48,7 @@ namespace pEp {
auto that = dynamic_cast< UserInterface_callback * >(_ui);
that->notifyHandshake(Identity(me), Identity(partner), signal);
return PEP_STATUS_OK;
return ::PEP_STATUS_OK;
}
void UserInterface::deliverHandshakeResult(int result, object identities) {
@ -73,7 +73,7 @@ namespace pEp {
}
}
PEP_STATUS status = ::deliverHandshakeResult(Adapter::session(),
::PEP_STATUS status = ::deliverHandshakeResult(Adapter::session(),
(sync_handshake_result) result, shared_identities);
free_identity_list(shared_identities);
_throw_status(status);
@ -82,7 +82,7 @@ namespace pEp {
//PEP_rating UserInterface::get_key_rating_for_user(string user_id, string fpr)
//{
// PEP_rating result;
// PEP_STATUS status =
// ::PEP_STATUS status =
// ::get_key_rating_for_user(Adapter::session(),
// user_id.c_str(), fpr.c_str(), &result);
// _throw_status(status);

2
src/pEp/_pEp/user_interface.hh

@ -37,7 +37,7 @@ 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);
};
class UserInterface_callback : public UserInterface {

Loading…
Cancel
Save