mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-31 09:43:25 -05:00
Implemented a big trust table where people can see who trusts who, and who is trusted by who. This makes trust discrepencies really easy to catch
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@805 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
90aac52257
commit
941e59f6e9
@ -68,6 +68,7 @@ HEADERS += rshare.h \
|
|||||||
gui/forums/CreateForum.h \
|
gui/forums/CreateForum.h \
|
||||||
gui/forums/CreateForumMsg.h \
|
gui/forums/CreateForumMsg.h \
|
||||||
gui/NetworkView.h \
|
gui/NetworkView.h \
|
||||||
|
gui/TrustView.h \
|
||||||
gui/MessengerWindow.h \
|
gui/MessengerWindow.h \
|
||||||
gui/PeersDialog.h \
|
gui/PeersDialog.h \
|
||||||
gui/SearchTreeWidget.h \
|
gui/SearchTreeWidget.h \
|
||||||
@ -194,6 +195,7 @@ FORMS += gui/ChatDialog.ui \
|
|||||||
gui/forums/CreateForum.ui \
|
gui/forums/CreateForum.ui \
|
||||||
gui/forums/CreateForumMsg.ui \
|
gui/forums/CreateForumMsg.ui \
|
||||||
gui/NetworkView.ui \
|
gui/NetworkView.ui \
|
||||||
|
gui/TrustView.ui \
|
||||||
gui/MessengerWindow.ui \
|
gui/MessengerWindow.ui \
|
||||||
gui/PeersDialog.ui \
|
gui/PeersDialog.ui \
|
||||||
gui/SearchDialog.ui \
|
gui/SearchDialog.ui \
|
||||||
@ -282,6 +284,7 @@ SOURCES += main.cpp \
|
|||||||
gui/forums/CreateForum.cpp \
|
gui/forums/CreateForum.cpp \
|
||||||
gui/forums/CreateForumMsg.cpp \
|
gui/forums/CreateForumMsg.cpp \
|
||||||
gui/NetworkView.cpp \
|
gui/NetworkView.cpp \
|
||||||
|
gui/TrustView.cpp \
|
||||||
gui/MessengerWindow.cpp \
|
gui/MessengerWindow.cpp \
|
||||||
gui/PeersDialog.cpp \
|
gui/PeersDialog.cpp \
|
||||||
gui/SearchTreeWidget.cpp \
|
gui/SearchTreeWidget.cpp \
|
||||||
@ -365,7 +368,7 @@ SOURCES += main.cpp \
|
|||||||
gui/MsgFeed.cpp \
|
gui/MsgFeed.cpp \
|
||||||
gui/TransferFeed.cpp \
|
gui/TransferFeed.cpp \
|
||||||
gui/ChannelFeed.cpp \
|
gui/ChannelFeed.cpp \
|
||||||
gui/GeneralMsgDialog.cpp \
|
gui/GeneralMsgDialog.cpp \
|
||||||
gui/feeds/ForumNewItem.cpp \
|
gui/feeds/ForumNewItem.cpp \
|
||||||
gui/feeds/ForumMsgItem.cpp \
|
gui/feeds/ForumMsgItem.cpp \
|
||||||
gui/feeds/PeerItem.cpp \
|
gui/feeds/PeerItem.cpp \
|
||||||
@ -432,7 +435,7 @@ win32 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
!win32 {
|
!win32 {
|
||||||
LIBS += -L../../../../lib -lretroshare -lminiupnpc -lssl -lcrypto
|
LIBS += -L../../../../lib -lretroshare -lminiupnpc ../../../../lib/libssl.a ../../../../lib/libcrypto.a
|
||||||
LIBS += -lqcheckers -lsmplayer
|
LIBS += -lqcheckers -lsmplayer
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
#include "util/rsversion.h"
|
#include "util/rsversion.h"
|
||||||
#include "NetworkDialog.h"
|
#include "NetworkDialog.h"
|
||||||
#include "NetworkView.h"
|
#include "NetworkView.h"
|
||||||
|
#include "TrustView.h"
|
||||||
#include "connect/ConnectDialog.h"
|
#include "connect/ConnectDialog.h"
|
||||||
#include "rsiface/rsiface.h"
|
#include "rsiface/rsiface.h"
|
||||||
#include "rsiface/rspeers.h"
|
#include "rsiface/rspeers.h"
|
||||||
@ -109,12 +110,14 @@ NetworkDialog::NetworkDialog(QWidget *parent)
|
|||||||
headerItem->setTextAlignment(8, Qt::AlignHCenter | Qt::AlignVCenter);
|
headerItem->setTextAlignment(8, Qt::AlignHCenter | Qt::AlignVCenter);
|
||||||
headerItem->setTextAlignment(9, Qt::AlignHCenter | Qt::AlignVCenter);
|
headerItem->setTextAlignment(9, Qt::AlignHCenter | Qt::AlignVCenter);
|
||||||
|
|
||||||
networkview = new NetworkView(ui.networkviewTab);
|
networkview = new NetworkView(ui.networkviewTab);
|
||||||
QVBoxLayout *layout = new QVBoxLayout;
|
QVBoxLayout *layout = new QVBoxLayout;
|
||||||
layout->addWidget(networkview);
|
layout->addWidget(networkview);
|
||||||
ui.networkviewTab->setLayout(layout);
|
ui.networkviewTab->setLayout(layout);
|
||||||
layout->setSpacing( 0 );
|
layout->setSpacing( 0 );
|
||||||
layout->setMargin( 0 );
|
layout->setMargin( 0 );
|
||||||
|
|
||||||
|
ui.networkTab->addTab(new TrustView(),QString("Trust table"));
|
||||||
|
|
||||||
// Set Log infos
|
// Set Log infos
|
||||||
setLogInfo(tr("RetroShare %1 started.", "e.g: RetroShare v0.x started.").arg(retroshareVersion()));
|
setLogInfo(tr("RetroShare %1 started.", "e.g: RetroShare v0.x started.").arg(retroshareVersion()));
|
||||||
|
207
retroshare-gui/src/gui/TrustView.cpp
Normal file
207
retroshare-gui/src/gui/TrustView.cpp
Normal file
@ -0,0 +1,207 @@
|
|||||||
|
#include <math.h>
|
||||||
|
#include <QWheelEvent>
|
||||||
|
#include "rsiface/rsiface.h"
|
||||||
|
#include "rsiface/rspeers.h"
|
||||||
|
|
||||||
|
#include <QTableView>
|
||||||
|
#include "TrustView.h"
|
||||||
|
|
||||||
|
using namespace std ;
|
||||||
|
|
||||||
|
TrustView::TrustView()
|
||||||
|
{
|
||||||
|
setupUi(this) ;
|
||||||
|
|
||||||
|
trustTableTW->setMouseTracking(true) ;
|
||||||
|
trustInconsistencyCB->setEnabled(false) ;
|
||||||
|
|
||||||
|
zoomHS->setValue(100) ;
|
||||||
|
|
||||||
|
QObject::connect(zoomHS,SIGNAL(valueChanged(int)),this,SLOT(updateZoom(int))) ;
|
||||||
|
QObject::connect(updatePB,SIGNAL(clicked()),this,SLOT(update())) ;
|
||||||
|
QObject::connect(trustTableTW,SIGNAL(cellClicked(int,int)),this,SLOT(selectCell(int,int))) ;
|
||||||
|
|
||||||
|
update() ;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TrustView::wheelEvent(QWheelEvent *e)
|
||||||
|
{
|
||||||
|
if(e->modifiers() & Qt::ShiftModifier)
|
||||||
|
{
|
||||||
|
if(e->delta() > 0)
|
||||||
|
zoomHS->setValue(zoomHS->value()-5) ;
|
||||||
|
else
|
||||||
|
zoomHS->setValue(zoomHS->value()+5) ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TrustView::selectCell(int row,int col)
|
||||||
|
{
|
||||||
|
static int last_row = -1 ;
|
||||||
|
static int last_col = -1 ;
|
||||||
|
|
||||||
|
if(last_row > -1)
|
||||||
|
{
|
||||||
|
int col_s,row_s ;
|
||||||
|
getCellSize(zoomHS->value(),col_s,row_s) ;
|
||||||
|
|
||||||
|
trustTableTW->setColumnWidth(last_col,col_s) ;
|
||||||
|
trustTableTW->setRowHeight(last_row,row_s) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(row != last_row || col != last_col)
|
||||||
|
{
|
||||||
|
trustTableTW->setColumnWidth(col,_base_cell_width) ;
|
||||||
|
trustTableTW->setRowHeight(row,_base_cell_height) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
last_col = col ;
|
||||||
|
last_row = row ;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TrustView::getCellSize(int z,int& col_s,int& row_s) const
|
||||||
|
{
|
||||||
|
col_s = max(10,(int)rint( z/100.0 * _base_cell_width )) ;
|
||||||
|
row_s = max(10,(int)rint( z/100.0 * _base_cell_height)) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TrustView::updateZoom(int z)
|
||||||
|
{
|
||||||
|
int col_s,row_s ;
|
||||||
|
getCellSize(z,col_s,row_s) ;
|
||||||
|
|
||||||
|
for(int i=0;i<trustTableTW->columnCount();++i)
|
||||||
|
trustTableTW->setColumnWidth(i,col_s) ;
|
||||||
|
|
||||||
|
for(int i=0;i<trustTableTW->rowCount();++i)
|
||||||
|
trustTableTW->setRowHeight(i,row_s) ;
|
||||||
|
|
||||||
|
cout << "updated zoom" << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
int TrustView::getRowColId(const string& name)
|
||||||
|
{
|
||||||
|
static map<string,int> nameToRow ;
|
||||||
|
|
||||||
|
map<string,int>::const_iterator itpr(nameToRow.find( name )) ;
|
||||||
|
int i ;
|
||||||
|
|
||||||
|
if(itpr == nameToRow.end())
|
||||||
|
{
|
||||||
|
i = trustTableTW->columnCount() ;
|
||||||
|
cout << " -> peer not in table. Creating entry # " << i << endl ;
|
||||||
|
|
||||||
|
trustTableTW->insertColumn(i) ;
|
||||||
|
trustTableTW->insertRow(i) ;
|
||||||
|
|
||||||
|
nameToRow[name] = i ;
|
||||||
|
|
||||||
|
trustTableTW->setHorizontalHeaderItem(i,new QTableWidgetItem(QString(name.c_str()))) ;
|
||||||
|
trustTableTW->setVerticalHeaderItem(i,new QTableWidgetItem(QString(name.c_str()))) ;
|
||||||
|
|
||||||
|
trustTableTW->setColumnWidth(i,_base_cell_width) ;
|
||||||
|
trustTableTW->setRowHeight(i,_base_cell_height) ;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
i = (*itpr).second ;
|
||||||
|
|
||||||
|
return i ;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TrustView::update()
|
||||||
|
{
|
||||||
|
// collect info.
|
||||||
|
|
||||||
|
std::list<std::string> neighs;
|
||||||
|
|
||||||
|
if(!rsPeers->getOthersList(neighs))
|
||||||
|
return ;
|
||||||
|
|
||||||
|
neighs.push_back(rsPeers->getOwnId()) ;
|
||||||
|
|
||||||
|
trustTableTW->setSortingEnabled(false) ;
|
||||||
|
|
||||||
|
RsPeerDetails details ;
|
||||||
|
|
||||||
|
#ifdef A_VIRER
|
||||||
|
// Build rows and columns
|
||||||
|
//
|
||||||
|
for(list<string>::const_iterator it(neighs.begin()); it != neighs.end(); it++)
|
||||||
|
{
|
||||||
|
cout << "Looking for peer " << *it << endl ;
|
||||||
|
|
||||||
|
if(!rsPeers->getPeerDetails(*it,details))
|
||||||
|
{
|
||||||
|
cout << " -> no details" << endl ;
|
||||||
|
continue ;
|
||||||
|
}
|
||||||
|
|
||||||
|
cout << " -> name = " << details.name << endl ;
|
||||||
|
|
||||||
|
int i = getRowColId( details.name ) ;
|
||||||
|
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Fill everything
|
||||||
|
for(list<string>::const_iterator it1(neighs.begin()); it1 != neighs.end(); ++it1)
|
||||||
|
{
|
||||||
|
if(!rsPeers->getPeerDetails(*it1,details))
|
||||||
|
continue ;
|
||||||
|
|
||||||
|
cout << "treating neigh = " << details.name << endl ;
|
||||||
|
cout << " signers = " ;
|
||||||
|
int i = getRowColId(details.name) ;
|
||||||
|
|
||||||
|
for(list<string>::const_iterator it2(details.signers.begin());it2!=details.signers.end();++it2)
|
||||||
|
{
|
||||||
|
cout << *it2 << " " ;
|
||||||
|
// Signers are identified by there name, so if we have twice the same signers, this gets crappy.
|
||||||
|
|
||||||
|
int j = getRowColId(*it2) ;
|
||||||
|
|
||||||
|
QString trr( (i==j)?"Self":"Trust") ;
|
||||||
|
|
||||||
|
if(trustTableTW->item(i,j) == NULL)
|
||||||
|
trustTableTW->setItem(i,j,new QTableWidgetItem(trr)) ;
|
||||||
|
else
|
||||||
|
trustTableTW->item(i,j)->setText(trr) ;
|
||||||
|
}
|
||||||
|
cout << endl ;
|
||||||
|
}
|
||||||
|
// assign colors
|
||||||
|
for(int i=0;i<trustTableTW->rowCount();++i)
|
||||||
|
for(int j=0;j<trustTableTW->columnCount();++j)
|
||||||
|
{
|
||||||
|
QTableWidgetItem *i_ij(trustTableTW->item(i,j)) ;
|
||||||
|
QTableWidgetItem *i_ji(trustTableTW->item(j,i)) ;
|
||||||
|
|
||||||
|
QColor color ;
|
||||||
|
|
||||||
|
// check bidirectional trust
|
||||||
|
//
|
||||||
|
if(i_ij != NULL)
|
||||||
|
{
|
||||||
|
if(i_ji == NULL)
|
||||||
|
{
|
||||||
|
i_ij->setBackgroundColor(Qt::yellow) ;
|
||||||
|
i_ij->setToolTip(trustTableTW->horizontalHeaderItem(i)->text() + QString(" is trusted (one way) by " )+trustTableTW->verticalHeaderItem(j)->text()) ;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(i==j)
|
||||||
|
{
|
||||||
|
i_ij->setBackgroundColor(Qt::red) ;
|
||||||
|
i_ij->setToolTip(trustTableTW->horizontalHeaderItem(i)->text() + QString(" trusts himself") ) ;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
i_ij->setBackgroundColor(Qt::green) ;
|
||||||
|
i_ij->setToolTip(trustTableTW->horizontalHeaderItem(i)->text() + " and " +trustTableTW->verticalHeaderItem(j)->text() + QString(" trust each others") ) ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
27
retroshare-gui/src/gui/TrustView.h
Normal file
27
retroshare-gui/src/gui/TrustView.h
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
#include "ui_TrustView.h"
|
||||||
|
|
||||||
|
class QWheelEvent ;
|
||||||
|
|
||||||
|
class TrustView: public QWidget, public Ui::TrustView
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
TrustView() ;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void wheelEvent(QWheelEvent *) ;
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void update() ;
|
||||||
|
void updateZoom(int) ;
|
||||||
|
void selectCell(int,int) ;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void getCellSize(int z,int& cell_width,int& cell_height) const ;
|
||||||
|
int getRowColId(const std::string& name) ;
|
||||||
|
|
||||||
|
static const int _base_cell_width = 60 ;
|
||||||
|
static const int _base_cell_height = 30 ;
|
||||||
|
};
|
||||||
|
|
66
retroshare-gui/src/gui/TrustView.ui
Normal file
66
retroshare-gui/src/gui/TrustView.ui
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
<ui version="4.0" >
|
||||||
|
<class>TrustView</class>
|
||||||
|
<widget class="QWidget" name="TrustView" >
|
||||||
|
<property name="geometry" >
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>468</width>
|
||||||
|
<height>394</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle" >
|
||||||
|
<string>Form</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout" >
|
||||||
|
<item>
|
||||||
|
<widget class="QTableWidget" name="trustTableTW" />
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout" >
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="trustInconsistencyCB" >
|
||||||
|
<property name="text" >
|
||||||
|
<string>Show trust inconsistencies</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="Line" name="line" >
|
||||||
|
<property name="orientation" >
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="updatePB" >
|
||||||
|
<property name="text" >
|
||||||
|
<string>Update</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label" >
|
||||||
|
<property name="text" >
|
||||||
|
<string>Zoom :</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QSlider" name="zoomHS" >
|
||||||
|
<property name="maximum" >
|
||||||
|
<number>100</number>
|
||||||
|
</property>
|
||||||
|
<property name="orientation" >
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<layoutdefault spacing="2" margin="3" />
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
Loading…
x
Reference in New Issue
Block a user