WebBrowser/SafeBrowsing/SafeBrowsingDialog.py

changeset 6233
a64b986abb54
parent 6230
77a1b22c8a1f
child 6234
fb1f9e681848
equal deleted inserted replaced
6232:d2eac9616a92 6233:a64b986abb54
51 self.__apiKey = Preferences.getWebBrowser("SafeBrowsingApiKey") 51 self.__apiKey = Preferences.getWebBrowser("SafeBrowsingApiKey")
52 self.__filterPlatform = Preferences.getWebBrowser( 52 self.__filterPlatform = Preferences.getWebBrowser(
53 "SafeBrowsingFilterPlatform") 53 "SafeBrowsingFilterPlatform")
54 self.__automaticUpdate = Preferences.getWebBrowser( 54 self.__automaticUpdate = Preferences.getWebBrowser(
55 "SafeBrowsingAutoUpdate") 55 "SafeBrowsingAutoUpdate")
56 self.__useLookupApi = Preferences.getWebBrowser(
57 "SafeBrowsingUseLookupApi")
56 58
57 self.buttonBox.setFocus() 59 self.buttonBox.setFocus()
58 60
59 msh = self.minimumSizeHint() 61 msh = self.minimumSizeHint()
60 self.resize(max(self.width(), msh.width()), msh.height()) 62 self.resize(max(self.width(), msh.width()), msh.height())
64 Public slot to show the dialog. 66 Public slot to show the dialog.
65 """ 67 """
66 self.gsbGroupBox.setChecked(self.__enabled) 68 self.gsbGroupBox.setChecked(self.__enabled)
67 self.gsbApiKeyEdit.setText(self.__apiKey) 69 self.gsbApiKeyEdit.setText(self.__apiKey)
68 self.gsbFilterPlatformCheckBox.setChecked(self.__filterPlatform) 70 self.gsbFilterPlatformCheckBox.setChecked(self.__filterPlatform)
69 # TODO: add text to label to indicate Update API only
70 self.gsbAutoUpdateCheckBox.setChecked(self.__automaticUpdate) 71 self.gsbAutoUpdateCheckBox.setChecked(self.__automaticUpdate)
71 # TODO: add checkbox to enable the Lookup API 72 self.gsbLookupCheckBox.setChecked(self.__useLookupApi)
72 73
73 # TODO: enable the cache buttons group box only on Update API
74 self.__updateCacheButtons() 74 self.__updateCacheButtons()
75 75
76 super(SafeBrowsingDialog, self).show() 76 super(SafeBrowsingDialog, self).show()
77 77
78 @pyqtSlot() 78 @pyqtSlot()
112 """ 112 """
113 self.__enabled = self.gsbGroupBox.isChecked() 113 self.__enabled = self.gsbGroupBox.isChecked()
114 self.__apiKey = self.gsbApiKeyEdit.text() 114 self.__apiKey = self.gsbApiKeyEdit.text()
115 self.__filterPlatform = self.gsbFilterPlatformCheckBox.isChecked() 115 self.__filterPlatform = self.gsbFilterPlatformCheckBox.isChecked()
116 self.__automaticUpdate = self.gsbAutoUpdateCheckBox.isChecked() 116 self.__automaticUpdate = self.gsbAutoUpdateCheckBox.isChecked()
117 self.__useLookupApi = self.gsbLookupCheckBox.isChecked()
117 118
118 Preferences.setWebBrowser("SafeBrowsingEnabled", self.__enabled) 119 Preferences.setWebBrowser("SafeBrowsingEnabled", self.__enabled)
119 Preferences.setWebBrowser("SafeBrowsingApiKey", self.__apiKey) 120 Preferences.setWebBrowser("SafeBrowsingApiKey", self.__apiKey)
120 Preferences.setWebBrowser("SafeBrowsingFilterPlatform", 121 Preferences.setWebBrowser("SafeBrowsingFilterPlatform",
121 self.__filterPlatform) 122 self.__filterPlatform)
122 Preferences.setWebBrowser("SafeBrowsingAutoUpdate", 123 Preferences.setWebBrowser("SafeBrowsingAutoUpdate",
123 self.__automaticUpdate) 124 self.__automaticUpdate)
125 Preferences.setWebBrowser("SafeBrowsingUseLookupApi",
126 self.__useLookupApi)
124 127
125 self.__manager.configurationChanged() 128 self.__manager.configurationChanged()
126 129
127 self.__updateCacheButtons() 130 self.__updateCacheButtons()
128 131
150 return ( 153 return (
151 (self.__enabled != self.gsbGroupBox.isChecked()) or 154 (self.__enabled != self.gsbGroupBox.isChecked()) or
152 (self.__apiKey != self.gsbApiKeyEdit.text()) or 155 (self.__apiKey != self.gsbApiKeyEdit.text()) or
153 (self.__filterPlatform != 156 (self.__filterPlatform !=
154 self.gsbFilterPlatformCheckBox.isChecked()) or 157 self.gsbFilterPlatformCheckBox.isChecked()) or
155 (self.__automaticUpdate != self.gsbAutoUpdateCheckBox.isChecked()) 158 (self.__automaticUpdate !=
159 self.gsbAutoUpdateCheckBox.isChecked()) or
160 (self.__useLookupApi != self.gsbLookupCheckBox.isChecked())
156 ) 161 )
157 162
158 def __okToClose(self): 163 def __okToClose(self):
159 """ 164 """
160 Private method to check, if it is safe to close the dialog. 165 Private method to check, if it is safe to close the dialog.
287 # http://ianfette.org 292 # http://ianfette.org
288 # 293 #
289 urlStr = self.urlEdit.text() 294 urlStr = self.urlEdit.text()
290 url = QUrl.fromUserInput(urlStr) 295 url = QUrl.fromUserInput(urlStr)
291 threatLists = self.__manager.lookupUrl(url) 296 threatLists = self.__manager.lookupUrl(url)
297 # TODO: handle threatLists being None (indicating a lookup error)
292 298
293 if threatLists: 299 if threatLists:
294 threatMessages = self.__manager.getThreatMessages(threatLists) 300 threatMessages = self.__manager.getThreatMessages(threatLists)
295 E5MessageBox.warning( 301 E5MessageBox.warning(
296 self, 302 self,

eric ide

mercurial