eric6/WebBrowser/Network/NetworkManager.py

Sat, 27 Feb 2021 12:08:23 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 27 Feb 2021 12:08:23 +0100
changeset 8138
169e65a6787c
parent 7923
91e843545d9a
child 8043
0acf98cd089a
child 8143
2c730d5fd177
permissions
-rw-r--r--

Shell: added functionality to show a prompt when the main client process has exited (e.g. a script ended).

4725
b19ff70ba509 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
b19ff70ba509 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
7923
91e843545d9a Updated copyright for 2021.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7781
diff changeset
3 # Copyright (c) 2016 - 2021 Detlev Offenbach <detlev@die-offenbachs.de>
4725
b19ff70ba509 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
b19ff70ba509 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
b19ff70ba509 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
b19ff70ba509 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing a network manager class.
b19ff70ba509 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
b19ff70ba509 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
4817
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4786
diff changeset
10 import json
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4786
diff changeset
11
4858
19dff9c9cf26 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4857
diff changeset
12 from PyQt5.QtCore import pyqtSignal, QByteArray
7761
ed2c67d20328 Eliminated use of qApp in order to prepare for PyQt6 migration.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7759
diff changeset
13 from PyQt5.QtWidgets import QStyle, QDialog
7268
a28338eaf694 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
14 from PyQt5.QtNetwork import (
a28338eaf694 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
15 QNetworkAccessManager, QNetworkProxy, QNetworkProxyFactory, QNetworkRequest
a28338eaf694 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
16 )
4725
b19ff70ba509 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17
b19ff70ba509 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18 from E5Gui import E5MessageBox
7761
ed2c67d20328 Eliminated use of qApp in order to prepare for PyQt6 migration.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7759
diff changeset
19 from E5Gui.E5Application import e5App
4725
b19ff70ba509 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20
4743
f9e2e536d130 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
21 from E5Network.E5NetworkProxyFactory import proxyAuthenticationRequired
4786
b149def67c6e Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4766
diff changeset
22 try:
b149def67c6e Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4766
diff changeset
23 from E5Network.E5SslErrorHandler import E5SslErrorHandler
b149def67c6e Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4766
diff changeset
24 SSL_AVAILABLE = True
b149def67c6e Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4766
diff changeset
25 except ImportError:
b149def67c6e Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4766
diff changeset
26 SSL_AVAILABLE = False
4743
f9e2e536d130 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
27
4758
c973eef8fef1 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4754
diff changeset
28 from WebBrowser.WebBrowserWindow import WebBrowserWindow
4857
8dba5fb92f12 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4845
diff changeset
29 from .NetworkUrlInterceptor import NetworkUrlInterceptor
7717
f32d7965a17e Changed the code to not rely on the Qt Resource system anymore (no .qrc files and no use of pyrcc5 anymore).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7570
diff changeset
30 from ..Tools.WebBrowserTools import getHtmlPage, pixmapToDataUrl
4758
c973eef8fef1 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4754
diff changeset
31
4817
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4786
diff changeset
32 from Utilities.AutoSaver import AutoSaver
4743
f9e2e536d130 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
33 import Preferences
f9e2e536d130 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
34
4725
b19ff70ba509 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35
b19ff70ba509 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36 class NetworkManager(QNetworkAccessManager):
b19ff70ba509 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37 """
b19ff70ba509 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38 Class implementing a network manager.
4817
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4786
diff changeset
39
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4786
diff changeset
40 @signal changed() emitted to indicate a change
4725
b19ff70ba509 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41 """
4817
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4786
diff changeset
42 changed = pyqtSignal()
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4786
diff changeset
43
4875
4ee26909ac0d Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4858
diff changeset
44 def __init__(self, engine, parent=None):
4725
b19ff70ba509 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45 """
b19ff70ba509 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46 Constructor
b19ff70ba509 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47
4875
4ee26909ac0d Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4858
diff changeset
48 @param engine reference to the help engine (QHelpEngine)
4725
b19ff70ba509 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49 @param parent reference to the parent object (QObject)
b19ff70ba509 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50 """
b19ff70ba509 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51 super(NetworkManager, self).__init__(parent)
b19ff70ba509 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52
6625
a67fee7bc09c Web Browser: changed the web browser logic inside eric to use a remote controlled web browser process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6555
diff changeset
53 from E5Network.E5NetworkProxyFactory import E5NetworkProxyFactory
a67fee7bc09c Web Browser: changed the web browser logic inside eric to use a remote controlled web browser process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6555
diff changeset
54
a67fee7bc09c Web Browser: changed the web browser logic inside eric to use a remote controlled web browser process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6555
diff changeset
55 self.__proxyFactory = E5NetworkProxyFactory()
a67fee7bc09c Web Browser: changed the web browser logic inside eric to use a remote controlled web browser process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6555
diff changeset
56 if Preferences.getUI("UseSystemProxy"):
a67fee7bc09c Web Browser: changed the web browser logic inside eric to use a remote controlled web browser process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6555
diff changeset
57 QNetworkProxyFactory.setUseSystemConfiguration(True)
a67fee7bc09c Web Browser: changed the web browser logic inside eric to use a remote controlled web browser process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6555
diff changeset
58 else:
a67fee7bc09c Web Browser: changed the web browser logic inside eric to use a remote controlled web browser process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6555
diff changeset
59 QNetworkProxyFactory.setApplicationProxyFactory(
a67fee7bc09c Web Browser: changed the web browser logic inside eric to use a remote controlled web browser process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6555
diff changeset
60 self.__proxyFactory)
a67fee7bc09c Web Browser: changed the web browser logic inside eric to use a remote controlled web browser process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6555
diff changeset
61 QNetworkProxyFactory.setUseSystemConfiguration(False)
4758
c973eef8fef1 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4754
diff changeset
62
4754
1ff6d0ecb2fd Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4745
diff changeset
63 self.languagesChanged()
1ff6d0ecb2fd Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4745
diff changeset
64
4786
b149def67c6e Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4766
diff changeset
65 if SSL_AVAILABLE:
b149def67c6e Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4766
diff changeset
66 self.__sslErrorHandler = E5SslErrorHandler(self)
7570
a7a5750aded4 Web Browser: made the URL entry background configurable and harmonized certificate handling for the web page and its web icon (favicon).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7565
diff changeset
67 self.sslErrors.connect(self.__sslErrorHandlingSlot)
4725
b19ff70ba509 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
68
4817
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4786
diff changeset
69 self.__temporarilyIgnoredSslErrors = {}
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4786
diff changeset
70 self.__permanentlyIgnoredSslErrors = {}
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4786
diff changeset
71 # dictionaries of permanently and temporarily ignored SSL errors
4786
b149def67c6e Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4766
diff changeset
72
7565
928373562e36 Implemented a preliminary fix for issue 328 showing the user an indication, if he made an exception for a certificate issue of a host.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
73 self.__insecureHosts = set()
928373562e36 Implemented a preliminary fix for issue 328 showing the user an indication, if he made an exception for a certificate issue of a host.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
74
4817
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4786
diff changeset
75 self.__loaded = False
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4786
diff changeset
76 self.__saveTimer = AutoSaver(self, self.__save)
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4786
diff changeset
77
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4786
diff changeset
78 self.changed.connect(self.__saveTimer.changeOccurred)
4786
b149def67c6e Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4766
diff changeset
79 self.proxyAuthenticationRequired.connect(proxyAuthenticationRequired)
4743
f9e2e536d130 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
80 self.authenticationRequired.connect(
f9e2e536d130 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
81 lambda reply, auth: self.authentication(reply.url(), auth))
4825
b5fb58f3830b Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4820
diff changeset
82
4858
19dff9c9cf26 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4857
diff changeset
83 from .EricSchemeHandler import EricSchemeHandler
19dff9c9cf26 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4857
diff changeset
84 self.__ericSchemeHandler = EricSchemeHandler()
19dff9c9cf26 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4857
diff changeset
85 WebBrowserWindow.webProfile().installUrlSchemeHandler(
19dff9c9cf26 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4857
diff changeset
86 QByteArray(b"eric"), self.__ericSchemeHandler)
4825
b5fb58f3830b Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4820
diff changeset
87
4875
4ee26909ac0d Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4858
diff changeset
88 if engine:
4ee26909ac0d Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4858
diff changeset
89 from .QtHelpSchemeHandler import QtHelpSchemeHandler
4ee26909ac0d Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4858
diff changeset
90 self.__qtHelpSchemeHandler = QtHelpSchemeHandler(engine)
4ee26909ac0d Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4858
diff changeset
91 WebBrowserWindow.webProfile().installUrlSchemeHandler(
4ee26909ac0d Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4858
diff changeset
92 QByteArray(b"qthelp"), self.__qtHelpSchemeHandler)
4ee26909ac0d Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4858
diff changeset
93
4857
8dba5fb92f12 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4845
diff changeset
94 self.__interceptor = NetworkUrlInterceptor(self)
7356
d975331c5daa Web Browser:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7316
diff changeset
95 try:
d975331c5daa Web Browser:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7316
diff changeset
96 WebBrowserWindow.webProfile().setUrlRequestInterceptor(
d975331c5daa Web Browser:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7316
diff changeset
97 self.__interceptor)
d975331c5daa Web Browser:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7316
diff changeset
98 except AttributeError:
d975331c5daa Web Browser:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7316
diff changeset
99 # Qt < 5.13
d975331c5daa Web Browser:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7316
diff changeset
100 WebBrowserWindow.webProfile().setRequestInterceptor(
d975331c5daa Web Browser:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7316
diff changeset
101 self.__interceptor)
4825
b5fb58f3830b Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4820
diff changeset
102
4845
2d22ff71c005 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4827
diff changeset
103 WebBrowserWindow.cookieJar()
4725
b19ff70ba509 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
104
4817
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4786
diff changeset
105 def __save(self):
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4786
diff changeset
106 """
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4786
diff changeset
107 Private slot to save the permanent SSL error exceptions.
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4786
diff changeset
108 """
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4786
diff changeset
109 if not self.__loaded:
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4786
diff changeset
110 return
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4786
diff changeset
111
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4786
diff changeset
112 from WebBrowser.WebBrowserWindow import WebBrowserWindow
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4786
diff changeset
113 if not WebBrowserWindow.isPrivate():
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4786
diff changeset
114 dbString = json.dumps(self.__permanentlyIgnoredSslErrors)
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4786
diff changeset
115 Preferences.setWebBrowser("SslExceptionsDB", dbString)
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4786
diff changeset
116
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4786
diff changeset
117 def __load(self):
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4786
diff changeset
118 """
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4786
diff changeset
119 Private method to load the permanent SSL error exceptions.
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4786
diff changeset
120 """
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4786
diff changeset
121 if self.__loaded:
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4786
diff changeset
122 return
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4786
diff changeset
123
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4786
diff changeset
124 dbString = Preferences.getWebBrowser("SslExceptionsDB")
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4786
diff changeset
125 if dbString:
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4786
diff changeset
126 try:
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4786
diff changeset
127 db = json.loads(dbString)
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4786
diff changeset
128 self.__permanentlyIgnoredSslErrors = db
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4786
diff changeset
129 except ValueError:
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4786
diff changeset
130 # ignore silently
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4786
diff changeset
131 pass
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4786
diff changeset
132
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4786
diff changeset
133 self.__loaded = True
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4786
diff changeset
134
4820
f38e4fb83ecd Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4819
diff changeset
135 def shutdown(self):
f38e4fb83ecd Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4819
diff changeset
136 """
f38e4fb83ecd Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4819
diff changeset
137 Public method to shut down the network manager.
f38e4fb83ecd Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4819
diff changeset
138 """
f38e4fb83ecd Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4819
diff changeset
139 self.__saveTimer.saveIfNeccessary()
f38e4fb83ecd Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4819
diff changeset
140 self.__loaded = False
f38e4fb83ecd Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4819
diff changeset
141 self.__temporarilyIgnoredSslErrors = {}
f38e4fb83ecd Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4819
diff changeset
142 self.__permanentlyIgnoredSslErrors = {}
6708
80fee080d9fe UserInterface, WebBrowser.Network.NetworkManager: added some shutdown code to prevent crashes related to QNetworkProxyFactory on shutdown.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
143
80fee080d9fe UserInterface, WebBrowser.Network.NetworkManager: added some shutdown code to prevent crashes related to QNetworkProxyFactory on shutdown.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
144 # set proxy factory to None to avoid crashes
80fee080d9fe UserInterface, WebBrowser.Network.NetworkManager: added some shutdown code to prevent crashes related to QNetworkProxyFactory on shutdown.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
145 QNetworkProxyFactory.setApplicationProxyFactory(None)
4820
f38e4fb83ecd Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4819
diff changeset
146
4817
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4786
diff changeset
147 def showSslErrorExceptionsDialog(self):
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4786
diff changeset
148 """
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4786
diff changeset
149 Public method to show the SSL error exceptions dialog.
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4786
diff changeset
150 """
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4786
diff changeset
151 self.__load()
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4786
diff changeset
152
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4786
diff changeset
153 from .SslErrorExceptionsDialog import SslErrorExceptionsDialog
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4786
diff changeset
154 dlg = SslErrorExceptionsDialog(self.__permanentlyIgnoredSslErrors)
7759
51aa6c6b66f7 Changed calls to exec_() into exec() (remainder of Python2 elimination).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7717
diff changeset
155 if dlg.exec() == QDialog.Accepted:
4817
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4786
diff changeset
156 self.__permanentlyIgnoredSslErrors = dlg.getSslErrorExceptions()
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4786
diff changeset
157 self.changed.emit()
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4786
diff changeset
158
4819
cb0672f0fc15 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4817
diff changeset
159 def clearSslExceptions(self):
cb0672f0fc15 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4817
diff changeset
160 """
cb0672f0fc15 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4817
diff changeset
161 Public method to clear the permanent SSL certificate error exceptions.
cb0672f0fc15 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4817
diff changeset
162 """
cb0672f0fc15 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4817
diff changeset
163 self.__load()
cb0672f0fc15 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4817
diff changeset
164
cb0672f0fc15 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4817
diff changeset
165 self.__permanentlyIgnoredSslErrors = {}
cb0672f0fc15 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4817
diff changeset
166 self.changed.emit()
4820
f38e4fb83ecd Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4819
diff changeset
167 self.__saveTimer.saveIfNeccessary()
4819
cb0672f0fc15 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4817
diff changeset
168
4725
b19ff70ba509 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
169 def certificateError(self, error, view):
b19ff70ba509 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
170 """
4726
c26e2a2dc0cb Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4725
diff changeset
171 Public method to handle SSL certificate errors.
4725
b19ff70ba509 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
172
b19ff70ba509 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
173 @param error object containing the certificate error information
b19ff70ba509 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
174 @type QWebEngineCertificateError
b19ff70ba509 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
175 @param view reference to a view to be used as parent for the dialog
b19ff70ba509 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
176 @type QWidget
b19ff70ba509 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
177 @return flag indicating to ignore this error
b19ff70ba509 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
178 @rtype bool
b19ff70ba509 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
179 """
7570
a7a5750aded4 Web Browser: made the URL entry background configurable and harmonized certificate handling for the web page and its web icon (favicon).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7565
diff changeset
180 if Preferences.getWebBrowser("AlwaysRejectFaultyCertificates"):
a7a5750aded4 Web Browser: made the URL entry background configurable and harmonized certificate handling for the web page and its web icon (favicon).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7565
diff changeset
181 return False
a7a5750aded4 Web Browser: made the URL entry background configurable and harmonized certificate handling for the web page and its web icon (favicon).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7565
diff changeset
182
4817
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4786
diff changeset
183 self.__load()
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4786
diff changeset
184
4725
b19ff70ba509 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
185 host = error.url().host()
b19ff70ba509 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
186
7565
928373562e36 Implemented a preliminary fix for issue 328 showing the user an indication, if he made an exception for a certificate issue of a host.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
187 self.__insecureHosts.add(host)
928373562e36 Implemented a preliminary fix for issue 328 showing the user an indication, if he made an exception for a certificate issue of a host.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
188
7268
a28338eaf694 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
189 if (
a28338eaf694 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
190 host in self.__temporarilyIgnoredSslErrors and
a28338eaf694 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
191 error.error() in self.__temporarilyIgnoredSslErrors[host]
a28338eaf694 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
192 ):
4817
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4786
diff changeset
193 return True
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4786
diff changeset
194
7268
a28338eaf694 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
195 if (
a28338eaf694 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
196 host in self.__permanentlyIgnoredSslErrors and
a28338eaf694 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
197 error.error() in self.__permanentlyIgnoredSslErrors[host]
a28338eaf694 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
198 ):
4725
b19ff70ba509 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
199 return True
b19ff70ba509 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
200
b19ff70ba509 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
201 title = self.tr("SSL Certificate Error")
4817
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4786
diff changeset
202 msgBox = E5MessageBox.E5MessageBox(
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4786
diff changeset
203 E5MessageBox.Warning,
4725
b19ff70ba509 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
204 title,
b19ff70ba509 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
205 self.tr("""<b>{0}</b>"""
7570
a7a5750aded4 Web Browser: made the URL entry background configurable and harmonized certificate handling for the web page and its web icon (favicon).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7565
diff changeset
206 """<p>The host <b>{1}</b> you are trying to access has"""
a7a5750aded4 Web Browser: made the URL entry background configurable and harmonized certificate handling for the web page and its web icon (favicon).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7565
diff changeset
207 """ errors in the SSL certificate.</p>"""
a7a5750aded4 Web Browser: made the URL entry background configurable and harmonized certificate handling for the web page and its web icon (favicon).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7565
diff changeset
208 """<ul><li>{2}</li></ul>"""
4725
b19ff70ba509 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
209 """<p>Would you like to make an exception?</p>""")
7570
a7a5750aded4 Web Browser: made the URL entry background configurable and harmonized certificate handling for the web page and its web icon (favicon).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7565
diff changeset
210 .format(title, host, error.errorDescription()),
4817
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4786
diff changeset
211 modal=True, parent=view)
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4786
diff changeset
212 permButton = msgBox.addButton(self.tr("&Permanent accept"),
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4786
diff changeset
213 E5MessageBox.AcceptRole)
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4786
diff changeset
214 tempButton = msgBox.addButton(self.tr("&Temporary accept"),
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4786
diff changeset
215 E5MessageBox.AcceptRole)
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4786
diff changeset
216 msgBox.addButton(self.tr("&Reject"), E5MessageBox.RejectRole)
7759
51aa6c6b66f7 Changed calls to exec_() into exec() (remainder of Python2 elimination).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7717
diff changeset
217 msgBox.exec()
4817
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4786
diff changeset
218 if msgBox.clickedButton() == permButton:
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4786
diff changeset
219 if host not in self.__permanentlyIgnoredSslErrors:
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4786
diff changeset
220 self.__permanentlyIgnoredSslErrors[host] = []
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4786
diff changeset
221 self.__permanentlyIgnoredSslErrors[host].append(error.error())
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4786
diff changeset
222 self.changed.emit()
4725
b19ff70ba509 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
223 return True
4817
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4786
diff changeset
224 elif msgBox.clickedButton() == tempButton:
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4786
diff changeset
225 if host not in self.__temporarilyIgnoredSslErrors:
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4786
diff changeset
226 self.__temporarilyIgnoredSslErrors[host] = []
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4786
diff changeset
227 self.__temporarilyIgnoredSslErrors[host].append(error.error())
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4786
diff changeset
228 return True
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4786
diff changeset
229 else:
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4786
diff changeset
230 return False
4743
f9e2e536d130 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
231
7570
a7a5750aded4 Web Browser: made the URL entry background configurable and harmonized certificate handling for the web page and its web icon (favicon).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7565
diff changeset
232 def __sslErrorHandlingSlot(self, reply, errors):
a7a5750aded4 Web Browser: made the URL entry background configurable and harmonized certificate handling for the web page and its web icon (favicon).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7565
diff changeset
233 """
a7a5750aded4 Web Browser: made the URL entry background configurable and harmonized certificate handling for the web page and its web icon (favicon).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7565
diff changeset
234 Private slot to handle SSL errors for a network reply.
a7a5750aded4 Web Browser: made the URL entry background configurable and harmonized certificate handling for the web page and its web icon (favicon).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7565
diff changeset
235
a7a5750aded4 Web Browser: made the URL entry background configurable and harmonized certificate handling for the web page and its web icon (favicon).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7565
diff changeset
236 @param reply reference to the reply object
a7a5750aded4 Web Browser: made the URL entry background configurable and harmonized certificate handling for the web page and its web icon (favicon).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7565
diff changeset
237 @type QNetworkReply
a7a5750aded4 Web Browser: made the URL entry background configurable and harmonized certificate handling for the web page and its web icon (favicon).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7565
diff changeset
238 @param errors list of SSL errors
a7a5750aded4 Web Browser: made the URL entry background configurable and harmonized certificate handling for the web page and its web icon (favicon).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7565
diff changeset
239 @type list of QSslError
a7a5750aded4 Web Browser: made the URL entry background configurable and harmonized certificate handling for the web page and its web icon (favicon).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7565
diff changeset
240 """
a7a5750aded4 Web Browser: made the URL entry background configurable and harmonized certificate handling for the web page and its web icon (favicon).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7565
diff changeset
241 if Preferences.getWebBrowser("AlwaysRejectFaultyCertificates"):
a7a5750aded4 Web Browser: made the URL entry background configurable and harmonized certificate handling for the web page and its web icon (favicon).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7565
diff changeset
242 return
a7a5750aded4 Web Browser: made the URL entry background configurable and harmonized certificate handling for the web page and its web icon (favicon).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7565
diff changeset
243
a7a5750aded4 Web Browser: made the URL entry background configurable and harmonized certificate handling for the web page and its web icon (favicon).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7565
diff changeset
244 self.__load()
a7a5750aded4 Web Browser: made the URL entry background configurable and harmonized certificate handling for the web page and its web icon (favicon).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7565
diff changeset
245
a7a5750aded4 Web Browser: made the URL entry background configurable and harmonized certificate handling for the web page and its web icon (favicon).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7565
diff changeset
246 host = reply.url().host()
a7a5750aded4 Web Browser: made the URL entry background configurable and harmonized certificate handling for the web page and its web icon (favicon).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7565
diff changeset
247 if (
a7a5750aded4 Web Browser: made the URL entry background configurable and harmonized certificate handling for the web page and its web icon (favicon).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7565
diff changeset
248 host in self.__permanentlyIgnoredSslErrors or
a7a5750aded4 Web Browser: made the URL entry background configurable and harmonized certificate handling for the web page and its web icon (favicon).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7565
diff changeset
249 host in self.__temporarilyIgnoredSslErrors
a7a5750aded4 Web Browser: made the URL entry background configurable and harmonized certificate handling for the web page and its web icon (favicon).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7565
diff changeset
250 ):
a7a5750aded4 Web Browser: made the URL entry background configurable and harmonized certificate handling for the web page and its web icon (favicon).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7565
diff changeset
251 reply.ignoreSslErrors()
a7a5750aded4 Web Browser: made the URL entry background configurable and harmonized certificate handling for the web page and its web icon (favicon).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7565
diff changeset
252 else:
a7a5750aded4 Web Browser: made the URL entry background configurable and harmonized certificate handling for the web page and its web icon (favicon).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7565
diff changeset
253 self.__sslErrorHandler.sslErrorsReply(reply, errors)
a7a5750aded4 Web Browser: made the URL entry background configurable and harmonized certificate handling for the web page and its web icon (favicon).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7565
diff changeset
254
7565
928373562e36 Implemented a preliminary fix for issue 328 showing the user an indication, if he made an exception for a certificate issue of a host.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
255 def isInsecureHost(self, host):
928373562e36 Implemented a preliminary fix for issue 328 showing the user an indication, if he made an exception for a certificate issue of a host.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
256 """
928373562e36 Implemented a preliminary fix for issue 328 showing the user an indication, if he made an exception for a certificate issue of a host.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
257 Public method to check a host against the list of insecure hosts.
928373562e36 Implemented a preliminary fix for issue 328 showing the user an indication, if he made an exception for a certificate issue of a host.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
258
7570
a7a5750aded4 Web Browser: made the URL entry background configurable and harmonized certificate handling for the web page and its web icon (favicon).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7565
diff changeset
259 @param host name of the host to be checked
a7a5750aded4 Web Browser: made the URL entry background configurable and harmonized certificate handling for the web page and its web icon (favicon).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7565
diff changeset
260 @type str
7565
928373562e36 Implemented a preliminary fix for issue 328 showing the user an indication, if he made an exception for a certificate issue of a host.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
261 @return flag indicating an insecure host
928373562e36 Implemented a preliminary fix for issue 328 showing the user an indication, if he made an exception for a certificate issue of a host.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
262 @rtype bool
928373562e36 Implemented a preliminary fix for issue 328 showing the user an indication, if he made an exception for a certificate issue of a host.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
263 """
928373562e36 Implemented a preliminary fix for issue 328 showing the user an indication, if he made an exception for a certificate issue of a host.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
264 return host in self.__insecureHosts
928373562e36 Implemented a preliminary fix for issue 328 showing the user an indication, if he made an exception for a certificate issue of a host.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
265
6120
4c60a21ce6dd Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
266 def authentication(self, url, auth, page=None):
4743
f9e2e536d130 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
267 """
f9e2e536d130 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
268 Public slot to handle an authentication request.
f9e2e536d130 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
269
6120
4c60a21ce6dd Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
270 @param url URL requesting authentication
4c60a21ce6dd Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
271 @type QUrl
4c60a21ce6dd Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
272 @param auth reference to the authenticator object
4c60a21ce6dd Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
273 @type QAuthenticator
4c60a21ce6dd Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
274 @param page reference to the web page
4c60a21ce6dd Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
275 @type QWebEnginePage or None
4743
f9e2e536d130 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
276 """
7268
a28338eaf694 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
277 urlRoot = (
a28338eaf694 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
278 "{0}://{1}".format(url.scheme(), url.authority())
a28338eaf694 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
279 )
4743
f9e2e536d130 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
280 realm = auth.realm()
f9e2e536d130 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
281 if not realm and 'realm' in auth.options():
f9e2e536d130 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
282 realm = auth.option("realm")
f9e2e536d130 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
283 if realm:
7268
a28338eaf694 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
284 info = self.tr(
a28338eaf694 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
285 "<b>Enter username and password for '{0}', realm '{1}'</b>"
a28338eaf694 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
286 ).format(urlRoot, realm)
4743
f9e2e536d130 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
287 else:
7268
a28338eaf694 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
288 info = self.tr(
a28338eaf694 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
289 "<b>Enter username and password for '{0}'</b>"
a28338eaf694 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
290 ).format(urlRoot)
4743
f9e2e536d130 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
291
f9e2e536d130 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
292 from UI.AuthenticationDialog import AuthenticationDialog
4745
285bfd224a1b Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4743
diff changeset
293 import WebBrowser.WebBrowserWindow
4743
f9e2e536d130 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
294
f9e2e536d130 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
295 dlg = AuthenticationDialog(info, auth.user(),
f9e2e536d130 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
296 Preferences.getUser("SavePasswords"),
f9e2e536d130 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
297 Preferences.getUser("SavePasswords"))
4745
285bfd224a1b Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4743
diff changeset
298 if Preferences.getUser("SavePasswords"):
7268
a28338eaf694 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
299 username, password = (
a28338eaf694 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
300 WebBrowser.WebBrowserWindow.WebBrowserWindow
a28338eaf694 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
301 .passwordManager().getLogin(url, realm)
a28338eaf694 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
302 )
4745
285bfd224a1b Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4743
diff changeset
303 if username:
285bfd224a1b Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4743
diff changeset
304 dlg.setData(username, password)
7759
51aa6c6b66f7 Changed calls to exec_() into exec() (remainder of Python2 elimination).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7717
diff changeset
305 if dlg.exec() == QDialog.Accepted:
4743
f9e2e536d130 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
306 username, password = dlg.getData()
f9e2e536d130 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
307 auth.setUser(username)
f9e2e536d130 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
308 auth.setPassword(password)
5366
001edc0a0807 Fixed a little issue using the authentication dialog from the old and new web browsers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5365
diff changeset
309 if Preferences.getUser("SavePasswords") and dlg.shallSave():
7268
a28338eaf694 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
310 (
a28338eaf694 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
311 WebBrowser.WebBrowserWindow.WebBrowserWindow
a28338eaf694 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
312 .passwordManager().setLogin(
a28338eaf694 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
313 url, realm, username, password)
a28338eaf694 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
314 )
5365
f0cb73e99e54 Added an error page to be shown if an authentication request is cancelled.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4917
diff changeset
315 else:
6120
4c60a21ce6dd Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
316 if page is not None:
5365
f0cb73e99e54 Added an error page to be shown if an authentication request is cancelled.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4917
diff changeset
317 self.__showAuthenticationErrorPage(page, url)
f0cb73e99e54 Added an error page to be shown if an authentication request is cancelled.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4917
diff changeset
318
f0cb73e99e54 Added an error page to be shown if an authentication request is cancelled.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4917
diff changeset
319 def __showAuthenticationErrorPage(self, page, url):
f0cb73e99e54 Added an error page to be shown if an authentication request is cancelled.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4917
diff changeset
320 """
f0cb73e99e54 Added an error page to be shown if an authentication request is cancelled.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4917
diff changeset
321 Private method to show an authentication error page.
f0cb73e99e54 Added an error page to be shown if an authentication request is cancelled.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4917
diff changeset
322
f0cb73e99e54 Added an error page to be shown if an authentication request is cancelled.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4917
diff changeset
323 @param page reference to the page
f0cb73e99e54 Added an error page to be shown if an authentication request is cancelled.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4917
diff changeset
324 @type QWebEnginePage
f0cb73e99e54 Added an error page to be shown if an authentication request is cancelled.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4917
diff changeset
325 @param url reference to the URL requesting authentication
f0cb73e99e54 Added an error page to be shown if an authentication request is cancelled.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4917
diff changeset
326 @type QUrl
f0cb73e99e54 Added an error page to be shown if an authentication request is cancelled.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4917
diff changeset
327 """
7717
f32d7965a17e Changed the code to not rely on the Qt Resource system anymore (no .qrc files and no use of pyrcc5 anymore).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7570
diff changeset
328 html = getHtmlPage("authenticationErrorPage.html")
5365
f0cb73e99e54 Added an error page to be shown if an authentication request is cancelled.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4917
diff changeset
329 html = html.replace("@IMAGE@", pixmapToDataUrl(
7761
ed2c67d20328 Eliminated use of qApp in order to prepare for PyQt6 migration.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7759
diff changeset
330 e5App().style().standardIcon(QStyle.SP_MessageBoxCritical).pixmap(
5365
f0cb73e99e54 Added an error page to be shown if an authentication request is cancelled.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4917
diff changeset
331 48, 48)).toString())
f0cb73e99e54 Added an error page to be shown if an authentication request is cancelled.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4917
diff changeset
332 html = html.replace("@FAVICON@", pixmapToDataUrl(
7761
ed2c67d20328 Eliminated use of qApp in order to prepare for PyQt6 migration.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7759
diff changeset
333 e5App().style() .standardIcon(QStyle.SP_MessageBoxCritical).pixmap(
5365
f0cb73e99e54 Added an error page to be shown if an authentication request is cancelled.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4917
diff changeset
334 16, 16)).toString())
f0cb73e99e54 Added an error page to be shown if an authentication request is cancelled.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4917
diff changeset
335 html = html.replace("@TITLE@", self.tr("Authentication required"))
f0cb73e99e54 Added an error page to be shown if an authentication request is cancelled.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4917
diff changeset
336 html = html.replace("@H1@", self.tr("Authentication required"))
f0cb73e99e54 Added an error page to be shown if an authentication request is cancelled.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4917
diff changeset
337 html = html.replace(
f0cb73e99e54 Added an error page to be shown if an authentication request is cancelled.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4917
diff changeset
338 "@LI-1@",
f0cb73e99e54 Added an error page to be shown if an authentication request is cancelled.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4917
diff changeset
339 self.tr("Authentication is required to access:"))
f0cb73e99e54 Added an error page to be shown if an authentication request is cancelled.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4917
diff changeset
340 html = html.replace(
f0cb73e99e54 Added an error page to be shown if an authentication request is cancelled.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4917
diff changeset
341 "@LI-2@",
f0cb73e99e54 Added an error page to be shown if an authentication request is cancelled.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4917
diff changeset
342 '<a href="{0}">{0}</a>'.format(url.toString()))
f0cb73e99e54 Added an error page to be shown if an authentication request is cancelled.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4917
diff changeset
343 page.setHtml(html, url)
4743
f9e2e536d130 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
344
4786
b149def67c6e Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4766
diff changeset
345 def proxyAuthentication(self, requestUrl, auth, proxyHost):
4743
f9e2e536d130 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
346 """
f9e2e536d130 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
347 Public slot to handle a proxy authentication request.
f9e2e536d130 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
348
4786
b149def67c6e Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4766
diff changeset
349 @param requestUrl requested URL
b149def67c6e Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4766
diff changeset
350 @type QUrl
b149def67c6e Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4766
diff changeset
351 @param auth reference to the authenticator object
b149def67c6e Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4766
diff changeset
352 @type QAuthenticator
4917
682750cc7bd5 Corrected some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4902
diff changeset
353 @param proxyHost name of the proxy host
4743
f9e2e536d130 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
354 @type str
f9e2e536d130 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
355 """
f9e2e536d130 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
356 proxy = QNetworkProxy.applicationProxy()
f9e2e536d130 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
357 if proxy.user() and proxy.password():
f9e2e536d130 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
358 auth.setUser(proxy.user())
f9e2e536d130 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
359 auth.setPassword(proxy.password())
f9e2e536d130 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
360 return
f9e2e536d130 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
361
f9e2e536d130 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
362 proxyAuthenticationRequired(proxy, auth)
4754
1ff6d0ecb2fd Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4745
diff changeset
363
1ff6d0ecb2fd Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4745
diff changeset
364 def languagesChanged(self):
1ff6d0ecb2fd Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4745
diff changeset
365 """
1ff6d0ecb2fd Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4745
diff changeset
366 Public slot to (re-)load the list of accepted languages.
1ff6d0ecb2fd Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4745
diff changeset
367 """
7268
a28338eaf694 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
368 from WebBrowser.WebBrowserLanguagesDialog import (
4754
1ff6d0ecb2fd Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4745
diff changeset
369 WebBrowserLanguagesDialog
7268
a28338eaf694 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
370 )
4754
1ff6d0ecb2fd Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4745
diff changeset
371 languages = Preferences.toList(
1ff6d0ecb2fd Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4745
diff changeset
372 Preferences.Prefs.settings.value(
1ff6d0ecb2fd Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4745
diff changeset
373 "WebBrowser/AcceptLanguages",
1ff6d0ecb2fd Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4745
diff changeset
374 WebBrowserLanguagesDialog.defaultAcceptLanguages()))
1ff6d0ecb2fd Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4745
diff changeset
375 self.__acceptLanguage = WebBrowserLanguagesDialog.httpString(languages)
1ff6d0ecb2fd Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4745
diff changeset
376
4858
19dff9c9cf26 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4857
diff changeset
377 WebBrowserWindow.webProfile().setHttpAcceptLanguage(
19dff9c9cf26 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4857
diff changeset
378 self.__acceptLanguage)
4766
5f8d08aa2217 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4758
diff changeset
379
5f8d08aa2217 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4758
diff changeset
380 def installUrlInterceptor(self, interceptor):
4825
b5fb58f3830b Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4820
diff changeset
381 """
b5fb58f3830b Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4820
diff changeset
382 Public method to install an URL interceptor.
b5fb58f3830b Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4820
diff changeset
383
b5fb58f3830b Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4820
diff changeset
384 @param interceptor URL interceptor to be installed
b5fb58f3830b Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4820
diff changeset
385 @type UrlInterceptor
b5fb58f3830b Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4820
diff changeset
386 """
4858
19dff9c9cf26 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4857
diff changeset
387 self.__interceptor.installUrlInterceptor(interceptor)
4766
5f8d08aa2217 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4758
diff changeset
388
5f8d08aa2217 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4758
diff changeset
389 def removeUrlInterceptor(self, interceptor):
4825
b5fb58f3830b Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4820
diff changeset
390 """
b5fb58f3830b Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4820
diff changeset
391 Public method to remove an URL interceptor.
b5fb58f3830b Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4820
diff changeset
392
b5fb58f3830b Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4820
diff changeset
393 @param interceptor URL interceptor to be removed
b5fb58f3830b Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4820
diff changeset
394 @type UrlInterceptor
b5fb58f3830b Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4820
diff changeset
395 """
4858
19dff9c9cf26 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4857
diff changeset
396 self.__interceptor.removeUrlInterceptor(interceptor)
4825
b5fb58f3830b Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4820
diff changeset
397
b5fb58f3830b Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4820
diff changeset
398 def preferencesChanged(self):
b5fb58f3830b Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4820
diff changeset
399 """
b5fb58f3830b Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4820
diff changeset
400 Public slot to handle a change of preferences.
b5fb58f3830b Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4820
diff changeset
401 """
4858
19dff9c9cf26 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4857
diff changeset
402 self.__interceptor.preferencesChanged()
5720
fc72c0c81a0f Fixed using the system proxy configuration in the web browser NG.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
403
6625
a67fee7bc09c Web Browser: changed the web browser logic inside eric to use a remote controlled web browser process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6555
diff changeset
404 if Preferences.getUI("UseSystemProxy"):
a67fee7bc09c Web Browser: changed the web browser logic inside eric to use a remote controlled web browser process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6555
diff changeset
405 QNetworkProxyFactory.setUseSystemConfiguration(True)
a67fee7bc09c Web Browser: changed the web browser logic inside eric to use a remote controlled web browser process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6555
diff changeset
406 else:
a67fee7bc09c Web Browser: changed the web browser logic inside eric to use a remote controlled web browser process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6555
diff changeset
407 QNetworkProxyFactory.setApplicationProxyFactory(
a67fee7bc09c Web Browser: changed the web browser logic inside eric to use a remote controlled web browser process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6555
diff changeset
408 self.__proxyFactory)
a67fee7bc09c Web Browser: changed the web browser logic inside eric to use a remote controlled web browser process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6555
diff changeset
409 QNetworkProxyFactory.setUseSystemConfiguration(False)
4902
7a49807e493c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4886
diff changeset
410
7a49807e493c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4886
diff changeset
411 def createRequest(self, op, request, data):
7a49807e493c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4886
diff changeset
412 """
7a49807e493c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4886
diff changeset
413 Public method to launch a network action.
7a49807e493c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4886
diff changeset
414
7a49807e493c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4886
diff changeset
415 @param op operation to be performed
7a49807e493c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4886
diff changeset
416 @type QNetworkAccessManager.Operation
7a49807e493c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4886
diff changeset
417 @param request request to be operated on
7a49807e493c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4886
diff changeset
418 @type QNetworkRequest
7a49807e493c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4886
diff changeset
419 @param data reference to the data to be sent
7a49807e493c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4886
diff changeset
420 @type QIODevice
7a49807e493c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4886
diff changeset
421 @return reference to the network reply
7a49807e493c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4886
diff changeset
422 @rtype QNetworkReply
7a49807e493c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4886
diff changeset
423 """
7a49807e493c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4886
diff changeset
424 req = QNetworkRequest(request)
7a49807e493c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4886
diff changeset
425 req.setAttribute(QNetworkRequest.SpdyAllowedAttribute, True)
7a49807e493c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4886
diff changeset
426 req.setAttribute(QNetworkRequest.FollowRedirectsAttribute, True)
7a49807e493c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4886
diff changeset
427
7a49807e493c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4886
diff changeset
428 return super(NetworkManager, self).createRequest(op, req, data)

eric ide

mercurial