diff --git a/src/Identity.hh b/src/Identity.hh index 8aff91c..50f1ed1 100644 --- a/src/Identity.hh +++ b/src/Identity.hh @@ -1,6 +1,5 @@ #pragma once -#include #include #include #include "str_attr.hh" @@ -8,7 +7,6 @@ namespace pEp { namespace PythonAdapter { using namespace utility; - using namespace boost::python; class Identity { pEp_identity *_ident; diff --git a/src/message.cc b/src/message.cc new file mode 100644 index 0000000..8ef421f --- /dev/null +++ b/src/message.cc @@ -0,0 +1,58 @@ +#include "message.hh" + +namespace pEp { + namespace PythonAdapter { + using namespace std; + + Message::Message() + : _msg(new_message(NULL, NULL, NULL, NULL)) + { + if (!_msg) + throw bad_alloc(); + } + + Message::Message(const Message& second) + : _msg(message_dup(second._msg)) + { + if (!_msg) + throw bad_alloc(); + } + + Message::Message(message *msg) + : _msg(msg) + { + + } + + Message::~Message() + { + free_message(_msg); + } + + void Message::attach(message *msg) + { + free_message(_msg); + _msg = msg; + } + + message *Message::detach() + { + message *new_one = new_message(NULL, NULL, NULL, NULL); + if (!new_one) + throw bad_alloc(); + + message *msg = _msg; + _msg = new_one; + + return msg; + } + + Message::operator message *() + { + if (!_msg) + throw bad_cast(); + return _msg; + } + } +} + diff --git a/src/message.hh b/src/message.hh new file mode 100644 index 0000000..ab37738 --- /dev/null +++ b/src/message.hh @@ -0,0 +1,55 @@ +#pragma once + +#include +#include +#include "str_attr.hh" + +namespace pEp { + namespace PythonAdapter { + using namespace utility; + + class Message { + message *_msg; + + public: + Message(); + Message(const Message& second); + Message(message *ident); + ~Message(); + operator message *(); + void attach(message *ident); + message *detach(); + + PEP_msg_direction dir; + char *id; + char *shortmsg; + char *longmsg; + + char *longmsg_formatted; + + bloblist_t *attachments; + char *rawmsg_ref; + size_t rawmsg_size; + timestamp *sent; + timestamp *recv; + pEp_identity *from; + identity_list *to; + pEp_identity *recv_by; + + identity_list *cc; + identity_list *bcc; + identity_list *reply_to; + stringlist_t *in_reply_to; + + struct _message *refering_msg_ref; + stringlist_t *references; + struct _message_ref_list *refered_by; + + stringlist_t *keywords; + char *comments; + stringpair_list_t *opt_fields; + PEP_enc_format enc_format; + }; + } +} +