Some small enhancements to the AdBlock Plus code.

Mon, 23 Jul 2012 19:21:44 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Mon, 23 Jul 2012 19:21:44 +0200
changeset 1955
9e6da33c1c10
parent 1953
26aa6fd94dc2
child 1956
ce5cd9fee192

Some small enhancements to the AdBlock Plus code.

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.Helpviewer.Network.FollowRedirectReply.html file | annotate | diff | comparison | revisions
Helpviewer/AdBlock/AdBlockNetwork.py file | annotate | diff | comparison | revisions
Helpviewer/AdBlock/AdBlockSubscription.py file | annotate | diff | comparison | revisions
Helpviewer/Network/FollowRedirectReply.py file | annotate | diff | comparison | revisions
--- a/APIs/Python3/eric5.api	Sun Jul 22 15:32:52 2012 +0200
+++ b/APIs/Python3/eric5.api	Mon Jul 23 19:21:44 2012 +0200
@@ -2487,7 +2487,9 @@
 eric5.Helpviewer.Network.EricAccessHandler.EricAccessHandler._homePage?8
 eric5.Helpviewer.Network.EricAccessHandler.EricAccessHandler._speedDialPage?8
 eric5.Helpviewer.Network.EricAccessHandler.EricAccessHandler.createRequest?4(op, request, outgoingData=None)
+eric5.Helpviewer.Network.FollowRedirectReply.FollowRedirectReply.close?4()
 eric5.Helpviewer.Network.FollowRedirectReply.FollowRedirectReply.error?4()
+eric5.Helpviewer.Network.FollowRedirectReply.FollowRedirectReply.errorString?4()
 eric5.Helpviewer.Network.FollowRedirectReply.FollowRedirectReply.finished?7
 eric5.Helpviewer.Network.FollowRedirectReply.FollowRedirectReply.originalUrl?4()
 eric5.Helpviewer.Network.FollowRedirectReply.FollowRedirectReply.readAll?4()
Binary file Documentation/Help/source.qch has changed
--- a/Documentation/Help/source.qhp	Sun Jul 22 15:32:52 2012 +0200
+++ b/Documentation/Help/source.qhp	Mon Jul 23 19:21:44 2012 +0200
@@ -4368,7 +4368,9 @@
       <keyword name="FollowRedirectReply (Constructor)" id="FollowRedirectReply (Constructor)" ref="eric5.Helpviewer.Network.FollowRedirectReply.html#FollowRedirectReply.__init__" />
       <keyword name="FollowRedirectReply (Module)" id="FollowRedirectReply (Module)" ref="eric5.Helpviewer.Network.FollowRedirectReply.html" />
       <keyword name="FollowRedirectReply.__replyFinished" id="FollowRedirectReply.__replyFinished" ref="eric5.Helpviewer.Network.FollowRedirectReply.html#FollowRedirectReply.__replyFinished" />
+      <keyword name="FollowRedirectReply.close" id="FollowRedirectReply.close" ref="eric5.Helpviewer.Network.FollowRedirectReply.html#FollowRedirectReply.close" />
       <keyword name="FollowRedirectReply.error" id="FollowRedirectReply.error" ref="eric5.Helpviewer.Network.FollowRedirectReply.html#FollowRedirectReply.error" />
+      <keyword name="FollowRedirectReply.errorString" id="FollowRedirectReply.errorString" ref="eric5.Helpviewer.Network.FollowRedirectReply.html#FollowRedirectReply.errorString" />
       <keyword name="FollowRedirectReply.originalUrl" id="FollowRedirectReply.originalUrl" ref="eric5.Helpviewer.Network.FollowRedirectReply.html#FollowRedirectReply.originalUrl" />
       <keyword name="FollowRedirectReply.readAll" id="FollowRedirectReply.readAll" ref="eric5.Helpviewer.Network.FollowRedirectReply.html#FollowRedirectReply.readAll" />
       <keyword name="FollowRedirectReply.reply" id="FollowRedirectReply.reply" ref="eric5.Helpviewer.Network.FollowRedirectReply.html#FollowRedirectReply.reply" />
--- a/Documentation/Source/eric5.Helpviewer.Network.FollowRedirectReply.html	Sun Jul 22 15:32:52 2012 +0200
+++ b/Documentation/Source/eric5.Helpviewer.Network.FollowRedirectReply.html	Mon Jul 23 19:21:44 2012 +0200
@@ -64,9 +64,15 @@
 <td><a href="#FollowRedirectReply.__replyFinished">__replyFinished</a></td>
 <td>Private slot handling the receipt of the requested data.</td>
 </tr><tr>
+<td><a href="#FollowRedirectReply.close">close</a></td>
+<td>Public method to close the data stream.</td>
+</tr><tr>
 <td><a href="#FollowRedirectReply.error">error</a></td>
 <td>Public method to get the error information.</td>
 </tr><tr>
+<td><a href="#FollowRedirectReply.errorString">errorString</a></td>
+<td>Public method to get the error message.</td>
+</tr><tr>
 <td><a href="#FollowRedirectReply.originalUrl">originalUrl</a></td>
 <td>Public method to get the original URL.</td>
 </tr><tr>
