From aee7baab245e7edabc960e52f6062393197b6a38 Mon Sep 17 00:00:00 2001 From: mathieui Date: Wed, 9 Nov 2011 14:29:13 +0100 Subject: Same as previous commit, but with _say --- src/tabs.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/tabs.py') diff --git a/src/tabs.py b/src/tabs.py index 6f100741..93f48757 100644 --- a/src/tabs.py +++ b/src/tabs.py @@ -722,7 +722,7 @@ class MucTab(ChatTab): # trigger the event BEFORE looking for colors. # This lets a plugin insert \x19xxx} colors, that will # be converted in xhtml. - self.core.events.trigger('muc_say', msg) + self.core.events.trigger('muc_say', msg, self) if msg['body'].find('\x19') != -1: msg['xhtml_im'] = xhtml.poezio_colors_to_html(msg['body']) msg['body'] = xhtml.clean_text(msg['body']) @@ -1217,7 +1217,7 @@ class PrivateTab(ChatTab): # trigger the event BEFORE looking for colors. # This lets a plugin insert \x19xxx} colors, that will # be converted in xhtml. - self.core.events.trigger('private_say', msg) + self.core.events.trigger('private_say', msg, self) self.core.add_message_to_text_buffer(self._text_buffer, msg['body'], None, self.core.own_nick or self.own_nick) if msg['body'].find('\x19') != -1: msg['xhtml_im'] = xhtml.poezio_colors_to_html(msg['body']) @@ -1894,7 +1894,7 @@ class ConversationTab(ChatTab): # and before displaying the message in the window # This lets a plugin insert \x19xxx} colors, that will # be converted in xhtml. - self.core.events.trigger('conversation_say', msg) + self.core.events.trigger('conversation_say', msg, self) self.core.add_message_to_text_buffer(self._text_buffer, msg['body'], None, self.core.own_nick) if msg['body'].find('\x19') != -1: msg['xhtml_im'] = xhtml.poezio_colors_to_html(msg['body']) -- cgit v1.2.3 From a7ed473437b6bc476c579e2e778947c572e7cd40 Mon Sep 17 00:00:00 2001 From: mathieui Date: Wed, 9 Nov 2011 18:39:33 +0100 Subject: What. --- src/tabs.py | 1 - 1 file changed, 1 deletion(-) (limited to 'src/tabs.py') diff --git a/src/tabs.py b/src/tabs.py index 93f48757..0e9f345a 100644 --- a/src/tabs.py +++ b/src/tabs.py @@ -1027,7 +1027,6 @@ class MucTab(ChatTab): self.core.doupdate() hide_exit_join = config.get('hide_exit_join', -1) if config.get('hide_exit_join', -1) >= -1 else -1 if hide_exit_join == -1 or user.has_talked_since(hide_exit_join): - log.debug("\n\nALLO: USERCOLOR: %s\n\n" % user.color.__repr__()) color = user.color[0] if config.get('display_user_color_in_join_part', '') == 'true' else 3 if not jid.full: leave_msg = _('\x191}%(spec)s \x19%(color)d}%(nick)s\x195} has left the room') % {'nick':from_nick, 'color':color, 'spec':get_theme().CHAR_QUIT} -- cgit v1.2.3 From 1f5d1048344b3e68b5fb294371f269c398c8f69a Mon Sep 17 00:00:00 2001 From: mathieui Date: Wed, 9 Nov 2011 22:00:38 +0100 Subject: -get -set +@property +@property.setter --- src/tabs.py | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) (limited to 'src/tabs.py') diff --git a/src/tabs.py b/src/tabs.py index 0e9f345a..6ba94c50 100644 --- a/src/tabs.py +++ b/src/tabs.py @@ -1487,10 +1487,10 @@ class RosterInfoTab(Tab): self.core.information(_('No such JID in roster'), 'Error') return - groups = set(contact.get_groups()) - subscription = contact.get_subscription() + groups = set(contact.groups) + subscription = contact.subscription if self.core.xmpp.update_roster(jid, name=name, groups=groups, subscription=subscription): - contact.set_name(name) + contact.name = name def command_groupadd(self, args): """ @@ -1507,7 +1507,7 @@ class RosterInfoTab(Tab): self.core.information(_('No such JID in roster'), 'Error') return - new_groups = set(contact.get_groups()) + new_groups = set(contact.groups) if group in new_groups: self.core.information(_('JID already in group'), 'Error') return @@ -1518,8 +1518,8 @@ class RosterInfoTab(Tab): except KeyError: pass - name = contact.get_name() - subscription = contact.get_subscription() + name = contact.name + subscription = contact.subscription if self.core.xmpp.update_roster(jid, name=name, groups=new_groups, subscription=subscription): roster.edit_groups_of_contact(contact, new_groups) @@ -1538,7 +1538,7 @@ class RosterInfoTab(Tab): self.core.information(_('No such JID in roster'), 'Error') return - new_groups = set(contact.get_groups()) + new_groups = set(contact.groups) try: new_groups.remove('none') except KeyError: @@ -1548,8 +1548,8 @@ class RosterInfoTab(Tab): return new_groups.remove(group) - name = contact.get_name() - subscription = contact.get_subscription() + name = contact.name + subscription = contact.subscription if self.core.xmpp.update_roster(jid, name=name, groups=new_groups, subscription=subscription): roster.edit_groups_of_contact(contact, new_groups) @@ -1624,7 +1624,7 @@ class RosterInfoTab(Tab): """ From with any JID presence in the roster """ - jids = [contact.get_bare_jid() for contact in roster.get_contacts()] + jids = [contact.bare_jid for contact in roster.get_contacts()] return the_input.auto_completion(jids, '') def completion_name(self, the_input): @@ -1634,7 +1634,7 @@ class RosterInfoTab(Tab): n += 1 if n == 2: - jids = [contact.get_bare_jid() for contact in roster.get_contacts()] + jids = [contact.bare_jid for contact in roster.get_contacts()] return the_input.auto_completion(jids, '') return False @@ -1645,7 +1645,7 @@ class RosterInfoTab(Tab): n += 1 if n == 2: - jids = [contact.get_bare_jid() for contact in roster.get_contacts()] + jids = [contact.bare_jid for contact in roster.get_contacts()] return the_input.auto_completion(jids, '') elif n == 3: groups = [group.name for group in roster.get_groups() if group.name != 'none'] @@ -1660,13 +1660,13 @@ class RosterInfoTab(Tab): n += 1 if n == 2: - jids = [contact.get_bare_jid() for contact in roster.get_contacts()] + jids = [contact.bare_jid for contact in roster.get_contacts()] return the_input.auto_completion(jids, '') elif n == 3: contact = roster.get_contact_by_jid(args[1]) if not contact: return False - groups = list(contact.get_groups()) + groups = list(contact.groups) try: groups.remove('none') except ValueError: @@ -1679,8 +1679,8 @@ class RosterInfoTab(Tab): Complete the first argument from the list of the contact with ask=='subscribe' """ - jids = [contact.get_bare_jid() for contact in roster.get_contacts()\ - if contact.get_ask() == 'asked'] + jids = [contact.bare_jid for contact in roster.get_contacts()\ + if contact.ask == 'asked'] return the_input.auto_completion(jids, '') def command_accept(self, args): @@ -1915,7 +1915,7 @@ class ConversationTab(ChatTab): 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._text_buffer.add_message("\x195}Status: %s\x193}" %resource.status, None, None, None, None, None) self.refresh() self.core.doupdate() @@ -2219,7 +2219,7 @@ def jid_and_name_match(contact, txt): """ if not txt: return True - if txt in JID(contact.get_bare_jid()).user: + if txt in JID(contact.bare_jid).user: return True return False @@ -2230,9 +2230,9 @@ def jid_and_name_match_slow(contact, txt): """ if not txt: return True # Everything matches when search is empty - user = JID(contact.get_bare_jid()).user + user = JID(contact.bare_jid).user if diffmatch(txt, user): return True - if contact.get_name() and diffmatch(txt, contact.get_name()): + if contact.name and diffmatch(txt, contact.name): return True return False -- cgit v1.2.3 From f55a0c92f21e8b0c5cbd1e0413f2c2a95b29a8ae Mon Sep 17 00:00:00 2001 From: mathieui Date: Wed, 9 Nov 2011 22:34:16 +0100 Subject: Do not send chatstates when the contact is offline --- src/tabs.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'src/tabs.py') diff --git a/src/tabs.py b/src/tabs.py index 6ba94c50..7639f54f 100644 --- a/src/tabs.py +++ b/src/tabs.py @@ -1975,17 +1975,31 @@ class ConversationTab(ChatTab): return False def on_lose_focus(self): + 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() self.state = 'normal' self.text_win.remove_line_separator() self.text_win.add_line_separator() if config.get('send_chat_states', 'true') == 'true' and not self.input.get_text() or not self.input.get_text().startswith('//'): - self.send_chat_state('inactive') + if resource: + self.send_chat_state('inactive') def on_gain_focus(self): + 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() self.state = 'current' curses.curs_set(1) if config.get('send_chat_states', 'true') == 'true' and not self.input.get_text() or not self.input.get_text().startswith('//'): - self.send_chat_state('active') + if resource: + self.send_chat_state('active') def on_scroll_up(self): self.text_win.scroll_up(self.text_win.height-1) -- cgit v1.2.3 From 138a0b78cd17ff508be80c5c54b98b1a3fcce8d6 Mon Sep 17 00:00:00 2001 From: mathieui Date: Thu, 10 Nov 2011 11:29:17 +0100 Subject: Forgotten changes --- src/tabs.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/tabs.py') diff --git a/src/tabs.py b/src/tabs.py index 7639f54f..64eda75a 100644 --- a/src/tabs.py +++ b/src/tabs.py @@ -1449,8 +1449,8 @@ class RosterInfoTab(Tab): args = args.split() if not args: item = self.roster_win.selected_row - if isinstance(item, Contact) and item.get_ask() == 'asked': - jid = item.get_bare_jid() + if isinstance(item, Contact) and item.ask == 'asked': + jid = item.bare_jid else: self.core.information('No subscription to deny') return @@ -1563,7 +1563,7 @@ class RosterInfoTab(Tab): else: item = self.roster_win.selected_row if isinstance(item, Contact): - jid = item.get_bare_jid() + jid = item.bare_jid else: self.core.information('No roster item to remove') return @@ -1690,8 +1690,8 @@ class RosterInfoTab(Tab): args = args.split() if not args: item = self.roster_win.selected_row - if isinstance(item, Contact) and item.get_ask() == 'asked': - jid = item.get_bare_jid() + if isinstance(item, Contact) and item.ask == 'asked': + jid = item.bare_jid else: self.core.information('No subscription to accept') return -- cgit v1.2.3 From 628ff3b0d982526aad48151bdce623d12b8db2b7 Mon Sep 17 00:00:00 2001 From: mathieui Date: Thu, 10 Nov 2011 14:39:19 +0100 Subject: Add per_tab_type commands for the plugins --- src/tabs.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'src/tabs.py') diff --git a/src/tabs.py b/src/tabs.py index 64eda75a..f037a368 100644 --- a/src/tabs.py +++ b/src/tabs.py @@ -91,6 +91,7 @@ class Tab(object): # and use them in on_input self.commands = {} # and their own commands + @property def core(self): if not Tab.tab_core: @@ -220,6 +221,18 @@ class Tab(object): def on_input(self, key): pass + def add_plugin_command(self, name, handler, help, completion=None): + if name in self.plugin_commands or name in self.commands: + return + self.plugin_commands[name] = (handler, help, completion) + self.commands[name] = (handler, help, completion) + self.update_commands() + + def update_commands(self): + for c in self.plugin_commands: + if not c in self.commands: + self.commands[name] = self.plugin_commands[c] + def on_lose_focus(self): """ called when this tab loses the focus. @@ -275,6 +288,7 @@ class ChatTab(Tab): Also, ^M is already bound to on_enter And also, add the /say command """ + plugin_commands = {} def __init__(self): Tab.__init__(self) self._text_buffer = TextBuffer() @@ -295,6 +309,7 @@ class ChatTab(Tab): _("""Usage: /say \nSay: Just send the message. Useful if you want your message to begin with a '/'."""), None) self.chat_state = None + self.update_commands() def last_words_completion(self): """ @@ -402,6 +417,7 @@ class MucTab(ChatTab): It contains an userlist, an input, a topic, an information and a chat zone """ message_type = 'groupchat' + plugin_commands = {} def __init__(self, jid, nick): ChatTab.__init__(self) self.own_nick = nick @@ -445,6 +461,7 @@ class MucTab(ChatTab): self.commands['clear'] = (self.command_clear, _('Usage: /clear\nClear: Clear the current buffer.'), None) self.resize() + self.update_commands() def scroll_user_list_up(self): self.user_win.scroll_up() @@ -1185,6 +1202,7 @@ class PrivateTab(ChatTab): The tab containg a private conversation (someone from a MUC) """ message_type = 'chat' + plugin_commands = {} def __init__(self, name, nick): ChatTab.__init__(self) self.own_nick = nick @@ -1203,6 +1221,7 @@ class PrivateTab(ChatTab): self.resize() self.parent_muc = self.core.get_tab_by_name(JID(name).bare, MucTab) self.on = True + self.update_commands() def completion(self): self.complete_commands(self.input) @@ -1380,6 +1399,7 @@ class RosterInfoTab(Tab): """ A tab, splitted in two, containing the roster and infos """ + plugin_commands = {} def __init__(self): Tab.__init__(self) self.name = "Roster" @@ -1414,6 +1434,7 @@ class RosterInfoTab(Tab): self.commands['import'] = (self.command_import, _("Usage: /import [/path/to/file]\nImport: Import your contacts from /path/to/file if specified, or $HOME/poezio_contacts if not."), None) self.commands['clear_infos'] = (self.command_clear_infos, _("Usage: /clear_infos\nClear Infos: Use this command to clear the info buffer."), None) self.resize() + self.update_commands() def resize(self): if not self.visible: @@ -1863,6 +1884,7 @@ class ConversationTab(ChatTab): """ The tab containg a normal conversation (not from a MUC) """ + plugin_commands = {} message_type = 'chat' def __init__(self, jid): ChatTab.__init__(self) @@ -1881,6 +1903,7 @@ class ConversationTab(ChatTab): 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() + self.update_commands() def completion(self): self.complete_commands(self.input) @@ -2029,6 +2052,7 @@ class MucListTab(Tab): A tab listing rooms from a specific server, displaying various information, scrollable, and letting the user join them, etc """ + plugin_commands = {} def __init__(self, server): Tab.__init__(self) self.state = 'normal' @@ -2059,6 +2083,7 @@ class MucListTab(Tab): self.listview.refresh() self.tab_win.refresh() self.input.refresh() + self.update_commands() def resize(self): if not self.visible: -- cgit v1.2.3 From eaced10c1667d0ddf8cf41aebf060a6c2be7173b Mon Sep 17 00:00:00 2001 From: mathieui Date: Thu, 10 Nov 2011 15:26:34 +0100 Subject: Also, do not crash when receiving a message from someone who is not a contact --- src/tabs.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'src/tabs.py') diff --git a/src/tabs.py b/src/tabs.py index f037a368..5b9c9fe8 100644 --- a/src/tabs.py +++ b/src/tabs.py @@ -2000,10 +2000,13 @@ class ConversationTab(ChatTab): def on_lose_focus(self): 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) + if contact: + if jid.resource: + resource = contact.get_resource_by_fulljid(jid.full) + else: + resource = contact.get_highest_priority_resource() else: - resource = contact.get_highest_priority_resource() + resource = None self.state = 'normal' self.text_win.remove_line_separator() self.text_win.add_line_separator() @@ -2014,10 +2017,14 @@ class ConversationTab(ChatTab): def on_gain_focus(self): 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) + if contact: + if jid.resource: + resource = contact.get_resource_by_fulljid(jid.full) + else: + resource = contact.get_highest_priority_resource() else: - resource = contact.get_highest_priority_resource() + resource = None + self.state = 'current' curses.curs_set(1) if config.get('send_chat_states', 'true') == 'true' and not self.input.get_text() or not self.input.get_text().startswith('//'): -- cgit v1.2.3 From fde8a8a1c96943a7531f3059eb8976d6894e3681 Mon Sep 17 00:00:00 2001 From: mathieui Date: Thu, 10 Nov 2011 20:59:55 +0100 Subject: Fixes #2231 --- src/tabs.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/tabs.py') diff --git a/src/tabs.py b/src/tabs.py index 5b9c9fe8..1e5775fc 100644 --- a/src/tabs.py +++ b/src/tabs.py @@ -2010,7 +2010,7 @@ class ConversationTab(ChatTab): self.state = 'normal' self.text_win.remove_line_separator() self.text_win.add_line_separator() - if config.get('send_chat_states', 'true') == 'true' and not self.input.get_text() or not self.input.get_text().startswith('//'): + if config.get('send_chat_states', 'true') == 'true' and (not self.input.get_text() or not self.input.get_text().startswith('//')): if resource: self.send_chat_state('inactive') @@ -2027,7 +2027,7 @@ class ConversationTab(ChatTab): self.state = 'current' curses.curs_set(1) - if config.get('send_chat_states', 'true') == 'true' and not self.input.get_text() or not self.input.get_text().startswith('//'): + if config.get('send_chat_states', 'true') == 'true' and (not self.input.get_text() or not self.input.get_text().startswith('//')): if resource: self.send_chat_state('active') -- cgit v1.2.3 From ea5692544ad196b90d64e46d7b43ae8c68c34e64 Mon Sep 17 00:00:00 2001 From: mathieui Date: Fri, 11 Nov 2011 21:47:52 +0100 Subject: Fixes presence handhake --- src/tabs.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/tabs.py') diff --git a/src/tabs.py b/src/tabs.py index 1e5775fc..5a1a33a3 100644 --- a/src/tabs.py +++ b/src/tabs.py @@ -1491,7 +1491,6 @@ class RosterInfoTab(Tab): self.core.information(_('No JID specified'), 'Error') return self.core.xmpp.sendPresence(pto=jid, ptype='subscribe') - self.core.xmpp.sendPresence(pto=jid, ptype='subscribed') def command_name(self, args): """ @@ -1588,6 +1587,7 @@ class RosterInfoTab(Tab): else: self.core.information('No roster item to remove') return + self.core.xmpp.sendPresence(pto=jid, ptype='unavailable') self.core.xmpp.sendPresence(pto=jid, ptype='unsubscribe') self.core.xmpp.sendPresence(pto=jid, ptype='unsubscribed') self.core.xmpp.del_roster_item(jid=jid) @@ -1719,6 +1719,12 @@ class RosterInfoTab(Tab): else: jid = args[0] self.core.xmpp.sendPresence(pto=jid, ptype='subscribed') + self.core.xmpp.sendPresence(pto=jid, ptype='') + contact = roster.get_contact_by_jid(jid) + if not contact: + return + if contact.subscription in ('to', 'none'): + self.core.xmpp.sendPresence(pto=jid, ptype='subscribe') def refresh(self): if self.need_resize: -- cgit v1.2.3 From 0cfe87a9a6d3ce85ed11114b0607ac178f2a5821 Mon Sep 17 00:00:00 2001 From: mathieui Date: Fri, 11 Nov 2011 22:13:51 +0100 Subject: Fix a (possible) traceback on /remove --- src/tabs.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/tabs.py') diff --git a/src/tabs.py b/src/tabs.py index 5a1a33a3..e0419fda 100644 --- a/src/tabs.py +++ b/src/tabs.py @@ -1590,7 +1590,10 @@ class RosterInfoTab(Tab): self.core.xmpp.sendPresence(pto=jid, ptype='unavailable') self.core.xmpp.sendPresence(pto=jid, ptype='unsubscribe') self.core.xmpp.sendPresence(pto=jid, ptype='unsubscribed') - self.core.xmpp.del_roster_item(jid=jid) + try: + self.core.xmpp.del_roster_item(jid=jid) + except: + pass def command_import(self, arg): """ -- cgit v1.2.3 From 4d5e2d21a464e6af56e5c968490c2dea61670011 Mon Sep 17 00:00:00 2001 From: mathieui Date: Sat, 12 Nov 2011 00:00:17 +0100 Subject: /xhtml command, Fixes #2237 --- src/tabs.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'src/tabs.py') diff --git a/src/tabs.py b/src/tabs.py index e0419fda..02678e7e 100644 --- a/src/tabs.py +++ b/src/tabs.py @@ -46,6 +46,7 @@ from os import getenv, path from logger import logger from datetime import datetime, timedelta +from xml.etree import cElementTree as ET SHOW_NAME = { 'dnd': _('busy'), @@ -308,6 +309,7 @@ class ChatTab(Tab): self.commands['say'] = (self.command_say, _("""Usage: /say \nSay: Just send the message. Useful if you want your message to begin with a '/'."""), None) + self.commands['xhtml'] = (self.command_xhtml, _("Usage: /xhtml \nXHTML: Send custom XHTML."), None) self.chat_state = None self.update_commands() @@ -339,6 +341,29 @@ class ChatTab(Tab): self.command_say(xhtml.convert_simple_to_full_colors(txt)) self.cancel_paused_delay() + def command_xhtml(self, arg): + """" + /xhtml + """ + if not arg: + return + try: + body = xhtml.clean_text(xhtml.xhtml_to_poezio_colors(arg)) + ET.fromstring(arg) + except: + self.core.information('Could not send custom xhtml', 'Error') + return + + msg = self.core.xmpp.make_message(self.get_name()) + msg['body'] = body + msg['xhtml_im'] = arg + if isinstance(self, MucTab): + msg['type'] = 'groupchat' + if isinstance(self, ConversationTab): + self.core.add_message_to_text_buffer(self._text_buffer, body, None, self.core.own_nick) + self.refresh() + msg.send() + def send_chat_state(self, state, always_send=False): """ Send an empty chatstate message -- cgit v1.2.3 From 744af2459d7d3a3c7a7e9d1f3861d4d494a837ba Mon Sep 17 00:00:00 2001 From: Florent Le Coz Date: Sat, 12 Nov 2011 03:42:07 +0100 Subject: Add three new events to modify a message JUST before we send it. It is NOT safe, and the doc says that pretty clearly. It is used to encrypt messages just before sending them (this way we can remove ALL potential in-clear bodies). --- src/tabs.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/tabs.py') diff --git a/src/tabs.py b/src/tabs.py index 02678e7e..d7f1323b 100644 --- a/src/tabs.py +++ b/src/tabs.py @@ -771,6 +771,7 @@ class MucTab(ChatTab): if config.get('send_chat_states', 'true') == 'true' and self.remote_wants_chatstates is not False: msg['chat_state'] = needed self.cancel_paused_delay() + self.core.events.trigger('muc_say_after', msg, self) msg.send() self.chat_state = needed @@ -1268,6 +1269,7 @@ class PrivateTab(ChatTab): if config.get('send_chat_states', 'true') == 'true' and self.remote_wants_chatstates is not False: needed = 'inactive' if self.core.status.show in ('xa', 'away') else 'active' msg['chat_state'] = needed + self.core.events.trigger('private_say_after', msg, self) msg.send() self.cancel_paused_delay() self.text_win.refresh() @@ -1958,6 +1960,7 @@ class ConversationTab(ChatTab): if config.get('send_chat_states', 'true') == 'true' and self.remote_wants_chatstates is not False: needed = 'inactive' if self.core.status.show in ('xa', 'away') else 'active' msg['chat_state'] = needed + self.core.events.trigger('conversation_say_after', msg, self) msg.send() logger.log_message(JID(self.get_name()).bare, self.core.own_nick, line) self.cancel_paused_delay() -- cgit v1.2.3 From 9e8706a2e8bfb5dc1242ca42f87a6e3df90d9138 Mon Sep 17 00:00:00 2001 From: Florent Le Coz Date: Sat, 12 Nov 2011 05:48:29 +0100 Subject: =?UTF-8?q?a=20plugin=20can=20now=20add=20informations=20in=20Conv?= =?UTF-8?q?ersationTab=E2=80=99s=20InfoWin.=20And=20the=20GPG=20plugin=20d?= =?UTF-8?q?oes=20that.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/tabs.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'src/tabs.py') diff --git a/src/tabs.py b/src/tabs.py index d7f1323b..472a15fa 100644 --- a/src/tabs.py +++ b/src/tabs.py @@ -1921,6 +1921,7 @@ class ConversationTab(ChatTab): The tab containg a normal conversation (not from a MUC) """ plugin_commands = {} + additional_informations = {} message_type = 'chat' def __init__(self, jid): ChatTab.__init__(self) @@ -1941,6 +1942,17 @@ class ConversationTab(ChatTab): self.resize() self.update_commands() + @staticmethod + def add_information_element(plugin_name, callback): + """ + Lets a plugin add its own information to the ConversationInfoWin + """ + ConversationTab.additional_informations[plugin_name] = callback + + @staticmethod + def remove_information_element(plugin_name): + del ConversationTab.additional_informations[plugin_name] + def completion(self): self.complete_commands(self.input) @@ -2013,13 +2025,13 @@ class ConversationTab(ChatTab): log.debug(' TAB Refresh: %s'%self.__class__.__name__) self.text_win.refresh() self.upper_bar.refresh(self.get_name(), roster.get_contact_by_jid(self.get_name())) - self.info_header.refresh(self.get_name(), roster.get_contact_by_jid(self.get_name()), self.text_win, self.chatstate) + self.info_header.refresh(self.get_name(), roster.get_contact_by_jid(self.get_name()), self.text_win, self.chatstate, ConversationTab.additional_informations) self.info_win.refresh() self.tab_win.refresh() self.input.refresh() def refresh_info_header(self): - self.info_header.refresh(self.get_name(), roster.get_contact_by_jid(self.get_name()), self.text_win, self.chatstate) + self.info_header.refresh(self.get_name(), roster.get_contact_by_jid(self.get_name()), self.text_win, self.chatstate, ConversationTab.additional_informations) self.input.refresh() def get_name(self): -- cgit v1.2.3