2007-11-14 22:18:48 -05:00
|
|
|
/****************************************************************
|
|
|
|
* RetroShare is distributed under the following license:
|
|
|
|
*
|
|
|
|
* Copyright (C) 2006, crypton
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program 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 General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
2009-07-17 17:41:20 -04:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
2007-11-14 22:18:48 -05:00
|
|
|
* Boston, MA 02110-1301, USA.
|
|
|
|
****************************************************************/
|
2010-12-21 16:13:08 -05:00
|
|
|
#include <gpgme.h>
|
|
|
|
|
2007-11-14 22:18:48 -05:00
|
|
|
#include "ConfCertDialog.h"
|
|
|
|
|
2010-07-23 14:52:58 -04:00
|
|
|
#include <QMessageBox>
|
|
|
|
#include <QDateTime>
|
|
|
|
#include <QMenu>
|
|
|
|
#include <QClipboard>
|
2010-10-25 16:19:57 -04:00
|
|
|
#include <QMap>
|
2010-07-23 14:52:58 -04:00
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
|
2010-08-06 05:40:23 -04:00
|
|
|
#include <retroshare/rspeers.h>
|
|
|
|
#include <retroshare/rsdisc.h>
|
2011-09-02 06:22:44 -04:00
|
|
|
#include <retroshare/rsmsgs.h>
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2010-07-23 14:52:58 -04:00
|
|
|
#include "gui/help/browser/helpbrowser.h"
|
2010-09-28 16:33:34 -04:00
|
|
|
#include "gui/common/PeerDefs.h"
|
2011-01-06 13:26:39 -05:00
|
|
|
#include "gui/common/StatusDefs.h"
|
2011-05-18 17:23:26 -04:00
|
|
|
#include "gui/RetroShareLink.h"
|
2011-09-02 06:22:44 -04:00
|
|
|
#include "gui/notifyqt.h"
|
|
|
|
#include "gui/common/AvatarDefs.h"
|
2009-01-01 19:55:03 -05:00
|
|
|
|
2011-02-18 18:26:08 -05:00
|
|
|
#ifndef MINIMAL_RSGUI
|
|
|
|
#include "gui/MainWindow.h"
|
|
|
|
#endif // !MINIMAL_RSGUI
|
|
|
|
|
2010-10-25 16:19:57 -04:00
|
|
|
static QMap<std::string, ConfCertDialog*> instances;
|
|
|
|
|
|
|
|
ConfCertDialog *ConfCertDialog::instance(const std::string& peer_id)
|
2009-05-07 18:43:11 -04:00
|
|
|
{
|
2010-10-25 16:19:57 -04:00
|
|
|
ConfCertDialog *d = instances[peer_id];
|
|
|
|
if (d) {
|
|
|
|
return d;
|
|
|
|
}
|
|
|
|
|
|
|
|
d = new ConfCertDialog(peer_id);
|
|
|
|
instances[peer_id] = d;
|
2009-05-07 18:43:11 -04:00
|
|
|
|
2010-10-25 16:19:57 -04:00
|
|
|
return d;
|
2009-05-07 18:43:11 -04:00
|
|
|
}
|
2009-01-01 19:55:03 -05:00
|
|
|
|
2007-11-14 22:18:48 -05:00
|
|
|
/* Define the format used for displaying the date and time */
|
|
|
|
#define DATETIME_FMT "MMM dd hh:mm:ss"
|
|
|
|
|
|
|
|
/** Default constructor */
|
2010-10-25 16:19:57 -04:00
|
|
|
ConfCertDialog::ConfCertDialog(const std::string& id, QWidget *parent, Qt::WFlags flags)
|
|
|
|
: QDialog(parent, flags), mId(id)
|
2007-11-14 22:18:48 -05:00
|
|
|
{
|
2010-10-25 16:19:57 -04:00
|
|
|
/* Invoke Qt Designer generated QObject setup routine */
|
|
|
|
ui.setupUi(this);
|
|
|
|
|
|
|
|
setAttribute(Qt::WA_DeleteOnClose, true);
|
|
|
|
|
|
|
|
connect(ui.applyButton, SIGNAL(clicked()), this, SLOT(applyDialog()));
|
|
|
|
connect(ui.cancelButton, SIGNAL(clicked()), this, SLOT(close()));
|
|
|
|
connect(ui.make_friend_button, SIGNAL(clicked()), this, SLOT(makeFriend()));
|
|
|
|
connect(ui.denyFriendButton, SIGNAL(clicked()), this, SLOT(denyFriend()));
|
|
|
|
connect(ui.signKeyButton, SIGNAL(clicked()), this, SLOT(signGPGKey()));
|
|
|
|
connect(ui.trusthelpButton, SIGNAL(clicked()), this, SLOT(showHelpDialog()));
|
2012-01-23 15:55:08 -05:00
|
|
|
connect(ui._shouldAddSignatures_CB, SIGNAL(toggled(bool)), this, SLOT(loadInvitePage()));
|
2010-10-25 16:19:57 -04:00
|
|
|
|
2011-02-18 18:26:08 -05:00
|
|
|
#ifndef MINIMAL_RSGUI
|
2010-10-25 16:19:57 -04:00
|
|
|
MainWindow *w = MainWindow::getInstance();
|
|
|
|
if (w) {
|
|
|
|
connect(this, SIGNAL(configChanged()), w->getPage(MainWindow::Network), SLOT(insertConnect()));
|
|
|
|
}
|
2011-02-18 18:26:08 -05:00
|
|
|
#endif // !MINIMAL_RSGUI
|
2007-11-14 22:18:48 -05:00
|
|
|
}
|
|
|
|
|
2010-10-25 16:19:57 -04:00
|
|
|
ConfCertDialog::~ConfCertDialog()
|
2009-05-07 18:43:11 -04:00
|
|
|
{
|
2010-10-25 16:19:57 -04:00
|
|
|
QMap<std::string, ConfCertDialog*>::iterator it = instances.find(mId);
|
|
|
|
if (it != instances.end()) {
|
|
|
|
instances.erase(it);
|
|
|
|
}
|
2010-01-13 16:32:05 -05:00
|
|
|
}
|
|
|
|
|
2010-10-25 16:19:57 -04:00
|
|
|
void ConfCertDialog::showIt(const std::string& peer_id, enumPage page)
|
2010-01-13 16:32:05 -05:00
|
|
|
{
|
2010-10-25 16:19:57 -04:00
|
|
|
ConfCertDialog *confdialog = instance(peer_id);
|
|
|
|
|
|
|
|
switch (page) {
|
|
|
|
case PageDetails:
|
|
|
|
confdialog->ui.stabWidget->setCurrentIndex(0);
|
|
|
|
break;
|
|
|
|
case PageTrust:
|
|
|
|
confdialog->ui.stabWidget->setCurrentIndex(1);
|
|
|
|
break;
|
|
|
|
case PageCertificate:
|
|
|
|
confdialog->ui.stabWidget->setCurrentIndex(2);
|
|
|
|
break;
|
|
|
|
}
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2010-10-25 16:19:57 -04:00
|
|
|
confdialog->load();
|
|
|
|
confdialog->show();
|
|
|
|
confdialog->raise();
|
|
|
|
confdialog->activateWindow();
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2010-10-25 16:19:57 -04:00
|
|
|
/* window will destroy itself! */
|
2010-01-13 16:32:05 -05:00
|
|
|
}
|
|
|
|
|
2010-10-25 16:19:57 -04:00
|
|
|
void ConfCertDialog::loadAll()
|
2010-01-13 16:32:05 -05:00
|
|
|
{
|
2010-10-25 16:19:57 -04:00
|
|
|
QMap<std::string, ConfCertDialog*>::iterator it;
|
|
|
|
for (it = instances.begin(); it != instances.end(); it++) {
|
|
|
|
it.value()->load();
|
|
|
|
}
|
2007-11-14 22:18:48 -05:00
|
|
|
}
|
|
|
|
|
2010-10-25 16:19:57 -04:00
|
|
|
void ConfCertDialog::load()
|
2007-11-14 22:18:48 -05:00
|
|
|
{
|
2010-10-25 16:19:57 -04:00
|
|
|
RsPeerDetails detail;
|
|
|
|
if (!rsPeers->getPeerDetails(mId, detail))
|
|
|
|
{
|
|
|
|
QMessageBox::information(this,
|
|
|
|
tr("RetroShare"),
|
|
|
|
tr("Error : cannot get peer details."));
|
|
|
|
close();
|
|
|
|
return;
|
|
|
|
}
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2011-07-17 19:07:29 -04:00
|
|
|
ui.name->setText(QString::fromUtf8(detail.name.c_str()));
|
2010-10-25 16:19:57 -04:00
|
|
|
ui.peerid->setText(QString::fromStdString(detail.id));
|
2011-05-18 17:23:26 -04:00
|
|
|
|
|
|
|
RetroShareLink link;
|
|
|
|
link.createPerson(detail.id);
|
|
|
|
|
|
|
|
ui.rsid->setText(link.toHtml());
|
|
|
|
ui.rsid->setToolTip(link.title());
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2010-10-25 16:19:57 -04:00
|
|
|
if (!detail.isOnlyGPGdetail) {
|
2011-09-05 17:19:07 -04:00
|
|
|
ui.avatar->setId(mId, false);
|
2010-10-25 16:19:57 -04:00
|
|
|
|
2011-05-08 19:11:27 -04:00
|
|
|
ui.loc->setText(QString::fromUtf8(detail.location.c_str()));
|
2010-10-25 16:19:57 -04:00
|
|
|
// Dont Show a timestamp in RS calculate the day
|
|
|
|
QDateTime date = QDateTime::fromTime_t(detail.lastConnect);
|
|
|
|
QString stime = date.toString(Qt::LocalDate);
|
|
|
|
ui.lastcontact-> setText(stime);
|
|
|
|
|
|
|
|
/* set retroshare version */
|
|
|
|
std::map<std::string, std::string>::iterator vit;
|
|
|
|
std::map<std::string, std::string> versions;
|
|
|
|
bool retv = rsDisc->getDiscVersions(versions);
|
|
|
|
if (retv && versions.end() != (vit = versions.find(detail.id)))
|
|
|
|
{
|
|
|
|
ui.version->setText(QString::fromStdString(vit->second));
|
|
|
|
}
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2010-10-25 16:19:57 -04:00
|
|
|
/* set local address */
|
|
|
|
ui.localAddress->setText(QString::fromStdString(detail.localAddr));
|
|
|
|
ui.localPort -> setValue(detail.localPort);
|
|
|
|
/* set the server address */
|
|
|
|
ui.extAddress->setText(QString::fromStdString(detail.extAddr));
|
|
|
|
ui.extPort -> setValue(detail.extPort);
|
|
|
|
|
|
|
|
ui.dynDNS->setText(QString::fromStdString(detail.dyndns));
|
2011-01-06 13:26:39 -05:00
|
|
|
|
|
|
|
ui.statusline->setText(StatusDefs::connectStateString(detail));
|
2010-10-25 16:19:57 -04:00
|
|
|
|
|
|
|
ui.ipAddressList->clear();
|
|
|
|
for(std::list<std::string>::const_iterator it(detail.ipAddressList.begin());it!=detail.ipAddressList.end();++it)
|
|
|
|
ui.ipAddressList->addItem(QString::fromStdString(*it));
|
|
|
|
|
|
|
|
ui.loc->show();
|
|
|
|
ui.label_loc->show();
|
2010-11-23 17:06:58 -05:00
|
|
|
ui.statusline->show();
|
|
|
|
ui.label_status->show();
|
2010-10-25 16:19:57 -04:00
|
|
|
ui.lastcontact->show();
|
|
|
|
ui.label_last_contact->show();
|
|
|
|
ui.version->show();
|
|
|
|
ui.label_version->show();
|
|
|
|
|
|
|
|
ui.groupBox->show();
|
|
|
|
ui.rsid->hide();
|
|
|
|
ui.label_rsid->hide();
|
|
|
|
} else {
|
2011-09-05 17:19:07 -04:00
|
|
|
ui.avatar->setId(mId, true);
|
|
|
|
|
2010-10-25 16:19:57 -04:00
|
|
|
ui.rsid->show();
|
|
|
|
ui.label_rsid->show();
|
|
|
|
ui.loc->hide();
|
|
|
|
ui.label_loc->hide();
|
2010-11-23 17:06:58 -05:00
|
|
|
ui.statusline->hide();
|
|
|
|
ui.label_status->hide();
|
2010-10-25 16:19:57 -04:00
|
|
|
ui.lastcontact->hide();
|
|
|
|
ui.label_last_contact->hide();
|
|
|
|
ui.version->hide();
|
|
|
|
ui.label_version->hide();
|
|
|
|
|
|
|
|
ui.groupBox->hide();
|
|
|
|
}
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2010-10-25 16:19:57 -04:00
|
|
|
if (detail.gpg_id == rsPeers->getGPGOwnId()) {
|
|
|
|
ui.make_friend_button->hide();
|
|
|
|
ui.signGPGKeyCheckBox->hide();
|
|
|
|
ui.signKeyButton->hide();
|
|
|
|
ui.denyFriendButton->hide();
|
2009-07-17 17:41:20 -04:00
|
|
|
|
2010-10-25 16:19:57 -04:00
|
|
|
ui.web_of_trust_label->hide();
|
|
|
|
ui.radioButton_trust_fully->hide();
|
|
|
|
ui.radioButton_trust_marginnaly->hide();
|
|
|
|
ui.radioButton_trust_never->hide();
|
2010-06-30 17:57:46 -04:00
|
|
|
|
2010-10-25 16:19:57 -04:00
|
|
|
ui.is_signing_me->hide();
|
|
|
|
ui.signersBox->setTitle(tr("Your key is signed by : "));
|
2010-01-13 16:11:02 -05:00
|
|
|
|
2010-10-25 16:19:57 -04:00
|
|
|
} else {
|
|
|
|
ui.web_of_trust_label->show();
|
|
|
|
ui.radioButton_trust_fully->show();
|
|
|
|
ui.radioButton_trust_marginnaly->show();
|
|
|
|
ui.radioButton_trust_never->show();
|
|
|
|
|
|
|
|
ui.is_signing_me->show();
|
|
|
|
ui.signersBox->setTitle(tr("Peer key is signed by : "));
|
2009-11-11 17:12:50 -05:00
|
|
|
|
2010-10-25 16:19:57 -04:00
|
|
|
if (detail.accept_connection) {
|
2010-01-13 16:32:56 -05:00
|
|
|
ui.make_friend_button->hide();
|
2010-10-25 16:19:57 -04:00
|
|
|
ui.denyFriendButton->show();
|
2010-01-13 16:32:56 -05:00
|
|
|
ui.signGPGKeyCheckBox->hide();
|
2010-10-25 16:19:57 -04:00
|
|
|
//connection already accepted, propose to sign gpg key
|
|
|
|
if (!detail.ownsign) {
|
|
|
|
ui.signKeyButton->show();
|
|
|
|
} else {
|
|
|
|
ui.signKeyButton->hide();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
ui.make_friend_button->show();
|
2010-01-13 16:32:56 -05:00
|
|
|
ui.denyFriendButton->hide();
|
2010-10-25 16:19:57 -04:00
|
|
|
ui.signKeyButton->hide();
|
|
|
|
if (!detail.ownsign) {
|
|
|
|
ui.signGPGKeyCheckBox->show();
|
2011-04-07 16:07:30 -04:00
|
|
|
ui.signGPGKeyCheckBox->setChecked(false);
|
2010-10-25 16:19:57 -04:00
|
|
|
} else {
|
|
|
|
ui.signGPGKeyCheckBox->hide();
|
|
|
|
}
|
|
|
|
}
|
2010-01-13 16:32:56 -05:00
|
|
|
|
2010-10-25 16:19:57 -04:00
|
|
|
//web of trust
|
2010-12-21 16:13:08 -05:00
|
|
|
if (detail.trustLvl == GPGME_VALIDITY_ULTIMATE) {
|
2010-10-25 16:19:57 -04:00
|
|
|
//trust is ultimate, it means it's one of our own keys
|
|
|
|
ui.web_of_trust_label->setText(tr("Your trust in this peer is ultimate, it's probably a key you own."));
|
2010-01-13 16:32:56 -05:00
|
|
|
ui.radioButton_trust_fully->hide();
|
|
|
|
ui.radioButton_trust_marginnaly->hide();
|
|
|
|
ui.radioButton_trust_never->hide();
|
2010-01-13 16:11:02 -05:00
|
|
|
} else {
|
2010-01-13 16:14:49 -05:00
|
|
|
ui.radioButton_trust_fully->show();
|
|
|
|
ui.radioButton_trust_marginnaly->show();
|
|
|
|
ui.radioButton_trust_never->show();
|
2010-12-21 16:13:08 -05:00
|
|
|
if (detail.trustLvl == GPGME_VALIDITY_FULL) {
|
2010-10-25 16:19:57 -04:00
|
|
|
ui.web_of_trust_label->setText(tr("Your trust in this peer is full."));
|
|
|
|
ui.radioButton_trust_fully->setChecked(true);
|
|
|
|
ui.radioButton_trust_fully->setIcon(QIcon(":/images/security-high-48.png"));
|
|
|
|
ui.radioButton_trust_marginnaly->setIcon(QIcon(":/images/security-medium-off-48.png"));
|
|
|
|
ui.radioButton_trust_never->setIcon(QIcon(":/images/security-low-off-48.png"));
|
2010-12-21 16:13:08 -05:00
|
|
|
} else if (detail.trustLvl == GPGME_VALIDITY_MARGINAL) {
|
2010-10-25 16:19:57 -04:00
|
|
|
ui.web_of_trust_label->setText(tr("Your trust in this peer is marginal."));
|
|
|
|
ui.radioButton_trust_marginnaly->setChecked(true);
|
|
|
|
ui.radioButton_trust_marginnaly->setIcon(QIcon(":/images/security-medium-48.png"));
|
|
|
|
ui.radioButton_trust_never->setIcon(QIcon(":/images/security-low-off-48.png"));
|
|
|
|
ui.radioButton_trust_fully->setIcon(QIcon(":/images/security-high-off-48.png"));
|
2010-12-21 16:13:08 -05:00
|
|
|
} else if (detail.trustLvl == GPGME_VALIDITY_NEVER) {
|
2010-10-25 16:19:57 -04:00
|
|
|
ui.web_of_trust_label->setText(tr("Your trust in this peer is none."));
|
|
|
|
ui.radioButton_trust_never->setChecked(true);
|
|
|
|
ui.radioButton_trust_never->setIcon(QIcon(":/images/security-low-48.png"));
|
|
|
|
ui.radioButton_trust_fully->setIcon(QIcon(":/images/security-high-off-48.png"));
|
|
|
|
ui.radioButton_trust_marginnaly->setIcon(QIcon(":/images/security-medium-off-48.png"));
|
|
|
|
} else {
|
|
|
|
ui.web_of_trust_label->setText(tr("Your trust in this peer is not set."));
|
2010-01-13 16:32:56 -05:00
|
|
|
|
2010-10-25 16:19:57 -04:00
|
|
|
//we have to set up the set exclusive to false in order to uncheck it all
|
|
|
|
ui.radioButton_trust_fully->setAutoExclusive(false);
|
|
|
|
ui.radioButton_trust_marginnaly->setAutoExclusive(false);
|
|
|
|
ui.radioButton_trust_never->setAutoExclusive(false);
|
2010-01-13 16:32:56 -05:00
|
|
|
|
2010-10-25 16:19:57 -04:00
|
|
|
ui.radioButton_trust_fully->setChecked(false);
|
|
|
|
ui.radioButton_trust_marginnaly->setChecked(false);
|
|
|
|
ui.radioButton_trust_never->setChecked(false);
|
2010-01-13 16:32:56 -05:00
|
|
|
|
2010-10-25 16:19:57 -04:00
|
|
|
ui.radioButton_trust_fully->setAutoExclusive(true);
|
|
|
|
ui.radioButton_trust_marginnaly->setAutoExclusive(true);
|
|
|
|
ui.radioButton_trust_never->setAutoExclusive(true);
|
2010-01-13 16:11:02 -05:00
|
|
|
|
2010-10-25 16:19:57 -04:00
|
|
|
ui.radioButton_trust_never->setIcon(QIcon(":/images/security-low-off-48.png"));
|
|
|
|
ui.radioButton_trust_fully->setIcon(QIcon(":/images/security-high-off-48.png"));
|
|
|
|
ui.radioButton_trust_marginnaly->setIcon(QIcon(":/images/security-medium-off-48.png"));
|
2010-01-13 16:11:02 -05:00
|
|
|
}
|
|
|
|
}
|
2010-09-03 15:23:24 -04:00
|
|
|
|
2010-10-25 16:19:57 -04:00
|
|
|
if (detail.hasSignedMe) {
|
|
|
|
ui.is_signing_me->setText(tr("Peer has authenticated me as a friend and did sign my GPG key"));
|
|
|
|
} else {
|
|
|
|
ui.is_signing_me->setText(tr("Peer has not authenticated me as a friend and did not sign my GPG key"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-05-18 17:23:26 -04:00
|
|
|
QString text;
|
2010-10-25 16:19:57 -04:00
|
|
|
for(std::list<std::string>::const_iterator it(detail.gpgSigners.begin());it!=detail.gpgSigners.end();++it) {
|
2011-05-18 17:23:26 -04:00
|
|
|
link.createPerson(*it);
|
|
|
|
if (link.valid()) {
|
|
|
|
text += link.toHtml() + "<BR>";
|
2010-10-25 16:19:57 -04:00
|
|
|
}
|
|
|
|
}
|
2011-05-18 17:23:26 -04:00
|
|
|
ui.signers->setHtml(text);
|
2010-10-25 16:19:57 -04:00
|
|
|
|
2012-01-23 15:55:08 -05:00
|
|
|
loadInvitePage() ;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ConfCertDialog::loadInvitePage()
|
|
|
|
{
|
|
|
|
RsPeerDetails detail;
|
|
|
|
if (!rsPeers->getPeerDetails(mId, detail))
|
|
|
|
{
|
|
|
|
QMessageBox::information(this,
|
|
|
|
tr("RetroShare"),
|
|
|
|
tr("Error : cannot get peer details."));
|
|
|
|
close();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
std::string invite = rsPeers->GetRetroshareInvite(detail.id,ui._shouldAddSignatures_CB->isChecked()) ; // this needs to be a SSL id
|
2010-09-03 15:23:24 -04:00
|
|
|
|
2010-10-25 16:19:57 -04:00
|
|
|
ui.userCertificateText->setReadOnly(true);
|
|
|
|
ui.userCertificateText->setMinimumHeight(200);
|
|
|
|
ui.userCertificateText->setMinimumWidth(530);
|
|
|
|
QFont font("Courier New",10,50,false);
|
|
|
|
font.setStyleHint(QFont::TypeWriter,QFont::PreferMatch);
|
|
|
|
font.setStyle(QFont::StyleNormal);
|
|
|
|
ui.userCertificateText->setFont(font);
|
2011-07-17 19:07:29 -04:00
|
|
|
ui.userCertificateText->setText(QString::fromUtf8(invite.c_str()));
|
2007-11-14 22:18:48 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ConfCertDialog::applyDialog()
|
|
|
|
{
|
2010-10-25 16:19:57 -04:00
|
|
|
std::cerr << "ConfCertDialog::applyDialog() called" << std::endl ;
|
|
|
|
RsPeerDetails detail;
|
|
|
|
if (!rsPeers->getPeerDetails(mId, detail))
|
|
|
|
{
|
|
|
|
if (!rsPeers->getGPGDetails(mId, detail)) {
|
|
|
|
QMessageBox::information(this,
|
|
|
|
tr("RetroShare"),
|
|
|
|
tr("Error : cannot get peer details."));
|
|
|
|
close();
|
|
|
|
return;
|
2010-01-13 16:14:49 -05:00
|
|
|
}
|
2010-10-25 16:19:57 -04:00
|
|
|
}
|
2009-07-17 17:41:20 -04:00
|
|
|
|
2010-10-25 16:19:57 -04:00
|
|
|
//check the GPG trustlvl
|
2010-12-21 16:13:08 -05:00
|
|
|
if (ui.radioButton_trust_fully->isChecked() && detail.trustLvl != GPGME_VALIDITY_FULL) {
|
2010-10-25 16:19:57 -04:00
|
|
|
//trust has changed to fully
|
2010-12-21 16:13:08 -05:00
|
|
|
rsPeers->trustGPGCertificate(detail.id, GPGME_VALIDITY_FULL);
|
|
|
|
} else if (ui.radioButton_trust_marginnaly->isChecked() && detail.trustLvl != GPGME_VALIDITY_MARGINAL) {
|
|
|
|
rsPeers->trustGPGCertificate(detail.id, GPGME_VALIDITY_MARGINAL);
|
|
|
|
} else if (ui.radioButton_trust_never->isChecked() && detail.trustLvl != GPGME_VALIDITY_NEVER) {
|
|
|
|
rsPeers->trustGPGCertificate(detail.id, GPGME_VALIDITY_NEVER);
|
2010-10-25 16:19:57 -04:00
|
|
|
}
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2010-10-25 16:19:57 -04:00
|
|
|
if (!detail.isOnlyGPGdetail) {
|
|
|
|
/* check if the data is the same */
|
|
|
|
bool localChanged = false;
|
|
|
|
bool extChanged = false;
|
|
|
|
bool dnsChanged = false;
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2010-10-25 16:19:57 -04:00
|
|
|
/* set local address */
|
|
|
|
if ((detail.localAddr != ui.localAddress->text().toStdString()) || (detail.localPort != ui.localPort -> value()))
|
|
|
|
localChanged = true;
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2010-10-25 16:19:57 -04:00
|
|
|
if ((detail.extAddr != ui.extAddress->text().toStdString()) || (detail.extPort != ui.extPort -> value()))
|
|
|
|
extChanged = true;
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2010-10-25 16:19:57 -04:00
|
|
|
if ((detail.dyndns != ui.dynDNS->text().toStdString()))
|
|
|
|
dnsChanged = true;
|
2010-04-22 14:49:51 -04:00
|
|
|
|
2010-10-25 16:19:57 -04:00
|
|
|
/* now we can action the changes */
|
|
|
|
if (localChanged)
|
|
|
|
rsPeers->setLocalAddress(mId, ui.localAddress->text().toStdString(), ui.localPort->value());
|
2009-07-17 17:41:20 -04:00
|
|
|
|
2010-10-25 16:19:57 -04:00
|
|
|
if (extChanged)
|
|
|
|
rsPeers->setExtAddress(mId,ui.extAddress->text().toStdString(), ui.extPort->value());
|
2010-01-13 16:14:49 -05:00
|
|
|
|
2010-10-25 16:19:57 -04:00
|
|
|
if (dnsChanged)
|
|
|
|
rsPeers->setDynDNS(mId, ui.dynDNS->text().toStdString());
|
2010-04-22 14:49:51 -04:00
|
|
|
|
2010-10-25 16:19:57 -04:00
|
|
|
if(localChanged || extChanged || dnsChanged)
|
|
|
|
emit configChanged();
|
|
|
|
}
|
2009-05-07 18:43:11 -04:00
|
|
|
|
2010-10-25 16:19:57 -04:00
|
|
|
loadAll();
|
|
|
|
close();
|
2007-11-14 22:18:48 -05:00
|
|
|
}
|
|
|
|
|
2010-10-25 16:19:57 -04:00
|
|
|
void ConfCertDialog::makeFriend()
|
|
|
|
{
|
2010-01-13 16:25:18 -05:00
|
|
|
std::string gpg_id = rsPeers->getGPGId(mId);
|
|
|
|
if (ui.signGPGKeyCheckBox->isChecked()) {
|
|
|
|
rsPeers->signGPGCertificate(gpg_id);
|
2011-08-07 17:14:09 -04:00
|
|
|
}
|
|
|
|
|
2010-01-13 16:25:18 -05:00
|
|
|
rsPeers->addFriend(mId, gpg_id);
|
2010-10-25 16:19:57 -04:00
|
|
|
loadAll();
|
|
|
|
|
|
|
|
emit configChanged();
|
2007-11-14 22:18:48 -05:00
|
|
|
}
|
2010-01-13 16:32:56 -05:00
|
|
|
|
2010-10-25 16:19:57 -04:00
|
|
|
void ConfCertDialog::denyFriend()
|
|
|
|
{
|
2010-01-13 16:32:56 -05:00
|
|
|
std::string gpg_id = rsPeers->getGPGId(mId);
|
2011-08-07 17:14:09 -04:00
|
|
|
rsPeers->removeFriend(gpg_id);
|
2010-10-25 16:19:57 -04:00
|
|
|
loadAll();
|
|
|
|
|
|
|
|
emit configChanged();
|
2010-01-13 16:32:56 -05:00
|
|
|
}
|
|
|
|
|
2010-10-25 16:19:57 -04:00
|
|
|
void ConfCertDialog::signGPGKey()
|
|
|
|
{
|
2010-01-13 16:32:56 -05:00
|
|
|
std::string gpg_id = rsPeers->getGPGId(mId);
|
2010-02-09 14:10:42 -05:00
|
|
|
if (!rsPeers->signGPGCertificate(gpg_id)) {
|
2010-09-28 16:33:34 -04:00
|
|
|
QMessageBox::warning ( NULL,
|
2010-02-09 14:10:42 -05:00
|
|
|
tr("Signature Failure"),
|
|
|
|
tr("Maybe password is wrong"),
|
|
|
|
QMessageBox::Ok);
|
|
|
|
}
|
2010-10-25 16:19:57 -04:00
|
|
|
loadAll();
|
|
|
|
|
|
|
|
emit configChanged();
|
2010-01-13 16:32:56 -05:00
|
|
|
}
|
|
|
|
|
2010-06-03 14:34:43 -04:00
|
|
|
/** Displays the help browser and displays the most recently viewed help
|
|
|
|
* topic. */
|
|
|
|
void ConfCertDialog::showHelpDialog()
|
|
|
|
{
|
2010-10-25 16:19:57 -04:00
|
|
|
showHelpDialog("trust");
|
2010-06-03 14:34:43 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**< Shows the help browser and displays the given help <b>topic</b>. */
|
|
|
|
void ConfCertDialog::showHelpDialog(const QString &topic)
|
|
|
|
{
|
2010-06-13 19:42:21 -04:00
|
|
|
static HelpBrowser *helpBrowser = 0;
|
|
|
|
if (!helpBrowser)
|
2010-06-03 14:34:43 -04:00
|
|
|
helpBrowser = new HelpBrowser(this);
|
2010-06-13 19:42:21 -04:00
|
|
|
helpBrowser->showWindow(topic);
|
|
|
|
}
|