13 import re |
13 import re |
14 import hashlib |
14 import hashlib |
15 import base64 |
15 import base64 |
16 |
16 |
17 from PyQt5.QtCore import pyqtSignal, Qt, QObject, QByteArray, QDateTime, \ |
17 from PyQt5.QtCore import pyqtSignal, Qt, QObject, QByteArray, QDateTime, \ |
18 QUrl, QCryptographicHash, QFile, QIODevice, QTextStream, QDate, QTime, \ |
18 QUrl, QCryptographicHash, QFile, QIODevice, QTextStream, QDate, QTime |
19 qVersion |
|
20 from PyQt5.QtNetwork import QNetworkReply |
19 from PyQt5.QtNetwork import QNetworkReply |
21 |
20 |
22 from E5Gui import E5MessageBox |
21 from E5Gui import E5MessageBox |
23 |
22 |
24 import Utilities |
23 import Utilities |
25 import Preferences |
24 import Preferences |
|
25 from Globals import qVersionTuple |
26 |
26 |
27 |
27 |
28 class AdBlockSubscription(QObject): |
28 class AdBlockSubscription(QObject): |
29 """ |
29 """ |
30 Class implementing the AdBlock subscription. |
30 Class implementing the AdBlock subscription. |
111 return |
111 return |
112 |
112 |
113 if url.path() != "subscribe": |
113 if url.path() != "subscribe": |
114 return |
114 return |
115 |
115 |
116 if qVersion() >= "5.0.0": |
116 if qVersionTuple() >= (5, 0, 0): |
117 from PyQt5.QtCore import QUrlQuery |
117 from PyQt5.QtCore import QUrlQuery |
118 urlQuery = QUrlQuery(url) |
118 urlQuery = QUrlQuery(url) |
119 self.__title = QUrl.fromPercentEncoding( |
119 self.__title = QUrl.fromPercentEncoding( |
120 QByteArray(urlQuery.queryItemValue("title").encode())) |
120 QByteArray(urlQuery.queryItemValue("title").encode())) |
121 self.__enabled = urlQuery.queryItemValue("enabled") != "false" |
121 self.__enabled = urlQuery.queryItemValue("enabled") != "false" |
183 if not self.__enabled: |
183 if not self.__enabled: |
184 queryItems.append(("enabled", "false")) |
184 queryItems.append(("enabled", "false")) |
185 if self.__lastUpdate.isValid(): |
185 if self.__lastUpdate.isValid(): |
186 queryItems.append(("lastUpdate", |
186 queryItems.append(("lastUpdate", |
187 self.__lastUpdate.toString(Qt.ISODate))) |
187 self.__lastUpdate.toString(Qt.ISODate))) |
188 if qVersion() >= "5.0.0": |
188 if qVersionTuple() >= (5, 0, 0): |
189 from PyQt5.QtCore import QUrlQuery |
189 from PyQt5.QtCore import QUrlQuery |
190 query = QUrlQuery() |
190 query = QUrlQuery() |
191 query.setQueryItems(queryItems) |
191 query.setQueryItems(queryItems) |
192 url.setQuery(query) |
192 url.setQuery(query) |
193 else: |
193 else: |