diff options
author | Florent Le Coz <louiz@louiz.org> | 2011-11-06 17:54:05 +0100 |
---|---|---|
committer | Florent Le Coz <louiz@louiz.org> | 2011-11-06 17:54:05 +0100 |
commit | 07f9fab401f34753d0619ebb8d65f6f9df97931d (patch) | |
tree | 11533f3d2b844696f8df1dcc3d48b1e477f89cfe | |
parent | 700a59df5c2fb953b6e28dff2485b5952dcb3515 (diff) | |
parent | 7d861ee88514b38081f748a2b9f844eb56c6c349 (diff) | |
download | poezio-07f9fab401f34753d0619ebb8d65f6f9df97931d.tar.gz poezio-07f9fab401f34753d0619ebb8d65f6f9df97931d.tar.bz2 poezio-07f9fab401f34753d0619ebb8d65f6f9df97931d.tar.xz poezio-07f9fab401f34753d0619ebb8d65f6f9df97931d.zip |
Merge branch 'master' into plugins
Conflicts:
src/core.py
-rw-r--r-- | src/core.py | 14 | ||||
-rw-r--r-- | src/tabs.py | 17 | ||||
-rw-r--r-- | src/windows.py | 23 |
3 files changed, 35 insertions, 19 deletions
diff --git a/src/core.py b/src/core.py index 1f21e36d..d9d0b00e 100644 --- a/src/core.py +++ b/src/core.py @@ -50,6 +50,7 @@ from text_buffer import TextBuffer from keyboard import read_char from theming import get_theme from fifo import Fifo +from windows import g_lock # http://xmpp.org/extensions/xep-0045.html#errorstatus ERROR_AND_STATUS_CODES = { @@ -72,8 +73,6 @@ possible_show = {'available':None, 'xa':'xa' } -resize_lock = threading.Lock() - Status = collections.namedtuple('Status', 'show message') class Core(object): @@ -269,15 +268,16 @@ class Core(object): """ Resize the global_information_win only once at each resize. """ - self.information_win.resize(self.information_win_size, tabs.Tab.width, - tabs.Tab.height - 2 - self.information_win_size, 0) - + with g_lock: + self.information_win.resize(self.information_win_size, tabs.Tab.width, + tabs.Tab.height - 2 - self.information_win_size, 0) def resize_global_info_bar(self): """ Resize the GlobalInfoBar only once at each resize """ - self.tab_win.resize(1, tabs.Tab.width, tabs.Tab.height - 2, 0) + with g_lock: + self.tab_win.resize(1, tabs.Tab.width, tabs.Tab.height - 2, 0) def on_exception(self, typ, value, trace): """ @@ -764,7 +764,7 @@ class Core(object): tabs.Tab.resize(self.stdscr) self.resize_global_information_win() self.resize_global_info_bar() - with resize_lock: + with g_lock: for tab in self.tabs: if config.get('lazy_resize', 'true') == 'true': tab.need_resize = True diff --git a/src/tabs.py b/src/tabs.py index 7e6c5dd2..63b1628f 100644 --- a/src/tabs.py +++ b/src/tabs.py @@ -305,7 +305,7 @@ class ChatTab(Tab): # build the list of the recent words char_we_dont_want = string.punctuation+' ' words = list() - for msg in self.messages[:-40:-1]: + for msg in self._text_buffer.messages[:-40:-1]: if not msg: continue txt = xhtml.clean_text(msg.txt) @@ -498,7 +498,7 @@ class MucTab(ChatTab): """ /clear """ - self.messages = [] + self._text_buffer.messages = [] self.text_win.rebuild_everything(self._text_buffer) self.refresh() self.core.doupdate() @@ -1863,6 +1863,7 @@ class ConversationTab(ChatTab): self.commands['unquery'] = (self.command_unquery, _("Usage: /unquery\nUnquery: close the tab"), None) self.commands['close'] = (self.command_unquery, _("Usage: /close\Close: close the tab"), None) self.commands['version'] = (self.command_version, _('Usage: /version\nVersion: get the software version of the current interlocutor (usually its XMPP client and Operating System)'), None) + self.commands['info'] = (self.command_info, _('Usage: /info\nInfo: get the status of the contact.'), None) self.resize() def completion(self): @@ -1886,6 +1887,18 @@ class ConversationTab(ChatTab): self.text_win.refresh() self.input.refresh() + def command_info(self, arg): + contact = roster.get_contact_by_jid(self.get_name()) + jid = JID(self.get_name()) + if jid.resource: + resource = contact.get_resource_by_fulljid(jid.full) + else: + resource = contact.get_highest_priority_resource() + if resource: + self._text_buffer.add_message("\x195}Status: %s\x193}" %resource.get_status(), None, None, None, None, None) + self.refresh() + self.core.doupdate() + def command_unquery(self, arg): self.core.close_tab() diff --git a/src/windows.py b/src/windows.py index 42c9bfa0..790dd858 100644 --- a/src/windows.py +++ b/src/windows.py @@ -24,7 +24,7 @@ import curses import string from config import config -from threading import Lock +from threading import RLock from contact import Contact, Resource from roster import RosterGroup, roster @@ -46,7 +46,7 @@ allowed_color_digits = ('0', '1', '2', '3', '4', '5', '6', '7') # first is a bool telling if this is the first line of the message. Line = collections.namedtuple('Line', 'msg start_pos end_pos') -g_lock = Lock() +g_lock = RLock() LINES_NB_LIMIT = 4096 @@ -79,7 +79,8 @@ class Win(object): """ Override if something has to be done on resize """ - self._resize(height, width, y, x) + with g_lock: + self._resize(height, width, y, x) def _refresh(self): self._win.noutrefresh() @@ -255,10 +256,11 @@ class UserList(Win): self._refresh() def resize(self, height, width, y, x): - self._resize(height, width, y, x) - self._win.attron(to_curses_attr(get_theme().COLOR_VERTICAL_SEPARATOR)) - self._win.vline(0, 0, curses.ACS_VLINE, self.height) - self._win.attroff(to_curses_attr(get_theme().COLOR_VERTICAL_SEPARATOR)) + with g_lock: + self._resize(height, width, y, x) + self._win.attron(to_curses_attr(get_theme().COLOR_VERTICAL_SEPARATOR)) + self._win.vline(0, 0, curses.ACS_VLINE, self.height) + self._win.attroff(to_curses_attr(get_theme().COLOR_VERTICAL_SEPARATOR)) class Topic(Win): def __init__(self): @@ -674,9 +676,10 @@ class TextWin(Win): self.addstr(' ') def resize(self, height, width, y, x, room=None): - self._resize(height, width, y, x) - if room: - self.rebuild_everything(room) + with g_lock: + self._resize(height, width, y, x) + if room: + self.rebuild_everything(room) def rebuild_everything(self, room): self.built_lines = [] |