summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorlouiz@4325f9fc-e183-4c21-96ce-0ab188b42d13 <louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13>2010-07-19 23:55:20 +0000
committerlouiz@4325f9fc-e183-4c21-96ce-0ab188b42d13 <louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13>2010-07-19 23:55:20 +0000
commit0cd619660c83a238bd0192ac5707e1ab591d7408 (patch)
tree5a7311a1f6997de4bef22cf13c15ba38b1c6eebf /src
parente656e5924bef38d5e69fffca6e1d46c7bed69139 (diff)
downloadpoezio-0cd619660c83a238bd0192ac5707e1ab591d7408.tar.gz
poezio-0cd619660c83a238bd0192ac5707e1ab591d7408.tar.bz2
poezio-0cd619660c83a238bd0192ac5707e1ab591d7408.tar.xz
poezio-0cd619660c83a238bd0192ac5707e1ab591d7408.zip
fixed #1587
Diffstat (limited to 'src')
-rw-r--r--src/common.py32
-rw-r--r--src/connection.py29
-rw-r--r--src/gui.py1
-rw-r--r--src/poezio.py32
4 files changed, 53 insertions, 41 deletions
diff --git a/src/common.py b/src/common.py
index 4406e4cb..456f73e5 100644
--- a/src/common.py
+++ b/src/common.py
@@ -43,9 +43,39 @@ import curses
import sys
import select
import errno
-import xmpp
import time
+class MyStdErr(object):
+ def __init__(self, fd):
+ """
+ Change sys.stderr to something like /dev/null
+ to disable any printout on the screen that would
+ mess everything
+ """
+ self.old_stderr = sys.stderr
+ sys.stderr = fd
+ def restaure(self):
+ """
+ Restaure the good ol' sys.stderr, because we need
+ it in order to print the tracebacks
+ """
+ sys.stderr = self.old_stderr
+
+my_stderr = MyStdErr(open('/dev/null', 'a'))
+
+def exception_handler(type_, value, trace):
+ """
+ on any traceback: exit ncurses and print the traceback
+ then exit the program
+ """
+ my_stderr.restaure()
+ curses.endwin()
+ curses.echo()
+ traceback.print_exception(type_, value, trace, None, sys.stderr)
+ sys.exit(2)
+
+import xmpp
+
def debug(string):
"""
Print a string in a file.
diff --git a/src/connection.py b/src/connection.py
index 62f17bb5..5e36ba97 100644
--- a/src/connection.py
+++ b/src/connection.py
@@ -31,7 +31,7 @@ import xmpp
from config import config
from logging import logger
from handler import Handler
-from common import jid_get_node, jid_get_domain, is_jid_the_same
+from common import jid_get_node, jid_get_domain, is_jid_the_same, exception_handler
class Connection(threading.Thread):
"""
@@ -125,21 +125,32 @@ class Connection(threading.Thread):
def handler_presence(self, connection, presence):
"""
- handles the presence messages
+ check if it's a normal or a muc presence
+ """
+ x = presence.getTag('x')
+ if x and x.getAttr('xmlns') == 'http://jabber.org/protocol/muc#user':
+ self.handler_muc_presence(connection, presence)
+ else:
+ self.handler_normal_presence(connection, presence)
+
+ def handler_normal_presence(self, connection, presence):
+ """
"""
- from common import debug
- debug('%s\n' % presence)
- if not connection:
- return
- if presence.getType() == 'error':
- self.error_message(presence)
- return
fro = presence.getFrom()
toj = presence.getAttr('to')
if fro == toj: # own presence
self.online = 2
self.jid = toj
self.handler.emit('on-connected', jid=fro)
+
+ def handler_muc_presence(self, connection, presence):
+ """
+ handles the presence messages
+ """
+ if not connection:
+ return
+ if presence.getType() == 'error':
+ self.error_message(presence)
return
self.handler.emit('room-presence', stanza=presence)
raise xmpp.protocol.NodeProcessed
diff --git a/src/gui.py b/src/gui.py
index 74194b6d..1c99ddef 100644
--- a/src/gui.py
+++ b/src/gui.py
@@ -351,7 +351,6 @@ class Gui(object):
doupdate()
def open_private_window(self, room_name, user_nick, focus=True):
- print anus
complete_jid = room_name+'/'+user_nick
for room in self.rooms: # if the room exists, focus it and return
if room.jid:
diff --git a/src/poezio.py b/src/poezio.py
index 501ccfd2..6a5dc435 100644
--- a/src/poezio.py
+++ b/src/poezio.py
@@ -20,39 +20,11 @@
"""
Starting point of poezio. Launches both the Connection and Gui
"""
+
import sys
import traceback
import curses
-
-class MyStdErr(object):
- def __init__(self, fd):
- """
- Change sys.stderr to something like /dev/null
- to disable any printout on the screen that would
- mess everything
- """
- self.old_stderr = sys.stderr
- sys.stderr = fd
- def restaure(self):
- """
- Restaure the good ol' sys.stderr, because we need
- it in order to print the tracebacks
- """
- sys.stderr = self.old_stderr
-
-my_stderr = MyStdErr(open('/dev/null', 'a'))
-
-def exception_handler(type_, value, trace):
- """
- on any traceback: exit ncurses and print the traceback
- then exit the program
- """
- global my_stderr
- my_stderr.restaure()
- curses.endwin()
- curses.echo()
- traceback.print_exception(type_, value, trace, None, sys.stderr)
- sys.exit(2)
+from common import MyStdErr, exception_handler
sys.excepthook = exception_handler