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
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
|
|
|
****************************************************************/
|
|
|
|
#include "ConfCertDialog.h"
|
|
|
|
|
|
|
|
#include "rsiface/rsiface.h"
|
2008-01-25 03:49:40 -05:00
|
|
|
#include "rsiface/rspeers.h"
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2009-01-01 19:55:03 -05:00
|
|
|
#include <QTime>
|
|
|
|
|
|
|
|
|
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 */
|
|
|
|
ConfCertDialog::ConfCertDialog(QWidget *parent, Qt::WFlags flags)
|
2008-04-07 20:31:46 -04:00
|
|
|
: QDialog(parent, flags)
|
2007-11-14 22:18:48 -05:00
|
|
|
{
|
|
|
|
/* Invoke Qt Designer generated QObject setup routine */
|
|
|
|
ui.setupUi(this);
|
|
|
|
|
|
|
|
|
|
|
|
connect(ui.applyButton, SIGNAL(clicked()), this, SLOT(applyDialog()));
|
|
|
|
connect(ui.cancelButton, SIGNAL(clicked()), this, SLOT(closeinfodlg()));
|
|
|
|
|
|
|
|
|
2008-04-07 20:31:46 -04:00
|
|
|
//setFixedSize(QSize(434, 462));
|
2007-11-14 22:18:48 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
Overloads the default show() slot so we can set opacity*/
|
|
|
|
|
|
|
|
void
|
|
|
|
ConfCertDialog::show()
|
|
|
|
{
|
|
|
|
//loadSettings();
|
|
|
|
if(!this->isVisible()) {
|
2008-04-07 20:31:46 -04:00
|
|
|
QDialog::show();
|
2007-11-14 22:18:48 -05:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ConfCertDialog::closeEvent (QCloseEvent * event)
|
|
|
|
{
|
|
|
|
QWidget::closeEvent(event);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ConfCertDialog::closeinfodlg()
|
|
|
|
{
|
|
|
|
close();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ConfCertDialog::loadId(std::string id)
|
|
|
|
{
|
|
|
|
mId = id;
|
|
|
|
loadDialog();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ConfCertDialog::loadDialog()
|
|
|
|
{
|
|
|
|
|
2008-01-25 03:49:40 -05:00
|
|
|
RsPeerDetails detail;
|
|
|
|
if (!rsPeers->getPeerDetails(mId, detail))
|
2007-11-14 22:18:48 -05:00
|
|
|
{
|
|
|
|
/* fail */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-01-25 03:49:40 -05:00
|
|
|
ui.name->setText(QString::fromStdString(detail.name));
|
|
|
|
ui.orgloc->setText(QString::fromStdString(detail.org));
|
|
|
|
ui.country->setText(QString::fromStdString(detail.location));
|
2009-01-01 19:55:03 -05:00
|
|
|
ui.peerid->setText(QString::fromStdString(detail.id));
|
|
|
|
// 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);
|
2007-11-14 22:18:48 -05:00
|
|
|
|
|
|
|
/* set local address */
|
2008-01-25 03:49:40 -05:00
|
|
|
ui.localAddress->setText(QString::fromStdString(detail.localAddr));
|
|
|
|
ui.localPort -> setValue(detail.localPort);
|
2007-11-14 22:18:48 -05:00
|
|
|
/* set the server address */
|
2008-01-25 03:49:40 -05:00
|
|
|
ui.extAddress->setText(QString::fromStdString(detail.extAddr));
|
|
|
|
ui.extPort -> setValue(detail.extPort);
|
|
|
|
|
|
|
|
/* set the url for DNS access (OLD) */
|
|
|
|
ui.extName->setText(QString::fromStdString(""));
|
|
|
|
|
|
|
|
/**** TODO ****/
|
|
|
|
//ui.chkFirewall ->setChecked(ni->firewalled);
|
|
|
|
//ui.chkForwarded ->setChecked(ni->forwardPort);
|
2008-04-05 08:14:49 -04:00
|
|
|
//ui.chkFirewall ->setChecked(0);
|
|
|
|
//ui.chkForwarded ->setChecked(0);
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2008-04-05 08:14:49 -04:00
|
|
|
//ui.indivRate->setValue(0);
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2008-01-25 03:49:40 -05:00
|
|
|
ui.trustLvl->setText(QString::fromStdString(RsPeerTrustString(detail.trustLvl)));
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2009-01-23 09:45:15 -05:00
|
|
|
if(rsPeers->isOnline(detail.id) || rsPeers->isTrustingMe(detail.id))
|
|
|
|
ui._isTrustingMeTF->setText("Yes");
|
|
|
|
else
|
|
|
|
ui._isTrustingMeTF->setText("No");
|
|
|
|
|
2008-01-25 03:49:40 -05:00
|
|
|
if (detail.ownsign)
|
2007-11-14 22:18:48 -05:00
|
|
|
{
|
|
|
|
ui.signBox -> setCheckState(Qt::Checked);
|
|
|
|
ui.signBox -> setEnabled(false);
|
2008-01-25 03:49:40 -05:00
|
|
|
if (detail.trusted)
|
2007-11-14 22:18:48 -05:00
|
|
|
{
|
|
|
|
ui.trustBox -> setCheckState(Qt::Checked);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ui.trustBox -> setCheckState(Qt::Unchecked);
|
|
|
|
}
|
|
|
|
ui.trustBox -> setCheckable(true);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ui.signBox -> setCheckState(Qt::Unchecked);
|
|
|
|
ui.signBox -> setEnabled(true);
|
|
|
|
|
|
|
|
ui.trustBox -> setCheckState(Qt::Unchecked);
|
|
|
|
ui.trustBox -> setEnabled(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ConfCertDialog::applyDialog()
|
|
|
|
{
|
2008-01-25 03:49:40 -05:00
|
|
|
RsPeerDetails detail;
|
|
|
|
if (!rsPeers->getPeerDetails(mId, detail))
|
2007-11-14 22:18:48 -05:00
|
|
|
{
|
|
|
|
/* fail */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* check if the data is the same */
|
|
|
|
bool localChanged = false;
|
|
|
|
bool extChanged = false;
|
|
|
|
bool fwChanged = false;
|
|
|
|
bool signChanged = false;
|
|
|
|
bool trustChanged = false;
|
|
|
|
|
|
|
|
/* set local address */
|
2008-01-25 03:49:40 -05:00
|
|
|
if ((detail.localAddr != ui.localAddress->text().toStdString())
|
|
|
|
|| (detail.localPort != ui.localPort -> value()))
|
2007-11-14 22:18:48 -05:00
|
|
|
{
|
|
|
|
/* changed ... set it */
|
|
|
|
localChanged = true;
|
|
|
|
}
|
|
|
|
|
2008-01-25 03:49:40 -05:00
|
|
|
if ((detail.extAddr != ui.extAddress->text().toStdString())
|
|
|
|
|| (detail.extPort != ui.extPort -> value()))
|
2007-11-14 22:18:48 -05:00
|
|
|
{
|
|
|
|
/* changed ... set it */
|
|
|
|
extChanged = true;
|
|
|
|
}
|
|
|
|
|
2008-01-25 03:49:40 -05:00
|
|
|
#if 0
|
|
|
|
if ((detail.firewalled != ui.chkFirewall ->isChecked()) ||
|
|
|
|
(detail.forwardPort != ui.chkForwarded ->isChecked()))
|
2007-11-14 22:18:48 -05:00
|
|
|
{
|
|
|
|
/* changed ... set it */
|
|
|
|
fwChanged = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ni -> maxRate != ui.indivRate->value())
|
|
|
|
{
|
|
|
|
/* nada */
|
|
|
|
}
|
2008-01-25 03:49:40 -05:00
|
|
|
#endif
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2008-01-25 03:49:40 -05:00
|
|
|
if (detail.ownsign)
|
2007-11-14 22:18:48 -05:00
|
|
|
{
|
2008-01-25 03:49:40 -05:00
|
|
|
if (detail.trusted != ui.trustBox->isChecked())
|
2007-11-14 22:18:48 -05:00
|
|
|
{
|
|
|
|
trustChanged = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (ui.signBox->isChecked())
|
|
|
|
{
|
|
|
|
signChanged = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* now we can action the changes */
|
|
|
|
if (localChanged)
|
2008-01-25 03:49:40 -05:00
|
|
|
rsPeers->setLocalAddress(mId,
|
2007-11-14 22:18:48 -05:00
|
|
|
ui.localAddress->text().toStdString(), ui.localPort->value());
|
|
|
|
|
|
|
|
if (extChanged)
|
2008-01-25 03:49:40 -05:00
|
|
|
rsPeers->setExtAddress(mId,
|
2007-11-14 22:18:48 -05:00
|
|
|
ui.extAddress->text().toStdString(), ui.extPort->value());
|
|
|
|
|
2008-01-25 03:49:40 -05:00
|
|
|
#if 0
|
2007-11-14 22:18:48 -05:00
|
|
|
if (fwChanged)
|
|
|
|
rsicontrol -> FriendSetFirewall(mId, ui.chkFirewall->isChecked(),
|
|
|
|
ui.chkForwarded->isChecked());
|
2008-01-25 03:49:40 -05:00
|
|
|
#endif
|
2007-11-14 22:18:48 -05:00
|
|
|
|
|
|
|
if (trustChanged)
|
2008-01-25 03:49:40 -05:00
|
|
|
rsPeers->TrustCertificate(mId, ui.trustBox->isChecked());
|
2007-11-14 22:18:48 -05:00
|
|
|
|
|
|
|
if (signChanged)
|
2008-01-25 03:49:40 -05:00
|
|
|
rsPeers->SignCertificate(mId);
|
2007-11-14 22:18:48 -05:00
|
|
|
|
|
|
|
/* reload now */
|
|
|
|
loadDialog();
|
|
|
|
|
|
|
|
/* close the Dialog after the Changes applied */
|
|
|
|
closeinfodlg();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ConfCertDialog::setInfo(std::string name,
|
|
|
|
std::string trust,
|
|
|
|
std::string org,
|
|
|
|
std::string loc,
|
|
|
|
std::string country,
|
|
|
|
std::string signers)
|
|
|
|
{
|
|
|
|
ui.name->setText(QString::fromStdString(name));
|
|
|
|
ui.trustLvl->setText(QString::fromStdString(trust));
|
|
|
|
ui.orgloc->setText(QString::fromStdString(org + loc));
|
|
|
|
//ui.loc->setText(QString::fromStdString(loc));
|
|
|
|
//ui.country->setText(QString::fromStdString(country));
|
|
|
|
//ui.signers->setText(QString::fromStdString(signers));
|
|
|
|
}
|
|
|
|
|
|
|
|
|