diff --git a/libretroshare/src/gxs/rsgxsdataaccess.cc b/libretroshare/src/gxs/rsgxsdataaccess.cc index be52966bd..5ebc11a2f 100644 --- a/libretroshare/src/gxs/rsgxsdataaccess.cc +++ b/libretroshare/src/gxs/rsgxsdataaccess.cc @@ -1494,8 +1494,10 @@ bool RsGxsDataAccess::getGroupStatistic(GroupStatisticRequest *req) req->mGroupStatistic.mGrpId = req->mGrpId; req->mGroupStatistic.mNumMsgs = msgMetaV.size(); req->mGroupStatistic.mTotalSizeOfMsgs = 0; - req->mGroupStatistic.mNumMsgsNew = 0; - req->mGroupStatistic.mNumMsgsUnread = 0; + req->mGroupStatistic.mNumThreadMsgsNew = 0; + req->mGroupStatistic.mNumThreadMsgsUnread = 0; + req->mGroupStatistic.mNumChildMsgsNew = 0; + req->mGroupStatistic.mNumChildMsgsUnread = 0; for(int i = 0; i < msgMetaV.size(); i++) { @@ -1504,11 +1506,21 @@ bool RsGxsDataAccess::getGroupStatistic(GroupStatisticRequest *req) if (IS_MSG_NEW(m->mMsgStatus)) { - ++req->mGroupStatistic.mNumMsgsNew; + if (m->mParentId.isNull()) + { + ++req->mGroupStatistic.mNumThreadMsgsNew; + } else { + ++req->mGroupStatistic.mNumChildMsgsNew; + } } if (IS_MSG_UNREAD(m->mMsgStatus)) { - ++req->mGroupStatistic.mNumMsgsUnread; + if (m->mParentId.isNull()) + { + ++req->mGroupStatistic.mNumThreadMsgsUnread; + } else { + ++req->mGroupStatistic.mNumChildMsgsUnread; + } } } @@ -1526,24 +1538,35 @@ bool RsGxsDataAccess::getServiceStatistic(ServiceStatisticRequest *req) std::map::iterator mit = grpMeta.begin(); req->mServiceStatistic.mNumGrps = grpMeta.size(); + req->mServiceStatistic.mNumMsgs = 0; req->mServiceStatistic.mSizeOfGrps = 0; req->mServiceStatistic.mSizeOfMsgs = 0; req->mServiceStatistic.mNumGrpsSubscribed = 0; - req->mServiceStatistic.mNumMsgsNew = 0; - req->mServiceStatistic.mNumMsgsUnread = 0; + req->mServiceStatistic.mNumThreadMsgsNew = 0; + req->mServiceStatistic.mNumThreadMsgsUnread = 0; + req->mServiceStatistic.mNumChildMsgsNew = 0; + req->mServiceStatistic.mNumChildMsgsUnread = 0; for(; mit != grpMeta.end(); mit++) { RsGxsGrpMetaData* m = mit->second; req->mServiceStatistic.mSizeOfGrps += m->mGrpSize + m->serial_size(); - GroupStatisticRequest gr; - gr.mGrpId = m->mGroupId; - getGroupStatistic(&gr); - req->mServiceStatistic.mNumMsgs += gr.mGroupStatistic.mNumMsgs; - req->mServiceStatistic.mSizeOfMsgs += gr.mGroupStatistic.mTotalSizeOfMsgs; - req->mServiceStatistic.mNumGrpsSubscribed += m->mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_SUBSCRIBED ? 1 : 0; - req->mServiceStatistic.mNumMsgsNew += gr.mGroupStatistic.mNumMsgsNew; - req->mServiceStatistic.mNumMsgsUnread += gr.mGroupStatistic.mNumMsgsUnread; + + if (IS_GROUP_SUBSCRIBED(m->mSubscribeFlags)) + { + ++req->mServiceStatistic.mNumGrpsSubscribed; + + GroupStatisticRequest gr; + gr.mGrpId = m->mGroupId; + getGroupStatistic(&gr); + + req->mServiceStatistic.mNumMsgs += gr.mGroupStatistic.mNumMsgs; + req->mServiceStatistic.mSizeOfMsgs += gr.mGroupStatistic.mTotalSizeOfMsgs; + req->mServiceStatistic.mNumThreadMsgsNew += gr.mGroupStatistic.mNumThreadMsgsNew; + req->mServiceStatistic.mNumThreadMsgsUnread += gr.mGroupStatistic.mNumThreadMsgsUnread; + req->mServiceStatistic.mNumChildMsgsNew += gr.mGroupStatistic.mNumChildMsgsNew; + req->mServiceStatistic.mNumChildMsgsUnread += gr.mGroupStatistic.mNumChildMsgsUnread; + } delete m; } diff --git a/libretroshare/src/retroshare/rsgxsifacetypes.h b/libretroshare/src/retroshare/rsgxsifacetypes.h index 87f474ada..b79f91c55 100644 --- a/libretroshare/src/retroshare/rsgxsifacetypes.h +++ b/libretroshare/src/retroshare/rsgxsifacetypes.h @@ -139,8 +139,10 @@ public: RsGxsGroupId mGrpId; uint32_t mNumMsgs; uint32_t mTotalSizeOfMsgs; - uint32_t mNumMsgsNew; - uint32_t mNumMsgsUnread; + uint32_t mNumThreadMsgsNew; + uint32_t mNumThreadMsgsUnread; + uint32_t mNumChildMsgsNew; + uint32_t mNumChildMsgsUnread; }; class GxsServiceStatistic @@ -152,8 +154,10 @@ public: uint32_t mSizeOfMsgs; uint32_t mSizeOfGrps; uint32_t mNumGrpsSubscribed; - uint32_t mNumMsgsNew; - uint32_t mNumMsgsUnread; + uint32_t mNumThreadMsgsNew; + uint32_t mNumThreadMsgsUnread; + uint32_t mNumChildMsgsNew; + uint32_t mNumChildMsgsUnread; uint32_t mSizeStore; }; diff --git a/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.cpp b/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.cpp index 313cc4590..9202168f0 100644 --- a/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.cpp +++ b/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.cpp @@ -74,6 +74,7 @@ GxsGroupFrameDialog::GxsGroupFrameDialog(RsGxsIfaceHelper *ifaceImpl, QWidget *p ui->setupUi(this); mInitialized = false; + mCountChildMsgs = false; mYourGroups = NULL; mSubscribedGroups = NULL; mPopularGroups = NULL; @@ -897,7 +898,7 @@ void GxsGroupFrameDialog::loadGroupStatistics(const uint32_t &token) return; } - ui->groupTreeWidget->setUnreadCount(item, stats.mNumMsgsUnread); + ui->groupTreeWidget->setUnreadCount(item, mCountChildMsgs ? (stats.mNumThreadMsgsUnread + stats.mNumChildMsgsUnread) : stats.mNumThreadMsgsUnread); } /*********************** **** **** **** ***********************/ diff --git a/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.h b/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.h index 4f649b588..3694daeb9 100644 --- a/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.h +++ b/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.h @@ -169,6 +169,9 @@ private: // void requestGroupSummary_CurrentGroup(const RsGxsGroupId &groupId); // void loadGroupSummary_CurrentGroup(const uint32_t &token); +protected: + bool mCountChildMsgs; // Count unread child messages? + private: bool mInitialized; QString mSettingsName; diff --git a/retroshare-gui/src/gui/gxs/GxsUserNotify.cpp b/retroshare-gui/src/gui/gxs/GxsUserNotify.cpp index e1f88a620..b01bae296 100644 --- a/retroshare-gui/src/gui/gxs/GxsUserNotify.cpp +++ b/retroshare-gui/src/gui/gxs/GxsUserNotify.cpp @@ -29,7 +29,9 @@ GxsUserNotify::GxsUserNotify(RsGxsIfaceHelper *ifaceImpl, QObject *parent) : UserNotify(parent), TokenResponse() { - mNewMessageCount = 0; + mNewThreadMessageCount = 0; + mNewChildMessageCount = 0; + mCountChildMsgs = false; mInterface = ifaceImpl; mTokenService = mInterface->getTokenService(); @@ -51,7 +53,8 @@ GxsUserNotify::~GxsUserNotify() void GxsUserNotify::startUpdate() { - mNewMessageCount = 0; + mNewThreadMessageCount = 0; + mNewChildMessageCount = 0; uint32_t token; mTokenService->requestServiceStatistic(token); @@ -68,7 +71,8 @@ void GxsUserNotify::loadRequest(const TokenQueue *queue, const TokenRequest &req GxsServiceStatistic stats; mInterface->getServiceStatistic(req.mToken, stats); - mNewMessageCount = stats.mNumMsgsNew; + mNewThreadMessageCount = stats.mNumThreadMsgsNew; + mNewChildMessageCount = stats.mNumChildMsgsNew; update(); } diff --git a/retroshare-gui/src/gui/gxs/GxsUserNotify.h b/retroshare-gui/src/gui/gxs/GxsUserNotify.h index 1ac7d8ff5..52c36b923 100644 --- a/retroshare-gui/src/gui/gxs/GxsUserNotify.h +++ b/retroshare-gui/src/gui/gxs/GxsUserNotify.h @@ -44,14 +44,18 @@ protected: virtual void startUpdate(); private: - virtual unsigned int getNewCount() { return mNewMessageCount; } + virtual unsigned int getNewCount() { return mCountChildMsgs ? (mNewThreadMessageCount + mNewChildMessageCount) : mNewThreadMessageCount; } + +protected: + bool mCountChildMsgs; // Count new child messages? private: RsGxsIfaceHelper *mInterface; RsTokenService *mTokenService; TokenQueue *mTokenQueue; RsGxsUpdateBroadcastBase *mBase; - unsigned int mNewMessageCount; + unsigned int mNewThreadMessageCount; + unsigned int mNewChildMessageCount; }; #endif // GXSUSERNOTIFY_H diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumUserNotify.cpp b/retroshare-gui/src/gui/gxsforums/GxsForumUserNotify.cpp index f381cd8e7..beb6433d2 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumUserNotify.cpp +++ b/retroshare-gui/src/gui/gxsforums/GxsForumUserNotify.cpp @@ -25,6 +25,7 @@ GxsForumUserNotify::GxsForumUserNotify(RsGxsIfaceHelper *ifaceImpl, QObject *parent) : GxsUserNotify(ifaceImpl, parent) { + mCountChildMsgs = true; } bool GxsForumUserNotify::hasSetting(QString *name, QString *group) diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumsDialog.cpp b/retroshare-gui/src/gui/gxsforums/GxsForumsDialog.cpp index fddf50cdb..8ea1b4606 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumsDialog.cpp +++ b/retroshare-gui/src/gui/gxsforums/GxsForumsDialog.cpp @@ -30,6 +30,7 @@ GxsForumsDialog::GxsForumsDialog(QWidget *parent) : GxsGroupFrameDialog(rsGxsForums, parent) { + mCountChildMsgs = true; } GxsForumsDialog::~GxsForumsDialog()