mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-25 23:49:35 -05:00
removed more token queue system from forums and comments
This commit is contained in:
parent
ac4b9b2971
commit
0488293a1f
@ -36,7 +36,7 @@ GxsCommentDialog::GxsCommentDialog(QWidget *parent, const RsGxsId &default_autho
|
||||
/* Invoke the Qt Designer generated QObject setup routine */
|
||||
ui->setupUi(this);
|
||||
|
||||
setTokenService(comment_service);
|
||||
setGxsService(comment_service);
|
||||
init(default_author);
|
||||
}
|
||||
|
||||
@ -67,7 +67,7 @@ void GxsCommentDialog::init(const RsGxsId& default_author)
|
||||
ui->sortBox->setIconSize(QSize(S*1.5,S*1.5));
|
||||
}
|
||||
|
||||
void GxsCommentDialog::setTokenService(RsGxsCommentService *comment_service)
|
||||
void GxsCommentDialog::setGxsService(RsGxsCommentService *comment_service)
|
||||
{
|
||||
ui->treeWidget->setup(comment_service);
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ public:
|
||||
GxsCommentDialog(QWidget *parent, const RsGxsId& default_author, RsGxsCommentService *comment_service);
|
||||
virtual ~GxsCommentDialog();
|
||||
|
||||
void setTokenService(RsGxsCommentService *comment_service);
|
||||
void setGxsService(RsGxsCommentService *comment_service);
|
||||
void setCommentHeader(QWidget *header);
|
||||
void commentLoad(const RsGxsGroupId &grpId, const std::set<RsGxsMessageId> &msg_versions, const RsGxsMessageId &most_recent_msgId, bool use_cache=false);
|
||||
void commentClear();
|
||||
|
@ -25,7 +25,6 @@
|
||||
#include <retroshare/rsidentity.h>
|
||||
|
||||
#include "retroshare/rsgxscommon.h"
|
||||
#include "util/TokenQueue.h"
|
||||
|
||||
namespace Ui {
|
||||
class GxsCreateCommentDialog;
|
||||
|
@ -52,11 +52,6 @@ protected:
|
||||
//virtual bool isLoading();
|
||||
//virtual void fillDisplay(RsGxsUpdateBroadcastBase *updateBroadcastBase, bool complete);
|
||||
|
||||
#ifdef TO_REMOVE
|
||||
/* TokenResponse */
|
||||
virtual void loadRequest(const TokenQueue *queue, const TokenRequest &req);
|
||||
#endif
|
||||
|
||||
protected slots:
|
||||
void comments(const QString &title);
|
||||
void copyMessageLink();
|
||||
|
@ -487,7 +487,7 @@ GxsChannelPostsWidgetWithModel::GxsChannelPostsWidgetWithModel(const RsGxsGroupI
|
||||
setAutoDownload(false);
|
||||
#endif
|
||||
|
||||
ui->commentsDialog->setTokenService(rsGxsChannels);
|
||||
ui->commentsDialog->setGxsService(rsGxsChannels);
|
||||
|
||||
/* Initialize GUI */
|
||||
settingsChanged();
|
||||
|
@ -39,6 +39,7 @@
|
||||
|
||||
#include "util/HandleRichText.h"
|
||||
#include "util/misc.h"
|
||||
#include "util/qtthreadsutils.h"
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <iostream>
|
||||
@ -60,10 +61,6 @@ CreateGxsForumMsg::CreateGxsForumMsg(const RsGxsGroupId &fId, const RsGxsMessage
|
||||
|
||||
setAttribute(Qt::WA_DeleteOnClose, true);
|
||||
|
||||
/* Setup Queue */
|
||||
mForumQueue = new TokenQueue(rsGxsForums->getTokenService(), this);
|
||||
mCirclesQueue = new TokenQueue(rsGxsCircles->getTokenService(), this);
|
||||
|
||||
/* Setup UI helper */
|
||||
mStateHelper = new UIStateHelper(this);
|
||||
mStateHelper->addWidget(CREATEGXSFORUMMSG_FORUMINFO, ui.postButton);
|
||||
@ -133,8 +130,6 @@ CreateGxsForumMsg::CreateGxsForumMsg(const RsGxsGroupId &fId, const RsGxsMessage
|
||||
CreateGxsForumMsg::~CreateGxsForumMsg()
|
||||
{
|
||||
processSettings(false);
|
||||
delete(mForumQueue);
|
||||
delete(mCirclesQueue);
|
||||
}
|
||||
|
||||
void CreateGxsForumMsg::processSettings(bool load)
|
||||
@ -194,59 +189,109 @@ void CreateGxsForumMsg::newMsg()
|
||||
return;
|
||||
}
|
||||
|
||||
{/* request Data */
|
||||
mStateHelper->setLoading(CREATEGXSFORUMMSG_FORUMINFO, true);
|
||||
|
||||
RsTokReqOptions opts;
|
||||
opts.mReqType = GXS_REQUEST_TYPE_GROUP_META;
|
||||
RsThread::async( [this]()
|
||||
{
|
||||
// We only need group Meta information, but forums do not provide it currently
|
||||
|
||||
std::list<RsGxsGroupId> groupIds;
|
||||
groupIds.push_back(mForumId);
|
||||
std::vector<RsGxsForumGroup> forums_info;
|
||||
rsGxsForums->getForumsInfo(std::list<RsGxsGroupId>{ mForumId },forums_info);
|
||||
|
||||
//std::cerr << "ForumsV2Dialog::newMsg() Requesting Group Summary(" << mForumId << ")"<< std::endl;
|
||||
|
||||
uint32_t token;
|
||||
mForumQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_SUMMARY, opts, groupIds, CREATEGXSFORUMMSG_FORUMINFO);
|
||||
}/* request Data */
|
||||
RsQThreadUtils::postToObject( [this,forums_info]()
|
||||
{
|
||||
if(forums_info.size() != 1)
|
||||
{
|
||||
RsErr() << "Cannot retrieve group information for forum " << mForumId ;
|
||||
mStateHelper->setActive(CREATEGXSFORUMMSG_FORUMINFO, false);
|
||||
mStateHelper->setLoading(CREATEGXSFORUMMSG_FORUMINFO, false);
|
||||
return;
|
||||
}
|
||||
auto fg(forums_info.front());
|
||||
|
||||
if (mParentId.isNull()) {
|
||||
const RsGroupMetaData& fi(fg.mMeta);
|
||||
mForumMetaLoaded = true;
|
||||
mForumMeta = fi;
|
||||
|
||||
if(!fi.mCircleId.isNull())
|
||||
loadCircleInfo(RsGxsGroupId(fi.mCircleId));
|
||||
|
||||
loadFormInformation();
|
||||
|
||||
mStateHelper->setActive(CREATEGXSFORUMMSG_FORUMINFO, false);
|
||||
mStateHelper->setLoading(CREATEGXSFORUMMSG_FORUMINFO, false);
|
||||
|
||||
},this);
|
||||
});
|
||||
|
||||
if (mParentId.isNull())
|
||||
{
|
||||
mStateHelper->setActive(CREATEGXSFORUMMSG_PARENTMSG, true);
|
||||
mParentMsgLoaded = true;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
mStateHelper->setLoading(CREATEGXSFORUMMSG_PARENTMSG, true);
|
||||
|
||||
RsTokReqOptions opts;
|
||||
opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA;
|
||||
RsThread::async( [this]() {
|
||||
|
||||
GxsMsgReq msgIds;
|
||||
std::set<RsGxsMessageId> &vect = msgIds[mForumId];
|
||||
vect.insert(mParentId);
|
||||
std::vector<RsGxsForumMsg> parent_msgs;
|
||||
rsGxsForums->getForumContent(mForumId,std::set<RsGxsMessageId>{ mParentId },parent_msgs);
|
||||
|
||||
//std::cerr << "ForumsV2Dialog::newMsg() Requesting Parent Summary(" << mParentId << ")";
|
||||
//std::cerr << std::endl;
|
||||
RsQThreadUtils::postToObject( [this,parent_msgs]() {
|
||||
if(parent_msgs.size() != 1)
|
||||
{
|
||||
RsErr() << "Cannot get parent message from forum." ;
|
||||
|
||||
uint32_t token;
|
||||
mForumQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgIds, CREATEGXSFORUMMSG_PARENTMSG);
|
||||
}
|
||||
mStateHelper->setActive(CREATEGXSFORUMMSG_PARENTMSG, false);
|
||||
mStateHelper->setLoading(CREATEGXSFORUMMSG_PARENTMSG, false);
|
||||
|
||||
if (mOrigMsgId.isNull()) {
|
||||
return ;
|
||||
}
|
||||
|
||||
mParentMsg = parent_msgs.front();
|
||||
mParentMsgLoaded = true;
|
||||
|
||||
loadFormInformation();
|
||||
|
||||
},this);
|
||||
});
|
||||
}
|
||||
|
||||
if (mOrigMsgId.isNull())
|
||||
{
|
||||
mStateHelper->setActive(CREATEGXSFORUMMSG_ORIGMSG, true);
|
||||
mOrigMsgLoaded = true;
|
||||
} else {
|
||||
mStateHelper->setLoading(CREATEGXSFORUMMSG_ORIGMSG, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
mStateHelper->setLoading(CREATEGXSFORUMMSG_ORIGMSG , true);
|
||||
|
||||
RsTokReqOptions opts;
|
||||
opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA;
|
||||
RsThread::async( [this]() {
|
||||
|
||||
GxsMsgReq msgIds;
|
||||
std::set<RsGxsMessageId> &vect = msgIds[mForumId];
|
||||
vect.insert(mOrigMsgId);
|
||||
std::vector<RsGxsForumMsg> orig_msgs;
|
||||
rsGxsForums->getForumContent(mForumId,std::set<RsGxsMessageId>{ mOrigMsgId },orig_msgs);
|
||||
|
||||
//std::cerr << "ForumsV2Dialog::newMsg() Requesting Parent Summary(" << mParentId << ")";
|
||||
//std::cerr << std::endl;
|
||||
RsQThreadUtils::postToObject( [this,orig_msgs]() {
|
||||
if(orig_msgs.size() != 1)
|
||||
{
|
||||
RsErr() << "Cannot get parent message from forum." ;
|
||||
|
||||
mStateHelper->setActive(CREATEGXSFORUMMSG_ORIGMSG, false);
|
||||
mStateHelper->setLoading(CREATEGXSFORUMMSG_ORIGMSG, false);
|
||||
|
||||
return ;
|
||||
}
|
||||
|
||||
mOrigMsg = orig_msgs.front();
|
||||
mOrigMsgLoaded = true;
|
||||
|
||||
loadFormInformation();
|
||||
|
||||
},this);
|
||||
});
|
||||
|
||||
uint32_t token;
|
||||
mForumQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgIds, CREATEGXSFORUMMSG_ORIGMSG);
|
||||
}
|
||||
}
|
||||
|
||||
@ -330,7 +375,7 @@ void CreateGxsForumMsg::loadFormInformation()
|
||||
else if (!mParentId.isNull())
|
||||
{
|
||||
QString title = QString::fromUtf8(mParentMsg.mMeta.mMsgName.c_str());
|
||||
name += " " + tr("In Reply to") + ": ";
|
||||
name += " - " + tr("In Reply to") + ": ";
|
||||
name += title;
|
||||
|
||||
QString text = title;
|
||||
@ -583,181 +628,52 @@ void CreateGxsForumMsg::fileHashingFinished(QList<HashedFile> hashedFiles)
|
||||
ui.hashGroupBox->hide();
|
||||
}
|
||||
|
||||
void CreateGxsForumMsg::loadForumInfo(const uint32_t &token)
|
||||
{
|
||||
//std::cerr << "CreateGxsForumMsg::loadForumInfo()";
|
||||
//std::cerr << std::endl;
|
||||
|
||||
std::list<RsGroupMetaData> groupInfo;
|
||||
rsGxsForums->getGroupSummary(token, groupInfo);
|
||||
|
||||
if (groupInfo.size() == 1)
|
||||
{
|
||||
RsGroupMetaData fi = groupInfo.front();
|
||||
|
||||
mForumMeta = fi;
|
||||
mForumMetaLoaded = true;
|
||||
|
||||
if(!fi.mCircleId.isNull())
|
||||
{
|
||||
//std::cerr << "Circle ID is not null: " << fi.mCircleId << ": loading circle info to add constraint to the GXS ID chooser." << std::endl;
|
||||
|
||||
RsTokReqOptions opts;
|
||||
opts.mReqType = GXS_REQUEST_TYPE_GROUP_DATA;
|
||||
|
||||
std::list<RsGxsGroupId> groupIds;
|
||||
groupIds.push_back(RsGxsGroupId(fi.mCircleId));
|
||||
uint32_t _token;
|
||||
|
||||
mCirclesQueue->requestGroupInfo(_token, RS_TOKREQ_ANSTYPE_DATA, opts, groupIds, CREATEGXSFORUMMSG_CIRCLENFO);
|
||||
}
|
||||
|
||||
loadFormInformation();
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "CreateGxsForumMsg::loadForumInfo() ERROR INVALID Number of Forums";
|
||||
std::cerr << std::endl;
|
||||
|
||||
mStateHelper->setActive(CREATEGXSFORUMMSG_FORUMINFO, false);
|
||||
mStateHelper->setLoading(CREATEGXSFORUMMSG_FORUMINFO, false);
|
||||
}
|
||||
}
|
||||
void CreateGxsForumMsg::loadForumCircleInfo(const uint32_t& token)
|
||||
void CreateGxsForumMsg::loadCircleInfo(const RsGxsGroupId& circle_id)
|
||||
{
|
||||
//std::cerr << "Loading forum circle info" << std::endl;
|
||||
|
||||
std::vector<RsGxsCircleGroup> circle_grp_v ;
|
||||
rsGxsCircles->getGroupData(token, circle_grp_v);
|
||||
|
||||
if (circle_grp_v.empty())
|
||||
RsThread::async( [circle_id,this]()
|
||||
{
|
||||
std::cerr << "(EE) unexpected empty result from getGroupData. Cannot process circle now!" << std::endl;
|
||||
return ;
|
||||
}
|
||||
|
||||
if (circle_grp_v.size() != 1)
|
||||
{
|
||||
std::cerr << "(EE) very weird result from getGroupData. Should get exactly one circle" << std::endl;
|
||||
return ;
|
||||
}
|
||||
|
||||
RsGxsCircleGroup cg = circle_grp_v.front();
|
||||
std::vector<RsGxsCircleGroup> circle_grp_v ;
|
||||
rsGxsCircles->getCirclesInfo(std::list<RsGxsGroupId>{ circle_id }, circle_grp_v);
|
||||
|
||||
mForumCircleData = cg;
|
||||
mForumCircleLoaded = true;
|
||||
|
||||
//std::cerr << "Loaded content of circle " << cg.mMeta.mGroupId << std::endl;
|
||||
|
||||
//for(std::set<RsGxsId>::const_iterator it(cg.mInvitedMembers.begin());it!=cg.mInvitedMembers.end();++it)
|
||||
// std::cerr << " added constraint to circle element " << *it << std::endl;
|
||||
|
||||
ui.idChooser->setIdConstraintSet(cg.mInvitedMembers) ;
|
||||
ui.idChooser->setFlags(IDCHOOSER_NO_CREATE | ui.idChooser->flags()) ; // since there's a circle involved, no ID creation can be needed
|
||||
|
||||
RsGxsId tmpid ;
|
||||
if(ui.idChooser->countEnabledEntries() == 0)
|
||||
{
|
||||
QMessageBox::information(NULL,tr("No compatible ID for this forum"),tr("None of your identities is allowed to post in this forum. This could be due to the forum being limited to a circle that contains none of your identities, or forum flags requiring a PGP-signed identity.")) ;
|
||||
close() ;
|
||||
}
|
||||
}
|
||||
|
||||
void CreateGxsForumMsg::loadOrigMsg(const uint32_t &token)
|
||||
{
|
||||
//std::cerr << "CreateGxsForumMsg::loadParentMsg()";
|
||||
//std::cerr << std::endl;
|
||||
|
||||
// Only grab one.... ignore more (shouldn't be any).
|
||||
std::vector<RsGxsForumMsg> msgs;
|
||||
if (rsGxsForums->getMsgData(token, msgs))
|
||||
{
|
||||
if (msgs.size() != 1)
|
||||
{
|
||||
/* error */
|
||||
std::cerr << "CreateGxsForumMsg::loadOrigMsg() ERROR wrong number of msgs";
|
||||
std::cerr << std::endl;
|
||||
|
||||
mStateHelper->setActive(CREATEGXSFORUMMSG_ORIGMSG, false);
|
||||
mStateHelper->setLoading(CREATEGXSFORUMMSG_ORIGMSG, false);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
mOrigMsg = msgs[0];
|
||||
mOrigMsgLoaded = true;
|
||||
|
||||
loadFormInformation();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CreateGxsForumMsg::loadParentMsg(const uint32_t &token)
|
||||
{
|
||||
//std::cerr << "CreateGxsForumMsg::loadParentMsg()";
|
||||
//std::cerr << std::endl;
|
||||
|
||||
// Only grab one.... ignore more (shouldn't be any).
|
||||
std::vector<RsGxsForumMsg> msgs;
|
||||
if (rsGxsForums->getMsgData(token, msgs))
|
||||
{
|
||||
if (msgs.size() != 1)
|
||||
{
|
||||
/* error */
|
||||
std::cerr << "CreateGxsForumMsg::loadParentMsg() ERROR wrong number of msgs";
|
||||
std::cerr << std::endl;
|
||||
|
||||
mStateHelper->setActive(CREATEGXSFORUMMSG_PARENTMSG, false);
|
||||
mStateHelper->setLoading(CREATEGXSFORUMMSG_PARENTMSG, false);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
mParentMsg = msgs[0];
|
||||
mParentMsgLoaded = true;
|
||||
|
||||
loadFormInformation();
|
||||
}
|
||||
}
|
||||
|
||||
void CreateGxsForumMsg::loadRequest(const TokenQueue *queue, const TokenRequest &req)
|
||||
{
|
||||
//std::cerr << "CreateGxsForum::loadRequest() UserType: " << req.mUserType;
|
||||
//std::cerr << std::endl;
|
||||
|
||||
if (queue == mForumQueue)
|
||||
{
|
||||
/* now switch on req */
|
||||
switch(req.mUserType)
|
||||
{
|
||||
case CREATEGXSFORUMMSG_FORUMINFO:
|
||||
loadForumInfo(req.mToken);
|
||||
break;
|
||||
case CREATEGXSFORUMMSG_ORIGMSG:
|
||||
loadOrigMsg(req.mToken);
|
||||
break;
|
||||
case CREATEGXSFORUMMSG_PARENTMSG:
|
||||
loadParentMsg(req.mToken);
|
||||
break;
|
||||
default:
|
||||
std::cerr << "CreateGxsForumMsg::loadRequest() UNKNOWN UserType " << req.mUserType << " for token request in mForumQueue";
|
||||
std::cerr << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
if(queue == mCirclesQueue)
|
||||
if (circle_grp_v.empty())
|
||||
{
|
||||
switch(req.mUserType)
|
||||
{
|
||||
case CREATEGXSFORUMMSG_CIRCLENFO:
|
||||
loadForumCircleInfo(req.mToken) ;
|
||||
break ;
|
||||
default:
|
||||
std::cerr << "CreateGxsForumMsg::loadRequest() UNKNOWN UserType " << req.mUserType << " for token request in mCirclesQueue";
|
||||
std::cerr << std::endl;
|
||||
}
|
||||
std::cerr << "(EE) unexpected empty result from getGroupData. Cannot process circle now!" << std::endl;
|
||||
return ;
|
||||
}
|
||||
|
||||
if (circle_grp_v.size() != 1)
|
||||
{
|
||||
std::cerr << "(EE) very weird result from getGroupData. Should get exactly one circle" << std::endl;
|
||||
return ;
|
||||
}
|
||||
|
||||
RsGxsCircleGroup cg = circle_grp_v.front();
|
||||
|
||||
RsQThreadUtils::postToObject( [cg,this]()
|
||||
{
|
||||
mForumCircleData = cg;
|
||||
mForumCircleLoaded = true;
|
||||
|
||||
//std::cerr << "Loaded content of circle " << cg.mMeta.mGroupId << std::endl;
|
||||
|
||||
//for(std::set<RsGxsId>::const_iterator it(cg.mInvitedMembers.begin());it!=cg.mInvitedMembers.end();++it)
|
||||
// std::cerr << " added constraint to circle element " << *it << std::endl;
|
||||
|
||||
ui.idChooser->setIdConstraintSet(cg.mInvitedMembers) ;
|
||||
ui.idChooser->setFlags(IDCHOOSER_NO_CREATE | ui.idChooser->flags()) ; // since there's a circle involved, no ID creation can be needed
|
||||
|
||||
RsGxsId tmpid ;
|
||||
if(ui.idChooser->countEnabledEntries() == 0)
|
||||
{
|
||||
QMessageBox::information(NULL,tr("No compatible ID for this forum"),tr("None of your identities is allowed to post in this forum. This could be due to the forum being limited to a circle that contains none of your identities, or forum flags requiring a PGP-signed identity.")) ;
|
||||
close() ;
|
||||
}
|
||||
}, this);
|
||||
});
|
||||
}
|
||||
|
||||
void CreateGxsForumMsg::setSubject(const QString& msg)
|
||||
{
|
||||
ui.forumSubject->setText(msg);
|
||||
|
@ -23,14 +23,12 @@
|
||||
|
||||
#include "ui_CreateGxsForumMsg.h"
|
||||
|
||||
#include "util/TokenQueue.h"
|
||||
|
||||
#include <retroshare/rsgxsforums.h>
|
||||
#include <retroshare/rsgxscircles.h>
|
||||
|
||||
class UIStateHelper;
|
||||
|
||||
class CreateGxsForumMsg : public QDialog, public TokenResponse
|
||||
class CreateGxsForumMsg : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@ -39,7 +37,6 @@ public:
|
||||
~CreateGxsForumMsg();
|
||||
|
||||
void newMsg(); /* cleanup */
|
||||
virtual void loadRequest(const TokenQueue *queue, const TokenRequest &req);
|
||||
void insertPastedText(const QString& msg) ;
|
||||
void setSubject(const QString& msg);
|
||||
|
||||
@ -58,15 +55,11 @@ private slots:
|
||||
protected:
|
||||
void closeEvent (QCloseEvent * event);
|
||||
|
||||
void loadCircleInfo(const RsGxsGroupId& circle_id);
|
||||
private:
|
||||
void processSettings(bool load);
|
||||
void loadFormInformation();
|
||||
|
||||
void loadForumInfo(const uint32_t &token);
|
||||
void loadParentMsg(const uint32_t &token);
|
||||
void loadOrigMsg(const uint32_t &token);
|
||||
void loadForumCircleInfo(const uint32_t &token);
|
||||
|
||||
RsGxsGroupId mForumId;
|
||||
RsGxsCircleId mCircleId ;
|
||||
RsGxsMessageId mParentId;
|
||||
@ -84,9 +77,6 @@ private:
|
||||
RsGroupMetaData mForumMeta;
|
||||
RsGxsCircleGroup mForumCircleData ;
|
||||
|
||||
TokenQueue *mForumQueue;
|
||||
TokenQueue *mCirclesQueue;
|
||||
|
||||
UIStateHelper *mStateHelper;
|
||||
|
||||
/** Qt Designer generated object */
|
||||
|
Loading…
Reference in New Issue
Block a user