From b758be23c641290fdd24490eac7d600b2065d720 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Tue, 12 Jun 2007 09:36:17 +0000 Subject: linklocal_plugin: Don't start up unless Avahi is on the system bus. We can't rely on all sugar-jhbuild users having Avahi installed system-wide. --- diff --git a/src/linklocal_plugin.py b/src/linklocal_plugin.py index 7d2073c..e4a821b 100644 --- a/src/linklocal_plugin.py +++ b/src/linklocal_plugin.py @@ -23,6 +23,7 @@ from string import hexdigits # Other libraries import gobject +from dbus import SystemBus from telepathy.client import (ConnectionManager, Connection) from telepathy.interfaces import (CONN_MGR_INTERFACE, CONN_INTERFACE, CHANNEL_INTERFACE_GROUP) @@ -56,6 +57,30 @@ class LinkLocalPlugin(TelepathyPlugin): def __init__(self, registry, owner): TelepathyPlugin.__init__(self, registry, owner) + self._sys_bus = SystemBus() + self._have_avahi = False + self._watch = self._sys_bus.watch_name_owner('org.freedesktop.Avahi', + self._avahi_owner_cb) + + def _avahi_owner_cb(self, unique_name): + had_avahi = self._have_avahi + + if unique_name: + self._have_avahi = True + if not had_avahi: + _logger.info('Avahi appeared on the system bus (%s) - ' + 'starting...', unique_name) + self.start() + else: + self._have_avahi = False + if had_avahi: + _logger.info('Avahi disappeared from the system bus - ' + 'stopping...') + self.cleanup() + + def _could_connect(self): + return self._have_avahi + def _get_account_info(self): """Retrieve connection manager parameters for this account """ -- cgit v0.9.1