2006-04-05 14:12:37 +02:00
|
|
|
## vcard.py (has VcardWindow class and a func get_avatar_pixbuf_encoded_mime)
|
2005-04-19 23:53:19 +02:00
|
|
|
##
|
2007-10-22 13:33:50 +02:00
|
|
|
## Copyright (C) 2003-2007 Yann Leboulanger <asterix@lagaule.org>
|
2006-03-15 03:09:57 +01:00
|
|
|
## Copyright (C) 2005-2006 Nikos Kouremenos <kourem@gmail.com>
|
2006-10-02 14:14:56 +02:00
|
|
|
## Copyright (C) 2006 Stefan Bethge <stefan@lanpartei.de>
|
2007-07-04 15:23:16 +02:00
|
|
|
## Copyright (C) 2007 Lukas Petrovicky <lukas@petrovicky.net>
|
2005-04-19 23:53:19 +02:00
|
|
|
##
|
2007-10-22 13:13:13 +02:00
|
|
|
## This file is part of Gajim.
|
|
|
|
##
|
|
|
|
## Gajim is free software; you can redistribute it and/or modify
|
2005-04-19 23:53:19 +02:00
|
|
|
## it under the terms of the GNU General Public License as published
|
2007-10-22 13:13:13 +02:00
|
|
|
## by the Free Software Foundation; version 3 only.
|
2005-04-19 23:53:19 +02:00
|
|
|
##
|
2007-10-22 13:13:13 +02:00
|
|
|
## Gajim is distributed in the hope that it will be useful,
|
2005-04-19 23:53:19 +02:00
|
|
|
## 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.
|
|
|
|
##
|
2007-10-22 13:13:13 +02:00
|
|
|
## You should have received a copy of the GNU General Public License
|
|
|
|
## along with Gajim. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
##
|
2005-04-19 23:53:19 +02:00
|
|
|
|
2006-10-02 18:24:10 +02:00
|
|
|
# THIS FILE IS FOR **OTHERS'** PROFILE (when we VIEW their INFO)
|
|
|
|
|
2005-04-19 23:53:19 +02:00
|
|
|
import gtk
|
2005-09-05 15:35:45 +02:00
|
|
|
import gobject
|
2005-06-06 22:16:51 +02:00
|
|
|
import base64
|
2006-02-22 15:31:01 +01:00
|
|
|
import time
|
2006-03-24 19:48:26 +01:00
|
|
|
import locale
|
2007-04-22 12:23:23 +02:00
|
|
|
import os
|
2006-03-24 19:48:26 +01:00
|
|
|
|
2005-10-03 20:27:39 +02:00
|
|
|
import gtkgui_helpers
|
2007-04-22 12:23:23 +02:00
|
|
|
import dialogs
|
|
|
|
import message_control
|
2005-08-03 12:59:44 +02:00
|
|
|
|
|
|
|
from common import helpers
|
2005-04-19 23:53:19 +02:00
|
|
|
from common import gajim
|
2006-06-15 08:49:04 +02:00
|
|
|
from common.i18n import Q_
|
2005-04-19 23:53:19 +02:00
|
|
|
|
2005-10-31 12:06:11 +01:00
|
|
|
def get_avatar_pixbuf_encoded_mime(photo):
|
2005-10-31 11:23:33 +01:00
|
|
|
'''return the pixbuf of the image
|
|
|
|
photo is a dictionary containing PHOTO information'''
|
|
|
|
if not isinstance(photo, dict):
|
|
|
|
return None, None, None
|
|
|
|
img_decoded = None
|
2005-11-16 12:05:45 +01:00
|
|
|
avatar_encoded = None
|
|
|
|
avatar_mime_type = None
|
2006-06-09 15:41:31 +02:00
|
|
|
if photo.has_key('BINVAL'):
|
2005-10-31 11:23:33 +01:00
|
|
|
img_encoded = photo['BINVAL']
|
|
|
|
avatar_encoded = img_encoded
|
|
|
|
try:
|
|
|
|
img_decoded = base64.decodestring(img_encoded)
|
|
|
|
except:
|
|
|
|
pass
|
|
|
|
if img_decoded:
|
2006-06-09 15:41:31 +02:00
|
|
|
if photo.has_key('TYPE'):
|
|
|
|
avatar_mime_type = photo['TYPE']
|
|
|
|
pixbuf = gtkgui_helpers.get_pixbuf_from_data(img_decoded)
|
|
|
|
else:
|
|
|
|
pixbuf, avatar_mime_type = gtkgui_helpers.get_pixbuf_from_data(
|
|
|
|
img_decoded, want_type=True)
|
2005-11-16 12:05:45 +01:00
|
|
|
else:
|
|
|
|
pixbuf = None
|
|
|
|
return pixbuf, avatar_encoded, avatar_mime_type
|
2005-10-31 11:23:33 +01: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-07-03 01:03:57 +02:00
|
|
|
|
2006-10-06 16:29:15 +02:00
|
|
|
def __init__(self, contact, account, gc_contact = None):
|
Merged in trunk updates, including meta_contacts
Merged revisions 4951,4962-4969 via svnmerge from
svn://svn.gajim.org/gajim/trunk
........
r4951 | nk | 2005-12-30 16:50:36 -0700 (Fri, 30 Dec 2005) | 1 line
fixes in greek transl
........
r4962 | asterix | 2006-01-01 11:41:04 -0700 (Sun, 01 Jan 2006) | 2 lines
merge meta_contacts branch with trunk. Meta contacts are not in gajim yet, but framework is here. We now use gajim.contacts.many_functions() to handle contacts and groupchat_contacts.
........
r4963 | asterix | 2006-01-01 11:43:24 -0700 (Sun, 01 Jan 2006) | 2 lines
correct contacts file
........
r4964 | asterix | 2006-01-01 11:47:26 -0700 (Sun, 01 Jan 2006) | 2 lines
dict.remove() doesn't exists, it's del dict[]
........
r4965 | asterix | 2006-01-01 11:50:15 -0700 (Sun, 01 Jan 2006) | 2 lines
some missing commits from branch
........
r4966 | asterix | 2006-01-01 11:53:30 -0700 (Sun, 01 Jan 2006) | 2 lines
end of gc_contact.nick -> gc_contact.name
........
r4967 | asterix | 2006-01-01 12:05:59 -0700 (Sun, 01 Jan 2006) | 2 lines
new ACE option: send_sha_in_gc_presence that allow to send sha info in groupchat presences
........
r4968 | asterix | 2006-01-01 12:12:36 -0700 (Sun, 01 Jan 2006) | 2 lines
0.9.1-2 in debian that solve the group bug (commit [4924])
........
r4969 | asterix | 2006-01-01 12:31:13 -0700 (Sun, 01 Jan 2006) | 2 lines
typo
........
2006-01-01 21:06:26 +01:00
|
|
|
# the contact variable is the jid if vcard is true
|
2006-05-02 17:53:25 +02:00
|
|
|
self.xml = gtkgui_helpers.get_glade('vcard_information_window.glade')
|
2005-07-03 01:03:57 +02:00
|
|
|
self.window = self.xml.get_widget('vcard_information_window')
|
2006-09-19 10:17:36 +02:00
|
|
|
self.progressbar = self.xml.get_widget('progressbar')
|
2006-03-29 17:46:34 +02:00
|
|
|
|
2006-09-08 19:35:28 +02:00
|
|
|
self.contact = contact
|
2005-07-03 01:03:57 +02:00
|
|
|
self.account = account
|
2006-10-06 16:29:15 +02:00
|
|
|
self.gc_contact = gc_contact
|
2006-09-08 19:35:28 +02:00
|
|
|
|
2007-07-22 15:39:18 +02:00
|
|
|
# Get real jid
|
|
|
|
if gc_contact:
|
|
|
|
if gc_contact.jid:
|
|
|
|
self.real_jid = gc_contact.jid
|
|
|
|
if gc_contact.resource:
|
|
|
|
self.real_jid += '/' + gc_contact.resource
|
|
|
|
else:
|
|
|
|
self.real_jid = gc_contact.get_full_jid()
|
|
|
|
else:
|
|
|
|
self.real_jid = contact.get_full_jid()
|
|
|
|
|
2007-04-22 12:23:23 +02:00
|
|
|
puny_jid = helpers.sanitize_filename(contact.jid)
|
|
|
|
local_avatar_basepath = os.path.join(gajim.AVATAR_PATH, puny_jid) + \
|
|
|
|
'_local'
|
|
|
|
for extension in ('.png', '.jpeg'):
|
|
|
|
local_avatar_path = local_avatar_basepath + extension
|
|
|
|
if os.path.isfile(local_avatar_path):
|
2007-07-10 19:53:42 +02:00
|
|
|
image = self.xml.get_widget('custom_avatar_image')
|
2007-04-22 12:23:23 +02:00
|
|
|
image.set_from_file(local_avatar_path)
|
2007-07-10 19:53:42 +02:00
|
|
|
image.show()
|
|
|
|
self.xml.get_widget('custom_avatar_label').show()
|
2007-04-22 12:23:23 +02:00
|
|
|
break
|
2005-07-03 01:03:57 +02:00
|
|
|
self.avatar_mime_type = None
|
|
|
|
self.avatar_encoded = None
|
2006-09-19 10:17:36 +02:00
|
|
|
self.vcard_arrived = False
|
|
|
|
self.os_info_arrived = False
|
|
|
|
self.update_progressbar_timeout_id = gobject.timeout_add(100,
|
|
|
|
self.update_progressbar)
|
2005-07-03 01:03:57 +02:00
|
|
|
|
2006-09-08 19:35:28 +02:00
|
|
|
self.fill_jabber_page()
|
2006-11-09 20:13:53 +01:00
|
|
|
annotations = gajim.connections[self.account].annotations
|
|
|
|
if self.contact.jid in annotations:
|
|
|
|
buffer = self.xml.get_widget('textview_annotation').get_buffer()
|
|
|
|
buffer.set_text(annotations[self.contact.jid])
|
2006-09-08 19:35:28 +02:00
|
|
|
|
2005-07-03 01:03:57 +02:00
|
|
|
self.xml.signal_autoconnect(self)
|
|
|
|
self.window.show_all()
|
2006-11-02 17:13:39 +01:00
|
|
|
self.xml.get_widget('close_button').grab_focus()
|
2005-07-03 01:03:57 +02:00
|
|
|
|
2006-09-19 10:17:36 +02:00
|
|
|
def update_progressbar(self):
|
|
|
|
self.progressbar.pulse()
|
|
|
|
return True # loop forever
|
|
|
|
|
2007-04-22 12:23:23 +02:00
|
|
|
def update_avatar_in_gui(self):
|
|
|
|
jid = self.contact.jid
|
|
|
|
# Update roster
|
|
|
|
gajim.interface.roster.draw_avatar(jid, self.account)
|
|
|
|
# Update chat window
|
|
|
|
if gajim.interface.msg_win_mgr.has_window(jid, self.account):
|
|
|
|
win = gajim.interface.msg_win_mgr.get_window(jid, self.account)
|
|
|
|
ctrl = win.get_control(jid, self.account)
|
|
|
|
if win and ctrl.type_id != message_control.TYPE_GC:
|
|
|
|
ctrl.show_avatar()
|
|
|
|
|
2005-12-07 22:06:43 +01:00
|
|
|
def on_vcard_information_window_destroy(self, widget):
|
2006-09-19 10:17:36 +02:00
|
|
|
if self.update_progressbar_timeout_id is not None:
|
|
|
|
gobject.source_remove(self.update_progressbar_timeout_id)
|
2006-09-08 19:35:28 +02:00
|
|
|
del gajim.interface.instances[self.account]['infos'][self.contact.jid]
|
2006-11-09 20:13:53 +01:00
|
|
|
buffer = self.xml.get_widget('textview_annotation').get_buffer()
|
2006-11-13 18:52:08 +01:00
|
|
|
annotation = buffer.get_text(buffer.get_start_iter(),
|
|
|
|
buffer.get_end_iter())
|
|
|
|
connection = gajim.connections[self.account]
|
2006-11-13 21:34:24 +01:00
|
|
|
if annotation != connection.annotations.get(self.contact.jid, ''):
|
2006-11-13 18:52:08 +01:00
|
|
|
connection.annotations[self.contact.jid] = annotation
|
|
|
|
connection.store_annotations()
|
2006-11-09 20:13:53 +01:00
|
|
|
|
2005-04-19 23:53:19 +02:00
|
|
|
def on_vcard_information_window_key_press_event(self, widget, event):
|
2005-07-03 01:03:57 +02:00
|
|
|
if event.keyval == gtk.keysyms.Escape:
|
2005-04-19 23:53:19 +02:00
|
|
|
self.window.destroy()
|
|
|
|
|
2006-09-08 23:34:10 +02:00
|
|
|
def on_PHOTO_eventbox_button_press_event(self, widget, event):
|
2006-05-26 15:19:52 +02:00
|
|
|
'''If right-clicked, show popup'''
|
|
|
|
if event.button == 3: # right click
|
|
|
|
menu = gtk.Menu()
|
|
|
|
menuitem = gtk.ImageMenuItem(gtk.STOCK_SAVE_AS)
|
|
|
|
menuitem.connect('activate',
|
|
|
|
gtkgui_helpers.on_avatar_save_as_menuitem_activate,
|
2006-11-08 15:31:40 +01:00
|
|
|
self.contact.jid, self.account, self.contact.get_shown_name() +
|
|
|
|
'.jpeg')
|
2006-05-26 15:19:52 +02:00
|
|
|
menu.append(menuitem)
|
|
|
|
menu.connect('selection-done', lambda w:w.destroy())
|
|
|
|
# show the menu
|
|
|
|
menu.show_all()
|
|
|
|
menu.popup(None, None, None, event.button, event.time)
|
|
|
|
|
2005-04-19 23:53:19 +02:00
|
|
|
def set_value(self, entry_name, value):
|
|
|
|
try:
|
2006-09-16 17:56:39 +02:00
|
|
|
if value and entry_name == 'URL_label':
|
|
|
|
if gtk.pygtk_version >= (2, 10, 0) and gtk.gtk_version >= (2, 10, 0):
|
2006-09-25 23:14:59 +02:00
|
|
|
widget = gtk.LinkButton(value, value)
|
2006-09-16 14:20:12 +02:00
|
|
|
else:
|
2006-09-25 23:14:59 +02:00
|
|
|
widget = gtk.Label(value)
|
2006-11-10 20:18:40 +01:00
|
|
|
widget.set_selectable(True)
|
2006-10-02 18:24:10 +02:00
|
|
|
widget.show()
|
2006-09-16 17:56:39 +02:00
|
|
|
table = self.xml.get_widget('personal_info_table')
|
2006-09-25 23:14:59 +02:00
|
|
|
table.attach(widget, 1, 4, 3, 4, yoptions = 0)
|
2006-09-16 14:20:12 +02:00
|
|
|
else:
|
|
|
|
self.xml.get_widget(entry_name).set_text(value)
|
2005-07-19 22:12:02 +02:00
|
|
|
except AttributeError:
|
2005-04-19 23:53:19 +02:00
|
|
|
pass
|
|
|
|
|
|
|
|
def set_values(self, vcard):
|
|
|
|
for i in vcard.keys():
|
2006-11-15 20:29:53 +01:00
|
|
|
if i == 'PHOTO' and self.xml.get_widget('information_notebook').\
|
|
|
|
get_n_pages() > 4:
|
2005-10-31 11:23:33 +01:00
|
|
|
pixbuf, self.avatar_encoded, self.avatar_mime_type = \
|
2005-10-31 12:06:11 +01:00
|
|
|
get_avatar_pixbuf_encoded_mime(vcard[i])
|
2006-09-02 23:51:16 +02:00
|
|
|
image = self.xml.get_widget('PHOTO_image')
|
2007-04-22 12:23:23 +02:00
|
|
|
image.show()
|
2008-01-11 18:23:26 +01:00
|
|
|
self.xml.get_widget('user_avatar_label').show()
|
2006-03-10 22:58:23 +01:00
|
|
|
if not pixbuf:
|
2006-09-02 23:51:16 +02:00
|
|
|
image.set_from_icon_name('stock_person',
|
|
|
|
gtk.ICON_SIZE_DIALOG)
|
2006-03-10 22:58:23 +01:00
|
|
|
continue
|
2006-03-08 17:01:01 +01:00
|
|
|
pixbuf = gtkgui_helpers.get_scaled_pixbuf(pixbuf, 'vcard')
|
2005-10-31 11:23:33 +01:00
|
|
|
image.set_from_pixbuf(pixbuf)
|
2005-06-07 10:50:47 +02:00
|
|
|
continue
|
2006-10-02 18:24:10 +02:00
|
|
|
if i in ('ADR', 'TEL', 'EMAIL'):
|
2005-06-07 10:50:47 +02:00
|
|
|
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():
|
2006-09-08 19:35:28 +02:00
|
|
|
self.set_value(i + add_on + '_' + j + '_label', entry[j])
|
2005-08-26 14:52:40 +02:00
|
|
|
if isinstance(vcard[i], dict):
|
2005-04-19 23:53:19 +02:00
|
|
|
for j in vcard[i].keys():
|
2006-09-08 19:35:28 +02:00
|
|
|
self.set_value(i + '_' + j + '_label', 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)
|
2006-09-19 10:52:51 +02:00
|
|
|
elif i != 'jid': # Do not override jid_label
|
2006-09-08 19:35:28 +02:00
|
|
|
self.set_value(i + '_label', vcard[i])
|
2006-09-19 10:17:36 +02:00
|
|
|
self.vcard_arrived = True
|
|
|
|
self.test_remove_progressbar()
|
|
|
|
|
|
|
|
def test_remove_progressbar(self):
|
|
|
|
if self.update_progressbar_timeout_id is not None and \
|
|
|
|
self.vcard_arrived and self.os_info_arrived:
|
|
|
|
gobject.source_remove(self.update_progressbar_timeout_id)
|
|
|
|
self.progressbar.hide()
|
|
|
|
self.update_progressbar_timeout_id = None
|
2006-02-22 15:31:01 +01:00
|
|
|
|
|
|
|
def set_last_status_time(self):
|
|
|
|
self.fill_status_label()
|
|
|
|
|
2005-04-25 00:58:41 +02:00
|
|
|
def set_os_info(self, resource, client_info, os_info):
|
2006-11-10 09:24:36 +01:00
|
|
|
if self.xml.get_widget('information_notebook').get_n_pages() < 5:
|
2006-07-17 13:31:42 +02:00
|
|
|
return
|
2005-04-25 00:58:41 +02:00
|
|
|
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):
|
2005-07-20 14:48:11 +02:00
|
|
|
if not self.os_info[i]['resource'] or \
|
|
|
|
self.os_info[i]['resource'] == resource:
|
2005-04-25 00:58:41 +02:00
|
|
|
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 == '':
|
2005-08-13 00:32:35 +02:00
|
|
|
client = Q_('?Client:Unknown')
|
2005-05-11 13:09:53 +02:00
|
|
|
if os == '':
|
2005-08-13 00:32:35 +02:00
|
|
|
os = Q_('?OS:Unknown')
|
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)
|
2006-09-19 10:17:36 +02:00
|
|
|
self.os_info_arrived = True
|
|
|
|
self.test_remove_progressbar()
|
2005-04-19 23:53:19 +02:00
|
|
|
|
2006-02-22 15:31:01 +01:00
|
|
|
def fill_status_label(self):
|
2006-11-10 09:24:36 +01:00
|
|
|
if self.xml.get_widget('information_notebook').get_n_pages() < 5:
|
2006-07-17 13:31:42 +02:00
|
|
|
return
|
2007-07-04 15:23:16 +02:00
|
|
|
contact_list = gajim.contacts.get_contacts(self.account, self.contact.jid)
|
2006-10-15 23:47:35 +02:00
|
|
|
connected_contact_list = []
|
|
|
|
for c in contact_list:
|
|
|
|
if c.show not in ('offline', 'error'):
|
|
|
|
connected_contact_list.append(c)
|
|
|
|
if not connected_contact_list:
|
|
|
|
# no connected contact, get the offline one
|
|
|
|
connected_contact_list = contact_list
|
2006-02-22 15:31:01 +01:00
|
|
|
# stats holds show and status message
|
|
|
|
stats = ''
|
2006-10-15 23:47:35 +02:00
|
|
|
if connected_contact_list:
|
2007-08-20 10:16:26 +02:00
|
|
|
# Start with self.contact, as with resources
|
|
|
|
stats = helpers.get_uf_show(self.contact.show)
|
|
|
|
if self.contact.status:
|
|
|
|
stats += ': ' + self.contact.status
|
|
|
|
if self.contact.last_status_time:
|
|
|
|
stats += '\n' + _('since %s') % time.strftime('%c',
|
|
|
|
self.contact.last_status_time).decode(
|
|
|
|
locale.getpreferredencoding())
|
2006-10-15 23:47:35 +02:00
|
|
|
for c in connected_contact_list:
|
2007-08-20 10:16:26 +02:00
|
|
|
if c.resource != self.contact.resource:
|
2006-02-22 15:31:01 +01:00
|
|
|
stats += '\n'
|
2007-08-20 10:16:26 +02:00
|
|
|
stats += helpers.get_uf_show(c.show)
|
|
|
|
if c.status:
|
|
|
|
stats += ': ' + c.status
|
|
|
|
if c.last_status_time:
|
|
|
|
stats += '\n' + _('since %s') % time.strftime('%c',
|
|
|
|
c.last_status_time).decode(locale.getpreferredencoding())
|
2006-09-08 20:53:10 +02:00
|
|
|
else: # Maybe gc_vcard ?
|
2006-03-28 22:17:13 +02:00
|
|
|
stats = helpers.get_uf_show(self.contact.show)
|
|
|
|
if self.contact.status:
|
|
|
|
stats += ': ' + self.contact.status
|
2006-02-22 15:31:01 +01:00
|
|
|
status_label = self.xml.get_widget('status_label')
|
|
|
|
status_label.set_max_width_chars(15)
|
|
|
|
status_label.set_text(stats)
|
|
|
|
|
|
|
|
tip = gtk.Tooltips()
|
|
|
|
status_label_eventbox = self.xml.get_widget('status_label_eventbox')
|
|
|
|
tip.set_tip(status_label_eventbox, stats)
|
|
|
|
|
2005-04-19 23:53:19 +02:00
|
|
|
def fill_jabber_page(self):
|
2005-12-01 15:42:25 +01:00
|
|
|
tooltips = gtk.Tooltips()
|
2006-09-02 23:51:16 +02:00
|
|
|
self.xml.get_widget('nickname_label').set_markup(
|
|
|
|
'<b><span size="x-large">' +
|
|
|
|
self.contact.get_shown_name() +
|
|
|
|
'</span></b>')
|
2005-07-24 21:31:37 +02:00
|
|
|
self.xml.get_widget('jid_label').set_text(self.contact.jid)
|
2006-10-06 16:29:15 +02:00
|
|
|
|
|
|
|
subscription_label = self.xml.get_widget('subscription_label')
|
|
|
|
ask_label = self.xml.get_widget('ask_label')
|
|
|
|
if self.gc_contact:
|
|
|
|
self.xml.get_widget('subscription_title_label').set_text(_("Role:"))
|
|
|
|
uf_role = helpers.get_uf_role(self.gc_contact.role)
|
|
|
|
subscription_label.set_text(uf_role)
|
|
|
|
|
|
|
|
self.xml.get_widget('ask_title_label').set_text(_("Affiliation:"))
|
|
|
|
uf_affiliation = helpers.get_uf_affiliation(self.gc_contact.affiliation)
|
|
|
|
ask_label.set_text(uf_affiliation)
|
|
|
|
else:
|
|
|
|
uf_sub = helpers.get_uf_sub(self.contact.sub)
|
|
|
|
subscription_label.set_text(uf_sub)
|
|
|
|
eb = self.xml.get_widget('subscription_label_eventbox')
|
|
|
|
if self.contact.sub == 'from':
|
|
|
|
tt_text = _("This contact is interested in your presence information, but you are not interested in his/her presence")
|
|
|
|
elif self.contact.sub == 'to':
|
|
|
|
tt_text = _("You are interested in the contact's presence information, but he/she is not interested in yours")
|
|
|
|
elif self.contact.sub == 'both':
|
|
|
|
tt_text = _("You and the contact are interested in each other's presence information")
|
|
|
|
else: # None
|
|
|
|
tt_text = _("You are not interested in the contact's presence, and neither he/she is interested in yours")
|
|
|
|
tooltips.set_tip(eb, tt_text)
|
|
|
|
|
|
|
|
uf_ask = helpers.get_uf_ask(self.contact.ask)
|
|
|
|
ask_label.set_text(uf_ask)
|
|
|
|
eb = self.xml.get_widget('ask_label_eventbox')
|
|
|
|
if self.contact.ask == 'subscribe':
|
|
|
|
tooltips.set_tip(eb,
|
|
|
|
_("You are waiting contact's answer about your subscription request"))
|
|
|
|
|
2005-08-26 02:52:44 +02:00
|
|
|
resources = '%s (%s)' % (self.contact.resource, unicode(
|
2005-08-04 21:48:57 +02:00
|
|
|
self.contact.priority))
|
2005-07-24 21:31:37 +02:00
|
|
|
uf_resources = self.contact.resource + _(' resource with priority ')\
|
2005-08-26 02:52:44 +02:00
|
|
|
+ unicode(self.contact.priority)
|
2005-07-24 21:31:37 +02:00
|
|
|
if not self.contact.status:
|
|
|
|
self.contact.status = ''
|
2006-02-22 15:31:01 +01:00
|
|
|
|
|
|
|
# Request list time status
|
2007-07-22 20:25:43 +02:00
|
|
|
if self.gc_contact:
|
|
|
|
j, r = gajim.get_room_and_nick_from_fjid(self.real_jid)
|
|
|
|
gajim.connections[self.account].request_last_status_time(j, r,
|
|
|
|
self.contact.jid)
|
|
|
|
else:
|
|
|
|
gajim.connections[self.account].request_last_status_time(
|
|
|
|
self.contact.jid, self.contact.resource)
|
2006-02-22 15:31:01 +01:00
|
|
|
|
2006-10-10 18:01:15 +02:00
|
|
|
# do not wait for os_info if contact is not connected or has error
|
|
|
|
# additional check for observer is needed, as show is offline for him
|
|
|
|
if self.contact.show in ('offline', 'error')\
|
|
|
|
and not self.contact.is_observer():
|
2006-09-26 05:07:52 +02:00
|
|
|
self.os_info_arrived = True
|
|
|
|
else: # Request os info if contact is connected
|
2007-07-22 20:25:43 +02:00
|
|
|
if self.gc_contact:
|
|
|
|
j, r = gajim.get_room_and_nick_from_fjid(self.real_jid)
|
|
|
|
gobject.idle_add(gajim.connections[self.account].request_os_info,
|
|
|
|
j, r, self.contact.jid)
|
|
|
|
else:
|
|
|
|
gobject.idle_add(gajim.connections[self.account].request_os_info,
|
|
|
|
self.contact.jid, self.contact.resource)
|
2005-07-24 21:31:37 +02:00
|
|
|
self.os_info = {0: {'resource': self.contact.resource, 'client': '',
|
2005-05-05 16:02:39 +02:00
|
|
|
'os': ''}}
|
2005-04-25 00:58:41 +02:00
|
|
|
i = 1
|
2007-07-04 15:23:16 +02:00
|
|
|
contact_list = gajim.contacts.get_contacts(self.account, self.contact.jid)
|
Merged in trunk updates, including meta_contacts
Merged revisions 4951,4962-4969 via svnmerge from
svn://svn.gajim.org/gajim/trunk
........
r4951 | nk | 2005-12-30 16:50:36 -0700 (Fri, 30 Dec 2005) | 1 line
fixes in greek transl
........
r4962 | asterix | 2006-01-01 11:41:04 -0700 (Sun, 01 Jan 2006) | 2 lines
merge meta_contacts branch with trunk. Meta contacts are not in gajim yet, but framework is here. We now use gajim.contacts.many_functions() to handle contacts and groupchat_contacts.
........
r4963 | asterix | 2006-01-01 11:43:24 -0700 (Sun, 01 Jan 2006) | 2 lines
correct contacts file
........
r4964 | asterix | 2006-01-01 11:47:26 -0700 (Sun, 01 Jan 2006) | 2 lines
dict.remove() doesn't exists, it's del dict[]
........
r4965 | asterix | 2006-01-01 11:50:15 -0700 (Sun, 01 Jan 2006) | 2 lines
some missing commits from branch
........
r4966 | asterix | 2006-01-01 11:53:30 -0700 (Sun, 01 Jan 2006) | 2 lines
end of gc_contact.nick -> gc_contact.name
........
r4967 | asterix | 2006-01-01 12:05:59 -0700 (Sun, 01 Jan 2006) | 2 lines
new ACE option: send_sha_in_gc_presence that allow to send sha info in groupchat presences
........
r4968 | asterix | 2006-01-01 12:12:36 -0700 (Sun, 01 Jan 2006) | 2 lines
0.9.1-2 in debian that solve the group bug (commit [4924])
........
r4969 | asterix | 2006-01-01 12:31:13 -0700 (Sun, 01 Jan 2006) | 2 lines
typo
........
2006-01-01 21:06:26 +01:00
|
|
|
if contact_list:
|
|
|
|
for c in contact_list:
|
2005-07-24 21:31:37 +02:00
|
|
|
if c.resource != self.contact.resource:
|
2005-08-26 02:52:44 +02:00
|
|
|
resources += '\n%s (%s)' % (c.resource,
|
|
|
|
unicode(c.priority))
|
2006-02-22 15:31:01 +01:00
|
|
|
uf_resources += '\n' + c.resource + \
|
|
|
|
_(' resource with priority ') + unicode(c.priority)
|
|
|
|
if c.show not in ('offline', 'error'):
|
2006-08-21 21:54:09 +02:00
|
|
|
gobject.idle_add(
|
|
|
|
gajim.connections[self.account].request_os_info, c.jid,
|
2006-02-22 15:31:01 +01:00
|
|
|
c.resource)
|
|
|
|
gajim.connections[self.account].request_last_status_time(c.jid,
|
2005-07-24 21:31:37 +02:00
|
|
|
c.resource)
|
|
|
|
self.os_info[i] = {'resource': c.resource, 'client': '',
|
2005-06-26 21:40:57 +02:00
|
|
|
'os': ''}
|
|
|
|
i += 1
|
2005-07-24 21:31:37 +02:00
|
|
|
self.xml.get_widget('resource_prio_label').set_text(resources)
|
|
|
|
resource_prio_label_eventbox = self.xml.get_widget(
|
|
|
|
'resource_prio_label_eventbox')
|
2006-02-22 15:31:01 +01:00
|
|
|
tooltips.set_tip(resource_prio_label_eventbox, uf_resources)
|
|
|
|
|
|
|
|
self.fill_status_label()
|
|
|
|
|
2007-05-20 17:41:20 +02:00
|
|
|
if self.gc_contact:
|
2008-02-09 11:08:44 +01:00
|
|
|
# If we know the real jid, remove the resource from vcard request
|
|
|
|
if self.gc_contact.jid:
|
|
|
|
jid = self.gc_contact.jid
|
|
|
|
else:
|
|
|
|
jid = self.real_jid
|
|
|
|
gajim.connections[self.account].request_vcard(jid,
|
2007-05-20 17:41:20 +02:00
|
|
|
self.gc_contact.get_full_jid())
|
|
|
|
else:
|
|
|
|
gajim.connections[self.account].request_vcard(self.contact.jid)
|
2006-09-25 07:20:06 +02:00
|
|
|
|
|
|
|
def on_close_button_clicked(self, widget):
|
|
|
|
self.window.destroy()
|
2006-09-29 16:39:29 +02:00
|
|
|
|
|
|
|
|
|
|
|
class ZeroconfVcardWindow:
|
|
|
|
def __init__(self, contact, account, is_fake = False):
|
|
|
|
# the contact variable is the jid if vcard is true
|
|
|
|
self.xml = gtkgui_helpers.get_glade('zeroconf_information_window.glade')
|
|
|
|
self.window = self.xml.get_widget('zeroconf_information_window')
|
|
|
|
|
|
|
|
self.contact = contact
|
|
|
|
self.account = account
|
|
|
|
self.is_fake = is_fake
|
|
|
|
|
|
|
|
# self.avatar_mime_type = None
|
|
|
|
# self.avatar_encoded = None
|
|
|
|
|
|
|
|
self.fill_contact_page()
|
|
|
|
self.fill_personal_page()
|
|
|
|
|
|
|
|
self.xml.signal_autoconnect(self)
|
|
|
|
self.window.show_all()
|
|
|
|
|
|
|
|
def on_zeroconf_information_window_destroy(self, widget):
|
|
|
|
del gajim.interface.instances[self.account]['infos'][self.contact.jid]
|
|
|
|
|
|
|
|
def on_zeroconf_information_window_key_press_event(self, widget, event):
|
|
|
|
if event.keyval == gtk.keysyms.Escape:
|
|
|
|
self.window.destroy()
|
|
|
|
|
|
|
|
def on_PHOTO_eventbox_button_press_event(self, widget, event):
|
|
|
|
'''If right-clicked, show popup'''
|
|
|
|
if event.button == 3: # right click
|
|
|
|
menu = gtk.Menu()
|
|
|
|
menuitem = gtk.ImageMenuItem(gtk.STOCK_SAVE_AS)
|
|
|
|
menuitem.connect('activate',
|
|
|
|
gtkgui_helpers.on_avatar_save_as_menuitem_activate,
|
2006-11-08 15:31:40 +01:00
|
|
|
self.contact.jid, self.account, self.contact.get_shown_name() +
|
|
|
|
'.jpeg')
|
2006-09-29 16:39:29 +02:00
|
|
|
menu.append(menuitem)
|
|
|
|
menu.connect('selection-done', lambda w:w.destroy())
|
|
|
|
# show the menu
|
|
|
|
menu.show_all()
|
|
|
|
menu.popup(None, None, None, event.button, event.time)
|
|
|
|
|
|
|
|
def set_value(self, entry_name, value):
|
|
|
|
try:
|
|
|
|
if value and entry_name == 'URL_label':
|
|
|
|
if gtk.pygtk_version >= (2, 10, 0) and gtk.gtk_version >= (2, 10, 0):
|
|
|
|
widget = gtk.LinkButton(value, value)
|
|
|
|
else:
|
|
|
|
widget = gtk.Label(value)
|
2006-10-16 15:53:35 +02:00
|
|
|
widget.set_selectable(True)
|
2006-09-29 16:39:29 +02:00
|
|
|
table = self.xml.get_widget('personal_info_table')
|
|
|
|
table.attach(widget, 1, 4, 3, 4, yoptions = 0)
|
|
|
|
else:
|
|
|
|
self.xml.get_widget(entry_name).set_text(value)
|
|
|
|
except AttributeError:
|
|
|
|
pass
|
|
|
|
|
|
|
|
def fill_status_label(self):
|
|
|
|
if self.xml.get_widget('information_notebook').get_n_pages() < 2:
|
|
|
|
return
|
2007-07-04 15:23:16 +02:00
|
|
|
contact_list = gajim.contacts.get_contacts(self.account, self.contact.jid)
|
2006-09-29 16:39:29 +02:00
|
|
|
# stats holds show and status message
|
|
|
|
stats = ''
|
|
|
|
one = True # Are we adding the first line ?
|
|
|
|
if contact_list:
|
|
|
|
for c in contact_list:
|
|
|
|
if not one:
|
|
|
|
stats += '\n'
|
|
|
|
stats += helpers.get_uf_show(c.show)
|
|
|
|
if c.status:
|
|
|
|
stats += ': ' + c.status
|
|
|
|
if c.last_status_time:
|
|
|
|
stats += '\n' + _('since %s') % time.strftime('%c',
|
|
|
|
c.last_status_time).decode(locale.getpreferredencoding())
|
|
|
|
one = False
|
|
|
|
else: # Maybe gc_vcard ?
|
|
|
|
stats = helpers.get_uf_show(self.contact.show)
|
|
|
|
if self.contact.status:
|
|
|
|
stats += ': ' + self.contact.status
|
|
|
|
status_label = self.xml.get_widget('status_label')
|
|
|
|
status_label.set_max_width_chars(15)
|
|
|
|
status_label.set_text(stats)
|
|
|
|
|
|
|
|
tip = gtk.Tooltips()
|
|
|
|
status_label_eventbox = self.xml.get_widget('status_label_eventbox')
|
|
|
|
tip.set_tip(status_label_eventbox, stats)
|
|
|
|
|
|
|
|
def fill_contact_page(self):
|
|
|
|
tooltips = gtk.Tooltips()
|
|
|
|
self.xml.get_widget('nickname_label').set_markup(
|
|
|
|
'<b><span size="x-large">' +
|
|
|
|
self.contact.get_shown_name() +
|
|
|
|
'</span></b>')
|
|
|
|
self.xml.get_widget('local_jid_label').set_text(self.contact.jid)
|
|
|
|
|
|
|
|
resources = '%s (%s)' % (self.contact.resource, unicode(
|
|
|
|
self.contact.priority))
|
|
|
|
uf_resources = self.contact.resource + _(' resource with priority ')\
|
|
|
|
+ unicode(self.contact.priority)
|
|
|
|
if not self.contact.status:
|
|
|
|
self.contact.status = ''
|
|
|
|
|
|
|
|
# Request list time status
|
|
|
|
# gajim.connections[self.account].request_last_status_time(self.contact.jid,
|
|
|
|
# self.contact.resource)
|
|
|
|
|
|
|
|
self.xml.get_widget('resource_prio_label').set_text(resources)
|
|
|
|
resource_prio_label_eventbox = self.xml.get_widget(
|
|
|
|
'resource_prio_label_eventbox')
|
|
|
|
tooltips.set_tip(resource_prio_label_eventbox, uf_resources)
|
|
|
|
|
|
|
|
self.fill_status_label()
|
|
|
|
|
|
|
|
# gajim.connections[self.account].request_vcard(self.contact.jid, self.is_fake)
|
|
|
|
|
|
|
|
def fill_personal_page(self):
|
|
|
|
contact = gajim.connections[gajim.ZEROCONF_ACC_NAME].roster.getItem(self.contact.jid)
|
2006-10-15 04:09:23 +02:00
|
|
|
for key in ('1st', 'last', 'jid', 'email'):
|
|
|
|
if not contact['txt_dict'].has_key(key):
|
|
|
|
contact['txt_dict'][key] = ''
|
2006-09-29 16:39:29 +02:00
|
|
|
self.xml.get_widget('first_name_label').set_text(contact['txt_dict']['1st'])
|
|
|
|
self.xml.get_widget('last_name_label').set_text(contact['txt_dict']['last'])
|
|
|
|
self.xml.get_widget('jabber_id_label').set_text(contact['txt_dict']['jid'])
|
|
|
|
self.xml.get_widget('email_label').set_text(contact['txt_dict']['email'])
|
2006-09-26 17:57:47 +02:00
|
|
|
|
|
|
|
def on_close_button_clicked(self, widget):
|
|
|
|
self.window.destroy()
|