diff options
author | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2007-06-12 09:36:17 (GMT) |
---|---|---|
committer | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2007-06-12 09:36:17 (GMT) |
commit | b758be23c641290fdd24490eac7d600b2065d720 (patch) | |
tree | 93cebf86797b5e153fda1dbd900da13a2892f2e8 | |
parent | 3ffe8b89e6d495519f03afd981ade616dc3c2430 (diff) |
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.
-rw-r--r-- | src/linklocal_plugin.py | 25 |
1 files changed, 25 insertions, 0 deletions
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 """ |