2012-02-13 13:43:15 -05:00
|
|
|
/*
|
|
|
|
* Retroshare Identity
|
|
|
|
*
|
|
|
|
* Copyright 2012-2012 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 "gui/Identity/IdEditDialog.h"
|
2013-07-10 17:57:23 -04:00
|
|
|
#include "gui/common/UIStateHelper.h"
|
2012-06-13 20:36:25 -04:00
|
|
|
#include "util/TokenQueue.h"
|
2012-02-13 13:43:15 -05:00
|
|
|
|
|
|
|
#include <retroshare/rsidentity.h>
|
|
|
|
#include <retroshare/rspeers.h>
|
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
|
2012-06-13 20:36:25 -04:00
|
|
|
#define IDEDITDIALOG_LOADID 1
|
|
|
|
|
2012-02-13 13:43:15 -05:00
|
|
|
/** Constructor */
|
|
|
|
IdEditDialog::IdEditDialog(QWidget *parent)
|
2013-07-10 17:57:23 -04:00
|
|
|
: QDialog(parent, Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint)
|
2012-02-13 13:43:15 -05:00
|
|
|
{
|
2013-07-10 17:57:23 -04:00
|
|
|
mIsNew = true;
|
|
|
|
|
2012-02-13 13:43:15 -05:00
|
|
|
ui.setupUi(this);
|
2013-09-02 15:20:47 -04:00
|
|
|
|
2014-02-19 11:20:19 -05:00
|
|
|
ui.headerFrame->setHeaderImage(QPixmap(":/images/identity/identity_create_64.png"));
|
2013-09-02 15:20:47 -04:00
|
|
|
ui.headerFrame->setHeaderText(tr("Create New Identity"));
|
2012-02-13 13:43:15 -05:00
|
|
|
|
2013-07-10 17:57:23 -04:00
|
|
|
/* Setup UI helper */
|
|
|
|
mStateHelper = new UIStateHelper(this);
|
|
|
|
|
|
|
|
mStateHelper->addWidget(IDEDITDIALOG_LOADID, ui.lineEdit_Nickname);
|
|
|
|
mStateHelper->addWidget(IDEDITDIALOG_LOADID, ui.lineEdit_KeyId);
|
|
|
|
mStateHelper->addWidget(IDEDITDIALOG_LOADID, ui.lineEdit_GpgHash);
|
|
|
|
mStateHelper->addWidget(IDEDITDIALOG_LOADID, ui.lineEdit_GpgId);
|
|
|
|
mStateHelper->addWidget(IDEDITDIALOG_LOADID, ui.lineEdit_GpgName);
|
|
|
|
mStateHelper->addWidget(IDEDITDIALOG_LOADID, ui.radioButton_GpgId);
|
|
|
|
mStateHelper->addWidget(IDEDITDIALOG_LOADID, ui.radioButton_Pseudo);
|
|
|
|
|
|
|
|
mStateHelper->addLoadPlaceholder(IDEDITDIALOG_LOADID, ui.lineEdit_Nickname);
|
|
|
|
mStateHelper->addLoadPlaceholder(IDEDITDIALOG_LOADID, ui.lineEdit_GpgName);
|
|
|
|
mStateHelper->addLoadPlaceholder(IDEDITDIALOG_LOADID, ui.lineEdit_KeyId);
|
|
|
|
mStateHelper->addLoadPlaceholder(IDEDITDIALOG_LOADID, ui.lineEdit_GpgHash);
|
|
|
|
mStateHelper->addLoadPlaceholder(IDEDITDIALOG_LOADID, ui.lineEdit_GpgId);
|
|
|
|
mStateHelper->addLoadPlaceholder(IDEDITDIALOG_LOADID, ui.lineEdit_GpgName);
|
|
|
|
|
|
|
|
/* Connect signals */
|
|
|
|
connect(ui.radioButton_GpgId, SIGNAL(toggled(bool)), this, SLOT(idTypeToggled(bool)));
|
|
|
|
connect(ui.radioButton_Pseudo, SIGNAL(toggled(bool)), this, SLOT(idTypeToggled(bool)));
|
2013-10-20 05:56:12 -04:00
|
|
|
connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(submit()));
|
2013-07-10 17:57:23 -04:00
|
|
|
connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(close()));
|
|
|
|
|
2013-10-20 05:56:12 -04:00
|
|
|
connect(ui.plainTextEdit_Tag, SIGNAL(textChanged()), this, SLOT(checkNewTag()));
|
|
|
|
connect(ui.pushButton_Tag, SIGNAL(clicked(bool)), this, SLOT(addRecognTag()));
|
|
|
|
connect(ui.toolButton_Tag1, SIGNAL(clicked(bool)), this, SLOT(rmTag1()));
|
|
|
|
connect(ui.toolButton_Tag2, SIGNAL(clicked(bool)), this, SLOT(rmTag2()));
|
|
|
|
connect(ui.toolButton_Tag3, SIGNAL(clicked(bool)), this, SLOT(rmTag3()));
|
|
|
|
connect(ui.toolButton_Tag4, SIGNAL(clicked(bool)), this, SLOT(rmTag4()));
|
|
|
|
connect(ui.toolButton_Tag5, SIGNAL(clicked(bool)), this, SLOT(rmTag5()));
|
|
|
|
|
2012-11-01 20:49:06 -04:00
|
|
|
mIdQueue = new TokenQueue(rsIdentity->getTokenService(), this);
|
2013-10-20 05:56:12 -04:00
|
|
|
ui.pushButton_Tag->setEnabled(false);
|
2012-02-13 13:43:15 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void IdEditDialog::setupNewId(bool pseudo)
|
|
|
|
{
|
2013-07-10 17:57:23 -04:00
|
|
|
setWindowTitle(tr("New identity"));
|
|
|
|
|
|
|
|
mIsNew = true;
|
|
|
|
|
|
|
|
ui.lineEdit_KeyId->setText(tr("To be generated"));
|
2012-02-13 13:43:15 -05:00
|
|
|
ui.lineEdit_Nickname->setText("");
|
|
|
|
ui.radioButton_GpgId->setEnabled(true);
|
|
|
|
ui.radioButton_Pseudo->setEnabled(true);
|
|
|
|
|
|
|
|
if (pseudo)
|
|
|
|
{
|
|
|
|
ui.radioButton_Pseudo->setChecked(true);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ui.radioButton_GpgId->setChecked(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
// force - incase it wasn't triggered.
|
2013-07-10 17:57:23 -04:00
|
|
|
idTypeToggled(true);
|
2013-10-20 05:56:12 -04:00
|
|
|
|
|
|
|
ui.frame_Tags->setHidden(true);
|
|
|
|
ui.radioButton_GpgId->setEnabled(true);
|
|
|
|
ui.radioButton_Pseudo->setEnabled(true);
|
2012-02-13 13:43:15 -05:00
|
|
|
}
|
|
|
|
|
2013-07-10 17:57:23 -04:00
|
|
|
void IdEditDialog::idTypeToggled(bool checked)
|
2012-02-13 13:43:15 -05:00
|
|
|
{
|
|
|
|
if (checked)
|
|
|
|
{
|
|
|
|
bool pseudo = ui.radioButton_Pseudo->isChecked();
|
|
|
|
updateIdType(pseudo);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void IdEditDialog::updateIdType(bool pseudo)
|
|
|
|
{
|
|
|
|
if (pseudo)
|
|
|
|
{
|
2013-07-10 17:57:23 -04:00
|
|
|
ui.lineEdit_GpgHash->setText(tr("N/A"));
|
|
|
|
ui.lineEdit_GpgId->setText(tr("N/A"));
|
|
|
|
ui.lineEdit_GpgName->setText(tr("N/A"));
|
2012-02-13 13:43:15 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* get GPG Details from rsPeers */
|
2014-03-17 16:56:06 -04:00
|
|
|
RsPgpId gpgid = rsPeers->getGPGOwnId();
|
2012-02-13 13:43:15 -05:00
|
|
|
RsPeerDetails details;
|
2014-03-17 16:56:06 -04:00
|
|
|
rsPeers->getGPGDetails(gpgid, details);
|
2012-02-13 13:43:15 -05:00
|
|
|
|
2014-03-17 16:56:06 -04:00
|
|
|
ui.lineEdit_GpgId->setText(QString::fromStdString(gpgid.toStdString()));
|
2013-07-10 17:57:23 -04:00
|
|
|
ui.lineEdit_GpgHash->setText(tr("To be generated"));
|
2013-07-24 10:33:47 -04:00
|
|
|
ui.lineEdit_GpgName->setText(QString::fromUtf8(details.name.c_str()));
|
2012-02-13 13:43:15 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-13 20:36:25 -04:00
|
|
|
void IdEditDialog::setupExistingId(std::string keyId)
|
|
|
|
{
|
2013-07-10 17:57:23 -04:00
|
|
|
setWindowTitle(tr("Edit identity"));
|
2014-02-19 11:20:19 -05:00
|
|
|
ui.headerFrame->setHeaderImage(QPixmap(":/images/identity/identity_edit_64.png"));
|
2014-02-13 06:55:14 -05:00
|
|
|
ui.headerFrame->setHeaderText(tr("Edit identity"));
|
2012-06-13 20:36:25 -04:00
|
|
|
|
2013-07-10 17:57:23 -04:00
|
|
|
mIsNew = false;
|
2012-06-13 20:36:25 -04:00
|
|
|
|
2013-07-10 17:57:23 -04:00
|
|
|
mStateHelper->setLoading(IDEDITDIALOG_LOADID, true);
|
2012-06-13 20:36:25 -04:00
|
|
|
|
2013-07-10 17:57:23 -04:00
|
|
|
RsTokReqOptions opts;
|
|
|
|
opts.mReqType = GXS_REQUEST_TYPE_GROUP_DATA;
|
|
|
|
|
2014-03-17 16:56:06 -04:00
|
|
|
std::list<RsGxsGroupId> groupIds;
|
|
|
|
groupIds.push_back(RsGxsGroupId(keyId));
|
2013-07-10 17:57:23 -04:00
|
|
|
|
|
|
|
uint32_t token;
|
|
|
|
mIdQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, groupIds, IDEDITDIALOG_LOADID);
|
|
|
|
}
|
2012-06-13 20:36:25 -04:00
|
|
|
|
|
|
|
void IdEditDialog::loadExistingId(uint32_t token)
|
2012-02-13 13:43:15 -05:00
|
|
|
{
|
2013-07-10 17:57:23 -04:00
|
|
|
mStateHelper->setLoading(IDEDITDIALOG_LOADID, false);
|
2012-02-13 13:43:15 -05:00
|
|
|
|
2013-07-10 17:57:23 -04:00
|
|
|
/* get details from libretroshare */
|
2012-11-01 20:49:06 -04:00
|
|
|
std::vector<RsGxsIdGroup> datavector;
|
|
|
|
if (!rsIdentity->getGroupData(token, datavector))
|
|
|
|
{
|
2013-07-10 17:57:23 -04:00
|
|
|
ui.lineEdit_KeyId->setText(tr("Error getting key!"));
|
2012-11-01 20:49:06 -04:00
|
|
|
return;
|
|
|
|
}
|
2013-07-11 04:14:38 -04:00
|
|
|
|
2012-11-01 20:49:06 -04:00
|
|
|
if (datavector.size() != 1)
|
|
|
|
{
|
|
|
|
std::cerr << "IdDialog::insertIdDetails() Invalid datavector size";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
|
2013-07-10 17:57:23 -04:00
|
|
|
ui.lineEdit_KeyId->setText(tr("Error KeyID invalid"));
|
2012-02-13 13:43:15 -05:00
|
|
|
ui.lineEdit_Nickname->setText("");
|
|
|
|
|
2013-07-10 17:57:23 -04:00
|
|
|
ui.lineEdit_GpgHash->setText(tr("N/A"));
|
|
|
|
ui.lineEdit_GpgId->setText(tr("N/A"));
|
|
|
|
ui.lineEdit_GpgName->setText(tr("N/A"));
|
2012-02-13 13:43:15 -05:00
|
|
|
return;
|
|
|
|
}
|
2012-11-01 20:49:06 -04:00
|
|
|
|
2013-10-20 05:56:12 -04:00
|
|
|
mEditGroup = datavector[0];
|
2012-11-01 20:49:06 -04:00
|
|
|
|
2013-10-20 05:56:12 -04:00
|
|
|
bool realid = (mEditGroup.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID);
|
2012-11-05 17:32:52 -05:00
|
|
|
|
2012-11-06 14:18:56 -05:00
|
|
|
if (realid)
|
2012-02-13 13:43:15 -05:00
|
|
|
{
|
2012-11-06 14:18:56 -05:00
|
|
|
ui.radioButton_GpgId->setChecked(true);
|
2012-02-13 13:43:15 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-11-06 14:18:56 -05:00
|
|
|
ui.radioButton_Pseudo->setChecked(true);
|
2012-02-13 13:43:15 -05:00
|
|
|
}
|
2013-10-20 05:56:12 -04:00
|
|
|
// these are not editable for existing Id.
|
|
|
|
ui.radioButton_GpgId->setEnabled(false);
|
|
|
|
ui.radioButton_Pseudo->setEnabled(false);
|
2012-02-13 13:43:15 -05:00
|
|
|
|
|
|
|
// DOES THIS TRIGGER ALREADY???
|
|
|
|
// force - incase it wasn't triggered.
|
2013-07-10 17:57:23 -04:00
|
|
|
idTypeToggled(true);
|
2012-02-13 13:43:15 -05:00
|
|
|
|
2013-10-20 05:56:12 -04:00
|
|
|
ui.lineEdit_Nickname->setText(QString::fromUtf8(mEditGroup.mMeta.mGroupName.c_str()));
|
2014-03-17 16:56:06 -04:00
|
|
|
ui.lineEdit_KeyId->setText(QString::fromStdString(mEditGroup.mMeta.mGroupId.toStdString()));
|
2012-02-13 13:43:15 -05:00
|
|
|
|
2012-11-06 14:18:56 -05:00
|
|
|
if (realid)
|
2012-02-13 13:43:15 -05:00
|
|
|
{
|
2013-10-20 05:56:12 -04:00
|
|
|
ui.lineEdit_GpgHash->setText(QString::fromStdString(mEditGroup.mPgpIdHash));
|
2012-02-13 13:43:15 -05:00
|
|
|
|
2013-10-20 05:56:12 -04:00
|
|
|
if (mEditGroup.mPgpKnown)
|
2012-02-13 13:43:15 -05:00
|
|
|
{
|
2012-11-06 14:18:56 -05:00
|
|
|
RsPeerDetails details;
|
2013-10-20 05:56:12 -04:00
|
|
|
rsPeers->getGPGDetails(mEditGroup.mPgpId, details);
|
2013-07-24 10:33:47 -04:00
|
|
|
ui.lineEdit_GpgName->setText(QString::fromUtf8(details.name.c_str()));
|
2012-11-06 14:18:56 -05:00
|
|
|
|
2014-03-17 16:56:06 -04:00
|
|
|
ui.lineEdit_GpgId->setText(QString::fromStdString(mEditGroup.mPgpId.toStdString()));
|
2012-02-13 13:43:15 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-07-10 17:57:23 -04:00
|
|
|
ui.lineEdit_GpgId->setText(tr("Unknown GpgId"));
|
|
|
|
ui.lineEdit_GpgName->setText(tr("Unknown real name"));
|
2012-02-13 13:43:15 -05:00
|
|
|
}
|
|
|
|
}
|
2012-11-06 14:18:56 -05:00
|
|
|
else
|
|
|
|
{
|
2013-07-10 17:57:23 -04:00
|
|
|
ui.lineEdit_GpgHash->setText(tr("N/A"));
|
|
|
|
ui.lineEdit_GpgId->setText(tr("N/A"));
|
|
|
|
ui.lineEdit_GpgName->setText(tr("N/A"));
|
2012-11-06 14:18:56 -05:00
|
|
|
}
|
2013-10-20 05:56:12 -04:00
|
|
|
|
|
|
|
// RecognTags.
|
|
|
|
ui.frame_Tags->setHidden(false);
|
|
|
|
|
|
|
|
loadRecognTags();
|
2012-02-13 13:43:15 -05:00
|
|
|
}
|
|
|
|
|
2013-10-20 05:56:12 -04:00
|
|
|
#define MAX_RECOGN_TAGS 5
|
|
|
|
|
|
|
|
void IdEditDialog::checkNewTag()
|
2012-02-13 13:43:15 -05:00
|
|
|
{
|
2013-10-20 05:56:12 -04:00
|
|
|
std::string tag = ui.plainTextEdit_Tag->toPlainText().toStdString();
|
2014-03-17 16:56:06 -04:00
|
|
|
RsGxsId id ( ui.lineEdit_KeyId->text().toStdString());
|
2013-10-20 05:56:12 -04:00
|
|
|
std::string name = ui.lineEdit_Nickname->text().toUtf8().data();
|
2012-02-13 13:43:15 -05:00
|
|
|
|
2013-10-20 05:56:12 -04:00
|
|
|
QString desc;
|
|
|
|
bool ok = tagDetails(id, name, tag, desc);
|
|
|
|
ui.label_TagCheck->setText(desc);
|
2012-02-13 13:43:15 -05:00
|
|
|
|
2013-10-21 23:42:20 -04:00
|
|
|
// hack to allow add invalid tags (for testing).
|
|
|
|
if (!tag.empty())
|
2012-02-13 13:43:15 -05:00
|
|
|
{
|
2013-10-21 23:42:20 -04:00
|
|
|
ok = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-10-20 05:56:12 -04:00
|
|
|
if (mEditGroup.mRecognTags.size() >= MAX_RECOGN_TAGS)
|
2012-02-13 13:43:15 -05:00
|
|
|
{
|
2013-10-20 05:56:12 -04:00
|
|
|
ok = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
ui.pushButton_Tag->setEnabled(ok);
|
|
|
|
}
|
|
|
|
|
|
|
|
void IdEditDialog::addRecognTag()
|
|
|
|
{
|
|
|
|
std::string tag = ui.plainTextEdit_Tag->toPlainText().toStdString();
|
|
|
|
if (mEditGroup.mRecognTags.size() >= MAX_RECOGN_TAGS)
|
|
|
|
{
|
|
|
|
std::cerr << "IdEditDialog::addRecognTag() Too many Tags, delete one first";
|
2012-02-13 13:43:15 -05:00
|
|
|
std::cerr << std::endl;
|
|
|
|
}
|
|
|
|
|
2013-10-20 05:56:12 -04:00
|
|
|
mEditGroup.mRecognTags.push_back(tag);
|
|
|
|
loadRecognTags();
|
|
|
|
}
|
|
|
|
|
|
|
|
void IdEditDialog::rmTag1()
|
|
|
|
{
|
|
|
|
rmTag(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void IdEditDialog::rmTag2()
|
|
|
|
{
|
|
|
|
rmTag(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
void IdEditDialog::rmTag3()
|
|
|
|
{
|
|
|
|
rmTag(2);
|
|
|
|
}
|
|
|
|
|
|
|
|
void IdEditDialog::rmTag4()
|
|
|
|
{
|
|
|
|
rmTag(3);
|
|
|
|
}
|
|
|
|
|
|
|
|
void IdEditDialog::rmTag5()
|
|
|
|
{
|
|
|
|
rmTag(4);
|
|
|
|
}
|
|
|
|
|
|
|
|
void IdEditDialog::rmTag(int idx)
|
|
|
|
{
|
|
|
|
std::list<std::string>::iterator it;
|
|
|
|
int i = 0;
|
|
|
|
for(it = mEditGroup.mRecognTags.begin(); it != mEditGroup.mRecognTags.end() && (idx < i); it++, i++) ;
|
|
|
|
|
|
|
|
if (it != mEditGroup.mRecognTags.end())
|
2012-02-13 13:43:15 -05:00
|
|
|
{
|
2013-10-20 05:56:12 -04:00
|
|
|
mEditGroup.mRecognTags.erase(it);
|
|
|
|
}
|
|
|
|
loadRecognTags();
|
|
|
|
}
|
|
|
|
|
2014-03-17 16:56:06 -04:00
|
|
|
bool IdEditDialog::tagDetails(const RsGxsId &id, const std::string &name, const std::string &tag, QString &desc)
|
2013-10-20 05:56:12 -04:00
|
|
|
{
|
|
|
|
if (tag.empty())
|
2012-02-13 13:43:15 -05:00
|
|
|
{
|
2013-10-20 05:56:12 -04:00
|
|
|
desc += "Empty Tag";
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* extract details for each tag */
|
|
|
|
RsRecognTagDetails tagDetails;
|
|
|
|
|
|
|
|
bool ok = false;
|
|
|
|
if (rsIdentity->parseRecognTag(id, name, tag, tagDetails))
|
|
|
|
{
|
|
|
|
desc += QString::number(tagDetails.tag_class);
|
|
|
|
desc += ":";
|
|
|
|
desc += QString::number(tagDetails.tag_type);
|
|
|
|
|
|
|
|
if (tagDetails.is_valid)
|
|
|
|
{
|
|
|
|
ok = true;
|
|
|
|
desc += " Valid";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
desc += " Invalid";
|
|
|
|
}
|
|
|
|
|
|
|
|
if (tagDetails.is_pending)
|
|
|
|
{
|
|
|
|
ok = true;
|
|
|
|
desc += " Pending";
|
|
|
|
}
|
2012-02-13 13:43:15 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-10-20 05:56:12 -04:00
|
|
|
desc += "Unparseable";
|
2012-02-13 13:43:15 -05:00
|
|
|
}
|
2013-10-20 05:56:12 -04:00
|
|
|
return ok;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void IdEditDialog::loadRecognTags()
|
|
|
|
{
|
|
|
|
std::cerr << "IdEditDialog::loadRecognTags()";
|
|
|
|
std::cerr << std::endl;
|
2012-02-13 13:43:15 -05:00
|
|
|
|
2013-10-20 05:56:12 -04:00
|
|
|
// delete existing items.
|
|
|
|
ui.label_Tag1->setHidden(true);
|
|
|
|
ui.label_Tag2->setHidden(true);
|
|
|
|
ui.label_Tag3->setHidden(true);
|
|
|
|
ui.label_Tag4->setHidden(true);
|
|
|
|
ui.label_Tag5->setHidden(true);
|
|
|
|
ui.toolButton_Tag1->setHidden(true);
|
|
|
|
ui.toolButton_Tag2->setHidden(true);
|
|
|
|
ui.toolButton_Tag3->setHidden(true);
|
|
|
|
ui.toolButton_Tag4->setHidden(true);
|
|
|
|
ui.toolButton_Tag5->setHidden(true);
|
|
|
|
ui.plainTextEdit_Tag->setPlainText("");
|
|
|
|
|
|
|
|
int i = 0;
|
|
|
|
std::list<std::string>::const_iterator it;
|
|
|
|
for(it = mEditGroup.mRecognTags.begin(); it != mEditGroup.mRecognTags.end(); it++, i++)
|
2012-02-13 13:43:15 -05:00
|
|
|
{
|
2013-10-20 05:56:12 -04:00
|
|
|
QString recognTag;
|
2014-03-17 16:56:06 -04:00
|
|
|
tagDetails(mEditGroup.mMeta.mAuthorId, mEditGroup.mMeta.mGroupName, *it, recognTag);
|
2012-02-13 13:43:15 -05:00
|
|
|
|
2013-10-20 05:56:12 -04:00
|
|
|
switch(i)
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
case 0:
|
|
|
|
ui.label_Tag1->setText(recognTag);
|
|
|
|
ui.label_Tag1->setHidden(false);
|
|
|
|
ui.toolButton_Tag1->setHidden(false);
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
ui.label_Tag2->setText(recognTag);
|
|
|
|
ui.label_Tag2->setHidden(false);
|
|
|
|
ui.toolButton_Tag2->setHidden(false);
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
ui.label_Tag3->setText(recognTag);
|
|
|
|
ui.label_Tag3->setHidden(false);
|
|
|
|
ui.toolButton_Tag3->setHidden(false);
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
ui.label_Tag4->setText(recognTag);
|
|
|
|
ui.label_Tag4->setHidden(false);
|
|
|
|
ui.toolButton_Tag4->setHidden(false);
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
ui.label_Tag5->setText(recognTag);
|
|
|
|
ui.label_Tag5->setHidden(false);
|
|
|
|
ui.toolButton_Tag5->setHidden(false);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-02-13 13:43:15 -05:00
|
|
|
|
2013-10-20 05:56:12 -04:00
|
|
|
void IdEditDialog::submit()
|
|
|
|
{
|
|
|
|
if (mIsNew)
|
|
|
|
{
|
|
|
|
createId();
|
2012-02-13 13:43:15 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-10-20 05:56:12 -04:00
|
|
|
updateId();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-02-13 13:43:15 -05:00
|
|
|
|
2013-10-20 05:56:12 -04:00
|
|
|
void IdEditDialog::createId()
|
|
|
|
{
|
|
|
|
std::string groupname = ui.lineEdit_Nickname->text().toUtf8().constData();
|
2012-02-13 13:43:15 -05:00
|
|
|
|
2013-10-20 05:56:12 -04:00
|
|
|
if (groupname.size() < 2)
|
|
|
|
{
|
|
|
|
std::cerr << "IdEditDialog::createId() Nickname too short";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
return;
|
2012-02-13 13:43:15 -05:00
|
|
|
}
|
2013-07-11 04:14:38 -04:00
|
|
|
|
2012-11-07 16:40:07 -05:00
|
|
|
RsIdentityParameters params;
|
2013-10-20 05:56:12 -04:00
|
|
|
params.nickname = groupname;
|
2012-11-07 16:40:07 -05:00
|
|
|
params.isPgpLinked = (ui.radioButton_GpgId->isChecked());
|
|
|
|
|
|
|
|
uint32_t dummyToken = 0;
|
|
|
|
rsIdentity->createIdentity(dummyToken, params);
|
2012-02-13 13:43:15 -05:00
|
|
|
|
2013-07-10 17:57:23 -04:00
|
|
|
close();
|
2012-02-13 13:43:15 -05:00
|
|
|
}
|
|
|
|
|
2013-10-20 05:56:12 -04:00
|
|
|
|
|
|
|
void IdEditDialog::updateId()
|
|
|
|
{
|
|
|
|
/* submit updated details */
|
|
|
|
std::string groupname = ui.lineEdit_Nickname->text().toUtf8().constData();
|
|
|
|
|
|
|
|
if (groupname.size() < 2)
|
|
|
|
{
|
|
|
|
std::cerr << "IdEditDialog::updateId() Nickname too short";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
mEditGroup.mMeta.mGroupName = groupname;
|
|
|
|
|
|
|
|
uint32_t dummyToken = 0;
|
|
|
|
rsIdentity->updateIdentity(dummyToken, mEditGroup);
|
|
|
|
|
|
|
|
close();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-07-10 17:57:23 -04:00
|
|
|
void IdEditDialog::loadRequest(const TokenQueue */*queue*/, const TokenRequest &req)
|
2012-06-13 20:36:25 -04:00
|
|
|
{
|
|
|
|
std::cerr << "IdDialog::loadRequest() UserType: " << req.mUserType;
|
|
|
|
std::cerr << std::endl;
|
2013-07-11 04:14:38 -04:00
|
|
|
|
2012-06-13 20:36:25 -04:00
|
|
|
// only one here!
|
|
|
|
loadExistingId(req.mToken);
|
|
|
|
}
|