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

svn_qgis at osgeo.org svn_qgis at osgeo.org
Sun Jun 15 18:35:03 EDT 2008


Author: timlinux
Date: 2008-06-15 18:35:03 -0400 (Sun, 15 Jun 2008)
New Revision: 8649

Modified:
   trunk/qgis/python/core/qgsrasterdataprovider.sip
   trunk/qgis/python/core/qgsrasterlayer.sip
   trunk/qgis/src/app/qgisapp.cpp
   trunk/qgis/src/app/qgisapp.h
   trunk/qgis/src/app/qgsnewhttpconnection.cpp
   trunk/qgis/src/app/qgsnewhttpconnection.h
   trunk/qgis/src/app/qgsserversourceselect.cpp
   trunk/qgis/src/core/qgsrasterdataprovider.h
   trunk/qgis/src/core/raster/qgsrasterlayer.cpp
   trunk/qgis/src/core/raster/qgsrasterlayer.h
   trunk/qgis/src/providers/wms/qgswmsprovider.cpp
   trunk/qgis/src/providers/wms/qgswmsprovider.h
   trunk/qgis/src/ui/qgsnewhttpconnectionbase.ui
Log:
Implemented proxy support to be application global rather than set on a per connection basis


Modified: trunk/qgis/python/core/qgsrasterdataprovider.sip
===================================================================
--- trunk/qgis/python/core/qgsrasterdataprovider.sip	2008-06-15 18:37:57 UTC (rev 8648)
+++ trunk/qgis/python/core/qgsrasterdataprovider.sip	2008-06-15 22:35:03 UTC (rev 8649)
@@ -29,41 +29,7 @@
 
     virtual ~QgsRasterDataProvider();
 
-
     /**
-     * Gets the HTTP proxy host used for this connection
-     */
-    virtual QString proxyHost() const = 0;
-
-    /**
-     * Gets the HTTP proxy port used for this connection
-     */
-    virtual int proxyPort() const = 0;
-
-    /**
-     * Gets the HTTP proxy user name used for this connection
-     */
-    virtual QString proxyUser() const = 0;
-
-    /**
-     * Gets the HTTP proxy user password used for this connection
-     */
-    virtual QString proxyPass() const = 0;
-
-    /**
-     *
-     * Sets a proxy for the URL given in the constructor
-     *
-     *
-     * \retval TRUE if proxy setting is successful (if indeed it is supported)
-     */
-    virtual bool setProxy(const QString & host,
-                                      int port,
-                          const QString & user,
-                          const QString & pass);
-    
-
-    /**
      * Add the list of WMS layer names to be rendered by this server
      */
     virtual void addLayers(const QStringList & layers,

Modified: trunk/qgis/python/core/qgsrasterlayer.sip
===================================================================
--- trunk/qgis/python/core/qgsrasterlayer.sip	2008-06-15 18:37:57 UTC (rev 8648)
+++ trunk/qgis/python/core/qgsrasterlayer.sip	2008-06-15 22:35:03 UTC (rev 8649)
@@ -535,35 +535,17 @@
                  const QStringList & layers = QStringList(),
                  const QStringList & styles = QStringList(),
                  const QString & format = QString(),
-                 const QString & crs = QString(),
-                 const QString & proxyHost = QString(),
-                 int proxyPort = 80,
-                 const QString & proxyUser = QString(),
-                 const QString & proxyPass = QString());
+                 const QString & crs = QString());
 
   void setDataProvider( const QString & provider,
                         const QStringList & layers,
                         const QStringList & styles,
                         const QString & format,
-                        const QString & crs,
-                        const QString & proxyHost,
-                        int proxyPort,
-                        const QString & proxyUser,
-                        const QString & proxyPass );
+                        const QString & crs);
 
   //! Does this layer use a provider for setting/retrieving data?
   bool usesProvider();
 
-  /**
-   * Sets a proxy for the path given in the constructor
-   *
-   * \retval TRUE if proxy setting is successful (if indeed it is supported)
-   */
-  bool setProxy(const QString & host = 0,
-                            int port = 80,
-                const QString & user = 0,
-                const QString & pass = 0);
-
   //! Which provider is being used for this Raster Layer?
   QString providerKey();
 

Modified: trunk/qgis/src/app/qgisapp.cpp
===================================================================
--- trunk/qgis/src/app/qgisapp.cpp	2008-06-15 18:37:57 UTC (rev 8648)
+++ trunk/qgis/src/app/qgisapp.cpp	2008-06-15 22:35:03 UTC (rev 8649)
@@ -45,6 +45,7 @@
 #include <QMenuBar>
 #include <QMenuItem>
 #include <QMessageBox>
+#include <QNetworkProxy>
 #include <QPainter>
 #include <QPictureIO>
 #include <QPixmap>
@@ -331,6 +332,7 @@
   createLegend();
   createOverview();
   createMapTips();
+  setupProxy();
 
   mComposer = new QgsComposer(this); // Map composer
   mInternalClipboard = new QgsClipboard; // create clipboard
@@ -2216,12 +2218,7 @@
         wmss->selectedLayers(),
         wmss->selectedStylesForSelectedLayers(),
         wmss->selectedImageEncoding(),
-        wmss->selectedCrs(),
-        wmss->connProxyHost(),
-        wmss->connProxyPort(),
-        wmss->connProxyUser(),
-        wmss->connProxyPass()
-        );
+        wmss->selectedCrs());
   }
 }
 
@@ -4355,6 +4352,7 @@
 //    bool splitterRedraw = mySettings.value("/qgis/splitterRedraw", true).toBool();
 //    canvasLegendSplit->setOpaqueResize(splitterRedraw);
 //    legendOverviewSplit->setOpaqueResize(splitterRedraw);
+    setupProxy();
   }
 }
 
@@ -5221,11 +5219,7 @@
     QStringList const & layers,
     QStringList const & styles,
     QString const & format,
-    QString const & crs,
-    QString const & proxyHost, 
-    int proxyPort, 
-    QString const & proxyUser,
-    QString const & proxyPassword)
+    QString const & crs)
 {
   QgsDebugMsg("about to get library for " + providerKey);
 
@@ -5254,8 +5248,7 @@
              + " and CRS of " + crs );
 
   // TODO: Remove the 0 when the raster layer becomes a full provider gateway.
-  layer = new QgsRasterLayer(0, rasterLayerPath, baseName, providerKey, layers, styles, format, crs,
-			     proxyHost, proxyPort, proxyUser, proxyPassword);
+  layer = new QgsRasterLayer(0, rasterLayerPath, baseName, providerKey, layers, styles, format, crs);
 
   QgsDebugMsg("Constructed new layer.");
 
@@ -5521,3 +5514,23 @@
   }  
   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);
+}

Modified: trunk/qgis/src/app/qgisapp.h
===================================================================
--- trunk/qgis/src/app/qgisapp.h	2008-06-15 18:37:57 UTC (rev 8648)
+++ trunk/qgis/src/app/qgisapp.h	2008-06-15 22:35:03 UTC (rev 8649)
@@ -102,11 +102,7 @@
       QStringList const & layers,
       QStringList const & styles,
       QString const & format,
-      QString const & crs,
-      QString const & proxyHost = QString(),
-      int proxyPort = 80,
-      QString const & proxyUser = QString(), 
-      QString const & proxyPassword = QString());
+      QString const & crs);
 
   /** open a raster layer for the given file
     @returns false if unable to open a raster layer for rasterFile
@@ -150,6 +146,22 @@
 
   void dropEvent(QDropEvent *);
 
+  /** Setup the proxy settings from the QSettings environment.
+    * This is not called by default in the constructor. Rather, 
+    * the application must explicitly call setupProx(). If 
+    * you write your own application and wish to explicitly 
+    * set up your own proxy rather, you should e.g.
+    *  QNetworkProxy proxy;
+    *  proxy.setType(QNetworkProxy::Socks5Proxy);
+    *  proxy.setHostName("proxy.example.com");
+    *  proxy.setPort(1080);
+    *  proxy.setUser("username");
+    *  proxy.setPassword("password");
+    *  QNetworkProxy::setApplicationProxy(proxy);
+    *  
+    *  (as documented in Qt documentation.
+  */
+  void setupProxy();
 //private slots:
 public slots:
   //! About QGis

Modified: trunk/qgis/src/app/qgsnewhttpconnection.cpp
===================================================================
--- trunk/qgis/src/app/qgsnewhttpconnection.cpp	2008-06-15 18:37:57 UTC (rev 8648)
+++ trunk/qgis/src/app/qgsnewhttpconnection.cpp	2008-06-15 22:35:03 UTC (rev 8649)
@@ -19,61 +19,48 @@
 #include "qgscontexthelp.h"
 #include <QSettings>
 
-QgsNewHttpConnection::QgsNewHttpConnection(QWidget *parent, const QString& baseKey, const QString& connName, Qt::WFlags fl): QDialog(parent, fl), mBaseKey(baseKey), mOriginalConnName(connName)
+QgsNewHttpConnection::QgsNewHttpConnection(
+    QWidget *parent, const QString& baseKey, const QString& connName, Qt::WFlags fl): 
+    QDialog(parent, fl), 
+    mBaseKey(baseKey), 
+    mOriginalConnName(connName)
 {
   setupUi(this);
-  connect(btnCancel, SIGNAL(clicked()), this, SLOT(reject()));
-  connect(btnOk, SIGNAL(clicked()), this, SLOT(saveConnection()));
 
   if (!connName.isEmpty())
-    {
-      // populate the dialog with the information stored for the connection
-      // populate the fields with the stored setting parameters
-      
-      QSettings settings;
+  {
+    // populate the dialog with the information stored for the connection
+    // populate the fields with the stored setting parameters
 
-      QString key = mBaseKey + connName;
-      txtName->setText     (connName);
-      txtUrl->setText      (settings.value(key + "/url").toString());
-      txtProxyHost->setText(settings.value(key + "/proxyhost").toString());
-      txtProxyPort->setText(settings.value(key + "/proxyport").toString());
-      txtProxyUser->setText(settings.value(key + "/proxyuser").toString());
-      txtProxyPass->setText(settings.value(key + "/proxypassword").toString());
-    }
+    QSettings settings;
+
+    QString key = mBaseKey + connName;
+    txtName->setText     (connName);
+    txtUrl->setText      (settings.value(key + "/url").toString());
+  }
+  connect(buttonBox, SIGNAL(helpRequested()), this, SLOT(helpRequested()));
 }
 
 QgsNewHttpConnection::~QgsNewHttpConnection()
 {
 }
 
-void QgsNewHttpConnection::testConnection()
+void QgsNewHttpConnection::accept()
 {
-  // following line uses Qt SQL plugin - currently not used
-  // QSqlDatabase *testCon = QSqlDatabase::addDatabase("QPSQL7","testconnection");
-
-
-}
-
-void QgsNewHttpConnection::saveConnection()
-{
   QSettings settings; 
   QString key = mBaseKey + txtName->text();
-  
+
   //delete original entry first
   if(!mOriginalConnName.isNull() && mOriginalConnName != key)
-    {
-      settings.remove(mBaseKey + mOriginalConnName);
-    }
+  {
+    settings.remove(mBaseKey + mOriginalConnName);
+  }
   settings.setValue(key + "/url", txtUrl->text().trimmed());
-  settings.setValue(key + "/proxyhost", txtProxyHost->text().trimmed());
-  settings.setValue(key + "/proxyport", txtProxyPort->text().trimmed());
-  settings.setValue(key + "/proxyuser", txtProxyUser->text().trimmed());
-  settings.setValue(key + "/proxypassword", txtProxyPass->text().trimmed());
-  
-  accept();
+
+  QDialog::accept();
 }
 
-void QgsNewHttpConnection::on_btnHelp_clicked()
+void QgsNewHttpConnection::helpRequested()
 {
   QgsContextHelp::run(context_id);
 }

Modified: trunk/qgis/src/app/qgsnewhttpconnection.h
===================================================================
--- trunk/qgis/src/app/qgsnewhttpconnection.h	2008-06-15 18:37:57 UTC (rev 8648)
+++ trunk/qgis/src/app/qgsnewhttpconnection.h	2008-06-15 22:35:03 UTC (rev 8649)
@@ -31,13 +31,11 @@
     QgsNewHttpConnection(QWidget *parent = 0, const QString& baseKey = "/Qgis/connections-wms/", const QString& connName = QString::null, Qt::WFlags fl = QgisGui::ModalDialogFlags);
     //! Destructor
     ~QgsNewHttpConnection();
-    //! Tests the connection using the parameters supplied
-    void testConnection();
  public slots:
     //! Saves the connection to ~/.qt/qgisrc
-    void saveConnection();
+    void accept();
     //! Show context help
-    void on_btnHelp_clicked();
+    void helpRequested();
  private:
     QString mBaseKey;
     QString mOriginalConnName; //store initial name to delete entry in case of rename

Modified: trunk/qgis/src/app/qgsserversourceselect.cpp
===================================================================
--- trunk/qgis/src/app/qgsserversourceselect.cpp	2008-06-15 18:37:57 UTC (rev 8648)
+++ trunk/qgis/src/app/qgsserversourceselect.cpp	2008-06-15 22:35:03 UTC (rev 8649)
@@ -363,47 +363,7 @@
   
   connStringParts += settings.value(key + "/url").toString();
 
-/*
-  // Add the proxy host and port if any are defined.
-  if ( ! ( (part = settings.value(key + "/proxyhost").toString()).isEmpty() ) )
-  {
-#ifdef QGISDEBUG
-  std::cout << "QgsServerSourceSelect::serverConnect: Got a proxyhost - '" << part.toLocal8Bit().data() << "'." << std::endl;
-#endif
-    connStringParts += part;
-  
-    if ( ! ( (part = settings.value(key + "/proxyport").toString()).isEmpty() ) )
-    {
-#ifdef QGISDEBUG
-  std::cout << "QgsServerSourceSelect::serverConnect: Got a proxyport - '" << part.toLocal8Bit().data() << "'." << std::endl;
-#endif
-      connStringParts += part;
-    }
-    else
-    {
-      connStringParts += "80";   // well-known http port
-    }
-
-    if ( ! ( (part = settings.value(key + "/proxyuser").toString()).isEmpty() ) )
-    {
-#ifdef QGISDEBUG
-  std::cout << "QgsServerSourceSelect::serverConnect: Got a proxyuser - '" << part.toLocal8Bit().data() << "'." << std::endl;
-#endif
-      connStringParts += part;
-
-      if ( ! ( (part = settings.value(key + "/proxypass").toString()).isEmpty() ) )
-      {
-#ifdef QGISDEBUG
-  std::cout << "QgsServerSourceSelect::serverConnect: Got a proxypass - '" << part.toLocal8Bit().data() << "'." << std::endl;
-#endif
-        connStringParts += part;
-      }
-    }
-  }
-*/
-
   m_connName = cmbConnections->currentText();
-  // setup 'url ( + " " + proxyhost + " " + proxyport + " " + proxyuser + " " + proxypass)'
   m_connInfo = connStringParts.join(" ");
 
 #ifdef QGISDEBUG
@@ -423,20 +383,6 @@
   {
     connect(mWmsProvider, SIGNAL(setStatus(QString)), this, SLOT(showStatusMessage(QString)));
 
-    // Collect and set HTTP proxy on WMS provider
-
-    m_connProxyHost = settings.value(key + "/proxyhost").toString(),
-    m_connProxyPort = settings.value(key + "/proxyport").toInt(),
-    m_connProxyUser = settings.value(key + "/proxyuser").toString(),
-    m_connProxyPass = settings.value(key + "/proxypassword").toString(),
-
-    mWmsProvider->setProxy(
-      m_connProxyHost,
-      m_connProxyPort,
-      m_connProxyUser,
-      m_connProxyPass
-    );
-
     // WMS Provider all set up; let's get some layers
 
     if (!populateLayerList(mWmsProvider))
@@ -632,26 +578,6 @@
   return m_connInfo;
 }
 
-QString QgsServerSourceSelect::connProxyHost()
-{
-  return m_connProxyHost;
-}
-
-int QgsServerSourceSelect::connProxyPort()
-{
-  return m_connProxyPort;
-}
-
-QString QgsServerSourceSelect::connProxyUser()
-{
-  return m_connProxyUser;
-}
-
-QString QgsServerSourceSelect::connProxyPass()
-{
-  return m_connProxyPass;
-}
-
 QStringList QgsServerSourceSelect::selectedLayers()
 {
   return m_selectedLayers;
@@ -796,17 +722,16 @@
     if (!keys.contains(i.key()))
     {
       QString path = i.key();
-      settings.setValue(path + "/proxyhost", "");
-      settings.setValue(path + "/proxyport", 80);
-      settings.setValue(path + "/proxyuser", "");
-      settings.setValue(path + "/proxypassword", "");
       settings.setValue(path + "/url", i.value());
     }
   }
   settings.endGroup();
   populateConnectionList();
 
-  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>"));
+  QMessageBox::information(this, tr("WMS proxies"), "<p>" + tr("Several WMS servers have "
+        "been added to the server list. Note that if "
+        "you access the internet via a web proxy, you will "
+        "need to set the proxy settings in the QGIS options dialog.") + "</p>");
 }
 
 // ENDS

Modified: trunk/qgis/src/core/qgsrasterdataprovider.h
===================================================================
--- trunk/qgis/src/core/qgsrasterdataprovider.h	2008-06-15 18:37:57 UTC (rev 8648)
+++ trunk/qgis/src/core/qgsrasterdataprovider.h	2008-06-15 22:35:03 UTC (rev 8649)
@@ -58,48 +58,6 @@
 
 
     /**
-     * Gets the HTTP proxy host used for this connection
-     */
-    virtual QString proxyHost() const = 0;
-
-    /**
-     * Gets the HTTP proxy port used for this connection
-     */
-    virtual int proxyPort() const = 0;
-
-    /**
-     * Gets the HTTP proxy user name used for this connection
-     */
-    virtual QString proxyUser() const = 0;
-
-    /**
-     * Gets the HTTP proxy user password used for this connection
-     */
-    virtual QString proxyPass() const = 0;
-
-
-    /**
-     *
-     * Sets a proxy for the URL given in the constructor
-     *
-     *
-     * \retval TRUE if proxy setting is successful (if indeed it is supported)
-     */
-    virtual bool setProxy(QString const & host,
-                                      int port,
-                          QString const & user,
-                          QString const & pass)
-    {
-      //this is mainly to prevent compiler warnings
-      if (host.isEmpty() || port < 1 || user.isEmpty() || pass.isEmpty())
-      {
-        return FALSE;
-      }
-
-      return FALSE;
-    }
-
-    /**
      * Add the list of WMS layer names to be rendered by this server
      */
     virtual void addLayers(QStringList const & layers,

Modified: trunk/qgis/src/core/raster/qgsrasterlayer.cpp
===================================================================
--- trunk/qgis/src/core/raster/qgsrasterlayer.cpp	2008-06-15 18:37:57 UTC (rev 8648)
+++ trunk/qgis/src/core/raster/qgsrasterlayer.cpp	2008-06-15 22:35:03 UTC (rev 8649)
@@ -4164,14 +4164,7 @@
     // Collect CRS
     QString crs = QString("EPSG:%1").arg(srs().epsg());
 
-    // Collect proxy information
-    QString proxyHost = rpNode.namedItem("wmsProxyHost").toElement().text();
-    int     proxyPort = rpNode.namedItem("wmsProxyPort").toElement().text().toInt();
-    QString proxyUser = rpNode.namedItem("wmsProxyUser").toElement().text();
-    QString proxyPass = rpNode.namedItem("wmsProxyPass").toElement().text();
-
-    setDataProvider( mProviderKey, layers, styles, format, crs,
-        proxyHost, proxyPort, proxyUser, proxyPass );
+    setDataProvider( mProviderKey, layers, styles, format, crs );
   }
   else
   {
@@ -4447,33 +4440,6 @@
     formatElement.appendChild(formatText);
     rasterPropertiesElement.appendChild(formatElement);
 
-    // <rasterproperties><wmsProxyHost>
-    QDomElement proxyHostElement = document.createElement("wmsProxyHost");
-    QDomText proxyHostText =
-      document.createTextNode(mDataProvider->proxyHost());
-    proxyHostElement.appendChild(proxyHostText);
-    rasterPropertiesElement.appendChild(proxyHostElement);
-
-    // <rasterproperties><wmsProxyPort>
-    QDomElement proxyPortElement = document.createElement("wmsProxyPort");
-    QDomText proxyPortText =
-      document.createTextNode( QString::number(mDataProvider->proxyPort()) );
-    proxyPortElement.appendChild(proxyPortText);
-    rasterPropertiesElement.appendChild(proxyPortElement);
-
-    // <rasterproperties><wmsProxyUser>
-    QDomElement proxyUserElement = document.createElement("wmsProxyUser");
-    QDomText proxyUserText =
-      document.createTextNode(mDataProvider->proxyUser());
-    proxyUserElement.appendChild(proxyUserText);
-    rasterPropertiesElement.appendChild(proxyUserElement);
-
-    // <rasterproperties><wmsProxyPass>
-    QDomElement proxyPassElement = document.createElement("wmsProxyPass");
-    QDomText proxyPassText =
-      document.createTextNode(mDataProvider->proxyPass());
-    proxyPassElement.appendChild(proxyPassText);
-    rasterPropertiesElement.appendChild(proxyPassElement);
   }
 
   // <mDebugOverlayFlag>
@@ -4907,11 +4873,7 @@
     QStringList const & layers,
     QStringList const & styles,
     QString const & format,
-    QString const & crs,
-    QString const & proxyHost,
-    int proxyPort,
-    QString const & proxyUser,
-    QString const & proxyPass )
+    QString const & crs)
 : QgsMapLayer(RASTER, baseName, rasterLayerPath),
   mRasterXDim( std::numeric_limits<int>::max() ),
   mRasterYDim( std::numeric_limits<int>::max() ),
@@ -4941,8 +4903,7 @@
   // if we're given a provider type, try to create and bind one to this layer
   if ( ! providerKey.isEmpty() )
   {
-    setDataProvider( providerKey, layers, styles, format, crs,
-        proxyHost, proxyPort, proxyUser, proxyPass );
+    setDataProvider( providerKey, layers, styles, format, crs );
   }
 
   // Default for the popup menu
@@ -4981,11 +4942,7 @@
     QStringList const & layers,
     QStringList const & styles,
     QString const & format,
-    QString const & crs,
-    QString const & proxyHost,
-    int proxyPort,
-    QString const & proxyUser,
-    QString const & proxyPass )
+    QString const & crs)
 {
   // XXX should I check for and possibly delete any pre-existing providers?
   // XXX How often will that scenario occur?
@@ -5052,7 +5009,6 @@
           mDataProvider->addLayers(layers, styles);
           mDataProvider->setImageEncoding(format);
           mDataProvider->setImageCrs(crs);
-          mDataProvider->setProxy(proxyHost, proxyPort, proxyUser, proxyPass);
 
           // get the extent
           QgsRect mbr = mDataProvider->extent();
@@ -5095,29 +5051,6 @@
 } // QgsRasterLayer::setDataProvider
 
 
-bool QgsRasterLayer::setProxy(QString const & host,
-    int port,
-    QString const & user,
-    QString const & pass)
-{
-  if (!mDataProvider)
-  {
-    return FALSE;
-  }
-  else
-  {
-#ifdef QGISDEBUG
-    std::cout << "  QgsRasterLayer::setProxy: host = " << host.toLocal8Bit().data() << "." << std::endl;
-    std::cout << "  QgsRasterLayer::setProxy: port = " << port << "." << std::endl;
-    std::cout << "  QgsRasterLayer::setProxy: user = " << user.toLocal8Bit().data() << "." << std::endl;
-    std::cout << "  QgsRasterLayer::setProxy: pass = " << pass.toLocal8Bit().data() << "." << std::endl;
-#endif
-    return mDataProvider->setProxy(host, port, user, pass);
-  }
-}
-
-
-
 bool QgsRasterLayer::usesProvider()
 {
   if (mProviderKey.isEmpty())

Modified: trunk/qgis/src/core/raster/qgsrasterlayer.h
===================================================================
--- trunk/qgis/src/core/raster/qgsrasterlayer.h	2008-06-15 18:37:57 UTC (rev 8648)
+++ trunk/qgis/src/core/raster/qgsrasterlayer.h	2008-06-15 22:35:03 UTC (rev 8649)
@@ -1090,35 +1090,18 @@
                  const QStringList & layers = QStringList(),
                  const QStringList & styles = QStringList(),
                  const QString & format = QString(),
-                 const QString & crs = QString(),
-                 const QString & proxyHost = QString(),
-                 int proxyPort = 80,
-                 const QString & proxyUser = QString(),
-                 const QString & proxyPass = QString());
+                 const QString & crs = QString()
+                 );
 
   void setDataProvider( const QString & provider,
                         const QStringList & layers,
                         const QStringList & styles,
                         const QString & format,
-                        const QString & crs,
-                        const QString & proxyHost,
-                        int proxyPort,
-                        const QString & proxyUser,
-                        const QString & proxyPass );
+                        const QString & crs);
 
   //! Does this layer use a provider for setting/retrieving data?
   bool usesProvider();
 
