# HG changeset patch # User Goffi # Date 1424794450 -3600 # Node ID e31a07a5614dc92aa87b2e8a28a3e4a9a7b8c64c # Parent 6dbeb2ef966c654a42c2e762ab55cb4a9429cba4 quick_frontends, primitivus (contact list): added nick observer + implemented onNickUpdate diff -r 6dbeb2ef966c -r e31a07a5614d frontends/src/primitivus/contact_list.py --- a/frontends/src/primitivus/contact_list.py Tue Feb 24 17:01:33 2015 +0100 +++ b/frontends/src/primitivus/contact_list.py Tue Feb 24 17:14:10 2015 +0100 @@ -152,6 +152,9 @@ 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 -r 6dbeb2ef966c -r e31a07a5614d frontends/src/quick_frontend/constants.py --- a/frontends/src/quick_frontend/constants.py Tue Feb 24 17:01:33 2015 +0100 +++ b/frontends/src/quick_frontend/constants.py Tue Feb 24 17:14:10 2015 +0100 @@ -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 @@ WIDGET_RAISE = 'RAISE' WIDGET_RECREATE = 'RECREATE' - LISTENERS = {'avatar', 'presence'} + LISTENERS = {'avatar', 'nick', 'presence'} diff -r 6dbeb2ef966c -r e31a07a5614d frontends/src/quick_frontend/quick_app.py --- a/frontends/src/quick_frontend/quick_app.py Tue Feb 24 17:01:33 2015 +0100 +++ b/frontends/src/quick_frontend/quick_app.py Tue Feb 24 17:14:10 2015 +0100 @@ -313,6 +313,8 @@ @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 @@ 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 -r 6dbeb2ef966c -r e31a07a5614d frontends/src/quick_frontend/quick_contact_list.py --- a/frontends/src/quick_frontend/quick_contact_list.py Tue Feb 24 17:01:33 2015 +0100 +++ b/frontends/src/quick_frontend/quick_contact_list.py Tue Feb 24 17:14:10 2015 +0100 @@ -75,6 +75,8 @@ # 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 @@ 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()