changeset 336:953536246d9d

core: added email in registerNewAccount
author Goffi <goffi@goffi.org>
date Wed, 25 May 2011 17:18:05 +0200
parents 99206631503e
children 4402ac630712
files frontends/src/bridge/DBus.py src/bridge/DBus.py src/bridge/bridge_constructor/bridge_template.ini src/core/sat_main.py src/core/xmpp.py
diffstat 5 files changed, 33 insertions(+), 57 deletions(-) [+]
line wrap: on
line diff
--- a/frontends/src/bridge/DBus.py	Tue May 24 00:56:35 2011 +0200
+++ b/frontends/src/bridge/DBus.py	Wed May 25 17:18:05 2011 +0200
@@ -124,8 +124,8 @@
     def launchAction(self, action_type, data, profile_key="@DEFAULT@"):
         return unicode(self.db_req_iface.launchAction(action_type, data, profile_key))
 
-    def registerNewAccount(self, login, password, host, port=5222):
-        return unicode(self.db_comm_iface.registerNewAccount(login, password, host, port))
+    def registerNewAccount(self, login, password, email, host, port=5222):
+        return unicode(self.db_comm_iface.registerNewAccount(login, password, email, host, port))
 
     def sendMessage(self, to_jid, message, subject='', mess_type="chat", profile_key="@DEFAULT@"):
         return self.db_comm_iface.sendMessage(to_jid, message, subject, mess_type, profile_key)
--- a/src/bridge/DBus.py	Tue May 24 00:56:35 2011 +0200
+++ b/src/bridge/DBus.py	Wed May 25 17:18:05 2011 +0200
@@ -45,72 +45,72 @@
     @dbus.service.signal(const_INT_PREFIX+const_REQ_SUFFIX,
                          signature='ssa{ss}')
     def actionResult(self, answer_type, id, data):
-        debug ("actionResult")
+        pass
 
     @dbus.service.signal(const_INT_PREFIX+const_REQ_SUFFIX,
                          signature='ssa{sa{ss}}')
     def actionResultExt(self, answer_type, id, data):
-        debug ("actionResultExt")
+        pass
 
     @dbus.service.signal(const_INT_PREFIX+const_REQ_SUFFIX,
                          signature='ssa{ss}')
     def askConfirmation(self, conf_type, id, data):
-        debug ("askConfirmation")
+        pass
 
     @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX,
                          signature='s')
     def connected(self, profile):
-        debug ("connected")
+        pass
 
     @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX,
                          signature='ss')
     def connectionError(self, error_type, profile):
-        debug ("connectionError")
+        pass
 
     @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX,
                          signature='ss')
     def contactDeleted(self, entity, profile):
-        debug ("contactDeleted")
+        pass
 
     @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX,
                          signature='s')
     def disconnected(self, profile):
-        debug ("disconnected")
+        pass
 
     @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX,
                          signature='ssss')
     def newAlert(self, message, title, alert_type, profile):
-        debug ("newAlert")
+        pass
 
     @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX,
                          signature='sa{ss}ass')
     def newContact(self, contact, attributes, groups, profile):
-        debug ("newContact")
+        pass
 
     @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX,
                          signature='sssss')
     def newMessage(self, from_jid, message, mess_type, to_jid, profile):
-        debug ("newMessage")
+        pass
 
     @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX,
                          signature='ssss')
     def paramUpdate(self, name, value, category, profile):
-        debug ("paramUpdate")
+        pass
 
     @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX,
                          signature='ssia{ss}s')
     def presenceUpdate(self, entity, show, priority, statuses, profile):
-        debug ("presenceUpdate")
+        pass
 
     @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX,
                          signature='sss')
     def subscribe(self, sub_type, entity, profile):
-        debug ("subscribe")
+        pass
 
     @dbus.service.signal(const_INT_PREFIX+const_REQ_SUFFIX,
                          signature='sa{ss}')
     def updatedValue(self, name, value):
-        debug ("updatedValue")
+        pass
 
 
     ### methods ###    
@@ -118,181 +118,151 @@
     @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
                          in_signature='ss', out_signature='')
     def addContact(self, entity, profile_key="@DEFAULT@"):
-        debug ("addContact")
         return self.cb["addContact"](unicode(entity), unicode(profile_key))
 
     @dbus.service.method(const_INT_PREFIX+const_REQ_SUFFIX,
                          in_signature='ssss', out_signature='s')
     def callMenu(self, category, name, menu_type, profile_key):
-        debug ("callMenu")
         return self.cb["callMenu"](unicode(category), unicode(name), unicode(menu_type), unicode(profile_key))
 
     @dbus.service.method(const_INT_PREFIX+const_REQ_SUFFIX,
                          in_signature='sba{ss}', out_signature='')
     def confirmationAnswer(self, id, accepted, data):
-        debug ("confirmationAnswer")
         return self.cb["confirmationAnswer"](unicode(id), accepted, data)
 
     @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
                          in_signature='s', out_signature='')
     def connect(self, profile_key="@DEFAULT@"):
-        debug ("connect")
         return self.cb["connect"](unicode(profile_key))
 
     @dbus.service.method(const_INT_PREFIX+const_REQ_SUFFIX,
                          in_signature='s', out_signature='i')
     def createProfile(self, profile):
-        debug ("createProfile")
         return self.cb["createProfile"](unicode(profile))
 
     @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
                          in_signature='ss', out_signature='')
     def delContact(self, entity, profile_key="@DEFAULT@"):
-        debug ("delContact")
         return self.cb["delContact"](unicode(entity), unicode(profile_key))
 
     @dbus.service.method(const_INT_PREFIX+const_REQ_SUFFIX,
                          in_signature='s', out_signature='i')
     def deleteProfile(self, profile):
-        debug ("deleteProfile")
         return self.cb["deleteProfile"](unicode(profile))
 
     @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
                          in_signature='s', out_signature='')
     def disconnect(self, profile_key="@DEFAULT@"):
-        debug ("disconnect")
         return self.cb["disconnect"](unicode(profile_key))
 
     @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
                          in_signature='s', out_signature='a(sa{ss}as)')
     def getContacts(self, profile_key="@DEFAULT@"):
-        debug ("getContacts")
         return self.cb["getContacts"](unicode(profile_key))
 
     @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
                          in_signature='ssi', out_signature='a{i(ss)}')
     def getHistory(self, from_jid, to_jid, size):
-        debug ("getHistory")
         return self.cb["getHistory"](unicode(from_jid), unicode(to_jid), size)
 
     @dbus.service.method(const_INT_PREFIX+const_REQ_SUFFIX,
                          in_signature='sss', out_signature='s')
     def getMenuHelp(self, category, name, menu_type):
-        debug ("getMenuHelp")
         return self.cb["getMenuHelp"](unicode(category), unicode(name), unicode(menu_type))
 
     @dbus.service.method(const_INT_PREFIX+const_REQ_SUFFIX,
                          in_signature='', out_signature='a(sss)')
     def getMenus(self, ):
-        debug ("getMenus")
         return self.cb["getMenus"]()
 
     @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
                          in_signature='ssss', out_signature='s')
     def getParamA(self, name, category, attribute="value", profile_key="@DEFAULT@"):
-        debug ("getParamA")
         return self.cb["getParamA"](unicode(name), unicode(category), unicode(attribute), unicode(profile_key))
 
     @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
                          in_signature='s', out_signature='s')
     def getParams(self, profile_key="@DEFAULT@"):
-        debug ("getParams")
         return self.cb["getParams"](unicode(profile_key))
 
     @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
                          in_signature='', out_signature='as')
     def getParamsCategories(self, ):
-        debug ("getParamsCategories")
         return self.cb["getParamsCategories"]()
 
     @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
                          in_signature='ss', out_signature='s')
     def getParamsForCategory(self, category, profile_key="@DEFAULT@"):
-        debug ("getParamsForCategory")
         return self.cb["getParamsForCategory"](unicode(category), unicode(profile_key))
 
     @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
                          in_signature='s', out_signature='s')
     def getParamsUI(self, profile_key="@DEFAULT@"):
-        debug ("getParamsUI")
         return self.cb["getParamsUI"](unicode(profile_key))
 
     @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
                          in_signature='s', out_signature='a{sa{s(sia{ss})}}')
     def getPresenceStatus(self, profile_key="@DEFAULT@"):
-        debug ("getPresenceStatus")
         return self.cb["getPresenceStatus"](unicode(profile_key))
 
     @dbus.service.method(const_INT_PREFIX+const_REQ_SUFFIX,
                          in_signature='s', out_signature='s')
     def getProfileName(self, profile_key="@DEFAULT@"):
-        debug ("getProfileName")
         return self.cb["getProfileName"](unicode(profile_key))
 
     @dbus.service.method(const_INT_PREFIX+const_REQ_SUFFIX,
                          in_signature='', out_signature='as')
     def getProfilesList(self, ):
-        debug ("getProfilesList")
         return self.cb["getProfilesList"]()
 
     @dbus.service.method(const_INT_PREFIX+const_REQ_SUFFIX,
                          in_signature='s', out_signature='a{ss}')
     def getProgress(self, id):
-        debug ("getProgress")
         return self.cb["getProgress"](unicode(id))
 
     @dbus.service.method(const_INT_PREFIX+const_REQ_SUFFIX,
                          in_signature='', out_signature='s')
     def getVersion(self, ):
-        debug ("getVersion")
         return self.cb["getVersion"]()
 
     @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
                          in_signature='s', out_signature='a{ss}')
     def getWaitingSub(self, profile_key="@DEFAULT@"):
-        debug ("getWaitingSub")
         return self.cb["getWaitingSub"](unicode(profile_key))
 
     @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
                          in_signature='s', out_signature='b')
     def isConnected(self, profile_key="@DEFAULT@"):
-        debug ("isConnected")
         return self.cb["isConnected"](unicode(profile_key))
 
     @dbus.service.method(const_INT_PREFIX+const_REQ_SUFFIX,
                          in_signature='sa{ss}s', out_signature='s')
     def launchAction(self, action_type, data, profile_key="@DEFAULT@"):
-        debug ("launchAction")
         return self.cb["launchAction"](unicode(action_type), data, unicode(profile_key))
 
     @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
-                         in_signature='sssi', out_signature='s')
-    def registerNewAccount(self, login, password, host, port=5222):
-        debug ("registerNewAccount")
-        return self.cb["registerNewAccount"](unicode(login), unicode(password), unicode(host), port)
+                         in_signature='ssssi', out_signature='s')
+    def registerNewAccount(self, login, password, email, host, port=5222):
+        return self.cb["registerNewAccount"](unicode(login), unicode(password), unicode(email), unicode(host), port)
 
     @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
                          in_signature='sssss', out_signature='')
     def sendMessage(self, to_jid, message, subject='', mess_type="chat", profile_key="@DEFAULT@"):
-        debug ("sendMessage")
         return self.cb["sendMessage"](unicode(to_jid), unicode(message), unicode(subject), unicode(mess_type), unicode(profile_key))
 
     @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
                          in_signature='ssss', out_signature='')
     def setParam(self, name, value, category, profile_key="@DEFAULT@"):
-        debug ("setParam")
         return self.cb["setParam"](unicode(name), unicode(value), unicode(category), unicode(profile_key))
 
     @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
                          in_signature='ssia{ss}s', out_signature='')
     def setPresence(self, to_jid='', show='', priority=0, statuses={}, profile_key="@DEFAULT@"):
-        debug ("setPresence")
         return self.cb["setPresence"](unicode(to_jid), unicode(show), priority, statuses, unicode(profile_key))
 
     @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
                          in_signature='sss', out_signature='')
     def subscription(self, sub_type, entity, profile_key="@DEFAULT@"):
-        debug ("subscription")
         return self.cb["subscription"](unicode(sub_type), unicode(entity), unicode(profile_key))
 
     
--- a/src/bridge/bridge_constructor/bridge_template.ini	Tue May 24 00:56:35 2011 +0200
+++ b/src/bridge/bridge_constructor/bridge_template.ini	Wed May 25 17:18:05 2011 +0200
@@ -196,14 +196,15 @@
 deprecated=
 type=method
 category=communication
-sig_in=sssi
+sig_in=ssssi
 sig_out=s
-param_3_default=5222
+param_4_default=5222
 doc=Register a new account on a given server
 doc_param_0=login: login of the account
 doc_param_1=password: password of the account
-doc_param_2=host: host of the server to register to
-doc_param_3=port: port of the server to register to
+doc_param_2=email: email of the account
+doc_param_3=host: host of the server to register to
+doc_param_4=port: port of the server to register to
 
 [connect]
 type=method
--- a/src/core/sat_main.py	Tue May 24 00:56:35 2011 +0200
+++ b/src/core/sat_main.py	Wed May 25 17:18:05 2011 +0200
@@ -265,11 +265,11 @@
             return None
         return self.profiles[profile]
 
-    def registerNewAccount(self, login, password, server, port = 5222, id = None):
+    def registerNewAccount(self, login, password, email, server, port = 5222, id = None):
         """Connect to a server and create a new account using in-band registration"""
 
         next_id = id or sat_next_id()  #the id is used to send server's answer
-        serverRegistrer = xmlstream.XmlStreamFactory(xmpp.RegisteringAuthenticator(self, server, login, password, next_id))
+        serverRegistrer = xmlstream.XmlStreamFactory(xmpp.RegisteringAuthenticator(self, server, login, password, email, next_id))
         connector = reactor.connectTCP(server, port, serverRegistrer)
         serverRegistrer.clientConnectionLost = lambda conn, reason: connector.disconnect()
         
@@ -304,7 +304,7 @@
             user = jid.parse(self.memory.getParamA("JabberID", "Connection", profile_key=profile))[0]
             password = self.memory.getParamA("Password", "Connection", profile_key=profile)
             server = self.memory.getParamA("Server", "Connection", profile_key=profile)
-            self.registerNewAccount(user, password, server, id=action_id)
+            self.registerNewAccount(user, password, None, server, id=action_id)
         else:
             self.actionResult(action_id, "SUPPRESS", {})
 
--- a/src/core/xmpp.py	Tue May 24 00:56:35 2011 +0200
+++ b/src/core/xmpp.py	Wed May 25 17:18:05 2011 +0200
@@ -236,12 +236,13 @@
 
 class RegisteringAuthenticator(xmlstream.ConnectAuthenticator):
 
-    def __init__(self, host, jabber_host, user_login, user_pass, answer_id):
+    def __init__(self, host, jabber_host, user_login, user_pass, email, answer_id):
         xmlstream.ConnectAuthenticator.__init__(self, jabber_host)
         self.host = host
         self.jabber_host = jabber_host
         self.user_login = user_login
         self.user_pass = user_pass
+        self.user_email = email
         self.answer_id = answer_id
         print _("Registration asked for"),user_login, user_pass, jabber_host
     
@@ -258,6 +259,10 @@
         _user.addContent(self.user_login)
         _pass = query.addElement('password')
         _pass.addContent(self.user_pass)
+        if self.user_email:
+            _email = query.addElement('email')
+            _email.addContent(self.user_email)
+        print iq.toXml()
         reg = iq.send(self.jabber_host).addCallbacks(self.registrationAnswer, self.registrationFailure)
 
     def registrationAnswer(self, answer):