2005-06-11 00:45:50 +02:00
|
|
|
## vcard.py (has VcardWindow class)
|
2005-04-19 23:53:19 +02:00
|
|
|
##
|
|
|
|
## Gajim Team:
|
|
|
|
## - Yann Le Boulanger <asterix@lagaule.org>
|
|
|
|
## - Vincent Hanquez <tab@snarc.org>
|
|
|
|
## - Nikos Kouremenos <kourem@gmail.com>
|
|
|
|
##
|
|
|
|
## Copyright (C) 2003-2005 Gajim Team
|
|
|
|
##
|
|
|
|
## This program is free software; you can redistribute it and/or modify
|
|
|
|
## it under the terms of the GNU General Public License as published
|
|
|
|
## by the Free Software Foundation; version 2 only.
|
|
|
|
##
|
|
|
|
## This program is distributed in the hope that it will be useful,
|
|
|
|
## but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
## GNU General Public License for more details.
|
|
|
|
##
|
|
|
|
|
|
|
|
import gtk
|
|
|
|
import gtk.glade
|
2005-06-06 22:16:51 +02:00
|
|
|
import urllib
|
|
|
|
import base64
|
2005-06-07 00:58:06 +02:00
|
|
|
import mimetypes
|
|
|
|
import os
|
2005-06-10 23:14:16 +02:00
|
|
|
import dialogs
|
2005-04-19 23:53:19 +02:00
|
|
|
from common import gajim
|
|
|
|
from common import i18n
|
|
|
|
_ = i18n._
|
|
|
|
APP = i18n.APP
|
|
|
|
gtk.glade.bindtextdomain (APP, i18n.DIR)
|
|
|
|
gtk.glade.textdomain (APP)
|
|
|
|
|
2005-04-22 01:20:18 +02:00
|
|
|
GTKGUI_GLADE = 'gtkgui.glade'
|
2005-04-19 23:53:19 +02:00
|
|
|
|
2005-06-11 00:45:50 +02:00
|
|
|
class VcardWindow:
|
2005-05-16 16:15:13 +02:00
|
|
|
'''Class for contact's information window'''
|
2005-04-22 01:20:18 +02:00
|
|
|
def on_user_information_window_destroy(self, widget = None):
|
2005-04-19 23:53:19 +02:00
|
|
|
del self.plugin.windows[self.account]['infos'][self.jid]
|
|
|
|
|
|
|
|
def on_vcard_information_window_key_press_event(self, widget, event):
|
|
|
|
if event.keyval == gtk.keysyms.Escape: # ESCAPE
|
|
|
|
self.window.destroy()
|
|
|
|
|
|
|
|
def on_close_button_clicked(self, widget):
|
|
|
|
'''Save user's informations and update the roster on the Jabber server'''
|
|
|
|
if self.vcard:
|
|
|
|
self.window.destroy()
|
|
|
|
return
|
|
|
|
#update user.name if it's not ''
|
|
|
|
name_entry = self.xml.get_widget('nickname_entry')
|
|
|
|
new_name = name_entry.get_text()
|
|
|
|
if new_name != self.user.name and new_name != '':
|
|
|
|
self.user.name = new_name
|
|
|
|
for i in self.plugin.roster.get_user_iter(self.user.jid, self.account):
|
|
|
|
self.plugin.roster.tree.get_model().set_value(i, 1, new_name)
|
2005-05-16 16:15:13 +02:00
|
|
|
gajim.connections[self.account].update_user(self.user.jid,
|
2005-04-19 23:53:19 +02:00
|
|
|
self.user.name, self.user.groups)
|
|
|
|
#log history ?
|
2005-06-10 21:03:32 +02:00
|
|
|
oldlog = True
|
2005-05-16 16:15:13 +02:00
|
|
|
no_log_for = gajim.config.get_per('accounts', self.account,
|
|
|
|
'no_log_for').split()
|
2005-04-19 23:53:19 +02:00
|
|
|
if self.user.jid in no_log_for:
|
2005-06-10 21:03:32 +02:00
|
|
|
oldlog = False
|
2005-04-19 23:53:19 +02:00
|
|
|
log = self.xml.get_widget('log_checkbutton').get_active()
|
|
|
|
if not log and not self.user.jid in no_log_for:
|
|
|
|
no_log_for.append(self.user.jid)
|
|
|
|
if log and self.user.jid in no_log_for:
|
|
|
|
no_log_for.remove(self.user.jid)
|
|
|
|
if oldlog != log:
|
2005-05-16 16:15:13 +02:00
|
|
|
gajim.config.set_per('accounts', self.account, 'no_log_for',
|
2005-04-19 23:53:19 +02:00
|
|
|
' '.join(no_log_for))
|
|
|
|
self.window.destroy()
|
|
|
|
|
2005-06-07 00:58:06 +02:00
|
|
|
def on_clear_button_clicked(self, widget):
|
|
|
|
# empty the image
|
|
|
|
self.xml.get_widget('PHOTO_image').set_from_pixbuf(None)
|
2005-06-10 22:40:07 +02:00
|
|
|
self.avatar_encoded = None
|
2005-06-07 00:58:06 +02:00
|
|
|
|
|
|
|
def image_is_ok(self, image):
|
|
|
|
if not os.path.exists(image):
|
|
|
|
return False
|
|
|
|
return True
|
|
|
|
|
2005-06-10 21:03:32 +02:00
|
|
|
def update_preview(self, widget):
|
|
|
|
path_to_file = widget.get_preview_filename()
|
|
|
|
widget.get_preview_widget().set_from_file(path_to_file)
|
|
|
|
|
2005-06-07 00:58:06 +02:00
|
|
|
def on_set_avatar_button_clicked(self, widget):
|
2005-06-07 21:54:32 +02:00
|
|
|
file = None
|
2005-06-10 21:03:32 +02:00
|
|
|
dialog = gtk.FileChooserDialog(_('Choose avatar'), None,
|
2005-06-07 00:58:06 +02:00
|
|
|
gtk.FILE_CHOOSER_ACTION_OPEN,
|
|
|
|
(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
|
|
|
|
gtk.STOCK_OPEN, gtk.RESPONSE_OK))
|
|
|
|
dialog.set_default_response(gtk.RESPONSE_OK)
|
|
|
|
filter = gtk.FileFilter()
|
2005-06-10 21:03:32 +02:00
|
|
|
filter.set_name(_('All files'))
|
2005-06-07 00:58:06 +02:00
|
|
|
filter.add_pattern('*')
|
|
|
|
dialog.add_filter(filter)
|
|
|
|
|
|
|
|
filter = gtk.FileFilter()
|
2005-06-10 21:03:32 +02:00
|
|
|
filter.set_name(_('Images'))
|
2005-06-07 00:58:06 +02:00
|
|
|
filter.add_mime_type('image/png')
|
|
|
|
filter.add_mime_type('image/jpeg')
|
|
|
|
filter.add_mime_type('image/gif')
|
|
|
|
filter.add_pattern('*.png')
|
|
|
|
filter.add_pattern('*.jpg')
|
|
|
|
filter.add_pattern('*.gif')
|
|
|
|
filter.add_pattern('*.tif')
|
|
|
|
filter.add_pattern('*.xpm')
|
|
|
|
dialog.add_filter(filter)
|
|
|
|
dialog.set_filter(filter)
|
2005-06-10 21:03:32 +02:00
|
|
|
dialog.set_use_preview_label(False)
|
|
|
|
dialog.set_preview_widget(gtk.Image())
|
|
|
|
dialog.connect('selection-changed', self.update_preview)
|
2005-06-07 00:58:06 +02:00
|
|
|
|
|
|
|
ok = False
|
|
|
|
while not ok:
|
|
|
|
response = dialog.run()
|
|
|
|
if response == gtk.RESPONSE_OK:
|
|
|
|
file = dialog.get_filename()
|
|
|
|
if self.image_is_ok(file):
|
|
|
|
ok = True
|
|
|
|
else:
|
|
|
|
ok = True
|
|
|
|
dialog.destroy()
|
|
|
|
|
|
|
|
if file:
|
2005-06-10 23:14:16 +02:00
|
|
|
filesize = os.path.getsize(file) # in bytes
|
|
|
|
if filesize > 8192:
|
2005-06-12 22:38:19 +02:00
|
|
|
dialogs.ErrorDialog(_('The filesize of image "%s" is too large') % file,
|
|
|
|
_('The file must not be more than 8 kilobytes.')).get_response()
|
2005-06-10 23:14:16 +02:00
|
|
|
return
|
2005-06-07 00:58:06 +02:00
|
|
|
fd = open(file)
|
|
|
|
data = fd.read()
|
|
|
|
pixbufloader = gtk.gdk.PixbufLoader()
|
|
|
|
pixbufloader.write(data)
|
|
|
|
pixbufloader.close()
|
|
|
|
pixbuf = pixbufloader.get_pixbuf()
|
|
|
|
image = self.xml.get_widget('PHOTO_image')
|
|
|
|
image.set_from_pixbuf(pixbuf)
|
|
|
|
self.avatar_encoded = base64.encodestring(data)
|
|
|
|
self.avatar_mime_type = mimetypes.guess_type(file)[0]
|
|
|
|
|
2005-04-19 23:53:19 +02:00
|
|
|
def set_value(self, entry_name, value):
|
|
|
|
try:
|
|
|
|
self.xml.get_widget(entry_name).set_text(value)
|
|
|
|
except AttributeError, e:
|
|
|
|
pass
|
|
|
|
|
|
|
|
def set_values(self, vcard):
|
|
|
|
for i in vcard.keys():
|
2005-06-07 10:50:47 +02:00
|
|
|
if i == 'PHOTO':
|
2005-06-10 15:46:41 +02:00
|
|
|
if not type(vcard[i]) == type({}):
|
|
|
|
continue
|
2005-06-07 10:50:47 +02:00
|
|
|
img_decoded = None
|
2005-06-07 16:31:10 +02:00
|
|
|
if vcard[i].has_key('BINVAL') and vcard[i].has_key('TYPE'):
|
2005-06-07 10:50:47 +02:00
|
|
|
img_encoded = vcard[i]['BINVAL']
|
|
|
|
self.avatar_encoded = img_encoded
|
|
|
|
self.avatar_mime_type = vcard[i]['TYPE']
|
|
|
|
try:
|
|
|
|
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
|
|
|
|
if i == 'ADR' or i == 'TEL' or i == 'EMAIL':
|
|
|
|
for entry in vcard[i]:
|
2005-06-06 17:29:27 +02:00
|
|
|
add_on = '_HOME'
|
2005-06-07 10:50:47 +02:00
|
|
|
if 'WORK' in entry:
|
2005-06-06 17:29:27 +02:00
|
|
|
add_on = '_WORK'
|
2005-06-07 10:50:47 +02:00
|
|
|
for j in entry.keys():
|
|
|
|
self.set_value(i + add_on + '_' + j + '_entry', entry[j])
|
|
|
|
if type(vcard[i]) == type({}):
|
2005-04-19 23:53:19 +02:00
|
|
|
for j in vcard[i].keys():
|
2005-06-07 10:50:47 +02:00
|
|
|
self.set_value(i + '_' + j + '_entry', vcard[i][j])
|
2005-04-19 23:53:19 +02:00
|
|
|
else:
|
|
|
|
if i == 'DESC':
|
2005-05-16 16:15:13 +02:00
|
|
|
self.xml.get_widget('DESC_textview').get_buffer().set_text(
|
|
|
|
vcard[i], 0)
|
2005-04-19 23:53:19 +02:00
|
|
|
else:
|
2005-04-22 01:20:18 +02:00
|
|
|
self.set_value(i + '_entry', vcard[i])
|
2005-04-19 23:53:19 +02:00
|
|
|
|
2005-04-25 00:58:41 +02:00
|
|
|
def set_os_info(self, resource, client_info, os_info):
|
|
|
|
i = 0
|
|
|
|
client = ''
|
2005-05-05 16:02:39 +02:00
|
|
|
os = ''
|
2005-04-25 00:58:41 +02:00
|
|
|
while self.os_info.has_key(i):
|
|
|
|
if self.os_info[i]['resource'] == resource:
|
|
|
|
self.os_info[i]['client'] = client_info
|
2005-05-05 16:02:39 +02:00
|
|
|
self.os_info[i]['os'] = os_info
|
2005-04-25 00:58:41 +02:00
|
|
|
if i > 0:
|
|
|
|
client += '\n'
|
2005-05-05 16:02:39 +02:00
|
|
|
os += '\n'
|
2005-04-25 00:58:41 +02:00
|
|
|
client += self.os_info[i]['client']
|
2005-05-05 16:02:39 +02:00
|
|
|
os += self.os_info[i]['os']
|
2005-04-25 00:58:41 +02:00
|
|
|
i += 1
|
2005-05-11 13:09:53 +02:00
|
|
|
|
|
|
|
if client == '':
|
|
|
|
client = 'N/A'
|
|
|
|
if os == '':
|
|
|
|
os = 'N/A'
|
2005-04-25 00:58:41 +02:00
|
|
|
self.xml.get_widget('client_name_version_label').set_text(client)
|
2005-05-05 16:02:39 +02:00
|
|
|
self.xml.get_widget('os_label').set_text(os)
|
2005-04-19 23:53:19 +02:00
|
|
|
|
|
|
|
def fill_jabber_page(self):
|
|
|
|
self.xml.get_widget('nickname_label').set_text(self.user.name)
|
|
|
|
self.xml.get_widget('jid_label').set_text(self.user.jid)
|
|
|
|
self.xml.get_widget('subscription_label').set_text(self.user.sub)
|
2005-04-22 03:35:36 +02:00
|
|
|
label = self.xml.get_widget('ask_label')
|
2005-04-19 23:53:19 +02:00
|
|
|
if self.user.ask:
|
2005-04-22 03:35:36 +02:00
|
|
|
label.set_text(self.user.ask)
|
2005-04-19 23:53:19 +02:00
|
|
|
else:
|
2005-04-22 03:35:36 +02:00
|
|
|
label.set_text('None')
|
2005-04-19 23:53:19 +02:00
|
|
|
self.xml.get_widget('nickname_entry').set_text(self.user.name)
|
|
|
|
log = 1
|
2005-05-16 16:15:13 +02:00
|
|
|
if self.user.jid in gajim.config.get_per('accounts', self.account,
|
2005-04-19 23:53:19 +02:00
|
|
|
'no_log_for').split(' '):
|
|
|
|
log = 0
|
|
|
|
self.xml.get_widget('log_checkbutton').set_active(log)
|
|
|
|
resources = self.user.resource + ' (' + str(self.user.priority) + ')'
|
|
|
|
if not self.user.status:
|
|
|
|
self.user.status = ''
|
2005-05-20 17:50:44 +02:00
|
|
|
stats = self.user.show
|
|
|
|
if self.user.status:
|
|
|
|
stats += ': ' + self.user.status
|
2005-05-16 16:15:13 +02:00
|
|
|
gajim.connections[self.account].request_os_info(self.user.jid,
|
2005-04-25 00:58:41 +02:00
|
|
|
self.user.resource)
|
|
|
|
self.os_info = {0: {'resource': self.user.resource, 'client': '',
|
2005-05-05 16:02:39 +02:00
|
|
|
'os': ''}}
|
2005-04-25 00:58:41 +02:00
|
|
|
i = 1
|
2005-04-19 23:53:19 +02:00
|
|
|
for u in self.plugin.roster.contacts[self.account][self.user.jid]:
|
|
|
|
if u.resource != self.user.resource:
|
|
|
|
resources += '\n' + u.resource + ' (' + str(u.priority) + ')'
|
|
|
|
if not u.status:
|
|
|
|
u.status = ''
|
|
|
|
stats += '\n' + u.show + ': ' + u.status
|
2005-05-16 16:15:13 +02:00
|
|
|
gajim.connections[self.account].request_os_info(self.user.jid,
|
2005-04-25 00:58:41 +02:00
|
|
|
u.resource)
|
|
|
|
self.os_info[i] = {'resource': u.resource, 'client': '',
|
2005-05-05 16:02:39 +02:00
|
|
|
'os': ''}
|
2005-04-25 00:58:41 +02:00
|
|
|
i += 1
|
2005-04-19 23:53:19 +02:00
|
|
|
self.xml.get_widget('resource_label').set_text(resources)
|
2005-06-14 17:51:34 +02:00
|
|
|
|
|
|
|
status_label = self.xml.get_widget('status_label')
|
|
|
|
#FIXME: when gtk2.4 is OOOOLD do it via glade2.10+
|
|
|
|
if gtk.pygtk_version > (2, 6, 0) and gtk.gtk_version > (2, 6, 0):
|
|
|
|
tip = gtk.Tooltips()
|
|
|
|
status_label_eventbox = self.xml.get_widget('status_label_eventbox')
|
|
|
|
tip.set_tip(status_label_eventbox, stats)
|
|
|
|
status_label.set_max_width_chars(15)
|
|
|
|
status_label.set_text(stats)
|
|
|
|
|
2005-04-19 23:53:19 +02:00
|
|
|
gajim.connections[self.account].request_vcard(self.user.jid)
|
|
|
|
|
|
|
|
def add_to_vcard(self, vcard, entry, txt):
|
|
|
|
'''Add an information to the vCard dictionary'''
|
|
|
|
entries = entry.split('_')
|
|
|
|
loc = vcard
|
2005-06-07 10:50:47 +02:00
|
|
|
if len(entries) == 3: # We need to use lists
|
|
|
|
if not loc.has_key(entries[0]):
|
|
|
|
loc[entries[0]] = []
|
|
|
|
found = False
|
|
|
|
for e in loc[entries[0]]:
|
|
|
|
if entries[1] in e:
|
|
|
|
found = True
|
|
|
|
break
|
|
|
|
if found:
|
|
|
|
e[entries[2]] = txt
|
|
|
|
else:
|
|
|
|
loc[entries[0]].append({entries[1]: '', entries[2]: txt})
|
|
|
|
return vcard
|
2005-04-19 23:53:19 +02:00
|
|
|
while len(entries) > 1:
|
|
|
|
if not loc.has_key(entries[0]):
|
|
|
|
loc[entries[0]] = {}
|
|
|
|
loc = loc[entries[0]]
|
|
|
|
del entries[0]
|
|
|
|
loc[entries[0]] = txt
|
|
|
|
return vcard
|
|
|
|
|
|
|
|
def make_vcard(self):
|
|
|
|
'''make the vCard dictionary'''
|
2005-06-06 17:29:27 +02:00
|
|
|
entries = ['FN', 'NICKNAME', 'BDAY', 'EMAIL_HOME_USERID', 'URL',
|
|
|
|
'TEL_HOME_NUMBER', 'N_FAMILY', 'N_GIVEN', 'N_MIDDLE', 'N_PREFIX',
|
|
|
|
'N_SUFFIX', 'ADR_HOME_STREET', 'ADR_HOME_EXTADR', 'ADR_HOME_LOCALITY',
|
|
|
|
'ADR_HOME_REGION', 'ADR_HOME_PCODE', 'ADR_HOME_CTRY', 'ORG_ORGNAME',
|
|
|
|
'ORG_ORGUNIT', 'TITLE', 'ROLE', 'ADR_WORK_STREET', 'ADR_WORK_EXTADR',
|
|
|
|
'ADR_WORK_LOCALITY', 'ADR_WORK_REGION', 'ADR_WORK_PCODE',
|
|
|
|
'ADR_WORK_CTRY']
|
2005-04-19 23:53:19 +02:00
|
|
|
vcard = {}
|
|
|
|
for e in entries:
|
2005-04-22 01:20:18 +02:00
|
|
|
txt = self.xml.get_widget(e + '_entry').get_text()
|
2005-04-19 23:53:19 +02:00
|
|
|
if txt != '':
|
|
|
|
vcard = self.add_to_vcard(vcard, e, txt)
|
2005-06-07 00:58:06 +02:00
|
|
|
|
|
|
|
# DESC textview
|
2005-04-19 23:53:19 +02:00
|
|
|
buffer = self.xml.get_widget('DESC_textview').get_buffer()
|
|
|
|
start_iter = buffer.get_start_iter()
|
|
|
|
end_iter = buffer.get_end_iter()
|
|
|
|
txt = buffer.get_text(start_iter, end_iter, 0)
|
|
|
|
if txt != '':
|
|
|
|
vcard['DESC'] = txt
|
2005-06-07 00:58:06 +02:00
|
|
|
|
|
|
|
# Avatar
|
|
|
|
if self.avatar_encoded:
|
|
|
|
vcard['PHOTO'] = {'TYPE': self.avatar_mime_type,
|
|
|
|
'BINVAL': self.avatar_encoded}
|
2005-04-19 23:53:19 +02:00
|
|
|
return vcard
|
|
|
|
|
|
|
|
def on_publish_button_clicked(self, widget):
|
|
|
|
if gajim.connections[self.account].connected < 2:
|
2005-06-10 23:14:16 +02:00
|
|
|
ErrorDialog(_('You are not connected to the server'),
|
2005-06-07 03:10:24 +02:00
|
|
|
_('Without a connection you can not publish your contact information.')).get_response()
|
2005-04-19 23:53:19 +02:00
|
|
|
return
|
|
|
|
vcard = self.make_vcard()
|
|
|
|
nick = ''
|
|
|
|
if vcard.has_key('NICKNAME'):
|
|
|
|
nick = vcard['NICKNAME']
|
|
|
|
if nick == '':
|
|
|
|
nick = gajim.config.get_per('accounts', self.account, 'name')
|
|
|
|
self.plugin.nicks[self.account] = nick
|
|
|
|
gajim.connections[self.account].send_vcard(vcard)
|
|
|
|
|
|
|
|
def on_retrieve_button_clicked(self, widget):
|
2005-06-06 17:29:27 +02:00
|
|
|
entries = ['FN', 'NICKNAME', 'BDAY', 'EMAIL_HOME_USERID', 'URL',
|
|
|
|
'TEL_HOME_NUMBER', 'N_FAMILY', 'N_GIVEN', 'N_MIDDLE', 'N_PREFIX',
|
|
|
|
'N_SUFFIX', 'ADR_HOME_STREET', 'ADR_HOME_EXTADR', 'ADR_HOME_LOCALITY',
|
|
|
|
'ADR_HOME_REGION', 'ADR_HOME_PCODE', 'ADR_HOME_CTRY', 'ORG_ORGNAME',
|
|
|
|
'ORG_ORGUNIT', 'TITLE', 'ROLE', 'ADR_WORK_STREET', 'ADR_WORK_EXTADR',
|
|
|
|
'ADR_WORK_LOCALITY', 'ADR_WORK_REGION', 'ADR_WORK_PCODE',
|
|
|
|
'ADR_WORK_CTRY']
|
2005-04-19 23:53:19 +02:00
|
|
|
if gajim.connections[self.account].connected > 1:
|
|
|
|
# clear all entries
|
|
|
|
for e in entries:
|
|
|
|
self.xml.get_widget(e + '_entry').set_text('')
|
|
|
|
self.xml.get_widget('DESC_textview').get_buffer().set_text('')
|
2005-06-07 10:50:47 +02:00
|
|
|
self.xml.get_widget('PHOTO_image').set_from_pixbuf(None)
|
2005-04-19 23:53:19 +02:00
|
|
|
gajim.connections[self.account].request_vcard(self.jid)
|
|
|
|
else:
|
2005-06-10 23:14:16 +02:00
|
|
|
ErrorDialog(_('You are not connected to the server'),
|
2005-06-07 03:10:24 +02:00
|
|
|
_('Without a connection, you can not get your contact information.')).get_response()
|
2005-04-19 23:53:19 +02:00
|
|
|
|
|
|
|
def change_to_vcard(self):
|
|
|
|
self.xml.get_widget('information_notebook').remove_page(0)
|
|
|
|
self.xml.get_widget('nickname_label').set_text('Personal details')
|
|
|
|
information_hbuttonbox = self.xml.get_widget('information_hbuttonbox')
|
|
|
|
#publish button
|
2005-04-22 01:20:18 +02:00
|
|
|
button = gtk.Button(stock = gtk.STOCK_GOTO_TOP)
|
2005-05-16 16:15:13 +02:00
|
|
|
button.get_children()[0].get_children()[0].get_children()[1].set_text(
|
2005-06-14 17:51:34 +02:00
|
|
|
_('_Publish'))
|
2005-04-19 23:53:19 +02:00
|
|
|
button.connect('clicked', self.on_publish_button_clicked)
|
|
|
|
button.show_all()
|
|
|
|
information_hbuttonbox.pack_start(button)
|
|
|
|
#retrieve button
|
2005-04-22 01:20:18 +02:00
|
|
|
button = gtk.Button(stock = gtk.STOCK_GOTO_BOTTOM)
|
2005-05-16 16:15:13 +02:00
|
|
|
button.get_children()[0].get_children()[0].get_children()[1].set_text(
|
2005-06-14 17:51:34 +02:00
|
|
|
_('_Retrieve'))
|
2005-04-19 23:53:19 +02:00
|
|
|
button.connect('clicked', self.on_retrieve_button_clicked)
|
|
|
|
button.show_all()
|
|
|
|
information_hbuttonbox.pack_start(button)
|
|
|
|
#close button at the end
|
|
|
|
button = self.xml.get_widget('close_button')
|
|
|
|
information_hbuttonbox.reorder_child(button, 2)
|
2005-06-07 00:58:06 +02:00
|
|
|
#photo_vbuttonbox visible
|
|
|
|
self.xml.get_widget('photo_vbuttonbox').show()
|
2005-04-19 23:53:19 +02:00
|
|
|
|
|
|
|
#make all entries editable
|
2005-06-06 17:29:27 +02:00
|
|
|
entries = ['FN', 'NICKNAME', 'BDAY', 'EMAIL_HOME_USERID', 'URL',
|
|
|
|
'TEL_HOME_NUMBER', 'N_FAMILY', 'N_GIVEN', 'N_MIDDLE', 'N_PREFIX',
|
|
|
|
'N_SUFFIX', 'ADR_HOME_STREET', 'ADR_HOME_EXTADR', 'ADR_HOME_LOCALITY',
|
|
|
|
'ADR_HOME_REGION', 'ADR_HOME_PCODE', 'ADR_HOME_CTRY', 'ORG_ORGNAME',
|
|
|
|
'ORG_ORGUNIT', 'TITLE', 'ROLE', 'ADR_WORK_STREET', 'ADR_WORK_EXTADR',
|
|
|
|
'ADR_WORK_LOCALITY', 'ADR_WORK_REGION', 'ADR_WORK_PCODE',
|
|
|
|
'ADR_WORK_CTRY']
|
2005-04-19 23:53:19 +02:00
|
|
|
for e in entries:
|
|
|
|
self.xml.get_widget(e + '_entry').set_property('editable', True)
|
|
|
|
|
|
|
|
description_textview = self.xml.get_widget('DESC_textview')
|
|
|
|
description_textview.set_editable(True)
|
|
|
|
description_textview.set_cursor_visible(True)
|
|
|
|
|
|
|
|
#the user variable is the jid if vcard is true
|
2005-04-22 01:20:18 +02:00
|
|
|
def __init__(self, user, plugin, account, vcard = False):
|
2005-04-19 23:53:19 +02:00
|
|
|
self.xml = gtk.glade.XML(GTKGUI_GLADE, 'vcard_information_window', APP)
|
|
|
|
self.window = self.xml.get_widget('vcard_information_window')
|
2005-06-07 00:58:06 +02:00
|
|
|
self.xml.get_widget('photo_vbuttonbox').set_no_show_all(True)
|
2005-04-19 23:53:19 +02:00
|
|
|
self.plugin = plugin
|
|
|
|
self.user = user #don't use it if vcard is true
|
|
|
|
self.account = account
|
|
|
|
self.vcard = vcard
|
2005-06-07 00:58:06 +02:00
|
|
|
self.avatar_mime_type = None
|
|
|
|
self.avatar_encoded = None
|
2005-04-19 23:53:19 +02:00
|
|
|
|
|
|
|
if vcard:
|
|
|
|
self.jid = user
|
|
|
|
self.change_to_vcard()
|
|
|
|
else:
|
|
|
|
self.jid = user.jid
|
|
|
|
self.fill_jabber_page()
|
|
|
|
|
|
|
|
self.xml.signal_autoconnect(self)
|
|
|
|
self.window.show_all()
|