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