From 01bbd5ef0393c04b5e53202c72870818af62701b Mon Sep 17 00:00:00 2001 From: csoler Date: Thu, 7 May 2009 22:43:11 +0000 Subject: [PATCH] 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 --- retroshare-gui/src/gui/NetworkDialog.cpp | 7 +- retroshare-gui/src/gui/PeersDialog.cpp | 19 +- .../src/gui/connect/ConfCertDialog.cpp | 130 ++-- .../src/gui/connect/ConfCertDialog.h | 15 +- .../src/gui/connect/ConfCertDialog.ui | 717 +++++++++--------- retroshare-gui/src/main.cpp | 3 + 6 files changed, 431 insertions(+), 460 deletions(-) diff --git a/retroshare-gui/src/gui/NetworkDialog.cpp b/retroshare-gui/src/gui/NetworkDialog.cpp index b68dac9d1..53c749079 100644 --- a/retroshare-gui/src/gui/NetworkDialog.cpp +++ b/retroshare-gui/src/gui/NetworkDialog.cpp @@ -43,6 +43,8 @@ #include #include +#include "connect/ConfCertDialog.h" + /* Images for context menu icons */ #define IMAGE_LOADCERT ":/images/loadcert16.png" #define IMAGE_PEERDETAILS ":/images/peerdetails_16x16.png" @@ -247,11 +249,12 @@ void NetworkDialog::makeFriend() /** Shows Peer Information/Auth Dialog */ void NetworkDialog::peerdetails() { +#if 0 #ifdef NET_DEBUG std::cerr << "ConnectionsDialog::peerdetails()" << std::endl; #endif - QTreeWidgetItem *wi = getCurrentNeighbour(); + QTreeWidgetItem *wi = if (!wi) return; @@ -260,6 +263,8 @@ void NetworkDialog::peerdetails() out << id; showpeerdetails(out.str()); +#endif + ConfCertDialog::show(getCurrentNeighbour()->text(9).toStdString()); } /** Shows Peer Information/Auth Dialog */ diff --git a/retroshare-gui/src/gui/PeersDialog.cpp b/retroshare-gui/src/gui/PeersDialog.cpp index e071ccc40..4bc0cb3a9 100644 --- a/retroshare-gui/src/gui/PeersDialog.cpp +++ b/retroshare-gui/src/gui/PeersDialog.cpp @@ -637,24 +637,7 @@ void PeersDialog::trustfriend() /* GUI stuff -> don't do anything directly with Control */ void PeersDialog::configurefriend() { - /* display Dialog */ -#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(); + ConfCertDialog::show(getPeerRsCertId(getCurrentPeer())); } void PeersDialog::updatePeerStatusString(const QString& peer_id,const QString& status_string) diff --git a/retroshare-gui/src/gui/connect/ConfCertDialog.cpp b/retroshare-gui/src/gui/connect/ConfCertDialog.cpp index 1159648a6..be9842aed 100644 --- a/retroshare-gui/src/gui/connect/ConfCertDialog.cpp +++ b/retroshare-gui/src/gui/connect/ConfCertDialog.cpp @@ -25,6 +25,12 @@ #include +ConfCertDialog *ConfCertDialog::instance() +{ + static ConfCertDialog *confdialog = new ConfCertDialog ; + + return confdialog ; +} /* Define the format used for displaying the date and time */ #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.cancelButton, SIGNAL(clicked()), this, SLOT(closeinfodlg())); + connect(ui._makeFriendPB, SIGNAL(clicked()), this, SLOT(makeFriend())); //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); /* set the url for DNS access (OLD) */ - ui.extName->setText(QString::fromStdString("")); + //ui.extName->setText(QString::fromStdString("")); /**** TODO ****/ //ui.chkFirewall ->setChecked(ni->firewalled); @@ -113,44 +127,29 @@ void ConfCertDialog::loadDialog() //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._isTrustingMeTF->setText("Yes"); - else - ui._isTrustingMeTF->setText("No"); + ui._peerTrustsMeCB->setChecked(rsPeers->isOnline(detail.id) || rsPeers->isTrustingMe(detail.id)) ; + ui._peerTrustsMeCB->setEnabled(false); + ui.signBox->setChecked(detail.ownsign) ; + ui.signBox->setEnabled(!detail.ownsign) ; - if (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._peerAcceptedCB->setChecked(detail.state & RS_PEER_STATE_FRIEND) ; + ui._peerAcceptedCB->setEnabled(detail.ownsign) ; + ui.signers->clear() ; + for(std::list::const_iterator it(detail.signers.begin());it!=detail.signers.end();++it) + ui.signers->append(QString::fromStdString(*it)) ; } void ConfCertDialog::applyDialog() { + std::cerr << "In apply dialog" << std::endl ; RsPeerDetails detail; if (!rsPeers->getPeerDetails(mId, detail)) { + std::cerr << "Could not get details from " << mId << std::endl ; /* fail */ return; } @@ -163,57 +162,26 @@ void ConfCertDialog::applyDialog() bool trustChanged = false; /* set local address */ - if ((detail.localAddr != ui.localAddress->text().toStdString()) - || (detail.localPort != ui.localPort -> value())) - { - /* changed ... set it */ + if ((detail.localAddr != ui.localAddress->text().toStdString()) || (detail.localPort != ui.localPort -> value())) localChanged = true; - } - if ((detail.extAddr != ui.extAddress->text().toStdString()) - || (detail.extPort != ui.extPort -> value())) - { - /* changed ... set it */ + if ((detail.extAddr != ui.extAddress->text().toStdString()) || (detail.extPort != ui.extPort -> value())) 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.trusted != ui.trustBox->isChecked()) - { + if (ui._peerAcceptedCB->isChecked() != ((detail.state & RS_PEER_STATE_FRIEND) > 0)) trustChanged = true; - } } - else - { - if (ui.signBox->isChecked()) - { - signChanged = true; - } - } - + else if (ui.signBox->isChecked()) + signChanged = true; + /* now we can action the changes */ if (localChanged) - rsPeers->setLocalAddress(mId, - ui.localAddress->text().toStdString(), ui.localPort->value()); + rsPeers->setLocalAddress(mId, ui.localAddress->text().toStdString(), ui.localPort->value()); if (extChanged) - rsPeers->setExtAddress(mId, - ui.extAddress->text().toStdString(), ui.extPort->value()); + rsPeers->setExtAddress(mId,ui.extAddress->text().toStdString(), ui.extPort->value()); #if 0 if (fwChanged) @@ -221,20 +189,41 @@ void ConfCertDialog::applyDialog() ui.chkForwarded->isChecked()); #endif - if (trustChanged) - rsPeers->TrustCertificate(mId, ui.trustBox->isChecked()); - if (signChanged) + { + std::cerr << "Signature changed. Signing certificate" << mId << std::endl ; 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 */ loadDialog(); /* close the Dialog after the Changes applied */ 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, std::string trust, std::string org, @@ -249,5 +238,6 @@ void ConfCertDialog::setInfo(std::string name, //ui.country->setText(QString::fromStdString(country)); //ui.signers->setText(QString::fromStdString(signers)); } +#endif diff --git a/retroshare-gui/src/gui/connect/ConfCertDialog.h b/retroshare-gui/src/gui/connect/ConfCertDialog.h index 4e31d5c38..e9370456f 100644 --- a/retroshare-gui/src/gui/connect/ConfCertDialog.h +++ b/retroshare-gui/src/gui/connect/ConfCertDialog.h @@ -31,7 +31,14 @@ class ConfCertDialog : public QDialog { Q_OBJECT -public: + public: + static void show(const std::string& id) ; + + static ConfCertDialog *instance() ; +signals: + void configChanged() ; +private: + /** Default constructor */ ConfCertDialog(QWidget *parent = 0, Qt::WFlags flags = 0); /** Default destructor */ @@ -39,14 +46,16 @@ public: void loadId(std::string id); +#if 0 void setInfo(std::string name, std::string trust, std::string org, std::string loc, std::string country, std::string signers); +#endif -public slots: +private slots: /** Overloaded QWidget.show */ void show(); @@ -57,6 +66,7 @@ private slots: void closeinfodlg(); void applyDialog(); + void makeFriend(); private: @@ -68,6 +78,7 @@ void loadDialog(); std::string mId; /** Qt Designer generated object */ Ui::ConfCertDialog ui; + }; #endif diff --git a/retroshare-gui/src/gui/connect/ConfCertDialog.ui b/retroshare-gui/src/gui/connect/ConfCertDialog.ui index ac150551d..88c99e8a2 100644 --- a/retroshare-gui/src/gui/connect/ConfCertDialog.ui +++ b/retroshare-gui/src/gui/connect/ConfCertDialog.ui @@ -1,170 +1,171 @@ - + + ConfCertDialog - - + + 0 0 - 491 - 427 + 598 + 428 - - + + 0 0 - + - - - + + + 0 0 0 - - - + + + 208 208 208 - - - + + + 255 255 255 - - - + + + 247 247 247 - - - + + + 104 104 104 - - - + + + 139 139 139 - - - + + + 0 0 0 - - - + + + 255 255 255 - - - + + + 0 0 0 - - - + + + 255 255 255 - - - + + + 240 240 240 - - - + + + 0 0 0 - - - + + + 0 0 128 - - - + + + 255 255 255 - - - + + + 0 0 255 - - - + + + 255 0 255 - - - + + + 231 231 231 @@ -173,153 +174,153 @@ - - - + + + 0 0 0 - - - + + + 208 208 208 - - - + + + 255 255 255 - - - + + + 247 247 247 - - - + + + 104 104 104 - - - + + + 139 139 139 - - - + + + 0 0 0 - - - + + + 255 255 255 - - - + + + 0 0 0 - - - + + + 255 255 255 - - - + + + 240 240 240 - - - + + + 0 0 0 - - - + + + 192 192 192 - - - + + + 0 0 0 - - - + + + 0 0 255 - - - + + + 255 0 255 - - - + + + 231 231 231 @@ -328,153 +329,153 @@ - - - + + + 104 104 104 - - - + + + 208 208 208 - - - + + + 255 255 255 - - - + + + 247 247 247 - - - + + + 104 104 104 - - - + + + 139 139 139 - - - + + + 104 104 104 - - - + + + 255 255 255 - - - + + + 104 104 104 - - - + + + 240 240 240 - - - + + + 240 240 240 - - - + + + 0 0 0 - - - + + + 0 0 128 - - - + + + 255 255 255 - - - + + + 0 0 255 - - - + + + 255 0 255 - - - + + + 231 231 231 @@ -484,7 +485,7 @@ - + Arial 8 @@ -495,111 +496,103 @@ false - + Qt::NoContextMenu - + Details - - + + :/images/rstray3.png:/images/rstray3.png - - - - - 0 + + + + + 1 - - - - 0 - 0 - 469 - 335 - - - - Details - - - + + + :/images/peerdetails_16x16.png:/images/peerdetails_16x16.png - - - - + + Details + + + + + Peer Info - - - - + + + + Name: - - - + + + true - - - + + + Org / Loc: - - - + + + true - - - + + + Country/State: - - - + + + true - - - + + + Peer ID - - - + + + true - - - + + + Last Contact - - - + + + true @@ -607,87 +600,60 @@ - - - + + + Peer Address - - - - - Local Address: - - - - - - - 6 - - - 0 - + + + - - - 0 - - - 6 - - - - - 0 + + + + + Qt::LeftToRight - - 65535 + + Local Address: - - 7812 + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - Port: + + + + External Address: - - - - - - 0 - - - 6 - - - + + + - - - - 0 - - - 65535 - - - 7812 + + + + + + + + + + + Port: - - - + + + Port: @@ -695,107 +661,121 @@ - - - false - - + + + + + 0 + + + 65535 + + + 7812 + + + + + + + 0 + + + 65535 + + + 7812 + + + + - - - - External Address: + + + + Qt::Vertical - - - - - - External Name + + + 20 + 47 + - + - - - - 0 - 0 - 469 - 335 - - - + + Trust Settings - + - - + + Trust Settings - + - - - - - Trust Level - - - - - - - true - - - - - - - Trusting me - - - - - - - true - - - - - - - - - Sign The Certificate + + + + + + Sign this certificate - - - Trust Their Signature + + + Accept connexions from this peer + + + + + + + + + + Peer has signed my certficate + + + + Certificate signers + + + + + + + + + + + + Make friend (Sign certificate and accept) + + + - + Qt::Vertical - + 451 131 @@ -807,14 +787,14 @@ - - - + + + - + Qt::Horizontal - + 311 20 @@ -822,22 +802,22 @@ - - - + + + Cancel - - - - OK + + + + Apply and close - + false - + true @@ -854,12 +834,11 @@ localPort extAddress extPort - extName cancelButton applyButton - + diff --git a/retroshare-gui/src/main.cpp b/retroshare-gui/src/main.cpp index a76ee2177..0de9f1405 100644 --- a/retroshare-gui/src/main.cpp +++ b/retroshare-gui/src/main.cpp @@ -26,6 +26,7 @@ #include #include #include +#include /*** WINDOWS DON'T LIKE THIS - REDEFINES VER numbers. #include @@ -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(logInfoChanged(const QString&)),w->networkDialog,SLOT(setLogInfo(QString))) ; + QObject::connect(ConfCertDialog::instance(),SIGNAL(configChanged()),w->networkDialog,SLOT(insertConnect())) ; + /* only show window, if not startMinimized */ if (!startMinimised) {