Mercurial > libervia-backend
diff 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 |
line wrap: on
line diff
--- a/plugins/plugin_xep_0100.py Mon Dec 14 02:11:05 2009 +1100 +++ b/plugins/plugin_xep_0100.py Tue Dec 15 01:27:32 2009 +1100 @@ -30,7 +30,7 @@ "name": "Gateways Plugin", "import_name": "XEP_0100", "type": "XEP", -"dependencies": [], +"dependencies": ["XEP_0077"], "main": "XEP_0100", "description": """Implementation of Gateways protocol""" } @@ -42,6 +42,7 @@ self.host = host self.__gateways = {} #dict used to construct the answer to findGateways. Key = target jid host.bridge.addMethod("findGateways", ".communication", in_sign='s', out_sign='s', method=self.findGateways) + host.bridge.addMethod("gatewayRegister", ".request", in_sign='ssa(ss)', out_sign='s', method=self.gatewayRegister) def discoInfo(self, disco, entity, request_id): """Find disco infos about entity, to check if it is a gateway""" @@ -76,6 +77,18 @@ debug ("item found: %s", item.name) self.host.disco.requestInfo(item.entity).addCallback(self.discoInfo, 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""" + print "Registration successful, doing the rest" + self.host.addContact(target) + self.host.setPresence(target) + + def gatewayRegister(self, action, target, fields): + """Register gateway using in-band registration, then log-in to gateway""" + if action == 'SUBMIT': + 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): """Find gateways in the target JID, using discovery protocol Return an id used for retrieving the list of gateways