From 163f3aef889cb581dbba1f02d825978655ba8f0b Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Wed, 13 Feb 2008 16:06:07 +0000 Subject: disconnect Salut when msh0 got an not LL IP (#6299) --- diff --git a/src/linklocal_plugin.py b/src/linklocal_plugin.py index 5646018..b741d02 100644 --- a/src/linklocal_plugin.py +++ b/src/linklocal_plugin.py @@ -62,6 +62,10 @@ class LinkLocalPlugin(TelepathyPlugin): self._watch = self._sys_bus.watch_name_owner('org.freedesktop.Avahi', self._avahi_owner_cb) + # Glib source ID indicating we have to wait before be allowed to try + # to connect + self._have_to_wait_id = 0 + def _avahi_owner_cb(self, unique_name): had_avahi = self._have_avahi @@ -89,7 +93,8 @@ class LinkLocalPlugin(TelepathyPlugin): self._watch = None def _could_connect(self): - return TelepathyPlugin._could_connect(self) and self._have_avahi + return TelepathyPlugin._could_connect(self) and self._have_avahi and \ + self._have_to_wait_id == 0 def _get_account_info(self): """Retrieve connection manager parameters for this account @@ -194,3 +199,26 @@ class LinkLocalPlugin(TelepathyPlugin): ret[handle] = 'salut/' + psutils.escape_identifier(ident) return ret + + + def _have_to_wait_cb(self): + if self._have_to_wait_id > 0: + gobject.source_remove(self._have_to_wait_id) + self._have_to_wait_id = 0 + + _logger.debug("Timeout elapsed. Salut can connect now") + self.start() + + def _ip4_address_changed_cb(self, ip4am, address, iface): + TelepathyPlugin._ip4_address_changed_cb(self, ip4am, address, iface) + + # FIXME: what about IPv6 ? + if iface == "msh0" and not address.startswith("169.254."): + # msh0 got a not link-local IP so we are connected to a school + # server. Let's disable Salut. See #6299 for details. + _logger.debug("Connected to a school server. Disable Salut") + self._stop() + + # Salut can't connect during the next 2 minutes + self._have_to_wait_id = gobject.timeout_add(120000, + self._have_to_wait_cb) -- cgit v0.9.1