[Telepathy-commits] [mingle/master] Support old-style entity capabilities

Sjoerd Simons sjoerd at luon.net
Thu Nov 13 02:28:36 PST 2008


---
 client.py |   39 +++++++++++++++++++++++++++++++++++----
 1 files changed, 35 insertions(+), 4 deletions(-)

diff --git a/client.py b/client.py
index c9396c6..c46bfc4 100644
--- a/client.py
+++ b/client.py
@@ -66,18 +66,49 @@ class Contact:
 
             # If any capability related has changed update
             if self.ver != None and self.node != None:
-                self.query_caps()
+                if self.ext != None:
+                    self.query_oldstyle_caps()
+                else:
+                    self.query_caps()
 
-    def disco_result(self, stanza):
+    def get_caps_from_stanza(self, stanza):
         features = xpath.queryForNodes('/iq/query[@xmlns="%s"]/feature' %
             ns.DISCO_INFO, stanza)
 
-        self.capabilities = []
 
         if features != None:
-            self.capabilities = map(lambda x: x.getAttribute("var"), features)
+            return  map(lambda x: x.getAttribute("var"), features)
+        return []
+
+    def disco_result(self, stanza):
+        self.capabilities = self.get_caps_from_stanza(stanza)
         self.capabilities_updated()
 
+    def oldstyle_disco_done(self, *args):
+        self.capabilities_updated()
+
+    def oldstyle_disco_result(self, deferred, stanza):
+        self.capabilities += self.get_caps_from_stanza(stanza)
+        deferred.callback(True)
+
+    def query_oldstyle_caps(self):
+        dlist = []
+
+        for e in [self.ver] + self.ext.split():
+            iq = IQ(self.client.stream, 'get')
+            iq['to'] = self.jid.full()
+            q = iq.addElement((ns.DISCO_INFO, 'query'))
+            q['node'] = self.node + '#' + e
+
+            d = defer.Deferred()
+            dlist.append(d)
+
+            iq.addCallback(self.oldstyle_disco_result, d)
+            iq.send()
+
+        d = defer.DeferredList(dlist)
+        d.addCallback(self.oldstyle_disco_done)
+
     def query_caps(self):
         iq = IQ(self.client.stream, 'get')
         iq['to'] = self.jid.full()
-- 
1.5.6.5



More information about the Telepathy-commits mailing list