From dd2a6d1d6552476db671ad77d55d549122947954 Mon Sep 17 00:00:00 2001 From: Florent Le Coz Date: Sat, 26 Jan 2013 05:22:12 +0100 Subject: Implement XEP 296 for locking resource in conversations. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit With a few specific behaviours: When manually opening a conversation with a bare jid, we open a normal conversation that follows the XEP (locked and unlocked accordingly). If the user manually opens a conversation with a fulljid (by selecting a specific resource in the roster, or by specifying a fulljid to the /message command), we open a special tab that doesn’t follow the XEP (it is always locked to the same resource, and cannot be unlocked). When a message is received, unless a special tab has been manually opened by the other with that specific resource, we always send the messages to a uniq normal tab, unlocking or locking it according to the XEP. This means that only one tab can be opened with a given contact, unless the user specifically chooses to open a special tab for a specific resource. fixes #2159 --- src/windows.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'src/windows.py') diff --git a/src/windows.py b/src/windows.py index f0911086..e507be60 100644 --- a/src/windows.py +++ b/src/windows.py @@ -503,7 +503,7 @@ class ConversationInfoWin(InfoWin): else: resource = None # if contact is None, then resource is None too: user is not in the roster - # so we don't know almost anything about it + # so we know almost nothing about it # If contact is a Contact, then # resource can now be a Resource: user is in the roster and online # or resource is None: user is in the roster but offline @@ -546,8 +546,9 @@ class ConversationInfoWin(InfoWin): if not contact: self.addstr("(contact not in roster)", to_curses_attr(get_theme().COLOR_INFORMATION_BAR)) return - display_name = contact.name or contact.bare_jid - self.addstr('%s '%(display_name), to_curses_attr(get_theme().COLOR_INFORMATION_BAR)) + display_name = contact.name + if display_name: + self.addstr('%s '%(display_name), to_curses_attr(get_theme().COLOR_INFORMATION_BAR)) def write_contact_jid(self, jid): """ @@ -561,6 +562,18 @@ class ConversationInfoWin(InfoWin): if state: self.addstr(' %s' % (state,), to_curses_attr(get_theme().COLOR_INFORMATION_BAR)) +class DynamicConversationInfoWin(ConversationInfoWin): + def write_contact_jid(self, jid): + """ + Just displays the resource in an other color + """ + log.debug("write_contact_jid DynamicConversationInfoWin, jid: %s" % jid.resource) + self.addstr('[', to_curses_attr(get_theme().COLOR_INFORMATION_BAR)) + self.addstr(jid.bare, to_curses_attr(get_theme().COLOR_CONVERSATION_NAME)) + if jid.resource: + self.addstr("/%s" % (jid.resource,), to_curses_attr(get_theme().COLOR_CONVERSATION_RESOURCE)) + self.addstr('] ', to_curses_attr(get_theme().COLOR_INFORMATION_BAR)) + class ConversationStatusMessageWin(InfoWin): """ The upper bar displaying the status message of the contact -- cgit v1.2.3