SF.net SVN: fclient: [41] trunk/fclient/config.py
Status: Pre-Alpha
Brought to you by:
jurner
From: <jU...@us...> - 2007-11-04 17:29:34
|
Revision: 41 http://fclient.svn.sourceforge.net/fclient/?rev=41&view=rev Author: jUrner Date: 2007-11-04 09:29:34 -0800 (Sun, 04 Nov 2007) Log Message: ----------- new: FcPClient manager Modified Paths: -------------- trunk/fclient/config.py Modified: trunk/fclient/config.py =================================================================== --- trunk/fclient/config.py 2007-11-04 17:28:46 UTC (rev 40) +++ trunk/fclient/config.py 2007-11-04 17:29:34 UTC (rev 41) @@ -7,7 +7,9 @@ from PyQt4 import QtCore from fclient_lib.qt4ex import assistant, language, settingsbase, resources +from fclient_ui.fcp_client_manager import FcpClientManager + _ = os.path.join #*********************************************************************** # @@ -34,7 +36,7 @@ #***************************************************************************** class Config(object): - def __init__(self, parent, connectDelay=100, pollDelay=300): + def __init__(self, parent): """ @param parent: parent widget @param connectDelay: (miliseconds) frequency by qich a connection to the node is made @@ -42,95 +44,32 @@ value will make messages from the node come in quickly but make the gui unresponsive to user interaction - @ivar assistant: app global user docs management + @ivar assistant: app global user documentation management @ivar defaultDownloadsDir: default directory for downloads - @ivar fcpClient: app global FcpClient + @ivar fcpClientManager: app global FcpClientManager @ivar language: app global language management @ivar nodeHello: NodeHello message as returned from the client as soon as a connection is established @ivar resources: app global resource management - @ivar settings: global settings + @ivar settings: app global settings """ #TODO: assistant can not handle locale dependend docs yet self.assistant = assistant.Assistant(parent, profile=AssistantProfile, pages=DocPages) self.defaultDownloadsDir = os.path.join(BaseDir, 'downloads') - + self.fcpClientManager = FcpClientManager(parent) self.language = language.Language([LanguageDir, ], translationPrefixes=TranslationPrefixes) - self.resources = resources.Resources([ResourceDir, ], ) self.settings = settingsbase.Settings(OrgName, AppName) - self.fcpClient = None - self.nodeHello = None - self.connectDelay = connectDelay - self.pollDelay = pollDelay - self._pollTimer = QtCore.QTimer() - self._connectMethod = None - self._connectTimer = QtCore.QTimer() - QtCore.QObject.connect( - self._connectTimer, - QtCore.SIGNAL('timeout()'), - self.handleFcpConnect - ) - - #TODO: have to find a way to handle multiple clients - def connectFcpNode(self, eventConnectedHandler): - """Establishes a connection to the freenet node - @param eventConnectedHandler: handler to handle the events.ClientConnected of the client - @note: the clients events.ClientConnected gets automatically connected in the call. So no - need to connect once more. - @note: make shure not to access the 'fcpClient' or 'nodeHello' attrs of the config before - the handler gets called. - """ - if self.fcpClient is None: - # some magic here to determine the client version to use - from fclient_lib.fcp.fcp2_0 import FcpClient - self.fcpClient = FcpClient( - connectionName='', - #verbosity=FcpClient.Verbosity.Debug, - ) - self.fcpClient.events.ClientDisconnected += self.handleFcpClientDisconnected - QtCore.QObject.connect( - self._pollTimer, - QtCore.SIGNAL('timeout()'), - self.fcpClient.next - ) - self._connectMethod = self.fcpClient.connect() - self.fcpClient.events.ClientConnected += eventConnectedHandler - self._connectTimer.start(self.connectDelay) - - else: - cb(self.fcpClient.events.ClientConnected, self.nodeHello) - def handleFcpConnect(self): - """Handles establishing of the node connection""" - self._connectTimer.stop() - try: - result = self._connectMethod.next() - if result is not None: - self.nodeHello = result - self._pollTimer.start(self.pollDelay) - - except StopIteration: - return - self._connectTimer.start() - - - def handleFcpClientDisconnected(self, params): - """Handles client disconneting""" - self.fcpClient = None - self.nodeHello = None - - - This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |