From f978524b22496dcc8398752305038972f5b3732d Mon Sep 17 00:00:00 2001 From: souliane Date: Fri, 24 Apr 2015 16:10:46 +0200 Subject: [PATCH] display the resource in the chat dialog when printing a private MUC message --- frontends/src/quick_frontend/quick_chat.py | 4 ++-- frontends/src/quick_frontend/quick_contact_list.py | 12 ++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/frontends/src/quick_frontend/quick_chat.py b/frontends/src/quick_frontend/quick_chat.py index 28331692..bb42458b 100644 --- a/frontends/src/quick_frontend/quick_chat.py +++ b/frontends/src/quick_frontend/quick_chat.py @@ -158,9 +158,9 @@ class QuickChat(quick_widgets.QuickWidget): def _get_nick(self, entity): """Return nick of this entity when possible""" - if self.type == C.CHAT_GROUP: - return entity.resource contact_list = self.host.contact_lists[self.profile] + if self.type == C.CHAT_GROUP or entity in contact_list.getSpecialExtras(C.CONTACT_SPECIAL_GROUP): + return entity.resource if entity.bare in contact_list: return contact_list.getCache(entity,'nick') or contact_list.getCache(entity,'name') or entity.node or entity return entity.node or entity diff --git a/frontends/src/quick_frontend/quick_contact_list.py b/frontends/src/quick_frontend/quick_contact_list.py index a84c7155..abf76c15 100644 --- a/frontends/src/quick_frontend/quick_contact_list.py +++ b/frontends/src/quick_frontend/quick_contact_list.py @@ -243,6 +243,18 @@ class QuickContactList(QuickWidget): return self._specials return set([entity for entity in self._specials if self.getCache(entity, C.CONTACT_SPECIAL) == special_type]) + def getSpecialExtras(self, special_type=None): + """Return all the JIDs of the special extras entities that are related + to a special entity of the type specified by special_type. + If special_type is None, return all special extras. + + @param special_type: one of special type (e.g. C.CONTACT_SPECIAL_GROUP) or None to return all special extras. + @return: set(jid.JID) + """ + if special_type is None: + return self._special_extras + return set([extra for extra in self._special_extras if extra.bare in self.getSpecials(special_type)]) + def clearContacts(self): """Clear all the contact list""" self.unselectAll()