fixed merge with upstream

This commit is contained in:
csoler 2018-06-22 23:38:31 +02:00
commit 5b9666855d
No known key found for this signature in database
GPG key ID: 7BCA522266C0804C
241 changed files with 20561 additions and 3381 deletions

View file

@ -48,8 +48,8 @@ void RsBanListItem::serial_process(RsGenericSerializer::SerializeJob j,RsGeneric
void RsBanListConfigItem::serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx)
{
RsTypeSerializer::serial_process<uint32_t>(j,ctx,type,"type") ;
RsTypeSerializer::serial_process (j,ctx,peerId,"peerId") ;
RsTypeSerializer::serial_process<uint32_t>(j,ctx,banListType,"type") ;
RsTypeSerializer::serial_process (j,ctx,banListPeerId,"peerId") ;
RsTypeSerializer::serial_process<time_t> (j,ctx,update_time,"update_time") ;
RsTypeSerializer::serial_process (j,ctx,banned_peers,"banned_peers") ;
}

View file

@ -60,18 +60,20 @@ class RsBanListItem: public RsItem
class RsBanListConfigItem: public RsItem
{
public:
RsBanListConfigItem()
:RsItem(RS_PKT_VERSION_SERVICE, RS_SERVICE_TYPE_BANLIST, RS_PKT_SUBTYPE_BANLIST_CONFIG_ITEM) {}
RsBanListConfigItem()
: RsItem(RS_PKT_VERSION_SERVICE, RS_SERVICE_TYPE_BANLIST, RS_PKT_SUBTYPE_BANLIST_CONFIG_ITEM)
, banListType(0), update_time(0)
{}
virtual ~RsBanListConfigItem(){}
virtual void clear() { banned_peers.TlvClear() ; }
virtual ~RsBanListConfigItem(){}
virtual void clear() { banned_peers.TlvClear() ; }
void serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx);
uint32_t type ;
RsPeerId peerId ;
time_t update_time ;
RsTlvBanList banned_peers;
uint32_t banListType ;
RsPeerId banListPeerId ;
time_t update_time ;
RsTlvBanList banned_peers;
};
class RsBanListSerialiser: public RsServiceSerializer

View file

@ -28,6 +28,7 @@
#include "rsitems/rsconfigitems.h"
#include "retroshare/rspeers.h" // Needed for RsGroupInfo.
#include "serialiser/rsserializable.h"
#include "serialiser/rstypeserializer.h"
/***
* #define RSSERIAL_DEBUG 1
@ -89,7 +90,7 @@ void RsFileTransfer::serial_process(RsGenericSerializer::SerializeJob j,RsGeneri
RsTypeSerializer::serial_process<uint32_t> (j,ctx,flags,"flags") ;
RsTypeSerializer::serial_process<uint32_t> (j,ctx,chunk_strategy,"chunk_strategy") ;
RsTypeSerializer::serial_process (j,ctx,compressed_chunk_map,"compressed_chunk_map") ;
RS_SERIAL_PROCESS(compressed_chunk_map);
}
void RsFileConfigItem::serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx)
@ -136,9 +137,9 @@ RsItem *RsPeerConfigSerialiser::create_item(uint8_t item_type,uint8_t item_subty
void RsPeerNetItem::clear()
{
peerId.clear();
pgpId.clear();
location.clear();
nodePeerId.clear();
pgpId.clear();
location.clear();
netMode = 0;
vs_disc = 0;
vs_dht = 0;
@ -159,7 +160,7 @@ void RsPeerNetItem::clear()
}
void RsPeerNetItem::serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx)
{
RsTypeSerializer::serial_process(j,ctx,peerId,"peerId") ;
RsTypeSerializer::serial_process(j,ctx,nodePeerId,"peerId") ;
RsTypeSerializer::serial_process(j,ctx,pgpId,"pgpId") ;
RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_STR_LOCATION,location,"location") ;
@ -192,31 +193,6 @@ void RsPeerStunItem::serial_process(RsGenericSerializer::SerializeJob j,RsGeneri
RsTypeSerializer::serial_process<RsTlvItem>(j,ctx,stunList,"stunList") ;
}
template<> uint32_t RsTypeSerializer::serial_size(const PeerBandwidthLimits& /*s*/)
{
return 4+4 ;
}
template<> bool RsTypeSerializer::serialize(uint8_t data[], uint32_t size, uint32_t &offset,const PeerBandwidthLimits& s)
{
bool ok = true ;
ok = ok && setRawUInt32(data,size,&offset,s.max_up_rate_kbs);
ok = ok && setRawUInt32(data,size,&offset,s.max_dl_rate_kbs);
return ok;
}
template<> bool RsTypeSerializer::deserialize(const uint8_t data[], uint32_t size,uint32_t& offset,PeerBandwidthLimits& s)
{
bool ok = true ;
ok = ok && getRawUInt32(data,size,&offset,&s.max_up_rate_kbs);
ok = ok && getRawUInt32(data,size,&offset,&s.max_dl_rate_kbs);
return ok;
}
template<> void RsTypeSerializer::print_data(const std::string& /*n*/, const PeerBandwidthLimits& s)
{
std::cerr << " [Peer BW limit] " << s.max_up_rate_kbs << " / " << s.max_dl_rate_kbs << std::endl;
}
RsNodeGroupItem::RsNodeGroupItem(const RsGroupInfo& g)
:RsItem(RS_PKT_VERSION1, RS_PKT_CLASS_CONFIG, RS_PKT_TYPE_PEER_CONFIG, RS_PKT_SUBTYPE_NODE_GROUP)

