--- a/Helpviewer/Network/FtpAccessHandler.py Wed Sep 19 18:21:04 2012 +0200 +++ b/Helpviewer/Network/FtpAccessHandler.py Wed Sep 19 20:19:49 2012 +0200 @@ -17,6 +17,17 @@ """ Class implementing a scheme access handler for FTP. """ + def __init__(self, parent=None): + """ + Constructor + + @param parent reference to the parent object (QObject) + """ + super().__init__(parent) + + self.__authenticatorCache = {} + self.__proxyAuthenticator = None + def createRequest(self, op, request, outgoingData=None): """ Protected method to create a request. @@ -28,6 +39,49 @@ @return reference to the created reply object (QNetworkReply) """ if op == QNetworkAccessManager.GetOperation: - return FtpReply(request.url(), self.parent()) + return FtpReply(request.url(), self, self.parent()) else: return None + + def setAuthenticator(self, realm, authenticator): + """ + Public method to add or change an authenticator in our cache. + + @param realm name of the realm the authenticator belongs to (string) + @param authenticator authenticator to add to the cache (QAuthenticator). + If it is None, the entry will be deleted from the cache. + """ + if realm: + if authenticator: + self.__authenticatorCache[realm] = authenticator + else: + if realm in self.__authenticatorCache: + del self.__authenticatorCache[realm] + + def getAuthenticator(self, realm): + """ + Public method to get an authenticator for the given realm. + + @param realm name of the realm to get the authenticator for (string) + @return authenticator for the given realm (QAuthenticator) or None + """ + if realm in self.__authenticatorCache: + return self.__authenticatorCache[realm] + else: + return None + + def setProxyAuthenticator(self, authenticator): + """ + Public method to add or change the authenticator for the FTP proxy. + + @param authenticator authenticator for the FTP proxy (QAuthenticator) + """ + self.__proxyAuthenticator = authenticator + + def getProxyAuthenticator(self): + """ + Public method to get the authenticator for the FTP proxy. + + @return authenticator for the FTP proxy (QAuthenticator) + """ + return self.__proxyAuthenticator