mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-02 14:16:16 -04:00
Port GxsTrans to new serialization system
RsItem added some comment and more verbose error reporting RsTypeSerializer added support for RsItem derived classes as members added utility macros for better readability of the code and easier handling of RsItem derived members RS_REGISTER_SERIAL_MEMBER(I) RS_REGISTER_SERIAL_MEMBER_TYPED(I, T) RS_REGISTER_ITEM_TYPE(T) RsNxsMsg::serial_process use new macros for better readability and to have an exemple of usage with RsTlvItem derived class Fix undefined reference to RsNxsMsg::print
This commit is contained in:
parent
f7f36f697e
commit
ea8f800003
11 changed files with 655 additions and 728 deletions
|
@ -346,9 +346,9 @@ bool p3ChatService::sendChat(ChatId destination, std::string msg)
|
|||
if(it != mDistantGxsMap.end())
|
||||
{
|
||||
const DistantEndpoints& de(it->second);
|
||||
uint32_t sz = ci->serial_size();
|
||||
uint32_t sz = _serializer->size(ci);
|
||||
std::vector<uint8_t> data; data.resize(sz);
|
||||
ci->serialise(&data[0], sz);
|
||||
_serializer->serialise(ci, &data[0], &sz);
|
||||
mGxsTransport.sendMail(tId, GxsTransSubServices::P3_CHAT_SERVICE,
|
||||
de.from, de.to, &data[0], sz);
|
||||
}
|
||||
|
@ -717,8 +717,9 @@ bool p3ChatService::receiveGxsTransMail( const RsGxsId& authorId,
|
|||
if(initiateDistantChatConnexion(
|
||||
authorId, recipientId, pid, error_code, false ))
|
||||
{
|
||||
RsChatMsgItem* item = new RsChatMsgItem( const_cast<uint8_t*>(data),
|
||||
dataSize );
|
||||
RsChatMsgItem* item = static_cast<RsChatMsgItem*>(
|
||||
_serializer->deserialise(
|
||||
const_cast<uint8_t*>(data), &dataSize ));
|
||||
RsPeerId rd(p3GxsTunnelService::makeGxsTunnelId(authorId, recipientId));
|
||||
item->PeerId(rd);
|
||||
handleRecvChatMsgItem(item);
|
||||
|
|
|
@ -195,4 +195,11 @@ void RsPrivateChatMsgConfigItem::get(RsChatMsgItem *ci)
|
|||
ci->recvTime = recvTime;
|
||||
}
|
||||
|
||||
/* Necessary to serialize `store` that is an STL container with RsChatMsgItem
|
||||
* inside which is a subtype of RsItem */
|
||||
RS_REGISTER_ITEM_TYPE(RsChatMsgItem)
|
||||
|
||||
void PrivateOugoingMapItem::serial_process(
|
||||
RsGenericSerializer::SerializeJob j,
|
||||
RsGenericSerializer::SerializeContext& ctx )
|
||||
{ RS_REGISTER_SERIAL_MEMBER(store); }
|
||||
|
|
|
@ -325,6 +325,17 @@ class RsChatAvatarItem: public RsChatItem
|
|||
unsigned char *image_data ; // image
|
||||
};
|
||||
|
||||
|
||||
struct PrivateOugoingMapItem : RsChatItem
|
||||
{
|
||||
PrivateOugoingMapItem() : RsChatItem(RS_PKT_SUBTYPE_OUTGOING_MAP) {}
|
||||
|
||||
void serial_process( RsGenericSerializer::SerializeJob j,
|
||||
RsGenericSerializer::SerializeContext& ctx );
|
||||
|
||||
std::map<uint64_t, RsChatMsgItem> store;
|
||||
};
|
||||
|
||||
struct RsChatSerialiser : RsServiceSerializer
|
||||
{
|
||||
RsChatSerialiser(SerializationFlags flags = SERIALIZATION_FLAG_NONE) :
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue