[Telepathy-commits] [telepathy-salut/master] add avahi/caps_helper.py

Guillaume Desmottes guillaume.desmottes at collabora.co.uk
Thu Feb 26 11:20:23 PST 2009


---
 tests/twisted/avahi/caps_helper.py |   27 +++++++++++++++++++++++++++
 1 files changed, 27 insertions(+), 0 deletions(-)
 create mode 100644 tests/twisted/avahi/caps_helper.py

diff --git a/tests/twisted/avahi/caps_helper.py b/tests/twisted/avahi/caps_helper.py
new file mode 100644
index 0000000..95099d1
--- /dev/null
+++ b/tests/twisted/avahi/caps_helper.py
@@ -0,0 +1,27 @@
+import hashlib
+import base64
+from config import PACKAGE_STRING
+
+def compute_caps_hash(identities, features, dataforms):
+    S = ''
+
+    for identity in sorted(identities):
+        S += '%s<' % identity
+
+    for feature in sorted(features):
+        S += '%s<' % feature
+
+    # FIXME: support dataforms
+
+    m = hashlib.sha1()
+    m.update(S)
+    return base64.b64encode(m.digest())
+
+def generate_caps(features):
+    return compute_caps_hash(['client/pc//%s' % PACKAGE_STRING], features, [])
+
+if __name__ == '__main__':
+    # example from XEP-0115
+    assert compute_caps_hash(['client/pc//Exodus 0.9.1'], ["http://jabber.org/protocol/disco#info",
+        "http://jabber.org/protocol/disco#items", "http://jabber.org/protocol/muc",
+        "http://jabber.org/protocol/caps"], []) == 'QgayPKawpkPSDYmwT/WM94uAlu0='
-- 
1.5.6.5




More information about the telepathy-commits mailing list