summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/connection.py5
-rw-r--r--src/gui.py13
-rw-r--r--src/keyboard.py11
-rw-r--r--src/window.py5
4 files changed, 24 insertions, 10 deletions
diff --git a/src/connection.py b/src/connection.py
index f24403a8..62f17bb5 100644
--- a/src/connection.py
+++ b/src/connection.py
@@ -100,7 +100,7 @@ class Connection(threading.Thread):
password = config.get('password', '')
jid = config.get('jid', '')
auth = self.client.auth(jid_get_node(jid), password, "salut")
- return auth
+ return True
def register_handlers(self):
"""
@@ -127,6 +127,8 @@ class Connection(threading.Thread):
"""
handles the presence messages
"""
+ from common import debug
+ debug('%s\n' % presence)
if not connection:
return
if presence.getType() == 'error':
@@ -166,6 +168,7 @@ class Connection(threading.Thread):
self.handler.emit('room-message', stanza=message)
else:
self.handler.emit('private-message', stanza=message)
+
raise xmpp.protocol.NodeProcessed
def process(self, timeout=10):
diff --git a/src/gui.py b/src/gui.py
index 96f27907..74194b6d 100644
--- a/src/gui.py
+++ b/src/gui.py
@@ -145,8 +145,8 @@ class Gui(object):
if char in self.key_func.keys():
self.key_func[char]()
else:
- # if len(char) > 1:
- # continue # ignore non-handled keyboard shortcuts
+ if len(char.decode('utf-8')) > 1:
+ continue # ignore non-handled keyboard shortcuts
self.window.do_command(char)
def current_room(self):
@@ -343,12 +343,15 @@ class Gui(object):
room = self.get_room_by_name(jid) # get the tab with the private conversation
if not room: # It's the first message we receive: create the tab
room = self.open_private_window(room_from, nick_from, False)
+ if not room:
+ return
body = stanza.getBody()
self.add_message_to_room(room, body, None, nick_from)
self.window.input.refresh()
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:
@@ -356,7 +359,10 @@ class Gui(object):
self.command_win(str(room.nb))
return
# create the new tab
- own_nick = self.get_room_by_name(room_name).own_nick
+ room = self.get_room_by_name(room_name)
+ if not room:
+ return None
+ own_nick = room.own_nick
r = Room(complete_jid, own_nick, self.window, complete_jid)
# insert it in the rooms
if self.current_room().nb == 0:
@@ -377,6 +383,7 @@ class Gui(object):
"""
Display the message on the room window
"""
+ delay_tag = stanza.getTag('delay', namespace='urn:xmpp:delay')
if delay_tag:
delayed = True
date = common.datetime_tuple(delay_tag.getAttr('stamp'))
diff --git a/src/keyboard.py b/src/keyboard.py
index c9836250..c06e66ec 100644
--- a/src/keyboard.py
+++ b/src/keyboard.py
@@ -21,14 +21,17 @@
Functions to interact with the keyboard
Mainly, read keys entered and return a string (most
of the time ONE char, but may be longer if it's a keyboard
-shortcut, like ^A or KEY_RESIZE)
+shortcut, like ^A, M-a or KEY_RESIZE)
"""
+from common import debug
+
def get_next_byte(s):
"""
Read the next byte of the utf-8 char
"""
c = s.getkey()
+ debug(c)
if len(c) > 4:
return (None, c)
return (ord(c), c)
@@ -45,16 +48,16 @@ def read_char(s):
if first <= 26: # transform Ctrl+* keys
char = "^"+chr(first + 64)
if first == 27:
- (_, c) = get_next_byte(s)
+ (first, c) = get_next_byte(s)
char = "M-"+c
- return char
+ # return char
if 194 <= first:
(code, c) = get_next_byte(s) # 2 bytes char
char += c
if 224 <= first:
(code, c) = get_next_byte(s) # 3 bytes char
char += c
- if 240 <= code:
+ if 240 <= first:
(code, c) = get_next_byte(s) # 4 bytes char
char += c
return char
diff --git a/src/window.py b/src/window.py
index 833e77b7..8bef5a63 100644
--- a/src/window.py
+++ b/src/window.py
@@ -630,8 +630,9 @@ class Input(Win):
self.text = u''
self.pos = 0
self.line_pos = 0
- self.history.append(txt)
- self.histo_pos = len(self.history)-1
+ if len(txt) != 0:
+ self.history.append(txt)
+ self.histo_pos = len(self.history)-1
return txt.encode('utf-8')
def rewrite_text(self):