X-Git-Url: http://git.maemo.org/git/?p=theonering;a=blobdiff_plain;f=src%2Fchannel%2Fcall.py;h=865e55d4ecb50a3939e0f95d03b0fb637fc48341;hp=5ab9a0b4b68c104c43f3372ace98dd4a023faaa5;hb=816e92d6356c1ad745c589b790f1226af96fd858;hpb=c031c65923a021324ae3e9077332a9b3d43c716c diff --git a/src/channel/call.py b/src/channel/call.py index 5ab9a0b..865e55d 100644 --- a/src/channel/call.py +++ b/src/channel/call.py @@ -1,14 +1,14 @@ import logging import dbus -import gobject import telepathy import tp -import gtk_toolbox +import util.go_utils as gobject_utils +import util.misc as misc_utils -_moduleLogger = logging.getLogger("channel.call") +_moduleLogger = logging.getLogger(__name__) class CallChannel( @@ -20,7 +20,7 @@ class CallChannel( def __init__(self, connection, manager, props, contactHandle): self.__manager = manager self.__props = props - self.__cancelId = None + self._delayedClose = gobject_utils.Timeout(self._on_close_requested) if telepathy.interfaces.CHANNEL_INTERFACE + '.InitiatorHandle' in props: self._initiator = connection.get_handle_by_id( @@ -45,6 +45,7 @@ class CallChannel( tp.ChannelInterfaceCallState.__init__(self) tp.ChannelInterfaceGroup.__init__(self) self.__contactHandle = contactHandle + self.__calledNumer = None self._implement_property_get( telepathy.interfaces.CHANNEL_INTERFACE, @@ -87,7 +88,7 @@ class CallChannel( def initial_video(self): return False - @gtk_toolbox.log_exception(_moduleLogger) + @misc_utils.log_exception(_moduleLogger) def Close(self): self.close() @@ -95,47 +96,47 @@ class CallChannel( _moduleLogger.debug("Closing call") tp.ChannelTypeStreamedMedia.Close(self) self.remove_from_connection() - if self.__cancelId is not None: - gobject.source_remove(self.__cancelId) - self.__cancelId = None + if self.__calledNumer is not None: + self._conn.session.backend.cancel(self.__calledNumer) + self._delayedClose.cancel() - @gtk_toolbox.log_exception(_moduleLogger) + @misc_utils.log_exception(_moduleLogger) def GetLocalPendingMembersWithInfo(self): info = dbus.Array([], signature="(uuus)") for member in self._local_pending: info.append((member, self._handle, 0, '')) return info - @gtk_toolbox.log_exception(_moduleLogger) + @misc_utils.log_exception(_moduleLogger) def AddMembers(self, handles, message): _moduleLogger.info("Add members %r: %s" % (handles, message)) for handle in handles: if handle == int(self.GetSelfHandle()) and self.GetSelfHandle() in self._local_pending: _moduleLogger.info("Technically the user just accepted the call") - @gtk_toolbox.log_exception(_moduleLogger) + @misc_utils.log_exception(_moduleLogger) def RemoveMembers(self, handles, message): _moduleLogger.info("Remove members (no-op) %r: %s" % (handles, message)) - @gtk_toolbox.log_exception(_moduleLogger) + @misc_utils.log_exception(_moduleLogger) def RemoveMembersWithReason(self, handles, message, reason): _moduleLogger.info("Remove members (no-op) %r: %s (%i)" % (handles, message, reason)) - @gtk_toolbox.log_exception(_moduleLogger) + @misc_utils.log_exception(_moduleLogger) def ListStreams(self): """ For org.freedesktop.Telepathy.Channel.Type.StreamedMedia """ return () - @gtk_toolbox.log_exception(_moduleLogger) + @misc_utils.log_exception(_moduleLogger) def RemoveStreams(self, streams): """ For org.freedesktop.Telepathy.Channel.Type.StreamedMedia """ raise telepathy.errors.NotImplemented("Cannot remove a stream") - @gtk_toolbox.log_exception(_moduleLogger) + @misc_utils.log_exception(_moduleLogger) def RequestStreamDirection(self, stream, streamDirection): """ For org.freedesktop.Telepathy.Channel.Type.StreamedMedia @@ -145,7 +146,7 @@ class CallChannel( _moduleLogger.info("A request was made to change the stream direction") raise telepathy.errors.NotImplemented("Cannot change directions") - @gtk_toolbox.log_exception(_moduleLogger) + @misc_utils.log_exception(_moduleLogger) def RequestStreams(self, contactId, streamTypes): """ For org.freedesktop.Telepathy.Channel.Type.StreamedMedia @@ -156,9 +157,11 @@ class CallChannel( assert self.__contactHandle == contact, "%r != %r" % (self.__contactHandle, contact) contactNumber = contact.phoneNumber + self.__calledNumer = contactNumber self.CallStateChanged(self.__contactHandle, telepathy.constants.CHANNEL_CALL_STATE_RINGING) - self.__cancelId = gobject.idle_add(self._on_cancel) self._conn.session.backend.call(contactNumber) + self._delayedClose.start(seconds=2) + self.CallStateChanged(self.__contactHandle, telepathy.constants.CHANNEL_CALL_STATE_FORWARDED) streamId = 0 streamState = telepathy.constants.MEDIA_STREAM_STATE_CONNECTED @@ -166,7 +169,7 @@ class CallChannel( pendingSendFlags = telepathy.constants.MEDIA_STREAM_PENDING_REMOTE_SEND return [(streamId, contact, streamTypes[0], streamState, streamDirection, pendingSendFlags)] - @gtk_toolbox.log_exception(_moduleLogger) + @misc_utils.log_exception(_moduleLogger) def GetCallStates(self): """ For org.freedesktop.Telepathy.Channel.Interface.CallState @@ -176,9 +179,8 @@ class CallChannel( """ return {self.__contactHandle: telepathy.constants.CHANNEL_CALL_STATE_FORWARDED} - @gtk_toolbox.log_exception(_moduleLogger) - def _on_cancel(self, *args): - self.CallStateChanged(self.__contactHandle, telepathy.constants.CHANNEL_CALL_STATE_FORWARDED) + @misc_utils.log_exception(_moduleLogger) + def _on_close_requested(self, *args): + _moduleLogger.debug("Cancel now disallowed") + self.__calledNumer = None self.close() - self.__cancelId = None - return False