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".
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2013-07-10 17:57:23 -04:00
|
|
|
#include <QMessageBox>
|
2014-05-03 13:56:12 -04:00
|
|
|
#include <QMenu>
|
2013-07-10 17:57:23 -04:00
|
|
|
|
2012-02-13 13:43:15 -05:00
|
|
|
#include "IdDialog.h"
|
2014-09-14 12:28:02 -04:00
|
|
|
#include "gui/gxs/GxsIdDetails.h"
|
2013-06-04 17:00:43 -04:00
|
|
|
#include "gui/gxs/GxsIdTreeWidgetItem.h"
|
2013-07-10 17:57:23 -04:00
|
|
|
#include "gui/common/UIStateHelper.h"
|
2014-06-12 06:28:23 -04:00
|
|
|
#include "gui/chat/ChatDialog.h"
|
2012-02-13 13:43:15 -05:00
|
|
|
|
|
|
|
#include <retroshare/rspeers.h>
|
2014-07-06 07:19:58 -04:00
|
|
|
//#include <retroshare/rsidentity.h> //On header
|
2013-02-28 16:58:38 -05:00
|
|
|
#include "retroshare/rsgxsflags.h"
|
2014-06-12 06:28:23 -04:00
|
|
|
#include "retroshare/rsmsgs.h"
|
2012-02-13 13:43:15 -05:00
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
|
|
|
|
/******
|
|
|
|
* #define ID_DEBUG 1
|
|
|
|
*****/
|
|
|
|
|
2012-06-13 20:36:25 -04:00
|
|
|
// Data Requests.
|
|
|
|
#define IDDIALOG_IDLIST 1
|
|
|
|
#define IDDIALOG_IDDETAILS 2
|
2013-06-04 17:00:43 -04:00
|
|
|
#define IDDIALOG_REPLIST 3
|
2014-02-19 06:11:06 -05:00
|
|
|
#define IDDIALOG_REFRESH 4
|
2012-02-13 13:43:15 -05:00
|
|
|
|
|
|
|
/****************************************************************
|
|
|
|
*/
|
|
|
|
|
2013-07-11 04:14:38 -04:00
|
|
|
#define RSID_COL_NICKNAME 0
|
|
|
|
#define RSID_COL_KEYID 1
|
|
|
|
#define RSID_COL_IDTYPE 2
|
2012-02-13 13:43:15 -05:00
|
|
|
|
2013-07-11 04:14:38 -04:00
|
|
|
#define RSIDREP_COL_NAME 0
|
|
|
|
#define RSIDREP_COL_OPINION 1
|
|
|
|
#define RSIDREP_COL_COMMENT 2
|
|
|
|
#define RSIDREP_COL_REPUTATION 3
|
2012-02-13 13:43:15 -05:00
|
|
|
|
2013-07-10 17:57:23 -04:00
|
|
|
#define RSID_FILTER_YOURSELF 0x0001
|
|
|
|
#define RSID_FILTER_FRIENDS 0x0002
|
|
|
|
#define RSID_FILTER_OTHERS 0x0004
|
|
|
|
#define RSID_FILTER_PSEUDONYMS 0x0008
|
|
|
|
#define RSID_FILTER_ALL 0xffff
|
2012-06-07 13:11:57 -04:00
|
|
|
|
2014-05-03 13:56:12 -04:00
|
|
|
#define IMAGE_EDIT ":/images/edit_16.png"
|
|
|
|
|
2012-02-13 13:43:15 -05:00
|
|
|
/** Constructor */
|
|
|
|
IdDialog::IdDialog(QWidget *parent)
|
2013-07-14 14:48:40 -04:00
|
|
|
: RsGxsUpdateBroadcastPage(rsIdentity, parent)
|
2012-02-13 13:43:15 -05:00
|
|
|
{
|
|
|
|
ui.setupUi(this);
|
|
|
|
|
2013-07-10 17:57:23 -04:00
|
|
|
mIdQueue = NULL;
|
|
|
|
|
|
|
|
/* Setup UI helper */
|
|
|
|
mStateHelper = new UIStateHelper(this);
|
|
|
|
mStateHelper->addWidget(IDDIALOG_IDLIST, ui.treeWidget_IdList);
|
|
|
|
mStateHelper->addLoadPlaceholder(IDDIALOG_IDLIST, ui.treeWidget_IdList, false);
|
|
|
|
mStateHelper->addClear(IDDIALOG_IDLIST, ui.treeWidget_IdList);
|
|
|
|
|
|
|
|
mStateHelper->addWidget(IDDIALOG_IDDETAILS, ui.lineEdit_Nickname);
|
|
|
|
mStateHelper->addWidget(IDDIALOG_IDDETAILS, ui.lineEdit_KeyId);
|
2014-09-24 16:13:19 -04:00
|
|
|
// mStateHelper->addWidget(IDDIALOG_IDDETAILS, ui.lineEdit_GpgHash);
|
2013-07-10 17:57:23 -04:00
|
|
|
mStateHelper->addWidget(IDDIALOG_IDDETAILS, ui.lineEdit_GpgId);
|
|
|
|
mStateHelper->addWidget(IDDIALOG_IDDETAILS, ui.lineEdit_GpgName);
|
2014-09-24 16:48:16 -04:00
|
|
|
mStateHelper->addWidget(IDDIALOG_IDDETAILS, ui.lineEdit_Type);
|
2013-09-02 15:20:47 -04:00
|
|
|
mStateHelper->addWidget(IDDIALOG_IDDETAILS, ui.toolButton_Reputation);
|
|
|
|
mStateHelper->addWidget(IDDIALOG_IDDETAILS, ui.toolButton_Delete);
|
|
|
|
mStateHelper->addWidget(IDDIALOG_IDDETAILS, ui.toolButton_EditId);
|
2013-07-10 17:57:23 -04:00
|
|
|
mStateHelper->addWidget(IDDIALOG_IDDETAILS, ui.line_RatingOverall);
|
|
|
|
mStateHelper->addWidget(IDDIALOG_IDDETAILS, ui.line_RatingImplicit);
|
|
|
|
mStateHelper->addWidget(IDDIALOG_IDDETAILS, ui.line_RatingOwn);
|
2014-02-19 06:11:06 -05:00
|
|
|
mStateHelper->addWidget(IDDIALOG_IDDETAILS, ui.line_RatingPeers);
|
|
|
|
mStateHelper->addWidget(IDDIALOG_IDDETAILS, ui.repModButton);
|
|
|
|
mStateHelper->addWidget(IDDIALOG_IDDETAILS, ui.repMod_Accept);
|
|
|
|
mStateHelper->addWidget(IDDIALOG_IDDETAILS, ui.repMod_Ban);
|
|
|
|
mStateHelper->addWidget(IDDIALOG_IDDETAILS, ui.repMod_Negative);
|
|
|
|
mStateHelper->addWidget(IDDIALOG_IDDETAILS, ui.repMod_Positive);
|
|
|
|
mStateHelper->addWidget(IDDIALOG_IDDETAILS, ui.repMod_Custom);
|
|
|
|
mStateHelper->addWidget(IDDIALOG_IDDETAILS, ui.repMod_spinBox);
|
2013-07-10 17:57:23 -04:00
|
|
|
|
|
|
|
mStateHelper->addLoadPlaceholder(IDDIALOG_IDDETAILS, ui.lineEdit_Nickname);
|
|
|
|
mStateHelper->addLoadPlaceholder(IDDIALOG_IDDETAILS, ui.lineEdit_GpgName);
|
|
|
|
mStateHelper->addLoadPlaceholder(IDDIALOG_IDDETAILS, ui.lineEdit_KeyId);
|
2014-09-24 16:13:19 -04:00
|
|
|
// mStateHelper->addLoadPlaceholder(IDDIALOG_IDDETAILS, ui.lineEdit_GpgHash);
|
2013-07-10 17:57:23 -04:00
|
|
|
mStateHelper->addLoadPlaceholder(IDDIALOG_IDDETAILS, ui.lineEdit_GpgId);
|
2014-09-24 16:48:16 -04:00
|
|
|
mStateHelper->addLoadPlaceholder(IDDIALOG_IDDETAILS, ui.lineEdit_Type);
|
2013-07-10 17:57:23 -04:00
|
|
|
mStateHelper->addLoadPlaceholder(IDDIALOG_IDDETAILS, ui.lineEdit_GpgName);
|
|
|
|
mStateHelper->addLoadPlaceholder(IDDIALOG_IDDETAILS, ui.line_RatingOverall);
|
|
|
|
mStateHelper->addLoadPlaceholder(IDDIALOG_IDDETAILS, ui.line_RatingImplicit);
|
|
|
|
mStateHelper->addLoadPlaceholder(IDDIALOG_IDDETAILS, ui.line_RatingOwn);
|
2014-02-19 06:11:06 -05:00
|
|
|
mStateHelper->addLoadPlaceholder(IDDIALOG_IDDETAILS, ui.line_RatingPeers);
|
2013-07-10 17:57:23 -04:00
|
|
|
|
|
|
|
mStateHelper->addClear(IDDIALOG_IDDETAILS, ui.lineEdit_Nickname);
|
|
|
|
mStateHelper->addClear(IDDIALOG_IDDETAILS, ui.lineEdit_KeyId);
|
2014-09-24 16:13:19 -04:00
|
|
|
// mStateHelper->addClear(IDDIALOG_IDDETAILS, ui.lineEdit_GpgHash);
|
2013-07-10 17:57:23 -04:00
|
|
|
mStateHelper->addClear(IDDIALOG_IDDETAILS, ui.lineEdit_GpgId);
|
2014-09-24 16:48:16 -04:00
|
|
|
mStateHelper->addClear(IDDIALOG_IDDETAILS, ui.lineEdit_Type);
|
2013-07-10 17:57:23 -04:00
|
|
|
mStateHelper->addClear(IDDIALOG_IDDETAILS, ui.lineEdit_GpgName);
|
|
|
|
mStateHelper->addClear(IDDIALOG_IDDETAILS, ui.line_RatingOverall);
|
|
|
|
mStateHelper->addClear(IDDIALOG_IDDETAILS, ui.line_RatingImplicit);
|
|
|
|
mStateHelper->addClear(IDDIALOG_IDDETAILS, ui.line_RatingOwn);
|
2014-02-19 06:11:06 -05:00
|
|
|
mStateHelper->addClear(IDDIALOG_IDDETAILS, ui.line_RatingPeers);
|
2013-07-10 17:57:23 -04:00
|
|
|
|
2014-02-19 06:11:06 -05:00
|
|
|
//mStateHelper->addWidget(IDDIALOG_REPLIST, ui.treeWidget_RepList);
|
|
|
|
//mStateHelper->addLoadPlaceholder(IDDIALOG_REPLIST, ui.treeWidget_RepList);
|
|
|
|
//mStateHelper->addClear(IDDIALOG_REPLIST, ui.treeWidget_RepList);
|
2013-07-10 17:57:23 -04:00
|
|
|
|
|
|
|
/* Connect signals */
|
2013-09-02 15:20:47 -04:00
|
|
|
connect(ui.toolButton_NewId, SIGNAL(clicked()), this, SLOT(addIdentity()));
|
2013-07-10 17:57:23 -04:00
|
|
|
connect(ui.todoPushButton, SIGNAL(clicked()), this, SLOT(todo()));
|
2014-05-06 13:15:20 -04:00
|
|
|
connect(ui.toolButton_Delete, SIGNAL(clicked()), this, SLOT(removeIdentity()));
|
2013-09-02 15:20:47 -04:00
|
|
|
connect(ui.toolButton_EditId, SIGNAL(clicked()), this, SLOT(editIdentity()));
|
2014-05-06 13:15:20 -04:00
|
|
|
connect(ui.removeIdentity, SIGNAL(triggered()), this, SLOT(removeIdentity()));
|
2014-05-03 13:56:12 -04:00
|
|
|
connect(ui.editIdentity, SIGNAL(triggered()), this, SLOT(editIdentity()));
|
2014-06-12 06:28:23 -04:00
|
|
|
connect(ui.chatIdentity, SIGNAL(triggered()), this, SLOT(chatIdentity()));
|
2014-05-03 13:56:12 -04:00
|
|
|
|
2014-02-13 06:55:14 -05:00
|
|
|
connect(ui.treeWidget_IdList, SIGNAL(itemSelectionChanged()), this, SLOT(updateSelection()));
|
2014-05-03 13:56:12 -04:00
|
|
|
connect(ui.treeWidget_IdList, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(IdListCustomPopupMenu(QPoint)));
|
2012-02-13 13:43:15 -05:00
|
|
|
|
2013-07-10 17:57:23 -04:00
|
|
|
connect(ui.filterComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(filterComboBoxChanged()));
|
|
|
|
connect(ui.filterLineEdit, SIGNAL(textChanged(QString)), this, SLOT(filterChanged(QString)));
|
2014-02-19 06:11:06 -05:00
|
|
|
connect(ui.repModButton, SIGNAL(clicked()), this, SLOT(modifyReputation()));
|
2014-09-09 15:45:38 -04:00
|
|
|
|
2014-06-04 20:18:28 -04:00
|
|
|
ui.headerFrame->setHeaderImage(QPixmap(":/images/identity/identity_64.png"));
|
|
|
|
ui.headerFrame->setHeaderText(tr("Identities"));
|
2013-07-10 17:57:23 -04:00
|
|
|
|
|
|
|
/* Add filter types */
|
|
|
|
ui.filterComboBox->addItem(tr("All"), RSID_FILTER_ALL);
|
2014-09-24 16:48:16 -04:00
|
|
|
ui.filterComboBox->addItem(tr("Owned by you"), RSID_FILTER_YOURSELF);
|
|
|
|
ui.filterComboBox->addItem(tr("Owned by friend nodes / friends of friends"), RSID_FILTER_FRIENDS);
|
|
|
|
ui.filterComboBox->addItem(tr("Owned by distant nodes"), RSID_FILTER_OTHERS);
|
|
|
|
ui.filterComboBox->addItem(tr("Anonymous"), RSID_FILTER_PSEUDONYMS);
|
2013-07-10 17:57:23 -04:00
|
|
|
ui.filterComboBox->setCurrentIndex(0);
|
|
|
|
|
|
|
|
/* Add filter actions */
|
|
|
|
QTreeWidgetItem *headerItem = ui.treeWidget_IdList->headerItem();
|
|
|
|
QString headerText = headerItem->text(RSID_COL_NICKNAME);
|
|
|
|
ui.filterLineEdit->addFilter(QIcon(), headerText, RSID_COL_NICKNAME, QString("%1 %2").arg(tr("Search"), headerText));
|
|
|
|
headerText = headerItem->text(RSID_COL_KEYID);
|
|
|
|
ui.filterLineEdit->addFilter(QIcon(), headerItem->text(RSID_COL_KEYID), RSID_COL_KEYID, QString("%1 %2").arg(tr("Search"), headerText));
|
2014-09-15 19:28:53 -04:00
|
|
|
|
|
|
|
|
|
|
|
/* Set header resize modes and initial section sizes ID TreeView*/
|
|
|
|
QHeaderView * _idheader = ui.treeWidget_IdList->header () ;
|
|
|
|
_idheader->resizeSection ( RSID_COL_NICKNAME, 170 );
|
2013-07-10 17:57:23 -04:00
|
|
|
|
|
|
|
/* Setup tree */
|
|
|
|
ui.treeWidget_IdList->sortByColumn(RSID_COL_NICKNAME, Qt::AscendingOrder);
|
2014-05-03 13:56:12 -04:00
|
|
|
ui.treeWidget_IdList->setContextMenuPolicy(Qt::CustomContextMenu) ;
|
|
|
|
|
2012-02-13 13:43:15 -05:00
|
|
|
|
2012-11-01 20:49:06 -04:00
|
|
|
mIdQueue = new TokenQueue(rsIdentity->getTokenService(), this);
|
2013-07-10 17:57:23 -04:00
|
|
|
|
|
|
|
mStateHelper->setActive(IDDIALOG_IDDETAILS, false);
|
|
|
|
mStateHelper->setActive(IDDIALOG_REPLIST, false);
|
2014-02-19 06:11:06 -05:00
|
|
|
|
|
|
|
// Hiding RepList until that part is finished.
|
|
|
|
//ui.treeWidget_RepList->setVisible(false);
|
|
|
|
ui.toolButton_Reputation->setVisible(false);
|
2014-09-09 15:45:38 -04:00
|
|
|
#ifndef UNFINISHED
|
|
|
|
ui.todoPushButton->hide() ;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
QString hlp_str = tr(
|
|
|
|
" <h1><img width=\"32\" src=\":/images/64px_help.png\"> Identities</h1> \
|
|
|
|
<p>In this tab you can create/edit pseudo-anonymous identities. \
|
|
|
|
</p> \
|
|
|
|
<p>Identities are used to securely identify your data: sign forum and channel posts,\
|
|
|
|
and receive feedback using Retroshare built-in email system, post comments \
|
|
|
|
after channel posts, etc.</p> \
|
|
|
|
<p> \
|
|
|
|
Identities can optionally be signed by your Retroshare node's certificate. \
|
|
|
|
Signed identities are easier to trust but are easily linked to your node's IP address. \
|
|
|
|
</p> \
|
|
|
|
<p> \
|
|
|
|
Anonymous identities allow you to anonymously interact with other users. They cannot be \
|
|
|
|
spoofed, but noone can prove who really owns a given identity. \
|
|
|
|
</p> \
|
|
|
|
") ;
|
|
|
|
|
|
|
|
registerHelpButton(ui.helpButton, hlp_str) ;
|
2012-02-13 13:43:15 -05:00
|
|
|
}
|
|
|
|
|
2013-07-10 17:57:23 -04:00
|
|
|
void IdDialog::todo()
|
2012-02-13 13:43:15 -05:00
|
|
|
{
|
2013-07-10 17:57:23 -04:00
|
|
|
QMessageBox::information(this, "Todo",
|
|
|
|
"<b>Open points:</b><ul>"
|
2014-05-06 13:15:20 -04:00
|
|
|
// "<li>Delete ID"
|
2013-07-10 17:57:23 -04:00
|
|
|
"<li>Reputation"
|
|
|
|
"<li>Load/save settings"
|
|
|
|
"</ul>");
|
|
|
|
}
|
|
|
|
|
|
|
|
void IdDialog::filterComboBoxChanged()
|
2013-07-11 04:14:38 -04:00
|
|
|
{
|
|
|
|
requestIdList();
|
|
|
|
}
|
2012-02-13 13:43:15 -05:00
|
|
|
|
2013-07-10 17:57:23 -04:00
|
|
|
void IdDialog::filterChanged(const QString& /*text*/)
|
|
|
|
{
|
|
|
|
filterIds();
|
|
|
|
}
|
2012-02-13 13:43:15 -05:00
|
|
|
|
|
|
|
void IdDialog::updateSelection()
|
|
|
|
{
|
|
|
|
QTreeWidgetItem *item = ui.treeWidget_IdList->currentItem();
|
2014-03-17 16:56:06 -04:00
|
|
|
RsGxsGroupId id;
|
2013-07-10 17:57:23 -04:00
|
|
|
|
|
|
|
if (item)
|
|
|
|
{
|
2014-03-17 16:56:06 -04:00
|
|
|
id = RsGxsGroupId(item->text(RSID_COL_KEYID).toStdString());
|
2013-07-10 17:57:23 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
requestIdDetails(id);
|
|
|
|
}
|
|
|
|
|
|
|
|
void IdDialog::requestIdList()
|
|
|
|
{
|
|
|
|
if (!mIdQueue)
|
|
|
|
return;
|
|
|
|
|
|
|
|
mStateHelper->setLoading(IDDIALOG_IDLIST, true);
|
|
|
|
mStateHelper->setLoading(IDDIALOG_IDDETAILS, true);
|
|
|
|
mStateHelper->setLoading(IDDIALOG_REPLIST, true);
|
|
|
|
|
|
|
|
mIdQueue->cancelActiveRequestTokens(IDDIALOG_IDLIST);
|
|
|
|
|
|
|
|
RsTokReqOptions opts;
|
|
|
|
opts.mReqType = GXS_REQUEST_TYPE_GROUP_DATA;
|
|
|
|
|
|
|
|
uint32_t token;
|
|
|
|
|
|
|
|
mIdQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, IDDIALOG_IDLIST);
|
|
|
|
}
|
|
|
|
|
2014-03-17 16:56:06 -04:00
|
|
|
bool IdDialog::fillIdListItem(const RsGxsIdGroup& data, QTreeWidgetItem *&item, const RsPgpId &ownPgpId, int accept)
|
2013-07-10 17:57:23 -04:00
|
|
|
{
|
|
|
|
bool isOwnId = (data.mPgpKnown && (data.mPgpId == ownPgpId)) || (data.mMeta.mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_ADMIN);
|
|
|
|
|
|
|
|
/* do filtering */
|
|
|
|
bool ok = false;
|
|
|
|
if (data.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID)
|
|
|
|
{
|
|
|
|
if (isOwnId && (accept & RSID_FILTER_YOURSELF))
|
|
|
|
{
|
|
|
|
ok = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (data.mPgpKnown)
|
|
|
|
{
|
|
|
|
if (accept & RSID_FILTER_FRIENDS)
|
|
|
|
{
|
|
|
|
ok = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (accept & RSID_FILTER_OTHERS)
|
|
|
|
{
|
|
|
|
ok = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (accept & RSID_FILTER_PSEUDONYMS)
|
|
|
|
{
|
|
|
|
ok = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isOwnId && (accept & RSID_FILTER_YOURSELF))
|
|
|
|
{
|
|
|
|
ok = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!ok)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2012-02-13 13:43:15 -05:00
|
|
|
|
|
|
|
if (!item)
|
|
|
|
{
|
2013-07-10 17:57:23 -04:00
|
|
|
item = new QTreeWidgetItem();
|
2012-02-13 13:43:15 -05:00
|
|
|
}
|
2013-07-10 17:57:23 -04:00
|
|
|
item->setText(RSID_COL_NICKNAME, QString::fromUtf8(data.mMeta.mGroupName.c_str()));
|
2014-03-17 16:56:06 -04:00
|
|
|
item->setText(RSID_COL_KEYID, QString::fromStdString(data.mMeta.mGroupId.toStdString()));
|
2013-07-10 17:57:23 -04:00
|
|
|
|
2014-09-24 17:00:40 -04:00
|
|
|
QFont font("Courier New",10,50,false);
|
|
|
|
font.setStyleHint(QFont::TypeWriter,QFont::PreferMatch);
|
|
|
|
item->setFont(RSID_COL_KEYID,font) ;
|
|
|
|
|
2014-09-24 16:13:19 -04:00
|
|
|
if(isOwnId)
|
|
|
|
{
|
|
|
|
QFont font = item->font(RSID_COL_NICKNAME) ;
|
|
|
|
font.setWeight(QFont::Bold) ;
|
|
|
|
item->setFont(RSID_COL_NICKNAME,font) ;
|
|
|
|
item->setFont(RSID_COL_IDTYPE,font) ;
|
|
|
|
|
2014-09-24 17:00:40 -04:00
|
|
|
font = item->font(RSID_COL_KEYID) ;
|
|
|
|
font.setWeight(QFont::Bold) ;
|
|
|
|
item->setFont(RSID_COL_KEYID,font) ;
|
|
|
|
|
2014-09-24 16:13:19 -04:00
|
|
|
item->setToolTip(RSID_COL_NICKNAME,tr("This identity is owned by you")) ;
|
|
|
|
item->setToolTip(RSID_COL_KEYID ,tr("This identity is owned by you")) ;
|
|
|
|
item->setToolTip(RSID_COL_IDTYPE ,tr("This identity is owned by you")) ;
|
2014-09-24 17:00:40 -04:00
|
|
|
|
2014-09-24 16:13:19 -04:00
|
|
|
}
|
|
|
|
|
2014-09-15 19:28:53 -04:00
|
|
|
QPixmap pixmap = QPixmap::fromImage(GxsIdDetails::makeDefaultIcon(RsGxsId(data.mMeta.mGroupId))) ;
|
|
|
|
std::cerr << "Setting item image : " << pixmap.width() << " x " << pixmap.height() << std::endl;
|
|
|
|
item->setIcon(RSID_COL_NICKNAME, QIcon(pixmap));
|
|
|
|
|
2013-07-10 17:57:23 -04:00
|
|
|
if (data.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID)
|
|
|
|
{
|
|
|
|
if (data.mPgpKnown)
|
|
|
|
{
|
|
|
|
RsPeerDetails details;
|
|
|
|
rsPeers->getGPGDetails(data.mPgpId, details);
|
|
|
|
item->setText(RSID_COL_IDTYPE, QString::fromUtf8(details.name.c_str()));
|
2014-09-24 16:13:19 -04:00
|
|
|
item->setToolTip(RSID_COL_IDTYPE,QString()) ;
|
2013-07-10 17:57:23 -04:00
|
|
|
}
|
2014-04-14 11:37:06 -04:00
|
|
|
else
|
|
|
|
{
|
2014-09-24 16:13:19 -04:00
|
|
|
item->setText(RSID_COL_IDTYPE, tr("Unknown PGP key 0x")+QString::fromStdString(data.mPgpId.toStdString()));
|
|
|
|
item->setToolTip(RSID_COL_IDTYPE,tr("Unknown key ID")) ;
|
2014-04-14 11:37:06 -04:00
|
|
|
}
|
2012-06-07 13:11:57 -04:00
|
|
|
}
|
2013-07-10 17:57:23 -04:00
|
|
|
else
|
|
|
|
{
|
2014-09-24 16:13:19 -04:00
|
|
|
item->setText(RSID_COL_IDTYPE, QString()) ;
|
|
|
|
item->setToolTip(RSID_COL_IDTYPE,QString()) ;
|
2013-07-10 17:57:23 -04:00
|
|
|
}
|
2012-02-13 13:43:15 -05:00
|
|
|
|
2013-07-10 17:57:23 -04:00
|
|
|
return true;
|
|
|
|
}
|
2012-02-13 13:43:15 -05:00
|
|
|
|
2013-07-10 17:57:23 -04:00
|
|
|
void IdDialog::insertIdList(uint32_t token)
|
2012-06-07 13:11:57 -04:00
|
|
|
{
|
2013-07-10 17:57:23 -04:00
|
|
|
mStateHelper->setLoading(IDDIALOG_IDLIST, false);
|
|
|
|
|
|
|
|
int accept = ui.filterComboBox->itemData(ui.filterComboBox->currentIndex()).toInt();
|
|
|
|
|
|
|
|
RsGxsIdGroup data;
|
|
|
|
std::vector<RsGxsIdGroup> datavector;
|
|
|
|
std::vector<RsGxsIdGroup>::iterator vit;
|
|
|
|
if (!rsIdentity->getGroupData(token, datavector))
|
|
|
|
{
|
|
|
|
std::cerr << "IdDialog::insertIdList() Error getting GroupData";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
|
|
|
|
mStateHelper->setLoading(IDDIALOG_IDDETAILS, false);
|
|
|
|
mStateHelper->setLoading(IDDIALOG_REPLIST, false);
|
|
|
|
mStateHelper->setActive(IDDIALOG_IDLIST, false);
|
|
|
|
mStateHelper->setActive(IDDIALOG_IDDETAILS, false);
|
|
|
|
mStateHelper->setActive(IDDIALOG_REPLIST, false);
|
|
|
|
mStateHelper->clear(IDDIALOG_IDLIST);
|
|
|
|
mStateHelper->clear(IDDIALOG_IDDETAILS);
|
|
|
|
mStateHelper->clear(IDDIALOG_REPLIST);
|
|
|
|
|
|
|
|
return;
|
2014-04-14 11:37:06 -04:00
|
|
|
}
|
2012-02-13 13:43:15 -05:00
|
|
|
|
2013-07-10 17:57:23 -04:00
|
|
|
mStateHelper->setActive(IDDIALOG_IDLIST, true);
|
|
|
|
|
2014-03-17 16:56:06 -04:00
|
|
|
RsPgpId ownPgpId = rsPeers->getGPGOwnId();
|
2012-02-13 13:43:15 -05:00
|
|
|
|
2013-07-10 17:57:23 -04:00
|
|
|
/* Update existing and remove not existing items */
|
|
|
|
QTreeWidgetItemIterator itemIterator(ui.treeWidget_IdList);
|
|
|
|
QTreeWidgetItem *item = NULL;
|
|
|
|
while ((item = *itemIterator) != NULL) {
|
|
|
|
itemIterator++;
|
2012-06-13 20:36:25 -04:00
|
|
|
|
2013-07-10 17:57:23 -04:00
|
|
|
for (vit = datavector.begin(); vit != datavector.end(); ++vit)
|
|
|
|
{
|
2014-03-17 16:56:06 -04:00
|
|
|
if (vit->mMeta.mGroupId == RsGxsGroupId(item->text(RSID_COL_KEYID).toStdString()))
|
2013-07-10 17:57:23 -04:00
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (vit == datavector.end())
|
|
|
|
{
|
|
|
|
delete(item);
|
|
|
|
} else {
|
|
|
|
if (!fillIdListItem(*vit, item, ownPgpId, accept))
|
|
|
|
{
|
|
|
|
delete(item);
|
|
|
|
}
|
|
|
|
datavector.erase(vit);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Insert new items */
|
|
|
|
for (vit = datavector.begin(); vit != datavector.end(); ++vit)
|
|
|
|
{
|
|
|
|
data = (*vit);
|
|
|
|
|
|
|
|
item = NULL;
|
|
|
|
if (fillIdListItem(*vit, item, ownPgpId, accept))
|
|
|
|
{
|
|
|
|
ui.treeWidget_IdList->addTopLevelItem(item);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
filterIds();
|
|
|
|
|
|
|
|
// fix up buttons.
|
|
|
|
updateSelection();
|
|
|
|
}
|
2012-06-13 20:36:25 -04:00
|
|
|
|
2014-03-17 16:56:06 -04:00
|
|
|
void IdDialog::requestIdDetails(RsGxsGroupId &id)
|
2012-02-13 13:43:15 -05:00
|
|
|
{
|
2013-07-10 17:57:23 -04:00
|
|
|
mIdQueue->cancelActiveRequestTokens(IDDIALOG_IDDETAILS);
|
|
|
|
|
2014-03-17 16:56:06 -04:00
|
|
|
if (id.isNull())
|
2013-07-10 17:57:23 -04:00
|
|
|
{
|
|
|
|
mStateHelper->setActive(IDDIALOG_IDDETAILS, false);
|
|
|
|
mStateHelper->setActive(IDDIALOG_REPLIST, false);
|
|
|
|
mStateHelper->setLoading(IDDIALOG_IDDETAILS, false);
|
|
|
|
mStateHelper->setLoading(IDDIALOG_REPLIST, false);
|
|
|
|
mStateHelper->clear(IDDIALOG_IDDETAILS);
|
|
|
|
mStateHelper->clear(IDDIALOG_REPLIST);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
mStateHelper->setLoading(IDDIALOG_IDDETAILS, true);
|
|
|
|
mStateHelper->setLoading(IDDIALOG_REPLIST, true);
|
|
|
|
|
2012-06-13 20:36:25 -04:00
|
|
|
RsTokReqOptions opts;
|
2013-07-11 04:14:38 -04:00
|
|
|
opts.mReqType = GXS_REQUEST_TYPE_GROUP_DATA;
|
2012-02-13 13:43:15 -05:00
|
|
|
|
2012-06-13 20:36:25 -04:00
|
|
|
uint32_t token;
|
2014-03-17 16:56:06 -04:00
|
|
|
std::list<RsGxsGroupId> groupIds;
|
2012-06-13 20:36:25 -04:00
|
|
|
groupIds.push_back(id);
|
2012-02-13 13:43:15 -05:00
|
|
|
|
2013-07-11 04:14:38 -04:00
|
|
|
mIdQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, groupIds, IDDIALOG_IDDETAILS);
|
2012-02-13 13:43:15 -05:00
|
|
|
}
|
|
|
|
|
2012-06-07 13:11:57 -04:00
|
|
|
void IdDialog::insertIdDetails(uint32_t token)
|
2012-02-13 13:43:15 -05:00
|
|
|
{
|
2013-07-10 17:57:23 -04:00
|
|
|
mStateHelper->setLoading(IDDIALOG_IDDETAILS, false);
|
|
|
|
|
2012-06-07 13:11:57 -04:00
|
|
|
/* get details from libretroshare */
|
2012-10-31 19:32:56 -04:00
|
|
|
RsGxsIdGroup data;
|
2012-11-01 20:49:06 -04:00
|
|
|
std::vector<RsGxsIdGroup> datavector;
|
|
|
|
if (!rsIdentity->getGroupData(token, datavector))
|
2012-02-13 13:43:15 -05:00
|
|
|
{
|
2013-07-10 17:57:23 -04:00
|
|
|
mStateHelper->setActive(IDDIALOG_IDDETAILS, false);
|
|
|
|
mStateHelper->setActive(IDDIALOG_REPLIST, false);
|
|
|
|
mStateHelper->setLoading(IDDIALOG_REPLIST, false);
|
|
|
|
mStateHelper->clear(IDDIALOG_IDDETAILS);
|
|
|
|
mStateHelper->clear(IDDIALOG_REPLIST);
|
|
|
|
|
2012-06-07 13:11:57 -04:00
|
|
|
ui.lineEdit_KeyId->setText("ERROR GETTING KEY!");
|
2013-07-10 17:57:23 -04:00
|
|
|
|
2012-06-07 13:11:57 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-11-01 20:49:06 -04:00
|
|
|
if (datavector.size() != 1)
|
|
|
|
{
|
|
|
|
std::cerr << "IdDialog::insertIdDetails() Invalid datavector size";
|
2013-07-10 17:57:23 -04:00
|
|
|
|
|
|
|
mStateHelper->setActive(IDDIALOG_IDDETAILS, false);
|
|
|
|
mStateHelper->setActive(IDDIALOG_REPLIST, false);
|
|
|
|
mStateHelper->setLoading(IDDIALOG_REPLIST, false);
|
|
|
|
mStateHelper->clear(IDDIALOG_IDDETAILS);
|
|
|
|
mStateHelper->clear(IDDIALOG_REPLIST);
|
|
|
|
|
2012-11-01 20:49:06 -04:00
|
|
|
ui.lineEdit_KeyId->setText("INVALID DV SIZE");
|
2013-07-10 17:57:23 -04:00
|
|
|
|
2012-11-01 20:49:06 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-07-10 17:57:23 -04:00
|
|
|
mStateHelper->setActive(IDDIALOG_IDDETAILS, true);
|
|
|
|
|
2012-11-01 20:49:06 -04:00
|
|
|
data = datavector[0];
|
|
|
|
|
2012-06-07 13:11:57 -04:00
|
|
|
/* get GPG Details from rsPeers */
|
2014-03-17 16:56:06 -04:00
|
|
|
RsPgpId ownPgpId = rsPeers->getGPGOwnId();
|
2013-07-11 04:14:38 -04:00
|
|
|
|
2013-07-24 10:33:47 -04:00
|
|
|
ui.lineEdit_Nickname->setText(QString::fromUtf8(data.mMeta.mGroupName.c_str()));
|
2014-06-04 20:18:28 -04:00
|
|
|
ui.lineEdit_KeyId->setText(QString::fromStdString(data.mMeta.mGroupId.toStdString()));
|
2014-09-24 16:13:19 -04:00
|
|
|
//ui.lineEdit_GpgHash->setText(QString::fromStdString(data.mPgpIdHash.toStdString()));
|
2014-03-17 16:56:06 -04:00
|
|
|
ui.lineEdit_GpgId->setText(QString::fromStdString(data.mPgpId.toStdString()));
|
2014-06-04 20:18:28 -04:00
|
|
|
|
|
|
|
ui.headerFrame->setHeaderText(QString::fromUtf8(data.mMeta.mGroupName.c_str()));
|
2012-11-05 17:32:52 -05:00
|
|
|
|
2014-09-14 12:28:02 -04:00
|
|
|
QPixmap pix = QPixmap::fromImage(GxsIdDetails::makeDefaultIcon(RsGxsId(data.mMeta.mGroupId))) ;
|
|
|
|
std::cerr << "Setting header frame image : " << pix.width() << " x " << pix.height() << std::endl;
|
|
|
|
ui.headerFrame->setHeaderImage(pix);
|
|
|
|
|
2012-11-06 14:18:56 -05:00
|
|
|
if (data.mPgpKnown)
|
2012-06-07 13:11:57 -04:00
|
|
|
{
|
2012-11-06 14:18:56 -05:00
|
|
|
RsPeerDetails details;
|
|
|
|
rsPeers->getGPGDetails(data.mPgpId, details);
|
2013-07-24 10:33:47 -04:00
|
|
|
ui.lineEdit_GpgName->setText(QString::fromUtf8(details.name.c_str()));
|
2012-06-07 13:11:57 -04:00
|
|
|
}
|
2012-11-06 14:18:56 -05:00
|
|
|
else
|
2012-06-07 13:11:57 -04:00
|
|
|
{
|
2012-11-06 14:18:56 -05:00
|
|
|
if (data.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID)
|
|
|
|
{
|
2013-07-10 17:57:23 -04:00
|
|
|
ui.lineEdit_GpgName->setText(tr("Unknown real name"));
|
2012-11-06 14:18:56 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-07-10 17:57:23 -04:00
|
|
|
ui.lineEdit_GpgName->setText(tr("Anonymous Id"));
|
2012-11-06 14:18:56 -05:00
|
|
|
}
|
2012-06-07 13:11:57 -04:00
|
|
|
}
|
2012-11-06 14:18:56 -05:00
|
|
|
|
2014-09-24 16:13:19 -04:00
|
|
|
if(data.mPgpId.isNull())
|
|
|
|
{
|
|
|
|
ui.lineEdit_GpgId->hide() ;
|
|
|
|
ui.lineEdit_GpgName->hide() ;
|
|
|
|
ui.PgpId_LB->hide() ;
|
|
|
|
ui.PgpName_LB->hide() ;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ui.lineEdit_GpgId->show() ;
|
|
|
|
ui.lineEdit_GpgName->show() ;
|
|
|
|
ui.PgpId_LB->show() ;
|
|
|
|
ui.PgpName_LB->show() ;
|
|
|
|
}
|
|
|
|
|
2013-07-10 17:57:23 -04:00
|
|
|
bool isOwnId = (data.mPgpKnown && (data.mPgpId == ownPgpId)) || (data.mMeta.mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_ADMIN);
|
2012-11-06 14:18:56 -05:00
|
|
|
|
2014-09-24 16:48:16 -04:00
|
|
|
if(isOwnId)
|
|
|
|
if (data.mPgpKnown)
|
|
|
|
ui.lineEdit_Type->setText(tr("Identity owned by you, linked to your Retroshare node")) ;
|
|
|
|
else
|
|
|
|
ui.lineEdit_Type->setText(tr("Anonymous identity, owned by you")) ;
|
2012-11-06 14:18:56 -05:00
|
|
|
else if (data.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID)
|
2012-06-07 13:11:57 -04:00
|
|
|
{
|
2012-11-06 14:18:56 -05:00
|
|
|
if (data.mPgpKnown)
|
|
|
|
if (rsPeers->isGPGAccepted(data.mPgpId))
|
2014-09-24 16:48:16 -04:00
|
|
|
ui.lineEdit_Type->setText(tr("Owned by a friend Retroshare node")) ;
|
2012-11-06 14:18:56 -05:00
|
|
|
else
|
2014-09-24 16:48:16 -04:00
|
|
|
ui.lineEdit_Type->setText(tr("Owned by 2-hops Retroshare node")) ;
|
2013-07-11 04:14:38 -04:00
|
|
|
else
|
2014-09-24 16:48:16 -04:00
|
|
|
ui.lineEdit_Type->setText(tr("Owned by unknown Retroshare node")) ;
|
2012-06-07 13:11:57 -04:00
|
|
|
}
|
2012-11-06 14:18:56 -05:00
|
|
|
else
|
2014-09-24 16:48:16 -04:00
|
|
|
ui.lineEdit_Type->setText(tr("Anonymous identity")) ;
|
|
|
|
|
|
|
|
// if (isOwnId)
|
|
|
|
// {
|
|
|
|
// ui.radioButton_IdYourself->setChecked(true);
|
|
|
|
// }
|
|
|
|
// else if (data.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID)
|
|
|
|
// {
|
|
|
|
// if (data.mPgpKnown)
|
|
|
|
// {
|
|
|
|
// if (rsPeers->isGPGAccepted(data.mPgpId))
|
|
|
|
// {
|
|
|
|
// ui.radioButton_IdFriend->setChecked(true);
|
|
|
|
// }
|
|
|
|
// else
|
|
|
|
// {
|
|
|
|
// ui.radioButton_IdFOF->setChecked(true);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// else
|
|
|
|
// {
|
|
|
|
// ui.radioButton_IdOther->setChecked(true);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// else
|
|
|
|
// {
|
|
|
|
// ui.radioButton_IdPseudo->setChecked(true);
|
|
|
|
// }
|
2012-11-06 14:18:56 -05:00
|
|
|
|
|
|
|
if (isOwnId)
|
2012-06-07 13:11:57 -04:00
|
|
|
{
|
2013-09-02 15:20:47 -04:00
|
|
|
mStateHelper->setWidgetEnabled(ui.toolButton_Reputation, false);
|
2014-05-06 13:15:20 -04:00
|
|
|
mStateHelper->setWidgetEnabled(ui.toolButton_Delete, true);
|
2014-02-01 09:16:15 -05:00
|
|
|
mStateHelper->setWidgetEnabled(ui.toolButton_EditId, true);
|
2014-05-03 13:56:12 -04:00
|
|
|
ui.editIdentity->setEnabled(true);
|
2014-05-06 13:15:20 -04:00
|
|
|
ui.removeIdentity->setEnabled(true);
|
2014-06-12 06:28:23 -04:00
|
|
|
ui.chatIdentity->setEnabled(false);
|
2012-06-07 13:11:57 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-07-10 17:57:23 -04:00
|
|
|
// No Reputation yet!
|
2013-09-02 15:20:47 -04:00
|
|
|
mStateHelper->setWidgetEnabled(ui.toolButton_Reputation, /*true*/ false);
|
|
|
|
mStateHelper->setWidgetEnabled(ui.toolButton_Delete, false);
|
|
|
|
mStateHelper->setWidgetEnabled(ui.toolButton_EditId, false);
|
2014-05-03 13:56:12 -04:00
|
|
|
ui.editIdentity->setEnabled(false);
|
2014-05-06 13:15:20 -04:00
|
|
|
ui.removeIdentity->setEnabled(false);
|
2014-06-12 06:28:23 -04:00
|
|
|
ui.chatIdentity->setEnabled(true);
|
2012-06-07 13:11:57 -04:00
|
|
|
}
|
2013-06-04 17:00:43 -04:00
|
|
|
|
|
|
|
/* now fill in the reputation information */
|
|
|
|
ui.line_RatingOverall->setText("Overall Rating TODO");
|
|
|
|
ui.line_RatingOwn->setText("Own Rating TODO");
|
|
|
|
|
|
|
|
if (data.mPgpKnown)
|
|
|
|
{
|
|
|
|
ui.line_RatingImplicit->setText("+50 Known PGP");
|
|
|
|
}
|
|
|
|
else if (data.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID)
|
|
|
|
{
|
|
|
|
ui.line_RatingImplicit->setText("+10 UnKnown PGP");
|
|
|
|
}
|
2013-07-11 04:14:38 -04:00
|
|
|
else
|
2013-06-04 17:00:43 -04:00
|
|
|
{
|
|
|
|
ui.line_RatingImplicit->setText("+5 Anon Id");
|
|
|
|
}
|
|
|
|
|
2014-02-19 06:11:06 -05:00
|
|
|
{
|
|
|
|
QString rating = QString::number(data.mReputation.mOverallScore);
|
|
|
|
ui.line_RatingOverall->setText(rating);
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
QString rating = QString::number(data.mReputation.mIdScore);
|
|
|
|
ui.line_RatingImplicit->setText(rating);
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
QString rating = QString::number(data.mReputation.mOwnOpinion);
|
|
|
|
ui.line_RatingOwn->setText(rating);
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
QString rating = QString::number(data.mReputation.mPeerOpinion);
|
|
|
|
ui.line_RatingPeers->setText(rating);
|
|
|
|
}
|
|
|
|
|
2013-06-04 17:00:43 -04:00
|
|
|
/* request network ratings */
|
2014-02-19 06:11:06 -05:00
|
|
|
// Removing this for the moment.
|
|
|
|
// requestRepList(data.mMeta.mGroupId);
|
|
|
|
}
|
|
|
|
|
|
|
|
void IdDialog::modifyReputation()
|
|
|
|
{
|
|
|
|
std::cerr << "IdDialog::modifyReputation()";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
|
2014-03-20 07:26:53 -04:00
|
|
|
RsGxsId id(ui.lineEdit_KeyId->text().toStdString());
|
2014-02-19 06:11:06 -05:00
|
|
|
|
|
|
|
int mod = 0;
|
|
|
|
if (ui.repMod_Accept->isChecked())
|
|
|
|
{
|
|
|
|
mod += 100;
|
|
|
|
}
|
|
|
|
else if (ui.repMod_Positive->isChecked())
|
|
|
|
{
|
|
|
|
mod += 10;
|
|
|
|
}
|
|
|
|
else if (ui.repMod_Negative->isChecked())
|
|
|
|
{
|
|
|
|
mod += -10;
|
|
|
|
}
|
|
|
|
else if (ui.repMod_Ban->isChecked())
|
|
|
|
{
|
|
|
|
mod += -100;
|
|
|
|
}
|
|
|
|
else if (ui.repMod_Custom->isChecked())
|
|
|
|
{
|
|
|
|
mod += ui.repMod_spinBox->value();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// invalid
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::cerr << "IdDialog::modifyReputation() ID: " << id << " Mod: " << mod;
|
|
|
|
std::cerr << std::endl;
|
|
|
|
|
|
|
|
uint32_t token;
|
|
|
|
if (!rsIdentity->submitOpinion(token, id, false, mod))
|
|
|
|
{
|
|
|
|
std::cerr << "IdDialog::modifyReputation() Error submitting Opinion";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
std::cerr << "IdDialog::modifyReputation() queuingRequest(), token: " << token;
|
|
|
|
std::cerr << std::endl;
|
|
|
|
|
|
|
|
// trigger refresh when finished.
|
|
|
|
// basic / anstype are not needed.
|
|
|
|
mIdQueue->queueRequest(token, 0, 0, IDDIALOG_REFRESH);
|
|
|
|
|
|
|
|
return;
|
2012-02-13 13:43:15 -05:00
|
|
|
}
|
2014-02-19 06:11:06 -05:00
|
|
|
|
2013-07-19 05:48:51 -04:00
|
|
|
void IdDialog::updateDisplay(bool /*complete*/)
|
2012-02-13 13:43:15 -05:00
|
|
|
{
|
2013-07-14 14:48:40 -04:00
|
|
|
/* Update identity list */
|
|
|
|
requestIdList();
|
2012-02-13 13:43:15 -05:00
|
|
|
}
|
|
|
|
|
2013-07-10 17:57:23 -04:00
|
|
|
void IdDialog::addIdentity()
|
2012-02-13 13:43:15 -05:00
|
|
|
{
|
2013-07-10 17:57:23 -04:00
|
|
|
IdEditDialog dlg(this);
|
|
|
|
dlg.setupNewId(false);
|
|
|
|
dlg.exec();
|
2014-04-14 11:37:06 -04:00
|
|
|
}
|
2012-02-13 13:43:15 -05:00
|
|
|
|
2014-05-06 13:15:20 -04:00
|
|
|
void IdDialog::removeIdentity()
|
|
|
|
{
|
|
|
|
QTreeWidgetItem *item = ui.treeWidget_IdList->currentItem();
|
|
|
|
if (!item)
|
|
|
|
{
|
|
|
|
std::cerr << "IdDialog::editIdentity() Invalid item";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
return;
|
|
|
|
}
|
2014-05-06 19:43:14 -04:00
|
|
|
|
|
|
|
QString queryWrn;
|
|
|
|
queryWrn.clear();
|
|
|
|
queryWrn.append(tr("Do you really want to delete this Identity ?"));
|
|
|
|
|
|
|
|
if ((QMessageBox::question(this, tr("Really delete? "),queryWrn,QMessageBox::Yes|QMessageBox::No, QMessageBox::Yes))== QMessageBox::Yes)
|
|
|
|
{
|
|
|
|
std::string keyId = item->text(RSID_COL_KEYID).toStdString();
|
|
|
|
|
|
|
|
uint32_t dummyToken = 0;
|
|
|
|
RsGxsIdGroup group;
|
|
|
|
group.mMeta.mGroupId=RsGxsGroupId(keyId);
|
|
|
|
rsIdentity->deleteIdentity(dummyToken, group);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return;
|
2014-05-06 13:15:20 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-07-10 17:57:23 -04:00
|
|
|
void IdDialog::editIdentity()
|
2012-02-13 13:43:15 -05:00
|
|
|
{
|
|
|
|
QTreeWidgetItem *item = ui.treeWidget_IdList->currentItem();
|
|
|
|
if (!item)
|
|
|
|
{
|
2013-07-10 17:57:23 -04:00
|
|
|
std::cerr << "IdDialog::editIdentity() Invalid item";
|
2012-02-13 13:43:15 -05:00
|
|
|
std::cerr << std::endl;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string keyId = item->text(RSID_COL_KEYID).toStdString();
|
|
|
|
|
2013-07-10 17:57:23 -04:00
|
|
|
IdEditDialog dlg(this);
|
|
|
|
dlg.setupExistingId(keyId);
|
|
|
|
dlg.exec();
|
2014-04-14 11:37:06 -04:00
|
|
|
}
|
2012-02-13 13:43:15 -05:00
|
|
|
|
2013-07-10 17:57:23 -04:00
|
|
|
void IdDialog::filterIds()
|
2012-02-13 13:43:15 -05:00
|
|
|
{
|
2013-07-10 17:57:23 -04:00
|
|
|
int filterColumn = ui.filterLineEdit->currentFilter();
|
|
|
|
QString text = ui.filterLineEdit->text();
|
2012-02-13 13:43:15 -05:00
|
|
|
|
2013-07-10 17:57:23 -04:00
|
|
|
ui.treeWidget_IdList->filterItems(filterColumn, text);
|
2012-02-13 13:43:15 -05:00
|
|
|
}
|
|
|
|
|
2013-07-10 17:57:23 -04:00
|
|
|
void IdDialog::requestRepList(const RsGxsGroupId &aboutId)
|
2012-02-13 13:43:15 -05:00
|
|
|
{
|
2013-07-10 17:57:23 -04:00
|
|
|
mStateHelper->setLoading(IDDIALOG_REPLIST, true);
|
2012-02-13 13:43:15 -05:00
|
|
|
|
2013-07-10 17:57:23 -04:00
|
|
|
mIdQueue->cancelActiveRequestTokens(IDDIALOG_REPLIST);
|
2012-02-13 13:43:15 -05:00
|
|
|
|
2013-07-11 04:14:38 -04:00
|
|
|
std::list<RsGxsGroupId> groupIds;
|
|
|
|
groupIds.push_back(aboutId);
|
2013-06-04 17:00:43 -04:00
|
|
|
|
2013-07-11 04:14:38 -04:00
|
|
|
RsTokReqOptions opts;
|
|
|
|
opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA;
|
2013-06-04 17:00:43 -04:00
|
|
|
|
2013-07-11 04:14:38 -04:00
|
|
|
uint32_t token;
|
|
|
|
mIdQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, groupIds, IDDIALOG_REPLIST);
|
2013-06-04 17:00:43 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void IdDialog::insertRepList(uint32_t token)
|
|
|
|
{
|
2014-05-06 13:15:20 -04:00
|
|
|
Q_UNUSED(token)
|
2013-07-10 17:57:23 -04:00
|
|
|
mStateHelper->setLoading(IDDIALOG_REPLIST, false);
|
2014-02-19 06:11:06 -05:00
|
|
|
#if 0
|
2013-06-04 17:00:43 -04:00
|
|
|
|
|
|
|
std::vector<RsGxsIdOpinion> opinions;
|
|
|
|
std::vector<RsGxsIdOpinion>::iterator vit;
|
|
|
|
if (!rsIdentity->getMsgData(token, opinions))
|
|
|
|
{
|
|
|
|
std::cerr << "IdDialog::insertRepList() Error getting Opinions";
|
|
|
|
std::cerr << std::endl;
|
2013-07-10 17:57:23 -04:00
|
|
|
|
|
|
|
mStateHelper->setActive(IDDIALOG_REPLIST, false);
|
|
|
|
mStateHelper->clear(IDDIALOG_REPLIST);
|
|
|
|
|
2013-06-04 17:00:43 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
for(vit = opinions.begin(); vit != opinions.end(); vit++)
|
|
|
|
{
|
|
|
|
RsGxsIdOpinion &op = (*vit);
|
|
|
|
GxsIdTreeWidgetItem *item = new GxsIdTreeWidgetItem();
|
|
|
|
|
|
|
|
/* insert 4 columns */
|
|
|
|
|
|
|
|
/* friend name */
|
2014-03-17 16:56:06 -04:00
|
|
|
item->setId(op.mMeta.mAuthorId, RSIDREP_COL_NAME);
|
2013-06-04 17:00:43 -04:00
|
|
|
|
|
|
|
/* score */
|
|
|
|
item->setText(RSIDREP_COL_OPINION, QString::number(op.getOpinion()));
|
|
|
|
|
|
|
|
/* comment */
|
|
|
|
item->setText(RSIDREP_COL_COMMENT, QString::fromUtf8(op.mComment.c_str()));
|
|
|
|
|
|
|
|
/* local reputation */
|
|
|
|
item->setText(RSIDREP_COL_REPUTATION, QString::number(op.getReputation()));
|
|
|
|
|
2013-07-10 17:57:23 -04:00
|
|
|
ui.treeWidget_RepList->addTopLevelItem(item);
|
2013-06-04 17:00:43 -04:00
|
|
|
}
|
2014-02-19 06:11:06 -05:00
|
|
|
#endif
|
|
|
|
mStateHelper->setActive(IDDIALOG_REPLIST, true);
|
2013-06-04 17:00:43 -04:00
|
|
|
}
|
|
|
|
|
2014-02-19 06:11:06 -05:00
|
|
|
void IdDialog::loadRequest(const TokenQueue * /*queue*/, const TokenRequest &req)
|
2012-02-13 13:43:15 -05:00
|
|
|
{
|
2013-07-11 04:14:38 -04:00
|
|
|
std::cerr << "IdDialog::loadRequest() UserType: " << req.mUserType;
|
|
|
|
std::cerr << std::endl;
|
|
|
|
|
2012-06-13 20:36:25 -04:00
|
|
|
switch(req.mUserType)
|
2012-02-13 13:43:15 -05:00
|
|
|
{
|
2012-06-13 20:36:25 -04:00
|
|
|
case IDDIALOG_IDLIST:
|
|
|
|
insertIdList(req.mToken);
|
|
|
|
break;
|
2013-07-11 04:14:38 -04:00
|
|
|
|
2012-06-13 20:36:25 -04:00
|
|
|
case IDDIALOG_IDDETAILS:
|
|
|
|
insertIdDetails(req.mToken);
|
|
|
|
break;
|
2013-07-11 04:14:38 -04:00
|
|
|
|
2013-06-04 17:00:43 -04:00
|
|
|
case IDDIALOG_REPLIST:
|
|
|
|
insertRepList(req.mToken);
|
|
|
|
break;
|
2013-07-11 04:14:38 -04:00
|
|
|
|
2014-02-19 06:11:06 -05:00
|
|
|
case IDDIALOG_REFRESH:
|
|
|
|
updateDisplay(true);
|
|
|
|
break;
|
2012-06-07 13:11:57 -04:00
|
|
|
default:
|
2013-07-11 04:14:38 -04:00
|
|
|
std::cerr << "IdDialog::loadRequest() ERROR";
|
|
|
|
std::cerr << std::endl;
|
2012-06-13 20:36:25 -04:00
|
|
|
break;
|
2012-02-13 13:43:15 -05:00
|
|
|
}
|
|
|
|
}
|
2014-05-03 13:56:12 -04:00
|
|
|
|
|
|
|
void IdDialog::IdListCustomPopupMenu( QPoint )
|
|
|
|
{
|
2014-05-07 06:19:32 -04:00
|
|
|
//Disable by default, will be enable by insertIdDetails()
|
|
|
|
ui.removeIdentity->setEnabled(false);
|
|
|
|
ui.editIdentity->setEnabled(false);
|
2014-05-03 13:56:12 -04:00
|
|
|
|
|
|
|
QMenu contextMnu( this );
|
|
|
|
|
|
|
|
contextMnu.addAction(ui.editIdentity);
|
2014-06-12 06:28:23 -04:00
|
|
|
contextMnu.addAction(ui.removeIdentity);
|
|
|
|
contextMnu.addAction(ui.chatIdentity);
|
2014-05-03 13:56:12 -04:00
|
|
|
|
|
|
|
contextMnu.exec(QCursor::pos());
|
2014-05-06 13:15:20 -04:00
|
|
|
}
|
2014-06-12 06:28:23 -04:00
|
|
|
|
|
|
|
void IdDialog::chatIdentity()
|
|
|
|
{
|
|
|
|
QTreeWidgetItem *item = ui.treeWidget_IdList->currentItem();
|
|
|
|
if (!item)
|
|
|
|
{
|
|
|
|
std::cerr << "IdDialog::editIdentity() Invalid item";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string keyId = item->text(RSID_COL_KEYID).toStdString();
|
|
|
|
|
|
|
|
uint32_t error_code ;
|
|
|
|
|
2014-06-12 13:05:49 -04:00
|
|
|
if(!rsMsgs->initiateDistantChatConnexion(RsGxsId(keyId), error_code))
|
2014-06-12 06:28:23 -04:00
|
|
|
QMessageBox::information(NULL,"Distant cannot work","Distant chat refused with this peer. Reason: "+QString::number(error_code)) ;
|
|
|
|
}
|
|
|
|
|
|
|
|
|