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
This commit is contained in:
csoler 2009-04-05 13:04:18 +00:00
parent afb51d5d31
commit 4bb497a905
16 changed files with 145 additions and 136 deletions

View File

@ -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<std::string>& 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 ;

View File

@ -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<std::string>& ip_servers) ;
bool getNetStatusOk();
bool getNetStatusUpnpOk();
bool getNetStatusDhtOk();
@ -350,6 +354,7 @@ private:
std::list<pqiMonitor *> clients;
ExtAddrFinder *mExtAddrFinder ;
bool use_extr_addr_finder ;
/* external Address determination */
bool mUpnpAddrValid, mStunAddrValid;

View File

@ -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<std::string>& ip_servers) = 0;
virtual void allowServerIPDetermination(bool) = 0;
virtual bool getAllowServerIPDetermination() = 0 ;
/* Auth Stuff */
virtual std::string GetRetroshareInvite() = 0;

View File

@ -459,6 +459,19 @@ bool p3Peers::connectAttempt(std::string id)
return mConnMgr->retryConnect(id);
}
void p3Peers::getIPServersList(std::list<std::string>& 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

View File

@ -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<std::string>& ip_servers) ;
virtual void allowServerIPDetermination(bool) ;
virtual bool getAllowServerIPDetermination() ;
/* Auth Stuff */
virtual std::string GetRetroshareInvite();

View File

@ -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<std::string> res ;
ExtAddrFinder *af = (ExtAddrFinder*)p ;
for(int i=0;i<nb_ipservers;++i)
for(std::list<std::string>::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() ;
}

View File

@ -1,5 +1,7 @@
#pragma once
#include <list>
#include <string>
#include "util/rsthreads.h"
struct sockaddr ;
@ -11,11 +13,16 @@ class ExtAddrFinder
~ExtAddrFinder() ;
bool hasValidIP(struct sockaddr_in *addr) ;
void getIPServersList(std::list<std::string>& 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<std::string> _ip_servers ;
};

View File

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

View File

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

View File

@ -34,14 +34,6 @@
<number>0</number>
</property>
<widget class="QWidget" name="networkTab" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>564</width>
<height>411</height>
</rect>
</property>
<attribute name="title" >
<string>Network</string>
</attribute>
@ -126,17 +118,17 @@ p, li { white-space: pre-wrap; }
</property>
<column>
<property name="text" >
<string>#</string>
<string/>
</property>
</column>
<column>
<property name="text" >
<string>Accept</string>
<string>Your trust</string>
</property>
</column>
<column>
<property name="text" >
<string>Trust</string>
<string>Peer's trust</string>
</property>
</column>
<column>
@ -191,14 +183,6 @@ p, li { white-space: pre-wrap; }
<number>0</number>
</property>
<widget class="QWidget" name="log_tab" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>558</width>
<height>115</height>
</rect>
</property>
<attribute name="title" >
<string>Log</string>
</attribute>
@ -235,14 +219,6 @@ p, li { white-space: pre-wrap; }
</layout>
</widget>
<widget class="QWidget" name="networkviewTab" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>564</width>
<height>411</height>
</rect>
</property>
<attribute name="title" >
<string>Network View</string>
</attribute>

View File

@ -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<std::string> ip_servers ;
rsPeers->getIPServersList(ip_servers) ;
for(std::list<std::string>::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)

View File

@ -49,6 +49,7 @@ public slots:
private slots:
void saveAddresses();
void toggleUPnP();
void toggleIpDetermination(bool) ;
private:

View File

@ -6,7 +6,7 @@
<x>0</x>
<y>0</y>
<width>409</width>
<height>373</height>
<height>406</height>
</rect>
</property>
<property name="sizePolicy" >
@ -488,22 +488,10 @@
<enum>Qt::NoContextMenu</enum>
</property>
<layout class="QGridLayout" >
<property name="leftMargin" >
<property name="margin" >
<number>6</number>
</property>
<property name="topMargin" >
<number>6</number>
</property>
<property name="rightMargin" >
<number>6</number>
</property>
<property name="bottomMargin" >
<number>6</number>
</property>
<property name="horizontalSpacing" >
<number>0</number>
</property>
<property name="verticalSpacing" >
<property name="spacing" >
<number>0</number>
</property>
<item row="0" column="0" >
@ -578,7 +566,7 @@
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<property name="sizeHint" stdset="0" >
<size>
<width>40</width>
<height>20</height>
@ -610,8 +598,8 @@
<property name="title" >
<string>Network Configuration</string>
</property>
<layout class="QGridLayout" >
<item row="0" column="0" >
<layout class="QVBoxLayout" name="verticalLayout" >
<item>
<layout class="QHBoxLayout" >
<item>
<layout class="QVBoxLayout" >
@ -683,18 +671,28 @@
</item>
</layout>
</item>
<item row="1" column="0" >
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
<item>
<widget class="QCheckBox" name="allowIpDeterminationCB" >
<property name="toolTip" >
<string>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.</string>
</property>
<property name="sizeHint" >
<size>
<width>301</width>
<height>20</height>
</size>
<property name="text" >
<string>Allow RetroShare to ask my ip to these websites:</string>
</property>
</spacer>
<property name="checked" >
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QListWidget" name="IPServersLV" >
<property name="editTriggers" >
<set>QAbstractItemView::NoEditTriggers</set>
</property>
</widget>
</item>
</layout>
</widget>
@ -817,16 +815,7 @@
<property name="spacing" >
<number>6</number>
</property>
<property name="leftMargin" >
<number>0</number>
</property>
<property name="topMargin" >
<number>0</number>
</property>
<property name="rightMargin" >
<number>0</number>
</property>
<property name="bottomMargin" >
<property name="margin" >
<number>0</number>
</property>
<item>
@ -856,16 +845,7 @@
<property name="spacing" >
<number>6</number>
</property>
<property name="leftMargin" >
<number>0</number>
</property>
<property name="topMargin" >
<number>0</number>
</property>
<property name="rightMargin" >
<number>0</number>
</property>
<property name="bottomMargin" >
<property name="margin" >
<number>0</number>
</property>
<item>
@ -895,7 +875,7 @@
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<property name="sizeHint" stdset="0" >
<size>
<width>40</width>
<height>20</height>

View File

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

View File

@ -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<std::string>& ip_servers) = 0;
virtual void allowServerIPDetermination(bool) = 0;
virtual bool getAllowServerIPDetermination() = 0 ;
/* Auth Stuff */
virtual std::string GetRetroshareInvite() = 0;

View File

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