mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-21 04:44:25 -04:00
Added user type interogation of tokenQueue
fix for posteditem serialisation added voting to gui, but no feedback yet post and topic generation code added for testing git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-gxs-b1@5945 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
694885963e
commit
de757cfcae
16 changed files with 621 additions and 318 deletions
|
@ -291,7 +291,7 @@ bool RsGxsPostedSerialiser::serialiseGxsPostedVoteItem(RsGxsPostedVoteItem* item
|
||||||
/* skip the header */
|
/* skip the header */
|
||||||
offset += 8;
|
offset += 8;
|
||||||
|
|
||||||
ok &= setRawUInt32(data, tlvsize, &offset, item->mVote.mDirection);
|
ok &= setRawUInt8(data, tlvsize, &offset, item->mVote.mDirection);
|
||||||
|
|
||||||
if(offset != tlvsize)
|
if(offset != tlvsize)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,11 +1,16 @@
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
#include "p3posted.h"
|
#include "p3posted.h"
|
||||||
#include "gxs/rsgxsflags.h"
|
#include "gxs/rsgxsflags.h"
|
||||||
#include "serialiser/rsposteditems.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_COMMENT = 0x0001;
|
||||||
const uint32_t RsPosted::FLAG_MSGTYPE_POST = 0x0002;
|
const uint32_t RsPosted::FLAG_MSGTYPE_POST = 0x0002;
|
||||||
const uint32_t RsPosted::FLAG_MSGTYPE_VOTE = 0x0004;
|
const uint32_t RsPosted::FLAG_MSGTYPE_VOTE = 0x0004;
|
||||||
|
@ -29,7 +34,7 @@ RsPostedVote::RsPostedVote(const RsGxsPostedVoteItem& item)
|
||||||
|
|
||||||
p3Posted::p3Posted(RsGeneralDataService *gds, RsNetworkExchangeService *nes)
|
p3Posted::p3Posted(RsGeneralDataService *gds, RsNetworkExchangeService *nes)
|
||||||
: RsGenExchange(gds, nes, new RsGxsPostedSerialiser(), RS_SERVICE_GXSV1_TYPE_POSTED), RsPosted(this), mPostedMutex("Posted"),
|
: 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();
|
mTokenService = RsGenExchange::getTokenService();
|
||||||
}
|
}
|
||||||
|
@ -41,6 +46,118 @@ void p3Posted::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
||||||
|
|
||||||
void p3Posted::service_tick()
|
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<RsGxsGroupId> grpIds;
|
||||||
|
RsGenExchange::getGroupList(token, grpIds);
|
||||||
|
|
||||||
|
|
||||||
|
// for each group generate NUM_POSTS_TO_GENERATE posts
|
||||||
|
std::list<RsGxsGroupId>::iterator lit = grpIds.begin();
|
||||||
|
|
||||||
|
for(; lit != grpIds.end(); lit++)
|
||||||
|
{
|
||||||
|
RsGxsGroupId& grpId = *lit;
|
||||||
|
|
||||||
|
std::vector<uint32_t> 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<uint32_t>::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<uint32_t> 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<uint32_t>::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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -62,6 +62,21 @@ protected:
|
||||||
|
|
||||||
void service_tick();
|
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:
|
public:
|
||||||
|
|
||||||
bool getGroup(const uint32_t &token, std::vector<RsPostedGroup> &group);
|
bool getGroup(const uint32_t &token, std::vector<RsPostedGroup> &group);
|
||||||
|
@ -132,6 +147,11 @@ private:
|
||||||
|
|
||||||
RsTokenService* mTokenService;
|
RsTokenService* mTokenService;
|
||||||
RsMutex mPostedMutex;
|
RsMutex mPostedMutex;
|
||||||
|
|
||||||
|
|
||||||
|
// for data generation
|
||||||
|
|
||||||
|
bool mGeneratingPosts, mGeneratingTopics;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // P3POSTED_H
|
#endif // P3POSTED_H
|
||||||
|
|
|
@ -20,7 +20,16 @@ void GenExchangeTester::setUp()
|
||||||
|
|
||||||
RsGixsDummy* gixsDummy = new RsGixsDummy("incoming", "outgoing");
|
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();
|
mTokenService = mTestService->getTokenService();
|
||||||
mTestService->start();
|
mTestService->start();
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,6 +49,12 @@ public:
|
||||||
bool testGrpMetaModRequest();
|
bool testGrpMetaModRequest();
|
||||||
bool testMsgMetaModRequest();
|
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:
|
private:
|
||||||
|
|
||||||
// to be called at start
|
// to be called at start
|
||||||
|
|
|
@ -197,8 +197,8 @@ bitdht {
|
||||||
LIBS += ../../libbitdht/src/lib/libbitdht.a
|
LIBS += ../../libbitdht/src/lib/libbitdht.a
|
||||||
PRE_TARGETDEPS *= ../../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
|
# 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
|
# PRE_TARGETDEPS *= C:\Development\Rs\v0.5-gxs-b1\libbitdht\libbitdht-build-desktop\lib\libbitdht.a
|
||||||
|
|
||||||
# Chris version.
|
# Chris version.
|
||||||
#LIBS += ../../libbitdht/libbitdht-build-desktop/lib/libbitdht.a
|
#LIBS += ../../libbitdht/libbitdht-build-desktop/lib/libbitdht.a
|
||||||
|
@ -988,7 +988,8 @@ posted {
|
||||||
gui/Posted/PostedComments.h \
|
gui/Posted/PostedComments.h \
|
||||||
gui/Posted/PostedGroupDialog.h \
|
gui/Posted/PostedGroupDialog.h \
|
||||||
gui/Posted/PostedCreatePostDialog.h \
|
gui/Posted/PostedCreatePostDialog.h \
|
||||||
gui/Posted/PostedCreateCommentDialog.h
|
gui/Posted/PostedCreateCommentDialog.h \
|
||||||
|
gui/Posted/PostedUserTypes.h
|
||||||
|
|
||||||
FORMS += gui/Posted/PostedDialog.ui \
|
FORMS += gui/Posted/PostedDialog.ui \
|
||||||
gui/Posted/PostedListDialog.ui \
|
gui/Posted/PostedListDialog.ui \
|
||||||
|
|
|
@ -19,7 +19,7 @@ void PostedCreatePostDialog::createPost()
|
||||||
|
|
||||||
uint32_t token;
|
uint32_t token;
|
||||||
mPosted->submitPost(token, post);
|
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();
|
close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
#include "retroshare/rsposted.h"
|
#include "retroshare/rsposted.h"
|
||||||
|
#include "PostedUserTypes.h"
|
||||||
|
|
||||||
#include "util/TokenQueue.h"
|
#include "util/TokenQueue.h"
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
|
|
|
@ -58,6 +58,8 @@ PostedItem::PostedItem(PostedHolder *postHolder, const RsPostedPost &post)
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
@ -67,6 +69,22 @@ RsPostedPost PostedItem::getPost() const
|
||||||
return mPost;
|
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()
|
void PostedItem::loadComments()
|
||||||
{
|
{
|
||||||
std::cerr << "PostedItem::loadComments() Requesting for " << mThreadId;
|
std::cerr << "PostedItem::loadComments() Requesting for " << mThreadId;
|
||||||
|
|
|
@ -50,6 +50,11 @@ public:
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void loadComments();
|
void loadComments();
|
||||||
|
void makeUpVote();
|
||||||
|
void makeDownVote();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void vote(const RsGxsGrpMsgIdPair& msgId, bool up);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint32_t mType;
|
uint32_t mType;
|
||||||
|
|
|
@ -63,6 +63,9 @@
|
||||||
#define IMAGE_FORUMAUTHD ":/images/konv_message2.png"
|
#define IMAGE_FORUMAUTHD ":/images/konv_message2.png"
|
||||||
#define IMAGE_COPYLINK ":/images/copyrslink.png"
|
#define IMAGE_COPYLINK ":/images/copyrslink.png"
|
||||||
|
|
||||||
|
// token types to deal with
|
||||||
|
|
||||||
|
|
||||||
/** Constructor */
|
/** Constructor */
|
||||||
PostedListDialog::PostedListDialog(CommentHolder *commentHolder, QWidget *parent)
|
PostedListDialog::PostedListDialog(CommentHolder *commentHolder, QWidget *parent)
|
||||||
: RsAutoUpdatePage(1000,parent), mCommentHolder(commentHolder)
|
: RsAutoUpdatePage(1000,parent), mCommentHolder(commentHolder)
|
||||||
|
@ -87,8 +90,19 @@ PostedListDialog::PostedListDialog(CommentHolder *commentHolder, QWidget *parent
|
||||||
mSortButton = ui.hotSortButton;
|
mSortButton = ui.hotSortButton;
|
||||||
|
|
||||||
connect( ui.newTopicButton, SIGNAL( clicked() ), this, SLOT( newTopic() ) );
|
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*/ )
|
void PostedListDialog::groupListCustomPopupMenu( QPoint /*point*/ )
|
||||||
{
|
{
|
||||||
|
@ -106,6 +120,19 @@ void PostedListDialog::newPost()
|
||||||
cp.exec();
|
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)
|
void PostedListDialog::showComments(const RsPostedPost& post)
|
||||||
{
|
{
|
||||||
mCommentHolder->commentLoad(post);
|
mCommentHolder->commentLoad(post);
|
||||||
|
@ -167,10 +194,10 @@ void PostedListDialog::requestGroupSummary()
|
||||||
std::cerr << "PostedListDialog::requestGroupSummary()";
|
std::cerr << "PostedListDialog::requestGroupSummary()";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
|
||||||
std::list<std::string> ids;
|
|
||||||
RsTokReqOptions opts;
|
RsTokReqOptions opts;
|
||||||
|
opts.mReqType = GXS_REQUEST_TYPE_GROUP_META;
|
||||||
uint32_t token;
|
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)
|
void PostedListDialog::acknowledgeGroup(const uint32_t &token)
|
||||||
|
@ -180,17 +207,15 @@ void PostedListDialog::acknowledgeGroup(const uint32_t &token)
|
||||||
|
|
||||||
if(!grpId.empty())
|
if(!grpId.empty())
|
||||||
{
|
{
|
||||||
std::list<RsGxsGroupId> grpIds;
|
|
||||||
grpIds.push_back(grpId);
|
|
||||||
|
|
||||||
RsTokReqOptions opts;
|
RsTokReqOptions opts;
|
||||||
opts.mReqType = GXS_REQUEST_TYPE_GROUP_META;
|
opts.mReqType = GXS_REQUEST_TYPE_GROUP_META;
|
||||||
uint32_t reqToken;
|
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;
|
RsGxsGrpMsgIdPair msgId;
|
||||||
|
|
||||||
|
@ -222,6 +247,18 @@ void PostedListDialog::loadPostData(const uint32_t &token)
|
||||||
loadGroupThreadData_InsertThreads(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;
|
std::cerr << std::endl;
|
||||||
|
|
||||||
uint32_t token;
|
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)
|
void PostedListDialog::loadPost(const RsPostedPost &post)
|
||||||
{
|
{
|
||||||
PostedItem *item = new PostedItem(this, post);
|
PostedItem *item = new PostedItem(this, post);
|
||||||
|
connect(item, SIGNAL(vote(RsGxsGrpMsgIdPair,bool)), this, SLOT(submitVote(RsGxsGrpMsgIdPair,bool)));
|
||||||
QLayout *alayout = ui.scrollAreaWidgetContents->layout();
|
QLayout *alayout = ui.scrollAreaWidgetContents->layout();
|
||||||
alayout->addWidget(item);
|
alayout->addWidget(item);
|
||||||
}
|
}
|
||||||
|
@ -393,14 +431,12 @@ void PostedListDialog::loadRequest(const TokenQueue *queue, const TokenRequest &
|
||||||
if (queue == mPostedQueue)
|
if (queue == mPostedQueue)
|
||||||
{
|
{
|
||||||
/* now switch on req */
|
/* now switch on req */
|
||||||
switch(req.mType)
|
switch(req.mUserType)
|
||||||
{
|
{
|
||||||
case TOKENREQ_GROUPINFO:
|
|
||||||
|
case TOKEN_USER_TYPE_TOPIC:
|
||||||
switch(req.mAnsType)
|
switch(req.mAnsType)
|
||||||
{
|
{
|
||||||
case RS_TOKREQ_ANSTYPE_ACK:
|
|
||||||
acknowledgeGroup(req.mToken);
|
|
||||||
break;
|
|
||||||
case RS_TOKREQ_ANSTYPE_SUMMARY:
|
case RS_TOKREQ_ANSTYPE_SUMMARY:
|
||||||
loadGroupSummary(req.mToken);
|
loadGroupSummary(req.mToken);
|
||||||
break;
|
break;
|
||||||
|
@ -409,11 +445,11 @@ void PostedListDialog::loadRequest(const TokenQueue *queue, const TokenRequest &
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case TOKENREQ_MSGINFO:
|
case TOKEN_USER_TYPE_POST:
|
||||||
switch(req.mAnsType)
|
switch(req.mAnsType)
|
||||||
{
|
{
|
||||||
case RS_TOKREQ_ANSTYPE_ACK:
|
case RS_TOKREQ_ANSTYPE_ACK:
|
||||||
acknowledgeMsg(req.mToken);
|
acknowledgePostMsg(req.mToken);
|
||||||
break;
|
break;
|
||||||
case RS_TOKREQ_ANSTYPE_DATA:
|
case RS_TOKREQ_ANSTYPE_DATA:
|
||||||
loadPostData(req.mToken);
|
loadPostData(req.mToken);
|
||||||
|
@ -422,13 +458,37 @@ void PostedListDialog::loadRequest(const TokenQueue *queue, const TokenRequest &
|
||||||
std::cerr << "Error, unexpected anstype:" << req.mAnsType << std::endl;
|
std::cerr << "Error, unexpected anstype:" << req.mAnsType << std::endl;
|
||||||
break;
|
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:
|
default:
|
||||||
std::cerr << "PostedListDialog::loadRequest() ERROR: INVALID TYPE";
|
std::cerr << "PostedListDialog::loadRequest() ERROR: INVALID TYPE";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
break;
|
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)
|
void PostedListDialog::groupInfoToGroupItemInfo(const RsGroupMetaData &groupInfo, GroupItemInfo &groupItemInfo)
|
||||||
{
|
{
|
||||||
groupItemInfo.id = QString::fromStdString(groupInfo.mGroupId);
|
groupItemInfo.id = QString::fromStdString(groupInfo.mGroupId);
|
||||||
groupItemInfo.name = QString::fromUtf8(groupInfo.mGroupName.c_str());
|
groupItemInfo.name = QString::fromUtf8(groupInfo.mGroupName.c_str());
|
||||||
//groupItemInfo.description = QString::fromUtf8(groupInfo.forumDesc);
|
//groupItemInfo.description = QString::fromUtf8(groupInfo.forumDesc);
|
||||||
groupItemInfo.popularity = groupInfo.mPop;
|
groupItemInfo.popularity = groupInfo.mPop;
|
||||||
groupItemInfo.lastpost = QDateTime::fromTime_t(groupInfo.mLastPost);
|
groupItemInfo.lastpost = QDateTime::fromTime_t(groupInfo.mLastPost);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,6 +37,7 @@
|
||||||
|
|
||||||
#include "util/TokenQueue.h"
|
#include "util/TokenQueue.h"
|
||||||
#include "retroshare-gui/RsAutoUpdatePage.h"
|
#include "retroshare-gui/RsAutoUpdatePage.h"
|
||||||
|
#include "PostedUserTypes.h"
|
||||||
|
|
||||||
|
|
||||||
class CommentHolder;
|
class CommentHolder;
|
||||||
|
@ -69,6 +70,9 @@ private slots:
|
||||||
void newTopic();
|
void newTopic();
|
||||||
void showGroupDetails();
|
void showGroupDetails();
|
||||||
void newPost();
|
void newPost();
|
||||||
|
void refreshTopics();
|
||||||
|
|
||||||
|
void submitVote(const RsGxsGrpMsgIdPair& msgId, bool up);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
@ -86,13 +90,20 @@ private:
|
||||||
void loadGroupSummary_CurrentForum(const uint32_t &token);
|
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 loadPostData(const uint32_t &token);
|
||||||
void insertThreads();
|
void insertThreads();
|
||||||
void loadCurrentTopicThreads(const std::string &forumId);
|
void loadCurrentTopicThreads(const std::string &forumId);
|
||||||
void requestGroupThreadData_InsertThreads(const std::string &forumId);
|
void requestGroupThreadData_InsertThreads(const std::string &forumId);
|
||||||
void loadGroupThreadData_InsertThreads(const uint32_t &token);
|
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<RsGroupMetaData> &groupList);
|
void insertGroupData(const std::list<RsGroupMetaData> &groupList);
|
||||||
void groupInfoToGroupItemInfo(const RsGroupMetaData &groupInfo, GroupItemInfo &groupItemInfo);
|
void groupInfoToGroupItemInfo(const RsGroupMetaData &groupInfo, GroupItemInfo &groupItemInfo);
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
</property>
|
</property>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
<property name="spacing">
|
<property name="spacing">
|
||||||
<number>-1</number>
|
<number>6</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="margin">
|
<property name="margin">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
|
@ -73,6 +73,13 @@
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="refreshButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>Refresh</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<spacer name="horizontalSpacer">
|
<spacer name="horizontalSpacer">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
|
@ -167,13 +174,6 @@
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="refreshButton">
|
|
||||||
<property name="text">
|
|
||||||
<string>Refresh</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
<item>
|
||||||
<spacer name="horizontalSpacer_2">
|
<spacer name="horizontalSpacer_2">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
|
@ -220,8 +220,8 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>406</width>
|
<width>472</width>
|
||||||
<height>333</height>
|
<height>327</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
|
|
8
retroshare-gui/src/gui/Posted/PostedUserTypes.h
Normal file
8
retroshare-gui/src/gui/Posted/PostedUserTypes.h
Normal file
|
@ -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
|
|
@ -98,7 +98,9 @@ void TokenQueue::queueRequest(uint32_t token, uint32_t basictype, uint32_t ansty
|
||||||
gettimeofday(&req.mRequestTs, NULL);
|
gettimeofday(&req.mRequestTs, NULL);
|
||||||
req.mPollTs = req.mRequestTs;
|
req.mPollTs = req.mRequestTs;
|
||||||
|
|
||||||
|
mTokenMtx.lock();
|
||||||
mRequests.push_back(req);
|
mRequests.push_back(req);
|
||||||
|
mTokenMtx.unlock();
|
||||||
|
|
||||||
if (mRequests.size() == 1)
|
if (mRequests.size() == 1)
|
||||||
{
|
{
|
||||||
|
@ -123,8 +125,11 @@ void TokenQueue::pollRequests()
|
||||||
}
|
}
|
||||||
|
|
||||||
TokenRequest req;
|
TokenRequest req;
|
||||||
|
|
||||||
|
mTokenMtx.lock();
|
||||||
req = mRequests.front();
|
req = mRequests.front();
|
||||||
mRequests.pop_front();
|
mRequests.pop_front();
|
||||||
|
mTokenMtx.unlock();
|
||||||
|
|
||||||
if (checkForRequest(req.mToken))
|
if (checkForRequest(req.mToken))
|
||||||
{
|
{
|
||||||
|
@ -139,7 +144,9 @@ void TokenQueue::pollRequests()
|
||||||
/* drop old requests too */
|
/* drop old requests too */
|
||||||
if (time(NULL) - req.mRequestTs.tv_sec < MAX_REQUEST_AGE)
|
if (time(NULL) - req.mRequestTs.tv_sec < MAX_REQUEST_AGE)
|
||||||
{
|
{
|
||||||
|
mTokenMtx.lock();
|
||||||
mRequests.push_back(req);
|
mRequests.push_back(req);
|
||||||
|
mTokenMtx.unlock();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -163,6 +170,39 @@ bool TokenQueue::checkForRequest(uint32_t token)
|
||||||
(RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE == status) );
|
(RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE == status) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool TokenQueue::activeRequestExist(const uint32_t& userType)
|
||||||
|
{
|
||||||
|
mTokenMtx.lock();
|
||||||
|
|
||||||
|
std::list<TokenRequest>::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<uint32_t>& tokens)
|
||||||
|
{
|
||||||
|
mTokenMtx.lock();
|
||||||
|
|
||||||
|
std::list<TokenRequest>::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)
|
void TokenQueue::loadRequest(const TokenRequest &req)
|
||||||
{
|
{
|
||||||
|
@ -181,6 +221,7 @@ bool TokenQueue::cancelRequest(const uint32_t token)
|
||||||
|
|
||||||
std::list<TokenRequest>::iterator it;
|
std::list<TokenRequest>::iterator it;
|
||||||
|
|
||||||
|
mTokenMtx.lock();
|
||||||
for(it = mRequests.begin(); it != mRequests.end(); it++)
|
for(it = mRequests.begin(); it != mRequests.end(); it++)
|
||||||
{
|
{
|
||||||
if (it->mToken == token)
|
if (it->mToken == token)
|
||||||
|
@ -193,6 +234,7 @@ bool TokenQueue::cancelRequest(const uint32_t token)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
mTokenMtx.unlock();
|
||||||
|
|
||||||
std::cerr << "TokenQueue::cancelRequest() Failed to Find Request: " << token;
|
std::cerr << "TokenQueue::cancelRequest() Failed to Find Request: " << token;
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
#include <QMutex>
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
|
@ -99,6 +100,8 @@ public:
|
||||||
bool checkForRequest(uint32_t token);
|
bool checkForRequest(uint32_t token);
|
||||||
void loadRequest(const TokenRequest &req);
|
void loadRequest(const TokenRequest &req);
|
||||||
|
|
||||||
|
bool activeRequestExist(const uint32_t& userType);
|
||||||
|
void activeRequestTokens(const uint32_t& userType, std::list<uint32_t>& tokens);
|
||||||
protected:
|
protected:
|
||||||
void doPoll(float dt);
|
void doPoll(float dt);
|
||||||
|
|
||||||
|
@ -111,6 +114,7 @@ private:
|
||||||
|
|
||||||
RsTokenService *mService;
|
RsTokenService *mService;
|
||||||
TokenResponse *mResponder;
|
TokenResponse *mResponder;
|
||||||
|
QMutex mTokenMtx;
|
||||||
|
|
||||||
QTimer *mTrigger;
|
QTimer *mTrigger;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue