2008-08-15 19:31:51 +02:00
|
|
|
# -*- coding:utf-8 -*-
|
2008-08-15 05:20:23 +02:00
|
|
|
## src/profile_window.py
|
2006-09-08 19:48:37 +02:00
|
|
|
##
|
2014-01-02 09:33:54 +01:00
|
|
|
## Copyright (C) 2003-2014 Yann Leboulanger <asterix AT lagaule.org>
|
2008-08-15 05:20:23 +02:00
|
|
|
## Copyright (C) 2005-2006 Nikos Kouremenos <kourem AT gmail.com>
|
|
|
|
## Copyright (C) 2006-2008 Jean-Marie Traissard <jim AT lapin.org>
|
2006-09-08 19:48:37 +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
|
2006-09-08 19:48:37 +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.
|
2006-09-08 19:48:37 +02:00
|
|
|
##
|
2007-10-22 13:13:13 +02:00
|
|
|
## Gajim is distributed in the hope that it will be useful,
|
2006-09-08 19:48:37 +02:00
|
|
|
## but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2008-08-15 05:20:23 +02:00
|
|
|
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2006-09-08 19:48:37 +02:00
|
|
|
## 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
|
2008-08-15 05:20:23 +02:00
|
|
|
## along with Gajim. If not, see <http://www.gnu.org/licenses/>.
|
2007-10-22 13:13:13 +02:00
|
|
|
##
|
2006-09-08 19:48:37 +02:00
|
|
|
|
2006-10-02 18:24:10 +02:00
|
|
|
# THIS FILE IS FOR **OUR** PROFILE (when we edit our INFO)
|
|
|
|
|
2012-12-23 16:23:43 +01:00
|
|
|
from gi.repository import Gtk
|
2012-12-31 18:14:21 +01:00
|
|
|
from gi.repository import Gdk
|
2013-07-28 20:50:30 +02:00
|
|
|
from gi.repository import GLib
|
2017-09-16 11:49:31 +02:00
|
|
|
from gi.repository import GdkPixbuf
|
2006-09-08 19:48:37 +02:00
|
|
|
import base64
|
2010-09-01 20:18:24 +02:00
|
|
|
import time
|
2017-09-26 07:14:01 +02:00
|
|
|
import logging
|
2018-04-08 21:55:29 +02:00
|
|
|
import hashlib
|
2006-09-08 19:48:37 +02:00
|
|
|
|
2017-06-13 23:58:06 +02:00
|
|
|
from gajim import gtkgui_helpers
|
|
|
|
from gajim import dialogs
|
2017-09-16 11:49:31 +02:00
|
|
|
from gajim.common.const import AvatarSize
|
2006-09-08 19:48:37 +02:00
|
|
|
|
2017-08-13 13:18:56 +02:00
|
|
|
from gajim.common import app
|
2017-06-13 23:58:06 +02:00
|
|
|
from gajim.common import ged
|
2008-10-20 23:38:06 +02:00
|
|
|
|
2017-09-26 07:14:01 +02:00
|
|
|
log = logging.getLogger('gajim.profile')
|
2006-09-08 19:48:37 +02:00
|
|
|
|
|
|
|
class ProfileWindow:
|
2010-02-08 15:08:40 +01:00
|
|
|
"""
|
|
|
|
Class for our information window
|
|
|
|
"""
|
|
|
|
|
2012-07-05 21:53:51 +02:00
|
|
|
def __init__(self, account, transient_for=None):
|
2010-02-08 15:08:40 +01:00
|
|
|
self.xml = gtkgui_helpers.get_gtk_builder('profile_window.ui')
|
|
|
|
self.window = self.xml.get_object('profile_window')
|
2012-12-31 18:14:21 +01:00
|
|
|
self.window.set_transient_for(transient_for)
|
2010-02-08 15:08:40 +01:00
|
|
|
self.progressbar = self.xml.get_object('progressbar')
|
|
|
|
self.statusbar = self.xml.get_object('statusbar')
|
|
|
|
self.context_id = self.statusbar.get_context_id('profile')
|
|
|
|
|
|
|
|
self.account = account
|
2017-08-13 13:18:56 +02:00
|
|
|
self.jid = app.get_jid_from_account(account)
|
2010-02-08 15:08:40 +01:00
|
|
|
|
|
|
|
self.dialog = None
|
|
|
|
self.avatar_mime_type = None
|
|
|
|
self.avatar_encoded = None
|
2017-09-16 11:49:31 +02:00
|
|
|
self.avatar_sha = None
|
2010-02-08 15:08:40 +01:00
|
|
|
self.message_id = self.statusbar.push(self.context_id,
|
2017-02-04 23:29:45 +01:00
|
|
|
_('Retrieving profile…'))
|
2013-07-28 20:50:30 +02:00
|
|
|
self.update_progressbar_timeout_id = GLib.timeout_add(100,
|
2010-11-08 22:34:04 +01:00
|
|
|
self.update_progressbar)
|
2010-02-08 15:08:40 +01:00
|
|
|
self.remove_statusbar_timeout_id = None
|
|
|
|
|
|
|
|
# Create Image for avatar button
|
2012-12-23 16:23:43 +01:00
|
|
|
image = Gtk.Image()
|
2010-02-08 15:08:40 +01:00
|
|
|
self.xml.get_object('PHOTO_button').set_image(image)
|
|
|
|
self.xml.connect_signals(self)
|
2017-08-13 13:18:56 +02:00
|
|
|
app.ged.register_event_handler('vcard-published', ged.GUI1,
|
2010-11-08 22:34:04 +01:00
|
|
|
self._nec_vcard_published)
|
2017-08-13 13:18:56 +02:00
|
|
|
app.ged.register_event_handler('vcard-not-published', ged.GUI1,
|
2010-11-08 22:34:04 +01:00
|
|
|
self._nec_vcard_not_published)
|
2010-02-08 15:08:40 +01:00
|
|
|
self.window.show_all()
|
2012-06-28 10:49:54 +02:00
|
|
|
self.xml.get_object('ok_button').grab_focus()
|
2017-09-16 11:49:31 +02:00
|
|
|
app.connections[account].request_vcard(
|
|
|
|
self._nec_vcard_received, self.jid)
|
2012-06-28 10:49:54 +02:00
|
|
|
|
|
|
|
def on_information_notebook_switch_page(self, widget, page, page_num):
|
2013-07-28 20:50:30 +02:00
|
|
|
GLib.idle_add(self.xml.get_object('ok_button').grab_focus)
|
2010-02-08 15:08:40 +01:00
|
|
|
|
|
|
|
def update_progressbar(self):
|
|
|
|
self.progressbar.pulse()
|
|
|
|
return True # loop forever
|
|
|
|
|
|
|
|
def remove_statusbar(self, message_id):
|
2012-12-31 18:14:21 +01:00
|
|
|
self.statusbar.remove(self.context_id, message_id)
|
2010-02-08 15:08:40 +01:00
|
|
|
self.remove_statusbar_timeout_id = None
|
|
|
|
|
|
|
|
def on_profile_window_destroy(self, widget):
|
|
|
|
if self.update_progressbar_timeout_id is not None:
|
2013-07-28 20:50:30 +02:00
|
|
|
GLib.source_remove(self.update_progressbar_timeout_id)
|
2010-02-08 15:08:40 +01:00
|
|
|
if self.remove_statusbar_timeout_id is not None:
|
2013-07-28 20:50:30 +02:00
|
|
|
GLib.source_remove(self.remove_statusbar_timeout_id)
|
2017-08-13 13:18:56 +02:00
|
|
|
app.ged.remove_event_handler('vcard-published', ged.GUI1,
|
2010-11-08 22:34:04 +01:00
|
|
|
self._nec_vcard_published)
|
2017-08-13 13:18:56 +02:00
|
|
|
app.ged.remove_event_handler('vcard-not-published', ged.GUI1,
|
2010-11-08 22:34:04 +01:00
|
|
|
self._nec_vcard_not_published)
|
2017-08-13 13:18:56 +02:00
|
|
|
del app.interface.instances[self.account]['profile']
|
2010-02-08 15:08:40 +01:00
|
|
|
if self.dialog: # Image chooser dialog
|
|
|
|
self.dialog.destroy()
|
|
|
|
|
|
|
|
def on_profile_window_key_press_event(self, widget, event):
|
2012-12-23 16:23:43 +01:00
|
|
|
if event.keyval == Gdk.KEY_Escape:
|
2010-02-08 15:08:40 +01:00
|
|
|
self.window.destroy()
|
|
|
|
|
|
|
|
def on_clear_button_clicked(self, widget):
|
|
|
|
# empty the image
|
|
|
|
button = self.xml.get_object('PHOTO_button')
|
|
|
|
image = button.get_image()
|
|
|
|
image.set_from_pixbuf(None)
|
|
|
|
button.hide()
|
|
|
|
text_button = self.xml.get_object('NOPHOTO_button')
|
|
|
|
text_button.show()
|
|
|
|
self.avatar_encoded = None
|
2017-09-16 11:49:31 +02:00
|
|
|
self.avatar_sha = None
|
2010-02-08 15:08:40 +01:00
|
|
|
self.avatar_mime_type = None
|
|
|
|
|
|
|
|
def on_set_avatar_button_clicked(self, widget):
|
|
|
|
def on_ok(widget, path_to_file):
|
2017-09-16 11:49:31 +02:00
|
|
|
with open(path_to_file, 'rb') as file:
|
|
|
|
data = file.read()
|
|
|
|
sha = app.interface.save_avatar(data, publish=True)
|
|
|
|
if sha is None:
|
|
|
|
dialogs.ErrorDialog(
|
|
|
|
_('Could not load image'), transient_for=self.window)
|
2010-02-08 15:08:40 +01:00
|
|
|
return
|
2017-09-16 11:49:31 +02:00
|
|
|
|
2010-02-08 15:08:40 +01:00
|
|
|
self.dialog.destroy()
|
|
|
|
self.dialog = None
|
2017-09-16 11:49:31 +02:00
|
|
|
|
2017-10-19 21:12:27 +02:00
|
|
|
scale = self.window.get_scale_factor()
|
|
|
|
surface = app.interface.get_avatar(sha, AvatarSize.VCARD, scale)
|
2017-09-16 11:49:31 +02:00
|
|
|
|
2010-02-08 15:08:40 +01:00
|
|
|
button = self.xml.get_object('PHOTO_button')
|
|
|
|
image = button.get_image()
|
2017-10-19 21:12:27 +02:00
|
|
|
image.set_from_surface(surface)
|
2010-02-08 15:08:40 +01:00
|
|
|
button.show()
|
|
|
|
text_button = self.xml.get_object('NOPHOTO_button')
|
|
|
|
text_button.hide()
|
2017-09-16 11:49:31 +02:00
|
|
|
|
|
|
|
self.avatar_sha = sha
|
|
|
|
publish = app.interface.get_avatar(sha, publish=True)
|
|
|
|
self.avatar_encoded = base64.b64encode(publish).decode('utf-8')
|
|
|
|
self.avatar_mime_type = 'image/jpeg'
|
2010-02-08 15:08:40 +01:00
|
|
|
|
|
|
|
def on_clear(widget):
|
|
|
|
self.dialog.destroy()
|
|
|
|
self.dialog = None
|
|
|
|
self.on_clear_button_clicked(widget)
|
|
|
|
|
|
|
|
def on_cancel(widget):
|
|
|
|
self.dialog.destroy()
|
|
|
|
self.dialog = None
|
|
|
|
|
|
|
|
if self.dialog:
|
|
|
|
self.dialog.present()
|
|
|
|
else:
|
2017-09-16 11:49:31 +02:00
|
|
|
self.dialog = dialogs.AvatarChooserDialog(
|
|
|
|
on_response_ok=on_ok, on_response_cancel=on_cancel,
|
|
|
|
on_response_clear=on_clear)
|
2010-02-08 15:08:40 +01:00
|
|
|
|
|
|
|
def on_PHOTO_button_press_event(self, widget, event):
|
|
|
|
"""
|
|
|
|
If right-clicked, show popup
|
|
|
|
"""
|
2017-09-16 11:49:31 +02:00
|
|
|
pixbuf = self.xml.get_object('PHOTO_button').get_image().get_pixbuf()
|
|
|
|
if event.button == 3 and pixbuf: # right click
|
2012-12-23 16:23:43 +01:00
|
|
|
menu = Gtk.Menu()
|
2010-02-08 15:08:40 +01:00
|
|
|
|
2017-09-16 11:49:31 +02:00
|
|
|
nick = app.config.get_per('accounts', self.account, 'name')
|
|
|
|
sha = app.contacts.get_avatar_sha(self.account, self.jid)
|
|
|
|
menuitem = Gtk.MenuItem.new_with_mnemonic(_('Save _As'))
|
|
|
|
menuitem.connect('activate',
|
|
|
|
gtkgui_helpers.on_avatar_save_as_menuitem_activate,
|
|
|
|
sha, nick)
|
|
|
|
menu.append(menuitem)
|
2010-02-08 15:08:40 +01:00
|
|
|
# show clear
|
2014-11-11 23:11:15 +01:00
|
|
|
menuitem = Gtk.MenuItem.new_with_mnemonic(_('_Clear'))
|
2010-02-08 15:08:40 +01:00
|
|
|
menuitem.connect('activate', self.on_clear_button_clicked)
|
|
|
|
menu.append(menuitem)
|
|
|
|
menu.connect('selection-done', lambda w:w.destroy())
|
|
|
|
# show the menu
|
|
|
|
menu.show_all()
|
2013-01-07 23:28:44 +01:00
|
|
|
menu.attach_to_widget(widget, None)
|
2012-12-27 21:58:52 +01:00
|
|
|
menu.popup(None, None, None, None, event.button, event.time)
|
2010-02-08 15:08:40 +01:00
|
|
|
elif event.button == 1: # left click
|
|
|
|
self.on_set_avatar_button_clicked(widget)
|
|
|
|
|
2010-05-11 16:58:53 +02:00
|
|
|
def on_BDAY_entry_focus_out_event(self, widget, event):
|
|
|
|
txt = widget.get_text()
|
|
|
|
if not txt:
|
|
|
|
return
|
|
|
|
try:
|
|
|
|
time.strptime(txt, '%Y-%m-%d')
|
|
|
|
except ValueError:
|
|
|
|
if not widget.is_focus():
|
|
|
|
pritext = _('Wrong date format')
|
|
|
|
dialogs.ErrorDialog(pritext, _('Format of the date must be '
|
2013-08-15 22:20:13 +02:00
|
|
|
'YYYY-MM-DD'), transient_for=self.window)
|
2013-07-28 20:50:30 +02:00
|
|
|
GLib.idle_add(lambda: widget.grab_focus())
|
2010-05-11 16:58:53 +02:00
|
|
|
return True
|
|
|
|
|
2010-02-08 15:08:40 +01:00
|
|
|
def set_value(self, entry_name, value):
|
|
|
|
try:
|
2012-04-18 11:34:57 +02:00
|
|
|
widget = self.xml.get_object(entry_name)
|
|
|
|
val = widget.get_text()
|
|
|
|
if val:
|
|
|
|
value = val + ' / ' + value
|
|
|
|
widget.set_text(value)
|
2010-02-08 15:08:40 +01:00
|
|
|
except AttributeError:
|
|
|
|
pass
|
|
|
|
|
|
|
|
def set_values(self, vcard_):
|
|
|
|
button = self.xml.get_object('PHOTO_button')
|
|
|
|
image = button.get_image()
|
|
|
|
text_button = self.xml.get_object('NOPHOTO_button')
|
|
|
|
if not 'PHOTO' in vcard_:
|
|
|
|
# set default image
|
|
|
|
image.set_from_pixbuf(None)
|
|
|
|
button.hide()
|
|
|
|
text_button.show()
|
|
|
|
for i in vcard_.keys():
|
|
|
|
if i == 'PHOTO':
|
2017-09-16 11:49:31 +02:00
|
|
|
photo_encoded = vcard_[i]['BINVAL']
|
|
|
|
if photo_encoded == '':
|
2010-02-08 15:08:40 +01:00
|
|
|
continue
|
2018-04-08 20:58:24 +02:00
|
|
|
self.avatar_encoded = photo_encoded
|
2017-09-16 11:49:31 +02:00
|
|
|
photo_decoded = base64.b64decode(photo_encoded.encode('utf-8'))
|
2018-04-08 21:55:29 +02:00
|
|
|
self.avatar_sha = hashlib.sha1(photo_decoded).hexdigest()
|
|
|
|
if 'TYPE' in vcard_[i]:
|
|
|
|
self.avatar_mime_type = vcard_[i]['TYPE']
|
2017-09-16 11:49:31 +02:00
|
|
|
pixbuf = gtkgui_helpers.get_pixbuf_from_data(photo_decoded)
|
|
|
|
if pixbuf is None:
|
|
|
|
continue
|
|
|
|
pixbuf = pixbuf.scale_simple(
|
|
|
|
AvatarSize.PROFILE, AvatarSize.PROFILE,
|
|
|
|
GdkPixbuf.InterpType.BILINEAR)
|
2010-02-08 15:08:40 +01:00
|
|
|
image.set_from_pixbuf(pixbuf)
|
|
|
|
button.show()
|
|
|
|
text_button.hide()
|
|
|
|
continue
|
|
|
|
if i == 'ADR' or i == 'TEL' or i == 'EMAIL':
|
|
|
|
for entry in vcard_[i]:
|
|
|
|
add_on = '_HOME'
|
|
|
|
if 'WORK' in entry:
|
|
|
|
add_on = '_WORK'
|
|
|
|
for j in entry.keys():
|
|
|
|
self.set_value(i + add_on + '_' + j + '_entry', entry[j])
|
|
|
|
if isinstance(vcard_[i], dict):
|
|
|
|
for j in vcard_[i].keys():
|
|
|
|
self.set_value(i + '_' + j + '_entry', vcard_[i][j])
|
|
|
|
else:
|
|
|
|
if i == 'DESC':
|
|
|
|
self.xml.get_object('DESC_textview').get_buffer().set_text(
|
2017-10-20 20:51:40 +02:00
|
|
|
vcard_[i], len(vcard_[i].encode('utf-8')))
|
2010-02-08 15:08:40 +01:00
|
|
|
else:
|
|
|
|
self.set_value(i + '_entry', vcard_[i])
|
|
|
|
if self.update_progressbar_timeout_id is not None:
|
|
|
|
if self.message_id:
|
2012-12-31 18:14:21 +01:00
|
|
|
self.statusbar.remove(self.context_id, self.message_id)
|
2010-02-08 15:08:40 +01:00
|
|
|
self.message_id = self.statusbar.push(self.context_id,
|
|
|
|
_('Information received'))
|
2013-07-28 20:50:30 +02:00
|
|
|
self.remove_statusbar_timeout_id = GLib.timeout_add_seconds(3,
|
|
|
|
self.remove_statusbar, self.message_id)
|
|
|
|
GLib.source_remove(self.update_progressbar_timeout_id)
|
2010-02-08 15:08:40 +01:00
|
|
|
self.progressbar.hide()
|
|
|
|
self.progressbar.set_fraction(0)
|
|
|
|
self.update_progressbar_timeout_id = None
|
|
|
|
|
2017-09-16 11:49:31 +02:00
|
|
|
def _nec_vcard_received(self, jid, resource, room, vcard_):
|
|
|
|
self.set_values(vcard_)
|
2010-11-26 21:14:59 +01:00
|
|
|
|
2010-02-08 15:08:40 +01:00
|
|
|
def add_to_vcard(self, vcard_, entry, txt):
|
|
|
|
"""
|
|
|
|
Add an information to the vCard dictionary
|
|
|
|
"""
|
|
|
|
entries = entry.split('_')
|
|
|
|
loc = vcard_
|
|
|
|
if len(entries) == 3: # We need to use lists
|
|
|
|
if entries[0] not in loc:
|
|
|
|
loc[entries[0]] = []
|
|
|
|
found = False
|
|
|
|
for e in loc[entries[0]]:
|
|
|
|
if entries[1] in e:
|
|
|
|
e[entries[2]] = txt
|
|
|
|
break
|
|
|
|
else:
|
|
|
|
loc[entries[0]].append({entries[1]: '', entries[2]: txt})
|
|
|
|
return vcard_
|
|
|
|
while len(entries) > 1:
|
|
|
|
if entries[0] not in loc:
|
|
|
|
loc[entries[0]] = {}
|
|
|
|
loc = loc[entries[0]]
|
|
|
|
del entries[0]
|
|
|
|
loc[entries[0]] = txt
|
|
|
|
return vcard_
|
|
|
|
|
|
|
|
def make_vcard(self):
|
|
|
|
"""
|
|
|
|
Make the vCard dictionary
|
|
|
|
"""
|
|
|
|
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', 'TEL_WORK_NUMBER', 'EMAIL_WORK_USERID',
|
|
|
|
'ADR_WORK_STREET', 'ADR_WORK_EXTADR', 'ADR_WORK_LOCALITY',
|
|
|
|
'ADR_WORK_REGION', 'ADR_WORK_PCODE', 'ADR_WORK_CTRY']
|
|
|
|
vcard_ = {}
|
|
|
|
for e in entries:
|
2013-01-01 19:44:25 +01:00
|
|
|
txt = self.xml.get_object(e + '_entry').get_text()
|
2010-02-08 15:08:40 +01:00
|
|
|
if txt != '':
|
|
|
|
vcard_ = self.add_to_vcard(vcard_, e, txt)
|
|
|
|
|
|
|
|
# DESC textview
|
|
|
|
buff = self.xml.get_object('DESC_textview').get_buffer()
|
|
|
|
start_iter = buff.get_start_iter()
|
|
|
|
end_iter = buff.get_end_iter()
|
2012-12-23 16:23:43 +01:00
|
|
|
txt = buff.get_text(start_iter, end_iter, False)
|
2010-02-08 15:08:40 +01:00
|
|
|
if txt != '':
|
2013-01-01 19:44:25 +01:00
|
|
|
vcard_['DESC'] = txt
|
2010-02-08 15:08:40 +01:00
|
|
|
|
|
|
|
# Avatar
|
|
|
|
if self.avatar_encoded:
|
|
|
|
vcard_['PHOTO'] = {'BINVAL': self.avatar_encoded}
|
|
|
|
if self.avatar_mime_type:
|
|
|
|
vcard_['PHOTO']['TYPE'] = self.avatar_mime_type
|
2017-09-16 11:49:31 +02:00
|
|
|
return vcard_, self.avatar_sha
|
2010-02-08 15:08:40 +01:00
|
|
|
|
|
|
|
def on_ok_button_clicked(self, widget):
|
|
|
|
if self.update_progressbar_timeout_id:
|
|
|
|
# Operation in progress
|
|
|
|
return
|
2017-08-13 13:18:56 +02:00
|
|
|
if app.connections[self.account].connected < 2:
|
2010-02-08 15:08:40 +01:00
|
|
|
dialogs.ErrorDialog(_('You are not connected to the server'),
|
2013-08-15 10:33:27 +02:00
|
|
|
_('Without a connection, you can not publish your contact '
|
2013-08-15 22:20:13 +02:00
|
|
|
'information.'), transient_for=self.window)
|
2010-02-08 15:08:40 +01:00
|
|
|
return
|
2017-09-16 11:49:31 +02:00
|
|
|
vcard_, sha = self.make_vcard()
|
2010-02-08 15:08:40 +01:00
|
|
|
nick = ''
|
|
|
|
if 'NICKNAME' in vcard_:
|
|
|
|
nick = vcard_['NICKNAME']
|
2017-08-13 13:18:56 +02:00
|
|
|
app.connections[self.account].send_nickname(nick)
|
2010-02-08 15:08:40 +01:00
|
|
|
if nick == '':
|
2017-08-13 13:18:56 +02:00
|
|
|
app.connections[self.account].retract_nickname()
|
|
|
|
nick = app.config.get_per('accounts', self.account, 'name')
|
|
|
|
app.nicks[self.account] = nick
|
2017-09-16 11:49:31 +02:00
|
|
|
app.connections[self.account].send_vcard(vcard_, sha)
|
2010-02-08 15:08:40 +01:00
|
|
|
self.message_id = self.statusbar.push(self.context_id,
|
2017-02-04 23:29:45 +01:00
|
|
|
_('Sending profile…'))
|
2010-02-08 15:08:40 +01:00
|
|
|
self.progressbar.show()
|
2013-07-28 20:50:30 +02:00
|
|
|
self.update_progressbar_timeout_id = GLib.timeout_add(100,
|
|
|
|
self.update_progressbar)
|
2010-02-08 15:08:40 +01:00
|
|
|
|
2010-11-08 22:34:04 +01:00
|
|
|
def _nec_vcard_published(self, obj):
|
|
|
|
if obj.conn.name != self.account:
|
|
|
|
return
|
2010-02-08 15:08:40 +01:00
|
|
|
if self.update_progressbar_timeout_id is not None:
|
2013-07-28 20:50:30 +02:00
|
|
|
GLib.source_remove(self.update_progressbar_timeout_id)
|
2010-02-08 15:08:40 +01:00
|
|
|
self.update_progressbar_timeout_id = None
|
|
|
|
self.window.destroy()
|
|
|
|
|
2010-11-08 22:34:04 +01:00
|
|
|
def _nec_vcard_not_published(self, obj):
|
|
|
|
if obj.conn.name != self.account:
|
|
|
|
return
|
2010-02-08 15:08:40 +01:00
|
|
|
if self.message_id:
|
2012-12-31 18:14:21 +01:00
|
|
|
self.statusbar.remove(self.context_id, self.message_id)
|
2010-02-08 15:08:40 +01:00
|
|
|
self.message_id = self.statusbar.push(self.context_id,
|
2010-11-08 22:34:04 +01:00
|
|
|
_('Information NOT published'))
|
2013-07-28 20:50:30 +02:00
|
|
|
self.remove_statusbar_timeout_id = GLib.timeout_add_seconds(3,
|
2010-11-08 22:34:04 +01:00
|
|
|
self.remove_statusbar, self.message_id)
|
2010-02-08 15:08:40 +01:00
|
|
|
if self.update_progressbar_timeout_id is not None:
|
2013-07-28 20:50:30 +02:00
|
|
|
GLib.source_remove(self.update_progressbar_timeout_id)
|
2010-02-08 15:08:40 +01:00
|
|
|
self.progressbar.set_fraction(0)
|
|
|
|
self.update_progressbar_timeout_id = None
|
|
|
|
dialogs.InformationDialog(_('vCard publication failed'),
|
2010-11-08 22:34:04 +01:00
|
|
|
_('There was an error while publishing your personal information, '
|
2013-08-15 22:20:13 +02:00
|
|
|
'try again later.'), transient_for=self.window)
|
2010-02-08 15:08:40 +01:00
|
|
|
|
|
|
|
def on_cancel_button_clicked(self, widget):
|
|
|
|
self.window.destroy()
|