Commit 6a388790 authored by sb's avatar sb

add new zeroconf 'vcard' window, shows the information from the txt record

parent a2d7f3a8
This diff is collapsed.
......@@ -73,7 +73,6 @@ class ConnectionZeroconf(ConnectionHandlersZeroconf):
#we don't need a password, but must be non-empty
self.password = 'zeroconf'
#XXX use that somewhere
self.autoconnect = False
self.sync_with_global_status = True
self.no_log_for = False
......@@ -86,10 +85,6 @@ class ConnectionZeroconf(ConnectionHandlersZeroconf):
else:
gajim.config.set('usegpg', False)
self.on_connect_success = None
self.on_connect_failure = None
self.retrycount = 0
self.jids_for_auto_auth = [] # list of jid to auto-authorize
self.get_config_values_or_default()
self.zeroconf = zeroconf.Zeroconf(self._on_new_service,
self._on_remove_service, self._on_name_conflictCB,
......@@ -148,9 +143,9 @@ class ConnectionZeroconf(ConnectionHandlersZeroconf):
gajim.log.debug('reconnect')
signed = self.get_signed_msg(self.status)
self.reconnect()
def quit(self, kill_core):
if kill_core and self.connected > 1:
self.disconnect()
......@@ -445,19 +440,9 @@ class ConnectionZeroconf(ConnectionHandlersZeroconf):
def request_last_status_time(self, jid, resource):
gajim.log.debug('This should not happen (request_last_status_time)')
def request_os_info(self, jid, resource):
'''
if not self.connection:
return
to_whom_jid = jid
if resource:
to_whom_jid += '/' + resource
iq = common.xmpp.Iq(to = to_whom_jid, typ = 'get', queryNS =\
common.xmpp.NS_VERSION)
self.connection.send(iq)
'''
pass
gajim.log.debug('This should not happen (request_os_info)')
def get_settings(self):
gajim.log.debug('This should not happen (get_settings)')
......@@ -474,39 +459,6 @@ class ConnectionZeroconf(ConnectionHandlersZeroconf):
def send_agent_status(self, agent, ptype):
gajim.log.debug('This should not happen (send_agent_status)')
def join_gc(self, nick, room, server, password):
gajim.log.debug('This should not happen (join_gc)')
def send_gc_message(self, jid, msg):
gajim.log.debug('This should not happen (send_gc_message)')
def send_gc_subject(self, jid, subject):
gajim.log.debug('This should not happen (send_gc_subject)')
def request_gc_config(self, room_jid):
gajim.log.debug('This should not happen (request_gc_config)')
def change_gc_nick(self, room_jid, nick):
gajim.log.debug('This should not happen (change_gc_nick)')
def send_gc_status(self, nick, jid, show, status):
gajim.log.debug('This should not happen (send_gc_status)')
def gc_set_role(self, room_jid, nick, role, reason = ''):
gajim.log.debug('This should not happen (gc_set_role)')
def gc_set_affiliation(self, room_jid, jid, affiliation, reason = ''):
gajim.log.debug('This should not happen (gc_set_affiliation)')
def send_gc_affiliation_list(self, room_jid, list):
gajim.log.debug('This should not happen (send_gc_affiliation_list)')
def get_affiliation_list(self, room_jid, affiliation):
gajim.log.debug('This should not happen (get_affiliation_list)')
def send_gc_config(self, room_jid, config):
gajim.log.debug('This should not happen (send_gc_config)')
def gpg_passphrase(self, passphrase):
if USE_GPG:
use_gpg_agent = gajim.config.get('use_gpg_agent')
......@@ -527,30 +479,6 @@ class ConnectionZeroconf(ConnectionHandlersZeroconf):
return keys
return None
def change_password(self, password):
if not self.connection:
return
'''
hostname = gajim.config.get_per('accounts', self.name, 'hostname')
username = gajim.config.get_per('accounts', self.name, 'name')
iq = common.xmpp.Iq(typ = 'set', to = hostname)
q = iq.setTag(common.xmpp.NS_REGISTER + ' query')
q.setTagData('username',username)
q.setTagData('password',password)
self.connection.send(iq)
'''
pass
def unregister_account(self, on_remove_success):
gajim.log.debug('This should not happen (unregister_account)')
def send_invite(self, room, to, reason=''):
gajim.log.debug('This should not happen (send_invite)')
def send_keepalive(self):
# nothing received for the last foo seconds (60 secs by default)
pass
def _event_dispatcher(self, realm, event, data):
if realm == '':
if event == common.xmpp.transports.DATA_RECEIVED:
......
......@@ -1116,6 +1116,14 @@ class RosterWindow:
else:
info[contact.jid] = vcard.VcardWindow(contact, account)
def on_info_zeroconf(self, widget, contact, account):
info = gajim.interface.instances[account]['infos']
if info.has_key(contact.jid):
info[contact.jid].window.present()
else:
info[contact.jid] = vcard.ZeroconfVcardWindow(contact, account)
def show_tooltip(self, contact):
pointer = self.tree.get_pointer()
props = self.tree.get_path_at_pos(pointer[0], pointer[1])
......@@ -1424,7 +1432,7 @@ class RosterWindow:
send_file_menuitem.set_no_show_all(True)
rename_menuitem.connect('activate', self.on_rename, iter, tree_path)
information_menuitem.connect('activate', self.on_info, contact,
information_menuitem.connect('activate', self.on_info_zeroconf, contact,
account)
history_menuitem.connect('activate', self.on_history, contact,
account)
......@@ -1471,6 +1479,7 @@ class RosterWindow:
event.time)
return
# normal account
xml = gtkgui_helpers.get_glade('roster_contact_context_menu.glade')
roster_contact_context_menu = xml.get_widget(
......
......@@ -315,6 +315,153 @@ class VcardWindow:
self.fill_status_label()
gajim.connections[self.account].request_vcard(self.contact.jid, self.is_fake)
def on_close_button_clicked(self, widget):
self.window.destroy()
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_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))
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,
self.contact.jid, self.account, self.contact.name + '.jpeg')
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)
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
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:
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)
log = True
if self.contact.jid in gajim.config.get_per('accounts', self.account,
'no_log_for').split(' '):
log = False
checkbutton = self.xml.get_widget('log_history_checkbutton')
checkbutton.set_active(log)
checkbutton.connect('toggled', self.on_log_history_checkbutton_toggled)
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)
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'])
def on_close_button_clicked(self, widget):
self.window.destroy()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment