mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-22 13:24:26 -04:00
Fixed up a couple of serialiser bugs.
- service_type is 16bit. - missing return statement. - added a bit more debugging too. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@6189 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
eeeb50d23c
commit
c2150768db
3 changed files with 32 additions and 6 deletions
|
@ -34,6 +34,10 @@
|
||||||
|
|
||||||
uint32_t RsGxsChannelSerialiser::size(RsItem *item)
|
uint32_t RsGxsChannelSerialiser::size(RsItem *item)
|
||||||
{
|
{
|
||||||
|
#ifdef GXSCHANNEL_DEBUG
|
||||||
|
std::cerr << "RsGxsChannelSerialiser::size()" << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
RsGxsChannelGroupItem* grp_item = NULL;
|
RsGxsChannelGroupItem* grp_item = NULL;
|
||||||
RsGxsChannelPostItem* op_item = NULL;
|
RsGxsChannelPostItem* op_item = NULL;
|
||||||
|
|
||||||
|
@ -47,13 +51,17 @@ uint32_t RsGxsChannelSerialiser::size(RsItem *item)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
RsGxsCommentSerialiser::size(item);
|
return RsGxsCommentSerialiser::size(item);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RsGxsChannelSerialiser::serialise(RsItem *item, void *data, uint32_t *size)
|
bool RsGxsChannelSerialiser::serialise(RsItem *item, void *data, uint32_t *size)
|
||||||
{
|
{
|
||||||
|
#ifdef GXSCHANNEL_DEBUG
|
||||||
|
std::cerr << "RsGxsChannelSerialiser::serialise()" << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
RsGxsChannelGroupItem* grp_item = NULL;
|
RsGxsChannelGroupItem* grp_item = NULL;
|
||||||
RsGxsChannelPostItem* op_item = NULL;
|
RsGxsChannelPostItem* op_item = NULL;
|
||||||
|
|
||||||
|
@ -69,7 +77,6 @@ bool RsGxsChannelSerialiser::serialise(RsItem *item, void *data, uint32_t *size)
|
||||||
{
|
{
|
||||||
return RsGxsCommentSerialiser::serialise(item, data, size);
|
return RsGxsCommentSerialiser::serialise(item, data, size);
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RsItem* RsGxsChannelSerialiser::deserialise(void* data, uint32_t* size)
|
RsItem* RsGxsChannelSerialiser::deserialise(void* data, uint32_t* size)
|
||||||
|
@ -84,6 +91,9 @@ RsItem* RsGxsChannelSerialiser::deserialise(void* data, uint32_t* size)
|
||||||
if ((RS_PKT_VERSION_SERVICE != getRsItemVersion(rstype)) ||
|
if ((RS_PKT_VERSION_SERVICE != getRsItemVersion(rstype)) ||
|
||||||
(RS_SERVICE_GXSV1_TYPE_CHANNELS != getRsItemService(rstype)))
|
(RS_SERVICE_GXSV1_TYPE_CHANNELS != getRsItemService(rstype)))
|
||||||
{
|
{
|
||||||
|
#ifdef GXSCHANNEL_DEBUG
|
||||||
|
std::cerr << "RsGxsChannelSerialiser::deserialise() ERROR Wrong Type" << std::endl;
|
||||||
|
#endif
|
||||||
return NULL; /* wrong type */
|
return NULL; /* wrong type */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -300,7 +310,7 @@ bool RsGxsChannelSerialiser::serialiseGxsChannelPostItem(RsGxsChannelPostItem *i
|
||||||
if(*size < tlvsize)
|
if(*size < tlvsize)
|
||||||
{
|
{
|
||||||
#ifdef GXSCHANNEL_DEBUG
|
#ifdef GXSCHANNEL_DEBUG
|
||||||
std::cerr << "RsGxsChannelSerialiser::serialiseGxsChannelPostItem()" << std::endl;
|
std::cerr << "RsGxsChannelSerialiser::serialiseGxsChannelPostItem() ERROR space too small" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,6 +34,10 @@
|
||||||
|
|
||||||
uint32_t RsGxsCommentSerialiser::size(RsItem *item)
|
uint32_t RsGxsCommentSerialiser::size(RsItem *item)
|
||||||
{
|
{
|
||||||
|
#ifdef GXSCOMMENT_DEBUG
|
||||||
|
std::cerr << "RsGxsCommentSerialiser::size()" << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
RsGxsCommentItem* com_item = NULL;
|
RsGxsCommentItem* com_item = NULL;
|
||||||
RsGxsVoteItem* vote_item = NULL;
|
RsGxsVoteItem* vote_item = NULL;
|
||||||
|
|
||||||
|
@ -51,6 +55,10 @@ uint32_t RsGxsCommentSerialiser::size(RsItem *item)
|
||||||
|
|
||||||
bool RsGxsCommentSerialiser::serialise(RsItem *item, void *data, uint32_t *size)
|
bool RsGxsCommentSerialiser::serialise(RsItem *item, void *data, uint32_t *size)
|
||||||
{
|
{
|
||||||
|
#ifdef GXSCOMMENT_DEBUG
|
||||||
|
std::cerr << "RsGxsCommentSerialiser::serialise()" << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
RsGxsCommentItem* com_item = NULL;
|
RsGxsCommentItem* com_item = NULL;
|
||||||
RsGxsVoteItem* vote_item = NULL;
|
RsGxsVoteItem* vote_item = NULL;
|
||||||
|
|
||||||
|
@ -78,6 +86,9 @@ RsItem* RsGxsCommentSerialiser::deserialise(void* data, uint32_t* size)
|
||||||
if ((RS_PKT_VERSION_SERVICE != getRsItemVersion(rstype)) ||
|
if ((RS_PKT_VERSION_SERVICE != getRsItemVersion(rstype)) ||
|
||||||
(getRsItemService(PacketId()) != getRsItemService(rstype)))
|
(getRsItemService(PacketId()) != getRsItemService(rstype)))
|
||||||
{
|
{
|
||||||
|
#ifdef GXSCOMMENT_DEBUG
|
||||||
|
std::cerr << "RsGxsCommentSerialiser::deserialise() ERROR Wrong Type" << std::endl;
|
||||||
|
#endif
|
||||||
return NULL; /* wrong type */
|
return NULL; /* wrong type */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -134,6 +145,10 @@ uint32_t RsGxsCommentSerialiser::sizeGxsCommentItem(RsGxsCommentItem *item)
|
||||||
|
|
||||||
s += GetTlvStringSize(msg.mComment); // mMsg.
|
s += GetTlvStringSize(msg.mComment); // mMsg.
|
||||||
|
|
||||||
|
#ifdef GXSCOMMENT_DEBUG
|
||||||
|
std::cerr << "RsGxsCommentSerialiser::sizeGxsCommentItem() is: " << s << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -150,8 +165,9 @@ bool RsGxsCommentSerialiser::serialiseGxsCommentItem(RsGxsCommentItem *item, voi
|
||||||
if(*size < tlvsize)
|
if(*size < tlvsize)
|
||||||
{
|
{
|
||||||
#ifdef GXSCOMMENT_DEBUG
|
#ifdef GXSCOMMENT_DEBUG
|
||||||
std::cerr << "RsGxsCommentSerialiser::serialiseGxsCommentItem()" << std::endl;
|
std::cerr << "RsGxsCommentSerialiser::serialiseGxsCommentItem() Failed size too small" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,7 @@ class RsGxsCommentItem : public RsGxsMsgItem
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
RsGxsCommentItem(uint8_t service_type): RsGxsMsgItem(service_type,
|
RsGxsCommentItem(uint16_t service_type): RsGxsMsgItem(service_type,
|
||||||
RS_PKT_SUBTYPE_GXSCOMMENT_COMMENT_ITEM) {return; }
|
RS_PKT_SUBTYPE_GXSCOMMENT_COMMENT_ITEM) {return; }
|
||||||
virtual ~RsGxsCommentItem() { return;}
|
virtual ~RsGxsCommentItem() { return;}
|
||||||
void clear();
|
void clear();
|
||||||
|
@ -57,7 +57,7 @@ class RsGxsVoteItem : public RsGxsMsgItem
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
RsGxsVoteItem(uint8_t service_type): RsGxsMsgItem(service_type,
|
RsGxsVoteItem(uint16_t service_type): RsGxsMsgItem(service_type,
|
||||||
RS_PKT_SUBTYPE_GXSCOMMENT_VOTE_ITEM) {return; }
|
RS_PKT_SUBTYPE_GXSCOMMENT_VOTE_ITEM) {return; }
|
||||||
virtual ~RsGxsVoteItem() { return;}
|
virtual ~RsGxsVoteItem() { return;}
|
||||||
void clear();
|
void clear();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue