comparison src/plugins/plugin_xep_0115.py @ 667:a79a6843928c

plugin XEP-0115: changed node for "http://sat.goffi.org" + filtering using list comprehension instead of filter()
author Goffi <goffi@goffi.org>
date Tue, 05 Nov 2013 22:40:56 +0100
parents 84a6e83157c2
children bfabeedbf32e
comparison
equal deleted inserted replaced
666:2a7185b8452c 667:a79a6843928c
99 """modify SatPresenceProtocol to add capabilities data""" 99 """modify SatPresenceProtocol to add capabilities data"""
100 client = self.host.getClient(profile) 100 client = self.host.getClient(profile)
101 presenceInst = client.presence 101 presenceInst = client.presence
102 c_elt = domish.Element((NS_ENTITY_CAPABILITY, 'c')) 102 c_elt = domish.Element((NS_ENTITY_CAPABILITY, 'c'))
103 c_elt['hash'] = 'sha-1' 103 c_elt['hash'] = 'sha-1'
104 c_elt['node'] = 'http://wiki.goffi.org/wiki/Salut_%C3%A0_Toi' 104 c_elt['node'] = 'http://sat.goffi.org'
105 c_elt['ver'] = XEP_0115.cap_hash 105 c_elt['ver'] = XEP_0115.cap_hash
106 presenceInst._c_elt = c_elt 106 presenceInst._c_elt = c_elt
107 if "_legacy_send" in dir(presenceInst): 107 if "_legacy_send" in dir(presenceInst):
108 debug('capabilities already added to presence instance') 108 debug('capabilities already added to presence instance')
109 return 109 return
128 error('Requesting hash for an inexistant client') 128 error('Requesting hash for an inexistant client')
129 raise HashGenerationError 129 raise HashGenerationError
130 130
131 def generateHash_2(services, profile): 131 def generateHash_2(services, profile):
132 _s = [] 132 _s = []
133 byte_identities = [ByteIdentity(identity) for identity in filter(lambda x: isinstance(x, disco.DiscoIdentity), services)] # FIXME: lang must be managed here 133 byte_identities = [ByteIdentity(service) for service in services if isinstance(service, disco.DiscoIdentity)] # FIXME: lang must be managed here
134 byte_identities.sort(key=lambda i: i.lang) 134 byte_identities.sort(key=lambda i: i.lang)
135 byte_identities.sort(key=lambda i: i.idType) 135 byte_identities.sort(key=lambda i: i.idType)
136 byte_identities.sort(key=lambda i: i.category) 136 byte_identities.sort(key=lambda i: i.category)
137 for identity in byte_identities: 137 for identity in byte_identities:
138 _s.append(str(identity)) 138 _s.append(str(identity))
139 _s.append('<') 139 _s.append('<')
140 byte_features = [feature.encode('utf-8') for feature in filter(lambda x: isinstance(x, disco.DiscoFeature), services)] 140 byte_features = [service.encode('utf-8') for service in services if isinstance(service, disco.DiscoFeature)]
141 byte_features.sort() # XXX: the default sort has the same behaviour as the requested RFC 4790 i;octet sort 141 byte_features.sort() # XXX: the default sort has the same behaviour as the requested RFC 4790 i;octet sort
142 for feature in byte_features: 142 for feature in byte_features:
143 _s.append(feature) 143 _s.append(feature)
144 _s.append('<') 144 _s.append('<')
145 #TODO: manage XEP-0128 data form here 145 #TODO: manage XEP-0128 data form here