mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-06 21:58:57 -04:00
Forums:
- Switched from own token member to the new methods on TokenQueue. - Reactivated thread from the old forum to fill the messages. - Load all messages at once. - Added processing of missing messages. - Fixed new/read/unread status. git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-gxs-b1@5952 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
6527aaf2d8
commit
4413536926
10 changed files with 781 additions and 661 deletions
|
@ -34,6 +34,7 @@
|
||||||
#include "gxs/rsgxsifaceimpl.h"
|
#include "gxs/rsgxsifaceimpl.h"
|
||||||
|
|
||||||
|
|
||||||
|
#define IS_MSG_NEW(status) (status & GXS_SERV::GXS_MSG_STATUS_UNPROCESSED)
|
||||||
#define IS_MSG_UNREAD(status) (status & GXS_SERV::GXS_MSG_STATUS_UNREAD)
|
#define IS_MSG_UNREAD(status) (status & GXS_SERV::GXS_MSG_STATUS_UNREAD)
|
||||||
#define IS_GROUP_ADMIN(subscribeFlags) (subscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_ADMIN)
|
#define IS_GROUP_ADMIN(subscribeFlags) (subscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_ADMIN)
|
||||||
#define IS_GROUP_SUBSCRIBED(subscribeFlags) (subscribeFlags & (GXS_SERV::GROUP_SUBSCRIBE_ADMIN | GXS_SERV::GROUP_SUBSCRIBE_SUBSCRIBED))
|
#define IS_GROUP_SUBSCRIBED(subscribeFlags) (subscribeFlags & (GXS_SERV::GROUP_SUBSCRIBE_ADMIN | GXS_SERV::GROUP_SUBSCRIBE_SUBSCRIBED))
|
||||||
|
|
|
@ -228,7 +228,7 @@ bool p3GxsForums::createMsg(uint32_t &token, RsGxsForumMsg &msg)
|
||||||
|
|
||||||
void p3GxsForums::setMessageReadStatus(uint32_t& token, const RsGxsGrpMsgIdPair& msgId, bool read)
|
void p3GxsForums::setMessageReadStatus(uint32_t& token, const RsGxsGrpMsgIdPair& msgId, bool read)
|
||||||
{
|
{
|
||||||
uint32_t mask = GXS_SERV::GXS_MSG_STATUS_UNREAD;
|
uint32_t mask = GXS_SERV::GXS_MSG_STATUS_UNREAD | GXS_SERV::GXS_MSG_STATUS_UNPROCESSED;
|
||||||
uint32_t status = GXS_SERV::GXS_MSG_STATUS_UNREAD;
|
uint32_t status = GXS_SERV::GXS_MSG_STATUS_UNREAD;
|
||||||
if (read)
|
if (read)
|
||||||
{
|
{
|
||||||
|
@ -285,7 +285,7 @@ void p3GxsForums::dummy_tick()
|
||||||
|
|
||||||
if (mGenActive)
|
if (mGenActive)
|
||||||
{
|
{
|
||||||
std::cerr << "p3Wiki::dummyTick() AboutActive";
|
std::cerr << "p3GxsForums::dummyTick() AboutActive";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
|
||||||
uint32_t status = RsGenExchange::getTokenService()->requestStatus(mGenToken);
|
uint32_t status = RsGenExchange::getTokenService()->requestStatus(mGenToken);
|
||||||
|
@ -406,6 +406,8 @@ bool p3GxsForums::generateMessage(uint32_t &token, const RsGxsGroupId &grpId, co
|
||||||
msg.mMeta.mThreadId = threadId;
|
msg.mMeta.mThreadId = threadId;
|
||||||
msg.mMeta.mParentId = parentId;
|
msg.mMeta.mParentId = parentId;
|
||||||
|
|
||||||
|
msg.mMeta.mMsgStatus = GXS_SERV::GXS_MSG_STATUS_UNPROCESSED | GXS_SERV::GXS_MSG_STATUS_UNREAD;
|
||||||
|
|
||||||
/* chose a random Id to sign with */
|
/* chose a random Id to sign with */
|
||||||
std::list<RsGxsId> ownIds;
|
std::list<RsGxsId> ownIds;
|
||||||
std::list<RsGxsId>::iterator it;
|
std::list<RsGxsId>::iterator it;
|
||||||
|
|
|
@ -968,7 +968,8 @@ gxsforums {
|
||||||
|
|
||||||
HEADERS += gui/GxsForumsDialog.h \
|
HEADERS += gui/GxsForumsDialog.h \
|
||||||
gui/gxsforums/CreateGxsForumMsg.h \
|
gui/gxsforums/CreateGxsForumMsg.h \
|
||||||
gui/gxsforums/GxsForumThreadWidget.h
|
gui/gxsforums/GxsForumThreadWidget.h \
|
||||||
|
gui/gxsforums/GxsForumsFillThread.h
|
||||||
|
|
||||||
FORMS += gui/GxsForumsDialog.ui \
|
FORMS += gui/GxsForumsDialog.ui \
|
||||||
gui/gxsforums/CreateGxsForumMsg.ui \
|
gui/gxsforums/CreateGxsForumMsg.ui \
|
||||||
|
@ -976,7 +977,8 @@ gxsforums {
|
||||||
|
|
||||||
SOURCES += gui/GxsForumsDialog.cpp \
|
SOURCES += gui/GxsForumsDialog.cpp \
|
||||||
gui/gxsforums/CreateGxsForumMsg.cpp \
|
gui/gxsforums/CreateGxsForumMsg.cpp \
|
||||||
gui/gxsforums/GxsForumThreadWidget.cpp
|
gui/gxsforums/GxsForumThreadWidget.cpp \
|
||||||
|
gui/gxsforums/GxsForumsFillThread.cpp
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -69,8 +69,6 @@ GxsForumsDialog::GxsForumsDialog(QWidget *parent)
|
||||||
|
|
||||||
/* Setup Queue */
|
/* Setup Queue */
|
||||||
mForumQueue = new TokenQueue(rsGxsForums->getTokenService(), this);
|
mForumQueue = new TokenQueue(rsGxsForums->getTokenService(), this);
|
||||||
mTokenGroupSummary = 0;
|
|
||||||
mRequestGroupSummary = false;
|
|
||||||
|
|
||||||
connect(ui.forumTreeWidget, SIGNAL(treeCustomContextMenuRequested(QPoint)), this, SLOT(forumListCustomPopupMenu(QPoint)));
|
connect(ui.forumTreeWidget, SIGNAL(treeCustomContextMenuRequested(QPoint)), this, SLOT(forumListCustomPopupMenu(QPoint)));
|
||||||
connect(ui.newForumButton, SIGNAL(clicked()), this, SLOT(newforum()));
|
connect(ui.newForumButton, SIGNAL(clicked()), this, SLOT(newforum()));
|
||||||
|
@ -172,10 +170,10 @@ void GxsForumsDialog::forumListCustomPopupMenu(QPoint /*point*/)
|
||||||
|
|
||||||
contextMnu.addSeparator();
|
contextMnu.addSeparator();
|
||||||
|
|
||||||
action = contextMnu.addAction(QIcon(":/images/message-mail-read.png"), tr("Mark all as read"), this, SLOT(markMsgAsReadAll()));
|
action = contextMnu.addAction(QIcon(":/images/message-mail-read.png"), tr("Mark all as read"), this, SLOT(markMsgAsRead()));
|
||||||
action->setEnabled (!mForumId.empty () && IS_GROUP_SUBSCRIBED(subscribeFlags));
|
action->setEnabled (!mForumId.empty () && IS_GROUP_SUBSCRIBED(subscribeFlags));
|
||||||
|
|
||||||
action = contextMnu.addAction(QIcon(":/images/message-mail.png"), tr("Mark all as unread"), this, SLOT(markMsgAsUnreadAll()));
|
action = contextMnu.addAction(QIcon(":/images/message-mail.png"), tr("Mark all as unread"), this, SLOT(markMsgAsUnread()));
|
||||||
action->setEnabled (!mForumId.empty () && IS_GROUP_SUBSCRIBED(subscribeFlags));
|
action->setEnabled (!mForumId.empty () && IS_GROUP_SUBSCRIBED(subscribeFlags));
|
||||||
|
|
||||||
#ifdef DEBUG_FORUMS
|
#ifdef DEBUG_FORUMS
|
||||||
|
@ -319,6 +317,20 @@ void GxsForumsDialog::insertForumsData(const std::list<RsGroupMetaData> &forumLi
|
||||||
updateMessageSummaryList("");
|
updateMessageSummaryList("");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GxsForumThreadWidget *GxsForumsDialog::forumThreadWidget(const std::string &id)
|
||||||
|
{
|
||||||
|
int tabCount = ui.threadTabWidget->count();
|
||||||
|
for (int index = 0; index < tabCount; ++index) {
|
||||||
|
GxsForumThreadWidget *childWidget = dynamic_cast<GxsForumThreadWidget*>(ui.threadTabWidget->widget(index));
|
||||||
|
if (childWidget && childWidget->forumId() == id) {
|
||||||
|
return childWidget;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
void GxsForumsDialog::changedForum(const QString &id)
|
void GxsForumsDialog::changedForum(const QString &id)
|
||||||
{
|
{
|
||||||
mForumId = id.toStdString();
|
mForumId = id.toStdString();
|
||||||
|
@ -329,20 +341,12 @@ void GxsForumsDialog::changedForum(const QString &id)
|
||||||
// requestGroupSummary_CurrentForum(mForumId);
|
// requestGroupSummary_CurrentForum(mForumId);
|
||||||
|
|
||||||
/* search exisiting tab */
|
/* search exisiting tab */
|
||||||
GxsForumThreadWidget *threadWidget = NULL;
|
GxsForumThreadWidget *threadWidget = forumThreadWidget(id.toStdString());
|
||||||
int tabCount = ui.threadTabWidget->count();
|
|
||||||
for (int index = 0; index < tabCount; ++index) {
|
|
||||||
GxsForumThreadWidget *childWidget = dynamic_cast<GxsForumThreadWidget*>(ui.threadTabWidget->widget(index));
|
|
||||||
if (childWidget && childWidget->forumId() == id.toStdString()) {
|
|
||||||
threadWidget = childWidget;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!threadWidget) {
|
if (!threadWidget) {
|
||||||
/* create a thread widget */
|
/* create a thread widget */
|
||||||
threadWidget = new GxsForumThreadWidget(id.toStdString());
|
threadWidget = new GxsForumThreadWidget(id.toStdString());
|
||||||
int index = ui.threadTabWidget->addTab(threadWidget, threadWidget->forumName());
|
int index = ui.threadTabWidget->addTab(threadWidget, threadWidget->forumName(true));
|
||||||
ui.threadTabWidget->setTabIcon(index, threadWidget->forumIcon());
|
ui.threadTabWidget->setTabIcon(index, threadWidget->forumIcon());
|
||||||
connect(threadWidget, SIGNAL(forumChanged(QWidget*)), this, SLOT(threadTabChanged(QWidget*)));
|
connect(threadWidget, SIGNAL(forumChanged(QWidget*)), this, SLOT(threadTabChanged(QWidget*)));
|
||||||
}
|
}
|
||||||
|
@ -370,33 +374,10 @@ void GxsForumsDialog::threadTabChanged(QWidget *widget)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ui.threadTabWidget->setTabText(index, threadWidget->forumName());
|
ui.threadTabWidget->setTabText(index, threadWidget->forumName(true));
|
||||||
ui.threadTabWidget->setTabIcon(index, threadWidget->forumIcon());
|
ui.threadTabWidget->setTabIcon(index, threadWidget->forumIcon());
|
||||||
}
|
}
|
||||||
|
|
||||||
QString GxsForumsDialog::titleFromInfo(const RsMsgMetaData &meta)
|
|
||||||
{
|
|
||||||
// NOTE - NOTE SURE HOW THIS WILL WORK!
|
|
||||||
#ifdef TOGXS
|
|
||||||
if (meta.mMsgStatus & RS_DISTRIB_MISSING_MSG) {
|
|
||||||
return QApplication::translate("GxsForumsDialog", "[ ... Missing Message ... ]");
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return QString::fromUtf8(meta.mMsgName.c_str());
|
|
||||||
}
|
|
||||||
|
|
||||||
QString GxsForumsDialog::messageFromInfo(const RsGxsForumMsg &msg)
|
|
||||||
{
|
|
||||||
#ifdef TOGXS
|
|
||||||
if (msg.mMeta.mMsgStatus & RS_DISTRIB_MISSING_MSG) {
|
|
||||||
return QApplication::translate("GxsForumsDialog", "Placeholder for missing Message");
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return QString::fromUtf8(msg.mMsg.c_str());
|
|
||||||
}
|
|
||||||
|
|
||||||
void GxsForumsDialog::copyForumLink()
|
void GxsForumsDialog::copyForumLink()
|
||||||
{
|
{
|
||||||
if (mForumId.empty()) {
|
if (mForumId.empty()) {
|
||||||
|
@ -422,6 +403,22 @@ void GxsForumsDialog::copyForumLink()
|
||||||
QMessageBox::warning(this, "RetroShare", "ToDo");
|
QMessageBox::warning(this, "RetroShare", "ToDo");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GxsForumsDialog::markMsgAsRead()
|
||||||
|
{
|
||||||
|
GxsForumThreadWidget *threadWidget = forumThreadWidget(mForumId);
|
||||||
|
if (threadWidget) {
|
||||||
|
threadWidget->setAllMsgReadStatus(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void GxsForumsDialog::markMsgAsUnread()
|
||||||
|
{
|
||||||
|
GxsForumThreadWidget *threadWidget = forumThreadWidget(mForumId);
|
||||||
|
if (threadWidget) {
|
||||||
|
threadWidget->setAllMsgReadStatus(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void GxsForumsDialog::newforum()
|
void GxsForumsDialog::newforum()
|
||||||
{
|
{
|
||||||
GxsForumGroupDialog cf(mForumQueue, this);
|
GxsForumGroupDialog cf(mForumQueue, this);
|
||||||
|
@ -597,8 +594,8 @@ void GxsForumsDialog::generateMassData()
|
||||||
/** Request / Response of Data ********************************/
|
/** Request / Response of Data ********************************/
|
||||||
/*********************** **** **** **** ***********************/
|
/*********************** **** **** **** ***********************/
|
||||||
|
|
||||||
#define FORUMSV2DIALOG_LISTING 1
|
#define TOKEN_TYPE_LISTING 1
|
||||||
//#define FORUMSV2DIALOG_CURRENTFORUM 2
|
//#define TOKEN_TYPE_CURRENTFORUM 2
|
||||||
|
|
||||||
void GxsForumsDialog::insertForums()
|
void GxsForumsDialog::insertForums()
|
||||||
{
|
{
|
||||||
|
@ -610,20 +607,23 @@ void GxsForumsDialog::requestGroupSummary()
|
||||||
std::cerr << "GxsForumsDialog::requestGroupSummary()";
|
std::cerr << "GxsForumsDialog::requestGroupSummary()";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
|
||||||
if (mRequestGroupSummary) {
|
std::list<uint32_t> tokens;
|
||||||
std::cerr << "GxsForumsDialog::requestGroupSummary() Canceling Request: " << mTokenGroupSummary;
|
mForumQueue->activeRequestTokens(TOKEN_TYPE_LISTING, tokens);
|
||||||
std::cerr << std::endl;
|
if (!tokens.empty()) {
|
||||||
|
std::list<uint32_t>::iterator tokenIt;
|
||||||
|
for (tokenIt = tokens.begin(); tokenIt != tokens.end(); ++tokenIt) {
|
||||||
|
std::cerr << "GxsForumsDialog::requestGroupSummary() Canceling Request: " << *tokenIt;
|
||||||
|
std::cerr << std::endl;
|
||||||
|
|
||||||
mForumQueue->cancelRequest(mTokenGroupSummary);
|
mForumQueue->cancelRequest(*tokenIt);
|
||||||
mTokenGroupSummary = 0;
|
}
|
||||||
mRequestGroupSummary = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RsTokReqOptions opts;
|
RsTokReqOptions opts;
|
||||||
opts.mReqType = GXS_REQUEST_TYPE_GROUP_META;
|
opts.mReqType = GXS_REQUEST_TYPE_GROUP_META;
|
||||||
|
|
||||||
mForumQueue->requestGroupInfo(mTokenGroupSummary, RS_TOKREQ_ANSTYPE_SUMMARY, opts, FORUMSV2DIALOG_LISTING);
|
uint32_t token;
|
||||||
mRequestGroupSummary = true;
|
mForumQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_SUMMARY, opts, TOKEN_TYPE_LISTING);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GxsForumsDialog::loadGroupSummary(const uint32_t &token)
|
void GxsForumsDialog::loadGroupSummary(const uint32_t &token)
|
||||||
|
@ -631,18 +631,6 @@ void GxsForumsDialog::loadGroupSummary(const uint32_t &token)
|
||||||
std::cerr << "GxsForumsDialog::loadGroupSummary()";
|
std::cerr << "GxsForumsDialog::loadGroupSummary()";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
|
||||||
if (!mRequestGroupSummary) {
|
|
||||||
std::cerr << "GxsForumsDialog::loadGroupSummary()) No waiting request got token: " << token;
|
|
||||||
std::cerr << std::endl;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (token != mTokenGroupSummary) {
|
|
||||||
std::cerr << "GxsForumsDialog::loadGroupSummary()) Wrong token - want: " << mTokenGroupSummary << " got: " << token;
|
|
||||||
std::cerr << std::endl;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::list<RsGroupMetaData> groupInfo;
|
std::list<RsGroupMetaData> groupInfo;
|
||||||
rsGxsForums->getGroupSummary(token, groupInfo);
|
rsGxsForums->getGroupSummary(token, groupInfo);
|
||||||
|
|
||||||
|
@ -655,8 +643,6 @@ void GxsForumsDialog::loadGroupSummary(const uint32_t &token)
|
||||||
std::cerr << "GxsForumsDialog::loadGroupSummary() ERROR No Groups...";
|
std::cerr << "GxsForumsDialog::loadGroupSummary() ERROR No Groups...";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
}
|
}
|
||||||
mTokenGroupSummary = 0;
|
|
||||||
mRequestGroupSummary = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*********************** **** **** **** ***********************/
|
/*********************** **** **** **** ***********************/
|
||||||
|
@ -674,7 +660,7 @@ void GxsForumsDialog::loadGroupSummary(const uint32_t &token)
|
||||||
// std::cerr << std::endl;
|
// std::cerr << std::endl;
|
||||||
|
|
||||||
// uint32_t token;
|
// uint32_t token;
|
||||||
// mForumQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_SUMMARY, opts, grpIds, FORUMSV2DIALOG_CURRENTFORUM);
|
// mForumQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_SUMMARY, opts, grpIds, TOKEN_TYPE_CURRENTFORUM);
|
||||||
//}
|
//}
|
||||||
|
|
||||||
//void GxsForumsDialog::loadGroupSummary_CurrentForum(const uint32_t &token)
|
//void GxsForumsDialog::loadGroupSummary_CurrentForum(const uint32_t &token)
|
||||||
|
@ -713,11 +699,11 @@ void GxsForumsDialog::loadRequest(const TokenQueue *queue, const TokenRequest &r
|
||||||
/* now switch on req */
|
/* now switch on req */
|
||||||
switch(req.mUserType)
|
switch(req.mUserType)
|
||||||
{
|
{
|
||||||
case FORUMSV2DIALOG_LISTING:
|
case TOKEN_TYPE_LISTING:
|
||||||
loadGroupSummary(req.mToken);
|
loadGroupSummary(req.mToken);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// case FORUMSV2DIALOG_CURRENTFORUM:
|
// case TOKEN_TYPE_CURRENTFORUM:
|
||||||
// loadGroupSummary_CurrentForum(req.mToken);
|
// loadGroupSummary_CurrentForum(req.mToken);
|
||||||
// break;
|
// break;
|
||||||
|
|
||||||
|
|
|
@ -36,6 +36,7 @@
|
||||||
|
|
||||||
class ForumInfo;
|
class ForumInfo;
|
||||||
class RsGxsForumMsg;
|
class RsGxsForumMsg;
|
||||||
|
class GxsForumThreadWidget;
|
||||||
|
|
||||||
class GxsForumsDialog : public RsAutoUpdatePage, public TokenResponse
|
class GxsForumsDialog : public RsAutoUpdatePage, public TokenResponse
|
||||||
{
|
{
|
||||||
|
@ -55,10 +56,6 @@ public:
|
||||||
// Callback for all Loads.
|
// Callback for all Loads.
|
||||||
virtual void loadRequest(const TokenQueue *queue, const TokenRequest &req);
|
virtual void loadRequest(const TokenQueue *queue, const TokenRequest &req);
|
||||||
|
|
||||||
// Utility Fns.
|
|
||||||
static QString titleFromInfo(const RsMsgMetaData &meta);
|
|
||||||
static QString messageFromInfo(const RsGxsForumMsg &msg);
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void forceUpdateDisplay(); // TEMP HACK FN.
|
void forceUpdateDisplay(); // TEMP HACK FN.
|
||||||
|
|
||||||
|
@ -80,6 +77,9 @@ private slots:
|
||||||
void showForumDetails();
|
void showForumDetails();
|
||||||
void editForumDetails();
|
void editForumDetails();
|
||||||
|
|
||||||
|
void markMsgAsRead();
|
||||||
|
void markMsgAsUnread();
|
||||||
|
|
||||||
void generateMassData();
|
void generateMassData();
|
||||||
|
|
||||||
void shareKey();
|
void shareKey();
|
||||||
|
@ -101,13 +101,13 @@ private:
|
||||||
void requestGroupSummary();
|
void requestGroupSummary();
|
||||||
void loadGroupSummary(const uint32_t &token);
|
void loadGroupSummary(const uint32_t &token);
|
||||||
|
|
||||||
|
GxsForumThreadWidget *forumThreadWidget(const std::string &id);
|
||||||
|
|
||||||
// void requestGroupSummary_CurrentForum(const std::string &forumId);
|
// void requestGroupSummary_CurrentForum(const std::string &forumId);
|
||||||
// void loadGroupSummary_CurrentForum(const uint32_t &token);
|
// void loadGroupSummary_CurrentForum(const uint32_t &token);
|
||||||
|
|
||||||
std::string mForumId;
|
std::string mForumId;
|
||||||
TokenQueue *mForumQueue;
|
TokenQueue *mForumQueue;
|
||||||
uint32_t mTokenGroupSummary;
|
|
||||||
bool mRequestGroupSummary;
|
|
||||||
|
|
||||||
QTreeWidgetItem *yourForums;
|
QTreeWidgetItem *yourForums;
|
||||||
QTreeWidgetItem *subscribedForums;
|
QTreeWidgetItem *subscribedForums;
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -6,38 +6,14 @@
|
||||||
#include "util/TokenQueue.h"
|
#include "util/TokenQueue.h"
|
||||||
|
|
||||||
class QTreeWidgetItem;
|
class QTreeWidgetItem;
|
||||||
class GxsIdTreeWidgetItem;
|
|
||||||
class RSTreeWidgetItemCompareRole;
|
class RSTreeWidgetItemCompareRole;
|
||||||
class RsGxsForumMsg;
|
class RsGxsForumMsg;
|
||||||
|
class GxsForumsFillThread;
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class GxsForumThreadWidget;
|
class GxsForumThreadWidget;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* These are all the parameters that are required for thread loading.
|
|
||||||
* They are kept static for the load duration.
|
|
||||||
*/
|
|
||||||
|
|
||||||
class GxsForumsThreadLoadParameters
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
std::string ForumId;
|
|
||||||
std::string FocusMsgId;
|
|
||||||
|
|
||||||
uint32_t SubscribeFlags;
|
|
||||||
int ViewType;
|
|
||||||
uint32_t FilterColumn;
|
|
||||||
|
|
||||||
std::map<uint32_t, QTreeWidgetItem *> MsgTokens;
|
|
||||||
QList<QTreeWidgetItem*> Items;
|
|
||||||
QList<QTreeWidgetItem*> ItemToExpand;
|
|
||||||
|
|
||||||
bool FillComplete;
|
|
||||||
bool FlatView;
|
|
||||||
bool UseChildTS;
|
|
||||||
bool ExpandNewMessages;
|
|
||||||
};
|
|
||||||
|
|
||||||
class GxsForumThreadWidget : public QWidget, public TokenResponse
|
class GxsForumThreadWidget : public QWidget, public TokenResponse
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -65,8 +41,15 @@ public:
|
||||||
void setTextColorMissing(QColor color) { mTextColorMissing = color; }
|
void setTextColorMissing(QColor color) { mTextColorMissing = color; }
|
||||||
|
|
||||||
std::string forumId() { return mForumId; }
|
std::string forumId() { return mForumId; }
|
||||||
QString forumName();
|
QString forumName(bool withUnreadCount);
|
||||||
QIcon forumIcon();
|
QIcon forumIcon();
|
||||||
|
unsigned int newCount() { return mNewCount; }
|
||||||
|
unsigned int unreadCount() { return mUnreadCount; }
|
||||||
|
|
||||||
|
QTreeWidgetItem *convertMsgToThreadWidget(const RsGxsForumMsg &msg, bool useChildTS, uint32_t filterColumn);
|
||||||
|
QTreeWidgetItem *generateMissingItem(const std::string &msgId);
|
||||||
|
|
||||||
|
void setAllMsgReadStatus(bool read);
|
||||||
|
|
||||||
// Callback for all Loads.
|
// Callback for all Loads.
|
||||||
virtual void loadRequest(const TokenQueue *queue, const TokenRequest &req);
|
virtual void loadRequest(const TokenQueue *queue, const TokenRequest &req);
|
||||||
|
@ -98,9 +81,7 @@ private slots:
|
||||||
//void removemessage();
|
//void removemessage();
|
||||||
void markMsgAsRead();
|
void markMsgAsRead();
|
||||||
void markMsgAsReadChildren();
|
void markMsgAsReadChildren();
|
||||||
void markMsgAsReadAll();
|
|
||||||
void markMsgAsUnread();
|
void markMsgAsUnread();
|
||||||
void markMsgAsUnreadAll();
|
|
||||||
void markMsgAsUnreadChildren();
|
void markMsgAsUnreadChildren();
|
||||||
|
|
||||||
void copyMessageLink();
|
void copyMessageLink();
|
||||||
|
@ -122,7 +103,8 @@ private slots:
|
||||||
void filterItems(const QString &text);
|
void filterItems(const QString &text);
|
||||||
|
|
||||||
void fillThreadFinished();
|
void fillThreadFinished();
|
||||||
// void fillThreadProgress(int current, int count);
|
void fillThreadProgress(int current, int count);
|
||||||
|
void fillThreadStatus(QString text);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void insertForumThreads(const RsGroupMetaData &fi);
|
void insertForumThreads(const RsGroupMetaData &fi);
|
||||||
|
@ -141,6 +123,7 @@ private:
|
||||||
void markMsgAsReadUnread(bool read, bool children, bool forum);
|
void markMsgAsReadUnread(bool read, bool children, bool forum);
|
||||||
void calculateIconsAndFonts(QTreeWidgetItem *item = NULL);
|
void calculateIconsAndFonts(QTreeWidgetItem *item = NULL);
|
||||||
void calculateIconsAndFonts(QTreeWidgetItem *item, bool &hasReadChilddren, bool &hasUnreadChilddren);
|
void calculateIconsAndFonts(QTreeWidgetItem *item, bool &hasReadChilddren, bool &hasUnreadChilddren);
|
||||||
|
void calculateUnreadCount();
|
||||||
|
|
||||||
void togglethreadview_internal();
|
void togglethreadview_internal();
|
||||||
|
|
||||||
|
@ -159,35 +142,19 @@ private:
|
||||||
int mLastViewType;
|
int mLastViewType;
|
||||||
RSTreeWidgetItemCompareRole *mThreadCompareRole;
|
RSTreeWidgetItemCompareRole *mThreadCompareRole;
|
||||||
TokenQueue *mThreadQueue;
|
TokenQueue *mThreadQueue;
|
||||||
uint32_t mTokenGroupSummary;
|
|
||||||
uint32_t mTokenPost;
|
|
||||||
bool mRequestGroupSummary;
|
|
||||||
// QTimer *mTimer;
|
// QTimer *mTimer;
|
||||||
|
GxsForumsFillThread *mFillThread;
|
||||||
|
unsigned int mUnreadCount;
|
||||||
|
unsigned int mNewCount;
|
||||||
|
|
||||||
void requestGroupSummary_CurrentForum(const std::string &forumId);
|
void requestGroupSummary_CurrentForum(const std::string &forumId);
|
||||||
void loadGroupSummary_CurrentForum(const uint32_t &token);
|
void loadGroupSummary_CurrentForum(const uint32_t &token);
|
||||||
|
|
||||||
void loadCurrentForumThreads(const std::string &forumId);
|
|
||||||
void requestGroupThreadData_InsertThreads(const std::string &forumId);
|
|
||||||
void loadGroupThreadData_InsertThreads(const uint32_t &token);
|
|
||||||
void loadForumBaseThread(const RsGxsForumMsg &msg);
|
|
||||||
|
|
||||||
void requestChildData_InsertThreads(uint32_t &token, const RsGxsGrpMsgIdPair &parentId);
|
|
||||||
void loadChildData_InsertThreads(const uint32_t &token);
|
|
||||||
void loadForumChildMsg(const RsGxsForumMsg &msg, QTreeWidgetItem *parent);
|
|
||||||
|
|
||||||
void requestMsgData_InsertPost(const RsGxsGrpMsgIdPair &msgId);
|
void requestMsgData_InsertPost(const RsGxsGrpMsgIdPair &msgId);
|
||||||
void loadMsgData_InsertPost(const uint32_t &token);
|
void loadMsgData_InsertPost(const uint32_t &token);
|
||||||
void requestMsgData_ReplyMessage(const RsGxsGrpMsgIdPair &msgId);
|
void requestMsgData_ReplyMessage(const RsGxsGrpMsgIdPair &msgId);
|
||||||
void loadMsgData_ReplyMessage(const uint32_t &token);
|
void loadMsgData_ReplyMessage(const uint32_t &token);
|
||||||
|
|
||||||
bool convertMsgToThreadWidget(const RsGxsForumMsg &msgInfo, bool useChildTS, uint32_t filterColumn, GxsIdTreeWidgetItem *item);
|
|
||||||
// bool convertMsgToThreadWidget(const RsGxsForumMsg &msgInfo, std::string authorName, bool useChildTS, uint32_t filterColumn, QTreeWidgetItem *item);
|
|
||||||
|
|
||||||
// New Datatypes to replace the FillThread.
|
|
||||||
bool mThreadLoading;
|
|
||||||
GxsForumsThreadLoadParameters mThreadLoad;
|
|
||||||
|
|
||||||
/* Color definitions (for standard see qss.default) */
|
/* Color definitions (for standard see qss.default) */
|
||||||
QColor mTextColorRead;
|
QColor mTextColorRead;
|
||||||
QColor mTextColorUnread;
|
QColor mTextColorUnread;
|
||||||
|
|
|
@ -193,12 +193,12 @@
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="progressBarLayOut">
|
<layout class="QHBoxLayout" name="progressBarLayout">
|
||||||
<property name="leftMargin">
|
<property name="leftMargin">
|
||||||
<number>3</number>
|
<number>3</number>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="progLayOutTxt">
|
<widget class="QLabel" name="progressText">
|
||||||
<property name="font">
|
<property name="font">
|
||||||
<font>
|
<font>
|
||||||
<pointsize>10</pointsize>
|
<pointsize>10</pointsize>
|
||||||
|
|
260
retroshare-gui/src/gui/gxsforums/GxsForumsFillThread.cpp
Normal file
260
retroshare-gui/src/gui/gxsforums/GxsForumsFillThread.cpp
Normal file
|
@ -0,0 +1,260 @@
|
||||||
|
/****************************************************************
|
||||||
|
* RetroShare is distributed under the following license:
|
||||||
|
*
|
||||||
|
* Copyright (C) 2012, RetroShare Team
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||||
|
* Boston, MA 02110-1301, USA.
|
||||||
|
****************************************************************/
|
||||||
|
|
||||||
|
#include <QApplication>
|
||||||
|
#include <QTreeWidgetItem>
|
||||||
|
|
||||||
|
#include "GxsForumsFillThread.h"
|
||||||
|
#include "GxsForumThreadWidget.h"
|
||||||
|
|
||||||
|
#include <retroshare/rsgxsforums.h>
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
#define DEBUG_FORUMS
|
||||||
|
|
||||||
|
GxsForumsFillThread::GxsForumsFillThread(GxsForumThreadWidget *parent)
|
||||||
|
: QThread(parent), mParent(parent)
|
||||||
|
{
|
||||||
|
mStopped = false;
|
||||||
|
mCompareRole = NULL;
|
||||||
|
|
||||||
|
mExpandNewMessages = true;
|
||||||
|
mFillComplete = false;
|
||||||
|
|
||||||
|
mFilterColumn = 0;
|
||||||
|
mSubscribeFlags = 0;
|
||||||
|
|
||||||
|
mViewType = 0;
|
||||||
|
mFlatView = false;
|
||||||
|
mUseChildTS = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
GxsForumsFillThread::~GxsForumsFillThread()
|
||||||
|
{
|
||||||
|
#ifdef DEBUG_FORUMS
|
||||||
|
std::cerr << "GxsForumsFillThread::~GxsForumsFillThread" << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// remove all items (when items are available, the thread was terminated)
|
||||||
|
QList<QTreeWidgetItem *>::iterator item;
|
||||||
|
for (item = mItems.begin (); item != mItems.end (); item++) {
|
||||||
|
if (*item) {
|
||||||
|
delete (*item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mItems.clear();
|
||||||
|
|
||||||
|
mItemToExpand.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void GxsForumsFillThread::stop()
|
||||||
|
{
|
||||||
|
disconnect();
|
||||||
|
mStopped = true;
|
||||||
|
QApplication::processEvents();
|
||||||
|
wait();
|
||||||
|
}
|
||||||
|
|
||||||
|
void GxsForumsFillThread::run()
|
||||||
|
{
|
||||||
|
RsTokenService *service = rsGxsForums->getTokenService();
|
||||||
|
|
||||||
|
emit status(tr("Waiting"));
|
||||||
|
|
||||||
|
/* get all messages of the forum */
|
||||||
|
RsTokReqOptions opts;
|
||||||
|
opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA;
|
||||||
|
opts.mOptions = RS_TOKREQOPT_MSG_LATEST;
|
||||||
|
|
||||||
|
std::list<std::string> grpIds;
|
||||||
|
grpIds.push_back(mForumId);
|
||||||
|
|
||||||
|
#ifdef DEBUG_FORUMS
|
||||||
|
std::cerr << "GxsForumsFillThread::run() forum id " << mForumId << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
uint32_t token;
|
||||||
|
service->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, grpIds);
|
||||||
|
|
||||||
|
/* wait for the answer */
|
||||||
|
uint32_t requestStatus;
|
||||||
|
while (!wasStopped()) {
|
||||||
|
requestStatus = service->requestStatus(token);
|
||||||
|
if (requestStatus == RsTokenService::GXS_REQUEST_V2_STATUS_FAILED ||
|
||||||
|
requestStatus == RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
msleep(100);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (wasStopped()) {
|
||||||
|
#ifdef DEBUG_FORUMS
|
||||||
|
std::cerr << "GxsForumsFillThread::run() thread stopped, cancel request" << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* cancel request */
|
||||||
|
service->cancelRequest(token);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (requestStatus == RsTokenService::GXS_REQUEST_V2_STATUS_FAILED) {
|
||||||
|
//#TODO
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//#TODO
|
||||||
|
// if (failed) {
|
||||||
|
// mService->cancelRequest(token);
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
|
||||||
|
emit status(tr("Retrieving"));
|
||||||
|
|
||||||
|
/* get messages */
|
||||||
|
std::vector<RsGxsForumMsg> msgs;
|
||||||
|
if (!rsGxsForums->getMsgData(token, msgs)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
emit status(tr("Loading"));
|
||||||
|
|
||||||
|
int count = msgs.size();
|
||||||
|
int pos = 0;
|
||||||
|
QList<QPair<std::string, QTreeWidgetItem*> > threadList;
|
||||||
|
QPair<std::string, QTreeWidgetItem*> threadPair;
|
||||||
|
|
||||||
|
/* add all threads */
|
||||||
|
std::vector<RsGxsForumMsg>::iterator msgIt;
|
||||||
|
for (msgIt = msgs.begin(); msgIt != msgs.end(); ) {
|
||||||
|
if (wasStopped()) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
const RsGxsForumMsg &msg = *msgIt;
|
||||||
|
|
||||||
|
if (!msg.mMeta.mParentId.empty()) {
|
||||||
|
++msgIt;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef DEBUG_FORUMS
|
||||||
|
std::cerr << "GxsForumsFillThread::run() Adding TopLevel Thread: mId: " << msg.mMeta.mMsgId << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
QTreeWidgetItem *item = mParent->convertMsgToThreadWidget(msg, mUseChildTS, mFilterColumn);
|
||||||
|
threadList.push_back(QPair<std::string, QTreeWidgetItem*>(msg.mMeta.mMsgId, item));
|
||||||
|
|
||||||
|
mItems.append(item);
|
||||||
|
emit progress(++pos, count);
|
||||||
|
|
||||||
|
msgIt = msgs.erase(msgIt);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* process messages */
|
||||||
|
while (msgs.size()) {
|
||||||
|
while (threadList.size() > 0) {
|
||||||
|
if (wasStopped()) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
threadPair = threadList.front();
|
||||||
|
threadList.pop_front();
|
||||||
|
|
||||||
|
#ifdef DEBUG_FORUMS
|
||||||
|
std::cerr << "GxsForumsFillThread::run() Getting Children of : " << threadPair.first << std::endl;
|
||||||
|
#endif
|
||||||
|
/* iterate through child */
|
||||||
|
for (msgIt = msgs.begin(); msgIt != msgs.end(); ) {
|
||||||
|
const RsGxsForumMsg &msg = *msgIt;
|
||||||
|
|
||||||
|
if (msg.mMeta.mParentId != threadPair.first) {
|
||||||
|
++msgIt;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef DEBUG_FORUMS
|
||||||
|
std::cerr << "GxsForumsFillThread::run() adding " << msg.mMeta.mMsgId << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
QTreeWidgetItem *item = mParent->convertMsgToThreadWidget(msg, mUseChildTS, mFilterColumn);
|
||||||
|
if (mFlatView) {
|
||||||
|
mItems.append(item);
|
||||||
|
} else {
|
||||||
|
threadPair.second->addChild(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* add item to process list */
|
||||||
|
threadList.push_back(QPair<std::string, QTreeWidgetItem*>(msg.mMeta.mMsgId, item));
|
||||||
|
|
||||||
|
emit progress(++pos, count);
|
||||||
|
msgIt = msgs.erase(msgIt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (wasStopped()) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* process missing messages */
|
||||||
|
|
||||||
|
/* search for a message with missing parent */
|
||||||
|
for (msgIt = msgs.begin(); msgIt != msgs.end(); ++msgIt) {
|
||||||
|
const RsGxsForumMsg &msg = *msgIt;
|
||||||
|
|
||||||
|
/* search for parent */
|
||||||
|
std::vector<RsGxsForumMsg>::iterator msgIt1;
|
||||||
|
for (msgIt1 = msgs.begin(); msgIt1 != msgs.end(); ++msgIt1) {
|
||||||
|
if (wasStopped()) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
const RsGxsForumMsg &msg1 = *msgIt1;
|
||||||
|
|
||||||
|
if (msg.mMeta.mParentId == msg1.mMeta.mMsgId) {
|
||||||
|
/* found parent */
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (wasStopped()) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (msgIt1 != msgs.end()) {
|
||||||
|
/* parant found */
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* add dummy item */
|
||||||
|
QTreeWidgetItem *item = mParent->generateMissingItem(msg.mMeta.mParentId);
|
||||||
|
threadList.push_back(QPair<std::string, QTreeWidgetItem*>(msg.mMeta.mParentId, item));
|
||||||
|
|
||||||
|
mItems.append(item);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef DEBUG_FORUMS
|
||||||
|
std::cerr << "GxsForumsFillThread::run() stopped: " << (wasStopped() ? "yes" : "no") << std::endl;
|
||||||
|
#endif
|
||||||
|
}
|
46
retroshare-gui/src/gui/gxsforums/GxsForumsFillThread.h
Normal file
46
retroshare-gui/src/gui/gxsforums/GxsForumsFillThread.h
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
#ifndef GXSFORUMSFILLTHREAD_H
|
||||||
|
#define GXSFORUMSFILLTHREAD_H
|
||||||
|
|
||||||
|
#include <QThread>
|
||||||
|
|
||||||
|
class GxsForumThreadWidget;
|
||||||
|
class RSTreeWidgetItemCompareRole;
|
||||||
|
class QTreeWidgetItem;
|
||||||
|
|
||||||
|
class GxsForumsFillThread : public QThread
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
GxsForumsFillThread(GxsForumThreadWidget *parent);
|
||||||
|
~GxsForumsFillThread();
|
||||||
|
|
||||||
|
void run();
|
||||||
|
void stop();
|
||||||
|
bool wasStopped() { return mStopped; }
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void progress(int current, int count);
|
||||||
|
void status(QString text);
|
||||||
|
|
||||||
|
public:
|
||||||
|
std::string mForumId;
|
||||||
|
int mFilterColumn;
|
||||||
|
int mSubscribeFlags;
|
||||||
|
bool mFillComplete;
|
||||||
|
int mViewType;
|
||||||
|
bool mFlatView;
|
||||||
|
bool mUseChildTS;
|
||||||
|
bool mExpandNewMessages;
|
||||||
|
std::string mFocusMsgId;
|
||||||
|
RSTreeWidgetItemCompareRole *mCompareRole;
|
||||||
|
|
||||||
|
QList<QTreeWidgetItem*> mItems;
|
||||||
|
QList<QTreeWidgetItem*> mItemToExpand;
|
||||||
|
|
||||||
|
private:
|
||||||
|
GxsForumThreadWidget *mParent;
|
||||||
|
volatile bool mStopped;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // GXSFORUMSFILLTHREAD_H
|
Loading…
Add table
Add a link
Reference in a new issue