mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-24 22:30:42 -04:00
fixed serialization of posts with images
fix by cyril
This commit is contained in:
parent
019233e840
commit
c7e4986710
2 changed files with 22 additions and 10 deletions
|
@ -28,6 +28,17 @@ void RsGxsPostedPostItem::serial_process(RsGenericSerializer::SerializeJob j,RsG
|
||||||
{
|
{
|
||||||
RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_STR_LINK,mPost.mLink,"mPost.mLink") ;
|
RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_STR_LINK,mPost.mLink,"mPost.mLink") ;
|
||||||
RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_STR_MSG ,mPost.mNotes,"mPost.mNotes") ;
|
RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_STR_MSG ,mPost.mNotes,"mPost.mNotes") ;
|
||||||
|
|
||||||
|
// Do not serialize mImage member if it is empty (keeps compatibility of new posts without image toward older RS)
|
||||||
|
// and do not expect to deserialize mImage member if the data block has been consummed entirely (keeps compatibility
|
||||||
|
// of new RS with older posts.
|
||||||
|
|
||||||
|
if(j == RsGenericSerializer::DESERIALIZE && ctx.mOffset == ctx.mSize)
|
||||||
|
return ;
|
||||||
|
|
||||||
|
if((j == RsGenericSerializer::SIZE_ESTIMATE || j == RsGenericSerializer::SERIALIZE) && mImage.empty())
|
||||||
|
return ;
|
||||||
|
|
||||||
RsTypeSerializer::serial_process<RsTlvItem>(j,ctx,mImage,"mImage") ;
|
RsTypeSerializer::serial_process<RsTlvItem>(j,ctx,mImage,"mImage") ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,18 +33,19 @@
|
||||||
|
|
||||||
class RsTlvImage: public RsTlvItem
|
class RsTlvImage: public RsTlvItem
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
RsTlvImage();
|
RsTlvImage();
|
||||||
RsTlvImage(const RsTlvImage& );
|
RsTlvImage(const RsTlvImage& );
|
||||||
virtual ~RsTlvImage() { return; }
|
virtual ~RsTlvImage() { return; }
|
||||||
virtual uint32_t TlvSize() const;
|
virtual uint32_t TlvSize() const;
|
||||||
virtual void TlvClear();
|
virtual void TlvClear();
|
||||||
virtual bool SetTlv(void *data, uint32_t size, uint32_t *offset) const;
|
virtual bool SetTlv(void *data, uint32_t size, uint32_t *offset) const;
|
||||||
virtual bool GetTlv(void *data, uint32_t size, uint32_t *offset);
|
virtual bool GetTlv(void *data, uint32_t size, uint32_t *offset);
|
||||||
|
|
||||||
virtual std::ostream &print(std::ostream &out, uint16_t indent) const;
|
bool empty() const { return binData.bin_len == 0 ; }
|
||||||
|
virtual std::ostream &print(std::ostream &out, uint16_t indent) const;
|
||||||
|
|
||||||
uint32_t image_type; // Mandatory:
|
uint32_t image_type; // Mandatory:
|
||||||
RsTlvBinaryData binData; // Mandatory: serialised file info
|
RsTlvBinaryData binData; // Mandatory: serialised file info
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue