X-Git-Url: http://git.maemo.org/git/?p=theonering;a=blobdiff_plain;f=src%2Fautogv.py;h=6c7f3cc6b0cdaf72580324b5952808b8eb67bc88;hp=346f48ce52a9ecdda3e7a9625ae991bf15d4a1fa;hb=40830dbb5b708c02bf56cc1a1557b34dbf7d70fc;hpb=548c58651ec7849619b9d823fdeee169be6c87b5 diff --git a/src/autogv.py b/src/autogv.py index 346f48c..6c7f3cc 100644 --- a/src/autogv.py +++ b/src/autogv.py @@ -1,5 +1,6 @@ import logging +import dbus import telepathy try: @@ -118,7 +119,11 @@ class RefreshVoicemail(object): return conn = telepathy.client.Connection(serviceName, connObjectPath) - chan = telepathy.client.Channel(serviceName, channelObjectPath) + try: + chan = telepathy.client.Channel(serviceName, channelObjectPath) + except dbus.exceptions.UnknownMethodException: + _moduleLogger.exception("Client might not have implemented a deprecated method") + return missDetection = telepathy_utils.WasMissedCall( bus, conn, chan, self._on_missed_call, self._on_error_for_missed ) @@ -136,6 +141,24 @@ class RefreshVoicemail(object): self._outstandingRequests.remove(missDetection) +class TimedDisconnect(object): + + def __init__(self, connRef): + self._connRef = connRef + self.__delayedDisconnect = gobject_utils.Timeout(self._on_delayed_disconnect) + + def start(self): + self.__delayedDisconnect.start(seconds=60) + + def stop(self): + self.__delayedDisconnect.cancel() + + @misc_utils.log_exception(_moduleLogger) + def _on_delayed_disconnect(self): + _moduleLogger.info("Timed disconnect occurred") + self._connRef().disconnect(telepathy.CONNECTION_STATUS_REASON_NETWORK_ERROR) + + class AutoDisconnect(object): def __init__(self, connRef): @@ -174,6 +197,7 @@ class AutoDisconnect(object): else: _moduleLogger.info("Other status: %r" % (status, )) + @misc_utils.log_exception(_moduleLogger) def _cancel_delayed_disconnect(self): _moduleLogger.info("Cancelling auto-log off") self.__delayedDisconnect.cancel() @@ -230,3 +254,25 @@ class DisconnectOnShutdown(object): self._connRef().disconnect(telepathy.CONNECTION_STATUS_REASON_REQUESTED) except Exception: _moduleLogger.exception("Error durring disconnect") + + +class DelayEnableContactIntegration(object): + + def __init__(self, protocolName): + self.__enableSystemContactSupport = telepathy_utils.EnableSystemContactIntegration( + protocolName + ) + self.__delayedEnable = gobject_utils.Async(self._on_delayed_enable) + + def start(self): + self.__delayedEnable.start() + + def stop(self): + self.__delayedEnable.cancel() + + @misc_utils.log_exception(_moduleLogger) + def _on_delayed_enable(self): + try: + self.__enableSystemContactSupport.start() + except dbus.DBusException, e: + _moduleLogger.info("Contact integration seems to not be supported (%s)" % e)