diff --git a/frontends/src/primitivus/contact_list.py b/frontends/src/primitivus/contact_list.py index 83c54fbd..31a42864 100644 --- a/frontends/src/primitivus/contact_list.py +++ b/frontends/src/primitivus/contact_list.py @@ -152,6 +152,9 @@ class ContactList(PrimitivusWidget, QuickContactList): super(ContactList, self).onPresenceUpdate(entity, show, priority, statuses, profile) self.update() + def onNickUpdate(self, entity, new_nick, profile): + self.update() + # Methods to build the widget def _buildEntityWidget(self, entity, keys=None, use_bare_jid=False, with_alert=True, with_show_attr=True, markup_prepend=None, markup_append = None): diff --git a/frontends/src/quick_frontend/constants.py b/frontends/src/quick_frontend/constants.py index 7cb6e4b1..860ebbce 100644 --- a/frontends/src/quick_frontend/constants.py +++ b/frontends/src/quick_frontend/constants.py @@ -18,7 +18,7 @@ # along with this program. If not, see . from sat.core import constants -from sat.core.i18n import _, D_ +from sat.core.i18n import _ from collections import OrderedDict # only available from python 2.7 @@ -71,4 +71,4 @@ class Const(constants.Const): WIDGET_RAISE = 'RAISE' WIDGET_RECREATE = 'RECREATE' - LISTENERS = {'avatar', 'presence'} + LISTENERS = {'avatar', 'nick', 'presence'} diff --git a/frontends/src/quick_frontend/quick_app.py b/frontends/src/quick_frontend/quick_app.py index 34999360..6bf796d1 100644 --- a/frontends/src/quick_frontend/quick_app.py +++ b/frontends/src/quick_frontend/quick_app.py @@ -313,6 +313,8 @@ class QuickApp(object): @param type_: type of event, can be: - avatar: called when avatar data is updated args: (entity, avatar file, profile) + - nick: called when nick data is updated + args: (entity, new_nick, profile) - presence: called when a presence is received args: (entity, show, priority, statuses, profile) @param callback: method to call on event @@ -685,6 +687,7 @@ class QuickApp(object): if key == "nick": if entity in self.contact_lists[profile]: self.contact_lists[profile].setCache(entity, 'nick', value) + self.callListeners('nick', entity, value, profile=profile) elif key == "avatar": if entity in self.contact_lists[profile]: def gotFilename(filename): diff --git a/frontends/src/quick_frontend/quick_contact_list.py b/frontends/src/quick_frontend/quick_contact_list.py index 7790e619..aa508431 100644 --- a/frontends/src/quick_frontend/quick_contact_list.py +++ b/frontends/src/quick_frontend/quick_contact_list.py @@ -75,6 +75,8 @@ class QuickContactList(QuickWidget): # FIXME: workaround for a pyjamas issue: calling hash on a class method always return a different value if that method is defined directly within the class (with the "def" keyword) self.presenceListener = self.onPresenceUpdate self.host.addListener('presence', self.presenceListener, [profile]) + self.nickListener = self.onNickUpdate + self.host.addListener('nick', self.nickListener, [profile]) def __contains__(self, entity): """Check if entity is in contact list @@ -399,6 +401,15 @@ class QuickContactList(QuickWidget): priority_resource = max(resources_data, key=lambda res: resources_data[res][C.PRESENCE_PRIORITY]) cache[C.CONTACT_MAIN_RESOURCE] = priority_resource + def onNickUpdate(self, entity, new_nick, profile): + """Update entity's nick + + @param entity(jid.JID): entity updated + @param new_nick(unicode): new nick of the entity + @param profile: %(doc_profile)s + """ + raise NotImplementedError # Must be implemented by frontends + def unselectAll(self): """Unselect all contacts""" self._selected.clear()