mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-27 08:29:26 -05:00
switched wiki and wire items to new serialization
This commit is contained in:
parent
5cba0059c8
commit
d58c638af8
@ -31,7 +31,22 @@
|
||||
|
||||
#define GXSID_DEBUG 1
|
||||
|
||||
RsItem *RsGxsWikiSerialiser::create_item(uint16_t service, uint8_t item_sub_id) const
|
||||
{
|
||||
if(service != RS_SERVICE_GXS_TYPE_WIKI)
|
||||
return NULL ;
|
||||
|
||||
switch(item_sub_id)
|
||||
{
|
||||
case RS_PKT_SUBTYPE_WIKI_COLLECTION_ITEM: return new RsGxsWikiCollectionItem();
|
||||
case RS_PKT_SUBTYPE_WIKI_COMMENT_ITEM: return new RsGxsWikiCommentItem();
|
||||
case RS_PKT_SUBTYPE_WIKI_SNAPSHOT_ITEM: return new RsGxsWikiSnapshotItem();
|
||||
default:
|
||||
return NULL ;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef TO_REMOVE
|
||||
uint32_t RsGxsWikiSerialiser::size(RsItem *item)
|
||||
{
|
||||
RsGxsWikiCollectionItem* grp_item = NULL;
|
||||
@ -117,6 +132,7 @@ RsItem* RsGxsWikiSerialiser::deserialise(void* data, uint32_t* size)
|
||||
/*****************************************************************************************/
|
||||
/*****************************************************************************************/
|
||||
|
||||
#endif
|
||||
|
||||
void RsGxsWikiCollectionItem::clear()
|
||||
{
|
||||
@ -125,6 +141,7 @@ void RsGxsWikiCollectionItem::clear()
|
||||
collection.mHashTags.clear();
|
||||
}
|
||||
|
||||
#ifdef TO_REMOVE
|
||||
std::ostream& RsGxsWikiCollectionItem::print(std::ostream& out, uint16_t indent)
|
||||
{
|
||||
printRsItemBase(out, "RsGxsWikiCollectionItem", indent);
|
||||
@ -154,7 +171,16 @@ uint32_t RsGxsWikiSerialiser::sizeGxsWikiCollectionItem(RsGxsWikiCollectionItem
|
||||
|
||||
return s;
|
||||
}
|
||||
#endif
|
||||
|
||||
void RsGxsWikiCollectionItem::serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx)
|
||||
{
|
||||
RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_STR_DESCR ,collection.mDescription,"collection.mDescription") ;
|
||||
RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_STR_CATEGORY,collection.mCategory ,"collection.mCategory") ;
|
||||
RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_STR_HASH_TAG,collection.mHashTags ,"collection.mHashTags") ;
|
||||
}
|
||||
|
||||
#ifdef TO_REMOVE
|
||||
bool RsGxsWikiSerialiser::serialiseGxsWikiCollectionItem(RsGxsWikiCollectionItem *item, void *data, uint32_t *size)
|
||||
{
|
||||
|
||||
@ -277,6 +303,7 @@ RsGxsWikiCollectionItem* RsGxsWikiSerialiser::deserialiseGxsWikiCollectionItem(v
|
||||
/*****************************************************************************************/
|
||||
/*****************************************************************************************/
|
||||
|
||||
#endif
|
||||
|
||||
void RsGxsWikiSnapshotItem::clear()
|
||||
{
|
||||
@ -284,6 +311,7 @@ void RsGxsWikiSnapshotItem::clear()
|
||||
snapshot.mHashTags.clear();
|
||||
}
|
||||
|
||||
#ifdef TO_REMOVE
|
||||
std::ostream& RsGxsWikiSnapshotItem::print(std::ostream& out, uint16_t indent)
|
||||
{
|
||||
printRsItemBase(out, "RsGxsWikiSnapshotItem", indent);
|
||||
@ -311,7 +339,15 @@ uint32_t RsGxsWikiSerialiser::sizeGxsWikiSnapshotItem(RsGxsWikiSnapshotItem *ite
|
||||
|
||||
return s;
|
||||
}
|
||||
#endif
|
||||
|
||||
void RsGxsWikiSnapshotItem::serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx)
|
||||
{
|
||||
RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_STR_WIKI_PAGE,snapshot.mPage,"snapshot.mPage") ;
|
||||
RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_STR_HASH_TAG ,snapshot.mPage,"snapshot.mHashTags") ;
|
||||
}
|
||||
|
||||
#ifdef TO_REMOVE
|
||||
bool RsGxsWikiSerialiser::serialiseGxsWikiSnapshotItem(RsGxsWikiSnapshotItem *item, void *data, uint32_t *size)
|
||||
{
|
||||
|
||||
@ -431,12 +467,14 @@ RsGxsWikiSnapshotItem* RsGxsWikiSerialiser::deserialiseGxsWikiSnapshotItem(void
|
||||
/*****************************************************************************************/
|
||||
/*****************************************************************************************/
|
||||
|
||||
#endif
|
||||
|
||||
void RsGxsWikiCommentItem::clear()
|
||||
{
|
||||
comment.mComment.clear();
|
||||
}
|
||||
|
||||
#ifdef TO_REMOVE
|
||||
std::ostream& RsGxsWikiCommentItem::print(std::ostream& out, uint16_t indent)
|
||||
{
|
||||
printRsItemBase(out, "RsGxsWikiCommentItem", indent);
|
||||
@ -460,7 +498,14 @@ uint32_t RsGxsWikiSerialiser::sizeGxsWikiCommentItem(RsGxsWikiCommentItem *item)
|
||||
|
||||
return s;
|
||||
}
|
||||
#endif
|
||||
|
||||
void RsGxsWikiCommentItem::serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx)
|
||||
{
|
||||
RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_STR_COMMENT,comment.mComment,"comment.mComment") ;
|
||||
}
|
||||
|
||||
#ifdef TO_REMOVE
|
||||
bool RsGxsWikiSerialiser::serialiseGxsWikiCommentItem(RsGxsWikiCommentItem *item, void *data, uint32_t *size)
|
||||
{
|
||||
|
||||
@ -578,3 +623,5 @@ RsGxsWikiCommentItem* RsGxsWikiSerialiser::deserialiseGxsWikiCommentItem(void *d
|
||||
/*****************************************************************************************/
|
||||
/*****************************************************************************************/
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -29,10 +29,9 @@
|
||||
#include <map>
|
||||
|
||||
#include "rsitems/rsserviceids.h"
|
||||
#include "serialiser/rsserial.h"
|
||||
//#include "serialiser/rstlvtypes.h"
|
||||
#include "rsitems/rsitem.h"
|
||||
|
||||
#include "rsgxsitems.h"
|
||||
#include "serialiser/rsgxsitems.h"
|
||||
#include "retroshare/rswiki.h"
|
||||
|
||||
const uint8_t RS_PKT_SUBTYPE_WIKI_COLLECTION_ITEM = 0x02;
|
||||
@ -41,16 +40,13 @@ const uint8_t RS_PKT_SUBTYPE_WIKI_COMMENT_ITEM = 0x04;
|
||||
|
||||
class RsGxsWikiCollectionItem : public RsGxsGrpItem
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
RsGxsWikiCollectionItem(): RsGxsGrpItem(RS_SERVICE_GXS_TYPE_WIKI,
|
||||
RS_PKT_SUBTYPE_WIKI_COLLECTION_ITEM) { return;}
|
||||
virtual ~RsGxsWikiCollectionItem() { return;}
|
||||
RsGxsWikiCollectionItem(): RsGxsGrpItem(RS_SERVICE_GXS_TYPE_WIKI, RS_PKT_SUBTYPE_WIKI_COLLECTION_ITEM) {}
|
||||
virtual ~RsGxsWikiCollectionItem() {}
|
||||
|
||||
void clear();
|
||||
std::ostream &print(std::ostream &out, uint16_t indent = 0);
|
||||
|
||||
virtual void serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx);
|
||||
|
||||
RsWikiCollection collection;
|
||||
};
|
||||
@ -59,11 +55,12 @@ class RsGxsWikiSnapshotItem : public RsGxsMsgItem
|
||||
{
|
||||
public:
|
||||
|
||||
RsGxsWikiSnapshotItem(): RsGxsMsgItem(RS_SERVICE_GXS_TYPE_WIKI,
|
||||
RS_PKT_SUBTYPE_WIKI_SNAPSHOT_ITEM) {return; }
|
||||
virtual ~RsGxsWikiSnapshotItem() { return;}
|
||||
RsGxsWikiSnapshotItem(): RsGxsMsgItem(RS_SERVICE_GXS_TYPE_WIKI, RS_PKT_SUBTYPE_WIKI_SNAPSHOT_ITEM) {}
|
||||
virtual ~RsGxsWikiSnapshotItem() {}
|
||||
void clear();
|
||||
std::ostream &print(std::ostream &out, uint16_t indent = 0);
|
||||
|
||||
virtual void serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx);
|
||||
|
||||
RsWikiSnapshot snapshot;
|
||||
};
|
||||
|
||||
@ -71,42 +68,23 @@ class RsGxsWikiCommentItem : public RsGxsMsgItem
|
||||
{
|
||||
public:
|
||||
|
||||
RsGxsWikiCommentItem(): RsGxsMsgItem(RS_SERVICE_GXS_TYPE_WIKI,
|
||||
RS_PKT_SUBTYPE_WIKI_COMMENT_ITEM) { return; }
|
||||
virtual ~RsGxsWikiCommentItem() { return; }
|
||||
RsGxsWikiCommentItem(): RsGxsMsgItem(RS_SERVICE_GXS_TYPE_WIKI, RS_PKT_SUBTYPE_WIKI_COMMENT_ITEM) {}
|
||||
virtual ~RsGxsWikiCommentItem() {}
|
||||
void clear();
|
||||
std::ostream &print(std::ostream &out, uint16_t indent = 0);
|
||||
virtual void serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx);
|
||||
|
||||
RsWikiComment comment;
|
||||
|
||||
};
|
||||
|
||||
class RsGxsWikiSerialiser : public RsSerialType
|
||||
class RsGxsWikiSerialiser : public RsServiceSerializer
|
||||
{
|
||||
public:
|
||||
|
||||
RsGxsWikiSerialiser()
|
||||
:RsSerialType(RS_PKT_VERSION_SERVICE, RS_SERVICE_GXS_TYPE_WIKI)
|
||||
{ return; }
|
||||
virtual ~RsGxsWikiSerialiser() { return; }
|
||||
|
||||
uint32_t size(RsItem *item);
|
||||
bool serialise (RsItem *item, void *data, uint32_t *size);
|
||||
RsItem * deserialise(void *data, uint32_t *size);
|
||||
|
||||
private:
|
||||
|
||||
uint32_t sizeGxsWikiCollectionItem(RsGxsWikiCollectionItem *item);
|
||||
bool serialiseGxsWikiCollectionItem (RsGxsWikiCollectionItem *item, void *data, uint32_t *size);
|
||||
RsGxsWikiCollectionItem * deserialiseGxsWikiCollectionItem(void *data, uint32_t *size);
|
||||
|
||||
uint32_t sizeGxsWikiSnapshotItem(RsGxsWikiSnapshotItem *item);
|
||||
bool serialiseGxsWikiSnapshotItem (RsGxsWikiSnapshotItem *item, void *data, uint32_t *size);
|
||||
RsGxsWikiSnapshotItem * deserialiseGxsWikiSnapshotItem(void *data, uint32_t *size);
|
||||
|
||||
uint32_t sizeGxsWikiCommentItem(RsGxsWikiCommentItem *item);
|
||||
bool serialiseGxsWikiCommentItem (RsGxsWikiCommentItem *item, void *data, uint32_t *size);
|
||||
RsGxsWikiCommentItem * deserialiseGxsWikiCommentItem(void *data, uint32_t *size);
|
||||
RsGxsWikiSerialiser() :RsServiceSerializer(RS_SERVICE_GXS_TYPE_WIKI) {}
|
||||
virtual ~RsGxsWikiSerialiser() {}
|
||||
|
||||
virtual RsItem *create_item(uint16_t /* service */, uint8_t /* item_sub_id */) const;
|
||||
};
|
||||
|
||||
#endif /* RS_WIKI_ITEMS_H */
|
||||
|
@ -26,12 +26,27 @@
|
||||
#include <iostream>
|
||||
|
||||
#include "rswireitems.h"
|
||||
#include "serialiser/rstlvbase.h"
|
||||
#include "serialiser/rsbaseserial.h"
|
||||
|
||||
#include "serialization/rstypeserializer.h"
|
||||
|
||||
#define WIRE_DEBUG 1
|
||||
|
||||
|
||||
RsItem *RsGxsWireSerialiser::create_item(uint16_t service,uint8_t item_subtype) const
|
||||
{
|
||||
if(service != RS_SERVICE_GXS_TYPE_WIRE)
|
||||
return NULL ;
|
||||
|
||||
switch(item_subtype)
|
||||
{
|
||||
case RS_PKT_SUBTYPE_WIRE_GROUP_ITEM: return new RsGxsWireGroupItem();
|
||||
case RS_PKT_SUBTYPE_WIRE_PULSE_ITEM: return new RsGxsWirePulseItem();
|
||||
default:
|
||||
return NULL ;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef TO_REMOVE
|
||||
uint32_t RsGxsWireSerialiser::size(RsItem *item)
|
||||
{
|
||||
RsGxsWireGroupItem* grp_item = NULL;
|
||||
@ -104,12 +119,14 @@ RsItem* RsGxsWireSerialiser::deserialise(void* data, uint32_t* size)
|
||||
/*****************************************************************************************/
|
||||
/*****************************************************************************************/
|
||||
|
||||
#endif
|
||||
|
||||
void RsGxsWireGroupItem::clear()
|
||||
{
|
||||
group.mDescription.clear();
|
||||
}
|
||||
|
||||
#ifdef TO_REMOVE
|
||||
std::ostream& RsGxsWireGroupItem::print(std::ostream& out, uint16_t indent)
|
||||
{
|
||||
printRsItemBase(out, "RsGxsWireGroupItem", indent);
|
||||
@ -134,6 +151,14 @@ uint32_t RsGxsWireSerialiser::sizeGxsWireGroupItem(RsGxsWireGroupItem *item)
|
||||
return s;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void RsGxsWireGroupItem::serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx)
|
||||
{
|
||||
RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_STR_DESCR,group.mDescription,"group.mDescription") ;
|
||||
}
|
||||
|
||||
#ifdef TO_REMOVE
|
||||
bool RsGxsWireSerialiser::serialiseGxsWireGroupItem(RsGxsWireGroupItem *item, void *data, uint32_t *size)
|
||||
{
|
||||
|
||||
@ -287,6 +312,15 @@ uint32_t RsGxsWireSerialiser::sizeGxsWirePulseItem(RsGxsWirePulseItem *item)
|
||||
return s;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void RsGxsWirePulseItem::serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx)
|
||||
{
|
||||
RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_STR_MSG,pulse.mPulseText,"pulse.mPulseText") ;
|
||||
RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_STR_HASH_TAG,pulse.mHashTags,"pulse.mHashTags") ;
|
||||
}
|
||||
|
||||
#ifdef TO_REMOVE
|
||||
bool RsGxsWireSerialiser::serialiseGxsWirePulseItem(RsGxsWirePulseItem *item, void *data, uint32_t *size)
|
||||
{
|
||||
|
||||
@ -406,3 +440,4 @@ RsGxsWirePulseItem* RsGxsWireSerialiser::deserialiseGxsWirePulseItem(void *data,
|
||||
/*****************************************************************************************/
|
||||
/*****************************************************************************************/
|
||||
|
||||
#endif
|
||||
|
@ -43,13 +43,12 @@ class RsGxsWireGroupItem : public RsGxsGrpItem
|
||||
|
||||
public:
|
||||
|
||||
RsGxsWireGroupItem(): RsGxsGrpItem(RS_SERVICE_GXS_TYPE_WIRE,
|
||||
RS_PKT_SUBTYPE_WIRE_GROUP_ITEM) { return;}
|
||||
virtual ~RsGxsWireGroupItem() { return;}
|
||||
RsGxsWireGroupItem(): RsGxsGrpItem(RS_SERVICE_GXS_TYPE_WIRE, RS_PKT_SUBTYPE_WIRE_GROUP_ITEM) {}
|
||||
virtual ~RsGxsWireGroupItem() {}
|
||||
|
||||
void clear();
|
||||
std::ostream &print(std::ostream &out, uint16_t indent = 0);
|
||||
|
||||
virtual void serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx);
|
||||
|
||||
RsWireGroup group;
|
||||
};
|
||||
@ -58,36 +57,23 @@ class RsGxsWirePulseItem : public RsGxsMsgItem
|
||||
{
|
||||
public:
|
||||
|
||||
RsGxsWirePulseItem(): RsGxsMsgItem(RS_SERVICE_GXS_TYPE_WIRE,
|
||||
RS_PKT_SUBTYPE_WIRE_PULSE_ITEM) {return; }
|
||||
virtual ~RsGxsWirePulseItem() { return;}
|
||||
RsGxsWirePulseItem(): RsGxsMsgItem(RS_SERVICE_GXS_TYPE_WIRE, RS_PKT_SUBTYPE_WIRE_PULSE_ITEM) {}
|
||||
virtual ~RsGxsWirePulseItem() {}
|
||||
void clear();
|
||||
std::ostream &print(std::ostream &out, uint16_t indent = 0);
|
||||
|
||||
virtual void serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx);
|
||||
|
||||
RsWirePulse pulse;
|
||||
};
|
||||
|
||||
class RsGxsWireSerialiser : public RsSerialType
|
||||
class RsGxsWireSerialiser : public RsServiceSerializer
|
||||
{
|
||||
public:
|
||||
|
||||
RsGxsWireSerialiser()
|
||||
:RsSerialType(RS_PKT_VERSION_SERVICE, RS_SERVICE_GXS_TYPE_WIRE)
|
||||
{ return; }
|
||||
virtual ~RsGxsWireSerialiser() { return; }
|
||||
RsGxsWireSerialiser() :RsServiceSerializer(RS_SERVICE_GXS_TYPE_WIRE) {}
|
||||
virtual ~RsGxsWireSerialiser() {}
|
||||
|
||||
uint32_t size(RsItem *item);
|
||||
bool serialise (RsItem *item, void *data, uint32_t *size);
|
||||
RsItem * deserialise(void *data, uint32_t *size);
|
||||
|
||||
private:
|
||||
|
||||
uint32_t sizeGxsWireGroupItem(RsGxsWireGroupItem *item);
|
||||
bool serialiseGxsWireGroupItem (RsGxsWireGroupItem *item, void *data, uint32_t *size);
|
||||
RsGxsWireGroupItem * deserialiseGxsWireGroupItem(void *data, uint32_t *size);
|
||||
|
||||
uint32_t sizeGxsWirePulseItem(RsGxsWirePulseItem *item);
|
||||
bool serialiseGxsWirePulseItem (RsGxsWirePulseItem *item, void *data, uint32_t *size);
|
||||
RsGxsWirePulseItem * deserialiseGxsWirePulseItem(void *data, uint32_t *size);
|
||||
virtual RsItem *create_item(uint16_t service,uint8_t item_subtype) const ;
|
||||
};
|
||||
|
||||
#endif /* RS_WIKI_ITEMS_H */
|
||||
|
Loading…
Reference in New Issue
Block a user