merged peer detail dialogs from network and friends tab

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@1191 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2009-05-07 22:43:11 +00:00
parent d201d41736
commit 01bbd5ef03
6 changed files with 431 additions and 460 deletions

View File

@ -43,6 +43,8 @@
#include <QPixmap> #include <QPixmap>
#include <QHeaderView> #include <QHeaderView>
#include "connect/ConfCertDialog.h"
/* Images for context menu icons */ /* Images for context menu icons */
#define IMAGE_LOADCERT ":/images/loadcert16.png" #define IMAGE_LOADCERT ":/images/loadcert16.png"
#define IMAGE_PEERDETAILS ":/images/peerdetails_16x16.png" #define IMAGE_PEERDETAILS ":/images/peerdetails_16x16.png"
@ -247,11 +249,12 @@ void NetworkDialog::makeFriend()
/** Shows Peer Information/Auth Dialog */ /** Shows Peer Information/Auth Dialog */
void NetworkDialog::peerdetails() void NetworkDialog::peerdetails()
{ {
#if 0
#ifdef NET_DEBUG #ifdef NET_DEBUG
std::cerr << "ConnectionsDialog::peerdetails()" << std::endl; std::cerr << "ConnectionsDialog::peerdetails()" << std::endl;
#endif #endif
QTreeWidgetItem *wi = getCurrentNeighbour(); QTreeWidgetItem *wi =
if (!wi) if (!wi)
return; return;
@ -260,6 +263,8 @@ void NetworkDialog::peerdetails()
out << id; out << id;
showpeerdetails(out.str()); showpeerdetails(out.str());
#endif
ConfCertDialog::show(getCurrentNeighbour()->text(9).toStdString());
} }
/** Shows Peer Information/Auth Dialog */ /** Shows Peer Information/Auth Dialog */

View File

@ -637,24 +637,7 @@ void PeersDialog::trustfriend()
/* GUI stuff -> don't do anything directly with Control */ /* GUI stuff -> don't do anything directly with Control */
void PeersDialog::configurefriend() void PeersDialog::configurefriend()
{ {
/* display Dialog */ ConfCertDialog::show(getPeerRsCertId(getCurrentPeer()));
#ifdef PEERS_DEBUG
std::cerr << "PeersDialog::configurefriend()" << std::endl;
#endif
QTreeWidgetItem *c = getCurrentPeer();
static ConfCertDialog *confdialog = new ConfCertDialog();
if (!c)
return;
/* set the Id */
std::string id = getPeerRsCertId(c);
confdialog -> loadId(id);
confdialog -> show();
} }
void PeersDialog::updatePeerStatusString(const QString& peer_id,const QString& status_string) void PeersDialog::updatePeerStatusString(const QString& peer_id,const QString& status_string)

View File

@ -25,6 +25,12 @@
#include <QTime> #include <QTime>
ConfCertDialog *ConfCertDialog::instance()
{
static ConfCertDialog *confdialog = new ConfCertDialog ;
return confdialog ;
}
/* Define the format used for displaying the date and time */ /* Define the format used for displaying the date and time */
#define DATETIME_FMT "MMM dd hh:mm:ss" #define DATETIME_FMT "MMM dd hh:mm:ss"
@ -39,11 +45,19 @@ ConfCertDialog::ConfCertDialog(QWidget *parent, Qt::WFlags flags)
connect(ui.applyButton, SIGNAL(clicked()), this, SLOT(applyDialog())); connect(ui.applyButton, SIGNAL(clicked()), this, SLOT(applyDialog()));
connect(ui.cancelButton, SIGNAL(clicked()), this, SLOT(closeinfodlg())); connect(ui.cancelButton, SIGNAL(clicked()), this, SLOT(closeinfodlg()));
connect(ui._makeFriendPB, SIGNAL(clicked()), this, SLOT(makeFriend()));
//setFixedSize(QSize(434, 462)); //setFixedSize(QSize(434, 462));
} }
void ConfCertDialog::show(const std::string& peer_id)
{
/* set the Id */
instance()->loadId(peer_id);
instance()->show();
}
/** /**
@ -103,7 +117,7 @@ void ConfCertDialog::loadDialog()
ui.extPort -> setValue(detail.extPort); ui.extPort -> setValue(detail.extPort);
/* set the url for DNS access (OLD) */ /* set the url for DNS access (OLD) */
ui.extName->setText(QString::fromStdString("")); //ui.extName->setText(QString::fromStdString(""));
/**** TODO ****/ /**** TODO ****/
//ui.chkFirewall ->setChecked(ni->firewalled); //ui.chkFirewall ->setChecked(ni->firewalled);
@ -113,44 +127,29 @@ void ConfCertDialog::loadDialog()
//ui.indivRate->setValue(0); //ui.indivRate->setValue(0);
ui.trustLvl->setText(QString::fromStdString(RsPeerTrustString(detail.trustLvl))); //ui.trustLvl->setText(QString::fromStdString(RsPeerTrustString(detail.trustLvl)));
if(rsPeers->isOnline(detail.id) || rsPeers->isTrustingMe(detail.id)) ui._peerTrustsMeCB->setChecked(rsPeers->isOnline(detail.id) || rsPeers->isTrustingMe(detail.id)) ;
ui._isTrustingMeTF->setText("Yes"); ui._peerTrustsMeCB->setEnabled(false);
else ui.signBox->setChecked(detail.ownsign) ;
ui._isTrustingMeTF->setText("No"); ui.signBox->setEnabled(!detail.ownsign) ;
if (detail.ownsign) ui._peerAcceptedCB->setChecked(detail.state & RS_PEER_STATE_FRIEND) ;
{ ui._peerAcceptedCB->setEnabled(detail.ownsign) ;
ui.signBox -> setCheckState(Qt::Checked);
ui.signBox -> setEnabled(false);
if (detail.trusted)
{
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);
}
ui.signers->clear() ;
for(std::list<std::string>::const_iterator it(detail.signers.begin());it!=detail.signers.end();++it)
ui.signers->append(QString::fromStdString(*it)) ;
} }
void ConfCertDialog::applyDialog() void ConfCertDialog::applyDialog()
{ {
std::cerr << "In apply dialog" << std::endl ;
RsPeerDetails detail; RsPeerDetails detail;
if (!rsPeers->getPeerDetails(mId, detail)) if (!rsPeers->getPeerDetails(mId, detail))
{ {
std::cerr << "Could not get details from " << mId << std::endl ;
/* fail */ /* fail */
return; return;
} }
@ -163,57 +162,26 @@ void ConfCertDialog::applyDialog()
bool trustChanged = false; bool trustChanged = false;
/* set local address */ /* set local address */
if ((detail.localAddr != ui.localAddress->text().toStdString()) if ((detail.localAddr != ui.localAddress->text().toStdString()) || (detail.localPort != ui.localPort -> value()))
|| (detail.localPort != ui.localPort -> value()))
{
/* changed ... set it */
localChanged = true; localChanged = true;
}
if ((detail.extAddr != ui.extAddress->text().toStdString()) if ((detail.extAddr != ui.extAddress->text().toStdString()) || (detail.extPort != ui.extPort -> value()))
|| (detail.extPort != ui.extPort -> value()))
{
/* changed ... set it */
extChanged = true; extChanged = true;
}
#if 0
if ((detail.firewalled != ui.chkFirewall ->isChecked()) ||
(detail.forwardPort != ui.chkForwarded ->isChecked()))
{
/* changed ... set it */
fwChanged = true;
}
if (ni -> maxRate != ui.indivRate->value())
{
/* nada */
}
#endif
if (detail.ownsign) if (detail.ownsign)
{ {
if (detail.trusted != ui.trustBox->isChecked()) if (ui._peerAcceptedCB->isChecked() != ((detail.state & RS_PEER_STATE_FRIEND) > 0))
{
trustChanged = true; trustChanged = true;
} }
} else if (ui.signBox->isChecked())
else
{
if (ui.signBox->isChecked())
{
signChanged = true; signChanged = true;
}
}
/* now we can action the changes */ /* now we can action the changes */
if (localChanged) if (localChanged)
rsPeers->setLocalAddress(mId, rsPeers->setLocalAddress(mId, ui.localAddress->text().toStdString(), ui.localPort->value());
ui.localAddress->text().toStdString(), ui.localPort->value());
if (extChanged) if (extChanged)
rsPeers->setExtAddress(mId, rsPeers->setExtAddress(mId,ui.extAddress->text().toStdString(), ui.extPort->value());
ui.extAddress->text().toStdString(), ui.extPort->value());
#if 0 #if 0
if (fwChanged) if (fwChanged)
@ -221,20 +189,41 @@ void ConfCertDialog::applyDialog()
ui.chkForwarded->isChecked()); ui.chkForwarded->isChecked());
#endif #endif
if (trustChanged)
rsPeers->TrustCertificate(mId, ui.trustBox->isChecked());
if (signChanged) if (signChanged)
{
std::cerr << "Signature changed. Signing certificate" << mId << std::endl ;
rsPeers->SignCertificate(mId); rsPeers->SignCertificate(mId);
}
if (trustChanged)
{
std::cerr << "Acceptance changed. Authing ceAuthrtificate" << mId << std::endl ;
if(ui._peerAcceptedCB->isChecked())
rsPeers->AuthCertificate(mId, "");
else
rsPeers->removeFriend(mId);
}
/* reload now */ /* reload now */
loadDialog(); loadDialog();
/* close the Dialog after the Changes applied */ /* close the Dialog after the Changes applied */
closeinfodlg(); closeinfodlg();
if(trustChanged || signChanged)
emit configChanged() ;
} }
void ConfCertDialog::makeFriend()
{
ui.signBox->setChecked(true) ;
ui._peerAcceptedCB->setChecked(true) ;
// rsPeers->TrustCertificate(mId, ui.trustBox->isChecked());
// rsPeers->SignCertificate(mId);
}
#if 0
void ConfCertDialog::setInfo(std::string name, void ConfCertDialog::setInfo(std::string name,
std::string trust, std::string trust,
std::string org, std::string org,
@ -249,5 +238,6 @@ void ConfCertDialog::setInfo(std::string name,
//ui.country->setText(QString::fromStdString(country)); //ui.country->setText(QString::fromStdString(country));
//ui.signers->setText(QString::fromStdString(signers)); //ui.signers->setText(QString::fromStdString(signers));
} }
#endif

View File

@ -32,6 +32,13 @@ class ConfCertDialog : public QDialog
Q_OBJECT Q_OBJECT
public: public:
static void show(const std::string& id) ;
static ConfCertDialog *instance() ;
signals:
void configChanged() ;
private:
/** Default constructor */ /** Default constructor */
ConfCertDialog(QWidget *parent = 0, Qt::WFlags flags = 0); ConfCertDialog(QWidget *parent = 0, Qt::WFlags flags = 0);
/** Default destructor */ /** Default destructor */
@ -39,14 +46,16 @@ public:
void loadId(std::string id); void loadId(std::string id);
#if 0
void setInfo(std::string name, void setInfo(std::string name,
std::string trust, std::string trust,
std::string org, std::string org,
std::string loc, std::string loc,
std::string country, std::string country,
std::string signers); std::string signers);
#endif
public slots: private slots:
/** Overloaded QWidget.show */ /** Overloaded QWidget.show */
void show(); void show();
@ -57,6 +66,7 @@ private slots:
void closeinfodlg(); void closeinfodlg();
void applyDialog(); void applyDialog();
void makeFriend();
private: private:
@ -68,6 +78,7 @@ void loadDialog();
std::string mId; std::string mId;
/** Qt Designer generated object */ /** Qt Designer generated object */
Ui::ConfCertDialog ui; Ui::ConfCertDialog ui;
}; };
#endif #endif

