Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/src/buddy.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/buddy.py')
-rw-r--r--src/buddy.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/buddy.py b/src/buddy.py
index 6199342..5c0a877 100644
--- a/src/buddy.py
+++ b/src/buddy.py
@@ -543,6 +543,34 @@ class Buddy(ExportedGObject):
except AttributeError:
self._valid = False
+ def update_avatar(self, tp, new_avatar_token):
+ """Handle update of the avatar"""
+ conn = tp.get_connection()
+ handle, identifier = self._handles[tp]
+
+ icon = buddy_icon_cache.get_icon(conn.object_path, identifier,
+ new_avatar_token)
+ if not icon:
+ # cache miss
+ def got_avatar(avatar, mime_type):
+ icon = str(icon)
+ buddy_icon_cache.store_icon(conn.object_path, identifier,
+ new_avatar_token, icon)
+ if self._icon != icon:
+ self._icon = icon
+ self.IconChanged(self._icon)
+
+ conn[CONN_INTERFACE_AVATARS].RequestAvatar(handle,
+ reply_handler=got_avatar,
+ error_handler=lambda e:
+ _logger.warning('Error getting avatar for %r: %s',
+ self, e),
+ byte_arrays=True)
+ else:
+ if self._icon != icon:
+ self._icon = icon
+ self.IconChanged(self._icon)
+
class GenericOwner(Buddy):
"""Common functionality for Local User-like objects
@@ -745,6 +773,11 @@ class GenericOwner(Buddy):
"""Customisation point: handle the registration of the owner"""
raise RuntimeError("Subclasses must implement")
+ def update_avatar(self, tp, new_avatar_token):
+ # This should never get called because Owner avatar changes are
+ # driven by the Sugar shell, but just in case:
+ _logger.warning('GenericOwner.update_avatar() should not be called')
+
class ShellOwner(GenericOwner):
"""Representation of the local-machine owner using Sugar's Shell