summaryrefslogtreecommitdiff
path: root/sunshine
diff options
context:
space:
mode:
authorKrzysztof Klinikowski <kkszysiu@gmail.com>2010-05-26 22:20:46 +0200
committerKrzysztof Klinikowski <kkszysiu@gmail.com>2010-05-26 22:20:46 +0200
commitd6aa08166dce40fd49904f8426336bab76755425 (patch)
tree4f91c470f90a1a645046d6d9deab084915e732ce /sunshine
parent2bd3787185b4e7095b93cc058f02d6b5b42967e4 (diff)
Dynamical avatar updating reimplemented.
Diffstat (limited to 'sunshine')
-rw-r--r--sunshine/avatars.py16
1 files changed, 13 insertions, 3 deletions
diff --git a/sunshine/avatars.py b/sunshine/avatars.py
index 8c831c6..86c27c9 100644
--- a/sunshine/avatars.py
+++ b/sunshine/avatars.py
@@ -116,13 +116,23 @@ class SunshineAvatars(telepathy.server.ConnectionInterfaceAvatars):
pass
def getAvatar(self, sender, url):
- logger.info("getAvatar: %s %s" % (sender, url))
handle_id = self.get_handle_id_by_name(telepathy.constants.HANDLE_TYPE_CONTACT, str(sender))
if handle_id != 0:
+ handle = self.handle(telepathy.HANDLE_TYPE_CONTACT, handle_id)
+
+ h = hashlib.new('md5')
+ h.update(handle.name)
+ h.update(url)
+ token = h.hexdigest()
+
+ self.avatars_urls[handle.name] = {}
+ self.avatars_urls[handle.name]['token'] = token
+ self.avatars_urls[handle.name]['avatar'] = url
+
d = getPage(str(url), timeout=20)
- d.addCallback(self.on_fetch_avatars_ok, str(url), handle_id)
- d.addErrback(self.on_fetch_avatars_failed, str(url), handle_id)
+ d.addCallback(self.on_fetch_avatars_ok, handle)
+ d.addErrback(self.on_fetch_avatars_failed, handle)
def on_fetch_avatars_file_ok(self, result, url, handle):
try: