fix set avatar

This commit is contained in:
Denis Fomin 2013-01-03 17:02:14 +04:00
parent d6f807bc0b
commit 3911c72ba9
2 changed files with 3 additions and 5 deletions

View File

@ -431,8 +431,7 @@ class ConnectionVcard:
if 'PHOTO' in vcard and isinstance(vcard['PHOTO'], dict) and \ if 'PHOTO' in vcard and isinstance(vcard['PHOTO'], dict) and \
'BINVAL' in vcard['PHOTO']: 'BINVAL' in vcard['PHOTO']:
photo = vcard['PHOTO']['BINVAL'] photo = vcard['PHOTO']['BINVAL']
photo_decoded = base64.b64decode(photo.encode('utf-8')).decode( photo_decoded = base64.b64decode(photo.encode('utf-8'))
'utf-8')
gajim.interface.save_avatar_files(our_jid, photo_decoded) gajim.interface.save_avatar_files(our_jid, photo_decoded)
avatar_sha = hashlib.sha1(photo_decoded).hexdigest() avatar_sha = hashlib.sha1(photo_decoded).hexdigest()
iq2.getTag('PHOTO').setTagData('SHA', avatar_sha) iq2.getTag('PHOTO').setTagData('SHA', avatar_sha)
@ -685,7 +684,7 @@ class ConnectionVcard:
'BINVAL' in vcard['PHOTO']: 'BINVAL' in vcard['PHOTO']:
photo = vcard['PHOTO']['BINVAL'] photo = vcard['PHOTO']['BINVAL']
try: 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() avatar_sha = hashlib.sha1(photo_decoded).hexdigest()
except Exception: except Exception:
avatar_sha = '' avatar_sha = ''

View File

@ -171,8 +171,7 @@ class ProfileWindow:
button.show() button.show()
text_button = self.xml.get_object('NOPHOTO_button') text_button = self.xml.get_object('NOPHOTO_button')
text_button.hide() text_button.hide()
self.avatar_encoded = base64.b64encode(data.encode('utf-8')).decode( self.avatar_encoded = base64.b64encode(data).decode('utf-8')
'utf-8')
# returns None if unknown type # returns None if unknown type
self.avatar_mime_type = mimetypes.guess_type(path_to_file)[0] self.avatar_mime_type = mimetypes.guess_type(path_to_file)[0]
if must_delete: if must_delete: