mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-07 06:02:41 -04:00
dynamic update of networkview from p3disc info. Disabled friend level for now.
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3752 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
3fa3e2d6db
commit
a32bcbb635
14 changed files with 194 additions and 202 deletions
|
@ -199,6 +199,7 @@ class NotifyBase
|
||||||
/* one or more peers has changed the states */
|
/* one or more peers has changed the states */
|
||||||
virtual void notifyPeerStatusChangedSummary() {}
|
virtual void notifyPeerStatusChangedSummary() {}
|
||||||
virtual void notifyChannelMsgReadSatusChanged(const std::string& /* channelId */, const std::string& /* msgId */, uint32_t /* status */) {}
|
virtual void notifyChannelMsgReadSatusChanged(const std::string& /* channelId */, const std::string& /* msgId */, uint32_t /* status */) {}
|
||||||
|
virtual void notifyDiscInfoChanged() {}
|
||||||
|
|
||||||
virtual std::string askForPassword(const std::string& /* key_details */ ,bool /* prev_is_bad */ ) { return "" ;}
|
virtual std::string askForPassword(const std::string& /* key_details */ ,bool /* prev_is_bad */ ) { return "" ;}
|
||||||
};
|
};
|
||||||
|
|
|
@ -618,9 +618,15 @@ void p3disc::recvPeerDetails(RsDiscReply *item, const std::string &certGpgId)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool should_notify_discovery = false ;
|
||||||
|
|
||||||
for (std::list<RsPeerNetItem>::iterator pitem = item->rsPeerList.begin(); pitem != item->rsPeerList.end(); pitem++)
|
for (std::list<RsPeerNetItem>::iterator pitem = item->rsPeerList.begin(); pitem != item->rsPeerList.end(); pitem++)
|
||||||
{
|
{
|
||||||
addDiscoveryData(item->PeerId(), pitem->pid, pitem->currentlocaladdr, pitem->currentremoteaddr, 0, time(NULL));
|
bool new_info ;
|
||||||
|
addDiscoveryData(item->PeerId(), pitem->pid, pitem->currentlocaladdr, pitem->currentremoteaddr, 0, time(NULL),new_info);
|
||||||
|
|
||||||
|
if(new_info)
|
||||||
|
should_notify_discovery = true ;
|
||||||
|
|
||||||
#ifdef P3DISC_DEBUG
|
#ifdef P3DISC_DEBUG
|
||||||
std::cerr << "p3disc::recvPeerFriendMsg() Peer Config Item:" << std::endl;
|
std::cerr << "p3disc::recvPeerFriendMsg() Peer Config Item:" << std::endl;
|
||||||
|
@ -725,6 +731,9 @@ void p3disc::recvPeerDetails(RsDiscReply *item, const std::string &certGpgId)
|
||||||
|
|
||||||
rsicontrol->getNotify().notifyListChange(NOTIFY_LIST_NEIGHBOURS, NOTIFY_TYPE_MOD);
|
rsicontrol->getNotify().notifyListChange(NOTIFY_LIST_NEIGHBOURS, NOTIFY_TYPE_MOD);
|
||||||
|
|
||||||
|
if(should_notify_discovery)
|
||||||
|
rsicontrol->getNotify().notifyDiscInfoChanged();
|
||||||
|
|
||||||
/* cleanup (handled by caller) */
|
/* cleanup (handled by caller) */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -894,10 +903,12 @@ void p3disc::setGPGOperation(AuthGPGOperation *operation)
|
||||||
/*************************************************************************************/
|
/*************************************************************************************/
|
||||||
/* Storing Network Graph */
|
/* Storing Network Graph */
|
||||||
/*************************************************************************************/
|
/*************************************************************************************/
|
||||||
int p3disc::addDiscoveryData(std::string fromId, std::string aboutId, struct sockaddr_in laddr, struct sockaddr_in raddr, uint32_t flags, time_t ts)
|
int p3disc::addDiscoveryData(std::string fromId, std::string aboutId, struct sockaddr_in laddr, struct sockaddr_in raddr, uint32_t flags, time_t ts,bool& new_info)
|
||||||
{
|
{
|
||||||
RsStackMutex stack(mDiscMtx); /********** STACK LOCKED MTX ******/
|
RsStackMutex stack(mDiscMtx); /********** STACK LOCKED MTX ******/
|
||||||
|
|
||||||
|
new_info = false ;
|
||||||
|
std::cerr << "Adding discovery data " << fromId << " - " << aboutId << std::endl ;
|
||||||
/* Store Network information */
|
/* Store Network information */
|
||||||
std::map<std::string, autoneighbour>::iterator it;
|
std::map<std::string, autoneighbour>::iterator it;
|
||||||
if (neighbours.end() == (it = neighbours.find(aboutId)))
|
if (neighbours.end() == (it = neighbours.find(aboutId)))
|
||||||
|
@ -914,6 +925,7 @@ int p3disc::addDiscoveryData(std::string fromId, std::string aboutId, struct soc
|
||||||
neighbours[aboutId] = an;
|
neighbours[aboutId] = an;
|
||||||
|
|
||||||
it = neighbours.find(aboutId);
|
it = neighbours.find(aboutId);
|
||||||
|
new_info = true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* it always valid */
|
/* it always valid */
|
||||||
|
@ -943,7 +955,11 @@ int p3disc::addDiscoveryData(std::string fromId, std::string aboutId, struct soc
|
||||||
it->second.discFlags = as.discFlags;
|
it->second.discFlags = as.discFlags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(it->second.neighbour_of.find(fromId) == it->second.neighbour_of.end())
|
||||||
|
{
|
||||||
(it->second).neighbour_of[fromId] = as;
|
(it->second).neighbour_of[fromId] = as;
|
||||||
|
new_info =true ;
|
||||||
|
}
|
||||||
|
|
||||||
/* do we update network address info??? */
|
/* do we update network address info??? */
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -959,6 +975,9 @@ bool p3disc::potentialproxies(std::string id, std::list<std::string> &proxyIds)
|
||||||
{
|
{
|
||||||
/* find id -> and extract the neighbour_of ids */
|
/* find id -> and extract the neighbour_of ids */
|
||||||
|
|
||||||
|
if(id == rsPeers->getOwnId()) // SSL id // This is treated appart, because otherwise we don't receive any disc info about us
|
||||||
|
return rsPeers->getFriendList(proxyIds) ;
|
||||||
|
|
||||||
RsStackMutex stack(mDiscMtx); /********** STACK LOCKED MTX ******/
|
RsStackMutex stack(mDiscMtx); /********** STACK LOCKED MTX ******/
|
||||||
|
|
||||||
std::map<std::string, autoneighbour>::iterator it;
|
std::map<std::string, autoneighbour>::iterator it;
|
||||||
|
|
|
@ -132,7 +132,7 @@ void removeFriend(std::string ssl_id); //keep tracks of removed friend so we're
|
||||||
/* handle network shape */
|
/* handle network shape */
|
||||||
int addDiscoveryData(std::string fromId, std::string aboutId,
|
int addDiscoveryData(std::string fromId, std::string aboutId,
|
||||||
struct sockaddr_in laddr, struct sockaddr_in raddr,
|
struct sockaddr_in laddr, struct sockaddr_in raddr,
|
||||||
uint32_t flags, time_t ts);
|
uint32_t flags, time_t ts,bool& new_info);
|
||||||
|
|
||||||
int idServers();
|
int idServers();
|
||||||
|
|
||||||
|
|
|
@ -146,7 +146,7 @@ NetworkDialog::NetworkDialog(QWidget *parent)
|
||||||
ui.unvalidGPGkeyWidget->sortItems( 1, Qt::AscendingOrder );
|
ui.unvalidGPGkeyWidget->sortItems( 1, Qt::AscendingOrder );
|
||||||
|
|
||||||
ui.networkTab->addTab(new TrustView(),QString(tr("Authentication matrix")));
|
ui.networkTab->addTab(new TrustView(),QString(tr("Authentication matrix")));
|
||||||
ui.networkTab->addTab(new NetworkView(),QString(tr("Network View")));
|
ui.networkTab->addTab(networkview = new NetworkView(),QString(tr("Network View")));
|
||||||
|
|
||||||
QString version = "-";
|
QString version = "-";
|
||||||
std::map<std::string, std::string>::iterator vit;
|
std::map<std::string, std::string>::iterator vit;
|
||||||
|
@ -201,6 +201,13 @@ NetworkDialog::NetworkDialog(QWidget *parent)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NetworkDialog::updateNewDiscoveryInfo()
|
||||||
|
{
|
||||||
|
std::cerr << "Received new p3disc info. Updating networkview." << std::endl;
|
||||||
|
networkview->update();
|
||||||
|
networkview->updateDisplay();
|
||||||
|
}
|
||||||
|
|
||||||
void NetworkDialog::connecttreeWidgetCostumPopupMenu( QPoint point )
|
void NetworkDialog::connecttreeWidgetCostumPopupMenu( QPoint point )
|
||||||
{
|
{
|
||||||
std::cerr << "NetworkDialog::connecttreeWidgetCostumPopupMenu( QPoint point ) called" << std::endl;
|
std::cerr << "NetworkDialog::connecttreeWidgetCostumPopupMenu( QPoint point ) called" << std::endl;
|
||||||
|
|
|
@ -42,6 +42,7 @@ public slots:
|
||||||
std::string loadneighbour();
|
std::string loadneighbour();
|
||||||
/* void loadneighbour(); */
|
/* void loadneighbour(); */
|
||||||
void setLogInfo(QString info, QColor color=QApplication::palette().color(QPalette::WindowText));
|
void setLogInfo(QString info, QColor color=QApplication::palette().color(QPalette::WindowText));
|
||||||
|
void updateNewDiscoveryInfo() ;
|
||||||
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
|
|
||||||
#include "NetworkView.h"
|
#include "NetworkView.h"
|
||||||
#include <retroshare/rspeers.h>
|
#include <retroshare/rspeers.h>
|
||||||
|
#include <retroshare/rsdisc.h>
|
||||||
|
|
||||||
#include <gpgme.h>
|
#include <gpgme.h>
|
||||||
|
|
||||||
|
@ -31,9 +32,14 @@
|
||||||
|
|
||||||
#include "gui/elastic/node.h"
|
#include "gui/elastic/node.h"
|
||||||
|
|
||||||
|
/********
|
||||||
|
* #define DEBUG_NETWORKVIEW
|
||||||
|
********/
|
||||||
|
#define DEBUG_NETWORKVIEW
|
||||||
|
|
||||||
/** Constructor */
|
/** Constructor */
|
||||||
NetworkView::NetworkView(QWidget *parent)
|
NetworkView::NetworkView(QWidget *parent)
|
||||||
: MainPage(parent)
|
: RsAutoUpdatePage(60000,parent)
|
||||||
{
|
{
|
||||||
/* Invoke the Qt Designer generated object setup routine */
|
/* Invoke the Qt Designer generated object setup routine */
|
||||||
ui.setupUi(this);
|
ui.setupUi(this);
|
||||||
|
@ -45,7 +51,7 @@ NetworkView::NetworkView(QWidget *parent)
|
||||||
setMaxFriendLevel(ui.maxFriendLevelSB->value()) ;
|
setMaxFriendLevel(ui.maxFriendLevelSB->value()) ;
|
||||||
|
|
||||||
/* add button */
|
/* add button */
|
||||||
connect( ui.refreshButton, SIGNAL( clicked( void ) ), this, SLOT( insertPeers( void ) ) );
|
connect( ui.refreshButton, SIGNAL( clicked( void ) ), this, SLOT( updateDisplay( void ) ) );
|
||||||
connect( mScene, SIGNAL( changed ( const QList<QRectF> & ) ), this, SLOT ( changedScene( void ) ) );
|
connect( mScene, SIGNAL( changed ( const QList<QRectF> & ) ), this, SLOT ( changedScene( void ) ) );
|
||||||
|
|
||||||
/* Hide Settings frame */
|
/* Hide Settings frame */
|
||||||
|
@ -53,7 +59,7 @@ NetworkView::NetworkView(QWidget *parent)
|
||||||
connect( ui.maxFriendLevelSB, SIGNAL(valueChanged(int)), this, SLOT(setMaxFriendLevel(int)));
|
connect( ui.maxFriendLevelSB, SIGNAL(valueChanged(int)), this, SLOT(setMaxFriendLevel(int)));
|
||||||
connect( ui.edgeLengthSB, SIGNAL(valueChanged(int)), this, SLOT(setEdgeLength(int)));
|
connect( ui.edgeLengthSB, SIGNAL(valueChanged(int)), this, SLOT(setEdgeLength(int)));
|
||||||
|
|
||||||
insertPeers();
|
_should_update = true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NetworkView::setEdgeLength(int l)
|
void NetworkView::setEdgeLength(int l)
|
||||||
|
@ -63,21 +69,11 @@ void NetworkView::setEdgeLength(int l)
|
||||||
void NetworkView::setMaxFriendLevel(int m)
|
void NetworkView::setMaxFriendLevel(int m)
|
||||||
{
|
{
|
||||||
_max_friend_level = m ;
|
_max_friend_level = m ;
|
||||||
insertPeers() ;
|
updateDisplay() ;
|
||||||
}
|
}
|
||||||
void NetworkView::changedFoFCheckBox( )
|
void NetworkView::changedFoFCheckBox( )
|
||||||
{
|
{
|
||||||
insertPeers();
|
updateDisplay();
|
||||||
}
|
|
||||||
|
|
||||||
void NetworkView::changedDrawSignatures( )
|
|
||||||
{
|
|
||||||
insertPeers();
|
|
||||||
}
|
|
||||||
|
|
||||||
void NetworkView::changedDrawFriends( )
|
|
||||||
{
|
|
||||||
insertPeers();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void NetworkView::clearPeerItems()
|
void NetworkView::clearPeerItems()
|
||||||
|
@ -120,47 +116,60 @@ void NetworkView::clearLineItems()
|
||||||
class NodeInfo
|
class NodeInfo
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
NodeInfo(const std::string& id,uint32_t lev) : gpg_id(id),friend_level(lev) {}
|
NodeInfo(const std::string& _gpg_id,const std::string& _ssl_id,uint32_t lev) : gpg_id(_gpg_id),ssl_id(_ssl_id),friend_level(lev) {}
|
||||||
|
|
||||||
std::string gpg_id ;
|
std::string gpg_id ;
|
||||||
|
std::string ssl_id ;
|
||||||
uint32_t friend_level ;
|
uint32_t friend_level ;
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
void NetworkView::insertPeers()
|
void NetworkView::update()
|
||||||
{
|
{
|
||||||
/* clear graphics scene */
|
_should_update = true ;
|
||||||
ui.graphicsView->clearGraph();
|
}
|
||||||
|
void NetworkView::updateDisplay()
|
||||||
|
{
|
||||||
|
if(!isVisible())
|
||||||
|
return ;
|
||||||
|
if(!_should_update)
|
||||||
|
return ;
|
||||||
|
|
||||||
/* add all friends */
|
/* add all friends */
|
||||||
std::string ownId = rsPeers->getGPGOwnId();
|
std::string ownGPGId = rsPeers->getGPGOwnId();
|
||||||
std::cerr << "NetworkView::insertPeers()" << std::endl;
|
std::string ownSSLId = rsPeers->getOwnId();
|
||||||
|
#ifdef DEBUG_NETWORKVIEW
|
||||||
|
std::cerr << "NetworkView::updateDisplay()" << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
std::map<std::string,GraphWidget::NodeId> node_ids ; // node ids of the created nodes.
|
|
||||||
std::deque<NodeInfo> nodes_to_treat ; // list of nodes to be treated. Used as a queue. The int is the level of friendness
|
std::deque<NodeInfo> nodes_to_treat ; // list of nodes to be treated. Used as a queue. The int is the level of friendness
|
||||||
std::set<std::string> nodes_considered ; // list of nodes already considered. Eases lookup.
|
std::set<std::string> nodes_considered ; // list of nodes already considered. Eases lookup.
|
||||||
|
|
||||||
nodes_to_treat.push_front(NodeInfo(ownId,0)) ; // initialize queue with own id.
|
nodes_to_treat.push_front(NodeInfo(ownGPGId,ownSSLId,0)) ; // initialize queue with own id.
|
||||||
nodes_considered.insert(ownId) ;
|
nodes_considered.insert(rsPeers->getOwnId()) ;
|
||||||
|
|
||||||
// compute the list of GPG friends
|
// compute the list of GPG friends
|
||||||
|
|
||||||
std::set<std::string> gpg_friends ;
|
std::set<std::string> gpg_friends ;
|
||||||
std::list<std::string> ssl_friends ;
|
std::list<std::string> friends ;
|
||||||
|
std::set<std::string> ssl_friends ;
|
||||||
|
|
||||||
if(!rsPeers->getFriendList(ssl_friends))
|
if(!rsPeers->getFriendList(friends))
|
||||||
return ;
|
return ;
|
||||||
|
|
||||||
for(std::list<std::string>::const_iterator it(ssl_friends.begin());it!=ssl_friends.end();++it)
|
for(std::list<std::string>::const_iterator it(friends.begin());it!=friends.end();++it)
|
||||||
{
|
{
|
||||||
RsPeerDetails d ;
|
RsPeerDetails d ;
|
||||||
if(!rsPeers->getPeerDetails(*it,d))
|
if(!rsPeers->getPeerDetails(*it,d))
|
||||||
continue ;
|
continue ;
|
||||||
|
|
||||||
gpg_friends.insert(d.gpg_id) ;
|
gpg_friends.insert(d.gpg_id) ;
|
||||||
|
ssl_friends.insert(d.id) ;
|
||||||
}
|
}
|
||||||
std::cerr << "Found " << gpg_friends.size() << " gpg friends." << std::endl ;
|
#ifdef DEBUG_NETWORKVIEW
|
||||||
|
std::cerr << "Found " << ssl_friends.size() << " gpg friends." << std::endl ;
|
||||||
|
#endif
|
||||||
|
|
||||||
// Put own id in queue, and empty the queue, treating all nodes.
|
// Put own id in queue, and empty the queue, treating all nodes.
|
||||||
//
|
//
|
||||||
|
@ -168,19 +177,23 @@ void NetworkView::insertPeers()
|
||||||
{
|
{
|
||||||
NodeInfo info(nodes_to_treat.back()) ;
|
NodeInfo info(nodes_to_treat.back()) ;
|
||||||
nodes_to_treat.pop_back() ;
|
nodes_to_treat.pop_back() ;
|
||||||
|
#ifdef DEBUG_NETWORKVIEW
|
||||||
|
std::cerr << " Poped out of queue: " << info.ssl_id << ", with level " << info.friend_level << std::endl ;
|
||||||
|
#endif
|
||||||
|
std::list<std::string> friendList;
|
||||||
|
rsDisc->getDiscFriends(info.ssl_id, friendList);
|
||||||
|
|
||||||
std::cerr << " Poped out of queue: " << info.gpg_id << ", with level " << info.friend_level << std::endl ;
|
#ifdef DEBUG_NETWORKVIEW
|
||||||
RsPeerDetails detail ;
|
std::cerr << " Got a list of " << friendList.size() << " friends for this peer." << std::endl ;
|
||||||
|
#endif
|
||||||
|
// if(!rsPeers->getPeerDetails(info.gpg_id,detail))
|
||||||
|
// {
|
||||||
|
// std::cerr << "Could not request GPG details for node " << info.gpg_id << std::endl ;
|
||||||
|
// continue ;
|
||||||
|
// }
|
||||||
|
|
||||||
if(!rsPeers->getPeerDetails(info.gpg_id,detail))
|
// if(info.friend_level <= _max_friend_level && (info.friend_level != 1 || ssl_friends.find(info.ssl_id) != ssl_friends.end()))
|
||||||
{
|
{
|
||||||
std::cerr << "Could not request GPG details for node " << info.gpg_id << std::endl ;
|
|
||||||
continue ;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(info.friend_level <= _max_friend_level && (info.friend_level != 1 || gpg_friends.find(info.gpg_id) != gpg_friends.end()))
|
|
||||||
{
|
|
||||||
|
|
||||||
GraphWidget::NodeType type ;
|
GraphWidget::NodeType type ;
|
||||||
GraphWidget::AuthType auth ;
|
GraphWidget::AuthType auth ;
|
||||||
|
|
||||||
|
@ -196,6 +209,10 @@ void NetworkView::insertPeers()
|
||||||
type = GraphWidget::ELASTIC_NODE_TYPE_UNKNOWN ;
|
type = GraphWidget::ELASTIC_NODE_TYPE_UNKNOWN ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RsPeerDetails detail ;
|
||||||
|
if (!rsPeers->getPeerDetails(info.ssl_id, detail))
|
||||||
|
continue ;
|
||||||
|
|
||||||
switch(detail.validLvl)
|
switch(detail.validLvl)
|
||||||
{
|
{
|
||||||
case GPGME_VALIDITY_MARGINAL: auth = GraphWidget::ELASTIC_NODE_AUTH_MARGINAL ; break;
|
case GPGME_VALIDITY_MARGINAL: auth = GraphWidget::ELASTIC_NODE_AUTH_MARGINAL ; break;
|
||||||
|
@ -207,16 +224,22 @@ void NetworkView::insertPeers()
|
||||||
default: auth = GraphWidget::ELASTIC_NODE_AUTH_UNKNOWN ; break ;
|
default: auth = GraphWidget::ELASTIC_NODE_AUTH_UNKNOWN ; break ;
|
||||||
}
|
}
|
||||||
|
|
||||||
node_ids[info.gpg_id] = ui.graphicsView->addNode(" "+detail.name, detail.name+"@"+info.gpg_id,type,auth);
|
if(_node_ids.find(info.ssl_id) == _node_ids.end())
|
||||||
std::cerr << " inserted node " << info.gpg_id << ", type=" << type << ", auth=" << auth << std::endl ;
|
{
|
||||||
|
_node_ids[info.ssl_id] = ui.graphicsView->addNode(" "+detail.name +"("+detail.location+")", "("+detail.name+","+info.ssl_id+","+detail.gpg_id+")",type,auth);
|
||||||
|
#ifdef DEBUG_NETWORKVIEW
|
||||||
|
std::cerr << " inserted node " << info.ssl_id << ", type=" << type << ", auth=" << auth << std::endl ;
|
||||||
|
std::cerr << " NetworkView::updateDisplay() Added Friend: " << info.ssl_id << std::endl;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
std::cerr << "NetworkView::insertPeers() Added Friend: " << info.gpg_id << std::endl;
|
for(std::list<std::string>::const_iterator sit(friendList.begin()); sit != friendList.end(); ++sit)
|
||||||
|
|
||||||
for(std::list<std::string>::const_iterator sit(detail.gpgSigners.begin()); sit != detail.gpgSigners.end(); ++sit)
|
|
||||||
if(nodes_considered.find(*sit) == nodes_considered.end())
|
if(nodes_considered.find(*sit) == nodes_considered.end())
|
||||||
{
|
{
|
||||||
|
#ifdef DEBUG_NETWORKVIEW
|
||||||
std::cerr << " adding to queue: " << *sit << ", with level " << info.friend_level+1 << std::endl ;
|
std::cerr << " adding to queue: " << *sit << ", with level " << info.friend_level+1 << std::endl ;
|
||||||
nodes_to_treat.push_front( NodeInfo(*sit,info.friend_level + 1) ) ;
|
#endif
|
||||||
|
nodes_to_treat.push_front( NodeInfo("unknown",*sit,info.friend_level + 1) ) ;
|
||||||
nodes_considered.insert(*sit) ;
|
nodes_considered.insert(*sit) ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -224,114 +247,32 @@ void NetworkView::insertPeers()
|
||||||
|
|
||||||
/* iterate through all friends */
|
/* iterate through all friends */
|
||||||
|
|
||||||
|
#ifdef DEBUG_NETWORKVIEW
|
||||||
std::cerr << "NetworkView::insertSignatures()" << std::endl;
|
std::cerr << "NetworkView::insertSignatures()" << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
for(std::map<std::string,GraphWidget::NodeId>::const_iterator it(node_ids.begin()); it != node_ids.end(); it++)
|
for(std::map<std::string,GraphWidget::NodeId>::const_iterator it(_node_ids.begin()); it != _node_ids.end(); it++)
|
||||||
{
|
{
|
||||||
RsPeerDetails detail;
|
std::list<std::string> friendList ;
|
||||||
if (!rsPeers->getPeerDetails(it->first, detail))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
for(std::list<std::string>::const_iterator sit(detail.gpgSigners.begin()); sit != detail.gpgSigners.end(); sit++)
|
if(rsDisc->getDiscFriends(it->first,friendList))
|
||||||
|
for(std::list<std::string>::const_iterator sit(friendList.begin()); sit != friendList.end(); sit++)
|
||||||
{
|
{
|
||||||
if(it->first < *sit)
|
if(it->first < *sit)
|
||||||
{
|
{
|
||||||
|
#ifdef DEBUG_NETWORKVIEW
|
||||||
std::cerr << "NetworkView: Adding Arrow: ";
|
std::cerr << "NetworkView: Adding Arrow: ";
|
||||||
std::cerr << *sit << " <-> " << it->first;
|
std::cerr << *sit << " <-> " << it->first;
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
|
||||||
if(node_ids.find(*sit) != node_ids.end())
|
|
||||||
ui.graphicsView->addEdge(node_ids[*sit], it->second);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void NetworkView::insertConnections()
|
|
||||||
{
|
|
||||||
#if 0
|
|
||||||
/* iterate through all friends */
|
|
||||||
std::list<std::string> fids, ids;
|
|
||||||
std::list<std::string>::iterator it;
|
|
||||||
|
|
||||||
std::string ownId = rsPeers->getGPGOwnId();
|
|
||||||
rsPeers->getPGPAllList(ids);
|
|
||||||
rsPeers->getPGPFriendList(fids);
|
|
||||||
|
|
||||||
std::cerr << "NetworkView::insertConnections()" << std::endl;
|
|
||||||
|
|
||||||
// For the moment, only add friends.
|
|
||||||
for(it = fids.begin(); it != fids.end(); it++)
|
|
||||||
{
|
|
||||||
ui.graphicsView->addEdge("", *it);
|
|
||||||
std::cerr << "NetworkView: Adding Edge: Self -> " << *it;
|
|
||||||
std::cerr << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
int i = 0;
|
|
||||||
for(it = ids.begin(); it != ids.end(); it++, i++)
|
|
||||||
{
|
|
||||||
if (rsPeers->isFriend(*it))
|
|
||||||
{
|
|
||||||
/* add own connection (check for it first) */
|
|
||||||
std::list<std::string> &refList = connLists[*it];
|
|
||||||
if (refList.end() == std::find(refList.begin(), refList.end(), ownId))
|
|
||||||
{
|
|
||||||
connLists[ownId].push_back(*it);
|
|
||||||
connLists[*it].push_back(ownId);
|
|
||||||
|
|
||||||
ui.graphicsView->addEdge("", *it);
|
|
||||||
std::cerr << "NetworkView: Adding Edge: Self -> " << *it;
|
|
||||||
std::cerr << std::endl;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
std::cerr << "NetworkView: Already Edge: Self -> " << *it;
|
|
||||||
std::cerr << std::endl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
std::list<std::string> friendList;
|
|
||||||
std::list<std::string>::iterator it2;
|
|
||||||
|
|
||||||
rsDisc->getDiscFriends(*it, friendList);
|
|
||||||
int j = 0;
|
|
||||||
|
|
||||||
for(it2 = friendList.begin(); it2 != friendList.end(); it2++)
|
|
||||||
{
|
|
||||||
if (*it == *it2)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
/* check that we haven't added this one already */
|
|
||||||
std::list<std::string> &refList = connLists[*it];
|
|
||||||
if (refList.end() == std::find(refList.begin(), refList.end(), *it2))
|
|
||||||
{
|
|
||||||
connLists[*it2].push_back(*it);
|
|
||||||
connLists[*it].push_back(*it2);
|
|
||||||
|
|
||||||
ui.graphicsView->addEdge(*it, *it2);
|
|
||||||
std::cerr << "NetworkView: Adding Edge: " << *it << " <-> " << *it2;
|
|
||||||
std::cerr << std::endl;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
std::cerr << "NetworkView: Already Edge: " << *it << " <-> " << *it2;
|
|
||||||
std::cerr << std::endl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if(_node_ids.find(*sit) != _node_ids.end())
|
||||||
|
ui.graphicsView->addEdge(_node_ids[*sit], it->second);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void NetworkView::insertSignatures()
|
_should_update = false ;
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void NetworkView::changedScene()
|
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -24,31 +24,28 @@
|
||||||
|
|
||||||
#include <QGraphicsScene>
|
#include <QGraphicsScene>
|
||||||
|
|
||||||
#include "mainpage.h"
|
#include "RsAutoUpdatePage.h"
|
||||||
#include "ui_NetworkView.h"
|
#include "ui_NetworkView.h"
|
||||||
|
|
||||||
|
|
||||||
class NetworkView : public MainPage
|
class NetworkView : public RsAutoUpdatePage
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
NetworkView(QWidget *parent = 0);
|
NetworkView(QWidget *parent = 0);
|
||||||
|
|
||||||
|
virtual void updateDisplay() ; // derived from RsAutoUpdatePage
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void update() ;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
void setMaxFriendLevel(int) ;
|
void setMaxFriendLevel(int) ;
|
||||||
void setEdgeLength(int) ;
|
void setEdgeLength(int) ;
|
||||||
void insertPeers();
|
|
||||||
void insertSignatures();
|
|
||||||
void insertConnections();
|
|
||||||
|
|
||||||
void changedScene();
|
|
||||||
|
|
||||||
void changedFoFCheckBox( );
|
void changedFoFCheckBox( );
|
||||||
void changedDrawSignatures( );
|
|
||||||
void changedDrawFriends( );
|
|
||||||
|
|
||||||
/** Called when Settings button is toggled */
|
/** Called when Settings button is toggled */
|
||||||
void shownwSettingsFrame(bool show);
|
void shownwSettingsFrame(bool show);
|
||||||
|
@ -71,6 +68,9 @@ private:
|
||||||
/** Qt Designer generated object */
|
/** Qt Designer generated object */
|
||||||
Ui::NetworkView ui;
|
Ui::NetworkView ui;
|
||||||
int _max_friend_level ;
|
int _max_friend_level ;
|
||||||
|
std::map<std::string,GraphWidget::NodeId> _node_ids ;
|
||||||
|
|
||||||
|
bool _should_update ;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -125,6 +125,7 @@ GraphWidget::GraphWidget(QWidget *)
|
||||||
{
|
{
|
||||||
QGraphicsScene *scene = new QGraphicsScene(this);
|
QGraphicsScene *scene = new QGraphicsScene(this);
|
||||||
scene->setItemIndexMethod(QGraphicsScene::NoIndex);
|
scene->setItemIndexMethod(QGraphicsScene::NoIndex);
|
||||||
|
scene->clear() ;
|
||||||
scene->setSceneRect(-200, -200, 1000, 1000);
|
scene->setSceneRect(-200, -200, 1000, 1000);
|
||||||
setScene(scene);
|
setScene(scene);
|
||||||
|
|
||||||
|
@ -167,15 +168,25 @@ GraphWidget::NodeId GraphWidget::addNode(const std::string& node_short_string,co
|
||||||
node->setToolTip(QString::fromStdString(node_complete_string)) ;
|
node->setToolTip(QString::fromStdString(node_complete_string)) ;
|
||||||
_nodes.push_back(node) ;
|
_nodes.push_back(node) ;
|
||||||
scene()->addItem(node);
|
scene()->addItem(node);
|
||||||
node->setPos(-50+rand()%1000/53.0f, -50+rand()%1000/53.0f);
|
node->setPos(rand()%1000/53.0f, rand()%1000/53.0f);
|
||||||
|
std::cerr << "Added node " << _nodes.size()-1 << std::endl ;
|
||||||
return _nodes.size()-1 ;
|
return _nodes.size()-1 ;
|
||||||
}
|
}
|
||||||
GraphWidget::EdgeId GraphWidget::addEdge(NodeId n1,NodeId n2)
|
GraphWidget::EdgeId GraphWidget::addEdge(NodeId n1,NodeId n2)
|
||||||
|
{
|
||||||
|
std::pair<NodeId,NodeId> ed(std::min(n1,n2),std::max(n1,n2)) ;
|
||||||
|
|
||||||
|
if( _edges.find(ed) == _edges.end() )
|
||||||
{
|
{
|
||||||
Edge *edge = new Edge(_nodes[n1],_nodes[n2]);
|
Edge *edge = new Edge(_nodes[n1],_nodes[n2]);
|
||||||
scene()->addItem(edge);
|
scene()->addItem(edge);
|
||||||
|
_edges[ed] = edge ;
|
||||||
|
std::cerr << "Added edge " << n1 << " - " << n2 << std::endl ;
|
||||||
|
}
|
||||||
|
|
||||||
return 0 ;
|
return 0 ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphWidget::itemMoved()
|
void GraphWidget::itemMoved()
|
||||||
{
|
{
|
||||||
if (!timerId)
|
if (!timerId)
|
||||||
|
|
|
@ -42,10 +42,12 @@
|
||||||
#ifndef GRAPHWIDGET_H
|
#ifndef GRAPHWIDGET_H
|
||||||
#define GRAPHWIDGET_H
|
#define GRAPHWIDGET_H
|
||||||
|
|
||||||
|
#include <map>
|
||||||
#include <QtGui/QGraphicsView>
|
#include <QtGui/QGraphicsView>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
class Node;
|
class Node;
|
||||||
|
class Edge;
|
||||||
|
|
||||||
class GraphWidget : public QGraphicsView
|
class GraphWidget : public QGraphicsView
|
||||||
{
|
{
|
||||||
|
@ -93,7 +95,7 @@ private:
|
||||||
bool mDeterminedBB ;
|
bool mDeterminedBB ;
|
||||||
|
|
||||||
std::vector<Node *> _nodes ;
|
std::vector<Node *> _nodes ;
|
||||||
std::vector<Node *> _edges ;
|
std::map<std::pair<NodeId,NodeId>,Edge *> _edges ;
|
||||||
|
|
||||||
uint32_t _edge_length ;
|
uint32_t _edge_length ;
|
||||||
};
|
};
|
||||||
|
|
|
@ -73,7 +73,7 @@ void Node::addEdge(Edge *edge)
|
||||||
edge->adjust();
|
edge->adjust();
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<Edge *> Node::edges() const
|
const QList<Edge *>& Node::edges() const
|
||||||
{
|
{
|
||||||
return edgeList;
|
return edgeList;
|
||||||
}
|
}
|
||||||
|
@ -163,8 +163,6 @@ void Node::calculateForces(const double *map,int width,int height,int W,int H,fl
|
||||||
yforce += 0.01*pos.y() * val / weight;
|
yforce += 0.01*pos.y() * val / weight;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const float friction = 0.4 ;
|
|
||||||
|
|
||||||
xforce -= FRICTION_FACTOR * _speedx ;
|
xforce -= FRICTION_FACTOR * _speedx ;
|
||||||
yforce -= FRICTION_FACTOR * _speedy ;
|
yforce -= FRICTION_FACTOR * _speedy ;
|
||||||
|
|
||||||
|
@ -193,10 +191,13 @@ void Node::calculateForces(const double *map,int width,int height,int W,int H,fl
|
||||||
|
|
||||||
bool Node::advance()
|
bool Node::advance()
|
||||||
{
|
{
|
||||||
|
if(_type == GraphWidget::ELASTIC_NODE_TYPE_OWN)
|
||||||
|
return false;
|
||||||
|
|
||||||
float f = std::max(fabs(newPos.x() - pos().x()), fabs(newPos.y() - pos().y())) ;
|
float f = std::max(fabs(newPos.x() - pos().x()), fabs(newPos.y() - pos().y())) ;
|
||||||
|
|
||||||
setPos(newPos);
|
setPos(newPos);
|
||||||
return f > 0.05;
|
return f > 0.5;
|
||||||
}
|
}
|
||||||
|
|
||||||
QRectF Node::boundingRect() const
|
QRectF Node::boundingRect() const
|
||||||
|
|
|
@ -58,7 +58,7 @@ public:
|
||||||
Node(const std::string& node_string,GraphWidget::NodeType type,GraphWidget::AuthType auth,GraphWidget *graphWidget);
|
Node(const std::string& node_string,GraphWidget::NodeType type,GraphWidget::AuthType auth,GraphWidget *graphWidget);
|
||||||
|
|
||||||
void addEdge(Edge *edge);
|
void addEdge(Edge *edge);
|
||||||
QList<Edge *> edges() const;
|
const QList<Edge *>& edges() const;
|
||||||
|
|
||||||
int type() const { return Type; }
|
int type() const { return Type; }
|
||||||
|
|
||||||
|
|
|
@ -71,6 +71,12 @@ std::string NotifyQt::askForPassword(const std::string& key_details,bool prev_is
|
||||||
return res ;
|
return res ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NotifyQt::notifyDiscInfoChanged()
|
||||||
|
{
|
||||||
|
std::cerr << "Notifyqt:: notified that discoveryInfo changed" << std::endl ;
|
||||||
|
|
||||||
|
emit discInfoChanged() ;
|
||||||
|
}
|
||||||
void NotifyQt::notifyDiskFull(uint32_t loc,uint32_t size_in_mb)
|
void NotifyQt::notifyDiskFull(uint32_t loc,uint32_t size_in_mb)
|
||||||
{
|
{
|
||||||
std::cerr << "Notifyqt:: notified that disk is full" << std::endl ;
|
std::cerr << "Notifyqt:: notified that disk is full" << std::endl ;
|
||||||
|
|
|
@ -46,6 +46,7 @@ class NotifyQt: public QObject, public NotifyBase
|
||||||
virtual void notifyPeerStatusChangedSummary();
|
virtual void notifyPeerStatusChangedSummary();
|
||||||
virtual void notifyChannelMsgReadSatusChanged(const std::string& channelId, const std::string& msgId, uint32_t status);
|
virtual void notifyChannelMsgReadSatusChanged(const std::string& channelId, const std::string& msgId, uint32_t status);
|
||||||
|
|
||||||
|
virtual void notifyDiscInfoChanged() ;
|
||||||
virtual std::string askForPassword(const std::string& key_details,bool prev_is_bad) ;
|
virtual std::string askForPassword(const std::string& key_details,bool prev_is_bad) ;
|
||||||
|
|
||||||
/* Notify from GUI */
|
/* Notify from GUI */
|
||||||
|
@ -80,6 +81,7 @@ class NotifyQt: public QObject, public NotifyBase
|
||||||
void publicChatChanged(int type) const ;
|
void publicChatChanged(int type) const ;
|
||||||
void privateChatChanged(int list, int type) const ;
|
void privateChatChanged(int list, int type) const ;
|
||||||
void groupsChanged(int type) const ;
|
void groupsChanged(int type) const ;
|
||||||
|
void discInfoChanged() const ;
|
||||||
void channelMsgReadSatusChanged(const QString& channelId, const QString& msgId, int status);
|
void channelMsgReadSatusChanged(const QString& channelId, const QString& msgId, int status);
|
||||||
|
|
||||||
/* Notify from GUI */
|
/* Notify from GUI */
|
||||||
|
|
|
@ -261,6 +261,7 @@ int main(int argc, char *argv[])
|
||||||
QObject::connect(notify,SIGNAL(ownStatusMessageChanged()),w->peersDialog,SLOT(loadmypersonalstatus()));
|
QObject::connect(notify,SIGNAL(ownStatusMessageChanged()),w->peersDialog,SLOT(loadmypersonalstatus()));
|
||||||
|
|
||||||
QObject::connect(notify,SIGNAL(logInfoChanged(const QString&)) ,w->networkDialog,SLOT(setLogInfo(QString))) ;
|
QObject::connect(notify,SIGNAL(logInfoChanged(const QString&)) ,w->networkDialog,SLOT(setLogInfo(QString))) ;
|
||||||
|
QObject::connect(notify,SIGNAL(discInfoChanged()) ,w->networkDialog,SLOT(updateNewDiscoveryInfo()),Qt::QueuedConnection) ;
|
||||||
QObject::connect(notify,SIGNAL(errorOccurred(int,int,const QString&)),w,SLOT(displayErrorMessage(int,int,const QString&))) ;
|
QObject::connect(notify,SIGNAL(errorOccurred(int,int,const QString&)),w,SLOT(displayErrorMessage(int,int,const QString&))) ;
|
||||||
|
|
||||||
QObject::connect(w->peersDialog,SIGNAL(friendsUpdated()),w->networkDialog,SLOT(insertConnect())) ;
|
QObject::connect(w->peersDialog,SIGNAL(friendsUpdated()),w->networkDialog,SLOT(insertConnect())) ;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue