fixed merge with upstream/master

This commit is contained in:
csoler 2020-04-08 10:41:47 +02:00
commit c60f1d1331
No known key found for this signature in database
GPG key ID: 7BCA522266C0804C
23 changed files with 274 additions and 214 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

@ -22,63 +22,50 @@
//#include "gui/gxs/RsGxsUpdateBroadcastBase.h"
#include "retroshare/rsgxsifacehelper.h"
#include "util/qtthreadsutils.h"
#define TOKEN_TYPE_STATISTICS 1
GxsUserNotify::GxsUserNotify(RsGxsIfaceHelper *ifaceImpl, QObject *parent) :
UserNotify(parent), TokenResponse()
GxsUserNotify::GxsUserNotify(RsGxsIfaceHelper *ifaceImpl, QObject *parent) : UserNotify(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;
RsTokReqOptions opts;
opts.mReqType = GXS_REQUEST_TYPE_SERVICE_STATS;
RsThread::async([this]()
{
// 1 - get message data from p3GxsForums
mTokenService->requestServiceStatistic(token,opts);
mTokenQueue->queueRequest(token, 0, RS_TOKREQ_ANSTYPE_ACK, TOKEN_TYPE_STATISTICS);
}
#ifdef DEBUG_FORUMS
std::cerr << "Retrieving post data for post " << mThreadId << std::endl;
#endif
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);
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);

View file

