mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-07-25 07:25:36 -04:00
Added attach picture for posted links
This commit is contained in:
parent
d63655c9b6
commit
7cf17569c5
18 changed files with 993 additions and 363 deletions
|
@ -22,15 +22,18 @@
|
|||
#include "rsitems/rsposteditems.h"
|
||||
#include "serialiser/rstypeserializer.h"
|
||||
|
||||
|
||||
|
||||
void RsGxsPostedPostItem::serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx)
|
||||
{
|
||||
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<RsTlvItem>(j,ctx,mImage,"mImage") ;
|
||||
}
|
||||
|
||||
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 ,mGroup.mDescription,"mGroup.mDescription") ;
|
||||
}
|
||||
|
||||
RsItem *RsGxsPostedSerialiser::create_item(uint16_t service_id,uint8_t item_subtype) const
|
||||
|
@ -47,12 +50,54 @@ RsItem *RsGxsPostedSerialiser::create_item(uint16_t service_id,uint8_t item_subt
|
|||
}
|
||||
}
|
||||
|
||||
bool RsGxsPostedPostItem::fromPostedPost(RsPostedPost &post, bool moveImage)
|
||||
{
|
||||
clear();
|
||||
|
||||
mPost = post;
|
||||
meta = post.mMeta;
|
||||
|
||||
if (moveImage)
|
||||
{
|
||||
mImage.binData.bin_data = post.mImage.mData;
|
||||
mImage.binData.bin_len = post.mImage.mSize;
|
||||
post.mImage.shallowClear();
|
||||
}
|
||||
else
|
||||
{
|
||||
mImage.binData.setBinData(post.mImage.mData, post.mImage.mSize);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RsGxsPostedPostItem::toPostedPost(RsPostedPost &post, bool moveImage)
|
||||
{
|
||||
post = mPost;
|
||||
post.mMeta = meta;
|
||||
|
||||
if (moveImage)
|
||||
{
|
||||
post.mImage.take((uint8_t *) mImage.binData.bin_data, mImage.binData.bin_len);
|
||||
// mImage doesn't have a ShallowClear at the moment!
|
||||
mImage.binData.TlvShallowClear();
|
||||
}
|
||||
else
|
||||
{
|
||||
post.mImage.copy((uint8_t *) mImage.binData.bin_data, mImage.binData.bin_len);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void RsGxsPostedPostItem::clear()
|
||||
{
|
||||
mPost.mLink.clear();
|
||||
mPost.mNotes.clear();
|
||||
mImage.TlvClear();
|
||||
}
|
||||
void RsGxsPostedGroupItem::clear()
|
||||
{
|
||||
mGroup.mDescription.clear();
|
||||
}
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include "rsitems/rsserviceids.h"
|
||||
#include "rsitems/rsgxscommentitems.h"
|
||||
#include "rsitems/rsgxsitems.h"
|
||||
#include "serialiser/rstlvimage.h"
|
||||
|
||||
#include "retroshare/rsposted.h"
|
||||
|
||||
|
@ -38,9 +39,12 @@ public:
|
|||
virtual ~RsGxsPostedGroupItem() {}
|
||||
|
||||
void clear();
|
||||
|
||||
virtual void serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx);
|
||||
|
||||
|
||||
RsPostedGroup mGroup;
|
||||
|
||||
|
||||
};
|
||||
|
||||
class RsGxsPostedPostItem : public RsGxsMsgItem
|
||||
|
@ -51,8 +55,14 @@ public:
|
|||
|
||||
void clear();
|
||||
virtual void serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx);
|
||||
|
||||
// Slightly unusual structure.
|
||||
// use conversion functions to transform:
|
||||
bool fromPostedPost(RsPostedPost &post, bool moveImage);
|
||||
bool toPostedPost(RsPostedPost &post, bool moveImage);
|
||||
|
||||
RsPostedPost mPost;
|
||||
RsTlvImage mImage;
|
||||
};
|
||||
|
||||
class RsGxsPostedSerialiser : public RsGxsCommentSerialiser
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue