summaryrefslogtreecommitdiff
path: root/src/core.py
diff options
context:
space:
mode:
authorlouiz@4325f9fc-e183-4c21-96ce-0ab188b42d13 <louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13>2011-01-08 23:20:27 +0000
committerlouiz@4325f9fc-e183-4c21-96ce-0ab188b42d13 <louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13>2011-01-08 23:20:27 +0000
commit8017b2d9f1eceaf31aa95f87ee356ab8c114cde3 (patch)
tree8a4df03f24a7c785a37c1a947b7b05486894af0b /src/core.py
parentaf651cbc46e5227ff815689ee7cf3ce4b3ffe0be (diff)
downloadpoezio-8017b2d9f1eceaf31aa95f87ee356ab8c114cde3.tar.gz
poezio-8017b2d9f1eceaf31aa95f87ee356ab8c114cde3.tar.bz2
poezio-8017b2d9f1eceaf31aa95f87ee356ab8c114cde3.tar.xz
poezio-8017b2d9f1eceaf31aa95f87ee356ab8c114cde3.zip
Handle authentication and connection errors. fixed #1994
Diffstat (limited to 'src/core.py')
-rw-r--r--src/core.py40
1 files changed, 34 insertions, 6 deletions
diff --git a/src/core.py b/src/core.py
index 7ab4917d..de16bcae 100644
--- a/src/core.py
+++ b/src/core.py
@@ -147,7 +147,10 @@ class Core(object):
}
# Add handlers
- self.xmpp.add_event_handler("session_start", self.on_connected)
+ self.xmpp.add_event_handler('connected', self.on_connected)
+ self.xmpp.add_event_handler('disconnected', self.on_disconnected)
+ self.xmpp.add_event_handler('failed_auth', self.on_failed_auth)
+ self.xmpp.add_event_handler("session_start", self.on_session_start)
self.xmpp.add_event_handler("groupchat_presence", self.on_groupchat_presence)
self.xmpp.add_event_handler("groupchat_message", self.on_groupchat_message)
self.xmpp.add_event_handler("groupchat_subject", self.on_groupchat_subject)
@@ -157,6 +160,9 @@ class Core(object):
self.xmpp.add_event_handler("roster_update", self.on_roster_update)
self.xmpp.add_event_handler("changed_status", self.on_presence)
+ self.information(_('Welcome to poezio!'))
+ self.refresh_window()
+
def on_exception(self, typ, value, trace):
"""
When an exception in raised, open a special tab
@@ -240,14 +246,36 @@ class Core(object):
if tab and isinstance(tab, tabs.ConversationTab):
self.add_message_to_text_buffer(tab.get_room(), msg)
+ def on_failed_connection(self):
+ """
+ We cannot contact the remote server
+ """
+ self.information(_("Connection to remote server failed"))
+
+ def on_disconnected(self, event):
+ """
+ When we are disconnected from remote server
+ """
+ self.information(_("Disconnected from server."))
+
+ def on_failed_auth(self, event):
+ """
+ Authentication failed
+ """
+ self.information(_("Authentication failed."))
def on_connected(self, event):
"""
+ Remote host responded, but we are not yet authenticated
+ """
+ self.information(_("Connected to server."))
+
+ def on_session_start(self, event):
+ """
Called when we are connected and authenticated
"""
- self.information(_("Welcome on Poezio \o/!"))
+ self.information(_("Authentication success."))
self.information(_("Your JID is %s") % self.xmpp.boundjid.full)
-
if not self.xmpp.anon:
# request the roster
self.xmpp.getRoster()
@@ -598,15 +626,15 @@ class Core(object):
"""
main loop waiting for the user to press a key
"""
- self.refresh_window()
+ curses.ungetch('\n') # FIXME
while self.running:
- self.doupdate()
- char=read_char(self.stdscr)
+ char = read_char(self.stdscr)
# search for keyboard shortcut
if char in list(self.key_func.keys()):
self.key_func[char]()
else:
self.do_command(char)
+ self.doupdate()
def current_tab(self):
"""