X-Git-Url: http://git.maemo.org/git/?p=theonering;a=blobdiff_plain;f=src%2Fconnection_manager.py;h=b9a8e3777452a2e8893872112cd46cbdf5d4b764;hp=dae1f407fcd4487211846bb7210df4769b9734b2;hb=b14494d3d36e55d4a6c2cbd2e467e1686cbb8f7e;hpb=4f7f7378a6bcd5ed4bc332659a133fcd67dfda22 diff --git a/src/connection_manager.py b/src/connection_manager.py index dae1f40..b9a8e37 100644 --- a/src/connection_manager.py +++ b/src/connection_manager.py @@ -1,19 +1,21 @@ import logging -import gobject import telepathy import constants import tp -import gtk_toolbox +import util.go_utils as gobject_utils +import util.misc as misc_utils import connection -_moduleLogger = logging.getLogger("connection_manager") +_moduleLogger = logging.getLogger(__name__) class TheOneRingConnectionManager(tp.ConnectionManager): + IDLE_TIMEOUT = 10 + def __init__(self, shutdown_func=None): tp.ConnectionManager.__init__(self, constants._telepathy_implementation_name_) @@ -22,7 +24,7 @@ class TheOneRingConnectionManager(tp.ConnectionManager): self._on_shutdown = shutdown_func _moduleLogger.info("Connection manager created") - @gtk_toolbox.log_exception(_moduleLogger) + @misc_utils.log_exception(_moduleLogger) def GetParameters(self, proto): """ For org.freedesktop.telepathy.ConnectionManager @@ -59,22 +61,18 @@ class TheOneRingConnectionManager(tp.ConnectionManager): return result - def disconnected(self, conn): - """ - Overrides tp.ConnectionManager - """ - result = tp.ConnectionManager.disconnected(self, conn) - gobject.timeout_add(5000, self._shutdown) + def disconnect_completed(self): + gobject_utils.timeout_add_seconds(self.IDLE_TIMEOUT, self._shutdown) def quit(self): """ Terminates all connections. Must be called upon quit """ - for connection in self._connections: - connection.Disconnect() + for conn in self._connections: + conn.Disconnect() _moduleLogger.info("Connection manager quitting") - @gtk_toolbox.log_exception(_moduleLogger) + @misc_utils.log_exception(_moduleLogger) def _shutdown(self): if ( self._on_shutdown is not None and