Mercurial > libervia-backend
comparison plugins/plugin_xep_0100.py @ 37:a61beb21d16d
Gateway registration, unregistration & edition
- default values added in form
- DBus bridge: fixed array of struct management when adding dynamically a method
- fixed doc for some methods
- ugly fix for presence status
- added dependency for XEP-0077 in XEP-0100 plugin
- Wix: added unregister button in gateways manager
- Wix: added privacy warning in gateways manager
author | Goffi <goffi@goffi.org> |
---|---|
date | Tue, 15 Dec 2009 01:27:32 +1100 |
parents | d6b613764dd7 |
children | 2e3411a6baad |
comparison
equal
deleted
inserted
replaced
36:6491b7956c80 | 37:a61beb21d16d |
---|---|
28 | 28 |
29 PLUGIN_INFO = { | 29 PLUGIN_INFO = { |
30 "name": "Gateways Plugin", | 30 "name": "Gateways Plugin", |
31 "import_name": "XEP_0100", | 31 "import_name": "XEP_0100", |
32 "type": "XEP", | 32 "type": "XEP", |
33 "dependencies": [], | 33 "dependencies": ["XEP_0077"], |
34 "main": "XEP_0100", | 34 "main": "XEP_0100", |
35 "description": """Implementation of Gateways protocol""" | 35 "description": """Implementation of Gateways protocol""" |
36 } | 36 } |
37 | 37 |
38 class XEP_0100(): | 38 class XEP_0100(): |
40 def __init__(self, host): | 40 def __init__(self, host): |
41 info("Gateways plugin initialization") | 41 info("Gateways plugin initialization") |
42 self.host = host | 42 self.host = host |
43 self.__gateways = {} #dict used to construct the answer to findGateways. Key = target jid | 43 self.__gateways = {} #dict used to construct the answer to findGateways. Key = target jid |
44 host.bridge.addMethod("findGateways", ".communication", in_sign='s', out_sign='s', method=self.findGateways) | 44 host.bridge.addMethod("findGateways", ".communication", in_sign='s', out_sign='s', method=self.findGateways) |
45 host.bridge.addMethod("gatewayRegister", ".request", in_sign='ssa(ss)', out_sign='s', method=self.gatewayRegister) | |
45 | 46 |
46 def discoInfo(self, disco, entity, request_id): | 47 def discoInfo(self, disco, entity, request_id): |
47 """Find disco infos about entity, to check if it is a gateway""" | 48 """Find disco infos about entity, to check if it is a gateway""" |
48 | 49 |
49 for identity in disco.identities: | 50 for identity in disco.identities: |
74 self.__gateways[request_id] = {'__total_items':len(disco._items), '__handled_items':0} | 75 self.__gateways[request_id] = {'__total_items':len(disco._items), '__handled_items':0} |
75 for item in disco._items: | 76 for item in disco._items: |
76 debug ("item found: %s", item.name) | 77 debug ("item found: %s", item.name) |
77 self.host.disco.requestInfo(item.entity).addCallback(self.discoInfo, entity=item.entity, request_id=request_id) | 78 self.host.disco.requestInfo(item.entity).addCallback(self.discoInfo, entity=item.entity, request_id=request_id) |
78 | 79 |
80 def registrationSuccessful(self, target): | |
81 """Called when in_band registration is ok, we must now follow the rest of procedure""" | |
82 print "Registration successful, doing the rest" | |
83 self.host.addContact(target) | |
84 self.host.setPresence(target) | |
85 | |
86 def gatewayRegister(self, action, target, fields): | |
87 """Register gateway using in-band registration, then log-in to gateway""" | |
88 if action == 'SUBMIT': | |
89 self.host.plugins["XEP_0077"].addTrigger(target, self.registrationSuccessful) | |
90 return self.host.plugins["XEP_0077"].in_band_submit(action, target, fields) | |
91 | |
79 def findGateways(self, target): | 92 def findGateways(self, target): |
80 """Find gateways in the target JID, using discovery protocol | 93 """Find gateways in the target JID, using discovery protocol |
81 Return an id used for retrieving the list of gateways | 94 Return an id used for retrieving the list of gateways |
82 """ | 95 """ |
83 debug ("find gateways (target = %s)" % target) | 96 debug ("find gateways (target = %s)" % target) |