Skip to content

Commit b092ae7

Browse files
author
mhugent
committedJan 7, 2009
Apply proxy patch that let select the proxy type in the option dialog
git-svn-id: http://svn.osgeo.org/qgis/trunk@9939 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 64e9d93 commit b092ae7

File tree

6 files changed

+92
-34
lines changed

6 files changed

+92
-34
lines changed
 

‎src/app/qgisapp.cpp

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,6 @@ QgisApp::QgisApp( QSplashScreen *splash, QWidget * parent, Qt::WFlags fl )
345345
createLegend();
346346
createOverview();
347347
createMapTips();
348-
setupProxy();
349348
readSettings();
350349
updateRecentProjectPaths();
351350

@@ -4293,8 +4292,6 @@ void QgisApp::options()
42934292
int action = mySettings.value( "/qgis/wheel_action", 0 ).toInt();
42944293
double zoomFactor = mySettings.value( "/qgis/zoom_factor", 2 ).toDouble();
42954294
mMapCanvas->setWheelAction(( QgsMapCanvas::WheelAction ) action, zoomFactor );
4296-
4297-
setupProxy();
42984295
}
42994296
}
43004297

@@ -5506,26 +5503,6 @@ void QgisApp::oldProjectVersionWarning( QString oldVersion )
55065503
return;
55075504
}
55085505

5509-
void QgisApp::setupProxy()
5510-
{
5511-
QSettings mySettings;
5512-
bool myFlag = mySettings.value( "proxy/proxyEnabled", "0" ).toBool();
5513-
QNetworkProxy myProxy;
5514-
if ( myFlag )
5515-
{
5516-
myProxy.setType( QNetworkProxy::HttpProxy );
5517-
myProxy.setHostName( mySettings.value( "proxy/proxyHost", "" ).toString() );
5518-
myProxy.setPort( mySettings.value( "proxy/proxyPort", "" ).toInt() );
5519-
myProxy.setUser( mySettings.value( "proxy/proxyUser", "" ).toString() );
5520-
myProxy.setPassword( mySettings.value( "proxy/proxyPassword", "" ).toString() );
5521-
}
5522-
else
5523-
{
5524-
// otherwise leave it blank to disable proxy usage
5525-
}
5526-
QNetworkProxy::setApplicationProxy( myProxy );
5527-
}
5528-
55295506
QIcon QgisApp::getThemeIcon( const QString theName )
55305507
{
55315508
QString myPreferredPath = QgsApplication::activeThemePath() + QDir::separator() + theName;

‎src/app/qgsoptions.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,16 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WFlags fl ) :
6262
leProxyPort->setText( settings.value( "proxy/proxyPort", "" ).toString() );
6363
leProxyUser->setText( settings.value( "proxy/proxyUser", "" ).toString() );
6464
leProxyPassword->setText( settings.value( "proxy/proxyPassword", "" ).toString() );
65+
66+
//available proxy types
67+
mProxyTypeComboBox->insertItem(0, "DefaultProxy");
68+
mProxyTypeComboBox->insertItem(1, "Socks5Proxy");
69+
mProxyTypeComboBox->insertItem(2, "HttpProxy");
70+
mProxyTypeComboBox->insertItem(3, "HttpCachingProxy");
71+
mProxyTypeComboBox->insertItem(4, "FtpCachingProxy");
72+
QString settingProxyType = settings.value("proxy/proxyType", "DefaultProxy").toString();
73+
mProxyTypeComboBox->setCurrentIndex(mProxyTypeComboBox->findText(settingProxyType));
74+
6575
// set the current theme
6676
cmbTheme->setItemText( cmbTheme->currentIndex(), settings.value( "/Themes" ).toString() );
6777