@@ -105,6 +111,11 @@
 <b>__replyFinished</b>(<i></i>)
 <p>
         Private slot handling the receipt of the requested data.
+</p><a NAME="FollowRedirectReply.close" ID="FollowRedirectReply.close"></a>
+<h4>FollowRedirectReply.close</h4>
+<b>close</b>(<i></i>)
+<p>
+        Public method to close the data stream.
 </p><a NAME="FollowRedirectReply.error" ID="FollowRedirectReply.error"></a>
 <h4>FollowRedirectReply.error</h4>
 <b>error</b>(<i></i>)
@@ -115,6 +126,16 @@
 <dd>
 error code (QNetworkReply.NetworkError)
 </dd>
+</dl><a NAME="FollowRedirectReply.errorString" ID="FollowRedirectReply.errorString"></a>
+<h4>FollowRedirectReply.errorString</h4>
+<b>errorString</b>(<i></i>)
+<p>
+        Public method to get the error message.
+</p><dl>
+<dt>Returns:</dt>
+<dd>
+error message (string)
+</dd>
 </dl><a NAME="FollowRedirectReply.originalUrl" ID="FollowRedirectReply.originalUrl"></a>
 <h4>FollowRedirectReply.originalUrl</h4>
 <b>originalUrl</b>(<i></i>)
--- a/Helpviewer/AdBlock/AdBlockNetwork.py	Sun Jul 22 15:32:52 2012 +0200
+++ b/Helpviewer/AdBlock/AdBlockNetwork.py	Mon Jul 23 19:21:44 2012 +0200
@@ -26,7 +26,7 @@
         """
         url = request.url()
         
-        if url.scheme() in ["data", "eric", "qthelp", "qrc", "file"]:
+        if url.scheme() in ["data", "eric", "qthelp", "qrc", "file", "abp"]:
             return None
         
         manager = Helpviewer.HelpWindow.HelpWindow.adblockManager()
--- a/Helpviewer/AdBlock/AdBlockSubscription.py	Sun Jul 22 15:32:52 2012 +0200
+++ b/Helpviewer/AdBlock/AdBlockSubscription.py	Mon Jul 23 19:21:44 2012 +0200
@@ -11,13 +11,14 @@
 
 from PyQt4.QtCore import pyqtSignal, Qt, QObject, QByteArray, QDateTime, QUrl, \
     QCryptographicHash, QFile, QIODevice, QTextStream
-from PyQt4.QtNetwork import QNetworkRequest, QNetworkReply
+from PyQt4.QtNetwork import QNetworkReply
 
 from E5Gui import E5MessageBox
 
 from .AdBlockRule import AdBlockRule
 
 import Helpviewer.HelpWindow
+from Helpviewer.Network.FollowRedirectReply import FollowRedirectReply
 
 import Utilities
 import Preferences
@@ -256,9 +257,8 @@
             self.changed.emit()
             return
         
-        request = QNetworkRequest(self.location())
-        self.__downloading = \
-            Helpviewer.HelpWindow.HelpWindow.networkAccessManager().get(request)
+        self.__downloading = FollowRedirectReply(self.location(),
+            Helpviewer.HelpWindow.HelpWindow.networkAccessManager())
         self.__downloading.finished[()].connect(self.__rulesDownloaded)
     
     def __rulesDownloaded(self):
@@ -268,7 +268,6 @@
         reply = self.sender()
         
         response = reply.readAll()
-        redirect = reply.attribute(QNetworkRequest.RedirectionTargetAttribute) or QUrl()
         reply.close()
         self.__downloading = None
         
@@ -284,13 +283,6 @@
                 self.__defaultSubscription = False
             return
         
-        if redirect.isValid():
-            request = QNetworkRequest(redirect)
-            self.__downloading = \
-                Helpviewer.HelpWindow.HelpWindow.networkAccessManager().get(request)
-            self.__downloading.finished[()].connect(self.__rulesDownloaded)
-            return
-        
         if response.isEmpty():
             E5MessageBox.warning(None,
                 self.trUtf8("Downloading subscription rules"),
--- a/Helpviewer/Network/FollowRedirectReply.py	Sun Jul 22 15:32:52 2012 +0200
+++ b/Helpviewer/Network/FollowRedirectReply.py	Mon Jul 23 19:21:44 2012 +0200
@@ -66,6 +66,14 @@
         """
         return self.__reply.error()
     
+    def errorString(self):
+        """
+        Public method to get the error message.
+        
+        @return error message (string)
+        """
+        return self.__reply.errorString()
+    
     def readAll(self):
         """
         Public method to read all received data.
@@ -74,6 +82,12 @@
         """
         return self.__reply.readAll()
     
+    def close(self):
+        """
+        Public method to close the data stream.
+        """
+        self.__reply.close()
+    
     def __replyFinished(self):
         """
         Private slot handling the receipt of the requested data.

eric ide

mercurial