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.
This commit is contained in:
parent
8dc201bc5f
commit
723bd21e77
@ -50,24 +50,23 @@ class ShellOwner(gobject.GObject):
|
|||||||
gobject.GObject.__init__(self)
|
gobject.GObject.__init__(self)
|
||||||
|
|
||||||
self._nick = profile.get_nick_name()
|
self._nick = profile.get_nick_name()
|
||||||
user_dir = env.get_profile_path()
|
|
||||||
|
|
||||||
self._icon = None
|
self._icon = None
|
||||||
self._icon_hash = ""
|
self._icon_hash = ""
|
||||||
for fname in os.listdir(user_dir):
|
icon = os.path.join(env.get_profile_path(), "buddy-icon.jpg")
|
||||||
if not fname.startswith("buddy-icon."):
|
if not os.path.exists(icon):
|
||||||
continue
|
raise RuntimeError("missing buddy icon")
|
||||||
fd = open(os.path.join(user_dir, fname), "r")
|
|
||||||
|
fd = open(icon, "r")
|
||||||
self._icon = fd.read()
|
self._icon = fd.read()
|
||||||
fd.close()
|
fd.close()
|
||||||
if not self._icon:
|
if not self._icon:
|
||||||
raise RuntimeError("No buddy icon exists")
|
raise RuntimeError("invalid buddy icon")
|
||||||
|
|
||||||
# Get the icon's hash
|
# Get the icon's hash
|
||||||
import md5, binascii
|
import md5
|
||||||
digest = md5.new(self._icon).digest()
|
digest = md5.new(self._icon).digest()
|
||||||
self._icon_hash = util.printable_hash(digest)
|
self._icon_hash = util.printable_hash(digest)
|
||||||
break
|
|
||||||
|
|
||||||
self._pservice = PresenceService.get_instance()
|
self._pservice = PresenceService.get_instance()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user