fixes some stuff. Also fixed #1617

parent 93351156
......@@ -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):
......
......@@ -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'))
......
......@@ -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
......@@ -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):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment