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

@ -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<std::string> neighs; //these are GPG ids
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 */
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.
*/

View file

@ -95,18 +95,9 @@
<attribute name="headerStretchLastSection">
<bool>true</bool>
</attribute>
<attribute name="headerCascadingSectionResizes">
<bool>true</bool>
</attribute>
<attribute name="headerDefaultSectionSize">
<number>200</number>
</attribute>
<attribute name="headerStretchLastSection">
<bool>true</bool>
</attribute>
<column>
<property name="text">
<string> </string>
<string/>
</property>
</column>
<column>
@ -116,7 +107,12 @@
</column>
<column>
<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>
</column>
<column>
@ -171,7 +167,7 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</item>
<item row="0" column="2">
<item row="0" column="3">
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
@ -184,7 +180,7 @@ p, li { white-space: pre-wrap; }
</property>
</spacer>
</item>
<item row="0" column="3">
<item row="0" column="4">
<widget class="QPushButton" name="viewButton">
<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;
@ -216,6 +212,13 @@ subcontrol-position: bottom right;
</property>
</widget>
</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>
</widget>
</item>

View file

@ -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()

View file

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>506</width>
<height>523</height>
<height>529</height>
</rect>
</property>
<property name="windowTitle">
@ -21,7 +21,7 @@
<item row="0" column="0">
<widget class="QTabWidget" name="stabWidget">
<property name="currentIndex">
<number>0</number>
<number>1</number>
</property>
<widget class="QWidget" name="tab">
<attribute name="icon">
@ -243,6 +243,19 @@
</layout>
</widget>
</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>
</widget>
<widget class="QWidget" name="tab_2">
@ -263,7 +276,7 @@
</font>
</property>
<property name="title">
<string>Key signing settings</string>
<string>GPG Key signing settings</string>
</property>
<layout class="QVBoxLayout" name="_10">
<item>
@ -303,14 +316,69 @@
</widget>
</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">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>451</width>
<height>131</height>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>

View file

@ -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"