From d07dc39830199974d55bb158e097854cbd92cd1b Mon Sep 17 00:00:00 2001 From: Stefan Bethge Date: Fri, 29 Sep 2006 17:40:11 +0000 Subject: [PATCH] check if avahi is available and we're not on windows, otherwise checkbutton is not sensitive --- data/glade/accounts_window.glade | 3 ++- src/common/zeroconf/connection_zeroconf.py | 31 +++++++++++----------- src/config.py | 10 +++++++ 3 files changed, 28 insertions(+), 16 deletions(-) diff --git a/data/glade/accounts_window.glade b/data/glade/accounts_window.glade index 7c92c0508..39b637bae 100644 --- a/data/glade/accounts_window.glade +++ b/data/glade/accounts_window.glade @@ -95,7 +95,8 @@ True - If checked, all local contacts that use a Bonjour compatible chat client (like iChat, Trillian or Gaim) will be shown in roster. You don't need a jabber server for it. + If checked, all local contacts that use a Bonjour compatible chat client (like iChat, Trillian or Gaim) will be shown in roster. You don't need to be connected to a jabber server for it to work. +This is only available if python-avahi is installed and avahi-daemon is running. True _Enable link-local messaging True diff --git a/src/common/zeroconf/connection_zeroconf.py b/src/common/zeroconf/connection_zeroconf.py index 96b6b1653..01bc2d41c 100644 --- a/src/common/zeroconf/connection_zeroconf.py +++ b/src/common/zeroconf/connection_zeroconf.py @@ -256,24 +256,25 @@ class ConnectionZeroconf(ConnectionHandlersZeroconf): self.zeroconf.disconnect() def reconnect(self, new_port): - txt = {} - txt['1st'] = gajim.config.get_per('accounts', gajim.ZEROCONF_ACC_NAME, 'zeroconf_first_name') - txt['last'] = gajim.config.get_per('accounts', gajim.ZEROCONF_ACC_NAME, 'zeroconf_last_name') - txt['jid'] = gajim.config.get_per('accounts', gajim.ZEROCONF_ACC_NAME, 'zeroconf_jabber_id') - txt['email'] = gajim.config.get_per('accounts', gajim.ZEROCONF_ACC_NAME, 'zeroconf_email') + if self.connected: + txt = {} + txt['1st'] = gajim.config.get_per('accounts', gajim.ZEROCONF_ACC_NAME, 'zeroconf_first_name') + txt['last'] = gajim.config.get_per('accounts', gajim.ZEROCONF_ACC_NAME, 'zeroconf_last_name') + txt['jid'] = gajim.config.get_per('accounts', gajim.ZEROCONF_ACC_NAME, 'zeroconf_jabber_id') + txt['email'] = gajim.config.get_per('accounts', gajim.ZEROCONF_ACC_NAME, 'zeroconf_email') - port = gajim.config.get_per('accounts', gajim.ZEROCONF_ACC_NAME, 'custom_port') + port = gajim.config.get_per('accounts', gajim.ZEROCONF_ACC_NAME, 'custom_port') - if new_port or use_tls: - self.connection.kill_all_connections() - self.connection.listener.disconnect() - self.connection.start_listener(port) + if new_port or use_tls: + self.connection.kill_all_connections() + self.connection.listener.disconnect() + self.connection.start_listener(port) - self.zeroconf.remove_announce() - self.zeroconf.txt = txt - self.zeroconf.port = port - self.zeroconf.username = self.username - self.zeroconf.announce() + self.zeroconf.remove_announce() + self.zeroconf.txt = txt + self.zeroconf.port = port + self.zeroconf.username = self.username + self.zeroconf.announce() def change_status(self, show, msg, sync = False, auto = False): if not show in STATUS_LIST: diff --git a/src/config.py b/src/config.py index 4003c378e..ef953d74b 100644 --- a/src/config.py +++ b/src/config.py @@ -1790,10 +1790,20 @@ class AccountsWindow: st = gajim.config.get('mergeaccounts') self.xml.get_widget('merge_checkbutton').set_active(st) + import os + + avahi_error = False + try: + import avahi + except ImportError: + avahi_error = True + # enable zeroconf st = gajim.config.get('enable_zeroconf') w = self.xml.get_widget('enable_zeroconf_checkbutton') w.set_active(st) + if os.name == 'nt' or avahi_error: + w.set_sensitive(False) w.connect('toggled', self.on_enable_zeroconf_checkbutton_toggled) def on_accounts_window_key_press_event(self, widget, event):