mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-13 17:13:06 -04:00
- Added two new members to GxsGroupStatistic/GxsServiceStatistic - mNumMsgsNew, mNumMsgsUnread
- Set mGrpId on GxsGroupStatistic - Changed GxsUserNotify and GxsGroupFrameDialog to statistics git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7462 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
5399618cef
commit
9c3266fdd9
6 changed files with 50 additions and 102 deletions
|
@ -1460,12 +1460,25 @@ bool RsGxsDataAccess::getGroupStatistic(GroupStatisticRequest *req)
|
||||||
|
|
||||||
std::vector<RsGxsMsgMetaData*>& msgMetaV = metaResult[req->mGrpId];
|
std::vector<RsGxsMsgMetaData*>& msgMetaV = metaResult[req->mGrpId];
|
||||||
|
|
||||||
|
req->mGroupStatistic.mGrpId = req->mGrpId;
|
||||||
req->mGroupStatistic.mNumMsgs = msgMetaV.size();
|
req->mGroupStatistic.mNumMsgs = msgMetaV.size();
|
||||||
req->mGroupStatistic.mTotalSizeOfMsgs = 0;
|
req->mGroupStatistic.mTotalSizeOfMsgs = 0;
|
||||||
|
req->mGroupStatistic.mNumMsgsNew = 0;
|
||||||
|
req->mGroupStatistic.mNumMsgsUnread = 0;
|
||||||
|
|
||||||
for(int i = 0; i < msgMetaV.size(); i++)
|
for(int i = 0; i < msgMetaV.size(); i++)
|
||||||
{
|
{
|
||||||
RsGxsMsgMetaData* m = msgMetaV[i];
|
RsGxsMsgMetaData* m = msgMetaV[i];
|
||||||
req->mGroupStatistic.mTotalSizeOfMsgs += m->mMsgSize + m->serial_size();
|
req->mGroupStatistic.mTotalSizeOfMsgs += m->mMsgSize + m->serial_size();
|
||||||
|
|
||||||
|
if (IS_MSG_NEW(m->mMsgStatus))
|
||||||
|
{
|
||||||
|
++req->mGroupStatistic.mNumMsgsNew;
|
||||||
|
}
|
||||||
|
if (IS_MSG_UNREAD(m->mMsgStatus))
|
||||||
|
{
|
||||||
|
++req->mGroupStatistic.mNumMsgsUnread;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cleanseMsgMetaMap(metaResult);
|
cleanseMsgMetaMap(metaResult);
|
||||||
|
@ -1485,6 +1498,8 @@ bool RsGxsDataAccess::getServiceStatistic(ServiceStatisticRequest *req)
|
||||||
req->mServiceStatistic.mSizeOfGrps = 0;
|
req->mServiceStatistic.mSizeOfGrps = 0;
|
||||||
req->mServiceStatistic.mSizeOfMsgs = 0;
|
req->mServiceStatistic.mSizeOfMsgs = 0;
|
||||||
req->mServiceStatistic.mNumGrpsSubscribed = 0;
|
req->mServiceStatistic.mNumGrpsSubscribed = 0;
|
||||||
|
req->mServiceStatistic.mNumMsgsNew = 0;
|
||||||
|
req->mServiceStatistic.mNumMsgsUnread = 0;
|
||||||
|
|
||||||
for(; mit != grpMeta.end(); mit++)
|
for(; mit != grpMeta.end(); mit++)
|
||||||
{
|
{
|
||||||
|
@ -1496,6 +1511,8 @@ bool RsGxsDataAccess::getServiceStatistic(ServiceStatisticRequest *req)
|
||||||
req->mServiceStatistic.mNumMsgs += gr.mGroupStatistic.mNumMsgs;
|
req->mServiceStatistic.mNumMsgs += gr.mGroupStatistic.mNumMsgs;
|
||||||
req->mServiceStatistic.mSizeOfMsgs += gr.mGroupStatistic.mTotalSizeOfMsgs;
|
req->mServiceStatistic.mSizeOfMsgs += gr.mGroupStatistic.mTotalSizeOfMsgs;
|
||||||
req->mServiceStatistic.mNumGrpsSubscribed += m->mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_SUBSCRIBED ? 1 : 0;
|
req->mServiceStatistic.mNumGrpsSubscribed += m->mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_SUBSCRIBED ? 1 : 0;
|
||||||
|
req->mServiceStatistic.mNumMsgsNew += gr.mGroupStatistic.mNumMsgsNew;
|
||||||
|
req->mServiceStatistic.mNumMsgsUnread += gr.mGroupStatistic.mNumMsgsUnread;
|
||||||
|
|
||||||
delete m;
|
delete m;
|
||||||
}
|
}
|
||||||
|
|
|
@ -139,6 +139,8 @@ public:
|
||||||
RsGxsGroupId mGrpId;
|
RsGxsGroupId mGrpId;
|
||||||
uint32_t mNumMsgs;
|
uint32_t mNumMsgs;
|
||||||
uint32_t mTotalSizeOfMsgs;
|
uint32_t mTotalSizeOfMsgs;
|
||||||
|
uint32_t mNumMsgsNew;
|
||||||
|
uint32_t mNumMsgsUnread;
|
||||||
};
|
};
|
||||||
|
|
||||||
class GxsServiceStatistic
|
class GxsServiceStatistic
|
||||||
|
@ -150,6 +152,8 @@ public:
|
||||||
uint32_t mSizeOfMsgs;
|
uint32_t mSizeOfMsgs;
|
||||||
uint32_t mSizeOfGrps;
|
uint32_t mSizeOfGrps;
|
||||||
uint32_t mNumGrpsSubscribed;
|
uint32_t mNumGrpsSubscribed;
|
||||||
|
uint32_t mNumMsgsNew;
|
||||||
|
uint32_t mNumMsgsUnread;
|
||||||
uint32_t mSizeStore;
|
uint32_t mSizeStore;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -82,6 +82,7 @@ GxsGroupFrameDialog::GxsGroupFrameDialog(RsGxsIfaceHelper *ifaceImpl, QWidget *p
|
||||||
|
|
||||||
/* Setup Queue */
|
/* Setup Queue */
|
||||||
mInterface = ifaceImpl;
|
mInterface = ifaceImpl;
|
||||||
|
mTokenService = mInterface->getTokenService();
|
||||||
mTokenQueue = new TokenQueue(mInterface->getTokenService(), this);
|
mTokenQueue = new TokenQueue(mInterface->getTokenService(), this);
|
||||||
|
|
||||||
/* Setup UI helper */
|
/* Setup UI helper */
|
||||||
|
@ -203,8 +204,13 @@ void GxsGroupFrameDialog::updateDisplay(bool complete)
|
||||||
/* Update group list */
|
/* Update group list */
|
||||||
requestGroupSummary();
|
requestGroupSummary();
|
||||||
} else {
|
} else {
|
||||||
if (!getMsgIds().empty() || !getMsgIdsMeta().empty()) {
|
/* Update all groups of changed messages */
|
||||||
updateMessageSummaryList(RsGxsGroupId());
|
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > msgIds;
|
||||||
|
getAllMsgIds(msgIds);
|
||||||
|
|
||||||
|
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> >::iterator msgIt;
|
||||||
|
for (msgIt = msgIds.begin(); msgIt != msgIds.end(); ++msgIt) {
|
||||||
|
updateMessageSummaryList(msgIt->first);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -745,8 +751,6 @@ void GxsGroupFrameDialog::updateMessageSummaryList(RsGxsGroupId groupId)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::list<RsGxsGroupId> groupIds;
|
|
||||||
|
|
||||||
if (groupId.isNull()) {
|
if (groupId.isNull()) {
|
||||||
QTreeWidgetItem *items[2] = { mYourGroups, mSubscribedGroups };
|
QTreeWidgetItem *items[2] = { mYourGroups, mSubscribedGroups };
|
||||||
for (int item = 0; item < 2; item++) {
|
for (int item = 0; item < 2; item++) {
|
||||||
|
@ -759,14 +763,12 @@ void GxsGroupFrameDialog::updateMessageSummaryList(RsGxsGroupId groupId)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
groupIds.push_back(RsGxsGroupId(childId.toLatin1().constData()));
|
requestGroupStatistics(RsGxsGroupId(childId.toLatin1().constData()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
groupIds.push_back(groupId);
|
requestGroupStatistics(groupId);
|
||||||
}
|
}
|
||||||
|
|
||||||
requestGroupStatistics(groupIds);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*********************** **** **** **** ***********************/
|
/*********************** **** **** **** ***********************/
|
||||||
|
@ -878,48 +880,24 @@ void GxsGroupFrameDialog::loadGroupSummary(const uint32_t &token)
|
||||||
/*********************** **** **** **** ***********************/
|
/*********************** **** **** **** ***********************/
|
||||||
/*********************** **** **** **** ***********************/
|
/*********************** **** **** **** ***********************/
|
||||||
|
|
||||||
void GxsGroupFrameDialog::requestGroupStatistics(const std::list<RsGxsGroupId> &groupIds)
|
void GxsGroupFrameDialog::requestGroupStatistics(const RsGxsGroupId &groupId)
|
||||||
{
|
{
|
||||||
// uint32_t token;
|
|
||||||
// GxsServiceStatistic stats;
|
|
||||||
// mInterface->getGroupStatistic(token, stats);
|
|
||||||
// TokenQueue->queueRequest(token, 0, RS_TOKREQ_ANSTYPE_ACK, TOKEN_TYPE_STATISTICS);
|
|
||||||
|
|
||||||
mTokenQueue->cancelActiveRequestTokens(TOKEN_TYPE_STATISTICS);
|
|
||||||
|
|
||||||
RsTokReqOptions opts;
|
|
||||||
opts.mReqType = GXS_REQUEST_TYPE_MSG_META;
|
|
||||||
|
|
||||||
uint32_t token;
|
uint32_t token;
|
||||||
mTokenQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, groupIds, TOKEN_TYPE_STATISTICS);
|
mTokenService->requestGroupStatistic(token, groupId);
|
||||||
|
mTokenQueue->queueRequest(token, 0, RS_TOKREQ_ANSTYPE_ACK, TOKEN_TYPE_STATISTICS);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GxsGroupFrameDialog::loadGroupStatistics(const uint32_t &token)
|
void GxsGroupFrameDialog::loadGroupStatistics(const uint32_t &token)
|
||||||
{
|
{
|
||||||
GxsMsgMetaMap msgList;
|
GxsGroupStatistic stats;
|
||||||
mInterface->getMsgSummary(token, msgList);
|
mInterface->getGroupStatistic(token, stats);
|
||||||
|
|
||||||
GxsMsgMetaMap::const_iterator groupIt;
|
QTreeWidgetItem *item = ui->groupTreeWidget->getItemFromId(QString::fromStdString(stats.mGrpId.toStdString()));
|
||||||
for (groupIt = msgList.begin(); groupIt != msgList.end(); ++groupIt) {
|
|
||||||
const RsGxsGroupId &groupId = groupIt->first;
|
|
||||||
QTreeWidgetItem *item = ui->groupTreeWidget->getItemFromId(QString::fromStdString(groupId.toStdString()));
|
|
||||||
if (!item) {
|
if (!item) {
|
||||||
continue;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::vector<RsMsgMetaData> &groupData = groupIt->second;
|
ui->groupTreeWidget->setUnreadCount(item, stats.mNumMsgsUnread);
|
||||||
|
|
||||||
unsigned int newCount = 0;
|
|
||||||
std::vector<RsMsgMetaData>::const_iterator msgIt;
|
|
||||||
for (msgIt = groupData.begin(); msgIt != groupData.end(); ++msgIt) {
|
|
||||||
const RsMsgMetaData &metaData = *msgIt;
|
|
||||||
if (IS_MSG_NEW(metaData.mMsgStatus) || IS_MSG_UNREAD(metaData.mMsgStatus)) {
|
|
||||||
++newCount;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ui->groupTreeWidget->setUnreadCount(item, newCount);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*********************** **** **** **** ***********************/
|
/*********************** **** **** **** ***********************/
|
||||||
|
|
|
@ -148,7 +148,7 @@ private:
|
||||||
void requestGroupSummary();
|
void requestGroupSummary();
|
||||||
void loadGroupSummary(const uint32_t &token);
|
void loadGroupSummary(const uint32_t &token);
|
||||||
|
|
||||||
void requestGroupStatistics(const std::list<RsGxsGroupId> &groupIds);
|
void requestGroupStatistics(const RsGxsGroupId &groupId);
|
||||||
void loadGroupStatistics(const uint32_t &token);
|
void loadGroupStatistics(const uint32_t &token);
|
||||||
|
|
||||||
// subscribe/unsubscribe ack.
|
// subscribe/unsubscribe ack.
|
||||||
|
@ -167,6 +167,7 @@ private:
|
||||||
QString mSettingsName;
|
QString mSettingsName;
|
||||||
RsGxsGroupId mGroupId;
|
RsGxsGroupId mGroupId;
|
||||||
RsGxsIfaceHelper *mInterface;
|
RsGxsIfaceHelper *mInterface;
|
||||||
|
RsTokenService *mTokenService;
|
||||||
TokenQueue *mTokenQueue;
|
TokenQueue *mTokenQueue;
|
||||||
GxsMessageFrameWidget *mMessageWidget;
|
GxsMessageFrameWidget *mMessageWidget;
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,6 @@
|
||||||
#include "retroshare/rsgxsifacehelper.h"
|
#include "retroshare/rsgxsifacehelper.h"
|
||||||
|
|
||||||
#define TOKEN_TYPE_STATISTICS 1
|
#define TOKEN_TYPE_STATISTICS 1
|
||||||
#define TOKEN_TYPE_GROUP_META 2
|
|
||||||
|
|
||||||
GxsUserNotify::GxsUserNotify(RsGxsIfaceHelper *ifaceImpl, QObject *parent) :
|
GxsUserNotify::GxsUserNotify(RsGxsIfaceHelper *ifaceImpl, QObject *parent) :
|
||||||
UserNotify(parent), TokenResponse()
|
UserNotify(parent), TokenResponse()
|
||||||
|
@ -33,6 +32,7 @@ GxsUserNotify::GxsUserNotify(RsGxsIfaceHelper *ifaceImpl, QObject *parent) :
|
||||||
mNewMessageCount = 0;
|
mNewMessageCount = 0;
|
||||||
|
|
||||||
mInterface = ifaceImpl;
|
mInterface = ifaceImpl;
|
||||||
|
mTokenService = mInterface->getTokenService();
|
||||||
mTokenQueue = new TokenQueue(mInterface->getTokenService(), this);
|
mTokenQueue = new TokenQueue(mInterface->getTokenService(), this);
|
||||||
|
|
||||||
mBase = new RsGxsUpdateBroadcastBase(ifaceImpl);
|
mBase = new RsGxsUpdateBroadcastBase(ifaceImpl);
|
||||||
|
@ -51,22 +51,11 @@ GxsUserNotify::~GxsUserNotify()
|
||||||
|
|
||||||
void GxsUserNotify::startUpdate()
|
void GxsUserNotify::startUpdate()
|
||||||
{
|
{
|
||||||
// uint32_t token;
|
|
||||||
// GxsServiceStatistic stats;
|
|
||||||
// mInterface->getServiceStatistic(token, stats);
|
|
||||||
// TokenQueue->queueRequest(token, 0, RS_TOKREQ_ANSTYPE_ACK, TOKEN_TYPE_STATISTICS);
|
|
||||||
|
|
||||||
mNewMessageCount = 0;
|
mNewMessageCount = 0;
|
||||||
|
|
||||||
/* Get all messages until statistics are available */
|
|
||||||
mTokenQueue->cancelActiveRequestTokens(TOKEN_TYPE_GROUP_META);
|
|
||||||
mTokenQueue->cancelActiveRequestTokens(TOKEN_TYPE_STATISTICS);
|
|
||||||
|
|
||||||
RsTokReqOptions opts;
|
|
||||||
opts.mReqType = GXS_REQUEST_TYPE_GROUP_META;
|
|
||||||
|
|
||||||
uint32_t token;
|
uint32_t token;
|
||||||
mTokenQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, TOKEN_TYPE_GROUP_META);
|
mTokenService->requestServiceStatistic(token);
|
||||||
|
mTokenQueue->queueRequest(token, 0, RS_TOKREQ_ANSTYPE_ACK, TOKEN_TYPE_STATISTICS);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GxsUserNotify::loadRequest(const TokenQueue *queue, const TokenRequest &req)
|
void GxsUserNotify::loadRequest(const TokenQueue *queue, const TokenRequest &req)
|
||||||
|
@ -76,56 +65,14 @@ void GxsUserNotify::loadRequest(const TokenQueue *queue, const TokenRequest &req
|
||||||
switch(req.mUserType) {
|
switch(req.mUserType) {
|
||||||
case TOKEN_TYPE_STATISTICS:
|
case TOKEN_TYPE_STATISTICS:
|
||||||
{
|
{
|
||||||
GxsMsgMetaMap msgList;
|
GxsServiceStatistic stats;
|
||||||
mInterface->getMsgSummary(req.mToken, msgList);
|
mInterface->getServiceStatistic(req.mToken, stats);
|
||||||
|
|
||||||
GxsMsgMetaMap::const_iterator groupIt;
|
mNewMessageCount = stats.mNumMsgsNew;
|
||||||
for (groupIt = msgList.begin(); groupIt != msgList.end(); ++groupIt) {
|
|
||||||
const std::vector<RsMsgMetaData> &groupData = groupIt->second;
|
|
||||||
|
|
||||||
std::vector<RsMsgMetaData>::const_iterator msgIt;
|
|
||||||
for (msgIt = groupData.begin(); msgIt != groupData.end(); ++msgIt) {
|
|
||||||
const RsMsgMetaData &metaData = *msgIt;
|
|
||||||
if (IS_MSG_NEW(metaData.mMsgStatus)) {
|
|
||||||
++mNewMessageCount;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case TOKEN_TYPE_GROUP_META:
|
|
||||||
{
|
|
||||||
std::list<RsGroupMetaData> groupMeta;
|
|
||||||
mInterface->getGroupSummary(req.mToken, groupMeta);
|
|
||||||
|
|
||||||
if (!groupMeta.size()) {
|
|
||||||
update();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::list<RsGxsGroupId> groupIds;
|
|
||||||
std::list<RsGroupMetaData>::const_iterator groupIt;
|
|
||||||
for (groupIt = groupMeta.begin(); groupIt != groupMeta.end(); groupIt++) {
|
|
||||||
uint32_t flags = groupIt->mSubscribeFlags;
|
|
||||||
if (IS_GROUP_SUBSCRIBED(flags)) {
|
|
||||||
groupIds.push_back(groupIt->mGroupId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!groupIds.size()) {
|
|
||||||
update();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
RsTokReqOptions opts;
|
|
||||||
opts.mReqType = GXS_REQUEST_TYPE_MSG_META;
|
|
||||||
|
|
||||||
uint32_t token;
|
|
||||||
mTokenQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, groupIds, TOKEN_TYPE_STATISTICS);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,6 +48,7 @@ private:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
RsGxsIfaceHelper *mInterface;
|
RsGxsIfaceHelper *mInterface;
|
||||||
|
RsTokenService *mTokenService;
|
||||||
TokenQueue *mTokenQueue;
|
TokenQueue *mTokenQueue;
|
||||||
RsGxsUpdateBroadcastBase *mBase;
|
RsGxsUpdateBroadcastBase *mBase;
|
||||||
unsigned int mNewMessageCount;
|
unsigned int mNewMessageCount;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue