[QGIS Commit] r9939 - in trunk/qgis/src: app core providers/wms ui

svn_qgis at osgeo.org svn_qgis at osgeo.org
Wed Jan 7 09:44:18 EST 2009


Author: mhugent
Date: 2009-01-07 09:44:18 -0500 (Wed, 07 Jan 2009)
New Revision: 9939

Modified:
   trunk/qgis/src/app/qgisapp.cpp
   trunk/qgis/src/app/qgsoptions.cpp
   trunk/qgis/src/core/qgshttptransaction.cpp
   trunk/qgis/src/core/qgshttptransaction.h
   trunk/qgis/src/providers/wms/qgswmsprovider.cpp
   trunk/qgis/src/ui/qgsoptionsbase.ui
Log:
Apply proxy patch that let select the proxy type in the option dialog

Modified: trunk/qgis/src/app/qgisapp.cpp
===================================================================
--- trunk/qgis/src/app/qgisapp.cpp	2009-01-07 13:38:46 UTC (rev 9938)
+++ trunk/qgis/src/app/qgisapp.cpp	2009-01-07 14:44:18 UTC (rev 9939)
@@ -345,7 +345,6 @@
   createLegend();
   createOverview();
   createMapTips();
-  setupProxy();
   readSettings();
   updateRecentProjectPaths();
 
@@ -4293,8 +4292,6 @@
     int action = mySettings.value( "/qgis/wheel_action", 0 ).toInt();
     double zoomFactor = mySettings.value( "/qgis/zoom_factor", 2 ).toDouble();
     mMapCanvas->setWheelAction(( QgsMapCanvas::WheelAction ) action, zoomFactor );
-
-    setupProxy();
   }
 }
 
@@ -5506,26 +5503,6 @@
   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 )
 {
   QString myPreferredPath = QgsApplication::activeThemePath() + QDir::separator() + theName;

Modified: trunk/qgis/src/app/qgsoptions.cpp
===================================================================
--- trunk/qgis/src/app/qgsoptions.cpp	2009-01-07 13:38:46 UTC (rev 9938)
+++ trunk/qgis/src/app/qgsoptions.cpp	2009-01-07 14:44:18 UTC (rev 9939)
@@ -62,6 +62,16 @@
   leProxyPort->setText( settings.value( "proxy/proxyPort", "" ).toString() );
   leProxyUser->setText( settings.value( "proxy/proxyUser", "" ).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
   cmbTheme->setItemText( cmbTheme->currentIndex(), settings.value( "/Themes" ).toString() );
 
@@ -261,6 +271,8 @@
   settings.setValue( "proxy/proxyPort", leProxyPort->text() );
   settings.setValue( "proxy/proxyUser", leProxyUser->text() );
   settings.setValue( "proxy/proxyPassword", leProxyPassword->text() );
+  settings.setValue( "proxy/proxyType", mProxyTypeComboBox->currentText());
+
   //general settings
   settings.setValue( "/Map/identifyRadius", spinBoxIdentifyValue->value() );
   settings.setValue( "/qgis/showLegendClassifiers", cbxLegendClassifiers->isChecked() );

Modified: trunk/qgis/src/core/qgshttptransaction.cpp
===================================================================
--- trunk/qgis/src/core/qgshttptransaction.cpp	2009-01-07 13:38:46 UTC (rev 9938)
+++ trunk/qgis/src/core/qgshttptransaction.cpp	2009-01-07 14:44:18 UTC (rev 9939)
@@ -37,13 +37,15 @@
                                         QString proxyHost,
                                         int     proxyPort,
                                         QString proxyUser,
-                                        QString proxyPass )
+                                        QString proxyPass,
+                                        QNetworkProxy::ProxyType proxyType)
     : httpresponsecontenttype( 0 ),
     httpurl( uri ),
     httphost( proxyHost ),
     httpport( proxyPort ),
     httpuser( proxyUser ),
     httppass( proxyPass ),
+    mProxyType(proxyType),
     mError( 0 )
 {
 
@@ -105,7 +107,7 @@
   else
   {
     // 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() );

Modified: trunk/qgis/src/core/qgshttptransaction.h
===================================================================
--- trunk/qgis/src/core/qgshttptransaction.h	2009-01-07 13:38:46 UTC (rev 9938)
+++ trunk/qgis/src/core/qgshttptransaction.h	2009-01-07 14:44:18 UTC (rev 9939)
@@ -23,6 +23,7 @@
 #define QGSHTTPTRANSACTION_H
 
 #include <QHttp>
+#include <QNetworkProxy>
 #include <QString>
 
 class QTimer;
@@ -46,7 +47,8 @@
                         QString proxyHost = QString(),
                         int     proxyPort = 80,
                         QString proxyUser = QString(),
-                        QString proxyPass = QString() );
+                        QString proxyPass = QString(),
+                        QNetworkProxy::ProxyType proxyType = QNetworkProxy::NoProxy);
 
     //! Destructor
     virtual ~QgsHttpTransaction();
@@ -187,6 +189,8 @@
      */
     int httpredirections;
 
+    QNetworkProxy::ProxyType mProxyType;
+
     /**
      * Indicates the associated QTimer object - used to detect network timeouts
      */

Modified: trunk/qgis/src/providers/wms/qgswmsprovider.cpp
===================================================================
--- trunk/qgis/src/providers/wms/qgswmsprovider.cpp	2009-01-07 13:38:46 UTC (rev 9938)
+++ trunk/qgis/src/providers/wms/qgswmsprovider.cpp	2009-01-07 14:44:18 UTC (rev 9939)
@@ -32,6 +32,7 @@
 #include <QUrl>
 #include <QImage>
 #include <QSet>
+#include <QSettings>
 
 #ifdef _MSC_VER
 #include <float.h>
@@ -636,8 +637,47 @@
 QByteArray QgsWmsProvider::retrieveUrl( QString 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
   connect(
     &http, SIGNAL( statusChanged( QString ) ),

Modified: trunk/qgis/src/ui/qgsoptionsbase.ui
===================================================================
--- trunk/qgis/src/ui/qgsoptionsbase.ui	2009-01-07 13:38:46 UTC (rev 9938)
+++ trunk/qgis/src/ui/qgsoptionsbase.ui	2009-01-07 14:44:18 UTC (rev 9939)
@@ -25,7 +25,7 @@
    <item row="0" column="0" >
     <widget class="QTabWidget" name="tabWidget" >
      <property name="currentIndex" >
-      <number>0</number>
+      <number>6</number>
      </property>
      <widget class="QWidget" name="tabGeneral" >
       <attribute name="title" >
@@ -1000,7 +1000,7 @@
             </property>
            </widget>
           </item>
-          <item row="0" column="1" >
+          <item row="0" column="1" colspan="2" >
            <widget class="QLineEdit" name="leProxyHost" />
           </item>
           <item row="1" column="0" >
@@ -1013,7 +1013,7 @@
             </property>
            </widget>
           </item>
-          <item row="1" column="1" >
+          <item row="1" column="1" colspan="2" >
            <widget class="QLineEdit" name="leProxyPort" />
           </item>
           <item row="2" column="0" >
@@ -1026,7 +1026,7 @@
             </property>
            </widget>
           </item>
-          <item row="2" column="1" >
+          <item row="2" column="1" colspan="2" >
            <widget class="QLineEdit" name="leProxyUser" >
             <property name="toolTip" >
              <string>Leave this blank if no proxy username / password are required</string>
@@ -1043,7 +1043,7 @@
             </property>
            </widget>
           </item>
-          <item row="3" column="1" >
+          <item row="3" column="1" colspan="2" >
            <widget class="QLineEdit" name="leProxyPassword" >
             <property name="toolTip" >
              <string>Leave this blank if no proxy username / password are required</string>
@@ -1053,6 +1053,29 @@
             </property>
            </widget>
           </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>
         </widget>
        </item>
@@ -1063,8 +1086,8 @@
          </property>
          <property name="sizeHint" >
           <size>
-           <width>20</width>
-           <height>40</height>
+           <width>577</width>
+           <height>251</height>
           </size>
          </property>
         </spacer>



More information about the QGIS-commit mailing list