# HG changeset patch # User Goffi # Date 1255988971 -7200 # Node ID c0c92129a54bf52bf20ce125e5d24c5ea783f4ae # Parent 3c1cefd411865997b4038b49e93178d9fcb40eb5 connect and disconnect management diff -r 3c1cefd41186 -r c0c92129a54b sat.tac --- a/sat.tac Mon Oct 19 22:53:21 2009 +0200 +++ b/sat.tac Mon Oct 19 23:49:31 2009 +0200 @@ -81,7 +81,7 @@ self.bridge.register("getProgress", self.getProgress) self._import_plugins() - self.connect() + #self.connect() def _import_plugins(self): @@ -99,13 +99,16 @@ def connect(self): print "connecting..." + reactor.connectTCP(self.memory.getParamV("Server", "Connection"), 5222, self.factory) + self.connectionStatus="online" #TODO: check if connection is OK + self.connected=True #TODO: use startedConnecting and clientConnectionLost of XMPPClientFactory def getService(self): print "GetService !" """if (self.connected): info("already connected !") return""" - info("Getting client...") + info("Getting service...") self.me = jid.JID(self.memory.getParamV("JabberID", "Connection")) self.factory = client.XMPPClientFactory(self.me, self.memory.getParamV("Password", "Connection")) self.factory.addBootstrap(xmlstream.STREAM_AUTHD_EVENT,self.authd) @@ -119,6 +122,11 @@ info("not connected !") return info("Disconnecting...") + self.factory.stopTrying() + if self.xmlstream: + self.xmlstream.sendFooter() + self.connectionStatus="offline" #TODO: check if connection is OK + self.connected=False #TODO: use startedConnecting and clientConnectionLost of XMPPClientFactory def run(self): debug("running app")