diff --git a/libretroshare/src/pqi/authgpg.cc b/libretroshare/src/pqi/authgpg.cc index 2866ce7ff..9ae44fd46 100644 --- a/libretroshare/src/pqi/authgpg.cc +++ b/libretroshare/src/pqi/authgpg.cc @@ -912,7 +912,9 @@ bool AuthGPG::getPGPDetails(std::string id, RsPeerDetails &d) d.trustLvl = it->second.trustLvl; d.validLvl = it->second.validLvl; d.ownsign = it->second.ownsign; - d.signers = it->second.signers; + d.gpgSigners = it->second.signers; + std::cerr << "AuthGPG::getPGPDetails() get details for : " << id << std::endl; + std::cerr << "AuthGPG::getPGPDetails() Name : " << it->second.name << std::endl; return true; } else { return false; @@ -926,8 +928,7 @@ bool AuthGPG::decryptText(gpgme_data_t CIPHER, gpgme_data_t PLAIN) { if (GPG_ERR_NO_ERROR != (ERR = gpgme_op_decrypt (CTX, CIPHER, PLAIN))) { ProcessPGPmeError(ERR); - std::cerr << "AuthGPG::decryptText() Error decrypting text."; - std::cerr << std::endl; + std::cerr << "AuthGPG::decryptText() Error decrypting text." << std::endl; return false; } diff --git a/libretroshare/src/rsiface/rspeers.h b/libretroshare/src/rsiface/rspeers.h index a9d40d8b2..8de764624 100644 --- a/libretroshare/src/rsiface/rspeers.h +++ b/libretroshare/src/rsiface/rspeers.h @@ -86,7 +86,7 @@ class RsPeerDetails std::string fpr; /* pgp fingerprint */ std::string authcode; - std::list signers; + std::list gpgSigners; uint32_t trustLvl; uint32_t validLvl; @@ -140,6 +140,7 @@ virtual bool getPeerDetails(std::string id, RsPeerDetails &d) = 0; /* Using PGP Ids */ virtual std::string getPGPOwnId() = 0; +virtual std::string getPGPId(std::string ssl_id) = 0; virtual bool getPGPFriendList(std::list &ids) = 0; virtual bool getPGPAllList(std::list &ids) = 0; virtual bool getPGPDetails(std::string id, RsPeerDetails &d) = 0; diff --git a/libretroshare/src/rsserver/p3peers.cc b/libretroshare/src/rsserver/p3peers.cc index 9eef07616..9f011da5a 100644 --- a/libretroshare/src/rsserver/p3peers.cc +++ b/libretroshare/src/rsserver/p3peers.cc @@ -314,7 +314,7 @@ bool p3Peers::getPeerDetails(std::string id, RsPeerDetails &d) d.email = authDetail.email; d.location = authDetail.location; d.org = authDetail.org; - d.signers = authDetail.signers; + d.gpgSigners = authDetail.signers; d.issuer = authDetail.issuer; @@ -552,13 +552,12 @@ bool p3Peers::getPGPAllList(std::list &ids) bool p3Peers::getPGPDetails(std::string id, RsPeerDetails &d) { #ifdef P3PEERS_DEBUG - std::cerr << "p3Peers::getPgpDetails()"; + std::cerr << "p3Peers::getPgpDetails() called for id : " << id; std::cerr << std::endl; #endif /* get from mAuthMgr */ - AuthGPG::getAuthGPG()->getPGPDetails(id, d); - return true; + return AuthGPG::getAuthGPG()->getPGPDetails(id, d); } std::string p3Peers::getPGPOwnId() @@ -572,6 +571,16 @@ std::string p3Peers::getPGPOwnId() return AuthGPG::getAuthGPG()->PGPOwnId(); } +std::string p3Peers::getPGPId(std::string ssl_id) +{ +#ifdef P3PEERS_DEBUG + std::cerr << "p3Peers::getPGPId()"; + std::cerr << std::endl; +#endif + + /* get from mAuthMgr */ + return AuthSSL::getAuthSSL()->getGPGId(ssl_id); +} @@ -970,8 +979,8 @@ std::ostream &operator<<(std::ostream &out, const RsPeerDetails &detail) out << std::endl; std::list::const_iterator it; - for(it = detail.signers.begin(); - it != detail.signers.end(); it++) + for(it = detail.gpgSigners.begin(); + it != detail.gpgSigners.end(); it++) { out << "\t" << *it; out << std::endl; diff --git a/libretroshare/src/rsserver/p3peers.h b/libretroshare/src/rsserver/p3peers.h index 621fc3770..a3c964f2a 100644 --- a/libretroshare/src/rsserver/p3peers.h +++ b/libretroshare/src/rsserver/p3peers.h @@ -55,6 +55,7 @@ virtual bool getPeerDetails(std::string id, RsPeerDetails &d); /* Using PGP Ids */ virtual std::string getPGPOwnId(); +virtual std::string getPGPId(std::string ssl_id); virtual bool getPGPFriendList(std::list &ids); virtual bool getPGPAllList(std::list &ids); virtual bool getPGPDetails(std::string id, RsPeerDetails &d); diff --git a/libretroshare/src/services/p3disc.cc b/libretroshare/src/services/p3disc.cc index 47ad971f5..3eed8efef 100644 --- a/libretroshare/src/services/p3disc.cc +++ b/libretroshare/src/services/p3disc.cc @@ -500,7 +500,7 @@ void p3disc::sendPeerDetails(std::string to, std::string about) RsPeerDetails pd ; std::string name = rsPeers->getPeerName(about) ; if(rsPeers->getPeerDetails(to,pd)) - for(std::list::const_iterator it(pd.signers.begin());it!=pd.signers.end();++it) + for(std::list::const_iterator it(pd.gpgSigners.begin());it!=pd.gpgSigners.end();++it) if(*it == name) { di->discFlags |= P3DISC_FLAGS_PEER_TRUSTS_ME; diff --git a/retroshare-gui/src/gui/NetworkDialog.cpp b/retroshare-gui/src/gui/NetworkDialog.cpp index 16357949a..0badda672 100644 --- a/retroshare-gui/src/gui/NetworkDialog.cpp +++ b/retroshare-gui/src/gui/NetworkDialog.cpp @@ -178,7 +178,7 @@ void NetworkDialog::connecttreeWidgetCostumPopupMenu( QPoint point ) QMouseEvent *mevent = new QMouseEvent( QEvent::MouseButtonPress, point, Qt::RightButton, Qt::RightButton, Qt::NoModifier ); contextMnu.clear(); - std::string peer_id = wi->text(9).toStdString() ; + std::string peer_id = wi->text(3).toStdString() ; // That's what context menus are made for RsPeerDetails detail; @@ -380,7 +380,7 @@ void NetworkDialog::insertConnect() /* (2) has me auth */ bool hasSignedMe = false; std::list::iterator signersIt; - for(signersIt = ownGPGDetails.signers.begin(); signersIt != ownGPGDetails.signers.end() ; ++signersIt) { + for(signersIt = ownGPGDetails.gpgSigners.begin(); signersIt != ownGPGDetails.gpgSigners.end() ; ++signersIt) { if (*signersIt == detail.id) { hasSignedMe = true; break; diff --git a/retroshare-gui/src/gui/NetworkView.cpp b/retroshare-gui/src/gui/NetworkView.cpp index ecdc44932..82bcd95e2 100644 --- a/retroshare-gui/src/gui/NetworkView.cpp +++ b/retroshare-gui/src/gui/NetworkView.cpp @@ -341,7 +341,7 @@ void NetworkView::insertSignatures() continue; } - for(sit = detail.signers.begin(); sit != detail.signers.end(); sit++) + for(sit = detail.gpgSigners.begin(); sit != detail.gpgSigners.end(); sit++) { if (*it != *sit) diff --git a/retroshare-gui/src/gui/TrustView.cpp b/retroshare-gui/src/gui/TrustView.cpp index cdf0624ef..f6a117703 100644 --- a/retroshare-gui/src/gui/TrustView.cpp +++ b/retroshare-gui/src/gui/TrustView.cpp @@ -162,7 +162,7 @@ void TrustView::update() int i = getRowColId(details.id) ; std::string issuer(details.issuer) ; // the one we check for trust. - for(list::const_iterator it2(details.signers.begin());it2!=details.signers.end();++it2) + for(list::const_iterator it2(details.gpgSigners.begin());it2!=details.gpgSigners.end();++it2) { cout << *it2 << " " ; diff --git a/retroshare-gui/src/gui/connect/ConfCertDialog.cpp b/retroshare-gui/src/gui/connect/ConfCertDialog.cpp index 82063851f..ac558c2a8 100644 --- a/retroshare-gui/src/gui/connect/ConfCertDialog.cpp +++ b/retroshare-gui/src/gui/connect/ConfCertDialog.cpp @@ -25,6 +25,7 @@ #include "rsiface/rsdisc.h" #include +#include ConfCertDialog *ConfCertDialog::instance() { @@ -46,7 +47,7 @@ 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())); + connect(ui.sign_button, SIGNAL(clicked()), this, SLOT(makeFriend())); ui.applyButton->setToolTip(tr("Apply and Close")); @@ -93,42 +94,60 @@ void ConfCertDialog::loadId(std::string id) void ConfCertDialog::loadDialog() { - + isPGPId = false; RsPeerDetails detail; if (!rsPeers->getPeerDetails(mId, detail)) { - /* fail */ - return; - } + isPGPId = true; + if (!rsPeers->getPGPDetails(mId, detail)) { + QMessageBox::information(this, + tr("RetroShare"), + tr("Error : cannot get peer details.")); + this->close(); + } + } ui.name->setText(QString::fromStdString(detail.name)); - ui.orgloc->setText(QString::fromStdString(detail.org)); - ui.country->setText(QString::fromStdString(detail.location)); 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); + if (!isPGPId) { + ui.orgloc->setText(QString::fromStdString(detail.org)); + ui.country->setText(QString::fromStdString(detail.location)); + // 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::iterator vit; - std::map versions; - bool retv = rsDisc->getDiscVersions(versions); - if (retv && versions.end() != (vit = versions.find(detail.id))) - { - ui.version->setText(QString::fromStdString(vit->second)); - } + /* set retroshare version */ + std::map::iterator vit; + std::map versions; + bool retv = rsDisc->getDiscVersions(versions); + if (retv && versions.end() != (vit = versions.find(detail.id))) + { + ui.version->setText(QString::fromStdString(vit->second)); + } - /* 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); + /* 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.ipAddressList->clear(); - for(std::list::const_iterator it(detail.ipAddressList.begin());it!=detail.ipAddressList.end();++it) - ui.ipAddressList->addItem(QString::fromStdString(*it)); + ui.ipAddressList->clear(); + for(std::list::const_iterator it(detail.ipAddressList.begin());it!=detail.ipAddressList.end();++it) + ui.ipAddressList->addItem(QString::fromStdString(*it)); + } else { + ui.orgloc->hide(); + ui.label_11->hide(); + ui.country->hide(); + ui.label_8->hide(); + ui.lastcontact->hide(); + ui.label_7->hide(); + ui.version->hide(); + ui.label_3->hide(); + + ui.groupBox->hide(); + } /* set the url for DNS access (OLD) */ //ui.extName->setText(QString::fromStdString("")); @@ -143,17 +162,37 @@ void ConfCertDialog::loadDialog() //ui.trustLvl->setText(QString::fromStdString(RsPeerTrustString(detail.trustLvl))); - 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.sign_button->hide(); + ui.signed_already_label->show(); + } else { + ui.sign_button->show(); + ui.signed_already_label->hide(); + } - ui._peerAcceptedCB->setChecked(detail.state & RS_PEER_STATE_FRIEND) ; - ui._peerAcceptedCB->setEnabled(detail.ownsign) ; + bool hasSignedMe = false; + RsPeerDetails ownGPGDetails ; + rsPeers->getPGPDetails(rsPeers->getPGPOwnId(), ownGPGDetails); + std::list::iterator signersIt; + for(signersIt = ownGPGDetails.gpgSigners.begin(); signersIt != ownGPGDetails.gpgSigners.end() ; ++signersIt) { + if (*signersIt == detail.id) { + hasSignedMe = true; + break; + } + } + if (hasSignedMe) { + ui.is_signing_me->setText(tr("Peer has acepted me as a friend and did not signed my GPG key")); + } else { + ui.is_signing_me->setText(tr("Peer has not acepted me as a friend and did not signed my GPG key")); + } - ui.signers->clear() ; - for(std::list::const_iterator it(detail.signers.begin());it!=detail.signers.end();++it) - ui.signers->append(QString::fromStdString(*it)) ; + ui.signers->clear() ; + for(std::list::const_iterator it(detail.gpgSigners.begin());it!=detail.gpgSigners.end();++it) { + RsPeerDetails signerDetail; + if (rsPeers->getPGPDetails(*it, signerDetail)) { + ui.signers->append(QString::fromStdString(signerDetail.name)); + } + } } @@ -172,8 +211,6 @@ void ConfCertDialog::applyDialog() bool localChanged = false; bool extChanged = false; bool fwChanged = false; - bool signChanged = false; - bool trustChanged = false; /* set local address */ if ((detail.localAddr != ui.localAddress->text().toStdString()) || (detail.localPort != ui.localPort -> value())) @@ -182,14 +219,6 @@ void ConfCertDialog::applyDialog() if ((detail.extAddr != ui.extAddress->text().toStdString()) || (detail.extPort != ui.extPort -> value())) extChanged = true; - if (detail.ownsign) - { - if (ui._peerAcceptedCB->isChecked() != ((detail.state & RS_PEER_STATE_FRIEND) > 0)) - trustChanged = 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()); @@ -197,61 +226,18 @@ void ConfCertDialog::applyDialog() if (extChanged) rsPeers->setExtAddress(mId,ui.extAddress->text().toStdString(), ui.extPort->value()); -#if 0 - if (fwChanged) - rsicontrol -> FriendSetFirewall(mId, ui.chkFirewall->isChecked(), - ui.chkForwarded->isChecked()); -#endif - - 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 || localChanged || extChanged) + if(localChanged || extChanged) emit configChanged() ; } void ConfCertDialog::makeFriend() { - ui.signBox->setChecked(true) ; - ui._peerAcceptedCB->setChecked(true) ; - -// rsPeers->TrustCertificate(mId, ui.trustBox->isChecked()); -// rsPeers->SignCertificate(mId); + rsPeers->SignGPGCertificate(mId); + loadDialog(); } - -#if 0 -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)); -} -#endif - - diff --git a/retroshare-gui/src/gui/connect/ConfCertDialog.h b/retroshare-gui/src/gui/connect/ConfCertDialog.h index e9370456f..c4330f675 100644 --- a/retroshare-gui/src/gui/connect/ConfCertDialog.h +++ b/retroshare-gui/src/gui/connect/ConfCertDialog.h @@ -76,6 +76,7 @@ private: void loadDialog(); std::string mId; +bool isPGPId; /** Qt Designer generated object */ Ui::ConfCertDialog ui; diff --git a/retroshare-gui/src/gui/connect/ConfCertDialog.ui b/retroshare-gui/src/gui/connect/ConfCertDialog.ui index 0fea19ce4..7a9ae7d6a 100644 --- a/retroshare-gui/src/gui/connect/ConfCertDialog.ui +++ b/retroshare-gui/src/gui/connect/ConfCertDialog.ui @@ -1,372 +1,359 @@ - - - ConfCertDialog - - - - 0 - 0 - 506 - 474 - - - - Peer Details - - - - :/images/rstray3.png:/images/rstray3.png - - - - - - 0 - - - - - :/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 - - - - - - - true - - - - - - - Version - - - - - - - - - - Peer Address - - - - - - - - - - Qt::LeftToRight - - - Local Address: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - External Address: - - - - - - - - - - - - - - - - - - - - - Port: - - - - - - - Port: - - - - - - - - - - - 0 - - - 65535 - - - 7812 - - - - - - - 0 - - - 65535 - - - 7812 - - - - - - - - - - - Addresses list - - - - - - - - - - Qt::Vertical - - - - 20 - 47 - - - - - - - - - - - - - :/images/security-high-16.png:/images/security-high-16.png - - - Trust - - - - - - Trust Settings - - - - - - - - - Sign this certificate - - - - - - - Accept connexions from this peer - - - - - - - - - - Peer has signed my certficate - - - - - - - - - - Certificate signers - - - - - - - - - - - - Make friend (Sign certificate and accept) - - - - - - - Qt::Vertical - - - - 451 - 131 - - - - - - - - - - - - - - Qt::Horizontal - - - - 311 - 20 - - - - - - - - Cancel - - - - - - - OK - - - false - - - true - - - - - - - - - - - - + + + ConfCertDialog + + + + 0 + 0 + 506 + 523 + + + + Peer Details + + + + :/images/rstray3.png:/images/rstray3.png + + + + + + 1 + + + + + :/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 + + + + + + + true + + + + + + + Version + + + + + + + + + + Peer Address + + + + + + + + + + Qt::LeftToRight + + + Local Address: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + External Address: + + + + + + + + + + + + + + + + + + + + + Port: + + + + + + + Port: + + + + + + + + + + + 0 + + + 65535 + + + 7812 + + + + + + + 0 + + + 65535 + + + 7812 + + + + + + + + + + + Addresses list + + + + + + + + + + Qt::Vertical + + + + 20 + 47 + + + + + + + + + + + + + :/images/security-high-16.png:/images/security-high-16.png + + + Trust + + + + + + Key signing settings + + + + + + Peer has signed my GPG key + + + + + + + Peer key is already signed by : + + + + + + + + + + + + Peer is already a friend of me (his GPG key is signed by me) + + + + + + + Make friend (Sign his GPG key) + + + + + + + + + + Qt::Vertical + + + + 451 + 131 + + + + + + + + + + + + + + Qt::Horizontal + + + + 311 + 20 + + + + + + + + Cancel + + + + + + + OK + + + false + + + true + + + + + + + + + + + + diff --git a/retroshare-gui/src/gui/connect/ConnectDialog.cpp b/retroshare-gui/src/gui/connect/ConnectDialog.cpp index 8a604a782..aa1a808e5 100644 --- a/retroshare-gui/src/gui/connect/ConnectDialog.cpp +++ b/retroshare-gui/src/gui/connect/ConnectDialog.cpp @@ -130,7 +130,7 @@ void ConnectDialog::authAttempt() /* well lets do it ! */ std::cerr << "Attempting AuthCode:" << authCode << std::endl; - rsPeers->AuthCertificate(authId, authCode); + //rsPeers->AuthCertificate(authId, authCode); rsPeers->addFriend(authId); rsicontrol->getNotify().notifyListChange(NOTIFY_LIST_NEIGHBOURS,1) ; @@ -166,7 +166,7 @@ bool ConnectDialog::loadPeer(std::string id) std::ostringstream out; std::list::iterator it; - for(it = detail.signers.begin(); it != detail.signers.end(); it++) + for(it = detail.gpgSigners.begin(); it != detail.gpgSigners.end(); it++) { out << rsPeers->getPeerName(*it) << " <" << *it << ">"; out << std::endl; diff --git a/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp b/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp index ab1856fcb..3f5a00f95 100755 --- a/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp +++ b/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp @@ -97,7 +97,7 @@ ConnectFriendWizard::accept() std::string authId = field("idField").toString().toStdString(); std::string authCode = field("authCode").toString().toStdString(); - rsPeers->AuthCertificate(authId, authCode ); + //rsPeers->AuthCertificate(authId, authCode ); rsPeers->addFriend(authId); //let's check if there is ip adresses in the wizard. @@ -485,7 +485,7 @@ void FofPage::updatePeersList(int e) std::set common_friends ; - for(std::list::const_iterator it2(details.signers.begin());it2!=details.signers.end();++it2) + for(std::list::const_iterator it2(details.gpgSigners.begin());it2!=details.gpgSigners.end();++it2) if(my_friends_names.find(*it2) != my_friends_names.end() && *it2 != details.name) common_friends.insert(*it2) ; @@ -565,7 +565,7 @@ void FofPage::signAllSelectedUsers() if(it->first->isChecked()) { std::cerr << "Making friend with " << it->second << std::endl ; - rsPeers->AuthCertificate(it->second, ""); + //rsPeers->AuthCertificate(it->second, ""); rsPeers->addFriend(it->second); } @@ -868,7 +868,7 @@ ConclusionPage::initializePage() QString ts; std::list::iterator it; - for(it = detail.signers.begin(); it != detail.signers.end(); it++) + for(it = detail.gpgSigners.begin(); it != detail.gpgSigners.end(); it++) { ts.append(QString::fromStdString( rsPeers->getPeerName(*it) )); ts.append( "<" ) ;