fixed serialization of posts with images

fix by cyril
This commit is contained in:
defnax 2019-03-19 23:23:49 +01:00
parent 019233e840
commit c7e4986710
2 changed files with 22 additions and 10 deletions

View File

@ -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_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") ;
}

View File

@ -33,18 +33,19 @@
class RsTlvImage: public RsTlvItem
{
public:
RsTlvImage();
RsTlvImage(const RsTlvImage& );
virtual ~RsTlvImage() { return; }
virtual uint32_t TlvSize() const;
virtual void TlvClear();
virtual bool SetTlv(void *data, uint32_t size, uint32_t *offset) const;
virtual bool GetTlv(void *data, uint32_t size, uint32_t *offset);
public:
RsTlvImage();
RsTlvImage(const RsTlvImage& );
virtual ~RsTlvImage() { return; }
virtual uint32_t TlvSize() const;
virtual void TlvClear();
virtual bool SetTlv(void *data, uint32_t size, uint32_t *offset) const;
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
};