From 723bd21e776bc19e136aaca0ffdbbdb8c1d2ca3f Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Fri, 9 Mar 2007 10:18:23 -0500 Subject: [PATCH] Require jpeg format buddy icon Since the intro screen ensures that a buddy icon exists and is in jpg format, we can simplify the buddy icon code in the ShellOwner object. --- shell/model/Owner.py | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/shell/model/Owner.py b/shell/model/Owner.py index 760697aa..3d5b3333 100644 --- a/shell/model/Owner.py +++ b/shell/model/Owner.py @@ -50,24 +50,23 @@ class ShellOwner(gobject.GObject): gobject.GObject.__init__(self) self._nick = profile.get_nick_name() - user_dir = env.get_profile_path() self._icon = None self._icon_hash = "" - for fname in os.listdir(user_dir): - if not fname.startswith("buddy-icon."): - continue - fd = open(os.path.join(user_dir, fname), "r") - self._icon = fd.read() - fd.close() - if not self._icon: - raise RuntimeError("No buddy icon exists") + icon = os.path.join(env.get_profile_path(), "buddy-icon.jpg") + if not os.path.exists(icon): + raise RuntimeError("missing buddy icon") - # Get the icon's hash - import md5, binascii - digest = md5.new(self._icon).digest() - self._icon_hash = util.printable_hash(digest) - break + fd = open(icon, "r") + self._icon = fd.read() + fd.close() + if not self._icon: + raise RuntimeError("invalid buddy icon") + + # Get the icon's hash + import md5 + digest = md5.new(self._icon).digest() + self._icon_hash = util.printable_hash(digest) self._pservice = PresenceService.get_instance()