View File

@ -1,3 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0"> <ui version="4.0">
<class>ConfCertDialog</class> <class>ConfCertDialog</class>
<widget class="QDialog" name="ConfCertDialog"> <widget class="QDialog" name="ConfCertDialog">
@ -5,12 +6,12 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>491</width> <width>598</width>
<height>427</height> <height>428</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy vsizetype="Expanding" hsizetype="Expanding" > <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
@ -505,28 +506,20 @@
<iconset resource="../images.qrc"> <iconset resource="../images.qrc">
<normaloff>:/images/rstray3.png</normaloff>:/images/rstray3.png</iconset> <normaloff>:/images/rstray3.png</normaloff>:/images/rstray3.png</iconset>
</property> </property>
<layout class="QGridLayout" > <layout class="QVBoxLayout" name="verticalLayout_8">
<item row="0" column="0" > <item>
<widget class="QTabWidget" name="stabWidget"> <widget class="QTabWidget" name="stabWidget">
<property name="currentIndex"> <property name="currentIndex">
<number>0</number> <number>1</number>
</property> </property>
<widget class="QWidget" name="tab"> <widget class="QWidget" name="tab">
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>469</width>
<height>335</height>
</rect>
</property>
<attribute name="title" >
<string>Details</string>
</attribute>
<attribute name="icon"> <attribute name="icon">
<iconset resource="../images.qrc"> <iconset resource="../images.qrc">
<normaloff>:/images/peerdetails_16x16.png</normaloff>:/images/peerdetails_16x16.png</iconset> <normaloff>:/images/peerdetails_16x16.png</normaloff>:/images/peerdetails_16x16.png</iconset>
</attribute> </attribute>
<attribute name="title">
<string>Details</string>
</attribute>
<layout class="QGridLayout"> <layout class="QGridLayout">
<item row="0" column="0"> <item row="0" column="0">
<widget class="QGroupBox" name="groupBox_2"> <widget class="QGroupBox" name="groupBox_2">
@ -612,31 +605,64 @@
<property name="title"> <property name="title">
<string>Peer Address</string> <string>Peer Address</string>
</property> </property>
<layout class="QGridLayout" > <layout class="QVBoxLayout" name="verticalLayout_7">
<item row="0" column="0" > <item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<layout class="QVBoxLayout" name="verticalLayout_6">
<item>
<widget class="QLabel" name="label"> <widget class="QLabel" name="label">
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="text"> <property name="text">
<string>Local Address:</string> <string>Local Address:</string>
</property> </property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget> </widget>
</item> </item>
<item rowspan="3" row="0" column="1" >
<layout class="QVBoxLayout" >
<property name="spacing" >
<number>6</number>
</property>
<property name="margin" >
<number>0</number>
</property>
<item> <item>
<layout class="QGridLayout" > <widget class="QLabel" name="label_2">
<property name="margin" > <property name="text">
<number>0</number> <string>External Address:</string>
</property> </property>
<property name="spacing" > </widget>
<number>6</number> </item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<widget class="QLineEdit" name="localAddress"/>
</item>
<item>
<widget class="QLineEdit" name="extAddress"/>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QLabel" name="label_5">
<property name="text">
<string>Port:</string>
</property> </property>
<item row="0" column="2" > </widget>
</item>
<item>
<widget class="QLabel" name="label_4">
<property name="text">
<string>Port:</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QSpinBox" name="localPort"> <widget class="QSpinBox" name="localPort">
<property name="minimum"> <property name="minimum">
<number>0</number> <number>0</number>
@ -649,30 +675,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="1" >
<widget class="QLabel" name="label_5" >
<property name="text" >
<string>Port:</string>
</property>
</widget>
</item>
<item row="0" column="0" >
<widget class="QLineEdit" name="localAddress" />
</item>
</layout>
</item>
<item> <item>
<layout class="QGridLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item row="0" column="0" >
<widget class="QLineEdit" name="extAddress" />
</item>
<item row="0" column="2" >
<widget class="QSpinBox" name="extPort"> <widget class="QSpinBox" name="extPort">
<property name="minimum"> <property name="minimum">
<number>0</number> <number>0</number>
@ -685,37 +688,22 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="1" > </layout>
<widget class="QLabel" name="label_4" >
<property name="text" >
<string>Port:</string>
</property>
</widget>
</item> </item>
</layout> </layout>
</item> </item>
<item> <item>
<widget class="QLineEdit" name="extName" > <spacer name="verticalSpacer">
<property name="enabled" > <property name="orientation">
<bool>false</bool> <enum>Qt::Vertical</enum>
</property> </property>
</widget> <property name="sizeHint" stdset="0">
</item> <size>
</layout> <width>20</width>
</item> <height>47</height>
<item row="1" column="0" > </size>
<widget class="QLabel" name="label_2" >
<property name="text" >
<string>External Address:</string>
</property> </property>
</widget> </spacer>
</item>
<item row="2" column="0" >
<widget class="QLabel" name="label_3" >
<property name="text" >
<string>External Name</string>
</property>
</widget>
</item> </item>
</layout> </layout>
</widget> </widget>
@ -723,14 +711,6 @@
</layout> </layout>
</widget> </widget>
<widget class="QWidget" name="tab"> <widget class="QWidget" name="tab">
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>469</width>
<height>335</height>
</rect>
</property>
<attribute name="title"> <attribute name="title">
<string>Trust Settings</string> <string>Trust Settings</string>
</attribute> </attribute>
@ -740,56 +720,56 @@
<property name="title"> <property name="title">
<string>Trust Settings</string> <string>Trust Settings</string>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout" > <layout class="QVBoxLayout" name="verticalLayout_9">
<item>
<layout class="QGridLayout" name="gridLayout" >
<item row="0" column="0" >
<widget class="QLabel" name="label_9" >
<property name="text" >
<string>Trust Level</string>
</property>
</widget>
</item>
<item row="0" column="1" >
<widget class="QLineEdit" name="trustLvl" >
<property name="readOnly" >
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0" >
<widget class="QLabel" name="label_12" >
<property name="text" >
<string>Trusting me</string>
</property>
</widget>
</item>
<item row="1" column="1" >
<widget class="QLineEdit" name="_isTrustingMeTF" >
<property name="readOnly" >
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item> <item>
<widget class="QCheckBox" name="signBox"> <widget class="QCheckBox" name="signBox">
<property name="toolTip">
<string comment="Once signed, you cannot unsign a certificate, only deny connexions." extracomment="Once signed, you cannot unsign a certificate, only deny connexions."/>
</property>
<property name="text"> <property name="text">
<string>Sign The Certificate</string> <string>Sign this certificate</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QCheckBox" name="trustBox" > <widget class="QCheckBox" name="_peerAcceptedCB">
<property name="text"> <property name="text">
<string>Trust Their Signature</string> <string>Accept connexions from this peer</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="_peerTrustsMeCB">
<property name="toolTip">
<string extracomment="This info is obtained through your other friends, so it is only reliable when checked."/>
</property>
<property name="text">
<string>Peer has signed my certficate</string>
</property> </property>
</widget> </widget>
</item> </item>
</layout> </layout>
</widget> </widget>
</item> </item>
<item>
<widget class="QGroupBox" name="groupBox_4">
<property name="title">
<string>Certificate signers</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QTextBrowser" name="signers"/>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QPushButton" name="_makeFriendPB">
<property name="text">
<string>Make friend (Sign certificate and accept)</string>
</property>
</widget>
</item>
<item> <item>
<spacer> <spacer>
<property name="orientation"> <property name="orientation">
@ -807,7 +787,7 @@
</widget> </widget>
</widget> </widget>
</item> </item>
<item row="1" column="0" > <item>
<layout class="QGridLayout"> <layout class="QGridLayout">
<item row="0" column="0"> <item row="0" column="0">
<spacer> <spacer>
@ -832,7 +812,7 @@
<item row="0" column="2"> <item row="0" column="2">
<widget class="QPushButton" name="applyButton"> <widget class="QPushButton" name="applyButton">
<property name="text"> <property name="text">
<string>OK</string> <string>Apply and close</string>
</property> </property>
<property name="autoDefault"> <property name="autoDefault">
<bool>false</bool> <bool>false</bool>
@ -854,7 +834,6 @@
<tabstop>localPort</tabstop> <tabstop>localPort</tabstop>
<tabstop>extAddress</tabstop> <tabstop>extAddress</tabstop>
<tabstop>extPort</tabstop> <tabstop>extPort</tabstop>
<tabstop>extName</tabstop>
<tabstop>cancelButton</tabstop> <tabstop>cancelButton</tabstop>
<tabstop>applyButton</tabstop> <tabstop>applyButton</tabstop>
</tabstops> </tabstops>

View File

@ -26,6 +26,7 @@
#include <gui/StartDialog.h> #include <gui/StartDialog.h>
#include <gui/GenCertDialog.h> #include <gui/GenCertDialog.h>
#include <gui/Preferences/rsharesettings.h> #include <gui/Preferences/rsharesettings.h>
#include <gui/connect/ConfCertDialog.h>
/*** WINDOWS DON'T LIKE THIS - REDEFINES VER numbers. /*** WINDOWS DON'T LIKE THIS - REDEFINES VER numbers.
#include <gui/qskinobject/qskinobject.h> #include <gui/qskinobject/qskinobject.h>
@ -172,6 +173,8 @@ int main(int argc, char *argv[])
QObject::connect(notify,SIGNAL(chatStatusChanged(const QString&,const QString&)),w->peersDialog,SLOT(updatePeerStatusString(const QString&,const QString&))); QObject::connect(notify,SIGNAL(chatStatusChanged(const QString&,const QString&)),w->peersDialog,SLOT(updatePeerStatusString(const QString&,const QString&)));
QObject::connect(notify,SIGNAL(logInfoChanged(const QString&)),w->networkDialog,SLOT(setLogInfo(QString))) ; QObject::connect(notify,SIGNAL(logInfoChanged(const QString&)),w->networkDialog,SLOT(setLogInfo(QString))) ;
QObject::connect(ConfCertDialog::instance(),SIGNAL(configChanged()),w->networkDialog,SLOT(insertConnect())) ;
/* only show window, if not startMinimized */ /* only show window, if not startMinimized */
if (!startMinimised) if (!startMinimised)
{ {