Mercurial > libervia-backend
diff src/core/xmpp.py @ 341:9eebdc655b8b
code: added asyncConnect
author | Goffi <goffi@goffi.org> |
---|---|
date | Thu, 26 May 2011 16:49:47 +0200 |
parents | 953536246d9d |
children | ca3a041fed30 |
line wrap: on
line diff
--- a/src/core/xmpp.py Thu May 26 16:49:07 2011 +0200 +++ b/src/core/xmpp.py Thu May 26 16:49:47 2011 +0200 @@ -34,6 +34,11 @@ self.profile = profile self.host_app = host_app self.client_initialized = defer.Deferred() + self.conn_deferred = defer.Deferred() + + def getConnectionDeferred(self): + """Return a deferred which fire when the client is connected""" + return self.conn_deferred def _authd(self, xmlstream): if not self.host_app.trigger.point("XML Initialized", xmlstream, self.profile): @@ -65,6 +70,7 @@ self.disco.requestInfo(jid.JID(self.host_app.memory.getParamA("Server", "Connection", profile_key=self.profile))).addCallback(self.host_app.serverDisco, self.profile) #FIXME: use these informations self.disco.requestItems(jid.JID(self.host_app.memory.getParamA("Server", "Connection", profile_key=self.profile))).addCallback(self.host_app.serverDiscoItems, self.disco, self.profile, self.client_initialized) + self.conn_deferred.callback(None) def initializationFailed(self, reason): print ("initializationFailed: %s" % reason) @@ -74,6 +80,7 @@ except: #we already send an error signal, no need to raise an exception pass + self.conn_deferred.errback() def isConnected(self): return self.__connected @@ -262,7 +269,6 @@ if self.user_email: _email = query.addElement('email') _email.addContent(self.user_email) - print iq.toXml() reg = iq.send(self.jabber_host).addCallbacks(self.registrationAnswer, self.registrationFailure) def registrationAnswer(self, answer):