From 3911c72ba93a67c9c5a29884f3199611e95c96c3 Mon Sep 17 00:00:00 2001 From: Denis Fomin Date: Thu, 3 Jan 2013 17:02:14 +0400 Subject: [PATCH] fix set avatar --- src/common/connection_handlers.py | 5 ++--- src/profile_window.py | 3 +-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/common/connection_handlers.py b/src/common/connection_handlers.py index df4710caf..7382a5ccb 100644 --- a/src/common/connection_handlers.py +++ b/src/common/connection_handlers.py @@ -431,8 +431,7 @@ class ConnectionVcard: if 'PHOTO' in vcard and isinstance(vcard['PHOTO'], dict) and \ 'BINVAL' in vcard['PHOTO']: photo = vcard['PHOTO']['BINVAL'] - photo_decoded = base64.b64decode(photo.encode('utf-8')).decode( - 'utf-8') + photo_decoded = base64.b64decode(photo.encode('utf-8')) gajim.interface.save_avatar_files(our_jid, photo_decoded) avatar_sha = hashlib.sha1(photo_decoded).hexdigest() iq2.getTag('PHOTO').setTagData('SHA', avatar_sha) @@ -685,7 +684,7 @@ class ConnectionVcard: 'BINVAL' in vcard['PHOTO']: photo = vcard['PHOTO']['BINVAL'] try: - photo_decoded = base64.b64decode(photo.encode('utf-8')).decode('utf-8') + photo_decoded = base64.b64decode(photo.encode('utf-8')) avatar_sha = hashlib.sha1(photo_decoded).hexdigest() except Exception: avatar_sha = '' diff --git a/src/profile_window.py b/src/profile_window.py index 696c66beb..a56911cc2 100644 --- a/src/profile_window.py +++ b/src/profile_window.py @@ -171,8 +171,7 @@ class ProfileWindow: button.show() text_button = self.xml.get_object('NOPHOTO_button') text_button.hide() - self.avatar_encoded = base64.b64encode(data.encode('utf-8')).decode( - 'utf-8') + self.avatar_encoded = base64.b64encode(data).decode('utf-8') # returns None if unknown type self.avatar_mime_type = mimetypes.guess_type(path_to_file)[0] if must_delete: