diff options
Diffstat (limited to 'src/jarabe/util/telepathy/connection_watcher.py')
-rw-r--r-- | src/jarabe/util/telepathy/connection_watcher.py | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/src/jarabe/util/telepathy/connection_watcher.py b/src/jarabe/util/telepathy/connection_watcher.py index 4a4c6e0..96af1cf 100644 --- a/src/jarabe/util/telepathy/connection_watcher.py +++ b/src/jarabe/util/telepathy/connection_watcher.py @@ -28,12 +28,16 @@ from telepathy.interfaces import CONN_INTERFACE from telepathy.constants import CONNECTION_STATUS_CONNECTED, \ CONNECTION_STATUS_DISCONNECTED + +_instance = None + + class ConnectionWatcher(gobject.GObject): __gsignals__ = { 'connection-added': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, ([gobject.TYPE_PYOBJECT])), 'connection-removed': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, - ([gobject.TYPE_PYOBJECT])) + ([gobject.TYPE_PYOBJECT])), } def __init__(self, bus=None): @@ -93,14 +97,22 @@ class ConnectionWatcher(gobject.GObject): def get_connections(self): return self._connections.values() + +def get_instance(): + global _instance + if _instance is None: + _instance = ConnectionWatcher() + return _instance + + if __name__ == '__main__': dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) def connection_added_cb(conn_watcher, conn): - print "new connection", conn.service_name + print 'new connection', conn.service_name def connection_removed_cb(conn_watcher, conn): - print "removed connection", conn.service_name + print 'removed connection', conn.service_name watcher = ConnectionWatcher() watcher.connect('connection-added', connection_added_cb) |