Skip to content

Commit 0fa8024

Browse files
author
timlinux
committedJun 15, 2008
Implemented proxy support to be application global rather than set on a per connection basis
git-svn-id: http://svn.osgeo.org/qgis/trunk@8649 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 1131288 commit 0fa8024

13 files changed

+136
-637
lines changed
 

‎python/core/qgsrasterdataprovider.sip

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -29,40 +29,6 @@ public:
2929

3030
virtual ~QgsRasterDataProvider();
3131

32-
33-
/**
34-
* Gets the HTTP proxy host used for this connection
35-
*/
36-
virtual QString proxyHost() const = 0;
37-
38-
/**
39-
* Gets the HTTP proxy port used for this connection
40-
*/
41-
virtual int proxyPort() const = 0;
42-
43-
/**
44-
* Gets the HTTP proxy user name used for this connection
45-
*/
46-
virtual QString proxyUser() const = 0;
47-
48-
/**
49-
* Gets the HTTP proxy user password used for this connection
50-
*/
51-
virtual QString proxyPass() const = 0;
52-
53-
/**
54-
*
55-
* Sets a proxy for the URL given in the constructor
56-
*
57-
*
58-
* \retval TRUE if proxy setting is successful (if indeed it is supported)
59-
*/
60-
virtual bool setProxy(const QString & host,
61-
int port,
62-
const QString & user,
63-
const QString & pass);
64-
65-
6632
/**
6733
* Add the list of WMS layer names to be rendered by this server
6834
*/

‎python/core/qgsrasterlayer.sip

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -535,35 +535,17 @@ public:
535535
const QStringList & layers = QStringList(),
536536
const QStringList & styles = QStringList(),
537537
const QString & format = QString(),
538-
const QString & crs = QString(),
539-
const QString & proxyHost = QString(),
540-
int proxyPort = 80,
541-
const QString & proxyUser = QString(),
542-
const QString & proxyPass = QString());
538+
const QString & crs = QString());
543539

544540
void setDataProvider( const QString & provider,
545541
const QStringList & layers,
546542
const QStringList & styles,
547543
const QString & format,
548-
const QString & crs,
549-
const QString & proxyHost,
550-
int proxyPort,
551-
const QString & proxyUser,
552-
const QString & proxyPass );
544+
const QString & crs);
553545

554546
//! Does this layer use a provider for setting/retrieving data?
555547
bool usesProvider();
556548

557-
/**
558-
* Sets a proxy for the path given in the constructor
559-
*
560-
* \retval TRUE if proxy setting is successful (if indeed it is supported)
561-
*/
562-
bool setProxy(const QString & host = 0,
563-
int port = 80,
564-
const QString & user = 0,
565-
const QString & pass = 0);
566-
567549
//! Which provider is being used for this Raster Layer?
568550
QString providerKey();
569551

‎src/app/qgisapp.cpp

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
#include <QMenuBar>
4646
#include <QMenuItem>
4747
#include <QMessageBox>
48+
#include <QNetworkProxy>
4849
#include <QPainter>
4950
#include <QPictureIO>
5051
#include <QPixmap>
@@ -331,6 +332,7 @@ static void customSrsValidation_(QgsSpatialRefSys* srs)
331332
createLegend();
332333
createOverview();
333334
createMapTips();
335+
setupProxy();
334336

335337
mComposer = new QgsComposer(this); // Map composer
336338
mInternalClipboard = new QgsClipboard; // create clipboard
@@ -2216,12 +2218,7 @@ void QgisApp::addWmsLayer()
22162218
wmss->selectedLayers(),
22172219
wmss->selectedStylesForSelectedLayers(),
22182220
wmss->selectedImageEncoding(),
2219-
wmss->selectedCrs(),
2220-
wmss->connProxyHost(),
2221-
wmss->connProxyPort(),
2222-
wmss->connProxyUser(),
2223-
wmss->connProxyPass()
2224-
);
2221+
wmss->selectedCrs());
22252222
}
22262223
}
22272224

@@ -4355,6 +4352,7 @@ void QgisApp::options()
43554352
// bool splitterRedraw = mySettings.value("/qgis/splitterRedraw", true).toBool();
43564353
// canvasLegendSplit->setOpaqueResize(splitterRedraw);
43574354
// legendOverviewSplit->setOpaqueResize(splitterRedraw);
4355+
setupProxy();
43584356
}
43594357
}
43604358

