mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-06 21:58:57 -04:00
Merge pull request #1847 from csoler/v0.6-GxsDbFix
This branch aims at fixing the requests problems in RsGxsDataAccess
This commit is contained in:
commit
b6c5e2f188
29 changed files with 1059 additions and 774 deletions
|
@ -26,10 +26,6 @@
|
||||||
* #define RS_DATA_SERVICE_DEBUG_CACHE 1
|
* #define RS_DATA_SERVICE_DEBUG_CACHE 1
|
||||||
****/
|
****/
|
||||||
|
|
||||||
#define RS_DATA_SERVICE_DEBUG 1
|
|
||||||
#define RS_DATA_SERVICE_DEBUG_TIME 1
|
|
||||||
#define RS_DATA_SERVICE_DEBUG_CACHE 1
|
|
||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <util/rsdir.h>
|
#include <util/rsdir.h>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
|
@ -1193,7 +1193,7 @@ bool RsGenExchange::getGroupList(const uint32_t &token, std::list<RsGxsGroupId>
|
||||||
bool RsGenExchange::getMsgList(const uint32_t &token,
|
bool RsGenExchange::getMsgList(const uint32_t &token,
|
||||||
GxsMsgIdResult &msgIds)
|
GxsMsgIdResult &msgIds)
|
||||||
{
|
{
|
||||||
return mDataAccess->getMsgList(token, msgIds);
|
return mDataAccess->getMsgIdList(token, msgIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RsGenExchange::getMsgRelatedList(const uint32_t &token, MsgRelatedIdResult &msgIds)
|
bool RsGenExchange::getMsgRelatedList(const uint32_t &token, MsgRelatedIdResult &msgIds)
|
||||||
|
@ -1692,7 +1692,7 @@ void RsGenExchange::notifyChangedGroupStats(const RsGxsGroupId &grpId)
|
||||||
{
|
{
|
||||||
RS_STACK_MUTEX(mGenMtx);
|
RS_STACK_MUTEX(mGenMtx);
|
||||||
|
|
||||||
RsGxsGroupChange* gc = new RsGxsGroupChange(RsGxsNotify::TYPE_PROCESSED, false);
|
RsGxsGroupChange* gc = new RsGxsGroupChange(RsGxsNotify::TYPE_STATISTICS_CHANGED, false);
|
||||||
gc->mGrpIdList.push_back(grpId);
|
gc->mGrpIdList.push_back(grpId);
|
||||||
mNotifications.push_back(gc);
|
mNotifications.push_back(gc);
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -22,6 +22,7 @@
|
||||||
#ifndef RSGXSDATAACCESS_H
|
#ifndef RSGXSDATAACCESS_H
|
||||||
#define RSGXSDATAACCESS_H
|
#define RSGXSDATAACCESS_H
|
||||||
|
|
||||||
|
#include <queue>
|
||||||
#include "retroshare/rstokenservice.h"
|
#include "retroshare/rstokenservice.h"
|
||||||
#include "rsgxsrequesttypes.h"
|
#include "rsgxsrequesttypes.h"
|
||||||
#include "rsgds.h"
|
#include "rsgds.h"
|
||||||
|
@ -30,6 +31,8 @@
|
||||||
typedef std::map< RsGxsGroupId, std::map<RsGxsMessageId, RsGxsMsgMetaData*> > MsgMetaFilter;
|
typedef std::map< RsGxsGroupId, std::map<RsGxsMessageId, RsGxsMsgMetaData*> > MsgMetaFilter;
|
||||||
typedef std::map< RsGxsGroupId, RsGxsGrpMetaData* > GrpMetaFilter;
|
typedef std::map< RsGxsGroupId, RsGxsGrpMetaData* > GrpMetaFilter;
|
||||||
|
|
||||||
|
bool operator<(const std::pair<uint32_t,GxsRequest*>& p1,const std::pair<uint32_t,GxsRequest*>& p2);
|
||||||
|
|
||||||
class RsGxsDataAccess : public RsTokenService
|
class RsGxsDataAccess : public RsTokenService
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -56,7 +59,7 @@ public:
|
||||||
* @param groupIds group id to request info for
|
* @param groupIds group id to request info for
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
bool requestGroupInfo(uint32_t &token, uint32_t ansType, const RsTokReqOptions &opts, const std::list<RsGxsGroupId> &groupIds);
|
bool requestGroupInfo(uint32_t &token, uint32_t ansType, const RsTokReqOptions &opts, const std::list<RsGxsGroupId> &groupIds) override;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Use this to request all group related info
|
* Use this to request all group related info
|
||||||
|
@ -65,7 +68,7 @@ public:
|
||||||
* @param opts Additional option that affect outcome of request. Please see specific services, for valid values
|
* @param opts Additional option that affect outcome of request. Please see specific services, for valid values
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
bool requestGroupInfo(uint32_t &token, uint32_t ansType, const RsTokReqOptions &opts);
|
bool requestGroupInfo(uint32_t &token, uint32_t ansType, const RsTokReqOptions &opts) override;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Use this to get msg information (id, meta, or data), store token value to poll for request completion
|
* Use this to get msg information (id, meta, or data), store token value to poll for request completion
|
||||||
|
@ -75,7 +78,7 @@ public:
|
||||||
* @param groupIds The ids of the groups to get, second entry of map empty to query for all msgs
|
* @param groupIds The ids of the groups to get, second entry of map empty to query for all msgs
|
||||||
* @return true if request successful false otherwise
|
* @return true if request successful false otherwise
|
||||||
*/
|
*/
|
||||||
bool requestMsgInfo(uint32_t &token, uint32_t ansType, const RsTokReqOptions &opts, const GxsMsgReq& msgIds);
|
bool requestMsgInfo(uint32_t &token, uint32_t ansType, const RsTokReqOptions &opts, const GxsMsgReq& msgIds) override;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Use this to get message information (id, meta, or data), store token value to poll for request completion
|
* Use this to get message information (id, meta, or data), store token value to poll for request completion
|
||||||
|
@ -86,7 +89,7 @@ public:
|
||||||
* all messages for all groups are retrieved
|
* all messages for all groups are retrieved
|
||||||
* @return true if request successful false otherwise
|
* @return true if request successful false otherwise
|
||||||
*/
|
*/
|
||||||
bool requestMsgInfo(uint32_t &token, uint32_t ansType, const RsTokReqOptions &opts, const std::list<RsGxsGroupId>& grpIds);
|
bool requestMsgInfo(uint32_t &token, uint32_t ansType, const RsTokReqOptions &opts, const std::list<RsGxsGroupId>& grpIds) override;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* For requesting msgs related to a given msg id within a group
|
* For requesting msgs related to a given msg id within a group
|
||||||
|
@ -96,7 +99,7 @@ public:
|
||||||
* @param groupIds The ids of the groups to get, second entry of map empty to query for all msgs
|
* @param groupIds The ids of the groups to get, second entry of map empty to query for all msgs
|
||||||
* @return true if request successful false otherwise
|
* @return true if request successful false otherwise
|
||||||
*/
|
*/
|
||||||
bool requestMsgRelatedInfo(uint32_t &token, uint32_t ansType, const RsTokReqOptions &opts, const std::vector<RsGxsGrpMsgIdPair> &msgIds);
|
bool requestMsgRelatedInfo(uint32_t &token, uint32_t ansType, const RsTokReqOptions &opts, const std::vector<RsGxsGrpMsgIdPair> &msgIds) override;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* This request statistics on amount of data held
|
* This request statistics on amount of data held
|
||||||
|
@ -107,19 +110,20 @@ public:
|
||||||
* total size of messages
|
* total size of messages
|
||||||
* total size of groups
|
* total size of groups
|
||||||
* @param token
|
* @param token
|
||||||
|
* @param opts Additional option that affect outcome of request. Please see specific services, for valid values
|
||||||
*/
|
*/
|
||||||
void requestServiceStatistic(uint32_t& token);
|
void requestServiceStatistic(uint32_t& token, const RsTokReqOptions &opts) override;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* To request statistic on a group
|
* To request statistic on a group
|
||||||
* @param token set to value to be redeemed to get statistic
|
* @param token set to value to be redeemed to get statistic
|
||||||
* @param grpId the id of the group
|
* @param grpId the id of the group
|
||||||
|
* @param opts Additional option that affect outcome of request. Please see specific services, for valid values
|
||||||
*/
|
*/
|
||||||
void requestGroupStatistic(uint32_t& token, const RsGxsGroupId& grpId);
|
void requestGroupStatistic(uint32_t& token, const RsGxsGroupId& grpId, const RsTokReqOptions &opts) override;
|
||||||
|
|
||||||
|
|
||||||
/* Poll */
|
/* Poll */
|
||||||
GxsRequestStatus requestStatus(const uint32_t token);
|
GxsRequestStatus requestStatus(uint32_t token);
|
||||||
|
|
||||||
/* Cancel Request */
|
/* Cancel Request */
|
||||||
bool cancelRequest(const uint32_t &token);
|
bool cancelRequest(const uint32_t &token);
|
||||||
|
@ -200,7 +204,8 @@ public:
|
||||||
* @param token request token to be redeemed
|
* @param token request token to be redeemed
|
||||||
* @param msgIds
|
* @param msgIds
|
||||||
*/
|
*/
|
||||||
bool getMsgList(const uint32_t &token, GxsMsgIdResult &msgIds);
|
bool getMsgIdList(const uint32_t &token, GxsMsgIdResult &msgIds);
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Retrieve msg list for a given token for message related info
|
* Retrieve msg list for a given token for message related info
|
||||||
|
@ -271,7 +276,7 @@ private:
|
||||||
* @param token the value of the token for the request object handle wanted
|
* @param token the value of the token for the request object handle wanted
|
||||||
* @return the request associated to this token
|
* @return the request associated to this token
|
||||||
*/
|
*/
|
||||||
GxsRequest* locked_retrieveRequest(const uint32_t& token);
|
GxsRequest* locked_retrieveCompetedRequest(const uint32_t& token);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Add a gxs request to queue
|
* Add a gxs request to queue
|
||||||
|
@ -378,8 +383,18 @@ private:
|
||||||
* @param req
|
* @param req
|
||||||
* @return false if unsuccessful, true otherwise
|
* @return false if unsuccessful, true otherwise
|
||||||
*/
|
*/
|
||||||
bool getMsgList(MsgIdReq* req);
|
bool getMsgIdList(MsgIdReq* req);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Attempts to retrieve msg Meta list from data store
|
||||||
|
* Computationally/CPU-Bandwidth expensive
|
||||||
|
*
|
||||||
|
* @param msgIds List of message Ids for the Message Metas to retrieve
|
||||||
|
* @param opts GxsRequest options
|
||||||
|
* @param result Map of Meta information for messages
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
bool getMsgMetaDataList( const GxsMsgReq& msgIds, const RsTokReqOptions& opts, GxsMsgMetaResult& result );
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Attempts to retrieve group meta data from data store
|
* Attempts to retrieve group meta data from data store
|
||||||
|
@ -445,7 +460,7 @@ private:
|
||||||
* @param opts the request options set by user
|
* @param opts the request options set by user
|
||||||
* @param meta The accompanying meta information for msg, ids
|
* @param meta The accompanying meta information for msg, ids
|
||||||
*/
|
*/
|
||||||
void filterMsgList(GxsMsgIdResult& msgIds, const RsTokReqOptions& opts, const MsgMetaFilter& meta) const;
|
void filterMsgIdList(GxsMsgIdResult& msgIds, const RsTokReqOptions& opts, const MsgMetaFilter& meta) const;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* This filter msgs based of options supplied (at the moment just status masks)
|
* This filter msgs based of options supplied (at the moment just status masks)
|
||||||
|
@ -482,9 +497,10 @@ private:
|
||||||
* @param opts the options used to parameterise the id filter
|
* @param opts the options used to parameterise the id filter
|
||||||
* @param msgIdsOut the left overs ids after filter is applied to msgIds
|
* @param msgIdsOut the left overs ids after filter is applied to msgIds
|
||||||
*/
|
*/
|
||||||
bool getMsgList(const GxsMsgReq& msgIds, const RsTokReqOptions& opts, GxsMsgReq& msgIdsOut);
|
bool getMsgIdList(const GxsMsgReq& msgIds, const RsTokReqOptions& opts, GxsMsgReq& msgIdsOut);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
bool locked_clearRequest(const uint32_t &token);
|
||||||
|
|
||||||
RsGeneralDataService* mDataStore;
|
RsGeneralDataService* mDataStore;
|
||||||
|
|
||||||
|
@ -492,10 +508,9 @@ private:
|
||||||
|
|
||||||
uint32_t mNextToken;
|
uint32_t mNextToken;
|
||||||
std::map<uint32_t, GxsRequestStatus> mPublicToken;
|
std::map<uint32_t, GxsRequestStatus> mPublicToken;
|
||||||
std::map<uint32_t, GxsRequest*> mRequests;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
std::set<std::pair<uint32_t,GxsRequest*> > mRequestQueue;
|
||||||
|
std::map<uint32_t, GxsRequest*> mCompletedRequests;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // RSGXSDATAACCESS_H
|
#endif // RSGXSDATAACCESS_H
|
||||||
|
|
|
@ -23,6 +23,128 @@
|
||||||
#include "rsgxsrequesttypes.h"
|
#include "rsgxsrequesttypes.h"
|
||||||
#include "util/rsstd.h"
|
#include "util/rsstd.h"
|
||||||
|
|
||||||
|
std::ostream& operator<<(std::ostream& o,const GxsRequest& g)
|
||||||
|
{
|
||||||
|
return g.print(o);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
std::ostream& GroupMetaReq::print(std::ostream& o) const
|
||||||
|
{
|
||||||
|
o << "[Request type=GroupMeta groupIds (size=" << mGroupIds.size() << "): " ;
|
||||||
|
|
||||||
|
if(!mGroupIds.empty())
|
||||||
|
{
|
||||||
|
o << *mGroupIds.begin() ;
|
||||||
|
|
||||||
|
if(mGroupIds.size() > 1)
|
||||||
|
o << " ..." ;
|
||||||
|
}
|
||||||
|
|
||||||
|
o << "]" ;
|
||||||
|
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
std::ostream& GroupIdReq::print(std::ostream& o) const
|
||||||
|
{
|
||||||
|
return o << "[Request type=GroupIdReq" << "]" ;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::ostream& GroupSerializedDataReq::print(std::ostream& o) const
|
||||||
|
{
|
||||||
|
return o << "[Request type=GroupSerializedData" << "]" ;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::ostream& GroupDataReq::print(std::ostream& o) const
|
||||||
|
{
|
||||||
|
o << "[Request type=GroupDataReq groupIds (size=" << mGroupIds.size() << "): " ;
|
||||||
|
|
||||||
|
if(!mGroupIds.empty())
|
||||||
|
{
|
||||||
|
o << *mGroupIds.begin() ;
|
||||||
|
|
||||||
|
if(mGroupIds.size() > 1)
|
||||||
|
o << " ..." ;
|
||||||
|
}
|
||||||
|
|
||||||
|
o << "]" ;
|
||||||
|
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::ostream& MsgIdReq::print(std::ostream& o) const
|
||||||
|
{
|
||||||
|
return o << "[Request type=MsgId" << "]" ;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::ostream& MsgMetaReq::print(std::ostream& o) const
|
||||||
|
{
|
||||||
|
o << "[Request type=MsgMetaReq groups (size=" << mMsgIds.size() << "): " ;
|
||||||
|
|
||||||
|
if(!mMsgIds.empty())
|
||||||
|
{
|
||||||
|
o << mMsgIds.begin()->first << " (" << mMsgIds.begin()->second.size() << " messages)";
|
||||||
|
|
||||||
|
if(mMsgIds.size() > 1)
|
||||||
|
o << " ..." ;
|
||||||
|
}
|
||||||
|
|
||||||
|
o << "]" ;
|
||||||
|
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::ostream& MsgDataReq::print(std::ostream& o) const
|
||||||
|
{
|
||||||
|
o << "[Request type=MsgDataReq groups (size=" << mMsgIds.size() << "): " ;
|
||||||
|
|
||||||
|
if(!mMsgIds.empty())
|
||||||
|
{
|
||||||
|
o << mMsgIds.begin()->first << " (" << mMsgIds.begin()->second.size() << " messages)";
|
||||||
|
|
||||||
|
if(mMsgIds.size() > 1)
|
||||||
|
o << " ..." ;
|
||||||
|
}
|
||||||
|
|
||||||
|
o << "]" ;
|
||||||
|
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::ostream& MsgRelatedInfoReq::print(std::ostream& o) const
|
||||||
|
{
|
||||||
|
o << "[Request type=MsgRelatedInfo msgIds (size=" << mMsgIds.size() << "): " ;
|
||||||
|
|
||||||
|
if(!mMsgIds.empty())
|
||||||
|
{
|
||||||
|
o << mMsgIds.begin()->first ;
|
||||||
|
|
||||||
|
if(mMsgIds.size() > 1)
|
||||||
|
o << " ..." ;
|
||||||
|
}
|
||||||
|
|
||||||
|
o << "]" ;
|
||||||
|
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::ostream& GroupSetFlagReq::print(std::ostream& o) const
|
||||||
|
{
|
||||||
|
return o << "[Request type=GroupFlagSet grpId=" << grpId << "]" ;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
std::ostream& ServiceStatisticRequest::print(std::ostream& o) const
|
||||||
|
{
|
||||||
|
return o << "[Request type=ServiceStatistics" << "]" ;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::ostream& GroupStatisticRequest::print(std::ostream& o) const
|
||||||
|
{
|
||||||
|
return o << "[Request type=GroupStatistics grpId=" << mGrpId << "]" ;
|
||||||
|
}
|
||||||
|
|
||||||
GroupMetaReq::~GroupMetaReq()
|
GroupMetaReq::~GroupMetaReq()
|
||||||
{
|
{
|
||||||
//rsstd::delete_all(mGroupMetaData.begin(), mGroupMetaData.end()); // now memory ownership is kept by the cache.
|
//rsstd::delete_all(mGroupMetaData.begin(), mGroupMetaData.end()); // now memory ownership is kept by the cache.
|
||||||
|
@ -57,3 +179,8 @@ MsgRelatedInfoReq::~MsgRelatedInfoReq()
|
||||||
rsstd::delete_all(dataIt->second.begin(), dataIt->second.end());
|
rsstd::delete_all(dataIt->second.begin(), dataIt->second.end());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
std::ostream& MessageSetFlagReq::print(std::ostream& o) const
|
||||||
|
{
|
||||||
|
return o << "[Request type=MsgFlagSet" << "]" ;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,25 +29,30 @@
|
||||||
struct GxsRequest
|
struct GxsRequest
|
||||||
{
|
{
|
||||||
GxsRequest() :
|
GxsRequest() :
|
||||||
token(0), reqTime(0), ansType(0), reqType(0),
|
token(0), reqTime(0), clientAnswerType(0), reqType(0),
|
||||||
status(RsTokenService::FAILED) {}
|
status(RsTokenService::FAILED) {}
|
||||||
virtual ~GxsRequest() {}
|
virtual ~GxsRequest() {}
|
||||||
|
|
||||||
uint32_t token;
|
uint32_t token;
|
||||||
uint32_t reqTime;
|
uint32_t reqTime;
|
||||||
|
|
||||||
RS_DEPRECATED uint32_t ansType; /// G10h4ck: This is of no use
|
uint32_t clientAnswerType; /// This is made available to the clients in order to keep track of why specific requests where sent..
|
||||||
uint32_t reqType;
|
uint32_t reqType;
|
||||||
RsTokReqOptions Options;
|
RsTokReqOptions Options;
|
||||||
|
|
||||||
RsTokenService::GxsRequestStatus status;
|
RsTokenService::GxsRequestStatus status;
|
||||||
|
|
||||||
|
virtual std::ostream& print(std::ostream& o) const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
std::ostream& operator<<(std::ostream& o,const GxsRequest& g);
|
||||||
|
|
||||||
class GroupMetaReq : public GxsRequest
|
class GroupMetaReq : public GxsRequest
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual ~GroupMetaReq();
|
virtual ~GroupMetaReq();
|
||||||
|
|
||||||
|
virtual std::ostream& print(std::ostream& o) const override;
|
||||||
public:
|
public:
|
||||||
std::list<RsGxsGroupId> mGroupIds;
|
std::list<RsGxsGroupId> mGroupIds;
|
||||||
std::list<const RsGxsGrpMetaData*> mGroupMetaData;
|
std::list<const RsGxsGrpMetaData*> mGroupMetaData;
|
||||||
|
@ -56,12 +61,16 @@ public:
|
||||||
class GroupIdReq : public GxsRequest
|
class GroupIdReq : public GxsRequest
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
virtual std::ostream& print(std::ostream& o) const override ;
|
||||||
|
|
||||||
std::list<RsGxsGroupId> mGroupIds;
|
std::list<RsGxsGroupId> mGroupIds;
|
||||||
std::list<RsGxsGroupId> mGroupIdResult;
|
std::list<RsGxsGroupId> mGroupIdResult;
|
||||||
};
|
};
|
||||||
class GroupSerializedDataReq : public GxsRequest
|
class GroupSerializedDataReq : public GxsRequest
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
virtual std::ostream& print(std::ostream& o) const override ;
|
||||||
|
|
||||||
std::list<RsGxsGroupId> mGroupIds;
|
std::list<RsGxsGroupId> mGroupIds;
|
||||||
std::list<RsNxsGrp*> mGroupData;
|
std::list<RsNxsGrp*> mGroupData;
|
||||||
};
|
};
|
||||||
|
@ -71,6 +80,7 @@ class GroupDataReq : public GxsRequest
|
||||||
public:
|
public:
|
||||||
virtual ~GroupDataReq();
|
virtual ~GroupDataReq();
|
||||||
|
|
||||||
|
virtual std::ostream& print(std::ostream& o) const override;
|
||||||
public:
|
public:
|
||||||
std::list<RsGxsGroupId> mGroupIds;
|
std::list<RsGxsGroupId> mGroupIds;
|
||||||
std::list<RsNxsGrp*> mGroupData;
|
std::list<RsNxsGrp*> mGroupData;
|
||||||
|
@ -79,6 +89,8 @@ public:
|
||||||
class MsgIdReq : public GxsRequest
|
class MsgIdReq : public GxsRequest
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
virtual std::ostream& print(std::ostream& o) const override ;
|
||||||
|
|
||||||
GxsMsgReq mMsgIds;
|
GxsMsgReq mMsgIds;
|
||||||
GxsMsgIdResult mMsgIdResult;
|
GxsMsgIdResult mMsgIdResult;
|
||||||
};
|
};
|
||||||
|
@ -88,6 +100,8 @@ class MsgMetaReq : public GxsRequest
|
||||||
public:
|
public:
|
||||||
virtual ~MsgMetaReq();
|
virtual ~MsgMetaReq();
|
||||||
|
|
||||||
|
virtual std::ostream& print(std::ostream& o) const override;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
GxsMsgReq mMsgIds;
|
GxsMsgReq mMsgIds;
|
||||||
GxsMsgMetaResult mMsgMetaData;
|
GxsMsgMetaResult mMsgMetaData;
|
||||||
|
@ -98,6 +112,7 @@ class MsgDataReq : public GxsRequest
|
||||||
public:
|
public:
|
||||||
virtual ~MsgDataReq();
|
virtual ~MsgDataReq();
|
||||||
|
|
||||||
|
virtual std::ostream& print(std::ostream& o) const override;
|
||||||
public:
|
public:
|
||||||
GxsMsgReq mMsgIds;
|
GxsMsgReq mMsgIds;
|
||||||
NxsMsgDataResult mMsgData;
|
NxsMsgDataResult mMsgData;
|
||||||
|
@ -106,12 +121,15 @@ public:
|
||||||
class ServiceStatisticRequest: public GxsRequest
|
class ServiceStatisticRequest: public GxsRequest
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
virtual std::ostream& print(std::ostream& o) const override ;
|
||||||
GxsServiceStatistic mServiceStatistic;
|
GxsServiceStatistic mServiceStatistic;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct GroupStatisticRequest: public GxsRequest
|
struct GroupStatisticRequest: public GxsRequest
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
virtual std::ostream& print(std::ostream& o) const override ;
|
||||||
|
|
||||||
RsGxsGroupId mGrpId;
|
RsGxsGroupId mGrpId;
|
||||||
GxsGroupStatistic mGroupStatistic;
|
GxsGroupStatistic mGroupStatistic;
|
||||||
};
|
};
|
||||||
|
@ -121,6 +139,7 @@ class MsgRelatedInfoReq : public GxsRequest
|
||||||
public:
|
public:
|
||||||
virtual ~MsgRelatedInfoReq();
|
virtual ~MsgRelatedInfoReq();
|
||||||
|
|
||||||
|
std::ostream& print(std::ostream& o) const override;
|
||||||
public:
|
public:
|
||||||
std::vector<RsGxsGrpMsgIdPair> mMsgIds;
|
std::vector<RsGxsGrpMsgIdPair> mMsgIds;
|
||||||
MsgRelatedIdResult mMsgIdResult;
|
MsgRelatedIdResult mMsgIdResult;
|
||||||
|
@ -131,6 +150,8 @@ public:
|
||||||
class GroupSetFlagReq : public GxsRequest
|
class GroupSetFlagReq : public GxsRequest
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
virtual std::ostream& print(std::ostream& o) const override ;
|
||||||
|
|
||||||
const static uint32_t FLAG_SUBSCRIBE;
|
const static uint32_t FLAG_SUBSCRIBE;
|
||||||
const static uint32_t FLAG_STATUS;
|
const static uint32_t FLAG_STATUS;
|
||||||
|
|
||||||
|
@ -145,6 +166,7 @@ class MessageSetFlagReq : public GxsRequest
|
||||||
public:
|
public:
|
||||||
const static uint32_t FLAG_STATUS;
|
const static uint32_t FLAG_STATUS;
|
||||||
|
|
||||||
|
virtual std::ostream& print(std::ostream& o) const override ;
|
||||||
uint8_t type;
|
uint8_t type;
|
||||||
uint32_t flag;
|
uint32_t flag;
|
||||||
uint32_t flagMask;
|
uint32_t flagMask;
|
||||||
|
|
|
@ -111,6 +111,7 @@ enum class RsChannelEventCode: uint8_t
|
||||||
SUBSCRIBE_STATUS_CHANGED = 0x06, // subscription for channel mChannelGroupId changed.
|
SUBSCRIBE_STATUS_CHANGED = 0x06, // subscription for channel mChannelGroupId changed.
|
||||||
READ_STATUS_CHANGED = 0x07, // existing message has been read or set to unread
|
READ_STATUS_CHANGED = 0x07, // existing message has been read or set to unread
|
||||||
RECEIVED_DISTANT_SEARCH_RESULT = 0x08, // result for the given group id available for the given turtle request id
|
RECEIVED_DISTANT_SEARCH_RESULT = 0x08, // result for the given group id available for the given turtle request id
|
||||||
|
STATISTICS_CHANGED = 0x09, // stats (nb of supplier friends, how many msgs they have etc) has changed
|
||||||
};
|
};
|
||||||
|
|
||||||
struct RsGxsChannelEvent: RsEvent
|
struct RsGxsChannelEvent: RsEvent
|
||||||
|
|
|
@ -111,6 +111,7 @@ enum class RsForumEventCode: uint8_t
|
||||||
UPDATED_MESSAGE = 0x04, /// existing message has been updated in a particular forum
|
UPDATED_MESSAGE = 0x04, /// existing message has been updated in a particular forum
|
||||||
SUBSCRIBE_STATUS_CHANGED = 0x05, /// forum was subscribed or unsubscribed
|
SUBSCRIBE_STATUS_CHANGED = 0x05, /// forum was subscribed or unsubscribed
|
||||||
READ_STATUS_CHANGED = 0x06, /// msg was read or marked unread
|
READ_STATUS_CHANGED = 0x06, /// msg was read or marked unread
|
||||||
|
STATISTICS_CHANGED = 0x07, /// suppliers and how many messages they have changed
|
||||||
};
|
};
|
||||||
|
|
||||||
struct RsGxsForumEvent: RsEvent
|
struct RsGxsForumEvent: RsEvent
|
||||||
|
|
|
@ -40,7 +40,9 @@
|
||||||
* are necessary, so at this point this workaround seems acceptable.
|
* are necessary, so at this point this workaround seems acceptable.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define DEBUG_GXSIFACEHELPER 1
|
//==================================
|
||||||
|
// #define DEBUG_GXSIFACEHELPER 1
|
||||||
|
//==================================
|
||||||
|
|
||||||
enum class TokenRequestType: uint8_t
|
enum class TokenRequestType: uint8_t
|
||||||
{
|
{
|
||||||
|
@ -267,7 +269,9 @@ public:
|
||||||
{
|
{
|
||||||
RS_STACK_MUTEX(mMtx);
|
RS_STACK_MUTEX(mMtx);
|
||||||
mActiveTokens[token]=high_priority_request? (TokenRequestType::NO_KILL_TYPE) : token_request_type;
|
mActiveTokens[token]=high_priority_request? (TokenRequestType::NO_KILL_TYPE) : token_request_type;
|
||||||
|
#ifdef DEBUG_GXSIFACEHELPER
|
||||||
locked_dumpTokens();
|
locked_dumpTokens();
|
||||||
|
#endif
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -295,7 +299,9 @@ public:
|
||||||
{
|
{
|
||||||
RS_STACK_MUTEX(mMtx);
|
RS_STACK_MUTEX(mMtx);
|
||||||
mActiveTokens[token]=high_priority_request? (TokenRequestType::NO_KILL_TYPE) : token_request_type;
|
mActiveTokens[token]=high_priority_request? (TokenRequestType::NO_KILL_TYPE) : token_request_type;
|
||||||
|
#ifdef DEBUG_GXSIFACEHELPER
|
||||||
locked_dumpTokens();
|
locked_dumpTokens();
|
||||||
|
#endif
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -310,7 +316,9 @@ public:
|
||||||
RS_STACK_MUTEX(mMtx);
|
RS_STACK_MUTEX(mMtx);
|
||||||
|
|
||||||
mActiveTokens[token]= (msgIds.size()==1 && msgIds.begin()->second.size()==0) ?(TokenRequestType::ALL_POSTS):(TokenRequestType::POSTS);
|
mActiveTokens[token]= (msgIds.size()==1 && msgIds.begin()->second.size()==0) ?(TokenRequestType::ALL_POSTS):(TokenRequestType::POSTS);
|
||||||
|
#ifdef DEBUG_GXSIFACEHELPER
|
||||||
locked_dumpTokens();
|
locked_dumpTokens();
|
||||||
|
#endif
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -324,7 +332,9 @@ public:
|
||||||
{
|
{
|
||||||
RS_STACK_MUTEX(mMtx);
|
RS_STACK_MUTEX(mMtx);
|
||||||
mActiveTokens[token]=TokenRequestType::ALL_POSTS;
|
mActiveTokens[token]=TokenRequestType::ALL_POSTS;
|
||||||
|
#ifdef DEBUG_GXSIFACEHELPER
|
||||||
locked_dumpTokens();
|
locked_dumpTokens();
|
||||||
|
#endif
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -340,7 +350,9 @@ public:
|
||||||
{
|
{
|
||||||
RS_STACK_MUTEX(mMtx);
|
RS_STACK_MUTEX(mMtx);
|
||||||
mActiveTokens[token]=TokenRequestType::MSG_RELATED_INFO;
|
mActiveTokens[token]=TokenRequestType::MSG_RELATED_INFO;
|
||||||
|
#ifdef DEBUG_GXSIFACEHELPER
|
||||||
locked_dumpTokens();
|
locked_dumpTokens();
|
||||||
|
#endif
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -357,23 +369,33 @@ public:
|
||||||
/// @see RsTokenService::requestServiceStatistic
|
/// @see RsTokenService::requestServiceStatistic
|
||||||
bool requestServiceStatistic(uint32_t& token)
|
bool requestServiceStatistic(uint32_t& token)
|
||||||
{
|
{
|
||||||
mTokenService.requestServiceStatistic(token);
|
RsTokReqOptions opts;
|
||||||
|
opts.mReqType = GXS_REQUEST_TYPE_SERVICE_STATS;
|
||||||
|
|
||||||
|
mTokenService.requestServiceStatistic(token,opts);
|
||||||
|
|
||||||
RS_STACK_MUTEX(mMtx);
|
RS_STACK_MUTEX(mMtx);
|
||||||
mActiveTokens[token]=TokenRequestType::SERVICE_STATISTICS;
|
mActiveTokens[token]=TokenRequestType::SERVICE_STATISTICS;
|
||||||
|
|
||||||
|
#ifdef DEBUG_GXSIFACEHELPER
|
||||||
locked_dumpTokens();
|
locked_dumpTokens();
|
||||||
|
#endif
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @see RsTokenService::requestGroupStatistic
|
/// @see RsTokenService::requestGroupStatistic
|
||||||
bool requestGroupStatistic(uint32_t& token, const RsGxsGroupId& grpId)
|
bool requestGroupStatistic(uint32_t& token, const RsGxsGroupId& grpId)
|
||||||
{
|
{
|
||||||
mTokenService.requestGroupStatistic(token, grpId);
|
RsTokReqOptions opts;
|
||||||
|
opts.mReqType = GXS_REQUEST_TYPE_GROUP_STATS;
|
||||||
|
|
||||||
|
mTokenService.requestGroupStatistic(token, grpId,opts);
|
||||||
|
|
||||||
RS_STACK_MUTEX(mMtx);
|
RS_STACK_MUTEX(mMtx);
|
||||||
mActiveTokens[token]=TokenRequestType::GROUP_STATISTICS;
|
mActiveTokens[token]=TokenRequestType::GROUP_STATISTICS;
|
||||||
|
#ifdef DEBUG_GXSIFACEHELPER
|
||||||
locked_dumpTokens();
|
locked_dumpTokens();
|
||||||
|
#endif
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -485,7 +507,7 @@ private:
|
||||||
|
|
||||||
uint32_t count[7] = {0};
|
uint32_t count[7] = {0};
|
||||||
|
|
||||||
std::cerr << "Service " << std::hex << service_id << std::dec
|
RsDbg() << "Service " << std::hex << service_id << std::dec
|
||||||
<< " (" << rsServiceControl->getServiceName(RsServiceInfo::RsServiceInfoUIn16ToFullServiceId(service_id))
|
<< " (" << rsServiceControl->getServiceName(RsServiceInfo::RsServiceInfoUIn16ToFullServiceId(service_id))
|
||||||
<< ") this=" << std::hex << (void*)this << std::dec << ") Active tokens (per type): " ;
|
<< ") this=" << std::hex << (void*)this << std::dec << ") Active tokens (per type): " ;
|
||||||
|
|
||||||
|
|
|
@ -45,6 +45,13 @@ struct RsMsgMetaData;
|
||||||
|
|
||||||
typedef std::map<RsGxsGroupId, std::vector<RsMsgMetaData> > MsgMetaResult;
|
typedef std::map<RsGxsGroupId, std::vector<RsMsgMetaData> > MsgMetaResult;
|
||||||
|
|
||||||
|
enum class GxsRequestPriority {
|
||||||
|
VERY_HIGH = 0x00,
|
||||||
|
HIGH = 0x01,
|
||||||
|
NORMAL = 0x02,
|
||||||
|
LOW = 0x03,
|
||||||
|
VERY_LOW = 0x04,
|
||||||
|
};
|
||||||
|
|
||||||
class RsGxsGrpMetaData;
|
class RsGxsGrpMetaData;
|
||||||
class RsGxsMsgMetaData;
|
class RsGxsMsgMetaData;
|
||||||
|
@ -232,7 +239,7 @@ public:
|
||||||
mNumChildMsgsNew = 0;
|
mNumChildMsgsNew = 0;
|
||||||
mNumChildMsgsUnread = 0;
|
mNumChildMsgsUnread = 0;
|
||||||
mSizeStore = 0;
|
mSizeStore = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
uint32_t mNumMsgs;
|
uint32_t mNumMsgs;
|
||||||
|
|
|
@ -46,7 +46,8 @@ struct RsGxsNotify
|
||||||
TYPE_RECEIVED_NEW = 0x02,
|
TYPE_RECEIVED_NEW = 0x02,
|
||||||
TYPE_PROCESSED = 0x03,
|
TYPE_PROCESSED = 0x03,
|
||||||
TYPE_RECEIVED_PUBLISHKEY = 0x04,
|
TYPE_RECEIVED_PUBLISHKEY = 0x04,
|
||||||
TYPE_RECEIVED_DISTANT_SEARCH_RESULTS = 0x05
|
TYPE_RECEIVED_DISTANT_SEARCH_RESULTS = 0x05,
|
||||||
|
TYPE_STATISTICS_CHANGED = 0x06
|
||||||
};
|
};
|
||||||
|
|
||||||
virtual ~RsGxsNotify() {}
|
virtual ~RsGxsNotify() {}
|
||||||
|
|
|
@ -114,6 +114,7 @@ enum class RsPostedEventCode: uint8_t
|
||||||
UPDATED_POSTED_GROUP = 0x04,
|
UPDATED_POSTED_GROUP = 0x04,
|
||||||
UPDATED_MESSAGE = 0x05,
|
UPDATED_MESSAGE = 0x05,
|
||||||
READ_STATUS_CHANGED = 0x06,
|
READ_STATUS_CHANGED = 0x06,
|
||||||
|
STATISTICS_CHANGED = 0x07,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -80,7 +80,7 @@ struct RsTokReqOptions
|
||||||
{
|
{
|
||||||
RsTokReqOptions() : mOptions(0), mStatusFilter(0), mStatusMask(0),
|
RsTokReqOptions() : mOptions(0), mStatusFilter(0), mStatusMask(0),
|
||||||
mMsgFlagMask(0), mMsgFlagFilter(0), mReqType(0), mSubscribeFilter(0),
|
mMsgFlagMask(0), mMsgFlagFilter(0), mReqType(0), mSubscribeFilter(0),
|
||||||
mSubscribeMask(0), mBefore(0), mAfter(0) {}
|
mSubscribeMask(0), mBefore(0), mAfter(0),mPriority(GxsRequestPriority::NORMAL) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Can be one or multiple RS_TOKREQOPT_*
|
* Can be one or multiple RS_TOKREQOPT_*
|
||||||
|
@ -107,6 +107,8 @@ struct RsTokReqOptions
|
||||||
// Time range... again applied after Options.
|
// Time range... again applied after Options.
|
||||||
rstime_t mBefore;
|
rstime_t mBefore;
|
||||||
rstime_t mAfter;
|
rstime_t mAfter;
|
||||||
|
|
||||||
|
GxsRequestPriority mPriority;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -181,6 +183,25 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual bool requestMsgRelatedInfo(uint32_t &token, uint32_t ansType, const RsTokReqOptions &opts, const std::vector<RsGxsGrpMsgIdPair>& msgIds) = 0;
|
virtual bool requestMsgRelatedInfo(uint32_t &token, uint32_t ansType, const RsTokReqOptions &opts, const std::vector<RsGxsGrpMsgIdPair>& msgIds) = 0;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* This request statistics on amount of data held
|
||||||
|
* number of groups
|
||||||
|
* number of groups subscribed
|
||||||
|
* number of messages
|
||||||
|
* size of db store
|
||||||
|
* total size of messages
|
||||||
|
* total size of groups
|
||||||
|
* @param token
|
||||||
|
*/
|
||||||
|
virtual void requestServiceStatistic(uint32_t& token, const RsTokReqOptions &opts) = 0;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* To request statistic on a group
|
||||||
|
* @param token set to value to be redeemed to get statistic
|
||||||
|
* @param grpId the id of the group
|
||||||
|
*/
|
||||||
|
virtual void requestGroupStatistic(uint32_t& token, const RsGxsGroupId& grpId, const RsTokReqOptions &opts) = 0;
|
||||||
|
|
||||||
|
|
||||||
/* Poll */
|
/* Poll */
|
||||||
|
|
||||||
|
@ -194,25 +215,6 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual GxsRequestStatus requestStatus(const uint32_t token) = 0;
|
virtual GxsRequestStatus requestStatus(const uint32_t token) = 0;
|
||||||
|
|
||||||
/*!
|
|
||||||
* This request statistics on amount of data held
|
|
||||||
* number of groups
|
|
||||||
* number of groups subscribed
|
|
||||||
* number of messages
|
|
||||||
* size of db store
|
|
||||||
* total size of messages
|
|
||||||
* total size of groups
|
|
||||||
* @param token
|
|
||||||
*/
|
|
||||||
virtual void requestServiceStatistic(uint32_t& token) = 0;
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* To request statistic on a group
|
|
||||||
* @param token set to value to be redeemed to get statistic
|
|
||||||
* @param grpId the id of the group
|
|
||||||
*/
|
|
||||||
virtual void requestGroupStatistic(uint32_t& token, const RsGxsGroupId& grpId) = 0;
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief Cancel Request
|
* @brief Cancel Request
|
||||||
* If this function returns false, it may be that the request has completed
|
* If this function returns false, it may be that the request has completed
|
||||||
|
|
|
@ -302,7 +302,6 @@ void p3GxsChannels::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
||||||
{
|
{
|
||||||
switch (grpChange->getType())
|
switch (grpChange->getType())
|
||||||
{
|
{
|
||||||
default:
|
|
||||||
case RsGxsNotify::TYPE_PROCESSED: // happens when the group is subscribed
|
case RsGxsNotify::TYPE_PROCESSED: // happens when the group is subscribed
|
||||||
{
|
{
|
||||||
std::list<RsGxsGroupId> &grpList = grpChange->mGrpIdList;
|
std::list<RsGxsGroupId> &grpList = grpChange->mGrpIdList;
|
||||||
|
@ -318,6 +317,20 @@ void p3GxsChannels::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case RsGxsNotify::TYPE_STATISTICS_CHANGED:
|
||||||
|
{
|
||||||
|
std::list<RsGxsGroupId> &grpList = grpChange->mGrpIdList;
|
||||||
|
std::list<RsGxsGroupId>::iterator git;
|
||||||
|
for (git = grpList.begin(); git != grpList.end(); ++git)
|
||||||
|
{
|
||||||
|
auto ev = std::make_shared<RsGxsChannelEvent>();
|
||||||
|
ev->mChannelGroupId = *git;
|
||||||
|
ev->mChannelEventCode = RsChannelEventCode::STATISTICS_CHANGED;
|
||||||
|
rsEvents->postEvent(ev);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case RsGxsNotify::TYPE_PUBLISHED:
|
case RsGxsNotify::TYPE_PUBLISHED:
|
||||||
case RsGxsNotify::TYPE_RECEIVED_NEW:
|
case RsGxsNotify::TYPE_RECEIVED_NEW:
|
||||||
{
|
{
|
||||||
|
@ -356,9 +369,14 @@ void p3GxsChannels::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
||||||
|
|
||||||
rsEvents->postEvent(ev);
|
rsEvents->postEvent(ev);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
RsErr() << " Got a GXS event of type " << grpChange->getType() << " Currently not handled." << std::endl;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RsGxsDistantSearchResultChange *dsrChange = dynamic_cast<RsGxsDistantSearchResultChange*>(*it);
|
RsGxsDistantSearchResultChange *dsrChange = dynamic_cast<RsGxsDistantSearchResultChange*>(*it);
|
||||||
|
|
|
@ -246,7 +246,6 @@ void p3GxsForums::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
||||||
{
|
{
|
||||||
switch (grpChange->getType())
|
switch (grpChange->getType())
|
||||||
{
|
{
|
||||||
default:
|
|
||||||
case RsGxsNotify::TYPE_PROCESSED: // happens when the group is subscribed
|
case RsGxsNotify::TYPE_PROCESSED: // happens when the group is subscribed
|
||||||
{
|
{
|
||||||
std::list<RsGxsGroupId> &grpList = grpChange->mGrpIdList;
|
std::list<RsGxsGroupId> &grpList = grpChange->mGrpIdList;
|
||||||
|
@ -260,7 +259,7 @@ void p3GxsForums::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RsGxsNotify::TYPE_PUBLISHED:
|
case RsGxsNotify::TYPE_PUBLISHED:
|
||||||
case RsGxsNotify::TYPE_RECEIVED_NEW:
|
case RsGxsNotify::TYPE_RECEIVED_NEW:
|
||||||
|
@ -288,8 +287,26 @@ void p3GxsForums::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
||||||
<< " Not notifying already known forum "
|
<< " Not notifying already known forum "
|
||||||
<< *git << std::endl;
|
<< *git << std::endl;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case RsGxsNotify::TYPE_STATISTICS_CHANGED:
|
||||||
|
{
|
||||||
|
std::list<RsGxsGroupId> &grpList = grpChange->mGrpIdList;
|
||||||
|
std::list<RsGxsGroupId>::iterator git;
|
||||||
|
for (git = grpList.begin(); git != grpList.end(); ++git)
|
||||||
|
{
|
||||||
|
auto ev = std::make_shared<RsGxsForumEvent>();
|
||||||
|
ev->mForumGroupId = *git;
|
||||||
|
ev->mForumEventCode = RsForumEventCode::STATISTICS_CHANGED;
|
||||||
|
rsEvents->postEvent(ev);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
RsErr() << " Got a GXS event of type " << grpChange->getType() << " Currently not handled." << std::endl;
|
||||||
|
break;
|
||||||
|
|
||||||
|
|
||||||
#ifdef NOT_USED_YET
|
#ifdef NOT_USED_YET
|
||||||
case RsGxsNotify::TYPE_RECEIVED_PUBLISHKEY:
|
case RsGxsNotify::TYPE_RECEIVED_PUBLISHKEY:
|
||||||
|
|
|
@ -133,8 +133,7 @@ void p3PostBase::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
switch(grpChange->getType())
|
switch(grpChange->getType())
|
||||||
{
|
{
|
||||||
default:
|
|
||||||
case RsGxsNotify::TYPE_PROCESSED: // happens when the group is subscribed
|
case RsGxsNotify::TYPE_PROCESSED: // happens when the group is subscribed
|
||||||
{
|
{
|
||||||
std::list<RsGxsGroupId> &grpList = grpChange->mGrpIdList;
|
std::list<RsGxsGroupId> &grpList = grpChange->mGrpIdList;
|
||||||
|
@ -148,15 +147,30 @@ void p3PostBase::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RsGxsNotify::TYPE_PUBLISHED:
|
case RsGxsNotify::TYPE_STATISTICS_CHANGED:
|
||||||
case RsGxsNotify::TYPE_RECEIVED_NEW:
|
{
|
||||||
{
|
std::list<RsGxsGroupId> &grpList = grpChange->mGrpIdList;
|
||||||
/* group received */
|
std::list<RsGxsGroupId>::iterator git;
|
||||||
const std::list<RsGxsGroupId>& grpList = grpChange->mGrpIdList;
|
|
||||||
|
|
||||||
for (auto git = grpList.begin(); git != grpList.end(); ++git)
|
for (git = grpList.begin(); git != grpList.end(); ++git)
|
||||||
|
{
|
||||||
|
auto ev = std::make_shared<RsGxsPostedEvent>();
|
||||||
|
ev->mPostedGroupId = *git;
|
||||||
|
ev->mPostedEventCode = RsPostedEventCode::STATISTICS_CHANGED;
|
||||||
|
rsEvents->postEvent(ev);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case RsGxsNotify::TYPE_PUBLISHED:
|
||||||
|
case RsGxsNotify::TYPE_RECEIVED_NEW:
|
||||||
|
{
|
||||||
|
/* group received */
|
||||||
|
const std::list<RsGxsGroupId>& grpList = grpChange->mGrpIdList;
|
||||||
|
|
||||||
|
for (auto git = grpList.begin(); git != grpList.end(); ++git)
|
||||||
{
|
{
|
||||||
if(mKnownPosted.find(*git) == mKnownPosted.end())
|
if(mKnownPosted.find(*git) == mKnownPosted.end())
|
||||||
{
|
{
|
||||||
|
@ -178,9 +192,13 @@ void p3PostBase::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
||||||
<< " Not notifying already known forum "
|
<< " Not notifying already known forum "
|
||||||
<< *git << std::endl;
|
<< *git << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
default:
|
||||||
|
RsErr() << " Got a GXS event of type " << grpChange->getType() << " Currently not handled." << std::endl;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
delete *it;
|
delete *it;
|
||||||
|
|
|
@ -62,13 +62,18 @@ void PostedDialog::handleEvent_main_thread(std::shared_ptr<const RsEvent> event)
|
||||||
case RsPostedEventCode::NEW_MESSAGE:
|
case RsPostedEventCode::NEW_MESSAGE:
|
||||||
case RsPostedEventCode::UPDATED_MESSAGE: // [[fallthrough]];
|
case RsPostedEventCode::UPDATED_MESSAGE: // [[fallthrough]];
|
||||||
case RsPostedEventCode::READ_STATUS_CHANGED: // [[fallthrough]];
|
case RsPostedEventCode::READ_STATUS_CHANGED: // [[fallthrough]];
|
||||||
updateMessageSummaryList(e->mPostedGroupId);
|
updateGroupStatisticsReal(e->mPostedGroupId); // update the list immediately
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RsPostedEventCode::NEW_POSTED_GROUP: // [[fallthrough]];
|
case RsPostedEventCode::NEW_POSTED_GROUP: // [[fallthrough]];
|
||||||
case RsPostedEventCode::SUBSCRIBE_STATUS_CHANGED: // [[fallthrough]];
|
case RsPostedEventCode::SUBSCRIBE_STATUS_CHANGED: // [[fallthrough]];
|
||||||
updateDisplay(true);
|
updateDisplay(true);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case RsPostedEventCode::STATISTICS_CHANGED:
|
||||||
|
updateGroupStatistics(e->mPostedGroupId);
|
||||||
|
break;
|
||||||
|
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -82,7 +87,7 @@ PostedDialog::~PostedDialog()
|
||||||
|
|
||||||
UserNotify *PostedDialog::createUserNotify(QObject *parent)
|
UserNotify *PostedDialog::createUserNotify(QObject *parent)
|
||||||
{
|
{
|
||||||
return new PostedUserNotify(rsPosted, parent);
|
return new PostedUserNotify(rsPosted, this, parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString PostedDialog::getHelpString() const
|
QString PostedDialog::getHelpString() const
|
||||||
|
|
|
@ -22,8 +22,8 @@
|
||||||
#include "PostedUserNotify.h"
|
#include "PostedUserNotify.h"
|
||||||
#include "gui/MainWindow.h"
|
#include "gui/MainWindow.h"
|
||||||
|
|
||||||
PostedUserNotify::PostedUserNotify(RsGxsIfaceHelper *ifaceImpl, QObject *parent) :
|
PostedUserNotify::PostedUserNotify(RsGxsIfaceHelper *ifaceImpl, const GxsGroupFrameDialog *g, QObject *parent) :
|
||||||
GxsUserNotify(ifaceImpl, parent)
|
GxsUserNotify(ifaceImpl, g, parent)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,10 +34,6 @@ 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()
|
||||||
{
|
{
|
||||||
|
|
|
@ -28,10 +28,9 @@ class PostedUserNotify : public GxsUserNotify
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PostedUserNotify(RsGxsIfaceHelper *ifaceImpl, QObject *parent = 0);
|
PostedUserNotify(RsGxsIfaceHelper *ifaceImpl, const GxsGroupFrameDialog *g, 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();
|
||||||
|
|
|
@ -59,6 +59,8 @@
|
||||||
|
|
||||||
#define MAX_COMMENT_TITLE 32
|
#define MAX_COMMENT_TITLE 32
|
||||||
|
|
||||||
|
static const uint32_t DELAY_BETWEEN_GROUP_STATISTICS_UPDATE = 120; // do not update group statistics more often than once every 2 mins
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Transformation Notes:
|
* Transformation Notes:
|
||||||
* there are still a couple of things that the new groups differ from Old version.
|
* there are still a couple of things that the new groups differ from Old version.
|
||||||
|
@ -76,6 +78,9 @@ GxsGroupFrameDialog::GxsGroupFrameDialog(RsGxsIfaceHelper *ifaceImpl, QWidget *p
|
||||||
ui = new Ui::GxsGroupFrameDialog();
|
ui = new Ui::GxsGroupFrameDialog();
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
mShouldUpdateMessageSummaryList = true;
|
||||||
|
mShouldUpdateGroupStatistics = false;
|
||||||
|
mLastGroupStatisticsUpdateTs=0;
|
||||||
mInitialized = false;
|
mInitialized = false;
|
||||||
mDistSyncAllowed = allow_dist_sync;
|
mDistSyncAllowed = allow_dist_sync;
|
||||||
mInFill = false;
|
mInFill = false;
|
||||||
|
@ -182,7 +187,43 @@ void GxsGroupFrameDialog::showEvent(QShowEvent *event)
|
||||||
initUi();
|
initUi();
|
||||||
}
|
}
|
||||||
|
|
||||||
updateDisplay( mCachedGroupMetas.empty() );
|
uint32_t children = mYourGroups->childCount() + mSubscribedGroups->childCount() + mPopularGroups->childCount() + mOtherGroups->childCount();
|
||||||
|
|
||||||
|
bool empty = mCachedGroupMetas.empty() || children==0;
|
||||||
|
|
||||||
|
updateDisplay( empty );
|
||||||
|
}
|
||||||
|
|
||||||
|
void GxsGroupFrameDialog::paintEvent(QPaintEvent *pe)
|
||||||
|
{
|
||||||
|
if(mShouldUpdateMessageSummaryList)
|
||||||
|
{
|
||||||
|
if(!mGroupIdsSummaryToUpdate.empty())
|
||||||
|
for(auto& group_id: mGroupIdsSummaryToUpdate)
|
||||||
|
updateMessageSummaryListReal(group_id);
|
||||||
|
else
|
||||||
|
updateMessageSummaryListReal(RsGxsGroupId());
|
||||||
|
|
||||||
|
mShouldUpdateMessageSummaryList = false;
|
||||||
|
mGroupIdsSummaryToUpdate.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
rstime_t now = time(nullptr);
|
||||||
|
|
||||||
|
if(mShouldUpdateGroupStatistics && now > DELAY_BETWEEN_GROUP_STATISTICS_UPDATE + mLastGroupStatisticsUpdateTs)
|
||||||
|
{
|
||||||
|
// This mechanism allows to gather multiple updateGroupStatistics events at once and not send too many of them at the same time.
|
||||||
|
// it avoids re-loadign all the group everytime a friend sends new statistics.
|
||||||
|
|
||||||
|
for(auto& groupId: mGroupStatisticsToUpdate)
|
||||||
|
updateGroupStatisticsReal(groupId);
|
||||||
|
|
||||||
|
mShouldUpdateGroupStatistics = false;
|
||||||
|
mLastGroupStatisticsUpdateTs = time(nullptr);
|
||||||
|
mGroupStatisticsToUpdate.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
MainPage::paintEvent(pe);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GxsGroupFrameDialog::processSettings(bool load)
|
void GxsGroupFrameDialog::processSettings(bool load)
|
||||||
|
@ -988,6 +1029,18 @@ void GxsGroupFrameDialog::insertGroupsData(const std::list<RsGxsGenericGroupData
|
||||||
}
|
}
|
||||||
|
|
||||||
void GxsGroupFrameDialog::updateMessageSummaryList(RsGxsGroupId groupId)
|
void GxsGroupFrameDialog::updateMessageSummaryList(RsGxsGroupId groupId)
|
||||||
|
{
|
||||||
|
// groupId.isNull() means that we need to update all groups so we clear up the list of groups to update.
|
||||||
|
|
||||||
|
if(!groupId.isNull())
|
||||||
|
mGroupIdsSummaryToUpdate.insert(groupId);
|
||||||
|
else
|
||||||
|
mGroupIdsSummaryToUpdate.clear();
|
||||||
|
|
||||||
|
mShouldUpdateMessageSummaryList = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void GxsGroupFrameDialog::updateMessageSummaryListReal(RsGxsGroupId groupId)
|
||||||
{
|
{
|
||||||
if (!mInitialized) {
|
if (!mInitialized) {
|
||||||
return;
|
return;
|
||||||
|
@ -1072,6 +1125,12 @@ void GxsGroupFrameDialog::updateGroupSummary()
|
||||||
/*********************** **** **** **** ***********************/
|
/*********************** **** **** **** ***********************/
|
||||||
|
|
||||||
void GxsGroupFrameDialog::updateGroupStatistics(const RsGxsGroupId &groupId)
|
void GxsGroupFrameDialog::updateGroupStatistics(const RsGxsGroupId &groupId)
|
||||||
|
{
|
||||||
|
mGroupStatisticsToUpdate.insert(groupId);
|
||||||
|
mShouldUpdateGroupStatistics = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void GxsGroupFrameDialog::updateGroupStatisticsReal(const RsGxsGroupId &groupId)
|
||||||
{
|
{
|
||||||
RsThread::async([this,groupId]()
|
RsThread::async([this,groupId]()
|
||||||
{
|
{
|
||||||
|
@ -1083,7 +1142,7 @@ void GxsGroupFrameDialog::updateGroupStatistics(const RsGxsGroupId &groupId)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
RsQThreadUtils::postToObject( [this,stats]()
|
RsQThreadUtils::postToObject( [this,stats, groupId]()
|
||||||
{
|
{
|
||||||
/* Here it goes any code you want to be executed on the Qt Gui
|
/* 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
|
* thread, for example to update the data model with new information
|
||||||
|
@ -1096,6 +1155,7 @@ void GxsGroupFrameDialog::updateGroupStatistics(const RsGxsGroupId &groupId)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ui->groupTreeWidget->setUnreadCount(item, mCountChildMsgs ? (stats.mNumThreadMsgsUnread + stats.mNumChildMsgsUnread) : stats.mNumThreadMsgsUnread);
|
ui->groupTreeWidget->setUnreadCount(item, mCountChildMsgs ? (stats.mNumThreadMsgsUnread + stats.mNumChildMsgsUnread) : stats.mNumThreadMsgsUnread);
|
||||||
|
mCachedGroupStats[groupId] = stats;
|
||||||
|
|
||||||
getUserNotify()->updateIcon();
|
getUserNotify()->updateIcon();
|
||||||
|
|
||||||
|
@ -1103,6 +1163,23 @@ void GxsGroupFrameDialog::updateGroupStatistics(const RsGxsGroupId &groupId)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GxsGroupFrameDialog::getServiceStatistics(GxsServiceStatistic& stats) const
|
||||||
|
{
|
||||||
|
stats = GxsServiceStatistic(); // clears everything
|
||||||
|
|
||||||
|
for(auto it: mCachedGroupStats)
|
||||||
|
{
|
||||||
|
const GxsGroupStatistic& s(it.second);
|
||||||
|
|
||||||
|
stats.mNumMsgs += s.mNumMsgs;
|
||||||
|
stats.mNumGrps += 1;
|
||||||
|
stats.mSizeOfMsgs += s.mTotalSizeOfMsgs;
|
||||||
|
stats.mNumThreadMsgsNew += s.mNumThreadMsgsNew;
|
||||||
|
stats.mNumThreadMsgsUnread += s.mNumThreadMsgsUnread;
|
||||||
|
stats.mNumChildMsgsNew += s.mNumChildMsgsNew ;
|
||||||
|
stats.mNumChildMsgsUnread += s.mNumChildMsgsUnread ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
TurtleRequestId GxsGroupFrameDialog::distantSearch(const QString& search_string) // this should be overloaded in the child class
|
TurtleRequestId GxsGroupFrameDialog::distantSearch(const QString& search_string) // this should be overloaded in the child class
|
||||||
{
|
{
|
||||||
|
|
|
@ -29,7 +29,6 @@
|
||||||
|
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
|
|
||||||
#include "util/TokenQueue.h"
|
|
||||||
#include "GxsIdTreeWidgetItem.h"
|
#include "GxsIdTreeWidgetItem.h"
|
||||||
#include "GxsGroupDialog.h"
|
#include "GxsGroupDialog.h"
|
||||||
|
|
||||||
|
@ -80,8 +79,11 @@ public:
|
||||||
|
|
||||||
virtual void getGroupList(std::map<RsGxsGroupId,RsGroupMetaData> &groups) ;
|
virtual void getGroupList(std::map<RsGxsGroupId,RsGroupMetaData> &groups) ;
|
||||||
|
|
||||||
|
void getServiceStatistics(GxsServiceStatistic& stats) const ;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void showEvent(QShowEvent *event);
|
virtual void showEvent(QShowEvent *event) override;
|
||||||
|
virtual void paintEvent(QPaintEvent *pe) override;
|
||||||
virtual void updateDisplay(bool complete);
|
virtual void updateDisplay(bool complete);
|
||||||
|
|
||||||
const RsGxsGroupId &groupId() { return mGroupId; }
|
const RsGxsGroupId &groupId() { return mGroupId; }
|
||||||
|
@ -102,6 +104,10 @@ protected:
|
||||||
|
|
||||||
virtual bool getGroupData(std::list<RsGxsGenericGroupData*>& groupInfo) =0;
|
virtual bool getGroupData(std::list<RsGxsGenericGroupData*>& groupInfo) =0;
|
||||||
virtual bool getGroupStatistics(const RsGxsGroupId& groupId,GxsGroupStatistic& stat) =0;
|
virtual bool getGroupStatistics(const RsGxsGroupId& groupId,GxsGroupStatistic& stat) =0;
|
||||||
|
|
||||||
|
void updateGroupStatisticsReal(const RsGxsGroupId &groupId);
|
||||||
|
void updateMessageSummaryListReal(RsGxsGroupId groupId);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void todo();
|
void todo();
|
||||||
|
|
||||||
|
@ -173,20 +179,13 @@ private:
|
||||||
|
|
||||||
virtual uint32_t requestGroupSummaryType() { return GXS_REQUEST_TYPE_GROUP_META; } // request only meta data
|
virtual uint32_t requestGroupSummaryType() { return GXS_REQUEST_TYPE_GROUP_META; } // request only meta data
|
||||||
|
|
||||||
void requestGroupStatistics(const RsGxsGroupId &groupId);
|
|
||||||
void loadGroupStatistics(const uint32_t &token);
|
|
||||||
|
|
||||||
// subscribe/unsubscribe ack.
|
// subscribe/unsubscribe ack.
|
||||||
// void acknowledgeSubscribeChange(const uint32_t &token);
|
|
||||||
|
|
||||||
GxsMessageFrameWidget *messageWidget(const RsGxsGroupId &groupId, bool ownTab);
|
GxsMessageFrameWidget *messageWidget(const RsGxsGroupId &groupId, bool ownTab);
|
||||||
GxsMessageFrameWidget *createMessageWidget(const RsGxsGroupId &groupId);
|
GxsMessageFrameWidget *createMessageWidget(const RsGxsGroupId &groupId);
|
||||||
|
|
||||||
GxsCommentDialog *commentWidget(const RsGxsMessageId &msgId);
|
GxsCommentDialog *commentWidget(const RsGxsMessageId &msgId);
|
||||||
|
|
||||||
// void requestGroupSummary_CurrentGroup(const RsGxsGroupId &groupId);
|
|
||||||
// void loadGroupSummary_CurrentGroup(const uint32_t &token);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void updateSearchResults();
|
void updateSearchResults();
|
||||||
|
|
||||||
|
@ -209,12 +208,23 @@ private:
|
||||||
RsGxsGroupId mNavigatePendingGroupId;
|
RsGxsGroupId mNavigatePendingGroupId;
|
||||||
RsGxsMessageId mNavigatePendingMsgId;
|
RsGxsMessageId mNavigatePendingMsgId;
|
||||||
|
|
||||||
|
// Message summary list update
|
||||||
|
|
||||||
|
bool mShouldUpdateMessageSummaryList ; // whether we should update the counting for groups. This takes some CPU so we only do it when needed.
|
||||||
|
std::set<RsGxsGroupId> mGroupIdsSummaryToUpdate;
|
||||||
|
|
||||||
|
// GroupStatistics update
|
||||||
|
bool mShouldUpdateGroupStatistics;
|
||||||
|
rstime_t mLastGroupStatisticsUpdateTs;
|
||||||
|
std::set<RsGxsGroupId> mGroupStatisticsToUpdate;
|
||||||
|
|
||||||
UIStateHelper *mStateHelper;
|
UIStateHelper *mStateHelper;
|
||||||
|
|
||||||
/** Qt Designer generated object */
|
/** Qt Designer generated object */
|
||||||
Ui::GxsGroupFrameDialog *ui;
|
Ui::GxsGroupFrameDialog *ui;
|
||||||
|
|
||||||
std::map<RsGxsGroupId,RsGroupMetaData> mCachedGroupMetas;
|
std::map<RsGxsGroupId,RsGroupMetaData> mCachedGroupMetas;
|
||||||
|
std::map<RsGxsGroupId,GxsGroupStatistic> mCachedGroupStats;
|
||||||
|
|
||||||
std::map<uint32_t,QTreeWidgetItem*> mSearchGroupsItems ;
|
std::map<uint32_t,QTreeWidgetItem*> mSearchGroupsItems ;
|
||||||
std::map<uint32_t,std::set<RsGxsGroupId> > mKnownGroups;
|
std::map<uint32_t,std::set<RsGxsGroupId> > mKnownGroups;
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
|
|
||||||
#define TOKEN_TYPE_STATISTICS 1
|
#define TOKEN_TYPE_STATISTICS 1
|
||||||
|
|
||||||
GxsUserNotify::GxsUserNotify(RsGxsIfaceHelper *ifaceImpl, QObject *parent) : UserNotify(parent)
|
GxsUserNotify::GxsUserNotify(RsGxsIfaceHelper *ifaceImpl, const GxsGroupFrameDialog *g,QObject *parent) : UserNotify(parent), mGroupFrameDialog(g)
|
||||||
{
|
{
|
||||||
mNewThreadMessageCount = 0;
|
mNewThreadMessageCount = 0;
|
||||||
mNewChildMessageCount = 0;
|
mNewChildMessageCount = 0;
|
||||||
|
@ -40,32 +40,17 @@ void GxsUserNotify::startUpdate()
|
||||||
mNewThreadMessageCount = 0;
|
mNewThreadMessageCount = 0;
|
||||||
mNewChildMessageCount = 0;
|
mNewChildMessageCount = 0;
|
||||||
|
|
||||||
RsThread::async([this]()
|
|
||||||
{
|
|
||||||
// 1 - get message data from p3GxsForums
|
|
||||||
|
|
||||||
#ifdef DEBUG_FORUMS
|
GxsServiceStatistic stats;
|
||||||
std::cerr << "Retrieving post data for post " << mThreadId << std::endl;
|
mGroupFrameDialog->getServiceStatistics(stats);
|
||||||
#endif
|
|
||||||
|
|
||||||
GxsServiceStatistic stats;
|
/* Here it goes any code you want to be executed on the Qt Gui
|
||||||
|
|
||||||
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
|
* thread, for example to update the data model with new information
|
||||||
* after a blocking call to RetroShare API complete */
|
* after a blocking call to RetroShare API complete */
|
||||||
|
|
||||||
mNewThreadMessageCount = stats.mNumThreadMsgsNew;
|
mNewThreadMessageCount = stats.mNumThreadMsgsNew;
|
||||||
mNewChildMessageCount = stats.mNumChildMsgsNew;
|
mNewChildMessageCount = stats.mNumChildMsgsNew;
|
||||||
|
|
||||||
update();
|
update();
|
||||||
|
|
||||||
}, this );
|
|
||||||
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include "gui/common/UserNotify.h"
|
#include "gui/common/UserNotify.h"
|
||||||
|
#include "gui/gxs/GxsGroupFrameDialog.h"
|
||||||
#include "util/TokenQueue.h"
|
#include "util/TokenQueue.h"
|
||||||
|
|
||||||
struct RsGxsIfaceHelper;
|
struct RsGxsIfaceHelper;
|
||||||
|
@ -33,12 +34,11 @@ class GxsUserNotify : public UserNotify
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
GxsUserNotify(RsGxsIfaceHelper *ifaceImpl, QObject *parent = 0);
|
GxsUserNotify(RsGxsIfaceHelper *ifaceImpl, const GxsGroupFrameDialog *g, QObject *parent = 0);
|
||||||
virtual ~GxsUserNotify();
|
virtual ~GxsUserNotify();
|
||||||
|
|
||||||
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; }
|
||||||
|
@ -48,6 +48,8 @@ protected:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
RsGxsUpdateBroadcastBase *mBase;
|
RsGxsUpdateBroadcastBase *mBase;
|
||||||
|
const GxsGroupFrameDialog *mGroupFrameDialog;
|
||||||
|
|
||||||
unsigned int mNewThreadMessageCount;
|
unsigned int mNewThreadMessageCount;
|
||||||
unsigned int mNewChildMessageCount;
|
unsigned int mNewChildMessageCount;
|
||||||
};
|
};
|
||||||
|
|
|
@ -64,10 +64,10 @@ void GxsChannelDialog::handleEvent_main_thread(std::shared_ptr<const RsEvent> ev
|
||||||
|
|
||||||
switch(e->mChannelEventCode)
|
switch(e->mChannelEventCode)
|
||||||
{
|
{
|
||||||
case RsChannelEventCode::NEW_MESSAGE:
|
case RsChannelEventCode::NEW_MESSAGE: // [[fallthrough]];
|
||||||
case RsChannelEventCode::UPDATED_MESSAGE: // [[fallthrough]];
|
case RsChannelEventCode::UPDATED_MESSAGE: // [[fallthrough]];
|
||||||
case RsChannelEventCode::READ_STATUS_CHANGED:
|
case RsChannelEventCode::READ_STATUS_CHANGED: // [[fallthrough]];
|
||||||
updateMessageSummaryList(e->mChannelGroupId);
|
updateGroupStatisticsReal(e->mChannelGroupId); // update the list immediately
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RsChannelEventCode::RECEIVED_DISTANT_SEARCH_RESULT:
|
case RsChannelEventCode::RECEIVED_DISTANT_SEARCH_RESULT:
|
||||||
|
@ -80,6 +80,10 @@ void GxsChannelDialog::handleEvent_main_thread(std::shared_ptr<const RsEvent> ev
|
||||||
updateDisplay(true);
|
updateDisplay(true);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case RsChannelEventCode::STATISTICS_CHANGED:
|
||||||
|
updateGroupStatistics(e->mChannelGroupId);
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -109,7 +113,7 @@ QString GxsChannelDialog::getHelpString() const
|
||||||
|
|
||||||
UserNotify *GxsChannelDialog::createUserNotify(QObject *parent)
|
UserNotify *GxsChannelDialog::createUserNotify(QObject *parent)
|
||||||
{
|
{
|
||||||
return new GxsChannelUserNotify(rsGxsChannels, parent);
|
return new GxsChannelUserNotify(rsGxsChannels,this, parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GxsChannelDialog::shareOnChannel(const RsGxsGroupId& channel_id,const QList<RetroShareLink>& file_links)
|
void GxsChannelDialog::shareOnChannel(const RsGxsGroupId& channel_id,const QList<RetroShareLink>& file_links)
|
||||||
|
|
|
@ -22,8 +22,8 @@
|
||||||
#include "GxsChannelUserNotify.h"
|
#include "GxsChannelUserNotify.h"
|
||||||
#include "gui/MainWindow.h"
|
#include "gui/MainWindow.h"
|
||||||
|
|
||||||
GxsChannelUserNotify::GxsChannelUserNotify(RsGxsIfaceHelper *ifaceImpl, QObject *parent) :
|
GxsChannelUserNotify::GxsChannelUserNotify(RsGxsIfaceHelper *ifaceImpl, const GxsGroupFrameDialog *g, QObject *parent) :
|
||||||
GxsUserNotify(ifaceImpl, parent)
|
GxsUserNotify(ifaceImpl, g, parent)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,11 +35,6 @@ 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");
|
||||||
|
|
|
@ -22,16 +22,16 @@
|
||||||
#define GXSCHANNELUSERNOTIFY_H
|
#define GXSCHANNELUSERNOTIFY_H
|
||||||
|
|
||||||
#include "gui/gxs/GxsUserNotify.h"
|
#include "gui/gxs/GxsUserNotify.h"
|
||||||
|
#include "gui/gxs/GxsGroupFrameDialog.h"
|
||||||
|
|
||||||
class GxsChannelUserNotify : public GxsUserNotify
|
class GxsChannelUserNotify : public GxsUserNotify
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
GxsChannelUserNotify(RsGxsIfaceHelper *ifaceImpl, QObject *parent = 0);
|
GxsChannelUserNotify(RsGxsIfaceHelper *ifaceImpl, const GxsGroupFrameDialog *g, 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();
|
||||||
|
|
|
@ -22,8 +22,8 @@
|
||||||
#include "GxsForumUserNotify.h"
|
#include "GxsForumUserNotify.h"
|
||||||
#include "gui/MainWindow.h"
|
#include "gui/MainWindow.h"
|
||||||
|
|
||||||
GxsForumUserNotify::GxsForumUserNotify(RsGxsIfaceHelper *ifaceImpl, QObject *parent) :
|
GxsForumUserNotify::GxsForumUserNotify(RsGxsIfaceHelper *ifaceImpl, const GxsGroupFrameDialog *g, QObject *parent) :
|
||||||
GxsUserNotify(ifaceImpl, parent)
|
GxsUserNotify(ifaceImpl, g, parent)
|
||||||
{
|
{
|
||||||
mCountChildMsgs = true;
|
mCountChildMsgs = true;
|
||||||
}
|
}
|
||||||
|
@ -35,10 +35,6 @@ 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()
|
||||||
{
|
{
|
||||||
|
|
|
@ -28,8 +28,7 @@ class GxsForumUserNotify : public GxsUserNotify
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
GxsForumUserNotify(RsGxsIfaceHelper *ifaceImpl, QObject *parent = 0);
|
GxsForumUserNotify(RsGxsIfaceHelper *ifaceImpl, const GxsGroupFrameDialog *g, QObject *parent = 0);
|
||||||
virtual bool getServiceStatistics(GxsServiceStatistic& stat) override;
|
|
||||||
|
|
||||||
virtual bool hasSetting(QString *name, QString *group);
|
virtual bool hasSetting(QString *name, QString *group);
|
||||||
|
|
||||||
|
|
|
@ -62,13 +62,18 @@ void GxsForumsDialog::handleEvent_main_thread(std::shared_ptr<const RsEvent> eve
|
||||||
case RsForumEventCode::NEW_MESSAGE:
|
case RsForumEventCode::NEW_MESSAGE:
|
||||||
case RsForumEventCode::UPDATED_MESSAGE: // [[fallthrough]];
|
case RsForumEventCode::UPDATED_MESSAGE: // [[fallthrough]];
|
||||||
case RsForumEventCode::READ_STATUS_CHANGED:
|
case RsForumEventCode::READ_STATUS_CHANGED:
|
||||||
updateMessageSummaryList(e->mForumGroupId);
|
updateGroupStatisticsReal(e->mForumGroupId); // update the list immediately
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RsForumEventCode::NEW_FORUM: // [[fallthrough]];
|
case RsForumEventCode::NEW_FORUM: // [[fallthrough]];
|
||||||
case RsForumEventCode::SUBSCRIBE_STATUS_CHANGED:
|
case RsForumEventCode::SUBSCRIBE_STATUS_CHANGED:
|
||||||
updateDisplay(true);
|
updateDisplay(true);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case RsForumEventCode::STATISTICS_CHANGED:
|
||||||
|
updateGroupStatistics(e->mForumGroupId); // update the list when redraw less often than once every 2 mins
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -133,7 +138,7 @@ void GxsForumsDialog::shareInMessage(const RsGxsGroupId& forum_id,const QList<Re
|
||||||
|
|
||||||
UserNotify *GxsForumsDialog::createUserNotify(QObject *parent)
|
UserNotify *GxsForumsDialog::createUserNotify(QObject *parent)
|
||||||
{
|
{
|
||||||
return new GxsForumUserNotify(rsGxsForums, parent);
|
return new GxsForumUserNotify(rsGxsForums,this, parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString GxsForumsDialog::text(TextType type)
|
QString GxsForumsDialog::text(TextType type)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue