comparison 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
comparison
equal deleted inserted replaced
282:6a0c6d8e119d 283:68cd30d982a5
94 94
95 def presenceHack(self, profile): 95 def presenceHack(self, profile):
96 """modify SatPresenceProtocol to add capabilities data""" 96 """modify SatPresenceProtocol to add capabilities data"""
97 client=self.host.getClient(profile) 97 client=self.host.getClient(profile)
98 presenceInst = client.presence 98 presenceInst = client.presence
99 c_elt = domish.Element((NS_ENTITY_CAPABILITY,'c'))
100 c_elt['hash']='sha-1'
101 c_elt['node']='http://wiki.goffi.org/wiki/Salut_%C3%A0_Toi'
102 c_elt['ver']=XEP_0115.cap_hash
103 presenceInst._c_elt = c_elt
104 if "_legacy_send" in dir(presenceInst):
105 debug('capabilities already added to presence instance')
106 return
99 def hacked_send(self, obj): 107 def hacked_send(self, obj):
100 obj.addChild(self._c_elt) 108 obj.addChild(self._c_elt)
101 self._legacy_send(obj) 109 self._legacy_send(obj)
102 new_send = types.MethodType(hacked_send, presenceInst, presenceInst.__class__) 110 new_send = types.MethodType(hacked_send, presenceInst, presenceInst.__class__)
103 presenceInst._legacy_send = presenceInst.send 111 presenceInst._legacy_send = presenceInst.send
104 presenceInst.send = new_send 112 presenceInst.send = new_send
105 c_elt = domish.Element((NS_ENTITY_CAPABILITY,'c'))
106 c_elt['hash']='sha-1'
107 c_elt['node']='http://wiki.goffi.org/wiki/Salut_%C3%A0_Toi'
108 c_elt['ver']=XEP_0115.cap_hash
109 presenceInst._c_elt = c_elt
110 113
111 114
112 def generateHash(self, profile_key="@DEFAULT@"): 115 def generateHash(self, profile_key="@DEFAULT@"):
113 """This method generate a sha1 hash as explained in xep-0115 #5.1 116 """This method generate a sha1 hash as explained in xep-0115 #5.1
114 it then store it in XEP_0115.cap_hash""" 117 it then store it in XEP_0115.cap_hash"""