@@ -5221,11 +5219,7 @@ QgsRasterLayer* QgisApp::addRasterLayer(QString const & rasterLayerPath,
52215219
QStringList const & layers,
52225220
QStringList const & styles,
52235221
QString const & format,
5224-
QString const & crs,
5225-
QString const & proxyHost,
5226-
int proxyPort,
5227-
QString const & proxyUser,
5228-
QString const & proxyPassword)
5222+
QString const & crs)
52295223
{
52305224
QgsDebugMsg("about to get library for " + providerKey);
52315225

@@ -5254,8 +5248,7 @@ QgsRasterLayer* QgisApp::addRasterLayer(QString const & rasterLayerPath,
52545248
+ " and CRS of " + crs );
52555249

52565250
// TODO: Remove the 0 when the raster layer becomes a full provider gateway.
5257-
layer = new QgsRasterLayer(0, rasterLayerPath, baseName, providerKey, layers, styles, format, crs,
5258-
proxyHost, proxyPort, proxyUser, proxyPassword);
5251+
layer = new QgsRasterLayer(0, rasterLayerPath, baseName, providerKey, layers, styles, format, crs);
52595252

52605253
QgsDebugMsg("Constructed new layer.");
52615254

@@ -5521,3 +5514,23 @@ void QgisApp::warnOlderProjectVersion(QString oldVersion)
55215514
}
55225515
return;
55235516
}
5517+
5518+
void QgisApp::setupProxy()
5519+
{
5520+
QSettings mySettings;
5521+
bool myFlag = mySettings.value("proxy/proxyEnabled", "0").toBool();
5522+
QNetworkProxy myProxy;
5523+
if (myFlag)
5524+
{
5525+
myProxy.setType(QNetworkProxy::HttpProxy);
5526+
myProxy.setHostName(mySettings.value("proxy/proxyHost", "").toString());
5527+
myProxy.setPort(mySettings.value("proxy/proxyPort", "").toInt());
5528+
myProxy.setUser(mySettings.value("proxy/proxyUser", "").toString());
5529+
myProxy.setPassword(mySettings.value("proxy/proxyPassword", "").toString());
5530+
}
5531+
else
5532+
{
5533+
// otherwise leave it blank to disable proxy usage
5534+
}
5535+
QNetworkProxy::setApplicationProxy(myProxy);
5536+
}

‎src/app/qgisapp.h

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,7 @@ class QgisApp : public QMainWindow
102102
QStringList const & layers,
103103
QStringList const & styles,
104104
QString const & format,
105-
QString const & crs,
106-
QString const & proxyHost = QString(),
107-
int proxyPort = 80,
108-
QString const & proxyUser = QString(),
109-
QString const & proxyPassword = QString());
105+
QString const & crs);
110106

111107
/** open a raster layer for the given file
112108
@returns false if unable to open a raster layer for rasterFile
@@ -150,6 +146,22 @@ class QgisApp : public QMainWindow
150146

151147
void dropEvent(QDropEvent *);
152148

149+
/** Setup the proxy settings from the QSettings environment.
150+
* This is not called by default in the constructor. Rather,
151+
* the application must explicitly call setupProx(). If
152+
* you write your own application and wish to explicitly
153+
* set up your own proxy rather, you should e.g.
154+
* QNetworkProxy proxy;
155+
* proxy.setType(QNetworkProxy::Socks5Proxy);
156+
* proxy.setHostName("proxy.example.com");
157+
* proxy.setPort(1080);
158+
* proxy.setUser("username");
159+
* proxy.setPassword("password");
160+
* QNetworkProxy::setApplicationProxy(proxy);
161+
*
162+
* (as documented in Qt documentation.
163+
*/
164+
void setupProxy();
153165
//private slots:
154166
public slots:
155167
//! About QGis

‎src/app/qgsnewhttpconnection.cpp

Lines changed: 23 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -19,61 +19,48 @@
1919
#include "qgscontexthelp.h"
2020
#include <QSettings>
2121

22-
QgsNewHttpConnection::QgsNewHttpConnection(QWidget *parent, const QString& baseKey, const QString& connName, Qt::WFlags fl): QDialog(parent, fl), mBaseKey(baseKey), mOriginalConnName(connName)
22+
QgsNewHttpConnection::QgsNewHttpConnection(
23+
QWidget *parent, const QString& baseKey, const QString& connName, Qt::WFlags fl):
24+
QDialog(parent, fl),
25+
mBaseKey(baseKey),
26+
mOriginalConnName(connName)
2327
{
2428
setupUi(this);
25-
connect(btnCancel, SIGNAL(clicked()), this, SLOT(reject()));
26-
connect(btnOk, SIGNAL(clicked()), this, SLOT(saveConnection()));
2729

2830
if (!connName.isEmpty())
29-
{
30-
// populate the dialog with the information stored for the connection
31-
// populate the fields with the stored setting parameters
32-
33-
QSettings settings;
31+
{
32+
// populate the dialog with the information stored for the connection
33+
// populate the fields with the stored setting parameters
3434

35-
QString key = mBaseKey + connName;
36-
txtName->setText (connName);
37-
txtUrl->setText (settings.value(key + "/url").toString());
38-
txtProxyHost->setText(settings.value(key + "/proxyhost").toString());
39-
txtProxyPort->setText(settings.value(key + "/proxyport").toString());
40-
txtProxyUser->setText(settings.value(key + "/proxyuser").toString());
41-
txtProxyPass->setText(settings.value(key + "/proxypassword").toString());
42-
}
43-
}
35+
QSettings settings;
4436

45-
QgsNewHttpConnection::~QgsNewHttpConnection()
46-
{
37+
QString key = mBaseKey + connName;
38+
txtName->setText (connName);
39+
txtUrl->setText (settings.value(key + "/url").toString());
40+
}
41+
connect(buttonBox, SIGNAL(helpRequested()), this, SLOT(helpRequested()));
4742
}
4843

49-
void QgsNewHttpConnection::testConnection()
44+
QgsNewHttpConnection::~QgsNewHttpConnection()
5045
{
51-
// following line uses Qt SQL plugin - currently not used
52-
// QSqlDatabase *testCon = QSqlDatabase::addDatabase("QPSQL7","testconnection");
53-
54-
5546
}
5647

57-
void QgsNewHttpConnection::saveConnection()
48+
void QgsNewHttpConnection::accept()
5849
{
5950
QSettings settings;
6051
QString key = mBaseKey + txtName->text();
61-
52+
6253
//delete original entry first
6354
if(!mOriginalConnName.isNull() && mOriginalConnName != key)
64-
{
65-
settings.remove(mBaseKey + mOriginalConnName);
66-
}
55+
{
56+
settings.remove(mBaseKey + mOriginalConnName);
57+
}
6758
settings.setValue(key + "/url", txtUrl->text().trimmed());
68-
settings.setValue(key + "/proxyhost", txtProxyHost->text().trimmed());
69-
settings.setValue(key + "/proxyport", txtProxyPort->text().trimmed());
70-
settings.setValue(key + "/proxyuser", txtProxyUser->text().trimmed());
71-
settings.setValue(key + "/proxypassword", txtProxyPass->text().trimmed());
72-
73-
accept();
59+
60+
QDialog::accept();
7461
}
7562

76-
void QgsNewHttpConnection::on_btnHelp_clicked()
63+
void QgsNewHttpConnection::helpRequested()
7764
{
7865
QgsContextHelp::run(context_id);
7966
}

‎src/app/qgsnewhttpconnection.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,11 @@ class QgsNewHttpConnection : public QDialog, private Ui::QgsNewHttpConnectionBas
3131
QgsNewHttpConnection(QWidget *parent = 0, const QString& baseKey = "/Qgis/connections-wms/", const QString& connName = QString::null, Qt::WFlags fl = QgisGui::ModalDialogFlags);
3232
//! Destructor
3333
~QgsNewHttpConnection();
34-
//! Tests the connection using the parameters supplied
35-
void testConnection();
3634
public slots:
3735
//! Saves the connection to ~/.qt/qgisrc
38-
void saveConnection();
36+
void accept();
3937
//! Show context help
40-
void on_btnHelp_clicked();
38+
void helpRequested();
4139
private:
4240
QString mBaseKey;
4341
QString mOriginalConnName; //store initial name to delete entry in case of rename

‎src/app/qgsserversourceselect.cpp

Lines changed: 4 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -363,47 +363,7 @@ void QgsServerSourceSelect::on_btnConnect_clicked()
363363

364364
connStringParts += settings.value(key + "/url").toString();
365365

366-
/*
367-
// Add the proxy host and port if any are defined.
368-
if ( ! ( (part = settings.value(key + "/proxyhost").toString()).isEmpty() ) )
369-
{
370-
#ifdef QGISDEBUG
371-
std::cout << "QgsServerSourceSelect::serverConnect: Got a proxyhost - '" << part.toLocal8Bit().data() << "'." << std::endl;
372-
#endif
373-
connStringParts += part;
374-
375-
if ( ! ( (part = settings.value(key + "/proxyport").toString()).isEmpty() ) )
376-
{
377-
#ifdef QGISDEBUG
378-
std::cout << "QgsServerSourceSelect::serverConnect: Got a proxyport - '" << part.toLocal8Bit().data() << "'." << std::endl;
379-
#endif
380-
connStringParts += part;
381-
}
382-
else
383-
{
384-
connStringParts += "80"; // well-known http port
385-
}
386-
387-
if ( ! ( (part = settings.value(key + "/proxyuser").toString()).isEmpty() ) )
388-
{
389-
#ifdef QGISDEBUG
390-
std::cout << "QgsServerSourceSelect::serverConnect: Got a proxyuser - '" << part.toLocal8Bit().data() << "'." << std::endl;
391-
#endif
392-
connStringParts += part;
393-
394-
if ( ! ( (part = settings.value(key + "/proxypass").toString()).isEmpty() ) )
395-
{
396-
#ifdef QGISDEBUG
397-
std::cout << "QgsServerSourceSelect::serverConnect: Got a proxypass - '" << part.toLocal8Bit().data() << "'." << std::endl;
398-
#endif
399-
connStringParts += part;
400-
}
401-
}
402-
}
403-
*/
404-
405366
m_connName = cmbConnections->currentText();
406-
// setup 'url ( + " " + proxyhost + " " + proxyport + " " + proxyuser + " " + proxypass)'
407367
m_connInfo = connStringParts.join(" ");
408368

409369
#ifdef QGISDEBUG
@@ -423,20 +383,6 @@ void QgsServerSourceSelect::on_btnConnect_clicked()
423383
{
424384
connect(mWmsProvider, SIGNAL(setStatus(QString)), this, SLOT(showStatusMessage(QString)));
425385

426-
// Collect and set HTTP proxy on WMS provider
427-
428-
m_connProxyHost = settings.value(key + "/proxyhost").toString(),
429-
m_connProxyPort = settings.value(key + "/proxyport").toInt(),
430-
m_connProxyUser = settings.value(key + "/proxyuser").toString(),
431-
m_connProxyPass = settings.value(key + "/proxypassword").toString(),
432-
433-
mWmsProvider->setProxy(
434-
m_connProxyHost,
435-
m_connProxyPort,
436-
m_connProxyUser,
437-
m_connProxyPass
438-
);
439-
440386
// WMS Provider all set up; let's get some layers
441387

442388
if (!populateLayerList(mWmsProvider))
@@ -632,26 +578,6 @@ QString QgsServerSourceSelect::connInfo()
632578
return m_connInfo;
633579
}
634580

635-
QString QgsServerSourceSelect::connProxyHost()
636-
{
637-
return m_connProxyHost;
638-
}
639-
640-
int QgsServerSourceSelect::connProxyPort()
641-
{
642-
return m_connProxyPort;
643-
}
644-
645-
QString QgsServerSourceSelect::connProxyUser()
646-
{
647-
return m_connProxyUser;
648-
}
649-
650-
QString QgsServerSourceSelect::connProxyPass()
651-
{
652-
return m_connProxyPass;
653-
}
654-
655581
QStringList QgsServerSourceSelect::selectedLayers()
656582
{
657583
return m_selectedLayers;
@@ -796,17 +722,16 @@ void QgsServerSourceSelect::addDefaultServers()
796722
if (!keys.contains(i.key()))
797723
{
798724
QString path = i.key();
799-
settings.setValue(path + "/proxyhost", "");
800-
settings.setValue(path + "/proxyport", 80);
801-
settings.setValue(path + "/proxyuser", "");
802-
settings.setValue(path + "/proxypassword", "");
803725
settings.setValue(path + "/url", i.value());
804726
}
805727
}
806728
settings.endGroup();
807729
populateConnectionList();
808730

809-
QMessageBox::information(this, tr("WMS proxies"), tr("<p>Several WMS servers have been added to the server list. Note that the proxy fields have been left blank and if you access the internet via a web proxy, you will need to individually set the proxy fields with appropriate values.</p>"));
731+
QMessageBox::information(this, tr("WMS proxies"), "<p>" + tr("Several WMS servers have "
732+
"been added to the server list. Note that if "
733+
"you access the internet via a web proxy, you will "
734+
"need to set the proxy settings in the QGIS options dialog.") + "</p>");
810735
}
811736

812737
// ENDS

‎src/core/qgsrasterdataprovider.h

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -57,48 +57,6 @@ class CORE_EXPORT QgsRasterDataProvider : public QgsDataProvider
5757
virtual ~QgsRasterDataProvider() {};
5858

5959

60-
/**
61-
* Gets the HTTP proxy host used for this connection
62-
*/
63-
virtual QString proxyHost() const = 0;
64-
65-
/**
66-
* Gets the HTTP proxy port used for this connection
67-
*/
68-
virtual int proxyPort() const = 0;
69-
70-
/**
71-
* Gets the HTTP proxy user name used for this connection
72-
*/
73-
virtual QString proxyUser() const = 0;
74-
75-
/**
76-
* Gets the HTTP proxy user password used for this connection
77-
*/
78-
virtual QString proxyPass() const = 0;
79-
80-
81-
/**
82-
*
83-
* Sets a proxy for the URL given in the constructor
84-
*
85-
*
86-
* \retval TRUE if proxy setting is successful (if indeed it is supported)
87-
*/
88-
virtual bool setProxy(QString const & host,
89-
int port,
90-
QString const & user,
91-
QString const & pass)
92-
{
93-
//this is mainly to prevent compiler warnings
94-
if (host.isEmpty() || port < 1 || user.isEmpty() || pass.isEmpty())
95-
{
96-
return FALSE;
97-
}
98-
99-
return FALSE;
100-
}
101-
10260
/**
10361
* Add the list of WMS layer names to be rendered by this server
10462
*/

‎src/core/raster/qgsrasterlayer.cpp

Lines changed: 4 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -4164,14 +4164,7 @@ bool QgsRasterLayer::readXML_( QDomNode & layer_node )
41644164
// Collect CRS
41654165
QString crs = QString("EPSG:%1").arg(srs().epsg());
41664166

4167-
// Collect proxy information
4168-
QString proxyHost = rpNode.namedItem("wmsProxyHost").toElement().text();
4169-
int proxyPort = rpNode.namedItem("wmsProxyPort").toElement().text().toInt();
4170-
QString proxyUser = rpNode.namedItem("wmsProxyUser").toElement().text();
4171-
QString proxyPass = rpNode.namedItem("wmsProxyPass").toElement().text();
4172-
4173-
setDataProvider( mProviderKey, layers, styles, format, crs,
4174-
proxyHost, proxyPort, proxyUser, proxyPass );
4167+
setDataProvider( mProviderKey, layers, styles, format, crs );
41754168
}
41764169
else
41774170
{
@@ -4447,33 +4440,6 @@ bool QgsRasterLayer::readXML_( QDomNode & layer_node )
44474440
formatElement.appendChild(formatText);
44484441
rasterPropertiesElement.appendChild(formatElement);
44494442

4450-
// <rasterproperties><wmsProxyHost>
4451-
QDomElement proxyHostElement = document.createElement("wmsProxyHost");
4452-
QDomText proxyHostText =
4453-
document.createTextNode(mDataProvider->proxyHost());
4454-
proxyHostElement.appendChild(proxyHostText);
4455-
rasterPropertiesElement.appendChild(proxyHostElement);
4456-
4457-
// <rasterproperties><wmsProxyPort>
4458-
QDomElement proxyPortElement = document.createElement("wmsProxyPort");
4459-
QDomText proxyPortText =
4460-
document.createTextNode( QString::number(mDataProvider->proxyPort()) );
4461-
proxyPortElement.appendChild(proxyPortText);
4462-
rasterPropertiesElement.appendChild(proxyPortElement);
4463-
4464-
// <rasterproperties><wmsProxyUser>
4465-
QDomElement proxyUserElement = document.createElement("wmsProxyUser");
4466-
QDomText proxyUserText =
4467-
document.createTextNode(mDataProvider->proxyUser());
4468-
proxyUserElement.appendChild(proxyUserText);
4469-
rasterPropertiesElement.appendChild(proxyUserElement);
4470-
4471-
// <rasterproperties><wmsProxyPass>
4472-
QDomElement proxyPassElement = document.createElement("wmsProxyPass");
4473-
QDomText proxyPassText =
4474-
document.createTextNode(mDataProvider->proxyPass());
4475-
proxyPassElement.appendChild(proxyPassText);
4476-
rasterPropertiesElement.appendChild(proxyPassElement);
44774443
}
44784444

44794445
// <mDebugOverlayFlag>
@@ -4907,11 +4873,7 @@ QgsRasterLayer::QgsRasterLayer(int dummy,
49074873
QStringList const & layers,
49084874
QStringList const & styles,
49094875
QString const & format,
4910-
QString const & crs,
4911-
QString const & proxyHost,
4912-
int proxyPort,
4913-
QString const & proxyUser,
4914-
QString const & proxyPass )
4876+
QString const & crs)
49154877
: QgsMapLayer(RASTER, baseName, rasterLayerPath),
49164878
mRasterXDim( std::numeric_limits<int>::max() ),
49174879
mRasterYDim( std::numeric_limits<int>::max() ),
@@ -4941,8 +4903,7 @@ mModified(false)
49414903
// if we're given a provider type, try to create and bind one to this layer
49424904
if ( ! providerKey.isEmpty() )
49434905
{
4944-
setDataProvider( providerKey, layers, styles, format, crs,
4945-
proxyHost, proxyPort, proxyUser, proxyPass );
4906+
setDataProvider( providerKey, layers, styles, format, crs );
49464907
}
49474908

49484909
// Default for the popup menu
@@ -4981,11 +4942,7 @@ void QgsRasterLayer::setDataProvider( QString const & provider,
49814942
QStringList const & layers,
49824943
QStringList const & styles,
49834944
QString const & format,
4984-
QString const & crs,
4985-
QString const & proxyHost,
4986-
int proxyPort,
4987-
QString const & proxyUser,
4988-
QString const & proxyPass )
4945+
QString const & crs)
49894946
{
49904947
// XXX should I check for and possibly delete any pre-existing providers?
49914948
// XXX How often will that scenario occur?
@@ -5052,7 +5009,6 @@ void QgsRasterLayer::setDataProvider( QString const & provider,
50525009
mDataProvider->addLayers(layers, styles);
50535010
mDataProvider->setImageEncoding(format);
50545011
mDataProvider->setImageCrs(crs);
5055-
mDataProvider->setProxy(proxyHost, proxyPort, proxyUser, proxyPass);
50565012

50575013
// get the extent
50585014
QgsRect mbr = mDataProvider->extent();
@@ -5095,29 +5051,6 @@ void QgsRasterLayer::setDataProvider( QString const & provider,
50955051
} // QgsRasterLayer::setDataProvider
50965052

50975053

5098-
bool QgsRasterLayer::setProxy(QString const & host,
5099-
int port,
5100-
QString const & user,
5101-
QString const & pass)
5102-
{
5103-
if (!mDataProvider)
5104-
{
5105-
return FALSE;
5106-
}
5107-
else
5108-
{
5109-
#ifdef QGISDEBUG
5110-
std::cout << " QgsRasterLayer::setProxy: host = " << host.toLocal8Bit().data() << "." << std::endl;
5111-
std::cout << " QgsRasterLayer::setProxy: port = " << port << "." << std::endl;
5112-
std::cout << " QgsRasterLayer::setProxy: user = " << user.toLocal8Bit().data() << "." << std::endl;
5113-
std::cout << " QgsRasterLayer::setProxy: pass = " << pass.toLocal8Bit().data() << "." << std::endl;
5114-
#endif
5115-
return mDataProvider->setProxy(host, port, user, pass);
5116-
}
5117-
}
5118-
5119-
5120-
51215054
bool QgsRasterLayer::usesProvider()
51225055
{
51235056
if (mProviderKey.isEmpty())

‎src/core/raster/qgsrasterlayer.h

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1090,35 +1090,18 @@ public slots:
10901090
const QStringList & layers = QStringList(),
10911091
const QStringList & styles = QStringList(),
10921092
const QString & format = QString(),
1093-
const QString & crs = QString(),
1094-
const QString & proxyHost = QString(),
1095-
int proxyPort = 80,
1096-
const QString & proxyUser = QString(),
1097-
const QString & proxyPass = QString());
1093+
const QString & crs = QString()
1094+
);
10981095

10991096
void setDataProvider( const QString & provider,
11001097
const QStringList & layers,
11011098
const QStringList & styles,
11021099
const QString & format,
1103-
const QString & crs,
1104-
const QString & proxyHost,
1105-
int proxyPort,
1106-
const QString & proxyUser,
1107-
const QString & proxyPass );
1100+
const QString & crs);
11081101

11091102
//! Does this layer use a provider for setting/retrieving data?
11101103
bool usesProvider();
11111104

1112-
/**
1113-
* Sets a proxy for the path given in the constructor
1114-
*
1115-
* \retval TRUE if proxy setting is successful (if indeed it is supported)
1116-
*/
1117-
bool setProxy(const QString & host = 0,
1118-
int port = 80,
1119-
const QString & user = 0,
1120-
const QString & pass = 0);
1121-
11221105
//! Which provider is being used for this Raster Layer?
11231106
QString providerKey();
11241107

‎src/providers/wms/qgswmsprovider.cpp

Lines changed: 1 addition & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,6 @@ static QString DEFAULT_LATLON_CRS = "CRS:84";
5151
QgsWmsProvider::QgsWmsProvider(QString const & uri)
5252
: QgsRasterDataProvider(uri),
5353
httpuri(uri),
54-
mHttpProxyHost(0),
55-
mHttpProxyPort(80),
56-
mHttpProxyUser(0),
57-
mHttpProxyPass(0),
5854
httpcapabilitiesresponse(0),
5955
imageCrs(DEFAULT_LATLON_CRS),
6056
cachedImage(0),
@@ -134,42 +130,6 @@ QgsWmsProvider::~QgsWmsProvider()
134130
}
135131

136132

137-
QString QgsWmsProvider::proxyHost() const
138-
{
139-
return mHttpProxyHost;
140-
}
141-
142-
143-
int QgsWmsProvider::proxyPort() const
144-
{
145-
return mHttpProxyPort;
146-
}
147-
148-
149-
QString QgsWmsProvider::proxyUser() const
150-
{
151-
return mHttpProxyUser;
152-
}
153-
154-
155-
QString QgsWmsProvider::proxyPass() const
156-
{
157-
return mHttpProxyPass;
158-
}
159-
160-
161-
bool QgsWmsProvider::setProxy(QString const & host,
162-
int port,
163-
QString const & user,
164-
QString const & pass)
165-
{
166-
mHttpProxyHost = host;
167-
mHttpProxyPort = port;
168-
mHttpProxyUser = user;
169-
mHttpProxyPass = pass;
170-
171-
return TRUE;
172-
}
173133

174134
bool QgsWmsProvider::supportedLayers(std::vector<QgsWmsLayerProperty> & layers)
175135
{
@@ -655,11 +615,7 @@ QByteArray QgsWmsProvider::retrieveUrl(QString url)
655615
{
656616
QgsDebugMsg("WMS request Url: " + url);
657617
QgsHttpTransaction http(
658-
url,
659-
mHttpProxyHost,
660-
mHttpProxyPort,
661-
mHttpProxyUser,
662-
mHttpProxyPass);
618+
url);
663619

664620
// Do a passthrough for the status bar text
665621
connect(

‎src/providers/wms/qgswmsprovider.h

Lines changed: 2 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -328,8 +328,6 @@ class QgsCoordinateTransform;
328328
interface defined in the QgsDataProvider class to provide access to spatial
329329
data residing in a OGC Web Map Service.
330330
331-
TODO: Make it work
332-
333331
*/
334332
class QgsWmsProvider : public QgsRasterDataProvider
335333
{
@@ -342,45 +340,15 @@ class QgsWmsProvider : public QgsRasterDataProvider
342340
/**
343341
* Constructor for the provider.
344342
*
345-
* \param uri HTTP URL of the Web Server. If setProxy() is not also called then we will
346-
* contact the host directly.
343+
* \param uri HTTP URL of the Web Server. If needed a proxy will be used
344+
* otherwise we contact the host directly.
347345
*
348346
*/
349347
QgsWmsProvider(QString const & uri = 0);
350348

351349
//! Destructor
352350
virtual ~QgsWmsProvider();
353351

354-
/**
355-
* Gets the HTTP proxy host used for this connection
356-
*/
357-
virtual QString proxyHost() const;
358-
359-
/**
360-
* Gets the HTTP proxy port used for this connection
361-
*/
362-
virtual int proxyPort() const;
363-
364-
/**
365-
* Gets the HTTP proxy user name used for this connection
366-
*/
367-
virtual QString proxyUser() const;
368-
369-
/**
370-
* Gets the HTTP proxy user password used for this connection
371-
*/
372-
virtual QString proxyPass() const;
373-
374-
/**
375-
*
376-
* Sets an HTTP proxy for the URL given in the constructor
377-
*
378-
*/
379-
virtual bool setProxy(QString const & host = 0,
380-
int port = 80,
381-
QString const & user = 0,
382-
QString const & pass = 0);
383-
384352
/**
385353
* \brief Returns a list of the supported layers of the WMS server
386354
*
@@ -723,18 +691,6 @@ public slots:
723691
//! URL part of URI (httpuri)
724692
QString baseUrl;
725693

726-
//! HTTP proxy host name for the WMS for this layer
727-
QString mHttpProxyHost;
728-
729-
//! HTTP proxy port number for the WMS for this layer
730-
int mHttpProxyPort;
731-
732-
//! HTTP proxy username for the WMS for this layer
733-
QString mHttpProxyUser;
734-
735-
//! HTTP proxy password for the WMS for this layer
736-
QString mHttpProxyPass;
737-
738694
/**
739695
* Flag indicating if the layer data source is a valid WMS layer
740696
*/

‎src/ui/qgsnewhttpconnectionbase.ui

Lines changed: 52 additions & 222 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
<rect>
66
<x>0</x>
77
<y>0</y>
8-
<width>437</width>
9-
<height>256</height>
8+
<width>431</width>
9+
<height>159</height>
1010
</rect>
1111
</property>
1212
<property name="windowTitle" >
13-
<string>Create a New WMS connection</string>
13+
<string>Create a new WMS connection</string>
1414
</property>
1515
<property name="sizeGripEnabled" >
1616
<bool>true</bool>
@@ -19,31 +19,22 @@
1919
<bool>true</bool>
2020
</property>
2121
<layout class="QGridLayout" >
22-
<property name="margin" >
23-
<number>9</number>
24-
</property>
25-
<property name="spacing" >
26-
<number>6</number>
27-
</property>
2822
<item row="0" column="0" >
2923
<widget class="QGroupBox" name="GroupBox1" >
3024
<property name="title" >
31-
<string>Connection Information</string>
25+
<string>Connection details</string>
3226
</property>
3327
<layout class="QGridLayout" >
34-
<property name="margin" >
35-
<number>0</number>
36-
</property>
37-
<property name="spacing" >
38-
<number>5</number>
39-
</property>
40-
<item rowspan="6" row="0" column="2" >
41-
<widget class="QFrame" name="frame" >
42-
<property name="frameShape" >
43-
<enum>QFrame::NoFrame</enum>
28+
<item row="0" column="0" >
29+
<widget class="QLabel" name="TextLabel1_2" >
30+
<property name="text" >
31+
<string>Name</string>
4432
</property>
45-
<property name="frameShadow" >
46-
<enum>QFrame::Plain</enum>
33+
<property name="margin" >
34+
<number>5</number>
35+
</property>
36+
<property name="buddy" >
37+
<cstring>txtName</cstring>
4738
</property>
4839
</widget>
4940
</item>
@@ -63,19 +54,6 @@
6354
</property>
6455
</widget>
6556
</item>
66-
<item row="0" column="0" >
67-
<widget class="QLabel" name="TextLabel1_2" >
68-
<property name="text" >
69-
<string>Name</string>
70-
</property>
71-
<property name="margin" >
72-
<number>5</number>
73-
</property>
74-
<property name="buddy" >
75-
<cstring>txtName</cstring>
76-
</property>
77-
</widget>
78-
</item>
7957
<item row="1" column="0" >
8058
<widget class="QLabel" name="TextLabel1" >
8159
<property name="text" >
@@ -89,211 +67,63 @@
8967
</property>
9068
</widget>
9169
</item>
92-
<item row="2" column="0" >
93-
<widget class="QLabel" name="TextLabel1_3" >
94-
<property name="text" >
95-
<string>Proxy Host</string>
96-
</property>
97-
<property name="margin" >
98-
<number>5</number>
99-
</property>
100-
<property name="buddy" >
101-
<cstring>txtProxyHost</cstring>
102-
</property>
103-
</widget>
104-
</item>
105-
<item row="3" column="0" >
106-
<widget class="QLabel" name="TextLabel1_3_2" >
107-
<property name="text" >
108-
<string>Proxy Port</string>
109-
</property>
110-
<property name="margin" >
111-
<number>5</number>
112-
</property>
113-
<property name="buddy" >
114-
<cstring>txtProxyPort</cstring>
115-
</property>
116-
</widget>
117-
</item>
118-
<item row="4" column="0" >
119-
<widget class="QLabel" name="TextLabel1_3_3" >
120-
<property name="text" >
121-
<string>Proxy User</string>
122-
</property>
123-
<property name="margin" >
124-
<number>5</number>
125-
</property>
126-
<property name="buddy" >
127-
<cstring>txtProxyUser</cstring>
128-
</property>
129-
</widget>
130-
</item>
131-
<item row="5" column="0" >
132-
<widget class="QLabel" name="TextLabel1_3_4" >
133-
<property name="text" >
134-
<string>Proxy Password</string>
135-
</property>
136-
<property name="margin" >
137-
<number>5</number>
138-
</property>
139-
<property name="buddy" >
140-
<cstring>txtProxyPass</cstring>
141-
</property>
142-
</widget>
143-
</item>
144-
<item row="4" column="1" >
145-
<widget class="QLineEdit" name="txtProxyUser" >
146-
<property name="sizePolicy" >
147-
<sizepolicy>
148-
<hsizetype>7</hsizetype>
149-
<vsizetype>0</vsizetype>
150-
<horstretch>1</horstretch>
151-
<verstretch>0</verstretch>
152-
</sizepolicy>
153-
</property>
154-
<property name="toolTip" >
155-
<string>Your user name for the HTTP proxy (optional)</string>
156-
</property>
157-
</widget>
158-
</item>
159-
<item row="5" column="1" >
160-
<widget class="QLineEdit" name="txtProxyPass" >
161-
<property name="sizePolicy" >
162-
<sizepolicy>
163-
<hsizetype>7</hsizetype>
164-
<vsizetype>0</vsizetype>
165-
<horstretch>1</horstretch>
166-
<verstretch>0</verstretch>
167-
</sizepolicy>
168-
</property>
169-
<property name="toolTip" >
170-
<string>Password for your HTTP proxy (optional)</string>
171-
</property>
172-
<property name="echoMode" >
173-
<enum>QLineEdit::Password</enum>
174-
</property>
175-
</widget>
176-
</item>
17770
<item row="1" column="1" >
17871
<widget class="QLineEdit" name="txtUrl" >
17972
<property name="toolTip" >
18073
<string>HTTP address of the Web Map Server</string>
18174
</property>
18275
</widget>
18376
</item>
184-
<item row="2" column="1" >
185-
<widget class="QLineEdit" name="txtProxyHost" >
186-
<property name="toolTip" >
187-
<string>Name of your HTTP proxy (optional)</string>
188-
</property>
189-
</widget>
190-
</item>
191-
<item row="3" column="1" >
192-
<widget class="QLineEdit" name="txtProxyPort" >
193-
<property name="sizePolicy" >
194-
<sizepolicy>
195-
<hsizetype>7</hsizetype>
196-
<vsizetype>0</vsizetype>
197-
<horstretch>1</horstretch>
198-
<verstretch>0</verstretch>
199-
</sizepolicy>
200-
</property>
201-
<property name="toolTip" >
202-
<string>Port number of your HTTP proxy (optional)</string>
203-
</property>
204-
<property name="maxLength" >
205-
<number>5</number>
206-
</property>
207-
</widget>
208-
</item>
20977
</layout>
21078
</widget>
21179
</item>
212-
<item row="0" column="1" >
213-
<layout class="QVBoxLayout" >
214-
<property name="margin" >
215-
<number>0</number>
80+
<item row="1" column="0" >
81+
<widget class="QDialogButtonBox" name="buttonBox" >
82+
<property name="standardButtons" >
83+
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Help|QDialogButtonBox::NoButton|QDialogButtonBox::Ok</set>
21684
</property>
217-
<property name="spacing" >
218-
<number>6</number>
219-
</property>
220-
<item>
221-
<widget class="QPushButton" name="btnOk" >
222-
<property name="text" >
223-
<string>OK</string>
224-
</property>
225-
<property name="shortcut" >
226-
<string/>
227-
</property>
228-
<property name="autoDefault" >
229-
<bool>true</bool>
230-
</property>
231-
<property name="default" >
232-
<bool>true</bool>
233-
</property>
234-
</widget>
235-
</item>
236-
<item>
237-
<widget class="QPushButton" name="btnCancel" >
238-
<property name="text" >
239-
<string>Cancel</string>
240-
</property>
241-
<property name="shortcut" >
242-
<string/>
243-
</property>
244-
<property name="autoDefault" >
245-
<bool>true</bool>
246-
</property>
247-
</widget>
248-
</item>
249-
<item>
250-
<widget class="QPushButton" name="btnHelp" >
251-
<property name="enabled" >
252-
<bool>true</bool>
253-
</property>
254-
<property name="text" >
255-
<string>Help</string>
256-
</property>
257-
<property name="shortcut" >
258-
<string>F1</string>
259-
</property>
260-
<property name="autoDefault" >
261-
<bool>true</bool>
262-
</property>
263-
</widget>
264-
</item>
265-
<item>
266-
<spacer>
267-
<property name="orientation" >
268-
<enum>Qt::Vertical</enum>
269-
</property>
270-
<property name="sizeType" >
271-
<enum>QSizePolicy::Expanding</enum>
272-
</property>
273-
<property name="sizeHint" >
274-
<size>
275-
<width>0</width>
276-
<height>20</height>
277-
</size>
278-
</property>
279-
</spacer>
280-
</item>
281-
</layout>
85+
</widget>
28286
</item>
28387
</layout>
28488
</widget>
28589
<layoutdefault spacing="6" margin="11" />
28690
<tabstops>
28791
<tabstop>txtName</tabstop>
28892
<tabstop>txtUrl</tabstop>
289-
<tabstop>txtProxyHost</tabstop>
290-
<tabstop>txtProxyPort</tabstop>
291-
<tabstop>txtProxyUser</tabstop>
292-
<tabstop>txtProxyPass</tabstop>
293-
<tabstop>btnOk</tabstop>
294-
<tabstop>btnCancel</tabstop>
295-
<tabstop>btnHelp</tabstop>
29693
</tabstops>
29794
<resources/>
298-
<connections/>
95+
<connections>
96+
<connection>
97+
<sender>buttonBox</sender>
98+
<signal>accepted()</signal>
99+
<receiver>QgsNewHttpConnectionBase</receiver>
100+
<slot>accept()</slot>
101+
<hints>
102+
<hint type="sourcelabel" >
103+
<x>403</x>
104+
<y>133</y>
105+
</hint>
106+
<hint type="destinationlabel" >
107+
<x>430</x>
108+
<y>98</y>
109+
</hint>
110+
</hints>
111+
</connection>
112+
<connection>
113+
<sender>buttonBox</sender>
114+
<signal>rejected()</signal>
115+
<receiver>QgsNewHttpConnectionBase</receiver>
116+
<slot>reject()</slot>
117+
<hints>
118+
<hint type="sourcelabel" >
119+
<x>312</x>
120+
<y>139</y>
121+
</hint>
122+
<hint type="destinationlabel" >
123+
<x>426</x>
124+
<y>38</y>
125+
</hint>
126+
</hints>
127+
</connection>
128+
</connections>
299129
</ui>

0 commit comments

Comments
 (0)
Please sign in to comment.