Merge pull request #1502 from defnax/added-group-icons-for-posted-links

Added group icons for posted links
This commit is contained in:
csoler 2019-04-18 21:56:07 +02:00 committed by GitHub
commit bc8adb74c4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 690 additions and 328 deletions

View file

@ -44,7 +44,15 @@ void RsGxsPostedPostItem::serial_process(RsGenericSerializer::SerializeJob j,RsG
void RsGxsPostedGroupItem::serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx)
{
RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_STR_DESCR ,mGroup.mDescription,"mGroup.mDescription") ;
RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_STR_DESCR ,mDescription,"mDescription") ;
if(j == RsGenericSerializer::DESERIALIZE && ctx.mOffset == ctx.mSize)
return ;
if((j == RsGenericSerializer::SIZE_ESTIMATE || j == RsGenericSerializer::SERIALIZE) && mGroupImage.empty())
return ;
RsTypeSerializer::serial_process<RsTlvItem>(j,ctx,mGroupImage,"mGroupImage") ;
}
RsItem *RsGxsPostedSerialiser::create_item(uint16_t service_id,uint8_t item_subtype) const
@ -109,6 +117,42 @@ void RsGxsPostedPostItem::clear()
}
void RsGxsPostedGroupItem::clear()
{
mGroup.mDescription.clear();
mDescription.clear();
mGroupImage.TlvClear();
}
bool RsGxsPostedGroupItem::fromPostedGroup(RsPostedGroup &group, bool moveImage)
{
clear();
meta = group.mMeta;
mDescription = group.mDescription;
if (moveImage)
{
mGroupImage.binData.bin_data = group.mGroupImage.mData;
mGroupImage.binData.bin_len = group.mGroupImage.mSize;
group.mGroupImage.shallowClear();
}
else
{
mGroupImage.binData.setBinData(group.mGroupImage.mData, group.mGroupImage.mSize);
}
return true;
}
bool RsGxsPostedGroupItem::toPostedGroup(RsPostedGroup &group, bool moveImage)
{
group.mMeta = meta;
group.mDescription = mDescription;
if (moveImage)
{
group.mGroupImage.take((uint8_t *) mGroupImage.binData.bin_data, mGroupImage.binData.bin_len);
// mGroupImage doesn't have a ShallowClear at the moment!
mGroupImage.binData.TlvShallowClear();
}
else
{
group.mGroupImage.copy((uint8_t *) mGroupImage.binData.bin_data, mGroupImage.binData.bin_len);
}
return true;
}

View file

@ -42,8 +42,12 @@ public:
virtual void serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx);
RsPostedGroup mGroup;
// use conversion functions to transform:
bool fromPostedGroup(RsPostedGroup &group, bool moveImage);
bool toPostedGroup(RsPostedGroup &group, bool moveImage);
std::string mDescription;
RsTlvImage mGroupImage;
};