eric6/WebBrowser/SafeBrowsing/SafeBrowsingDialog.py

Wed, 30 Dec 2020 11:00:44 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Wed, 30 Dec 2020 11:00:44 +0100
branch
maintenance
changeset 7924
8a96736d465e
parent 7781
607a6098cb44
child 8143
2c730d5fd177
permissions
-rw-r--r--

Updated copyright for 2021.

5820
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
7924
8a96736d465e Updated copyright for 2021.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7781
diff changeset
3 # Copyright (c) 2017 - 2021 Detlev Offenbach <detlev@die-offenbachs.de>
5820
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing a dialog to configure safe browsing support.
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
5839
fe4d62e23908 Added an auto-update feature to the safe browsing manager of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5829
diff changeset
10 from PyQt5.QtCore import pyqtSlot, Qt, QUrl, QDateTime
7269
0c63ea7f94bd Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
11 from PyQt5.QtWidgets import (
7771
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7533
diff changeset
12 QDialog, QDialogButtonBox, QAbstractButton
7269
0c63ea7f94bd Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
13 )
5820
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15 from E5Gui import E5MessageBox
7771
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7533
diff changeset
16 from E5Gui.E5OverrideCursor import E5OverrideCursor
5820
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18 from .Ui_SafeBrowsingDialog import Ui_SafeBrowsingDialog
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20 import UI.PixmapCache
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21 import Preferences
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24 class SafeBrowsingDialog(QDialog, Ui_SafeBrowsingDialog):
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25 """
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 Class implementing a dialog to configure safe browsing support.
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 """
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28 def __init__(self, manager, parent=None):
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29 """
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 Constructor
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32 @param manager reference to the safe browsing manager
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33 @type SafeBrowsingManager
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34 @param parent reference to the parent widget
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35 @type QWidget
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36 """
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37 super(SafeBrowsingDialog, self).__init__(parent)
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38 self.setupUi(self)
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39 self.setWindowFlags(Qt.Window)
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41 self.__manager = manager
5821
6c7766cde4c1 Added a progress bar to the management part and fine tuned the hash prefix update process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5820
diff changeset
42 self.__manager.progressMessage.connect(self.__setProgressMessage)
6c7766cde4c1 Added a progress bar to the management part and fine tuned the hash prefix update process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5820
diff changeset
43 self.__manager.progress.connect(self.__setProgress)
5820
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45 self.iconLabel.setPixmap(
7533
88261c96484b Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
46 UI.PixmapCache.getPixmap("safeBrowsing48"))
5820
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48 self.__gsbHelpDialog = None
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50 self.__enabled = Preferences.getWebBrowser("SafeBrowsingEnabled")
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51 self.__apiKey = Preferences.getWebBrowser("SafeBrowsingApiKey")
5829
d3448873ced3 Finished coding the safe browsing module of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5821
diff changeset
52 self.__filterPlatform = Preferences.getWebBrowser(
d3448873ced3 Finished coding the safe browsing module of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5821
diff changeset
53 "SafeBrowsingFilterPlatform")
5839
fe4d62e23908 Added an auto-update feature to the safe browsing manager of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5829
diff changeset
54 self.__automaticUpdate = Preferences.getWebBrowser(
fe4d62e23908 Added an auto-update feature to the safe browsing manager of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5829
diff changeset
55 "SafeBrowsingAutoUpdate")
6233
a64b986abb54 Web Browser (NG), Safe Browsing: added support for the Google Safe Browsing Lookup API (v4)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6230
diff changeset
56 self.__useLookupApi = Preferences.getWebBrowser(
a64b986abb54 Web Browser (NG), Safe Browsing: added support for the Google Safe Browsing Lookup API (v4)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6230
diff changeset
57 "SafeBrowsingUseLookupApi")
5820
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
59 self.buttonBox.setFocus()
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
60
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
61 msh = self.minimumSizeHint()
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
62 self.resize(max(self.width(), msh.width()), msh.height())
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
63
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
64 def show(self):
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
65 """
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
66 Public slot to show the dialog.
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
67 """
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
68 self.gsbGroupBox.setChecked(self.__enabled)
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
69 self.gsbApiKeyEdit.setText(self.__apiKey)
5829
d3448873ced3 Finished coding the safe browsing module of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5821
diff changeset
70 self.gsbFilterPlatformCheckBox.setChecked(self.__filterPlatform)
5839
fe4d62e23908 Added an auto-update feature to the safe browsing manager of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5829
diff changeset
71 self.gsbAutoUpdateCheckBox.setChecked(self.__automaticUpdate)
6233
a64b986abb54 Web Browser (NG), Safe Browsing: added support for the Google Safe Browsing Lookup API (v4)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6230
diff changeset
72 self.gsbLookupCheckBox.setChecked(self.__useLookupApi)
5820
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
73
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
74 self.__updateCacheButtons()
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
75
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
76 super(SafeBrowsingDialog, self).show()
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
77
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
78 @pyqtSlot()
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
79 def on_gsbHelpButton_clicked(self):
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
80 """
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
81 Private slot to show some help text "How to create a safe
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
82 browsing API key.".
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
83 """
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
84 if self.__gsbHelpDialog is None:
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
85 from E5Gui.E5SimpleHelpDialog import E5SimpleHelpDialog
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
86 from . import SafeBrowsingHelp
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
87
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
88 helpStr = SafeBrowsingHelp()
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
89 self.__gsbHelpDialog = E5SimpleHelpDialog(
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
90 title=self.tr("Google Safe Browsing API Help"),
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
91 helpStr=helpStr, parent=self)
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
92
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
93 self.__gsbHelpDialog.show()
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
94
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
95 @pyqtSlot(QAbstractButton)
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
96 def on_buttonBox_clicked(self, button):
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
97 """
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
98 Private slot called by a button of the button box clicked.
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
99
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
100 @param button button that was clicked (QAbstractButton)
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
101 """
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
102 if button == self.buttonBox.button(QDialogButtonBox.Close):
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
103 self.close()
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
104
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
105 @pyqtSlot()
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
106 def __save(self):
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
107 """
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
108 Private slot to save the configuration.
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
109
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
110 @return flag indicating success
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
111 @rtype bool
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
112 """
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
113 self.__enabled = self.gsbGroupBox.isChecked()
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
114 self.__apiKey = self.gsbApiKeyEdit.text()
5829
d3448873ced3 Finished coding the safe browsing module of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5821
diff changeset
115 self.__filterPlatform = self.gsbFilterPlatformCheckBox.isChecked()
5839
fe4d62e23908 Added an auto-update feature to the safe browsing manager of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5829
diff changeset
116 self.__automaticUpdate = self.gsbAutoUpdateCheckBox.isChecked()
6233
a64b986abb54 Web Browser (NG), Safe Browsing: added support for the Google Safe Browsing Lookup API (v4)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6230
diff changeset
117 self.__useLookupApi = self.gsbLookupCheckBox.isChecked()
5820
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
118
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
119 Preferences.setWebBrowser("SafeBrowsingEnabled", self.__enabled)
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
120 Preferences.setWebBrowser("SafeBrowsingApiKey", self.__apiKey)
5829
d3448873ced3 Finished coding the safe browsing module of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5821
diff changeset
121 Preferences.setWebBrowser("SafeBrowsingFilterPlatform",
d3448873ced3 Finished coding the safe browsing module of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5821
diff changeset
122 self.__filterPlatform)
5839
fe4d62e23908 Added an auto-update feature to the safe browsing manager of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5829
diff changeset
123 Preferences.setWebBrowser("SafeBrowsingAutoUpdate",
fe4d62e23908 Added an auto-update feature to the safe browsing manager of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5829
diff changeset
124 self.__automaticUpdate)
6233
a64b986abb54 Web Browser (NG), Safe Browsing: added support for the Google Safe Browsing Lookup API (v4)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6230
diff changeset
125 Preferences.setWebBrowser("SafeBrowsingUseLookupApi",
a64b986abb54 Web Browser (NG), Safe Browsing: added support for the Google Safe Browsing Lookup API (v4)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6230
diff changeset
126 self.__useLookupApi)
5820
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
127
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
128 self.__manager.configurationChanged()
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
129
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
130 self.__updateCacheButtons()
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
131
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
132 return True
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
133
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
134 def closeEvent(self, evt):
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
135 """
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
136 Protected method to handle close events.
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
137
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
138 @param evt reference to the close event
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
139 @type QCloseEvent
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
140 """
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
141 if self.__okToClose():
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
142 evt.accept()
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
143 else:
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
144 evt.ignore()
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
145
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
146 def __isModified(self):
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
147 """
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
148 Private method to check, if the dialog contains modified data.
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
149
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
150 @return flag indicating the presence of modified data
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
151 @rtype bool
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
152 """
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
153 return (
5839
fe4d62e23908 Added an auto-update feature to the safe browsing manager of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5829
diff changeset
154 (self.__enabled != self.gsbGroupBox.isChecked()) or
fe4d62e23908 Added an auto-update feature to the safe browsing manager of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5829
diff changeset
155 (self.__apiKey != self.gsbApiKeyEdit.text()) or
fe4d62e23908 Added an auto-update feature to the safe browsing manager of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5829
diff changeset
156 (self.__filterPlatform !=
fe4d62e23908 Added an auto-update feature to the safe browsing manager of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5829
diff changeset
157 self.gsbFilterPlatformCheckBox.isChecked()) or
6233
a64b986abb54 Web Browser (NG), Safe Browsing: added support for the Google Safe Browsing Lookup API (v4)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6230
diff changeset
158 (self.__automaticUpdate !=
a64b986abb54 Web Browser (NG), Safe Browsing: added support for the Google Safe Browsing Lookup API (v4)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6230
diff changeset
159 self.gsbAutoUpdateCheckBox.isChecked()) or
a64b986abb54 Web Browser (NG), Safe Browsing: added support for the Google Safe Browsing Lookup API (v4)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6230
diff changeset
160 (self.__useLookupApi != self.gsbLookupCheckBox.isChecked())
5820
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
161 )
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
162
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
163 def __okToClose(self):
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
164 """
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
165 Private method to check, if it is safe to close the dialog.
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
166
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
167 @return flag indicating safe to close
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
168 @rtype bool
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
169 """
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
170 if self.__isModified():
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
171 res = E5MessageBox.okToClearData(
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
172 self,
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
173 self.tr("Safe Browsing Management"),
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
174 self.tr("""The dialog contains unsaved changes."""),
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
175 self.__save)
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
176 if not res:
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
177 return False
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
178 return True
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
179
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
180 def __updateCacheButtons(self):
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
181 """
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
182 Private method to set enabled state of the cache buttons.
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
183 """
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
184 enable = self.__enabled and bool(self.__apiKey)
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
185
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
186 self.updateCacheButton.setEnabled(enable)
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
187 self.clearCacheButton.setEnabled(enable)
5839
fe4d62e23908 Added an auto-update feature to the safe browsing manager of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5829
diff changeset
188
fe4d62e23908 Added an auto-update feature to the safe browsing manager of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5829
diff changeset
189 self.showUpdateTimeButton.setEnabled(enable and self.__automaticUpdate)
5820
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
190
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
191 @pyqtSlot()
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
192 def on_updateCacheButton_clicked(self):
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
193 """
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
194 Private slot to update the local cache database.
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
195 """
5829
d3448873ced3 Finished coding the safe browsing module of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5821
diff changeset
196 E5MessageBox.information(
d3448873ced3 Finished coding the safe browsing module of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5821
diff changeset
197 self,
d3448873ced3 Finished coding the safe browsing module of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5821
diff changeset
198 self.tr("Update Safe Browsing Cache"),
d3448873ced3 Finished coding the safe browsing module of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5821
diff changeset
199 self.tr("""Updating the Safe Browsing cache might be a lengthy"""
d3448873ced3 Finished coding the safe browsing module of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5821
diff changeset
200 """ operation. Please be patient!"""))
d3448873ced3 Finished coding the safe browsing module of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5821
diff changeset
201
7771
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7533
diff changeset
202 with E5OverrideCursor():
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7533
diff changeset
203 ok, error = self.__manager.updateHashPrefixCache()
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7533
diff changeset
204 self.__resetProgress()
5820
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
205 if not ok:
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
206 if error:
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
207 E5MessageBox.critical(
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
208 self,
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
209 self.tr("Update Safe Browsing Cache"),
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
210 self.tr("""<p>Updating the Safe Browsing cache failed."""
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
211 """</p><p>Reason: {0}</p>""").format(error))
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
212 else:
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
213 E5MessageBox.critical(
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
214 self,
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
215 self.tr("Update Safe Browsing Cache"),
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
216 self.tr("""<p>Updating the Safe Browsing cache failed."""
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
217 """</p>"""))
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
218
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
219 @pyqtSlot()
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
220 def on_clearCacheButton_clicked(self):
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
221 """
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
222 Private slot to clear the local cache database.
b610cb5b501a Started implementing the safe browsing manager and management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
223 """
5829
d3448873ced3 Finished coding the safe browsing module of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5821
diff changeset
224 res = E5MessageBox.yesNo(
d3448873ced3 Finished coding the safe browsing module of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5821
diff changeset
225 self,
d3448873ced3 Finished coding the safe browsing module of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5821
diff changeset
226 self.tr("Clear Safe Browsing Cache"),
d3448873ced3 Finished coding the safe browsing module of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5821
diff changeset
227 self.tr("""Do you really want to clear the Safe Browsing cache?"""
d3448873ced3 Finished coding the safe browsing module of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5821
diff changeset
228 """ Re-populating it might take some time."""))
d3448873ced3 Finished coding the safe browsing module of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5821
diff changeset
229 if res:
7771
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7533
diff changeset
230 with E5OverrideCursor():
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7533
diff changeset
231 self.__manager.fullCacheCleanup()
5821
6c7766cde4c1 Added a progress bar to the management part and fine tuned the hash prefix update process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5820
diff changeset
232
6c7766cde4c1 Added a progress bar to the management part and fine tuned the hash prefix update process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5820
diff changeset
233 @pyqtSlot(str, int)
6c7766cde4c1 Added a progress bar to the management part and fine tuned the hash prefix update process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5820
diff changeset
234 def __setProgressMessage(self, message, maximum):
6c7766cde4c1 Added a progress bar to the management part and fine tuned the hash prefix update process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5820
diff changeset
235 """
6c7766cde4c1 Added a progress bar to the management part and fine tuned the hash prefix update process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5820
diff changeset
236 Private slot to set the progress message and the maximum value.
6c7766cde4c1 Added a progress bar to the management part and fine tuned the hash prefix update process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5820
diff changeset
237
6c7766cde4c1 Added a progress bar to the management part and fine tuned the hash prefix update process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5820
diff changeset
238 @param message progress message to be set
6c7766cde4c1 Added a progress bar to the management part and fine tuned the hash prefix update process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5820
diff changeset
239 @type str
6c7766cde4c1 Added a progress bar to the management part and fine tuned the hash prefix update process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5820
diff changeset
240 @param maximum maximum value to be set
6c7766cde4c1 Added a progress bar to the management part and fine tuned the hash prefix update process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5820
diff changeset
241 @type int
6c7766cde4c1 Added a progress bar to the management part and fine tuned the hash prefix update process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5820
diff changeset
242 """
6c7766cde4c1 Added a progress bar to the management part and fine tuned the hash prefix update process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5820
diff changeset
243 self.progressLabel.setText(message)
6c7766cde4c1 Added a progress bar to the management part and fine tuned the hash prefix update process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5820
diff changeset
244 self.progressBar.setMaximum(maximum)
6c7766cde4c1 Added a progress bar to the management part and fine tuned the hash prefix update process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5820
diff changeset
245 self.progressBar.setValue(0)
6c7766cde4c1 Added a progress bar to the management part and fine tuned the hash prefix update process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5820
diff changeset
246
6c7766cde4c1 Added a progress bar to the management part and fine tuned the hash prefix update process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5820
diff changeset
247 @pyqtSlot(int)
6c7766cde4c1 Added a progress bar to the management part and fine tuned the hash prefix update process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5820
diff changeset
248 def __setProgress(self, value):
6c7766cde4c1 Added a progress bar to the management part and fine tuned the hash prefix update process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5820
diff changeset
249 """
6c7766cde4c1 Added a progress bar to the management part and fine tuned the hash prefix update process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5820
diff changeset
250 Private slot to set the progress value.
6c7766cde4c1 Added a progress bar to the management part and fine tuned the hash prefix update process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5820
diff changeset
251
6c7766cde4c1 Added a progress bar to the management part and fine tuned the hash prefix update process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5820
diff changeset
252 @param value progress value to be set
6c7766cde4c1 Added a progress bar to the management part and fine tuned the hash prefix update process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5820
diff changeset
253 @type int
6c7766cde4c1 Added a progress bar to the management part and fine tuned the hash prefix update process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5820
diff changeset
254 """
5839
fe4d62e23908 Added an auto-update feature to the safe browsing manager of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5829
diff changeset
255 if bool(self.progressLabel.text()):
fe4d62e23908 Added an auto-update feature to the safe browsing manager of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5829
diff changeset
256 self.progressBar.setValue(value)
5821
6c7766cde4c1 Added a progress bar to the management part and fine tuned the hash prefix update process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5820
diff changeset
257
6c7766cde4c1 Added a progress bar to the management part and fine tuned the hash prefix update process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5820
diff changeset
258 def __resetProgress(self):
6c7766cde4c1 Added a progress bar to the management part and fine tuned the hash prefix update process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5820
diff changeset
259 """
6c7766cde4c1 Added a progress bar to the management part and fine tuned the hash prefix update process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5820
diff changeset
260 Private method to reset the progress info.
6c7766cde4c1 Added a progress bar to the management part and fine tuned the hash prefix update process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5820
diff changeset
261 """
6c7766cde4c1 Added a progress bar to the management part and fine tuned the hash prefix update process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5820
diff changeset
262 self.progressLabel.clear()
6c7766cde4c1 Added a progress bar to the management part and fine tuned the hash prefix update process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5820
diff changeset
263 self.progressBar.setMaximum(100)
6c7766cde4c1 Added a progress bar to the management part and fine tuned the hash prefix update process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5820
diff changeset
264 self.progressBar.setValue(0)
5829
d3448873ced3 Finished coding the safe browsing module of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5821
diff changeset
265
d3448873ced3 Finished coding the safe browsing module of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5821
diff changeset
266 @pyqtSlot(str)
d3448873ced3 Finished coding the safe browsing module of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5821
diff changeset
267 def on_urlEdit_textChanged(self, text):
d3448873ced3 Finished coding the safe browsing module of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5821
diff changeset
268 """
d3448873ced3 Finished coding the safe browsing module of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5821
diff changeset
269 Private slot to handle changes of the entered URL text.
d3448873ced3 Finished coding the safe browsing module of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5821
diff changeset
270
d3448873ced3 Finished coding the safe browsing module of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5821
diff changeset
271 @param text entered URL text
d3448873ced3 Finished coding the safe browsing module of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5821
diff changeset
272 @type str
d3448873ced3 Finished coding the safe browsing module of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5821
diff changeset
273 """
d3448873ced3 Finished coding the safe browsing module of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5821
diff changeset
274 url = QUrl.fromUserInput(text)
d3448873ced3 Finished coding the safe browsing module of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5821
diff changeset
275 enable = (
d3448873ced3 Finished coding the safe browsing module of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5821
diff changeset
276 url.isValid() and
d3448873ced3 Finished coding the safe browsing module of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5821
diff changeset
277 bool(url.scheme()) and
d3448873ced3 Finished coding the safe browsing module of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5821
diff changeset
278 url.scheme() not in self.__manager.getIgnoreSchemes()
d3448873ced3 Finished coding the safe browsing module of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5821
diff changeset
279 )
d3448873ced3 Finished coding the safe browsing module of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5821
diff changeset
280 self.urlCheckButton.setEnabled(enable)
d3448873ced3 Finished coding the safe browsing module of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5821
diff changeset
281
d3448873ced3 Finished coding the safe browsing module of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5821
diff changeset
282 @pyqtSlot()
d3448873ced3 Finished coding the safe browsing module of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5821
diff changeset
283 def on_urlCheckButton_clicked(self):
d3448873ced3 Finished coding the safe browsing module of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5821
diff changeset
284 """
d3448873ced3 Finished coding the safe browsing module of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5821
diff changeset
285 Private slot to check the entered URL.
d3448873ced3 Finished coding the safe browsing module of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5821
diff changeset
286 """
d3448873ced3 Finished coding the safe browsing module of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5821
diff changeset
287 # Malicious URL for testing:
d3448873ced3 Finished coding the safe browsing module of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5821
diff changeset
288 # http://malware.testing.google.test/testing/malware/*
d3448873ced3 Finished coding the safe browsing module of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5821
diff changeset
289 # http://ianfette.org
d3448873ced3 Finished coding the safe browsing module of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5821
diff changeset
290 #
d3448873ced3 Finished coding the safe browsing module of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5821
diff changeset
291 urlStr = self.urlEdit.text()
d3448873ced3 Finished coding the safe browsing module of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5821
diff changeset
292 url = QUrl.fromUserInput(urlStr)
6234
fb1f9e681848 Web Browser NG, Safe Browsing: improved error handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6233
diff changeset
293 threatLists, error = self.__manager.lookupUrl(url)
5829
d3448873ced3 Finished coding the safe browsing module of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5821
diff changeset
294
6234
fb1f9e681848 Web Browser NG, Safe Browsing: improved error handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6233
diff changeset
295 if error:
fb1f9e681848 Web Browser NG, Safe Browsing: improved error handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6233
diff changeset
296 E5MessageBox.warning(
fb1f9e681848 Web Browser NG, Safe Browsing: improved error handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6233
diff changeset
297 self,
fb1f9e681848 Web Browser NG, Safe Browsing: improved error handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6233
diff changeset
298 self.tr("Check URL"),
fb1f9e681848 Web Browser NG, Safe Browsing: improved error handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6233
diff changeset
299 self.tr("<p>The Google Safe Browsing Server reported an"
fb1f9e681848 Web Browser NG, Safe Browsing: improved error handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6233
diff changeset
300 " error.</p><p>{0}</p>").format(error)
fb1f9e681848 Web Browser NG, Safe Browsing: improved error handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6233
diff changeset
301 )
fb1f9e681848 Web Browser NG, Safe Browsing: improved error handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6233
diff changeset
302 elif threatLists:
5829
d3448873ced3 Finished coding the safe browsing module of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5821
diff changeset
303 threatMessages = self.__manager.getThreatMessages(threatLists)
d3448873ced3 Finished coding the safe browsing module of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5821
diff changeset
304 E5MessageBox.warning(
d3448873ced3 Finished coding the safe browsing module of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5821
diff changeset
305 self,
d3448873ced3 Finished coding the safe browsing module of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5821
diff changeset
306 self.tr("Check URL"),
6234
fb1f9e681848 Web Browser NG, Safe Browsing: improved error handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6233
diff changeset
307 self.tr("<p>The URL <b>{0}</b> was found in the Safe"
fb1f9e681848 Web Browser NG, Safe Browsing: improved error handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6233
diff changeset
308 " Browsing Database.</p>{1}").format(
fb1f9e681848 Web Browser NG, Safe Browsing: improved error handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6233
diff changeset
309 urlStr, "".join(threatMessages))
5829
d3448873ced3 Finished coding the safe browsing module of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5821
diff changeset
310 )
d3448873ced3 Finished coding the safe browsing module of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5821
diff changeset
311 else:
d3448873ced3 Finished coding the safe browsing module of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5821
diff changeset
312 E5MessageBox.information(
d3448873ced3 Finished coding the safe browsing module of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5821
diff changeset
313 self,
d3448873ced3 Finished coding the safe browsing module of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5821
diff changeset
314 self.tr("Check URL"),
d3448873ced3 Finished coding the safe browsing module of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5821
diff changeset
315 self.tr("<p>The URL <b>{0}</b> was not found in the Safe"
6234
fb1f9e681848 Web Browser NG, Safe Browsing: improved error handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6233
diff changeset
316 " Browsing Database and may be considered safe."
fb1f9e681848 Web Browser NG, Safe Browsing: improved error handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6233
diff changeset
317 "</p>")
5829
d3448873ced3 Finished coding the safe browsing module of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5821
diff changeset
318 .format(urlStr)
d3448873ced3 Finished coding the safe browsing module of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5821
diff changeset
319 )
d3448873ced3 Finished coding the safe browsing module of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5821
diff changeset
320
d3448873ced3 Finished coding the safe browsing module of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5821
diff changeset
321 @pyqtSlot()
d3448873ced3 Finished coding the safe browsing module of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5821
diff changeset
322 def on_saveButton_clicked(self):
d3448873ced3 Finished coding the safe browsing module of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5821
diff changeset
323 """
d3448873ced3 Finished coding the safe browsing module of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5821
diff changeset
324 Private slot to save the configuration data.
d3448873ced3 Finished coding the safe browsing module of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5821
diff changeset
325 """
d3448873ced3 Finished coding the safe browsing module of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5821
diff changeset
326 self.__save()
5839
fe4d62e23908 Added an auto-update feature to the safe browsing manager of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5829
diff changeset
327
fe4d62e23908 Added an auto-update feature to the safe browsing manager of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5829
diff changeset
328 @pyqtSlot()
fe4d62e23908 Added an auto-update feature to the safe browsing manager of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5829
diff changeset
329 def on_showUpdateTimeButton_clicked(self):
fe4d62e23908 Added an auto-update feature to the safe browsing manager of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5829
diff changeset
330 """
fe4d62e23908 Added an auto-update feature to the safe browsing manager of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5829
diff changeset
331 Private slot to show the time of the next automatic threat list update.
fe4d62e23908 Added an auto-update feature to the safe browsing manager of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5829
diff changeset
332 """
fe4d62e23908 Added an auto-update feature to the safe browsing manager of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5829
diff changeset
333 nextUpdateDateTime = Preferences.getWebBrowser(
fe4d62e23908 Added an auto-update feature to the safe browsing manager of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5829
diff changeset
334 "SafeBrowsingUpdateDateTime")
7269
0c63ea7f94bd Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
335 if (
0c63ea7f94bd Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
336 not nextUpdateDateTime.isValid() or
0c63ea7f94bd Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
337 nextUpdateDateTime <= QDateTime.currentDateTime()
0c63ea7f94bd Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
338 ):
5839
fe4d62e23908 Added an auto-update feature to the safe browsing manager of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5829
diff changeset
339 message = self.tr("The next automatic threat list update will be"
fe4d62e23908 Added an auto-update feature to the safe browsing manager of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5829
diff changeset
340 " done now.")
fe4d62e23908 Added an auto-update feature to the safe browsing manager of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5829
diff changeset
341 else:
fe4d62e23908 Added an auto-update feature to the safe browsing manager of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5829
diff changeset
342 message = self.tr("<p>The next automatic threat list update will"
fe4d62e23908 Added an auto-update feature to the safe browsing manager of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5829
diff changeset
343 " be done at <b>{0}</b>.</p>").format(
fe4d62e23908 Added an auto-update feature to the safe browsing manager of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5829
diff changeset
344 nextUpdateDateTime.toString("yyyy-MM-dd, HH:mm:ss"))
fe4d62e23908 Added an auto-update feature to the safe browsing manager of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5829
diff changeset
345
fe4d62e23908 Added an auto-update feature to the safe browsing manager of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5829
diff changeset
346 E5MessageBox.information(
fe4d62e23908 Added an auto-update feature to the safe browsing manager of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5829
diff changeset
347 self,
fe4d62e23908 Added an auto-update feature to the safe browsing manager of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5829
diff changeset
348 self.tr("Update Time"),
fe4d62e23908 Added an auto-update feature to the safe browsing manager of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5829
diff changeset
349 message)

eric ide

mercurial