diff -r 69fa45e95673 -r b610cb5b501a WebBrowser/SafeBrowsing/SafeBrowsingAPIClient.py --- a/WebBrowser/SafeBrowsing/SafeBrowsingAPIClient.py Wed Jul 26 19:46:17 2017 +0200 +++ b/WebBrowser/SafeBrowsing/SafeBrowsingAPIClient.py Sat Jul 29 19:41:16 2017 +0200 @@ -53,6 +53,15 @@ self.__nextRequestNoSoonerThan = QDateTime() self.__failCount = 0 + def setApiKey(self, apiKey): + """ + Public method to set the API key. + + @param apiKey API key to be set + @type str + """ + self.__apiKey = apiKey + def getThreatLists(self): """ Public method to retrieve all available threat lists. @@ -79,11 +88,11 @@ reply.deleteLater() return res - def getThreatsUpdate(self, clientState): + def getThreatsUpdate(self, clientStates): """ Public method to fetch hash prefix updates for the given threat list. - @param clientState dictionary of client states with keys like + @param clientStates dictionary of client states with keys like (threatType, platformType, threatEntryType) @type dict @return list of threat updates @@ -98,7 +107,7 @@ } for (threatType, platformType, threatEntryType), currentState in \ - clientState.items(): + clientStates.items(): requestBody["listUpdateRequests"].append( { "threatType": threatType, @@ -223,3 +232,15 @@ waitDuration = int(minimumWaitDuration.rstrip("s")) self.__nextRequestNoSoonerThan = \ QDateTime.currentDateTime().addSecs(waitDuration) + + def fairUseDelayExpired(self): + """ + Public method to check, if the fair use wait period has expired. + + @return flag indicating expiration + @rtype bool + """ + return ( + self.__fairUse and + QDateTime.currentDateTime() >= self.__nextRequestNoSoonerThan + ) or not self.__fairUse