added classes for both group data and group summary results in turtle search

This commit is contained in:
csoler 2018-06-02 18:12:27 +02:00
parent 90d7f55c40
commit b5c1b8210b
No known key found for this signature in database
GPG Key ID: 7BCA522266C0804C
3 changed files with 89 additions and 17 deletions

View File

@ -158,7 +158,8 @@ void p3turtle::getItemNames(std::map<uint8_t,std::string>& names) const
names[RS_TURTLE_SUBTYPE_STRING_SEARCH_REQUEST ] = "Filename substring search request";
names[RS_TURTLE_SUBTYPE_GXS_SEARCH_REQUEST ] = "GXS search request";
names[RS_TURTLE_SUBTYPE_FT_SEARCH_RESULT ] = "File search result";
names[RS_TURTLE_SUBTYPE_GXS_SEARCH_RESULT ] = "GXS search result";
names[RS_TURTLE_SUBTYPE_GXS_GROUP_SUMMARY ] = "GXS group summary";
names[RS_TURTLE_SUBTYPE_GXS_GROUP_DATA ] = "GXS group data";
names[RS_TURTLE_SUBTYPE_OPEN_TUNNEL ] = "Tunnel request";
names[RS_TURTLE_SUBTYPE_TUNNEL_OK ] = "Tunnel response";
names[RS_TURTLE_SUBTYPE_FILE_REQUEST ] = "Data request";
@ -842,7 +843,8 @@ int p3turtle::handleIncoming()
case RS_TURTLE_SUBTYPE_REGEXP_SEARCH_REQUEST: handleSearchRequest(dynamic_cast<RsTurtleSearchRequestItem *>(item)) ;
break ;
case RS_TURTLE_SUBTYPE_GXS_SEARCH_RESULT :
case RS_TURTLE_SUBTYPE_GXS_GROUP_DATA :
case RS_TURTLE_SUBTYPE_GXS_GROUP_SUMMARY :
case RS_TURTLE_SUBTYPE_FT_SEARCH_RESULT : handleSearchResult(dynamic_cast<RsTurtleSearchResultItem *>(item)) ;
break ;
@ -1794,9 +1796,15 @@ void RsTurtleFileSearchRequestItem::performLocalSearch(TurtleSearchRequestInfo &
void RsTurtleGxsSearchRequestItem::performLocalSearch(TurtleSearchRequestInfo &req, std::list<RsTurtleSearchResultItem*>& result) const
{
std::cerr << "(EE) Missing code to perform actual GXS search" << std::endl;
std::cerr << "(EE) p3turtle: Missing code to perform actual GXS search" << std::endl;
}
void RsTurtleGxsGroupRequestItem::performLocalSearch(TurtleSearchRequestInfo &req, std::list<RsTurtleSearchResultItem*>& result) const
{
std::cerr << "(EE) p3turtle: Missing code to perform actual retrieval of GXS group" << std::endl;
}
void RsTurtleStringSearchRequestItem::search(std::list<TurtleFileInfo>& result) const
{
/* call to core */
@ -1985,11 +1993,19 @@ void p3turtle::returnSearchResult(RsTurtleSearchResultItem *item)
return ;
}
RsTurtleGxsSearchResultItem *gxs_sr = dynamic_cast<RsTurtleGxsSearchResultItem*>(item) ;
RsTurtleGxsSearchResultGroupSummaryItem *gxs_sr_gs = dynamic_cast<RsTurtleGxsSearchResultGroupSummaryItem*>(item) ;
if(gxs_sr != NULL)
if(gxs_sr_gs != NULL)
{
RsServer::notify()->notifyTurtleSearchResult(gxs_sr->request_id,gxs_sr->result) ;
RsServer::notify()->notifyTurtleSearchResult(gxs_sr_gs->request_id,gxs_sr_gs->result) ;
return ;
}
RsTurtleGxsSearchResultGroupDataItem *gxs_sr_gd = dynamic_cast<RsTurtleGxsSearchResultGroupDataItem*>(item) ;
if(gxs_sr_gd != NULL)
{
#warning MISSING CODE HERE TO HANDLE ENCRYPTED INCOMING GROUP DATA.
//RsServer::notify()->notifyTurtleSearchResult(gxs_sr_gd->request_id,gxs_sr_gd->encrypted_nxs_group) ;
return ;
}
}

View File

@ -28,13 +28,16 @@ RsItem *RsTurtleSerialiser::create_item(uint16_t service,uint8_t item_subtype) c
{
case RS_TURTLE_SUBTYPE_STRING_SEARCH_REQUEST : return new RsTurtleStringSearchRequestItem();
case RS_TURTLE_SUBTYPE_REGEXP_SEARCH_REQUEST : return new RsTurtleRegExpSearchRequestItem();
case RS_TURTLE_SUBTYPE_GXS_SEARCH_REQUEST : return new RsTurtleGxsSearchRequestItem();
case RS_TURTLE_SUBTYPE_FT_SEARCH_RESULT : return new RsTurtleFTSearchResultItem();
case RS_TURTLE_SUBTYPE_GXS_SEARCH_RESULT : return new RsTurtleGxsSearchResultItem();
case RS_TURTLE_SUBTYPE_OPEN_TUNNEL : return new RsTurtleOpenTunnelItem();
case RS_TURTLE_SUBTYPE_TUNNEL_OK : return new RsTurtleTunnelOkItem();
case RS_TURTLE_SUBTYPE_GENERIC_DATA : return new RsTurtleGenericDataItem();
case RS_TURTLE_SUBTYPE_GXS_SEARCH_REQUEST : return new RsTurtleGxsSearchRequestItem();
case RS_TURTLE_SUBTYPE_GXS_GROUP_REQUEST : return new RsTurtleGxsGroupRequestItem();
case RS_TURTLE_SUBTYPE_GXS_GROUP_SUMMARY : return new RsTurtleGxsSearchResultGroupSummaryItem();
case RS_TURTLE_SUBTYPE_GXS_GROUP_DATA : return new RsTurtleGxsSearchResultGroupDataItem();
default:
break ;
}
@ -56,7 +59,6 @@ void RsTurtleStringSearchRequestItem::serial_process(RsGenericSerializer::Serial
RsTypeSerializer::serial_process<uint32_t>(j,ctx,request_id,"request_id") ;
RsTypeSerializer::serial_process<uint16_t>(j,ctx,depth ,"depth") ;
}
void RsTurtleRegExpSearchRequestItem::serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx)
{
RsTypeSerializer::serial_process<uint32_t>(j,ctx,request_id,"request_id") ;
@ -70,6 +72,14 @@ void RsTurtleGxsSearchRequestItem::serial_process(RsGenericSerializer::Serialize
RsTypeSerializer::serial_process<uint16_t>(j,ctx,service_id,"service_id") ;
RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_STR_VALUE,match_string,"match_string") ;
}
void RsTurtleGxsGroupRequestItem::serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx)
{
RsTypeSerializer::serial_process<uint32_t>(j,ctx,request_id,"request_id") ;
RsTypeSerializer::serial_process<uint16_t>(j,ctx,depth,"depth") ;
RsTypeSerializer::serial_process<uint16_t>(j,ctx,service_id,"service_id") ;
RsTypeSerializer::serial_process(j,ctx,hashed_group_id,"hashed_group_id") ;
}
template<> uint32_t RsTypeSerializer::serial_size(const RsRegularExpression::LinearizedExpression& r)
{
uint32_t s = 0 ;
@ -154,12 +164,18 @@ void RsTurtleFTSearchResultItem::serial_process(RsGenericSerializer::SerializeJo
RsTypeSerializer::serial_process<uint16_t>(j,ctx,depth ,"depth") ;
RsTypeSerializer::serial_process (j,ctx,result ,"result") ;
}
void RsTurtleGxsSearchResultItem::serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx)
void RsTurtleGxsSearchResultGroupSummaryItem::serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx)
{
RsTypeSerializer::serial_process<uint32_t>(j,ctx,request_id,"request_id") ;
RsTypeSerializer::serial_process<uint16_t>(j,ctx,depth ,"depth") ;
RsTypeSerializer::serial_process (j,ctx,result ,"result") ;
}
void RsTurtleGxsSearchResultGroupDataItem::serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx)
{
RsTypeSerializer::serial_process<uint32_t> (j,ctx,request_id,"request_id") ;
RsTypeSerializer::serial_process<uint16_t> (j,ctx,depth ,"depth") ;
RsTypeSerializer::serial_process<RsTlvItem>(j,ctx,encrypted_nxs_group,"encrypted_nxs_group") ;
}
template<> uint32_t RsTypeSerializer::serial_size(const TurtleFileInfo& i)
{
uint32_t s = 0 ;

View File

@ -24,11 +24,13 @@ const uint8_t RS_TURTLE_SUBTYPE_FILE_DATA = 0x08 ;
const uint8_t RS_TURTLE_SUBTYPE_REGEXP_SEARCH_REQUEST = 0x09 ;
const uint8_t RS_TURTLE_SUBTYPE_GENERIC_DATA = 0x0a ;
const uint8_t RS_TURTLE_SUBTYPE_GXS_SEARCH_REQUEST = 0x0b ;
const uint8_t RS_TURTLE_SUBTYPE_GXS_GROUP_REQUEST = 0x0c ;
const uint8_t RS_TURTLE_SUBTYPE_FILE_MAP = 0x10 ;
const uint8_t RS_TURTLE_SUBTYPE_FILE_MAP_REQUEST = 0x11 ;
const uint8_t RS_TURTLE_SUBTYPE_CHUNK_CRC = 0x14 ;
const uint8_t RS_TURTLE_SUBTYPE_CHUNK_CRC_REQUEST = 0x15 ;
const uint8_t RS_TURTLE_SUBTYPE_GXS_SEARCH_RESULT = 0x16 ;
const uint8_t RS_TURTLE_SUBTYPE_GXS_GROUP_SUMMARY = 0x16 ;
const uint8_t RS_TURTLE_SUBTYPE_GXS_GROUP_DATA = 0x17 ;
// const uint8_t RS_TURTLE_SUBTYPE_FILE_CRC = 0x12 ; // unused
// const uint8_t RS_TURTLE_SUBTYPE_FILE_CRC_REQUEST = 0x13 ;
@ -65,12 +67,18 @@ class RsTurtleItem: public RsItem
// | | +---- RsTurtleReqExpSearchRequestItem
// | |
// | +---- RsTurtleGxsSearchRequestItem
// | |
// | +---- RsTurtleGxsGroupRequestItem
// |
// +---- RsTurtleSearchResultItem
// |
// +---- RsTurtleFTSearchResultItem
// |
// +---- RsTurtleGxsSearchResultItem
// |
// +---- RsTurtleGxsSearchResultGroupSummaryItem
// |
// +---- RsTurtleGxsSearchResultGroupDataItem
//
class RsTurtleSearchResultItem ;
@ -149,21 +157,38 @@ class RsTurtleGxsSearchRequestItem: public RsTurtleSearchRequestItem
RsTurtleGxsSearchRequestItem() : RsTurtleSearchRequestItem(RS_TURTLE_SUBTYPE_GXS_SEARCH_REQUEST) {}
virtual ~RsTurtleGxsSearchRequestItem() {}
virtual void performLocalSearch(TurtleSearchRequestInfo& req,std::list<RsTurtleSearchResultItem*>&) const ; // abstracts the search method
std::string match_string ; // string to match
uint16_t service_id ; // searvice to search
std::string GetKeywords() { return match_string; }
virtual void performLocalSearch(TurtleSearchRequestInfo& req,std::list<RsTurtleSearchResultItem*>&) const ; // abstracts the search method
virtual RsTurtleSearchRequestItem *clone() const { return new RsTurtleGxsSearchRequestItem(*this) ; }
void clear() { match_string.clear() ; }
protected:
void serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx);
};
class RsTurtleGxsGroupRequestItem: public RsTurtleSearchRequestItem
{
public:
RsTurtleGxsGroupRequestItem() : RsTurtleSearchRequestItem(RS_TURTLE_SUBTYPE_GXS_GROUP_REQUEST) {}
virtual ~RsTurtleGxsGroupRequestItem() {}
uint16_t service_id ; // searvice to search
Sha1CheckSum hashed_group_id ; // the group ID is hashed in order to keep it private.
virtual RsTurtleSearchRequestItem *clone() const { return new RsTurtleGxsGroupRequestItem(*this) ; }
virtual void performLocalSearch(TurtleSearchRequestInfo& req,std::list<RsTurtleSearchResultItem*>&) const ; // abstracts the search method
void clear() { hashed_group_id.clear() ; }
std::string GetKeywords() { return hashed_group_id.toStdString(); }
protected:
void serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx);
};
class RsTurtleSearchResultItem: public RsTurtleItem
{
public:
@ -197,21 +222,36 @@ class RsTurtleFTSearchResultItem: public RsTurtleSearchResultItem
void serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx);
};
class RsTurtleGxsSearchResultItem: public RsTurtleSearchResultItem
class RsTurtleGxsSearchResultGroupSummaryItem: public RsTurtleSearchResultItem
{
public:
RsTurtleGxsSearchResultItem() : RsTurtleSearchResultItem(RS_TURTLE_SUBTYPE_GXS_SEARCH_RESULT){}
RsTurtleGxsSearchResultGroupSummaryItem() : RsTurtleSearchResultItem(RS_TURTLE_SUBTYPE_GXS_GROUP_SUMMARY){}
virtual ~RsTurtleGxsSearchResultGroupSummaryItem() {}
std::list<TurtleGxsInfo> result ;
void clear() { result.clear() ; }
uint32_t count() const { return result.size() ; }
virtual void pop() { result.pop_back() ;}
virtual RsTurtleSearchResultItem *duplicate() const { return new RsTurtleGxsSearchResultItem(*this) ; }
virtual RsTurtleSearchResultItem *duplicate() const { return new RsTurtleGxsSearchResultGroupSummaryItem(*this) ; }
protected:
void serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx);
};
class RsTurtleGxsSearchResultGroupDataItem: public RsTurtleSearchResultItem
{
public:
RsTurtleGxsSearchResultGroupDataItem() : RsTurtleSearchResultItem(RS_TURTLE_SUBTYPE_GXS_GROUP_DATA){}
virtual ~RsTurtleGxsSearchResultGroupDataItem() {}
RsTlvBinaryData encrypted_nxs_group; // data is encrypted with group ID.
uint32_t count() const { return 1 ; }
virtual void pop() { clear(); }
void clear() { encrypted_nxs_group.TlvClear() ; }
virtual RsTurtleSearchResultItem *duplicate() const { return new RsTurtleGxsSearchResultGroupDataItem(*this) ; }
protected:
void serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx);
};
/***********************************************************************************/
/* Turtle Tunnel Item classes */