Browse Source

Identity class

PYADPT-55
Volker Birk 9 years ago
parent
commit
0884509429
  1. 6
      src/Identity.cc
  2. 36
      src/Identity.hh
  3. 26
      src/pEpmodule.cc
  4. 2
      src/pEpmodule.hh

6
src/Identity.cc

@ -12,7 +12,7 @@ namespace pEp {
throw bad_alloc();
}
Identity::Identity(Identity& second)
Identity::Identity(const Identity& second)
: _ident(identity_dup(second._ident))
{
if (!_ident)
@ -31,7 +31,7 @@ namespace pEp {
return _ident;
}
void Identity::lang(string value)
void Identity::set_lang(string value)
{
if (value == "")
memset(_ident->lang, 0, 3);
@ -41,7 +41,7 @@ namespace pEp {
memcpy(_ident->lang, value.data(), 2);
}
string Identity::lang()
string Identity::get_lang()
{
return _ident->lang;
}

36
src/Identity.hh

@ -1,5 +1,6 @@
#pragma once
#include <boost/python.hpp>
#include <pEp/pEpEngine.h>
#include <string>
#include "str_attr.hh"
@ -7,39 +8,40 @@
namespace pEp {
namespace PythonAdapter {
using namespace utility;
using namespace boost::python;
class Identity {
pEp_identity *_ident;
public:
Identity();
Identity(Identity& second);
Identity(const Identity& second);
~Identity();
operator pEp_identity *();
void address(string value) { str_attr(_ident->address, value); }
string address() { return str_attr(_ident->address); }
void set_address(string value) { str_attr(_ident->address, value); }
string get_address() { return str_attr(_ident->address); }
void fpr(string value) { str_attr(_ident->fpr, value); }
string fpr() { return str_attr(_ident->fpr); }
void set_fpr(string value) { str_attr(_ident->fpr, value); }
string get_fpr() { return str_attr(_ident->fpr); }
void user_id(string value) { str_attr(_ident->user_id, value); }
string user_id() { return str_attr(_ident->user_id); }
void set_user_id(string value) { str_attr(_ident->user_id, value); }
string get_user_id() { return str_attr(_ident->user_id); }
void username(string value) { str_attr(_ident->username, value); }
string username() { return str_attr(_ident->username); }
void set_username(string value) { str_attr(_ident->username, value); }
string get_username() { return str_attr(_ident->username); }
void comm_type(PEP_comm_type value) { _ident->comm_type = value; };
PEP_comm_type comm_type() { return _ident->comm_type; }
void set_comm_type(PEP_comm_type value) { _ident->comm_type = value; };
PEP_comm_type get_comm_type() { return _ident->comm_type; }
void lang(std::string value);
std::string lang();
void set_lang(std::string value);
std::string get_lang();
void me(bool value) { _ident->me = value; }
bool me() { return _ident->me; }
void set_me(bool value) { _ident->me = value; }
bool get_me() { return _ident->me; }
void me(identity_flags_t flags) { _ident->flags = flags; }
identity_flags_t flags() { return _ident->flags; }
void set_flags(identity_flags_t flags) { _ident->flags = flags; }
identity_flags_t get_flags() { return _ident->flags; }
};
}
}

26
src/pEpmodule.cc

@ -1,12 +1,13 @@
#include "pEpmodule.hh"
#include <string>
#include <pEp/pEpEngine.h>
#include "Identity.hh"
namespace pEp {
namespace PythonAdapter {
using namespace std;
string about(void)
string about()
{
string version = string(version_string) + "\np≡p version "
+ PEP_VERSION + "\n";
@ -19,6 +20,27 @@ BOOST_PYTHON_MODULE(pEp)
{
using namespace boost::python;
using namespace pEp::PythonAdapter;
def("about", about);
docstring_options doc_options(true, true, false);
def("about", about, "delivers the p≡p about string");
class_<Identity>("Identity", "p≡p identity")
.add_property("address", &Identity::get_address,
&Identity::set_address, "email address or URI")
.add_property("fpr", &Identity::get_fpr,
&Identity::set_fpr, "key ID (fingerprint)")
.add_property("user_id", &Identity::get_user_id,
&Identity::set_user_id, "ID of person associated")
.add_property("username", &Identity::get_username,
&Identity::set_username, "name of person associated")
.add_property("comm_type", &Identity::get_comm_type,
&Identity::set_comm_type, "communication type (p≡p internal)")
.add_property("lang", &Identity::get_lang,
&Identity::set_lang, "ISO 639-1 language code")
.add_property("me", &Identity::get_me,
&Identity::set_me, "true if own identity, false otherwise")
.add_property("flags", &Identity::get_flags,
&Identity::set_flags);
}

2
src/pEpmodule.hh

@ -6,7 +6,7 @@ namespace pEp {
namespace PythonAdapter {
using namespace std;
const char *version_string = "p≡p Python adapter version 0.1";
string about(void);
string about();
}
}

Loading…
Cancel
Save