From 899a33ae477df3dec4541cb86d65783677d37211 Mon Sep 17 00:00:00 2001 From: "louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13" Date: Wed, 24 Mar 2010 16:44:55 +0000 Subject: fixed #1235 (affiche un message si la connexion echoue) --- src/connection.py | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'src/connection.py') diff --git a/src/connection.py b/src/connection.py index 9b047da9..c514d964 100644 --- a/src/connection.py +++ b/src/connection.py @@ -17,6 +17,16 @@ # You should have received a copy of the GNU General Public License # along with Poezio. If not, see . +from gettext import (bindtextdomain, textdomain, bind_textdomain_codeset, + gettext as _) + + +bindtextdomain('poezio') +textdomain('poezio') +bind_textdomain_codeset('poezio', 'utf-8') +import locale +locale.setlocale(locale.LC_ALL, '') + import sys import xmpp @@ -50,10 +60,10 @@ class Connection(threading.Thread): """ sys.excepthook = exception_handler if not self.connect_to_server(self.server, self.port): - logger.error('Could not connect to server') + self.handler.emit('error', msg='Could not connect to server') sys.exit(-1) if not self.authenticate(): - logger.error('Could not authenticate to server') + self.handler.emit('error', msg='Could not authenticate to server') sys.exit(-1) self.client.sendInitPresence(requestRoster=0) self.online = 1 # 2 when confirmation of auth is received @@ -74,7 +84,12 @@ class Connection(threading.Thread): def authenticate(self, anon=True): if anon: - return self.client.auth(None, "", self.resource) + try: + self.client.auth(None, "", self.resource) + return True + except TypeError: + self.handler.emit('error', msg=_('Error: Could not authenticate. Please make sure the server you chose (%s) supports anonymous authentication' % (config.get('server', '')))) # TODO msg + return None else: log.error('Non-anonymous connections not handled currently') return None -- cgit v1.2.3