mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-07 08:35:16 -04:00
Merge pull request #2623 from csoler/v0.6-TokenSystem
V0.6 token system
This commit is contained in:
commit
c280d030aa
34 changed files with 454 additions and 660 deletions
|
@ -1 +1 @@
|
||||||
Subproject commit 6abbec95073f3c1eb5059cbf8441111ef4a317a7
|
Subproject commit 659423769541169457c41f71c8a038e2d64ba079
|
|
@ -1 +1 @@
|
||||||
Subproject commit 72f8b7e8e240923731a141c6f2a0438588f04f59
|
Subproject commit 86745109f35dddbf9de9ff84537a1c97fa1d30b3
|
|
@ -25,6 +25,7 @@
|
||||||
#include "gui/Circles/CirclesDialog.h"
|
#include "gui/Circles/CirclesDialog.h"
|
||||||
#include "gui/Circles/CreateCircleDialog.h"
|
#include "gui/Circles/CreateCircleDialog.h"
|
||||||
#include "gui/common/UIStateHelper.h"
|
#include "gui/common/UIStateHelper.h"
|
||||||
|
#include "util/qtthreadsutils.h"
|
||||||
|
|
||||||
#include <retroshare/rsgxscircles.h>
|
#include <retroshare/rsgxscircles.h>
|
||||||
#include <retroshare/rspeers.h>
|
#include <retroshare/rspeers.h>
|
||||||
|
@ -72,9 +73,6 @@ CirclesDialog::CirclesDialog(QWidget *parent)
|
||||||
|
|
||||||
connect(ui.treeWidget_membership, SIGNAL(itemSelectionChanged()), this, SLOT(circle_selected()));
|
connect(ui.treeWidget_membership, SIGNAL(itemSelectionChanged()), this, SLOT(circle_selected()));
|
||||||
|
|
||||||
/* Setup TokenQueue */
|
|
||||||
mCircleQueue = new TokenQueue(rsGxsCircles->getTokenService(), this);
|
|
||||||
|
|
||||||
/* Set header resize modes and initial section sizes */
|
/* Set header resize modes and initial section sizes */
|
||||||
QHeaderView * membership_header = ui.treeWidget_membership->header () ;
|
QHeaderView * membership_header = ui.treeWidget_membership->header () ;
|
||||||
membership_header->resizeSection ( CIRCLEGROUP_CIRCLE_COL_GROUPNAME, 200 );
|
membership_header->resizeSection ( CIRCLEGROUP_CIRCLE_COL_GROUPNAME, 200 );
|
||||||
|
@ -82,7 +80,6 @@ CirclesDialog::CirclesDialog(QWidget *parent)
|
||||||
|
|
||||||
CirclesDialog::~CirclesDialog()
|
CirclesDialog::~CirclesDialog()
|
||||||
{
|
{
|
||||||
delete mCircleQueue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CirclesDialog::todo()
|
void CirclesDialog::todo()
|
||||||
|
@ -564,38 +561,36 @@ void CirclesDialog::requestGroupMeta()
|
||||||
{
|
{
|
||||||
mStateHelper->setLoading(CIRCLESDIALOG_GROUPMETA, true);
|
mStateHelper->setLoading(CIRCLESDIALOG_GROUPMETA, true);
|
||||||
|
|
||||||
std::cerr << "CirclesDialog::requestGroupMeta()";
|
RsThread::async([this]()
|
||||||
std::cerr << std::endl;
|
{
|
||||||
|
std::list<RsGroupMetaData> circles;
|
||||||
|
|
||||||
mCircleQueue->cancelActiveRequestTokens(CIRCLESDIALOG_GROUPMETA);
|
if(!rsGxsCircles->getCirclesSummaries(circles))
|
||||||
|
{
|
||||||
|
std::cerr << __PRETTY_FUNCTION__ << " failed to get circles summaries " << std::endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
RsTokReqOptions opts;
|
RsQThreadUtils::postToObject( [this,circles]()
|
||||||
opts.mReqType = GXS_REQUEST_TYPE_GROUP_META;
|
{
|
||||||
|
/* Here it goes any code you want to be executed on the Qt Gui
|
||||||
|
* thread, for example to update the data model with new information
|
||||||
|
* after a blocking call to RetroShare API complete, note that
|
||||||
|
* Qt::QueuedConnection is important!
|
||||||
|
*/
|
||||||
|
|
||||||
uint32_t token;
|
loadGroupMeta(circles);
|
||||||
mCircleQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_SUMMARY, opts, CIRCLESDIALOG_GROUPMETA);
|
|
||||||
|
}, this );
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void CirclesDialog::loadGroupMeta(const uint32_t &token)
|
void CirclesDialog::loadGroupMeta(const std::list<RsGroupMetaData>& groupInfo)
|
||||||
{
|
{
|
||||||
mStateHelper->setLoading(CIRCLESDIALOG_GROUPMETA, false);
|
mStateHelper->setLoading(CIRCLESDIALOG_GROUPMETA, false);
|
||||||
|
|
||||||
std::cerr << "CirclesDialog::loadGroupMeta()";
|
|
||||||
std::cerr << std::endl;
|
|
||||||
|
|
||||||
ui.treeWidget_membership->clear();
|
ui.treeWidget_membership->clear();
|
||||||
|
|
||||||
std::list<RsGroupMetaData> groupInfo;
|
|
||||||
std::list<RsGroupMetaData>::iterator vit;
|
|
||||||
|
|
||||||
if (!rsGxsCircles->getGroupSummary(token,groupInfo))
|
|
||||||
{
|
|
||||||
std::cerr << "CirclesDialog::loadGroupMeta() Error getting GroupMeta";
|
|
||||||
std::cerr << std::endl;
|
|
||||||
mStateHelper->setActive(CIRCLESDIALOG_GROUPMETA, false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
mStateHelper->setActive(CIRCLESDIALOG_GROUPMETA, true);
|
mStateHelper->setActive(CIRCLESDIALOG_GROUPMETA, true);
|
||||||
|
|
||||||
/* add the top level item */
|
/* add the top level item */
|
||||||
|
@ -615,7 +610,7 @@ void CirclesDialog::loadGroupMeta(const uint32_t &token)
|
||||||
externalOtherCirclesItem->setText(0, tr("External Circles (Other)"));
|
externalOtherCirclesItem->setText(0, tr("External Circles (Other)"));
|
||||||
ui.treeWidget_membership->addTopLevelItem(externalOtherCirclesItem);
|
ui.treeWidget_membership->addTopLevelItem(externalOtherCirclesItem);
|
||||||
|
|
||||||
for(vit = groupInfo.begin(); vit != groupInfo.end(); ++vit)
|
for(auto vit = groupInfo.begin(); vit != groupInfo.end(); ++vit)
|
||||||
{
|
{
|
||||||
/* Add Widget, and request Pages */
|
/* Add Widget, and request Pages */
|
||||||
std::cerr << "CirclesDialog::loadGroupMeta() GroupId: " << vit->mGroupId;
|
std::cerr << "CirclesDialog::loadGroupMeta() GroupId: " << vit->mGroupId;
|
||||||
|
@ -647,25 +642,3 @@ void CirclesDialog::loadGroupMeta(const uint32_t &token)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CirclesDialog::loadRequest(const TokenQueue *queue, const TokenRequest &req)
|
|
||||||
{
|
|
||||||
std::cerr << "CirclesDialog::loadRequest() UserType: " << req.mUserType;
|
|
||||||
std::cerr << std::endl;
|
|
||||||
|
|
||||||
if (queue == mCircleQueue)
|
|
||||||
{
|
|
||||||
/* now switch on req */
|
|
||||||
switch(req.mUserType)
|
|
||||||
{
|
|
||||||
case CIRCLESDIALOG_GROUPMETA:
|
|
||||||
loadGroupMeta(req.mToken);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
std::cerr << "CirclesDialog::loadRequest() ERROR: INVALID TYPE";
|
|
||||||
std::cerr << std::endl;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -24,14 +24,13 @@
|
||||||
#define MRK_CIRCLE_DIALOG_H
|
#define MRK_CIRCLE_DIALOG_H
|
||||||
|
|
||||||
#include "gui/gxs/RsGxsUpdateBroadcastPage.h"
|
#include "gui/gxs/RsGxsUpdateBroadcastPage.h"
|
||||||
#include "util/TokenQueue.h"
|
|
||||||
#include "ui_CirclesDialog.h"
|
#include "ui_CirclesDialog.h"
|
||||||
|
|
||||||
#define IMAGE_CIRCLES ":/icons/png/circles.png"
|
#define IMAGE_CIRCLES ":/icons/png/circles.png"
|
||||||
|
|
||||||
class UIStateHelper;
|
class UIStateHelper;
|
||||||
|
|
||||||
class CirclesDialog : public MainPage, public TokenResponse
|
class CirclesDialog : public MainPage
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
@ -43,8 +42,6 @@ public:
|
||||||
virtual QString pageName() const { return tr("Circles") ; } //MainPage
|
virtual QString pageName() const { return tr("Circles") ; } //MainPage
|
||||||
virtual QString helpText() const { return ""; } //MainPage
|
virtual QString helpText() const { return ""; } //MainPage
|
||||||
|
|
||||||
void loadRequest(const TokenQueue *queue, const TokenRequest &req);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void updateDisplay(bool complete);
|
virtual void updateDisplay(bool complete);
|
||||||
|
|
||||||
|
@ -62,9 +59,8 @@ private:
|
||||||
void reloadAll();
|
void reloadAll();
|
||||||
|
|
||||||
void requestGroupMeta();
|
void requestGroupMeta();
|
||||||
void loadGroupMeta(const uint32_t &token);
|
void loadGroupMeta(const std::list<RsGroupMetaData>& groupInfo);
|
||||||
|
|
||||||
TokenQueue *mCircleQueue;
|
|
||||||
UIStateHelper *mStateHelper;
|
UIStateHelper *mStateHelper;
|
||||||
|
|
||||||
/* UI - from Designer */
|
/* UI - from Designer */
|
||||||
|
|
|
@ -422,7 +422,7 @@ void CreateCircleDialog::createCircle()
|
||||||
close() ;
|
close() ;
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG_CREATE_CIRCLE_DIALOG
|
#ifdef DEBUG_CREATE_CIRCLE_DIALOG
|
||||||
std::cerr << "CreateCircleDialog::createCircle()";
|
std::cerr << "CreateCircleDialog::createCircle()";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
@ -431,10 +431,10 @@ void CreateCircleDialog::createCircle()
|
||||||
QString name = ui.circleName->text();
|
QString name = ui.circleName->text();
|
||||||
|
|
||||||
if(name.isEmpty()) {
|
if(name.isEmpty()) {
|
||||||
/* error message */
|
/* error message */
|
||||||
QMessageBox::warning(this, tr("RetroShare"),tr("Please set a name for your Circle"), QMessageBox::Ok, QMessageBox::Ok);
|
QMessageBox::warning(this, tr("RetroShare"),tr("Please set a name for your Circle"), QMessageBox::Ok, QMessageBox::Ok);
|
||||||
|
|
||||||
return; //Don't add a empty Subject!!
|
return; //Don't add a empty Subject!!
|
||||||
}
|
}
|
||||||
|
|
||||||
RsGxsCircleGroup circle = mCircleGroup; // init with loaded group
|
RsGxsCircleGroup circle = mCircleGroup; // init with loaded group
|
||||||
|
@ -448,23 +448,23 @@ void CreateCircleDialog::createCircle()
|
||||||
{
|
{
|
||||||
case GxsIdChooser::KnowId:
|
case GxsIdChooser::KnowId:
|
||||||
case GxsIdChooser::UnKnowId:
|
case GxsIdChooser::UnKnowId:
|
||||||
circle.mMeta.mAuthorId = authorId;
|
circle.mMeta.mAuthorId = authorId;
|
||||||
circle.mMeta.mAuthenFlags = GXS_SERV::GRP_OPTION_AUTHEN_AUTHOR_SIGN;
|
circle.mMeta.mAuthenFlags = GXS_SERV::GRP_OPTION_AUTHEN_AUTHOR_SIGN;
|
||||||
|
|
||||||
#ifdef DEBUG_CREATE_CIRCLE_DIALOG
|
#ifdef DEBUG_CREATE_CIRCLE_DIALOG
|
||||||
std::cerr << "CreateCircleDialog::createCircle() AuthorId: " << authorId;
|
std::cerr << "CreateCircleDialog::createCircle() AuthorId: " << authorId;
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case GxsIdChooser::NoId:
|
case GxsIdChooser::NoId:
|
||||||
case GxsIdChooser::None:
|
case GxsIdChooser::None:
|
||||||
circle.mMeta.mAuthorId.clear();
|
circle.mMeta.mAuthorId.clear();
|
||||||
circle.mMeta.mAuthenFlags = 0;
|
circle.mMeta.mAuthenFlags = 0;
|
||||||
default: ;
|
default: ;
|
||||||
#ifdef DEBUG_CREATE_CIRCLE_DIALOG
|
#ifdef DEBUG_CREATE_CIRCLE_DIALOG
|
||||||
std::cerr << "CreateCircleDialog::createCircle() No AuthorId Chosen!";
|
std::cerr << "CreateCircleDialog::createCircle() No AuthorId Chosen!";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -472,144 +472,163 @@ void CreateCircleDialog::createCircle()
|
||||||
/* copy Ids from GUI */
|
/* copy Ids from GUI */
|
||||||
QTreeWidget *tree = ui.treeWidget_membership;
|
QTreeWidget *tree = ui.treeWidget_membership;
|
||||||
int count = tree->topLevelItemCount();
|
int count = tree->topLevelItemCount();
|
||||||
for(int i = 0; i < count; ++i)
|
for(int i = 0; i < count; ++i)
|
||||||
{
|
{
|
||||||
QTreeWidgetItem *item = tree->topLevelItem(i);
|
QTreeWidgetItem *item = tree->topLevelItem(i);
|
||||||
QString keyId = item->text(RSCIRCLEID_COL_KEYID);
|
QString keyId = item->text(RSCIRCLEID_COL_KEYID);
|
||||||
|
|
||||||
/* insert into circle */
|
/* insert into circle */
|
||||||
if (mIsExternalCircle)
|
if (mIsExternalCircle)
|
||||||
{
|
{
|
||||||
RsGxsId key_id_gxs(keyId.toStdString()) ;
|
RsGxsId key_id_gxs(keyId.toStdString()) ;
|
||||||
|
|
||||||
if(key_id_gxs.isNull())
|
if(key_id_gxs.isNull())
|
||||||
{
|
{
|
||||||
std::cerr << "Error: Not a proper keyID: " << keyId.toStdString() << std::endl;
|
std::cerr << "Error: Not a proper keyID: " << keyId.toStdString() << std::endl;
|
||||||
continue ;
|
continue ;
|
||||||
}
|
}
|
||||||
|
|
||||||
circle.mInvitedMembers.insert(key_id_gxs) ;
|
circle.mInvitedMembers.insert(key_id_gxs) ;
|
||||||
#ifdef DEBUG_CREATE_CIRCLE_DIALOG
|
#ifdef DEBUG_CREATE_CIRCLE_DIALOG
|
||||||
std::cerr << "CreateCircleDialog::createCircle() Inserting Member: " << keyId.toStdString();
|
std::cerr << "CreateCircleDialog::createCircle() Inserting Member: " << keyId.toStdString();
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
RsPgpId key_id_pgp(keyId.toStdString()) ;
|
RsPgpId key_id_pgp(keyId.toStdString()) ;
|
||||||
|
|
||||||
if(key_id_pgp.isNull())
|
if(key_id_pgp.isNull())
|
||||||
{
|
{
|
||||||
std::cerr << "Error: Not a proper PGP keyID: " << keyId.toStdString() << std::endl;
|
std::cerr << "Error: Not a proper PGP keyID: " << keyId.toStdString() << std::endl;
|
||||||
continue ;
|
continue ;
|
||||||
}
|
}
|
||||||
|
|
||||||
circle.mLocalFriends.insert(key_id_pgp) ;
|
circle.mLocalFriends.insert(key_id_pgp) ;
|
||||||
#ifdef DEBUG_CREATE_CIRCLE_DIALOG
|
#ifdef DEBUG_CREATE_CIRCLE_DIALOG
|
||||||
std::cerr << "CreateCircleDialog::createCircle() Inserting Friend: " << keyId.toStdString();
|
std::cerr << "CreateCircleDialog::createCircle() Inserting Friend: " << keyId.toStdString();
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mIsExternalCircle)
|
if (mIsExternalCircle)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_CREATE_CIRCLE_DIALOG
|
#ifdef DEBUG_CREATE_CIRCLE_DIALOG
|
||||||
std::cerr << "CreateCircleDialog::createCircle() External Circle";
|
std::cerr << "CreateCircleDialog::createCircle() External Circle";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// set distribution from GUI.
|
// set distribution from GUI.
|
||||||
circle.mMeta.mCircleId.clear() ;
|
circle.mMeta.mCircleId.clear() ;
|
||||||
circle.mMeta.mGroupFlags = GXS_SERV::FLAG_PRIVACY_PUBLIC;
|
circle.mMeta.mGroupFlags = GXS_SERV::FLAG_PRIVACY_PUBLIC;
|
||||||
|
|
||||||
if (ui.radioButton_Public->isChecked()) {
|
if (ui.radioButton_Public->isChecked()) {
|
||||||
#ifdef DEBUG_CREATE_CIRCLE_DIALOG
|
#ifdef DEBUG_CREATE_CIRCLE_DIALOG
|
||||||
std::cerr << "CreateCircleDialog::createCircle() Public Circle";
|
std::cerr << "CreateCircleDialog::createCircle() Public Circle";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
circle.mMeta.mCircleType = GXS_CIRCLE_TYPE_PUBLIC;
|
circle.mMeta.mCircleType = GXS_CIRCLE_TYPE_PUBLIC;
|
||||||
|
|
||||||
} else if (ui.radioButton_Self->isChecked()) {
|
} else if (ui.radioButton_Self->isChecked()) {
|
||||||
#ifdef DEBUG_CREATE_CIRCLE_DIALOG
|
#ifdef DEBUG_CREATE_CIRCLE_DIALOG
|
||||||
std::cerr << "CreateCircleDialog::createCircle() ExtSelfRef Circle";
|
std::cerr << "CreateCircleDialog::createCircle() ExtSelfRef Circle";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
circle.mMeta.mCircleType = GXS_CIRCLE_TYPE_EXT_SELF;
|
circle.mMeta.mCircleType = GXS_CIRCLE_TYPE_EXT_SELF;
|
||||||
} else if (ui.radioButton_Restricted->isChecked()) {
|
} else if (ui.radioButton_Restricted->isChecked()) {
|
||||||
#ifdef DEBUG_CREATE_CIRCLE_DIALOG
|
#ifdef DEBUG_CREATE_CIRCLE_DIALOG
|
||||||
std::cerr << "CreateCircleDialog::createCircle() External (Other) Circle";
|
std::cerr << "CreateCircleDialog::createCircle() External (Other) Circle";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
circle.mMeta.mCircleType = GXS_CIRCLE_TYPE_EXTERNAL;
|
circle.mMeta.mCircleType = GXS_CIRCLE_TYPE_EXTERNAL;
|
||||||
|
|
||||||
/* grab circle ID from chooser */
|
/* grab circle ID from chooser */
|
||||||
RsGxsCircleId chosenId;
|
RsGxsCircleId chosenId;
|
||||||
if (ui.circleComboBox->getChosenCircle(chosenId)) {
|
if (ui.circleComboBox->getChosenCircle(chosenId)) {
|
||||||
#ifdef DEBUG_CREATE_CIRCLE_DIALOG
|
#ifdef DEBUG_CREATE_CIRCLE_DIALOG
|
||||||
std::cerr << "CreateCircleDialog::createCircle() ChosenId: " << chosenId;
|
std::cerr << "CreateCircleDialog::createCircle() ChosenId: " << chosenId;
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
circle.mMeta.mCircleId = chosenId;
|
circle.mMeta.mCircleId = chosenId;
|
||||||
} else {//if (ui.circleComboBox->getChosenCircle(chosenId))
|
} else {//if (ui.circleComboBox->getChosenCircle(chosenId))
|
||||||
#ifdef DEBUG_CREATE_CIRCLE_DIALOG
|
#ifdef DEBUG_CREATE_CIRCLE_DIALOG
|
||||||
std::cerr << "CreateCircleDialog::createCircle() Error no Id Chosen";
|
std::cerr << "CreateCircleDialog::createCircle() Error no Id Chosen";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
QMessageBox::warning(this, tr("RetroShare"),tr("No Restriction Circle Selected"), QMessageBox::Ok, QMessageBox::Ok);
|
QMessageBox::warning(this, tr("RetroShare"),tr("No Restriction Circle Selected"), QMessageBox::Ok, QMessageBox::Ok);
|
||||||
return;
|
return;
|
||||||
}//else (ui.circleComboBox->getChosenCircle(chosenId))
|
}//else (ui.circleComboBox->getChosenCircle(chosenId))
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
QMessageBox::warning(this, tr("RetroShare"),tr("No Circle Limitations Selected"), QMessageBox::Ok, QMessageBox::Ok);
|
QMessageBox::warning(this, tr("RetroShare"),tr("No Circle Limitations Selected"), QMessageBox::Ok, QMessageBox::Ok);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
#ifdef DEBUG_CREATE_CIRCLE_DIALOG
|
|
||||||
std::cerr << "CreateCircleDialog::createCircle() Personal Circle";
|
|
||||||
std::cerr << std::endl;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// set personal distribution
|
|
||||||
circle.mMeta.mCircleId.clear() ;
|
|
||||||
circle.mMeta.mCircleType = GXS_CIRCLE_TYPE_LOCAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t token;
|
|
||||||
|
|
||||||
if(mIsExistingCircle)
|
|
||||||
{
|
|
||||||
#ifdef DEBUG_CREATE_CIRCLE_DIALOG
|
|
||||||
std::cerr << "CreateCircleDialog::updateCircle() : mCircleType: " << circle.mMeta.mCircleType << std::endl;
|
|
||||||
std::cerr << "CreateCircleDialog::updateCircle() : mCircleId: " << circle.mMeta.mCircleId << std::endl;
|
|
||||||
std::cerr << "CreateCircleDialog::updateCircle() : mGroupId: " << circle.mMeta.mGroupId << std::endl;
|
|
||||||
|
|
||||||
std::cerr << "CreateCircleDialog::updateCircle() Checks and Balances Okay - calling service proper.."<< std::endl;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
rsGxsCircles->updateGroup(token, circle);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_CREATE_CIRCLE_DIALOG
|
#ifdef DEBUG_CREATE_CIRCLE_DIALOG
|
||||||
std::cerr << "CreateCircleDialog::createCircle() : mCircleType: " << circle.mMeta.mCircleType << std::endl;
|
std::cerr << "CreateCircleDialog::createCircle() Personal Circle";
|
||||||
std::cerr << "CreateCircleDialog::createCircle() : mCircleId: " << circle.mMeta.mCircleId << std::endl;
|
std::cerr << std::endl;
|
||||||
|
|
||||||
std::cerr << "CreateCircleDialog::createCircle() Checks and Balances Okay - calling service proper.."<< std::endl;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
rsGxsCircles->createGroup(token, circle);
|
// set personal distribution
|
||||||
|
circle.mMeta.mCircleId.clear() ;
|
||||||
|
circle.mMeta.mCircleType = GXS_CIRCLE_TYPE_LOCAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
RsThread::async([&circle,this]()
|
||||||
|
{
|
||||||
|
RsGxsCircleId circleId;
|
||||||
|
|
||||||
|
if(mIsExistingCircle)
|
||||||
|
{
|
||||||
|
#ifdef DEBUG_CREATE_CIRCLE_DIALOG
|
||||||
|
std::cerr << "CreateCircleDialog::updateCircle() : mCircleType: " << circle.mMeta.mCircleType << std::endl;
|
||||||
|
std::cerr << "CreateCircleDialog::updateCircle() : mCircleId: " << circle.mMeta.mCircleId << std::endl;
|
||||||
|
std::cerr << "CreateCircleDialog::updateCircle() : mGroupId: " << circle.mMeta.mGroupId << std::endl;
|
||||||
|
|
||||||
|
std::cerr << "CreateCircleDialog::updateCircle() Checks and Balances Okay - calling service proper.."<< std::endl;
|
||||||
|
#endif
|
||||||
|
rsGxsCircles->editCircle(circle);
|
||||||
|
|
||||||
|
circleId = RsGxsCircleId(circle.mMeta.mGroupId);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
#ifdef DEBUG_CREATE_CIRCLE_DIALOG
|
||||||
|
std::cerr << "CreateCircleDialog::createCircle() : mCircleType: " << circle.mMeta.mCircleType << std::endl;
|
||||||
|
std::cerr << "CreateCircleDialog::createCircle() : mCircleId: " << circle.mMeta.mCircleId << std::endl;
|
||||||
|
|
||||||
|
std::cerr << "CreateCircleDialog::createCircle() Checks and Balances Okay - calling service proper.."<< std::endl;
|
||||||
|
#endif
|
||||||
|
rsGxsCircles->createCircle(circle.mMeta.mGroupName,
|
||||||
|
static_cast<RsGxsCircleType>(circle.mMeta.mCircleType),
|
||||||
|
circleId,
|
||||||
|
circle.mMeta.mCircleId,
|
||||||
|
circle.mMeta.mAuthorId,
|
||||||
|
circle.mInvitedMembers,
|
||||||
|
circle.mLocalFriends);
|
||||||
|
}
|
||||||
|
|
||||||
|
RsQThreadUtils::postToObject( [this,circle,circleId]()
|
||||||
|
{
|
||||||
|
if(!mIsExistingCircle)
|
||||||
|
QMessageBox::information(nullptr,tr("Circle created"),
|
||||||
|
tr("Your new circle has been created:\n Name: %1\n Id: %2.")
|
||||||
|
.arg(QString::fromUtf8(circle.mMeta.mGroupName.c_str()))
|
||||||
|
.arg(QString::fromStdString(circleId.toStdString())));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -810,11 +829,6 @@ void CreateCircleDialog::loadIdentities()
|
||||||
|
|
||||||
void CreateCircleDialog::fillIdentitiesList(const std::vector<RsGxsIdGroup>& id_groups)
|
void CreateCircleDialog::fillIdentitiesList(const std::vector<RsGxsIdGroup>& id_groups)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_CREATE_CIRCLE_DIALOG
|
|
||||||
std::cerr << "CreateCircleDialog::loadIdentities(" << token << ")";
|
|
||||||
std::cerr << std::endl;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
QTreeWidget *tree = ui.treeWidget_IdList;
|
QTreeWidget *tree = ui.treeWidget_IdList;
|
||||||
tree->clear();
|
tree->clear();
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,6 @@
|
||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
|
|
||||||
#include "util/TokenQueue.h"
|
|
||||||
#include <retroshare/rsidentity.h>
|
#include <retroshare/rsidentity.h>
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
|
|
|
@ -23,7 +23,6 @@
|
||||||
|
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
|
|
||||||
#include "util/TokenQueue.h"
|
|
||||||
#include <retroshare/rsidentity.h>
|
#include <retroshare/rsidentity.h>
|
||||||
#include <retroshare/rsgxsifacetypes.h>
|
#include <retroshare/rsgxsifacetypes.h>
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
|
@ -71,7 +70,6 @@ private:
|
||||||
void updateIdType(bool pseudo);
|
void updateIdType(bool pseudo);
|
||||||
void loadExistingId(const RsGxsIdGroup& id_group);
|
void loadExistingId(const RsGxsIdGroup& id_group);
|
||||||
void setAvatar(const QPixmap &avatar);
|
void setAvatar(const QPixmap &avatar);
|
||||||
void idCreated(uint32_t token);
|
|
||||||
|
|
||||||
void loadRecognTags();
|
void loadRecognTags();
|
||||||
// extract details.
|
// extract details.
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
#include "ui_PostedCreatePostDialog.h"
|
#include "ui_PostedCreatePostDialog.h"
|
||||||
|
|
||||||
#include "util/misc.h"
|
#include "util/misc.h"
|
||||||
|
#include "util/qtthreadsutils.h"
|
||||||
#include "util/RichTextEdit.h"
|
#include "util/RichTextEdit.h"
|
||||||
#include "gui/feeds/SubFileItem.h"
|
#include "gui/feeds/SubFileItem.h"
|
||||||
#include "util/rsdir.h"
|
#include "util/rsdir.h"
|
||||||
|
@ -178,10 +179,20 @@ void PostedCreatePostDialog::createPost()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t token;
|
RsThread::async([this,post]()
|
||||||
mPosted->createPost(token, post);
|
{
|
||||||
|
RsGxsMessageId post_id;
|
||||||
|
|
||||||
accept();
|
bool res = rsPosted->createPost(post,post_id);
|
||||||
|
|
||||||
|
RsQThreadUtils::postToObject( [res,this]()
|
||||||
|
{
|
||||||
|
if(!res)
|
||||||
|
QMessageBox::information(nullptr,tr("Error while creating post"),tr("An error occurred while creating the post."));
|
||||||
|
|
||||||
|
accept();
|
||||||
|
}, this );
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void PostedCreatePostDialog::fileHashingFinished(QList<HashedFile> hashedFiles)
|
void PostedCreatePostDialog::fileHashingFinished(QList<HashedFile> hashedFiles)
|
||||||
|
|
|
@ -217,34 +217,6 @@ QWidget *PostedDialog::createCommentHeaderWidget(const RsGxsGroupId &grpId, cons
|
||||||
return new PostedItem(NULL, 0, grpId, msgId, true, false);
|
return new PostedItem(NULL, 0, grpId, msgId, true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef TO_REMOVE
|
|
||||||
void PostedDialog::loadGroupSummaryToken(const uint32_t &token, std::list<RsGroupMetaData> &groupInfo, RsUserdata *&userdata)
|
|
||||||
{
|
|
||||||
std::vector<RsPostedGroup> groups;
|
|
||||||
rsPosted->getGroupData(token, groups);
|
|
||||||
|
|
||||||
/* Save groups to fill description */
|
|
||||||
PostedGroupInfoData *postedData = new PostedGroupInfoData;
|
|
||||||
userdata = postedData;
|
|
||||||
|
|
||||||
std::vector<RsPostedGroup>::iterator groupIt;
|
|
||||||
for (groupIt = groups.begin(); groupIt != groups.end(); ++groupIt) {
|
|
||||||
RsPostedGroup &group = *groupIt;
|
|
||||||
groupInfo.push_back(group.mMeta);
|
|
||||||
|
|
||||||
if (group.mGroupImage.mData != NULL) {
|
|
||||||
QPixmap image;
|
|
||||||
GxsIdDetails::loadPixmapFromData(group.mGroupImage.mData, group.mGroupImage.mSize, image,GxsIdDetails::ORIGINAL);
|
|
||||||
postedData->mIcon[group.mMeta.mGroupId] = image;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!group.mDescription.empty()) {
|
|
||||||
postedData->mDescription[group.mMeta.mGroupId] = QString::fromUtf8(group.mDescription.c_str());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void PostedDialog::groupInfoToGroupItemInfo(const RsGxsGenericGroupData *groupData, GroupItemInfo &groupItemInfo)
|
void PostedDialog::groupInfoToGroupItemInfo(const RsGxsGenericGroupData *groupData, GroupItemInfo &groupItemInfo)
|
||||||
{
|
{
|
||||||
GxsGroupFrameDialog::groupInfoToGroupItemInfo(groupData, groupItemInfo);
|
GxsGroupFrameDialog::groupInfoToGroupItemInfo(groupData, groupItemInfo);
|
||||||
|
|
|
@ -279,16 +279,20 @@ void BasePostedItem::loadComments()
|
||||||
}
|
}
|
||||||
void BasePostedItem::readToggled(bool checked)
|
void BasePostedItem::readToggled(bool checked)
|
||||||
{
|
{
|
||||||
if (mInFill) {
|
if (mInFill) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
RsGxsGrpMsgIdPair msgPair = std::make_pair(groupId(), messageId());
|
RsThread::async([this,checked]()
|
||||||
|
{
|
||||||
|
RsGxsGrpMsgIdPair msgPair = std::make_pair(groupId(), messageId());
|
||||||
|
rsPosted->setPostReadStatus(msgPair, !checked);
|
||||||
|
|
||||||
uint32_t token;
|
RsQThreadUtils::postToObject( [checked,this]()
|
||||||
rsPosted->setMessageReadStatus(token, msgPair, !checked);
|
{
|
||||||
|
setReadStatus(false, checked);
|
||||||
setReadStatus(false, checked);
|
}, this );
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void BasePostedItem::readAndClearItem()
|
void BasePostedItem::readAndClearItem()
|
||||||
|
|
|
@ -773,7 +773,7 @@ QIcon PostedListWidgetWithModel::groupIcon()
|
||||||
return QIcon(postedImage);
|
return QIcon(postedImage);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PostedListWidgetWithModel::setAllMessagesReadDo(bool read, uint32_t &/*token*/)
|
void PostedListWidgetWithModel::setAllMessagesReadDo(bool read)
|
||||||
{
|
{
|
||||||
if (groupId().isNull() || !IS_GROUP_SUBSCRIBED(mGroup.mMeta.mSubscribeFlags))
|
if (groupId().isNull() || !IS_GROUP_SUBSCRIBED(mGroup.mMeta.mSubscribeFlags))
|
||||||
return;
|
return;
|
||||||
|
@ -795,7 +795,7 @@ void PostedListWidgetWithModel::openComments(const RsGxsMessageId& msgId)
|
||||||
ui->idChooser->getChosenId(current_author);
|
ui->idChooser->getChosenId(current_author);
|
||||||
|
|
||||||
RsPostedPost post = index.data(Qt::UserRole).value<RsPostedPost>() ;
|
RsPostedPost post = index.data(Qt::UserRole).value<RsPostedPost>() ;
|
||||||
auto *commentDialog = new GxsCommentDialog(this,current_author,rsPosted->getTokenService(),rsPosted);
|
auto *commentDialog = new GxsCommentDialog(this,current_author,rsPosted);
|
||||||
|
|
||||||
std::set<RsGxsMessageId> msg_versions({post.mMeta.mMsgId});
|
std::set<RsGxsMessageId> msg_versions({post.mMeta.mMsgId});
|
||||||
commentDialog->commentLoad(post.mMeta.mGroupId, msg_versions, post.mMeta.mMsgId);
|
commentDialog->commentLoad(post.mMeta.mGroupId, msg_versions, post.mMeta.mMsgId);
|
||||||
|
@ -1190,8 +1190,7 @@ void PostedListWidgetWithModel::subscribeGroup(bool subscribe)
|
||||||
|
|
||||||
RsThread::async([=]()
|
RsThread::async([=]()
|
||||||
{
|
{
|
||||||
uint32_t token;
|
rsPosted->subscribeToBoard(grpId, subscribe);
|
||||||
rsPosted->subscribeToGroup(token,grpId, subscribe);
|
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1204,7 +1203,14 @@ void PostedListWidgetWithModel::voteMsg(RsGxsGrpMsgIdPair msg,bool up_or_down)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
rsPosted->voteForPost(up_or_down,msg.first,msg.second,voter_id);
|
RsGxsVoteType tvote = up_or_down?(RsGxsVoteType::UP):(RsGxsVoteType::DOWN);
|
||||||
|
|
||||||
|
std::string error_str;
|
||||||
|
RsGxsMessageId vote_id;
|
||||||
|
if(!rsPosted->voteForPost(msg.first,msg.second,voter_id,tvote,vote_id,error_str))
|
||||||
|
QMessageBox::critical(nullptr,tr("Could not vote"), tr("Error occured while voting: ")+QString::fromStdString(error_str));
|
||||||
|
else
|
||||||
|
updateDisplay(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef TODO
|
#ifdef TODO
|
||||||
|
|
|
@ -130,7 +130,7 @@ protected:
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* GxsMessageFrameWidget */
|
/* GxsMessageFrameWidget */
|
||||||
virtual void setAllMessagesReadDo(bool read, uint32_t &token) override;
|
virtual void setAllMessagesReadDo(bool read) override;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
#ifdef TO_REMOVE
|
#ifdef TO_REMOVE
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
#include "gui/feeds/FeedHolder.h"
|
#include "gui/feeds/FeedHolder.h"
|
||||||
#include "gui/RetroShareLink.h"
|
#include "gui/RetroShareLink.h"
|
||||||
#include "gui/gxs/GxsIdDetails.h"
|
#include "gui/gxs/GxsIdDetails.h"
|
||||||
|
#include "util/qtthreadsutils.h"
|
||||||
#include "util/DateTime.h"
|
#include "util/DateTime.h"
|
||||||
#include "util/misc.h"
|
#include "util/misc.h"
|
||||||
#include "util/stringutil.h"
|
#include "util/stringutil.h"
|
||||||
|
@ -286,12 +287,15 @@ void BaseBoardsCommentsItem::readToggled(bool checked)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
RsGxsGrpMsgIdPair msgPair = std::make_pair(groupId(), messageId());
|
RsThread::async( [this,checked]() {
|
||||||
|
RsGxsGrpMsgIdPair msgPair = std::make_pair(groupId(), messageId());
|
||||||
uint32_t token;
|
|
||||||
rsPosted->setMessageReadStatus(token, msgPair, !checked);
|
rsPosted->setCommentReadStatus(msgPair, !checked);
|
||||||
|
|
||||||
setReadStatus(false, checked);
|
RsQThreadUtils::postToObject( [this,checked]() {
|
||||||
|
setReadStatus(false, checked);
|
||||||
|
} );
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseBoardsCommentsItem::readAndClearItem()
|
void BaseBoardsCommentsItem::readAndClearItem()
|
||||||
|
|
|
@ -617,7 +617,7 @@ void ChannelsCommentsItem::readToggled(bool /*checked*/)
|
||||||
|
|
||||||
RsGxsGrpMsgIdPair msgPair = std::make_pair(groupId(), messageId());
|
RsGxsGrpMsgIdPair msgPair = std::make_pair(groupId(), messageId());
|
||||||
|
|
||||||
rsGxsChannels->markRead(msgPair, isUnread());
|
rsGxsChannels->setCommentReadStatus(msgPair, isUnread());
|
||||||
|
|
||||||
//setReadStatus(false, checked); // Updated by events
|
//setReadStatus(false, checked); // Updated by events
|
||||||
}
|
}
|
||||||
|
|
|
@ -850,7 +850,7 @@ void GxsChannelPostItem::readToggled(bool /*checked*/)
|
||||||
|
|
||||||
RsGxsGrpMsgIdPair msgPair = std::make_pair(groupId(), messageId());
|
RsGxsGrpMsgIdPair msgPair = std::make_pair(groupId(), messageId());
|
||||||
|
|
||||||
rsGxsChannels->markRead(msgPair, isUnread());
|
rsGxsChannels->setMessageReadStatus(msgPair, isUnread());
|
||||||
|
|
||||||
//setReadStatus(false, checked); // Updated by events
|
//setReadStatus(false, checked); // Updated by events
|
||||||
}
|
}
|
||||||
|
|
|
@ -475,18 +475,21 @@ void GxsForumMsgItem::unsubscribeForum()
|
||||||
|
|
||||||
void GxsForumMsgItem::setAsRead()
|
void GxsForumMsgItem::setAsRead()
|
||||||
{
|
{
|
||||||
if (mInFill) {
|
if (mInFill) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
mCloseOnRead = false;
|
mCloseOnRead = false;
|
||||||
|
|
||||||
RsGxsGrpMsgIdPair msgPair = std::make_pair(groupId(), messageId());
|
RsThread::async( [this]() {
|
||||||
|
RsGxsGrpMsgIdPair msgPair = std::make_pair(groupId(), messageId());
|
||||||
|
|
||||||
uint32_t token;
|
rsGxsForums->markRead(msgPair, true);
|
||||||
rsGxsForums->setMessageReadStatus(token, msgPair, true);
|
|
||||||
|
|
||||||
setReadStatus(false, false);
|
RsQThreadUtils::postToObject( [this]() {
|
||||||
|
setReadStatus(false, true);
|
||||||
|
} );
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void GxsForumMsgItem::on_linkActivated(QString link)
|
void GxsForumMsgItem::on_linkActivated(QString link)
|
||||||
|
|
|
@ -60,7 +60,7 @@ void GxsCommentContainer::commentLoad(const RsGxsGroupId &grpId, const std::set<
|
||||||
comments += "...";
|
comments += "...";
|
||||||
}
|
}
|
||||||
|
|
||||||
GxsCommentDialog *commentDialog = new GxsCommentDialog(this, RsGxsId(),getTokenService(), getCommentService());
|
GxsCommentDialog *commentDialog = new GxsCommentDialog(this, RsGxsId(),getCommentService());
|
||||||
|
|
||||||
QWidget *commentHeader = createHeaderWidget(grpId, msgId);
|
QWidget *commentHeader = createHeaderWidget(grpId, msgId);
|
||||||
commentDialog->setCommentHeader(commentHeader);
|
commentDialog->setCommentHeader(commentHeader);
|
||||||
|
|
|
@ -30,13 +30,13 @@
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
|
|
||||||
/** Constructor */
|
/** Constructor */
|
||||||
GxsCommentDialog::GxsCommentDialog(QWidget *parent, const RsGxsId &default_author, RsTokenService *token_service, RsGxsCommentService *comment_service)
|
GxsCommentDialog::GxsCommentDialog(QWidget *parent, const RsGxsId &default_author, RsGxsCommentService *comment_service)
|
||||||
: QWidget(parent), ui(new Ui::GxsCommentDialog)
|
: QWidget(parent), ui(new Ui::GxsCommentDialog)
|
||||||
{
|
{
|
||||||
/* Invoke the Qt Designer generated QObject setup routine */
|
/* Invoke the Qt Designer generated QObject setup routine */
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
setTokenService(token_service,comment_service);
|
setGxsService(comment_service);
|
||||||
init(default_author);
|
init(default_author);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,9 +67,9 @@ void GxsCommentDialog::init(const RsGxsId& default_author)
|
||||||
ui->sortBox->setIconSize(QSize(S*1.5,S*1.5));
|
ui->sortBox->setIconSize(QSize(S*1.5,S*1.5));
|
||||||
}
|
}
|
||||||
|
|
||||||
void GxsCommentDialog::setTokenService(RsTokenService *token_service, RsGxsCommentService *comment_service)
|
void GxsCommentDialog::setGxsService(RsGxsCommentService *comment_service)
|
||||||
{
|
{
|
||||||
ui->treeWidget->setup(token_service, comment_service);
|
ui->treeWidget->setup(comment_service);
|
||||||
}
|
}
|
||||||
|
|
||||||
GxsCommentDialog::GxsCommentDialog(QWidget *parent,const RsGxsId &default_author)
|
GxsCommentDialog::GxsCommentDialog(QWidget *parent,const RsGxsId &default_author)
|
||||||
|
|
|
@ -33,10 +33,10 @@ class GxsCommentDialog: public QWidget
|
||||||
|
|
||||||
public:
|
public:
|
||||||
GxsCommentDialog(QWidget *parent=nullptr,const RsGxsId& default_author=RsGxsId());
|
GxsCommentDialog(QWidget *parent=nullptr,const RsGxsId& default_author=RsGxsId());
|
||||||
GxsCommentDialog(QWidget *parent,const RsGxsId& default_author, RsTokenService *token_service, RsGxsCommentService *comment_service);
|
GxsCommentDialog(QWidget *parent, const RsGxsId& default_author, RsGxsCommentService *comment_service);
|
||||||
virtual ~GxsCommentDialog();
|
virtual ~GxsCommentDialog();
|
||||||
|
|
||||||
void setTokenService(RsTokenService *token_service, RsGxsCommentService *comment_service);
|
void setGxsService(RsGxsCommentService *comment_service);
|
||||||
void setCommentHeader(QWidget *header);
|
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 commentLoad(const RsGxsGroupId &grpId, const std::set<RsGxsMessageId> &msg_versions, const RsGxsMessageId &most_recent_msgId, bool use_cache=false);
|
||||||
void commentClear();
|
void commentClear();
|
||||||
|
|
|
@ -25,12 +25,14 @@
|
||||||
#include "gui/common/RSTreeWidgetItem.h"
|
#include "gui/common/RSTreeWidgetItem.h"
|
||||||
#include "gui/gxs/GxsCreateCommentDialog.h"
|
#include "gui/gxs/GxsCreateCommentDialog.h"
|
||||||
#include "gui/gxs/GxsIdTreeWidgetItem.h"
|
#include "gui/gxs/GxsIdTreeWidgetItem.h"
|
||||||
|
#include "util/qtthreadsutils.h"
|
||||||
|
|
||||||
#include <QAbstractTextDocumentLayout>
|
#include <QAbstractTextDocumentLayout>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QTextEdit>
|
#include <QTextEdit>
|
||||||
#include <QHeaderView>
|
#include <QHeaderView>
|
||||||
#include <QClipboard>
|
#include <QClipboard>
|
||||||
|
#include <QMessageBox>
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QMimeData>
|
#include <QMimeData>
|
||||||
|
@ -247,7 +249,7 @@ void GxsCommentTreeWidget::mouseMoveEvent(QMouseEvent *e)
|
||||||
}
|
}
|
||||||
|
|
||||||
GxsCommentTreeWidget::GxsCommentTreeWidget(QWidget *parent)
|
GxsCommentTreeWidget::GxsCommentTreeWidget(QWidget *parent)
|
||||||
:QTreeWidget(parent), mTokenQueue(NULL), mRsTokenService(NULL), mCommentService(NULL)
|
:QTreeWidget(parent), mCommentService(NULL)
|
||||||
{
|
{
|
||||||
setVerticalScrollMode(ScrollPerPixel);
|
setVerticalScrollMode(ScrollPerPixel);
|
||||||
setContextMenuPolicy(Qt::CustomContextMenu);
|
setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
|
@ -297,9 +299,6 @@ void GxsCommentTreeWidget::updateContent()
|
||||||
}
|
}
|
||||||
GxsCommentTreeWidget::~GxsCommentTreeWidget()
|
GxsCommentTreeWidget::~GxsCommentTreeWidget()
|
||||||
{
|
{
|
||||||
if (mTokenQueue) {
|
|
||||||
delete(mTokenQueue);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GxsCommentTreeWidget::setCurrentCommentMsgId(QTreeWidgetItem *current, QTreeWidgetItem *previous)
|
void GxsCommentTreeWidget::setCurrentCommentMsgId(QTreeWidgetItem *current, QTreeWidgetItem *previous)
|
||||||
|
@ -401,35 +400,23 @@ void GxsCommentTreeWidget::setVoteId(const RsGxsId &voterId)
|
||||||
void GxsCommentTreeWidget::vote(const RsGxsGroupId &groupId, const RsGxsMessageId &threadId,
|
void GxsCommentTreeWidget::vote(const RsGxsGroupId &groupId, const RsGxsMessageId &threadId,
|
||||||
const RsGxsMessageId &parentId, const RsGxsId &authorId, bool up)
|
const RsGxsMessageId &parentId, const RsGxsId &authorId, bool up)
|
||||||
{
|
{
|
||||||
RsGxsVote vote;
|
RsThread::async([this,groupId,threadId,parentId,authorId,up]()
|
||||||
|
{
|
||||||
|
std::string error_string;
|
||||||
|
RsGxsMessageId vote_id;
|
||||||
|
RsGxsVoteType tvote = up?(RsGxsVoteType::UP):(RsGxsVoteType::DOWN);
|
||||||
|
|
||||||
vote.mMeta.mGroupId = groupId;
|
bool res = mCommentService->voteForComment(groupId, threadId, parentId, authorId,tvote,vote_id, error_string);
|
||||||
vote.mMeta.mThreadId = threadId;
|
|
||||||
vote.mMeta.mParentId = parentId;
|
|
||||||
vote.mMeta.mAuthorId = authorId;
|
|
||||||
|
|
||||||
if (up)
|
RsQThreadUtils::postToObject( [this,res,error_string]()
|
||||||
{
|
{
|
||||||
vote.mVoteType = GXS_VOTE_UP;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
vote.mVoteType = GXS_VOTE_DOWN;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef DEBUG_GXSCOMMENT_TREEWIDGET
|
if(res)
|
||||||
std::cerr << "GxsCommentTreeWidget::vote()";
|
service_requestComments(mGroupId,mMsgVersions);
|
||||||
std::cerr << std::endl;
|
else
|
||||||
|
QMessageBox::critical(nullptr,tr("Cannot vote"),tr("Error while voting: ")+QString::fromStdString(error_string));
|
||||||
std::cerr << "GroupId : " << vote.mMeta.mGroupId << std::endl;
|
});
|
||||||
std::cerr << "ThreadId : " << vote.mMeta.mThreadId << std::endl;
|
});
|
||||||
std::cerr << "ParentId : " << vote.mMeta.mParentId << std::endl;
|
|
||||||
std::cerr << "AuthorId : " << vote.mMeta.mAuthorId << std::endl;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
uint32_t token;
|
|
||||||
mCommentService->createNewVote(token, vote);
|
|
||||||
mTokenQueue->queueRequest(token, TOKENREQ_MSGINFO, RS_TOKREQ_ANSTYPE_ACK, COMMENT_VOTE_ACK);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -484,12 +471,10 @@ void GxsCommentTreeWidget::copyComment()
|
||||||
clipboard->setMimeData(mimeData, QClipboard::Clipboard);
|
clipboard->setMimeData(mimeData, QClipboard::Clipboard);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GxsCommentTreeWidget::setup(RsTokenService *token_service, RsGxsCommentService *comment_service)
|
void GxsCommentTreeWidget::setup(RsGxsCommentService *comment_service)
|
||||||
{
|
{
|
||||||
mRsTokenService = token_service;
|
|
||||||
mCommentService = comment_service;
|
mCommentService = comment_service;
|
||||||
mTokenQueue = new TokenQueue(token_service, this);
|
connect(this, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(customPopUpMenu(QPoint)));
|
||||||
connect(this, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(customPopUpMenu(QPoint)));
|
|
||||||
connect(this, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)), this, SLOT(setCurrentCommentMsgId(QTreeWidgetItem*, QTreeWidgetItem*)));
|
connect(this, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)), this, SLOT(setCurrentCommentMsgId(QTreeWidgetItem*, QTreeWidgetItem*)));
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
@ -529,25 +514,80 @@ void GxsCommentTreeWidget::service_requestComments(const RsGxsGroupId& group_id,
|
||||||
std::cerr << "GxsCommentTreeWidget::service_requestComments for group " << group_id << std::endl;
|
std::cerr << "GxsCommentTreeWidget::service_requestComments for group " << group_id << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
std::vector<RsGxsGrpMsgIdPair> ids_to_ask;
|
RsThread::async([this,group_id,msgIds]()
|
||||||
|
|
||||||
for(std::set<RsGxsMessageId>::const_iterator it(msgIds.begin());it!=msgIds.end();++it)
|
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_GXSCOMMENT_TREEWIDGET
|
std::vector<RsGxsComment> comments;
|
||||||
std::cerr << " asking for msg " << *it << std::endl;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
ids_to_ask.push_back(std::make_pair(group_id,*it));
|
if(!mCommentService->getRelatedComments(group_id,msgIds,comments))
|
||||||
}
|
{
|
||||||
|
std::cerr << __PRETTY_FUNCTION__ << " failed to get comments" << std::endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
RsTokReqOptions opts;
|
RsQThreadUtils::postToObject( [this,comments]()
|
||||||
opts.mReqType = GXS_REQUEST_TYPE_MSG_RELATED_DATA;
|
{
|
||||||
opts.mOptions = RS_TOKREQOPT_MSG_THREAD | RS_TOKREQOPT_MSG_LATEST;
|
/* Here it goes any code you want to be executed on the Qt Gui
|
||||||
|
* thread, for example to update the data model with new information
|
||||||
|
* after a blocking call to RetroShare API complete, note that
|
||||||
|
* Qt::QueuedConnection is important!
|
||||||
|
*/
|
||||||
|
|
||||||
uint32_t token;
|
clearItems();
|
||||||
mTokenQueue->requestMsgRelatedInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, ids_to_ask, GXSCOMMENTS_LOADTHREAD);
|
|
||||||
|
service_loadThread(comments);
|
||||||
|
|
||||||
|
completeItems();
|
||||||
|
|
||||||
|
emit commentsLoaded(treeCount(this));
|
||||||
|
|
||||||
|
}, this );
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef TODO
|
||||||
|
void GxsCommentTreeWidget::async_msg_action(const CmtMethod &action)
|
||||||
|
{
|
||||||
|
RsThread::async([this,action]()
|
||||||
|
{
|
||||||
|
// 1 - get message data from p3GxsForums
|
||||||
|
|
||||||
|
std::set<RsGxsMessageId> msgs_to_request ;
|
||||||
|
std::vector<RsGxsForumMsg> msgs;
|
||||||
|
|
||||||
|
msgs_to_request.insert(mThreadId);
|
||||||
|
|
||||||
|
if(!rsGxsForums->getForumContent(groupId(),msgs_to_request,msgs))
|
||||||
|
{
|
||||||
|
std::cerr << __PRETTY_FUNCTION__ << " failed to retrieve forum message info for forum " << groupId() << " and thread " << mThreadId << std::endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(msgs.size() != 1)
|
||||||
|
{
|
||||||
|
std::cerr << __PRETTY_FUNCTION__ << " more than 1 or no msgs selected in forum " << groupId() << std::endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2 - sort the messages into a proper hierarchy
|
||||||
|
|
||||||
|
RsGxsForumMsg msg = msgs[0];
|
||||||
|
|
||||||
|
// 3 - update the model in the UI thread.
|
||||||
|
|
||||||
|
RsQThreadUtils::postToObject( [msg,action,this]()
|
||||||
|
{
|
||||||
|
/* Here it goes any code you want to be executed on the Qt Gui
|
||||||
|
* thread, for example to update the data model with new information
|
||||||
|
* after a blocking call to RetroShare API complete */
|
||||||
|
|
||||||
|
(this->*action)(msg);
|
||||||
|
|
||||||
|
}, this );
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* Generic Handling */
|
/* Generic Handling */
|
||||||
void GxsCommentTreeWidget::clearItems()
|
void GxsCommentTreeWidget::clearItems()
|
||||||
|
@ -673,7 +713,7 @@ void GxsCommentTreeWidget::addItem(RsGxsMessageId itemId, RsGxsMessageId parentI
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int treeCount(QTreeWidget *tree, QTreeWidgetItem *parent = 0)
|
int GxsCommentTreeWidget::treeCount(QTreeWidget *tree, QTreeWidgetItem *parent)
|
||||||
{
|
{
|
||||||
int count = 0;
|
int count = 0;
|
||||||
if (parent == 0)
|
if (parent == 0)
|
||||||
|
@ -694,45 +734,11 @@ int treeCount(QTreeWidget *tree, QTreeWidgetItem *parent = 0)
|
||||||
}
|
}
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
void GxsCommentTreeWidget::loadThread(const uint32_t &token)
|
|
||||||
|
void GxsCommentTreeWidget::service_loadThread(const std::vector<RsGxsComment>& comments)
|
||||||
{
|
{
|
||||||
clearItems();
|
std::cerr << "GxsCommentTreeWidget::service_loadThread() ERROR must be overloaded!";
|
||||||
|
std::cerr << std::endl;
|
||||||
service_loadThread(token);
|
|
||||||
|
|
||||||
completeItems();
|
|
||||||
|
|
||||||
emit commentsLoaded(treeCount(this));
|
|
||||||
}
|
|
||||||
|
|
||||||
void GxsCommentTreeWidget::acknowledgeComment(const uint32_t &token)
|
|
||||||
{
|
|
||||||
RsGxsGrpMsgIdPair msgId;
|
|
||||||
mCommentService->acknowledgeComment(token, msgId);
|
|
||||||
|
|
||||||
// simply reload data
|
|
||||||
service_requestComments(mGroupId,mMsgVersions);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void GxsCommentTreeWidget::acknowledgeVote(const uint32_t &token)
|
|
||||||
{
|
|
||||||
RsGxsGrpMsgIdPair msgId;
|
|
||||||
if (mCommentService->acknowledgeVote(token, msgId))
|
|
||||||
{
|
|
||||||
// reload data if vote was added.
|
|
||||||
service_requestComments(mGroupId,mMsgVersions);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void GxsCommentTreeWidget::service_loadThread(const uint32_t &token)
|
|
||||||
{
|
|
||||||
std::cerr << "GxsCommentTreeWidget::service_loadThread() ERROR must be overloaded!";
|
|
||||||
std::cerr << std::endl;
|
|
||||||
|
|
||||||
std::vector<RsGxsComment> comments;
|
|
||||||
mCommentService->getRelatedComments(token, comments);
|
|
||||||
|
|
||||||
// This is inconsistent since we cannot know here that all comments are for the same thread. However they are only
|
// This is inconsistent since we cannot know here that all comments are for the same thread. However they are only
|
||||||
// requested in requestComments() where a single MsgId is used.
|
// requested in requestComments() where a single MsgId is used.
|
||||||
|
@ -821,10 +827,7 @@ void GxsCommentTreeWidget::insertComments(const std::vector<RsGxsComment>& comme
|
||||||
// now set all loaded comments as not new, since they have been loaded.
|
// now set all loaded comments as not new, since they have been loaded.
|
||||||
|
|
||||||
for(auto cid:new_comments)
|
for(auto cid:new_comments)
|
||||||
{
|
mCommentService->setCommentReadStatus(RsGxsGrpMsgIdPair(mGroupId,cid),true);
|
||||||
uint32_t token=0;
|
|
||||||
mCommentService->setCommentAsRead(token,mGroupId,cid);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QTreeWidgetItem *GxsCommentTreeWidget::service_createMissingItem(const RsGxsMessageId& parent)
|
QTreeWidgetItem *GxsCommentTreeWidget::service_createMissingItem(const RsGxsMessageId& parent)
|
||||||
|
@ -852,50 +855,3 @@ QTreeWidgetItem *GxsCommentTreeWidget::service_createMissingItem(const RsGxsMess
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void GxsCommentTreeWidget::loadRequest(const TokenQueue *queue, const TokenRequest &req)
|
|
||||||
{
|
|
||||||
#ifdef DEBUG_GXSCOMMENT_TREEWIDGET
|
|
||||||
std::cerr << "GxsCommentTreeWidget::loadRequest() UserType: " << req.mUserType;
|
|
||||||
std::cerr << std::endl;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (queue != mTokenQueue)
|
|
||||||
{
|
|
||||||
std::cerr << "GxsCommentTreeWidget::loadRequest() Queue ERROR";
|
|
||||||
std::cerr << std::endl;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* now switch on req */
|
|
||||||
switch(req.mType)
|
|
||||||
{
|
|
||||||
|
|
||||||
case TOKENREQ_MSGINFO:
|
|
||||||
{
|
|
||||||
switch(req.mAnsType)
|
|
||||||
{
|
|
||||||
case RS_TOKREQ_ANSTYPE_ACK:
|
|
||||||
if (req.mUserType == COMMENT_VOTE_ACK)
|
|
||||||
{
|
|
||||||
acknowledgeVote(req.mToken);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
acknowledgeComment(req.mToken);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case RS_TOKREQ_ANSTYPE_DATA:
|
|
||||||
loadThread(req.mToken);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
std::cerr << "GxsCommentTreeWidget::loadRequest() UNKNOWN UserType ";
|
|
||||||
std::cerr << std::endl;
|
|
||||||
break;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -24,26 +24,24 @@
|
||||||
#include <QTreeWidget>
|
#include <QTreeWidget>
|
||||||
#include <QMutex>
|
#include <QMutex>
|
||||||
|
|
||||||
#include "util/TokenQueue.h"
|
|
||||||
#include <retroshare/rsgxscommon.h>
|
#include <retroshare/rsgxscommon.h>
|
||||||
#include <retroshare/rsidentity.h>
|
#include <retroshare/rsidentity.h>
|
||||||
|
|
||||||
class RSTreeWidgetItemCompareRole;
|
class RSTreeWidgetItemCompareRole;
|
||||||
|
|
||||||
class GxsCommentTreeWidget : public QTreeWidget, public TokenResponse
|
class GxsCommentTreeWidget : public QTreeWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
GxsCommentTreeWidget(QWidget *parent = 0);
|
GxsCommentTreeWidget(QWidget *parent = 0);
|
||||||
~GxsCommentTreeWidget();
|
~GxsCommentTreeWidget();
|
||||||
void setup(RsTokenService *token_service, RsGxsCommentService *comment_service);
|
void setup(RsGxsCommentService *comment_service);
|
||||||
|
|
||||||
void requestComments(const RsGxsGroupId& group, const std::set<RsGxsMessageId> &message_versions, const RsGxsMessageId &most_recent_message);
|
void requestComments(const RsGxsGroupId& group, const std::set<RsGxsMessageId> &message_versions, const RsGxsMessageId &most_recent_message);
|
||||||
void getCurrentMsgId(RsGxsMessageId& parentId);
|
void getCurrentMsgId(RsGxsMessageId& parentId);
|
||||||
void applyRankings(std::map<RsGxsMessageId, uint32_t>& positions);
|
void applyRankings(std::map<RsGxsMessageId, uint32_t>& positions);
|
||||||
|
|
||||||
void loadRequest(const TokenQueue *queue, const TokenRequest &req);
|
|
||||||
void setVoteId(const RsGxsId &voterId);
|
void setVoteId(const RsGxsId &voterId);
|
||||||
|
|
||||||
void setUseCache(bool b) { mUseCache = b ;}
|
void setUseCache(bool b) { mUseCache = b ;}
|
||||||
|
@ -56,20 +54,17 @@ protected:
|
||||||
|
|
||||||
/* to be overloaded */
|
/* to be overloaded */
|
||||||
virtual void service_requestComments(const RsGxsGroupId &group_id, const std::set<RsGxsMessageId> &msgIds);
|
virtual void service_requestComments(const RsGxsGroupId &group_id, const std::set<RsGxsMessageId> &msgIds);
|
||||||
virtual void service_loadThread(const uint32_t &token);
|
virtual void service_loadThread(const std::vector<RsGxsComment>& comments);
|
||||||
|
|
||||||
virtual QTreeWidgetItem *service_createMissingItem(const RsGxsMessageId& parent);
|
virtual QTreeWidgetItem *service_createMissingItem(const RsGxsMessageId& parent);
|
||||||
|
|
||||||
void clearItems();
|
void clearItems();
|
||||||
void completeItems();
|
void completeItems();
|
||||||
|
|
||||||
void acknowledgeComment(const uint32_t& token);
|
|
||||||
void acknowledgeVote(const uint32_t &token);
|
|
||||||
|
|
||||||
void loadThread(const uint32_t &token);
|
|
||||||
|
|
||||||
void insertComments(const std::vector<RsGxsComment>& comments);
|
void insertComments(const std::vector<RsGxsComment>& comments);
|
||||||
void addItem(RsGxsMessageId itemId, RsGxsMessageId parentId, QTreeWidgetItem *item);
|
void addItem(RsGxsMessageId itemId, RsGxsMessageId parentId, QTreeWidgetItem *item);
|
||||||
|
|
||||||
|
static int treeCount(QTreeWidget *tree, QTreeWidgetItem *parent = 0);
|
||||||
public slots:
|
public slots:
|
||||||
void customPopUpMenu(const QPoint& point);
|
void customPopUpMenu(const QPoint& point);
|
||||||
void setCurrentCommentMsgId(QTreeWidgetItem* current, QTreeWidgetItem* previous);
|
void setCurrentCommentMsgId(QTreeWidgetItem* current, QTreeWidgetItem* previous);
|
||||||
|
@ -112,8 +107,6 @@ protected:
|
||||||
|
|
||||||
RSTreeWidgetItemCompareRole *commentsRole;
|
RSTreeWidgetItemCompareRole *commentsRole;
|
||||||
|
|
||||||
TokenQueue *mTokenQueue;
|
|
||||||
RsTokenService *mRsTokenService;
|
|
||||||
RsGxsCommentService *mCommentService;
|
RsGxsCommentService *mCommentService;
|
||||||
|
|
||||||
bool mUseCache;
|
bool mUseCache;
|
||||||
|
|
|
@ -25,7 +25,6 @@
|
||||||
#include <retroshare/rsidentity.h>
|
#include <retroshare/rsidentity.h>
|
||||||
|
|
||||||
#include "retroshare/rsgxscommon.h"
|
#include "retroshare/rsgxscommon.h"
|
||||||
#include "util/TokenQueue.h"
|
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class GxsCreateCommentDialog;
|
class GxsCreateCommentDialog;
|
||||||
|
|
|
@ -52,11 +52,6 @@ protected:
|
||||||
//virtual bool isLoading();
|
//virtual bool isLoading();
|
||||||
//virtual void fillDisplay(RsGxsUpdateBroadcastBase *updateBroadcastBase, bool complete);
|
//virtual void fillDisplay(RsGxsUpdateBroadcastBase *updateBroadcastBase, bool complete);
|
||||||
|
|
||||||
#ifdef TO_REMOVE
|
|
||||||
/* TokenResponse */
|
|
||||||
virtual void loadRequest(const TokenQueue *queue, const TokenRequest &req);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
void comments(const QString &title);
|
void comments(const QString &title);
|
||||||
void copyMessageLink();
|
void copyMessageLink();
|
||||||
|
|
|
@ -724,7 +724,7 @@ void GxsGroupFrameDialog::loadComment(const RsGxsGroupId &grpId, const QVector<R
|
||||||
comments += "…";
|
comments += "…";
|
||||||
}
|
}
|
||||||
|
|
||||||
commentDialog = new GxsCommentDialog(this,RsGxsId(), mInterface->getTokenService(), commentService);
|
commentDialog = new GxsCommentDialog(this,RsGxsId(), commentService);
|
||||||
|
|
||||||
QWidget *commentHeader = createCommentHeaderWidget(grpId, most_recent_msgId);
|
QWidget *commentHeader = createCommentHeaderWidget(grpId, most_recent_msgId);
|
||||||
if (commentHeader) {
|
if (commentHeader) {
|
||||||
|
|
|
@ -28,7 +28,6 @@ GxsMessageFrameWidget::GxsMessageFrameWidget(RsGxsIfaceHelper *ifaceImpl, QWidge
|
||||||
{
|
{
|
||||||
mNextTokenType = 0;
|
mNextTokenType = 0;
|
||||||
|
|
||||||
mTokenQueue = new TokenQueue(ifaceImpl->getTokenService(), this);
|
|
||||||
mStateHelper = new UIStateHelper(this);
|
mStateHelper = new UIStateHelper(this);
|
||||||
|
|
||||||
/* Set read status */
|
/* Set read status */
|
||||||
|
@ -46,8 +45,6 @@ GxsMessageFrameWidget::~GxsMessageFrameWidget()
|
||||||
|
|
||||||
emit waitingChanged(this);
|
emit waitingChanged(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
delete(mTokenQueue);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const RsGxsGroupId &GxsMessageFrameWidget::groupId()
|
const RsGxsGroupId &GxsMessageFrameWidget::groupId()
|
||||||
|
@ -95,34 +92,6 @@ void GxsMessageFrameWidget::setGroupId(const RsGxsGroupId &groupId)
|
||||||
|
|
||||||
void GxsMessageFrameWidget::setAllMessagesRead(bool read)
|
void GxsMessageFrameWidget::setAllMessagesRead(bool read)
|
||||||
{
|
{
|
||||||
uint32_t token = 0;
|
setAllMessagesReadDo(read);
|
||||||
setAllMessagesReadDo(read, token);
|
|
||||||
|
|
||||||
if (token) {
|
|
||||||
/* Wait for acknowlegde of the token */
|
|
||||||
mAcknowledgeReadStatusToken = token;
|
|
||||||
mTokenQueue->queueRequest(mAcknowledgeReadStatusToken, 0, 0, mTokenTypeAcknowledgeReadStatus);
|
|
||||||
mStateHelper->setLoading(mTokenTypeAcknowledgeReadStatus, true);
|
|
||||||
|
|
||||||
emit waitingChanged(this);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GxsMessageFrameWidget::loadRequest(const TokenQueue *queue, const TokenRequest &req)
|
|
||||||
{
|
|
||||||
if (queue == mTokenQueue)
|
|
||||||
{
|
|
||||||
if (req.mUserType == mTokenTypeAcknowledgeReadStatus) {
|
|
||||||
if (mAcknowledgeReadStatusToken == req.mToken) {
|
|
||||||
/* Set read status is finished */
|
|
||||||
mStateHelper->setLoading(mTokenTypeAcknowledgeReadStatus, false);
|
|
||||||
|
|
||||||
emit waitingChanged(this);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
std::cerr << "GxsMessageFrameWidget::loadRequest() ERROR: INVALID TYPE";
|
|
||||||
std::cerr << std::endl;
|
|
||||||
}
|
|
||||||
|
|
|
@ -22,12 +22,11 @@
|
||||||
#define GXSMESSAGEFRAMEWIDGET_H
|
#define GXSMESSAGEFRAMEWIDGET_H
|
||||||
|
|
||||||
#include "gui/gxs/RsGxsUpdateBroadcastWidget.h"
|
#include "gui/gxs/RsGxsUpdateBroadcastWidget.h"
|
||||||
#include "util/TokenQueue.h"
|
|
||||||
|
|
||||||
struct RsGxsIfaceHelper;
|
struct RsGxsIfaceHelper;
|
||||||
class UIStateHelper;
|
class UIStateHelper;
|
||||||
|
|
||||||
class GxsMessageFrameWidget : public QWidget, public TokenResponse
|
class GxsMessageFrameWidget : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
@ -49,7 +48,6 @@ public:
|
||||||
|
|
||||||
/* GXS functions */
|
/* GXS functions */
|
||||||
uint32_t nextTokenType() { return ++mNextTokenType; }
|
uint32_t nextTokenType() { return ++mNextTokenType; }
|
||||||
virtual void loadRequest(const TokenQueue *queue, const TokenRequest &req);
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void groupChanged(QWidget *widget);
|
void groupChanged(QWidget *widget);
|
||||||
|
@ -58,10 +56,9 @@ signals:
|
||||||
void groupDataLoaded();
|
void groupDataLoaded();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void setAllMessagesReadDo(bool read, uint32_t &token) = 0;
|
virtual void setAllMessagesReadDo(bool read) = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
TokenQueue *mTokenQueue;
|
|
||||||
UIStateHelper *mStateHelper;
|
UIStateHelper *mStateHelper;
|
||||||
|
|
||||||
/* Set read status */
|
/* Set read status */
|
||||||
|
|
|
@ -24,9 +24,8 @@
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include "gui/common/UserNotify.h"
|
#include "gui/common/UserNotify.h"
|
||||||
#include "gui/gxs/GxsGroupFrameDialog.h"
|
#include "gui/gxs/GxsGroupFrameDialog.h"
|
||||||
#include "util/TokenQueue.h"
|
|
||||||
|
|
||||||
struct RsGxsIfaceHelper;
|
class RsGxsIfaceHelper;
|
||||||
class RsGxsUpdateBroadcastBase;
|
class RsGxsUpdateBroadcastBase;
|
||||||
|
|
||||||
class GxsUserNotify : public UserNotify
|
class GxsUserNotify : public UserNotify
|
||||||
|
|
|
@ -798,7 +798,7 @@ void RsGxsChannelPostsModel::setAllMsgReadStatus(bool read_status)
|
||||||
for(uint32_t i=0;i<pairs.size();++i)
|
for(uint32_t i=0;i<pairs.size();++i)
|
||||||
RsThread::async([p=pairs[i], read_status]() // use async because each markRead() waits for the token to complete in order to properly acknowledge it.
|
RsThread::async([p=pairs[i], read_status]() // use async because each markRead() waits for the token to complete in order to properly acknowledge it.
|
||||||
{
|
{
|
||||||
if(!rsGxsChannels->markRead(p,read_status))
|
if(!rsGxsChannels->setMessageReadStatus(p,read_status))
|
||||||
RsErr() << "setAllMsgReadStatus: failed to change status of msg " << p.first << " in group " << p.second << " to status " << read_status << std::endl;
|
RsErr() << "setAllMsgReadStatus: failed to change status of msg " << p.first << " in group " << p.second << " to status " << read_status << std::endl;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -816,7 +816,7 @@ void RsGxsChannelPostsModel::setMsgReadStatus(const QModelIndex& i,bool read_sta
|
||||||
if(!convertRefPointerToTabEntry(ref,entry) || entry >= mFilteredPosts.size())
|
if(!convertRefPointerToTabEntry(ref,entry) || entry >= mFilteredPosts.size())
|
||||||
return ;
|
return ;
|
||||||
|
|
||||||
rsGxsChannels->markRead(RsGxsGrpMsgIdPair(mPosts[mFilteredPosts[entry]].mMeta.mGroupId,mPosts[mFilteredPosts[entry]].mMeta.mMsgId),read_status);
|
rsGxsChannels->setMessageReadStatus(RsGxsGrpMsgIdPair(mPosts[mFilteredPosts[entry]].mMeta.mGroupId,mPosts[mFilteredPosts[entry]].mMeta.mMsgId),read_status);
|
||||||
}
|
}
|
||||||
|
|
||||||
QModelIndex RsGxsChannelPostsModel::getIndexOfMessage(const RsGxsMessageId& mid) const
|
QModelIndex RsGxsChannelPostsModel::getIndexOfMessage(const RsGxsMessageId& mid) const
|
||||||
|
|
|
@ -487,7 +487,7 @@ GxsChannelPostsWidgetWithModel::GxsChannelPostsWidgetWithModel(const RsGxsGroupI
|
||||||
setAutoDownload(false);
|
setAutoDownload(false);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ui->commentsDialog->setTokenService(rsGxsChannels->getTokenService(),rsGxsChannels);
|
ui->commentsDialog->setGxsService(rsGxsChannels);
|
||||||
|
|
||||||
/* Initialize GUI */
|
/* Initialize GUI */
|
||||||
settingsChanged();
|
settingsChanged();
|
||||||
|
@ -852,7 +852,7 @@ void GxsChannelPostsWidgetWithModel::showPostDetails()
|
||||||
postId.second = post.mMeta.mMsgId;
|
postId.second = post.mMeta.mMsgId;
|
||||||
postId.first = post.mMeta.mGroupId;
|
postId.first = post.mMeta.mGroupId;
|
||||||
|
|
||||||
RsThread::async([postId]() { rsGxsChannels->markRead(postId, true) ; } );
|
RsThread::async([postId]() { rsGxsChannels->setMessageReadStatus(postId, true) ; } );
|
||||||
}
|
}
|
||||||
|
|
||||||
updateDAll_PB();
|
updateDAll_PB();
|
||||||
|
@ -1432,7 +1432,7 @@ public:
|
||||||
uint32_t mLastToken;
|
uint32_t mLastToken;
|
||||||
};
|
};
|
||||||
|
|
||||||
void GxsChannelPostsWidgetWithModel::setAllMessagesReadDo(bool read, uint32_t& /*token*/)
|
void GxsChannelPostsWidgetWithModel::setAllMessagesReadDo(bool read)
|
||||||
{
|
{
|
||||||
if (groupId().isNull() || !IS_GROUP_SUBSCRIBED(mGroup.mMeta.mSubscribeFlags))
|
if (groupId().isNull() || !IS_GROUP_SUBSCRIBED(mGroup.mMeta.mSubscribeFlags))
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -137,7 +137,7 @@ protected:
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* GxsMessageFrameWidget */
|
/* GxsMessageFrameWidget */
|
||||||
virtual void setAllMessagesReadDo(bool read, uint32_t &token) override;
|
virtual void setAllMessagesReadDo(bool read) override;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void showPostDetails();
|
void showPostDetails();
|
||||||
|
|
|
@ -39,6 +39,7 @@
|
||||||
|
|
||||||
#include "util/HandleRichText.h"
|
#include "util/HandleRichText.h"
|
||||||
#include "util/misc.h"
|
#include "util/misc.h"
|
||||||
|
#include "util/qtthreadsutils.h"
|
||||||
|
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
@ -60,10 +61,6 @@ CreateGxsForumMsg::CreateGxsForumMsg(const RsGxsGroupId &fId, const RsGxsMessage
|
||||||
|
|
||||||
setAttribute(Qt::WA_DeleteOnClose, true);
|
setAttribute(Qt::WA_DeleteOnClose, true);
|
||||||
|
|
||||||
/* Setup Queue */
|
|
||||||
mForumQueue = new TokenQueue(rsGxsForums->getTokenService(), this);
|
|
||||||
mCirclesQueue = new TokenQueue(rsGxsCircles->getTokenService(), this);
|
|
||||||
|
|
||||||
/* Setup UI helper */
|
/* Setup UI helper */
|
||||||
mStateHelper = new UIStateHelper(this);
|
mStateHelper = new UIStateHelper(this);
|
||||||
mStateHelper->addWidget(CREATEGXSFORUMMSG_FORUMINFO, ui.postButton);
|
mStateHelper->addWidget(CREATEGXSFORUMMSG_FORUMINFO, ui.postButton);
|
||||||
|
@ -133,8 +130,6 @@ CreateGxsForumMsg::CreateGxsForumMsg(const RsGxsGroupId &fId, const RsGxsMessage
|
||||||
CreateGxsForumMsg::~CreateGxsForumMsg()
|
CreateGxsForumMsg::~CreateGxsForumMsg()
|
||||||
{
|
{
|
||||||
processSettings(false);
|
processSettings(false);
|
||||||
delete(mForumQueue);
|
|
||||||
delete(mCirclesQueue);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CreateGxsForumMsg::processSettings(bool load)
|
void CreateGxsForumMsg::processSettings(bool load)
|
||||||
|
@ -194,59 +189,109 @@ void CreateGxsForumMsg::newMsg()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
{/* request Data */
|
|
||||||
mStateHelper->setLoading(CREATEGXSFORUMMSG_FORUMINFO, true);
|
mStateHelper->setLoading(CREATEGXSFORUMMSG_FORUMINFO, true);
|
||||||
|
|
||||||
RsTokReqOptions opts;
|
RsThread::async( [this]()
|
||||||
opts.mReqType = GXS_REQUEST_TYPE_GROUP_META;
|
{
|
||||||
|
// We only need group Meta information, but forums do not provide it currently
|
||||||
|
|
||||||
std::list<RsGxsGroupId> groupIds;
|
std::vector<RsGxsForumGroup> forums_info;
|
||||||
groupIds.push_back(mForumId);
|
rsGxsForums->getForumsInfo(std::list<RsGxsGroupId>{ mForumId },forums_info);
|
||||||
|
|
||||||
//std::cerr << "ForumsV2Dialog::newMsg() Requesting Group Summary(" << mForumId << ")"<< std::endl;
|
|
||||||
|
|
||||||
uint32_t token;
|
RsQThreadUtils::postToObject( [this,forums_info]()
|
||||||
mForumQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_SUMMARY, opts, groupIds, CREATEGXSFORUMMSG_FORUMINFO);
|
{
|
||||||
}/* request Data */
|
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);
|
mStateHelper->setActive(CREATEGXSFORUMMSG_PARENTMSG, true);
|
||||||
mParentMsgLoaded = true;
|
mParentMsgLoaded = true;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
mStateHelper->setLoading(CREATEGXSFORUMMSG_PARENTMSG, true);
|
mStateHelper->setLoading(CREATEGXSFORUMMSG_PARENTMSG, true);
|
||||||
|
|
||||||
RsTokReqOptions opts;
|
RsThread::async( [this]() {
|
||||||
opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA;
|
|
||||||
|
|
||||||
GxsMsgReq msgIds;
|
std::vector<RsGxsForumMsg> parent_msgs;
|
||||||
std::set<RsGxsMessageId> &vect = msgIds[mForumId];
|
rsGxsForums->getForumContent(mForumId,std::set<RsGxsMessageId>{ mParentId },parent_msgs);
|
||||||
vect.insert(mParentId);
|
|
||||||
|
|
||||||
//std::cerr << "ForumsV2Dialog::newMsg() Requesting Parent Summary(" << mParentId << ")";
|
RsQThreadUtils::postToObject( [this,parent_msgs]() {
|
||||||
//std::cerr << std::endl;
|
if(parent_msgs.size() != 1)
|
||||||
|
{
|
||||||
|
RsErr() << "Cannot get parent message from forum." ;
|
||||||
|
|
||||||
uint32_t token;
|
mStateHelper->setActive(CREATEGXSFORUMMSG_PARENTMSG, false);
|
||||||
mForumQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgIds, CREATEGXSFORUMMSG_PARENTMSG);
|
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);
|
mStateHelper->setActive(CREATEGXSFORUMMSG_ORIGMSG, true);
|
||||||
mOrigMsgLoaded = true;
|
mOrigMsgLoaded = true;
|
||||||
} else {
|
}
|
||||||
mStateHelper->setLoading(CREATEGXSFORUMMSG_ORIGMSG, true);
|
else
|
||||||
|
{
|
||||||
|
mStateHelper->setLoading(CREATEGXSFORUMMSG_ORIGMSG , true);
|
||||||
|
|
||||||
RsTokReqOptions opts;
|
RsThread::async( [this]() {
|
||||||
opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA;
|
|
||||||
|
|
||||||
GxsMsgReq msgIds;
|
std::vector<RsGxsForumMsg> orig_msgs;
|
||||||
std::set<RsGxsMessageId> &vect = msgIds[mForumId];
|
rsGxsForums->getForumContent(mForumId,std::set<RsGxsMessageId>{ mOrigMsgId },orig_msgs);
|
||||||
vect.insert(mOrigMsgId);
|
|
||||||
|
|
||||||
//std::cerr << "ForumsV2Dialog::newMsg() Requesting Parent Summary(" << mParentId << ")";
|
RsQThreadUtils::postToObject( [this,orig_msgs]() {
|
||||||
//std::cerr << std::endl;
|
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())
|
else if (!mParentId.isNull())
|
||||||
{
|
{
|
||||||
QString title = QString::fromUtf8(mParentMsg.mMeta.mMsgName.c_str());
|
QString title = QString::fromUtf8(mParentMsg.mMeta.mMsgName.c_str());
|
||||||
name += " " + tr("In Reply to") + ": ";
|
name += " - " + tr("In Reply to") + ": ";
|
||||||
name += title;
|
name += title;
|
||||||
|
|
||||||
QString text = title;
|
QString text = title;
|
||||||
|
@ -583,181 +628,52 @@ void CreateGxsForumMsg::fileHashingFinished(QList<HashedFile> hashedFiles)
|
||||||
ui.hashGroupBox->hide();
|
ui.hashGroupBox->hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CreateGxsForumMsg::loadForumInfo(const uint32_t &token)
|
void CreateGxsForumMsg::loadCircleInfo(const RsGxsGroupId& circle_id)
|
||||||
{
|
|
||||||
//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)
|
|
||||||
{
|
{
|
||||||
//std::cerr << "Loading forum circle info" << std::endl;
|
//std::cerr << "Loading forum circle info" << std::endl;
|
||||||
|
|
||||||
std::vector<RsGxsCircleGroup> circle_grp_v ;
|
RsThread::async( [circle_id,this]()
|
||||||
rsGxsCircles->getGroupData(token, circle_grp_v);
|
|
||||||
|
|
||||||
if (circle_grp_v.empty())
|
|
||||||
{
|
{
|
||||||
std::cerr << "(EE) unexpected empty result from getGroupData. Cannot process circle now!" << std::endl;
|
std::vector<RsGxsCircleGroup> circle_grp_v ;
|
||||||
return ;
|
rsGxsCircles->getCirclesInfo(std::list<RsGxsGroupId>{ circle_id }, circle_grp_v);
|
||||||
}
|
|
||||||
|
|
||||||
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();
|
|
||||||
|
|
||||||
mForumCircleData = cg;
|
if (circle_grp_v.empty())
|
||||||
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)
|
|
||||||
{
|
{
|
||||||
switch(req.mUserType)
|
std::cerr << "(EE) unexpected empty result from getGroupData. Cannot process circle now!" << std::endl;
|
||||||
{
|
return ;
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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)
|
void CreateGxsForumMsg::setSubject(const QString& msg)
|
||||||
{
|
{
|
||||||
ui.forumSubject->setText(msg);
|
ui.forumSubject->setText(msg);
|
||||||
|
|
|
@ -23,14 +23,12 @@
|
||||||
|
|
||||||
#include "ui_CreateGxsForumMsg.h"
|
#include "ui_CreateGxsForumMsg.h"
|
||||||
|
|
||||||
#include "util/TokenQueue.h"
|
|
||||||
|
|
||||||
#include <retroshare/rsgxsforums.h>
|
#include <retroshare/rsgxsforums.h>
|
||||||
#include <retroshare/rsgxscircles.h>
|
#include <retroshare/rsgxscircles.h>
|
||||||
|
|
||||||
class UIStateHelper;
|
class UIStateHelper;
|
||||||
|
|
||||||
class CreateGxsForumMsg : public QDialog, public TokenResponse
|
class CreateGxsForumMsg : public QDialog
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
@ -39,7 +37,6 @@ public:
|
||||||
~CreateGxsForumMsg();
|
~CreateGxsForumMsg();
|
||||||
|
|
||||||
void newMsg(); /* cleanup */
|
void newMsg(); /* cleanup */
|
||||||
virtual void loadRequest(const TokenQueue *queue, const TokenRequest &req);
|
|
||||||
void insertPastedText(const QString& msg) ;
|
void insertPastedText(const QString& msg) ;
|
||||||
void setSubject(const QString& msg);
|
void setSubject(const QString& msg);
|
||||||
|
|
||||||
|
@ -58,15 +55,11 @@ private slots:
|
||||||
protected:
|
protected:
|
||||||
void closeEvent (QCloseEvent * event);
|
void closeEvent (QCloseEvent * event);
|
||||||
|
|
||||||
|
void loadCircleInfo(const RsGxsGroupId& circle_id);
|
||||||
private:
|
private:
|
||||||
void processSettings(bool load);
|
void processSettings(bool load);
|
||||||
void loadFormInformation();
|
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;
|
RsGxsGroupId mForumId;
|
||||||
RsGxsCircleId mCircleId ;
|
RsGxsCircleId mCircleId ;
|
||||||
RsGxsMessageId mParentId;
|
RsGxsMessageId mParentId;
|
||||||
|
@ -84,9 +77,6 @@ private:
|
||||||
RsGroupMetaData mForumMeta;
|
RsGroupMetaData mForumMeta;
|
||||||
RsGxsCircleGroup mForumCircleData ;
|
RsGxsCircleGroup mForumCircleData ;
|
||||||
|
|
||||||
TokenQueue *mForumQueue;
|
|
||||||
TokenQueue *mCirclesQueue;
|
|
||||||
|
|
||||||
UIStateHelper *mStateHelper;
|
UIStateHelper *mStateHelper;
|
||||||
|
|
||||||
/** Qt Designer generated object */
|
/** Qt Designer generated object */
|
||||||
|
|
|
@ -1503,7 +1503,7 @@ void GxsForumThreadWidget::markMsgAsUnreadChildren()
|
||||||
markMsgAsReadUnread(false, true, false);
|
markMsgAsReadUnread(false, true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GxsForumThreadWidget::setAllMessagesReadDo(bool read, uint32_t &/*token*/)
|
void GxsForumThreadWidget::setAllMessagesReadDo(bool read)
|
||||||
{
|
{
|
||||||
markMsgAsReadUnread(read, true, true);
|
markMsgAsReadUnread(read, true, true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -102,7 +102,7 @@ protected:
|
||||||
virtual void updateDisplay(bool complete);
|
virtual void updateDisplay(bool complete);
|
||||||
|
|
||||||
/* GxsMessageFrameWidget */
|
/* GxsMessageFrameWidget */
|
||||||
virtual void setAllMessagesReadDo(bool read, uint32_t &token);
|
virtual void setAllMessagesReadDo(bool read);
|
||||||
|
|
||||||
void setMessageLoadingError(const QString& error);
|
void setMessageLoadingError(const QString& error);
|
||||||
private slots:
|
private slots:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue