5 |
5 |
6 """ |
6 """ |
7 Module implementing a network manager class. |
7 Module implementing a network manager class. |
8 """ |
8 """ |
9 |
9 |
10 |
|
11 import json |
10 import json |
12 |
11 |
13 from PyQt5.QtCore import pyqtSignal, QByteArray |
12 from PyQt5.QtCore import pyqtSignal, QByteArray |
14 from PyQt5.QtWidgets import qApp, QStyle, QDialog |
13 from PyQt5.QtWidgets import QStyle, QDialog |
15 from PyQt5.QtNetwork import ( |
14 from PyQt5.QtNetwork import ( |
16 QNetworkAccessManager, QNetworkProxy, QNetworkProxyFactory, QNetworkRequest |
15 QNetworkAccessManager, QNetworkProxy, QNetworkProxyFactory, QNetworkRequest |
17 ) |
16 ) |
18 |
17 |
19 from E5Gui import E5MessageBox |
18 from E5Gui import E5MessageBox |
|
19 from E5Gui.E5Application import e5App |
20 |
20 |
21 from E5Network.E5NetworkProxyFactory import proxyAuthenticationRequired |
21 from E5Network.E5NetworkProxyFactory import proxyAuthenticationRequired |
22 try: |
22 try: |
23 from E5Network.E5SslErrorHandler import E5SslErrorHandler |
23 from E5Network.E5SslErrorHandler import E5SslErrorHandler |
24 SSL_AVAILABLE = True |
24 SSL_AVAILABLE = True |
150 """ |
150 """ |
151 self.__load() |
151 self.__load() |
152 |
152 |
153 from .SslErrorExceptionsDialog import SslErrorExceptionsDialog |
153 from .SslErrorExceptionsDialog import SslErrorExceptionsDialog |
154 dlg = SslErrorExceptionsDialog(self.__permanentlyIgnoredSslErrors) |
154 dlg = SslErrorExceptionsDialog(self.__permanentlyIgnoredSslErrors) |
155 if dlg.exec_() == QDialog.Accepted: |
155 if dlg.exec() == QDialog.Accepted: |
156 self.__permanentlyIgnoredSslErrors = dlg.getSslErrorExceptions() |
156 self.__permanentlyIgnoredSslErrors = dlg.getSslErrorExceptions() |
157 self.changed.emit() |
157 self.changed.emit() |
158 |
158 |
159 def clearSslExceptions(self): |
159 def clearSslExceptions(self): |
160 """ |
160 """ |
212 permButton = msgBox.addButton(self.tr("&Permanent accept"), |
212 permButton = msgBox.addButton(self.tr("&Permanent accept"), |
213 E5MessageBox.AcceptRole) |
213 E5MessageBox.AcceptRole) |
214 tempButton = msgBox.addButton(self.tr("&Temporary accept"), |
214 tempButton = msgBox.addButton(self.tr("&Temporary accept"), |
215 E5MessageBox.AcceptRole) |
215 E5MessageBox.AcceptRole) |
216 msgBox.addButton(self.tr("&Reject"), E5MessageBox.RejectRole) |
216 msgBox.addButton(self.tr("&Reject"), E5MessageBox.RejectRole) |
217 msgBox.exec_() |
217 msgBox.exec() |
218 if msgBox.clickedButton() == permButton: |
218 if msgBox.clickedButton() == permButton: |
219 if host not in self.__permanentlyIgnoredSslErrors: |
219 if host not in self.__permanentlyIgnoredSslErrors: |
220 self.__permanentlyIgnoredSslErrors[host] = [] |
220 self.__permanentlyIgnoredSslErrors[host] = [] |
221 self.__permanentlyIgnoredSslErrors[host].append(error.error()) |
221 self.__permanentlyIgnoredSslErrors[host].append(error.error()) |
222 self.changed.emit() |
222 self.changed.emit() |
300 WebBrowser.WebBrowserWindow.WebBrowserWindow |
300 WebBrowser.WebBrowserWindow.WebBrowserWindow |
301 .passwordManager().getLogin(url, realm) |
301 .passwordManager().getLogin(url, realm) |
302 ) |
302 ) |
303 if username: |
303 if username: |
304 dlg.setData(username, password) |
304 dlg.setData(username, password) |
305 if dlg.exec_() == QDialog.Accepted: |
305 if dlg.exec() == QDialog.Accepted: |
306 username, password = dlg.getData() |
306 username, password = dlg.getData() |
307 auth.setUser(username) |
307 auth.setUser(username) |
308 auth.setPassword(password) |
308 auth.setPassword(password) |
309 if Preferences.getUser("SavePasswords") and dlg.shallSave(): |
309 if Preferences.getUser("SavePasswords") and dlg.shallSave(): |
310 ( |
310 ( |
325 @param url reference to the URL requesting authentication |
325 @param url reference to the URL requesting authentication |
326 @type QUrl |
326 @type QUrl |
327 """ |
327 """ |
328 html = getHtmlPage("authenticationErrorPage.html") |
328 html = getHtmlPage("authenticationErrorPage.html") |
329 html = html.replace("@IMAGE@", pixmapToDataUrl( |
329 html = html.replace("@IMAGE@", pixmapToDataUrl( |
330 qApp.style().standardIcon(QStyle.SP_MessageBoxCritical).pixmap( |
330 e5App().style().standardIcon(QStyle.SP_MessageBoxCritical).pixmap( |
331 48, 48)).toString()) |
331 48, 48)).toString()) |
332 html = html.replace("@FAVICON@", pixmapToDataUrl( |
332 html = html.replace("@FAVICON@", pixmapToDataUrl( |
333 qApp.style() .standardIcon(QStyle.SP_MessageBoxCritical).pixmap( |
333 e5App().style() .standardIcon(QStyle.SP_MessageBoxCritical).pixmap( |
334 16, 16)).toString()) |
334 16, 16)).toString()) |
335 html = html.replace("@TITLE@", self.tr("Authentication required")) |
335 html = html.replace("@TITLE@", self.tr("Authentication required")) |
336 html = html.replace("@H1@", self.tr("Authentication required")) |
336 html = html.replace("@H1@", self.tr("Authentication required")) |
337 html = html.replace( |
337 html = html.replace( |
338 "@LI-1@", |
338 "@LI-1@", |