From e27c6d74ada2dbe81c41b991a26028a4d9436ee4 Mon Sep 17 00:00:00 2001 From: mathieui Date: Sat, 4 Jun 2011 20:15:18 +0200 Subject: fix the display of the action 'emptying the status', and some few minor changes --- src/config.py | 6 +++--- src/contact.py | 2 +- src/multiuserchat.py | 8 +++++--- src/room.py | 6 ++++++ src/tabs.py | 33 +++++++++++++++++++-------------- src/xhtml.py | 7 ++++--- 6 files changed, 38 insertions(+), 24 deletions(-) diff --git a/src/config.py b/src/config.py index 4776e7d3..af6e05e6 100644 --- a/src/config.py +++ b/src/config.py @@ -134,15 +134,15 @@ class Config(RawConfigParser): # and copy the default config in it CONFIG_HOME = environ.get("XDG_CONFIG_HOME") if not CONFIG_HOME: - CONFIG_HOME = environ.get('HOME')+'/.config' -CONFIG_PATH = CONFIG_HOME + '/poezio/' + CONFIG_HOME = path.join(environ.get('HOME'), '/.config') +CONFIG_PATH = path.join(CONFIG_HOME, 'poezio') try: makedirs(CONFIG_PATH) except OSError: pass if not path.isfile(CONFIG_PATH+'poezio.cfg'): - copy2(path.join(path.dirname(__file__), '../data/default_config.cfg'), CONFIG_PATH+'poezio.cfg') + copy2(path.join(path.dirname(__file__), '../data/default_config.cfg'), path.join(CONFIG_PATH, 'poezio.cfg')) parser = OptionParser() parser.add_option("-f", "--file", dest="filename", default=CONFIG_PATH+'poezio.cfg', diff --git a/src/contact.py b/src/contact.py index 804a7068..ee0e1e80 100644 --- a/src/contact.py +++ b/src/contact.py @@ -166,5 +166,5 @@ class Contact(object): def __repr__(self): ret = '\n' diff --git a/src/multiuserchat.py b/src/multiuserchat.py index 87443e07..dd936039 100644 --- a/src/multiuserchat.py +++ b/src/multiuserchat.py @@ -25,6 +25,8 @@ from xml.etree import cElementTree as ET import logging log = logging.getLogger(__name__) +NS_MUC_ADMIN = 'http://jabber.org/protocol/muc#admin' + def send_private_message(xmpp, jid, line): """ Send a private message @@ -77,10 +79,10 @@ def eject_user(xmpp, jid, nick, reason): (try to) Eject an user from the room """ iq = xmpp.makeIqSet() - query = ET.Element('{http://jabber.org/protocol/muc#admin}query') - item = ET.Element('{http://jabber.org/protocol/muc#admin}item', {'nick':nick, 'role':'none'}) + query = ET.Element('{%s}query' % NS_MUC_ADMIN) + item = ET.Element('{%s}item' % NS_MUC_ADMIN, {'nick':nick, 'role':'none'}) if reason: - reason_el = ET.Element('{http://jabber.org/protocol/muc#admin}reason') + reason_el = ET.Element('{%s}reason' % NS_MUC_ADMIN) reason_el.text = reason item.append(reason_el) query.append(item) diff --git a/src/room.py b/src/room.py index a5a05845..45ebddbd 100644 --- a/src/room.py +++ b/src/room.py @@ -46,6 +46,9 @@ class Room(TextBuffer): self.joined = False def get_single_line_topic(self): + """ + Return the topic as a single-line string (for the window header) + """ return self.topic.replace('\n', '|') def log_message(self, txt, time, nickname): @@ -77,6 +80,9 @@ class Room(TextBuffer): return color def get_user_by_name(self, nick): + """ + Gets the user associated with the given nick, or None if not found + """ for user in self.users: if user.nick == nick: return user diff --git a/src/tabs.py b/src/tabs.py index 12bf08be..4ea3c280 100644 --- a/src/tabs.py +++ b/src/tabs.py @@ -63,6 +63,8 @@ SHOW_NAME = { '': _('available') } +NS_MUC_USER = 'http://jabber.org/protocol/muc#user' + class Tab(object): number = 0 tab_core = None @@ -119,8 +121,8 @@ class Tab(object): return command[2](the_input) else: # complete the command's name - words = ['/%s'%(name) for name in self.core.commands] +\ - ['/%s'% (name) for name in self.commands] + words = ['/%s'% (name) for name in self.core.commands] +\ + ['/%s' % (name) for name in self.commands] the_input.auto_completion(words, '') return True return False @@ -767,12 +769,10 @@ class MucTab(ChatTab): def handle_presence(self, presence): from_nick = presence['from'].resource from_room = presence['from'].bare - code = presence.find('{jabber:client}status') - status_codes = set([s.attrib['code'] for s in presence.findall('{http://jabber.org/protocol/muc#user}x/{http://jabber.org/protocol/muc#user}status')]) + status_codes = set([s.attrib['code'] for s in presence.findall('{%s}x/{%s}status' % (NS_MUC_USER, NS_MUC_USER))]) # Check if it's not an error presence. if presence['type'] == 'error': return self.core.room_error(presence, from_room) - msg = None affiliation = presence['muc']['affiliation'] show = presence['show'] status = presence['status'] @@ -834,7 +834,7 @@ class MucTab(ChatTab): room.add_message('\x194%(spec)s \x193%(nick)s \x195(\x194%(jid)s\x195) joined the room' % {'spec':theme.CHAR_JOIN, 'nick':from_nick, 'jid':jid.full}) def on_user_nick_change(self, room, presence, user, from_nick, from_room): - new_nick = presence.find('{http://jabber.org/protocol/muc#user}x/{http://jabber.org/protocol/muc#user}item').attrib['nick'] + new_nick = presence.find('{%s}x/{%s}item' % (NS_MUC_USER, NS_MUC_USER)).attrib['nick'] if user.nick == room.own_nick: room.own_nick = new_nick # also change our nick in all private discussion of this room @@ -851,8 +851,8 @@ class MucTab(ChatTab): When someone is banned from a muc """ room.users.remove(user) - by = presence.find('{http://jabber.org/protocol/muc#user}x/{http://jabber.org/protocol/muc#user}item/{http://jabber.org/protocol/muc#user}actor') - reason = presence.find('{http://jabber.org/protocol/muc#user}x/{http://jabber.org/protocol/muc#user}item/{http://jabber.org/protocol/muc#user}reason') + by = presence.find('{%s}x/{%s}item/{%s}actor' % (NS_MUC_USER, NS_MUC_USER, NS_MUC_USER)) + reason = presence.find('{%s}x/{%s}item/{%s}reason' % (NS_MUC_USER, NS_MUC_USER, NS_MUC_USER)) by = by.attrib['jid'] if by is not None else None if from_nick == room.own_nick: # we are banned room.disconnect() @@ -874,8 +874,8 @@ class MucTab(ChatTab): When someone is kicked from a muc """ room.users.remove(user) - by = presence.find('{http://jabber.org/protocol/muc#user}x/{http://jabber.org/protocol/muc#user}item/{http://jabber.org/protocol/muc#user}actor') - reason = presence.find('{http://jabber.org/protocol/muc#user}x/{http://jabber.org/protocol/muc#user}item/{http://jabber.org/protocol/muc#user}reason') + by = presence.find('{%s}x/{%s}item/{%s}actor' % (NS_MUC_USER, NS_MUC_USER, NS_MUC_USER)) + reason = presence.find('{%s}x/{%s}item/{%s}reason' % (NS_MUC_USER, NS_MUC_USER, NS_MUC_USER)) by = by.attrib['jid'] if by is not None else None if from_nick == room.own_nick: # we are kicked room.disconnect() @@ -931,9 +931,14 @@ class MucTab(ChatTab): if show != user.show and show in SHOW_NAME: msg += _('show: %s, ') % SHOW_NAME[show] display_message = True - if status and status != user.status: - msg += _('status: %s, ') % status + if status != user.status: + # if the user sets his status to nothing + if not status: + msg += _('show: %s, ') % SHOW_NAME[show] + else: + msg += _('status: %s, ') % status display_message = True + if not display_message: return msg = msg[:-2] # remove the last ", " @@ -1571,7 +1576,7 @@ class MucListTab(Tab): self.name = server self.upper_message = windows.Topic() self.upper_message.set_message('Chatroom list on server %s (Loading)' % self.name) - columns = ('node-part','name', 'users') + columns = ('node-part', 'name', 'users') self.list_header = windows.ColumnHeaderWin(columns) self.listview = windows.ListWin(columns) self.tab_win = windows.GlobalInfoBar() @@ -1764,6 +1769,7 @@ def diffmatch(search, string): def jid_and_name_match(contact, txt): """ + Match jid with text precisely """ if not txt: return True @@ -1776,7 +1782,6 @@ def jid_and_name_match_slow(contact, txt): A function used to know if a contact in the roster should be shown in the roster """ - ratio = 0.7 if not txt: return True # Everything matches when search is empty user = JID(contact.get_bare_jid()).user diff --git a/src/xhtml.py b/src/xhtml.py index d755229f..16972b65 100644 --- a/src/xhtml.py +++ b/src/xhtml.py @@ -28,11 +28,12 @@ import subprocess from sleekxmpp.xmlstream import ET from xml.etree.ElementTree import ElementTree from sys import version_info -from string import digits from config import config import logging +digits = '0123456789' # never trust the modules + log = logging.getLogger(__name__) shell_colors_re = re.compile(r'(\[(?:\d+;)*(?:\d+m))') @@ -73,9 +74,9 @@ def convert_links_to_plaintext(text): if child.tag == '{http://www.w3.org/1999/xhtml}a': if child.attrib['href'] != child.text: if child.text is None and 'title' in child.attrib: - link_text = '\n%s (%s)'%(child.attrib['href'], child.attrib['title']) + link_text = '\n%s (%s)' % (child.attrib['href'], child.attrib['title']) else: - link_text = '\n%s (%s)'%(child.attrib['href'], child.text) + link_text = '\n%s (%s)' % (child.attrib['href'], child.text) else: link_text = child.text if previous_child is not None: -- cgit v1.2.3 From 7d82a4fb19f8c180073c4313b2c5a9c8ec31b253 Mon Sep 17 00:00:00 2001 From: mathieui Date: Sat, 4 Jun 2011 20:44:14 +0200 Subject: =?UTF-8?q?some=20path.join=20forgotten=20causing=20the=20config?= =?UTF-8?q?=20file=20to=20be=20overwritten=20an=20not=20taken=20into=20acc?= =?UTF-8?q?ount=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/config.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/config.py b/src/config.py index af6e05e6..9cedcac7 100644 --- a/src/config.py +++ b/src/config.py @@ -134,18 +134,18 @@ class Config(RawConfigParser): # and copy the default config in it CONFIG_HOME = environ.get("XDG_CONFIG_HOME") if not CONFIG_HOME: - CONFIG_HOME = path.join(environ.get('HOME'), '/.config') + CONFIG_HOME = path.join(environ.get('HOME'), '.config') CONFIG_PATH = path.join(CONFIG_HOME, 'poezio') try: makedirs(CONFIG_PATH) except OSError: pass -if not path.isfile(CONFIG_PATH+'poezio.cfg'): +if not path.isfile(path.join(CONFIG_PATH, 'poezio.cfg')): copy2(path.join(path.dirname(__file__), '../data/default_config.cfg'), path.join(CONFIG_PATH, 'poezio.cfg')) parser = OptionParser() -parser.add_option("-f", "--file", dest="filename", default=CONFIG_PATH+'poezio.cfg', +parser.add_option("-f", "--file", dest="filename", default=path.join(CONFIG_PATH, 'poezio.cfg'), help="The config file you want to use", metavar="CONFIG_FILE") parser.add_option("-d", "--debug", dest="debug", help="The file where debug will be written", metavar="DEBUG_FILE") -- cgit v1.2.3 From 40d445e509dd5643150869862d608562ff5a01c0 Mon Sep 17 00:00:00 2001 From: Florent Le Coz Date: Tue, 14 Jun 2011 22:20:04 +0200 Subject: I add a char to show the active and paused chatstates in muc user lists --- src/windows.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/windows.py b/src/windows.py index eb6dde43..1d54f7ed 100644 --- a/src/windows.py +++ b/src/windows.py @@ -196,6 +196,10 @@ class UserList(Win): show_col = self.color_show[user.show] if user.chatstate == 'composing': char = 'X' + elif user.chatstate == 'active': + char = 'A' + elif user.chatstate == 'paused': + char = 'p' else: char = theme.CHAR_STATUS self.addstr(y, 0, char, common.curses_color_pair(show_col)) -- cgit v1.2.3 From dd9186c72a04f449c427bce31d35a283f3c61c25 Mon Sep 17 00:00:00 2001 From: Florent Le Coz Date: Wed, 15 Jun 2011 23:33:29 +0200 Subject: Fix the refresh of the muc info header on new messae --- src/core.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/core.py b/src/core.py index e096b65c..4aa1b2b3 100644 --- a/src/core.py +++ b/src/core.py @@ -971,6 +971,7 @@ class Core(object): self.add_message_to_text_buffer(room, body, date, nick_from) if tab is self.current_tab(): tab.text_win.refresh(tab._room) + tab.info_header.refresh(tab._room, tab.text_win) self.refresh_tab_win() def add_message_to_text_buffer(self, room, txt, time=None, nickname=None): -- cgit v1.2.3