mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-26 16:09:35 -05:00
switch rsrecognitems to new serialization
This commit is contained in:
parent
8341c68388
commit
23492698d4
@ -25,6 +25,7 @@
|
||||
|
||||
#include "serialiser/rsgxsrecognitems.h"
|
||||
#include "serialiser/rsbaseserial.h"
|
||||
#include "serialization/rstypeserializer.h"
|
||||
|
||||
/***
|
||||
#define RSSERIAL_DEBUG 1
|
||||
@ -34,9 +35,19 @@
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
RsGxsRecognReqItem::~RsGxsRecognReqItem()
|
||||
RsItem *RsGxsRecognSerialiser::create_item(uint16_t service, uint8_t item_sub_id) const
|
||||
{
|
||||
return;
|
||||
if(service != RS_SERVICE_TYPE_GXS_RECOGN)
|
||||
return NULL ;
|
||||
|
||||
switch(item_sub_id)
|
||||
{
|
||||
case RS_PKT_SUBTYPE_RECOGN_REQ: return new RsGxsRecognReqItem();
|
||||
case RS_PKT_SUBTYPE_RECOGN_SIGNER: return new RsGxsRecognSignerItem();
|
||||
case RS_PKT_SUBTYPE_RECOGN_TAG: return new RsGxsRecognTagItem();
|
||||
default:
|
||||
return NULL ;
|
||||
}
|
||||
}
|
||||
|
||||
void RsGxsRecognReqItem::clear()
|
||||
@ -53,6 +64,12 @@ void RsGxsRecognReqItem::clear()
|
||||
sign.TlvClear();
|
||||
|
||||
}
|
||||
#ifdef TO_REMOVE
|
||||
RsGxsRecognReqItem::~RsGxsRecognReqItem()
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
std::ostream &RsGxsRecognReqItem::print(std::ostream &out, uint16_t indent)
|
||||
{
|
||||
@ -104,6 +121,21 @@ uint32_t RsGxsRecognSerialiser::sizeReq(RsGxsRecognReqItem *item)
|
||||
return s;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void RsGxsRecognReqItem::serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx)
|
||||
{
|
||||
RsTypeSerializer::serial_process<uint32_t> (j,ctx,issued_at ,"issued_at") ;
|
||||
RsTypeSerializer::serial_process<uint32_t> (j,ctx,period ,"period") ;
|
||||
RsTypeSerializer::serial_process<uint16_t> (j,ctx,tag_class ,"tag_class") ;
|
||||
RsTypeSerializer::serial_process<uint16_t> (j,ctx,tag_type ,"tag_type") ;
|
||||
RsTypeSerializer::serial_process (j,ctx,identity ,"identity") ;
|
||||
RsTypeSerializer::serial_process (j,ctx,1,nickname ,"nickname") ;
|
||||
RsTypeSerializer::serial_process (j,ctx,1,comment ,"comment") ;
|
||||
RsTypeSerializer::serial_process<RsTlvItem>(j,ctx,sign ,"sign") ;
|
||||
}
|
||||
|
||||
#ifdef TO_REMOVE
|
||||
/* serialise the data to the buffer */
|
||||
bool RsGxsRecognSerialiser::serialiseReq(RsGxsRecognReqItem *item, void *data, uint32_t *pktsize)
|
||||
{
|
||||
@ -217,6 +249,7 @@ RsGxsRecognTagItem::~RsGxsRecognTagItem()
|
||||
{
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
void RsGxsRecognTagItem::clear()
|
||||
{
|
||||
@ -232,6 +265,7 @@ void RsGxsRecognTagItem::clear()
|
||||
sign.TlvClear();
|
||||
}
|
||||
|
||||
#ifdef TO_REMOVE
|
||||
std::ostream &RsGxsRecognTagItem::print(std::ostream &out, uint16_t indent)
|
||||
{
|
||||
printRsItemBase(out, "RsGxsRecognTagItem", indent);
|
||||
@ -279,7 +313,20 @@ uint32_t RsGxsRecognSerialiser::sizeTag(RsGxsRecognTagItem *item)
|
||||
|
||||
return s;
|
||||
}
|
||||
#endif
|
||||
|
||||
void RsGxsRecognTagItem::serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx)
|
||||
{
|
||||
RsTypeSerializer::serial_process<uint32_t> (j,ctx,valid_from ,"valid_from") ;
|
||||
RsTypeSerializer::serial_process<uint32_t> (j,ctx,valid_to ,"valid_to") ;
|
||||
RsTypeSerializer::serial_process<uint16_t> (j,ctx,tag_class ,"tag_class") ;
|
||||
RsTypeSerializer::serial_process<uint16_t> (j,ctx,tag_type ,"tag_type") ;
|
||||
RsTypeSerializer::serial_process (j,ctx,identity ,"identity");
|
||||
RsTypeSerializer::serial_process (j,ctx,1,nickname ,"nickname") ;
|
||||
RsTypeSerializer::serial_process<RsTlvItem>(j,ctx,sign ,"sign") ;
|
||||
}
|
||||
|
||||
#ifdef TO_REMOVE
|
||||
/* serialise the data to the buffer */
|
||||
bool RsGxsRecognSerialiser::serialiseTag(RsGxsRecognTagItem *item, void *data, uint32_t *pktsize)
|
||||
{
|
||||
@ -393,6 +440,7 @@ RsGxsRecognSignerItem::~RsGxsRecognSignerItem()
|
||||
{
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
void RsGxsRecognSignerItem::clear()
|
||||
{
|
||||
@ -401,6 +449,7 @@ void RsGxsRecognSignerItem::clear()
|
||||
sign.TlvClear();
|
||||
}
|
||||
|
||||
#ifdef TO_REMOVE
|
||||
std::ostream &RsGxsRecognSignerItem::print(std::ostream &out, uint16_t indent)
|
||||
{
|
||||
printRsItemBase(out, "RsGxsRecognSignerItem", indent);
|
||||
@ -435,7 +484,16 @@ uint32_t RsGxsRecognSerialiser::sizeSigner(RsGxsRecognSignerItem *item)
|
||||
|
||||
return s;
|
||||
}
|
||||
#endif
|
||||
|
||||
void RsGxsRecognSignerItem::serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx)
|
||||
{
|
||||
RsTypeSerializer::serial_process<RsTlvItem>(j,ctx,signing_classes ,"signing_classes") ;
|
||||
RsTypeSerializer::serial_process<RsTlvItem>(j,ctx,key ,"key");
|
||||
RsTypeSerializer::serial_process<RsTlvItem>(j,ctx,sign ,"sign") ;
|
||||
}
|
||||
|
||||
#ifdef TO_REMOVE
|
||||
/* serialise the data to the buffer */
|
||||
bool RsGxsRecognSerialiser::serialiseSigner(RsGxsRecognSignerItem *item, void *data, uint32_t *pktsize)
|
||||
{
|
||||
@ -604,6 +662,6 @@ RsItem *RsGxsRecognSerialiser::deserialise(void *data, uint32_t *pktsize)
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -32,7 +32,6 @@
|
||||
#include "rsitems/rsserviceids.h"
|
||||
#include "rsitems/itempriorities.h"
|
||||
|
||||
#include "serialiser/rsserial.h"
|
||||
#include "serialiser/rstlvkeys.h"
|
||||
#include "serialiser/rstlvidset.h"
|
||||
|
||||
@ -46,25 +45,23 @@
|
||||
|
||||
/**************************************************************************/
|
||||
|
||||
#define RS_PKT_SUBTYPE_RECOGN_REQ 0x01
|
||||
#define RS_PKT_SUBTYPE_RECOGN_TAG 0x02
|
||||
#define RS_PKT_SUBTYPE_RECOGN_SIGNER 0x03
|
||||
#define RS_PKT_SUBTYPE_RECOGN_REQ 0x01
|
||||
#define RS_PKT_SUBTYPE_RECOGN_TAG 0x02
|
||||
#define RS_PKT_SUBTYPE_RECOGN_SIGNER 0x03
|
||||
|
||||
|
||||
class RsGxsRecognReqItem: public RsItem
|
||||
{
|
||||
public:
|
||||
RsGxsRecognReqItem()
|
||||
:RsItem(RS_PKT_VERSION_SERVICE, RS_SERVICE_TYPE_GXS_RECOGN,
|
||||
RS_PKT_SUBTYPE_RECOGN_REQ)
|
||||
{
|
||||
public:
|
||||
RsGxsRecognReqItem() :RsItem(RS_PKT_VERSION_SERVICE, RS_SERVICE_TYPE_GXS_RECOGN, RS_PKT_SUBTYPE_RECOGN_REQ)
|
||||
{
|
||||
setPriorityLevel(QOS_PRIORITY_DEFAULT);
|
||||
return;
|
||||
return;
|
||||
}
|
||||
virtual ~RsGxsRecognReqItem();
|
||||
virtual void clear();
|
||||
std::ostream &print(std::ostream &out, uint16_t indent = 0);
|
||||
virtual ~RsGxsRecognReqItem(){}
|
||||
virtual void clear();
|
||||
|
||||
virtual void serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx);
|
||||
|
||||
uint32_t issued_at;
|
||||
uint32_t period;
|
||||
@ -82,16 +79,15 @@ std::ostream &print(std::ostream &out, uint16_t indent = 0);
|
||||
class RsGxsRecognTagItem: public RsItem
|
||||
{
|
||||
public:
|
||||
RsGxsRecognTagItem()
|
||||
:RsItem(RS_PKT_VERSION_SERVICE, RS_SERVICE_TYPE_GXS_RECOGN,
|
||||
RS_PKT_SUBTYPE_RECOGN_TAG)
|
||||
RsGxsRecognTagItem() :RsItem(RS_PKT_VERSION_SERVICE, RS_SERVICE_TYPE_GXS_RECOGN, RS_PKT_SUBTYPE_RECOGN_TAG)
|
||||
{
|
||||
setPriorityLevel(QOS_PRIORITY_DEFAULT);
|
||||
return;
|
||||
}
|
||||
virtual ~RsGxsRecognTagItem();
|
||||
virtual void clear();
|
||||
std::ostream &print(std::ostream &out, uint16_t indent = 0);
|
||||
virtual ~RsGxsRecognTagItem(){}
|
||||
virtual void clear();
|
||||
|
||||
virtual void serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx);
|
||||
|
||||
uint32_t valid_from;
|
||||
uint32_t valid_to;
|
||||
@ -107,52 +103,30 @@ std::ostream &print(std::ostream &out, uint16_t indent = 0);
|
||||
|
||||
class RsGxsRecognSignerItem: public RsItem
|
||||
{
|
||||
public:
|
||||
RsGxsRecognSignerItem()
|
||||
:RsItem(RS_PKT_VERSION_SERVICE, RS_SERVICE_TYPE_GXS_RECOGN,
|
||||
RS_PKT_SUBTYPE_RECOGN_SIGNER)
|
||||
{
|
||||
public:
|
||||
RsGxsRecognSignerItem() :RsItem(RS_PKT_VERSION_SERVICE, RS_SERVICE_TYPE_GXS_RECOGN, RS_PKT_SUBTYPE_RECOGN_SIGNER)
|
||||
{
|
||||
setPriorityLevel(QOS_PRIORITY_DEFAULT);
|
||||
return;
|
||||
return;
|
||||
}
|
||||
virtual ~RsGxsRecognSignerItem();
|
||||
virtual void clear();
|
||||
std::ostream &print(std::ostream &out, uint16_t indent = 0);
|
||||
virtual ~RsGxsRecognSignerItem(){}
|
||||
virtual void clear();
|
||||
|
||||
virtual void serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx);
|
||||
|
||||
RsTlvServiceIdSet signing_classes;
|
||||
RsTlvPublicRSAKey key; // has from->to, and flags.
|
||||
RsTlvPublicRSAKey key; // has from->to, and flags.
|
||||
RsTlvKeySignature sign;
|
||||
};
|
||||
|
||||
|
||||
class RsGxsRecognSerialiser: public RsSerialType
|
||||
class RsGxsRecognSerialiser: public RsServiceSerializer
|
||||
{
|
||||
public:
|
||||
RsGxsRecognSerialiser()
|
||||
:RsSerialType(RS_PKT_VERSION_SERVICE, RS_SERVICE_TYPE_GXS_RECOGN)
|
||||
{ return; }
|
||||
virtual ~RsGxsRecognSerialiser()
|
||||
{ return; }
|
||||
|
||||
|
||||
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 sizeReq(RsGxsRecognReqItem *);
|
||||
virtual bool serialiseReq(RsGxsRecognReqItem *item, void *data, uint32_t *size);
|
||||
virtual RsGxsRecognReqItem *deserialiseReq(void *data, uint32_t *size);
|
||||
|
||||
virtual uint32_t sizeTag(RsGxsRecognTagItem *);
|
||||
virtual bool serialiseTag(RsGxsRecognTagItem *item, void *data, uint32_t *size);
|
||||
virtual RsGxsRecognTagItem *deserialiseTag(void *data, uint32_t *size);
|
||||
|
||||
virtual uint32_t sizeSigner(RsGxsRecognSignerItem *);
|
||||
virtual bool serialiseSigner(RsGxsRecognSignerItem *item, void *data, uint32_t *size);
|
||||
virtual RsGxsRecognSignerItem *deserialiseSigner(void *data, uint32_t *size);
|
||||
RsGxsRecognSerialiser() :RsServiceSerializer(RS_SERVICE_TYPE_GXS_RECOGN) {}
|
||||
virtual ~RsGxsRecognSerialiser() {}
|
||||
|
||||
virtual RsItem *create_item(uint16_t service, uint8_t item_sub_id) const;
|
||||
};
|
||||
|
||||
/**************************************************************************/
|
||||
|
Loading…
Reference in New Issue
Block a user