-  /**
-   * Sets a proxy for the path given in the constructor
-   *
-   * \retval TRUE if proxy setting is successful (if indeed it is supported)
-   */
-  bool setProxy(const QString & host = 0,
-                            int port = 80,
-                const QString & user = 0,
-                const QString & pass = 0);
-
   //! Which provider is being used for this Raster Layer?
   QString providerKey();
 

Modified: trunk/qgis/src/providers/wms/qgswmsprovider.cpp
===================================================================
--- trunk/qgis/src/providers/wms/qgswmsprovider.cpp	2008-06-15 18:37:57 UTC (rev 8648)
+++ trunk/qgis/src/providers/wms/qgswmsprovider.cpp	2008-06-15 22:35:03 UTC (rev 8649)
@@ -51,10 +51,6 @@
 QgsWmsProvider::QgsWmsProvider(QString const & uri)
   : QgsRasterDataProvider(uri),
     httpuri(uri),
-    mHttpProxyHost(0),
-    mHttpProxyPort(80),
-    mHttpProxyUser(0),
-    mHttpProxyPass(0),
     httpcapabilitiesresponse(0),
     imageCrs(DEFAULT_LATLON_CRS),
     cachedImage(0),
@@ -134,43 +130,7 @@
 }
 
 
-QString QgsWmsProvider::proxyHost() const
-{
-  return mHttpProxyHost;
-}
 
-
-int QgsWmsProvider::proxyPort() const
-{
-  return mHttpProxyPort;
-}
-
-
-QString QgsWmsProvider::proxyUser() const
-{
-  return mHttpProxyUser;
-}
-
-
-QString QgsWmsProvider::proxyPass() const
-{
-  return mHttpProxyPass;
-}
-
-
-bool QgsWmsProvider::setProxy(QString const & host,
-                                          int port,
-                              QString const & user,
-                              QString const & pass)
-{
-  mHttpProxyHost = host;
-  mHttpProxyPort = port;
-  mHttpProxyUser = user;
-  mHttpProxyPass = pass;
-
-  return TRUE;
-}
-
 bool QgsWmsProvider::supportedLayers(std::vector<QgsWmsLayerProperty> & layers)
 {
   QgsDebugMsg("Entering.");
@@ -655,11 +615,7 @@
 {
   QgsDebugMsg("WMS request Url: " + url);
   QgsHttpTransaction http(
-    url,
-    mHttpProxyHost,
-    mHttpProxyPort,
-    mHttpProxyUser,
-    mHttpProxyPass);
+    url);
 
   // Do a passthrough for the status bar text
   connect(

Modified: trunk/qgis/src/providers/wms/qgswmsprovider.h
===================================================================
--- trunk/qgis/src/providers/wms/qgswmsprovider.h	2008-06-15 18:37:57 UTC (rev 8648)
+++ trunk/qgis/src/providers/wms/qgswmsprovider.h	2008-06-15 22:35:03 UTC (rev 8649)
@@ -328,8 +328,6 @@
   interface defined in the QgsDataProvider class to provide access to spatial
   data residing in a OGC Web Map Service.
   
-  TODO: Make it work
-  
 */
 class QgsWmsProvider : public QgsRasterDataProvider
 {
@@ -342,8 +340,8 @@
   /**
   * Constructor for the provider. 
   *
-  * \param   uri   HTTP URL of the Web Server.  If setProxy() is not also called then we will
-  *                contact the host directly.
+  * \param   uri   HTTP URL of the Web Server.  If needed a proxy will be used
+  *                otherwise we contact the host directly.
   *
   */
   QgsWmsProvider(QString const & uri = 0);
@@ -352,36 +350,6 @@
   virtual ~QgsWmsProvider();
 
   /**
-   * Gets the HTTP proxy host used for this connection
-   */
-  virtual QString proxyHost() const;
-
-  /**
-   * Gets the HTTP proxy port used for this connection
-   */
-  virtual int proxyPort() const;
-
-  /**
-   * Gets the HTTP proxy user name used for this connection
-   */
-  virtual QString proxyUser() const;
-
-  /**
-   * Gets the HTTP proxy user password used for this connection
-   */
-  virtual QString proxyPass() const;
-
-  /**
-   *
-   * Sets an HTTP proxy for the URL given in the constructor
-   *
-   */
-  virtual bool setProxy(QString const & host = 0,
-                                    int port = 80,
-                        QString const & user = 0,
-                        QString const & pass = 0);
-
-  /**
    * \brief   Returns a list of the supported layers of the WMS server
    *
    * \param[out] layers   The list of layers will be placed here.
@@ -723,18 +691,6 @@
   //! URL part of URI (httpuri)
   QString baseUrl;
 
-  //! HTTP proxy host name for the WMS for this layer
-  QString mHttpProxyHost;
-
-  //! HTTP proxy port number for the WMS for this layer
-  int mHttpProxyPort;
-
-  //! HTTP proxy username for the WMS for this layer
-  QString mHttpProxyUser;
-
-  //! HTTP proxy password for the WMS for this layer
-  QString mHttpProxyPass;
-
   /**
    * Flag indicating if the layer data source is a valid WMS layer
    */

Modified: trunk/qgis/src/ui/qgsnewhttpconnectionbase.ui
===================================================================
--- trunk/qgis/src/ui/qgsnewhttpconnectionbase.ui	2008-06-15 18:37:57 UTC (rev 8648)
+++ trunk/qgis/src/ui/qgsnewhttpconnectionbase.ui	2008-06-15 22:35:03 UTC (rev 8649)
@@ -5,12 +5,12 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>437</width>
-    <height>256</height>
+    <width>431</width>
+    <height>159</height>
    </rect>
   </property>
   <property name="windowTitle" >
-   <string>Create a New WMS connection</string>
+   <string>Create a new WMS connection</string>
   </property>
   <property name="sizeGripEnabled" >
    <bool>true</bool>
@@ -19,32 +19,23 @@
    <bool>true</bool>
   </property>
   <layout class="QGridLayout" >
-   <property name="margin" >
-    <number>9</number>
-   </property>
-   <property name="spacing" >
-    <number>6</number>
-   </property>
    <item row="0" column="0" >
     <widget class="QGroupBox" name="GroupBox1" >
      <property name="title" >
-      <string>Connection Information</string>
+      <string>Connection details</string>
      </property>
      <layout class="QGridLayout" >
-      <property name="margin" >
-       <number>0</number>
-      </property>
-      <property name="spacing" >
-       <number>5</number>
-      </property>
-      <item rowspan="6" row="0" column="2" >
-       <widget class="QFrame" name="frame" >
-        <property name="frameShape" >
-         <enum>QFrame::NoFrame</enum>
+      <item row="0" column="0" >
+       <widget class="QLabel" name="TextLabel1_2" >
+        <property name="text" >
+         <string>Name</string>
         </property>
-        <property name="frameShadow" >
-         <enum>QFrame::Plain</enum>
+        <property name="margin" >
+         <number>5</number>
         </property>
+        <property name="buddy" >
+         <cstring>txtName</cstring>
+        </property>
        </widget>
       </item>
       <item row="0" column="1" >
@@ -63,19 +54,6 @@
         </property>
        </widget>
       </item>
-      <item row="0" column="0" >
-       <widget class="QLabel" name="TextLabel1_2" >
-        <property name="text" >
-         <string>Name</string>
-        </property>
-        <property name="margin" >
-         <number>5</number>
-        </property>
-        <property name="buddy" >
-         <cstring>txtName</cstring>
-        </property>
-       </widget>
-      </item>
       <item row="1" column="0" >
        <widget class="QLabel" name="TextLabel1" >
         <property name="text" >
@@ -89,91 +67,6 @@
         </property>
        </widget>
       </item>
-      <item row="2" column="0" >
-       <widget class="QLabel" name="TextLabel1_3" >
-        <property name="text" >
-         <string>Proxy Host</string>
-        </property>
-        <property name="margin" >
-         <number>5</number>
-        </property>
-        <property name="buddy" >
-         <cstring>txtProxyHost</cstring>
-        </property>
-       </widget>
-      </item>
-      <item row="3" column="0" >
-       <widget class="QLabel" name="TextLabel1_3_2" >
-        <property name="text" >
-         <string>Proxy Port</string>
-        </property>
-        <property name="margin" >
-         <number>5</number>
-        </property>
-        <property name="buddy" >
-         <cstring>txtProxyPort</cstring>
-        </property>
-       </widget>
-      </item>
-      <item row="4" column="0" >
-       <widget class="QLabel" name="TextLabel1_3_3" >
-        <property name="text" >
-         <string>Proxy User</string>
-        </property>
-        <property name="margin" >
-         <number>5</number>
-        </property>
-        <property name="buddy" >
-         <cstring>txtProxyUser</cstring>
-        </property>
-       </widget>
-      </item>
-      <item row="5" column="0" >
-       <widget class="QLabel" name="TextLabel1_3_4" >
-        <property name="text" >
-         <string>Proxy Password</string>
-        </property>
-        <property name="margin" >
-         <number>5</number>
-        </property>
-        <property name="buddy" >
-         <cstring>txtProxyPass</cstring>
-        </property>
-       </widget>
-      </item>
-      <item row="4" column="1" >
-       <widget class="QLineEdit" name="txtProxyUser" >
-        <property name="sizePolicy" >
-         <sizepolicy>
-          <hsizetype>7</hsizetype>
-          <vsizetype>0</vsizetype>
-          <horstretch>1</horstretch>
-          <verstretch>0</verstretch>
-         </sizepolicy>
-        </property>
-        <property name="toolTip" >
-         <string>Your user name for the HTTP proxy (optional)</string>
-        </property>
-       </widget>
-      </item>
-      <item row="5" column="1" >
-       <widget class="QLineEdit" name="txtProxyPass" >
-        <property name="sizePolicy" >
-         <sizepolicy>
-          <hsizetype>7</hsizetype>
-          <vsizetype>0</vsizetype>
-          <horstretch>1</horstretch>
-          <verstretch>0</verstretch>
-         </sizepolicy>
-        </property>
-        <property name="toolTip" >
-         <string>Password for your HTTP proxy (optional)</string>
-        </property>
-        <property name="echoMode" >
-         <enum>QLineEdit::Password</enum>
-        </property>
-       </widget>
-      </item>
       <item row="1" column="1" >
        <widget class="QLineEdit" name="txtUrl" >
         <property name="toolTip" >
@@ -181,104 +74,15 @@
         </property>
        </widget>
       </item>
-      <item row="2" column="1" >
-       <widget class="QLineEdit" name="txtProxyHost" >
-        <property name="toolTip" >
-         <string>Name of your HTTP proxy (optional)</string>
-        </property>
-       </widget>
-      </item>
-      <item row="3" column="1" >
-       <widget class="QLineEdit" name="txtProxyPort" >
-        <property name="sizePolicy" >
-         <sizepolicy>
-          <hsizetype>7</hsizetype>
-          <vsizetype>0</vsizetype>
-          <horstretch>1</horstretch>
-          <verstretch>0</verstretch>
-         </sizepolicy>
-        </property>
-        <property name="toolTip" >
-         <string>Port number of your HTTP proxy (optional)</string>
-        </property>
-        <property name="maxLength" >
-         <number>5</number>
-        </property>
-       </widget>
-      </item>
      </layout>
     </widget>
    </item>
-   <item row="0" column="1" >
-    <layout class="QVBoxLayout" >
-     <property name="margin" >
-      <number>0</number>
+   <item row="1" column="0" >
+    <widget class="QDialogButtonBox" name="buttonBox" >
+     <property name="standardButtons" >
+      <set>QDialogButtonBox::Cancel|QDialogButtonBox::Help|QDialogButtonBox::NoButton|QDialogButtonBox::Ok</set>
      </property>
-     <property name="spacing" >
-      <number>6</number>
-     </property>
-     <item>
-      <widget class="QPushButton" name="btnOk" >
-       <property name="text" >
-        <string>OK</string>
-       </property>
-       <property name="shortcut" >
-        <string/>
-       </property>
-       <property name="autoDefault" >
-        <bool>true</bool>
-       </property>
-       <property name="default" >
-        <bool>true</bool>
-       </property>
-      </widget>
-     </item>
-     <item>
-      <widget class="QPushButton" name="btnCancel" >
-       <property name="text" >
-        <string>Cancel</string>
-       </property>
-       <property name="shortcut" >
-        <string/>
-       </property>
-       <property name="autoDefault" >
-        <bool>true</bool>
-       </property>
-      </widget>
-     </item>
-     <item>
-      <widget class="QPushButton" name="btnHelp" >
-       <property name="enabled" >
-        <bool>true</bool>
-       </property>
-       <property name="text" >
-        <string>Help</string>
-       </property>
-       <property name="shortcut" >
-        <string>F1</string>
-       </property>
-       <property name="autoDefault" >
-        <bool>true</bool>
-       </property>
-      </widget>
-     </item>
-     <item>
-      <spacer>
-       <property name="orientation" >
-        <enum>Qt::Vertical</enum>
-       </property>
-       <property name="sizeType" >
-        <enum>QSizePolicy::Expanding</enum>
-       </property>
-       <property name="sizeHint" >
-        <size>
-         <width>0</width>
-         <height>20</height>
-        </size>
-       </property>
-      </spacer>
-     </item>
-    </layout>
+    </widget>
    </item>
   </layout>
  </widget>
@@ -286,14 +90,40 @@
  <tabstops>
   <tabstop>txtName</tabstop>
   <tabstop>txtUrl</tabstop>
-  <tabstop>txtProxyHost</tabstop>
-  <tabstop>txtProxyPort</tabstop>
-  <tabstop>txtProxyUser</tabstop>
-  <tabstop>txtProxyPass</tabstop>
-  <tabstop>btnOk</tabstop>
-  <tabstop>btnCancel</tabstop>
-  <tabstop>btnHelp</tabstop>
  </tabstops>
  <resources/>
- <connections/>
+ <connections>
+  <connection>
+   <sender>buttonBox</sender>
+   <signal>accepted()</signal>
+   <receiver>QgsNewHttpConnectionBase</receiver>
+   <slot>accept()</slot>
+   <hints>
+    <hint type="sourcelabel" >
+     <x>403</x>
+     <y>133</y>
+    </hint>
+    <hint type="destinationlabel" >
+     <x>430</x>
+     <y>98</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>buttonBox</sender>
+   <signal>rejected()</signal>
+   <receiver>QgsNewHttpConnectionBase</receiver>
+   <slot>reject()</slot>
+   <hints>
+    <hint type="sourcelabel" >
+     <x>312</x>
+     <y>139</y>
+    </hint>
+    <hint type="destinationlabel" >
+     <x>426</x>
+     <y>38</y>
+    </hint>
+   </hints>
+  </connection>
+ </connections>
 </ui>



More information about the QGIS-commit mailing list