Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuillaume Desmottes <cassidy@cass-wks.(none)>2007-11-14 14:17:57 (GMT)
committer Guillaume Desmottes <cassidy@cass-wks.(none)>2007-11-14 14:17:57 (GMT)
commit2f018f3606cedb76922ac59db4f37e51597fb015 (patch)
tree09ffc68a58a5066a97a0398031cf60e358667574
parent655569208b20abf5eaee77d5fdede1daae09667f (diff)
Move IP4AddressMonitor object from ServerPlugin to TelepathyPlugin so we can reset the
reconnect timer when our IP is changed
-rw-r--r--src/server_plugin.py11
-rw-r--r--src/telepathy_plugin.py14
2 files changed, 16 insertions, 9 deletions
diff --git a/src/server_plugin.py b/src/server_plugin.py
index ef79aaa..fa7efdf 100644
--- a/src/server_plugin.py
+++ b/src/server_plugin.py
@@ -56,16 +56,9 @@ class ServerPlugin(TelepathyPlugin):
def __init__(self, registry, owner):
TelepathyPlugin.__init__(self, registry, owner)
- # Monitor IPv4 address as an indicator of the network connection
- self._ip4am = psutils.IP4AddressMonitor.get_instance()
- self._ip4am_sigid = self._ip4am.connect('address-changed', self._ip4_address_changed_cb)
-
- def cleanup(self):
- TelepathyPlugin.cleanup(self)
- self._ip4am.disconnect(self._ip4am_sigid)
-
def _ip4_address_changed_cb(self, ip4am, address):
- _logger.debug("::: IP4 address now %s", address)
+ TelepathyPlugin._ip4_address_changed_cb(self, ip4am, address)
+
if address:
_logger.debug("::: valid IP4 address, conn_status %s" %
self._conn_status)
diff --git a/src/telepathy_plugin.py b/src/telepathy_plugin.py
index af1a327..c73e7c7 100644
--- a/src/telepathy_plugin.py
+++ b/src/telepathy_plugin.py
@@ -36,6 +36,8 @@ from telepathy.interfaces import (CONN_INTERFACE, CHANNEL_TYPE_TEXT,
CONN_INTERFACE_ALIASING, CHANNEL_TYPE_CONTACT_LIST,
CONN_MGR_INTERFACE)
+import psutils
+
CONN_INTERFACE_BUDDY_INFO = 'org.laptop.Telepathy.BuddyInfo'
CONN_INTERFACE_ACTIVITY_PROPERTIES = 'org.laptop.Telepathy.ActivityProperties'
@@ -142,6 +144,11 @@ class TelepathyPlugin(gobject.GObject):
self._session_bus = SessionBus()
self._watch_conn_name = None
+ # Monitor IPv4 address as an indicator of the network connection
+ self._ip4am = psutils.IP4AddressMonitor.get_instance()
+ self._ip4am_sigid = self._ip4am.connect('address-changed',
+ self._ip4_address_changed_cb)
+
@property
def status(self):
"""Return the Telepathy connection status."""
@@ -332,6 +339,8 @@ class TelepathyPlugin(gobject.GObject):
gobject.source_remove(self._backoff_id)
self._backoff_id = 0
+ self._ip4am.disconnect(self._ip4am_sigid)
+
def _contacts_offline(self, handles):
"""Handle contacts going offline (send message, update set)"""
self._online_contacts -= handles
@@ -540,3 +549,8 @@ class TelepathyPlugin(gobject.GObject):
self._init_connection()
else:
_logger.debug('%r: Postponing connection', self)
+
+ def _ip4_address_changed_cb(self, ip4am, address):
+ _logger.debug("::: IP4 address now %s", address)
+
+ self._reconnect_timeout = self._RECONNECT_INITIAL_TIMEOUT