[telepathy-ashes/master] Detect disconnects and exit.
David Laban
david.laban at collabora.co.uk
Thu Oct 8 04:53:40 PDT 2009
---
ashes/tools/bases.py | 7 +++++--
ashes/tools/presence.py | 6 +++---
2 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/ashes/tools/bases.py b/ashes/tools/bases.py
index 1a9fb6b..6631903 100644
--- a/ashes/tools/bases.py
+++ b/ashes/tools/bases.py
@@ -2,7 +2,7 @@
This module contains the base classes for dbus and telepathy client objects.
"""
-
+import gobject
import dbus
import telepathy
@@ -125,7 +125,10 @@ class ConnectionListener(ObjectListener):
for signal_name in self._signal_names[iface_name]:
self.connect_to_signal(iface_name, signal_name)
-
+ def StatusChanged(self, status, reason=0):
+ if status == 2: #Disconnected
+ print "Disconnected. Exiting."
+ gobject.idle_add(quit)
#FIXME: this should really be auto-generated from the spec globally.
_signal_names = {
diff --git a/ashes/tools/presence.py b/ashes/tools/presence.py
index 415e118..206d989 100644
--- a/ashes/tools/presence.py
+++ b/ashes/tools/presence.py
@@ -23,9 +23,9 @@ class Onlineifier(ConnectionListener):
if status == 0: #Connected
print "Setting status to online"
self.connection[self.SIMPLE_PRESENCE].SetPresence('available', '')
- # FIXME: if anyone else in the mixin implements this method, we should
- # call super(Onlineifier, self).StatusChanged(status, reason)
- # This will be fixed when we use single inheritance.
+ # We know that ConnectionListener listens to this signal to detect
+ # disconnects. Other mixin classes MAY also override this.
+ super(Onlineifier, self).StatusChanged(status, reason)
class PresenceEchoer(ConnectionListener):
--
1.5.6.5
More information about the telepathy-commits
mailing list