mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-08-02 19:26:31 -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
|
@ -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 \
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
|
||||
#include <QDialog>
|
||||
#include "retroshare/rsposted.h"
|
||||
#include "PostedUserTypes.h"
|
||||
|
||||
#include "util/TokenQueue.h"
|
||||
|
||||
namespace Ui {
|
||||
|
|
|
@ -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("<a href=" + QString::fromStdString(post.mLink) +
|
||||
"><span style=\" text-decoration: underline; color:#0000ff;\">" +
|
||||
QString::fromStdString(post.mMeta.mMsgName) + "</span></a>");
|
||||
siteLabel->setText("<a href=" + QString::fromStdString(post.mLink) +
|
||||
"><span style=\" text-decoration: underline; color:#0000ff;\">" +
|
||||
QString::fromStdString(post.mLink) + "</span></a>");
|
||||
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("<a href=" + QString::fromStdString(post.mLink) +
|
||||
"><span style=\" text-decoration: underline; color:#0000ff;\">" +
|
||||
QString::fromStdString(post.mMeta.mMsgName) + "</span></a>");
|
||||
siteLabel->setText("<a href=" + QString::fromStdString(post.mLink) +
|
||||
"><span style=\" text-decoration: underline; color:#0000ff;\">" +
|
||||
QString::fromStdString(post.mLink) + "</span></a>");
|
||||
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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<std::string> 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<RsGxsGroupId> 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);
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -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<RsGroupMetaData> &groupList);
|
||||
void groupInfoToGroupItemInfo(const RsGroupMetaData &groupInfo, GroupItemInfo &groupItemInfo);
|
||||
|
|
|
@ -1,270 +1,270 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>PostedListDialog</class>
|
||||
<widget class="QWidget" name="PostedListDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>792</width>
|
||||
<height>426</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="sortGroup">
|
||||
<property name="checkable">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<property name="spacing">
|
||||
<number>-1</number>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QPushButton" name="hotSortButton">
|
||||
<property name="text">
|
||||
<string>Hot</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="autoExclusive">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="newSortButton">
|
||||
<property name="text">
|
||||
<string>New</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="autoExclusive">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="topSortButton">
|
||||
<property name="text">
|
||||
<string>Top</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="autoExclusive">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="periodComboBox">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Today</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Yesterday</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>This Week</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>This Month</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>This Year</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSplitter" name="splitter">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<widget class="QWidget" name="layoutWidget">
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<widget class="QPushButton" name="newTopicButton">
|
||||
<property name="text">
|
||||
<string>New Topic</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QPushButton" name="newPostButton">
|
||||
<property name="text">
|
||||
<string>Submit Post</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="3">
|
||||
<widget class="GroupTreeWidget" name="groupTreeWidget" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="layoutWidget">
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QPushButton" name="refreshButton">
|
||||
<property name="text">
|
||||
<string>Refresh</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Showing 1-100</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="prevButton">
|
||||
<property name="text">
|
||||
<string>Prev</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="nextButton">
|
||||
<property name="text">
|
||||
<string>Next</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QScrollArea" name="scrollArea">
|
||||
<property name="widgetResizable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<widget class="QWidget" name="scrollAreaWidgetContents">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>406</width>
|
||||
<height>333</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Minimum</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>309</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>GroupTreeWidget</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>gui/common/GroupTreeWidget.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>PostedListDialog</class>
|
||||
<widget class="QWidget" name="PostedListDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>792</width>
|
||||
<height>426</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="sortGroup">
|
||||
<property name="checkable">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QPushButton" name="hotSortButton">
|
||||
<property name="text">
|
||||
<string>Hot</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="autoExclusive">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="newSortButton">
|
||||
<property name="text">
|
||||
<string>New</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="autoExclusive">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="topSortButton">
|
||||
<property name="text">
|
||||
<string>Top</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="autoExclusive">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="refreshButton">
|
||||
<property name="text">
|
||||
<string>Refresh</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="periodComboBox">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Today</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Yesterday</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>This Week</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>This Month</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>This Year</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSplitter" name="splitter">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<widget class="QWidget" name="layoutWidget">
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<widget class="QPushButton" name="newTopicButton">
|
||||
<property name="text">
|
||||
<string>New Topic</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QPushButton" name="newPostButton">
|
||||
<property name="text">
|
||||
<string>Submit Post</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="3">
|
||||
<widget class="GroupTreeWidget" name="groupTreeWidget" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="layoutWidget">
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Showing 1-100</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="prevButton">
|
||||
<property name="text">
|
||||
<string>Prev</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="nextButton">
|
||||
<property name="text">
|
||||
<string>Next</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QScrollArea" name="scrollArea">
|
||||
<property name="widgetResizable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<widget class="QWidget" name="scrollAreaWidgetContents">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>472</width>
|
||||
<height>327</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Minimum</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>309</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>GroupTreeWidget</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>gui/common/GroupTreeWidget.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
|
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);
|
||||
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<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)
|
||||
{
|
||||
|
@ -181,6 +221,7 @@ bool TokenQueue::cancelRequest(const uint32_t token)
|
|||
|
||||
std::list<TokenRequest>::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;
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
|
||||
#include <QWidget>
|
||||
#include <QTimer>
|
||||
#include <QMutex>
|
||||
#include <list>
|
||||
#include <string>
|
||||
#include <sys/time.h>
|
||||
|
@ -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<uint32_t>& tokens);
|
||||
protected:
|
||||
void doPoll(float dt);
|
||||
|
||||
|
@ -111,6 +114,7 @@ private:
|
|||
|
||||
RsTokenService *mService;
|
||||
TokenResponse *mResponder;
|
||||
QMutex mTokenMtx;
|
||||
|
||||
QTimer *mTrigger;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue