we can now receive photos in vcard (sending it come soon)

This commit is contained in:
Yann Leboulanger 2005-06-06 20:16:51 +00:00
parent 69a6aaff74
commit 051adcab4d
2 changed files with 103 additions and 22 deletions

View File

@ -4775,7 +4775,7 @@
<property name="has_frame">True</property> <property name="has_frame">True</property>
<property name="invisible_char">*</property> <property name="invisible_char">*</property>
<property name="activates_default">False</property> <property name="activates_default">False</property>
<signal name="changed" handler="on_sounds_entry_changed" last_modification_time="Tue, 06 Jun 2005 19:59:41 GMT"/> <signal name="changed" handler="on_sounds_entry_changed" last_modification_time="Mon, 06 Jun 2005 19:59:41 GMT"/>
</widget> </widget>
<packing> <packing>
<property name="padding">0</property> <property name="padding">0</property>
@ -8011,6 +8011,12 @@ Custom</property>
</packing> </packing>
</child> </child>
<child>
<widget class="GtkVBox" id="vbox85">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child> <child>
<widget class="GtkScrolledWindow" id="scrolledwindow33"> <widget class="GtkScrolledWindow" id="scrolledwindow33">
<property name="visible">True</property> <property name="visible">True</property>
@ -8041,6 +8047,56 @@ Custom</property>
</widget> </widget>
</child> </child>
</widget> </widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
<child>
<widget class="GtkExpander" id="expander6">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="expanded">True</property>
<property name="spacing">0</property>
<child>
<widget class="GtkImage" id="PHOTO_image">
<property name="visible">True</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
</child>
<child>
<widget class="GtkLabel" id="label310">
<property name="visible">True</property>
<property name="label" translatable="yes">Photo</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
<packing>
<property name="type">label_item</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
</widget>
<packing> <packing>
<property name="tab_expand">False</property> <property name="tab_expand">False</property>
<property name="tab_fill">True</property> <property name="tab_fill">True</property>

View File

@ -19,6 +19,8 @@
import gtk import gtk
import gtk.glade import gtk.glade
import urllib
import base64
from common import gajim from common import gajim
from common import i18n from common import i18n
_ = i18n._ _ = i18n._
@ -76,6 +78,29 @@ class Vcard_window:
def set_values(self, vcard): def set_values(self, vcard):
for i in vcard.keys(): for i in vcard.keys():
if type(vcard[i]) == type({}): if type(vcard[i]) == type({}):
if i == 'PHOTO':
img_decoded = None
if vcard[i].has_key('BINVAL'):
try:
img_encoded = vcard[i]['BINVAL']
img_decoded = base64.decodestring(img_encoded)
except:
pass
elif vcard[i].has_key('EXTVAL'):
url = vcard[i]['EXTVAL']
try:
fd = urllib.urlopen(url)
img_decoded = fd.read()
except:
pass
if img_decoded:
pixbufloader = gtk.gdk.PixbufLoader()
pixbufloader.write(img_decoded)
pixbufloader.close()
pixbuf = pixbufloader.get_pixbuf()
image = self.xml.get_widget('PHOTO_image')
image.set_from_pixbuf(pixbuf)
continue
add_on = '' add_on = ''
if i == 'ADR' or i == 'TEL' or i == 'EMAIL': if i == 'ADR' or i == 'TEL' or i == 'EMAIL':
add_on = '_HOME' add_on = '_HOME'