core, memory, plugins, stdui, frontends: look for DNS SRV records when server is not specified:

- fix bug 3
    - modify "Connection" params:
          - rename "Server" to "Force server" and "Port" to "Force port"
          - set the default value to empty string for both
This commit is contained in:
souliane 2014-06-23 00:44:10 +02:00
commit d4eff5b99c
2 changed files with 26 additions and 19 deletions

View file

@ -192,7 +192,7 @@ class MiscAccount(object):
#FIXME: values must be in a config file instead of hardcoded
self.host.memory.setParam("JabberID", "%s@%s/%s" % (profile, self.getConfig('new_account_domain'), self.getConfig('new_account_resource')),
"Connection", profile_key=profile)
self.host.memory.setParam("Server", self.getConfig('new_account_server'),
self.host.memory.setParam(C.FORCE_SERVER_PARAM, self.getConfig('new_account_server'),
"Connection", profile_key=profile)
self.host.memory.setParam("Password", password,
"Connection", profile_key=profile)

View file

@ -55,14 +55,14 @@ class RegisterAccount(object):
def registerNewAccountCB(self, data, profile):
"""Called when the use click on the "New account" button."""
session_data = {}
for param in ('JabberID', 'Password', 'Port', 'Server'):
for param in ('JabberID', 'Password', C.FORCE_PORT_PARAM, C.FORCE_SERVER_PARAM):
try:
session_data[param] = data["%s%s%s%s" % (SAT_FORM_PREFIX, "Connection", SAT_PARAM_SEPARATOR, param)]
except KeyError:
if param == 'Port':
if param == C.FORCE_PORT_PARAM:
session_data[param] = 5222
for param in ('JabberID', 'Password', 'Server'):
for param in ('JabberID', 'Password', C.FORCE_SERVER_PARAM):
if not session_data[param]:
form_ui = xml_tools.XMLUI("popup", title=D_("Missing values"))
form_ui.addText(D_("No user, password or server given: can't register new account."))
@ -71,7 +71,7 @@ class RegisterAccount(object):
user = jid.parse(session_data['JabberID'])[0]
session_id, dummy = self._sessions.newSession(session_data, profile)
form_ui = xml_tools.XMLUI("form", title=D_("Register new account"), submit_id=self.__register_account_id, session_id=session_id)
form_ui.addText(D_("Do you want to register a new XMPP account [%(user)s] on server %(server)s ?") % {'user': user, 'server': session_data['Server']})
form_ui.addText(D_("Do you want to register a new XMPP account [%(user)s] on server %(server)s ?") % {'user': user, 'server': session_data[C.FORCE_SERVER_PARAM]})
return {'xmlui': form_ui.toXml()}
def _registerConfirmation(self, data, profile):
@ -80,11 +80,11 @@ class RegisterAccount(object):
self.host.memory.setParam("JabberID", session_data["JabberID"], "Connection", profile_key=profile)
self.host.memory.setParam("Password", session_data["Password"], "Connection", profile_key=profile)
self.host.memory.setParam("Server", session_data["Server"], "Connection", profile_key=profile)
self.host.memory.setParam("Port", session_data["Port"], "Connection", profile_key=profile)
self.host.memory.setParam(C.FORCE_SERVER_PARAM, session_data[C.FORCE_SERVER_PARAM], "Connection", profile_key=profile)
self.host.memory.setParam(C.FORCE_PORT_PARAM, session_data[C.FORCE_PORT_PARAM], "Connection", profile_key=profile)
user = jid.parse(session_data['JabberID'])[0]
d = self._registerNewAccount(user, session_data["Password"], None, session_data["Server"], profile_key=profile)
d = self._registerNewAccount(user, session_data["Password"], None, session_data[C.FORCE_SERVER_PARAM], profile_key=profile)
del self._sessions[data['session_id']]
return d