2005-06-11 00:45:50 +02:00
|
|
|
## vcard.py (has VcardWindow class)
|
2005-04-19 23:53:19 +02:00
|
|
|
##
|
2005-12-09 18:15:30 +01:00
|
|
|
## Contributors for this file:
|
2005-04-19 23:53:19 +02:00
|
|
|
## - Yann Le Boulanger <asterix@lagaule.org>
|
|
|
|
## - Nikos Kouremenos <kourem@gmail.com>
|
|
|
|
##
|
2005-12-10 00:30:28 +01:00
|
|
|
## Copyright (C) 2003-2004 Yann Le Boulanger <asterix@lagaule.org>
|
|
|
|
## Vincent Hanquez <tab@snarc.org>
|
|
|
|
## Copyright (C) 2005 Yann Le Boulanger <asterix@lagaule.org>
|
|
|
|
## Vincent Hanquez <tab@snarc.org>
|
|
|
|
## Nikos Kouremenos <nkour@jabber.org>
|
|
|
|
## Dimitur Kirov <dkirov@gmail.com>
|
|
|
|
## Travis Shirk <travis@pobox.com>
|
|
|
|
## Norman Rasmussen <norman@rasmussen.co.za>
|
2005-04-19 23:53:19 +02:00
|
|
|
##
|
|
|
|
## 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-09-05 15:35:45 +02:00
|
|
|
import gobject
|
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-08-30 23:03:23 +02:00
|
|
|
import sys
|
2006-02-22 15:31:01 +01:00
|
|
|
import time
|
2005-10-03 20:27:39 +02:00
|
|
|
import gtkgui_helpers
|
2005-11-13 21:25:04 +01:00
|
|
|
import dialogs
|
2006-03-05 23:09:39 +01:00
|
|
|
import locale
|
2005-08-03 12:59:44 +02:00
|
|
|
|
|
|
|
from common import helpers
|
2005-04-19 23:53:19 +02:00
|
|
|
from common import gajim
|
|
|
|
from common import i18n
|
|
|
|
_ = i18n._
|
2005-08-13 00:32:35 +02:00
|
|
|
Q_ = i18n.Q_
|
2005-04-19 23:53:19 +02:00
|
|
|
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-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
|
2005-10-31 11:23:33 +01:00
|
|
|
if photo.has_key('BINVAL') and photo.has_key('TYPE'):
|
|
|
|
img_encoded = photo['BINVAL']
|
|
|
|
avatar_encoded = img_encoded
|
|
|
|
avatar_mime_type = photo['TYPE']
|
|
|
|
try:
|
|
|
|
img_decoded = base64.decodestring(img_encoded)
|
|
|
|
except:
|
|
|
|
pass
|
|
|
|
elif photo.has_key('EXTVAL'):
|
|
|
|
url = photo['EXTVAL']
|
|
|
|
try:
|
|
|
|
fd = urllib.urlopen(url)
|
|
|
|
img_decoded = fd.read()
|
|
|
|
except:
|
|
|
|
pass
|
|
|
|
if img_decoded:
|
2005-11-16 12:05:45 +01:00
|
|
|
pixbuf = gtkgui_helpers.get_pixbuf_from_data(img_decoded)
|
|
|
|
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
|
|
|
|
2005-10-20 13:17:17 +02:00
|
|
|
def __init__(self, contact, account, vcard = False):
|
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
|
2005-07-03 01:03:57 +02:00
|
|
|
self.xml = gtk.glade.XML(GTKGUI_GLADE, 'vcard_information_window', APP)
|
|
|
|
self.window = self.xml.get_widget('vcard_information_window')
|
2005-07-06 15:05:07 +02:00
|
|
|
|
|
|
|
self.publish_button = self.xml.get_widget('publish_button')
|
|
|
|
self.retrieve_button = self.xml.get_widget('retrieve_button')
|
2006-02-23 15:36:41 +01:00
|
|
|
self.nickname_entry = self.xml.get_widget('nickname_entry')
|
|
|
|
|
2005-07-06 15:05:07 +02:00
|
|
|
self.publish_button.set_no_show_all(True)
|
|
|
|
self.retrieve_button.set_no_show_all(True)
|
2006-02-23 15:36:41 +01:00
|
|
|
self.xml.get_widget('photo_vbuttonbox').set_no_show_all(True)
|
2005-07-06 15:05:07 +02:00
|
|
|
|
2006-02-20 22:30:45 +01:00
|
|
|
self.contact = contact # don't use it if vcard is true
|
2005-07-03 01:03:57 +02:00
|
|
|
self.account = account
|
|
|
|
self.vcard = vcard
|
|
|
|
self.avatar_mime_type = None
|
|
|
|
self.avatar_encoded = None
|
|
|
|
|
2006-02-23 15:36:41 +01:00
|
|
|
if vcard: # we view/edit our own vcard
|
2005-07-24 21:36:26 +02:00
|
|
|
self.jid = contact
|
2006-02-23 15:36:41 +01:00
|
|
|
# remove Jabber tab & show publish/retrieve/close/set_avatar buttons
|
|
|
|
# and make entries and textview editable
|
2005-07-06 15:05:07 +02:00
|
|
|
self.change_to_vcard()
|
2006-02-23 15:36:41 +01:00
|
|
|
else: # we see someone else's vcard
|
2005-07-06 15:05:07 +02:00
|
|
|
self.publish_button.hide()
|
|
|
|
self.retrieve_button.hide()
|
2006-02-23 15:36:41 +01:00
|
|
|
self.jid = contact.jid
|
2005-07-03 01:03:57 +02:00
|
|
|
self.fill_jabber_page()
|
2006-02-23 15:36:41 +01:00
|
|
|
|
|
|
|
# if we are editing our own vcard publish button should publish
|
|
|
|
# vcard data we have typed including nickname, it's why we connect only
|
|
|
|
# here (when we see someone else's vcard)
|
2006-02-23 16:54:16 +01:00
|
|
|
self.nickname_entry.connect('focus-out-event',
|
|
|
|
self.on_nickname_entry_focus_out_event)
|
2005-07-03 01:03:57 +02:00
|
|
|
|
|
|
|
self.xml.signal_autoconnect(self)
|
|
|
|
self.window.show_all()
|
|
|
|
|
2005-12-07 22:06:43 +01:00
|
|
|
def on_vcard_information_window_destroy(self, widget):
|
2005-11-13 16:08:47 +01:00
|
|
|
del gajim.interface.instances[self.account]['infos'][self.jid]
|
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()
|
|
|
|
|
2005-12-07 15:32:42 +01:00
|
|
|
def on_log_history_checkbutton_toggled(self, widget):
|
|
|
|
#log conversation history?
|
|
|
|
oldlog = True
|
|
|
|
no_log_for = gajim.config.get_per('accounts', self.account,
|
|
|
|
'no_log_for').split()
|
|
|
|
if self.contact.jid in no_log_for:
|
|
|
|
oldlog = False
|
|
|
|
log = widget.get_active()
|
|
|
|
if not log and not self.contact.jid in no_log_for:
|
|
|
|
no_log_for.append(self.contact.jid)
|
|
|
|
if log and self.contact.jid in no_log_for:
|
|
|
|
no_log_for.remove(self.contact.jid)
|
|
|
|
if oldlog != log:
|
|
|
|
gajim.config.set_per('accounts', self.account, 'no_log_for',
|
|
|
|
' '.join(no_log_for))
|
|
|
|
|
2006-02-23 16:54:16 +01:00
|
|
|
def on_nickname_entry_focus_out_event(self, widget, event):
|
2006-02-23 15:36:41 +01:00
|
|
|
'''Save contact information and update
|
|
|
|
the roster item on the Jabber server'''
|
|
|
|
new_name = self.nickname_entry.get_text().decode('utf-8')
|
|
|
|
# update contact.name with new nickname if that is not ''
|
2005-07-24 21:31:37 +02:00
|
|
|
if new_name != self.contact.name and new_name != '':
|
|
|
|
self.contact.name = new_name
|
2006-02-23 15:36:41 +01:00
|
|
|
# update roster model
|
|
|
|
model = gajim.interface.roster.tree.get_model()
|
|
|
|
for iter_ in gajim.interface.roster.get_contact_iter(self.contact.jid,
|
2005-10-20 13:17:17 +02:00
|
|
|
self.account):
|
2006-02-23 15:36:41 +01:00
|
|
|
model[iter_][1] = new_name
|
2005-07-24 21:31:37 +02:00
|
|
|
gajim.connections[self.account].update_contact(self.contact.jid,
|
|
|
|
self.contact.name, self.contact.groups)
|
2006-02-23 15:36:41 +01:00
|
|
|
# update opened chat window
|
2006-02-21 21:51:01 +01:00
|
|
|
ctrl = gajim.interface.msg_win_mgr.get_control(self.contact.jid,
|
|
|
|
self.account)
|
|
|
|
if ctrl:
|
|
|
|
ctrl.update_ui()
|
|
|
|
win = gajim.interface.msg_win_mgr.get_window(self.contact.jid,
|
|
|
|
self.account)
|
|
|
|
win.redraw_tab(ctrl)
|
|
|
|
win.show_title()
|
2006-02-23 15:36:41 +01:00
|
|
|
|
|
|
|
def on_close_button_clicked(self, widget):
|
2005-04-19 23:53:19 +02:00
|
|
|
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
|
|
|
|
2005-06-10 21:03:32 +02:00
|
|
|
def update_preview(self, widget):
|
|
|
|
path_to_file = widget.get_preview_filename()
|
2005-09-05 15:59:41 +02:00
|
|
|
if path_to_file is None or os.path.isdir(path_to_file):
|
|
|
|
# nothing to preview or directory
|
|
|
|
# make sure you clean image do show nothing
|
|
|
|
widget.get_preview_widget().set_from_file(None)
|
2005-09-05 15:35:45 +02:00
|
|
|
return
|
|
|
|
try:
|
|
|
|
pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(path_to_file, 100, 100)
|
|
|
|
except gobject.GError:
|
|
|
|
return
|
2005-09-05 14:26:05 +02:00
|
|
|
widget.get_preview_widget().set_from_pixbuf(pixbuf)
|
2005-06-10 21:03:32 +02:00
|
|
|
|
2005-06-07 00:58:06 +02:00
|
|
|
def on_set_avatar_button_clicked(self, widget):
|
2005-07-19 22:12:02 +02:00
|
|
|
f = None
|
2005-08-07 01:22:57 +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))
|
2006-03-15 00:07:45 +01:00
|
|
|
try:
|
|
|
|
if os.name == 'nt':
|
|
|
|
path = os.environ['USERPROFILE']
|
|
|
|
else:
|
|
|
|
path = os.environ['HOME']
|
|
|
|
except:
|
|
|
|
path = ''
|
|
|
|
if path:
|
|
|
|
dialog.set_current_folder(path)
|
2005-06-07 00:58:06 +02:00
|
|
|
dialog.set_default_response(gtk.RESPONSE_OK)
|
2005-07-19 22:12:02 +02:00
|
|
|
filtr = gtk.FileFilter()
|
|
|
|
filtr.set_name(_('All files'))
|
|
|
|
filtr.add_pattern('*')
|
|
|
|
dialog.add_filter(filtr)
|
2005-06-07 00:58:06 +02:00
|
|
|
|
2005-07-19 22:12:02 +02:00
|
|
|
filtr = gtk.FileFilter()
|
|
|
|
filtr.set_name(_('Images'))
|
|
|
|
filtr.add_mime_type('image/png')
|
|
|
|
filtr.add_mime_type('image/jpeg')
|
|
|
|
filtr.add_mime_type('image/gif')
|
2005-11-14 16:54:13 +01:00
|
|
|
filtr.add_mime_type('image/tiff')
|
|
|
|
filtr.add_mime_type('image/x-xpixmap') # xpm
|
2005-07-19 22:12:02 +02:00
|
|
|
dialog.add_filter(filtr)
|
|
|
|
dialog.set_filter(filtr)
|
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
|
|
|
|
2005-11-14 16:54:13 +01:00
|
|
|
done = False
|
|
|
|
while not done:
|
2005-06-07 00:58:06 +02:00
|
|
|
response = dialog.run()
|
2006-02-09 17:47:31 +01:00
|
|
|
|
2005-06-07 00:58:06 +02:00
|
|
|
if response == gtk.RESPONSE_OK:
|
2006-02-09 17:47:31 +01:00
|
|
|
path_to_file = dialog.get_filename()
|
|
|
|
path_to_file = gtkgui_helpers.decode_filechooser_file_paths(
|
|
|
|
(path_to_file,))[0]
|
|
|
|
filesize = os.path.getsize(path_to_file) # in bytes
|
2006-01-20 14:58:52 +01:00
|
|
|
if filesize > 16384: # 16 kb
|
2006-02-09 17:47:31 +01:00
|
|
|
try:
|
|
|
|
pixbuf = gtk.gdk.pixbuf_new_from_file(path_to_file)
|
|
|
|
# get the image at 'notification size'
|
|
|
|
# and use that hoping size is okay
|
|
|
|
scaled_pixbuf = gtkgui_helpers.get_scaled_pixbuf(pixbuf,
|
|
|
|
'notification')
|
|
|
|
except gobject.GError, msg: # unknown format
|
|
|
|
dialogs.ErrorDialog(_('Could not load image'),
|
|
|
|
msg).get_response()
|
|
|
|
continue
|
|
|
|
else:
|
|
|
|
path_to_file = os.path.join(gajim.TMP, 'avatar_scaled.png')
|
|
|
|
scaled_pixbuf.save(path_to_file, 'png')
|
|
|
|
done = True
|
|
|
|
else:
|
2005-11-14 16:54:13 +01:00
|
|
|
done = True
|
|
|
|
else: # Cancel or WM X button
|
|
|
|
done = True
|
2006-02-09 17:47:31 +01:00
|
|
|
|
2005-06-07 00:58:06 +02:00
|
|
|
dialog.destroy()
|
2005-11-14 16:54:13 +01:00
|
|
|
if response == gtk.RESPONSE_OK:
|
2006-02-09 17:47:31 +01:00
|
|
|
fd = open(path_to_file, 'rb')
|
2005-06-07 00:58:06 +02:00
|
|
|
data = fd.read()
|
2005-10-03 20:19:31 +02:00
|
|
|
pixbuf = gtkgui_helpers.get_pixbuf_from_data(data)
|
2006-03-08 17:01:01 +01:00
|
|
|
# rescale it
|
|
|
|
pixbuf = gtkgui_helpers.get_scaled_pixbuf(pixbuf, 'vcard')
|
2005-06-07 00:58:06 +02:00
|
|
|
image = self.xml.get_widget('PHOTO_image')
|
|
|
|
image.set_from_pixbuf(pixbuf)
|
|
|
|
self.avatar_encoded = base64.encodestring(data)
|
2005-09-15 18:57:42 +02:00
|
|
|
# returns None if unknown type
|
2006-02-09 17:47:31 +01:00
|
|
|
self.avatar_mime_type = mimetypes.guess_type(path_to_file)[0]
|
2005-06-07 00:58:06 +02:00
|
|
|
|
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)
|
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():
|
2005-06-07 10:50:47 +02:00
|
|
|
if i == 'PHOTO':
|
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-03-10 22:58:23 +01:00
|
|
|
if not pixbuf:
|
|
|
|
continue
|
2005-10-31 11:23:33 +01:00
|
|
|
image = self.xml.get_widget('PHOTO_image')
|
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
|
|
|
|
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])
|
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():
|
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])
|
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):
|
|
|
|
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)
|
2005-04-19 23:53:19 +02:00
|
|
|
|
2006-02-22 15:31:01 +01:00
|
|
|
def fill_status_label(self):
|
|
|
|
contact_list = gajim.contacts.get_contact(self.account, self.contact.jid)
|
|
|
|
# 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:
|
2006-02-23 22:44:05 +01:00
|
|
|
stats += '\n' + _('since %s') % time.strftime('%c',
|
2006-03-05 23:09:39 +01:00
|
|
|
c.last_status_time).decode(locale.getpreferredencoding())
|
2006-02-22 15:31:01 +01:00
|
|
|
one = False
|
|
|
|
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-01-10 19:30:57 +01:00
|
|
|
self.xml.get_widget('nickname_label').set_text(
|
|
|
|
self.contact.get_shown_name())
|
2005-07-24 21:31:37 +02:00
|
|
|
self.xml.get_widget('jid_label').set_text(self.contact.jid)
|
2005-08-05 00:08:33 +02:00
|
|
|
uf_sub = helpers.get_uf_sub(self.contact.sub)
|
|
|
|
self.xml.get_widget('subscription_label').set_text(uf_sub)
|
2005-12-01 15:42:25 +01:00
|
|
|
eb = self.xml.get_widget('subscription_label_eventbox')
|
|
|
|
if self.contact.sub == 'from':
|
2005-12-01 16:21:20 +01:00
|
|
|
tt_text = _("This contact is interested in your presence information, but you are not interested in his/her presence")
|
2005-12-01 15:42:25 +01:00
|
|
|
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)
|
|
|
|
|
2005-04-22 03:35:36 +02:00
|
|
|
label = self.xml.get_widget('ask_label')
|
2005-08-05 00:08:33 +02:00
|
|
|
uf_ask = helpers.get_uf_ask(self.contact.ask)
|
|
|
|
label.set_text(uf_ask)
|
2005-12-01 15:42:25 +01:00
|
|
|
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"))
|
2006-02-23 15:36:41 +01:00
|
|
|
self.nickname_entry.set_text(self.contact.name)
|
2005-12-07 15:32:42 +01:00
|
|
|
log = True
|
2005-07-24 21:31:37 +02:00
|
|
|
if self.contact.jid in gajim.config.get_per('accounts', self.account,
|
2005-04-19 23:53:19 +02:00
|
|
|
'no_log_for').split(' '):
|
2005-12-07 15:32:42 +01:00
|
|
|
log = False
|
2005-12-07 22:06:43 +01:00
|
|
|
checkbutton = self.xml.get_widget('log_history_checkbutton')
|
|
|
|
checkbutton.set_active(log)
|
|
|
|
checkbutton.connect('toggled', self.on_log_history_checkbutton_toggled)
|
|
|
|
|
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
|
|
|
|
gajim.connections[self.account].request_last_status_time(self.contact.jid,
|
2005-07-24 21:31:37 +02:00
|
|
|
self.contact.resource)
|
2006-02-22 15:31:01 +01:00
|
|
|
|
|
|
|
# Request os info in contact is connected
|
|
|
|
if self.contact.show not in ('offline', 'error'):
|
|
|
|
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
|
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
|
|
|
contact_list = gajim.contacts.get_contact(self.account, self.contact.jid)
|
|
|
|
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'):
|
|
|
|
gajim.connections[self.account].request_os_info(c.jid,
|
|
|
|
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()
|
|
|
|
|
2006-03-13 14:25:51 +01:00
|
|
|
is_fake = False
|
|
|
|
if gajim.contacts.is_pm_from_jid(self.account, self.contact.jid):
|
|
|
|
is_fake = True
|
|
|
|
gajim.connections[self.account].request_vcard(self.contact.jid, is_fake)
|
2005-04-19 23:53:19 +02:00
|
|
|
|
|
|
|
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',
|
2005-06-26 23:35:52 +02:00
|
|
|
'ORG_ORGUNIT', 'TITLE', 'ROLE', 'TEL_WORK_NUMBER', 'EMAIL_WORK_USERID',
|
|
|
|
'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-08-26 02:52:44 +02:00
|
|
|
txt = self.xml.get_widget(e + '_entry').get_text().decode('utf-8')
|
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-07-19 22:12:02 +02:00
|
|
|
buff = self.xml.get_widget('DESC_textview').get_buffer()
|
|
|
|
start_iter = buff.get_start_iter()
|
|
|
|
end_iter = buff.get_end_iter()
|
|
|
|
txt = buff.get_text(start_iter, end_iter, 0)
|
2005-04-19 23:53:19 +02:00
|
|
|
if txt != '':
|
2005-08-26 02:52:44 +02:00
|
|
|
vcard['DESC'] = txt.decode('utf-8')
|
2005-06-07 00:58:06 +02:00
|
|
|
|
|
|
|
# Avatar
|
|
|
|
if self.avatar_encoded:
|
2005-09-15 18:57:42 +02:00
|
|
|
vcard['PHOTO'] = {'BINVAL': self.avatar_encoded}
|
|
|
|
if self.avatar_mime_type:
|
|
|
|
vcard['PHOTO']['TYPE'] = self.avatar_mime_type
|
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-12-01 19:07:43 +01:00
|
|
|
dialogs.ErrorDialog(_('You are not connected to the server'),
|
|
|
|
_('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')
|
2005-07-18 23:08:31 +02:00
|
|
|
gajim.nicks[self.account] = nick
|
2005-04-19 23:53:19 +02:00
|
|
|
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)
|
Merged revisions 4987-4989,4991-4996,4999,5003 via svnmerge from
svn://svn.gajim.org/gajim/trunk
........
r4987 | nk | 2006-01-03 04:00:51 -0700 (Tue, 03 Jan 2006) | 1 line
commit 48x48 transport online/offline imgs by Grenshad (I pngcrushed them)
........
r4988 | nk | 2006-01-03 04:32:01 -0700 (Tue, 03 Jan 2006) | 1 line
icon in notification window not always jabber now. MSN if he uses msn etc. thanks stian barmen for helping me test
........
r4989 | nk | 2006-01-03 04:40:44 -0700 (Tue, 03 Jan 2006) | 1 line
all strings I got report about them, are not translatable; pot/po update
........
r4991 | asterix | 2006-01-03 08:08:21 -0700 (Tue, 03 Jan 2006) | 2 lines
don't remove the jid entry in _contacts[account] when we remove a contact
........
r4992 | asterix | 2006-01-03 08:18:30 -0700 (Tue, 03 Jan 2006) | 2 lines
fix logic
........
r4993 | asterix | 2006-01-03 09:04:14 -0700 (Tue, 03 Jan 2006) | 2 lines
a GC_Contact can have a resource if we knoe his real JID
........
r4994 | asterix | 2006-01-03 09:32:58 -0700 (Tue, 03 Jan 2006) | 2 lines
missing argument in create_gc_contact
........
r4995 | asterix | 2006-01-03 10:36:41 -0700 (Tue, 03 Jan 2006) | 2 lines
we save gc_contact vcard instance in instances[self.account]['infos'][Fake_jid]
........
r4996 | asterix | 2006-01-03 11:17:43 -0700 (Tue, 03 Jan 2006) | 2 lines
in DataForm, a field of type 'list-single' can have no <value> element. Create a default one in such a case to prevent TB
........
r4999 | asterix | 2006-01-04 05:52:26 -0700 (Wed, 04 Jan 2006) | 2 lines
prevent TB when we move a contact that was in no group
........
r5003 | asterix | 2006-01-04 09:03:42 -0700 (Wed, 04 Jan 2006) | 2 lines
handle correctly unlabeled option values in DataForms
........
2006-01-05 04:17:36 +01:00
|
|
|
self.xml.get_widget('nickname_label').set_text(_('Personal details'))
|
2005-07-06 15:05:07 +02:00
|
|
|
|
|
|
|
self.publish_button.show()
|
|
|
|
self.retrieve_button.show()
|
|
|
|
|
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',
|
2005-09-01 18:16:46 +02:00
|
|
|
'ORG_ORGUNIT', 'TITLE', 'ROLE', 'TEL_WORK_NUMBER', 'EMAIL_WORK_USERID',
|
|
|
|
'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)
|