@@ -261,6 +271,8 @@ void QgsOptions::saveOptions()
261271
settings.setValue( "proxy/proxyPort", leProxyPort->text() );
262272
settings.setValue( "proxy/proxyUser", leProxyUser->text() );
263273
settings.setValue( "proxy/proxyPassword", leProxyPassword->text() );
274+
settings.setValue( "proxy/proxyType", mProxyTypeComboBox->currentText());
275+
264276
//general settings
265277
settings.setValue( "/Map/identifyRadius", spinBoxIdentifyValue->value() );
266278
settings.setValue( "/qgis/showLegendClassifiers", cbxLegendClassifiers->isChecked() );

‎src/core/qgshttptransaction.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,15 @@ QgsHttpTransaction::QgsHttpTransaction( QString uri,
3737
QString proxyHost,
3838
int proxyPort,
3939
QString proxyUser,
40-
QString proxyPass )
40+
QString proxyPass,
41+
QNetworkProxy::ProxyType proxyType)
4142
: httpresponsecontenttype( 0 ),
4243
httpurl( uri ),
4344
httphost( proxyHost ),
4445
httpport( proxyPort ),
4546
httpuser( proxyUser ),
4647
httppass( proxyPass ),
48+
mProxyType(proxyType),
4749
mError( 0 )
4850
{
4951

@@ -105,7 +107,7 @@ bool QgsHttpTransaction::getSynchronously( QByteArray &respondedContent, int red
105107
else
106108
{
107109
// Insert proxy username and password authentication
108-
http->setProxy( httphost, httpport, httpuser, httppass );
110+
http->setProxy( QNetworkProxy(mProxyType, httphost, httpport, httpuser, httppass) );
109111
}
110112

111113
// int httpid1 = http->setHost( qurl.host(), qurl.port() );

‎src/core/qgshttptransaction.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#define QGSHTTPTRANSACTION_H
2424

2525
#include <QHttp>
26+
#include <QNetworkProxy>
2627
#include <QString>
2728

2829
class QTimer;
@@ -46,7 +47,8 @@ class CORE_EXPORT QgsHttpTransaction : public QObject
4647
QString proxyHost = QString(),
4748
int proxyPort = 80,
4849
QString proxyUser = QString(),
49-
QString proxyPass = QString() );
50+
QString proxyPass = QString(),
51+
QNetworkProxy::ProxyType proxyType = QNetworkProxy::NoProxy);
5052

5153
//! Destructor
5254
virtual ~QgsHttpTransaction();
@@ -187,6 +189,8 @@ class CORE_EXPORT QgsHttpTransaction : public QObject
187189
*/
188190
int httpredirections;
189191

192+
QNetworkProxy::ProxyType mProxyType;
193+
190194
/**
191195
* Indicates the associated QTimer object - used to detect network timeouts
192196
*/

‎src/providers/wms/qgswmsprovider.cpp

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include <QUrl>
3333
#include <QImage>
3434
#include <QSet>
35+
#include <QSettings>
3536

3637
#ifdef _MSC_VER
3738
#include <float.h>
@@ -636,7 +637,46 @@ bool QgsWmsProvider::retrieveServerCapabilities( bool forceRefresh )
636637
QByteArray QgsWmsProvider::retrieveUrl( QString url )
637638
{
638639
QgsDebugMsg( "WMS request Url: " + url );
639-
QgsHttpTransaction http( url );
640+
641+
//read proxy settings
642+
QSettings settings;
643+
QString proxyHost, proxyUser, proxyPassword;
644+
int proxyPort;
645+
QNetworkProxy::ProxyType proxyType = QNetworkProxy::NoProxy;
646+
647+
bool proxyEnabled = settings.value( "proxy/proxyEnabled", "0" ).toBool();
648+
if(proxyEnabled)
649+
{
650+
proxyHost = settings.value( "proxy/proxyHost", "" ).toString();
651+
proxyPort = settings.value( "proxy/proxyPort", "" ).toString().toInt();
652+
proxyUser = settings.value( "proxy/proxyUser", "" ).toString();
653+
proxyPassword = settings.value( "proxy/proxyPassword", "" ).toString();
654+
QString proxyTypeString = settings.value( "proxy/proxyType", "" ).toString();
655+
if(proxyTypeString == "DefaultProxy")
656+
{
657+
proxyType = QNetworkProxy::DefaultProxy;
658+
}
659+
else if(proxyTypeString == "Socks5Proxy")
660+
{
661+
proxyType = QNetworkProxy::Socks5Proxy;
662+
}
663+
else if(proxyTypeString == "HttpProxy")
664+
{
665+
proxyType = QNetworkProxy::HttpProxy;
666+
}
667+
else if(proxyTypeString == "HttpCachingProxy")
668+
{
669+
proxyType = QNetworkProxy::HttpCachingProxy;
670+
}
671+
else if(proxyTypeString == "FtpCachingProxy")
672+
{
673+
proxyType = QNetworkProxy::FtpCachingProxy;
674+
}
675+
}
676+
677+
678+
QgsHttpTransaction http(url, proxyHost, proxyPort, proxyUser, proxyPassword, proxyType );
679+
640680

641681
// Do a passthrough for the status bar text
642682
connect(

‎src/ui/qgsoptionsbase.ui

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
<item row="0" column="0" >
2626
<widget class="QTabWidget" name="tabWidget" >
2727
<property name="currentIndex" >
28-
<number>0</number>
28+
<number>6</number>
2929
</property>
3030
<widget class="QWidget" name="tabGeneral" >
3131
<attribute name="title" >
@@ -1000,7 +1000,7 @@
10001000
</property>
10011001
</widget>
10021002
</item>
1003-
<item row="0" column="1" >
1003+
<item row="0" column="1" colspan="2" >
10041004
<widget class="QLineEdit" name="leProxyHost" />
10051005
</item>
10061006
<item row="1" column="0" >
@@ -1013,7 +1013,7 @@
10131013
</property>
10141014
</widget>
10151015
</item>
1016-
<item row="1" column="1" >
1016+
<item row="1" column="1" colspan="2" >
10171017
<widget class="QLineEdit" name="leProxyPort" />
10181018
</item>
10191019
<item row="2" column="0" >
@@ -1026,7 +1026,7 @@
10261026
</property>
10271027
</widget>
10281028
</item>
1029-
<item row="2" column="1" >
1029+
<item row="2" column="1" colspan="2" >
10301030
<widget class="QLineEdit" name="leProxyUser" >
10311031
<property name="toolTip" >
10321032
<string>Leave this blank if no proxy username / password are required</string>
@@ -1043,7 +1043,7 @@
10431043
</property>
10441044
</widget>
10451045
</item>
1046-
<item row="3" column="1" >
1046+
<item row="3" column="1" colspan="2" >
10471047
<widget class="QLineEdit" name="leProxyPassword" >
10481048
<property name="toolTip" >
10491049
<string>Leave this blank if no proxy username / password are required</string>
@@ -1053,6 +1053,29 @@
10531053
</property>
10541054
</widget>
10551055
</item>
1056+
<item row="4" column="0" >
1057+
<widget class="QLabel" name="mTypeLabel" >
1058+
<property name="text" >
1059+
<string>Proxy type</string>
1060+
</property>
1061+
</widget>
1062+
</item>
1063+
<item row="4" column="1" >
1064+
<widget class="QComboBox" name="mProxyTypeComboBox" />
1065+
</item>
1066+
<item row="4" column="2" >
1067+
<spacer>
1068+
<property name="orientation" >
1069+
<enum>Qt::Horizontal</enum>
1070+
</property>
1071+
<property name="sizeHint" >
1072+
<size>
1073+
<width>241</width>
1074+
<height>20</height>
1075+
</size>
1076+
</property>
1077+
</spacer>
1078+
</item>
10561079
</layout>
10571080
</widget>
10581081
</item>
@@ -1063,8 +1086,8 @@
10631086
</property>
10641087
<property name="sizeHint" >
10651088
<size>
1066-
<width>20</width>
1067-
<height>40</height>
1089+
<width>577</width>
1090+
<height>251</height>
10681091
</size>
10691092
</property>
10701093
</spacer>

0 commit comments

Comments
 (0)