Mercurial > libervia-backend
comparison plugins/plugin_xep_0100.py @ 42:874de3020e1c
Initial VCard (XEP-0054) support + misc fixes
- new xep-0054 plugin, avatar are cached, new getProfile bridge method
- gateways plugin (XEP-0100): new __private__ key in resulting data, used to keep target jid
author | Goffi <goffi@goffi.org> |
---|---|
date | Mon, 21 Dec 2009 13:22:11 +1100 |
parents | 2e3411a6baad |
children | 4392f1fdb064 |
comparison
equal
deleted
inserted
replaced
41:d24629c631fc | 42:874de3020e1c |
---|---|
73 failure.trap(jab_error.StanzaError) | 73 failure.trap(jab_error.StanzaError) |
74 error("Error when discovering [%s]: %s" % (entity.full(), failure.value.condition)) | 74 error("Error when discovering [%s]: %s" % (entity.full(), failure.value.condition)) |
75 self.__inc_handled_items(request_id) | 75 self.__inc_handled_items(request_id) |
76 | 76 |
77 | 77 |
78 def discoItems(self, disco, request_id): | 78 def discoItems(self, disco, request_id, target): |
79 """Look for items with disco protocol, and ask infos for each one""" | 79 """Look for items with disco protocol, and ask infos for each one""" |
80 #FIXME: target is used as we can't find the original iq node (parent is None) | |
81 # an other way would avoid this useless parameter (is there a way with wokkel ?) | |
80 | 82 |
81 if len(disco._items) == 0: | 83 if len(disco._items) == 0: |
82 debug ("No gateway found") | 84 debug ("No gateway found") |
83 self.host.actionResultExt(request_id,"DICT_DICT",{}) | 85 self.host.actionResultExt(request_id,"DICT_DICT",{}) |
84 return | 86 return |
85 | 87 |
86 self.__gateways[request_id] = {'__total_items':len(disco._items), '__handled_items':0} | 88 self.__gateways[request_id] = {'__total_items':len(disco._items), '__handled_items':0, '__private__':{'target':target.full()}} |
87 for item in disco._items: | 89 for item in disco._items: |
88 debug ("item found: %s", item.name) | 90 debug ("item found: %s", item.name) |
89 self.host.disco.requestInfo(item.entity).addCallback(self.discoInfo, entity=item.entity, request_id=request_id) | 91 self.host.disco.requestInfo(item.entity).addCallback(self.discoInfo, entity=item.entity, request_id=request_id) |
90 self.host.disco.requestInfo(item.entity).addErrback(self.discoInfoErr, entity=item.entity, request_id=request_id) | 92 self.host.disco.requestInfo(item.entity).addErrback(self.discoInfoErr, entity=item.entity, request_id=request_id) |
91 | 93 |
103 | 105 |
104 def findGateways(self, target): | 106 def findGateways(self, target): |
105 """Find gateways in the target JID, using discovery protocol | 107 """Find gateways in the target JID, using discovery protocol |
106 Return an id used for retrieving the list of gateways | 108 Return an id used for retrieving the list of gateways |
107 """ | 109 """ |
108 debug ("find gateways (target = %s)" % target) | 110 to_jid = jid.JID(target) |
111 debug ("find gateways (target = %s)" % to_jid.full()) | |
109 request_id = self.host.get_next_id() | 112 request_id = self.host.get_next_id() |
110 self.host.disco.requestItems(jid.JID(target)).addCallback(self.discoItems, request_id=request_id) | 113 self.host.disco.requestItems(to_jid).addCallback(self.discoItems, request_id=request_id, target = to_jid) |
111 return request_id | 114 return request_id |