mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-12-14 16:18:48 -05:00
removed multi-callback based distant search result handling, and use rsEvents instead
This commit is contained in:
parent
8e2c670716
commit
33da5c06b8
15 changed files with 204 additions and 123 deletions
|
|
@ -117,9 +117,7 @@ enum class RsChannelEventCode: uint8_t
|
|||
|
||||
struct RsGxsChannelEvent: RsEvent
|
||||
{
|
||||
RsGxsChannelEvent():
|
||||
RsEvent(RsEventType::GXS_CHANNELS),
|
||||
mChannelEventCode(RsChannelEventCode::UNKNOWN) {}
|
||||
RsGxsChannelEvent(): RsEvent(RsEventType::GXS_CHANNELS), mChannelEventCode(RsChannelEventCode::UNKNOWN) {}
|
||||
|
||||
RsChannelEventCode mChannelEventCode;
|
||||
RsGxsGroupId mChannelGroupId;
|
||||
|
|
@ -138,6 +136,23 @@ struct RsGxsChannelEvent: RsEvent
|
|||
}
|
||||
};
|
||||
|
||||
// This event is used to factor multiple search results notifications in a single event.
|
||||
|
||||
struct RsGxsChannelSearchResultEvent: public RsEvent
|
||||
{
|
||||
RsGxsChannelSearchResultEvent() : RsEvent(RsEventType::GXS_CHANNELS) {}
|
||||
|
||||
std::map<TurtleRequestId,std::set<RsGxsGroupId> > mSearchResultsMap;
|
||||
|
||||
///* @see RsEvent @see RsSerializable
|
||||
void serial_process( RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx) override
|
||||
{
|
||||
RsEvent::serial_process(j, ctx);
|
||||
|
||||
RS_SERIAL_PROCESS(mSearchResultsMap);
|
||||
}
|
||||
};
|
||||
|
||||
class RsGxsChannels: public RsGxsIfaceHelper, public RsGxsCommentService
|
||||
{
|
||||
public:
|
||||
|
|
@ -407,7 +422,7 @@ public:
|
|||
*/
|
||||
virtual bool getChannelStatistics(const RsGxsGroupId& channelId,GxsGroupStatistic& stat) =0;
|
||||
|
||||
|
||||
#ifdef TO_REMOVE
|
||||
/**
|
||||
* @brief Request remote channels search
|
||||
* @jsonapi{development}
|
||||
|
|
@ -448,6 +463,7 @@ public:
|
|||
const std::string& matchString,
|
||||
const std::function<void (const RsGxsGroupSummary& result)>& multiCallback,
|
||||
rstime_t maxWait = 30 ) = 0;
|
||||
#endif
|
||||
|
||||
/// default base URL used for channels links @see exportChannelLink
|
||||
static const std::string DEFAULT_CHANNEL_BASE_URL;
|
||||
|
|
@ -695,16 +711,15 @@ public:
|
|||
/// Distant synchronisation methods ///
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
///
|
||||
RS_DEPRECATED_FOR(turtleChannelRequest)
|
||||
///
|
||||
// This approach is much cleaner than the "multicallback" system. We should keep it and use rsEvents to warn when
|
||||
// new results are received.
|
||||
virtual TurtleRequestId turtleGroupRequest(const RsGxsGroupId& group_id)=0;
|
||||
RS_DEPRECATED
|
||||
virtual TurtleRequestId turtleSearchRequest(const std::string& match_string)=0;
|
||||
RS_DEPRECATED_FOR(turtleSearchRequest)
|
||||
virtual bool retrieveDistantSearchResults(TurtleRequestId req, std::map<RsGxsGroupId, RsGxsGroupSummary> &results) =0;
|
||||
RS_DEPRECATED
|
||||
virtual bool clearDistantSearchResults(TurtleRequestId req)=0;
|
||||
RS_DEPRECATED_FOR(turtleChannelRequest)
|
||||
virtual bool retrieveDistantGroup(const RsGxsGroupId& group_id,RsGxsChannelGroup& distant_group)=0;
|
||||
virtual bool retrieveDistantSearchResults(TurtleRequestId req, std::map<RsGxsGroupId, RsGxsGroupSearchResults> &results) =0;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
~RsGxsChannels() override;
|
||||
|
|
|
|||
|
|
@ -72,6 +72,46 @@ struct RsGxsGroupSummary : RsSerializable
|
|||
~RsGxsGroupSummary();
|
||||
};
|
||||
|
||||
/*!
|
||||
* This structure is used to locally store group search results for a given service.
|
||||
* It contains the group information as well as a context
|
||||
* strings 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 RsGxsGroupSearchResults : RsSerializable
|
||||
{
|
||||
RsGxsGroupSearchResults()
|
||||
: mPublishTs(0), mNumberOfMessages(0),mLastMessageTs(0), mSignFlags(0),mPopularity(0)
|
||||
{}
|
||||
|
||||
RsGxsGroupId mGroupId;
|
||||
std::string mGroupName;
|
||||
RsGxsId mAuthorId;
|
||||
rstime_t mPublishTs;
|
||||
uint32_t mNumberOfMessages;
|
||||
rstime_t mLastMessageTs;
|
||||
uint32_t mSignFlags;
|
||||
uint32_t mPopularity;
|
||||
|
||||
std::set<std::string> mSearchContexts;
|
||||
|
||||
/// @see RsSerializable::serial_process
|
||||
void serial_process( RsGenericSerializer::SerializeJob j,
|
||||
RsGenericSerializer::SerializeContext& ctx )
|
||||
{
|
||||
RS_SERIAL_PROCESS(mGroupId);
|
||||
RS_SERIAL_PROCESS(mGroupName);
|
||||
RS_SERIAL_PROCESS(mAuthorId);
|
||||
RS_SERIAL_PROCESS(mPublishTs);
|
||||
RS_SERIAL_PROCESS(mNumberOfMessages);
|
||||
RS_SERIAL_PROCESS(mLastMessageTs);
|
||||
RS_SERIAL_PROCESS(mSignFlags);
|
||||
RS_SERIAL_PROCESS(mPopularity);
|
||||
RS_SERIAL_PROCESS(mSearchContexts);
|
||||
}
|
||||
|
||||
virtual ~RsGxsGroupSearchResults() = default;
|
||||
};
|
||||
|
||||
/*!
|
||||
* Stores ids of changed gxs groups and messages.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue