From bfe55ff5890a8c0544f10e3c59b150ad342c8cbc Mon Sep 17 00:00:00 2001 From: Volker Birk Date: Sun, 7 Aug 2016 17:48:36 +0200 Subject: [PATCH] starting with basic API --- src/Identity.cc | 10 ++++++++-- src/Identity.hh | 1 + src/pEpmodule.cc | 8 +++++--- src/pEpmodule.hh | 3 ++- 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/Identity.cc b/src/Identity.cc index 7392b43..7189665 100644 --- a/src/Identity.cc +++ b/src/Identity.cc @@ -36,6 +36,13 @@ namespace pEp { free_identity(_ident); } + Identity::operator pEp_identity *() + { + if (!_ident) + throw bad_cast(); + return _ident; + } + void Identity::attach(pEp_identity *ident) { free_identity(_ident); @@ -115,8 +122,7 @@ namespace pEp { extract< string > extract_string(value); if (extract_string.check()) { string str = extract_string(); - pEp_identity *_ident = new_identity(str.c_str(), NULL, NULL, - NULL); + pEp_identity *_ident = new_identity(str.c_str(), NULL, NULL, NULL); if (!_ident) throw bad_alloc(); free_identity(ident); diff --git a/src/Identity.hh b/src/Identity.hh index 901b943..5b080df 100644 --- a/src/Identity.hh +++ b/src/Identity.hh @@ -21,6 +21,7 @@ namespace pEp { Identity(const Identity& second); Identity(pEp_identity *ident); ~Identity(); + operator pEp_identity *(); void attach(pEp_identity *ident); pEp_identity *detach(); diff --git a/src/pEpmodule.cc b/src/pEpmodule.cc index ae82139..35fd7ed 100644 --- a/src/pEpmodule.cc +++ b/src/pEpmodule.cc @@ -2,14 +2,13 @@ #include #include #include -#include -#include "Identity.hh" -#include "Message.hh" +#include "basic_api.hh" namespace pEp { namespace PythonAdapter { using namespace std; + static const char *version_string = "p≡p Python adapter version 0.1"; static string about() { string version = string(version_string) + "\np≡p version " @@ -160,6 +159,9 @@ BOOST_PYTHON_MODULE(pEp) (void(Message::*)(PEP_enc_format)) &Message::enc_format, "0: unencrypted, 1: inline PGP, 2: S/MIME, 3: PGP/MIME, 4: p≡p format"); + def("update_identity", &update_identity, "update identity information"); + def("myself", &myself, "ensures that the own identity is being complete"); + PyModuleDef * _def = PyModule_GetDef(scope().ptr()); _def->m_free = free_module; diff --git a/src/pEpmodule.hh b/src/pEpmodule.hh index eea21b3..25db5eb 100644 --- a/src/pEpmodule.hh +++ b/src/pEpmodule.hh @@ -1,11 +1,12 @@ #pragma once #include +#include "Identity.hh" +#include "Message.hh" #include namespace pEp { namespace PythonAdapter { - const char *version_string = "p≡p Python adapter version 0.1"; extern PEP_SESSION session; } }