2013-03-24 12:29:08 -04:00
|
|
|
/*
|
|
|
|
* Retroshare Circles.
|
|
|
|
*
|
|
|
|
* Copyright 2012-2013 by Robert Fernie.
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License Version 2.1 as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
|
|
* USA.
|
|
|
|
*
|
|
|
|
* Please report all bugs and problems to "retroshare@lunamutt.com".
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <QMessageBox>
|
2013-07-14 21:03:39 -04:00
|
|
|
|
2014-02-04 03:10:44 -05:00
|
|
|
#include <algorithm>
|
2013-07-14 21:03:39 -04:00
|
|
|
#include "gui/Circles/CreateCircleDialog.h"
|
2013-03-24 12:29:08 -04:00
|
|
|
|
|
|
|
#include <retroshare/rspeers.h>
|
|
|
|
#include <retroshare/rsidentity.h>
|
2014-07-06 07:19:58 -04:00
|
|
|
#include "gui/Identity/IdDialog.h"
|
2013-03-24 12:29:08 -04:00
|
|
|
|
2014-03-17 16:56:06 -04:00
|
|
|
#include <algorithm>
|
|
|
|
|
2013-07-14 21:03:39 -04:00
|
|
|
#define CREATECIRCLEDIALOG_CIRCLEINFO 2
|
|
|
|
#define CREATECIRCLEDIALOG_IDINFO 3
|
2013-03-24 12:29:08 -04:00
|
|
|
|
|
|
|
#define RSCIRCLEID_COL_NICKNAME 0
|
|
|
|
#define RSCIRCLEID_COL_KEYID 1
|
|
|
|
#define RSCIRCLEID_COL_IDTYPE 2
|
|
|
|
|
|
|
|
/** Constructor */
|
|
|
|
CreateCircleDialog::CreateCircleDialog()
|
2013-07-14 21:03:39 -04:00
|
|
|
: QDialog(NULL, Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint)
|
2013-03-24 12:29:08 -04:00
|
|
|
{
|
|
|
|
/* Invoke the Qt Designer generated object setup routine */
|
|
|
|
ui.setupUi(this);
|
|
|
|
|
|
|
|
/* Setup Queue */
|
|
|
|
mCircleQueue = new TokenQueue(rsGxsCircles->getTokenService(), this);
|
|
|
|
mIdQueue = new TokenQueue(rsIdentity->getTokenService(), this);
|
|
|
|
|
|
|
|
//QString text = pId.empty() ? tr("Start New Thread") : tr("Post Forum Message");
|
|
|
|
//setWindowTitle(text);
|
|
|
|
//Settings->loadWidgetInformation(this);
|
2013-09-02 19:01:24 -04:00
|
|
|
|
2014-05-04 12:56:41 -04:00
|
|
|
ui.headerFrame->setHeaderImage(QPixmap(":/images/circles/circles_64.png"));
|
2013-03-24 12:29:08 -04:00
|
|
|
|
|
|
|
// connect up the buttons.
|
|
|
|
connect(ui.addButton, SIGNAL(clicked()), this, SLOT(addMember()));
|
|
|
|
connect(ui.removeButton, SIGNAL(clicked()), this, SLOT(removeMember()));
|
|
|
|
|
2013-07-14 21:03:39 -04:00
|
|
|
connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(createCircle()));
|
|
|
|
connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(close()));
|
2013-03-24 12:29:08 -04:00
|
|
|
|
2013-07-14 21:03:39 -04:00
|
|
|
connect(ui.treeWidget_membership, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)), this, SLOT(selectedMember(QTreeWidgetItem*, QTreeWidgetItem*)));
|
|
|
|
connect(ui.treeWidget_IdList, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)), this, SLOT(selectedId(QTreeWidgetItem*, QTreeWidgetItem*)));
|
2014-01-06 13:31:12 -05:00
|
|
|
|
|
|
|
connect(ui.IdFilter, SIGNAL(textChanged(QString)), this, SLOT(filterChanged(QString)));
|
|
|
|
|
2014-07-06 07:19:58 -04:00
|
|
|
connect(ui.toolButton_NewId, SIGNAL(clicked()), this, SLOT(createNewGxsId()));
|
|
|
|
|
2014-01-06 13:31:12 -05:00
|
|
|
/* Add filter actions */
|
|
|
|
QTreeWidgetItem *headerItem = ui.treeWidget_IdList->headerItem();
|
|
|
|
QString headerText = headerItem->text(RSCIRCLEID_COL_NICKNAME);
|
|
|
|
ui.IdFilter->addFilter(QIcon(), headerText, RSCIRCLEID_COL_NICKNAME, QString("%1 %2").arg(tr("Search"), headerText));
|
|
|
|
headerText = headerItem->text(RSCIRCLEID_COL_KEYID);
|
|
|
|
ui.IdFilter->addFilter(QIcon(), headerItem->text(RSCIRCLEID_COL_KEYID), RSCIRCLEID_COL_KEYID, QString("%1 %2").arg(tr("Search"), headerText));
|
|
|
|
|
2013-03-24 12:29:08 -04:00
|
|
|
ui.removeButton->setEnabled(false);
|
|
|
|
ui.addButton->setEnabled(false);
|
2014-05-09 17:08:25 -04:00
|
|
|
ui.radioButton_ListAll->setChecked(true);
|
|
|
|
|
|
|
|
QObject::connect(ui.radioButton_ListAll, SIGNAL(toggled(bool)), this, SLOT(updateCircleGUI())) ;
|
|
|
|
QObject::connect(ui.radioButton_ListAllPGP, SIGNAL(toggled(bool)), this, SLOT(updateCircleGUI())) ;
|
|
|
|
QObject::connect(ui.radioButton_ListKnownPGP, SIGNAL(toggled(bool)), this, SLOT(updateCircleGUI())) ;
|
2013-06-04 17:00:43 -04:00
|
|
|
|
|
|
|
mIsExistingCircle = false;
|
|
|
|
mIsExternalCircle = true;
|
|
|
|
|
2014-03-17 16:56:06 -04:00
|
|
|
ui.idChooser->loadIds(0,RsGxsId());
|
|
|
|
ui.circleComboBox->loadCircles(GXS_CIRCLE_CHOOSER_EXTERNAL, RsGxsCircleId());
|
2013-03-24 12:29:08 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
CreateCircleDialog::~CreateCircleDialog()
|
|
|
|
{
|
|
|
|
delete(mCircleQueue);
|
|
|
|
delete(mIdQueue);
|
|
|
|
}
|
|
|
|
|
2014-03-17 16:56:06 -04:00
|
|
|
void CreateCircleDialog::editExistingId(const RsGxsGroupId& circleId)
|
2013-06-04 17:00:43 -04:00
|
|
|
{
|
2014-02-09 05:43:59 -05:00
|
|
|
std::cerr << "CreateCircleDialog::editExistingId() : " << circleId;
|
|
|
|
std::cerr << std::endl;
|
|
|
|
|
2013-06-04 17:00:43 -04:00
|
|
|
/* load this circle */
|
|
|
|
mIsExistingCircle = true;
|
2014-01-28 02:57:58 -05:00
|
|
|
requestCircle(circleId);
|
2014-05-04 12:21:43 -04:00
|
|
|
|
|
|
|
ui.headerFrame->setHeaderText(tr("Edit Circle"));
|
|
|
|
|
2013-06-04 17:00:43 -04:00
|
|
|
}
|
|
|
|
|
2014-01-28 02:57:58 -05:00
|
|
|
|
2013-06-04 17:00:43 -04:00
|
|
|
void CreateCircleDialog::editNewId(bool isExternal)
|
|
|
|
{
|
|
|
|
/* load this circle */
|
|
|
|
mIsExistingCircle = false;
|
|
|
|
|
|
|
|
/* setup personal or external circle */
|
|
|
|
if (isExternal)
|
|
|
|
{
|
|
|
|
setupForExternalCircle();
|
2014-05-04 12:21:43 -04:00
|
|
|
ui.headerFrame->setHeaderText(tr("Create New External Circle"));
|
2013-06-04 17:00:43 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
setupForPersonalCircle();
|
2014-05-04 12:21:43 -04:00
|
|
|
ui.headerFrame->setHeaderText(tr("Create New Personal Circle"));
|
2013-06-04 17:00:43 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* enable stuff that might be locked */
|
|
|
|
}
|
|
|
|
|
|
|
|
void CreateCircleDialog::setupForPersonalCircle()
|
|
|
|
{
|
|
|
|
mIsExternalCircle = false;
|
|
|
|
|
|
|
|
/* hide distribution line */
|
2014-05-04 12:21:43 -04:00
|
|
|
|
2013-06-04 17:00:43 -04:00
|
|
|
ui.groupBox_title->setTitle(tr("Personal Circle Details"));
|
|
|
|
ui.frame_PgpTypes->hide();
|
|
|
|
ui.frame_Distribution->hide();
|
|
|
|
ui.idChooserLabel->hide();
|
|
|
|
ui.idChooser->hide();
|
2014-07-06 07:19:58 -04:00
|
|
|
ui.toolButton_NewId->hide();
|
2013-06-04 17:00:43 -04:00
|
|
|
|
|
|
|
getPgpIdentities();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CreateCircleDialog::setupForExternalCircle()
|
|
|
|
{
|
|
|
|
mIsExternalCircle = true;
|
|
|
|
|
|
|
|
/* show distribution line */
|
|
|
|
ui.groupBox_title->setTitle(tr("External Circle Details"));
|
|
|
|
ui.frame_PgpTypes->show();
|
|
|
|
ui.frame_Distribution->show();
|
|
|
|
ui.idChooserLabel->show();
|
|
|
|
ui.idChooser->show();
|
2014-07-06 07:19:58 -04:00
|
|
|
ui.toolButton_NewId->show();
|
2013-09-02 19:01:24 -04:00
|
|
|
|
2013-06-04 17:00:43 -04:00
|
|
|
requestGxsIdentities();
|
|
|
|
}
|
|
|
|
|
2013-03-24 12:29:08 -04:00
|
|
|
void CreateCircleDialog::selectedId(QTreeWidgetItem *current, QTreeWidgetItem *previous)
|
|
|
|
{
|
2013-07-14 21:03:39 -04:00
|
|
|
Q_UNUSED(previous);
|
2013-03-24 12:29:08 -04:00
|
|
|
ui.addButton->setEnabled(current != NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CreateCircleDialog::selectedMember(QTreeWidgetItem *current, QTreeWidgetItem *previous)
|
|
|
|
{
|
2013-07-14 21:03:39 -04:00
|
|
|
Q_UNUSED(previous);
|
2013-03-24 12:29:08 -04:00
|
|
|
ui.removeButton->setEnabled(current != NULL);
|
|
|
|
}
|
|
|
|
|
2013-07-14 21:03:39 -04:00
|
|
|
void CreateCircleDialog::addMember()
|
2013-03-24 12:29:08 -04:00
|
|
|
{
|
2013-07-14 21:03:39 -04:00
|
|
|
QTreeWidgetItem *item = ui.treeWidget_IdList->currentItem();
|
2013-03-24 12:29:08 -04:00
|
|
|
if (!item)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2013-06-04 17:00:43 -04:00
|
|
|
|
|
|
|
/* check that its not there already */
|
2014-01-28 02:57:58 -05:00
|
|
|
QString keyId = item->text(RSCIRCLEID_COL_KEYID);
|
|
|
|
QString idtype = item->text(RSCIRCLEID_COL_IDTYPE);
|
|
|
|
QString nickname = item->text(RSCIRCLEID_COL_NICKNAME);
|
|
|
|
|
|
|
|
addMember(keyId, idtype, nickname);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CreateCircleDialog::addMember(const QString& keyId, const QString& idtype, const QString& nickname )
|
|
|
|
{
|
2013-07-14 21:03:39 -04:00
|
|
|
QTreeWidget *tree = ui.treeWidget_membership;
|
2013-06-04 17:00:43 -04:00
|
|
|
|
|
|
|
int count = tree->topLevelItemCount();
|
|
|
|
for(int i = 0; i < count; i++)
|
|
|
|
{
|
|
|
|
QTreeWidgetItem *item = tree->topLevelItem(i);
|
|
|
|
if (keyId == item->text(RSCIRCLEID_COL_KEYID))
|
|
|
|
{
|
|
|
|
std::cerr << "CreateCircleDialog::addMember() Already is a Member: " << keyId.toStdString();
|
|
|
|
std::cerr << std::endl;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-14 21:03:39 -04:00
|
|
|
QTreeWidgetItem *member = new QTreeWidgetItem();
|
2014-01-28 02:57:58 -05:00
|
|
|
member->setText(RSCIRCLEID_COL_NICKNAME, nickname);
|
|
|
|
member->setText(RSCIRCLEID_COL_KEYID, keyId);
|
|
|
|
member->setText(RSCIRCLEID_COL_IDTYPE, idtype);
|
2013-03-24 12:29:08 -04:00
|
|
|
|
2013-06-04 17:00:43 -04:00
|
|
|
tree->addTopLevelItem(member);
|
2013-03-24 12:29:08 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CreateCircleDialog::removeMember()
|
|
|
|
{
|
2013-07-14 21:03:39 -04:00
|
|
|
QTreeWidgetItem *item = ui.treeWidget_membership->currentItem();
|
2013-03-24 12:29:08 -04:00
|
|
|
if (!item)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// does this just work?
|
|
|
|
delete(item);
|
|
|
|
}
|
|
|
|
|
2013-07-14 21:03:39 -04:00
|
|
|
void CreateCircleDialog::createCircle()
|
2013-03-24 12:29:08 -04:00
|
|
|
{
|
2013-06-04 17:00:43 -04:00
|
|
|
std::cerr << "CreateCircleDialog::createCircle()";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
|
2013-03-24 12:29:08 -04:00
|
|
|
QString name = ui.circleName->text();
|
2014-07-06 07:19:58 -04:00
|
|
|
//QString desc;
|
2013-03-24 12:29:08 -04:00
|
|
|
|
2014-07-06 07:19:58 -04:00
|
|
|
if(name.isEmpty()) {
|
|
|
|
/* error message */
|
2013-07-14 21:03:39 -04:00
|
|
|
QMessageBox::warning(this, tr("RetroShare"),tr("Please set a name for your Circle"), QMessageBox::Ok, QMessageBox::Ok);
|
2013-03-24 12:29:08 -04:00
|
|
|
|
|
|
|
return; //Don't add a empty Subject!!
|
2014-07-06 07:19:58 -04:00
|
|
|
}//if(name.isEmpty())
|
2013-03-24 12:29:08 -04:00
|
|
|
|
|
|
|
RsGxsCircleGroup circle;
|
|
|
|
|
|
|
|
circle.mMeta.mGroupName = std::string(name.toUtf8());
|
|
|
|
|
|
|
|
RsGxsId authorId;
|
2014-07-06 07:19:58 -04:00
|
|
|
switch (ui.idChooser->getChosenId(authorId)) {
|
|
|
|
case GxsIdChooser::KnowId:
|
|
|
|
case GxsIdChooser::UnKnowId:
|
2013-03-24 12:29:08 -04:00
|
|
|
circle.mMeta.mAuthorId = authorId;
|
|
|
|
std::cerr << "CreateCircleDialog::createCircle() AuthorId: " << authorId;
|
|
|
|
std::cerr << std::endl;
|
2014-07-06 07:19:58 -04:00
|
|
|
|
|
|
|
break;
|
|
|
|
case GxsIdChooser::NoId:
|
|
|
|
case GxsIdChooser::None:
|
|
|
|
default:
|
2013-03-24 12:29:08 -04:00
|
|
|
std::cerr << "CreateCircleDialog::createCircle() No AuthorId Chosen!";
|
|
|
|
std::cerr << std::endl;
|
2014-07-06 07:19:58 -04:00
|
|
|
}//switch (ui.idChooser->getChosenId(authorId))
|
2013-03-24 12:29:08 -04:00
|
|
|
|
|
|
|
|
|
|
|
/* copy Ids from GUI */
|
2013-07-14 21:03:39 -04:00
|
|
|
QTreeWidget *tree = ui.treeWidget_membership;
|
2013-06-04 17:00:43 -04:00
|
|
|
int count = tree->topLevelItemCount();
|
2014-07-06 07:19:58 -04:00
|
|
|
for(int i = 0; i < count; i++) {
|
2013-06-04 17:00:43 -04:00
|
|
|
QTreeWidgetItem *item = tree->topLevelItem(i);
|
2013-07-14 21:03:39 -04:00
|
|
|
QString keyId = item->text(RSCIRCLEID_COL_KEYID);
|
2013-06-04 17:00:43 -04:00
|
|
|
|
|
|
|
/* insert into circle */
|
2014-07-06 07:19:58 -04:00
|
|
|
if (mIsExternalCircle) {
|
2014-03-17 16:56:06 -04:00
|
|
|
circle.mInvitedMembers.push_back(RsGxsId(keyId.toStdString()));
|
2013-06-04 17:00:43 -04:00
|
|
|
std::cerr << "CreateCircleDialog::createCircle() Inserting Member: " << keyId.toStdString();
|
|
|
|
std::cerr << std::endl;
|
2014-07-06 07:19:58 -04:00
|
|
|
} else {//if (mIsExternalCircle)
|
2014-03-17 16:56:06 -04:00
|
|
|
circle.mLocalFriends.push_back(RsPgpId(keyId.toStdString()));
|
2013-06-04 17:00:43 -04:00
|
|
|
std::cerr << "CreateCircleDialog::createCircle() Inserting Friend: " << keyId.toStdString();
|
|
|
|
std::cerr << std::endl;
|
2014-07-06 07:19:58 -04:00
|
|
|
}//if (mIsExternalCircle)
|
2013-06-04 17:00:43 -04:00
|
|
|
|
2014-07-06 07:19:58 -04:00
|
|
|
}//for(int i = 0; i < count; i++)
|
2013-06-04 17:00:43 -04:00
|
|
|
|
2014-07-06 07:19:58 -04:00
|
|
|
if (mIsExistingCircle) {
|
2013-06-04 17:00:43 -04:00
|
|
|
std::cerr << "CreateCircleDialog::createCircle() Existing Circle TODO";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
|
|
|
|
// cannot edit these yet.
|
2013-07-14 21:03:39 -04:00
|
|
|
QMessageBox::warning(this, tr("RetroShare"),tr("Cannot Edit Existing Circles Yet"), QMessageBox::Ok, QMessageBox::Ok);
|
2013-06-04 17:00:43 -04:00
|
|
|
return;
|
2014-07-06 07:19:58 -04:00
|
|
|
}//if (mIsExistingCircle)
|
2013-06-04 17:00:43 -04:00
|
|
|
|
2014-07-06 07:19:58 -04:00
|
|
|
if (mIsExternalCircle) {
|
2013-06-04 17:00:43 -04:00
|
|
|
std::cerr << "CreateCircleDialog::createCircle() External Circle";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
|
|
|
|
// set distribution from GUI.
|
2014-04-20 12:34:26 -04:00
|
|
|
circle.mMeta.mCircleId.clear() ;
|
2014-07-06 07:19:58 -04:00
|
|
|
if (ui.radioButton_Public->isChecked()) {
|
2013-06-04 17:00:43 -04:00
|
|
|
std::cerr << "CreateCircleDialog::createCircle() Public Circle";
|
|
|
|
std::cerr << std::endl;
|
2013-03-24 12:29:08 -04:00
|
|
|
|
2013-06-04 17:00:43 -04:00
|
|
|
circle.mMeta.mCircleType = GXS_CIRCLE_TYPE_PUBLIC;
|
2014-07-06 07:19:58 -04:00
|
|
|
|
|
|
|
} else if (ui.radioButton_Self->isChecked()) {
|
2013-06-04 17:00:43 -04:00
|
|
|
std::cerr << "CreateCircleDialog::createCircle() ExtSelfRef Circle";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
|
|
|
|
circle.mMeta.mCircleType = GXS_CIRCLE_TYPE_EXT_SELF;
|
2014-07-06 07:19:58 -04:00
|
|
|
} else if (ui.radioButton_Restricted->isChecked()) {
|
2013-06-04 17:00:43 -04:00
|
|
|
std::cerr << "CreateCircleDialog::createCircle() External (Other) Circle";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
|
|
|
|
circle.mMeta.mCircleType = GXS_CIRCLE_TYPE_EXTERNAL;
|
2013-03-24 12:29:08 -04:00
|
|
|
|
2013-06-04 17:00:43 -04:00
|
|
|
/* grab circle ID from chooser */
|
|
|
|
RsGxsCircleId chosenId;
|
2014-07-06 07:19:58 -04:00
|
|
|
if (ui.circleComboBox->getChosenCircle(chosenId)) {
|
2013-06-04 17:00:43 -04:00
|
|
|
std::cerr << "CreateCircleDialog::createCircle() ChosenId: " << chosenId;
|
|
|
|
std::cerr << std::endl;
|
|
|
|
|
|
|
|
circle.mMeta.mCircleId = chosenId;
|
2014-07-06 07:19:58 -04:00
|
|
|
} else {//if (ui.circleComboBox->getChosenCircle(chosenId))
|
2013-06-04 17:00:43 -04:00
|
|
|
std::cerr << "CreateCircleDialog::createCircle() Error no Id Chosen";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
|
2013-07-14 21:03:39 -04:00
|
|
|
QMessageBox::warning(this, tr("RetroShare"),tr("No Restriction Circle Selected"), QMessageBox::Ok, QMessageBox::Ok);
|
2013-06-04 17:00:43 -04:00
|
|
|
return;
|
2014-07-06 07:19:58 -04:00
|
|
|
}//if (ui.circleComboBox->getChosenCircle(chosenId))
|
|
|
|
} else { //if (ui.radioButton_Public->isChecked())
|
2013-07-14 21:03:39 -04:00
|
|
|
QMessageBox::warning(this, tr("RetroShare"),tr("No Circle Limitations Selected"), QMessageBox::Ok, QMessageBox::Ok);
|
2013-06-04 17:00:43 -04:00
|
|
|
return;
|
2014-07-06 07:19:58 -04:00
|
|
|
}//if (ui.radioButton_Public->isChecked())
|
|
|
|
} else {//if (mIsExternalCircle)
|
2013-06-04 17:00:43 -04:00
|
|
|
std::cerr << "CreateCircleDialog::createCircle() Personal Circle";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
|
|
|
|
// set personal distribution
|
2014-04-20 12:34:26 -04:00
|
|
|
circle.mMeta.mCircleId.clear() ;
|
2013-06-04 17:00:43 -04:00
|
|
|
circle.mMeta.mCircleType = GXS_CIRCLE_TYPE_LOCAL;
|
2014-07-06 07:19:58 -04:00
|
|
|
}//if (mIsExternalCircle)
|
|
|
|
|
2014-02-09 05:43:59 -05:00
|
|
|
std::cerr << "CreateCircleDialog::createCircle() : mCircleType: " << circle.mMeta.mCircleType;
|
|
|
|
std::cerr << std::endl;
|
|
|
|
std::cerr << "CreateCircleDialog::createCircle() : mCircleId: " << circle.mMeta.mCircleId;
|
|
|
|
std::cerr << std::endl;
|
2013-06-04 17:00:43 -04:00
|
|
|
|
|
|
|
std::cerr << "CreateCircleDialog::createCircle() Checks and Balances Okay - calling service proper..";
|
|
|
|
std::cerr << std::endl;
|
2013-03-24 12:29:08 -04:00
|
|
|
|
|
|
|
uint32_t token;
|
|
|
|
rsGxsCircles->createGroup(token, circle);
|
|
|
|
close();
|
|
|
|
}
|
|
|
|
|
2014-01-28 02:57:58 -05:00
|
|
|
|
|
|
|
void CreateCircleDialog::updateCircleGUI()
|
|
|
|
{
|
|
|
|
std::cerr << "CreateCircleDialog::updateCircleGUI()";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
|
|
|
|
ui.circleName->setText(QString::fromUtf8(mCircleGroup.mMeta.mGroupName.c_str()));
|
|
|
|
|
|
|
|
bool isExternal = true;
|
2014-02-09 05:43:59 -05:00
|
|
|
std::cerr << "CreateCircleDialog::updateCircleGUI() : CIRCLETYPE: " << mCircleGroup.mMeta.mCircleType;
|
|
|
|
std::cerr << std::endl;
|
2014-01-28 02:57:58 -05:00
|
|
|
switch(mCircleGroup.mMeta.mCircleType)
|
|
|
|
{
|
|
|
|
case GXS_CIRCLE_TYPE_LOCAL:
|
2014-02-09 05:43:59 -05:00
|
|
|
std::cerr << "CreateCircleDialog::updateCircleGUI() : LOCAL CIRCLETYPE";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
|
2014-01-28 02:57:58 -05:00
|
|
|
isExternal = false;
|
|
|
|
break;
|
|
|
|
case GXS_CIRCLE_TYPE_PUBLIC:
|
2014-02-09 05:43:59 -05:00
|
|
|
std::cerr << "CreateCircleDialog::updateCircleGUI() : PUBLIC CIRCLETYPE";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
|
2014-01-28 02:57:58 -05:00
|
|
|
ui.radioButton_Public->setChecked(true);
|
|
|
|
break;
|
|
|
|
case GXS_CIRCLE_TYPE_EXT_SELF:
|
2014-02-09 05:43:59 -05:00
|
|
|
std::cerr << "CreateCircleDialog::updateCircleGUI() : EXT_SELF CIRCLE (fallthrough)";
|
|
|
|
std::cerr << std::endl;
|
2014-01-28 02:57:58 -05:00
|
|
|
case GXS_CIRCLE_TYPE_EXTERNAL:
|
2014-02-09 05:43:59 -05:00
|
|
|
|
|
|
|
std::cerr << "CreateCircleDialog::updateCircleGUI() : EXTERNAL CIRCLETYPE";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
|
2014-03-20 07:26:53 -04:00
|
|
|
if (mCircleGroup.mMeta.mCircleId.toStdString() == mCircleGroup.mMeta.mGroupId.toStdString())
|
2014-01-28 02:57:58 -05:00
|
|
|
{
|
|
|
|
ui.radioButton_Restricted->setChecked(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
ui.circleComboBox->loadCircles(GXS_CIRCLE_CHOOSER_EXTERNAL, mCircleGroup.mMeta.mCircleId);
|
|
|
|
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
std::cerr << "CreateCircleDialog::updateCircleGUI() INVALID mCircleType";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// set preferredId.
|
|
|
|
ui.idChooser->loadIds(0,mCircleGroup.mMeta.mAuthorId);
|
|
|
|
|
|
|
|
/* setup personal or external circle */
|
|
|
|
if (isExternal)
|
|
|
|
{
|
|
|
|
setupForExternalCircle();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
setupForPersonalCircle();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-03-24 12:29:08 -04:00
|
|
|
void CreateCircleDialog::requestCircle(const RsGxsGroupId &groupId)
|
|
|
|
{
|
|
|
|
RsTokReqOptions opts;
|
|
|
|
opts.mReqType = GXS_REQUEST_TYPE_GROUP_DATA;
|
|
|
|
|
|
|
|
std::list<RsGxsGroupId> groupIds;
|
|
|
|
groupIds.push_back(groupId);
|
|
|
|
|
|
|
|
std::cerr << "CreateCircleDialog::requestCircle() Requesting Group Summary(" << groupId << ")";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
|
|
|
|
uint32_t token;
|
|
|
|
mCircleQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, groupIds, CREATECIRCLEDIALOG_CIRCLEINFO);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CreateCircleDialog::loadCircle(uint32_t token)
|
|
|
|
{
|
|
|
|
std::cerr << "CreateCircleDialog::loadCircle(" << token << ")";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
|
|
|
|
QTreeWidget *tree = ui.treeWidget_membership;
|
|
|
|
|
|
|
|
tree->clear();
|
|
|
|
|
|
|
|
std::list<std::string> ids;
|
|
|
|
std::list<std::string>::iterator it;
|
|
|
|
|
|
|
|
std::vector<RsGxsCircleGroup> groups;
|
|
|
|
if (!rsGxsCircles->getGroupData(token, groups))
|
|
|
|
{
|
|
|
|
std::cerr << "CreateCircleDialog::loadCircle() Error getting GroupData";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (groups.size() != 1)
|
|
|
|
{
|
|
|
|
std::cerr << "CreateCircleDialog::loadCircle() Error Group.size() != 1";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-02-09 05:43:59 -05:00
|
|
|
std::cerr << "CreateCircleDialog::loadCircle() LoadedGroup.meta: " << mCircleGroup.mMeta;
|
2013-03-24 12:29:08 -04:00
|
|
|
std::cerr << std::endl;
|
|
|
|
|
2014-01-28 02:57:58 -05:00
|
|
|
mCircleGroup = groups[0];
|
|
|
|
updateCircleGUI();
|
2013-03-24 12:29:08 -04:00
|
|
|
}
|
|
|
|
|
2013-06-04 17:00:43 -04:00
|
|
|
void CreateCircleDialog::getPgpIdentities()
|
|
|
|
{
|
|
|
|
std::cerr << "CreateCircleDialog::getPgpIdentities()";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
|
|
|
|
QTreeWidget *tree = ui.treeWidget_IdList;
|
|
|
|
|
|
|
|
tree->clear();
|
2014-03-17 16:56:06 -04:00
|
|
|
std::list<RsPgpId> ids;
|
|
|
|
std::list<RsPgpId>::iterator it;
|
2013-06-04 17:00:43 -04:00
|
|
|
|
|
|
|
rsPeers->getGPGAcceptedList(ids);
|
|
|
|
for(it = ids.begin(); it != ids.end(); it++)
|
|
|
|
{
|
2013-07-14 21:03:39 -04:00
|
|
|
RsPeerDetails details;
|
2013-06-04 17:00:43 -04:00
|
|
|
|
2013-07-14 21:03:39 -04:00
|
|
|
rsPeers->getGPGDetails(*it, details);
|
2013-06-04 17:00:43 -04:00
|
|
|
|
2014-03-17 16:56:06 -04:00
|
|
|
QString keyId = QString::fromStdString(details.gpg_id.toStdString());
|
2014-01-28 02:57:58 -05:00
|
|
|
QString nickname = QString::fromUtf8(details.name.c_str());
|
|
|
|
QString idtype = tr("PGP Identity");
|
2013-06-04 17:00:43 -04:00
|
|
|
|
2014-01-28 02:57:58 -05:00
|
|
|
QTreeWidgetItem *item = new QTreeWidgetItem();
|
|
|
|
item->setText(RSCIRCLEID_COL_NICKNAME, nickname);
|
|
|
|
item->setText(RSCIRCLEID_COL_KEYID, keyId);
|
|
|
|
item->setText(RSCIRCLEID_COL_IDTYPE, idtype);
|
2013-06-04 17:00:43 -04:00
|
|
|
tree->addTopLevelItem(item);
|
2014-01-28 02:57:58 -05:00
|
|
|
|
|
|
|
// Local Circle.
|
|
|
|
if (mIsExistingCircle)
|
|
|
|
{
|
|
|
|
// check if its in the circle.
|
|
|
|
std::list<RsPgpId>::const_iterator it;
|
|
|
|
it = std::find(mCircleGroup.mLocalFriends.begin(), mCircleGroup.mLocalFriends.end(), details.gpg_id);
|
|
|
|
if (it != mCircleGroup.mLocalFriends.end())
|
|
|
|
{
|
|
|
|
/* found it */
|
|
|
|
addMember(keyId, idtype, nickname);
|
|
|
|
}
|
|
|
|
}
|
2013-06-04 17:00:43 -04:00
|
|
|
}
|
2014-01-06 13:31:12 -05:00
|
|
|
|
|
|
|
filterIds();
|
2013-06-04 17:00:43 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CreateCircleDialog::requestGxsIdentities()
|
2013-03-24 12:29:08 -04:00
|
|
|
{
|
|
|
|
RsTokReqOptions opts;
|
|
|
|
opts.mReqType = GXS_REQUEST_TYPE_GROUP_DATA;
|
|
|
|
|
|
|
|
std::cerr << "CreateCircleDialog::requestIdentities()";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
|
|
|
|
uint32_t token;
|
|
|
|
mIdQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, CREATECIRCLEDIALOG_IDINFO);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CreateCircleDialog::loadIdentities(uint32_t token)
|
|
|
|
{
|
|
|
|
std::cerr << "CreateCircleDialog::loadIdentities(" << token << ")";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
|
|
|
|
QTreeWidget *tree = ui.treeWidget_IdList;
|
|
|
|
|
|
|
|
tree->clear();
|
|
|
|
|
|
|
|
std::list<std::string> ids;
|
|
|
|
std::list<std::string>::iterator it;
|
|
|
|
|
2014-05-09 17:08:25 -04:00
|
|
|
bool acceptAnonymous = ui.radioButton_ListAll->isChecked();
|
2013-03-24 12:29:08 -04:00
|
|
|
bool acceptAllPGP = ui.radioButton_ListAllPGP->isChecked();
|
|
|
|
bool acceptKnownPGP = ui.radioButton_ListKnownPGP->isChecked();
|
|
|
|
|
|
|
|
RsGxsIdGroup data;
|
|
|
|
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++)
|
|
|
|
{
|
|
|
|
data = (*vit);
|
|
|
|
|
|
|
|
/* do filtering */
|
|
|
|
bool ok = false;
|
|
|
|
{
|
2014-05-09 17:08:25 -04:00
|
|
|
if (acceptAnonymous)
|
2013-03-24 12:29:08 -04:00
|
|
|
ok = true;
|
2014-05-09 17:08:25 -04:00
|
|
|
else if (acceptAllPGP)
|
|
|
|
{
|
|
|
|
ok = data.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID ;
|
2013-03-24 12:29:08 -04:00
|
|
|
}
|
|
|
|
else if (data.mPgpKnown)
|
|
|
|
{
|
2014-05-09 17:08:25 -04:00
|
|
|
ok = data.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID ;
|
2013-03-24 12:29:08 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!ok)
|
|
|
|
{
|
|
|
|
std::cerr << "CreateCircleDialog::insertIdentities() Skipping ID: " << data.mMeta.mGroupId;
|
|
|
|
std::cerr << std::endl;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2014-03-17 16:56:06 -04:00
|
|
|
QString keyId = QString::fromStdString(data.mMeta.mGroupId.toStdString());
|
2014-01-28 02:57:58 -05:00
|
|
|
QString nickname = QString::fromUtf8(data.mMeta.mGroupName.c_str());
|
|
|
|
QString idtype = tr("Anon Id");
|
|
|
|
|
2013-07-14 21:03:39 -04:00
|
|
|
if (data.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID)
|
|
|
|
{
|
|
|
|
if (data.mPgpKnown)
|
|
|
|
{
|
|
|
|
RsPeerDetails details;
|
|
|
|
rsPeers->getGPGDetails(data.mPgpId, details);
|
2014-01-28 02:57:58 -05:00
|
|
|
idtype = QString::fromUtf8(details.name.c_str());
|
2013-07-14 21:03:39 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-01-28 02:57:58 -05:00
|
|
|
idtype = tr("PGP Linked Id");
|
2013-07-14 21:03:39 -04:00
|
|
|
}
|
|
|
|
}
|
2014-01-28 02:57:58 -05:00
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
// External Circle.
|
|
|
|
if (mIsExistingCircle)
|
2013-07-14 21:03:39 -04:00
|
|
|
{
|
2014-01-28 02:57:58 -05:00
|
|
|
// check if its in the circle.
|
|
|
|
std::list<RsGxsId>::const_iterator it;
|
2014-03-17 16:56:06 -04:00
|
|
|
|
|
|
|
// We use an explicit cast
|
|
|
|
//
|
|
|
|
it = std::find(mCircleGroup.mInvitedMembers.begin(), mCircleGroup.mInvitedMembers.end(), RsGxsId(data.mMeta.mGroupId));
|
2014-01-28 02:57:58 -05:00
|
|
|
|
|
|
|
if (it != mCircleGroup.mInvitedMembers.end())
|
|
|
|
{
|
|
|
|
/* found it */
|
|
|
|
addMember(keyId, idtype, nickname);
|
|
|
|
}
|
2013-07-14 21:03:39 -04:00
|
|
|
}
|
2013-03-24 12:29:08 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CreateCircleDialog::loadRequest(const TokenQueue *queue, const TokenRequest &req)
|
|
|
|
{
|
|
|
|
std::cerr << "CreateCircleDialog::loadRequest() UserType: " << req.mUserType;
|
|
|
|
std::cerr << std::endl;
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-01-06 13:31:12 -05:00
|
|
|
|
|
|
|
void CreateCircleDialog::filterChanged(const QString& /*text*/)
|
|
|
|
{
|
|
|
|
filterIds();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CreateCircleDialog::filterIds()
|
|
|
|
{
|
|
|
|
int filterColumn = ui.IdFilter->currentFilter();
|
|
|
|
QString text = ui.IdFilter->text();
|
|
|
|
|
|
|
|
ui.treeWidget_IdList->filterItems(filterColumn, text);
|
|
|
|
}
|
2014-07-06 07:19:58 -04:00
|
|
|
|
|
|
|
void CreateCircleDialog::createNewGxsId()
|
|
|
|
{
|
|
|
|
IdEditDialog dlg(this);
|
|
|
|
dlg.setupNewId(false);
|
|
|
|
dlg.exec();
|
|
|
|
ui.idChooser->setDefaultId(dlg.getLastIdName());
|
|
|
|
}
|