| 35 | | def get_avatar_pixbuf_encoded_mime(photo): |
| 36 | | '''return the pixbuf of the image |
| 37 | | photo is a dictionary containing PHOTO information''' |
| 38 | | if not isinstance(photo, dict): |
| 39 | | return None, None, None |
| 40 | | img_decoded = None |
| 41 | | avatar_encoded = None |
| 42 | | avatar_mime_type = None |
| 43 | | if photo.has_key('BINVAL'): |
| 44 | | img_encoded = photo['BINVAL'] |
| 45 | | avatar_encoded = img_encoded |
| 46 | | try: |
| 47 | | img_decoded = base64.decodestring(img_encoded) |
| 48 | | except: |
| 49 | | pass |
| 50 | | if img_decoded: |
| 51 | | if photo.has_key('TYPE'): |
| 52 | | avatar_mime_type = photo['TYPE'] |
| 53 | | pixbuf = gtkgui_helpers.get_pixbuf_from_data(img_decoded) |
| 54 | | else: |
| 55 | | pixbuf, avatar_mime_type = gtkgui_helpers.get_pixbuf_from_data( |
| 56 | | img_decoded, want_type=True) |
| 57 | | else: |
| 58 | | pixbuf = None |
| 59 | | return pixbuf, avatar_encoded, avatar_mime_type |