28 @signal rulesChanged() emitted after the subscription's rules have changed |
28 @signal rulesChanged() emitted after the subscription's rules have changed |
29 """ |
29 """ |
30 changed = pyqtSignal() |
30 changed = pyqtSignal() |
31 rulesChanged = pyqtSignal() |
31 rulesChanged = pyqtSignal() |
32 |
32 |
33 def __init__(self, url, parent = None): |
33 def __init__(self, url, parent = None, default = False): |
34 """ |
34 """ |
35 Constructor |
35 Constructor |
36 |
36 |
37 @param url AdBlock URL for the subscription (QUrl) |
37 @param url AdBlock URL for the subscription (QUrl) |
38 @param parent reference to the parent object (QObject) |
38 @param parent reference to the parent object (QObject) |
|
39 @param default flag indicating a default subscription (Boolean) |
39 """ |
40 """ |
40 QObject.__init__(self, parent) |
41 QObject.__init__(self, parent) |
41 |
42 |
42 self.__url = url.toEncoded() |
43 self.__url = url.toEncoded() |
43 self.__enabled = False |
44 self.__enabled = False |
44 self.__downloading = None |
45 self.__downloading = None |
|
46 self.__defaultSubscription = default |
45 |
47 |
46 self.__title = "" |
48 self.__title = "" |
47 self.__location = QByteArray() |
49 self.__location = QByteArray() |
48 self.__lastUpdate = QDateTime() |
50 self.__lastUpdate = QDateTime() |
49 |
51 |
259 redirect = reply.attribute(QNetworkRequest.RedirectionTargetAttribute) or QUrl() |
261 redirect = reply.attribute(QNetworkRequest.RedirectionTargetAttribute) or QUrl() |
260 reply.close() |
262 reply.close() |
261 self.__downloading = None |
263 self.__downloading = None |
262 |
264 |
263 if reply.error() != QNetworkReply.NoError: |
265 if reply.error() != QNetworkReply.NoError: |
264 E5MessageBox.warning(None, |
266 if not self.__defaultSubscription: |
265 self.trUtf8("Downloading subscription rules"), |
267 # don't show error if we try to load the default |
266 self.trUtf8("""<p>Subscription rules could not be downloaded.</p>""" |
268 E5MessageBox.warning(None, |
267 """<p>Error: {0}</p>""").format(reply.errorString())) |
269 self.trUtf8("Downloading subscription rules"), |
|
270 self.trUtf8("""<p>Subscription rules could not be downloaded.</p>""" |
|
271 """<p>Error: {0}</p>""").format(reply.errorString())) |
|
272 else: |
|
273 # reset after first download attempt |
|
274 self.__defaultSubscription = False |
268 return |
275 return |
269 |
276 |
270 if redirect.isValid(): |
277 if redirect.isValid(): |
271 request = QNetworkRequest(redirect) |
278 request = QNetworkRequest(redirect) |
272 self.__downloading = \ |
279 self.__downloading = \ |