@ -45,6 +45,7 @@
#include "util/QtVersion.h"
#include "gui/common/UIStateHelper.h"
#include "util/misc.h"
#include "util/qtthreadsutils.h"
#include "gui/gxs/GxsIdLabel.h"
#include "gui/gxs/GxsIdDetails.h"
#include "gui/gxs/GxsIdTreeWidgetItem.h"
@ -85,8 +86,6 @@ GxsTransportStatistics::GxsTransportStatistics(QWidget *parent)
mStateHelper = new UIStateHelper(this);
mStateHelper->addWidget(GXSTRANS_GROUP_META, treeWidget);
mTransQueue = new TokenQueue(rsGxsTrans->getTokenService(), this);
m_bProcessSettings = false;
mLastGroupReqTS = 0 ;
@ -154,7 +153,8 @@ void GxsTransportStatistics::updateDisplay(bool)
std::cerr << "GxsTransportStatistics::updateDisplay()" << std::endl;
#endif
requestGroupMeta();
loadGroups();
mLastGroupReqTS = now ;
}
@ -201,7 +201,7 @@ void GxsTransportStatistics::updateContent()
{
RsGxsTrans::GxsTransStatistics transinfo ;
rsGxsTrans->getStatistics(transinfo) ;
rsGxsTrans->getDataStatistics(transinfo) ;
// clear
@ -333,95 +333,8 @@ void GxsTransportStatistics::personDetails()
dialog->show();
}
void GxsTransportStatistics::loadRequest(const TokenQueue *queue, const TokenRequest &req)
{
#ifdef DEBUG_GXSTRANS_STATS
std::cerr << "GxsTransportStatistics::loadRequest() UserType: " << req.mUserType << std::endl;
#endif
if (queue != mTransQueue)
{
std::cerr << "Wrong queue!" << std::endl;
return ;
}
/* now switch on req */
switch(req.mUserType)
{
case GXSTRANS_GROUP_META: loadGroupMeta(req.mToken);
break;
case GXSTRANS_GROUP_STAT: loadGroupStat(req.mToken);
break;
case GXSTRANS_MSG_META: loadMsgMeta(req.mToken);
break;
default:
std::cerr << "GxsTransportStatistics::loadRequest() ERROR: INVALID TYPE";
std::cerr << std::endl;
break;
}
updateContent();
}
void GxsTransportStatistics::requestGroupMeta()
{
mStateHelper->setLoading(GXSTRANS_GROUP_META, true);
#ifdef DEBUG_GXSTRANS_STATS
std::cerr << "GxsTransportStatisticsWidget::requestGroupMeta()";
std::cerr << std::endl;
#endif
RsTokReqOptions opts;
opts.mReqType = GXS_REQUEST_TYPE_GROUP_META;
uint32_t token;
mTransQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_SUMMARY, opts, GXSTRANS_GROUP_META);
}
void GxsTransportStatistics::requestGroupStat(const RsGxsGroupId &groupId)
{
uint32_t token;
RsTokReqOptions opts;
opts.mReqType = GXS_REQUEST_TYPE_GROUP_STATS;
rsGxsTrans->getTokenService()->requestGroupStatistic(token, groupId,opts);
mTransQueue->queueRequest(token, 0, RS_TOKREQ_ANSTYPE_ACK, GXSTRANS_GROUP_STAT);
}
void GxsTransportStatistics::requestMsgMeta(const RsGxsGroupId& grpId)
{
mStateHelper->setLoading(GXSTRANS_MSG_META, true);
#ifdef DEBUG_GXSTRANS_STATS
std::cerr << "GxsTransportStatisticsWidget::requestGroupMeta()";
std::cerr << std::endl;
#endif
RsTokReqOptions opts;
opts.mReqType = GXS_REQUEST_TYPE_MSG_META;
std::list<RsGxsGroupId> grouplist ;
grouplist.push_back(grpId) ;
uint32_t token;
rsGxsTrans->getTokenService()->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_SUMMARY, opts, grouplist);
mTransQueue->queueRequest(token, 0, RS_TOKREQ_ANSTYPE_ACK, GXSTRANS_MSG_META);
}
void GxsTransportStatistics::loadGroupStat(const uint32_t &token)
{
GxsGroupStatistic stats;
rsGxsTrans->getGroupStatistic(token, stats);
#ifdef DEBUG_GXSTRANS_STATS
std::cerr << "Loading group stats: " << stats.mGrpId << ", num msgs=" << stats.mNumMsgs << ", total size=" << stats.mTotalSizeOfMsgs << std::endl;
#endif
dynamic_cast<GxsGroupStatistic&>(mGroupStats[stats.mGrpId]) = stats ;
}
void GxsTransportStatistics::loadGroupMeta(const uint32_t& token)
#ifdef TO_REMOVE
void GxsTransportStatistics::loadGroupMeta(const std::vector<RsGroupMetaData>& groupInfo)
{
mStateHelper->setLoading(GXSTRANS_GROUP_META, false);
@ -430,22 +343,11 @@ void GxsTransportStatistics::loadGroupMeta(const uint32_t& token)
std::cerr << std::endl;
#endif
std::list<RsGroupMetaData> groupInfo;
std::list<RsGroupMetaData>::iterator vit;
if (!rsGxsTrans->getGroupSummary(token,groupInfo))
{
std::cerr << "GxsTransportStatistics::loadGroupMeta() Error getting GroupMeta";
std::cerr << std::endl;
mStateHelper->setActive(GXSTRANS_GROUP_META, false);
return;
}
mStateHelper->setActive(GXSTRANS_GROUP_META, true);
std::set<RsGxsGroupId> existing_groups ;
for(vit = groupInfo.begin(); vit != groupInfo.end(); ++vit)
for(auto vit = groupInfo.begin(); vit != groupInfo.end(); ++vit)
{
existing_groups.insert(vit->mGroupId) ;
@ -454,8 +356,8 @@ void GxsTransportStatistics::loadGroupMeta(const uint32_t& token)
std::cerr << "GxsTransportStatisticsWidget::loadGroupMeta() GroupId: " << vit->mGroupId << " Group: " << vit->mGroupName << std::endl;
#endif
requestGroupStat(vit->mGroupId) ;
requestMsgMeta(vit->mGroupId) ;
loadGroupStats(vit->mGroupId) ;
loadMsgMetas(vit->mGroupId) ;
RsGxsTransGroupStatistics& s(mGroupStats[vit->mGroupId]);
s.popularity = vit->mPop ;
@ -472,17 +374,74 @@ void GxsTransportStatistics::loadGroupMeta(const uint32_t& token)
++it;
}
void GxsTransportStatistics::loadMsgMeta(const uint32_t& token)
void GxsTransportStatistics::loadGroupStats(const RsGxsGroupId& groupId)
{
mStateHelper->setLoading(GXSTRANS_MSG_META, false);
#ifdef DEBUG_GXSTRANS_STATS
std::cerr << "Loading group stats: " << stats.mGrpId << ", num msgs=" << stats.mNumMsgs << ", total size=" << stats.mTotalSizeOfMsgs << std::endl;
#endif
GxsMsgMetaMap m ;
RsThread::async([this]()
{
// 1 - get message data from p3GxsForums
if (!rsGxsTrans->getMsgSummary(token,m))
return ;
#ifdef DEBUG_FORUMS
std::cerr << "Retrieving post data for post " << mThreadId << std::endl;
#endif
GxsGroupStatistic stats;
rsGxsTrans->getGroupStatistic(groupId,stats);
for(GxsMsgMetaMap::const_iterator it(m.begin());it!=m.end();++it)
for(uint32_t i=0;i<it->second.size();++i)
mGroupStats[it->first].addMessageMeta(it->first,it->second[i]) ;
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 */
dynamic_cast<GxsGroupStatistic&>(mGroupStats[stats.mGrpId]) = stats ;
mStateHelper->setLoading(GXSTRANS_GROUP_STAT, false);
}, this );
});
}
#endif
void GxsTransportStatistics::loadGroups()
{
mStateHelper->setLoading(GXSTRANS_GROUP_META, true);
RsThread::async([this]()
{
// 1 - get message data from p3GxsForums
#ifdef DEBUG_FORUMS
std::cerr << "Retrieving post data for post " << mThreadId << std::endl;
#endif
std::map<RsGxsGroupId,RsGxsTransGroupStatistics> stats;
if(!rsGxsTrans->getGroupStatistics(stats))
{
RsErr() << "Cannot retrieve group statistics in GxsTransportStatistics" << std::endl;
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 */
mGroupStats = stats;
updateContent();
mStateHelper->setLoading(GXSTRANS_GROUP_META, false);
}, this );
});
}

