mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-20 15:00:36 -04:00
Merge branch 'master' into deep_search
Needed to make deep search and GXS search cooperate
This commit is contained in:
commit
a31b06ab60
103 changed files with 5004 additions and 989 deletions
|
@ -6,6 +6,8 @@
|
|||
*/
|
||||
|
||||
|
||||
#include "serialiser/rstypeserializer.h"
|
||||
#include "serialiser/rsbaseserial.h"
|
||||
#include "rsgxsitems.h"
|
||||
#include "gxs/rsgxsdata.h"
|
||||
#include <iostream>
|
||||
|
@ -70,4 +72,62 @@ std::ostream &operator<<(std::ostream &out, const RsMsgMetaData &meta)
|
|||
return out;
|
||||
}
|
||||
|
||||
template<> uint32_t RsTypeSerializer::serial_size(const TurtleGxsInfo& i)
|
||||
{
|
||||
uint32_t s = 0 ;
|
||||
|
||||
s += 2 ; // service_id
|
||||
s += i.group_id.SIZE_IN_BYTES ;
|
||||
s += GetTlvStringSize(i.name) ;
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
template<> bool RsTypeSerializer::deserialize(const uint8_t data[],uint32_t size,uint32_t& offset,TurtleGxsInfo& i)
|
||||
{
|
||||
uint32_t saved_offset = offset ;
|
||||
bool ok = true ;
|
||||
|
||||
ok &= getRawUInt16(data, size, &offset, &i.service_id); // service_id
|
||||
ok &= i.group_id.deserialise(data, size, offset); // group_id
|
||||
ok &= GetTlvString(data, size, &offset, TLV_TYPE_STR_NAME, i.name); // group name
|
||||
|
||||
if(!ok)
|
||||
offset = saved_offset ;
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
template<> bool RsTypeSerializer::serialize(uint8_t data[],uint32_t size,uint32_t& offset,const TurtleGxsInfo& i)
|
||||
{
|
||||
uint32_t saved_offset = offset ;
|
||||
bool ok = true ;
|
||||
|
||||
ok &= setRawUInt16(data, size, &offset, i.service_id); // service_id
|
||||
ok &= i.group_id.serialise(data, size, offset); // group_id
|
||||
ok &= SetTlvString(data, size, &offset, TLV_TYPE_STR_NAME, i.name); // group name
|
||||
|
||||
if(!ok)
|
||||
offset = saved_offset ;
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
template<> void RsTypeSerializer::print_data(const std::string& n, const TurtleGxsInfo& i)
|
||||
{
|
||||
std::cerr << " [GXS Info ] " << n << " group_id=" << i.group_id << " service=" << std::hex << i.service_id << std::dec << ", name=" << i.name << std::endl;
|
||||
}
|
||||
|
||||
void RsTurtleGxsSearchResultGroupSummaryItem::serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx)
|
||||
{
|
||||
RsTypeSerializer::serial_process(j,ctx,result,"result") ;
|
||||
}
|
||||
void RsTurtleGxsSearchResultGroupDataItem::serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx)
|
||||
{
|
||||
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)
|
||||
|
||||
|
|
|
@ -57,6 +57,82 @@ public:
|
|||
RsMsgMetaData meta;
|
||||
};
|
||||
|
||||
// We should make these items templates or generic classes so that each GXS service will handle them on its own.
|
||||
|
||||
static const uint8_t RS_PKT_SUBTYPE_GXS_SUBSTRING_SEARCH_ITEM = 0x20 ;
|
||||
static const uint8_t RS_PKT_SUBTYPE_GXS_GROUP_SEARCH_ITEM = 0x21 ;
|
||||
static const uint8_t RS_PKT_SUBTYPE_GXS_GROUP_SUMMARY_ITEM = 0x22 ;
|
||||
static const uint8_t RS_PKT_SUBTYPE_GXS_GROUP_DATA_ITEM = 0x23 ;
|
||||
|
||||
class RsGxsTurtleSubStringSearchItem: public RsItem
|
||||
{
|
||||
public:
|
||||
RsGxsTurtleSubStringSearchItem(uint16_t service): RsItem(RS_PKT_VERSION_SERVICE,service,RS_PKT_SUBTYPE_GXS_SUBSTRING_SEARCH_ITEM) {}
|
||||
virtual ~RsGxsTurtleSubStringSearchItem() {}
|
||||
|
||||
std::string match_string ; // string to match
|
||||
|
||||
std::string GetKeywords() { return match_string; }
|
||||
void clear() { match_string.clear() ; }
|
||||
|
||||
protected:
|
||||
void serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx);
|
||||
};
|
||||
|
||||
class RsGxsTurtleGroupSearchItem: public RsItem
|
||||
{
|
||||
public:
|
||||
RsGxsTurtleGroupSearchItem(uint16_t service): RsItem(RS_PKT_VERSION_SERVICE,service,RS_PKT_SUBTYPE_GXS_GROUP_SEARCH_ITEM) {}
|
||||
virtual ~RsGxsTurtleGroupSearchItem() {}
|
||||
|
||||
uint16_t service_id ; // searvice to search
|
||||
Sha1CheckSum hashed_group_id ; // the group ID is hashed in order to keep it private.
|
||||
|
||||
std::string GetKeywords() { return std::string("Group request for [hashed] ")+hashed_group_id.toStdString() ; }
|
||||
void clear() { hashed_group_id.clear() ; }
|
||||
|
||||
protected:
|
||||
void serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx);
|
||||
};
|
||||
|
||||
struct TurtleGxsInfo
|
||||
{
|
||||
uint16_t service_id ;
|
||||
RsGxsGroupId group_id ;
|
||||
RsGxsId author;
|
||||
std::string name ;
|
||||
std::string description ;
|
||||
time_t last_post ;
|
||||
uint32_t number_of_posts ;
|
||||
};
|
||||
|
||||
class RsTurtleGxsSearchResultGroupSummaryItem: public RsItem
|
||||
{
|
||||
public:
|
||||
RsTurtleGxsSearchResultGroupSummaryItem(uint16_t service) : RsItem(RS_PKT_VERSION_SERVICE,service,RS_PKT_SUBTYPE_GXS_GROUP_SUMMARY_ITEM){}
|
||||
virtual ~RsTurtleGxsSearchResultGroupSummaryItem() {}
|
||||
|
||||
std::list<TurtleGxsInfo> result ;
|
||||
|
||||
void clear() { result.clear() ; }
|
||||
protected:
|
||||
void serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx);
|
||||
};
|
||||
|
||||
class RsTurtleGxsSearchResultGroupDataItem: public RsItem
|
||||
{
|
||||
public:
|
||||
RsTurtleGxsSearchResultGroupDataItem(uint16_t service) : RsItem(RS_PKT_VERSION_SERVICE,service,RS_PKT_SUBTYPE_GXS_GROUP_DATA_ITEM){}
|
||||
virtual ~RsTurtleGxsSearchResultGroupDataItem() {}
|
||||
|
||||
unsigned char *encrypted_nxs_group_data; // data is encrypted with group ID. Only the requester, or anyone who already know the group id can decrypt.
|
||||
uint32_t encrypted_nxs_group_data_len ;
|
||||
|
||||
void clear() { free(encrypted_nxs_group_data); encrypted_nxs_group_data=NULL; encrypted_nxs_group_data_len=0; }
|
||||
protected:
|
||||
void serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx);
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -97,6 +97,31 @@ void RsGxsMsgUpdateItem::serial_process(RsGenericSerializer::SerializeJob j,RsGe
|
|||
RsTypeSerializer::serial_process(j,ctx,msgUpdateInfos,"msgUpdateInfos");
|
||||
}
|
||||
|
||||
template<> bool RsTypeSerializer::serialize(uint8_t data[], uint32_t size, uint32_t &offset, const RsGxsMsgUpdateItem::MsgUpdateInfo& info)
|
||||
{
|
||||
bool ok = true ;
|
||||
|
||||
ok = ok && setRawUInt32(data,size,&offset,info.time_stamp);
|
||||
ok = ok && setRawUInt32(data,size,&offset,info.message_count);
|
||||
|
||||
return ok;
|
||||
}
|
||||
template<> bool RsTypeSerializer::deserialize(const uint8_t data[], uint32_t size, uint32_t &offset, RsGxsMsgUpdateItem::MsgUpdateInfo& info)
|
||||
{
|
||||
bool ok = true ;
|
||||
|
||||
ok = ok && getRawUInt32(data,size,&offset,&info.time_stamp);
|
||||
ok = ok && getRawUInt32(data,size,&offset,&info.message_count);
|
||||
|
||||
return ok;
|
||||
}
|
||||
template<> uint32_t RsTypeSerializer::serial_size(const RsGxsMsgUpdateItem::MsgUpdateInfo& /* info */) { return 8; }
|
||||
|
||||
template<> void RsTypeSerializer::print_data(const std::string& name,const RsGxsMsgUpdateItem::MsgUpdateInfo& info)
|
||||
{
|
||||
std::cerr << "[MsgUpdateInfo]: " << name << ": " << info.time_stamp << ", " << info.message_count << std::endl;
|
||||
}
|
||||
|
||||
void RsGxsServerMsgUpdateItem::serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx)
|
||||
{
|
||||
RsTypeSerializer::serial_process (j,ctx,grpId,"grpId");
|
||||
|
@ -109,3 +134,4 @@ void RsGxsGrpConfigItem::serial_process(RsGenericSerializer::SerializeJob j,RsGe
|
|||
RsTypeSerializer::serial_process<uint32_t>(j,ctx,msg_send_delay,"msg_send_delay") ;
|
||||
RsTypeSerializer::serial_process<uint32_t>(j,ctx,msg_req_delay,"msg_req_delay") ;
|
||||
}
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
|
||||
#include "gxs/rsgxs.h"
|
||||
#include "gxs/rsgxsdata.h"
|
||||
#include "gxs/rsgxsnettunnel.h"
|
||||
#include "serialiser/rstlvidset.h"
|
||||
#include "serialiser/rstypeserializer.h"
|
||||
#include "serialiser/rsserializable.h"
|
||||
|
@ -41,6 +42,7 @@ const uint8_t RS_PKT_SUBTYPE_GXS_MSG_UPDATE = 0x03;
|
|||
const uint8_t RS_PKT_SUBTYPE_GXS_SERVER_GRP_UPDATE = 0x04;
|
||||
const uint8_t RS_PKT_SUBTYPE_GXS_SERVER_MSG_UPDATE = 0x08;
|
||||
const uint8_t RS_PKT_SUBTYPE_GXS_GRP_CONFIG = 0x09;
|
||||
const uint8_t RS_PKT_SUBTYPE_GXS_RANDOM_BIAS = 0x0a;
|
||||
|
||||
class RsGxsNetServiceItem: public RsItem
|
||||
{
|
||||
|
@ -188,7 +190,6 @@ public:
|
|||
RsGxsGroupId grpId;
|
||||
};
|
||||
|
||||
|
||||
class RsGxsUpdateSerialiser : public RsServiceSerializer
|
||||
{
|
||||
public:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue