From 442577d9fcedfda01240b35a6fd47cbcc3bcc21d Mon Sep 17 00:00:00 2001 From: joss17 Date: Wed, 13 Jan 2010 21:32:56 +0000 Subject: [PATCH] gui implementations git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@2025 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- retroshare-gui/src/gui/NetworkDialog.cpp | 95 ++++--- retroshare-gui/src/gui/NetworkDialog.h | 3 +- retroshare-gui/src/gui/NetworkDialog.ui | 43 ++- retroshare-gui/src/gui/PeersDialog.cpp | 11 +- retroshare-gui/src/gui/TrustView.cpp | 4 +- .../src/gui/connect/ConfCertDialog.cpp | 145 ++++++---- .../src/gui/connect/ConfCertDialog.h | 4 +- .../src/gui/connect/ConfCertDialog.ui | 261 +++++++++++------- 8 files changed, 368 insertions(+), 198 deletions(-) diff --git a/retroshare-gui/src/gui/NetworkDialog.cpp b/retroshare-gui/src/gui/NetworkDialog.cpp index c58e4d42a..9e870399a 100644 --- a/retroshare-gui/src/gui/NetworkDialog.cpp +++ b/retroshare-gui/src/gui/NetworkDialog.cpp @@ -87,6 +87,9 @@ NetworkDialog::NetworkDialog(QWidget *parent) _settings = new RshareSettings(); connect( ui.connecttreeWidget, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( connecttreeWidgetCostumPopupMenu( QPoint ) ) ); + connect( ui.connecttreeWidget, SIGNAL( itemSelectionChanged()), ui.unvalidGPGkeyWidget, SLOT( clearSelection() ) ); + connect( ui.unvalidGPGkeyWidget, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( connecttreeWidgetCostumPopupMenu( QPoint ) ) ); + connect( ui.unvalidGPGkeyWidget, SIGNAL( itemSelectionChanged()), ui.connecttreeWidget, SLOT( clearSelection() ) ); /* create a single connect dialog */ connectdialog = new ConnectDialog(); @@ -120,7 +123,29 @@ NetworkDialog::NetworkDialog(QWidget *parent) headerItem->setTextAlignment(3, Qt::AlignHCenter | Qt::AlignVCenter); headerItem->setTextAlignment(4, Qt::AlignVCenter); - ui.networkTab->addTab(new NetworkView(),QString(tr("Network View"))); + /* hide the Tree +/- */ + ui.unvalidGPGkeyWidget -> setRootIsDecorated( false ); + + /* Set header resize modes and initial section sizes */ + ui.unvalidGPGkeyWidget->header()->setResizeMode (0, QHeaderView::Custom); + ui.unvalidGPGkeyWidget->header()->setResizeMode (1, QHeaderView::Interactive); + ui.unvalidGPGkeyWidget->header()->setResizeMode (2, QHeaderView::Interactive); + ui.unvalidGPGkeyWidget->header()->setResizeMode (3, QHeaderView::Interactive); + ui.unvalidGPGkeyWidget->header()->setResizeMode (4, QHeaderView::Interactive); + + ui.unvalidGPGkeyWidget->header()->resizeSection ( 0, 25 ); + ui.unvalidGPGkeyWidget->header()->resizeSection ( 1, 200 ); + ui.unvalidGPGkeyWidget->header()->resizeSection ( 2, 200 ); + ui.unvalidGPGkeyWidget->header()->resizeSection ( 3, 200 ); + + // set header text aligment + ui.unvalidGPGkeyWidget->headerItem()->setTextAlignment(0, Qt::AlignHCenter | Qt::AlignVCenter); + ui.unvalidGPGkeyWidget->headerItem()->setTextAlignment(1, Qt::AlignHCenter | Qt::AlignVCenter); + ui.unvalidGPGkeyWidget->headerItem()->setTextAlignment(2, Qt::AlignHCenter | Qt::AlignVCenter); + ui.unvalidGPGkeyWidget->headerItem()->setTextAlignment(3, Qt::AlignHCenter | Qt::AlignVCenter); + ui.unvalidGPGkeyWidget->headerItem()->setTextAlignment(4, Qt::AlignVCenter); + + //ui.networkTab->addTab(new NetworkView(),QString(tr("Network View"))); ui.networkTab->addTab(new TrustView(),QString(tr("Trust matrix"))); QString version = "-"; @@ -173,7 +198,7 @@ NetworkDialog::NetworkDialog(QWidget *parent) void NetworkDialog::connecttreeWidgetCostumPopupMenu( QPoint point ) { - + std::cerr << "NetworkDialog::connecttreeWidgetCostumPopupMenu( QPoint point ) called" << std::endl; QTreeWidgetItem *wi = getCurrentNeighbour(); if (!wi) return; @@ -193,7 +218,7 @@ void NetworkDialog::connecttreeWidgetCostumPopupMenu( QPoint point ) if(peer_id != rsPeers->getGPGOwnId()) { - if(detail.ownsign) + if(detail.accept_connection) { denyFriendAct = new QAction(QIcon(IMAGE_DENIED), tr( "Deny friend" ), this ); @@ -341,11 +366,7 @@ void NetworkDialog::insertConnect() std::list neighs; //these are GPG ids std::list::iterator it; - if (ui.showUnvalidKeys->isChecked()) { - rsPeers->getGPGAllList(neighs); - } else { - rsPeers->getGPGValidList(neighs); - } + rsPeers->getGPGAllList(neighs); /* get a link to the table */ QTreeWidget *connectWidget = ui.connecttreeWidget; @@ -360,7 +381,8 @@ void NetworkDialog::insertConnect() RsPeerDetails ownGPGDetails ; rsPeers->getGPGDetails(rsPeers->getGPGOwnId(), ownGPGDetails); - QList items; + QList validItems; + QList unvalidItems; for(it = neighs.begin(); it != neighs.end(); it++) { if (*it == rsPeers->getGPGOwnId()) { @@ -413,7 +435,7 @@ void NetworkDialog::insertConnect() */ QColor backgrndcolor; - if (detail.ownsign) + if (detail.accept_connection) { item -> setIcon(0,(QIcon(IMAGE_AUTHED))); backgrndcolor=Qt::green; @@ -423,7 +445,7 @@ void NetworkDialog::insertConnect() if (detail.hasSignedMe) { backgrndcolor=Qt::magenta; - item -> setIcon(0,(QIcon(IMAGE_TRUSTED))); + item -> setIcon(0,(QIcon(IMAGE_DENIED))); for(int k=0;k<8;++k) item -> setToolTip(k,QString::fromStdString(detail.name) + QString(tr(" has authenticated you. \nRight-click and select 'make friend' to be able to connect."))) ; } @@ -440,7 +462,11 @@ void NetworkDialog::insertConnect() item -> setBackground(i,QBrush(backgrndcolor)); /* add to the list */ - items.append(item); + if (detail.accept_connection || detail.validLvl >= 3) { + validItems.append(item); + } else { + unvalidItems.append(item); + } } @@ -457,41 +483,44 @@ void NetworkDialog::insertConnect() self_item->setBackground(i,QBrush(Qt::green)); } self_item->setIcon(0,(QIcon(IMAGE_AUTHED))); - items.append(self_item); + validItems.append(self_item); /* remove old items ??? */ connectWidget->clear(); connectWidget->setColumnCount(5); + ui.unvalidGPGkeyWidget->clear(); + ui.unvalidGPGkeyWidget->setColumnCount(5); /* add the items in! */ - connectWidget->insertTopLevelItems(0, items); - if (newSelect) - { - connectWidget->setCurrentItem(newSelect); - } + connectWidget->insertTopLevelItems(0, validItems); + ui.unvalidGPGkeyWidget->insertTopLevelItems(0, unvalidItems); + if (newSelect) { + connectWidget->setCurrentItem(newSelect); + ui.unvalidGPGkeyWidget->setCurrentItem(newSelect); + } connectWidget->sortItems( 1, Qt::AscendingOrder ); - connectWidget->update(); /* update display */ + ui.unvalidGPGkeyWidget->sortItems( 1, Qt::AscendingOrder ); + + if (ui.showUnvalidKeys->isChecked()) { + ui.unvalidGPGkeyWidget->show(); + } else { + ui.unvalidGPGkeyWidget->hide(); + } + connectWidget->update(); /* update display */ + ui.unvalidGPGkeyWidget->update(); /* update display */ + } QTreeWidgetItem *NetworkDialog::getCurrentNeighbour() { - /* get the current, and extract the Id */ - - /* get a link to the table */ - QTreeWidget *connectWidget = ui.connecttreeWidget; - QTreeWidgetItem *item = connectWidget -> currentItem(); - if (!item) - { -#ifdef NET_DEBUG - std::cerr << "Invalid Current Item" << std::endl; -#endif - return NULL; + if (ui.connecttreeWidget->selectedItems().size() != 0) { + return ui.connecttreeWidget -> currentItem(); + } else if (ui.unvalidGPGkeyWidget->selectedItems().size() != 0) { + return ui.unvalidGPGkeyWidget->currentItem(); } - - /* Display the columns of this item. */ - return item; + return NULL; } /* Utility Fns */ diff --git a/retroshare-gui/src/gui/NetworkDialog.h b/retroshare-gui/src/gui/NetworkDialog.h index 42e7efc27..b6aa33900 100644 --- a/retroshare-gui/src/gui/NetworkDialog.h +++ b/retroshare-gui/src/gui/NetworkDialog.h @@ -64,7 +64,8 @@ private slots: void peerdetails(); /** Create the context popup menu and it's submenus */ void connecttreeWidgetCostumPopupMenu( QPoint point ); - + //void unvalidGPGkeyWidgetCostumPopupMenu( QPoint point ); + /** Called when user clicks "Load Cert" to choose location of a Cert file */ void loadcert(); diff --git a/retroshare-gui/src/gui/NetworkDialog.ui b/retroshare-gui/src/gui/NetworkDialog.ui index 6758a60c1..f7ac4b35c 100644 --- a/retroshare-gui/src/gui/NetworkDialog.ui +++ b/retroshare-gui/src/gui/NetworkDialog.ui @@ -222,7 +222,7 @@ subcontrol-position: bottom right; - + @@ -402,6 +402,47 @@ subcontrol-position: bottom right; + + + + Qt::CustomContextMenu + + + true + + + 200 + + + true + + + + + + + + + Name + + + + + GPG key validity + + + + + Did peer authenticated me + + + + + Cert Id + + + + diff --git a/retroshare-gui/src/gui/PeersDialog.cpp b/retroshare-gui/src/gui/PeersDialog.cpp index 716ccb601..d1de98021 100644 --- a/retroshare-gui/src/gui/PeersDialog.cpp +++ b/retroshare-gui/src/gui/PeersDialog.cpp @@ -213,7 +213,12 @@ void PeersDialog::peertreeWidgetCostumPopupMenu( QPoint point ) exportfriendAct = new QAction(QIcon(IMAGE_EXPIORTFRIEND), tr( "Export Friend" ), this ); connect( exportfriendAct , SIGNAL( triggered() ), this, SLOT( exportfriend() ) ); - removefriendAct = new QAction(QIcon(IMAGE_REMOVEFRIEND), tr( "Deny Friend" ), this ); + QTreeWidgetItem *c = getCurrentPeer(); + if (c->type() == 0) { + removefriendAct = new QAction(QIcon(IMAGE_REMOVEFRIEND), tr( "Deny Friend" ), this ); + } else { + removefriendAct = new QAction(QIcon(IMAGE_REMOVEFRIEND), tr( "Remove Friend Location" ), this ); + } connect( removefriendAct , SIGNAL( triggered() ), this, SLOT( removefriend() ) ); @@ -310,7 +315,7 @@ void PeersDialog::insertPeers() if (list.size() == 1) { gpg_item = list.front(); } else { - gpg_item = new QTreeWidgetItem(0); + gpg_item = new QTreeWidgetItem(0); //set type to 0 for custom popup menu gpg_item->setChildIndicatorPolicy(QTreeWidgetItem::DontShowIndicatorWhenChildless); } @@ -360,7 +365,7 @@ void PeersDialog::insertPeers() } } if (newChild) { - sslItem = new QTreeWidgetItem(1); + sslItem = new QTreeWidgetItem(1); //set type to 1 for custom popup menu } RsPeerDetails sslDetail; diff --git a/retroshare-gui/src/gui/TrustView.cpp b/retroshare-gui/src/gui/TrustView.cpp index 121898954..a8b899109 100644 --- a/retroshare-gui/src/gui/TrustView.cpp +++ b/retroshare-gui/src/gui/TrustView.cpp @@ -142,10 +142,10 @@ void TrustView::update() std::list neighs; -// if(!rsPeers->getOthersList(neighs)) + if(!rsPeers->getGPGAllList(neighs)) return ; -// neighs.push_back(rsPeers->getPGPOwnId()) ; + neighs.push_back(rsPeers->getGPGOwnId()) ; trustTableTW->setSortingEnabled(false) ; diff --git a/retroshare-gui/src/gui/connect/ConfCertDialog.cpp b/retroshare-gui/src/gui/connect/ConfCertDialog.cpp index 994dd8a8b..001636ac6 100644 --- a/retroshare-gui/src/gui/connect/ConfCertDialog.cpp +++ b/retroshare-gui/src/gui/connect/ConfCertDialog.cpp @@ -48,6 +48,8 @@ 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.make_friend_button, SIGNAL(clicked()), this, SLOT(makeFriend())); + connect(ui.denyFriendButton, SIGNAL(clicked()), this, SLOT(denyFriend())); + connect(ui.signKeyButton, SIGNAL(clicked()), this, SLOT(signGPGKey())); ui.applyButton->setToolTip(tr("Apply and Close")); @@ -171,64 +173,91 @@ void ConfCertDialog::loadDialog() ui.groupBox->hide(); } - if (detail.accept_connection) { - //connection already accepted, propose to sign gpg key - if (!detail.ownsign) { - ui.signGPGKeyCheckBox->setChecked(true); - ui.signGPGKeyCheckBox->hide(); - ui.signed_already_label->setText(tr("Peer is already a friend")); - ui.make_friend_button->setText(tr("Sign GPG key")); - ui.make_friend_button->show(); - } else { - ui.signGPGKeyCheckBox->hide(); - ui.signed_already_label->setText(tr("Peer is a friend and GPG key is signed")); - ui.signed_already_label->show(); - ui.make_friend_button->hide(); - } + if (detail.gpg_id == rsPeers->getGPGOwnId()) { + ui.make_friend_button->hide(); + ui.signGPGKeyCheckBox->hide(); + ui.signKeyButton->hide(); + ui.denyFriendButton->hide(); + + ui.web_of_trust_label->hide(); + ui.radioButton_trust_fully->hide(); + ui.radioButton_trust_marginnaly->hide(); + ui.radioButton_trust_never->hide(); + + ui.is_signing_me->hide(); + ui.signersBox->setTitle(tr("Your key is signed by : ")); + } else { ui.make_friend_button->show(); - ui.make_friend_button->setText(tr("Make Friend")); - if (!detail.ownsign) { - ui.signGPGKeyCheckBox->show(); - ui.signGPGKeyCheckBox->setChecked(true); - } else { - ui.signGPGKeyCheckBox->hide(); - } - ui.signed_already_label->hide(); - } + ui.signGPGKeyCheckBox->show(); + ui.signKeyButton->show(); + ui.denyFriendButton->show(); - 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")); - } - - //web of trust - if (detail.trustLvl == 5) { - //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.")); - ui.radioButton_trust_fully->hide(); - ui.radioButton_trust_marginnaly->hide(); - ui.radioButton_trust_never->hide(); - } else { + ui.web_of_trust_label->show(); ui.radioButton_trust_fully->show(); ui.radioButton_trust_marginnaly->show(); ui.radioButton_trust_never->show(); - if (detail.trustLvl == 4) { - ui.web_of_trust_label->setText(tr("Your trust in this peer is full.")); - ui.radioButton_trust_fully->setChecked(true); - } else if (detail.trustLvl == 3) { - ui.web_of_trust_label->setText(tr("Your trust in this peer is marginal.")); - ui.radioButton_trust_marginnaly->setChecked(true); - } else if (detail.trustLvl == 2) { - ui.web_of_trust_label->setText(tr("Your trust in this peer is none.")); - ui.radioButton_trust_never->setChecked(true); + + ui.is_signing_me->show(); + ui.signersBox->setTitle(tr("Peer key is signed by : ")); + + if (detail.accept_connection) { + ui.make_friend_button->hide(); + ui.denyFriendButton->show(); + ui.signGPGKeyCheckBox->hide(); + //connection already accepted, propose to sign gpg key + if (!detail.ownsign) { + ui.signGPGKeyCheckBox->hide(); + ui.signKeyButton->show(); + } else { + ui.signGPGKeyCheckBox->hide(); + ui.signKeyButton->hide(); + } } else { - ui.web_of_trust_label->setText(tr("Your trust in this peer is not set.")); - ui.radioButton_trust_fully->setChecked(false); - ui.radioButton_trust_marginnaly->setChecked(false); - ui.radioButton_trust_never->setChecked(false); + ui.make_friend_button->show(); + ui.denyFriendButton->hide(); + ui.signKeyButton->hide(); + if (!detail.ownsign) { + ui.signGPGKeyCheckBox->show(); + ui.signGPGKeyCheckBox->setChecked(true); + } else { + ui.signGPGKeyCheckBox->hide(); + } + } + + //web of trust + if (detail.trustLvl == 5) { + //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.")); + ui.radioButton_trust_fully->hide(); + ui.radioButton_trust_marginnaly->hide(); + ui.radioButton_trust_never->hide(); + } else { + ui.radioButton_trust_fully->show(); + ui.radioButton_trust_marginnaly->show(); + ui.radioButton_trust_never->show(); + if (detail.trustLvl == 4) { + ui.web_of_trust_label->setText(tr("Your trust in this peer is full.")); + ui.radioButton_trust_fully->setChecked(true); + } else if (detail.trustLvl == 3) { + ui.web_of_trust_label->setText(tr("Your trust in this peer is marginal.")); + ui.radioButton_trust_marginnaly->setChecked(true); + } else if (detail.trustLvl == 2) { + ui.web_of_trust_label->setText(tr("Your trust in this peer is none.")); + ui.radioButton_trust_never->setChecked(true); + } else { + ui.web_of_trust_label->setText(tr("Your trust in this peer is not set.")); + ui.radioButton_trust_fully->setChecked(false); + ui.radioButton_trust_marginnaly->setChecked(false); + ui.radioButton_trust_never->setChecked(false); + } } + + 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")); + } } ui.signers->clear() ; @@ -292,8 +321,7 @@ void ConfCertDialog::applyDialog() closeinfodlg(); } -void ConfCertDialog::makeFriend() -{ +void ConfCertDialog::makeFriend() { std::string gpg_id = rsPeers->getGPGId(mId); if (ui.signGPGKeyCheckBox->isChecked()) { rsPeers->signGPGCertificate(gpg_id); @@ -303,3 +331,16 @@ void ConfCertDialog::makeFriend() rsPeers->addFriend(mId, gpg_id); loadDialog(); } + +void ConfCertDialog::denyFriend() { + std::string gpg_id = rsPeers->getGPGId(mId); + rsPeers->setAcceptToConnectGPGCertificate(gpg_id, false); + loadDialog(); +} + +void ConfCertDialog::signGPGKey() { + std::string gpg_id = rsPeers->getGPGId(mId); + rsPeers->signGPGCertificate(gpg_id); + loadDialog(); +} + diff --git a/retroshare-gui/src/gui/connect/ConfCertDialog.h b/retroshare-gui/src/gui/connect/ConfCertDialog.h index 059c94bbf..5b75a6104 100644 --- a/retroshare-gui/src/gui/connect/ConfCertDialog.h +++ b/retroshare-gui/src/gui/connect/ConfCertDialog.h @@ -69,7 +69,9 @@ private slots: void closeinfodlg(); void applyDialog(); void makeFriend(); - + void denyFriend(); + void signGPGKey(); + private: /** Loads the saved connectidialog settings */ diff --git a/retroshare-gui/src/gui/connect/ConfCertDialog.ui b/retroshare-gui/src/gui/connect/ConfCertDialog.ui index 6c5101ba0..9390dbcfc 100644 --- a/retroshare-gui/src/gui/connect/ConfCertDialog.ui +++ b/retroshare-gui/src/gui/connect/ConfCertDialog.ui @@ -6,7 +6,7 @@ 0 0 - 459 + 512 529 @@ -21,7 +21,7 @@ - 0 + 1 @@ -253,6 +253,145 @@ Trust + + + + + + Deny Friend + + + + :/images/cancel.png:/images/cancel.png + + + + 15 + 15 + + + + + + + + Make Friends + + + + :/images/add-friend24.png:/images/add-friend24.png + + + + 15 + 15 + + + + + + + + Sign GPG key + + + + :/images/dauthed.png:/images/dauthed.png + + + + 15 + 15 + + + + true + + + + + + + Sign GPG Key + + + + :/images/dauthed.png:/images/dauthed.png + + + + 15 + 15 + + + + + + + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 10 + + + + + + + + + + Your trust in this peer is : + + + + + + + None + + + + + + + Marginal + + + + + + + Full + + + + + + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 10 + + + + @@ -262,20 +401,32 @@ - GPG Key signing settings + GPG Key + + + false + + + false + + + 75 + true + + Peer has signed my GPG key - + - Peer key is already signed by : + Peer key is signed by : @@ -284,106 +435,6 @@ - - - - - 450 - 50 - - - - Not filled - - - false - - - true - - - - - - - Sign GPG key (Default) - - - true - - - - - - - Make Friends - - - - - - - - - - true - - - - 0 - 50 - - - - - true - - - - GPG Web of Trust - - - - - - Your trust in this peer is : - - - - - - - - - Your trust in this peer is none, it means he is known to improperly sign other keys. - - - None - - - - - - - Your trust in this peer is marginal, it means he understands the implications of key signing and properly check keys before signing them. - - - Marginnaly - - - - - - - Your trust in this peer is full, it means he has an excellent understanding of key signing, and his signature on a key would be as good as your own. - - - Fully - - - - -