From 6d7ec70dd117bebb82a6af240df56d927c12d530 Mon Sep 17 00:00:00 2001 From: Yann Leboulanger Date: Thu, 3 Nov 2005 22:37:21 +0000 Subject: [PATCH] add some test when we create / modify an account (a valid JID can have no nickname according to the RFC, but an account MUST have one) --- src/config.py | 32 ++++++++++++++++++++++---------- src/gtkgui.glade | 2 +- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/src/config.py b/src/config.py index 655e2f946..991dae7b8 100644 --- a/src/config.py +++ b/src/config.py @@ -1174,16 +1174,23 @@ class AccountModificationWindow: try: jid = helpers.parse_jid(jid) except helpers.InvalidFormat, s: - pritext = _('Invalid User ID') - dialogs.ErrorDialog(pritext, s).get_response() + pritext = _('Invalid Jabber ID') + dialogs.ErrorDialog(pritext, str(s)).get_response() + return + + n, hn = jid.split('@', 1) + if not n: + pritext = _('Invalid Jabber ID') + sectext = _('A Jabber ID must be in the form "user@servername".') + dialogs.ErrorDialog(pritext, sectext).get_response() return resource = self.xml.get_widget('resource_entry').get_text().decode('utf-8') try: resource = helpers.parse_resource(resource) except helpers.InvalidFormat, s: - pritext = _('Invalid User ID') - dialogs.ErrorDialog(pritext, s).get_response() + pritext = _('Invalid Jabber ID') + dialogs.ErrorDialog(pritext, (s)).get_response() return config['savepass'] = self.xml.get_widget( @@ -1219,7 +1226,6 @@ class AccountModificationWindow: config['proxy'] = proxy config['usessl'] = self.xml.get_widget('use_ssl_checkbutton').get_active() - n, hn = jid.split('@') config['name'] = n config['hostname'] = hn @@ -2509,16 +2515,26 @@ class AccountCreationWizardWindow: widgets = self.get_widgets() username = widgets['nick_entry'].get_text().decode('utf-8') + if not username: + pritext = _('Invalid nickname') + sectext = _('You must provide a nickname to configure this account.') + dialogs.ErrorDialog(pritext, sectext).get_response() + return server = widgets['server_comboboxentry'].child.get_text() savepass = widgets['save_password_checkbutton'].get_active() password = widgets['pass_entry'].get_text() + if not self.modify and password == '': + dialogs.ErrorDialog(_('Invalid password'), + _('You must enter a password for the new account.')).get_response() + return + jid = username + '@' + server # check if jid is conform to RFC and stringprep it try: jid = helpers.parse_jid(jid) except helpers.InvalidFormat, s: - pritext = _('Invalid User ID') + pritext = _('Invalid Jabber ID') dialogs.ErrorDialog(pritext, str(s)).get_response() return @@ -2581,10 +2597,6 @@ class AccountCreationWizardWindow: jid_label.set_label(string) def save_account(self, name, login, server, savepass, password): - if not self.modify and password == '': - dialogs.ErrorDialog(_('Invalid password'), - _('You must enter a password for the new account.')).get_response() - return config = {} config['name'] = login config['hostname'] = server diff --git a/src/gtkgui.glade b/src/gtkgui.glade index 1bbe589c2..22c9615cf 100644 --- a/src/gtkgui.glade +++ b/src/gtkgui.glade @@ -14321,7 +14321,7 @@ to the Jabber network. True True - Go Online when I press Finish + Connect when I press Finish True GTK_RELIEF_NORMAL True