removed TokenQueue from UserNotify

This commit is contained in:
csoler 2020-04-04 22:54:54 +02:00
parent 4653f18dd1
commit 28a21392ca
No known key found for this signature in database
GPG key ID: 7BCA522266C0804C
18 changed files with 102 additions and 41 deletions

View file

@ -18,6 +18,7 @@
* *
*******************************************************************************/
#include "retroshare/rsposted.h"
#include "PostedUserNotify.h"
#include "gui/MainWindow.h"
@ -33,6 +34,10 @@ bool PostedUserNotify::hasSetting(QString *name, QString *group)
return true;
}
bool PostedUserNotify::getServiceStatistics(GxsServiceStatistic& stat)
{
return rsPosted->getBoardsServiceStatistics(stat);
}
QIcon PostedUserNotify::getIcon()
{

View file

@ -31,6 +31,7 @@ public:
PostedUserNotify(RsGxsIfaceHelper *ifaceImpl, QObject *parent = 0);
virtual bool hasSetting(QString *name, QString *group);
virtual bool getServiceStatistics(GxsServiceStatistic& stat) override;
private:
virtual QIcon getIcon();

View file

@ -31,51 +31,41 @@ GxsUserNotify::GxsUserNotify(RsGxsIfaceHelper *ifaceImpl, QObject *parent) :
mNewThreadMessageCount = 0;
mNewChildMessageCount = 0;
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()
{
if (mTokenQueue) {
delete(mTokenQueue);
}
//if (mBase) {
//delete(mBase);
//}
}
GxsUserNotify::~GxsUserNotify() {}
void GxsUserNotify::startUpdate()
{
mNewThreadMessageCount = 0;
mNewChildMessageCount = 0;
uint32_t token;
mTokenService->requestServiceStatistic(token);
mTokenQueue->queueRequest(token, 0, RS_TOKREQ_ANSTYPE_ACK, TOKEN_TYPE_STATISTICS);
}
RsThread::async([this]()
{
// 1 - get message data from p3GxsForums
void GxsUserNotify::loadRequest(const TokenQueue *queue, const TokenRequest &req)
{
if (queue == mTokenQueue) {
/* now switch on req */
switch(req.mUserType) {
case TOKEN_TYPE_STATISTICS:
{
GxsServiceStatistic stats;
mInterface->getServiceStatistic(req.mToken, stats);
#ifdef DEBUG_FORUMS
std::cerr << "Retrieving post data for post " << mThreadId << std::endl;
#endif
GxsServiceStatistic stats;
if(!getServiceStatistics(stats))
return;
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;
mNewChildMessageCount = stats.mNumChildMsgsNew;
update();
}
break;
}
}
}, this );
});
}

View file

@ -28,7 +28,7 @@
struct RsGxsIfaceHelper;
class RsGxsUpdateBroadcastBase;
class GxsUserNotify : public UserNotify, public TokenResponse
class GxsUserNotify : public UserNotify
{
Q_OBJECT
@ -36,11 +36,9 @@ public:
GxsUserNotify(RsGxsIfaceHelper *ifaceImpl, QObject *parent = 0);
virtual ~GxsUserNotify();
/* TokenResponse */
virtual void loadRequest(const TokenQueue *queue, const TokenRequest &req);
protected:
virtual void startUpdate();
virtual bool getServiceStatistics(GxsServiceStatistic& stat)=0;
private:
virtual unsigned int getNewCount() { return mCountChildMsgs ? (mNewThreadMessageCount + mNewChildMessageCount) : mNewThreadMessageCount; }
@ -49,9 +47,6 @@ protected:
bool mCountChildMsgs; // Count new child messages?
private:
RsGxsIfaceHelper *mInterface;
RsTokenService *mTokenService;
TokenQueue *mTokenQueue;
RsGxsUpdateBroadcastBase *mBase;
unsigned int mNewThreadMessageCount;
unsigned int mNewChildMessageCount;

View file

@ -18,6 +18,7 @@
* *
*******************************************************************************/
#include "retroshare/rsgxschannels.h"
#include "GxsChannelUserNotify.h"
#include "gui/MainWindow.h"
@ -34,6 +35,11 @@ bool GxsChannelUserNotify::hasSetting(QString *name, QString *group)
return true;
}
bool GxsChannelUserNotify::getServiceStatistics(GxsServiceStatistic& stat)
{
return rsGxsChannels->getChannelServiceStatistics(stat);
}
QIcon GxsChannelUserNotify::getIcon()
{
return QIcon(":/icons/png/channel.png");

View file

@ -31,6 +31,7 @@ public:
GxsChannelUserNotify(RsGxsIfaceHelper *ifaceImpl, QObject *parent = 0);
virtual bool hasSetting(QString *name, QString *group);
virtual bool getServiceStatistics(GxsServiceStatistic& stat) override;
private:
virtual QIcon getIcon();

View file

@ -18,6 +18,7 @@
* *
*******************************************************************************/
#include "retroshare/rsgxsforums.h"
#include "GxsForumUserNotify.h"
#include "gui/MainWindow.h"
@ -34,6 +35,10 @@ bool GxsForumUserNotify::hasSetting(QString *name, QString *group)
return true;
}
bool GxsForumUserNotify::getServiceStatistics(GxsServiceStatistic& stat)
{
return rsGxsForums->getForumServiceStatistics(stat);
}
QIcon GxsForumUserNotify::getIcon()
{

View file

@ -29,6 +29,7 @@ class GxsForumUserNotify : public GxsUserNotify
public:
GxsForumUserNotify(RsGxsIfaceHelper *ifaceImpl, QObject *parent = 0);
virtual bool getServiceStatistics(GxsServiceStatistic& stat) override;
virtual bool hasSetting(QString *name, QString *group);