Mercurial > libervia-backend
diff plugins/plugin_xep_0100.py @ 64:d46f849664aa
SàT: multi-profile, plugins updated
- core: 2 new convenient methods: getJidNStream and getClient
- new param in plugin info: "handler" to know if there is a handler to plug on profiles clients
- plugins with handler now use an other class which is returned to profile client with the new method "getHandler" and pluged when connecting
author | Goffi <goffi@goffi.org> |
---|---|
date | Sat, 30 Jan 2010 16:17:33 +1100 |
parents | a5b5fb5fc9fd |
children | d35c5edab53f |
line wrap: on
line diff
--- a/plugins/plugin_xep_0100.py Fri Jan 29 14:17:15 2010 +1100 +++ b/plugins/plugin_xep_0100.py Sat Jan 30 16:17:33 2010 +1100 @@ -21,7 +21,7 @@ from logging import debug, info, error from twisted.internet import protocol -from twisted.words.protocols.jabber import client, jid, xmlstream +from twisted.words.protocols.jabber import client, jid from twisted.words.protocols.jabber import error as jab_error import pdb @@ -76,7 +76,7 @@ self.__inc_handled_items(request_id) - def discoItems(self, disco, request_id, target): + def discoItems(self, disco, request_id, target, client): """Look for items with disco protocol, and ask infos for each one""" #FIXME: target is used as we can't find the original iq node (parent is None) # an other way would avoid this useless parameter (is there a way with wokkel ?) @@ -88,8 +88,8 @@ self.__gateways[request_id] = {'__total_items':len(disco._items), '__handled_items':0, '__private__':{'target':target.full()}} for item in disco._items: debug ("item found: %s", item.name) - self.host.disco.requestInfo(item.entity).addCallback(self.discoInfo, entity=item.entity, request_id=request_id) - self.host.disco.requestInfo(item.entity).addErrback(self.discoInfoErr, entity=item.entity, request_id=request_id) + client.disco.requestInfo(item.entity).addCallback(self.discoInfo, entity=item.entity, request_id=request_id) + client.disco.requestInfo(item.entity).addErrback(self.discoInfoErr, entity=item.entity, request_id=request_id) def registrationSuccessful(self, target): """Called when in_band registration is ok, we must now follow the rest of procedure""" @@ -103,12 +103,14 @@ self.host.plugins["XEP_0077"].addTrigger(target, self.registrationSuccessful) return self.host.plugins["XEP_0077"].in_band_submit(action, target, fields) - def findGateways(self, target): + def findGateways(self, target, profile_key='@DEFAULT@'): """Find gateways in the target JID, using discovery protocol Return an id used for retrieving the list of gateways """ + client = self.host.getClient(profile_key) + assert(client) to_jid = jid.JID(target) debug ("find gateways (target = %s)" % to_jid.full()) request_id = self.host.get_next_id() - self.host.disco.requestItems(to_jid).addCallback(self.discoItems, request_id=request_id, target = to_jid) + client.disco.requestItems(to_jid).addCallback(self.discoItems, request_id=request_id, target = to_jid, client = client) return request_id