completely removed TokenQueue from GxsGroupDialog and GxsGroupFrameDialog

This commit is contained in:
csoler 2020-03-22 21:47:14 +01:00
parent 7ba83272cf
commit 6c1f09a53b
No known key found for this signature in database
GPG key ID: 7BCA522266C0804C
26 changed files with 423 additions and 217 deletions

View file

@ -398,6 +398,15 @@ public:
virtual bool subscribeToChannel( const RsGxsGroupId& channelId,
bool subscribe ) = 0;
/**
* \brief Retrieve statistics about the given channel
* @jsonapi{development}
* \param[in] channelId Id of the channel group
* \param[out] stat Statistics structure
* \return
*/
virtual bool getChannelStatistics(const RsGxsGroupId& channelId,GxsGroupStatistic& stat) =0;
/**
* @brief Request remote channels search
* @jsonapi{development}

View file

@ -219,6 +219,15 @@ public:
*/
virtual bool getForumsSummaries(std::list<RsGroupMetaData>& forums) = 0;
/**
* @brief returns statistics about a particular forum
* @jsonapi{development}
* @param[in] forumId Id of the forum
* @param[out] stat statistics struct
* @return false when the object doesn't exist or when the timeout is reached requesting the data
*/
virtual bool getForumStatistics(const RsGxsGroupId& forumId,GxsGroupStatistic& stat)=0;
/**
* @brief Get forums information (description, thumbnail...).
* Blocking API.
@ -361,5 +370,5 @@ public:
RS_DEPRECATED_FOR(createMessage)
virtual bool createMsg(uint32_t &token, RsGxsForumMsg &msg) = 0;
RS_DEPRECATED_FOR(editForum)
virtual bool updateGroup(uint32_t &token, RsGxsForumGroup &group) = 0;
virtual bool updateGroup(uint32_t &token, const RsGxsForumGroup &group) = 0;
};

View file

@ -340,13 +340,14 @@ public:
}
/// @see RsTokenService::requestGroupStatistic
void requestGroupStatistic(uint32_t& token, const RsGxsGroupId& grpId)
bool requestGroupStatistic(uint32_t& token, const RsGxsGroupId& grpId)
{
mTokenService.requestGroupStatistic(token, grpId);
RS_STACK_MUTEX(mMtx);
mActiveTokens[token]=TokenRequestType::GROUP_STATISTICS;
locked_dumpTokens();
return true;
}
bool cancelActiveRequestTokens(TokenRequestType type)

View file

@ -157,6 +157,12 @@ public:
std::vector<RsPostedPost>& posts,
std::vector<RsGxsComment>& comments ) = 0;
virtual bool editBoard(RsPostedGroup& board) =0;
virtual bool createBoard(RsPostedGroup& board) =0;
virtual bool getBoardStatistics(const RsGxsGroupId& boardId,GxsGroupStatistic& stat) =0;
enum RS_DEPRECATED RankType {TopRankType, HotRankType, NewRankType };
RS_DEPRECATED_FOR(getBoardsInfo)

View file

@ -1053,6 +1053,15 @@ bool p3GxsChannels::getChannelsInfo( const std::list<RsGxsGroupId>& chanIds, std
return getGroupData(token, channelsInfo) && !channelsInfo.empty();
}
bool p3GxsChannels::getChannelStatistics(const RsGxsGroupId& channelId,GxsGroupStatistic& stat)
{
uint32_t token;
if(!RsGxsIfaceHelper::requestGroupStatistic(token, channelId) || waitToken(token) != RsTokenService::COMPLETE)
return false;
return RsGenExchange::getGroupStatistic(token,stat);
}
bool p3GxsChannels::getContentSummaries(
const RsGxsGroupId& channelId, std::vector<RsMsgMetaData>& summaries )
{

View file

@ -196,6 +196,9 @@ virtual bool ExtraFileRemove(const RsFileHash &hash);
const RsGxsGroupId& channelId,
std::vector<RsMsgMetaData>& summaries ) override;
/// Implementation of @see RsGxsChannels::getChannelStatistics
bool getChannelStatistics(const RsGxsGroupId& channelId,GxsGroupStatistic& stat) override;
/// Implementation of @see RsGxsChannels::createChannelV2
bool createChannelV2(
const std::string& name, const std::string& description,

View file

@ -819,7 +819,16 @@ bool p3GxsForums::createGroup(uint32_t &token, RsGxsForumGroup &group)
return true;
}
bool p3GxsForums::updateGroup(uint32_t &token, RsGxsForumGroup &group)
bool p3GxsForums::getForumStatistics(const RsGxsGroupId& ForumId,GxsGroupStatistic& stat)
{
uint32_t token;
if(!RsGxsIfaceHelper::requestGroupStatistic(token, ForumId) || waitToken(token) != RsTokenService::COMPLETE)
return false;
return RsGenExchange::getGroupStatistic(token,stat);
}
bool p3GxsForums::updateGroup(uint32_t &token, const RsGxsForumGroup &group)
{
std::cerr << "p3GxsForums::updateGroup()" << std::endl;

View file

@ -94,6 +94,9 @@ public:
const std::list<RsGxsGroupId>& forumIds,
std::vector<RsGxsForumGroup>& forumsInfo );
/// Implementation of @see RsGxsForums::getForumStatistics
bool getForumStatistics(const RsGxsGroupId& ForumId,GxsGroupStatistic& stat) override;
/// @see RsGxsForums::getForumMsgMetaData
virtual bool getForumMsgMetaData(const RsGxsGroupId& forumId, std::vector<RsMsgMetaData>& msg_metas) ;
@ -125,13 +128,16 @@ public:
std::string& errMsg = RS_DEFAULT_STORAGE_PARAM(std::string)
) override;
virtual bool getGroupData(const uint32_t &token, std::vector<RsGxsForumGroup> &groups);
virtual bool getMsgData(const uint32_t &token, std::vector<RsGxsForumMsg> &msgs);
virtual bool getMsgMetaData(const uint32_t &token, GxsMsgMetaMap& msg_metas);
virtual void setMessageReadStatus(uint32_t& token, const RsGxsGrpMsgIdPair& msgId, bool read);
virtual bool createGroup(uint32_t &token, RsGxsForumGroup &group);
virtual bool createMsg(uint32_t &token, RsGxsForumMsg &msg);
virtual bool updateGroup(uint32_t &token, RsGxsForumGroup &group);
/// implementation of rsGxsGorums
///
bool getGroupData(const uint32_t &token, std::vector<RsGxsForumGroup> &groups) override;
bool getMsgData(const uint32_t &token, std::vector<RsGxsForumMsg> &msgs) override;
void setMessageReadStatus(uint32_t& token, const RsGxsGrpMsgIdPair& msgId, bool read) override;
bool createGroup(uint32_t &token, RsGxsForumGroup &group) override;
bool createMsg(uint32_t &token, RsGxsForumMsg &msg) override;
bool updateGroup(uint32_t &token, const RsGxsForumGroup &group) override;
bool getMsgMetaData(const uint32_t &token, GxsMsgMetaMap& msg_metas) ;
private:

View file

@ -350,5 +350,62 @@ bool p3Posted::getBoardsSummaries(std::list<RsGroupMetaData>& boards )
return getGroupSummary(token, boards);
}
bool p3Posted::getBoardStatistics(const RsGxsGroupId& boardId,GxsGroupStatistic& stat)
{
uint32_t token;
if(!RsGxsIfaceHelper::requestGroupStatistic(token, boardId) || waitToken(token) != RsTokenService::COMPLETE)
return false;
return RsGenExchange::getGroupStatistic(token,stat);
}
bool p3Posted::createBoard(RsPostedGroup& board)
{
uint32_t token;
if(!createGroup(token, board))
{
std::cerr << __PRETTY_FUNCTION__ << "Error! Failed creating group." << std::endl;
return false;
}
if(waitToken(token,std::chrono::milliseconds(5000)) != RsTokenService::COMPLETE)
{
std::cerr << __PRETTY_FUNCTION__ << "Error! GXS operation failed." << std::endl;
return false;
}
if(!RsGenExchange::getPublishedGroupMeta(token, board.mMeta))
{
std::cerr << __PRETTY_FUNCTION__ << "Error! Failure getting updated " << " group data." << std::endl;
return false;
}
return true;
}
bool p3Posted::editBoard(RsPostedGroup& board)
{
uint32_t token;
if(!updateGroup(token, board))
{
std::cerr << __PRETTY_FUNCTION__ << " Error! Failed updating group." << std::endl;
return false;
}
if(waitToken(token) != RsTokenService::COMPLETE)
{
std::cerr << __PRETTY_FUNCTION__ << " Error! GXS operation failed." << std::endl;
return false;
}
if(!RsGenExchange::getPublishedGroupMeta(token, board.mMeta))
{
std::cerr << __PRETTY_FUNCTION__ << " Error! Failure getting updated " << " group data." << std::endl;
return false;
}
return true;
}
RsPosted::~RsPosted() = default;
RsGxsPostedEvent::~RsGxsPostedEvent() = default;

View file

@ -68,6 +68,12 @@ virtual void receiveHelperChanges(std::vector<RsGxsNotify*>& changes)
bool getBoardsSummaries(std::list<RsGroupMetaData>& groupInfo) override;
bool getBoardStatistics(const RsGxsGroupId& boardId,GxsGroupStatistic& stat) override;
bool editBoard(RsPostedGroup& board) override;
bool createBoard(RsPostedGroup& board) override;
virtual bool getGroupData(const uint32_t &token, std::vector<RsPostedGroup> &groups);
virtual bool getPostData(const uint32_t &token, std::vector<RsPostedPost> &posts, std::vector<RsGxsComment> &cmts);
virtual bool getPostData(const uint32_t &token, std::vector<RsPostedPost> &posts) { std::vector<RsGxsComment> cmts; return getPostData( token, posts, cmts);}