Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/src/telepathy_plugin.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/telepathy_plugin.py')
-rw-r--r--src/telepathy_plugin.py20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/telepathy_plugin.py b/src/telepathy_plugin.py
index 8baf3d1..26ca8fb 100644
--- a/src/telepathy_plugin.py
+++ b/src/telepathy_plugin.py
@@ -20,7 +20,7 @@
import logging
from itertools import izip
-from dbus import DBusException
+from dbus import DBusException, SessionBus
import gobject
from telepathy.client import (Channel, Connection)
@@ -135,6 +135,10 @@ class TelepathyPlugin(gobject.GObject):
#: The ``publish`` channel: a `telepathy.client.Channel` or None
self._publish_channel = None
+ #: Watch the connection on DBus session bus
+ self._session_bus = SessionBus()
+ self._watch_conn_name = None
+
@property
def status(self):
"""Return the Telepathy connection status."""
@@ -194,6 +198,8 @@ class TelepathyPlugin(gobject.GObject):
m = conn[CONN_INTERFACE].connect_to_signal('NewChannel',
self._new_channel_cb)
self._matches.append(m)
+ self._watch_conn_name = self._session_bus.watch_name_owner(
+ conn.service_name, self._watch_conn_name_cb)
self._conn = conn
status = self._conn[CONN_INTERFACE].GetStatus()
@@ -231,6 +237,18 @@ class TelepathyPlugin(gobject.GObject):
del acct
return conn
+ def _watch_conn_name_cb(self, dbus_name):
+ """Check if we still have a connection on the DBus session bus.
+
+ If the connection disappears, stop the plugin.
+ """
+ if not dbus_name:
+ if self._conn_status == CONNECTION_STATUS_CONNECTED:
+ _logger.debug('telepathy connection %s lost: stopping %s',
+ self._conn.service_name, self._TP_CONN_MANAGER)
+ self._conn = None
+ self._stop()
+
def _handle_connection_status_change(self, status, reason):
if status == self._conn_status:
return