mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-07 08:35:16 -04:00
removed TokenQueue from UserNotify
This commit is contained in:
parent
4653f18dd1
commit
28a21392ca
18 changed files with 102 additions and 41 deletions
|
@ -409,6 +409,14 @@ public:
|
||||||
virtual bool subscribeToChannel( const RsGxsGroupId& channelId,
|
virtual bool subscribeToChannel( const RsGxsGroupId& channelId,
|
||||||
bool subscribe ) = 0;
|
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
|
* \brief Retrieve statistics about the given channel
|
||||||
* @jsonapi{development}
|
* @jsonapi{development}
|
||||||
|
@ -418,6 +426,7 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual bool getChannelStatistics(const RsGxsGroupId& channelId,GxsGroupStatistic& stat) =0;
|
virtual bool getChannelStatistics(const RsGxsGroupId& channelId,GxsGroupStatistic& stat) =0;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Request remote channels search
|
* @brief Request remote channels search
|
||||||
* @jsonapi{development}
|
* @jsonapi{development}
|
||||||
|
|
|
@ -219,6 +219,14 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual bool getForumsSummaries(std::list<RsGroupMetaData>& forums) = 0;
|
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
|
* @brief returns statistics about a particular forum
|
||||||
* @jsonapi{development}
|
* @jsonapi{development}
|
||||||
|
@ -228,6 +236,7 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual bool getForumStatistics(const RsGxsGroupId& forumId,GxsGroupStatistic& stat)=0;
|
virtual bool getForumStatistics(const RsGxsGroupId& forumId,GxsGroupStatistic& stat)=0;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get forums information (description, thumbnail...).
|
* @brief Get forums information (description, thumbnail...).
|
||||||
* Blocking API.
|
* Blocking API.
|
||||||
|
|
|
@ -355,7 +355,7 @@ public:
|
||||||
{ return mTokenService.requestStatus(token); }
|
{ return mTokenService.requestStatus(token); }
|
||||||
|
|
||||||
/// @see RsTokenService::requestServiceStatistic
|
/// @see RsTokenService::requestServiceStatistic
|
||||||
void requestServiceStatistic(uint32_t& token)
|
bool requestServiceStatistic(uint32_t& token)
|
||||||
{
|
{
|
||||||
mTokenService.requestServiceStatistic(token);
|
mTokenService.requestServiceStatistic(token);
|
||||||
|
|
||||||
|
@ -363,6 +363,7 @@ public:
|
||||||
mActiveTokens[token]=TokenRequestType::SERVICE_STATISTICS;
|
mActiveTokens[token]=TokenRequestType::SERVICE_STATISTICS;
|
||||||
|
|
||||||
locked_dumpTokens();
|
locked_dumpTokens();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @see RsTokenService::requestGroupStatistic
|
/// @see RsTokenService::requestGroupStatistic
|
||||||
|
|
|
@ -167,6 +167,8 @@ public:
|
||||||
|
|
||||||
virtual bool getBoardStatistics(const RsGxsGroupId& boardId,GxsGroupStatistic& stat) =0;
|
virtual bool getBoardStatistics(const RsGxsGroupId& boardId,GxsGroupStatistic& stat) =0;
|
||||||
|
|
||||||
|
virtual bool getBoardsServiceStatistics(GxsServiceStatistic& stat) =0;
|
||||||
|
|
||||||
enum RS_DEPRECATED RankType {TopRankType, HotRankType, NewRankType };
|
enum RS_DEPRECATED RankType {TopRankType, HotRankType, NewRankType };
|
||||||
|
|
||||||
RS_DEPRECATED_FOR(getBoardsInfo)
|
RS_DEPRECATED_FOR(getBoardsInfo)
|
||||||
|
|
|
@ -1062,6 +1062,15 @@ bool p3GxsChannels::getChannelStatistics(const RsGxsGroupId& channelId,GxsGroupS
|
||||||
return RsGenExchange::getGroupStatistic(token,stat);
|
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(
|
bool p3GxsChannels::getContentSummaries(
|
||||||
const RsGxsGroupId& channelId, std::vector<RsMsgMetaData>& summaries )
|
const RsGxsGroupId& channelId, std::vector<RsMsgMetaData>& summaries )
|
||||||
{
|
{
|
||||||
|
|
|
@ -204,6 +204,9 @@ virtual bool ExtraFileRemove(const RsFileHash &hash);
|
||||||
/// Implementation of @see RsGxsChannels::getChannelStatistics
|
/// Implementation of @see RsGxsChannels::getChannelStatistics
|
||||||
bool getChannelStatistics(const RsGxsGroupId& channelId,GxsGroupStatistic& stat) override;
|
bool getChannelStatistics(const RsGxsGroupId& channelId,GxsGroupStatistic& stat) override;
|
||||||
|
|
||||||
|
/// Iplementation of @see RsGxsChannels::getChannelServiceStatistics
|
||||||
|
bool getChannelServiceStatistics(GxsServiceStatistic& stat) override;
|
||||||
|
|
||||||
/// Implementation of @see RsGxsChannels::createChannelV2
|
/// Implementation of @see RsGxsChannels::createChannelV2
|
||||||
bool createChannelV2(
|
bool createChannelV2(
|
||||||
const std::string& name, const std::string& description,
|
const std::string& name, const std::string& description,
|
||||||
|
|
|
@ -819,6 +819,15 @@ bool p3GxsForums::createGroup(uint32_t &token, RsGxsForumGroup &group)
|
||||||
return true;
|
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)
|
bool p3GxsForums::getForumStatistics(const RsGxsGroupId& ForumId,GxsGroupStatistic& stat)
|
||||||
{
|
{
|
||||||
uint32_t token;
|
uint32_t token;
|
||||||
|
|
|
@ -97,6 +97,9 @@ public:
|
||||||
/// Implementation of @see RsGxsForums::getForumStatistics
|
/// Implementation of @see RsGxsForums::getForumStatistics
|
||||||
bool getForumStatistics(const RsGxsGroupId& ForumId,GxsGroupStatistic& stat) override;
|
bool getForumStatistics(const RsGxsGroupId& ForumId,GxsGroupStatistic& stat) override;
|
||||||
|
|
||||||
|
/// Implementation of @see RsGxsForums::getForumServiceStatistics
|
||||||
|
bool getForumServiceStatistics(GxsServiceStatistic& stat) override;
|
||||||
|
|
||||||
/// @see RsGxsForums::getForumMsgMetaData
|
/// @see RsGxsForums::getForumMsgMetaData
|
||||||
virtual bool getForumMsgMetaData(const RsGxsGroupId& forumId, std::vector<RsMsgMetaData>& msg_metas) ;
|
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);
|
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)
|
bool p3Posted::getBoardStatistics(const RsGxsGroupId& boardId,GxsGroupStatistic& stat)
|
||||||
{
|
{
|
||||||
uint32_t token;
|
uint32_t token;
|
||||||
|
|
|
@ -74,6 +74,8 @@ virtual void receiveHelperChanges(std::vector<RsGxsNotify*>& changes)
|
||||||
|
|
||||||
bool getBoardStatistics(const RsGxsGroupId& boardId,GxsGroupStatistic& stat) override;
|
bool getBoardStatistics(const RsGxsGroupId& boardId,GxsGroupStatistic& stat) override;
|
||||||
|
|
||||||
|
bool getBoardsServiceStatistics(GxsServiceStatistic& stat) override;
|
||||||
|
|
||||||
bool editBoard(RsPostedGroup& board) override;
|
bool editBoard(RsPostedGroup& board) override;
|
||||||
|
|
||||||
bool createBoard(RsPostedGroup& board) override;
|
bool createBoard(RsPostedGroup& board) override;
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
* *
|
* *
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
|
#include "retroshare/rsposted.h"
|
||||||
#include "PostedUserNotify.h"
|
#include "PostedUserNotify.h"
|
||||||
#include "gui/MainWindow.h"
|
#include "gui/MainWindow.h"
|
||||||
|
|
||||||
|
@ -33,6 +34,10 @@ bool PostedUserNotify::hasSetting(QString *name, QString *group)
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
bool PostedUserNotify::getServiceStatistics(GxsServiceStatistic& stat)
|
||||||
|
{
|
||||||
|
return rsPosted->getBoardsServiceStatistics(stat);
|
||||||
|
}
|
||||||
|
|
||||||
QIcon PostedUserNotify::getIcon()
|
QIcon PostedUserNotify::getIcon()
|
||||||
{
|
{
|
||||||
|
|
|
@ -31,6 +31,7 @@ public:
|
||||||
PostedUserNotify(RsGxsIfaceHelper *ifaceImpl, QObject *parent = 0);
|
PostedUserNotify(RsGxsIfaceHelper *ifaceImpl, QObject *parent = 0);
|
||||||
|
|
||||||
virtual bool hasSetting(QString *name, QString *group);
|
virtual bool hasSetting(QString *name, QString *group);
|
||||||
|
virtual bool getServiceStatistics(GxsServiceStatistic& stat) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual QIcon getIcon();
|
virtual QIcon getIcon();
|
||||||
|
|
|
@ -31,51 +31,41 @@ GxsUserNotify::GxsUserNotify(RsGxsIfaceHelper *ifaceImpl, QObject *parent) :
|
||||||
mNewThreadMessageCount = 0;
|
mNewThreadMessageCount = 0;
|
||||||
mNewChildMessageCount = 0;
|
mNewChildMessageCount = 0;
|
||||||
mCountChildMsgs = false;
|
mCountChildMsgs = false;
|
||||||
|
|
||||||
mInterface = ifaceImpl;
|
|
||||||
mTokenService = mInterface->getTokenService();
|
|
||||||
mTokenQueue = new TokenQueue(mInterface->getTokenService(), this);
|
|
||||||
|
|
||||||
//mBase = new RsGxsUpdateBroadcastBase(ifaceImpl);
|
|
||||||
//connect(mBase, SIGNAL(fillDisplay(bool)), this, SLOT(updateIcon()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GxsUserNotify::~GxsUserNotify()
|
GxsUserNotify::~GxsUserNotify() {}
|
||||||
{
|
|
||||||
if (mTokenQueue) {
|
|
||||||
delete(mTokenQueue);
|
|
||||||
}
|
|
||||||
//if (mBase) {
|
|
||||||
//delete(mBase);
|
|
||||||
//}
|
|
||||||
}
|
|
||||||
|
|
||||||
void GxsUserNotify::startUpdate()
|
void GxsUserNotify::startUpdate()
|
||||||
{
|
{
|
||||||
mNewThreadMessageCount = 0;
|
mNewThreadMessageCount = 0;
|
||||||
mNewChildMessageCount = 0;
|
mNewChildMessageCount = 0;
|
||||||
|
|
||||||
uint32_t token;
|
RsThread::async([this]()
|
||||||
mTokenService->requestServiceStatistic(token);
|
{
|
||||||
mTokenQueue->queueRequest(token, 0, RS_TOKREQ_ANSTYPE_ACK, TOKEN_TYPE_STATISTICS);
|
// 1 - get message data from p3GxsForums
|
||||||
}
|
|
||||||
|
|
||||||
void GxsUserNotify::loadRequest(const TokenQueue *queue, const TokenRequest &req)
|
#ifdef DEBUG_FORUMS
|
||||||
{
|
std::cerr << "Retrieving post data for post " << mThreadId << std::endl;
|
||||||
if (queue == mTokenQueue) {
|
#endif
|
||||||
/* now switch on req */
|
|
||||||
switch(req.mUserType) {
|
GxsServiceStatistic stats;
|
||||||
case TOKEN_TYPE_STATISTICS:
|
|
||||||
{
|
if(!getServiceStatistics(stats))
|
||||||
GxsServiceStatistic stats;
|
return;
|
||||||
mInterface->getServiceStatistic(req.mToken, stats);
|
|
||||||
|
RsQThreadUtils::postToObject( [stats,this]()
|
||||||
|
{
|
||||||
|
/* Here it goes any code you want to be executed on the Qt Gui
|
||||||
|
* thread, for example to update the data model with new information
|
||||||
|
* after a blocking call to RetroShare API complete */
|
||||||
|
|
||||||
mNewThreadMessageCount = stats.mNumThreadMsgsNew;
|
mNewThreadMessageCount = stats.mNumThreadMsgsNew;
|
||||||
mNewChildMessageCount = stats.mNumChildMsgsNew;
|
mNewChildMessageCount = stats.mNumChildMsgsNew;
|
||||||
|
|
||||||
update();
|
update();
|
||||||
}
|
|
||||||
break;
|
}, this );
|
||||||
}
|
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
struct RsGxsIfaceHelper;
|
struct RsGxsIfaceHelper;
|
||||||
class RsGxsUpdateBroadcastBase;
|
class RsGxsUpdateBroadcastBase;
|
||||||
|
|
||||||
class GxsUserNotify : public UserNotify, public TokenResponse
|
class GxsUserNotify : public UserNotify
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
@ -36,11 +36,9 @@ public:
|
||||||
GxsUserNotify(RsGxsIfaceHelper *ifaceImpl, QObject *parent = 0);
|
GxsUserNotify(RsGxsIfaceHelper *ifaceImpl, QObject *parent = 0);
|
||||||
virtual ~GxsUserNotify();
|
virtual ~GxsUserNotify();
|
||||||
|
|
||||||
/* TokenResponse */
|
|
||||||
virtual void loadRequest(const TokenQueue *queue, const TokenRequest &req);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void startUpdate();
|
virtual void startUpdate();
|
||||||
|
virtual bool getServiceStatistics(GxsServiceStatistic& stat)=0;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual unsigned int getNewCount() { return mCountChildMsgs ? (mNewThreadMessageCount + mNewChildMessageCount) : mNewThreadMessageCount; }
|
virtual unsigned int getNewCount() { return mCountChildMsgs ? (mNewThreadMessageCount + mNewChildMessageCount) : mNewThreadMessageCount; }
|
||||||
|
@ -49,9 +47,6 @@ protected:
|
||||||
bool mCountChildMsgs; // Count new child messages?
|
bool mCountChildMsgs; // Count new child messages?
|
||||||
|
|
||||||
private:
|
private:
|
||||||
RsGxsIfaceHelper *mInterface;
|
|
||||||
RsTokenService *mTokenService;
|
|
||||||
TokenQueue *mTokenQueue;
|
|
||||||
RsGxsUpdateBroadcastBase *mBase;
|
RsGxsUpdateBroadcastBase *mBase;
|
||||||
unsigned int mNewThreadMessageCount;
|
unsigned int mNewThreadMessageCount;
|
||||||
unsigned int mNewChildMessageCount;
|
unsigned int mNewChildMessageCount;
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
* *
|
* *
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
|
#include "retroshare/rsgxschannels.h"
|
||||||
#include "GxsChannelUserNotify.h"
|
#include "GxsChannelUserNotify.h"
|
||||||
#include "gui/MainWindow.h"
|
#include "gui/MainWindow.h"
|
||||||
|
|
||||||
|
@ -34,6 +35,11 @@ bool GxsChannelUserNotify::hasSetting(QString *name, QString *group)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool GxsChannelUserNotify::getServiceStatistics(GxsServiceStatistic& stat)
|
||||||
|
{
|
||||||
|
return rsGxsChannels->getChannelServiceStatistics(stat);
|
||||||
|
}
|
||||||
|
|
||||||
QIcon GxsChannelUserNotify::getIcon()
|
QIcon GxsChannelUserNotify::getIcon()
|
||||||
{
|
{
|
||||||
return QIcon(":/icons/png/channel.png");
|
return QIcon(":/icons/png/channel.png");
|
||||||
|
|
|
@ -31,6 +31,7 @@ public:
|
||||||
GxsChannelUserNotify(RsGxsIfaceHelper *ifaceImpl, QObject *parent = 0);
|
GxsChannelUserNotify(RsGxsIfaceHelper *ifaceImpl, QObject *parent = 0);
|
||||||
|
|
||||||
virtual bool hasSetting(QString *name, QString *group);
|
virtual bool hasSetting(QString *name, QString *group);
|
||||||
|
virtual bool getServiceStatistics(GxsServiceStatistic& stat) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual QIcon getIcon();
|
virtual QIcon getIcon();
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
* *
|
* *
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
|
#include "retroshare/rsgxsforums.h"
|
||||||
#include "GxsForumUserNotify.h"
|
#include "GxsForumUserNotify.h"
|
||||||
#include "gui/MainWindow.h"
|
#include "gui/MainWindow.h"
|
||||||
|
|
||||||
|
@ -34,6 +35,10 @@ bool GxsForumUserNotify::hasSetting(QString *name, QString *group)
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
bool GxsForumUserNotify::getServiceStatistics(GxsServiceStatistic& stat)
|
||||||
|
{
|
||||||
|
return rsGxsForums->getForumServiceStatistics(stat);
|
||||||
|
}
|
||||||
|
|
||||||
QIcon GxsForumUserNotify::getIcon()
|
QIcon GxsForumUserNotify::getIcon()
|
||||||
{
|
{
|
||||||
|
|
|
@ -29,6 +29,7 @@ class GxsForumUserNotify : public GxsUserNotify
|
||||||
|
|
||||||
public:
|
public:
|
||||||
GxsForumUserNotify(RsGxsIfaceHelper *ifaceImpl, QObject *parent = 0);
|
GxsForumUserNotify(RsGxsIfaceHelper *ifaceImpl, QObject *parent = 0);
|
||||||
|
virtual bool getServiceStatistics(GxsServiceStatistic& stat) override;
|
||||||
|
|
||||||
virtual bool hasSetting(QString *name, QString *group);
|
virtual bool hasSetting(QString *name, QString *group);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue