mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-07-31 10:19:24 -04:00
Major improvements to the serialiser to make it work with retroshare.
This is still a first draft - the message types will surely change. -corrected ids and added service classes. -Added disc/msg/chat/cache/file messages -Extended serialiser to handle service extensions. -corrected IpAddrPort code. -More debugging code. -Added some tests. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@270 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
9f76b1a313
commit
e8ccb0b427
22 changed files with 3101 additions and 333 deletions
|
@ -28,50 +28,7 @@
|
|||
|
||||
#include <map>
|
||||
|
||||
const uint8_t RS_PKT_TYPE_DISC_MSG = 0x01;
|
||||
const uint8_t RS_PKT_TYPE_CHANNEL_MSG = 0x02;
|
||||
const uint8_t RS_PKT_TYPE_PROXY_MSG = 0x03;
|
||||
|
||||
/**************************************************************************/
|
||||
|
||||
class RsDiscMsg: public RsItem
|
||||
{
|
||||
public:
|
||||
RsDiscMsg()
|
||||
:RsItem(RS_PKT_VERSION1, RS_PKT_CLASS_SERVICE,
|
||||
RS_PKT_TYPE_DISC_MSG, 0)
|
||||
{ return; }
|
||||
virtual ~RsDiscMsg();
|
||||
virtual void clear();
|
||||
|
||||
uint32_t discType;
|
||||
uint32_t discFlags;
|
||||
|
||||
uint32_t connect_tr;
|
||||
uint32_t receive_tr;
|
||||
|
||||
struct sockaddr_in laddr;
|
||||
struct sockaddr_in saddr;
|
||||
|
||||
RsTlvBinaryData cert;
|
||||
};
|
||||
|
||||
class RsDiscMsgSerialiser: public RsSerialType
|
||||
{
|
||||
public:
|
||||
RsDiscMsgSerialiser()
|
||||
:RsSerialType(RS_PKT_VERSION1, RS_PKT_CLASS_SERVICE,
|
||||
RS_PKT_TYPE_DISC_MSG)
|
||||
{ return; }
|
||||
|
||||
virtual ~RsDiscMsgSerialiser();
|
||||
|
||||
virtual uint32_t size(RsItem *);
|
||||
virtual bool serialise (RsItem *item, void *data, uint32_t *size);
|
||||
virtual RsItem * deserialise(void *data, uint32_t *size);
|
||||
|
||||
};
|
||||
|
||||
#include "serialiser/rsserviceids.h"
|
||||
|
||||
/**************************************************************************/
|
||||
|
||||
|
@ -79,8 +36,8 @@ class RsChannelMsg: public RsItem
|
|||
{
|
||||
public:
|
||||
RsChannelMsg()
|
||||
:RsItem(RS_PKT_VERSION1, RS_PKT_CLASS_SERVICE,
|
||||
RS_PKT_TYPE_CHANNEL_MSG, 0)
|
||||
:RsItem(RS_PKT_VERSION_SERVICE, RS_SERVICE_TYPE_CHANNEL,
|
||||
RS_PKT_SUBTYPE_DEFAULT)
|
||||
{ return; }
|
||||
virtual ~RsChannelMsg();
|
||||
virtual void clear();
|
||||
|
@ -94,8 +51,7 @@ class RsChannelMsgSerialiser: public RsSerialType
|
|||
{
|
||||
public:
|
||||
RsChannelMsgSerialiser()
|
||||
:RsSerialType(RS_PKT_VERSION1, RS_PKT_CLASS_SERVICE,
|
||||
RS_PKT_TYPE_CHANNEL_MSG)
|
||||
:RsSerialType(RS_PKT_VERSION_SERVICE, RS_SERVICE_TYPE_CHANNEL)
|
||||
{ return; }
|
||||
|
||||
virtual ~RsChannelMsgSerialiser();
|
||||
|
@ -106,8 +62,115 @@ virtual RsItem * deserialise(void *data, uint32_t *size);
|
|||
|
||||
};
|
||||
|
||||
/**************************************************************************/
|
||||
|
||||
class RsChatItem: public RsItem
|
||||
{
|
||||
public:
|
||||
RsChatItem()
|
||||
:RsItem(RS_PKT_VERSION_SERVICE, RS_SERVICE_TYPE_CHAT,
|
||||
RS_PKT_SUBTYPE_DEFAULT)
|
||||
{ return; }
|
||||
virtual ~RsChatItem();
|
||||
virtual void clear();
|
||||
std::ostream &print(std::ostream &out, uint16_t indent);
|
||||
|
||||
uint32_t chatFlags;
|
||||
uint32_t sendTime;
|
||||
|
||||
std::string message;
|
||||
|
||||
};
|
||||
|
||||
class RsChatItemSerialiser: public RsSerialType
|
||||
{
|
||||
public:
|
||||
RsChatItemSerialiser()
|
||||
:RsSerialType(RS_PKT_VERSION_SERVICE, RS_SERVICE_TYPE_CHAT)
|
||||
{ return; }
|
||||
virtual ~RsChatItemSerialiser();
|
||||
|
||||
virtual uint32_t size(RsItem *);
|
||||
virtual bool serialise (RsItem *item, void *data, uint32_t *size);
|
||||
virtual RsItem * deserialise(void *data, uint32_t *size);
|
||||
|
||||
};
|
||||
|
||||
/**************************************************************************/
|
||||
|
||||
class RsMessageItem: public RsItem
|
||||
{
|
||||
public:
|
||||
RsMessageItem()
|
||||
:RsItem(RS_PKT_VERSION_SERVICE, RS_SERVICE_TYPE_MSG,
|
||||
RS_PKT_SUBTYPE_DEFAULT)
|
||||
{ return; }
|
||||
virtual ~RsMessageItem();
|
||||
virtual void clear();
|
||||
std::ostream &print(std::ostream &out, uint16_t indent);
|
||||
|
||||
uint32_t msgFlags;
|
||||
uint32_t sendTime;
|
||||
uint32_t recvTime;
|
||||
|
||||
std::string subject;
|
||||
std::string message;
|
||||
|
||||
RsTlvPeerIdSet msgto;
|
||||
RsTlvPeerIdSet msgcc;
|
||||
RsTlvPeerIdSet msgbcc;
|
||||
|
||||
RsTlvFileSet attachment;
|
||||
};
|
||||
|
||||
class RsMessageItemSerialiser: public RsSerialType
|
||||
{
|
||||
public:
|
||||
RsMessageItemSerialiser()
|
||||
:RsSerialType(RS_PKT_VERSION_SERVICE, RS_SERVICE_TYPE_MSG)
|
||||
{ return; }
|
||||
virtual ~RsMessageItemSerialiser();
|
||||
|
||||
virtual uint32_t size(RsItem *);
|
||||
virtual bool serialise (RsItem *item, void *data, uint32_t *size);
|
||||
virtual RsItem * deserialise(void *data, uint32_t *size);
|
||||
|
||||
};
|
||||
|
||||
/**************************************************************************/
|
||||
|
||||
class RsStatus: public RsItem
|
||||
{
|
||||
public:
|
||||
RsStatus()
|
||||
:RsItem(RS_PKT_VERSION_SERVICE, RS_SERVICE_TYPE_STATUS,
|
||||
RS_PKT_SUBTYPE_DEFAULT)
|
||||
{ return; }
|
||||
virtual ~RsStatus();
|
||||
virtual void clear();
|
||||
std::ostream &print(std::ostream &out, uint16_t indent);
|
||||
|
||||
/* status */
|
||||
uint32_t status;
|
||||
RsTlvServiceIdSet services;
|
||||
};
|
||||
|
||||
class RsStatusSerialiser: public RsSerialType
|
||||
{
|
||||
public:
|
||||
RsStatusSerialiser()
|
||||
:RsSerialType(RS_PKT_VERSION_SERVICE, RS_SERVICE_TYPE_STATUS)
|
||||
{ return; }
|
||||
virtual ~RsStatusSerialiser();
|
||||
|
||||
virtual uint32_t size(RsItem *);
|
||||
virtual bool serialise (RsItem *item, void *data, uint32_t *size);
|
||||
virtual RsItem * deserialise(void *data, uint32_t *size);
|
||||
|
||||
};
|
||||
|
||||
/**************************************************************************/
|
||||
|
||||
#endif /* RS_SERVICE_ITEMS_H */
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue