Extended the proxy handling to HTTPS and FTP.

Thu, 27 May 2010 20:27:46 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Thu, 27 May 2010 20:27:46 +0200
changeset 289
baf4c1354c6a
parent 288
a4e81ad85e82
child 290
1e0ab7fcff96
child 293
9ecc02b50325

Extended the proxy handling to HTTPS and FTP.

APIs/Python3/eric5.api file | annotate | diff | comparison | revisions
Documentation/Help/source.qch file | annotate | diff | comparison | revisions
Documentation/Help/source.qhp file | annotate | diff | comparison | revisions
Documentation/Source/eric5.E5Network.E5NetworkProxyFactory.html file | annotate | diff | comparison | revisions
Documentation/Source/eric5.Helpviewer.Network.FtpReply.html file | annotate | diff | comparison | revisions
Documentation/Source/eric5.Helpviewer.Network.NetworkAccessManager.html file | annotate | diff | comparison | revisions
Documentation/Source/eric5.PluginManager.PluginRepositoryDialog.html file | annotate | diff | comparison | revisions
Documentation/Source/eric5.UI.UserInterface.html file | annotate | diff | comparison | revisions
E5Network/E5NetworkProxyFactory.py file | annotate | diff | comparison | revisions
Preferences/ConfigurationPages/NetworkPage.py file | annotate | diff | comparison | revisions
Preferences/ConfigurationPages/NetworkPage.ui file | annotate | diff | comparison | revisions
Preferences/__init__.py file | annotate | diff | comparison | revisions
--- a/APIs/Python3/eric5.api	Thu May 27 18:07:41 2010 +0200
+++ b/APIs/Python3/eric5.api	Thu May 27 20:27:46 2010 +0200
@@ -1301,6 +1301,8 @@
 eric5.E5Network.E5NetworkMonitor.E5RequestModel?1(networkAccessManager, parent = None)
 eric5.E5Network.E5NetworkProxyFactory.E5NetworkProxyFactory.queryProxy?4(query)
 eric5.E5Network.E5NetworkProxyFactory.E5NetworkProxyFactory?1()
+eric5.E5Network.E5NetworkProxyFactory.proxyAuthenticationRequired?4(proxy, auth)
+eric5.E5Network.E5NetworkProxyFactory.schemeFromProxyType?4(proxyType)
 eric5.E5XML.Config.debuggerPropertiesFileFormatVersion?7
 eric5.E5XML.Config.highlightingStylesFileFormatVersion?7
 eric5.E5XML.Config.multiProjectFileFormatVersion?7
Binary file Documentation/Help/source.qch has changed
--- a/Documentation/Help/source.qhp	Thu May 27 18:07:41 2010 +0200
+++ b/Documentation/Help/source.qhp	Thu May 27 20:27:46 2010 +0200
@@ -1482,7 +1482,6 @@
       <keyword name="PluginRepositoryWidget.__formatDescription" id="PluginRepositoryWidget.__formatDescription" ref="eric5.PluginManager.PluginRepositoryDialog.html#PluginRepositoryWidget.__formatDescription" />
       <keyword name="PluginRepositoryWidget.__isUpToDate" id="PluginRepositoryWidget.__isUpToDate" ref="eric5.PluginManager.PluginRepositoryDialog.html#PluginRepositoryWidget.__isUpToDate" />
       <keyword name="PluginRepositoryWidget.__populateList" id="PluginRepositoryWidget.__populateList" ref="eric5.PluginManager.PluginRepositoryDialog.html#PluginRepositoryWidget.__populateList" />
-      <keyword name="PluginRepositoryWidget.__proxyAuthenticationRequired" id="PluginRepositoryWidget.__proxyAuthenticationRequired" ref="eric5.PluginManager.PluginRepositoryDialog.html#PluginRepositoryWidget.__proxyAuthenticationRequired" />
       <keyword name="PluginRepositoryWidget.__resortRepositoryList" id="PluginRepositoryWidget.__resortRepositoryList" ref="eric5.PluginManager.PluginRepositoryDialog.html#PluginRepositoryWidget.__resortRepositoryList" />
       <keyword name="PluginRepositoryWidget.__selectedItems" id="PluginRepositoryWidget.__selectedItems" ref="eric5.PluginManager.PluginRepositoryDialog.html#PluginRepositoryWidget.__selectedItems" />
       <keyword name="PluginRepositoryWidget.__sslErrors" id="PluginRepositoryWidget.__sslErrors" ref="eric5.PluginManager.PluginRepositoryDialog.html#PluginRepositoryWidget.__sslErrors" />
@@ -1800,6 +1799,8 @@
       <keyword name="E5NetworkHeaderDetailsDialog.setData" id="E5NetworkHeaderDetailsDialog.setData" ref="eric5.E5Network.E5NetworkHeaderDetailsDialog.html#E5NetworkHeaderDetailsDialog.setData" />
       <keyword name="E5NetworkProxyFactory (Module)" id="E5NetworkProxyFactory (Module)" ref="eric5.E5Network.E5NetworkProxyFactory.html" />
       <keyword name="E5NetworkProxyFactory" id="E5NetworkProxyFactory" ref="eric5.E5Network.E5NetworkProxyFactory.html#E5NetworkProxyFactory" />
+      <keyword name="proxyAuthenticationRequired" id="proxyAuthenticationRequired" ref="eric5.E5Network.E5NetworkProxyFactory.html#proxyAuthenticationRequired" />
+      <keyword name="schemeFromProxyType" id="schemeFromProxyType" ref="eric5.E5Network.E5NetworkProxyFactory.html#schemeFromProxyType" />
       <keyword name="E5NetworkProxyFactory (Constructor)" id="E5NetworkProxyFactory (Constructor)" ref="eric5.E5Network.E5NetworkProxyFactory.html#E5NetworkProxyFactory.__init__" />
       <keyword name="E5NetworkProxyFactory.queryProxy" id="E5NetworkProxyFactory.queryProxy" ref="eric5.E5Network.E5NetworkProxyFactory.html#E5NetworkProxyFactory.queryProxy" />
       <keyword name="E5NetworkMonitor (Module)" id="E5NetworkMonitor (Module)" ref="eric5.E5Network.E5NetworkMonitor.html" />
@@ -4006,7 +4007,6 @@
       <keyword name="UserInterface.__programChange" id="UserInterface.__programChange" ref="eric5.UI.UserInterface.html#UserInterface.__programChange" />
       <keyword name="UserInterface.__projectClosed" id="UserInterface.__projectClosed" ref="eric5.UI.UserInterface.html#UserInterface.__projectClosed" />
       <keyword name="UserInterface.__projectOpened" id="UserInterface.__projectOpened" ref="eric5.UI.UserInterface.html#UserInterface.__projectOpened" />
-      <keyword name="UserInterface.__proxyAuthenticationRequired" id="UserInterface.__proxyAuthenticationRequired" ref="eric5.UI.UserInterface.html#UserInterface.__proxyAuthenticationRequired" />
       <keyword name="UserInterface.__quit" id="UserInterface.__quit" ref="eric5.UI.UserInterface.html#UserInterface.__quit" />
       <keyword name="UserInterface.__readSession" id="UserInterface.__readSession" ref="eric5.UI.UserInterface.html#UserInterface.__readSession" />
       <keyword name="UserInterface.__readTasks" id="UserInterface.__readTasks" ref="eric5.UI.UserInterface.html#UserInterface.__readTasks" />
@@ -6924,7 +6924,6 @@
       <keyword name="NetworkAccessManager (Constructor)" id="NetworkAccessManager (Constructor)" ref="eric5.Helpviewer.Network.NetworkAccessManager.html#NetworkAccessManager.__init__" />
       <keyword name="NetworkAccessManager.__authenticationRequired" id="NetworkAccessManager.__authenticationRequired" ref="eric5.Helpviewer.Network.NetworkAccessManager.html#NetworkAccessManager.__authenticationRequired" />
       <keyword name="NetworkAccessManager.__certToString" id="NetworkAccessManager.__certToString" ref="eric5.Helpviewer.Network.NetworkAccessManager.html#NetworkAccessManager.__certToString" />
-      <keyword name="NetworkAccessManager.__proxyAuthenticationRequired" id="NetworkAccessManager.__proxyAuthenticationRequired" ref="eric5.Helpviewer.Network.NetworkAccessManager.html#NetworkAccessManager.__proxyAuthenticationRequired" />
       <keyword name="NetworkAccessManager.__setDiskCache" id="NetworkAccessManager.__setDiskCache" ref="eric5.Helpviewer.Network.NetworkAccessManager.html#NetworkAccessManager.__setDiskCache" />
       <keyword name="NetworkAccessManager.__sslErrors" id="NetworkAccessManager.__sslErrors" ref="eric5.Helpviewer.Network.NetworkAccessManager.html#NetworkAccessManager.__sslErrors" />
       <keyword name="NetworkAccessManager.createRequest" id="NetworkAccessManager.createRequest" ref="eric5.Helpviewer.Network.NetworkAccessManager.html#NetworkAccessManager.createRequest" />
@@ -6944,6 +6943,7 @@
       <keyword name="FtpReply.__commandStarted" id="FtpReply.__commandStarted" ref="eric5.Helpviewer.Network.FtpReply.html#FtpReply.__commandStarted" />
       <keyword name="FtpReply.__connectToHost" id="FtpReply.__connectToHost" ref="eric5.Helpviewer.Network.FtpReply.html#FtpReply.__connectToHost" />
       <keyword name="FtpReply.__cssLinkClass" id="FtpReply.__cssLinkClass" ref="eric5.Helpviewer.Network.FtpReply.html#FtpReply.__cssLinkClass" />
+      <keyword name="FtpReply.__errorSignals" id="FtpReply.__errorSignals" ref="eric5.Helpviewer.Network.FtpReply.html#FtpReply.__errorSignals" />
       <keyword name="FtpReply.__processCommand" id="FtpReply.__processCommand" ref="eric5.Helpviewer.Network.FtpReply.html#FtpReply.__processCommand" />
       <keyword name="FtpReply.__processData" id="FtpReply.__processData" ref="eric5.Helpviewer.Network.FtpReply.html#FtpReply.__processData" />
       <keyword name="FtpReply.__processListInfo" id="FtpReply.__processListInfo" ref="eric5.Helpviewer.Network.FtpReply.html#FtpReply.__processListInfo" />
--- a/Documentation/Source/eric5.E5Network.E5NetworkProxyFactory.html	Thu May 27 18:07:41 2010 +0200
+++ b/Documentation/Source/eric5.E5Network.E5NetworkProxyFactory.html	Thu May 27 20:27:46 2010 +0200
@@ -37,7 +37,13 @@
 </table>
 <h3>Functions</h3>
 <table>
-<tr><td>None</td></tr>
+<tr>
+<td><a href="#proxyAuthenticationRequired">proxyAuthenticationRequired</a></td>
+<td>Module slot to handle a proxy authentication request.</td>
+</tr><tr>
+<td><a href="#schemeFromProxyType">schemeFromProxyType</a></td>
+<td>Module function to determine the scheme name from the proxy type.</td>
+</tr>
 </table>
 <hr /><hr />
 <a NAME="E5NetworkProxyFactory" ID="E5NetworkProxyFactory"></a>
@@ -83,5 +89,39 @@
 </dd>
 </dl>
 <div align="right"><a href="#top">Up</a></div>
+<hr /><hr />
+<a NAME="proxyAuthenticationRequired" ID="proxyAuthenticationRequired"></a>
+<h2>proxyAuthenticationRequired</h2>
+<b>proxyAuthenticationRequired</b>(<i>proxy, auth</i>)
+<p>
+    Module slot to handle a proxy authentication request.
+</p><dl>
+<dt><i>proxy</i></dt>
+<dd>
+reference to the proxy object (QNetworkProxy)
+</dd><dt><i>auth</i></dt>
+<dd>
+reference to the authenticator object (QAuthenticator)
+</dd>
+</dl>
+<div align="right"><a href="#top">Up</a></div>
+<hr /><hr />
+<a NAME="schemeFromProxyType" ID="schemeFromProxyType"></a>
+<h2>schemeFromProxyType</h2>
+<b>schemeFromProxyType</b>(<i>proxyType</i>)
+<p>
+    Module function to determine the scheme name from the proxy type.
+</p><dl>
+<dt><i>proxyType</i></dt>
+<dd>
+type of the proxy (QNetworkProxy.ProxyType)
+</dd>
+</dl><dl>
+<dt>Returns:</dt>
+<dd>
+scheme (string, one of Http, Https, Ftp)
+</dd>
+</dl>
+<div align="right"><a href="#top">Up</a></div>
 <hr />
 </body></html>
\ No newline at end of file
--- a/Documentation/Source/eric5.Helpviewer.Network.FtpReply.html	Thu May 27 18:07:41 2010 +0200
+++ b/Documentation/Source/eric5.Helpviewer.Network.FtpReply.html	Thu May 27 20:27:46 2010 +0200
@@ -66,6 +66,9 @@
 <td><a href="#FtpReply.__cssLinkClass">__cssLinkClass</a></td>
 <td>Private method to generate a link class with an icon.</td>
 </tr><tr>
+<td><a href="#FtpReply.__errorSignals">__errorSignals</a></td>
+<td>Private slot to send signal for errors during initialisation.</td>
+</tr><tr>
 <td><a href="#FtpReply.__processCommand">__processCommand</a></td>
 <td>Private slot to handle the end of FTP commands.</td>
 </tr><tr>
@@ -140,7 +143,12 @@
 <dd>
 CSS class string (string)
 </dd>
-</dl><a NAME="FtpReply.__processCommand" ID="FtpReply.__processCommand"></a>
+</dl><a NAME="FtpReply.__errorSignals" ID="FtpReply.__errorSignals"></a>
+<h4>FtpReply.__errorSignals</h4>
+<b>__errorSignals</b>(<i></i>)
+<p>
+        Private slot to send signal for errors during initialisation.
+</p><a NAME="FtpReply.__processCommand" ID="FtpReply.__processCommand"></a>
 <h4>FtpReply.__processCommand</h4>
 <b>__processCommand</b>(<i>id, error</i>)
 <p>
--- a/Documentation/Source/eric5.Helpviewer.Network.NetworkAccessManager.html	Thu May 27 18:07:41 2010 +0200
+++ b/Documentation/Source/eric5.Helpviewer.Network.NetworkAccessManager.html	Thu May 27 20:27:46 2010 +0200
@@ -69,9 +69,6 @@
 <td><a href="#NetworkAccessManager.__certToString">__certToString</a></td>
 <td>Private method to convert a certificate to a formatted string.</td>
 </tr><tr>
-<td><a href="#NetworkAccessManager.__proxyAuthenticationRequired">__proxyAuthenticationRequired</a></td>
-<td>Private slot to handle a proxy authentication request.</td>
-</tr><tr>
 <td><a href="#NetworkAccessManager.__setDiskCache">__setDiskCache</a></td>
 <td>Private method to set the disk cache.</td>
 </tr><tr>
@@ -132,19 +129,6 @@
 <dd>
 formatted string (string)
 </dd>
-</dl><a NAME="NetworkAccessManager.__proxyAuthenticationRequired" ID="NetworkAccessManager.__proxyAuthenticationRequired"></a>
-<h4>NetworkAccessManager.__proxyAuthenticationRequired</h4>
-<b>__proxyAuthenticationRequired</b>(<i>proxy, auth</i>)
-<p>
-        Private slot to handle a proxy authentication request.
-</p><dl>
-<dt><i>proxy</i></dt>
-<dd>
-reference to the proxy object (QNetworkProxy)
-</dd><dt><i>auth</i></dt>
-<dd>
-reference to the authenticator object (QAuthenticator)
-</dd>
 </dl><a NAME="NetworkAccessManager.__setDiskCache" ID="NetworkAccessManager.__setDiskCache"></a>
 <h4>NetworkAccessManager.__setDiskCache</h4>
 <b>__setDiskCache</b>(<i></i>)
--- a/Documentation/Source/eric5.PluginManager.PluginRepositoryDialog.html	Thu May 27 18:07:41 2010 +0200
+++ b/Documentation/Source/eric5.PluginManager.PluginRepositoryDialog.html	Thu May 27 20:27:46 2010 +0200
@@ -157,9 +157,6 @@
 <td><a href="#PluginRepositoryWidget.__populateList">__populateList</a></td>
 <td>Private method to populate the list of available plugins.</td>
 </tr><tr>
-<td><a href="#PluginRepositoryWidget.__proxyAuthenticationRequired">__proxyAuthenticationRequired</a></td>
-<td>Private slot to handle a proxy authentication request.</td>
-</tr><tr>
 <td><a href="#PluginRepositoryWidget.__resortRepositoryList">__resortRepositoryList</a></td>
 <td>Private method to resort the tree.</td>
 </tr><tr>
@@ -317,20 +314,7 @@
 <b>__populateList</b>(<i></i>)
 <p>
         Private method to populate the list of available plugins.
-</p><a NAME="PluginRepositoryWidget.__proxyAuthenticationRequired" ID="PluginRepositoryWidget.__proxyAuthenticationRequired"></a>
-<h4>PluginRepositoryWidget.__proxyAuthenticationRequired</h4>
-<b>__proxyAuthenticationRequired</b>(<i>proxy, auth</i>)
-<p>
-        Private slot to handle a proxy authentication request.
-</p><dl>
-<dt><i>proxy</i></dt>
-<dd>
-reference to the proxy object (QNetworkProxy)
-</dd><dt><i>auth</i></dt>
-<dd>
-reference to the authenticator object (QAuthenticator)
-</dd>
-</dl><a NAME="PluginRepositoryWidget.__resortRepositoryList" ID="PluginRepositoryWidget.__resortRepositoryList"></a>
+</p><a NAME="PluginRepositoryWidget.__resortRepositoryList" ID="PluginRepositoryWidget.__resortRepositoryList"></a>
 <h4>PluginRepositoryWidget.__resortRepositoryList</h4>
 <b>__resortRepositoryList</b>(<i></i>)
 <p>
--- a/Documentation/Source/eric5.UI.UserInterface.html	Thu May 27 18:07:41 2010 +0200
+++ b/Documentation/Source/eric5.UI.UserInterface.html	Thu May 27 20:27:46 2010 +0200
@@ -370,9 +370,6 @@
 <td><a href="#UserInterface.__projectOpened">__projectOpened</a></td>
 <td>Private slot to handle the projectOpened signal.</td>
 </tr><tr>
-<td><a href="#UserInterface.__proxyAuthenticationRequired">__proxyAuthenticationRequired</a></td>
-<td>Private slot to handle a proxy authentication request.</td>
-</tr><tr>
 <td><a href="#UserInterface.__quit">__quit</a></td>
 <td>Private method to quit the application.</td>
 </tr><tr>
@@ -1208,20 +1205,7 @@
 <b>__projectOpened</b>(<i></i>)
 <p>
         Private slot to handle the projectOpened signal.
-</p><a NAME="UserInterface.__proxyAuthenticationRequired" ID="UserInterface.__proxyAuthenticationRequired"></a>
-<h4>UserInterface.__proxyAuthenticationRequired</h4>
-<b>__proxyAuthenticationRequired</b>(<i>proxy, auth</i>)
-<p>
-        Private slot to handle a proxy authentication request.
-</p><dl>
-<dt><i>proxy</i></dt>
-<dd>
-reference to the proxy object (QNetworkProxy)
-</dd><dt><i>auth</i></dt>
-<dd>
-reference to the authenticator object (QAuthenticator)
-</dd>
-</dl><a NAME="UserInterface.__quit" ID="UserInterface.__quit"></a>
+</p><a NAME="UserInterface.__quit" ID="UserInterface.__quit"></a>
 <h4>UserInterface.__quit</h4>
 <b>__quit</b>(<i></i>)
 <p>
--- a/E5Network/E5NetworkProxyFactory.py	Thu May 27 18:07:41 2010 +0200
+++ b/E5Network/E5NetworkProxyFactory.py	Thu May 27 20:27:46 2010 +0200
@@ -18,6 +18,48 @@
 
 import Preferences
 
+def schemeFromProxyType(proxyType):
+    """
+    Module function to determine the scheme name from the proxy type.
+    
+    @param proxyType type of the proxy (QNetworkProxy.ProxyType)
+    @return scheme (string, one of Http, Https, Ftp)
+    """
+    scheme = ""
+    if proxyType == QNetworkProxy.HttpProxy:
+        scheme = "Http"
+    elif proxyType == QNetworkProxy.HttpCachingProxy:
+        scheme = "Https"
+    elif proxyType == QNetworkProxy.FtpCachingProxy:
+        scheme = "Ftp"
+    elif proxyType == QNetworkProxy.NoProxy:
+        scheme = "NoProxy"
+    return scheme
+
+def proxyAuthenticationRequired(proxy, auth):
+    """
+    Module slot to handle a proxy authentication request.
+    
+    @param proxy reference to the proxy object (QNetworkProxy)
+    @param auth reference to the authenticator object (QAuthenticator)
+    """
+    info = QCoreApplication.translate("E5NetworkProxyFactory", 
+        "<b>Connect to proxy '{0}' using:</b>")\
+        .format(Qt.escape(proxy.hostName()))
+    
+    dlg = AuthenticationDialog(info, proxy.user(), True)
+    if dlg.exec_() == QDialog.Accepted:
+        username, password = dlg.getData()
+        auth.setUser(username)
+        auth.setPassword(password)
+        if dlg.shallSave():
+            scheme = schemeFromProxyType(proxy.type())
+            if scheme and scheme != "NoProxy":
+                Preferences.setUI("ProxyUser/{0}".format(scheme), username)
+                Preferences.setUI("ProxyPassword/{0}".format(scheme), password)
+            proxy.setUser(username)
+            proxy.setPassword(password)
+
 class E5NetworkProxyFactory(QNetworkProxyFactory):
     """
     Class implementing a network proxy factory.
@@ -51,51 +93,60 @@
                         if value and name[-6:] == '_proxy' and \
                            name[:-6] == query.protocolTag().lower():
                             url = QUrl(value)
-                            if url.scheme() in ["http", "https"]:
+                            if url.scheme() == "http":
                                 proxyType = QNetworkProxy.HttpProxy
+                            elif url.scheme() == "https":
+                                proxyType = QNetworkProxy.HttpCachingProxy
+                            elif url.scheme() == "ftp":
+                                proxyType = QNetworkProxy.FtpCachingProxy
                             else:
-                                proxyType = QNetworkProxy.FtpCachingProxy
+                                proxyType = QNetworkProxy.HttpProxy
                             proxy = QNetworkProxy(proxyType, url.host(), url.port(), 
                                                   url.userName(), url.password())
                             proxyList = [proxy]
                             break
-                proxyList[0].setUser(Preferences.getUI("ProxyUser/Http"))
-                proxyList[0].setPassword(Preferences.getUI("ProxyPassword/Http"))
+                scheme = schemeFromProxyType(proxyList[0].type())
+                if scheme == "":
+                    scheme = "Http"
+                if scheme != "NoProxy":
+                    proxyList[0].setUser(
+                        Preferences.getUI("ProxyUser/{0}".format(scheme)))
+                    proxyList[0].setPassword(
+                        Preferences.getUI("ProxyPassword/{0}".format(scheme)))
                 return proxyList
             else:
-                host = Preferences.getUI("ProxyHost/Http")
+                if Preferences.getUI("UseHttpProxyForAll"):
+                    protocol = "Http"
+                else:
+                    protocol = query.protocolTag().capitalize()
+                host = Preferences.getUI("ProxyHost/{0}".format(protocol))
                 if not host:
                     QMessageBox.critical(None,
-                        self.trUtf8("Proxy Configuration Error"),
-                        self.trUtf8("""Proxy usage was activated"""
-                                    """ but no proxy host configured."""))
+                        QCoreApplication.translate("E5NetworkProxyFactory", 
+                            "Proxy Configuration Error"),
+                        QCoreApplication.translate("E5NetworkProxyFactory", 
+                            """Proxy usage was activated"""
+                            """ but no proxy host for protocol"""
+                            """ '{0}' configured.""").format(protocol))
                     return [QNetworkProxy(QNetworkProxy.DefaultProxy)]
                 else:
-                    proxy = QNetworkProxy(QNetworkProxy.HttpProxy, host, 
-                        Preferences.getUI("ProxyPort/Http"),
-                        Preferences.getUI("ProxyUser/Http"),
-                        Preferences.getUI("ProxyPassword/Http"))
+                    if protocol == "Http":
+                        proxy = QNetworkProxy(QNetworkProxy.HttpProxy, host, 
+                            Preferences.getUI("ProxyPort/Http"),
+                            Preferences.getUI("ProxyUser/Http"),
+                            Preferences.getUI("ProxyPassword/Http"))
+                    elif protocol == "Https":
+                        proxy = QNetworkProxy(QNetworkProxy.HttpCachingProxy, host, 
+                            Preferences.getUI("ProxyPort/Https"),
+                            Preferences.getUI("ProxyUser/Https"),
+                            Preferences.getUI("ProxyPassword/Https"))
+                    elif protocol == "Ftp":
+                        proxy = QNetworkProxy(QNetworkProxy.FtpCachingProxy, host, 
+                            Preferences.getUI("ProxyPort/Ftp"),
+                            Preferences.getUI("ProxyUser/Ftp"),
+                            Preferences.getUI("ProxyPassword/Ftp"))
+                    else:
+                        proxy = QNetworkProxy(QNetworkProxy.DefaultProxy)
                     return [proxy, QNetworkProxy(QNetworkProxy.DefaultProxy)]
         else:
             return [QNetworkProxy(QNetworkProxy.NoProxy)]
-
-def proxyAuthenticationRequired(proxy, auth):
-    """
-    Module slot to handle a proxy authentication request.
-    
-    @param proxy reference to the proxy object (QNetworkProxy)
-    @param auth reference to the authenticator object (QAuthenticator)
-    """
-    info = QCoreApplication.translate("E5NetworkProxyFactory", "<b>Connect to proxy '{0}' using:</b>")\
-        .format(Qt.escape(proxy.hostName()))
-    
-    dlg = AuthenticationDialog(info, proxy.user(), True)
-    if dlg.exec_() == QDialog.Accepted:
-        username, password = dlg.getData()
-        auth.setUser(username)
-        auth.setPassword(password)
-        if dlg.shallSave():
-            Preferences.setUI("ProxyUser/Http", username)
-            Preferences.setUI("ProxyPassword/Http", password)
-            proxy.setUser(username)
-            proxy.setPassword(password)
--- a/Preferences/ConfigurationPages/NetworkPage.py	Thu May 27 18:07:41 2010 +0200
+++ b/Preferences/ConfigurationPages/NetworkPage.py	Thu May 27 20:27:46 2010 +0200
@@ -45,14 +45,20 @@
             self.systemProxyButton.setChecked(True)
         else:
             self.manualProxyButton.setChecked(True)
-        self.proxyHostEdit.setText(\
+        self.httpProxyForAllCheckBox.setChecked(
+            Preferences.getUI("UseHttpProxyForAll"))
+        self.httpProxyHostEdit.setText(\
             Preferences.getUI("ProxyHost/Http"))
-        self.proxyUserEdit.setText(\
-            Preferences.getUI("ProxyUser/Http"))
-        self.proxyPasswordEdit.setText(\
-            Preferences.getUI("ProxyPassword/Http"))
-        self.proxyPortSpin.setValue(\
+        self.httpsProxyHostEdit.setText(\
+            Preferences.getUI("ProxyHost/Https"))
+        self.ftpProxyHostEdit.setText(\
+            Preferences.getUI("ProxyHost/Ftp"))
+        self.httpProxyPortSpin.setValue(\
             Preferences.getUI("ProxyPort/Http"))
+        self.httpsProxyPortSpin.setValue(\
+            Preferences.getUI("ProxyPort/Https"))
+        self.ftpProxyPortSpin.setValue(\
+            Preferences.getUI("ProxyPort/Ftp"))
         
     def save(self):
         """
@@ -67,14 +73,20 @@
             self.proxyGroup.isChecked())
         Preferences.setUI("UseSystemProxy", 
             self.systemProxyButton.isChecked())
+        Preferences.setUI("UseHttpProxyForAll", 
+            self.httpProxyForAllCheckBox.isChecked())
         Preferences.setUI("ProxyHost/Http",
-            self.proxyHostEdit.text())
-        Preferences.setUI("ProxyUser/Http",
-            self.proxyUserEdit.text())
-        Preferences.setUI("ProxyPassword/Http",
-            self.proxyPasswordEdit.text())
+            self.httpProxyHostEdit.text())
+        Preferences.setUI("ProxyHost/Https",
+            self.httpsProxyHostEdit.text())
+        Preferences.setUI("ProxyHost/Ftp",
+            self.ftpProxyHostEdit.text())
         Preferences.setUI("ProxyPort/Http",
-            self.proxyPortSpin.value())
+            self.httpProxyPortSpin.value())
+        Preferences.setUI("ProxyPort/Https",
+            self.httpsProxyPortSpin.value())
+        Preferences.setUI("ProxyPort/Ftp",
+            self.ftpProxyPortSpin.value())
     
     @pyqtSlot()
     def on_downloadDirButton_clicked(self):
--- a/Preferences/ConfigurationPages/NetworkPage.ui	Thu May 27 18:07:41 2010 +0200
+++ b/Preferences/ConfigurationPages/NetworkPage.ui	Thu May 27 20:27:46 2010 +0200
@@ -92,6 +92,9 @@
         <property name="text">
          <string>Use system proxy configuration</string>
         </property>
+        <property name="checked">
+         <bool>true</bool>
+        </property>
        </widget>
       </item>
       <item>
@@ -102,10 +105,16 @@
         <property name="text">
          <string>Manual proxy configuration:</string>
         </property>
+        <property name="checked">
+         <bool>false</bool>
+        </property>
        </widget>
       </item>
       <item>
        <widget class="QGroupBox" name="groupBox">
+        <property name="enabled">
+         <bool>false</bool>
+        </property>
         <property name="title">
          <string>Manual proxy settings</string>
         </property>
@@ -114,44 +123,30 @@
         </property>
         <layout class="QGridLayout" name="gridLayout">
          <item row="0" column="0">
-          <widget class="QLabel" name="label_5">
+          <widget class="QLabel" name="label">
            <property name="text">
-            <string>Proxy-Type:</string>
-           </property>
-          </widget>
-         </item>
-         <item row="0" column="1" colspan="2">
-          <widget class="QComboBox" name="proxyTypeCombo">
-           <property name="toolTip">
-            <string>Select the type of the proxy</string>
+            <string>Http-Proxy:</string>
            </property>
           </widget>
          </item>
-         <item row="1" column="0">
-          <widget class="QLabel" name="label">
-           <property name="text">
-            <string>Proxy-Host:</string>
+         <item row="0" column="1">
+          <widget class="QLineEdit" name="httpProxyHostEdit">
+           <property name="toolTip">
+            <string>Enter the name of the HTTP proxy host</string>
            </property>
           </widget>
          </item>
-         <item row="1" column="1" colspan="2">
-          <widget class="QLineEdit" name="proxyHostEdit">
-           <property name="toolTip">
-            <string>Enter the name of the proxy host</string>
+         <item row="0" column="2">
+          <widget class="QLabel" name="label_2">
+           <property name="text">
+            <string>Port:</string>
            </property>
           </widget>
          </item>
-         <item row="2" column="0">
-          <widget class="QLabel" name="label_2">
-           <property name="text">
-            <string>Proxy-Port:</string>
-           </property>
-          </widget>
-         </item>
-         <item row="2" column="1">
-          <widget class="QSpinBox" name="proxyPortSpin">
+         <item row="0" column="3">
+          <widget class="QSpinBox" name="httpProxyPortSpin">
            <property name="toolTip">
-            <string>Enter the proxy port</string>
+            <string>Enter the HTTP proxy port</string>
            </property>
            <property name="alignment">
             <set>Qt::AlignRight</set>
@@ -167,47 +162,93 @@
            </property>
           </widget>
          </item>
-         <item row="2" column="2">
-          <spacer>
-           <property name="orientation">
-            <enum>Qt::Horizontal</enum>
+         <item row="1" column="1" colspan="3">
+          <widget class="QCheckBox" name="httpProxyForAllCheckBox">
+           <property name="toolTip">
+            <string>Select to use the HTTP proxy for all</string>
+           </property>
+           <property name="text">
+            <string>Use this proxy for all protocols</string>
+           </property>
+          </widget>
+         </item>
+         <item row="2" column="0">
+          <widget class="QLabel" name="label_4">
+           <property name="text">
+            <string>Https-Proxy:</string>
+           </property>
+          </widget>
+         </item>
+         <item row="2" column="1">
+          <widget class="QLineEdit" name="httpsProxyHostEdit">
+           <property name="toolTip">
+            <string>Enter the name of the HTTPS proxy host</string>
            </property>
-           <property name="sizeHint" stdset="0">
-            <size>
-             <width>40</width>
-             <height>20</height>
-            </size>
+          </widget>
+         </item>
+         <item row="2" column="2">
+          <widget class="QLabel" name="label_5">
+           <property name="text">
+            <string>Port:</string>
+           </property>
+          </widget>
+         </item>
+         <item row="2" column="3">
+          <widget class="QSpinBox" name="httpsProxyPortSpin">
+           <property name="toolTip">
+            <string>Enter the HTTPS proxy port</string>
            </property>
-          </spacer>
+           <property name="alignment">
+            <set>Qt::AlignRight</set>
+           </property>
+           <property name="minimum">
+            <number>1</number>
+           </property>
+           <property name="maximum">
+            <number>65535</number>
+           </property>
+           <property name="value">
+            <number>80</number>
+           </property>
+          </widget>
          </item>
          <item row="3" column="0">
           <widget class="QLabel" name="label_3">
            <property name="text">
-            <string>Username:</string>
+            <string>Ftp-Proxy:</string>
            </property>
           </widget>
          </item>
-         <item row="3" column="1" colspan="2">
-          <widget class="QLineEdit" name="proxyUserEdit">
+         <item row="3" column="1">
+          <widget class="QLineEdit" name="ftpProxyHostEdit">
            <property name="toolTip">
-            <string>Enter the username for the proxy</string>
+            <string>Enter the name of the FTP proxy host</string>
            </property>
           </widget>
          </item>
-         <item row="4" column="0">
-          <widget class="QLabel" name="label_4">
+         <item row="3" column="2">
+          <widget class="QLabel" name="label_7">
            <property name="text">
-            <string>Password:</string>
+            <string>Port:</string>
            </property>
           </widget>
          </item>
-         <item row="4" column="1" colspan="2">
-          <widget class="QLineEdit" name="proxyPasswordEdit">
+         <item row="3" column="3">
+          <widget class="QSpinBox" name="ftpProxyPortSpin">
            <property name="toolTip">
-            <string>Enter the password for the proxy</string>
+            <string>Enter the FTP proxy port</string>
+           </property>
+           <property name="alignment">
+            <set>Qt::AlignRight</set>
            </property>
-           <property name="echoMode">
-            <enum>QLineEdit::Password</enum>
+           <property name="minimum">
+            <number>1</number>
+           </property>
+           <property name="maximum">
+            <number>65535</number>
+           </property>
+           <property name="value">
+            <number>80</number>
            </property>
           </widget>
          </item>
@@ -239,11 +280,13 @@
   <tabstop>proxyGroup</tabstop>
   <tabstop>systemProxyButton</tabstop>
   <tabstop>manualProxyButton</tabstop>
-  <tabstop>proxyTypeCombo</tabstop>
-  <tabstop>proxyHostEdit</tabstop>
-  <tabstop>proxyPortSpin</tabstop>
-  <tabstop>proxyUserEdit</tabstop>
-  <tabstop>proxyPasswordEdit</tabstop>
+  <tabstop>httpProxyHostEdit</tabstop>
+  <tabstop>httpProxyPortSpin</tabstop>
+  <tabstop>httpProxyForAllCheckBox</tabstop>
+  <tabstop>httpsProxyHostEdit</tabstop>
+  <tabstop>httpsProxyPortSpin</tabstop>
+  <tabstop>ftpProxyHostEdit</tabstop>
+  <tabstop>ftpProxyPortSpin</tabstop>
  </tabstops>
  <resources/>
  <connections>
