mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-02-09 19:38:45 -05:00
added display of trust level in NetworkDialog
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3827 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
1585606c4c
commit
58dcb79f42
@ -18,6 +18,7 @@
|
|||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||||
* Boston, MA 02110-1301, USA.
|
* Boston, MA 02110-1301, USA.
|
||||||
****************************************************************/
|
****************************************************************/
|
||||||
|
#include <gpgme.h>
|
||||||
|
|
||||||
#include <QTreeWidget>
|
#include <QTreeWidget>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
@ -359,99 +360,110 @@ void NetworkDialog::insertConnect()
|
|||||||
|
|
||||||
last_time = now ;
|
last_time = now ;
|
||||||
|
|
||||||
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->getGPGAllList(neighs);
|
rsPeers->getGPGAllList(neighs);
|
||||||
|
|
||||||
/* get a link to the table */
|
/* get a link to the table */
|
||||||
QTreeWidget *connectWidget = ui.connecttreeWidget;
|
QTreeWidget *connectWidget = ui.connecttreeWidget;
|
||||||
|
|
||||||
//remove items
|
//remove items
|
||||||
int index = 0;
|
int index = 0;
|
||||||
while (index < connectWidget->topLevelItemCount()) {
|
while (index < connectWidget->topLevelItemCount()) {
|
||||||
std::string gpg_widget_id = (connectWidget->topLevelItem(index))->text(4).toStdString();
|
std::string gpg_widget_id = (connectWidget->topLevelItem(index))->text(4).toStdString();
|
||||||
RsPeerDetails detail;
|
RsPeerDetails detail;
|
||||||
if (!rsPeers->getGPGDetails(gpg_widget_id, detail) || (detail.validLvl < 3 && !detail.accept_connection)) {
|
if (!rsPeers->getGPGDetails(gpg_widget_id, detail) || (detail.validLvl < 3 && !detail.accept_connection)) {
|
||||||
delete (connectWidget->takeTopLevelItem(index));
|
delete (connectWidget->takeTopLevelItem(index));
|
||||||
} else {
|
} else {
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
index = 0;
|
index = 0;
|
||||||
while (index < ui.unvalidGPGkeyWidget->topLevelItemCount()) {
|
while (index < ui.unvalidGPGkeyWidget->topLevelItemCount()) {
|
||||||
std::string gpg_widget_id = (ui.unvalidGPGkeyWidget->topLevelItem(index))->text(4).toStdString();
|
std::string gpg_widget_id = (ui.unvalidGPGkeyWidget->topLevelItem(index))->text(4).toStdString();
|
||||||
RsPeerDetails detail;
|
RsPeerDetails detail;
|
||||||
if (!rsPeers->getGPGDetails(gpg_widget_id, detail) || detail.validLvl >= 3 || detail.accept_connection) {
|
if (!rsPeers->getGPGDetails(gpg_widget_id, detail) || detail.validLvl >= 3 || detail.accept_connection) {
|
||||||
delete (ui.unvalidGPGkeyWidget->takeTopLevelItem(index));
|
delete (ui.unvalidGPGkeyWidget->takeTopLevelItem(index));
|
||||||
} else {
|
} else {
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<QTreeWidgetItem *> validItems;
|
QList<QTreeWidgetItem *> validItems;
|
||||||
QList<QTreeWidgetItem *> unvalidItems;
|
QList<QTreeWidgetItem *> unvalidItems;
|
||||||
for(it = neighs.begin(); it != neighs.end(); it++)
|
for(it = neighs.begin(); it != neighs.end(); it++)
|
||||||
{
|
{
|
||||||
#ifdef NET_DEBUG
|
#ifdef NET_DEBUG
|
||||||
std::cerr << "NetworkDialog::insertConnect() inserting gpg key : " << *it << std::endl;
|
std::cerr << "NetworkDialog::insertConnect() inserting gpg key : " << *it << std::endl;
|
||||||
#endif
|
#endif
|
||||||
if (*it == rsPeers->getGPGOwnId()) {
|
if (*it == rsPeers->getGPGOwnId()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
RsPeerDetails detail;
|
RsPeerDetails detail;
|
||||||
if (!rsPeers->getGPGDetails(*it, detail))
|
if (!rsPeers->getGPGDetails(*it, detail))
|
||||||
{
|
{
|
||||||
continue; /* BAD */
|
continue; /* BAD */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* make a widget per friend */
|
/* make a widget per friend */
|
||||||
QTreeWidgetItem *item;
|
QTreeWidgetItem *item;
|
||||||
QList<QTreeWidgetItem *> list = connectWidget->findItems(QString::fromStdString(*it), Qt::MatchExactly, 4);
|
QList<QTreeWidgetItem *> list = connectWidget->findItems(QString::fromStdString(*it), Qt::MatchExactly, 4);
|
||||||
if (list.size() == 1) {
|
if (list.size() == 1) {
|
||||||
item = list.front();
|
item = list.front();
|
||||||
} else {
|
} else {
|
||||||
list = ui.unvalidGPGkeyWidget->findItems(QString::fromStdString(*it), Qt::MatchExactly, 4);
|
list = ui.unvalidGPGkeyWidget->findItems(QString::fromStdString(*it), Qt::MatchExactly, 4);
|
||||||
if (list.size() == 1) {
|
if (list.size() == 1) {
|
||||||
item = list.front();
|
item = list.front();
|
||||||
} else {
|
} else {
|
||||||
//create new item
|
//create new item
|
||||||
#ifdef NET_DEBUG
|
#ifdef NET_DEBUG
|
||||||
std::cerr << "NetworkDialog::insertConnect() creating new tree widget item : " << *it << std::endl;
|
std::cerr << "NetworkDialog::insertConnect() creating new tree widget item : " << *it << std::endl;
|
||||||
#endif
|
#endif
|
||||||
item = new RSTreeWidgetItem(NULL, 0);
|
item = new RSTreeWidgetItem(NULL, 0);
|
||||||
item -> setChildIndicatorPolicy(QTreeWidgetItem::DontShowIndicatorWhenChildless);
|
item -> setChildIndicatorPolicy(QTreeWidgetItem::DontShowIndicatorWhenChildless);
|
||||||
item -> setSizeHint(0, QSize( 18,18 ) );
|
item -> setSizeHint(0, QSize( 18,18 ) );
|
||||||
|
|
||||||
/* (1) Person */
|
/* (1) Person */
|
||||||
item -> setText(COLUMN_PEERNAME, QString::fromStdString(detail.name));
|
item -> setText(COLUMN_PEERNAME, QString::fromStdString(detail.name));
|
||||||
|
|
||||||
/* (4) key id */
|
/* (4) key id */
|
||||||
item -> setText(COLUMN_PEERID, QString::fromStdString(detail.id));
|
item -> setText(COLUMN_PEERID, QString::fromStdString(detail.id));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (2) Key validity */
|
QString TrustLevelString ;
|
||||||
if (detail.ownsign) {
|
|
||||||
item -> setText(2, tr("Authenticated"));
|
|
||||||
item -> setToolTip(2, tr("GPG key signed"));
|
|
||||||
} else {
|
|
||||||
item -> setText(2, tr("Not Authenticated"));
|
|
||||||
item -> setToolTip(2, tr("GPG key not signed"));
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (3) has me auth */
|
/* (2) Key validity */
|
||||||
if (detail.hasSignedMe)
|
if (detail.ownsign)
|
||||||
item -> setText(3, tr("Has authenticated me"));
|
{
|
||||||
else
|
item -> setText(2, tr("Personal signature"));
|
||||||
item -> setText(3, tr("Unknown"));
|
item -> setToolTip(2, tr("GPG key signed by you"));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
switch(detail.validLvl)
|
||||||
|
{
|
||||||
|
case GPGME_VALIDITY_MARGINAL: item->setText(2,tr("Marginally trusted peer")) ; break;
|
||||||
|
case GPGME_VALIDITY_FULL:
|
||||||
|
case GPGME_VALIDITY_ULTIMATE: item->setText(2,tr("Fully trusted peer")) ; break ;
|
||||||
|
case GPGME_VALIDITY_UNKNOWN:
|
||||||
|
case GPGME_VALIDITY_UNDEFINED:
|
||||||
|
case GPGME_VALIDITY_NEVER:
|
||||||
|
default: item->setText(2,tr("Untrusted peer")) ; break ;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString PeerAuthenticationString = tr("Unknown") ;
|
||||||
|
/* (3) has me auth */
|
||||||
|
if (detail.hasSignedMe)
|
||||||
|
PeerAuthenticationString = tr("Has authenticated me");
|
||||||
|
|
||||||
|
item->setText(3,PeerAuthenticationString) ;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determinated the Background Color
|
* Determinated the Background Color
|
||||||
*/
|
*/
|
||||||
QColor backgrndcolor;
|
QColor backgrndcolor;
|
||||||
|
|
||||||
if (detail.accept_connection)
|
if (detail.accept_connection)
|
||||||
{
|
{
|
||||||
if (detail.ownsign)
|
if (detail.ownsign)
|
||||||
@ -469,14 +481,14 @@ void NetworkDialog::insertConnect()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
item -> setText(0, "1");
|
item -> setText(0, "1");
|
||||||
|
|
||||||
if (detail.hasSignedMe)
|
if (detail.hasSignedMe)
|
||||||
{
|
{
|
||||||
backgrndcolor=QColor("#42B2B2"); //kind of darkCyan
|
backgrndcolor=QColor("#42B2B2"); //kind of darkCyan
|
||||||
item -> setIcon(0,(QIcon(IMAGE_DENIED)));
|
item -> setIcon(0,(QIcon(IMAGE_DENIED)));
|
||||||
for(int k=0;k<8;++k)
|
for(int k=0;k<8;++k)
|
||||||
item -> setToolTip(k, QString::fromStdString(detail.name) + tr(" has authenticated you. \nRight-click and select 'make friend' to be able to connect."));
|
item -> setToolTip(k, QString::fromStdString(detail.name) + tr(" has authenticated you. \nRight-click and select 'make friend' to be able to connect."));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -487,7 +499,7 @@ void NetworkDialog::insertConnect()
|
|||||||
|
|
||||||
// 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
|
||||||
// whith the determinated color
|
// whith the determinated color
|
||||||
for(int i = 0; i <10; i++)
|
for(int i = 0; i <10; i++)
|
||||||
item -> setBackground(i,QBrush(backgrndcolor));
|
item -> setBackground(i,QBrush(backgrndcolor));
|
||||||
|
|
||||||
/* add to the list */
|
/* add to the list */
|
||||||
@ -504,41 +516,41 @@ void NetworkDialog::insertConnect()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// add self to network.
|
// add self to network.
|
||||||
RsPeerDetails ownGPGDetails;
|
RsPeerDetails ownGPGDetails;
|
||||||
rsPeers->getGPGDetails(rsPeers->getGPGOwnId(), ownGPGDetails);
|
rsPeers->getGPGDetails(rsPeers->getGPGOwnId(), ownGPGDetails);
|
||||||
/* make a widget per friend */
|
/* make a widget per friend */
|
||||||
QTreeWidgetItem *self_item;
|
QTreeWidgetItem *self_item;
|
||||||
QList<QTreeWidgetItem *> list = connectWidget->findItems(QString::fromStdString(ownGPGDetails.gpg_id), Qt::MatchExactly, 4);
|
QList<QTreeWidgetItem *> list = connectWidget->findItems(QString::fromStdString(ownGPGDetails.gpg_id), Qt::MatchExactly, 4);
|
||||||
if (list.size() == 1) {
|
if (list.size() == 1) {
|
||||||
self_item = list.front();
|
self_item = list.front();
|
||||||
} else {
|
} else {
|
||||||
self_item = new RSTreeWidgetItem(NULL, 0);
|
self_item = new RSTreeWidgetItem(NULL, 0);
|
||||||
self_item->setChildIndicatorPolicy(QTreeWidgetItem::DontShowIndicatorWhenChildless);
|
self_item->setChildIndicatorPolicy(QTreeWidgetItem::DontShowIndicatorWhenChildless);
|
||||||
}
|
}
|
||||||
self_item -> setText(0, "0");
|
self_item -> setText(0, "0");
|
||||||
self_item->setIcon(0,(QIcon(IMAGE_AUTHED)));
|
self_item->setIcon(0,(QIcon(IMAGE_AUTHED)));
|
||||||
self_item->setText(COLUMN_PEERNAME, QString::fromStdString(ownGPGDetails.name) + " (" + tr("yourself") + ")");
|
self_item->setText(COLUMN_PEERNAME, QString::fromStdString(ownGPGDetails.name) + " (" + tr("yourself") + ")");
|
||||||
self_item->setText(2,"N/A");
|
self_item->setText(2,"N/A");
|
||||||
self_item->setText(COLUMN_PEERID, QString::fromStdString(ownGPGDetails.id));
|
self_item->setText(COLUMN_PEERID, 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=0;i<10;++i)
|
for(int i=0;i<10;++i)
|
||||||
{
|
{
|
||||||
self_item->setBackground(i,Qt::yellow) ;//QBrush(QColor("#45ff45")));
|
self_item->setBackground(i,Qt::yellow) ;//QBrush(QColor("#45ff45")));
|
||||||
}
|
}
|
||||||
connectWidget->addTopLevelItem(self_item);
|
connectWidget->addTopLevelItem(self_item);
|
||||||
|
|
||||||
if (ui.showUnvalidKeys->isChecked()) {
|
if (ui.showUnvalidKeys->isChecked()) {
|
||||||
ui.unvalidGPGkeyWidget->show();
|
ui.unvalidGPGkeyWidget->show();
|
||||||
} else {
|
} else {
|
||||||
ui.unvalidGPGkeyWidget->hide();
|
ui.unvalidGPGkeyWidget->hide();
|
||||||
}
|
}
|
||||||
connectWidget->update(); /* update display */
|
connectWidget->update(); /* update display */
|
||||||
ui.unvalidGPGkeyWidget->update(); /* update display */
|
ui.unvalidGPGkeyWidget->update(); /* update display */
|
||||||
|
|
||||||
if (ui.filterPatternLineEdit->text().isEmpty() == false) {
|
if (ui.filterPatternLineEdit->text().isEmpty() == false) {
|
||||||
FilterItems();
|
FilterItems();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user