make peer details work for GPG key in the network view gui

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@2010 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
joss17 2010-01-13 21:11:02 +00:00
parent 77b3c0afd0
commit 41600dc3cf
13 changed files with 472 additions and 486 deletions

View File

@ -912,7 +912,9 @@ bool AuthGPG::getPGPDetails(std::string id, RsPeerDetails &d)
d.trustLvl = it->second.trustLvl; d.trustLvl = it->second.trustLvl;
d.validLvl = it->second.validLvl; d.validLvl = it->second.validLvl;
d.ownsign = it->second.ownsign; 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; return true;
} else { } else {
return false; 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))) if (GPG_ERR_NO_ERROR != (ERR = gpgme_op_decrypt (CTX, CIPHER, PLAIN)))
{ {
ProcessPGPmeError(ERR); ProcessPGPmeError(ERR);
std::cerr << "AuthGPG::decryptText() Error decrypting text."; std::cerr << "AuthGPG::decryptText() Error decrypting text." << std::endl;
std::cerr << std::endl;
return false; return false;
} }

View File

@ -86,7 +86,7 @@ class RsPeerDetails
std::string fpr; /* pgp fingerprint */ std::string fpr; /* pgp fingerprint */
std::string authcode; std::string authcode;
std::list<std::string> signers; std::list<std::string> gpgSigners;
uint32_t trustLvl; uint32_t trustLvl;
uint32_t validLvl; uint32_t validLvl;
@ -140,6 +140,7 @@ virtual bool getPeerDetails(std::string id, RsPeerDetails &d) = 0;
/* 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 bool getPGPFriendList(std::list<std::string> &ids) = 0; virtual bool getPGPFriendList(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;

View File

@ -314,7 +314,7 @@ bool p3Peers::getPeerDetails(std::string id, RsPeerDetails &d)
d.email = authDetail.email; d.email = authDetail.email;
d.location = authDetail.location; d.location = authDetail.location;
d.org = authDetail.org; d.org = authDetail.org;
d.signers = authDetail.signers; d.gpgSigners = authDetail.signers;
d.issuer = authDetail.issuer; d.issuer = authDetail.issuer;
@ -552,13 +552,12 @@ bool p3Peers::getPGPAllList(std::list<std::string> &ids)
bool p3Peers::getPGPDetails(std::string id, RsPeerDetails &d) bool p3Peers::getPGPDetails(std::string id, RsPeerDetails &d)
{ {
#ifdef P3PEERS_DEBUG #ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::getPgpDetails()"; std::cerr << "p3Peers::getPgpDetails() called for id : " << id;
std::cerr << std::endl; std::cerr << std::endl;
#endif #endif
/* get from mAuthMgr */ /* get from mAuthMgr */
AuthGPG::getAuthGPG()->getPGPDetails(id, d); return AuthGPG::getAuthGPG()->getPGPDetails(id, d);
return true;
} }
std::string p3Peers::getPGPOwnId() std::string p3Peers::getPGPOwnId()
@ -572,6 +571,16 @@ std::string p3Peers::getPGPOwnId()
return AuthGPG::getAuthGPG()->PGPOwnId(); 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; out << std::endl;
std::list<std::string>::const_iterator it; std::list<std::string>::const_iterator it;
for(it = detail.signers.begin(); for(it = detail.gpgSigners.begin();
it != detail.signers.end(); it++) it != detail.gpgSigners.end(); it++)
{ {
out << "\t" << *it; out << "\t" << *it;
out << std::endl; out << std::endl;

View File

@ -55,6 +55,7 @@ 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 bool getPGPFriendList(std::list<std::string> &ids); virtual bool getPGPFriendList(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);

View File

@ -500,7 +500,7 @@ void p3disc::sendPeerDetails(std::string to, std::string about)
RsPeerDetails pd ; RsPeerDetails pd ;
std::string name = rsPeers->getPeerName(about) ; std::string name = rsPeers->getPeerName(about) ;
if(rsPeers->getPeerDetails(to,pd)) if(rsPeers->getPeerDetails(to,pd))
for(std::list<std::string>::const_iterator it(pd.signers.begin());it!=pd.signers.end();++it) for(std::list<std::string>::const_iterator it(pd.gpgSigners.begin());it!=pd.gpgSigners.end();++it)
if(*it == name) if(*it == name)
{ {
di->discFlags |= P3DISC_FLAGS_PEER_TRUSTS_ME; di->discFlags |= P3DISC_FLAGS_PEER_TRUSTS_ME;

View File

@ -178,7 +178,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(9).toStdString() ; std::string peer_id = wi->text(3).toStdString() ;
// That's what context menus are made for // That's what context menus are made for
RsPeerDetails detail; RsPeerDetails detail;
@ -380,7 +380,7 @@ void NetworkDialog::insertConnect()
/* (2) has me auth */ /* (2) has me auth */
bool hasSignedMe = false; bool hasSignedMe = false;
std::list<std::string>::iterator signersIt; std::list<std::string>::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) { if (*signersIt == detail.id) {
hasSignedMe = true; hasSignedMe = true;
break; break;

View File

@ -341,7 +341,7 @@ void NetworkView::insertSignatures()
continue; continue;
} }
for(sit = detail.signers.begin(); sit != detail.signers.end(); sit++) for(sit = detail.gpgSigners.begin(); sit != detail.gpgSigners.end(); sit++)
{ {
if (*it != *sit) if (*it != *sit)

View File

@ -162,7 +162,7 @@ void TrustView::update()
int i = getRowColId(details.id) ; int i = getRowColId(details.id) ;
std::string issuer(details.issuer) ; // the one we check for trust. std::string issuer(details.issuer) ; // the one we check for trust.
for(list<string>::const_iterator it2(details.signers.begin());it2!=details.signers.end();++it2) for(list<string>::const_iterator it2(details.gpgSigners.begin());it2!=details.gpgSigners.end();++it2)
{ {
cout << *it2 << " " ; cout << *it2 << " " ;

View File

@ -25,6 +25,7 @@
#include "rsiface/rsdisc.h" #include "rsiface/rsdisc.h"
#include <QTime> #include <QTime>
#include <QtGui>
ConfCertDialog *ConfCertDialog::instance() ConfCertDialog *ConfCertDialog::instance()
{ {
@ -46,7 +47,7 @@ ConfCertDialog::ConfCertDialog(QWidget *parent, Qt::WFlags flags)
connect(ui.applyButton, SIGNAL(clicked()), this, SLOT(applyDialog())); connect(ui.applyButton, SIGNAL(clicked()), this, SLOT(applyDialog()));
connect(ui.cancelButton, SIGNAL(clicked()), this, SLOT(closeinfodlg())); 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")); ui.applyButton->setToolTip(tr("Apply and Close"));
@ -93,18 +94,24 @@ 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))
{ {
/* fail */ isPGPId = true;
return; 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.name->setText(QString::fromStdString(detail.name));
ui.peerid->setText(QString::fromStdString(detail.id));
if (!isPGPId) {
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));
ui.peerid->setText(QString::fromStdString(detail.id));
// Dont Show a timestamp in RS calculate the day // Dont Show a timestamp in RS calculate the day
QDateTime date = QDateTime::fromTime_t(detail.lastConnect); QDateTime date = QDateTime::fromTime_t(detail.lastConnect);
QString stime = date.toString(Qt::LocalDate); QString stime = date.toString(Qt::LocalDate);
@ -129,6 +136,18 @@ void ConfCertDialog::loadDialog()
ui.ipAddressList->clear(); ui.ipAddressList->clear();
for(std::list<std::string>::const_iterator it(detail.ipAddressList.begin());it!=detail.ipAddressList.end();++it) for(std::list<std::string>::const_iterator it(detail.ipAddressList.begin());it!=detail.ipAddressList.end();++it)
ui.ipAddressList->addItem(QString::fromStdString(*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) */ /* set the url for DNS access (OLD) */
//ui.extName->setText(QString::fromStdString("")); //ui.extName->setText(QString::fromStdString(""));
@ -143,17 +162,37 @@ void ConfCertDialog::loadDialog()
//ui.trustLvl->setText(QString::fromStdString(RsPeerTrustString(detail.trustLvl))); //ui.trustLvl->setText(QString::fromStdString(RsPeerTrustString(detail.trustLvl)));
ui._peerTrustsMeCB->setChecked(rsPeers->isOnline(detail.id) || rsPeers->isTrustingMe(detail.id)) ; if (detail.ownsign) {
ui._peerTrustsMeCB->setEnabled(false); ui.sign_button->hide();
ui.signBox->setChecked(detail.ownsign) ; ui.signed_already_label->show();
ui.signBox->setEnabled(!detail.ownsign) ; } else {
ui.sign_button->show();
ui.signed_already_label->hide();
}
ui._peerAcceptedCB->setChecked(detail.state & RS_PEER_STATE_FRIEND) ; bool hasSignedMe = false;
ui._peerAcceptedCB->setEnabled(detail.ownsign) ; RsPeerDetails ownGPGDetails ;
rsPeers->getPGPDetails(rsPeers->getPGPOwnId(), ownGPGDetails);
std::list<std::string>::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() ; ui.signers->clear() ;
for(std::list<std::string>::const_iterator it(detail.signers.begin());it!=detail.signers.end();++it) for(std::list<std::string>::const_iterator it(detail.gpgSigners.begin());it!=detail.gpgSigners.end();++it) {
ui.signers->append(QString::fromStdString(*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 localChanged = false;
bool extChanged = false; bool extChanged = false;
bool fwChanged = false; bool fwChanged = false;
bool signChanged = false;
bool trustChanged = false;
/* set local address */ /* set local address */
if ((detail.localAddr != ui.localAddress->text().toStdString()) || (detail.localPort != ui.localPort -> value())) 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())) if ((detail.extAddr != ui.extAddress->text().toStdString()) || (detail.extPort != ui.extPort -> value()))
extChanged = true; 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 */ /* now we can action the changes */
if (localChanged) if (localChanged)
rsPeers->setLocalAddress(mId, ui.localAddress->text().toStdString(), ui.localPort->value()); rsPeers->setLocalAddress(mId, ui.localAddress->text().toStdString(), ui.localPort->value());
@ -197,61 +226,18 @@ void ConfCertDialog::applyDialog()
if (extChanged) if (extChanged)
rsPeers->setExtAddress(mId,ui.extAddress->text().toStdString(), ui.extPort->value()); rsPeers->setExtAddress(mId,ui.extAddress->text().toStdString(), ui.extPort->value());
#if 0
if (fwChanged)
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 */ /* reload now */
loadDialog(); loadDialog();
/* close the Dialog after the Changes applied */ /* close the Dialog after the Changes applied */
closeinfodlg(); closeinfodlg();
if(trustChanged || signChanged || localChanged || extChanged) if(localChanged || extChanged)
emit configChanged() ; emit configChanged() ;
} }
void ConfCertDialog::makeFriend() void ConfCertDialog::makeFriend()
{ {
ui.signBox->setChecked(true) ; rsPeers->SignGPGCertificate(mId);
ui._peerAcceptedCB->setChecked(true) ; loadDialog();
// rsPeers->TrustCertificate(mId, ui.trustBox->isChecked());
// rsPeers->SignCertificate(mId);
} }
#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

View File

@ -76,6 +76,7 @@ private:
void loadDialog(); void loadDialog();
std::string mId; std::string mId;
bool isPGPId;
/** Qt Designer generated object */ /** Qt Designer generated object */
Ui::ConfCertDialog ui; Ui::ConfCertDialog ui;

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>474</height> <height>523</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">
@ -257,43 +257,20 @@
<item> <item>
<widget class="QGroupBox" name="groupBox_3"> <widget class="QGroupBox" name="groupBox_3">
<property name="title"> <property name="title">
<string>Trust Settings</string> <string>Key signing settings</string>
</property> </property>
<layout class="QVBoxLayout" name="_10"> <layout class="QVBoxLayout" name="_10">
<item> <item>
<widget class="QCheckBox" name="signBox"> <widget class="QLabel" name="is_signing_me">
<property name="toolTip">
<string comment="Once signed, you cannot unsign a certificate, only deny connexions."/>
</property>
<property name="text"> <property name="text">
<string>Sign this certificate</string> <string>Peer has signed my GPG key</string>
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QCheckBox" name="_peerAcceptedCB">
<property name="text">
<string>Accept connexions from this peer</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="_peerTrustsMeCB">
<property name="toolTip">
<string/>
</property>
<property name="text">
<string>Peer has signed my certficate</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item> <item>
<widget class="QGroupBox" name="groupBox_4"> <widget class="QGroupBox" name="groupBox_4">
<property name="title"> <property name="title">
<string>Certificate signers</string> <string>Peer key is already signed by :</string>
</property> </property>
<layout class="QVBoxLayout" name="_11"> <layout class="QVBoxLayout" name="_11">
<item> <item>
@ -303,12 +280,22 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QPushButton" name="_makeFriendPB"> <widget class="QLabel" name="signed_already_label">
<property name="text"> <property name="text">
<string>Make friend (Sign certificate and accept)</string> <string>Peer is already a friend of me (his GPG key is signed by me)</string>
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QPushButton" name="sign_button">
<property name="text">
<string>Make friend (Sign his GPG key)</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item> <item>
<spacer> <spacer>
<property name="orientation"> <property name="orientation">

View File

@ -130,7 +130,7 @@ void ConnectDialog::authAttempt()
/* well lets do it ! */ /* well lets do it ! */
std::cerr << "Attempting AuthCode:" << authCode << std::endl; std::cerr << "Attempting AuthCode:" << authCode << std::endl;
rsPeers->AuthCertificate(authId, authCode); //rsPeers->AuthCertificate(authId, authCode);
rsPeers->addFriend(authId); rsPeers->addFriend(authId);
rsicontrol->getNotify().notifyListChange(NOTIFY_LIST_NEIGHBOURS,1) ; rsicontrol->getNotify().notifyListChange(NOTIFY_LIST_NEIGHBOURS,1) ;
@ -166,7 +166,7 @@ bool ConnectDialog::loadPeer(std::string id)
std::ostringstream out; std::ostringstream out;
std::list<std::string>::iterator it; std::list<std::string>::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 << rsPeers->getPeerName(*it) << " <" << *it << ">";
out << std::endl; out << std::endl;

View File

@ -97,7 +97,7 @@ ConnectFriendWizard::accept()
std::string authId = field("idField").toString().toStdString(); std::string authId = field("idField").toString().toStdString();
std::string authCode = field("authCode").toString().toStdString(); std::string authCode = field("authCode").toString().toStdString();
rsPeers->AuthCertificate(authId, authCode ); //rsPeers->AuthCertificate(authId, authCode );
rsPeers->addFriend(authId); rsPeers->addFriend(authId);
//let's check if there is ip adresses in the wizard. //let's check if there is ip adresses in the wizard.
@ -485,7 +485,7 @@ void FofPage::updatePeersList(int e)
std::set<std::string> common_friends ; std::set<std::string> common_friends ;
for(std::list<std::string>::const_iterator it2(details.signers.begin());it2!=details.signers.end();++it2) for(std::list<std::string>::const_iterator it2(details.gpgSigners.begin());it2!=details.gpgSigners.end();++it2)
if(my_friends_names.find(*it2) != my_friends_names.end() && *it2 != details.name) if(my_friends_names.find(*it2) != my_friends_names.end() && *it2 != details.name)
common_friends.insert(*it2) ; common_friends.insert(*it2) ;
@ -565,7 +565,7 @@ void FofPage::signAllSelectedUsers()
if(it->first->isChecked()) if(it->first->isChecked())
{ {
std::cerr << "Making friend with " << it->second << std::endl ; std::cerr << "Making friend with " << it->second << std::endl ;
rsPeers->AuthCertificate(it->second, ""); //rsPeers->AuthCertificate(it->second, "");
rsPeers->addFriend(it->second); rsPeers->addFriend(it->second);
} }
@ -868,7 +868,7 @@ ConclusionPage::initializePage()
QString ts; QString ts;
std::list<std::string>::iterator it; std::list<std::string>::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(QString::fromStdString( rsPeers->getPeerName(*it) ));
ts.append( "<" ) ; ts.append( "<" ) ;