View file

@ -84,7 +84,7 @@ public:
virtual void serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx);
/* networking information */
RsPeerId peerId; /* Mandatory */
RsPeerId nodePeerId; /* Mandatory */
RsPgpId pgpId; /* Mandatory */
std::string location; /* Mandatory */
uint32_t netMode; /* Mandatory */

View file

@ -91,48 +91,6 @@ void RsFileTransferSingleChunkCrcItem::serial_process(RsGenericSerializer::Seria
RsTypeSerializer::serial_process (j,ctx,check_sum, "check_sum") ;
}
//===================================================================================================//
// CompressedChunkMap //
//===================================================================================================//
template<> uint32_t RsTypeSerializer::serial_size(const CompressedChunkMap& s)
{
return 4 + 4*s._map.size() ;
}
template<> bool RsTypeSerializer::serialize(uint8_t data[], uint32_t size, uint32_t &offset,const CompressedChunkMap& s)
{
bool ok = true ;
ok &= setRawUInt32(data, size, &offset, s._map.size());
for(uint32_t i=0;i<s._map.size() && ok;++i)
ok &= setRawUInt32(data, size, &offset, s._map[i]);
return ok;
}
template<> bool RsTypeSerializer::deserialize(const uint8_t data[], uint32_t size,uint32_t& offset,CompressedChunkMap& s)
{
uint32_t S =0;
bool ok = getRawUInt32(data, size, &offset, &S);
if(ok)
{
s._map.resize(S) ;
for(uint32_t i=0;i<S && ok;++i)
ok &= getRawUInt32(data, size, &offset, &(s._map[i]));
}
return ok;
}
template<> void RsTypeSerializer::print_data(const std::string& n, const CompressedChunkMap& s)
{
std::cerr << " [Compressed chunk map] " << n << " : length=" << s._map.size() << std::endl;
}
//===================================================================================================//
// Serializer //
//===================================================================================================//

View file

@ -127,3 +127,7 @@ void RsTurtleGxsSearchResultGroupDataItem::serial_process(RsGenericSerializer::S
RsTypeSerializer::TlvMemBlock_proxy prox(encrypted_nxs_group_data,encrypted_nxs_group_data_len) ;
RsTypeSerializer::serial_process(j,ctx,prox,"encrypted_nxs_data") ;
}
RS_TYPE_SERIALIZER_FROM_JSON_NOT_IMPLEMENTED_DEF(TurtleGxsInfo)
RS_TYPE_SERIALIZER_TO_JSON_NOT_IMPLEMENTED_DEF(TurtleGxsInfo)

View file

