Skip to content
Permalink
Browse files

re-enable proxy exclusion

git-svn-id: http://svn.osgeo.org/qgis/trunk@13103 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef
jef committed Mar 20, 2010
1 parent 4f2d0f0 commit aa3c2e70b2507bd63a1b519dda624fc07e4b3ff6
Showing with 116 additions and 5 deletions.
  1. +1 −0 src/app/CMakeLists.txt
  2. +12 −5 src/app/qgisapp.cpp
  3. +59 −0 src/app/qgsnetworkproxyfactory.cpp
  4. +40 −0 src/app/qgsnetworkproxyfactory.h
  5. +4 −0 src/app/qgsoptions.cpp
@@ -70,6 +70,7 @@ SET(QGIS_APP_SRCS
qgsuniquevaluedialog.cpp
qgsvectorlayerproperties.cpp
qgsquerybuilder.cpp
qgsnetworkproxyfactory.cpp

qgsmanageconnectionsdialog.cpp

@@ -149,6 +149,7 @@
#include "qgsattributetabledialog.h"
#include "qgsvectorfilewriter.h"
#include "qgscredentialdialog.h"
#include "qgsnetworkproxyfactory.h"

#ifdef HAVE_QWT
#include "qgsgpsinformationwidget.h"
@@ -6219,12 +6220,16 @@ void QgisApp::namProxyAuthenticationRequired( const QNetworkProxy &proxy, QAuthe

void QgisApp::namUpdate()
{
QNetworkProxy proxy;
QStringList excludes;

QSettings settings;

//check if proxy is enabled
bool proxyEnabled = settings.value( "proxy/proxyEnabled", false ).toBool();
if ( proxyEnabled )
{
excludes = settings.value( "proxy/proxyExcludedUrls", "" ).toString().split( "|", QString::SkipEmptyParts );

//read type, host, port, user, passw from settings
QString proxyHost = settings.value( "proxy/proxyHost", "" ).toString();
@@ -6259,13 +6264,15 @@ void QgisApp::namUpdate()
.arg( proxyHost ).arg( proxyPort )
.arg( proxyUser ).arg( proxyPassword )
);
nam()->setProxy( QNetworkProxy( proxyType, proxyHost, proxyPort, proxyUser, proxyPassword ) );
}
else
{
nam()->setProxy( QNetworkProxy() );
proxy = QNetworkProxy( proxyType, proxyHost, proxyPort, proxyUser, proxyPassword );
}

#if QT_VERSION >= 0x40500
mNAM->setProxyFactory( new QgsNetworkProxyFactory( proxy, excludes ) );
#else
mNAM->setProxy( proxy );
#endif

QNetworkDiskCache *cache = qobject_cast<QNetworkDiskCache*>( nam()->cache() );
if ( !cache )
cache = new QNetworkDiskCache( this );
@@ -0,0 +1,59 @@
/***************************************************************************
qgsnetworkproxyfactory.cpp - description
-------------------
begin : Sat Mar 20 2010
copyright : (C) 2010 by Juergen E. Fischer
email : jef at norbit dot de
***************************************************************************/

/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
/* $Id$ */

#include <QtGlobal>

#if QT_VERSION >= 0x40500

#include <QSettings>
#include <QUrl>

#include "qgsnetworkproxyfactory.h"
#include "qgslogger.h"

QgsNetworkProxyFactory::QgsNetworkProxyFactory( const QNetworkProxy &proxy, const QStringList &excludes )
{
mProxy = proxy;
mExcludedURLs = excludes;
}

QgsNetworkProxyFactory::~QgsNetworkProxyFactory()
{
}

QList<QNetworkProxy> QgsNetworkProxyFactory::queryProxy( const QNetworkProxyQuery &query )
{
if( query.queryType() != QNetworkProxyQuery::UrlRequest )
return QList<QNetworkProxy>() << mProxy;

QString url = query.url().toString();

foreach( QString exclude, mExcludedURLs )
{
if ( url.startsWith( exclude ) )
{
QgsDebugMsg( QString("using default proxy for %1 [exclude %2]").arg( url ).arg( exclude ) );
return QList<QNetworkProxy>() << QNetworkProxy();
}
}

QgsDebugMsg( QString("using user proxy for %1").arg( url ) );
return QList<QNetworkProxy>() << mProxy;
}

#endif // QT_VERSION >= 0x40500
@@ -0,0 +1,40 @@
/***************************************************************************
qgsabout.h - description
-------------------
begin : Sat, 20 Mar 2010
copyright : (C) 2010 by Juergen E. Fischer
email : jef at norbit dot de
***************************************************************************/

/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
/* $Id:$ */
#ifndef QGSNETWORKPROXYFACTORY_H
#define QGSNETWORKPROXYFACTORY_H

#if QT_VERSION >= 0x40500

#include <QNetworkProxyFactory>
#include <QStringList>

class QgsNetworkProxyFactory : public QNetworkProxyFactory
{
public:
QgsNetworkProxyFactory( const QNetworkProxy &proxy, const QStringList &excludes );
virtual ~QgsNetworkProxyFactory();
virtual QList<QNetworkProxy> queryProxy( const QNetworkProxyQuery & query = QNetworkProxyQuery() );

private:
QStringList mExcludedURLs;
QNetworkProxy mProxy;
};

#endif // QT_VERSION >= 0x40500

#endif
@@ -116,6 +116,10 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WFlags fl ) :
}
}

#if QT_VERSION < 0x40500
mExcludeUrlListWidget->setDisabled( true );
#endif

// cache settings
QNetworkDiskCache *cache = qobject_cast<QNetworkDiskCache*>( QgisApp::instance()->nam()->cache() );
if ( cache )

0 comments on commit aa3c2e7

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