diff --git a/libretroshare/src/gxs/rsgenexchange.cc b/libretroshare/src/gxs/rsgenexchange.cc index a81c7341e..3430c2fd3 100644 --- a/libretroshare/src/gxs/rsgenexchange.cc +++ b/libretroshare/src/gxs/rsgenexchange.cc @@ -44,8 +44,8 @@ #define PUB_GRP_OFFSET 0 #define RESTR_GRP_OFFSET 8 -#define PRIV_GRP_OFFSET 16 -#define GRP_OPTIONS_OFFSET 24 +#define PRIV_GRP_OFFSET 9 +#define GRP_OPTIONS_OFFSET 7 #define GXS_MASK "GXS_MASK_HACK" diff --git a/libretroshare/src/retroshare/rsposted.h b/libretroshare/src/retroshare/rsposted.h index 29ea984b8..c1ae4b749 100644 --- a/libretroshare/src/retroshare/rsposted.h +++ b/libretroshare/src/retroshare/rsposted.h @@ -64,13 +64,14 @@ class RsPostedGroup class RsPostedPost; class RsPostedComment; class RsPostedVote; +class RsPostedPostRanking; typedef std::map > PostedPostResult; typedef std::map > PostedCommentResult; typedef std::map > PostedVoteResult; typedef std::map > PostedRelatedCommentResult; typedef std::pair GroupRank; -typedef std::map PostedRanking; +typedef std::map PostedRanking; std::ostream &operator<<(std::ostream &out, const RsPostedGroup &group); std::ostream &operator<<(std::ostream &out, const RsPostedPost &post); @@ -100,7 +101,7 @@ virtual ~RsPosted() { return; } virtual bool getPost(const uint32_t &token, PostedPostResult &post) = 0; virtual bool getComment(const uint32_t &token, PostedCommentResult &comment) = 0; virtual bool getRelatedComment(const uint32_t& token, PostedRelatedCommentResult& comments) = 0; - virtual bool getRanking(const uint32_t& token, PostedRanking& ranking) = 0; + virtual bool getPostRanking(const uint32_t& token, RsPostedPostRanking& ranking) = 0; virtual bool submitGroup(uint32_t &token, RsPostedGroup &group) = 0; virtual bool submitPost(uint32_t &token, RsPostedPost &post) = 0; @@ -116,7 +117,7 @@ virtual ~RsPosted() { return; } * @param rType * @param groupId */ - virtual bool requestMessageRankings(uint32_t &token, const RankType& rType, const RsGxsGroupId& groupId) = 0; + virtual bool requestPostRankings(uint32_t &token, const RankType& rType, const RsGxsGroupId& groupId) = 0; /*! * Makes request for ranking of comments for a post @@ -175,4 +176,12 @@ class RsPostedComment RsMsgMetaData mMeta; }; +class RsPostedPostRanking +{ +public: + + RsGxsGroupId grpId; + PostedRanking ranking; + RsPosted::RankType rType; +}; #endif // RSPOSTED_H diff --git a/libretroshare/src/rsserver/p3face-config.cc b/libretroshare/src/rsserver/p3face-config.cc index 4454a5b86..4dd922ca5 100644 --- a/libretroshare/src/rsserver/p3face-config.cc +++ b/libretroshare/src/rsserver/p3face-config.cc @@ -186,9 +186,21 @@ void RsServer::rsGlobalShutDown() mPluginsManager->stopPlugins(); // stop the p3distrib threads + mForums->join(); mChannels->join(); + if(mGxsCircles) mGxsCircles->join(); + if(mGxsForums) mGxsForums->join(); + if(mGxsIdService) mGxsIdService->join(); + if(mPosted) mPosted->join(); + if(mPhoto) mPhoto->join(); + if(mWiki) mWiki->join(); + if(mWire) mWire->join(); + + + + #ifdef RS_USE_BLOGS mBlogs->join(); #endif diff --git a/libretroshare/src/rsserver/p3face-server.cc b/libretroshare/src/rsserver/p3face-server.cc index fba404e68..e296cb726 100644 --- a/libretroshare/src/rsserver/p3face-server.cc +++ b/libretroshare/src/rsserver/p3face-server.cc @@ -76,6 +76,15 @@ RsServer::RsServer(RsIface &i, NotifyBase &callback) /* Config */ mConfigMgr = NULL; mGeneralConfig = NULL; + + /* GXS */ + mPhoto = NULL; + mWiki = NULL; + mPosted = NULL; + mGxsCircles = NULL; + mGxsIdService = NULL; + mGxsForums = NULL; + mWire = NULL; } RsServer::~RsServer() diff --git a/libretroshare/src/rsserver/p3face.h b/libretroshare/src/rsserver/p3face.h index 0290d0b0f..0cb082d5e 100644 --- a/libretroshare/src/rsserver/p3face.h +++ b/libretroshare/src/rsserver/p3face.h @@ -45,6 +45,15 @@ #include "services/p3channels.h" #include "services/p3forums.h" +#include "services/p3idservice.h" +#include "services/p3gxscircles.h" +#include "services/p3wiki.h" +#include "services/p3posted.h" +#include "services/p3photoservice.h" +#include "services/p3gxsforums.h" +#include "services/p3wire.h" + + class p3PeerMgrIMPL; class p3LinkMgrIMPL; class p3NetMgrIMPL; @@ -175,6 +184,16 @@ class RsServer: public RsControl, public RsThread p3Forums *mForums; /* caches (that need ticking) */ + /* GXS */ + + p3Wiki *mWiki; + p3Posted *mPosted; + p3PhotoService *mPhoto; + p3GxsCircles *mGxsCircles; + p3IdService *mGxsIdService; + p3GxsForums *mGxsForums; + p3Wire *mWire; + /* Config */ p3ConfigMgr *mConfigMgr; p3GeneralConfig *mGeneralConfig; diff --git a/libretroshare/src/rsserver/rsinit.cc b/libretroshare/src/rsserver/rsinit.cc index 6e4e4411a..50b62bf19 100644 --- a/libretroshare/src/rsserver/rsinit.cc +++ b/libretroshare/src/rsserver/rsinit.cc @@ -1823,15 +1823,6 @@ RsTurtle *rsTurtle = NULL ; #include "gxs/rsgxsflags.h" #endif -#ifdef ENABLE_GXS_SERVICES -#include "services/p3idservice.h" -#include "services/p3gxscircles.h" -#include "services/p3wiki.h" -#include "services/p3posted.h" -#include "services/p3photoservice.h" -#include "services/p3gxsforums.h" -#include "services/p3wire.h" -#endif #ifndef PQI_DISABLE_TUNNEL #include "services/p3tunnel.h" @@ -2302,8 +2293,6 @@ int RsServer::StartupRetroShare() /**** Identity service ****/ - p3IdService *mGxsIdService = NULL; - RsGeneralDataService* gxsid_ds = new RsDataService(currGxsDir + "/", "gxsid_db", RS_SERVICE_GXSV1_TYPE_GXSID, NULL); @@ -2318,7 +2307,6 @@ int RsServer::StartupRetroShare() /**** GxsCircle service ****/ - p3GxsCircles *mGxsCircles = NULL; RsGeneralDataService* gxscircles_ds = new RsDataService(currGxsDir + "/", "gxscircles_db", RS_SERVICE_GXSV1_TYPE_GXSCIRCLE, NULL); @@ -2354,8 +2342,6 @@ int RsServer::StartupRetroShare() RsGenExchange::setAuthenPolicyFlag(flag, photoAuthenPolicy, RsGenExchange::GRP_OPTION_BITS); - p3PhotoService *mPhoto = NULL; - RsGeneralDataService* photo_ds = new RsDataService(currGxsDir + "/", "photoV2_db", RS_SERVICE_GXSV1_TYPE_PHOTO, NULL); @@ -2372,7 +2358,7 @@ int RsServer::StartupRetroShare() /**** Posted GXS service ****/ - p3Posted *mPosted = NULL; + RsGeneralDataService* posted_ds = new RsDataService(currGxsDir + "/", "posted_db", RS_SERVICE_GXSV1_TYPE_POSTED); @@ -2388,7 +2374,7 @@ int RsServer::StartupRetroShare() /**** Wiki GXS service ****/ - p3Wiki *mWiki = NULL; + RsGeneralDataService* wiki_ds = new RsDataService(currGxsDir + "/", "wiki_db", RS_SERVICE_GXSV1_TYPE_WIKI); @@ -2404,7 +2390,6 @@ int RsServer::StartupRetroShare() /**** Wire GXS service ****/ - p3Wire *mWire = NULL; RsGeneralDataService* wire_ds = new RsDataService(currGxsDir + "/", "wire_db", RS_SERVICE_GXSV1_TYPE_WIRE); @@ -2420,8 +2405,6 @@ int RsServer::StartupRetroShare() /**** Forum GXS service ****/ - p3GxsForums *mGxsForums = NULL; - RsGeneralDataService* gxsforums_ds = new RsDataService(currGxsDir + "/", "gxsforums_db", RS_SERVICE_GXSV1_TYPE_FORUMS); diff --git a/libretroshare/src/services/p3posted.cc b/libretroshare/src/services/p3posted.cc index b3118e32e..eb9616c7f 100644 --- a/libretroshare/src/services/p3posted.cc +++ b/libretroshare/src/services/p3posted.cc @@ -15,12 +15,12 @@ #define UPDATE_PHASE_COMMENT_COUNT 5 #define UPDATE_PHASE_COMPLETE 6 -#define NUM_TOPICS_TO_GENERATE 1 -#define NUM_POSTS_TO_GENERATE 1 -#define NUM_VOTES_TO_GENERATE 23 -#define NUM_COMMENTS_TO_GENERATE 23 +#define NUM_TOPICS_TO_GENERATE 7 +#define NUM_POSTS_TO_GENERATE 7 +#define NUM_VOTES_TO_GENERATE 11 +#define NUM_COMMENTS_TO_GENERATE 4 -#define VOTE_UPDATE_PERIOD 30 // 20 seconds +#define VOTE_UPDATE_PERIOD 5 // 20 seconds const uint32_t RsPosted::FLAG_MSGTYPE_COMMENT = 0x0001; const uint32_t RsPosted::FLAG_MSGTYPE_POST = 0x0002; @@ -77,6 +77,8 @@ void p3Posted::service_tick() } updateVotes(); + + processRankings(); } void p3Posted::generateVotesAndComments() @@ -157,6 +159,7 @@ void p3Posted::generateVotesAndComments() c.mComment = "Comment " + ostrm.str(); c.mMeta.mParentId = msgId; c.mMeta.mGroupId = grpId; + c.mMeta.mThreadId = msgId; submitComment(token, c); mTokens.push_back(token); @@ -490,7 +493,7 @@ bool p3Posted::requestCommentRankings(uint32_t &token, const RankType &rType, co return true; } -bool p3Posted::requestMessageRankings(uint32_t &token, const RankType &rType, const RsGxsGroupId &groupId) +bool p3Posted::requestPostRankings(uint32_t &token, const RankType &rType, const RsGxsGroupId &groupId) { token = RsGenExchange::generatePublicToken(); @@ -499,64 +502,111 @@ bool p3Posted::requestMessageRankings(uint32_t &token, const RankType &rType, co gp->grpId = groupId; gp->rType = rType; gp->pubToken = token; + gp->rankingResult.rType = gp->rType; + gp->grpId = gp->grpId; - mPendingPostRanks.insert(std::make_pair(token, gp)); + mPendingPostRanks.push_back(gp); return true; } -bool p3Posted::getRanking(const uint32_t &token, PostedRanking &ranking) +bool p3Posted::getPostRanking(const uint32_t &token, RsPostedPostRanking &ranking) { + RsStackMutex stack(mPostedMutex); + if( mCompletePostRanks.find(token) == mCompletePostRanks.end()) return false; + + ranking = mCompletePostRanks[token]; + mCompletePostRanks.erase(token); + + // put this in service tick as it's blocking + // and likely costly + disposeOfPublicToken(token); + + return true; } void p3Posted::processRankings() { - processMessageRanks(); + // processPostRanks(); - processCommentRanks(); + //processCommentRanks(); } -void p3Posted::processMessageRanks() +void p3Posted::processPostRanks() { RsStackMutex stack(mPostedMutex); - std::map::iterator mit =mPendingPostRanks.begin(); + + std::vector::iterator vit = mPendingPostRanks.begin(); // go through all pending posts - for(; mit !=mPendingPostRanks.begin(); mit++) + for(; vit !=mPendingPostRanks.begin(); ) { + GxsPostedPostRanking* gp = *vit; uint32_t token; std::list grpL; - grpL.push_back(mit->second->grpId); + grpL.push_back(gp->grpId); + RsTokReqOptions opts; - opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA; + opts.mReqType = GXS_REQUEST_TYPE_MSG_META; + opts.mMsgFlagFilter = RsPosted::FLAG_MSGTYPE_POST; + opts.mMsgFlagMask = RsPosted::FLAG_MSGTYPE_MASK; opts.mOptions = RS_TOKREQOPT_MSG_LATEST | RS_TOKREQOPT_MSG_THREAD; + RsGenExchange::getTokenService()->requestMsgInfo(token, GXS_REQUEST_TYPE_GROUP_DATA, opts, grpL); - GxsPostedPostRanking* gp = mit->second; + + gp->reqToken = token; - while(true) - { - uint32_t status = mTokenService->requestStatus(token); - - if(RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE - == status) - { - completePostedPostCalc(gp); - break; - } - else if(RsTokenService::GXS_REQUEST_V2_STATUS_FAILED - == status) - { - discardCalc(token); - break; - } - } + vit = mPendingPostRanks.erase(vit); + mCompletionPostRanks.push_back(gp); } mPendingPostRanks.clear(); + vit = mCompletionPostRanks.begin(); + + for(; vit != mCompletionPostRanks.end(); ) + { + bool ok = false; + GxsPostedPostRanking *gp = *vit; + uint32_t status = mTokenService->requestStatus(gp->reqToken); + + if(RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE + == status) + { + ok = completePostedPostCalc(gp); + + if(ok) + { + mCompletePostRanks.insert( + std::make_pair(gp->pubToken, gp->rankingResult)); + } + } + else if(RsTokenService::GXS_REQUEST_V2_STATUS_FAILED + == status) + { + discardCalc(gp->reqToken); + ok = false; + }else + { + vit++; + continue; + } + + if(ok) + { + updatePublicRequestStatus(gp->pubToken, RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE); + } + else + { + updatePublicRequestStatus(gp->pubToken, RsTokenService::GXS_REQUEST_V2_STATUS_FAILED); + } + + vit = mCompletionPostRanks.erase(vit); + delete gp; + } } @@ -617,25 +667,27 @@ bool PostedBestScoreComp(const PostedScore& i, const PostedScore& j) return i_score < j_score; } -void p3Posted::completePostedPostCalc(GxsPostedPostRanking *gpp) +bool p3Posted::completePostedPostCalc(GxsPostedPostRanking *gpp) { GxsMsgMetaMap msgMetas; if(getMsgMeta(gpp->reqToken, msgMetas)) { - std::vector msgMetaV = msgMetas[gpp->grpId]; + std::vector& msgMetaV = msgMetas[gpp->grpId]; switch(gpp->rType) { case NewRankType: - calcPostedPostRank(msgMetaV, gpp->rankingResult, PostedNewScoreComp); + calcPostedPostRank(msgMetaV, gpp->rankingResult.ranking, PostedNewScoreComp); break; case TopRankType: - calcPostedPostRank(msgMetaV, gpp->rankingResult, PostedTopScoreComp); + calcPostedPostRank(msgMetaV, gpp->rankingResult.ranking, PostedTopScoreComp); break; default: std::cerr << "Unknown ranking tpye: " << gpp->rType << std::endl; } - } + return true; + }else + return false; } @@ -667,7 +719,7 @@ void p3Posted::calcPostedPostRank(const std::vector msgMeta, Pos for(; vit != scores.end(); vit++) { const PostedScore& p = *vit; - ranking.insert(std::make_pair(p.msgId, i++)); + ranking.insert(std::make_pair(i++, p.msgId)); } } @@ -713,7 +765,7 @@ void p3Posted::calcPostedCommentsRank(const std::map mPendingPostRanks; - std::map mPendingCalculationPostRanks; + std::vector mPendingPostRanks; + std::vector mCompletionPostRanks; + std::map mCompletePostRanks; std::map mPendingCommentRanks; std::map mPendingCalculationCommentRanks; diff --git a/retroshare-gui/src/gui/Posted/PostedListDialog.cpp b/retroshare-gui/src/gui/Posted/PostedListDialog.cpp index e3c8521f7..68f003739 100644 --- a/retroshare-gui/src/gui/Posted/PostedListDialog.cpp +++ b/retroshare-gui/src/gui/Posted/PostedListDialog.cpp @@ -80,6 +80,8 @@ PostedListDialog::PostedListDialog(CommentHolder *commentHolder, QWidget *parent connect( ui.groupTreeWidget, SIGNAL( treeCurrentItemChanged(QString) ), this, SLOT( changedTopic(QString) ) ); + connect(ui.hotSortButton, SIGNAL(clicked()), this, SLOT(getHotRankings())); + /* create posted tree */ yourTopics = ui.groupTreeWidget->addCategoryItem(tr("Your Topics"), QIcon(IMAGE_FOLDER), true); subscribedTopics = ui.groupTreeWidget->addCategoryItem(tr("Subscribed Topics"), QIcon(IMAGE_FOLDERRED), true); @@ -93,6 +95,60 @@ PostedListDialog::PostedListDialog(CommentHolder *commentHolder, QWidget *parent connect(ui.refreshButton, SIGNAL(clicked()), this, SLOT(refreshTopics())); } +void PostedListDialog::getHotRankings() +{ + + if(mCurrTopicId.empty()) + return; + + std::cerr << "PostedListDialog::getHotRankings()"; + std::cerr << std::endl; + + RsTokReqOptions opts; + opts.mReqType = GXS_REQUEST_TYPE_GROUP_META; + uint32_t token; + rsPosted->requestPostRankings(token, RsPosted::BestRankType, mCurrTopicId); + mPostedQueue->queueRequest(token, TOKENREQ_GROUPINFO, RS_TOKREQ_ANSTYPE_DATA, TOKEN_USER_TYPE_POST_RANKINGS); +} + +void PostedListDialog::loadRankings(const uint32_t &token) +{ + + RsPostedPostRanking rankings; + + if(!rsPosted->getPostRanking(token, rankings)) + return; + + if(rankings.grpId != mCurrTopicId) + return; + + applyRanking(rankings.ranking); +} + +void PostedListDialog::applyRanking(const PostedRanking& ranks) +{ + std::cerr << "PostedListDialog::loadGroupThreadData_InsertThreads()"; + std::cerr << std::endl; + + shallowClearPosts(); + + QLayout *alayout = ui.scrollAreaWidgetContents->layout(); + + PostedRanking::const_iterator mit = ranks.begin(); + + for(; mit != ranks.end(); mit++) + { + const RsGxsMessageId& msgId = mit->second; + + if(mPosts.find(msgId) != mPosts.end()) + alayout->addWidget(mPosts[msgId]); + } + + return; +} + + + void PostedListDialog::refreshTopics() { std::cerr << "PostedListDialog::requestGroupSummary()"; @@ -468,6 +524,48 @@ void PostedListDialog::clearPosts() mPosts.clear(); } +void PostedListDialog::shallowClearPosts() +{ + std::cerr << "PostedListDialog::clearPosts()" << std::endl; + + std::list postedItems; + std::list::iterator pit; + + QLayout *alayout = ui.scrollAreaWidgetContents->layout(); + int count = alayout->count(); + for(int i = 0; i < count; i++) + { + QLayoutItem *litem = alayout->itemAt(i); + if (!litem) + { + std::cerr << "PostedListDialog::clearPosts() missing litem"; + std::cerr << std::endl; + continue; + } + + PostedItem *item = dynamic_cast(litem->widget()); + if (item) + { + std::cerr << "PostedListDialog::clearPosts() item: " << item; + std::cerr << std::endl; + + postedItems.push_back(item); + } + else + { + std::cerr << "PostedListDialog::clearPosts() Found Child, which is not a PostedItem???"; + std::cerr << std::endl; + } + } + + for(pit = postedItems.begin(); pit != postedItems.end(); pit++) + { + PostedItem *item = *pit; + alayout->removeWidget(item); + } + +} + void PostedListDialog::updateCurrentDisplayComplete(const uint32_t &token) { std::cerr << "PostedListDialog::loadGroupThreadData_InsertThreads()"; @@ -558,6 +656,17 @@ void PostedListDialog::loadRequest(const TokenQueue *queue, const TokenRequest & break; } break; + case TOKEN_USER_TYPE_POST_RANKINGS: + switch(req.mAnsType) + { + case RS_TOKREQ_ANSTYPE_DATA: + loadRankings(req.mToken); + break; + default: + std::cerr << "Error, unexpected anstype:" << req.mAnsType << std::endl; + break; + } + break; default: std::cerr << "PostedListDialog::loadRequest() ERROR: INVALID TYPE"; std::cerr << std::endl; diff --git a/retroshare-gui/src/gui/Posted/PostedListDialog.h b/retroshare-gui/src/gui/Posted/PostedListDialog.h index efa809679..78eddc875 100644 --- a/retroshare-gui/src/gui/Posted/PostedListDialog.h +++ b/retroshare-gui/src/gui/Posted/PostedListDialog.h @@ -74,10 +74,17 @@ private slots: void submitVote(const RsGxsGrpMsgIdPair& msgId, bool up); + void getHotRankings(); + private: void clearPosts(); + /*! + * Only removes it from layout + */ + void shallowClearPosts(); + void updateDisplay(); void loadPost(const RsPostedPost &post); @@ -103,6 +110,11 @@ private: void acknowledgeVoteMsg(const uint32_t& token); void loadVoteData(const uint32_t &token); + // ranking + + void loadRankings(const uint32_t& token); + void applyRanking(const PostedRanking& ranks); + // update displayed item diff --git a/retroshare-gui/src/gui/Posted/PostedUserTypes.h b/retroshare-gui/src/gui/Posted/PostedUserTypes.h index 228067d6d..e802ae986 100644 --- a/retroshare-gui/src/gui/Posted/PostedUserTypes.h +++ b/retroshare-gui/src/gui/Posted/PostedUserTypes.h @@ -5,5 +5,6 @@ #define TOKEN_USER_TYPE_VOTE 5 #define TOKEN_USER_TYPE_TOPIC 6 #define TOKEN_USER_TYPE_POST_MOD 7 +#define TOKEN_USER_TYPE_POST_RANKINGS 8 #endif // POSTEDUSERTYPES_H diff --git a/retroshare-gui/src/util/TokenQueue.cpp b/retroshare-gui/src/util/TokenQueue.cpp index d8a35f7a1..8d114e95f 100644 --- a/retroshare-gui/src/util/TokenQueue.cpp +++ b/retroshare-gui/src/util/TokenQueue.cpp @@ -98,9 +98,9 @@ void TokenQueue::queueRequest(uint32_t token, uint32_t basictype, uint32_t ansty gettimeofday(&req.mRequestTs, NULL); req.mPollTs = req.mRequestTs; - mTokenMtx.lock(); + mRequests.push_back(req); - mTokenMtx.unlock(); + if (mRequests.size() == 1) { @@ -126,10 +126,10 @@ void TokenQueue::pollRequests() TokenRequest req; - mTokenMtx.lock(); + req = mRequests.front(); mRequests.pop_front(); - mTokenMtx.unlock(); + if (checkForRequest(req.mToken)) { @@ -144,9 +144,9 @@ void TokenQueue::pollRequests() /* drop old requests too */ if (time(NULL) - req.mRequestTs.tv_sec < MAX_REQUEST_AGE) { - mTokenMtx.lock(); + mRequests.push_back(req); - mTokenMtx.unlock(); + } else { @@ -170,9 +170,9 @@ bool TokenQueue::checkForRequest(uint32_t token) (RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE == status) ); } -bool TokenQueue::activeRequestExist(const uint32_t& userType) +bool TokenQueue::activeRequestExist(const uint32_t& userType) const { - mTokenMtx.lock(); + std::list::const_iterator lit = mRequests.begin(); @@ -182,19 +182,19 @@ bool TokenQueue::activeRequestExist(const uint32_t& userType) if(req.mUserType == userType) { - mTokenMtx.unlock(); + return true; } } - mTokenMtx.unlock(); + return false; } -void TokenQueue::activeRequestTokens(const uint32_t& userType, std::list& tokens) +void TokenQueue::activeRequestTokens(const uint32_t& userType, std::list& tokens) const { - mTokenMtx.lock(); + std::list::const_iterator lit = mRequests.begin(); @@ -206,7 +206,7 @@ void TokenQueue::activeRequestTokens(const uint32_t& userType, std::list::iterator it; - mTokenMtx.lock(); + for(it = mRequests.begin(); it != mRequests.end(); it++) { if (it->mToken == token) @@ -236,12 +236,12 @@ bool TokenQueue::cancelRequest(const uint32_t token) std::cerr << "TokenQueue::cancelRequest() Cleared Request: " << token; std::cerr << std::endl; - mTokenMtx.unlock(); + return true; } } - mTokenMtx.unlock(); + std::cerr << "TokenQueue::cancelRequest() Failed to Find Request: " << token; std::cerr << std::endl; diff --git a/retroshare-gui/src/util/TokenQueue.h b/retroshare-gui/src/util/TokenQueue.h index 0e39efb47..dcf580b52 100644 --- a/retroshare-gui/src/util/TokenQueue.h +++ b/retroshare-gui/src/util/TokenQueue.h @@ -26,7 +26,6 @@ #include #include -#include #include #include #include @@ -100,8 +99,8 @@ public: bool checkForRequest(uint32_t token); void loadRequest(const TokenRequest &req); - bool activeRequestExist(const uint32_t& userType); - void activeRequestTokens(const uint32_t& userType, std::list& tokens); + bool activeRequestExist(const uint32_t& userType) const; + void activeRequestTokens(const uint32_t& userType, std::list& tokens) const; protected: void doPoll(float dt); @@ -114,8 +113,7 @@ private: std::list mRequests; RsTokenService *mService; - TokenResponse *mResponder; - QMutex mTokenMtx; + TokenResponse *mResponder; QTimer *mTrigger; };