diff src/plugins/plugin_xep_0115.py @ 283:68cd30d982a5

core: added plugins for PubSub et PEP (first drafts) - plugin for XEP 0060, 0163 and 0107, based on Wokkel's pubsub - XEP 0115 plugin has been fixed, so generateHash can be called when features have changed (can be usefull to filter PEP)
author Goffi <goffi@goffi.org>
date Thu, 03 Feb 2011 18:06:25 +0100
parents 6a0c6d8e119d
children 7c79d4a8c9e6
line wrap: on
line diff
--- a/src/plugins/plugin_xep_0115.py	Thu Feb 03 01:27:57 2011 +0100
+++ b/src/plugins/plugin_xep_0115.py	Thu Feb 03 18:06:25 2011 +0100
@@ -96,17 +96,20 @@
         """modify SatPresenceProtocol to add capabilities data"""
         client=self.host.getClient(profile)
         presenceInst = client.presence
+        c_elt = domish.Element((NS_ENTITY_CAPABILITY,'c'))
+        c_elt['hash']='sha-1'
+        c_elt['node']='http://wiki.goffi.org/wiki/Salut_%C3%A0_Toi'
+        c_elt['ver']=XEP_0115.cap_hash
+        presenceInst._c_elt = c_elt
+        if "_legacy_send" in dir(presenceInst):
+            debug('capabilities already added to presence instance')
+            return
         def hacked_send(self, obj):
             obj.addChild(self._c_elt)
             self._legacy_send(obj)
         new_send = types.MethodType(hacked_send, presenceInst, presenceInst.__class__)
         presenceInst._legacy_send = presenceInst.send
         presenceInst.send = new_send
-        c_elt = domish.Element((NS_ENTITY_CAPABILITY,'c'))
-        c_elt['hash']='sha-1'
-        c_elt['node']='http://wiki.goffi.org/wiki/Salut_%C3%A0_Toi'
-        c_elt['ver']=XEP_0115.cap_hash
-        presenceInst._c_elt = c_elt
 
 
     def generateHash(self, profile_key="@DEFAULT@"):