mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-08-07 13:52:43 -04:00
Some cleanup and deprecation
RsGxsDataAccess deprecate unused ansType RsGxsDataAccess::setReq(...) use proper types for params RsGxsDataAccess::getGroupData(...) print useful information in case of error GxsRequest proper initialization in constructor GxsRequest deprecate meaningless ansType RsGroupMetaData Fix comment to avoid confusion Deprecated meaningless RS_TOKREQ_ANSTYPE_* common source of confusion p3GxsCircles::request_CircleIdList() removed unused variable p3GxsCircles::request_CircleIdList() preper return value
This commit is contained in:
parent
233c38d8db
commit
a881441384
9 changed files with 99 additions and 65 deletions
|
@ -1292,20 +1292,19 @@ bool RsGenExchange::getGroupData(const uint32_t &token, std::vector<RsGxsGrpItem
|
|||
RsGxsGrpItem* gItem = dynamic_cast<RsGxsGrpItem*>(item);
|
||||
if (gItem)
|
||||
{
|
||||
gItem->meta = *((*lit)->metaData);
|
||||
gItem->meta = *((*lit)->metaData);
|
||||
|
||||
RsGroupNetworkStats sts ;
|
||||
|
||||
if(mNetService != NULL && mNetService->getGroupNetworkStats(gItem->meta.mGroupId,sts))
|
||||
{
|
||||
gItem->meta.mPop = sts.mSuppliers ;
|
||||
gItem->meta.mVisibleMsgCount = sts.mMaxVisibleCount;
|
||||
}
|
||||
else
|
||||
{
|
||||
gItem->meta.mPop = 0 ;
|
||||
gItem->meta.mVisibleMsgCount = 0 ;
|
||||
}
|
||||
RsGroupNetworkStats sts ;
|
||||
if(mNetService && mNetService->getGroupNetworkStats(gItem->meta.mGroupId,sts))
|
||||
{
|
||||
gItem->meta.mPop = sts.mSuppliers;
|
||||
gItem->meta.mVisibleMsgCount = sts.mMaxVisibleCount;
|
||||
}
|
||||
else
|
||||
{
|
||||
gItem->meta.mPop = 0;
|
||||
gItem->meta.mVisibleMsgCount = 0;
|
||||
}
|
||||
grpItem.push_back(gItem);
|
||||
}
|
||||
else
|
||||
|
|
|
@ -875,6 +875,7 @@ private:
|
|||
|
||||
private:
|
||||
|
||||
// TODO: cleanup this should be an enum!
|
||||
const uint8_t CREATE_FAIL, CREATE_SUCCESS, CREATE_FAIL_TRY_LATER, SIGN_MAX_WAITING_TIME;
|
||||
const uint8_t SIGN_FAIL, SIGN_SUCCESS, SIGN_FAIL_TRY_LATER;
|
||||
const uint8_t VALIDATE_FAIL, VALIDATE_SUCCESS, VALIDATE_FAIL_TRY_LATER, VALIDATE_MAX_WAITING_TIME;
|
||||
|
|
|
@ -303,7 +303,7 @@ bool RsGxsDataAccess::requestMsgRelatedInfo(uint32_t &token, uint32_t ansType, c
|
|||
}
|
||||
|
||||
|
||||
void RsGxsDataAccess::setReq(GxsRequest* req, const uint32_t& token, const uint32_t& ansType, const RsTokReqOptions& opts) const
|
||||
void RsGxsDataAccess::setReq(GxsRequest* req, uint32_t token, uint32_t ansType, const RsTokReqOptions& opts) const
|
||||
{
|
||||
req->token = token;
|
||||
req->ansType = ansType;
|
||||
|
@ -378,29 +378,37 @@ bool RsGxsDataAccess::clearRequest(const uint32_t& token)
|
|||
bool RsGxsDataAccess::getGroupSummary(const uint32_t& token, std::list<RsGxsGrpMetaData*>& groupInfo)
|
||||
{
|
||||
|
||||
RsStackMutex stack(mDataMutex);
|
||||
RS_STACK_MUTEX(mDataMutex);
|
||||
|
||||
GxsRequest* req = locked_retrieveRequest(token);
|
||||
|
||||
if(req == NULL){
|
||||
|
||||
std::cerr << "RsGxsDataAccess::getGroupSummary() Unable to retrieve group summary" << std::endl;
|
||||
if(req == NULL)
|
||||
{
|
||||
std::cerr << "RsGxsDataAccess::getGroupSummary() Unable to retrieve "
|
||||
<< "group summary" << std::endl;
|
||||
return false;
|
||||
}else if(req->status == GXS_REQUEST_V2_STATUS_COMPLETE){
|
||||
|
||||
}
|
||||
else if(req->status == GXS_REQUEST_V2_STATUS_COMPLETE)
|
||||
{
|
||||
GroupMetaReq* gmreq = dynamic_cast<GroupMetaReq*>(req);
|
||||
|
||||
if(gmreq)
|
||||
{
|
||||
groupInfo = gmreq->mGroupMetaData;
|
||||
gmreq->mGroupMetaData.clear();
|
||||
locked_updateRequestStatus(token, GXS_REQUEST_V2_STATUS_DONE);
|
||||
}else{
|
||||
std::cerr << "RsGxsDataAccess::getGroupSummary() Req found, failed caste" << std::endl;
|
||||
locked_updateRequestStatus(token, GXS_REQUEST_V2_STATUS_DONE);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "RsGxsDataAccess::getGroupSummary() Req found, failed"
|
||||
<< "cast" << std::endl;
|
||||
return false;
|
||||
}
|
||||
}else{
|
||||
std::cerr << "RsGxsDataAccess::getGroupSummary() Req not ready" << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "RsGxsDataAccess::getGroupSummary() Req not ready"
|
||||
<< std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -409,28 +417,34 @@ bool RsGxsDataAccess::getGroupSummary(const uint32_t& token, std::list<RsGxsGrpM
|
|||
|
||||
bool RsGxsDataAccess::getGroupData(const uint32_t& token, std::list<RsNxsGrp*>& grpData)
|
||||
{
|
||||
RsStackMutex stack(mDataMutex);
|
||||
RS_STACK_MUTEX(mDataMutex);
|
||||
|
||||
GxsRequest* req = locked_retrieveRequest(token);
|
||||
|
||||
if(req == NULL){
|
||||
|
||||
std::cerr << "RsGxsDataAccess::getGroupData() Unable to retrieve group data" << std::endl;
|
||||
if(req == NULL)
|
||||
{
|
||||
std::cerr << "RsGxsDataAccess::getGroupData() Unable to retrieve group"
|
||||
<< "data" << std::endl;
|
||||
return false;
|
||||
}else if(req->status == GXS_REQUEST_V2_STATUS_COMPLETE){
|
||||
|
||||
}
|
||||
else if(req->status == GXS_REQUEST_V2_STATUS_COMPLETE)
|
||||
{
|
||||
GroupDataReq* gmreq = dynamic_cast<GroupDataReq*>(req);
|
||||
|
||||
if(gmreq)
|
||||
{
|
||||
grpData.swap(gmreq->mGroupData);
|
||||
gmreq->mGroupData.clear();
|
||||
locked_updateRequestStatus(token, GXS_REQUEST_V2_STATUS_DONE);
|
||||
}else{
|
||||
std::cerr << "RsGxsDataAccess::getGroupData() Req found, failed caste" << std::endl;
|
||||
locked_updateRequestStatus(token, GXS_REQUEST_V2_STATUS_DONE);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "RsGxsDataAccess::getGroupData() Req found, failed cast"
|
||||
<< " req->reqType: " << req->reqType << std::endl;
|
||||
return false;
|
||||
}
|
||||
}else{
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "RsGxsDataAccess::getGroupData() Req not ready" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -42,12 +42,18 @@ public:
|
|||
|
||||
public:
|
||||
|
||||
/** S: RsTokenService **/
|
||||
/** S: RsTokenService
|
||||
* TODO: cleanup
|
||||
* In the following methods @param uint32_t ansType is of no use, it is
|
||||
* deprecated and should be removed as soon as possible as it is cause of
|
||||
* many confusions, instead use const RsTokReqOptions::mReqType &opts to
|
||||
* specify the kind of data you are interested in.
|
||||
*/
|
||||
|
||||
/*!
|
||||
* Use this to request group related information
|
||||
* @param token The token returned for the request, store this value to pool for request completion
|
||||
* @param ansType The type of result (e.g. group data, meta, ids)
|
||||
* @param ansType @deprecated unused @see S: RsTokenService notice
|
||||
* @param opts Additional option that affect outcome of request. Please see specific services, for valid values
|
||||
* @param groupIds group id to request info for
|
||||
* @return
|
||||
|
@ -57,7 +63,7 @@ public:
|
|||
/*!
|
||||
* Use this to request all group related info
|
||||
* @param token The token returned for the request, store this value to pool for request completion
|
||||
* @param ansType The type of result (e.g. group data, meta, ids)
|
||||
* @param ansType @deprecated unused @see S: RsTokenService notice
|
||||
* @param opts Additional option that affect outcome of request. Please see specific services, for valid values
|
||||
* @return
|
||||
*/
|
||||
|
@ -66,7 +72,7 @@ public:
|
|||
/*!
|
||||
* Use this to get msg information (id, meta, or data), store token value to poll for request completion
|
||||
* @param token The token returned for the request
|
||||
* @param ansType The type of result wanted
|
||||
* @param ansType @deprecated unused @see S: RsTokenService notice
|
||||
* @param opts Additional option that affect outcome of request. Please see specific services, for valid values
|
||||
* @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
|
||||
|
@ -76,7 +82,7 @@ public:
|
|||
/*!
|
||||
* Use this to get message information (id, meta, or data), store token value to poll for request completion
|
||||
* @param token The token returned for the request
|
||||
* @param ansType The type of result wanted
|
||||
* @param ansType @deprecated unused @see S: RsTokenService notice
|
||||
* @param opts Additional option that affect outcome of request. Please see specific services, for valid values
|
||||
* @param groupIds The ids of the groups to get, this retrieve all the msgs info for each grpId in list, if group Id list is empty \n
|
||||
* all messages for all groups are retrieved
|
||||
|
@ -87,7 +93,7 @@ public:
|
|||
/*!
|
||||
* For requesting msgs related to a given msg id within a group
|
||||
* @param token The token returned for the request
|
||||
* @param ansType The type of result wanted
|
||||
* @param ansType @deprecated unused @see S: RsTokenService notice
|
||||
* @param opts Additional option that affect outcome of request. Please see specific services, for valid values
|
||||
* @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
|
||||
|
@ -274,7 +280,7 @@ private:
|
|||
* @param ansType
|
||||
* @param opts
|
||||
*/
|
||||
void setReq(GxsRequest* req,const uint32_t &token, const uint32_t& ansType, const RsTokReqOptions &opts) const;
|
||||
void setReq(GxsRequest* req, uint32_t token, uint32_t ansType, const RsTokReqOptions& opts) const;
|
||||
|
||||
/*!
|
||||
* Remove request for request queue
|
||||
|
|
|
@ -28,17 +28,17 @@
|
|||
|
||||
#include "retroshare/rstokenservice.h"
|
||||
#include "gxs/rsgds.h"
|
||||
#include "util/rsdeprecate.h"
|
||||
|
||||
class GxsRequest
|
||||
struct GxsRequest
|
||||
{
|
||||
public:
|
||||
GxsRequest() : token(0), reqTime(0), ansType(0), reqType(0), status(0) {}
|
||||
virtual ~GxsRequest() {}
|
||||
|
||||
public:
|
||||
uint32_t token;
|
||||
uint32_t reqTime;
|
||||
|
||||
uint32_t ansType;
|
||||
RS_DEPRECATED uint32_t ansType; /// G10h4ck: This is of no use
|
||||
uint32_t reqType;
|
||||
RsTokReqOptions Options;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue