Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2008-02-13 16:06:07 (GMT)
committer Morgan Collett <morgan.collett@gmail.com>2008-02-15 12:06:54 (GMT)
commit163f3aef889cb581dbba1f02d825978655ba8f0b (patch)
treee8fe12b76d0c3743b8133688caf110c459ad5d9f
parent08c75294c6bebe2a1b8e5466bc2d2bde5fcb3059 (diff)
disconnect Salut when msh0 got an not LL IP (#6299)
-rw-r--r--src/linklocal_plugin.py30
1 files changed, 29 insertions, 1 deletions
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)