Skip to content
Permalink
Browse files

network manager: support system proxy settings on windows (fixes #8600)

  • Loading branch information
jef-n committed Feb 16, 2014
1 parent ba47c9f commit 7f9a755f271a40c2e7864f7646cb5257d722d1ff
Showing with 55 additions and 24 deletions.
  1. +42 −24 src/app/qgisapp.cpp
  2. +13 −0 src/core/qgsnetworkaccessmanager.cpp
@@ -5765,8 +5765,8 @@ void QgisApp::editPaste( QgsMapLayer *destinationLayer )
if ( pkAttrList.contains( dst ) )
{
dstAttr[ dst ] = pasteVectorLayer->dataProvider()->defaultValue( dst );
if( !dstAttr[ dst ].isNull() )
continue;
if ( !dstAttr[ dst ].isNull() )
continue;
}

dstAttr[ dst ] = srcAttr[ src ];
@@ -7251,7 +7251,7 @@ void QgisApp::openURL( QString url, bool useQgisDocDirectory )
OSStatus status = LSOpenCFURLRef( urlRef, NULL );
status = 0; //avoid compiler warning
CFRelease( urlRef );
#elif defined(WIN32)
#elif defined(Q_OS_WIN)
if ( url.startsWith( "file://", Qt::CaseInsensitive ) )
ShellExecute( 0, 0, url.mid( 7 ).toLocal8Bit().constData(), 0, 0, SW_SHOWNORMAL );
else
@@ -9190,7 +9190,7 @@ void QgisApp::keyPressEvent( QKeyEvent * e )
{
stopRendering();
}
#if defined(Q_OS_WIN)&& defined(QGISDEBUG)
#if defined(Q_OS_WIN) && defined(QGISDEBUG)
else if ( e->key() == Qt::Key_Backslash && e->modifiers() & Qt::ControlModifier )
{
qgisCrashDump( 0 );
@@ -9480,6 +9480,14 @@ void QgisApp::namAuthenticationRequired( QNetworkReply *reply, QAuthenticator *a

void QgisApp::namProxyAuthenticationRequired( const QNetworkProxy &proxy, QAuthenticator *auth )
{
QSettings settings;
if ( !settings.value( "proxy/proxyEnabled", false ).toBool() ||
settings.value( "proxy/proxyType", "" ).toString() == "DefaultProxy" )
{
auth->setUser( "" );
return;
}

QString username = auth->user();
QString password = auth->password();

@@ -9554,29 +9562,39 @@ void QgisApp::namUpdate()
if ( proxyTypeString == "DefaultProxy" )
{
proxyType = QNetworkProxy::DefaultProxy;

#if defined(Q_OS_WIN)
QNetworkProxyFactory::setUseSystemConfiguration( true );
QList<QNetworkProxy> proxies = QNetworkProxyFactory::systemProxyForQuery();
if ( !proxies.isEmpty() )
{
proxy = proxies.first();
}
#endif

QgsDebugMsg( "setting default proxy" );
}
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" )
else
{
proxyType = QNetworkProxy::FtpCachingProxy;
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;
}

proxy = QNetworkProxy( proxyType, proxyHost, proxyPort, proxyUser, proxyPassword );
}
QgsDebugMsg( QString( "setting proxy %1 %2:%3 %4/%5" )
.arg( proxyType )
.arg( proxyHost ).arg( proxyPort )
.arg( proxyUser ).arg( proxyPassword )
);
proxy = QNetworkProxy( proxyType, proxyHost, proxyPort, proxyUser, proxyPassword );
}

#if QT_VERSION >= 0x40500
@@ -114,6 +114,19 @@ const QNetworkProxy &QgsNetworkAccessManager::fallbackProxy() const

void QgsNetworkAccessManager::setFallbackProxyAndExcludes( const QNetworkProxy &proxy, const QStringList &excludes )
{
QgsDebugMsg( QString( "proxy settings: (type:%1 host: %2:%3, user:%4, password:%5" )
.arg( proxy.type() == QNetworkProxy::DefaultProxy ? "DefaultProxy" :
proxy.type() == QNetworkProxy::Socks5Proxy ? "Socks5Proxy" :
proxy.type() == QNetworkProxy::NoProxy ? "NoProxy" :
proxy.type() == QNetworkProxy::HttpProxy ? "HttpProxy" :
proxy.type() == QNetworkProxy::HttpCachingProxy ? "HttpCachingProxy" :
proxy.type() == QNetworkProxy::FtpCachingProxy ? "FtpCachingProxy" :
"Undefined" )
.arg( proxy.hostName() )
.arg( proxy.port() )
.arg( proxy.user() )
.arg( proxy.password().isEmpty() ? "not set" : "set" ) );

mFallbackProxy = proxy;
mExcludedURLs = excludes;
}

0 comments on commit 7f9a755

Please sign in to comment.
You can’t perform that action at this time.