mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-02-17 13:24:15 -05:00
Enable JSON API for channel turtle search
Add event subtype to RsGxsChannelSearchResultEvent so its type can be recognized from JSON API Remove unused member remnant of the past from RsGxsChannelEvent
This commit is contained in:
parent
0c173587e2
commit
6510af7ab6
@ -122,7 +122,6 @@ struct RsGxsChannelEvent: RsEvent
|
||||
RsChannelEventCode mChannelEventCode;
|
||||
RsGxsGroupId mChannelGroupId;
|
||||
RsGxsMessageId mChannelMsgId;
|
||||
TurtleRequestId mDistantSearchRequestId;
|
||||
|
||||
///* @see RsEvent @see RsSerializable
|
||||
void serial_process( RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx) override
|
||||
@ -132,25 +131,28 @@ struct RsGxsChannelEvent: RsEvent
|
||||
RS_SERIAL_PROCESS(mChannelEventCode);
|
||||
RS_SERIAL_PROCESS(mChannelGroupId);
|
||||
RS_SERIAL_PROCESS(mChannelMsgId);
|
||||
RS_SERIAL_PROCESS(mDistantSearchRequestId);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// This event is used to factor multiple search results notifications in a single event.
|
||||
|
||||
struct RsGxsChannelSearchResultEvent: public RsEvent
|
||||
struct RsGxsChannelSearchResultEvent: RsEvent
|
||||
{
|
||||
RsGxsChannelSearchResultEvent() : RsEvent(RsEventType::GXS_CHANNELS) {}
|
||||
RsGxsChannelSearchResultEvent():
|
||||
RsEvent(RsEventType::GXS_CHANNELS),
|
||||
mChannelEventCode(RsChannelEventCode::RECEIVED_DISTANT_SEARCH_RESULT) {}
|
||||
|
||||
std::map<TurtleRequestId,std::set<RsGxsGroupId> > mSearchResultsMap;
|
||||
RsChannelEventCode mChannelEventCode;
|
||||
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(mChannelEventCode);
|
||||
RS_SERIAL_PROCESS(mSearchResultsMap);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
class RsGxsChannels: public RsGxsIfaceHelper, public RsGxsCommentService
|
||||
@ -422,49 +424,6 @@ public:
|
||||
*/
|
||||
virtual bool getChannelStatistics(const RsGxsGroupId& channelId,GxsGroupStatistic& stat) =0;
|
||||
|
||||
#ifdef TO_REMOVE
|
||||
/**
|
||||
* @brief Request remote channels search
|
||||
* @jsonapi{development}
|
||||
* @param[in] matchString string to look for in the search
|
||||
* @param multiCallback function that will be called each time a search
|
||||
* result is received
|
||||
* @param[in] maxWait maximum wait time in seconds for search results
|
||||
* @return false on error, true otherwise
|
||||
*/
|
||||
virtual bool turtleSearchRequest(
|
||||
const std::string& matchString,
|
||||
const std::function<void (const RsGxsGroupSummary& result)>& multiCallback,
|
||||
rstime_t maxWait = 300 ) = 0;
|
||||
|
||||
/**
|
||||
* @brief Request remote channel
|
||||
* @jsonapi{development}
|
||||
* @param[in] channelId id of the channel to request to distants peers
|
||||
* @param multiCallback function that will be called each time a result is
|
||||
* received
|
||||
* @param[in] maxWait maximum wait time in seconds for search results
|
||||
* @return false on error, true otherwise
|
||||
*/
|
||||
virtual bool turtleChannelRequest(
|
||||
const RsGxsGroupId& channelId,
|
||||
const std::function<void (const RsGxsChannelGroup& result)>& multiCallback,
|
||||
rstime_t maxWait = 300 ) = 0;
|
||||
|
||||
/**
|
||||
* @brief Search local channels
|
||||
* @jsonapi{development}
|
||||
* @param[in] matchString string to look for in the search
|
||||
* @param multiCallback function that will be called for each result
|
||||
* @param[in] maxWait maximum wait time in seconds for search results
|
||||
* @return false on error, true otherwise
|
||||
*/
|
||||
virtual bool localSearchRequest(
|
||||
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;
|
||||
|
||||
@ -509,6 +468,7 @@ public:
|
||||
|
||||
/**
|
||||
* @brief Import channel from full link
|
||||
* @jsonapi{development}
|
||||
* @param[in] link channel link either in radix or link format
|
||||
* @param[out] chanId optional storage for parsed channel id
|
||||
* @param[out] errMsg optional storage for error message, meaningful only in
|
||||
@ -520,7 +480,58 @@ public:
|
||||
RsGxsGroupId& chanId = RS_DEFAULT_STORAGE_PARAM(RsGxsGroupId),
|
||||
std::string& errMsg = RS_DEFAULT_STORAGE_PARAM(std::string) ) = 0;
|
||||
|
||||
/**
|
||||
* @brief Search the turtle reachable network for matching channels
|
||||
* @jsonapi{development}
|
||||
* An @see RsGxsChannelSearchResultEvent is emitted when matching channels
|
||||
* arrives from the network
|
||||
* @param[in] matchString string to search into the channels
|
||||
* @return search id
|
||||
*/
|
||||
virtual TurtleRequestId turtleSearchRequest(const std::string& matchString)=0;
|
||||
|
||||
/**
|
||||
* @brief Retrieve available search results
|
||||
* @jsonapi{development}
|
||||
* @param[in] searchId search id
|
||||
* @param[out] results storage for search results
|
||||
* @return false on error, true otherwise
|
||||
*/
|
||||
virtual bool retrieveDistantSearchResults(
|
||||
TurtleRequestId searchId,
|
||||
std::map<RsGxsGroupId, RsGxsGroupSearchResults>& results ) = 0;
|
||||
|
||||
/**
|
||||
* @brief Request distant channel details
|
||||
* @jsonapi{development}
|
||||
* An @see RsGxsChannelSearchResultEvent is emitted once details are
|
||||
* retrieved from the network
|
||||
* @param[in] groupId if of the group to request to the network
|
||||
* @return search id
|
||||
*/
|
||||
virtual TurtleRequestId turtleGroupRequest(const RsGxsGroupId& groupId) = 0;
|
||||
|
||||
/**
|
||||
* @brief Retrieve previously requested distant group
|
||||
* @jsonapi{development}
|
||||
* @param[in] groupId if of teh group
|
||||
* @param[out] distantGroup storage for group data
|
||||
* @return false on error, true otherwise
|
||||
*/
|
||||
virtual bool getDistantSearchResultGroupData(
|
||||
const RsGxsGroupId& groupId, RsGxsChannelGroup& distantGroup ) = 0;
|
||||
|
||||
/**
|
||||
* @brief Clear accumulated search results
|
||||
* @jsonapi{development}
|
||||
* @param[in] reqId search id
|
||||
* @return false on error, true otherwise
|
||||
*/
|
||||
virtual bool clearDistantSearchResults(TurtleRequestId reqId) = 0;
|
||||
|
||||
~RsGxsChannels() override;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
/* Following functions are deprecated and should not be considered a safe to
|
||||
* use API */
|
||||
|
||||
@ -706,21 +717,4 @@ public:
|
||||
*/
|
||||
RS_DEPRECATED_FOR(editChannel)
|
||||
virtual bool updateGroup(uint32_t& token, RsGxsChannelGroup& group) = 0;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
/// Distant synchronisation methods ///
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
///
|
||||
///
|
||||
// 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;
|
||||
virtual TurtleRequestId turtleSearchRequest(const std::string& match_string)=0;
|
||||
virtual bool clearDistantSearchResults(TurtleRequestId req)=0;
|
||||
virtual bool getDistantSearchResultGroupData(const RsGxsGroupId& group_id,RsGxsChannelGroup& distant_group)=0;
|
||||
virtual bool retrieveDistantSearchResults(TurtleRequestId req, std::map<RsGxsGroupId, RsGxsGroupSearchResults> &results) =0;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
~RsGxsChannels() override;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user