changeset 813:1a1600491d9d

core: registerNewAccount partial fix
author Goffi <goffi@goffi.org>
date Tue, 04 Feb 2014 18:54:06 +0100
parents 084b52afdceb
children 59c7bc51c323
files src/core/sat_main.py src/memory/memory.py
diffstat 2 files changed, 5 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/core/sat_main.py	Tue Feb 04 18:51:16 2014 +0100
+++ b/src/core/sat_main.py	Tue Feb 04 18:54:06 2014 +0100
@@ -378,12 +378,12 @@
             return None
         return self.profiles[profile].getHostJid()
 
-    def registerNewAccount(self, login, password, email, server, port=5222, id=None, profile_key='@NONE@'):
+    def registerNewAccount(self, login, password, email, server, port=5222, id_=None, profile_key='@NONE@'):
         """Connect to a server and create a new account using in-band registration"""
         profile = self.memory.getProfileName(profile_key)
         assert(profile)
 
-        next_id = id or sat_next_id()  # the id is used to send server's answer
+        next_id = id_ or self.get_next_id()  # the id is used to send server's answer
         serverRegistrer = xmlstream.XmlStreamFactory(xmpp.RegisteringAuthenticator(self, server, login, password, email, next_id, profile))
         connector = reactor.connectTCP(server, port, serverRegistrer)
         serverRegistrer.clientConnectionLost = lambda conn, reason: connector.disconnect()
@@ -397,11 +397,9 @@
         server = self.memory.getParamA("Server", "Connection", profile_key=profile)
 
         if not user or not password or not server:
-            info(_('No user or server given'))
-            #TODO: a proper error message must be sent to frontend
-            self.actionResult(id, "ERROR", {'message': _("No user, password or server given, can't register new account.")}, profile)
-            return
+            raise exceptions.DataError(_("No user, password or server given, can't register new account."))
 
+        # FIXME: to be fixed with XMLUI dialogs once their implemented
         confirm_id = sat_next_id()
         self.__private_data[confirm_id] = (id, profile)
 
--- a/src/memory/memory.py	Tue Feb 04 18:51:16 2014 +0100
+++ b/src/memory/memory.py	Tue Feb 04 18:54:06 2014 +0100
@@ -213,7 +213,7 @@
         self.default_profile = None
         self.params = {}
         self.params_gen = {}
-        host.registerCallback(host.registerNewAccountCB, force_id="registerNewAccount")
+        host.registerCallback(host.registerNewAccountCB, with_data=True, force_id="registerNewAccount")
 
     def createProfile(self, profile):
         """Create a new profile