Mercurial > libervia-backend
diff sat.tac @ 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 | 6491b7956c80 |
children | 2e3411a6baad |
line wrap: on
line diff
--- a/sat.tac Mon Dec 14 02:11:05 2009 +1100 +++ b/sat.tac Tue Dec 15 01:27:32 2009 +1100 @@ -42,6 +42,7 @@ import os.path from tools.memory import Memory +from tools.xml_tools import XMLTools from glob import glob try: @@ -278,7 +279,6 @@ self.bridge.register("isConnected", self.isConnected) self.bridge.register("launchAction", self.launchAction) self.bridge.register("confirmationAnswer", self.confirmationAnswer) - self.bridge.register("submitForm", self.submitForm) self.bridge.register("getProgress", self.getProgress) self._import_plugins() @@ -373,8 +373,8 @@ self.presence.available() self.disco.requestInfo(jid.JID(self.memory.getParamA("Server", "Connection"))).addCallback(self.serverDisco) - - ## Misc methods ## + + ## Misc methods ## def registerNewAccount(self, login, password, server, port = 5222, id = None): """Connect to a server and create a new account using in-band registration""" @@ -419,11 +419,29 @@ else: self.actionResult(action_id, "SUPPRESS", {}) - def submitForm(self, target, fields): - """Called when a form is submited""" + def submitForm(self, action, target, fields): + """submit a form + @param target: target jid where we are submitting + @param fields: list of tuples (name, value) + @return: tuple: (id, deferred) + """ to_jid = jid.JID(target) - print "Form submitted !", fields - return self.get_next_id() + + iq = compat.IQ(self.xmlstream, 'set') + iq["to"] = target + iq["from"] = self.me.full() + query = iq.addElement(('jabber:iq:register', 'query')) + if action=='SUBMIT': + form = XMLTools.tupleList2dataForm(fields) + query.addChild(form.toElement()) + elif action=='CANCEL': + query.addElement('remove') + else: + error ("FIXME FIXME FIXME: Unmanaged action (%s) in submitForm" % action) + raise NotImplementedError + + deferred = iq.send(target) + return (iq['id'], deferred) ## Client management ## @@ -448,7 +466,7 @@ def launchAction(self, type, data): """Launch a specific action asked by client @param type: action type (button) - @data: needed data to launch the action + @param data: needed data to launch the action @return: action id for result, or empty string in case or error """ @@ -489,6 +507,7 @@ #TODO: throw an error return to_jid=jid.JID(to) + status = None if not status else {None:status} #FIXME: use the proper way here (change signature to use dict) #TODO: refactor subscription bridge API if type=="": self.presence.available(to_jid, show, status, priority) @@ -531,16 +550,16 @@ def actionResult(self, id, type, data): """Send the result of an action @param id: same id used with action - @type: result type ("PARAM", "SUCCESS", "ERROR", "FORM") - @data: dictionary + @param type: result type ("PARAM", "SUCCESS", "ERROR", "FORM") + @param data: dictionary """ self.bridge.actionResult(type, id, data) def actionResultExt(self, id, type, data): """Send the result of an action, extended version @param id: same id used with action - @type: result type /!\ only "DICT_DICT" for this method - @data: dictionary of dictionaries + @param type: result type /!\ only "DICT_DICT" for this method + @param data: dictionary of dictionaries """ if type != "DICT_DICT": error("type for actionResultExt must be DICT_DICT, fixing it") @@ -552,9 +571,9 @@ def askConfirmation(self, id, type, data, cb): """Add a confirmation callback @param id: id used to get answer - @type: confirmation type ("YES/NO", "FILE_TRANSFERT") - @data: data (depend of confirmation type) - @cb: callback called with the answer + @param type: confirmation type ("YES/NO", "FILE_TRANSFERT") + @param data: data (depend of confirmation type) + @param cb: callback called with the answer """ if self.__waiting_conf.has_key(id): error ("Attempt to register two callbacks for the same confirmation")