From ff0166e95fafe6ea65496c4bf654b461533a0235 Mon Sep 17 00:00:00 2001 From: souliane Date: Wed, 25 Mar 2015 15:25:51 +0100 Subject: [PATCH] quick_frontend, primitivus: various fixes (MUC and cached signals): - actually call the cached signals, everything was there but the call was not done - display '[]' instead of '[None]' when group message coming from the room (no resource) - catch the exception when trying to delete an occupant who's not in the room - do not cache a "main resource" for MUC entities --- frontends/src/primitivus/chat.py | 7 +++++-- frontends/src/quick_frontend/quick_app.py | 1 + frontends/src/quick_frontend/quick_contact_list.py | 6 ++++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/frontends/src/primitivus/chat.py b/frontends/src/primitivus/chat.py index 989100bd..73c627fa 100644 --- a/frontends/src/primitivus/chat.py +++ b/frontends/src/primitivus/chat.py @@ -73,7 +73,7 @@ class ChatText(urwid.FlowWidget): if self.parent.show_short_nick: render_txt.append(('my_nick' if self.my_mess else 'other_nick', "**" if self.my_mess else "*")) else: - render_txt.append(('my_nick' if self.my_mess else 'other_nick', "[%s] " % self.nick)) + render_txt.append(('my_nick' if self.my_mess else 'other_nick', "[%s] " % (self.nick or ''))) render_txt.append(self.message) txt_widget = urwid.Text(render_txt, align=self.align) if self.is_info: @@ -188,7 +188,10 @@ class Chat(PrimitivusWidget, QuickChat): nick = entity.resource show = contact_list.getCache(entity, C.PRESENCE_SHOW) if show == C.PRESENCE_UNAVAILABLE or show is None: - self.occupants_list.deleteValue(nick) + try: + self.occupants_list.deleteValue(nick) + except ValueError: + pass else: values = self.occupants_list.getAllValues() markup = self._buildOccupantMarkup(entity) diff --git a/frontends/src/quick_frontend/quick_app.py b/frontends/src/quick_frontend/quick_app.py index 2a3d2614..638ec31b 100644 --- a/frontends/src/quick_frontend/quick_app.py +++ b/frontends/src/quick_frontend/quick_app.py @@ -388,6 +388,7 @@ class QuickApp(object): cached_signals = self.signals_cache.pop(profile, []) for function_name, handler, args, kwargs in cached_signals: log.debug(u"Calling cached signal [%s] with args %s and kwargs %s" % (function_name, args, kwargs)) + handler(*args, **kwargs) self.callListeners('profilePlugged', profile=profile) diff --git a/frontends/src/quick_frontend/quick_contact_list.py b/frontends/src/quick_frontend/quick_contact_list.py index c7d9c30a..f6b06765 100644 --- a/frontends/src/quick_frontend/quick_contact_list.py +++ b/frontends/src/quick_frontend/quick_contact_list.py @@ -296,6 +296,7 @@ class QuickContactList(QuickWidget): self._specials.remove(entity_bare) else: self._specials.add(entity_bare) + cache[C.CONTACT_MAIN_RESOURCE] = None # now the attribute we keep in cache for attribute, value in attributes.iteritems(): @@ -401,8 +402,9 @@ class QuickContactList(QuickWidget): resource_data[C.PRESENCE_PRIORITY] = int(priority) resource_data[C.PRESENCE_STATUSES] = statuses - priority_resource = max(resources_data, key=lambda res: resources_data[res][C.PRESENCE_PRIORITY]) - cache[C.CONTACT_MAIN_RESOURCE] = priority_resource + if entity.bare not in self._specials: + priority_resource = max(resources_data, key=lambda res: resources_data[res][C.PRESENCE_PRIORITY]) + cache[C.CONTACT_MAIN_RESOURCE] = priority_resource self.update() def onNickUpdate(self, entity, new_nick, profile):