View file

@ -25,8 +25,8 @@
#include <QPoint>
#include <retroshare/rsgrouter.h>
#include <retroshare/rstypes.h>
#include <retroshare/rsgxstrans.h>
#include "util/TokenQueue.h"
#include "RsAutoUpdatePage.h"
#include "ui_GxsTransportStatistics.h"
#include "gui/gxs/RsGxsUpdateBroadcastPage.h"
@ -35,32 +35,7 @@
class GxsTransportStatisticsWidget ;
class UIStateHelper;
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 ;
};
class GxsTransportStatistics: public MainPage, public TokenResponse, public Ui::GxsTransportStatistics
class GxsTransportStatistics: public MainPage, public Ui::GxsTransportStatistics
{
Q_OBJECT
@ -71,8 +46,6 @@ public:
// Cache for peer names.
static QString getPeerName(const RsPeerId& peer_id) ;
virtual void loadRequest(const TokenQueue *queue, const TokenRequest &req) ;
void updateContent() ;
private slots:
@ -82,19 +55,12 @@ private slots:
private:
void updateDisplay(bool complete) ;
void loadGroupMeta(const uint32_t& token);
void loadGroupStat(const uint32_t& token);
void loadMsgMeta(const uint32_t& token);
void requestGroupMeta();
void requestMsgMeta(const RsGxsGroupId& groupId);
void requestGroupStat(const RsGxsGroupId &groupId);
void loadGroups();
void processSettings(bool bLoad);
bool m_bProcessSettings;
GxsTransportStatisticsWidget *_tst_CW ;
TokenQueue *mTransQueue ;
UIStateHelper *mStateHelper;
uint32_t mLastGroupReqTS ;