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:
Gioacchino Mazzurco 2017-01-14 23:12:50 +01:00
parent 233c38d8db
commit a881441384
9 changed files with 99 additions and 65 deletions

View File

@ -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

View File

@ -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;

View File

@ -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;
}

View File

@ -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

View File

@ -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;

View File

@ -44,7 +44,7 @@ struct RsGroupMetaData
RsGxsGroupId mGroupId;
std::string mGroupName;
uint32_t mGroupFlags; // Combination of FLAGS_PRIVACY_PRIVATE | FLAGS_PRIVACY_RESTRICTED | FLAGS_PRIVACY_PUBLIC
uint32_t mGroupFlags; // Combination of FLAG_PRIVACY_PRIVATE | FLAG_PRIVACY_RESTRICTED | FLAG_PRIVACY_PUBLIC
uint32_t mSignFlags; // Combination of RSGXS_GROUP_SIGN_PUBLISH_MASK & RSGXS_GROUP_SIGN_AUTHOR_MASK.
time_t mPublishTs; // Mandatory.

View File

@ -31,6 +31,7 @@
#include <list>
#include "retroshare/rsgxsifacetypes.h"
#include "util/rsdeprecate.h"
// TODO CLEANUP: GXS_REQUEST_TYPE_* should be an inner enum of RsTokReqOptions
#define GXS_REQUEST_TYPE_GROUP_DATA 0x00010000
@ -57,9 +58,12 @@
#define RS_TOKREQOPT_MSG_AUTHOR 0x0040 // MSGLIST: Messages from this AuthorId
/* TODO CLEANUP: RS_TOKREQ_ANSTYPE_* values are not used by RsTokenService or
* its implementation, and may be arbitrarly defined by each GXS client, should
* be removed from here */
/* TODO CLEANUP: RS_TOKREQ_ANSTYPE_* values are meaningless and not used by
* RsTokenService or its implementation, and may be arbitrarly defined by each
* GXS client as they are of no usage, their use is deprecated */
#ifndef RS_NO_WARN_DEPRECATED
# warning RS_TOKREQ_ANSTYPE_* macros are deprecated!
#endif
#define RS_TOKREQ_ANSTYPE_LIST 0x0001
#define RS_TOKREQ_ANSTYPE_SUMMARY 0x0002
#define RS_TOKREQ_ANSTYPE_DATA 0x0003
@ -76,23 +80,31 @@ struct RsTokReqOptions
mMsgFlagMask(0), mMsgFlagFilter(0), mReqType(0), mSubscribeFilter(0),
mSubscribeMask(0), mBefore(0), mAfter(0) {}
uint32_t mOptions;
/**
* Can be one or multiple RS_TOKREQOPT_*
* TODO: cleanup this should be made with proper flags instead of macros
*/
uint32_t mOptions;
// Request specific matches with Group / Message Status.
// Should be usable with any Options... applied afterwards.
uint32_t mStatusFilter;
uint32_t mStatusMask;
// Request specific matches with Group / Message Status.
// Should be usable with any Options... applied afterwards.
uint32_t mStatusFilter;
uint32_t mStatusMask;
// use
uint32_t mMsgFlagMask, mMsgFlagFilter;
// use
uint32_t mMsgFlagMask, mMsgFlagFilter;
uint32_t mReqType;
/**
* Must be one of GXS_REQUEST_TYPE_*
* TODO: cleanup this should be made an enum instead of macros
*/
uint32_t mReqType;
uint32_t mSubscribeFilter, mSubscribeMask; // Only for Groups.
uint32_t mSubscribeFilter, mSubscribeMask; // Only for Groups.
// Time range... again applied after Options.
time_t mBefore;
time_t mAfter;
// Time range... again applied after Options.
time_t mBefore;
time_t mAfter;
};
std::ostream &operator<<(std::ostream &out, const RsGroupMetaData &meta);

View File

@ -658,7 +658,6 @@ bool RsGxsCircleCache::addLocalFriend(const RsPgpId &pgpId)
bool p3GxsCircles::request_CircleIdList()
{
/* trigger request to load missing ids into cache */
std::list<RsGxsGroupId> groupIds;
#ifdef DEBUG_CIRCLES
std::cerr << "p3GxsCircles::request_CircleIdList()";
std::cerr << std::endl;
@ -672,7 +671,7 @@ bool p3GxsCircles::request_CircleIdList()
RsGenExchange::getTokenService()->requestGroupInfo(token, ansType, opts);
GxsTokenQueue::queueRequest(token, CIRCLEREQ_CIRCLE_LIST);
return 1;
return true;
}

View File

@ -162,5 +162,8 @@ rs_autologin {
rs_nodeprecatedwarning {
QMAKE_CXXFLAGS += -Wno-deprecated
QMAKE_CXXFLAGS += -Wno-deprecated-declarations
DEFINES *= RS_NO_WARN_DEPRECATED
warning("QMAKE: You have disable deprecated warnings.")
}
rs_gxs_mail:DEFINES *= RS_GXS_MAIL