2013-11-10 17:27:50 -05:00
|
|
|
#ifndef RSGXSUPDATEITEMS_H_
|
|
|
|
#define RSGXSUPDATEITEMS_H_
|
|
|
|
|
|
|
|
/*
|
|
|
|
* libretroshare/src/serialiser: rsgxsupdateitems.h
|
|
|
|
*
|
|
|
|
* RetroShare Serialiser.
|
|
|
|
*
|
|
|
|
* Copyright 2012 Christopher Evi-Parker
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License Version 2 as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
|
|
* USA.
|
|
|
|
*
|
|
|
|
* Please report all bugs and problems to "retroshare@lunamutt.com".
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-03-29 11:34:37 -04:00
|
|
|
#if 0
|
|
|
|
#include <map>
|
2013-11-10 17:27:50 -05:00
|
|
|
#include "serialiser/rsserviceids.h"
|
|
|
|
#include "serialiser/rsserial.h"
|
|
|
|
#include "serialiser/rstlvbase.h"
|
|
|
|
#include "serialiser/rstlvtypes.h"
|
|
|
|
#include "serialiser/rstlvkeys.h"
|
2014-03-29 11:34:37 -04:00
|
|
|
#endif
|
|
|
|
|
2013-11-10 17:27:50 -05:00
|
|
|
#include "gxs/rsgxsdata.h"
|
|
|
|
|
|
|
|
|
2013-11-16 08:40:04 -05:00
|
|
|
const uint8_t RS_PKT_SUBTYPE_GXS_GRP_UPDATE = 0x0001;
|
2015-01-31 13:06:37 -05:00
|
|
|
const uint8_t RS_PKT_SUBTYPE_GXS_MSG_UPDATE_deprecated = 0x0002;
|
|
|
|
const uint8_t RS_PKT_SUBTYPE_GXS_MSG_UPDATE = 0x0003;
|
2013-11-16 08:40:04 -05:00
|
|
|
const uint8_t RS_PKT_SUBTYPE_GXS_SERVER_GRP_UPDATE = 0x0004;
|
|
|
|
const uint8_t RS_PKT_SUBTYPE_GXS_SERVER_MSG_UPDATE = 0x0008;
|
2013-11-10 17:27:50 -05:00
|
|
|
|
|
|
|
class RsGxsGrpUpdateItem : public RsItem {
|
|
|
|
public:
|
2013-11-16 08:40:04 -05:00
|
|
|
RsGxsGrpUpdateItem(uint16_t servType) : RsItem(RS_PKT_VERSION_SERVICE, servType,
|
|
|
|
RS_PKT_SUBTYPE_GXS_GRP_UPDATE)
|
2013-11-24 07:38:21 -05:00
|
|
|
{clear();}
|
2015-01-31 13:06:37 -05:00
|
|
|
virtual ~RsGxsGrpUpdateItem() {}
|
2013-11-10 17:27:50 -05:00
|
|
|
|
2015-01-31 13:06:37 -05:00
|
|
|
virtual void clear();
|
|
|
|
virtual std::ostream &print(std::ostream &out, uint16_t indent);
|
2013-11-10 17:27:50 -05:00
|
|
|
|
2014-03-17 16:56:06 -04:00
|
|
|
RsPeerId peerId;
|
2015-01-31 13:06:37 -05:00
|
|
|
uint32_t grpUpdateTS;
|
2013-11-10 17:27:50 -05:00
|
|
|
};
|
|
|
|
|
2013-11-16 08:40:04 -05:00
|
|
|
class RsGxsServerGrpUpdateItem : public RsItem {
|
|
|
|
public:
|
|
|
|
RsGxsServerGrpUpdateItem(uint16_t servType) : RsItem(RS_PKT_VERSION_SERVICE, servType,
|
|
|
|
RS_PKT_SUBTYPE_GXS_SERVER_GRP_UPDATE)
|
2013-11-24 07:38:21 -05:00
|
|
|
{ clear();}
|
2013-11-17 18:15:39 -05:00
|
|
|
virtual ~RsGxsServerGrpUpdateItem() {}
|
2013-11-16 08:40:04 -05:00
|
|
|
|
|
|
|
virtual void clear();
|
|
|
|
virtual std::ostream &print(std::ostream &out, uint16_t indent);
|
|
|
|
|
|
|
|
uint32_t grpUpdateTS;
|
|
|
|
};
|
|
|
|
|
2013-11-10 17:27:50 -05:00
|
|
|
class RsGxsMsgUpdateItem : public RsItem
|
|
|
|
{
|
|
|
|
public:
|
2013-11-16 08:40:04 -05:00
|
|
|
RsGxsMsgUpdateItem(uint16_t servType) : RsItem(RS_PKT_VERSION_SERVICE, servType, RS_PKT_SUBTYPE_GXS_MSG_UPDATE)
|
2013-11-24 07:38:21 -05:00
|
|
|
{ clear();}
|
2013-11-17 18:15:39 -05:00
|
|
|
virtual ~RsGxsMsgUpdateItem() {}
|
2013-11-10 17:27:50 -05:00
|
|
|
|
2014-12-02 15:06:56 -05:00
|
|
|
virtual void clear();
|
|
|
|
virtual std::ostream &print(std::ostream &out, uint16_t indent);
|
2013-11-10 17:27:50 -05:00
|
|
|
|
2015-01-31 13:06:37 -05:00
|
|
|
struct MsgUpdateInfo
|
|
|
|
{
|
2015-12-11 22:38:17 -05:00
|
|
|
MsgUpdateInfo(): time_stamp(0), message_count(0) {}
|
|
|
|
|
2015-01-31 13:06:37 -05:00
|
|
|
uint32_t time_stamp ;
|
|
|
|
uint32_t message_count ;
|
|
|
|
};
|
|
|
|
|
2014-03-17 16:56:06 -04:00
|
|
|
RsPeerId peerId;
|
2015-01-31 13:06:37 -05:00
|
|
|
std::map<RsGxsGroupId, MsgUpdateInfo> msgUpdateInfos;
|
2013-11-10 17:27:50 -05:00
|
|
|
};
|
|
|
|
|
2013-11-16 08:40:04 -05:00
|
|
|
class RsGxsServerMsgUpdateItem : public RsItem
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
RsGxsServerMsgUpdateItem(uint16_t servType) : RsItem(RS_PKT_VERSION_SERVICE,
|
|
|
|
servType, RS_PKT_SUBTYPE_GXS_SERVER_MSG_UPDATE)
|
2013-11-24 07:38:21 -05:00
|
|
|
{ clear();}
|
2013-11-17 18:15:39 -05:00
|
|
|
virtual ~RsGxsServerMsgUpdateItem() {}
|
2013-11-16 08:40:04 -05:00
|
|
|
|
|
|
|
virtual void clear();
|
|
|
|
virtual std::ostream &print(std::ostream &out, uint16_t indent);
|
|
|
|
|
2014-03-17 16:56:06 -04:00
|
|
|
RsGxsGroupId grpId;
|
2015-12-11 22:38:17 -05:00
|
|
|
uint32_t msgUpdateTS; // local time stamp this group last received a new msg
|
2013-11-16 08:40:04 -05:00
|
|
|
};
|
2013-11-10 17:27:50 -05:00
|
|
|
|
|
|
|
|
|
|
|
class RsGxsUpdateSerialiser : public RsSerialType
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
RsGxsUpdateSerialiser(uint16_t servtype) :
|
|
|
|
RsSerialType(RS_PKT_VERSION_SERVICE, servtype), SERVICE_TYPE(servtype) { return; }
|
|
|
|
|
|
|
|
virtual ~RsGxsUpdateSerialiser() { return; }
|
|
|
|
|
|
|
|
virtual uint32_t size(RsItem *item);
|
|
|
|
virtual bool serialise(RsItem *item, void *data, uint32_t *size);
|
|
|
|
virtual RsItem* deserialise(void *data, uint32_t *size);
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
|
|
|
|
/* for RS_PKT_SUBTYPE_GRP_UPDATE_ITEM */
|
|
|
|
|
|
|
|
virtual uint32_t sizeGxsGrpUpdate(RsGxsGrpUpdateItem* item);
|
|
|
|
virtual bool serialiseGxsGrpUpdate(RsGxsGrpUpdateItem *item, void *data, uint32_t *size);
|
|
|
|
virtual RsGxsGrpUpdateItem* deserialGxsGrpUpddate(void *data, uint32_t *size);
|
|
|
|
|
2013-11-16 08:40:04 -05:00
|
|
|
/* for RS_PKT_SUBTYPE_GRP_SERVER_UPDATE_ITEM */
|
|
|
|
|
|
|
|
virtual uint32_t sizeGxsServerGrpUpdate(RsGxsServerGrpUpdateItem* item);
|
|
|
|
virtual bool serialiseGxsServerGrpUpdate(RsGxsServerGrpUpdateItem *item, void *data, uint32_t *size);
|
|
|
|
virtual RsGxsServerGrpUpdateItem* deserialGxsServerGrpUpddate(void *data, uint32_t *size);
|
|
|
|
|
|
|
|
/* for RS_PKT_SUBTYPE_GXS_MSG_UPDATE_ITEM */
|
2013-11-10 17:27:50 -05:00
|
|
|
|
|
|
|
virtual uint32_t sizeGxsMsgUpdate(RsGxsMsgUpdateItem* item);
|
|
|
|
virtual bool serialiseGxsMsgUpdate(RsGxsMsgUpdateItem *item, void *data, uint32_t *size);
|
|
|
|
virtual RsGxsMsgUpdateItem* deserialGxsMsgUpdate(void *data, uint32_t *size);
|
|
|
|
|
2013-11-16 08:40:04 -05:00
|
|
|
/* for RS_PKT_SUBTYPE_GXS_SERVER_UPDATE_ITEM */
|
|
|
|
|
|
|
|
virtual uint32_t sizeGxsServerMsgUpdate(RsGxsServerMsgUpdateItem* item);
|
|
|
|
virtual bool serialiseGxsServerMsgUpdate(RsGxsServerMsgUpdateItem *item, void *data, uint32_t *size);
|
|
|
|
virtual RsGxsServerMsgUpdateItem* deserialGxsServerMsgUpdate(void *data, uint32_t *size);
|
|
|
|
|
2013-11-10 17:27:50 -05:00
|
|
|
private:
|
|
|
|
|
|
|
|
const uint16_t SERVICE_TYPE;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* RSGXSUPDATEITEMS_H_ */
|