mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-28 08:59:37 -05:00
Added initial implementation of get statistic functions
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7455 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
6dace62abe
commit
c30318f0c0
@ -287,14 +287,25 @@ bool RsGxsDataAccess::requestMsgInfo(uint32_t &token, uint32_t ansType,
|
||||
}
|
||||
|
||||
|
||||
void RsGxsDataAccess::requestServiceStatistic(const uint32_t& token)
|
||||
void RsGxsDataAccess::requestServiceStatistic(uint32_t& token)
|
||||
{
|
||||
ServiceStatisticRequest* req = new ServiceStatisticRequest();
|
||||
|
||||
generateToken(token);
|
||||
|
||||
setReq(req, token, 0, RsTokReqOptions());
|
||||
storeRequest(req);
|
||||
}
|
||||
|
||||
void RsGxsDataAccess::requestGroupStatistic(const uint32_t& token, const RsGxsGroupId& grpId)
|
||||
void RsGxsDataAccess::requestGroupStatistic(uint32_t& token, const RsGxsGroupId& grpId)
|
||||
{
|
||||
GroupStatisticRequest* req = new GroupStatisticRequest();
|
||||
req->mGrpId = grpId;
|
||||
|
||||
generateToken(token);
|
||||
|
||||
setReq(req, token, 0, RsTokReqOptions());
|
||||
storeRequest(req);
|
||||
}
|
||||
|
||||
bool RsGxsDataAccess::requestMsgRelatedInfo(uint32_t &token, uint32_t ansType, const RsTokReqOptions &opts,
|
||||
@ -797,7 +808,69 @@ void RsGxsDataAccess::processRequests()
|
||||
clearRequest(*cit);
|
||||
}
|
||||
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
bool RsGxsDataAccess::getGroupStatistic(const uint32_t &token, GxsGroupStatistic &grpStatistic)
|
||||
{
|
||||
RsStackMutex stack(mDataMutex);
|
||||
|
||||
GxsRequest* req = locked_retrieveRequest(token);
|
||||
|
||||
if(req == NULL){
|
||||
|
||||
std::cerr << "RsGxsDataAccess::getGroupStatistic() Unable to retrieve grp stats" << std::endl;
|
||||
return false;
|
||||
}else if(req->status == GXS_REQUEST_V2_STATUS_COMPLETE){
|
||||
|
||||
GroupStatisticRequest* gsreq = dynamic_cast<GroupStatisticRequest*>(req);
|
||||
|
||||
if(gsreq)
|
||||
{
|
||||
grpStatistic = gsreq->mGroupStatistic;
|
||||
locked_updateRequestStatus(token, GXS_REQUEST_V2_STATUS_DONE);
|
||||
}
|
||||
else{
|
||||
std::cerr << "RsGxsDataAccess::getGroupStatistic() Req found, failed caste" << std::endl;
|
||||
return false;
|
||||
}
|
||||
}else{
|
||||
std::cerr << "RsGxsDataAccess::getGroupStatistic() Req not ready" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RsGxsDataAccess::getServiceStatistic(const uint32_t &token, GxsServiceStatistic &servStatistic)
|
||||
{
|
||||
RsStackMutex stack(mDataMutex);
|
||||
|
||||
GxsRequest* req = locked_retrieveRequest(token);
|
||||
|
||||
if(req == NULL){
|
||||
|
||||
std::cerr << "RsGxsDataAccess::getServiceStatistic() Unable to retrieve grp stats" << std::endl;
|
||||
return false;
|
||||
}else if(req->status == GXS_REQUEST_V2_STATUS_COMPLETE){
|
||||
|
||||
ServiceStatisticRequest* ssreq = dynamic_cast<ServiceStatisticRequest*>(req);
|
||||
|
||||
if(ssreq)
|
||||
{
|
||||
servStatistic = ssreq->mServiceStatistic;
|
||||
locked_updateRequestStatus(token, GXS_REQUEST_V2_STATUS_DONE);
|
||||
}
|
||||
else{
|
||||
std::cerr << "RsGxsDataAccess::getServiceStatistic() Req found, failed caste" << std::endl;
|
||||
return false;
|
||||
}
|
||||
}else{
|
||||
std::cerr << "RsGxsDataAccess::getServiceStatistic() Req not ready" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
@ -104,14 +104,14 @@ public:
|
||||
* total size of groups
|
||||
* @param token
|
||||
*/
|
||||
void requestServiceStatistic(const uint32_t& token);
|
||||
void requestServiceStatistic(uint32_t& token);
|
||||
|
||||
/*!
|
||||
* To request statistic on a group
|
||||
* @param token set to value to be redeemed to get statistic
|
||||
* @param grpId the id of the group
|
||||
*/
|
||||
void requestGroupStatistic(const uint32_t& token, const RsGxsGroupId& grpId);
|
||||
void requestGroupStatistic(uint32_t& token, const RsGxsGroupId& grpId);
|
||||
|
||||
|
||||
/* Poll */
|
||||
@ -152,11 +152,28 @@ public:
|
||||
|
||||
public:
|
||||
|
||||
|
||||
|
||||
/*!
|
||||
* This must be called periodically to progress requests
|
||||
*/
|
||||
void processRequests();
|
||||
|
||||
/*!
|
||||
* @param token
|
||||
* @param grpStatistic
|
||||
* @return false if token cannot be redeemed
|
||||
*/
|
||||
bool getGroupStatistic(const uint32_t &token, GxsGroupStatistic& grpStatistic);
|
||||
|
||||
/*!
|
||||
* @param token
|
||||
* @param servStatistic
|
||||
* @return false if token cannot be redeemed
|
||||
*/
|
||||
bool getServiceStatistic(const uint32_t &token, GxsServiceStatistic& servStatistic);
|
||||
|
||||
|
||||
/*!
|
||||
* Retrieve group list for a given token
|
||||
* @param token request token to be redeemed
|
||||
|
@ -97,6 +97,19 @@ public:
|
||||
NxsMsgDataResult mMsgData;
|
||||
};
|
||||
|
||||
class ServiceStatisticRequest: public GxsRequest
|
||||
{
|
||||
public:
|
||||
GxsServiceStatistic mServiceStatistic;
|
||||
};
|
||||
|
||||
struct GroupStatisticRequest: public GxsRequest
|
||||
{
|
||||
public:
|
||||
RsGxsGroupId mGrpId;
|
||||
GxsGroupStatistic mGroupStatistic;
|
||||
};
|
||||
|
||||
class MsgRelatedInfoReq : public GxsRequest
|
||||
{
|
||||
|
||||
|
@ -199,14 +199,14 @@ public:
|
||||
* total size of groups
|
||||
* @param token
|
||||
*/
|
||||
virtual void requestServiceStatistic(const uint32_t& token) = 0;
|
||||
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(const uint32_t& token, const RsGxsGroupId& grpId) = 0;
|
||||
virtual void requestGroupStatistic(uint32_t& token, const RsGxsGroupId& grpId) = 0;
|
||||
|
||||
|
||||
/* Cancel Request */
|
||||
|
Loading…
Reference in New Issue
Block a user