diff --git a/libretroshare/src/serialiser/rsposteditems.cc b/libretroshare/src/serialiser/rsposteditems.cc index 99280b634..3b8269628 100644 --- a/libretroshare/src/serialiser/rsposteditems.cc +++ b/libretroshare/src/serialiser/rsposteditems.cc @@ -291,7 +291,7 @@ bool RsGxsPostedSerialiser::serialiseGxsPostedVoteItem(RsGxsPostedVoteItem* item /* skip the header */ offset += 8; - ok &= setRawUInt32(data, tlvsize, &offset, item->mVote.mDirection); + ok &= setRawUInt8(data, tlvsize, &offset, item->mVote.mDirection); if(offset != tlvsize) { diff --git a/libretroshare/src/services/p3posted.cc b/libretroshare/src/services/p3posted.cc index cc9e695cc..0f26845bf 100644 --- a/libretroshare/src/services/p3posted.cc +++ b/libretroshare/src/services/p3posted.cc @@ -1,11 +1,16 @@ #include #include +#include #include "p3posted.h" #include "gxs/rsgxsflags.h" #include "serialiser/rsposteditems.h" +#define NUM_TOPICS_TO_GENERATE 7 +#define NUM_POSTS_TO_GENERATE 8 +#define NUM_VOTES_TO_GENERATE 23 + const uint32_t RsPosted::FLAG_MSGTYPE_COMMENT = 0x0001; const uint32_t RsPosted::FLAG_MSGTYPE_POST = 0x0002; const uint32_t RsPosted::FLAG_MSGTYPE_VOTE = 0x0004; @@ -29,7 +34,7 @@ RsPostedVote::RsPostedVote(const RsGxsPostedVoteItem& item) p3Posted::p3Posted(RsGeneralDataService *gds, RsNetworkExchangeService *nes) : RsGenExchange(gds, nes, new RsGxsPostedSerialiser(), RS_SERVICE_GXSV1_TYPE_POSTED), RsPosted(this), mPostedMutex("Posted"), - mTokenService(NULL) + mTokenService(NULL), mGeneratingTopics(true), mGeneratingPosts(false) { mTokenService = RsGenExchange::getTokenService(); } @@ -41,6 +46,118 @@ void p3Posted::notifyChanges(std::vector &changes) void p3Posted::service_tick() { + generateTopics(); + + //generatePosts(); +} + +void p3Posted::generatePosts() +{ + if(mGeneratingPosts) + { + // request topics then chose at random which one to use to generate a post about + uint32_t token; + RsTokReqOptions opts; + opts.mReqType = GXS_REQUEST_TYPE_GROUP_IDS; + mTokenService->requestGroupInfo(token, 0, opts); + double timeDelta = 2.; // slow tick + while(mTokenService->requestStatus(token) != RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE) + { +#ifndef WINDOWS_SYS + usleep((int) (timeDelta * 1000000)); +#else + Sleep((int) (timeDelta * 1000)); +#endif + } + + std::list grpIds; + RsGenExchange::getGroupList(token, grpIds); + + + // for each group generate NUM_POSTS_TO_GENERATE posts + std::list::iterator lit = grpIds.begin(); + + for(; lit != grpIds.end(); lit++) + { + RsGxsGroupId& grpId = *lit; + + std::vector tokens; + + for(int i=0; i < NUM_POSTS_TO_GENERATE; i++) + { + std::ostringstream ostrm; + ostrm << i; + std::string link = "link" + ostrm.str(); + + RsPostedPost post; + post.mLink = link; + post.mNotes = link; + post.mMeta.mMsgName = link; + post.mMeta.mGroupId = grpId; + + submitPost(token, post); + tokens.push_back(token); + } + + while(!tokens.empty()) + { + std::vector::iterator vit = tokens.begin(); + + for(; vit != tokens.end(); ) + { + if(mTokenService->requestStatus(*vit) != RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE) + vit = tokens.erase(vit); + else + vit++; + } + } + } + + + + + // stop generating posts after acknowledging all the ones you created + mGeneratingPosts = false; + } +} + +void p3Posted::generateTopics() +{ + if(mGeneratingTopics) + { + std::vector tokens; + + for(int i=0; i < NUM_TOPICS_TO_GENERATE; i++) + { + std::ostringstream strm; + strm << i; + std::string topicName = "Topic " + strm.str(); + + RsPostedGroup topic; + topic.mMeta.mGroupName = topicName; + + uint32_t token; + submitGroup(token, topic); + tokens.push_back(token); + } + + + while(!tokens.empty()) + { + std::vector::iterator vit = tokens.begin(); + + for(; vit != tokens.end(); ) + { + if(mTokenService->requestStatus(*vit) != RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE) + vit = tokens.erase(vit); + else + vit++; + } + } + + mGeneratingTopics = false; + mGeneratingPosts = true; + } } diff --git a/libretroshare/src/services/p3posted.h b/libretroshare/src/services/p3posted.h index 7a5e9d42b..f0df0ba19 100644 --- a/libretroshare/src/services/p3posted.h +++ b/libretroshare/src/services/p3posted.h @@ -62,6 +62,21 @@ protected: void service_tick(); +public: + + void generateTopics(); + /*! + * Exists solely for testing + */ + void generatePosts(); + + /*! + * Exists solely for testing + * Generates random votes to existing posts + * in the system + */ + void generateVotes(); + public: bool getGroup(const uint32_t &token, std::vector &group); @@ -132,6 +147,11 @@ private: RsTokenService* mTokenService; RsMutex mPostedMutex; + + + // for data generation + + bool mGeneratingPosts, mGeneratingTopics; }; #endif // P3POSTED_H diff --git a/libretroshare/src/tests/gxs/genexchangetester.cpp b/libretroshare/src/tests/gxs/genexchangetester.cpp index 15afd5135..203b57bc0 100644 --- a/libretroshare/src/tests/gxs/genexchangetester.cpp +++ b/libretroshare/src/tests/gxs/genexchangetester.cpp @@ -20,7 +20,16 @@ void GenExchangeTester::setUp() RsGixsDummy* gixsDummy = new RsGixsDummy("incoming", "outgoing"); - mTestService = new GenExchangeTestService(mDataStore, mNxs, gixsDummy, 0); + uint32_t serviceAuthenPolicy = 0; + + uint8_t flag = 0; + + flag = GXS_SERV::MSG_AUTHEN_ROOT_PUBLISH_SIGN; + RsGenExchange::setAuthenPolicyFlag(flag, serviceAuthenPolicy, + RsGenExchange::RESTRICTED_GRP_BITS); + + + mTestService = new GenExchangeTestService(mDataStore, mNxs, gixsDummy, serviceAuthenPolicy); mTokenService = mTestService->getTokenService(); mTestService->start(); } diff --git a/libretroshare/src/tests/gxs/genexchangetester.h b/libretroshare/src/tests/gxs/genexchangetester.h index 7dfc1d2e2..fac83a02d 100644 --- a/libretroshare/src/tests/gxs/genexchangetester.h +++ b/libretroshare/src/tests/gxs/genexchangetester.h @@ -49,6 +49,12 @@ public: bool testGrpMetaModRequest(); bool testMsgMetaModRequest(); + + // testing verification (publish). + // Strategy is + // inject a group which you only have the public signature for + // The injection can be done via + private: // to be called at start diff --git a/retroshare-gui/src/RetroShare.pro b/retroshare-gui/src/RetroShare.pro index f91209128..daaee05e4 100644 --- a/retroshare-gui/src/RetroShare.pro +++ b/retroshare-gui/src/RetroShare.pro @@ -197,8 +197,8 @@ bitdht { LIBS += ../../libbitdht/src/lib/libbitdht.a PRE_TARGETDEPS *= ../../libbitdht/src/lib/libbitdht.a - #LIBS += C:\Development\Rs\v0.5-gxs-b1\libbitdht\libbitdht-build-desktop\lib\libbitdht.a - #PRE_TARGETDEPS *= C:\Development\Rs\v0.5-gxs-b1\libbitdht\libbitdht-build-desktop\lib\libbitdht.a +# LIBS += C:\Development\Rs\v0.5-gxs-b1\libbitdht\libbitdht-build-desktop\lib\libbitdht.a + # PRE_TARGETDEPS *= C:\Development\Rs\v0.5-gxs-b1\libbitdht\libbitdht-build-desktop\lib\libbitdht.a # Chris version. #LIBS += ../../libbitdht/libbitdht-build-desktop/lib/libbitdht.a @@ -988,7 +988,8 @@ posted { gui/Posted/PostedComments.h \ gui/Posted/PostedGroupDialog.h \ gui/Posted/PostedCreatePostDialog.h \ - gui/Posted/PostedCreateCommentDialog.h + gui/Posted/PostedCreateCommentDialog.h \ + gui/Posted/PostedUserTypes.h FORMS += gui/Posted/PostedDialog.ui \ gui/Posted/PostedListDialog.ui \ diff --git a/retroshare-gui/src/gui/Posted/PostedCreatePostDialog.cpp b/retroshare-gui/src/gui/Posted/PostedCreatePostDialog.cpp index 00512379e..c9eebf008 100644 --- a/retroshare-gui/src/gui/Posted/PostedCreatePostDialog.cpp +++ b/retroshare-gui/src/gui/Posted/PostedCreatePostDialog.cpp @@ -19,7 +19,7 @@ void PostedCreatePostDialog::createPost() uint32_t token; mPosted->submitPost(token, post); - mTokenQueue->queueRequest(token, TOKENREQ_MSGINFO, RS_TOKREQ_ANSTYPE_ACK, 0); + mTokenQueue->queueRequest(token, TOKENREQ_MSGINFO, RS_TOKREQ_ANSTYPE_ACK, TOKEN_USER_TYPE_POST); close(); } diff --git a/retroshare-gui/src/gui/Posted/PostedCreatePostDialog.h b/retroshare-gui/src/gui/Posted/PostedCreatePostDialog.h index 0c5ba887e..9a06042b8 100644 --- a/retroshare-gui/src/gui/Posted/PostedCreatePostDialog.h +++ b/retroshare-gui/src/gui/Posted/PostedCreatePostDialog.h @@ -3,6 +3,8 @@ #include #include "retroshare/rsposted.h" +#include "PostedUserTypes.h" + #include "util/TokenQueue.h" namespace Ui { diff --git a/retroshare-gui/src/gui/Posted/PostedItem.cpp b/retroshare-gui/src/gui/Posted/PostedItem.cpp index 449f54fc5..daf77a365 100644 --- a/retroshare-gui/src/gui/Posted/PostedItem.cpp +++ b/retroshare-gui/src/gui/Posted/PostedItem.cpp @@ -40,26 +40,28 @@ PostedItem::PostedItem(PostedHolder *postHolder, const RsPostedPost &post) :QWidget(NULL), mPostHolder(postHolder), mPost(post) { - setupUi(this); - setAttribute ( Qt::WA_DeleteOnClose, true ); + setupUi(this); + setAttribute ( Qt::WA_DeleteOnClose, true ); - QDateTime qtime; - qtime.setTime_t(mPost.mMeta.mPublishTs); - QString timestamp = qtime.toString("dd.MMMM yyyy hh:mm"); - dateLabel->setText(timestamp); - fromLabel->setText(QString::fromUtf8(post.mMeta.mAuthorId.c_str())); - titleLabel->setText("" + - QString::fromStdString(post.mMeta.mMsgName) + ""); - siteLabel->setText("" + - QString::fromStdString(post.mLink) + ""); + QDateTime qtime; + qtime.setTime_t(mPost.mMeta.mPublishTs); + QString timestamp = qtime.toString("dd.MMMM yyyy hh:mm"); + dateLabel->setText(timestamp); + fromLabel->setText(QString::fromUtf8(post.mMeta.mAuthorId.c_str())); + titleLabel->setText("" + + QString::fromStdString(post.mMeta.mMsgName) + ""); + siteLabel->setText("" + + QString::fromStdString(post.mLink) + ""); - scoreLabel->setText(QString("1")); + scoreLabel->setText(QString("1")); - connect( commentButton, SIGNAL( clicked() ), this, SLOT( loadComments() ) ); + connect( commentButton, SIGNAL( clicked() ), this, SLOT( loadComments() ) ); + connect( voteUpButton, SIGNAL(clicked()), this, SLOT(makeUpVote())); + connect( voteDownButton, SIGNAL(clicked()), this, SLOT( makeDownVote())); - return; + return; } RsPostedPost PostedItem::getPost() const @@ -67,9 +69,25 @@ RsPostedPost PostedItem::getPost() const return mPost; } +void PostedItem::makeDownVote() +{ + RsGxsGrpMsgIdPair msgId; + msgId.first = mPost.mMeta.mMsgId; + msgId.second = mPost.mMeta.mGroupId; + emit vote(msgId, false); +} + +void PostedItem::makeUpVote() +{ + RsGxsGrpMsgIdPair msgId; + msgId.first = mPost.mMeta.mMsgId; + msgId.second = mPost.mMeta.mGroupId; + emit vote(msgId, true); +} + void PostedItem::loadComments() { - std::cerr << "PostedItem::loadComments() Requesting for " << mThreadId; - std::cerr << std::endl; - mPostHolder->showComments(mPost); + std::cerr << "PostedItem::loadComments() Requesting for " << mThreadId; + std::cerr << std::endl; + mPostHolder->showComments(mPost); } diff --git a/retroshare-gui/src/gui/Posted/PostedItem.h b/retroshare-gui/src/gui/Posted/PostedItem.h index 6ed65ac9e..a78865040 100644 --- a/retroshare-gui/src/gui/Posted/PostedItem.h +++ b/retroshare-gui/src/gui/Posted/PostedItem.h @@ -50,6 +50,11 @@ public: private slots: void loadComments(); + void makeUpVote(); + void makeDownVote(); + +signals: + void vote(const RsGxsGrpMsgIdPair& msgId, bool up); private: uint32_t mType; diff --git a/retroshare-gui/src/gui/Posted/PostedListDialog.cpp b/retroshare-gui/src/gui/Posted/PostedListDialog.cpp index 586fb54d3..6e632f791 100644 --- a/retroshare-gui/src/gui/Posted/PostedListDialog.cpp +++ b/retroshare-gui/src/gui/Posted/PostedListDialog.cpp @@ -63,6 +63,9 @@ #define IMAGE_FORUMAUTHD ":/images/konv_message2.png" #define IMAGE_COPYLINK ":/images/copyrslink.png" +// token types to deal with + + /** Constructor */ PostedListDialog::PostedListDialog(CommentHolder *commentHolder, QWidget *parent) : RsAutoUpdatePage(1000,parent), mCommentHolder(commentHolder) @@ -87,8 +90,19 @@ PostedListDialog::PostedListDialog(CommentHolder *commentHolder, QWidget *parent mSortButton = ui.hotSortButton; connect( ui.newTopicButton, SIGNAL( clicked() ), this, SLOT( newTopic() ) ); + connect(ui.refreshButton, SIGNAL(clicked()), this, SLOT(refreshTopics())); } +void PostedListDialog::refreshTopics() +{ + std::cerr << "PostedListDialog::requestGroupSummary()"; + std::cerr << std::endl; + + RsTokReqOptions opts; + opts.mReqType = GXS_REQUEST_TYPE_GROUP_META; + uint32_t token; + mPostedQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_SUMMARY, opts, TOKEN_USER_TYPE_TOPIC); +} void PostedListDialog::groupListCustomPopupMenu( QPoint /*point*/ ) { @@ -106,6 +120,19 @@ void PostedListDialog::newPost() cp.exec(); } +void PostedListDialog::submitVote(const RsGxsGrpMsgIdPair &msgId, bool up) +{ + uint32_t token; + RsPostedVote vote; + + vote.mMeta.mGroupId = msgId.first; + vote.mMeta.mParentId = msgId.second; + vote.mDirection = (uint8_t)up; + rsPosted->submitVote(token, vote); + + mPostedQueue->queueRequest(token, 0 , RS_TOKREQ_ANSTYPE_ACK, TOKEN_USER_TYPE_VOTE); +} + void PostedListDialog::showComments(const RsPostedPost& post) { mCommentHolder->commentLoad(post); @@ -167,10 +194,10 @@ void PostedListDialog::requestGroupSummary() std::cerr << "PostedListDialog::requestGroupSummary()"; std::cerr << std::endl; - std::list ids; RsTokReqOptions opts; + opts.mReqType = GXS_REQUEST_TYPE_GROUP_META; uint32_t token; - mPostedQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_SUMMARY, opts, ids, POSTEDDIALOG_LISTING); + mPostedQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_SUMMARY, opts, TOKEN_USER_TYPE_TOPIC); } void PostedListDialog::acknowledgeGroup(const uint32_t &token) @@ -180,17 +207,15 @@ void PostedListDialog::acknowledgeGroup(const uint32_t &token) if(!grpId.empty()) { - std::list grpIds; - grpIds.push_back(grpId); RsTokReqOptions opts; opts.mReqType = GXS_REQUEST_TYPE_GROUP_META; uint32_t reqToken; - mPostedQueue->requestGroupInfo(reqToken, RS_TOKREQ_ANSTYPE_SUMMARY, opts, grpIds, 0); + mPostedQueue->requestGroupInfo(reqToken, RS_TOKREQ_ANSTYPE_SUMMARY, opts, TOKEN_USER_TYPE_TOPIC); } } -void PostedListDialog::acknowledgeMsg(const uint32_t &token) +void PostedListDialog::acknowledgePostMsg(const uint32_t &token) { RsGxsGrpMsgIdPair msgId; @@ -222,6 +247,18 @@ void PostedListDialog::loadPostData(const uint32_t &token) loadGroupThreadData_InsertThreads(token); } +void PostedListDialog::acknowledgeVoteMsg(const uint32_t &token) +{ + RsGxsGrpMsgIdPair msgId; + + rsPosted->acknowledgeMsg(token, msgId); +} + +void PostedListDialog::loadVoteData(const uint32_t &token) +{ + return; +} + /*********************** **** **** **** ***********************/ /*********************** **** **** **** ***********************/ @@ -307,7 +344,7 @@ void PostedListDialog::requestGroupThreadData_InsertThreads(const std::string &g std::cerr << std::endl; uint32_t token; - mPostedQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, grpIds, POSTEDDIALOG_INSERTTHREADS); + mPostedQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, grpIds, TOKEN_USER_TYPE_POST); } @@ -332,6 +369,7 @@ void PostedListDialog::loadGroupThreadData_InsertThreads(const uint32_t &token) void PostedListDialog::loadPost(const RsPostedPost &post) { PostedItem *item = new PostedItem(this, post); + connect(item, SIGNAL(vote(RsGxsGrpMsgIdPair,bool)), this, SLOT(submitVote(RsGxsGrpMsgIdPair,bool))); QLayout *alayout = ui.scrollAreaWidgetContents->layout(); alayout->addWidget(item); } @@ -391,16 +429,14 @@ void PostedListDialog::loadRequest(const TokenQueue *queue, const TokenRequest & std::cerr << std::endl; if (queue == mPostedQueue) - { + { /* now switch on req */ - switch(req.mType) + switch(req.mUserType) { - case TOKENREQ_GROUPINFO: + + case TOKEN_USER_TYPE_TOPIC: switch(req.mAnsType) { - case RS_TOKREQ_ANSTYPE_ACK: - acknowledgeGroup(req.mToken); - break; case RS_TOKREQ_ANSTYPE_SUMMARY: loadGroupSummary(req.mToken); break; @@ -409,11 +445,11 @@ void PostedListDialog::loadRequest(const TokenQueue *queue, const TokenRequest & break; } break; - case TOKENREQ_MSGINFO: + case TOKEN_USER_TYPE_POST: switch(req.mAnsType) { case RS_TOKREQ_ANSTYPE_ACK: - acknowledgeMsg(req.mToken); + acknowledgePostMsg(req.mToken); break; case RS_TOKREQ_ANSTYPE_DATA: loadPostData(req.mToken); @@ -422,13 +458,37 @@ void PostedListDialog::loadRequest(const TokenQueue *queue, const TokenRequest & std::cerr << "Error, unexpected anstype:" << req.mAnsType << std::endl; break; } - + break; + case TOKEN_USER_TYPE_VOTE: + switch(req.mAnsType) + { + case RS_TOKREQ_ANSTYPE_ACK: + acknowledgeVoteMsg(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; break; } } + + /* now switch on req */ + switch(req.mType) + { + case TOKENREQ_GROUPINFO: + switch(req.mAnsType) + { + case RS_TOKREQ_ANSTYPE_ACK: + acknowledgeGroup(req.mToken); + break; + } + break; + } } @@ -442,10 +502,10 @@ void PostedListDialog::loadRequest(const TokenQueue *queue, const TokenRequest & void PostedListDialog::groupInfoToGroupItemInfo(const RsGroupMetaData &groupInfo, GroupItemInfo &groupItemInfo) { groupItemInfo.id = QString::fromStdString(groupInfo.mGroupId); -groupItemInfo.name = QString::fromUtf8(groupInfo.mGroupName.c_str()); -//groupItemInfo.description = QString::fromUtf8(groupInfo.forumDesc); -groupItemInfo.popularity = groupInfo.mPop; -groupItemInfo.lastpost = QDateTime::fromTime_t(groupInfo.mLastPost); + groupItemInfo.name = QString::fromUtf8(groupInfo.mGroupName.c_str()); + //groupItemInfo.description = QString::fromUtf8(groupInfo.forumDesc); + groupItemInfo.popularity = groupInfo.mPop; + groupItemInfo.lastpost = QDateTime::fromTime_t(groupInfo.mLastPost); } diff --git a/retroshare-gui/src/gui/Posted/PostedListDialog.h b/retroshare-gui/src/gui/Posted/PostedListDialog.h index 0f61aefc1..0609a5406 100644 --- a/retroshare-gui/src/gui/Posted/PostedListDialog.h +++ b/retroshare-gui/src/gui/Posted/PostedListDialog.h @@ -37,6 +37,7 @@ #include "util/TokenQueue.h" #include "retroshare-gui/RsAutoUpdatePage.h" +#include "PostedUserTypes.h" class CommentHolder; @@ -69,6 +70,9 @@ private slots: void newTopic(); void showGroupDetails(); void newPost(); + void refreshTopics(); + + void submitVote(const RsGxsGrpMsgIdPair& msgId, bool up); private: @@ -86,13 +90,20 @@ private: void loadGroupSummary_CurrentForum(const uint32_t &token); - void acknowledgeMsg(const uint32_t &token); + // posts + void acknowledgePostMsg(const uint32_t &token); void loadPostData(const uint32_t &token); void insertThreads(); void loadCurrentTopicThreads(const std::string &forumId); void requestGroupThreadData_InsertThreads(const std::string &forumId); void loadGroupThreadData_InsertThreads(const uint32_t &token); + // votes + + void acknowledgeVoteMsg(const uint32_t& token); + void loadVoteData(const uint32_t &token); + + void insertGroupData(const std::list &groupList); void groupInfoToGroupItemInfo(const RsGroupMetaData &groupInfo, GroupItemInfo &groupItemInfo); diff --git a/retroshare-gui/src/gui/Posted/PostedListDialog.ui b/retroshare-gui/src/gui/Posted/PostedListDialog.ui index a685a6d99..32192f8d8 100644 --- a/retroshare-gui/src/gui/Posted/PostedListDialog.ui +++ b/retroshare-gui/src/gui/Posted/PostedListDialog.ui @@ -1,270 +1,270 @@ - - - PostedListDialog - - - - 0 - 0 - 792 - 426 - - - - Form - - - - - - - - false - - - - -1 - - - 0 - - - - - Hot - - - true - - - true - - - - - - - New - - - true - - - true - - - - - - - Top - - - true - - - false - - - true - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - Today - - - - - Yesterday - - - - - This Week - - - - - This Month - - - - - This Year - - - - - - - - - - Qt::Horizontal - - - - - - - New Topic - - - - - - - Submit Post - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 0 - 0 - - - - - - - - - - - - - - Refresh - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Showing 1-100 - - - - - - - Prev - - - - - - - Next - - - - - - - - - true - - - - - 0 - 0 - 406 - 333 - - - - - 0 - 0 - - - - - - - Qt::Vertical - - - QSizePolicy::Minimum - - - - 20 - 309 - - - - - - - - - - - - - - - - - GroupTreeWidget - QWidget -
gui/common/GroupTreeWidget.h
- 1 -
-
- - -
+ + + PostedListDialog + + + + 0 + 0 + 792 + 426 + + + + Form + + + + + + + + false + + + + 6 + + + 0 + + + + + Hot + + + true + + + true + + + + + + + New + + + true + + + true + + + + + + + Top + + + true + + + false + + + true + + + + + + + + + + Refresh + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + Today + + + + + Yesterday + + + + + This Week + + + + + This Month + + + + + This Year + + + + + + + + + + Qt::Horizontal + + + + + + + New Topic + + + + + + + Submit Post + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 0 + 0 + + + + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Showing 1-100 + + + + + + + Prev + + + + + + + Next + + + + + + + + + true + + + + + 0 + 0 + 472 + 327 + + + + + 0 + 0 + + + + + + + Qt::Vertical + + + QSizePolicy::Minimum + + + + 20 + 309 + + + + + + + + + + + + + + + + + GroupTreeWidget + QWidget +
gui/common/GroupTreeWidget.h
+ 1 +
+
+ + +
diff --git a/retroshare-gui/src/gui/Posted/PostedUserTypes.h b/retroshare-gui/src/gui/Posted/PostedUserTypes.h new file mode 100644 index 000000000..aa05682ef --- /dev/null +++ b/retroshare-gui/src/gui/Posted/PostedUserTypes.h @@ -0,0 +1,8 @@ +#ifndef POSTEDUSERTYPES_H +#define POSTEDUSERTYPES_H + +#define TOKEN_USER_TYPE_POST 4 +#define TOKEN_USER_TYPE_VOTE 5 +#define TOKEN_USER_TYPE_TOPIC 6 + +#endif // POSTEDUSERTYPES_H diff --git a/retroshare-gui/src/util/TokenQueue.cpp b/retroshare-gui/src/util/TokenQueue.cpp index 43b3b419d..592448892 100644 --- a/retroshare-gui/src/util/TokenQueue.cpp +++ b/retroshare-gui/src/util/TokenQueue.cpp @@ -98,7 +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) { @@ -123,8 +125,11 @@ void TokenQueue::pollRequests() } TokenRequest req; + + mTokenMtx.lock(); req = mRequests.front(); mRequests.pop_front(); + mTokenMtx.unlock(); if (checkForRequest(req.mToken)) { @@ -139,7 +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 { @@ -163,6 +170,39 @@ bool TokenQueue::checkForRequest(uint32_t token) (RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE == status) ); } +bool TokenQueue::activeRequestExist(const uint32_t& userType) +{ + mTokenMtx.lock(); + + std::list::const_iterator lit = mRequests.begin(); + + for(; lit != mRequests.end(); lit++) + { + const TokenRequest& req = *lit; + + if(req.mUserType == userType) + return true; + } + + mTokenMtx.unlock(); +} + +void TokenQueue::activeRequestTokens(const uint32_t& userType, std::list& tokens) +{ + mTokenMtx.lock(); + + std::list::const_iterator lit = mRequests.begin(); + + for(; lit != mRequests.end(); lit++) + { + const TokenRequest& req = *lit; + + if(req.mUserType == userType) + tokens.push_back(req.mToken); + } + + mTokenMtx.unlock(); +} void TokenQueue::loadRequest(const TokenRequest &req) { @@ -181,6 +221,7 @@ bool TokenQueue::cancelRequest(const uint32_t token) std::list::iterator it; + mTokenMtx.lock(); for(it = mRequests.begin(); it != mRequests.end(); it++) { if (it->mToken == token) @@ -193,6 +234,7 @@ bool TokenQueue::cancelRequest(const uint32_t token) 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 f69b81d37..309c2647e 100644 --- a/retroshare-gui/src/util/TokenQueue.h +++ b/retroshare-gui/src/util/TokenQueue.h @@ -26,6 +26,7 @@ #include #include +#include #include #include #include @@ -37,7 +38,7 @@ #define TOKENREQ_GROUPINFO 1 #define TOKENREQ_MSGINFO 2 -#define TOKENREQ_MSGRELATEDINFO 3 +#define TOKENREQ_MSGRELATEDINFO 3 class TokenQueue; @@ -99,6 +100,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); protected: void doPoll(float dt); @@ -111,6 +114,7 @@ private: RsTokenService *mService; TokenResponse *mResponder; + QMutex mTokenMtx; QTimer *mTrigger; };