From 4bb497a9057c6b6a8973095d8f54f5ab1ed9a78e Mon Sep 17 00:00:00 2001 From: csoler Date: Sun, 5 Apr 2009 13:04:18 +0000 Subject: [PATCH] Cleaned the gui a little bit: - added a checkbox to control the use of external servers for ip determination. - put back Network on the left - put channels out of RS_RELEASE_VERSION, as it's not working yet. - NetworkDialog: - set the info in columns about trust to be more explicit - changed dark green into light green to comply with colors in the trust matrix (it's also more readable in light green) - corrected trust strings that appeared in the Last Contact column - changed "generate certificate" in connect friends wizard into "export my certificate..." which is more appropriate git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@1113 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- libretroshare/src/pqi/p3connmgr.cc | 21 +++-- libretroshare/src/pqi/p3connmgr.h | 5 ++ libretroshare/src/rsiface/rspeers.h | 4 + libretroshare/src/rsserver/p3peers.cc | 13 ++++ libretroshare/src/rsserver/p3peers.h | 4 + libretroshare/src/tcponudp/extaddrfinder.cc | 22 +++--- libretroshare/src/tcponudp/extaddrfinder.h | 7 ++ retroshare-gui/src/gui/MainWindow.cpp | 11 +-- retroshare-gui/src/gui/NetworkDialog.cpp | 49 +++++------- retroshare-gui/src/gui/NetworkDialog.ui | 30 +------ .../src/gui/Preferences/ServerDialog.cpp | 16 ++++ .../src/gui/Preferences/ServerDialog.h | 1 + .../src/gui/Preferences/ServerDialog.ui | 78 +++++++------------ .../src/gui/connect/ConnectFriendWizard.cpp | 4 +- retroshare-gui/src/rsiface/rspeers.h | 4 + retroshare-gui/src/rsiface/rsturtle.h | 12 ++- 16 files changed, 145 insertions(+), 136 deletions(-) diff --git a/libretroshare/src/pqi/p3connmgr.cc b/libretroshare/src/pqi/p3connmgr.cc index c04a99355..8de575864 100644 --- a/libretroshare/src/pqi/p3connmgr.cc +++ b/libretroshare/src/pqi/p3connmgr.cc @@ -123,11 +123,23 @@ p3ConnectMgr::p3ConnectMgr(p3AuthMgr *am) ownState.name = mAuthMgr->getName(ownState.id); ownState.netMode = RS_NET_MODE_UDP; } - mExtAddrFinder = NULL ; + use_extr_addr_finder = true ; + mExtAddrFinder = new ExtAddrFinder ; return; } +void p3ConnectMgr::getIPServersList(std::list& ip_servers) +{ + mExtAddrFinder->getIPServersList(ip_servers); +} + +void p3ConnectMgr::setIPServersEnabled(bool b) +{ + use_extr_addr_finder = b ; + + std::cerr << "p3ConnectMgr: setIPServers to " << b << std::endl ; +} void p3ConnectMgr::setOwnNetConfig(uint32_t netMode, uint32_t visState) { @@ -406,9 +418,6 @@ void p3ConnectMgr::netTick() uint32_t netStatus = mNetStatus; - if(mExtAddrFinder == NULL) - mExtAddrFinder = new ExtAddrFinder ; - connMtx.unlock(); /* UNLOCK MUTEX */ switch(netStatus) @@ -579,7 +588,7 @@ void p3ConnectMgr::netUdpCheck() #endif struct sockaddr_in tmpip ; - if (udpExtAddressCheck() || (mUpnpAddrValid) || mExtAddrFinder->hasValidIP(&tmpip)) + if (udpExtAddressCheck() || (mUpnpAddrValid) || (use_extr_addr_finder && mExtAddrFinder->hasValidIP(&tmpip))) { bool extValid = false; bool extAddrStable = false; @@ -605,7 +614,7 @@ void p3ConnectMgr::netUdpCheck() extAddr = mStunExtAddr; extAddrStable = mStunAddrStable; } - else if(mExtAddrFinder->hasValidIP(&tmpip)) + else if(use_extr_addr_finder && mExtAddrFinder->hasValidIP(&tmpip)) { extValid = true; extAddr = tmpip ; diff --git a/libretroshare/src/pqi/p3connmgr.h b/libretroshare/src/pqi/p3connmgr.h index d02ec121f..6a6e4ff71 100644 --- a/libretroshare/src/pqi/p3connmgr.h +++ b/libretroshare/src/pqi/p3connmgr.h @@ -186,6 +186,10 @@ bool getUPnPState(); bool getUPnPEnabled(); bool getDHTEnabled(); +bool getIPServersEnabled() { return use_extr_addr_finder ;} +void setIPServersEnabled(bool b) ; +void getIPServersList(std::list& ip_servers) ; + bool getNetStatusOk(); bool getNetStatusUpnpOk(); bool getNetStatusDhtOk(); @@ -350,6 +354,7 @@ private: std::list clients; ExtAddrFinder *mExtAddrFinder ; + bool use_extr_addr_finder ; /* external Address determination */ bool mUpnpAddrValid, mStunAddrValid; diff --git a/libretroshare/src/rsiface/rspeers.h b/libretroshare/src/rsiface/rspeers.h index 7807d6bda..278e30e66 100644 --- a/libretroshare/src/rsiface/rspeers.h +++ b/libretroshare/src/rsiface/rspeers.h @@ -144,6 +144,10 @@ virtual bool setExtAddress( std::string id, std::string addr, uint16_t port) = virtual bool setNetworkMode(std::string id, uint32_t netMode) = 0; virtual bool setVisState(std::string id, uint32_t vis) = 0; +virtual void getIPServersList(std::list& ip_servers) = 0; +virtual void allowServerIPDetermination(bool) = 0; +virtual bool getAllowServerIPDetermination() = 0 ; + /* Auth Stuff */ virtual std::string GetRetroshareInvite() = 0; diff --git a/libretroshare/src/rsserver/p3peers.cc b/libretroshare/src/rsserver/p3peers.cc index bf7d7af9f..a31ee220a 100644 --- a/libretroshare/src/rsserver/p3peers.cc +++ b/libretroshare/src/rsserver/p3peers.cc @@ -459,6 +459,19 @@ bool p3Peers::connectAttempt(std::string id) return mConnMgr->retryConnect(id); } +void p3Peers::getIPServersList(std::list& ip_servers) +{ + mConnMgr->getIPServersList(ip_servers) ; +} +void p3Peers::allowServerIPDetermination(bool b) +{ + mConnMgr->setIPServersEnabled(b) ; +} +bool p3Peers::getAllowServerIPDetermination() +{ + return mConnMgr->getIPServersEnabled() ; +} + bool p3Peers::setLocalAddress(std::string id, std::string addr_str, uint16_t port) { #ifdef P3PEERS_DEBUG diff --git a/libretroshare/src/rsserver/p3peers.h b/libretroshare/src/rsserver/p3peers.h index 215684611..76f0f2ec8 100644 --- a/libretroshare/src/rsserver/p3peers.h +++ b/libretroshare/src/rsserver/p3peers.h @@ -67,6 +67,10 @@ virtual bool setExtAddress(std::string id, std::string addr, uint16_t port); virtual bool setNetworkMode(std::string id, uint32_t netMode); virtual bool setVisState(std::string id, uint32_t mode); +virtual void getIPServersList(std::list& ip_servers) ; +virtual void allowServerIPDetermination(bool) ; +virtual bool getAllowServerIPDetermination() ; + /* Auth Stuff */ virtual std::string GetRetroshareInvite(); diff --git a/libretroshare/src/tcponudp/extaddrfinder.cc b/libretroshare/src/tcponudp/extaddrfinder.cc index 30ac21db3..bb6f40c96 100644 --- a/libretroshare/src/tcponudp/extaddrfinder.cc +++ b/libretroshare/src/tcponudp/extaddrfinder.cc @@ -120,31 +120,24 @@ static void getPage(const std::string& server_name,std::string& page) } -extern "C" void* doExtAddrSearch(void *p) +void* doExtAddrSearch(void *p) { - static const int nb_ipservers = 4 ; - const std::string servers[nb_ipservers] = { - "checkip.dyndns.org", - "www.showmyip.com", - "showip.net", - "www.displaymyip.com" - }; - + std::vector res ; ExtAddrFinder *af = (ExtAddrFinder*)p ; - for(int i=0;i::const_iterator it(af->_ip_servers.begin());it!=af->_ip_servers.end();++it) { std::string page ; - getPage(servers[i],page) ; + getPage(*it,page) ; std::string ip = scan_ip(page) ; if(ip != "") res.push_back(ip) ; #ifdef EXTADDRSEARCH_DEBUG - std::cout << "ip found through " << servers[i] << ": \"" << ip << "\"" << std::endl ; + std::cout << "ip found through " << *it << ": \"" << ip << "\"" << std::endl ; #endif } if(res.empty()) @@ -244,6 +237,11 @@ ExtAddrFinder::ExtAddrFinder() _addr = (sockaddr_in*)malloc(sizeof(sockaddr_in)) ; + _ip_servers.push_back(std::string( "checkip.dyndns.org" )) ; + _ip_servers.push_back(std::string( "www.showmyip.com" )) ; + _ip_servers.push_back(std::string( "showip.net" )) ; + _ip_servers.push_back(std::string( "www.displaymyip.com")) ; + start_request() ; } diff --git a/libretroshare/src/tcponudp/extaddrfinder.h b/libretroshare/src/tcponudp/extaddrfinder.h index 516f2f430..0c1f11313 100644 --- a/libretroshare/src/tcponudp/extaddrfinder.h +++ b/libretroshare/src/tcponudp/extaddrfinder.h @@ -1,5 +1,7 @@ #pragma once +#include +#include #include "util/rsthreads.h" struct sockaddr ; @@ -11,11 +13,16 @@ class ExtAddrFinder ~ExtAddrFinder() ; bool hasValidIP(struct sockaddr_in *addr) ; + void getIPServersList(std::list& ip_servers) { ip_servers = _ip_servers ; } void start_request() ; + private: + friend void* doExtAddrSearch(void *p) ; + RsMutex _addrMtx ; struct sockaddr_in *_addr ; bool *_found ; bool *_searching ; + std::list _ip_servers ; }; diff --git a/retroshare-gui/src/gui/MainWindow.cpp b/retroshare-gui/src/gui/MainWindow.cpp index 4ea52ff7d..9ca5c9aa7 100644 --- a/retroshare-gui/src/gui/MainWindow.cpp +++ b/retroshare-gui/src/gui/MainWindow.cpp @@ -217,10 +217,6 @@ MainWindow::MainWindow(QWidget* parent, Qt::WFlags flags) ui.stackPages->add(linksDialog = new LinksDialog(ui.stackPages), createPageAction(QIcon(IMAGE_LINKS), tr("Links Cloud"), grp)); - ChannelFeed *channelFeed = NULL; - ui.stackPages->add(channelFeed = new ChannelFeed(ui.stackPages), - createPageAction(QIcon(IMAGE_CHANNELS), tr("Channel Feed"), grp)); - ForumsDialog *forumsDialog = NULL; ui.stackPages->add(forumsDialog = new ForumsDialog(ui.stackPages), createPageAction(QIcon(IMAGE_FORUMS), tr("Forums"), grp)); @@ -240,6 +236,9 @@ MainWindow::MainWindow(QWidget* parent, Qt::WFlags flags) createPageAction(QIcon(IMAGE_FORUMS), tr("Forums"), grp)); #endif + NewsFeed *newsFeed = NULL; + ui.stackPages->add(newsFeed = new NewsFeed(ui.stackPages), + createPageAction(QIcon(IMAGE_NEWSFEED), tr("News Feed"), grp)); ui.stackPages->add(pluginsPage = new PluginsPage(ui.stackPages), createPageAction(QIcon(IMAGE_PLUGINS), tr("Plugins"), grp)); @@ -271,10 +270,6 @@ MainWindow::MainWindow(QWidget* parent, Qt::WFlags flags) #else - NewsFeed *newsFeed = NULL; - ui.stackPages->add(newsFeed = new NewsFeed(ui.stackPages), - createPageAction(QIcon(IMAGE_NEWSFEED), tr("News Feed"), grp)); - addAction(new QAction(QIcon(IMAGE_UNFINISHED), tr("Unfinished"), ui.toolBar), SLOT(showApplWindow())); toolAct = ui.toolBarservice->toggleViewAction(); diff --git a/retroshare-gui/src/gui/NetworkDialog.cpp b/retroshare-gui/src/gui/NetworkDialog.cpp index 1f66648f2..7db67d5f5 100644 --- a/retroshare-gui/src/gui/NetworkDialog.cpp +++ b/retroshare-gui/src/gui/NetworkDialog.cpp @@ -300,29 +300,23 @@ void NetworkDialog::insertConnect() /* (1) Accept/Deny */ if (detail.state & RS_PEER_STATE_FRIEND) - { - item -> setText(1, tr("Accept")); - } + item -> setText(1, tr("Trusted")); else - { - item -> setText(1, tr("Deny")); - } + item -> setText(1, tr("Denied")); - item -> setText(2,QString::fromStdString( RsPeerTrustString(detail.trustLvl))); + if (rsPeers->isTrustingMe(detail.id) || detail.lastConnect>0) + item -> setText(2,QString("Is trusting me")); + else + item -> setText(2,QString("Unknown")); /* (3) Last Connect */ { std::ostringstream out; // Show anouncement if a friend never was connected. - if (detail.lastConnect==0 ) { - if(detail.state & RS_PEER_STATE_FRIEND) { - out << "Friend never seen"; - item -> setText(3, QString::fromStdString(out.str())); - } else { - // Show that there is no Trust - item -> setText(3, QString::fromStdString(RsPeerTrustString(detail.trustLvl))); - } - } else { + if (detail.lastConnect==0 ) + item -> setText(3, QString("Never seen")); + else + { // Dont Show a timestamp in RS calculate the day QDateTime datum = QDateTime::fromTime_t(detail.lastConnect); // out << datum.toString(Qt::LocalDate); @@ -372,16 +366,11 @@ void NetworkDialog::insertConnect() if (detail.state & RS_PEER_STATE_FRIEND) { if (detail.lastConnect < 10000) /* 3 hours? */ - { - /* bright green */ - backgrndcolor=Qt::darkGreen; item -> setIcon(0,(QIcon(IMAGE_AUTHED))); - } else - { - backgrndcolor=Qt::darkGreen; item -> setIcon(0,(QIcon(IMAGE_AUTHED))); - } + + backgrndcolor=Qt::green; } else { @@ -389,7 +378,6 @@ void NetworkDialog::insertConnect() { backgrndcolor=Qt::magenta; item -> setIcon(0,(QIcon(IMAGE_TRUSTED))); - item -> setText(2,QString("Is trusting you")); for(int k=0;k<8;++k) item -> setToolTip(k,QString::fromStdString(detail.name) + QString(tr(" is trusting you. \nRight-click and select 'make friend' to be able to connect."))) ; } @@ -413,9 +401,8 @@ void NetworkDialog::insertConnect() // Color each Background column in the Network Tab except the first one => 1-9 // whith the determinated color for(int i = 1; i <10; i++) - { item -> setBackground(i,QBrush(backgrndcolor)); - } + /* add to the list */ items.append(item); } @@ -426,10 +413,10 @@ void NetworkDialog::insertConnect() { QTreeWidgetItem *self_item = new QTreeWidgetItem((QTreeWidget*)0); - self_item->setText(1,"Accept"); - self_item->setText(2,"Good"); - self_item->setText(3,"0"); - self_item->setText(4,QString::fromStdString(pd.name)) ; + self_item->setText(1,"N/A"); + self_item->setText(2,"N/A"); + self_item->setText(3,"N/A"); + self_item->setText(4,QString::fromStdString(pd.name) + " (yourself)") ; std::ostringstream out; out << pd.localAddr << ":" << pd.localPort << "/" << pd.extAddr << ":" << pd.extPort; @@ -442,7 +429,7 @@ void NetworkDialog::insertConnect() // Color each Background column in the Network Tab except the first one => 1-9 for(int i=1;i<10;++i) { - self_item->setBackground(i,QBrush(Qt::darkGreen)); + self_item->setBackground(i,QBrush(Qt::green)); } self_item->setIcon(0,(QIcon(IMAGE_AUTHED))); items.append(self_item); diff --git a/retroshare-gui/src/gui/NetworkDialog.ui b/retroshare-gui/src/gui/NetworkDialog.ui index 0c3fb85da..bbd7ceaf4 100644 --- a/retroshare-gui/src/gui/NetworkDialog.ui +++ b/retroshare-gui/src/gui/NetworkDialog.ui @@ -34,14 +34,6 @@ 0 - - - 0 - 0 - 564 - 411 - - Network @@ -126,17 +118,17 @@ p, li { white-space: pre-wrap; } - # + - Accept + Your trust - Trust + Peer's trust @@ -191,14 +183,6 @@ p, li { white-space: pre-wrap; } 0 - - - 0 - 0 - 558 - 115 - - Log @@ -235,14 +219,6 @@ p, li { white-space: pre-wrap; } - - - 0 - 0 - 564 - 411 - - Network View diff --git a/retroshare-gui/src/gui/Preferences/ServerDialog.cpp b/retroshare-gui/src/gui/Preferences/ServerDialog.cpp index 74eea2f27..6ab85df4e 100644 --- a/retroshare-gui/src/gui/Preferences/ServerDialog.cpp +++ b/retroshare-gui/src/gui/Preferences/ServerDialog.cpp @@ -43,6 +43,7 @@ ServerDialog::ServerDialog(QWidget *parent) _settings = new RshareSettings(); connect( ui.netModeComboBox, SIGNAL( activated ( int ) ), this, SLOT( toggleUPnP( ) ) ); + connect( ui.allowIpDeterminationCB, SIGNAL( toggled( bool ) ), this, SLOT( toggleIpDetermination(bool) ) ); QTimer *timer = new QTimer(this); timer->connect(timer, SIGNAL(timeout()), this, SLOT(updateStatus())); @@ -51,6 +52,15 @@ ServerDialog::ServerDialog(QWidget *parent) load(); updateStatus(); + bool b = rsPeers->getAllowServerIPDetermination() ; + ui.allowIpDeterminationCB->setChecked(b) ; + ui.IPServersLV->setEnabled(b) ; + + std::list ip_servers ; + rsPeers->getIPServersList(ip_servers) ; + + for(std::list::const_iterator it(ip_servers.begin());it!=ip_servers.end();++it) + ui.IPServersLV->addItem(QString::fromStdString(*it)) ; /* Hide platform specific features */ #ifdef Q_WS_WIN @@ -58,6 +68,12 @@ ServerDialog::ServerDialog(QWidget *parent) #endif } +void ServerDialog::toggleIpDetermination(bool b) +{ + rsPeers->allowServerIPDetermination(b) ; + ui.IPServersLV->setEnabled(b) ; +} + /** Saves the changes on this page */ bool ServerDialog::save(QString &errmsg) diff --git a/retroshare-gui/src/gui/Preferences/ServerDialog.h b/retroshare-gui/src/gui/Preferences/ServerDialog.h index 1842f0359..25e931d67 100644 --- a/retroshare-gui/src/gui/Preferences/ServerDialog.h +++ b/retroshare-gui/src/gui/Preferences/ServerDialog.h @@ -49,6 +49,7 @@ public slots: private slots: void saveAddresses(); void toggleUPnP(); + void toggleIpDetermination(bool) ; private: diff --git a/retroshare-gui/src/gui/Preferences/ServerDialog.ui b/retroshare-gui/src/gui/Preferences/ServerDialog.ui index 3c99951ce..a595741c1 100644 --- a/retroshare-gui/src/gui/Preferences/ServerDialog.ui +++ b/retroshare-gui/src/gui/Preferences/ServerDialog.ui @@ -6,7 +6,7 @@ 0 0 409 - 373 + 406 @@ -488,22 +488,10 @@ Qt::NoContextMenu - + 6 - - 6 - - - 6 - - - 6 - - - 0 - - + 0 @@ -578,7 +566,7 @@ Qt::Horizontal - + 40 20 @@ -610,8 +598,8 @@ Network Configuration - - + + @@ -683,18 +671,28 @@ - - - - Qt::Vertical + + + + If you unckeck this, RetroShare can only determine your IP +when you connect to somebody. Leaving this checked helps +connecting when you have few friends. It also helps if you're +behind a firewall or a VPN. - - - 301 - 20 - + + Allow RetroShare to ask my ip to these websites: - + + true + + + + + + + QAbstractItemView::NoEditTriggers + + @@ -817,16 +815,7 @@ 6 - - 0 - - - 0 - - - 0 - - + 0 @@ -856,16 +845,7 @@ 6 - - 0 - - - 0 - - - 0 - - + 0 @@ -895,7 +875,7 @@ Qt::Horizontal - + 40 20 diff --git a/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp b/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp index 7c8e909c7..c03ad19c6 100755 --- a/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp +++ b/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp @@ -292,7 +292,7 @@ CertificatePage::CertificatePage(QWidget *parent) userFileLabel->setWordWrap(true); userFileCreateButton = new QPushButton; - userFileCreateButton->setText("Generate certificate"); + userFileCreateButton->setText("Export my certificate..."); connect(userFileCreateButton, SIGNAL( clicked() ), this, SLOT( generateCertificateCalled())); @@ -302,7 +302,7 @@ CertificatePage::CertificatePage(QWidget *parent) userFileFrame = new QGroupBox; userFileFrame->setFlat(true); - userFileFrame->setTitle("Generate certificate"); + userFileFrame->setTitle("Export my certificate..."); userFileFrame->setLayout(userFileLayout); friendFileLabel = new QLabel(tr("Specify path to your friend's " diff --git a/retroshare-gui/src/rsiface/rspeers.h b/retroshare-gui/src/rsiface/rspeers.h index 7807d6bda..278e30e66 100644 --- a/retroshare-gui/src/rsiface/rspeers.h +++ b/retroshare-gui/src/rsiface/rspeers.h @@ -144,6 +144,10 @@ virtual bool setExtAddress( std::string id, std::string addr, uint16_t port) = virtual bool setNetworkMode(std::string id, uint32_t netMode) = 0; virtual bool setVisState(std::string id, uint32_t vis) = 0; +virtual void getIPServersList(std::list& ip_servers) = 0; +virtual void allowServerIPDetermination(bool) = 0; +virtual bool getAllowServerIPDetermination() = 0 ; + /* Auth Stuff */ virtual std::string GetRetroshareInvite() = 0; diff --git a/retroshare-gui/src/rsiface/rsturtle.h b/retroshare-gui/src/rsiface/rsturtle.h index abaf4e24e..11cb81182 100644 --- a/retroshare-gui/src/rsiface/rsturtle.h +++ b/retroshare-gui/src/rsiface/rsturtle.h @@ -56,9 +56,11 @@ struct TurtleFileInfo class RsTurtle { public: - RsTurtle() {} + RsTurtle() { _sharing_strategy = SHARE_ENTIRE_NETWORK ;} virtual ~RsTurtle() {} + enum FileSharingStrategy { SHARE_ENTIRE_NETWORK, SHARE_FRIENDS_ONLY } ; + // Lauches a search request through the pipes, and immediately returns // the request id, which will be further used by the gui to store results // as they come back. @@ -70,6 +72,14 @@ class RsTurtle // initialization process. // virtual void turtleDownload(const std::string& file_hash) = 0 ; + + // Sets the file sharing strategy. It concerns all local files. It would + // be better to handle this for each file, of course. + + void setFileSharingStrategy(FileSharingStrategy f) { _sharing_strategy = f ; } + + protected: + FileSharingStrategy _sharing_strategy ; }; #endif