diff --git a/libretroshare/src/pqi/authgpg.cc b/libretroshare/src/pqi/authgpg.cc index e700184a1..4f4333520 100644 --- a/libretroshare/src/pqi/authgpg.cc +++ b/libretroshare/src/pqi/authgpg.cc @@ -29,6 +29,8 @@ #include #include #include +#include + // initialisation du pointeur de singleton à zéro AuthGPG *AuthGPG::instance_gpg = new AuthGPG(); @@ -60,7 +62,7 @@ gpgcert::~gpgcert() { if (key) { - gpgme_key_unref(key); + gpgme_key_unref(key); } } @@ -294,21 +296,6 @@ int AuthGPG::GPGInit(std::string ownId) { } -//int AuthGPG::LoadGPGPassword(std::string pwd) -//{ -// RsStackMutex stack(pgpMtx); /******* LOCKED ******/ -// -// if (!gpgmeInit) { -// return 0; -// } -// -// this->passphrase = pwd; -// setPGPPassword_locked(pwd); -// -// return 1; -//} - - // store all keys in map mKeyList to avoid callin gpgme exe repeatedly bool AuthGPG::storeAllKeys_locked() @@ -326,7 +313,7 @@ bool AuthGPG::storeAllKeys_locked() std::cerr << "AuthGPG::storeAllKeys_locked() clearing existing ones"; std::cerr << std::endl; - mKeyList.clear(); + mKeyList.clear(); /* enable SIG mode */ gpgme_keylist_mode_t origmode = gpgme_get_keylist_mode(CTX); @@ -410,9 +397,7 @@ bool AuthGPG::storeAllKeys_locked() { nu.signers.push_back(keyid); } - std::cerr << "keyid: " << keyid << std::endl; - std::cerr << "mOwnGpgId: " << mOwnGpgId << std::endl; - if (keyid == mOwnGpgId) { + if (keyid == mOwnGpgId) { nu.ownsign = true; } } @@ -614,7 +599,7 @@ bool AuthGPG::printOwnKeys_locked() bool AuthGPG::printKeys() { - //RsStackMutex stack(pgpMtx); /******* LOCKED ******/ + RsStackMutex stack(pgpMtx); /******* LOCKED ******/ printAllKeys_locked(); return printOwnKeys_locked(); } @@ -860,7 +845,7 @@ int AuthGPG::setConfigDirectories(std::string confFile, std::string neighDir /**** These Two are common */ std::string AuthGPG::getPGPName(GPG_id id) { - //RsStackMutex stack(pgpMtx); /******* LOCKED ******/ + RsStackMutex stack(pgpMtx); /******* LOCKED ******/ certmap::iterator it; if (mKeyList.end() != (it = mKeyList.find(id))) @@ -872,7 +857,7 @@ std::string AuthGPG::getPGPName(GPG_id id) /**** These Two are common */ std::string AuthGPG::getPGPEmail(GPG_id id) { - //RsStackMutex stack(pgpMtx); /******* LOCKED ******/ + RsStackMutex stack(pgpMtx); /******* LOCKED ******/ certmap::iterator it; if (mKeyList.end() != (it = mKeyList.find(id))) @@ -892,7 +877,7 @@ std::string AuthGPG::PGPOwnId() bool AuthGPG::getPGPAllList(std::list &ids) { - //RsStackMutex stack(pgpMtx); /******* LOCKED ******/ + RsStackMutex stack(pgpMtx); /******* LOCKED ******/ /* add an id for each pgp certificate */ certmap::iterator it; @@ -903,9 +888,24 @@ bool AuthGPG::getPGPAllList(std::list &ids) return true; } +bool AuthGPG::getPGPValidList(std::list &ids) +{ + RsStackMutex stack(pgpMtx); /******* LOCKED ******/ + + /* add an id for each pgp certificate */ + certmap::iterator it; + for(it = mKeyList.begin(); it != mKeyList.end(); it++) + { + if (it->second.validLvl >= GPGME_VALIDITY_MARGINAL) { + ids.push_back(it->first); + } + } + return true; +} + bool AuthGPG::getPGPDetails(std::string id, RsPeerDetails &d) { - //RsStackMutex stack(pgpMtx); /******* LOCKED ******/ + RsStackMutex stack(pgpMtx); /******* LOCKED ******/ /* add an id for each pgp certificate */ certmap::iterator it; @@ -1193,8 +1193,6 @@ bool AuthGPG::RevokeCertificate(std::string id) bool AuthGPG::TrustCertificateMarginally(std::string id) { - RsStackMutex stack(pgpMtx); /******* LOCKED ******/ - std::cerr << "AuthGPG::TrustCertificateMarginally(" << id << ")"; std::cerr << std::endl; //TODO implement it @@ -1202,6 +1200,12 @@ bool AuthGPG::TrustCertificateMarginally(std::string id) return false; } +bool AuthGPG::TrustCertificate(std::string id, int trustlvl) +{ + std::cerr << "AuthGPG::TrustCertificate(" << id << ", " << trustlvl << ")" << std::endl; + return this->privateTrustCertificate(id, trustlvl); +} + bool AuthGPG::SignData(std::string input, std::string &sign) { return false; @@ -1263,8 +1267,7 @@ int AuthGPG::privateSignCertificate(std::string id) } - if(GPG_ERR_NO_ERROR != (ERR = gpgme_op_edit(CTX, signKey, keySignCallback, \ - ¶ms, out))) { + if(GPG_ERR_NO_ERROR != (ERR = gpgme_op_edit(CTX, signKey, keySignCallback, ¶ms, out))) { return 0; } @@ -1294,8 +1297,8 @@ int AuthGPG::privateTrustCertificate(std::string id, int trustlvl) gpgcert trustCert = mKeyList.find(id)->second; gpgme_key_t trustKey = trustCert.key; - const char *lvls[] = {"1", "2", "3", "4", "5"}; - class EditParams params(TRUST_START, (void *) *(lvls + trustlvl -1)); + class TrustParams sparams((boost::lexical_cast(trustlvl))); + class EditParams params(TRUST_START, &sparams); gpgme_data_t out; gpg_error_t ERR; @@ -1306,6 +1309,11 @@ int AuthGPG::privateTrustCertificate(std::string id, int trustlvl) if(GPG_ERR_NO_ERROR != (ERR = gpgme_op_edit(CTX, trustKey, trustCallback, ¶ms, out))) return 0; + + //the key ref has changed, we got to get rid of the old reference. + trustCert.key = NULL; + + storeAllKeys_locked(); return 1; } @@ -1750,9 +1758,44 @@ static gpg_error_t keySignCallback(void *opaque, gpgme_status_code_t status, \ static gpgme_error_t trustCallback(void *opaque, gpgme_status_code_t status, \ const char *args, int fd) { - class EditParams *params = (class EditParams *)opaque; - const char *result = NULL; - char *trustLvl = (char *)params->oParams; + class EditParams *params = (class EditParams *)opaque; + class TrustParams *tparams = (class TrustParams *)params->oParams; + const char *result = NULL; + + /* printf stuff out */ + if (status == GPGME_STATUS_EOF) + fprintf(stderr,"keySignCallback GPGME_STATUS_EOF\n"); + if (status == GPGME_STATUS_GOT_IT) + fprintf(stderr,"keySignCallback GPGME_STATUS_GOT_IT\n"); + if (status == GPGME_STATUS_USERID_HINT) + fprintf(stderr,"keySignCallback GPGME_STATUS_USERID_HINT\n"); + if (status == GPGME_STATUS_NEED_PASSPHRASE) + fprintf(stderr,"keySignCallback GPGME_STATUS_NEED_PASSPHRASE\n"); + if (status == GPGME_STATUS_GOOD_PASSPHRASE) + fprintf(stderr,"keySignCallback GPGME_STATUS_GOOD_PASSPHRASE\n"); + if (status == GPGME_STATUS_BAD_PASSPHRASE) + fprintf(stderr,"keySignCallback GPGME_STATUS_BAD_PASSPHRASE\n"); + if (status == GPGME_STATUS_GET_LINE) + fprintf(stderr,"keySignCallback GPGME_STATUS_GET_LINE\n"); + if (status == GPGME_STATUS_GET_BOOL) + fprintf(stderr,"keySignCallback GPGME_STATUS_GET_BOOL \n"); + if (status == GPGME_STATUS_ALREADY_SIGNED) + fprintf(stderr,"keySignCallback GPGME_STATUS_ALREADY_SIGNED\n"); + + /* printf stuff out */ + if (params->state == TRUST_START) + fprintf(stderr,"keySignCallback params->state TRUST_START\n"); + if (params->state == TRUST_COMMAND) + fprintf(stderr,"keySignCallback params->state TRUST_COMMAND\n"); + if (params->state == TRUST_VALUE) + fprintf(stderr,"keySignCallback params->state TRUST_VALUE\n"); + if (params->state == TRUST_REALLY_ULTIMATE) + fprintf(stderr,"keySignCallback params->state TRUST_REALLY_ULTIMATE\n"); + if (params->state == TRUST_QUIT) + fprintf(stderr,"keySignCallback params->state TRUST_QUIT\n"); + if (params->state == TRUST_ERROR) + fprintf(stderr,"keySignCallback params->state TRUST_ERROR\n"); + if(status == GPGME_STATUS_EOF || status == GPGME_STATUS_GOT_IT) { @@ -1777,7 +1820,7 @@ static gpgme_error_t trustCallback(void *opaque, gpgme_status_code_t status, \ if (status == GPGME_STATUS_GET_LINE && (!std::string("edit_ownertrust.value").compare(args))) { params->state = TRUST_VALUE; - result = trustLvl; + result = tparams->trustLvl.c_str();; } else { params->state = TRUST_ERROR; params->err = gpg_error (GPG_ERR_GENERAL); @@ -1844,6 +1887,7 @@ static gpgme_error_t trustCallback(void *opaque, gpgme_status_code_t status, \ WriteFile(winFd, result, strlen (result), &written, NULL); WriteFile(winFd, "\n", 1, &written, NULL); #endif + std::cerr << "trustCallback() result : " << result << std::endl; } return params->err; diff --git a/libretroshare/src/pqi/authgpg.h b/libretroshare/src/pqi/authgpg.h index 9b4e031c7..414466a2b 100644 --- a/libretroshare/src/pqi/authgpg.h +++ b/libretroshare/src/pqi/authgpg.h @@ -182,6 +182,7 @@ class AuthGPG bool TrustCertificateNone(std::string id); bool TrustCertificateMarginally(std::string id); bool TrustCertificateFully(std::string id); + bool TrustCertificate(std::string id, int trustlvl); //trustlvl is 2 for none, 3 for marginal and 4 for full trust /*********************************************************************************/ /************************* STAGE 7 ***********************************************/ @@ -296,4 +297,16 @@ class SignParams } }; +/* Data specific to key signing */ +class TrustParams +{ + public: + + std::string trustLvl; + + TrustParams(std::string trustLvl) { + this->trustLvl = trustLvl; + } +}; + #endif diff --git a/libretroshare/src/rsiface/rspeers.h b/libretroshare/src/rsiface/rspeers.h index fafbf9867..697a9ebcd 100644 --- a/libretroshare/src/rsiface/rspeers.h +++ b/libretroshare/src/rsiface/rspeers.h @@ -76,6 +76,7 @@ class RsPeerDetails RsPeerDetails(); /* Auth details */ + bool isOnlyGPGdetail; std::string id; std::string name; std::string email; @@ -137,22 +138,23 @@ virtual bool isOnline(std::string id) = 0; virtual bool isFriend(std::string id) = 0; virtual std::string getPeerName(std::string id) = 0; virtual std::string getPeerPGPName(std::string pgp_id) = 0; -virtual bool getPeerDetails(std::string id, RsPeerDetails &d) = 0; +virtual bool getPeerDetails(std::string id, RsPeerDetails &d) = 0; //get Peer detail accept SSL and PGP certs /* 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 getPGPAcceptedList(std::list &ids) = 0; +virtual bool getPGPSignedList(std::list &ids) = 0;//friends that we accpet to connect with but we don't want to sign their gpg key +virtual bool getPGPValidList(std::list &ids) = 0; virtual bool getPGPAllList(std::list &ids) = 0; virtual bool getPGPDetails(std::string id, RsPeerDetails &d) = 0; +virtual bool getPGPFriendList(std::list &ids) = 0; + /* Add/Remove Friends */ virtual bool addFriend(std::string id) = 0; virtual bool removeFriend(std::string id) = 0; - /* get/set third party info about who trusts me */ -virtual bool isTrustingMe(std::string id) const = 0 ; - /* Network Stuff */ virtual bool connectAttempt(std::string id) = 0; virtual bool setLocalAddress(std::string id, std::string addr, uint16_t port) = 0; @@ -175,7 +177,7 @@ virtual bool SaveCertificateToFile(std::string id, std::string fname) = 0; virtual std::string SaveCertificateToString(std::string id) = 0; virtual bool SignGPGCertificate(std::string id) = 0; -virtual bool TrustCertificate(std::string id, bool trust) = 0; +virtual bool TrustGPGCertificate(std::string id, uint32_t trustlvl) = 0; }; diff --git a/libretroshare/src/rsserver/p3peers.cc b/libretroshare/src/rsserver/p3peers.cc index fefcc2414..22cefe2c3 100644 --- a/libretroshare/src/rsserver/p3peers.cc +++ b/libretroshare/src/rsserver/p3peers.cc @@ -259,11 +259,6 @@ bool p3Peers::isOnline(std::string id) return false; } -bool p3Peers::isTrustingMe(std::string id) const -{ - return AuthSSL::getAuthSSL()->isTrustingMe(id) ; -} - bool p3Peers::isFriend(std::string id) { #ifdef P3PEERS_DEBUG @@ -300,9 +295,17 @@ bool p3Peers::getPeerDetails(std::string id, RsPeerDetails &d) std::cerr << "p3Peers::getPeerDetails() " << id; std::cerr << std::endl; #endif + //first, check if it's a gpg or a ssl id. + if (AuthSSL::getAuthSSL()->getGPGId(id) == "") { + //assume is not SSL, because every ssl_id has got a pgp_id + d.isOnlyGPGdetail = true; + return this->getPGPDetails(id, d); + } /* get from gpg (first), to fill in the sign and trust details */ + /* don't retrun now, we've got fill in the ssl and connection info */ this->getPGPDetails(AuthSSL::getAuthSSL()->getGPGId(id), d); + d.isOnlyGPGdetail = false; //get the ssl details sslcert authDetail; @@ -533,8 +536,6 @@ bool p3Peers::getPGPFriendList(std::list &ids) return true; } - - bool p3Peers::getPGPAllList(std::list &ids) { #ifdef P3PEERS_DEBUG @@ -547,6 +548,42 @@ bool p3Peers::getPGPAllList(std::list &ids) return true; } +bool p3Peers::getPGPValidList(std::list &ids) +{ +#ifdef P3PEERS_DEBUG + std::cerr << "p3Peers::getPGPOthersList()"; + std::cerr << std::endl; +#endif + + /* get from mAuthMgr */ + AuthGPG::getAuthGPG()->getPGPValidList(ids); + return true; +} + +bool p3Peers::getPGPSignedList(std::list &ids) +{ +#ifdef P3PEERS_DEBUG + std::cerr << "p3Peers::getPGPOthersList()"; + std::cerr << std::endl; +#endif + + /* get from mAuthMgr */ + AuthGPG::getAuthGPG()->getPGPSignedList(ids); + return true; +} + +bool p3Peers::getPGPAcceptedList(std::list &ids) +{ +#ifdef P3PEERS_DEBUG + std::cerr << "p3Peers::getPGPOthersList()"; + std::cerr << std::endl; +#endif + + /* get from mAuthMgr */ + AuthGPG::getAuthGPG()->getPGPSignedList(ids); + return true; +} + bool p3Peers::getPGPDetails(std::string id, RsPeerDetails &d) { #ifdef P3PEERS_DEBUG @@ -903,18 +940,22 @@ bool p3Peers::SignGPGCertificate(std::string id) return AuthGPG::getAuthGPG()->SignCertificateLevel0(id); } -bool p3Peers::TrustCertificate(std::string id, bool trust) +bool p3Peers::TrustGPGCertificate(std::string id, uint32_t trustlvl) { #ifdef P3PEERS_DEBUG std::cerr << "p3Peers::TrustCertificate() " << id; std::cerr << std::endl; #endif - - return AuthSSL::getAuthSSL()->TrustCertificate(id, trust); + //check if we've got a ssl or gpg id + if (AuthSSL::getAuthSSL()->getGPGId(id) == "") { + //if no result then it must be a gpg id + return AuthGPG::getAuthGPG()->TrustCertificate(id, trustlvl); + } else { + return AuthGPG::getAuthGPG()->TrustCertificate(AuthSSL::getAuthSSL()->getGPGId(id), trustlvl); + } } - int ensureExtension(std::string &name, std::string def_ext) { /* if it has an extension, don't change */ diff --git a/libretroshare/src/rsserver/p3peers.h b/libretroshare/src/rsserver/p3peers.h index a3c964f2a..f980089b8 100644 --- a/libretroshare/src/rsserver/p3peers.h +++ b/libretroshare/src/rsserver/p3peers.h @@ -56,18 +56,19 @@ 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 getPGPAcceptedList(std::list &ids); +virtual bool getPGPSignedList(std::list &ids); +virtual bool getPGPValidList(std::list &ids); virtual bool getPGPAllList(std::list &ids); virtual bool getPGPDetails(std::string id, RsPeerDetails &d); +virtual bool getPGPFriendList(std::list &ids); + /* Add/Remove Friends */ virtual bool addFriend(std::string id); virtual bool removeFriend(std::string id); - /* get/set third party info about who trusts me */ -virtual bool isTrustingMe(std::string id) const ; - /* Network Stuff */ virtual bool connectAttempt(std::string id); virtual bool setLocalAddress(std::string id, std::string addr, uint16_t port); @@ -90,7 +91,7 @@ virtual bool SaveCertificateToFile(std::string id, std::string fname); virtual std::string SaveCertificateToString(std::string id); virtual bool SignGPGCertificate(std::string id); -virtual bool TrustCertificate(std::string id, bool trust); +virtual bool TrustGPGCertificate(std::string id, uint32_t trustlvl); private: diff --git a/retroshare-gui/src/gui/NetworkDialog.cpp b/retroshare-gui/src/gui/NetworkDialog.cpp index c540a3c66..cf333f23d 100644 --- a/retroshare-gui/src/gui/NetworkDialog.cpp +++ b/retroshare-gui/src/gui/NetworkDialog.cpp @@ -92,7 +92,10 @@ NetworkDialog::NetworkDialog(QWidget *parent) connectdialog = new ConnectDialog(); connect(ui.infoLog, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(displayInfoLogMenu(const QPoint&))); - + + connect(ui.showUnvalidKeys, SIGNAL(clicked()), this, SLOT(insertConnect())); + + /* hide the Tree +/- */ ui.connecttreeWidget -> setRootIsDecorated( false ); @@ -102,17 +105,20 @@ NetworkDialog::NetworkDialog(QWidget *parent) _header->setResizeMode (1, QHeaderView::Interactive); _header->setResizeMode (2, QHeaderView::Interactive); _header->setResizeMode (3, QHeaderView::Interactive); + _header->setResizeMode (4, QHeaderView::Interactive); _header->resizeSection ( 0, 25 ); _header->resizeSection ( 1, 200 ); _header->resizeSection ( 2, 200 ); + _header->resizeSection ( 3, 200 ); // set header text aligment QTreeWidgetItem * headerItem = ui.connecttreeWidget->headerItem(); headerItem->setTextAlignment(0, Qt::AlignHCenter | Qt::AlignVCenter); headerItem->setTextAlignment(1, Qt::AlignHCenter | Qt::AlignVCenter); headerItem->setTextAlignment(2, Qt::AlignHCenter | Qt::AlignVCenter); - headerItem->setTextAlignment(3, Qt::AlignVCenter); + headerItem->setTextAlignment(3, Qt::AlignHCenter | Qt::AlignVCenter); + headerItem->setTextAlignment(4, Qt::AlignVCenter); ui.networkTab->addTab(new NetworkView(),QString(tr("Network View"))); ui.networkTab->addTab(new TrustView(),QString(tr("Trust matrix"))); @@ -178,7 +184,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(3).toStdString() ; + std::string peer_id = wi->text(4).toStdString() ; // That's what context menus are made for RsPeerDetails detail; @@ -229,7 +235,7 @@ void NetworkDialog::connecttreeWidgetCostumPopupMenu( QPoint point ) void NetworkDialog::denyFriend() { QTreeWidgetItem *wi = getCurrentNeighbour(); - std::string peer_id = wi->text(3).toStdString() ; + std::string peer_id = wi->text(4).toStdString() ; rsPeers->removeFriend(peer_id) ; insertConnect() ; @@ -252,7 +258,7 @@ void NetworkDialog::deleteCert() void NetworkDialog::makeFriend() { QTreeWidgetItem *wi = getCurrentNeighbour(); - std::string authId = wi->text(3).toStdString() ; + std::string authId = wi->text(4).toStdString() ; rsPeers->SignGPGCertificate(authId); rsPeers->addFriend(authId); @@ -263,7 +269,7 @@ void NetworkDialog::makeFriend() /** Shows Peer Information/Auth Dialog */ void NetworkDialog::peerdetails() { - ConfCertDialog::show(getCurrentNeighbour()->text(3).toStdString()); + ConfCertDialog::show(getCurrentNeighbour()->text(4).toStdString()); } /** Shows Peer Information/Auth Dialog */ @@ -341,7 +347,11 @@ void NetworkDialog::insertConnect() std::list neighs; //these are GPG ids std::list::iterator it; - rsPeers->getPGPAllList(neighs); + if (ui.showUnvalidKeys->isChecked()) { + rsPeers->getPGPAllList(neighs); + } else { + rsPeers->getPGPValidList(neighs); + } /* get a link to the table */ QTreeWidget *connectWidget = ui.connecttreeWidget; @@ -350,7 +360,7 @@ void NetworkDialog::insertConnect() std::string oldId; if (oldSelect) { - oldId = (oldSelect -> text(3)).toStdString(); + oldId = (oldSelect -> text(4)).toStdString(); } RsPeerDetails ownGPGDetails ; @@ -377,15 +387,26 @@ void NetworkDialog::insertConnect() /* (1) Person */ item -> setText(1, QString::fromStdString(detail.name)); - /* (2) has me auth */ + /* (2) Key validity */ + if (detail.validLvl == 3) { + item -> setText(2, tr("Marginnal")); + } else if (detail.validLvl == 4) { + item -> setText(2, tr("Full")); + } else if (detail.validLvl == 5) { + item -> setText(2, tr("Ultimate")); + } else{ + item -> setText(2, tr("None")); + } + + /* (3) has me auth */ if (detail.hasSignedMe) - item -> setText(2, tr("Has authenticated me")); + item -> setText(3, tr("Has authenticated me")); else - item -> setText(2, tr("Unknown")); + item -> setText(3, tr("Unknown")); - /* (3) key id */ + /* (4) key id */ { - item -> setText(3, QString::fromStdString(detail.id)); + item -> setText(4, QString::fromStdString(detail.id)); if ((oldSelect) && (oldId == detail.id)) { newSelect = item; @@ -410,7 +431,7 @@ void NetworkDialog::insertConnect() backgrndcolor=Qt::magenta; item -> setIcon(0,(QIcon(IMAGE_TRUSTED))); for(int k=0;k<8;++k) - item -> setToolTip(k,QString::fromStdString(detail.name) + QString(tr(" has authenticaed you. \nRight-click and select 'make friend' to be able to connect."))) ; + item -> setToolTip(k,QString::fromStdString(detail.name) + QString(tr(" has authenticated you. \nRight-click and select 'make friend' to be able to connect."))) ; } else { @@ -434,7 +455,7 @@ void NetworkDialog::insertConnect() self_item->setText(1,QString::fromStdString(ownGPGDetails.name) + " (yourself)") ; self_item->setText(2,"N/A"); - self_item->setText(3, QString::fromStdString(ownGPGDetails.id)); + self_item->setText(4, QString::fromStdString(ownGPGDetails.id)); // Color each Background column in the Network Tab except the first one => 1-9 for(int i=1;i<10;++i) @@ -447,7 +468,7 @@ void NetworkDialog::insertConnect() /* remove old items ??? */ connectWidget->clear(); - connectWidget->setColumnCount(4); + connectWidget->setColumnCount(5); /* add the items in! */ connectWidget->insertTopLevelItems(0, items); @@ -482,14 +503,14 @@ QTreeWidgetItem *NetworkDialog::getCurrentNeighbour() /* Utility Fns */ RsCertId getNeighRsCertId(QTreeWidgetItem *i) { - RsCertId id = (i -> text(3)).toStdString(); + RsCertId id = (i -> text(4)).toStdString(); return id; } /* So from the Neighbours Dialog we can call the following control Functions: * (1) Load Certificate NeighLoadCertificate(std::string file) * (2) Neigh Auth NeighAuthFriend(id, code) - * (3) Neigh Add NeighAddFriend(id) + * (4) Neigh Add NeighAddFriend(id) * * All of these rely on the finding of the current Id. */ diff --git a/retroshare-gui/src/gui/NetworkDialog.ui b/retroshare-gui/src/gui/NetworkDialog.ui index ce906a7de..6758a60c1 100644 --- a/retroshare-gui/src/gui/NetworkDialog.ui +++ b/retroshare-gui/src/gui/NetworkDialog.ui @@ -95,18 +95,9 @@ true - - true - - - 200 - - - true - - + @@ -116,7 +107,12 @@ - Peer's trust + GPG key validity + + + + + Did peer authenticated me @@ -171,7 +167,7 @@ p, li { white-space: pre-wrap; } - + Qt::Horizontal @@ -184,7 +180,7 @@ p, li { white-space: pre-wrap; } - + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> @@ -216,6 +212,13 @@ subcontrol-position: bottom right; + + + + Show keys that are not validated by the GPG web of trust + + + diff --git a/retroshare-gui/src/gui/connect/ConfCertDialog.cpp b/retroshare-gui/src/gui/connect/ConfCertDialog.cpp index 2907202c8..4cdef024f 100644 --- a/retroshare-gui/src/gui/connect/ConfCertDialog.cpp +++ b/retroshare-gui/src/gui/connect/ConfCertDialog.cpp @@ -94,22 +94,18 @@ void ConfCertDialog::loadId(std::string id) void ConfCertDialog::loadDialog() { - isPGPId = false; RsPeerDetails detail; if (!rsPeers->getPeerDetails(mId, detail)) { - isPGPId = true; - if (!rsPeers->getPGPDetails(mId, detail)) { - QMessageBox::information(this, - tr("RetroShare"), - tr("Error : cannot get peer details.")); - this->close(); - } + QMessageBox::information(this, + tr("RetroShare"), + tr("Error : cannot get peer details.")); + closeinfodlg(); } ui.name->setText(QString::fromStdString(detail.name)); ui.peerid->setText(QString::fromStdString(detail.id)); - if (!isPGPId) { + if (!detail.isOnlyGPGdetail) { ui.orgloc->setText(QString::fromStdString(detail.org)); ui.country->setText(QString::fromStdString(detail.location)); // Dont Show a timestamp in RS calculate the day @@ -160,19 +156,6 @@ void ConfCertDialog::loadDialog() ui.groupBox->hide(); } - /* set the url for DNS access (OLD) */ - //ui.extName->setText(QString::fromStdString("")); - - /**** TODO ****/ - //ui.chkFirewall ->setChecked(ni->firewalled); - //ui.chkForwarded ->setChecked(ni->forwardPort); - //ui.chkFirewall ->setChecked(0); - //ui.chkForwarded ->setChecked(0); - - //ui.indivRate->setValue(0); - - //ui.trustLvl->setText(QString::fromStdString(RsPeerTrustString(detail.trustLvl))); - if (detail.ownsign) { ui.sign_button->hide(); ui.signed_already_label->show(); @@ -182,9 +165,37 @@ void ConfCertDialog::loadDialog() } if (detail.hasSignedMe) { - ui.is_signing_me->setText(tr("Peer has acepted me as a friend and did signed my GPG key")); + 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 acepted me as a friend and did not signed my GPG key")); + 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.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, it means he has an excellent understanding of key signing, and his signature on a key would be as good as your own.")); + 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, it means he understands the implications of key signing and properly check keys before signing them.")); + 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, it means he is known to improperly sign other keys.")); + 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); + } } ui.signers->clear() ; @@ -199,42 +210,54 @@ void ConfCertDialog::loadDialog() void ConfCertDialog::applyDialog() { - std::cerr << "In apply dialog" << std::endl ; - RsPeerDetails detail; + std::cerr << "ConfCertDialog::applyDialog() called" << std::endl ; + RsPeerDetails detail; if (!rsPeers->getPeerDetails(mId, detail)) { - std::cerr << "Could not get details from " << mId << std::endl ; - /* fail */ - return; - } + if (!rsPeers->getPGPDetails(mId, detail)) { + QMessageBox::information(this, + tr("RetroShare"), + tr("Error : cannot get peer details.")); + closeinfodlg(); + } + } - /* check if the data is the same */ - bool localChanged = false; - bool extChanged = false; - bool fwChanged = false; + //check the GPG trustlvl + if (ui.radioButton_trust_fully->isChecked() && detail.trustLvl != 4) { + //trust has changed to fully + rsPeers->TrustGPGCertificate(detail.id, 4); + } else if (ui.radioButton_trust_marginnaly->isChecked() && detail.trustLvl != 3) { + rsPeers->TrustGPGCertificate(detail.id, 3); - /* set local address */ - if ((detail.localAddr != ui.localAddress->text().toStdString()) || (detail.localPort != ui.localPort -> value())) - localChanged = true; + } else if (ui.radioButton_trust_never->isChecked() && detail.trustLvl != 2) { + rsPeers->TrustGPGCertificate(detail.id, 2); + } - if ((detail.extAddr != ui.extAddress->text().toStdString()) || (detail.extPort != ui.extPort -> value())) - extChanged = true; + if (!detail.isOnlyGPGdetail) { + /* check if the data is the same */ + bool localChanged = false; + bool extChanged = false; + bool fwChanged = false; - /* now we can action the changes */ - if (localChanged) - rsPeers->setLocalAddress(mId, ui.localAddress->text().toStdString(), ui.localPort->value()); + /* set local address */ + if ((detail.localAddr != ui.localAddress->text().toStdString()) || (detail.localPort != ui.localPort -> value())) + localChanged = true; - if (extChanged) - rsPeers->setExtAddress(mId,ui.extAddress->text().toStdString(), ui.extPort->value()); + if ((detail.extAddr != ui.extAddress->text().toStdString()) || (detail.extPort != ui.extPort -> value())) + extChanged = true; - /* reload now */ - loadDialog(); + /* now we can action the changes */ + if (localChanged) + rsPeers->setLocalAddress(mId, ui.localAddress->text().toStdString(), ui.localPort->value()); - /* close the Dialog after the Changes applied */ - closeinfodlg(); + if (extChanged) + rsPeers->setExtAddress(mId,ui.extAddress->text().toStdString(), ui.extPort->value()); - if(localChanged || extChanged) - emit configChanged() ; + if(localChanged || extChanged) + emit configChanged() ; + } + + closeinfodlg(); } void ConfCertDialog::makeFriend() diff --git a/retroshare-gui/src/gui/connect/ConfCertDialog.ui b/retroshare-gui/src/gui/connect/ConfCertDialog.ui index f14091bb4..575cb7e15 100644 --- a/retroshare-gui/src/gui/connect/ConfCertDialog.ui +++ b/retroshare-gui/src/gui/connect/ConfCertDialog.ui @@ -7,7 +7,7 @@ 0 0 506 - 523 + 529 @@ -21,7 +21,7 @@ - 0 + 1 @@ -243,6 +243,19 @@ + + + + Qt::Vertical + + + + 20 + 40 + + + + @@ -263,7 +276,7 @@ - Key signing settings + GPG Key signing settings @@ -303,14 +316,69 @@ - + + + true + + + + 0 + 50 + + + + + true + + + + GPG Web of Trust + + + + + + Your trust in this peer is : + + + + + + + + + None + + + + + + + Marginnaly + + + + + + + Fully + + + + + + + + + + Qt::Vertical - 451 - 131 + 20 + 40 diff --git a/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp b/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp index 3f5a00f95..9efaf992b 100755 --- a/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp +++ b/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp @@ -499,8 +499,8 @@ void FofPage::updatePeersList(int e) break ; case 1: // "Unsigned peers who already signed my certificate" - show = rsPeers->isTrustingMe(details.id) && !(details.state & RS_PEER_STATE_FRIEND) ; - std::cerr << "case 1, ownsign=" << details.ownsign << ", is_trusting_me=" << rsPeers->isTrustingMe(details.id) << ", show=" << show << std::endl ; + show = details.hasSignedMe && !(details.state & RS_PEER_STATE_FRIEND) ; + std::cerr << "case 1, ownsign=" << details.ownsign << ", is_authed_me=" << details.hasSignedMe << ", show=" << show << std::endl ; break ; case 0: // "All unsigned friends of my friends"