@ -28,19 +28,12 @@
#if 0
#include <map>
#include "rsitems/rsserviceids.h"
#include "serialiser/rsserial.h"
#include "serialiser/rstlvbase.h"
#include "serialiser/rstlvtypes.h"
#include "serialiser/rstlvkeys.h"
#endif
#include "gxs/rsgxs.h"
#include "gxs/rsgxsdata.h"
#include "gxs/rsgxsnettunnel.h"
#include "serialiser/rstlvidset.h"
#include "serialiser/rstypeserializer.h"
#include "serialiser/rsserializable.h"
const uint8_t RS_PKT_SUBTYPE_GXS_GRP_UPDATE = 0x01;
@ -142,17 +135,26 @@ public:
class RsGxsMsgUpdate
{
public:
struct MsgUpdateInfo
struct MsgUpdateInfo : RsSerializable
{
MsgUpdateInfo(): time_stamp(0), message_count(0) {}
uint32_t time_stamp ;
uint32_t message_count ;
/// @see RsSerializable
void serial_process(RsGenericSerializer::SerializeJob j,
RsGenericSerializer::SerializeContext& ctx)
{
RS_SERIAL_PROCESS(time_stamp);
RS_SERIAL_PROCESS(message_count);
}
};
std::map<RsGxsGroupId, MsgUpdateInfo> msgUpdateInfos;
};
class RsGxsMsgUpdateItem : public RsGxsNetServiceItem, public RsGxsMsgUpdate
{
public:

View file

@ -44,7 +44,7 @@ void RsHistoryMsgItem::serial_process(RsGenericSerializer::SerializeJob j,RsGene
RsTypeSerializer::serial_process<uint16_t>(j,ctx,version,"version") ;
RsTypeSerializer::serial_process (j,ctx,chatPeerId,"chatPeerId") ;
RsTypeSerializer::serial_process<bool> (j,ctx,incoming,"incoming") ;
RsTypeSerializer::serial_process (j,ctx,peerId,"peerId") ;
RsTypeSerializer::serial_process (j,ctx,msgPeerId,"peerId") ;
RsTypeSerializer::serial_process (j,ctx,TLV_TYPE_STR_NAME,peerName,"peerName") ;
RsTypeSerializer::serial_process<uint32_t>(j,ctx,sendTime,"sendTime") ;
RsTypeSerializer::serial_process<uint32_t>(j,ctx,recvTime,"recvTime") ;

View file

@ -46,7 +46,7 @@ public:
RsPeerId chatPeerId; // empty for global chat
bool incoming;
RsPeerId peerId;
RsPeerId msgPeerId;
std::string peerName;
uint32_t sendTime;
uint32_t recvTime;

View file

@ -1,76 +1,96 @@
#pragma once
/*
* RetroShare Serialiser.
* Copyright (C) 2018 Gioacchino Mazzurco <gio@eigenlab.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <typeinfo> // for typeid
#include "util/smallobject.h"
#include "retroshare/rstypes.h"
#include "serialiser/rsserializer.h"
#include "serialiser/rsserializable.h"
#include "util/stacktrace.h"
#include <typeinfo>
class RsItem: public RsMemoryManagement::SmallObject
struct RsItem : RsMemoryManagement::SmallObject, RsSerializable
{
public:
explicit RsItem(uint32_t t);
RsItem(uint8_t ver, uint8_t cls, uint8_t t, uint8_t subtype);
explicit RsItem(uint32_t t);
RsItem(uint8_t ver, uint8_t cls, uint8_t t, uint8_t subtype);
#ifdef DO_STATISTICS
void *operator new(size_t s) ;
void operator delete(void *,size_t s) ;
void *operator new(size_t s) ;
void operator delete(void *,size_t s) ;
#endif
virtual ~RsItem();
virtual ~RsItem();
/// TODO: Do this make sense with the new serialization system?
virtual void clear() = 0;
/// TODO: Do this make sense with the new serialization system?
virtual void clear() = 0;
virtual std::ostream &print(std::ostream &out, uint16_t /* indent */ = 0)
{
RsGenericSerializer::SerializeContext ctx(NULL,0,RsGenericSerializer::FORMAT_BINARY,RsGenericSerializer::SERIALIZATION_FLAG_NONE);
serial_process(RsGenericSerializer::PRINT,ctx) ;
return out;
}
virtual std::ostream &print(std::ostream &out, uint16_t /* indent */ = 0)
{
RsGenericSerializer::SerializeContext ctx(
NULL, 0, RsGenericSerializer::FORMAT_BINARY,
RsGenericSerializer::SERIALIZATION_FLAG_NONE );
serial_process(RsGenericSerializer::PRINT,ctx);
return out;
}
void print_string(std::string &out, uint16_t indent = 0);
void print_string(std::string &out, uint16_t indent = 0);
/* source / destination id */
const RsPeerId& PeerId() const { return peerId; }
void PeerId(const RsPeerId& id) { peerId = id; }
/// source / destination id
const RsPeerId& PeerId() const { return peerId; }
void PeerId(const RsPeerId& id) { peerId = id; }
/* complete id */
uint32_t PacketId() const;
/// complete id
uint32_t PacketId() const;
/* id parts */
uint8_t PacketVersion();
uint8_t PacketClass();
uint8_t PacketType();
uint8_t PacketSubType() const;
/// id parts
uint8_t PacketVersion();
uint8_t PacketClass();
uint8_t PacketType();
uint8_t PacketSubType() const;
/* For Service Packets */
RsItem(uint8_t ver, uint16_t service, uint8_t subtype);
uint16_t PacketService() const; /* combined Packet class/type (mid 16bits) */
void setPacketService(uint16_t service);
/// For Service Packets
RsItem(uint8_t ver, uint16_t service, uint8_t subtype);
uint16_t PacketService() const; /* combined Packet class/type (mid 16bits) */
void setPacketService(uint16_t service);
inline uint8_t priority_level() const { return _priority_level ;}
inline void setPriorityLevel(uint8_t l) { _priority_level = l ;}
inline uint8_t priority_level() const { return _priority_level ;}
inline void setPriorityLevel(uint8_t l) { _priority_level = l ;}
/**
* TODO: This should be made pure virtual as soon as all the codebase
* is ported to the new serialization system
*/
virtual void serial_process(RsGenericSerializer::SerializeJob,
RsGenericSerializer::SerializeContext&)// = 0;
{
std::cerr << "(EE) RsItem::serial_process() called by an item using"
<< "new serialization classes, but not derived! Class is "
<< typeid(*this).name() << std::endl;
print_stacktrace();
}
/**
* TODO: This default implementation should be removed and childs structs
* implement ::serial_process(...) as soon as all the codebase is ported to
* the new serialization system
*/
virtual void serial_process(RsGenericSerializer::SerializeJob,
RsGenericSerializer::SerializeContext&)// = 0;
{
std::cerr << "(EE) RsItem::serial_process(...) called by an item using"
<< "new serialization classes, but not derived! Class is "
<< typeid(*this).name() << std::endl;
print_stacktrace();
}
protected:
uint32_t type;
RsPeerId peerId;
uint8_t _priority_level ;
protected:
uint32_t type;
RsPeerId peerId;
uint8_t _priority_level;
};
/// TODO: Do this make sense with the new serialization system?

View file

@ -73,12 +73,12 @@ void RsNxsSyncMsgItem::serial_process(RsGenericSerializer::SerializeJob j,RsGene
void RsNxsMsg::serial_process( RsGenericSerializer::SerializeJob j,
RsGenericSerializer::SerializeContext& ctx )
{
RS_REGISTER_SERIAL_MEMBER_TYPED(transactionNumber, uint32_t);
RS_REGISTER_SERIAL_MEMBER_TYPED(pos, uint8_t);
RS_REGISTER_SERIAL_MEMBER(msgId);
RS_REGISTER_SERIAL_MEMBER(grpId);
RS_REGISTER_SERIAL_MEMBER_TYPED(msg, RsTlvItem);
RS_REGISTER_SERIAL_MEMBER_TYPED(meta, RsTlvItem);
RS_SERIAL_PROCESS(transactionNumber);
RS_SERIAL_PROCESS(pos);
RS_SERIAL_PROCESS(msgId);
RS_SERIAL_PROCESS(grpId);
RS_SERIAL_PROCESS(msg);
RS_SERIAL_PROCESS(meta);
}
void RsNxsGrp::serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx)

View file

@ -61,24 +61,23 @@ void RsGxsPhotoAlbumItem::serial_process(RsGenericSerializer::SerializeJob j,RsG
RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_STR_LOCATION, album.mWhere, "mWhere");
RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_STR_PIC_TYPE, album.mThumbnail.type,"mThumbnail.type");
RsTlvBinaryDataRef b(RS_SERVICE_GXS_TYPE_PHOTO, album.mThumbnail.data,album.mThumbnail.size);
RsTypeSerializer::serial_process<RsTlvItem>(j,ctx,b,"thumbnail binary data") ;
RsTlvBinaryDataRef b(RS_SERVICE_GXS_TYPE_PHOTO, album.mThumbnail.data, album.mThumbnail.size);
RsTypeSerializer::serial_process<RsTlvItem>(j, ctx, b, "thumbnail binary data") ;
}
void RsGxsPhotoPhotoItem::serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx)
{
RsTypeSerializer::serial_process(j,ctx, TLV_TYPE_STR_CAPTION, photo.mCaption);
RsTypeSerializer::serial_process(j,ctx, TLV_TYPE_STR_CATEGORY, photo.mCategory);
RsTypeSerializer::serial_process(j,ctx, TLV_TYPE_STR_DESCR, photo.mDescription);
RsTypeSerializer::serial_process(j,ctx, TLV_TYPE_STR_HASH_TAG, photo.mHashTags);
RsTypeSerializer::serial_process(j,ctx, TLV_TYPE_STR_MSG, photo.mOther);
RsTypeSerializer::serial_process(j,ctx, TLV_TYPE_STR_PIC_AUTH, photo.mPhotographer);
RsTypeSerializer::serial_process(j,ctx, TLV_TYPE_STR_DATE, photo.mWhen);
RsTypeSerializer::serial_process(j,ctx, TLV_TYPE_STR_LOCATION, photo.mWhere);
RsTypeSerializer::serial_process(j,ctx, TLV_TYPE_STR_PIC_TYPE, photo.mThumbnail.type);
RsTypeSerializer::serial_process(j, ctx, TLV_TYPE_STR_CAPTION, photo.mCaption, "mCaption");
RsTypeSerializer::serial_process(j, ctx, TLV_TYPE_STR_CATEGORY, photo.mCategory, "mCategory");
RsTypeSerializer::serial_process(j, ctx, TLV_TYPE_STR_DESCR, photo.mDescription, "mDescription");
RsTypeSerializer::serial_process(j, ctx, TLV_TYPE_STR_HASH_TAG, photo.mHashTags, "mHashTags");
RsTypeSerializer::serial_process(j, ctx, TLV_TYPE_STR_MSG, photo.mOther, "mOther");
RsTypeSerializer::serial_process(j, ctx, TLV_TYPE_STR_PIC_AUTH, photo.mPhotographer, "mPhotographer");
RsTypeSerializer::serial_process(j, ctx, TLV_TYPE_STR_DATE, photo.mWhen, "mWhen");
RsTypeSerializer::serial_process(j, ctx, TLV_TYPE_STR_LOCATION, photo.mWhere, "mWhere");
RsTypeSerializer::serial_process(j, ctx, TLV_TYPE_STR_PIC_TYPE, photo.mThumbnail.type, "mThumbnail.type");
RsTlvBinaryDataRef b(RS_SERVICE_GXS_TYPE_PHOTO,photo.mThumbnail.data, photo.mThumbnail.size);
RsTypeSerializer::serial_process<RsTlvItem>(j,ctx, b, "mThumbnail") ;
RsTlvBinaryDataRef b(RS_SERVICE_GXS_TYPE_PHOTO, photo.mThumbnail.data, photo.mThumbnail.size);
RsTypeSerializer::serial_process<RsTlvItem>(j, ctx, b, "mThumbnail") ;
}
void RsGxsPhotoCommentItem::serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx)
{

View file

@ -50,7 +50,7 @@ public:
virtual ~RsGxsPhotoAlbumItem() { return;}
void clear();
std::ostream &print(std::ostream &out, uint16_t indent = 0);
// std::ostream &print(std::ostream &out, uint16_t indent = 0);
virtual void serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx);