Skip to content

Commit aab17ff

Browse files
committed
HTTP Proxy support
1 parent 32b0520 commit aab17ff

File tree

2 files changed

+32
-8
lines changed

2 files changed

+32
-8
lines changed

src/plugins/globe/globe_plugin.cpp

+29-7
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ void GlobePlugin::run()
112112
osgViewer::Viewer viewer;
113113
#endif
114114

115+
setupProxy();
116+
115117
// install the programmable manipulator.
116118
osgEarthUtil::EarthManipulator* manip = new osgEarthUtil::EarthManipulator();
117119
viewer.setCameraManipulator( manip );
@@ -187,16 +189,36 @@ void GlobePlugin::run()
187189
#endif
188190
}
189191

192+
void GlobePlugin::setupProxy()
193+
{
194+
QSettings settings;
195+
settings.beginGroup( "proxy" );
196+
if (settings.value("/proxyEnabled").toBool())
197+
{
198+
ProxySettings proxySettings(settings.value("/proxyHost").toString().toStdString(),
199+
settings.value("/proxyPort").toInt());
200+
if (!settings.value("/proxyUser").toString().isEmpty())
201+
{
202+
QString auth = settings.value("/proxyUser").toString() + ":" + settings.value("/proxyPassword").toString();
203+
setenv("OSGEARTH_CURL_PROXYAUTH", auth.toStdString().c_str(), 0);
204+
}
205+
//TODO: settings.value("/proxyType")
206+
//TODO: URL exlusions
207+
HTTPClient::setProxySettings(proxySettings);
208+
}
209+
settings.endGroup();
210+
}
211+
190212
void GlobePlugin::extentsChanged()
191213
{
192-
QgsDebugMsg(">>>>>>>>>> extentsChanged: " + mQGisIface->mapCanvas()->extent().toString());
214+
QgsDebugMsg("extentsChanged: " + mQGisIface->mapCanvas()->extent().toString());
193215
}
194216

195217
typedef std::list< osg::ref_ptr<VersionedTile> > TileList;
196218

197219
void GlobePlugin::layersChanged()
198220
{
199-
QgsDebugMsg(">>>>>>>>>> layersChanged");
221+
QgsDebugMsg("layersChanged");
200222
if (mTileSource) {
201223
/*
202224
//viewer.getDatabasePager()->clear();
@@ -211,16 +233,16 @@ void GlobePlugin::layersChanged()
211233
}
212234
if (mTileSource && mMapNode->getMap()->getImageMapLayers().size() > 1)
213235
{
214-
QgsDebugMsg(">>>>>>>>>> removeMapLayer");
215-
QgsDebugMsg(QString(">>>>>>>>>> getImageMapLayers().size = %1").arg(mMapNode->getMap()->getImageMapLayers().size() ));
236+
QgsDebugMsg("removeMapLayer");
237+
QgsDebugMsg(QString("getImageMapLayers().size = %1").arg(mMapNode->getMap()->getImageMapLayers().size() ));
216238
mMapNode->getMap()->removeMapLayer( mQgisMapLayer );
217-
QgsDebugMsg(QString(">>>>>>>>>> getImageMapLayers().size = %1").arg(mMapNode->getMap()->getImageMapLayers().size() ));
218-
QgsDebugMsg(">>>>>>>>>> addMapLayer");
239+
QgsDebugMsg(QString("getImageMapLayers().size = %1").arg(mMapNode->getMap()->getImageMapLayers().size() ));
240+
QgsDebugMsg("addMapLayer");
219241
mTileSource = new QgsOsgEarthTileSource(mQGisIface);
220242
mTileSource->initialize("", 0);
221243
mQgisMapLayer = new ImageMapLayer( "QGIS", mTileSource );
222244
mMapNode->getMap()->addMapLayer( mQgisMapLayer );
223-
QgsDebugMsg(QString(">>>>>>>>>> getImageMapLayers().size = %1").arg(mMapNode->getMap()->getImageMapLayers().size() ));
245+
QgsDebugMsg(QString("getImageMapLayers().size = %1").arg(mMapNode->getMap()->getImageMapLayers().size() ));
224246
}
225247
}
226248

src/plugins/globe/globe_plugin.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ class GlobePlugin : public QObject, public QgisPlugin
5050
//! show the help document
5151
void help();
5252

53-
//! Called when the main canvas is about to be rendered.
53+
//! Set HTTP proxy settings
54+
void setupProxy();
55+
//! Called when the main canvas is about to be rendered
5456
void renderStarting();
5557
//! Called when the main canvas has rendered.
5658
void renderComplete( QPainter * );

0 commit comments

Comments
 (0)