Browse Source

adding message implementation draft

PYADPT-55
Volker Birk 9 years ago
parent
commit
69f91a134b
  1. 2
      src/Identity.hh
  2. 58
      src/message.cc
  3. 55
      src/message.hh

2
src/Identity.hh

@ -1,6 +1,5 @@
#pragma once
#include <boost/python.hpp>
#include <pEp/pEpEngine.h>
#include <string>
#include "str_attr.hh"
@ -8,7 +7,6 @@
namespace pEp {
namespace PythonAdapter {
using namespace utility;
using namespace boost::python;
class Identity {
pEp_identity *_ident;

58
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;
}
}
}

55
src/message.hh

@ -0,0 +1,55 @@
#pragma once
#include <pEp/message.h>
#include <string>
#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;
};
}
}
Loading…
Cancel
Save