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
This commit is contained in:
parent
7b520ddc93
commit
656bea30dd
1 changed files with 175 additions and 109 deletions
|
|
@ -21,7 +21,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
|
||||
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 @@ class XEP_0100():
|
|||
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 @@ class XEP_0100():
|
|||
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 @@ class XEP_0100():
|
|||
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
|
||||
|
|
|
|||
Loading…
Reference in a new issue