removed TokenQueue from CircleCreationDialog

This commit is contained in:
csoler 2020-02-29 23:48:37 +01:00
parent 5ccc59e2ea
commit 8be92f24b6
No known key found for this signature in database
GPG Key ID: 7BCA522266C0804C
2 changed files with 71 additions and 158 deletions

View File

@ -29,6 +29,7 @@
#include <retroshare/rsidentity.h>
#include "gui/common/AvatarDefs.h"
#include "util/qtthreadsutils.h"
#include "gui/Circles/CreateCircleDialog.h"
#include "gui/gxs/GxsIdDetails.h"
#include "gui/Identity/IdDialog.h"
@ -51,9 +52,6 @@ CreateCircleDialog::CreateCircleDialog()
ui.setupUi(this);
/* Setup Queue */
mCircleQueue = new TokenQueue(rsGxsCircles->getTokenService(), this);
mIdQueue = new TokenQueue(rsIdentity->getTokenService(), this);
ui.headerFrame->setHeaderImage(QPixmap(":/icons/png/circles.png"));
// connect up the buttons.
@ -107,8 +105,6 @@ CreateCircleDialog::CreateCircleDialog()
CreateCircleDialog::~CreateCircleDialog()
{
delete(mCircleQueue);
delete(mIdQueue);
}
void CreateCircleDialog::editExistingId(const RsGxsGroupId &circleId, const bool &clearList /*= true*/,bool readonly)
@ -147,14 +143,15 @@ void CreateCircleDialog::editExistingId(const RsGxsGroupId &circleId, const bool
ui.removeButton->setEnabled(!readonly) ;
if(readonly)
{
ui.buttonBox->setStandardButtons(QDialogButtonBox::Cancel);
ui.buttonBox->button(QDialogButtonBox::Cancel)->setText(tr("Close"));
ui.peersSelection_GB->hide() ;
ui.addButton->hide() ;
ui.removeButton->hide() ;
}
requestCircle(circleId);
{
ui.buttonBox->setStandardButtons(QDialogButtonBox::Cancel);
ui.buttonBox->button(QDialogButtonBox::Cancel)->setText(tr("Close"));
ui.peersSelection_GB->hide() ;
ui.addButton->hide() ;
ui.removeButton->hide() ;
}
loadCircle(circleId);
}
@ -233,7 +230,7 @@ void CreateCircleDialog::setupForExternalCircle()
ui.idChooser->show();
//ui.toolButton_NewId->show();
requestGxsIdentities();
loadIdentities();
}
void CreateCircleDialog::selectedId(QTreeWidgetItem *current, QTreeWidgetItem *previous)
@ -663,107 +660,79 @@ void CreateCircleDialog::updateCircleGUI()
}
}
void CreateCircleDialog::requestCircle(const RsGxsGroupId &groupId)
void CreateCircleDialog::loadCircle(const RsGxsGroupId& groupId)
{
RsTokReqOptions opts;
opts.mReqType = GXS_REQUEST_TYPE_GROUP_DATA;
std::list<RsGxsGroupId> groupIds;
groupIds.push_back(groupId);
#ifdef DEBUG_CREATE_CIRCLE_DIALOG
std::cerr << "CreateCircleDialog::requestCircle() Requesting Group Summary(" << groupId << ")";
std::cerr << std::endl;
#endif
uint32_t token;
mCircleQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, groupIds, CREATECIRCLEDIALOG_CIRCLEINFO);
}
void CreateCircleDialog::loadCircle(uint32_t token)
{
#ifdef DEBUG_CREATE_CIRCLE_DIALOG
std::cerr << "CreateCircleDialog::loadCircle(" << token << ")";
std::cerr << std::endl;
#endif
QTreeWidget *tree = ui.treeWidget_membership;
if (mClearList) tree->clear();
std::vector<RsGxsCircleGroup> groups;
if (!rsGxsCircles->getGroupData(token, groups)) {
std::cerr << "CreateCircleDialog::loadCircle() Error getting GroupData";
std::cerr << std::endl;
return;
}
RsThread::async([groupId,this]()
{
std::vector<RsGxsCircleGroup> circlesInfo ;
if (groups.size() != 1) {
std::cerr << "CreateCircleDialog::loadCircle() Error Group.size() != 1";
std::cerr << std::endl;
return;
}
mCircleGroup = groups[0];
#ifdef DEBUG_CREATE_CIRCLE_DIALOG
std::cerr << "CreateCircleDialog::loadCircle() LoadedGroup.meta: " << mCircleGroup.mMeta << std::endl;
if(! rsGxsCircles->getCirclesInfo(std::list<RsGxsGroupId>({ groupId }), circlesInfo) || circlesInfo.size() != 1)
{
std::cerr << __PRETTY_FUNCTION__ << " failed to retrieve circle info for circle " << groupId << std::endl;
return;
}
RsGxsCircleGroup grp(circlesInfo[0]);
RsQThreadUtils::postToObject( [grp,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 */
mCircleGroup = grp;
#ifdef DEBUG_CREATE_CIRCLE_DIALOG
std::cerr << "CreateCircleDialog::loadCircle() LoadedGroup.meta: " << mCircleGroup.mMeta << std::endl;
#endif
updateCircleGUI();
updateCircleGUI();
}, this );
});
}
/*void CreateCircleDialog::getPgpIdentities()
void CreateCircleDialog::loadIdentities()
{
std::cerr << "CreateCircleDialog::getPgpIdentities()";
std::cerr << std::endl;
RsThread::async([this]()
{
std::list<RsGroupMetaData> ids_meta;
QTreeWidget *tree = ui.treeWidget_IdList;
if(!rsIdentity->getIdentitiesSummaries(ids_meta))
{
std::cerr << __PRETTY_FUNCTION__ << " failed to retrieve identities ids for all identities" << std::endl;
return;
}
std::set<RsGxsId> ids;
tree->clear();
std::list<RsPgpId> ids;
std::list<RsPgpId>::iterator it;
for(auto& meta:ids_meta)
ids.insert(RsGxsId(meta.mGroupId)) ;
rsPeers->getGPGAcceptedList(ids);
for(it = ids.begin(); it != ids.end(); ++it) {
RsPeerDetails details;
std::vector<RsGxsIdGroup> id_groups;
rsPeers->getGPGDetails(*it, details);
if(!rsIdentity->getIdentitiesInfo(ids,id_groups))
{
std::cerr << __PRETTY_FUNCTION__ << " failed to retrieve identities group info for all identities" << std::endl;
return;
}
QString keyId = QString::fromStdString(details.gpg_id.toStdString());
QString nickname = QString::fromUtf8(details.name.c_str());
QString idtype = tr("PGP Identity");
RsQThreadUtils::postToObject( [id_groups,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 */
QTreeWidgetItem *item = new QTreeWidgetItem();
item->setText(RSCIRCLEID_COL_NICKNAME, nickname);
item->setText(RSCIRCLEID_COL_KEYID, keyId);
item->setText(RSCIRCLEID_COL_IDTYPE, idtype);
tree->addTopLevelItem(item);
fillIdentitiesList(id_groups) ;
// Local Circle.
if (mIsExistingCircle)
if ( mCircleGroup.mLocalFriends.find(details.gpg_id) != mCircleGroup.mLocalFriends.end()) // check if its in the circle.
addMember(keyId, idtype, nickname);
}
filterIds();
}*/
}, this );
});
void CreateCircleDialog::requestGxsIdentities()
{
RsTokReqOptions opts;
opts.mReqType = GXS_REQUEST_TYPE_GROUP_DATA;
#ifdef DEBUG_CREATE_CIRCLE_DIALOG
std::cerr << "CreateCircleDialog::requestIdentities()";
std::cerr << std::endl;
#endif
uint32_t token;
mIdQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, CREATECIRCLEDIALOG_IDINFO);
}
void CreateCircleDialog::loadIdentities(uint32_t token)
void CreateCircleDialog::fillIdentitiesList(const std::vector<RsGxsIdGroup>& id_groups)
{
#ifdef DEBUG_CREATE_CIRCLE_DIALOG
std::cerr << "CreateCircleDialog::loadIdentities(" << token << ")";
@ -771,26 +740,14 @@ void CreateCircleDialog::loadIdentities(uint32_t token)
#endif
QTreeWidget *tree = ui.treeWidget_IdList;
tree->clear();
bool acceptAnonymous = ui.radioButton_ListAll->isChecked();
bool acceptAllPGP = ui.radioButton_ListAllPGP->isChecked();
//bool acceptKnownPGP = ui.radioButton_ListKnownPGP->isChecked();
RsGxsIdGroup idGroup;
std::vector<RsGxsIdGroup> datavector;
std::vector<RsGxsIdGroup>::iterator vit;
if (!rsIdentity->getGroupData(token, datavector)) {
std::cerr << "CreateCircleDialog::insertIdentities() Error getting GroupData";
std::cerr << std::endl;
return;
}
for(vit = datavector.begin(); vit != datavector.end(); ++vit)
for(const auto& idGroup:id_groups)
{
idGroup = (*vit);
/* do filtering */
bool ok = false;
if (acceptAnonymous)
@ -851,43 +808,9 @@ void CreateCircleDialog::loadIdentities(uint32_t token)
}
}
void CreateCircleDialog::loadRequest(const TokenQueue *queue, const TokenRequest &req)
{
#ifdef DEBUG_CREATE_CIRCLE_DIALOG
std::cerr << "CreateCircleDialog::loadRequest() UserType: " << req.mUserType;
std::cerr << std::endl;
#endif
if (queue == mCircleQueue) {
/* now switch on req */
switch(req.mUserType) {
case CREATECIRCLEDIALOG_CIRCLEINFO:
loadCircle(req.mToken);
break;
default:
std::cerr << "CreateCircleDialog::loadRequest() UNKNOWN UserType ";
std::cerr << std::endl;
}
}
if (queue == mIdQueue) {
/* now switch on req */
switch(req.mUserType) {
case CREATECIRCLEDIALOG_IDINFO:
loadIdentities(req.mToken);
break;
default:
std::cerr << "CreateCircleDialog::loadRequest() UNKNOWN UserType ";
std::cerr << std::endl;
}
}
}
void CreateCircleDialog::idTypeChanged()
{
requestGxsIdentities();
loadIdentities();
}
void CreateCircleDialog::filterChanged(const QString &text)
{

View File

@ -25,12 +25,10 @@
#include "ui_CreateCircleDialog.h"
#include "util/TokenQueue.h"
#include <retroshare/rsgxscircles.h>
#include <QDialog>
class CreateCircleDialog : public QDialog, public TokenResponse
class CreateCircleDialog : public QDialog
{
Q_OBJECT
@ -45,8 +43,6 @@ public:
void addMember(const RsGxsIdGroup &idGroup);
void addCircle(const RsGxsCircleDetails &cirDetails);
virtual void loadRequest(const TokenQueue *queue, const TokenRequest &req);
private slots:
void addMember();
void removeMember();
@ -75,17 +71,11 @@ private:
bool mIsExternalCircle;
bool mReadOnly;
void loadCircle(uint32_t token);
void loadIdentities(uint32_t token);
void requestCircle(const RsGxsGroupId &groupId);
void requestGxsIdentities();
//void getPgpIdentities();
void loadCircle(const RsGxsGroupId& groupId);
void loadIdentities();
void filterIds();
TokenQueue *mCircleQueue;
TokenQueue *mIdQueue;
void fillIdentitiesList(const std::vector<RsGxsIdGroup>& id_groups);
RsGxsCircleGroup mCircleGroup; // for editting existing Circles.
bool mClearList;