diff src/plugins/plugin_xep_0065.py @ 956:132de9d487ac

plugin XEP-0065: fixed initialisation sequence
author Goffi <goffi@goffi.org>
date Mon, 31 Mar 2014 16:08:15 +0200
parents e1842ebcb2f3
children 301b342c697a
line wrap: on
line diff
--- a/src/plugins/plugin_xep_0065.py	Mon Mar 31 15:22:35 2014 +0200
+++ b/src/plugins/plugin_xep_0065.py	Mon Mar 31 16:08:15 2014 +0200
@@ -787,22 +787,24 @@
                                           "File Transfer", profile_key=self.parent.profile)
 
     def connectionInitialized(self):
-        self.xmlstream.addObserver(BS_REQUEST, self.plugin_parent.streamQuery, profile=self.parent.profile)
-        proxy = self.host.memory.getParamA("Proxy", "File Transfer", profile_key=self.parent.profile)
-        if not proxy:
-            def proxiesFound(entities):
-                try:
-                    proxy_ent = entities.pop()
-                except KeyError:
-                    info(_("No proxy found on this server"))
-                    return
-                iq_elt = jabber_client.IQ(self.parent.xmlstream, 'get')
-                iq_elt["to"] = proxy_ent.full()
-                iq_elt.addElement('query', NS_BS)
-                iq_elt.addCallback(self._proxyDataResult)
-                iq_elt.send()
-            d = self.host.findServiceEntities("proxy", "bytestreams", profile_key=self.parent.profile)
-            d.addCallback(proxiesFound)
+        def connection_ok(dummy):
+            self.xmlstream.addObserver(BS_REQUEST, self.plugin_parent.streamQuery, profile=self.parent.profile)
+            proxy = self.host.memory.getParamA("Proxy", "File Transfer", profile_key=self.parent.profile)
+            if not proxy:
+                def proxiesFound(entities):
+                    try:
+                        proxy_ent = entities.pop()
+                    except KeyError:
+                        info(_("No proxy found on this server"))
+                        return
+                    iq_elt = jabber_client.IQ(self.parent.xmlstream, 'get')
+                    iq_elt["to"] = proxy_ent.full()
+                    iq_elt.addElement('query', NS_BS)
+                    iq_elt.addCallback(self._proxyDataResult)
+                    iq_elt.send()
+                d = self.host.findServiceEntities("proxy", "bytestreams", profile_key=self.parent.profile)
+                d.addCallback(proxiesFound)
+        self.parent.getConnectionDeferred().addCallback(connection_ok)
 
 
     def getDiscoInfo(self, requestor, target, nodeIdentifier=''):