@@ -263,5 +306,133 @@
     </hint>
    </hints>
   </connection>
+  <connection>
+   <sender>httpProxyForAllCheckBox</sender>
+   <signal>toggled(bool)</signal>
+   <receiver>label_4</receiver>
+   <slot>setDisabled(bool)</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>113</x>
+     <y>240</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>83</x>
+     <y>265</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>httpProxyForAllCheckBox</sender>
+   <signal>toggled(bool)</signal>
+   <receiver>label_3</receiver>
+   <slot>setDisabled(bool)</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>129</x>
+     <y>240</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>64</x>
+     <y>291</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>httpProxyForAllCheckBox</sender>
+   <signal>toggled(bool)</signal>
+   <receiver>httpsProxyHostEdit</receiver>
+   <slot>setDisabled(bool)</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>195</x>
+     <y>236</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>153</x>
+     <y>267</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>httpProxyForAllCheckBox</sender>
+   <signal>toggled(bool)</signal>
+   <receiver>ftpProxyHostEdit</receiver>
+   <slot>setDisabled(bool)</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>191</x>
+     <y>240</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>183</x>
+     <y>295</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>httpProxyForAllCheckBox</sender>
+   <signal>toggled(bool)</signal>
+   <receiver>label_5</receiver>
+   <slot>setDisabled(bool)</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>401</x>
+     <y>240</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>480</x>
+     <y>265</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>httpProxyForAllCheckBox</sender>
+   <signal>toggled(bool)</signal>
+   <receiver>label_7</receiver>
+   <slot>setDisabled(bool)</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>366</x>
+     <y>238</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>474</x>
+     <y>290</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>httpProxyForAllCheckBox</sender>
+   <signal>toggled(bool)</signal>
+   <receiver>httpsProxyPortSpin</receiver>
+   <slot>setDisabled(bool)</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>465</x>
+     <y>239</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>522</x>
+     <y>268</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>httpProxyForAllCheckBox</sender>
+   <signal>toggled(bool)</signal>
+   <receiver>ftpProxyPortSpin</receiver>
+   <slot>setDisabled(bool)</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>438</x>
+     <y>237</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>516</x>
+     <y>293</y>
+    </hint>
+   </hints>
+  </connection>
  </connections>
 </ui>
--- a/Preferences/__init__.py	Thu May 27 18:07:41 2010 +0200
+++ b/Preferences/__init__.py	Thu May 27 20:27:46 2010 +0200
@@ -166,22 +166,15 @@
         "ProxyHost/Http" : "",
         "ProxyHost/Https" : "",
         "ProxyHost/Ftp" : "",
-        "ProxyHost/Socks5" : "",
         "ProxyPort/Http" : 80,
         "ProxyPort/Https" : 443,
         "ProxyPort/Ftp" : 21,
-        "ProxyPort/Socks5" : 0,
         "ProxyUser/Http" : "",
         "ProxyUser/Https" : "",
         "ProxyUser/Ftp" : "",
-        "ProxyUser/Socks5" : "",
         "ProxyPassword/Http" : "",
         "ProxyPassword/Https" : "",
         "ProxyPassword/Ftp" : "",
-        "ProxyPassword/Socks5" : "",
-        "ProxyType" : 0,            # 0 = transparent HTTP proxy
-                                    # 1 = caching HTTP proxy
-                                    # 2 = SOCKS5 proxy
         
         "PluginRepositoryUrl5" : \
             "http://die-offenbachs.homelinux.org/eric/plugins5/repository.xml",
@@ -1077,13 +1070,13 @@
         return toBool(prefClass.settings.value("UI/" + key,
             prefClass.uiDefaults[key]))
     elif key in ["TabViewManagerFilenameLength", "CaptionFilenameLength",
-                 "ProxyPort/Http", "ProxyPort/Https", "ProxyPort/Ftp", "ProxyPort/Socks5", 
+                 "ProxyPort/Http", "ProxyPort/Https", "ProxyPort/Ftp", 
                  "OpenOnStartup", 
                  "PerformVersionCheck", "RecentNumber", ]:
         return int(prefClass.settings.value("UI/" + key,
             prefClass.uiDefaults[key]))
     elif key in ["ProxyPassword/Http", "ProxyPassword/Https", 
-                 "ProxyPassword/Ftp", "ProxyPassword/Socks5", ]:
+                 "ProxyPassword/Ftp", ]:
         from Utilities import pwDecode
         return pwDecode(prefClass.settings.value("UI/" + key, prefClass.uiDefaults[key]))
     elif key in ["LogStdErrColour"]:
@@ -1154,7 +1147,7 @@
     elif key == "LogStdErrColour":
         prefClass.settings.setValue("UI/" + key, value.name())
     elif key in ["ProxyPassword/Http", "ProxyPassword/Https", 
-                 "ProxyPassword/Ftp", "ProxyPassword/Socks5", ]:
+                 "ProxyPassword/Ftp", ]:
         from Utilities import pwEncode
         prefClass.settings.setValue("UI/" + key, pwEncode(value))
     else:

eric ide

mercurial