switch RsConfigItems to new serialization

This commit is contained in:
csoler 2017-04-24 18:51:51 +02:00
parent af4fcf7679
commit fcabe6359f
4 changed files with 297 additions and 174 deletions

View File

@ -396,7 +396,8 @@ bool ftExtraList::saveList(bool &cleanup, std::list<RsItem *>& sList)
std::map<RsFileHash, FileDetails>::const_iterator it;
for(it = mFiles.begin(); it != mFiles.end(); ++it)
{
RsFileConfigItem_deprecated *fi = new RsFileConfigItem_deprecated();
RsFileConfigItem *fi = new RsFileConfigItem();
fi->file.path = (it->second).info.path;
fi->file.name = (it->second).info.fname;
fi->file.hash = (it->second).info.hash;
@ -429,7 +430,7 @@ bool ftExtraList::loadList(std::list<RsItem *>& load)
for(it = load.begin(); it != load.end(); ++it)
{
RsFileConfigItem_deprecated *fi = dynamic_cast<RsFileConfigItem_deprecated *>(*it);
RsFileConfigItem *fi = dynamic_cast<RsFileConfigItem *>(*it);
if (!fi)
{
delete (*it);

View File

@ -2294,7 +2294,7 @@ bool p3PeerMgrIMPL::loadList(std::list<RsItem *>& load)
continue;
}
#ifdef TO_REMOVE
RsPeerGroupItem_deprecated *gitem = dynamic_cast<RsPeerGroupItem_deprecated *>(*it) ;
if (gitem)
@ -2331,6 +2331,7 @@ bool p3PeerMgrIMPL::loadList(std::list<RsItem *>& load)
continue;
}
#endif
RsNodeGroupItem *gitem2 = dynamic_cast<RsNodeGroupItem*>(*it) ;

View File

@ -40,6 +40,37 @@
/*************************************************************************/
RsItem *RsFileConfigSerialiser::create_item(uint8_t item_class,uint8_t item_type) const
{
if(item_class != RS_PKT_CLASS_CONFIG)
return NULL ;
switch(item_type)
{
case RS_PKT_SUBTYPE_FILE_TRANSFER: return new RsFileTransfer() ;
case RS_PKT_SUBTYPE_FILE_ITEM: return new RsFileConfigItem() ;
default:
return NULL ;
}
}
void RsFileTransfer::clear()
{
file.TlvClear();
allPeerIds.TlvClear();
cPeerId.clear() ;
state = 0;
in = false;
transferred = 0;
crate = 0;
trate = 0;
lrate = 0;
ltransfer = 0;
}
#ifdef TO_REMOVE
uint32_t RsFileConfigSerialiser::size(RsItem *i)
{
RsFileTransfer *rft;
@ -110,22 +141,6 @@ RsFileTransfer::~RsFileTransfer()
return;
}
void RsFileTransfer::clear()
{
file.TlvClear();
allPeerIds.TlvClear();
cPeerId.clear() ;
state = 0;
in = false;
transferred = 0;
crate = 0;
trate = 0;
lrate = 0;
ltransfer = 0;
}
std::ostream &RsFileTransfer::print(std::ostream &out, uint16_t indent)
{
printRsItemBase(out, "RsFileTransfer", indent);
@ -231,7 +246,31 @@ uint32_t RsFileConfigSerialiser::sizeTransfer(RsFileTransfer *item)
return s;
}
#endif
void RsFileTransfer::serial_process(SerializeJob j,SerializeContext& ctx)
{
RsTypeSerializer::serial_process<RsTlvItem>(j,ctx,file,"file") ;
RsTypeSerializer::serial_process<RsTlvItem>(j,ctx,allPeerIds,"allPeerIds") ;
RsTypeSerializer::serial_process (j,ctx,cPeerId,"cPeerId") ;
RsTypeSerializer::serial_process<uint16_t> (j,ctx,state,"state") ;
RsTypeSerializer::serial_process<uint16_t> (j,ctx,in,"in") ;
RsTypeSerializer::serial_process<uint64_t> (j,ctx,transferred,"transferred") ;
RsTypeSerializer::serial_process<uint32_t> (j,ctx,crate,"crate") ;
RsTypeSerializer::serial_process<uint32_t> (j,ctx,trate,"trate") ;
RsTypeSerializer::serial_process<uint32_t> (j,ctx,lrate,"lrate") ;
RsTypeSerializer::serial_process<uint32_t> (j,ctx,ltransfer,"ltransfer") ;
RsTypeSerializer::serial_process<uint32_t> (j,ctx,flags,"flags") ;
RsTypeSerializer::serial_process<uint32_t> (j,ctx,chunk_strategy,"chunk_strategy") ;
RsTypeSerializer::serial_process (j,ctx,compressed_chunk_map,"compressed_chunk_map") ;
}
#ifdef TO_REMOVE
bool RsFileConfigSerialiser::serialiseTransfer(RsFileTransfer *item, void *data, uint32_t *pktsize)
{
uint32_t tlvsize = sizeTransfer(item);
@ -374,7 +413,16 @@ uint32_t RsFileConfigSerialiser::sizeFileItem(RsFileConfigItem *item)
return s;
}
#endif
void RsFileConfigItem::serial_process(SerializeJob j,SerializeContext& ctx)
{
RsTypeSerializer::serial_process<RsTlvItem>(j,ctx,file,"file") ;
RsTypeSerializer::serial_process<uint32_t> (j,ctx,flags,"flags") ;
RsTypeSerializer::serial_process<RsTlvItem>(j,ctx,parent_groups,"parent_groups") ;
}
#ifdef TO_REMOVE
bool RsFileConfigSerialiser::serialiseFileItem(RsFileConfigItem *item, void *data, uint32_t *pktsize)
{
uint32_t tlvsize = sizeFileItem(item);
@ -540,6 +588,22 @@ RsGeneralConfigSerialiser::~RsGeneralConfigSerialiser()
return;
}
#endif
RsItem *RsGeneralConfigSerialiser::create_item(uint8_t item_class,uint8_t item_type) const
{
if(item_class != RS_PKT_TYPE_GENERAL_CONFIG)
return NULL ;
switch(item_type)
{
case RS_PKT_SUBTYPE_KEY_VALUE: return new RsConfigKeyValueSet();
default:
return NULL ;
}
}
#ifdef TO_REMOVE
uint32_t RsGeneralConfigSerialiser::size(RsItem *i)
{
RsConfigKeyValueSet *kvs;
@ -632,7 +696,14 @@ uint32_t RsGeneralConfigSerialiser::sizeKeyValueSet(RsConfigKeyValueSet *item
return s;
}
#endif
void RsConfigKeyValueSet::serial_process(SerializeJob j,SerializeContext& ctx)
{
RsTypeSerializer::serial_process<RsTlvItem>(j,ctx,tlvkvs,"tlvkvs") ;
}
#ifdef TO_REMOVE
/* serialise the data to the buffer */
bool RsGeneralConfigSerialiser::serialiseKeyValueSet(RsConfigKeyValueSet *item, void *data, uint32_t *pktsize)
{
@ -745,7 +816,49 @@ RsPeerConfigSerialiser::~RsPeerConfigSerialiser()
{
return;
}
#endif
RsItem *RsPeerConfigSerialiser::create_item(uint8_t item_class,uint8_t item_type) const
{
if(item_class != RS_PKT_TYPE_PEER_CONFIG)
return NULL ;
switch(item_type)
{
case RS_PKT_SUBTYPE_PEER_NET: return new RsPeerNetItem();
case RS_PKT_SUBTYPE_PEER_STUN: return new RsPeerStunItem();
case RS_PKT_SUBTYPE_NODE_GROUP: return new RsNodeGroupItem() ;
case RS_PKT_SUBTYPE_PEER_PERMISSIONS: return new RsPeerServicePermissionItem();
case RS_PKT_SUBTYPE_PEER_BANDLIMITS: return new RsPeerBandwidthLimitsItem();
default:
return NULL ;
}
}
void RsPeerNetItem::clear()
{
peerId.clear();
pgpId.clear();
location.clear();
netMode = 0;
vs_disc = 0;
vs_dht = 0;
lastContact = 0;
localAddrV4.TlvClear();
extAddrV4.TlvClear();
localAddrV6.TlvClear();
extAddrV6.TlvClear();
dyndns.clear();
localAddrList.TlvClear();
extAddrList.TlvClear();
domain_addr.clear();
domain_port = 0;
}
#ifdef TO_REMOVE
uint32_t RsPeerConfigSerialiser::size(RsItem *i)
{
RsPeerStunItem *psi;
@ -855,29 +968,7 @@ RsPeerNetItem::~RsPeerNetItem()
return;
}
void RsPeerNetItem::clear()
{
peerId.clear();
pgpId.clear();
location.clear();
netMode = 0;
vs_disc = 0;
vs_dht = 0;
lastContact = 0;
localAddrV4.TlvClear();
extAddrV4.TlvClear();
localAddrV6.TlvClear();
extAddrV6.TlvClear();
dyndns.clear();
localAddrList.TlvClear();
extAddrList.TlvClear();
domain_addr.clear();
domain_port = 0;
}
std::ostream &RsPeerNetItem::print(std::ostream &out, uint16_t indent)
{
@ -963,7 +1054,34 @@ uint32_t RsPeerConfigSerialiser::sizeNet(RsPeerNetItem *i)
return s;
}
#endif
void RsPeerNetItem::serial_process(SerializeJob j,SerializeContext& ctx)
{
RsTypeSerializer::serial_process(j,ctx,peerId,"peerId") ;
RsTypeSerializer::serial_process(j,ctx,pgpId,"pgpId") ;
RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_STR_LOCATION,location,"location") ;
RsTypeSerializer::serial_process<uint32_t>(j,ctx,netMode,"netMode") ;
RsTypeSerializer::serial_process<uint16_t>(j,ctx,vs_disc,"vs_disc") ;
RsTypeSerializer::serial_process<uint16_t>(j,ctx,vs_dht,"vs_dht") ;
RsTypeSerializer::serial_process<uint32_t>(j,ctx,lastContact,"lastContact") ;
RsTypeSerializer::serial_process<RsTlvItem>(j,ctx,localAddrV4,"localAddrV4") ;
RsTypeSerializer::serial_process<RsTlvItem>(j,ctx,extAddrV4,"extAddrV4") ;
RsTypeSerializer::serial_process<RsTlvItem>(j,ctx,localAddrV6,"localAddrV6") ;
RsTypeSerializer::serial_process<RsTlvItem>(j,ctx,extAddrV6,"extAddrV6") ;
RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_STR_DYNDNS,dyndns,"dyndns") ;
RsTypeSerializer::serial_process<RsTlvItem>(j,ctx,localAddrList,"localAddrList") ;
RsTypeSerializer::serial_process<RsTlvItem>(j,ctx,extAddrList,"extAddrList") ;
RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_STR_DOMADDR,domain_addr,"domain_addr") ;
RsTypeSerializer::serial_process<uint16_t>(j,ctx,domain_port,"domain_port") ;
}
#ifdef TO_REMOVE
bool RsPeerConfigSerialiser::serialiseNet(RsPeerNetItem *item, void *data, uint32_t *size)
{
uint32_t tlvsize = RsPeerConfigSerialiser::sizeNet(item);
@ -1119,7 +1237,14 @@ uint32_t RsPeerConfigSerialiser::sizePeerBandwidthLimits(RsPeerBandwidthLimitsIt
return s;
}
#endif
void RsPeerBandwidthLimitsItem::serial_process(SerializeJob j,SerializeContext& ctx)
{
RsTypeSerializer::serial_process(j,ctx,peers,"peers") ;
}
#ifdef TO_REMOVE
bool RsPeerConfigSerialiser::serialisePeerBandwidthLimits(RsPeerBandwidthLimitsItem *item, void *data, uint32_t *size)
{
uint32_t tlvsize = RsPeerConfigSerialiser::sizePeerBandwidthLimits(item);
@ -1296,7 +1421,50 @@ uint32_t RsPeerConfigSerialiser::sizeStun(RsPeerStunItem *i)
return s;
}
#endif
void RsPeerStunItem::serial_process(SerializeJob j,SerializeContext& ctx)
{
RsTypeSerializer::serial_process<RsTlvItem>(j,ctx,stunList,"stunList") ;
}
template<> uint32_t RsTypeSerializer::serial_size(const PeerBandwidthLimits& s)
{
return 4+4 ;
}
template<> bool RsTypeSerializer::serialize(uint8_t data[], uint32_t size, uint32_t &offset,const PeerBandwidthLimits& s)
{
bool ok = true ;
ok = ok && setRawUInt32(data,size,&offset,s.max_up_rate_kbs);
ok = ok && setRawUInt32(data,size,&offset,s.max_dl_rate_kbs);
return ok;
}
template<> bool RsTypeSerializer::deserialize(const uint8_t data[], uint32_t size,uint32_t& offset,PeerBandwidthLimits& s)
{
bool ok = true ;
ok = ok && getRawUInt32(data,size,&offset,&s.max_up_rate_kbs);
ok = ok && getRawUInt32(data,size,&offset,&s.max_dl_rate_kbs);
return ok;
}
template<> void RsTypeSerializer::print_data(const std::string& n, const PeerBandwidthLimits& s)
{
std::cerr << " [Peer BW limit] " << s.max_up_rate_kbs << " / " << s.max_dl_rate_kbs << std::endl;
}
RsNodeGroupItem::RsNodeGroupItem(const RsGroupInfo& g)
:RsItem(RS_PKT_VERSION1, RS_PKT_CLASS_CONFIG, RS_PKT_TYPE_PEER_CONFIG, RS_PKT_SUBTYPE_NODE_GROUP)
{
id = g.id ;
name = g.name ;
flag = g.flag ;
pgpList.ids = g.peerIds;
}
#ifdef TO_REMOVE
bool RsPeerConfigSerialiser::serialiseStun(RsPeerStunItem *item, void *data, uint32_t *size)
{
uint32_t tlvsize = RsPeerConfigSerialiser::sizeStun(item);
@ -1382,18 +1550,6 @@ RsPeerStunItem *RsPeerConfigSerialiser::deserialiseStun(void *data, uint32_t *si
}
/*************************************************************************/
RsNodeGroupItem::RsNodeGroupItem() : RsItem(RS_PKT_VERSION1, RS_PKT_CLASS_CONFIG, RS_PKT_TYPE_PEER_CONFIG, RS_PKT_SUBTYPE_NODE_GROUP)
{
}
RsNodeGroupItem::RsNodeGroupItem(const RsGroupInfo& g)
:RsItem(RS_PKT_VERSION1, RS_PKT_CLASS_CONFIG, RS_PKT_TYPE_PEER_CONFIG, RS_PKT_SUBTYPE_NODE_GROUP)
{
id = g.id ;
name = g.name ;
flag = g.flag ;
pgpList.ids = g.peerIds;
}
void RsNodeGroupItem::clear()
{
@ -1531,6 +1687,20 @@ uint32_t RsPeerConfigSerialiser::sizeGroup(RsNodeGroupItem *i)
return s;
}
#endif
void RsNodeGroupItem::serial_process(SerializeJob j,SerializeContext& ctx)
{
uint32_t v=0 ;
RsTypeSerializer::serial_process<uint32_t>(j,ctx,v,"dummy field 0") ;
RsTypeSerializer::serial_process (j,ctx,id,"id") ;
RsTypeSerializer::serial_process (j,ctx,TLV_TYPE_STR_NAME,name,"name") ;
RsTypeSerializer::serial_process<uint32_t>(j,ctx,flag,"flag") ;
RsTypeSerializer::serial_process<RsTlvItem>(j,ctx,pgpList,"pgpList") ;
}
#ifdef TO_REMOVE
bool RsPeerConfigSerialiser::serialiseGroup(RsNodeGroupItem *item, void *data, uint32_t *size)
{
uint32_t tlvsize = RsPeerConfigSerialiser::sizeGroup(item);
@ -1650,7 +1820,14 @@ uint32_t RsPeerConfigSerialiser::sizePermissions(RsPeerServicePermissionItem *i)
return s;
}
#endif
void RsPeerServicePermissionItem::serial_process(SerializeJob j,SerializeContext& ctx)
{
RsTypeSerializer::serial_process(j,ctx,pgp_ids,"pgp_ids") ;
}
#ifdef TO_REMOVE
bool RsPeerConfigSerialiser::serialisePermissions(RsPeerServicePermissionItem *item, void *data, uint32_t *size)
{
uint32_t tlvsize = RsPeerConfigSerialiser::sizePermissions(item);
@ -1932,6 +2109,7 @@ RsItem *RsCacheConfigSerialiser::deserialise(void *data, uint32_t *size)
}
#endif

View File

@ -37,6 +37,8 @@
#include "serialiser/rstlvkeyvalue.h"
#include "serialiser/rstlvaddrs.h"
#include "serialization/rsserializer.h"
class RsGroupInfo;
const uint8_t RS_PKT_TYPE_GENERAL_CONFIG = 0x01;
@ -68,21 +70,22 @@ const uint8_t RS_PKT_SUBTYPE_FILE_ITEM = 0x03;
class RsPeerNetItem: public RsItem
{
public:
RsPeerNetItem()
:RsItem(RS_PKT_VERSION1, RS_PKT_CLASS_CONFIG,
RS_PKT_TYPE_PEER_CONFIG,
RS_PKT_SUBTYPE_PEER_NET)
{ return; }
virtual ~RsPeerNetItem();
virtual void clear();
std::ostream &print(std::ostream &out, uint16_t indent = 0);
public:
RsPeerNetItem()
:RsItem(RS_PKT_VERSION1, RS_PKT_CLASS_CONFIG,
RS_PKT_TYPE_PEER_CONFIG,
RS_PKT_SUBTYPE_PEER_NET) {}
virtual ~RsPeerNetItem(){}
virtual void clear();
virtual void serial_process(SerializeJob j,SerializeContext& ctx);
/* networking information */
RsPeerId peerId; /* Mandatory */
RsPgpId pgpId; /* Mandatory */
std::string location; /* Mandatory */
uint32_t netMode; /* Mandatory */
RsPgpId pgpId; /* Mandatory */
std::string location; /* Mandatory */
uint32_t netMode; /* Mandatory */
uint16_t vs_disc; /* Mandatory */
uint16_t vs_dht; /* Mandatory */
uint32_t lastContact; /* Mandatory */
@ -92,14 +95,14 @@ std::ostream &print(std::ostream &out, uint16_t indent = 0);
RsTlvIpAddress localAddrV6; /* Mandatory */
RsTlvIpAddress extAddrV6; /* Mandatory */
std::string dyndns;
std::string dyndns;
RsTlvIpAddrSet localAddrList;
RsTlvIpAddrSet extAddrList;
// for proxy connection.
std::string domain_addr;
uint16_t domain_port;
uint16_t domain_port;
};
// This item should be merged with the next item, but that is not backward compatible.
@ -114,7 +117,8 @@ class RsPeerServicePermissionItem : public RsItem
pgp_ids.clear() ;
service_flags.clear() ;
}
std::ostream &print(std::ostream &out, uint16_t indent = 0);
virtual void serial_process(SerializeJob j,SerializeContext& ctx);
/* Mandatory */
std::vector<RsPgpId> pgp_ids ;
@ -130,12 +134,13 @@ class RsPeerBandwidthLimitsItem : public RsItem
{
peers.clear() ;
}
std::ostream &print(std::ostream &out, uint16_t indent = 0);
virtual void serial_process(SerializeJob j,SerializeContext& ctx);
/* Mandatory */
std::map<RsPgpId,PeerBandwidthLimits> peers ;
};
#ifdef TO_REMOVE
class RsPeerGroupItem_deprecated : public RsItem
{
public:
@ -157,18 +162,20 @@ public:
RsTlvPgpIdSet pgpList;
};
#endif
class RsNodeGroupItem: public RsItem
{
public:
RsNodeGroupItem();
RsNodeGroupItem(): RsItem(RS_PKT_VERSION1, RS_PKT_CLASS_CONFIG, RS_PKT_TYPE_PEER_CONFIG, RS_PKT_SUBTYPE_NODE_GROUP){}
virtual ~RsNodeGroupItem() {}
virtual void clear();
std::ostream &print(std::ostream &out, uint16_t indent = 0);
virtual void clear() { pgpList.TlvClear();}
explicit RsNodeGroupItem(const RsGroupInfo&) ;
virtual void serial_process(SerializeJob j,SerializeContext& ctx);
// /* set data from RsGroupInfo to RsPeerGroupItem */
// void set(RsGroupInfo &groupInfo);
// /* get data from RsGroupInfo to RsPeerGroupItem */
@ -184,63 +191,32 @@ public:
class RsPeerStunItem: public RsItem
{
public:
RsPeerStunItem()
:RsItem(RS_PKT_VERSION1, RS_PKT_CLASS_CONFIG,
RS_PKT_TYPE_PEER_CONFIG,
RS_PKT_SUBTYPE_PEER_STUN)
{ return; }
virtual ~RsPeerStunItem();
virtual void clear();
std::ostream &print(std::ostream &out, uint16_t indent = 0);
public:
RsPeerStunItem()
:RsItem(RS_PKT_VERSION1, RS_PKT_CLASS_CONFIG,
RS_PKT_TYPE_PEER_CONFIG,
RS_PKT_SUBTYPE_PEER_STUN) {}
virtual ~RsPeerStunItem(){}
virtual void clear() { stunList.TlvClear() ;}
virtual void serial_process(SerializeJob j,SerializeContext& ctx);
RsTlvPeerIdSet stunList; /* Mandatory */
};
class RsPeerConfigSerialiser: public RsSerialType
class RsPeerConfigSerialiser: public RsConfigSerializer
{
public:
RsPeerConfigSerialiser()
:RsSerialType(RS_PKT_VERSION1, RS_PKT_CLASS_CONFIG,
RS_PKT_TYPE_PEER_CONFIG)
{ return; }
RsPeerConfigSerialiser() :RsConfigSerializer(RS_PKT_CLASS_CONFIG,RS_PKT_TYPE_PEER_CONFIG) {}
virtual ~RsPeerConfigSerialiser();
virtual uint32_t size(RsItem *);
virtual bool serialise (RsItem *item, void *data, uint32_t *size);
virtual RsItem * deserialise(void *data, uint32_t *size);
virtual ~RsPeerConfigSerialiser(){}
private:
virtual uint32_t sizeNet(RsPeerNetItem *);
virtual bool serialiseNet (RsPeerNetItem *item, void *data, uint32_t *size);
virtual RsPeerNetItem *deserialiseNet(void *data, uint32_t *size);
virtual uint32_t sizeStun(RsPeerStunItem *);
virtual bool serialiseStun (RsPeerStunItem *item, void *data, uint32_t *size);
virtual RsPeerStunItem * deserialiseStun(void *data, uint32_t *size);
virtual uint32_t sizeGroup(RsNodeGroupItem *);
virtual bool serialiseGroup (RsNodeGroupItem *item, void *data, uint32_t *size);
virtual RsNodeGroupItem *deserialiseGroup(void *data, uint32_t *size);
virtual RsPeerGroupItem_deprecated * deserialiseGroup_deprecated(void *data, uint32_t *size);
virtual uint32_t sizePeerBandwidthLimits(RsPeerBandwidthLimitsItem *);
virtual bool serialisePeerBandwidthLimits (RsPeerBandwidthLimitsItem *item, void *data, uint32_t *size);
virtual RsPeerBandwidthLimitsItem *deserialisePeerBandwidthLimits(void *data, uint32_t *size);
virtual uint32_t sizePermissions(RsPeerServicePermissionItem *);
virtual bool serialisePermissions (RsPeerServicePermissionItem *item, void *data, uint32_t *size);
virtual RsPeerServicePermissionItem * deserialisePermissions(void *data, uint32_t *size);
virtual RsItem *create_item(uint8_t item_class,uint8_t item_type) const ;
};
/**************************************************************************/
/**************************************************************************/
/**************************************************************************/
#ifdef TO_REMOVE
class RsCacheConfig: public RsItem
{
public:
@ -281,6 +257,7 @@ virtual bool serialise (RsItem *item, void *data, uint32_t *size);
virtual RsItem * deserialise(void *data, uint32_t *size);
};
#endif
/**************************************************************************/
@ -299,14 +276,15 @@ class RsFileTransfer: public RsItem
flags = 0;
chunk_strategy = 0;
}
virtual ~RsFileTransfer();
virtual ~RsFileTransfer(){}
virtual void clear();
std::ostream &print(std::ostream &out, uint16_t indent = 0);
virtual void serial_process(SerializeJob j,SerializeContext& ctx);
RsTlvFileItem file;
RsTlvPeerIdSet allPeerIds;
RsPeerId cPeerId;
RsPeerId cPeerId;
uint16_t state;
uint16_t in;
@ -328,6 +306,7 @@ class RsFileTransfer: public RsItem
const uint32_t RS_FILE_CONFIG_CLEANUP_DELETE = 0x0001;
#ifdef TO_REMOVE
/* Used by ft / extralist / configdirs / anyone who wants a basic file */
class RsFileConfigItem_deprecated: public RsItem
{
@ -345,18 +324,16 @@ public:
uint32_t flags;
std::list<std::string> parent_groups ;
};
#endif
class RsFileConfigItem: public RsItem
{
public:
RsFileConfigItem()
:RsItem(RS_PKT_VERSION1, RS_PKT_CLASS_CONFIG,
RS_PKT_TYPE_FILE_CONFIG,
RS_PKT_SUBTYPE_FILE_ITEM)
{}
RsFileConfigItem() :RsItem(RS_PKT_VERSION1, RS_PKT_CLASS_CONFIG, RS_PKT_TYPE_FILE_CONFIG, RS_PKT_SUBTYPE_FILE_ITEM) {}
virtual ~RsFileConfigItem() {}
virtual void clear();
std::ostream &print(std::ostream &out, uint16_t indent = 0);
virtual void clear() { parent_groups.TlvClear(); }
virtual void serial_process(SerializeJob j,SerializeContext& ctx);
RsTlvFileItem file;
uint32_t flags;
@ -364,31 +341,13 @@ public:
};
/**************************************************************************/
class RsFileConfigSerialiser: public RsSerialType
class RsFileConfigSerialiser: public RsConfigSerializer
{
public:
RsFileConfigSerialiser()
:RsSerialType(RS_PKT_VERSION1, RS_PKT_CLASS_CONFIG,
RS_PKT_TYPE_FILE_CONFIG)
{ return; }
virtual ~RsFileConfigSerialiser() { return; }
RsFileConfigSerialiser() :RsConfigSerializer(RS_PKT_CLASS_CONFIG, RS_PKT_TYPE_FILE_CONFIG) { }
virtual ~RsFileConfigSerialiser() {}
virtual uint32_t size(RsItem *);
virtual bool serialise (RsItem *item, void *data, uint32_t *size);
virtual RsItem * deserialise(void *data, uint32_t *size);
private:
virtual uint32_t sizeTransfer(RsFileTransfer *);
virtual bool serialiseTransfer(RsFileTransfer *item, void *data, uint32_t *size);
virtual RsFileTransfer * deserialiseTransfer(void *data, uint32_t *size);
virtual RsFileConfigItem_deprecated * deserialiseFileItem_deprecated(void *data, uint32_t *size);
virtual uint32_t sizeFileItem(RsFileConfigItem *);
virtual bool serialiseFileItem(RsFileConfigItem *item, void *data, uint32_t *size);
virtual RsFileConfigItem *deserialiseFileItem(void *data, uint32_t *size);
virtual RsItem *create_item(uint8_t item_class,uint8_t item_type) const ;
};
/**************************************************************************/
@ -397,39 +356,23 @@ virtual RsFileConfigItem *deserialiseFileItem(void *data, uint32_t *size);
class RsConfigKeyValueSet: public RsItem
{
public:
RsConfigKeyValueSet()
:RsItem(RS_PKT_VERSION1, RS_PKT_CLASS_CONFIG,
RS_PKT_TYPE_GENERAL_CONFIG,
RS_PKT_SUBTYPE_KEY_VALUE)
{ return; }
virtual ~RsConfigKeyValueSet();
virtual void clear();
std::ostream &print(std::ostream &out, uint16_t indent = 0);
public:
RsConfigKeyValueSet() :RsItem(RS_PKT_VERSION1, RS_PKT_CLASS_CONFIG, RS_PKT_TYPE_GENERAL_CONFIG, RS_PKT_SUBTYPE_KEY_VALUE) {}
virtual ~RsConfigKeyValueSet(){}
virtual void clear() { tlvkvs.TlvClear();}
virtual void serial_process(SerializeJob j,SerializeContext& ctx);
RsTlvKeyValueSet tlvkvs;
};
class RsGeneralConfigSerialiser: public RsSerialType
class RsGeneralConfigSerialiser: public RsConfigSerializer
{
public:
RsGeneralConfigSerialiser()
:RsSerialType(RS_PKT_VERSION1, RS_PKT_CLASS_CONFIG,
RS_PKT_TYPE_GENERAL_CONFIG)
{ return; }
virtual ~RsGeneralConfigSerialiser();
virtual uint32_t size(RsItem *);
virtual bool serialise (RsItem *item, void *data, uint32_t *size);
virtual RsItem * deserialise(void *data, uint32_t *size);
private:
uint32_t sizeKeyValueSet(RsConfigKeyValueSet *item);
bool serialiseKeyValueSet(RsConfigKeyValueSet *item, void *data, uint32_t *pktsize);
RsConfigKeyValueSet *deserialiseKeyValueSet(void *data, uint32_t *pktsize);
RsGeneralConfigSerialiser() :RsConfigSerializer(RS_PKT_CLASS_CONFIG, RS_PKT_TYPE_GENERAL_CONFIG) {}
virtual RsItem *create_item(uint8_t item_class,uint8_t item_type) const ;
};
#endif /* RS_CONFIG_ITEMS_SERIALISER_H */