added retrieval of search results in UI

This commit is contained in:
csoler 2018-06-24 16:55:38 +02:00
parent 6ccc7654d6
commit e351d7257e
No known key found for this signature in database
GPG Key ID: 7BCA522266C0804C
13 changed files with 87 additions and 65 deletions

View File

@ -1844,15 +1844,6 @@ uint32_t RsGenExchange::getSyncPeriod(const RsGxsGroupId& grpId)
return RS_GXS_DEFAULT_MSG_REQ_PERIOD;
}
bool RsGenExchange::getDistantSearchResults(const TurtleRequestId& id,std::list<RsGxsGroupSummary>& group_infos)
{
return (mNetService!=NULL) && mNetService->getDistantSearchResults(id,group_infos) ;
}
bool RsGenExchange::clearDistantSearchResults(const TurtleRequestId& id)
{
return (mNetService!=NULL) && mNetService->clearDistantSearchResults(id) ;
}
bool RsGenExchange::getGroupNetworkStats(const RsGxsGroupId& grpId,RsGroupNetworkStats& stats)
{
return (!mNetService) || mNetService->getGroupNetworkStats(grpId,stats) ;

View File

@ -121,9 +121,9 @@ public:
virtual ~RsGenExchange();
// Convention that this is implemented here.
// Convention that this is implemented here.
// and passes to network service.
virtual RsServiceInfo getServiceInfo() = 0;
virtual RsServiceInfo getServiceInfo() = 0;
void setNetworkExchangeService(RsNetworkExchangeService *ns) ;
@ -581,7 +581,7 @@ public:
* @param msgs
*/
void deleteMsgs(uint32_t& token, const GxsMsgReq& msgs);
protected:
/*!
* This represents the group before its signature is calculated
@ -665,7 +665,7 @@ public:
*/
void shareGroupPublishKey(const RsGxsGroupId& grpId,const std::set<RsPeerId>& peers) ;
/*!
* Returns the local TS of the group as known by the network service.
* This is useful to allow various network services to sync their update TS
@ -688,9 +688,6 @@ public:
virtual void setSyncPeriod(const RsGxsGroupId& grpId,uint32_t age_in_secs) ;
virtual bool getGroupNetworkStats(const RsGxsGroupId& grpId,RsGroupNetworkStats& stats);
virtual bool getDistantSearchResults(const TurtleRequestId& id,std::list<RsGxsGroupSummary>& group_infos) ;
virtual bool clearDistantSearchResults(const TurtleRequestId& id);
uint16_t serviceType() const { return mServType ; }
uint32_t serviceFullType() const { return ((uint32_t)mServType << 8) + (((uint32_t) RS_PKT_VERSION_SERVICE) << 24); }

View File

@ -5117,6 +5117,25 @@ static bool termSearch(const std::string& src, const std::string& substring)
/* always ignore case */
return src.end() != std::search( src.begin(), src.end(), substring.begin(), substring.end(), RsRegularExpression::CompareCharIC() );
}
bool RsGxsNetService::retrieveDistantSearchResults(TurtleRequestId req,std::map<RsGxsGroupId,RsGxsGroupSummary>& group_infos)
{
RS_STACK_MUTEX(mNxsMutex) ;
auto it = mDistantSearchResults.find(req) ;
if(it == mDistantSearchResults.end())
return false ;
group_infos = it->second;
return true ;
}
bool RsGxsNetService::clearDistantSearchResults(const TurtleRequestId& id)
{
RS_STACK_MUTEX(mNxsMutex) ;
mDistantSearchResults.erase(id);
return true ;
}
void RsGxsNetService::receiveTurtleSearchResults(TurtleRequestId req, const std::list<RsGxsGroupSummary>& group_infos)
{
RS_STACK_MUTEX(mNxsMutex) ;
@ -5179,21 +5198,4 @@ bool RsGxsNetService::search(const std::string& substring,std::list<RsGxsGroupSu
return !group_infos.empty();
}
bool RsGxsNetService::getDistantSearchResults(const TurtleRequestId& id,std::list<RsGxsGroupSummary>& group_infos)
{
RS_STACK_MUTEX(mNxsMutex) ;
auto it = mDistantSearchResults.find(id) ;
if(it == mDistantSearchResults.end())
return false ;
for(auto it2(it->second.begin());it2!=it->second.end();++it2)
group_infos.push_back(it2->second);
return true;
}
bool RsGxsNetService::clearDistantSearchResults(const TurtleRequestId& id)
{
RS_STACK_MUTEX(mNxsMutex) ;
mDistantSearchResults.erase(id);
return true ;
}

View File

@ -132,6 +132,8 @@ public:
virtual bool search(const std::string& substring,std::list<RsGxsGroupSummary>& group_infos) ;
virtual void receiveTurtleSearchResults(TurtleRequestId req,const std::list<RsGxsGroupSummary>& group_infos);
virtual bool retrieveDistantSearchResults(TurtleRequestId req, std::map<RsGxsGroupId, RsGxsGroupSummary> &group_infos);
virtual bool clearDistantSearchResults(const TurtleRequestId& id);
/*!
* pauses synchronisation of subscribed groups and request for group id
@ -170,16 +172,6 @@ public:
*/
virtual bool getGroupNetworkStats(const RsGxsGroupId& id,RsGroupNetworkStats& stats) ;
/*!
* \brief getDistantSearchResults
* \param id Id of the search request previously issued
* \param group_infos Groups currently known for this search request.
* \return
* false if the id does not correspond to an ongoing distant search request.
*/
virtual bool getDistantSearchResults(const TurtleRequestId& id,std::list<RsGxsGroupSummary>& group_infos) ;
virtual bool clearDistantSearchResults(const TurtleRequestId& id);
/*!
* Used to inform the net service that we changed subscription status. That helps
* optimising data transfer when e.g. unsubsribed groups are updated less often, etc

View File

@ -60,25 +60,6 @@
* - the also group matrix settings which is by default everyone can transfer to each other
*/
/*!
* \brief The RsGxsGroupSymmary struct
* This structure is used to transport group summary information when a GXS service is searched. It contains the group information
* as well as a context string to tell where the information was found. It is more compact than a GroupMeta object, so as to make
* search responses as light as possible.
*/
struct RsGxsGroupSummary
{
RsGxsGroupId group_id ;
std::string group_name ;
std::string group_description ;
std::string search_context ;
RsGxsId author_id ;
time_t publish_ts ;
uint32_t number_of_messages ;
time_t last_message_ts ;
};
class RsNetworkExchangeService
{
public:
@ -132,13 +113,22 @@ public:
* \param group_infos Group summary information for the groups returned by the search
*/
virtual void receiveTurtleSearchResults(TurtleRequestId req,const std::list<RsGxsGroupSummary>& group_infos)=0;
/*!
* \brief retrieveTurtleSearchResults
* To be used to retrieve the search results that have been notified (or not)
* \param req request that match the results to retrieve
* \param group_infos results to retrieve.
* \return
* false when the request is unknown.
*/
virtual bool retrieveDistantSearchResults(TurtleRequestId req, std::map<RsGxsGroupId, RsGxsGroupSummary> &group_infos)=0;
/*!
* \brief getDistantSearchResults
* \param id
* \param group_infos
* \return
*/
virtual bool getDistantSearchResults(const TurtleRequestId& id,std::list<RsGxsGroupSummary>& group_infos)=0 ;
virtual bool clearDistantSearchResults(const TurtleRequestId& id)=0;
virtual bool search(const std::string& substring,std::list<RsGxsGroupSummary>& group_infos) =0;

View File

@ -35,8 +35,6 @@
#include "retroshare/rsgxscommon.h"
#include "retroshare/rsturtle.h"
/* The Main Interface Class - for information about your Peers */
class RsGxsChannels;
extern RsGxsChannels *rsGxsChannels;
@ -99,6 +97,8 @@ virtual bool getPostData(const uint32_t &token, std::vector<RsGxsChannelPost> &p
virtual TurtleRequestId turtleGroupRequest(const RsGxsGroupId& group_id)=0;
virtual TurtleRequestId turtleSearchRequest(const std::string& match_string)=0;
virtual bool retrieveDistantSearchResults(TurtleRequestId req, std::map<RsGxsGroupId, RsGxsGroupSummary> &results) =0;
virtual bool clearDistantSearchResults(TurtleRequestId req)=0;
//////////////////////////////////////////////////////////////////////////////
virtual void setMessageReadStatus(uint32_t& token, const RsGxsGrpMsgIdPair& msgId, bool read) = 0;

View File

@ -32,6 +32,26 @@
#include "gxs/rsgxsdata.h"
#include "retroshare/rsgxsifacetypes.h"
/*!
* \brief The RsGxsGroupSymmary struct
* This structure is used to transport group summary information when a GXS service is searched. It contains the group information
* as well as a context string to tell where the information was found. It is more compact than a GroupMeta object, so as to make
* search responses as light as possible.
*/
struct RsGxsGroupSummary
{
RsGxsGroupId group_id ;
std::string group_name ;
std::string group_description ;
std::string search_context ;
RsGxsId author_id ;
time_t publish_ts ;
uint32_t number_of_messages ;
time_t last_message_ts ;
};
/*!
* Stores ids of changed gxs groups and messages. It is used to notify the GUI about changes.
*/

View File

@ -1696,3 +1696,13 @@ TurtleRequestId p3GxsChannels::turtleSearchRequest(const std::string& match_stri
return netService()->turtleSearchRequest(match_string) ;
}
bool p3GxsChannels::clearDistantSearchResults(TurtleRequestId req)
{
return netService()->clearDistantSearchResults(req);
}
bool p3GxsChannels::retrieveDistantSearchResults(TurtleRequestId req,std::map<RsGxsGroupId,RsGxsGroupSummary>& results)
{
return netService()->retrieveDistantSearchResults(req,results);
}

View File

@ -74,6 +74,8 @@ virtual void service_tick();
virtual TurtleRequestId turtleGroupRequest(const RsGxsGroupId& group_id);
virtual TurtleRequestId turtleSearchRequest(const std::string& match_string);
virtual bool retrieveDistantSearchResults(TurtleRequestId req, std::map<RsGxsGroupId, RsGxsGroupSummary> &results) ;
virtual bool clearDistantSearchResults(TurtleRequestId req);
// Overloaded to cache new groups.
virtual RsGenExchange::ServiceCreate_Return service_CreateGroup(RsGxsGrpItem* grpItem, RsTlvSecurityKeySet& keySet);

View File

@ -254,7 +254,18 @@ void GxsGroupFrameDialog::updateSearchResults()
const std::set<TurtleRequestId>& reqs = getSearchResults();
for(auto it(reqs.begin());it!=reqs.end();++it)
{
std::cerr << "updating search ID " << std::hex << *it << std::dec << std::endl;
std::map<RsGxsGroupId,RsGxsGroupSummary> group_infos;
getDistantSearchResults(*it,group_infos) ;
std::cerr << "retrieved " << std::endl;
for(auto it2(group_infos.begin());it2!=group_infos.end();++it2)
std::cerr << " " << it2->first << " " << it2->second.group_id << " \"" << it2->second.group_name << "\"" << std::endl;
}
}
void GxsGroupFrameDialog::todo()

View File

@ -148,6 +148,7 @@ private:
virtual void groupTreeCustomActions(RsGxsGroupId /*grpId*/, int /*subscribeFlags*/, QList<QAction*> &/*actions*/) {}
virtual RsGxsCommentService *getCommentService() { return NULL; }
virtual QWidget *createCommentHeaderWidget(const RsGxsGroupId &/*grpId*/, const RsGxsMessageId &/*msgId*/) { return NULL; }
virtual bool getDistantSearchResults(TurtleRequestId id, std::map<RsGxsGroupId,RsGxsGroupSummary>& group_infos){ return false ;}
void initUi();

View File

@ -341,3 +341,8 @@ TurtleRequestId GxsChannelDialog::distantSearch(const QString& search_string)
{
return rsGxsChannels->turtleSearchRequest(search_string.toStdString()) ;
}
bool GxsChannelDialog::getDistantSearchResults(TurtleRequestId id, std::map<RsGxsGroupId,RsGxsGroupSummary>& group_infos)
{
return rsGxsChannels->retrieveDistantSearchResults(id,group_infos);
}

View File

@ -50,6 +50,7 @@ protected:
virtual GroupFrameSettings::Type groupFrameSettingsType() { return GroupFrameSettings::Channel; }
virtual QString getHelpString() const ;
virtual void groupInfoToGroupItemInfo(const RsGroupMetaData &groupInfo, GroupItemInfo &groupItemInfo, const RsUserdata *userdata);
virtual bool getDistantSearchResults(TurtleRequestId id, std::map<RsGxsGroupId,RsGxsGroupSummary>& group_infos);
virtual TurtleRequestId distantSearch(const QString& search_string) ;
private slots: