RsTokenService use enum for request status

This commit is contained in:
Gioacchino Mazzurco 2018-06-24 18:56:48 +02:00
parent ec95b6d054
commit b4d2ce82c1
No known key found for this signature in database
GPG Key ID: A1FBCA3872E87051
20 changed files with 146 additions and 153 deletions

View File

@ -71,12 +71,12 @@ void ChannelsHandler::handleListChannels(Request& /*req*/, Response& resp)
tChannels.requestGroupInfo(token, RS_DEPRECATED_TOKREQ_ANSTYPE, opts); tChannels.requestGroupInfo(token, RS_DEPRECATED_TOKREQ_ANSTYPE, opts);
time_t start = time(NULL); time_t start = time(NULL);
while((tChannels.requestStatus(token) != RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE) while((tChannels.requestStatus(token) != RsTokenService::COMPLETE)
&&(tChannels.requestStatus(token) != RsTokenService::GXS_REQUEST_V2_STATUS_FAILED) &&(tChannels.requestStatus(token) != RsTokenService::FAILED)
&&((time(NULL) < (start+10)))) rstime::rs_usleep(500*1000); &&((time(NULL) < (start+10)))) rstime::rs_usleep(500*1000);
std::list<RsGroupMetaData> grps; std::list<RsGroupMetaData> grps;
if( tChannels.requestStatus(token) == RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE if( tChannels.requestStatus(token) == RsTokenService::COMPLETE
&& mChannels.getGroupSummary(token, grps) ) && mChannels.getGroupSummary(token, grps) )
{ {
for( RsGroupMetaData& grp : grps ) for( RsGroupMetaData& grp : grps )
@ -136,12 +136,12 @@ void ChannelsHandler::handleGetChannelInfo(Request& req, Response& resp)
opts, groupIds ); opts, groupIds );
time_t start = time(NULL); time_t start = time(NULL);
while((tChannels.requestStatus(token) != RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE) while((tChannels.requestStatus(token) != RsTokenService::COMPLETE)
&&(tChannels.requestStatus(token) != RsTokenService::GXS_REQUEST_V2_STATUS_FAILED) &&(tChannels.requestStatus(token) != RsTokenService::FAILED)
&&((time(NULL) < (start+10)))) rstime::rs_usleep(500*1000); &&((time(NULL) < (start+10)))) rstime::rs_usleep(500*1000);
std::vector<RsGxsChannelGroup> grps; std::vector<RsGxsChannelGroup> grps;
if( tChannels.requestStatus(token) == RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE if( tChannels.requestStatus(token) == RsTokenService::COMPLETE
&& mChannels.getGroupData(token, grps) ) && mChannels.getGroupData(token, grps) )
{ {
for( RsGxsChannelGroup& grp : grps ) for( RsGxsChannelGroup& grp : grps )
@ -210,14 +210,14 @@ void ChannelsHandler::handleGetChannelContent(Request& req, Response& resp)
} }
time_t start = time(NULL); time_t start = time(NULL);
while((mChannels.getTokenService()->requestStatus(token) != RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE) while((mChannels.getTokenService()->requestStatus(token) != RsTokenService::COMPLETE)
&&(mChannels.getTokenService()->requestStatus(token) != RsTokenService::GXS_REQUEST_V2_STATUS_FAILED) &&(mChannels.getTokenService()->requestStatus(token) != RsTokenService::FAILED)
&&((time(NULL) < (start+10)))) rstime::rs_usleep(500*1000); &&((time(NULL) < (start+10)))) rstime::rs_usleep(500*1000);
std::vector<RsGxsChannelPost> posts; std::vector<RsGxsChannelPost> posts;
std::vector<RsGxsComment> comments; std::vector<RsGxsComment> comments;
if( mChannels.getTokenService()->requestStatus(token) == if( mChannels.getTokenService()->requestStatus(token) ==
RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE && RsTokenService::COMPLETE &&
mChannels.getPostData(token, posts, comments) ) mChannels.getPostData(token, posts, comments) )
{ {
for( std::vector<RsGxsChannelPost>::iterator vit = posts.begin(); for( std::vector<RsGxsChannelPost>::iterator vit = posts.begin();
@ -286,11 +286,11 @@ void ChannelsHandler::handleToggleSubscription(Request& req, Response& resp)
RsTokenService& tChannels = *mChannels.getTokenService(); RsTokenService& tChannels = *mChannels.getTokenService();
time_t start = time(NULL); time_t start = time(NULL);
while((tChannels.requestStatus(token) != RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE) while((tChannels.requestStatus(token) != RsTokenService::COMPLETE)
&&(tChannels.requestStatus(token) != RsTokenService::GXS_REQUEST_V2_STATUS_FAILED) &&(tChannels.requestStatus(token) != RsTokenService::FAILED)
&&((time(NULL) < (start+10)))) rstime::rs_usleep(500*1000); &&((time(NULL) < (start+10)))) rstime::rs_usleep(500*1000);
if(tChannels.requestStatus(token) == RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE) if(tChannels.requestStatus(token) == RsTokenService::COMPLETE)
resp.setOk(); resp.setOk();
else resp.setFail("Unknown GXS error!"); else resp.setFail("Unknown GXS error!");
} }
@ -353,11 +353,11 @@ void ChannelsHandler::handleCreateChannel(Request& req, Response& resp)
RsTokenService& tChannels = *mChannels.getTokenService(); RsTokenService& tChannels = *mChannels.getTokenService();
time_t start = time(NULL); time_t start = time(NULL);
while((tChannels.requestStatus(token) != RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE) while((tChannels.requestStatus(token) != RsTokenService::COMPLETE)
&&(tChannels.requestStatus(token) != RsTokenService::GXS_REQUEST_V2_STATUS_FAILED) &&(tChannels.requestStatus(token) != RsTokenService::FAILED)
&&((time(NULL) < (start+10)))) rstime::rs_usleep(500*1000); &&((time(NULL) < (start+10)))) rstime::rs_usleep(500*1000);
if(tChannels.requestStatus(token) == RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE) if(tChannels.requestStatus(token) == RsTokenService::COMPLETE)
resp.setOk(); resp.setOk();
else resp.setFail("Unknown GXS error!"); else resp.setFail("Unknown GXS error!");
} }
@ -436,11 +436,11 @@ void ChannelsHandler::handleTogglePostRead(Request& req, Response& resp)
RsTokenService& tChannels = *mChannels.getTokenService(); RsTokenService& tChannels = *mChannels.getTokenService();
time_t start = time(NULL); time_t start = time(NULL);
while((tChannels.requestStatus(token) != RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE) while((tChannels.requestStatus(token) != RsTokenService::COMPLETE)
&&(tChannels.requestStatus(token) != RsTokenService::GXS_REQUEST_V2_STATUS_FAILED) &&(tChannels.requestStatus(token) != RsTokenService::FAILED)
&&((time(NULL) < (start+10)))) rstime::rs_usleep(500*1000); &&((time(NULL) < (start+10)))) rstime::rs_usleep(500*1000);
if(tChannels.requestStatus(token) == RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE) if(tChannels.requestStatus(token) == RsTokenService::COMPLETE)
resp.setOk(); resp.setOk();
else resp.setFail("Unknown GXS error!"); else resp.setFail("Unknown GXS error!");
} }
@ -522,11 +522,11 @@ void ChannelsHandler::handleCreatePost(Request &req, Response &resp)
RsTokenService& tChannels = *mChannels.getTokenService(); RsTokenService& tChannels = *mChannels.getTokenService();
time_t start = time(NULL); time_t start = time(NULL);
while((tChannels.requestStatus(token) != RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE) while((tChannels.requestStatus(token) != RsTokenService::COMPLETE)
&&(tChannels.requestStatus(token) != RsTokenService::GXS_REQUEST_V2_STATUS_FAILED) &&(tChannels.requestStatus(token) != RsTokenService::FAILED)
&&((time(NULL) < (start+10)))) rstime::rs_usleep(500*1000); &&((time(NULL) < (start+10)))) rstime::rs_usleep(500*1000);
if(tChannels.requestStatus(token) == RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE) if(tChannels.requestStatus(token) == RsTokenService::COMPLETE)
resp.setOk(); resp.setOk();
else resp.setFail("Unknown GXS error!"); else resp.setFail("Unknown GXS error!");
} }

View File

@ -38,8 +38,8 @@ void ForumHandler::handleWildcard(Request &req, Response &resp)
mRsGxsForums->getTokenService()->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, groupIds); mRsGxsForums->getTokenService()->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, groupIds);
time_t start = time(NULL); time_t start = time(NULL);
while((mRsGxsForums->getTokenService()->requestStatus(token) != RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE) while((mRsGxsForums->getTokenService()->requestStatus(token) != RsTokenService::COMPLETE)
&&(mRsGxsForums->getTokenService()->requestStatus(token) != RsTokenService::GXS_REQUEST_V2_STATUS_FAILED) &&(mRsGxsForums->getTokenService()->requestStatus(token) != RsTokenService::FAILED)
&&((time(NULL) < (start+10))) &&((time(NULL) < (start+10)))
) )
{ {
@ -50,7 +50,7 @@ void ForumHandler::handleWildcard(Request &req, Response &resp)
#endif #endif
} }
if(mRsGxsForums->getTokenService()->requestStatus(token) == RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE) if(mRsGxsForums->getTokenService()->requestStatus(token) == RsTokenService::COMPLETE)
{ {
std::vector<RsGxsForumMsg> grps; std::vector<RsGxsForumMsg> grps;
ok &= mRsGxsForums->getMsgData(token, grps); ok &= mRsGxsForums->getMsgData(token, grps);
@ -86,8 +86,8 @@ void ForumHandler::handleWildcard(Request &req, Response &resp)
mRsGxsForums->getTokenService()->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts); mRsGxsForums->getTokenService()->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts);
time_t start = time(NULL); time_t start = time(NULL);
while((mRsGxsForums->getTokenService()->requestStatus(token) != RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE) while((mRsGxsForums->getTokenService()->requestStatus(token) != RsTokenService::COMPLETE)
&&(mRsGxsForums->getTokenService()->requestStatus(token) != RsTokenService::GXS_REQUEST_V2_STATUS_FAILED) &&(mRsGxsForums->getTokenService()->requestStatus(token) != RsTokenService::FAILED)
&&((time(NULL) < (start+10))) &&((time(NULL) < (start+10)))
) )
{ {
@ -97,7 +97,7 @@ void ForumHandler::handleWildcard(Request &req, Response &resp)
usleep(500*1000) ; usleep(500*1000) ;
#endif #endif
} }
if(mRsGxsForums->getTokenService()->requestStatus(token) == RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE) if(mRsGxsForums->getTokenService()->requestStatus(token) == RsTokenService::COMPLETE)
{ {
std::vector<RsGxsForumGroup> grps; std::vector<RsGxsForumGroup> grps;
ok &= mRsGxsForums->getGroupData(token, grps); ok &= mRsGxsForums->getGroupData(token, grps);

View File

@ -21,11 +21,11 @@ bool GxsResponseTask::doWork(Request &req, Response &resp)
for(std::vector<uint32_t>::iterator vit = mWaitingTokens.begin(); vit != mWaitingTokens.end(); ++vit) for(std::vector<uint32_t>::iterator vit = mWaitingTokens.begin(); vit != mWaitingTokens.end(); ++vit)
{ {
uint8_t status = mTokenService->requestStatus(*vit); uint8_t status = mTokenService->requestStatus(*vit);
if(status != RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE) if(status != RsTokenService::COMPLETE)
{ {
ready = false; ready = false;
} }
if(status == RsTokenService::GXS_REQUEST_V2_STATUS_FAILED) if(status == RsTokenService::FAILED)
{ {
std::cerr << "GxsResponseTask::doWork() Error: token failed. aborting." << std::endl; std::cerr << "GxsResponseTask::doWork() Error: token failed. aborting." << std::endl;
resp.setFail("GxsResponseTask::doWork() Error: token failed."); resp.setFail("GxsResponseTask::doWork() Error: token failed.");

View File

@ -220,15 +220,15 @@ void IdentityHandler::handleWildcard(Request & /*req*/, Response &resp)
time_t timeout = time(NULL)+10; time_t timeout = time(NULL)+10;
uint8_t rStatus = mRsIdentity->getTokenService()->requestStatus(token); uint8_t rStatus = mRsIdentity->getTokenService()->requestStatus(token);
while( rStatus != RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE && while( rStatus != RsTokenService::COMPLETE &&
rStatus != RsTokenService::GXS_REQUEST_V2_STATUS_FAILED && rStatus != RsTokenService::FAILED &&
time(NULL) < timeout ) time(NULL) < timeout )
{ {
usleep(50*1000); usleep(50*1000);
rStatus = mRsIdentity->getTokenService()->requestStatus(token); rStatus = mRsIdentity->getTokenService()->requestStatus(token);
} }
if(rStatus == RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE) if(rStatus == RsTokenService::COMPLETE)
{ {
std::vector<RsGxsIdGroup> grps; std::vector<RsGxsIdGroup> grps;
ok &= mRsIdentity->getGroupData(token, grps); ok &= mRsIdentity->getGroupData(token, grps);
@ -277,15 +277,15 @@ void IdentityHandler::handleNotOwnIdsRequest(Request & /*req*/, Response &resp)
time_t timeout = time(NULL)+10; time_t timeout = time(NULL)+10;
uint8_t rStatus = mRsIdentity->getTokenService()->requestStatus(token); uint8_t rStatus = mRsIdentity->getTokenService()->requestStatus(token);
while( rStatus != RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE && while( rStatus != RsTokenService::COMPLETE &&
rStatus != RsTokenService::GXS_REQUEST_V2_STATUS_FAILED && rStatus != RsTokenService::FAILED &&
time(NULL) < timeout ) time(NULL) < timeout )
{ {
usleep(50*1000); usleep(50*1000);
rStatus = mRsIdentity->getTokenService()->requestStatus(token); rStatus = mRsIdentity->getTokenService()->requestStatus(token);
} }
if(rStatus == RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE) if(rStatus == RsTokenService::COMPLETE)
{ {
std::vector<RsGxsIdGroup> grps; std::vector<RsGxsIdGroup> grps;
ok &= mRsIdentity->getGroupData(token, grps); ok &= mRsIdentity->getGroupData(token, grps);
@ -327,8 +327,8 @@ void IdentityHandler::handleOwnIdsRequest(Request & /*req*/, Response &resp)
mRsIdentity->getTokenService()->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts); mRsIdentity->getTokenService()->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts);
time_t start = time(NULL); time_t start = time(NULL);
while((mRsIdentity->getTokenService()->requestStatus(token) != RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE) while((mRsIdentity->getTokenService()->requestStatus(token) != RsTokenService::COMPLETE)
&&(mRsIdentity->getTokenService()->requestStatus(token) != RsTokenService::GXS_REQUEST_V2_STATUS_FAILED) &&(mRsIdentity->getTokenService()->requestStatus(token) != RsTokenService::FAILED)
&&((time(NULL) < (start+10))) &&((time(NULL) < (start+10)))
) )
{ {
@ -339,7 +339,7 @@ void IdentityHandler::handleOwnIdsRequest(Request & /*req*/, Response &resp)
#endif #endif
} }
if(mRsIdentity->getTokenService()->requestStatus(token) == RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE) if(mRsIdentity->getTokenService()->requestStatus(token) == RsTokenService::COMPLETE)
{ {
std::vector<RsGxsIdGroup> grps; std::vector<RsGxsIdGroup> grps;
ok &= mRsIdentity->getGroupData(token, grps); ok &= mRsIdentity->getGroupData(token, grps);
@ -410,8 +410,8 @@ void IdentityHandler::handleGetIdentityDetails(Request& req, Response& resp)
mRsIdentity->getTokenService()->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, groupIds); mRsIdentity->getTokenService()->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, groupIds);
time_t start = time(NULL); time_t start = time(NULL);
while((mRsIdentity->getTokenService()->requestStatus(token) != RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE) while((mRsIdentity->getTokenService()->requestStatus(token) != RsTokenService::COMPLETE)
&&(mRsIdentity->getTokenService()->requestStatus(token) != RsTokenService::GXS_REQUEST_V2_STATUS_FAILED) &&(mRsIdentity->getTokenService()->requestStatus(token) != RsTokenService::FAILED)
&&((time(NULL) < (start+10))) &&((time(NULL) < (start+10)))
) )
{ {
@ -545,8 +545,8 @@ void IdentityHandler::handleSetAvatar(Request& req, Response& resp)
mRsIdentity->getTokenService()->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, groupIds); mRsIdentity->getTokenService()->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, groupIds);
time_t start = time(NULL); time_t start = time(NULL);
while((mRsIdentity->getTokenService()->requestStatus(token) != RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE) while((mRsIdentity->getTokenService()->requestStatus(token) != RsTokenService::COMPLETE)
&&(mRsIdentity->getTokenService()->requestStatus(token) != RsTokenService::GXS_REQUEST_V2_STATUS_FAILED) &&(mRsIdentity->getTokenService()->requestStatus(token) != RsTokenService::FAILED)
&&((time(NULL) < (start+10))) &&((time(NULL) < (start+10)))
) )
{ {

View File

@ -59,7 +59,7 @@ void GxsTokenQueue::checkRequests()
uint32_t token = it->mToken; uint32_t token = it->mToken;
uint32_t status = mGenExchange->getTokenService()->requestStatus(token); uint32_t status = mGenExchange->getTokenService()->requestStatus(token);
if (status == RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE) if (status == RsTokenService::COMPLETE)
{ {
toload.push_back(*it); toload.push_back(*it);
it = mQueue.erase(it); it = mQueue.erase(it);
@ -71,7 +71,7 @@ void GxsTokenQueue::checkRequests()
#endif #endif
++it; ++it;
} }
else if (status == RsTokenService::GXS_REQUEST_V2_STATUS_FAILED) else if (status == RsTokenService::FAILED)
{ {
// maybe we should do alternative callback? // maybe we should do alternative callback?
std::cerr << "GxsTokenQueue::checkRequests() ERROR Request Failed: " << token; std::cerr << "GxsTokenQueue::checkRequests() ERROR Request Failed: " << token;

View File

@ -1987,7 +1987,7 @@ void RsGenExchange::processMsgMetaChanges()
if(ok) if(ok)
{ {
mDataAccess->updatePublicRequestStatus(token, RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE); mDataAccess->updatePublicRequestStatus(token, RsTokenService::COMPLETE);
if (changed) if (changed)
{ {
msgIds[m.msgId.first].insert(m.msgId.second); msgIds[m.msgId.first].insert(m.msgId.second);
@ -1995,7 +1995,7 @@ void RsGenExchange::processMsgMetaChanges()
} }
else else
{ {
mDataAccess->updatePublicRequestStatus(token, RsTokenService::GXS_REQUEST_V2_STATUS_FAILED); mDataAccess->updatePublicRequestStatus(token, RsTokenService::FAILED);
} }
{ {
@ -2041,11 +2041,11 @@ void RsGenExchange::processGrpMetaChanges()
if(ok) if(ok)
{ {
mDataAccess->updatePublicRequestStatus(token, RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE); mDataAccess->updatePublicRequestStatus(token, RsTokenService::COMPLETE);
grpChanged.push_back(g.grpId); grpChanged.push_back(g.grpId);
}else }else
{ {
mDataAccess->updatePublicRequestStatus(token, RsTokenService::GXS_REQUEST_V2_STATUS_FAILED); mDataAccess->updatePublicRequestStatus(token, RsTokenService::FAILED);
} }
{ {
@ -2278,7 +2278,7 @@ void RsGenExchange::publishMsgs()
// add to published to allow acknowledgement // add to published to allow acknowledgement
mMsgNotify.insert(std::make_pair(mit->first, std::make_pair(grpId, msgId))); mMsgNotify.insert(std::make_pair(mit->first, std::make_pair(grpId, msgId)));
mDataAccess->updatePublicRequestStatus(mit->first, RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE); mDataAccess->updatePublicRequestStatus(mit->first, RsTokenService::COMPLETE);
} }
else else
@ -2288,7 +2288,7 @@ void RsGenExchange::publishMsgs()
if(!tryLater) if(!tryLater)
mDataAccess->updatePublicRequestStatus(mit->first, mDataAccess->updatePublicRequestStatus(mit->first,
RsTokenService::GXS_REQUEST_V2_STATUS_FAILED); RsTokenService::FAILED);
std::cerr << "RsGenExchange::publishMsgs() failed to publish msg " << std::endl; std::cerr << "RsGenExchange::publishMsgs() failed to publish msg " << std::endl;
} }
@ -2365,7 +2365,7 @@ void RsGenExchange::processGroupUpdatePublish()
if(mit == grpMeta.end() || mit->second == NULL) if(mit == grpMeta.end() || mit->second == NULL)
{ {
std::cerr << "Error! could not find meta of old group to update!" << std::endl; std::cerr << "Error! could not find meta of old group to update!" << std::endl;
mDataAccess->updatePublicRequestStatus(gup.mToken, RsTokenService::GXS_REQUEST_V2_STATUS_FAILED); mDataAccess->updatePublicRequestStatus(gup.mToken, RsTokenService::FAILED);
delete gup.grpItem; delete gup.grpItem;
continue; continue;
} }
@ -2393,7 +2393,7 @@ void RsGenExchange::processGroupUpdatePublish()
std::cerr << "(EE) publish group fails because RS cannot find the private publish and author keys" << std::endl; std::cerr << "(EE) publish group fails because RS cannot find the private publish and author keys" << std::endl;
delete gup.grpItem; delete gup.grpItem;
mDataAccess->updatePublicRequestStatus(gup.mToken, RsTokenService::GXS_REQUEST_V2_STATUS_FAILED); mDataAccess->updatePublicRequestStatus(gup.mToken, RsTokenService::FAILED);
} }
} }
@ -2435,8 +2435,8 @@ void RsGenExchange::processGroupDelete()
for(; mit != toNotify.end(); ++mit) for(; mit != toNotify.end(); ++mit)
{ {
GrpNote& note = mit->second; GrpNote& note = mit->second;
uint8_t status = note.first ? RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE uint8_t status = note.first ? RsTokenService::COMPLETE
: RsTokenService::GXS_REQUEST_V2_STATUS_FAILED; : RsTokenService::FAILED;
mGrpNotify.insert(std::make_pair(mit->first, note.second)); mGrpNotify.insert(std::make_pair(mit->first, note.second));
mDataAccess->updatePublicRequestStatus(mit->first, status); mDataAccess->updatePublicRequestStatus(mit->first, status);
@ -2744,8 +2744,8 @@ void RsGenExchange::publishGrps()
for(; mit != toNotify.end(); ++mit) for(; mit != toNotify.end(); ++mit)
{ {
GrpNote& note = mit->second; GrpNote& note = mit->second;
uint8_t status = note.first ? RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE uint8_t status = note.first ? RsTokenService::COMPLETE
: RsTokenService::GXS_REQUEST_V2_STATUS_FAILED; : RsTokenService::FAILED;
mGrpNotify.insert(std::make_pair(mit->first, note.second)); mGrpNotify.insert(std::make_pair(mit->first, note.second));
mDataAccess->updatePublicRequestStatus(mit->first, status); mDataAccess->updatePublicRequestStatus(mit->first, status);

View File

@ -29,14 +29,6 @@
#include "rsgxsdataaccess.h" #include "rsgxsdataaccess.h"
#include "retroshare/rsgxsflags.h" #include "retroshare/rsgxsflags.h"
// TODO CLEANUP: This should be an enum defined in rstokenservice.h
const uint8_t RsTokenService::GXS_REQUEST_V2_STATUS_FAILED = 0;
const uint8_t RsTokenService::GXS_REQUEST_V2_STATUS_PENDING = 1;
const uint8_t RsTokenService::GXS_REQUEST_V2_STATUS_PARTIAL = 2;
const uint8_t RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE = 4;
const uint8_t RsTokenService::GXS_REQUEST_V2_STATUS_DONE = 5; // ONCE ALL DATA RETRIEVED.
const uint8_t RsTokenService::GXS_REQUEST_V2_STATUS_CANCELLED = 6;
/*********** /***********
* #define DATA_DEBUG 1 * #define DATA_DEBUG 1
**********/ **********/
@ -316,7 +308,7 @@ void RsGxsDataAccess::storeRequest(GxsRequest* req)
{ {
RsStackMutex stack(mDataMutex); /****** LOCKED *****/ RsStackMutex stack(mDataMutex); /****** LOCKED *****/
req->status = GXS_REQUEST_V2_STATUS_PENDING; req->status = PENDING;
req->reqTime = time(NULL); req->reqTime = time(NULL);
mRequests[req->token] = req; mRequests[req->token] = req;
@ -339,7 +331,7 @@ uint32_t RsGxsDataAccess::requestStatus(uint32_t token)
} }
if (!checkRequestStatus(token, status, reqtype, anstype, ts)) if (!checkRequestStatus(token, status, reqtype, anstype, ts))
return RsTokenService::GXS_REQUEST_V2_STATUS_FAILED; return RsTokenService::FAILED;
return status; return status;
} }
@ -354,7 +346,7 @@ bool RsGxsDataAccess::cancelRequest(const uint32_t& token)
return false; return false;
} }
req->status = GXS_REQUEST_V2_STATUS_CANCELLED; req->status = CANCELLED;
return true; return true;
} }
@ -390,7 +382,7 @@ bool RsGxsDataAccess::getGroupSummary(const uint32_t& token, std::list<const RsG
<< "group summary" << std::endl; << "group summary" << std::endl;
return false; return false;
} }
else if(req->status == GXS_REQUEST_V2_STATUS_COMPLETE) else if(req->status == COMPLETE)
{ {
GroupMetaReq* gmreq = dynamic_cast<GroupMetaReq*>(req); GroupMetaReq* gmreq = dynamic_cast<GroupMetaReq*>(req);
@ -398,7 +390,7 @@ bool RsGxsDataAccess::getGroupSummary(const uint32_t& token, std::list<const RsG
{ {
groupInfo = gmreq->mGroupMetaData; groupInfo = gmreq->mGroupMetaData;
gmreq->mGroupMetaData.clear(); gmreq->mGroupMetaData.clear();
locked_updateRequestStatus(token, GXS_REQUEST_V2_STATUS_DONE); locked_updateRequestStatus(token, DONE);
} }
else else
{ {
@ -429,7 +421,7 @@ bool RsGxsDataAccess::getGroupData(const uint32_t& token, std::list<RsNxsGrp*>&
<< "data" << std::endl; << "data" << std::endl;
return false; return false;
} }
else if(req->status == GXS_REQUEST_V2_STATUS_COMPLETE) else if(req->status == COMPLETE)
{ {
GroupDataReq* gmreq = dynamic_cast<GroupDataReq*>(req); GroupDataReq* gmreq = dynamic_cast<GroupDataReq*>(req);
GroupSerializedDataReq* gsreq = dynamic_cast<GroupSerializedDataReq*>(req); GroupSerializedDataReq* gsreq = dynamic_cast<GroupSerializedDataReq*>(req);
@ -439,13 +431,13 @@ bool RsGxsDataAccess::getGroupData(const uint32_t& token, std::list<RsNxsGrp*>&
grpData.swap(gsreq->mGroupData); grpData.swap(gsreq->mGroupData);
gsreq->mGroupData.clear(); gsreq->mGroupData.clear();
locked_updateRequestStatus(token, GXS_REQUEST_V2_STATUS_DONE); locked_updateRequestStatus(token, DONE);
} }
else if(gmreq) else if(gmreq)
{ {
grpData.swap(gmreq->mGroupData); grpData.swap(gmreq->mGroupData);
gmreq->mGroupData.clear(); gmreq->mGroupData.clear();
locked_updateRequestStatus(token, GXS_REQUEST_V2_STATUS_DONE); locked_updateRequestStatus(token, DONE);
} }
else else
{ {
@ -474,7 +466,7 @@ bool RsGxsDataAccess::getMsgData(const uint32_t& token, NxsMsgDataResult& msgDat
std::cerr << "RsGxsDataAccess::getMsgData() Unable to retrieve group data" << std::endl; std::cerr << "RsGxsDataAccess::getMsgData() Unable to retrieve group data" << std::endl;
return false; return false;
}else if(req->status == GXS_REQUEST_V2_STATUS_COMPLETE){ }else if(req->status == COMPLETE){
MsgDataReq* mdreq = dynamic_cast<MsgDataReq*>(req); MsgDataReq* mdreq = dynamic_cast<MsgDataReq*>(req);
@ -482,7 +474,7 @@ bool RsGxsDataAccess::getMsgData(const uint32_t& token, NxsMsgDataResult& msgDat
{ {
msgData.swap(mdreq->mMsgData); msgData.swap(mdreq->mMsgData);
mdreq->mMsgData.clear(); mdreq->mMsgData.clear();
locked_updateRequestStatus(token, GXS_REQUEST_V2_STATUS_DONE); locked_updateRequestStatus(token, DONE);
} }
else else
{ {
@ -508,7 +500,7 @@ bool RsGxsDataAccess::getMsgRelatedData(const uint32_t &token, NxsMsgRelatedData
std::cerr << "RsGxsDataAccess::getMsgRelatedData() Unable to retrieve group data" << std::endl; std::cerr << "RsGxsDataAccess::getMsgRelatedData() Unable to retrieve group data" << std::endl;
return false; return false;
}else if(req->status == GXS_REQUEST_V2_STATUS_COMPLETE){ }else if(req->status == COMPLETE){
MsgRelatedInfoReq* mrireq = dynamic_cast<MsgRelatedInfoReq*>(req); MsgRelatedInfoReq* mrireq = dynamic_cast<MsgRelatedInfoReq*>(req);
@ -519,7 +511,7 @@ bool RsGxsDataAccess::getMsgRelatedData(const uint32_t &token, NxsMsgRelatedData
{ {
msgData.swap(mrireq->mMsgDataResult); msgData.swap(mrireq->mMsgDataResult);
mrireq->mMsgDataResult.clear(); mrireq->mMsgDataResult.clear();
locked_updateRequestStatus(token, GXS_REQUEST_V2_STATUS_DONE); locked_updateRequestStatus(token, DONE);
} }
else else
{ {
@ -545,7 +537,7 @@ bool RsGxsDataAccess::getMsgSummary(const uint32_t& token, GxsMsgMetaResult& msg
std::cerr << "RsGxsDataAccess::getMsgSummary() Unable to retrieve group data" << std::endl; std::cerr << "RsGxsDataAccess::getMsgSummary() Unable to retrieve group data" << std::endl;
return false; return false;
}else if(req->status == GXS_REQUEST_V2_STATUS_COMPLETE){ }else if(req->status == COMPLETE){
MsgMetaReq* mmreq = dynamic_cast<MsgMetaReq*>(req); MsgMetaReq* mmreq = dynamic_cast<MsgMetaReq*>(req);
@ -553,7 +545,7 @@ bool RsGxsDataAccess::getMsgSummary(const uint32_t& token, GxsMsgMetaResult& msg
{ {
msgInfo.swap(mmreq->mMsgMetaData); msgInfo.swap(mmreq->mMsgMetaData);
mmreq->mMsgMetaData.clear(); mmreq->mMsgMetaData.clear();
locked_updateRequestStatus(token, GXS_REQUEST_V2_STATUS_DONE); locked_updateRequestStatus(token, DONE);
} }
else else
@ -582,7 +574,7 @@ bool RsGxsDataAccess::getMsgRelatedSummary(const uint32_t &token, MsgRelatedMeta
std::cerr << "RsGxsDataAccess::getMsgRelatedSummary() Unable to retrieve message summary" << std::endl; std::cerr << "RsGxsDataAccess::getMsgRelatedSummary() Unable to retrieve message summary" << std::endl;
return false; return false;
}else if(req->status == GXS_REQUEST_V2_STATUS_COMPLETE){ }else if(req->status == COMPLETE){
if(req->Options.mReqType != GXS_REQUEST_TYPE_MSG_RELATED_META) if(req->Options.mReqType != GXS_REQUEST_TYPE_MSG_RELATED_META)
return false; return false;
@ -593,7 +585,7 @@ bool RsGxsDataAccess::getMsgRelatedSummary(const uint32_t &token, MsgRelatedMeta
{ {
msgMeta.swap(mrireq->mMsgMetaResult); msgMeta.swap(mrireq->mMsgMetaResult);
mrireq->mMsgMetaResult.clear(); mrireq->mMsgMetaResult.clear();
locked_updateRequestStatus(token, GXS_REQUEST_V2_STATUS_DONE); locked_updateRequestStatus(token, DONE);
} }
else else
{ {
@ -621,7 +613,7 @@ bool RsGxsDataAccess::getMsgRelatedList(const uint32_t &token, MsgRelatedIdResul
std::cerr << "RsGxsDataAccess::getMsgRelatedList() Unable to retrieve message data" << std::endl; std::cerr << "RsGxsDataAccess::getMsgRelatedList() Unable to retrieve message data" << std::endl;
return false; return false;
}else if(req->status == GXS_REQUEST_V2_STATUS_COMPLETE){ }else if(req->status == COMPLETE){
if(req->Options.mReqType != GXS_REQUEST_TYPE_MSG_RELATED_IDS) if(req->Options.mReqType != GXS_REQUEST_TYPE_MSG_RELATED_IDS)
return false; return false;
@ -632,7 +624,7 @@ bool RsGxsDataAccess::getMsgRelatedList(const uint32_t &token, MsgRelatedIdResul
{ {
msgIds.swap(mrireq->mMsgIdResult); msgIds.swap(mrireq->mMsgIdResult);
mrireq->mMsgIdResult.clear(); mrireq->mMsgIdResult.clear();
locked_updateRequestStatus(token, GXS_REQUEST_V2_STATUS_DONE); locked_updateRequestStatus(token, DONE);
} }
else{ else{
std::cerr << "RsGxsDataAccess::getMsgRelatedList() Req found, failed caste" << std::endl; std::cerr << "RsGxsDataAccess::getMsgRelatedList() Req found, failed caste" << std::endl;
@ -658,7 +650,7 @@ bool RsGxsDataAccess::getMsgList(const uint32_t& token, GxsMsgIdResult& msgIds)
std::cerr << "RsGxsDataAccess::getMsgList() Unable to retrieve msg Ids" << std::endl; std::cerr << "RsGxsDataAccess::getMsgList() Unable to retrieve msg Ids" << std::endl;
return false; return false;
}else if(req->status == GXS_REQUEST_V2_STATUS_COMPLETE){ }else if(req->status == COMPLETE){
MsgIdReq* mireq = dynamic_cast<MsgIdReq*>(req); MsgIdReq* mireq = dynamic_cast<MsgIdReq*>(req);
@ -666,7 +658,7 @@ bool RsGxsDataAccess::getMsgList(const uint32_t& token, GxsMsgIdResult& msgIds)
{ {
msgIds.swap(mireq->mMsgIdResult); msgIds.swap(mireq->mMsgIdResult);
mireq->mMsgIdResult.clear(); mireq->mMsgIdResult.clear();
locked_updateRequestStatus(token, GXS_REQUEST_V2_STATUS_DONE); locked_updateRequestStatus(token, DONE);
} }
else{ else{
std::cerr << "RsGxsDataAccess::getMsgList() Req found, failed caste" << std::endl; std::cerr << "RsGxsDataAccess::getMsgList() Req found, failed caste" << std::endl;
@ -691,7 +683,7 @@ bool RsGxsDataAccess::getGroupList(const uint32_t& token, std::list<RsGxsGroupId
std::cerr << "RsGxsDataAccess::getGroupList() Unable to retrieve group Ids," std::cerr << "RsGxsDataAccess::getGroupList() Unable to retrieve group Ids,"
"\nRequest does not exist" << std::endl; "\nRequest does not exist" << std::endl;
return false; return false;
}else if(req->status == GXS_REQUEST_V2_STATUS_COMPLETE){ }else if(req->status == COMPLETE){
GroupIdReq* gireq = dynamic_cast<GroupIdReq*>(req); GroupIdReq* gireq = dynamic_cast<GroupIdReq*>(req);
@ -699,7 +691,7 @@ bool RsGxsDataAccess::getGroupList(const uint32_t& token, std::list<RsGxsGroupId
{ {
groupIds.swap(gireq->mGroupIdResult); groupIds.swap(gireq->mGroupIdResult);
gireq->mGroupIdResult.clear(); gireq->mGroupIdResult.clear();
locked_updateRequestStatus(token, GXS_REQUEST_V2_STATUS_DONE); locked_updateRequestStatus(token, DONE);
}else{ }else{
std::cerr << "RsGxsDataAccess::getGroupList() Req found, failed caste" << std::endl; std::cerr << "RsGxsDataAccess::getGroupList() Req found, failed caste" << std::endl;
@ -741,21 +733,21 @@ void RsGxsDataAccess::processRequests()
switch (req->status) switch (req->status)
{ {
case GXS_REQUEST_V2_STATUS_PENDING: case PENDING:
// process request later // process request later
break; break;
case GXS_REQUEST_V2_STATUS_PARTIAL: case PARTIAL:
// should not happen // should not happen
req->status = GXS_REQUEST_V2_STATUS_COMPLETE; req->status = COMPLETE;
break; break;
case GXS_REQUEST_V2_STATUS_DONE: case DONE:
#ifdef DATA_DEBUG #ifdef DATA_DEBUG
std::cerr << "RsGxsDataAccess::processrequests() Clearing Done Request Token: " << req->token; std::cerr << "RsGxsDataAccess::processrequests() Clearing Done Request Token: " << req->token;
std::cerr << std::endl; std::cerr << std::endl;
#endif #endif
toClear.push_back(req->token); toClear.push_back(req->token);
break; break;
case GXS_REQUEST_V2_STATUS_CANCELLED: case CANCELLED:
#ifdef DATA_DEBUG #ifdef DATA_DEBUG
std::cerr << "RsGxsDataAccess::processrequests() Clearing Cancelled Request Token: " << req->token; std::cerr << "RsGxsDataAccess::processrequests() Clearing Cancelled Request Token: " << req->token;
std::cerr << std::endl; std::cerr << std::endl;
@ -793,10 +785,10 @@ void RsGxsDataAccess::processRequests()
for (it = mRequests.begin(); it != mRequests.end(); ++it) for (it = mRequests.begin(); it != mRequests.end(); ++it)
{ {
GxsRequest* reqCheck = it->second; GxsRequest* reqCheck = it->second;
if (reqCheck->status == GXS_REQUEST_V2_STATUS_PENDING) if (reqCheck->status == PENDING)
{ {
req = reqCheck; req = reqCheck;
req->status = GXS_REQUEST_V2_STATUS_PARTIAL; req->status = PARTIAL;
break; break;
} }
} }
@ -876,9 +868,9 @@ void RsGxsDataAccess::processRequests()
{ {
RsStackMutex stack(mDataMutex); /******* LOCKED *******/ RsStackMutex stack(mDataMutex); /******* LOCKED *******/
if (req->status == GXS_REQUEST_V2_STATUS_PARTIAL) if (req->status == PARTIAL)
{ {
req->status = ok ? GXS_REQUEST_V2_STATUS_COMPLETE : GXS_REQUEST_V2_STATUS_FAILED; req->status = ok ? COMPLETE : FAILED;
} }
} // END OF MUTEX. } // END OF MUTEX.
} }
@ -894,14 +886,14 @@ bool RsGxsDataAccess::getGroupStatistic(const uint32_t &token, GxsGroupStatistic
std::cerr << "RsGxsDataAccess::getGroupStatistic() Unable to retrieve grp stats" << std::endl; std::cerr << "RsGxsDataAccess::getGroupStatistic() Unable to retrieve grp stats" << std::endl;
return false; return false;
}else if(req->status == GXS_REQUEST_V2_STATUS_COMPLETE){ }else if(req->status == COMPLETE){
GroupStatisticRequest* gsreq = dynamic_cast<GroupStatisticRequest*>(req); GroupStatisticRequest* gsreq = dynamic_cast<GroupStatisticRequest*>(req);
if(gsreq) if(gsreq)
{ {
grpStatistic = gsreq->mGroupStatistic; grpStatistic = gsreq->mGroupStatistic;
locked_updateRequestStatus(token, GXS_REQUEST_V2_STATUS_DONE); locked_updateRequestStatus(token, DONE);
} }
else{ else{
std::cerr << "RsGxsDataAccess::getGroupStatistic() Req found, failed caste" << std::endl; std::cerr << "RsGxsDataAccess::getGroupStatistic() Req found, failed caste" << std::endl;
@ -925,14 +917,14 @@ bool RsGxsDataAccess::getServiceStatistic(const uint32_t &token, GxsServiceStati
std::cerr << "RsGxsDataAccess::getServiceStatistic() Unable to retrieve service stats" << std::endl; std::cerr << "RsGxsDataAccess::getServiceStatistic() Unable to retrieve service stats" << std::endl;
return false; return false;
}else if(req->status == GXS_REQUEST_V2_STATUS_COMPLETE){ }else if(req->status == COMPLETE){
ServiceStatisticRequest* ssreq = dynamic_cast<ServiceStatisticRequest*>(req); ServiceStatisticRequest* ssreq = dynamic_cast<ServiceStatisticRequest*>(req);
if(ssreq) if(ssreq)
{ {
servStatistic = ssreq->mServiceStatistic; servStatistic = ssreq->mServiceStatistic;
locked_updateRequestStatus(token, GXS_REQUEST_V2_STATUS_DONE); locked_updateRequestStatus(token, DONE);
} }
else{ else{
std::cerr << "RsGxsDataAccess::getServiceStatistic() Req found, failed caste" << std::endl; std::cerr << "RsGxsDataAccess::getServiceStatistic() Req found, failed caste" << std::endl;
@ -1777,7 +1769,7 @@ bool RsGxsDataAccess::checkRequestStatus(const uint32_t& token,
GxsRequest* req = locked_retrieveRequest(token); GxsRequest* req = locked_retrieveRequest(token);
if (req == NULL || req->status == GXS_REQUEST_V2_STATUS_CANCELLED) if (req == NULL || req->status == CANCELLED)
return false; return false;
anstype = req->ansType; anstype = req->ansType;
@ -1852,7 +1844,7 @@ uint32_t RsGxsDataAccess::generatePublicToken()
{ {
RsStackMutex stack(mDataMutex); RsStackMutex stack(mDataMutex);
mPublicToken[token] = RsTokenService::GXS_REQUEST_V2_STATUS_PENDING; mPublicToken[token] = RsTokenService::PENDING;
} }
return token; return token;

View File

@ -123,18 +123,19 @@ class RsTokenService
public: public:
// TODO CLEANUP: This should be an enum enum GxsRequestStatus : uint8_t
static const uint8_t GXS_REQUEST_V2_STATUS_FAILED; {
static const uint8_t GXS_REQUEST_V2_STATUS_PENDING; FAILED,
static const uint8_t GXS_REQUEST_V2_STATUS_PARTIAL; PENDING,
static const uint8_t GXS_REQUEST_V2_STATUS_COMPLETE; PARTIAL,
static const uint8_t GXS_REQUEST_V2_STATUS_DONE; // ONCE ALL DATA RETRIEVED. COMPLETE,
static const uint8_t GXS_REQUEST_V2_STATUS_CANCELLED; DONE, /// Once all data has been retrived
CANCELLED
};
public:
RsTokenService() { return; } RsTokenService() {}
virtual ~RsTokenService() { return; } virtual ~RsTokenService() {}
/* Data Requests */ /* Data Requests */

View File

@ -1315,14 +1315,14 @@ void p3GxsChannels::dummy_tick()
#endif #endif
uint32_t status = RsGenExchange::getTokenService()->requestStatus(mGenToken); uint32_t status = RsGenExchange::getTokenService()->requestStatus(mGenToken);
if (status != RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE) if (status != RsTokenService::COMPLETE)
{ {
#ifdef GXSCHANNELS_DEBUG #ifdef GXSCHANNELS_DEBUG
std::cerr << "p3GxsChannels::dummy_tick() Status: " << status; std::cerr << "p3GxsChannels::dummy_tick() Status: " << status;
std::cerr << std::endl; std::cerr << std::endl;
#endif #endif
if (status == RsTokenService::GXS_REQUEST_V2_STATUS_FAILED) if (status == RsTokenService::FAILED)
{ {
#ifdef GXSCHANNELS_DEBUG #ifdef GXSCHANNELS_DEBUG
std::cerr << "p3GxsChannels::dummy_tick() generateDummyMsgs() FAILED"; std::cerr << "p3GxsChannels::dummy_tick() generateDummyMsgs() FAILED";

View File

@ -1656,8 +1656,8 @@ void p3GxsCircles::checkDummyIdData()
// check the token. // check the token.
uint32_t status = rsIdentity->getTokenService()->requestStatus(mDummyIdToken); uint32_t status = rsIdentity->getTokenService()->requestStatus(mDummyIdToken);
if ( (RsTokenService::GXS_REQUEST_V2_STATUS_FAILED == status) || if ( (RsTokenService::FAILED == status) ||
(RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE == status) ) (RsTokenService::COMPLETE == status) )
{ {
std::vector<RsGxsIdGroup> ids; std::vector<RsGxsIdGroup> ids;
if (!rsIdentity->getGroupData(mDummyIdToken, ids)) if (!rsIdentity->getGroupData(mDummyIdToken, ids))

View File

@ -572,7 +572,7 @@ void p3GxsCommentService::load_PendingVoteParent(const uint32_t &token)
std::cerr << std::endl; std::cerr << std::endl;
pit->second.mStatus = VoteHolder::VOTE_ERROR; pit->second.mStatus = VoteHolder::VOTE_ERROR;
uint32_t status = RsTokenService::GXS_REQUEST_V2_STATUS_FAILED; uint32_t status = RsTokenService::FAILED;
mExchange->updatePublicRequestStatus(pit->second.mReqToken, status); mExchange->updatePublicRequestStatus(pit->second.mReqToken, status);
continue; continue;
} }

View File

@ -489,12 +489,12 @@ void p3GxsForums::dummy_tick()
std::cerr << std::endl; std::cerr << std::endl;
uint32_t status = RsGenExchange::getTokenService()->requestStatus(mGenToken); uint32_t status = RsGenExchange::getTokenService()->requestStatus(mGenToken);
if (status != RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE) if (status != RsTokenService::COMPLETE)
{ {
std::cerr << "p3GxsForums::dummy_tick() Status: " << status; std::cerr << "p3GxsForums::dummy_tick() Status: " << status;
std::cerr << std::endl; std::cerr << std::endl;
if (status == RsTokenService::GXS_REQUEST_V2_STATUS_FAILED) if (status == RsTokenService::FAILED)
{ {
std::cerr << "p3GxsForums::dummy_tick() generateDummyMsgs() FAILED"; std::cerr << "p3GxsForums::dummy_tick() generateDummyMsgs() FAILED";
std::cerr << std::endl; std::cerr << std::endl;

View File

@ -1536,7 +1536,7 @@ bool p3IdService::opinion_handlerequest(uint32_t token)
std::cerr << "p3IdService::opinion_handlerequest() ERROR getGroupMeta()"; std::cerr << "p3IdService::opinion_handlerequest() ERROR getGroupMeta()";
std::cerr << std::endl; std::cerr << std::endl;
updatePublicRequestStatus(req.mToken, RsTokenService::GXS_REQUEST_V2_STATUS_FAILED); updatePublicRequestStatus(req.mToken, RsTokenService::FAILED);
return false; return false;
} }
@ -1546,7 +1546,7 @@ bool p3IdService::opinion_handlerequest(uint32_t token)
std::cerr << std::endl; std::cerr << std::endl;
// error. // error.
updatePublicRequestStatus(req.mToken, RsTokenService::GXS_REQUEST_V2_STATUS_FAILED); updatePublicRequestStatus(req.mToken, RsTokenService::FAILED);
return false; return false;
} }
RsGroupMetaData &meta = *(groups.begin()); RsGroupMetaData &meta = *(groups.begin());
@ -1557,7 +1557,7 @@ bool p3IdService::opinion_handlerequest(uint32_t token)
std::cerr << std::endl; std::cerr << std::endl;
// error. // error.
updatePublicRequestStatus(req.mToken, RsTokenService::GXS_REQUEST_V2_STATUS_FAILED); updatePublicRequestStatus(req.mToken, RsTokenService::FAILED);
return false; return false;
} }
@ -1592,7 +1592,7 @@ bool p3IdService::opinion_handlerequest(uint32_t token)
setGroupServiceString(dummyToken, meta.mGroupId, serviceString); setGroupServiceString(dummyToken, meta.mGroupId, serviceString);
cache_update_if_cached(RsGxsId(meta.mGroupId), serviceString); cache_update_if_cached(RsGxsId(meta.mGroupId), serviceString);
updatePublicRequestStatus(req.mToken, RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE); updatePublicRequestStatus(req.mToken, RsTokenService::COMPLETE);
return true; return true;
} }

View File

@ -538,7 +538,7 @@ void p3Wiki::dummyTick()
uint32_t status = RsGenExchange::getTokenService()->requestStatus(mAboutToken); uint32_t status = RsGenExchange::getTokenService()->requestStatus(mAboutToken);
if (status == RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE) if (status == RsTokenService::COMPLETE)
{ {
std::cerr << "p3Wiki::dummyTick() AboutActive, Lines: " << mAboutLines; std::cerr << "p3Wiki::dummyTick() AboutActive, Lines: " << mAboutLines;
std::cerr << std::endl; std::cerr << std::endl;
@ -605,7 +605,7 @@ void p3Wiki::dummyTick()
uint32_t status = RsGenExchange::getTokenService()->requestStatus(mImprovToken); uint32_t status = RsGenExchange::getTokenService()->requestStatus(mImprovToken);
if (status == RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE) if (status == RsTokenService::COMPLETE)
{ {
std::cerr << "p3Wiki::dummyTick() ImprovActive, Lines: " << mImprovLines; std::cerr << "p3Wiki::dummyTick() ImprovActive, Lines: " << mImprovLines;
std::cerr << std::endl; std::cerr << std::endl;
@ -673,7 +673,7 @@ void p3Wiki::dummyTick()
uint32_t status = RsGenExchange::getTokenService()->requestStatus(mMarkdownToken); uint32_t status = RsGenExchange::getTokenService()->requestStatus(mMarkdownToken);
if (status == RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE) if (status == RsTokenService::COMPLETE)
{ {
std::cerr << "p3Wiki::dummyTick() MarkdownActive, Lines: " << mMarkdownLines; std::cerr << "p3Wiki::dummyTick() MarkdownActive, Lines: " << mMarkdownLines;
std::cerr << std::endl; std::cerr << std::endl;

View File

@ -2229,11 +2229,11 @@ bool p3FeedReader::waitForToken(uint32_t token)
while (!mStopped) { while (!mStopped) {
uint32_t status = service->requestStatus(token); uint32_t status = service->requestStatus(token);
if (status == RsTokenService::GXS_REQUEST_V2_STATUS_FAILED) { if (status == RsTokenService::FAILED) {
break; break;
} }
if (status == RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE) { if (status == RsTokenService::COMPLETE) {
return true; return true;
} }

View File

@ -112,11 +112,11 @@ void GxsForumsFillThread::run()
service->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, grpIds); service->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, grpIds);
/* wait for the answer */ /* wait for the answer */
uint32_t requestStatus = RsTokenService::GXS_REQUEST_V2_STATUS_PENDING; uint32_t requestStatus = RsTokenService::PENDING;
while (!wasStopped()) { while (!wasStopped()) {
requestStatus = service->requestStatus(token); requestStatus = service->requestStatus(token);
if (requestStatus == RsTokenService::GXS_REQUEST_V2_STATUS_FAILED || if (requestStatus == RsTokenService::FAILED ||
requestStatus == RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE) { requestStatus == RsTokenService::COMPLETE) {
break; break;
} }
msleep(100); msleep(100);
@ -132,7 +132,7 @@ void GxsForumsFillThread::run()
return; return;
} }
if (requestStatus == RsTokenService::GXS_REQUEST_V2_STATUS_FAILED) { if (requestStatus == RsTokenService::FAILED) {
//#TODO //#TODO
return; return;
} }

View File

@ -164,8 +164,8 @@ bool TokenQueue::checkForRequest(uint32_t token)
{ {
/* check token */ /* check token */
uint32_t status = mService->requestStatus(token); uint32_t status = mService->requestStatus(token);
return ( (RsTokenService::GXS_REQUEST_V2_STATUS_FAILED == status) || return ( (RsTokenService::FAILED == status) ||
(RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE == status) ); (RsTokenService::COMPLETE == status) );
} }
bool TokenQueue::activeRequestExist(const uint32_t& userType) const bool TokenQueue::activeRequestExist(const uint32_t& userType) const

View File

@ -42,7 +42,7 @@ void GenExchangeTest::pollForToken(uint32_t token, const RsTokReqOptions &opts,
Sleep((int) (timeDelta * 1000)); Sleep((int) (timeDelta * 1000));
#endif #endif
if((RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE == mTokenService->requestStatus(token))) if((RsTokenService::COMPLETE == mTokenService->requestStatus(token)))
{ {
switch(opts.mReqType) switch(opts.mReqType)
{ {
@ -81,7 +81,7 @@ void GenExchangeTest::pollForToken(uint32_t token, const RsTokReqOptions &opts,
} }
break; break;
} }
else if(RsTokenService::GXS_REQUEST_V2_STATUS_FAILED == mTokenService->requestStatus(token)) else if(RsTokenService::FAILED == mTokenService->requestStatus(token))
{ {
mTokenService->cancelRequest(token); mTokenService->cancelRequest(token);
break; break;
@ -108,12 +108,12 @@ bool GenExchangeTest::pollForMsgAcknowledgement(uint32_t token,
Sleep((int) (timeDelta * 1000)); Sleep((int) (timeDelta * 1000));
#endif #endif
if((RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE == mTokenService->requestStatus(token))) if((RsTokenService::COMPLETE == mTokenService->requestStatus(token)))
{ {
mTestService->acknowledgeTokenMsg(token, msgId); mTestService->acknowledgeTokenMsg(token, msgId);
return true; return true;
} }
else if(RsTokenService::GXS_REQUEST_V2_STATUS_FAILED == mTokenService->requestStatus(token)) else if(RsTokenService::FAILED == mTokenService->requestStatus(token))
{ {
mTokenService->cancelRequest(token); mTokenService->cancelRequest(token);
return false; return false;
@ -146,12 +146,12 @@ bool GenExchangeTest::pollForGrpAcknowledgement(uint32_t token,
Sleep((int) (timeDelta * 1000)); Sleep((int) (timeDelta * 1000));
#endif #endif
if((RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE == mTokenService->requestStatus(token))) if((RsTokenService::COMPLETE == mTokenService->requestStatus(token)))
{ {
mTestService->acknowledgeTokenGrp(token, grpId); mTestService->acknowledgeTokenGrp(token, grpId);
return true; return true;
} }
else if(RsTokenService::GXS_REQUEST_V2_STATUS_FAILED == mTokenService->requestStatus(token)) else if(RsTokenService::FAILED == mTokenService->requestStatus(token))
{ {
mTokenService->cancelRequest(token); mTokenService->cancelRequest(token);
return false; return false;

View File

@ -242,7 +242,7 @@ bool GxsPeerNode::createIdentity(const std::string &name,
return false; return false;
} }
while(tokenService->requestStatus(token) != RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE) while(tokenService->requestStatus(token) != RsTokenService::COMPLETE)
{ {
tick(); tick();
sleep(1); sleep(1);
@ -316,7 +316,7 @@ bool GxsPeerNode::createCircle(const std::string &name,
uint32_t token; uint32_t token;
mGxsCircles->createGroup(token, grp1) ; mGxsCircles->createGroup(token, grp1) ;
while(tokenService->requestStatus(token) != RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE) while(tokenService->requestStatus(token) != RsTokenService::COMPLETE)
{ {
tick(); tick();
sleep(1); sleep(1);
@ -371,7 +371,7 @@ bool GxsPeerNode::createGroup(const std::string &name,
return false; return false;
} }
while(tokenService->requestStatus(token) != RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE) while(tokenService->requestStatus(token) != RsTokenService::COMPLETE)
{ {
tick(); tick();
sleep(1); sleep(1);
@ -402,7 +402,7 @@ bool GxsPeerNode::createMsg(const std::string &msgstr,
return false; return false;
} }
while(tokenService->requestStatus(token) != RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE) while(tokenService->requestStatus(token) != RsTokenService::COMPLETE)
{ {
tick(); tick();
sleep(1); sleep(1);
@ -430,7 +430,7 @@ bool GxsPeerNode::subscribeToGroup(const RsGxsGroupId &groupId, bool subscribe)
return false; return false;
} }
while(tokenService->requestStatus(token) != RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE) while(tokenService->requestStatus(token) != RsTokenService::COMPLETE)
{ {
tick(); tick();
sleep(1); sleep(1);
@ -453,7 +453,7 @@ bool GxsPeerNode::getGroups(std::vector<RsTestGroup> &groups)
uint32_t token; uint32_t token;
tokenService->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts); tokenService->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts);
while(tokenService->requestStatus(token) != RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE) while(tokenService->requestStatus(token) != RsTokenService::COMPLETE)
{ {
tick(); tick();
sleep(1); sleep(1);
@ -475,7 +475,7 @@ bool GxsPeerNode::getGroupList(std::list<RsGxsGroupId> &groups)
uint32_t token; uint32_t token;
tokenService->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_LIST, opts); tokenService->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_LIST, opts);
while(tokenService->requestStatus(token) != RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE) while(tokenService->requestStatus(token) != RsTokenService::COMPLETE)
{ {
tick(); tick();
sleep(1); sleep(1);
@ -500,7 +500,7 @@ bool GxsPeerNode::getMsgList(const RsGxsGroupId &id, std::list<RsGxsMessageId> &
grpIds.push_back(id); grpIds.push_back(id);
tokenService->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_LIST, opts, grpIds); tokenService->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_LIST, opts, grpIds);
while(tokenService->requestStatus(token) != RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE) while(tokenService->requestStatus(token) != RsTokenService::COMPLETE)
{ {
tick(); tick();
sleep(1); sleep(1);
@ -533,7 +533,7 @@ bool GxsPeerNode::getIdentities(std::vector<RsGxsIdGroup> &groups)
uint32_t token; uint32_t token;
tokenService->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts); tokenService->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts);
while(tokenService->requestStatus(token) != RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE) while(tokenService->requestStatus(token) != RsTokenService::COMPLETE)
{ {
tick(); tick();
sleep(1); sleep(1);
@ -553,7 +553,7 @@ bool GxsPeerNode::getIdentitiesList(std::list<RsGxsGroupId> &groups)
uint32_t token; uint32_t token;
tokenService->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_LIST, opts); tokenService->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_LIST, opts);
while(tokenService->requestStatus(token) != RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE) while(tokenService->requestStatus(token) != RsTokenService::COMPLETE)
{ {
tick(); tick();
sleep(1); sleep(1);
@ -575,7 +575,7 @@ bool GxsPeerNode::getCircles(std::vector<RsGxsCircleGroup> &groups)
uint32_t token; uint32_t token;
tokenService->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts); tokenService->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts);
while(tokenService->requestStatus(token) != RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE) while(tokenService->requestStatus(token) != RsTokenService::COMPLETE)
{ {
tick(); tick();
sleep(1); sleep(1);
@ -595,7 +595,7 @@ bool GxsPeerNode::getCirclesList(std::list<RsGxsGroupId> &groups)
uint32_t token; uint32_t token;
tokenService->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_LIST, opts); tokenService->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_LIST, opts);
while(tokenService->requestStatus(token) != RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE) while(tokenService->requestStatus(token) != RsTokenService::COMPLETE)
{ {
tick(); tick();
sleep(1); sleep(1);

View File

@ -118,14 +118,14 @@ TEST(libretroshare_services, DISABLED_GXS_nxs_basic2)
uint32_t token2; uint32_t token2;
ASSERT_TRUE(testService->submitTestGroup(token1, grp1)); ASSERT_TRUE(testService->submitTestGroup(token1, grp1));
while(tokenService->requestStatus(token1) != RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE) while(tokenService->requestStatus(token1) != RsTokenService::COMPLETE)
{ {
tester.tick(); tester.tick();
sleep(1); sleep(1);
} }
ASSERT_TRUE(testService->submitTestGroup(token2, grp2)); ASSERT_TRUE(testService->submitTestGroup(token2, grp2));
while(tokenService->requestStatus(token2) != RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE) while(tokenService->requestStatus(token2) != RsTokenService::COMPLETE)
{ {
tester.tick(); tester.tick();
sleep(1); sleep(1);