implement the trust settings in the gui

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@2012 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
joss17 2010-01-13 21:14:49 +00:00
parent dabe44356a
commit 1ae1c9a98b
10 changed files with 362 additions and 146 deletions

View File

@ -29,6 +29,8 @@
#include <iostream> #include <iostream>
#include <sstream> #include <sstream>
#include <algorithm> #include <algorithm>
#include <boost/lexical_cast.hpp>
// initialisation du pointeur de singleton à zéro // initialisation du pointeur de singleton à zéro
AuthGPG *AuthGPG::instance_gpg = new AuthGPG(); AuthGPG *AuthGPG::instance_gpg = new AuthGPG();
@ -60,7 +62,7 @@ gpgcert::~gpgcert()
{ {
if (key) 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 // store all keys in map mKeyList to avoid callin gpgme exe repeatedly
bool AuthGPG::storeAllKeys_locked() bool AuthGPG::storeAllKeys_locked()
@ -326,7 +313,7 @@ bool AuthGPG::storeAllKeys_locked()
std::cerr << "AuthGPG::storeAllKeys_locked() clearing existing ones"; std::cerr << "AuthGPG::storeAllKeys_locked() clearing existing ones";
std::cerr << std::endl; std::cerr << std::endl;
mKeyList.clear(); mKeyList.clear();
/* enable SIG mode */ /* enable SIG mode */
gpgme_keylist_mode_t origmode = gpgme_get_keylist_mode(CTX); gpgme_keylist_mode_t origmode = gpgme_get_keylist_mode(CTX);
@ -410,9 +397,7 @@ bool AuthGPG::storeAllKeys_locked()
{ {
nu.signers.push_back(keyid); nu.signers.push_back(keyid);
} }
std::cerr << "keyid: " << keyid << std::endl; if (keyid == mOwnGpgId) {
std::cerr << "mOwnGpgId: " << mOwnGpgId << std::endl;
if (keyid == mOwnGpgId) {
nu.ownsign = true; nu.ownsign = true;
} }
} }
@ -614,7 +599,7 @@ bool AuthGPG::printOwnKeys_locked()
bool AuthGPG::printKeys() bool AuthGPG::printKeys()
{ {
//RsStackMutex stack(pgpMtx); /******* LOCKED ******/ RsStackMutex stack(pgpMtx); /******* LOCKED ******/
printAllKeys_locked(); printAllKeys_locked();
return printOwnKeys_locked(); return printOwnKeys_locked();
} }
@ -860,7 +845,7 @@ int AuthGPG::setConfigDirectories(std::string confFile, std::string neighDir
/**** These Two are common */ /**** These Two are common */
std::string AuthGPG::getPGPName(GPG_id id) std::string AuthGPG::getPGPName(GPG_id id)
{ {
//RsStackMutex stack(pgpMtx); /******* LOCKED ******/ RsStackMutex stack(pgpMtx); /******* LOCKED ******/
certmap::iterator it; certmap::iterator it;
if (mKeyList.end() != (it = mKeyList.find(id))) if (mKeyList.end() != (it = mKeyList.find(id)))
@ -872,7 +857,7 @@ std::string AuthGPG::getPGPName(GPG_id id)
/**** These Two are common */ /**** These Two are common */
std::string AuthGPG::getPGPEmail(GPG_id id) std::string AuthGPG::getPGPEmail(GPG_id id)
{ {
//RsStackMutex stack(pgpMtx); /******* LOCKED ******/ RsStackMutex stack(pgpMtx); /******* LOCKED ******/
certmap::iterator it; certmap::iterator it;
if (mKeyList.end() != (it = mKeyList.find(id))) if (mKeyList.end() != (it = mKeyList.find(id)))
@ -892,7 +877,7 @@ std::string AuthGPG::PGPOwnId()
bool AuthGPG::getPGPAllList(std::list<std::string> &ids) bool AuthGPG::getPGPAllList(std::list<std::string> &ids)
{ {
//RsStackMutex stack(pgpMtx); /******* LOCKED ******/ RsStackMutex stack(pgpMtx); /******* LOCKED ******/
/* add an id for each pgp certificate */ /* add an id for each pgp certificate */
certmap::iterator it; certmap::iterator it;
@ -903,9 +888,24 @@ bool AuthGPG::getPGPAllList(std::list<std::string> &ids)
return true; return true;
} }
bool AuthGPG::getPGPValidList(std::list<std::string> &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) bool AuthGPG::getPGPDetails(std::string id, RsPeerDetails &d)
{ {
//RsStackMutex stack(pgpMtx); /******* LOCKED ******/ RsStackMutex stack(pgpMtx); /******* LOCKED ******/
/* add an id for each pgp certificate */ /* add an id for each pgp certificate */
certmap::iterator it; certmap::iterator it;
@ -1193,8 +1193,6 @@ bool AuthGPG::RevokeCertificate(std::string id)
bool AuthGPG::TrustCertificateMarginally(std::string id) bool AuthGPG::TrustCertificateMarginally(std::string id)
{ {
RsStackMutex stack(pgpMtx); /******* LOCKED ******/
std::cerr << "AuthGPG::TrustCertificateMarginally(" << id << ")"; std::cerr << "AuthGPG::TrustCertificateMarginally(" << id << ")";
std::cerr << std::endl; std::cerr << std::endl;
//TODO implement it //TODO implement it
@ -1202,6 +1200,12 @@ bool AuthGPG::TrustCertificateMarginally(std::string id)
return false; 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) bool AuthGPG::SignData(std::string input, std::string &sign)
{ {
return false; return false;
@ -1263,8 +1267,7 @@ int AuthGPG::privateSignCertificate(std::string id)
} }
if(GPG_ERR_NO_ERROR != (ERR = gpgme_op_edit(CTX, signKey, keySignCallback, \ if(GPG_ERR_NO_ERROR != (ERR = gpgme_op_edit(CTX, signKey, keySignCallback, &params, out))) {
&params, out))) {
return 0; return 0;
} }
@ -1294,8 +1297,8 @@ int AuthGPG::privateTrustCertificate(std::string id, int trustlvl)
gpgcert trustCert = mKeyList.find(id)->second; gpgcert trustCert = mKeyList.find(id)->second;
gpgme_key_t trustKey = trustCert.key; gpgme_key_t trustKey = trustCert.key;
const char *lvls[] = {"1", "2", "3", "4", "5"}; class TrustParams sparams((boost::lexical_cast<std::string>(trustlvl)));
class EditParams params(TRUST_START, (void *) *(lvls + trustlvl -1)); class EditParams params(TRUST_START, &sparams);
gpgme_data_t out; gpgme_data_t out;
gpg_error_t ERR; 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, &params, out))) if(GPG_ERR_NO_ERROR != (ERR = gpgme_op_edit(CTX, trustKey, trustCallback, &params, out)))
return 0; return 0;
//the key ref has changed, we got to get rid of the old reference.
trustCert.key = NULL;
storeAllKeys_locked();
return 1; 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, \ static gpgme_error_t trustCallback(void *opaque, gpgme_status_code_t status, \
const char *args, int fd) { const char *args, int fd) {
class EditParams *params = (class EditParams *)opaque; class EditParams *params = (class EditParams *)opaque;
const char *result = NULL; class TrustParams *tparams = (class TrustParams *)params->oParams;
char *trustLvl = (char *)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 || if(status == GPGME_STATUS_EOF ||
status == GPGME_STATUS_GOT_IT) { 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 && if (status == GPGME_STATUS_GET_LINE &&
(!std::string("edit_ownertrust.value").compare(args))) { (!std::string("edit_ownertrust.value").compare(args))) {
params->state = TRUST_VALUE; params->state = TRUST_VALUE;
result = trustLvl; result = tparams->trustLvl.c_str();;
} else { } else {
params->state = TRUST_ERROR; params->state = TRUST_ERROR;
params->err = gpg_error (GPG_ERR_GENERAL); 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, result, strlen (result), &written, NULL);
WriteFile(winFd, "\n", 1, &written, NULL); WriteFile(winFd, "\n", 1, &written, NULL);
#endif #endif
std::cerr << "trustCallback() result : " << result << std::endl;
} }
return params->err; return params->err;

View File

@ -182,6 +182,7 @@ class AuthGPG
bool TrustCertificateNone(std::string id); bool TrustCertificateNone(std::string id);
bool TrustCertificateMarginally(std::string id); bool TrustCertificateMarginally(std::string id);
bool TrustCertificateFully(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 ***********************************************/ /************************* 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 #endif

View File

@ -76,6 +76,7 @@ class RsPeerDetails
RsPeerDetails(); RsPeerDetails();
/* Auth details */ /* Auth details */
bool isOnlyGPGdetail;
std::string id; std::string id;
std::string name; std::string name;
std::string email; std::string email;
@ -137,22 +138,23 @@ virtual bool isOnline(std::string id) = 0;
virtual bool isFriend(std::string id) = 0; virtual bool isFriend(std::string id) = 0;
virtual std::string getPeerName(std::string id) = 0; virtual std::string getPeerName(std::string id) = 0;
virtual std::string getPeerPGPName(std::string pgp_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 */ /* Using PGP Ids */
virtual std::string getPGPOwnId() = 0; virtual std::string getPGPOwnId() = 0;
virtual std::string getPGPId(std::string ssl_id) = 0; virtual std::string getPGPId(std::string ssl_id) = 0;
virtual bool getPGPFriendList(std::list<std::string> &ids) = 0; virtual bool getPGPAcceptedList(std::list<std::string> &ids) = 0;
virtual bool getPGPSignedList(std::list<std::string> &ids) = 0;//friends that we accpet to connect with but we don't want to sign their gpg key
virtual bool getPGPValidList(std::list<std::string> &ids) = 0;
virtual bool getPGPAllList(std::list<std::string> &ids) = 0; virtual bool getPGPAllList(std::list<std::string> &ids) = 0;
virtual bool getPGPDetails(std::string id, RsPeerDetails &d) = 0; virtual bool getPGPDetails(std::string id, RsPeerDetails &d) = 0;
virtual bool getPGPFriendList(std::list<std::string> &ids) = 0;
/* Add/Remove Friends */ /* Add/Remove Friends */
virtual bool addFriend(std::string id) = 0; virtual bool addFriend(std::string id) = 0;
virtual bool removeFriend(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 */ /* Network Stuff */
virtual bool connectAttempt(std::string id) = 0; virtual bool connectAttempt(std::string id) = 0;
virtual bool setLocalAddress(std::string id, std::string addr, uint16_t port) = 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 std::string SaveCertificateToString(std::string id) = 0;
virtual bool SignGPGCertificate(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;
}; };

View File

@ -259,11 +259,6 @@ bool p3Peers::isOnline(std::string id)
return false; return false;
} }
bool p3Peers::isTrustingMe(std::string id) const
{
return AuthSSL::getAuthSSL()->isTrustingMe(id) ;
}
bool p3Peers::isFriend(std::string id) bool p3Peers::isFriend(std::string id)
{ {
#ifdef P3PEERS_DEBUG #ifdef P3PEERS_DEBUG
@ -300,9 +295,17 @@ bool p3Peers::getPeerDetails(std::string id, RsPeerDetails &d)
std::cerr << "p3Peers::getPeerDetails() " << id; std::cerr << "p3Peers::getPeerDetails() " << id;
std::cerr << std::endl; std::cerr << std::endl;
#endif #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 */ /* 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); this->getPGPDetails(AuthSSL::getAuthSSL()->getGPGId(id), d);
d.isOnlyGPGdetail = false;
//get the ssl details //get the ssl details
sslcert authDetail; sslcert authDetail;
@ -533,8 +536,6 @@ bool p3Peers::getPGPFriendList(std::list<std::string> &ids)
return true; return true;
} }
bool p3Peers::getPGPAllList(std::list<std::string> &ids) bool p3Peers::getPGPAllList(std::list<std::string> &ids)
{ {
#ifdef P3PEERS_DEBUG #ifdef P3PEERS_DEBUG
@ -547,6 +548,42 @@ bool p3Peers::getPGPAllList(std::list<std::string> &ids)
return true; return true;
} }
bool p3Peers::getPGPValidList(std::list<std::string> &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<std::string> &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<std::string> &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) bool p3Peers::getPGPDetails(std::string id, RsPeerDetails &d)
{ {
#ifdef P3PEERS_DEBUG #ifdef P3PEERS_DEBUG
@ -903,18 +940,22 @@ bool p3Peers::SignGPGCertificate(std::string id)
return AuthGPG::getAuthGPG()->SignCertificateLevel0(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 #ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::TrustCertificate() " << id; std::cerr << "p3Peers::TrustCertificate() " << id;
std::cerr << std::endl; std::cerr << std::endl;
#endif #endif
//check if we've got a ssl or gpg id
return AuthSSL::getAuthSSL()->TrustCertificate(id, trust); 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) int ensureExtension(std::string &name, std::string def_ext)
{ {
/* if it has an extension, don't change */ /* if it has an extension, don't change */

View File

@ -56,18 +56,19 @@ virtual bool getPeerDetails(std::string id, RsPeerDetails &d);
/* Using PGP Ids */ /* Using PGP Ids */
virtual std::string getPGPOwnId(); virtual std::string getPGPOwnId();
virtual std::string getPGPId(std::string ssl_id); virtual std::string getPGPId(std::string ssl_id);
virtual bool getPGPFriendList(std::list<std::string> &ids); virtual bool getPGPAcceptedList(std::list<std::string> &ids);
virtual bool getPGPSignedList(std::list<std::string> &ids);
virtual bool getPGPValidList(std::list<std::string> &ids);
virtual bool getPGPAllList(std::list<std::string> &ids); virtual bool getPGPAllList(std::list<std::string> &ids);
virtual bool getPGPDetails(std::string id, RsPeerDetails &d); virtual bool getPGPDetails(std::string id, RsPeerDetails &d);
virtual bool getPGPFriendList(std::list<std::string> &ids);
/* Add/Remove Friends */ /* Add/Remove Friends */
virtual bool addFriend(std::string id); virtual bool addFriend(std::string id);
virtual bool removeFriend(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 */ /* Network Stuff */
virtual bool connectAttempt(std::string id); virtual bool connectAttempt(std::string id);
virtual bool setLocalAddress(std::string id, std::string addr, uint16_t port); 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 std::string SaveCertificateToString(std::string id);
virtual bool SignGPGCertificate(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: private:

View File

@ -92,7 +92,10 @@ NetworkDialog::NetworkDialog(QWidget *parent)
connectdialog = new ConnectDialog(); connectdialog = new ConnectDialog();
connect(ui.infoLog, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(displayInfoLogMenu(const QPoint&))); connect(ui.infoLog, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(displayInfoLogMenu(const QPoint&)));
connect(ui.showUnvalidKeys, SIGNAL(clicked()), this, SLOT(insertConnect()));
/* hide the Tree +/- */ /* hide the Tree +/- */
ui.connecttreeWidget -> setRootIsDecorated( false ); ui.connecttreeWidget -> setRootIsDecorated( false );
@ -102,17 +105,20 @@ NetworkDialog::NetworkDialog(QWidget *parent)
_header->setResizeMode (1, QHeaderView::Interactive); _header->setResizeMode (1, QHeaderView::Interactive);
_header->setResizeMode (2, QHeaderView::Interactive); _header->setResizeMode (2, QHeaderView::Interactive);
_header->setResizeMode (3, QHeaderView::Interactive); _header->setResizeMode (3, QHeaderView::Interactive);
_header->setResizeMode (4, QHeaderView::Interactive);
_header->resizeSection ( 0, 25 ); _header->resizeSection ( 0, 25 );
_header->resizeSection ( 1, 200 ); _header->resizeSection ( 1, 200 );
_header->resizeSection ( 2, 200 ); _header->resizeSection ( 2, 200 );
_header->resizeSection ( 3, 200 );
// set header text aligment // set header text aligment
QTreeWidgetItem * headerItem = ui.connecttreeWidget->headerItem(); QTreeWidgetItem * headerItem = ui.connecttreeWidget->headerItem();
headerItem->setTextAlignment(0, Qt::AlignHCenter | Qt::AlignVCenter); headerItem->setTextAlignment(0, Qt::AlignHCenter | Qt::AlignVCenter);
headerItem->setTextAlignment(1, Qt::AlignHCenter | Qt::AlignVCenter); headerItem->setTextAlignment(1, Qt::AlignHCenter | Qt::AlignVCenter);
headerItem->setTextAlignment(2, 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 NetworkView(),QString(tr("Network View")));
ui.networkTab->addTab(new TrustView(),QString(tr("Trust matrix"))); 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 ); QMouseEvent *mevent = new QMouseEvent( QEvent::MouseButtonPress, point, Qt::RightButton, Qt::RightButton, Qt::NoModifier );
contextMnu.clear(); 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 // That's what context menus are made for
RsPeerDetails detail; RsPeerDetails detail;
@ -229,7 +235,7 @@ void NetworkDialog::connecttreeWidgetCostumPopupMenu( QPoint point )
void NetworkDialog::denyFriend() void NetworkDialog::denyFriend()
{ {
QTreeWidgetItem *wi = getCurrentNeighbour(); QTreeWidgetItem *wi = getCurrentNeighbour();
std::string peer_id = wi->text(3).toStdString() ; std::string peer_id = wi->text(4).toStdString() ;
rsPeers->removeFriend(peer_id) ; rsPeers->removeFriend(peer_id) ;
insertConnect() ; insertConnect() ;
@ -252,7 +258,7 @@ void NetworkDialog::deleteCert()
void NetworkDialog::makeFriend() void NetworkDialog::makeFriend()
{ {
QTreeWidgetItem *wi = getCurrentNeighbour(); QTreeWidgetItem *wi = getCurrentNeighbour();
std::string authId = wi->text(3).toStdString() ; std::string authId = wi->text(4).toStdString() ;
rsPeers->SignGPGCertificate(authId); rsPeers->SignGPGCertificate(authId);
rsPeers->addFriend(authId); rsPeers->addFriend(authId);
@ -263,7 +269,7 @@ void NetworkDialog::makeFriend()
/** Shows Peer Information/Auth Dialog */ /** Shows Peer Information/Auth Dialog */
void NetworkDialog::peerdetails() void NetworkDialog::peerdetails()
{ {
ConfCertDialog::show(getCurrentNeighbour()->text(3).toStdString()); ConfCertDialog::show(getCurrentNeighbour()->text(4).toStdString());
} }
/** Shows Peer Information/Auth Dialog */ /** Shows Peer Information/Auth Dialog */
@ -341,7 +347,11 @@ void NetworkDialog::insertConnect()
std::list<std::string> neighs; //these are GPG ids std::list<std::string> neighs; //these are GPG ids
std::list<std::string>::iterator it; std::list<std::string>::iterator it;
rsPeers->getPGPAllList(neighs); if (ui.showUnvalidKeys->isChecked()) {
rsPeers->getPGPAllList(neighs);
} else {
rsPeers->getPGPValidList(neighs);
}
/* get a link to the table */ /* get a link to the table */
QTreeWidget *connectWidget = ui.connecttreeWidget; QTreeWidget *connectWidget = ui.connecttreeWidget;
@ -350,7 +360,7 @@ void NetworkDialog::insertConnect()
std::string oldId; std::string oldId;
if (oldSelect) if (oldSelect)
{ {
oldId = (oldSelect -> text(3)).toStdString(); oldId = (oldSelect -> text(4)).toStdString();
} }
RsPeerDetails ownGPGDetails ; RsPeerDetails ownGPGDetails ;
@ -377,15 +387,26 @@ void NetworkDialog::insertConnect()
/* (1) Person */ /* (1) Person */
item -> setText(1, QString::fromStdString(detail.name)); 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) if (detail.hasSignedMe)
item -> setText(2, tr("Has authenticated me")); item -> setText(3, tr("Has authenticated me"));
else 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)) if ((oldSelect) && (oldId == detail.id))
{ {
newSelect = item; newSelect = item;
@ -410,7 +431,7 @@ void NetworkDialog::insertConnect()
backgrndcolor=Qt::magenta; backgrndcolor=Qt::magenta;
item -> setIcon(0,(QIcon(IMAGE_TRUSTED))); item -> setIcon(0,(QIcon(IMAGE_TRUSTED)));
for(int k=0;k<8;++k) 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 else
{ {
@ -434,7 +455,7 @@ void NetworkDialog::insertConnect()
self_item->setText(1,QString::fromStdString(ownGPGDetails.name) + " (yourself)") ; self_item->setText(1,QString::fromStdString(ownGPGDetails.name) + " (yourself)") ;
self_item->setText(2,"N/A"); 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 // Color each Background column in the Network Tab except the first one => 1-9
for(int i=1;i<10;++i) for(int i=1;i<10;++i)
@ -447,7 +468,7 @@ void NetworkDialog::insertConnect()
/* remove old items ??? */ /* remove old items ??? */
connectWidget->clear(); connectWidget->clear();
connectWidget->setColumnCount(4); connectWidget->setColumnCount(5);
/* add the items in! */ /* add the items in! */
connectWidget->insertTopLevelItems(0, items); connectWidget->insertTopLevelItems(0, items);
@ -482,14 +503,14 @@ QTreeWidgetItem *NetworkDialog::getCurrentNeighbour()
/* Utility Fns */ /* Utility Fns */
RsCertId getNeighRsCertId(QTreeWidgetItem *i) RsCertId getNeighRsCertId(QTreeWidgetItem *i)
{ {
RsCertId id = (i -> text(3)).toStdString(); RsCertId id = (i -> text(4)).toStdString();
return id; return id;
} }
/* So from the Neighbours Dialog we can call the following control Functions: /* So from the Neighbours Dialog we can call the following control Functions:
* (1) Load Certificate NeighLoadCertificate(std::string file) * (1) Load Certificate NeighLoadCertificate(std::string file)
* (2) Neigh Auth NeighAuthFriend(id, code) * (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. * All of these rely on the finding of the current Id.
*/ */

View File

@ -95,18 +95,9 @@
<attribute name="headerStretchLastSection"> <attribute name="headerStretchLastSection">
<bool>true</bool> <bool>true</bool>
</attribute> </attribute>
<attribute name="headerCascadingSectionResizes">
<bool>true</bool>
</attribute>
<attribute name="headerDefaultSectionSize">
<number>200</number>
</attribute>
<attribute name="headerStretchLastSection">
<bool>true</bool>
</attribute>
<column> <column>
<property name="text"> <property name="text">
<string> </string> <string/>
</property> </property>
</column> </column>
<column> <column>
@ -116,7 +107,12 @@
</column> </column>
<column> <column>
<property name="text"> <property name="text">
<string>Peer's trust</string> <string>GPG key validity</string>
</property>
</column>
<column>
<property name="text">
<string>Did peer authenticated me</string>
</property> </property>
</column> </column>
<column> <column>
@ -171,7 +167,7 @@ p, li { white-space: pre-wrap; }
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="2"> <item row="0" column="3">
<spacer> <spacer>
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
@ -184,7 +180,7 @@ p, li { white-space: pre-wrap; }
</property> </property>
</spacer> </spacer>
</item> </item>
<item row="0" column="3"> <item row="0" column="4">
<widget class="QPushButton" name="viewButton"> <widget class="QPushButton" name="viewButton">
<property name="toolTip"> <property name="toolTip">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt; <string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
@ -216,6 +212,13 @@ subcontrol-position: bottom right;
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="2">
<widget class="QCheckBox" name="showUnvalidKeys">
<property name="text">
<string>Show keys that are not validated by the GPG web of trust</string>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>

View File

@ -94,22 +94,18 @@ void ConfCertDialog::loadId(std::string id)
void ConfCertDialog::loadDialog() void ConfCertDialog::loadDialog()
{ {
isPGPId = false;
RsPeerDetails detail; RsPeerDetails detail;
if (!rsPeers->getPeerDetails(mId, detail)) if (!rsPeers->getPeerDetails(mId, detail))
{ {
isPGPId = true; QMessageBox::information(this,
if (!rsPeers->getPGPDetails(mId, detail)) { tr("RetroShare"),
QMessageBox::information(this, tr("Error : cannot get peer details."));
tr("RetroShare"), closeinfodlg();
tr("Error : cannot get peer details."));
this->close();
}
} }
ui.name->setText(QString::fromStdString(detail.name)); ui.name->setText(QString::fromStdString(detail.name));
ui.peerid->setText(QString::fromStdString(detail.id)); ui.peerid->setText(QString::fromStdString(detail.id));
if (!isPGPId) { if (!detail.isOnlyGPGdetail) {
ui.orgloc->setText(QString::fromStdString(detail.org)); ui.orgloc->setText(QString::fromStdString(detail.org));
ui.country->setText(QString::fromStdString(detail.location)); ui.country->setText(QString::fromStdString(detail.location));
// Dont Show a timestamp in RS calculate the day // Dont Show a timestamp in RS calculate the day
@ -160,19 +156,6 @@ void ConfCertDialog::loadDialog()
ui.groupBox->hide(); 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) { if (detail.ownsign) {
ui.sign_button->hide(); ui.sign_button->hide();
ui.signed_already_label->show(); ui.signed_already_label->show();
@ -182,9 +165,37 @@ void ConfCertDialog::loadDialog()
} }
if (detail.hasSignedMe) { 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 { } 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() ; ui.signers->clear() ;
@ -199,42 +210,54 @@ void ConfCertDialog::loadDialog()
void ConfCertDialog::applyDialog() void ConfCertDialog::applyDialog()
{ {
std::cerr << "In apply dialog" << std::endl ; std::cerr << "ConfCertDialog::applyDialog() called" << 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 ; if (!rsPeers->getPGPDetails(mId, detail)) {
/* fail */ QMessageBox::information(this,
return; tr("RetroShare"),
} tr("Error : cannot get peer details."));
closeinfodlg();
}
}
/* check if the data is the same */ //check the GPG trustlvl
bool localChanged = false; if (ui.radioButton_trust_fully->isChecked() && detail.trustLvl != 4) {
bool extChanged = false; //trust has changed to fully
bool fwChanged = false; rsPeers->TrustGPGCertificate(detail.id, 4);
} else if (ui.radioButton_trust_marginnaly->isChecked() && detail.trustLvl != 3) {
rsPeers->TrustGPGCertificate(detail.id, 3);
/* set local address */ } else if (ui.radioButton_trust_never->isChecked() && detail.trustLvl != 2) {
if ((detail.localAddr != ui.localAddress->text().toStdString()) || (detail.localPort != ui.localPort -> value())) rsPeers->TrustGPGCertificate(detail.id, 2);
localChanged = true; }
if ((detail.extAddr != ui.extAddress->text().toStdString()) || (detail.extPort != ui.extPort -> value())) if (!detail.isOnlyGPGdetail) {
extChanged = true; /* check if the data is the same */
bool localChanged = false;
bool extChanged = false;
bool fwChanged = false;
/* now we can action the changes */ /* set local address */
if (localChanged) if ((detail.localAddr != ui.localAddress->text().toStdString()) || (detail.localPort != ui.localPort -> value()))
rsPeers->setLocalAddress(mId, ui.localAddress->text().toStdString(), ui.localPort->value()); localChanged = true;
if (extChanged) if ((detail.extAddr != ui.extAddress->text().toStdString()) || (detail.extPort != ui.extPort -> value()))
rsPeers->setExtAddress(mId,ui.extAddress->text().toStdString(), ui.extPort->value()); extChanged = true;
/* reload now */ /* now we can action the changes */
loadDialog(); if (localChanged)
rsPeers->setLocalAddress(mId, ui.localAddress->text().toStdString(), ui.localPort->value());
/* close the Dialog after the Changes applied */ if (extChanged)
closeinfodlg(); rsPeers->setExtAddress(mId,ui.extAddress->text().toStdString(), ui.extPort->value());
if(localChanged || extChanged) if(localChanged || extChanged)
emit configChanged() ; emit configChanged() ;
}
closeinfodlg();
} }
void ConfCertDialog::makeFriend() void ConfCertDialog::makeFriend()

View File

@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>506</width> <width>506</width>
<height>523</height> <height>529</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -21,7 +21,7 @@
<item row="0" column="0"> <item row="0" column="0">
<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">
<attribute name="icon"> <attribute name="icon">
@ -243,6 +243,19 @@
</layout> </layout>
</widget> </widget>
</item> </item>
<item row="2" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout> </layout>
</widget> </widget>
<widget class="QWidget" name="tab_2"> <widget class="QWidget" name="tab_2">
@ -263,7 +276,7 @@
</font> </font>
</property> </property>
<property name="title"> <property name="title">
<string>Key signing settings</string> <string>GPG Key signing settings</string>
</property> </property>
<layout class="QVBoxLayout" name="_10"> <layout class="QVBoxLayout" name="_10">
<item> <item>
@ -303,14 +316,69 @@
</widget> </widget>
</item> </item>
<item> <item>
<spacer> <widget class="QGroupBox" name="groupBox_5">
<property name="enabled">
<bool>true</bool>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>50</height>
</size>
</property>
<property name="font">
<font>
<kerning>true</kerning>
</font>
</property>
<property name="title">
<string>GPG Web of Trust</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="web_of_trust_label">
<property name="text">
<string>Your trust in this peer is :</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QRadioButton" name="radioButton_trust_never">
<property name="text">
<string>None</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButton_trust_marginnaly">
<property name="text">
<string>Marginnaly</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButton_trust_fully">
<property name="text">
<string>Fully</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation"> <property name="orientation">
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>
</property> </property>
<property name="sizeHint" stdset="0"> <property name="sizeHint" stdset="0">
<size> <size>
<width>451</width> <width>20</width>
<height>131</height> <height>40</height>
</size> </size>
</property> </property>
</spacer> </spacer>

View File

@ -499,8 +499,8 @@ void FofPage::updatePeersList(int e)
break ; break ;
case 1: // "Unsigned peers who already signed my certificate" case 1: // "Unsigned peers who already signed my certificate"
show = rsPeers->isTrustingMe(details.id) && !(details.state & RS_PEER_STATE_FRIEND) ; show = details.hasSignedMe && !(details.state & RS_PEER_STATE_FRIEND) ;
std::cerr << "case 1, ownsign=" << details.ownsign << ", is_trusting_me=" << rsPeers->isTrustingMe(details.id) << ", show=" << show << std::endl ; std::cerr << "case 1, ownsign=" << details.ownsign << ", is_authed_me=" << details.hasSignedMe << ", show=" << show << std::endl ;
break ; break ;
case 0: // "All unsigned friends of my friends" case 0: // "All unsigned friends of my friends"