mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-03 14:45:12 -04:00
fixed merge with upstream/master
This commit is contained in:
commit
c60f1d1331
23 changed files with 274 additions and 214 deletions
|
@ -43,7 +43,7 @@ p3GxsTrans::~p3GxsTrans()
|
|||
}
|
||||
}
|
||||
|
||||
bool p3GxsTrans::getStatistics(GxsTransStatistics& stats)
|
||||
bool p3GxsTrans::getDataStatistics(GxsTransStatistics& stats)
|
||||
{
|
||||
{
|
||||
RS_STACK_MUTEX(mDataMutex);
|
||||
|
@ -1335,4 +1335,53 @@ bool p3GxsTrans::acceptNewMessage(const RsGxsMsgMetaData *msgMeta,uint32_t msg_s
|
|||
}
|
||||
|
||||
|
||||
bool p3GxsTrans::getGroupStatistics(std::map<RsGxsGroupId,RsGxsTransGroupStatistics>& stats)
|
||||
{
|
||||
uint32_t token1;
|
||||
|
||||
RsTokReqOptions opts1;
|
||||
opts1.mReqType = GXS_REQUEST_TYPE_GROUP_META;
|
||||
if( !requestGroupInfo(token1, opts1) || waitToken(token1) != RsTokenService::COMPLETE )
|
||||
return false;
|
||||
|
||||
std::list<RsGroupMetaData> group_metas;
|
||||
getGroupSummary(token1,group_metas);
|
||||
|
||||
for(auto& group_meta:group_metas)
|
||||
{
|
||||
RsGxsTransGroupStatistics& stat(stats[group_meta.mGroupId]);
|
||||
|
||||
uint32_t token2;
|
||||
if(!RsGxsIfaceHelper::requestGroupStatistic(token2,group_meta.mGroupId) || waitToken(token2) != RsTokenService::COMPLETE)
|
||||
continue;
|
||||
|
||||
RsGenExchange::getGroupStatistic(token2,stat);
|
||||
|
||||
stat.popularity = group_meta.mPop ;
|
||||
stat.subscribed = IS_GROUP_SUBSCRIBED(group_meta.mSubscribeFlags) ;
|
||||
stat.mGrpId = group_meta.mGroupId ;
|
||||
|
||||
std::vector<RsMsgMetaData> metas;
|
||||
|
||||
uint32_t token3;
|
||||
RsTokReqOptions opts;
|
||||
opts.mReqType = GXS_REQUEST_TYPE_MSG_META;
|
||||
|
||||
std::list<RsGxsGroupId> groupIds;
|
||||
groupIds.push_back(group_meta.mGroupId);
|
||||
|
||||
if( !requestMsgInfo(token3, opts, groupIds) || waitToken(token3, std::chrono::seconds(5)) != RsTokenService::COMPLETE )
|
||||
continue;
|
||||
|
||||
GxsMsgMetaMap metaMap;
|
||||
if(!RsGenExchange::getMsgMeta(token3, metaMap) || metaMap.size() != 1)
|
||||
continue;
|
||||
|
||||
for(auto& meta: metaMap.begin()->second)
|
||||
stat.addMessageMeta(group_meta.mGroupId,meta) ;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -113,13 +113,21 @@ public:
|
|||
|
||||
/*!
|
||||
* \brief getStatistics
|
||||
* Gathers all sorts of statistics about the internals of p3GxsTrans, in order to display info about the running status,
|
||||
* message transport, etc.
|
||||
* Gathers all sorts of statistics about the data transported by p3GxsTrans, in order to display info about the running status,
|
||||
* message transport, etc. This is a blocking call. Use it in a thread.
|
||||
* \param stats This structure contains all statistics information.
|
||||
* \return true is the call succeeds.
|
||||
*/
|
||||
|
||||
virtual bool getStatistics(GxsTransStatistics& stats);
|
||||
virtual bool getDataStatistics(GxsTransStatistics& stats) override;
|
||||
|
||||
/*!
|
||||
* \brief getGroupStatistics
|
||||
* Gathers statistics about GXS groups and messages used by GxsTrans to transport data. This is a blocking call. Use it in a thread.
|
||||
* \param stats
|
||||
* \return true if the data collection succeeds.
|
||||
*/
|
||||
virtual bool getGroupStatistics(std::map<RsGxsGroupId,RsGxsTransGroupStatistics>& stats) override;
|
||||
|
||||
/**
|
||||
* Send an email to recipient, in the process author of the email is
|
||||
|
|
|
@ -409,6 +409,14 @@ public:
|
|||
virtual bool subscribeToChannel( const RsGxsGroupId& channelId,
|
||||
bool subscribe ) = 0;
|
||||
|
||||
/**
|
||||
* \brief Retrieve statistics about the channel service
|
||||
* @jsonapi{development}
|
||||
* \param[out] stat Statistics structure
|
||||
* \return
|
||||
*/
|
||||
virtual bool getChannelServiceStatistics(GxsServiceStatistic& stat) =0;
|
||||
|
||||
/**
|
||||
* \brief Retrieve statistics about the given channel
|
||||
* @jsonapi{development}
|
||||
|
@ -418,6 +426,7 @@ public:
|
|||
*/
|
||||
virtual bool getChannelStatistics(const RsGxsGroupId& channelId,GxsGroupStatistic& stat) =0;
|
||||
|
||||
|
||||
/**
|
||||
* @brief Request remote channels search
|
||||
* @jsonapi{development}
|
||||
|
|
|
@ -219,6 +219,14 @@ public:
|
|||
*/
|
||||
virtual bool getForumsSummaries(std::list<RsGroupMetaData>& forums) = 0;
|
||||
|
||||
/**
|
||||
* @brief returns statistics for the forum service
|
||||
* @jsonapi{development}
|
||||
* @param[out] stat statistics struct
|
||||
* @return false if the call fails
|
||||
*/
|
||||
virtual bool getForumServiceStatistics(GxsServiceStatistic& stat) =0;
|
||||
|
||||
/**
|
||||
* @brief returns statistics about a particular forum
|
||||
* @jsonapi{development}
|
||||
|
@ -228,6 +236,7 @@ public:
|
|||
*/
|
||||
virtual bool getForumStatistics(const RsGxsGroupId& forumId,GxsGroupStatistic& stat)=0;
|
||||
|
||||
|
||||
/**
|
||||
* @brief Get forums information (description, thumbnail...).
|
||||
* Blocking API.
|
||||
|
|
|
@ -85,8 +85,7 @@ public:
|
|||
* @param groupIds the ids return for given request token
|
||||
* @return false if request token is invalid, check token status for error report
|
||||
*/
|
||||
bool getGroupList(const uint32_t &token,
|
||||
std::list<RsGxsGroupId> &groupIds)
|
||||
bool getGroupList(const uint32_t &token, std::list<RsGxsGroupId> &groupIds)
|
||||
{
|
||||
return mGxs.getGroupList(token, groupIds);
|
||||
}
|
||||
|
@ -119,8 +118,7 @@ public:
|
|||
* @param groupInfo the ids returned for given request token
|
||||
* @return false if request token is invalid, check token status for error report
|
||||
*/
|
||||
bool getGroupSummary(const uint32_t &token,
|
||||
std::list<RsGroupMetaData> &groupInfo)
|
||||
bool getGroupSummary(const uint32_t &token, std::list<RsGroupMetaData> &groupInfo)
|
||||
{
|
||||
return mGxs.getGroupMeta(token, groupInfo);
|
||||
}
|
||||
|
@ -130,8 +128,7 @@ public:
|
|||
* @param msgInfo the message metadata returned for given request token
|
||||
* @return false if request token is invalid, check token status for error report
|
||||
*/
|
||||
bool getMsgSummary(const uint32_t &token,
|
||||
GxsMsgMetaMap &msgInfo)
|
||||
bool getMsgSummary(const uint32_t &token, GxsMsgMetaMap &msgInfo)
|
||||
{
|
||||
return mGxs.getMsgMeta(token, msgInfo);
|
||||
}
|
||||
|
@ -358,7 +355,7 @@ public:
|
|||
{ return mTokenService.requestStatus(token); }
|
||||
|
||||
/// @see RsTokenService::requestServiceStatistic
|
||||
void requestServiceStatistic(uint32_t& token)
|
||||
bool requestServiceStatistic(uint32_t& token)
|
||||
{
|
||||
RsTokReqOptions opts;
|
||||
opts.mReqType = GXS_REQUEST_TYPE_SERVICE_STATS;
|
||||
|
@ -369,6 +366,7 @@ public:
|
|||
mActiveTokens[token]=TokenRequestType::SERVICE_STATISTICS;
|
||||
|
||||
locked_dumpTokens();
|
||||
return true;
|
||||
}
|
||||
|
||||
/// @see RsTokenService::requestGroupStatistic
|
||||
|
|
|
@ -70,10 +70,8 @@ enum class GxsTransSendStatus : uint8_t
|
|||
|
||||
typedef uint64_t RsGxsTransId;
|
||||
|
||||
class RsGxsTransGroup
|
||||
class RsGxsTransGroup: public RsGxsGenericGroupData
|
||||
{
|
||||
public:
|
||||
RsGroupMetaData mMeta;
|
||||
};
|
||||
|
||||
class RsGxsTransMsg
|
||||
|
@ -103,7 +101,34 @@ struct RsGxsTransOutgoingRecord
|
|||
RsGxsGroupId group_id ;
|
||||
};
|
||||
|
||||
class RsGxsTransGroupStatistics: public GxsGroupStatistic
|
||||
{
|
||||
public:
|
||||
RsGxsTransGroupStatistics()
|
||||
{
|
||||
last_publish_TS = 0;
|
||||
popularity = 0;
|
||||
subscribed = false;
|
||||
}
|
||||
|
||||
void addMessageMeta(const RsGxsGroupId& grp,const RsMsgMetaData& meta)
|
||||
{
|
||||
messages_metas[meta.mMsgId] = meta ;
|
||||
last_publish_TS = std::max(last_publish_TS,meta.mPublishTs) ;
|
||||
mGrpId = grp ;
|
||||
}
|
||||
|
||||
bool subscribed ;
|
||||
int popularity ;
|
||||
|
||||
rstime_t last_publish_TS;
|
||||
|
||||
std::map<RsGxsMessageId,RsMsgMetaData> messages_metas ;
|
||||
};
|
||||
|
||||
|
||||
/// RetroShare GxsTrans asyncronous redundant small mail trasport on top of GXS
|
||||
///
|
||||
class RsGxsTrans: public RsGxsIfaceHelper
|
||||
{
|
||||
public:
|
||||
|
@ -120,10 +145,8 @@ public:
|
|||
|
||||
virtual ~RsGxsTrans() {}
|
||||
|
||||
virtual bool getStatistics(GxsTransStatistics& stats)=0;
|
||||
|
||||
// virtual bool getGroupData(const uint32_t &token, std::vector<RsGxsTransGroup> &groups) = 0;
|
||||
// virtual bool getPostData(const uint32_t &token, std::vector<RsGxsTransMsg> &posts) = 0;
|
||||
virtual bool getDataStatistics(GxsTransStatistics& stats)=0;
|
||||
virtual bool getGroupStatistics(std::map<RsGxsGroupId,RsGxsTransGroupStatistics>& stats) =0;
|
||||
};
|
||||
|
||||
extern RsGxsTrans *rsGxsTrans ;
|
||||
|
|
|
@ -167,6 +167,8 @@ public:
|
|||
|
||||
virtual bool getBoardStatistics(const RsGxsGroupId& boardId,GxsGroupStatistic& stat) =0;
|
||||
|
||||
virtual bool getBoardsServiceStatistics(GxsServiceStatistic& stat) =0;
|
||||
|
||||
enum RS_DEPRECATED RankType {TopRankType, HotRankType, NewRankType };
|
||||
|
||||
RS_DEPRECATED_FOR(getBoardsInfo)
|
||||
|
|
|
@ -1062,6 +1062,15 @@ bool p3GxsChannels::getChannelStatistics(const RsGxsGroupId& channelId,GxsGroupS
|
|||
return RsGenExchange::getGroupStatistic(token,stat);
|
||||
}
|
||||
|
||||
bool p3GxsChannels::getChannelServiceStatistics(GxsServiceStatistic& stat)
|
||||
{
|
||||
uint32_t token;
|
||||
if(!RsGxsIfaceHelper::requestServiceStatistic(token) || waitToken(token) != RsTokenService::COMPLETE)
|
||||
return false;
|
||||
|
||||
return RsGenExchange::getServiceStatistic(token,stat);
|
||||
}
|
||||
|
||||
bool p3GxsChannels::getContentSummaries(
|
||||
const RsGxsGroupId& channelId, std::vector<RsMsgMetaData>& summaries )
|
||||
{
|
||||
|
|
|
@ -204,6 +204,9 @@ virtual bool ExtraFileRemove(const RsFileHash &hash);
|
|||
/// Implementation of @see RsGxsChannels::getChannelStatistics
|
||||
bool getChannelStatistics(const RsGxsGroupId& channelId,GxsGroupStatistic& stat) override;
|
||||
|
||||
/// Iplementation of @see RsGxsChannels::getChannelServiceStatistics
|
||||
bool getChannelServiceStatistics(GxsServiceStatistic& stat) override;
|
||||
|
||||
/// Implementation of @see RsGxsChannels::createChannelV2
|
||||
bool createChannelV2(
|
||||
const std::string& name, const std::string& description,
|
||||
|
|
|
@ -819,6 +819,15 @@ bool p3GxsForums::createGroup(uint32_t &token, RsGxsForumGroup &group)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool p3GxsForums::getForumServiceStatistics(GxsServiceStatistic& stat)
|
||||
{
|
||||
uint32_t token;
|
||||
if(!RsGxsIfaceHelper::requestServiceStatistic(token) || waitToken(token) != RsTokenService::COMPLETE)
|
||||
return false;
|
||||
|
||||
return RsGenExchange::getServiceStatistic(token,stat);
|
||||
}
|
||||
|
||||
bool p3GxsForums::getForumStatistics(const RsGxsGroupId& ForumId,GxsGroupStatistic& stat)
|
||||
{
|
||||
uint32_t token;
|
||||
|
|
|
@ -97,6 +97,9 @@ public:
|
|||
/// Implementation of @see RsGxsForums::getForumStatistics
|
||||
bool getForumStatistics(const RsGxsGroupId& ForumId,GxsGroupStatistic& stat) override;
|
||||
|
||||
/// Implementation of @see RsGxsForums::getForumServiceStatistics
|
||||
bool getForumServiceStatistics(GxsServiceStatistic& stat) override;
|
||||
|
||||
/// @see RsGxsForums::getForumMsgMetaData
|
||||
virtual bool getForumMsgMetaData(const RsGxsGroupId& forumId, std::vector<RsMsgMetaData>& msg_metas) ;
|
||||
|
||||
|
|
|
@ -364,6 +364,16 @@ bool p3Posted::getBoardsSummaries(std::list<RsGroupMetaData>& boards )
|
|||
return getGroupSummary(token, boards);
|
||||
}
|
||||
|
||||
bool p3Posted::getBoardsServiceStatistics(GxsServiceStatistic& stat)
|
||||
{
|
||||
uint32_t token;
|
||||
if(!RsGxsIfaceHelper::requestServiceStatistic(token) || waitToken(token) != RsTokenService::COMPLETE)
|
||||
return false;
|
||||
|
||||
return RsGenExchange::getServiceStatistic(token,stat);
|
||||
}
|
||||
|
||||
|
||||
bool p3Posted::getBoardStatistics(const RsGxsGroupId& boardId,GxsGroupStatistic& stat)
|
||||
{
|
||||
uint32_t token;
|
||||
|
|
|
@ -74,6 +74,8 @@ virtual void receiveHelperChanges(std::vector<RsGxsNotify*>& changes)
|
|||
|
||||
bool getBoardStatistics(const RsGxsGroupId& boardId,GxsGroupStatistic& stat) override;
|
||||
|
||||
bool getBoardsServiceStatistics(GxsServiceStatistic& stat) override;
|
||||
|
||||
bool editBoard(RsPostedGroup& board) override;
|
||||
|
||||
bool createBoard(RsPostedGroup& board) override;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue