diff src/core/sat_main.py @ 1037:6e975c6b0faf

core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin: - the bridge method has been removed, now a plugin takes care of it with XMLUI callback system - TODO: xmpp.RegisteringAuthenticator still needs to be fixed
author souliane <souliane@mailoo.org>
date Fri, 16 May 2014 00:58:20 +0200
parents b262ae6d53af
children 066308706dc6
line wrap: on
line diff
--- a/src/core/sat_main.py	Fri May 16 00:53:09 2014 +0200
+++ b/src/core/sat_main.py	Fri May 16 00:58:20 2014 +0200
@@ -20,7 +20,7 @@
 from sat.core.i18n import _, languageSwitch
 from twisted.application import service
 from twisted.internet import defer
-from twisted.words.protocols.jabber import jid, xmlstream
+from twisted.words.protocols.jabber import jid
 from twisted.words.xish import domish
 from twisted.internet import reactor
 from wokkel.xmppim import RosterItem
@@ -102,7 +102,6 @@
         self.bridge.register("getEntityData", lambda _jid, keys, profile: self.memory.getEntityData(jid.JID(_jid), keys, profile))
         self.bridge.register("asyncCreateProfile", self.memory.asyncCreateProfile)
         self.bridge.register("asyncDeleteProfile", self.memory.asyncDeleteProfile)
-        self.bridge.register("registerNewAccount", self.registerNewAccount)
         self.bridge.register("connect", self.connect)
         self.bridge.register("asyncConnect", self.asyncConnect)
         self.bridge.register("disconnect", self.disconnect)
@@ -413,52 +412,6 @@
             raise exceptions.ProfileKeyUnknownError
         return [self.profiles[profile]]
 
-    def registerNewAccount(self, login, password, email, server, port=5222, id_=None, profile_key=C.PROF_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 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()
-
-        return next_id
-
-    def registerNewAccountCB(self, data, profile):
-        # FIXME: to be removed/redone elsewhere
-        user = jid.parse(self.memory.getParamA("JabberID", "Connection", profile_key=profile))[0]
-        server = self.memory.getParamA("Server", "Connection", profile_key=profile)
-        d = self.memory.asyncGetParamA("Password", "Connection", profile_key=profile)
-
-        def gotPassword(password):
-            if not user or not password or not server:
-                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)
-
-            self.askConfirmation(
-                confirm_id, "YES/NO",
-                {"message": _("Are you sure to register new account [%(user)s] to server %(server)s ?") % {'user': user, 'server': server, 'profile': profile}},
-                self.regisConfirmCB, profile)
-            print "===============+++++++++++ REGISTER NEW ACCOUNT++++++++++++++============"
-
-        d.addCallback(gotPassword)
-
-    def regisConfirmCB(self, id, accepted, data, profile):
-        print _("register Confirmation CB ! (%s)") % str(accepted)
-        action_id, profile = self.__private_data[id]
-        del self.__private_data[id]
-        if accepted:
-            user = jid.parse(self.memory.getParamA("JabberID", "Connection", profile_key=profile))[0]
-            server = self.memory.getParamA("Server", "Connection", profile_key=profile)
-            d = self.memory.asyncGetParamA("Password", "Connection", profile_key=profile)
-            d.addCallback(lambda password: self.registerNewAccount(user, password, None, server, id=action_id))
-        else:
-            self.actionResult(action_id, "SUPPRESS", {}, profile)
-
     ## Client management ##
 
     def setParam(self, name, value, category, security_limit, profile_key):