This patch gets rid of some almost-dead code in sugar-presence-service for handling bitmap avatars.
Signed-off-by: Bernie Innocenti <ber...@codewiz.org> --- src/buddy.py | 63 +-------------------------------------------------------- 1 files changed, 2 insertions(+), 61 deletions(-) diff --git a/src/buddy.py b/src/buddy.py index d81952e..4335f2d 100644 --- a/src/buddy.py +++ b/src/buddy.py @@ -69,37 +69,6 @@ def _buddy_icon_save_cb(buf, data): data[0] += buf return True -def _get_buddy_icon_at_size(icon, maxw, maxh, maxsize): -# FIXME Do not import gtk in the presence service, -# it uses a lot of memory and slow down startup. -# loader = gtk.gdk.PixbufLoader() -# loader.write(icon) -# loader.close() -# unscaled_pixbuf = loader.get_pixbuf() -# del loader -# -# pixbuf = unscaled_pixbuf.scale_simple(maxw, maxh, gtk.gdk.INTERP_BILINEAR) -# del unscaled_pixbuf -# -# data = [""] -# quality = 90 -# img_size = maxsize + 1 -# while img_size > maxsize: -# data = [""] -# pixbuf.save_to_callback(_buddy_icon_save_cb, "jpeg", -# {"quality":"%d" % quality}, data) -# quality -= 10 -# img_size = len(data[0]) -# del pixbuf -# -# if img_size > maxsize: -# data = [""] -# raise RuntimeError("could not size image less than %d bytes" % maxsize) -# -# return str(data[0]) - - return "" - class Buddy(ExportedGObject): """Person on the network (tracks properties and shared activites) @@ -212,20 +181,9 @@ class Buddy(ExportedGObject): _logger.debug("Invalid init property '%s'; ignoring..." % key) del kwargs[key] - # Set icon after superclass init, because it sends DBus and GObject - # signals when set - icon_data = None - if kwargs.has_key(_PROP_ICON): - icon_data = kwargs[_PROP_ICON] - del kwargs[_PROP_ICON] - ExportedGObject.__init__(self, bus, self._object_path, gobject_properties=kwargs) - if icon_data is not None: - self._icon = str(icon_data) - self.IconChanged(self._icon) - def __repr__(self): return '<ps.buddy.Buddy %s>' % (self._nick or u'').encode('utf-8') @@ -893,17 +851,6 @@ class GenericOwner(Buddy): if maxsize > 0 and size > maxsize: size = maxsize - if 1: - # FIXME: Avatars have been disabled for Trial-2 due to performance - # issues in the avatar cache. Revisit this afterwards - pass - else: - img_data = _get_buddy_icon_at_size(icon_data, width, height, size) - conn[CONN_INTERFACE_AVATARS].SetAvatar(img_data, "image/jpeg", - reply_handler=set_self_avatar_cb, - error_handler=lambda e: - _logger.warning('Error setting avatar: %s', e)) - def _property_changed(self, changed_props): for tp in self._handles.iterkeys(): @@ -963,8 +910,7 @@ class ShellOwner(GenericOwner): bus -- a connection to the D-Bus session bus Retrieves initial property values from the profile - module. Loads the buddy icon from file as well. - XXX note: no error handling on that + module. calls GenericOwner.__init__ """ @@ -981,14 +927,9 @@ class ShellOwner(GenericOwner): if not isinstance(nick, unicode): nick = unicode(nick, 'utf-8') - icon_file = os.path.join(env.get_profile_path(), "buddy-icon.jpg") - f = open(icon_file, "r") - icon = f.read() - f.close() - GenericOwner.__init__(self, ps, bus, 'keyid/' + psutils.pubkey_to_keyid(key), - key=key, nick=nick, color=color, icon=icon, key_hash=key_hash, + key=key, nick=nick, color=color, key_hash=key_hash, tags=tags) # Ask to get notifications on Owner object property changes in the -- 1.7.2.1 _______________________________________________ Sugar-devel mailing list Sugar-devel@lists.sugarlabs.org http://lists.sugarlabs.org/listinfo/sugar-devel