mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-25 00:58:06 -05:00
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
This commit is contained in:
parent
64e9d9338a
commit
b092ae7f7a
@ -345,7 +345,6 @@ QgisApp::QgisApp( QSplashScreen *splash, QWidget * parent, Qt::WFlags fl )
|
|||||||
createLegend();
|
createLegend();
|
||||||
createOverview();
|
createOverview();
|
||||||
createMapTips();
|
createMapTips();
|
||||||
setupProxy();
|
|
||||||
readSettings();
|
readSettings();
|
||||||
updateRecentProjectPaths();
|
updateRecentProjectPaths();
|
||||||
|
|
||||||
@ -4293,8 +4292,6 @@ void QgisApp::options()
|
|||||||
int action = mySettings.value( "/qgis/wheel_action", 0 ).toInt();
|
int action = mySettings.value( "/qgis/wheel_action", 0 ).toInt();
|
||||||
double zoomFactor = mySettings.value( "/qgis/zoom_factor", 2 ).toDouble();
|
double zoomFactor = mySettings.value( "/qgis/zoom_factor", 2 ).toDouble();
|
||||||
mMapCanvas->setWheelAction(( QgsMapCanvas::WheelAction ) action, zoomFactor );
|
mMapCanvas->setWheelAction(( QgsMapCanvas::WheelAction ) action, zoomFactor );
|
||||||
|
|
||||||
setupProxy();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5506,26 +5503,6 @@ void QgisApp::oldProjectVersionWarning( QString oldVersion )
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QgisApp::setupProxy()
|
|
||||||
{
|
|
||||||
QSettings mySettings;
|
|
||||||
bool myFlag = mySettings.value( "proxy/proxyEnabled", "0" ).toBool();
|
|
||||||
QNetworkProxy myProxy;
|
|
||||||
if ( myFlag )
|
|
||||||
{
|
|
||||||
myProxy.setType( QNetworkProxy::HttpProxy );
|
|
||||||
myProxy.setHostName( mySettings.value( "proxy/proxyHost", "" ).toString() );
|
|
||||||
myProxy.setPort( mySettings.value( "proxy/proxyPort", "" ).toInt() );
|
|
||||||
myProxy.setUser( mySettings.value( "proxy/proxyUser", "" ).toString() );
|
|
||||||
myProxy.setPassword( mySettings.value( "proxy/proxyPassword", "" ).toString() );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// otherwise leave it blank to disable proxy usage
|
|
||||||
}
|
|
||||||
QNetworkProxy::setApplicationProxy( myProxy );
|
|
||||||
}
|
|
||||||
|
|
||||||
QIcon QgisApp::getThemeIcon( const QString theName )
|
QIcon QgisApp::getThemeIcon( const QString theName )
|
||||||
{
|
{
|
||||||
QString myPreferredPath = QgsApplication::activeThemePath() + QDir::separator() + theName;
|
QString myPreferredPath = QgsApplication::activeThemePath() + QDir::separator() + theName;
|
||||||
|
@ -62,6 +62,16 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WFlags fl ) :
|
|||||||
leProxyPort->setText( settings.value( "proxy/proxyPort", "" ).toString() );
|
leProxyPort->setText( settings.value( "proxy/proxyPort", "" ).toString() );
|
||||||
leProxyUser->setText( settings.value( "proxy/proxyUser", "" ).toString() );
|
leProxyUser->setText( settings.value( "proxy/proxyUser", "" ).toString() );
|
||||||
leProxyPassword->setText( settings.value( "proxy/proxyPassword", "" ).toString() );
|
leProxyPassword->setText( settings.value( "proxy/proxyPassword", "" ).toString() );
|
||||||
|
|
||||||
|
//available proxy types
|
||||||
|
mProxyTypeComboBox->insertItem(0, "DefaultProxy");
|
||||||
|
mProxyTypeComboBox->insertItem(1, "Socks5Proxy");
|
||||||
|
mProxyTypeComboBox->insertItem(2, "HttpProxy");
|
||||||
|
mProxyTypeComboBox->insertItem(3, "HttpCachingProxy");
|
||||||
|
mProxyTypeComboBox->insertItem(4, "FtpCachingProxy");
|
||||||
|
QString settingProxyType = settings.value("proxy/proxyType", "DefaultProxy").toString();
|
||||||
|
mProxyTypeComboBox->setCurrentIndex(mProxyTypeComboBox->findText(settingProxyType));
|
||||||
|
|
||||||
// set the current theme
|
// set the current theme
|
||||||
cmbTheme->setItemText( cmbTheme->currentIndex(), settings.value( "/Themes" ).toString() );
|
cmbTheme->setItemText( cmbTheme->currentIndex(), settings.value( "/Themes" ).toString() );
|
||||||
|
|
||||||
@ -261,6 +271,8 @@ void QgsOptions::saveOptions()
|
|||||||
settings.setValue( "proxy/proxyPort", leProxyPort->text() );
|
settings.setValue( "proxy/proxyPort", leProxyPort->text() );
|
||||||
settings.setValue( "proxy/proxyUser", leProxyUser->text() );
|
settings.setValue( "proxy/proxyUser", leProxyUser->text() );
|
||||||
settings.setValue( "proxy/proxyPassword", leProxyPassword->text() );
|
settings.setValue( "proxy/proxyPassword", leProxyPassword->text() );
|
||||||
|
settings.setValue( "proxy/proxyType", mProxyTypeComboBox->currentText());
|
||||||
|
|
||||||
//general settings
|
//general settings
|
||||||
settings.setValue( "/Map/identifyRadius", spinBoxIdentifyValue->value() );
|
settings.setValue( "/Map/identifyRadius", spinBoxIdentifyValue->value() );
|
||||||
settings.setValue( "/qgis/showLegendClassifiers", cbxLegendClassifiers->isChecked() );
|
settings.setValue( "/qgis/showLegendClassifiers", cbxLegendClassifiers->isChecked() );
|
||||||
|
@ -37,13 +37,15 @@ QgsHttpTransaction::QgsHttpTransaction( QString uri,
|
|||||||
QString proxyHost,
|
QString proxyHost,
|
||||||
int proxyPort,
|
int proxyPort,
|
||||||
QString proxyUser,
|
QString proxyUser,
|
||||||
QString proxyPass )
|
QString proxyPass,
|
||||||
|
QNetworkProxy::ProxyType proxyType)
|
||||||
: httpresponsecontenttype( 0 ),
|
: httpresponsecontenttype( 0 ),
|
||||||
httpurl( uri ),
|
httpurl( uri ),
|
||||||
httphost( proxyHost ),
|
httphost( proxyHost ),
|
||||||
httpport( proxyPort ),
|
httpport( proxyPort ),
|
||||||
httpuser( proxyUser ),
|
httpuser( proxyUser ),
|
||||||
httppass( proxyPass ),
|
httppass( proxyPass ),
|
||||||
|
mProxyType(proxyType),
|
||||||
mError( 0 )
|
mError( 0 )
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -105,7 +107,7 @@ bool QgsHttpTransaction::getSynchronously( QByteArray &respondedContent, int red
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Insert proxy username and password authentication
|
// Insert proxy username and password authentication
|
||||||
http->setProxy( httphost, httpport, httpuser, httppass );
|
http->setProxy( QNetworkProxy(mProxyType, httphost, httpport, httpuser, httppass) );
|
||||||
}
|
}
|
||||||
|
|
||||||
// int httpid1 = http->setHost( qurl.host(), qurl.port() );
|
// int httpid1 = http->setHost( qurl.host(), qurl.port() );
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
#define QGSHTTPTRANSACTION_H
|
#define QGSHTTPTRANSACTION_H
|
||||||
|
|
||||||
#include <QHttp>
|
#include <QHttp>
|
||||||
|
#include <QNetworkProxy>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
class QTimer;
|
class QTimer;
|
||||||
@ -46,7 +47,8 @@ class CORE_EXPORT QgsHttpTransaction : public QObject
|
|||||||
QString proxyHost = QString(),
|
QString proxyHost = QString(),
|
||||||
int proxyPort = 80,
|
int proxyPort = 80,
|
||||||
QString proxyUser = QString(),
|
QString proxyUser = QString(),
|
||||||
QString proxyPass = QString() );
|
QString proxyPass = QString(),
|
||||||
|
QNetworkProxy::ProxyType proxyType = QNetworkProxy::NoProxy);
|
||||||
|
|
||||||
//! Destructor
|
//! Destructor
|
||||||
virtual ~QgsHttpTransaction();
|
virtual ~QgsHttpTransaction();
|
||||||
@ -187,6 +189,8 @@ class CORE_EXPORT QgsHttpTransaction : public QObject
|
|||||||
*/
|
*/
|
||||||
int httpredirections;
|
int httpredirections;
|
||||||
|
|
||||||
|
QNetworkProxy::ProxyType mProxyType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicates the associated QTimer object - used to detect network timeouts
|
* Indicates the associated QTimer object - used to detect network timeouts
|
||||||
*/
|
*/
|
||||||
|
@ -32,6 +32,7 @@
|
|||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
#include <QImage>
|
#include <QImage>
|
||||||
#include <QSet>
|
#include <QSet>
|
||||||
|
#include <QSettings>
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#include <float.h>
|
#include <float.h>
|
||||||
@ -636,7 +637,46 @@ bool QgsWmsProvider::retrieveServerCapabilities( bool forceRefresh )
|
|||||||
QByteArray QgsWmsProvider::retrieveUrl( QString url )
|
QByteArray QgsWmsProvider::retrieveUrl( QString url )
|
||||||
{
|
{
|
||||||
QgsDebugMsg( "WMS request Url: " + url );
|
QgsDebugMsg( "WMS request Url: " + url );
|
||||||
QgsHttpTransaction http( url );
|
|
||||||
|
//read proxy settings
|
||||||
|
QSettings settings;
|
||||||
|
QString proxyHost, proxyUser, proxyPassword;
|
||||||
|
int proxyPort;
|
||||||
|
QNetworkProxy::ProxyType proxyType = QNetworkProxy::NoProxy;
|
||||||
|
|
||||||
|
bool proxyEnabled = settings.value( "proxy/proxyEnabled", "0" ).toBool();
|
||||||
|
if(proxyEnabled)
|
||||||
|
{
|
||||||
|
proxyHost = settings.value( "proxy/proxyHost", "" ).toString();
|
||||||
|
proxyPort = settings.value( "proxy/proxyPort", "" ).toString().toInt();
|
||||||
|
proxyUser = settings.value( "proxy/proxyUser", "" ).toString();
|
||||||
|
proxyPassword = settings.value( "proxy/proxyPassword", "" ).toString();
|
||||||
|
QString proxyTypeString = settings.value( "proxy/proxyType", "" ).toString();
|
||||||
|
if(proxyTypeString == "DefaultProxy")
|
||||||
|
{
|
||||||
|
proxyType = QNetworkProxy::DefaultProxy;
|
||||||
|
}
|
||||||
|
else if(proxyTypeString == "Socks5Proxy")
|
||||||
|
{
|
||||||
|
proxyType = QNetworkProxy::Socks5Proxy;
|
||||||
|
}
|
||||||
|
else if(proxyTypeString == "HttpProxy")
|
||||||
|
{
|
||||||
|
proxyType = QNetworkProxy::HttpProxy;
|
||||||
|
}
|
||||||
|
else if(proxyTypeString == "HttpCachingProxy")
|
||||||
|
{
|
||||||
|
proxyType = QNetworkProxy::HttpCachingProxy;
|
||||||
|
}
|
||||||
|
else if(proxyTypeString == "FtpCachingProxy")
|
||||||
|
{
|
||||||
|
proxyType = QNetworkProxy::FtpCachingProxy;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QgsHttpTransaction http(url, proxyHost, proxyPort, proxyUser, proxyPassword, proxyType );
|
||||||
|
|
||||||
|
|
||||||
// Do a passthrough for the status bar text
|
// Do a passthrough for the status bar text
|
||||||
connect(
|
connect(
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
<item row="0" column="0" >
|
<item row="0" column="0" >
|
||||||
<widget class="QTabWidget" name="tabWidget" >
|
<widget class="QTabWidget" name="tabWidget" >
|
||||||
<property name="currentIndex" >
|
<property name="currentIndex" >
|
||||||
<number>0</number>
|
<number>6</number>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="tabGeneral" >
|
<widget class="QWidget" name="tabGeneral" >
|
||||||
<attribute name="title" >
|
<attribute name="title" >
|
||||||
@ -1000,7 +1000,7 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="1" >
|
<item row="0" column="1" colspan="2" >
|
||||||
<widget class="QLineEdit" name="leProxyHost" />
|
<widget class="QLineEdit" name="leProxyHost" />
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="0" >
|
<item row="1" column="0" >
|
||||||
@ -1013,7 +1013,7 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="1" >
|
<item row="1" column="1" colspan="2" >
|
||||||
<widget class="QLineEdit" name="leProxyPort" />
|
<widget class="QLineEdit" name="leProxyPort" />
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0" >
|
<item row="2" column="0" >
|
||||||
@ -1026,7 +1026,7 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="1" >
|
<item row="2" column="1" colspan="2" >
|
||||||
<widget class="QLineEdit" name="leProxyUser" >
|
<widget class="QLineEdit" name="leProxyUser" >
|
||||||
<property name="toolTip" >
|
<property name="toolTip" >
|
||||||
<string>Leave this blank if no proxy username / password are required</string>
|
<string>Leave this blank if no proxy username / password are required</string>
|
||||||
@ -1043,7 +1043,7 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="1" >
|
<item row="3" column="1" colspan="2" >
|
||||||
<widget class="QLineEdit" name="leProxyPassword" >
|
<widget class="QLineEdit" name="leProxyPassword" >
|
||||||
<property name="toolTip" >
|
<property name="toolTip" >
|
||||||
<string>Leave this blank if no proxy username / password are required</string>
|
<string>Leave this blank if no proxy username / password are required</string>
|
||||||
@ -1053,6 +1053,29 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="4" column="0" >
|
||||||
|
<widget class="QLabel" name="mTypeLabel" >
|
||||||
|
<property name="text" >
|
||||||
|
<string>Proxy type</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="4" column="1" >
|
||||||
|
<widget class="QComboBox" name="mProxyTypeComboBox" />
|
||||||
|
</item>
|
||||||
|
<item row="4" column="2" >
|
||||||
|
<spacer>
|
||||||
|
<property name="orientation" >
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" >
|
||||||
|
<size>
|
||||||
|
<width>241</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@ -1063,8 +1086,8 @@
|
|||||||
</property>
|
</property>
|
||||||
<property name="sizeHint" >
|
<property name="sizeHint" >
|
||||||
<size>
|
<size>
|
||||||
<width>20</width>
|
<width>577</width>
|
||||||
<height>40</height>
|
<height>251</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user