265 threatLists, error = self.__apiClient.getThreatLists() |
265 threatLists, error = self.__apiClient.getThreatLists() |
266 if error: |
266 if error: |
267 return False, error |
267 return False, error |
268 |
268 |
269 maximum = len(threatLists) |
269 maximum = len(threatLists) |
270 current = 0 |
|
271 self.progressMessage.emit(self.tr("Updating threat lists"), maximum) |
270 self.progressMessage.emit(self.tr("Updating threat lists"), maximum) |
272 for entry in threatLists: |
271 for current, entry in enumerate(threatLists, start=1): |
273 current += 1 |
|
274 self.progress.emit(current) |
272 self.progress.emit(current) |
275 QCoreApplication.processEvents() |
273 QCoreApplication.processEvents() |
276 threatList = ThreatList.fromApiEntry(entry) |
274 threatList = ThreatList.fromApiEntry(entry) |
277 if ( |
275 if ( |
278 self.__platforms is None or |
276 self.__platforms is None or |
280 ): |
278 ): |
281 self.__cache.addThreatList(threatList) |
279 self.__cache.addThreatList(threatList) |
282 key = repr(threatList) |
280 key = repr(threatList) |
283 if key in threatListsForRemove: |
281 if key in threatListsForRemove: |
284 del threatListsForRemove[key] |
282 del threatListsForRemove[key] |
|
283 |
285 maximum = len(threatListsForRemove.values()) |
284 maximum = len(threatListsForRemove.values()) |
286 current = 0 |
|
287 self.progressMessage.emit(self.tr("Deleting obsolete threat lists"), |
285 self.progressMessage.emit(self.tr("Deleting obsolete threat lists"), |
288 maximum) |
286 maximum) |
289 for threatList in threatListsForRemove.values(): |
287 for current, threatList in enumerate( |
290 current += 1 |
288 threatListsForRemove.values(), start=1 |
|
289 ): |
291 self.progress.emit(current) |
290 self.progress.emit(current) |
292 QCoreApplication.processEvents() |
291 QCoreApplication.processEvents() |
293 self.__cache.deleteHashPrefixList(threatList) |
292 self.__cache.deleteHashPrefixList(threatList) |
294 self.__cache.deleteThreatList(threatList) |
293 self.__cache.deleteThreatList(threatList) |
295 del threatListsForRemove |
294 del threatListsForRemove |
303 clientStates) |
302 clientStates) |
304 if error: |
303 if error: |
305 return False, error |
304 return False, error |
306 |
305 |
307 maximum = len(threatsUpdateResponses) |
306 maximum = len(threatsUpdateResponses) |
308 current = 0 |
|
309 self.progressMessage.emit(self.tr("Updating hash prefixes"), maximum) |
307 self.progressMessage.emit(self.tr("Updating hash prefixes"), maximum) |
310 for response in threatsUpdateResponses: |
308 for current, response in enumerate(threatsUpdateResponses, start=1): |
311 current += 1 |
|
312 self.progress.emit(current) |
309 self.progress.emit(current) |
313 QCoreApplication.processEvents() |
310 QCoreApplication.processEvents() |
314 responseThreatList = ThreatList.fromApiEntry(response) |
311 responseThreatList = ThreatList.fromApiEntry(response) |
315 if response["responseType"] == "FULL_UPDATE": |
312 if response["responseType"] == "FULL_UPDATE": |
316 self.__cache.deleteHashPrefixList(responseThreatList) |
313 self.__cache.deleteHashPrefixList(responseThreatList) |