10 _moduleLogger = logging.getLogger("channel.call")
14 tp.ChannelTypeStreamedMedia,
15 tp.ChannelInterfaceCallState,
16 tp.ChannelInterfaceGroup,
18 # @bug On Maemo 5 this is having some kind of "General" error, possibly due to an issue with "GetAll" DBusProperties stuff
20 def __init__(self, connection, manager, props, contactHandle):
21 self.__manager = manager
23 self.__cancelId = None
25 tp.ChannelTypeStreamedMedia.__init__(self, connection, manager, props)
26 tp.ChannelInterfaceCallState.__init__(self)
27 tp.ChannelInterfaceGroup.__init__(self)
28 self.__contactHandle = contactHandle
29 self._implement_property_get(
30 telepathy.interfaces.CHANNEL_TYPE_STREAMED_MEDIA,
32 "InitialAudio": self.initial_audio,
33 "InitialVideo": self.initial_video,
37 self.GroupFlagsChanged(0, 0)
39 '', [self._conn.GetSelfHandle()], [], [], [contactHandle],
40 0, telepathy.CHANNEL_GROUP_CHANGE_REASON_NONE
43 def initial_audio(self):
46 def initial_video(self):
49 @gtk_toolbox.log_exception(_moduleLogger)
54 _moduleLogger.debug("Closing call")
55 tp.ChannelTypeStreamedMedia.Close(self)
56 self.remove_from_connection()
57 if self.__cancelId is not None:
58 gobject.source_remove(self.__cancelId)
59 self.__cancelId = None
61 @gtk_toolbox.log_exception(_moduleLogger)
62 def ListStreams(self):
64 For org.freedesktop.Telepathy.Channel.Type.StreamedMedia
68 @gtk_toolbox.log_exception(_moduleLogger)
69 def RemoveStreams(self, streams):
71 For org.freedesktop.Telepathy.Channel.Type.StreamedMedia
73 raise telepathy.errors.NotImplemented("Cannot remove a stream")
75 @gtk_toolbox.log_exception(_moduleLogger)
76 def RequestStreamDirection(self, stream, streamDirection):
78 For org.freedesktop.Telepathy.Channel.Type.StreamedMedia
80 @note Since streams are short lived, not bothering to implement this
82 _moduleLogger.info("A request was made to change the stream direction")
83 raise telepathy.errors.NotImplemented("Cannot change directions")
85 @gtk_toolbox.log_exception(_moduleLogger)
86 def RequestStreams(self, contactId, streamTypes):
88 For org.freedesktop.Telepathy.Channel.Type.StreamedMedia
90 @returns [(Stream ID, contact, stream type, stream state, stream direction, pending send flags)]
92 contact = self._conn.get_handle_by_id(telepathy.constants.HANDLE_TYPE_CONTACT, contactId)
93 assert self.__contactHandle == contact, "%r != %r" % (self.__contactHandle, contact)
94 contactNumber = contact.phoneNumber
96 self.CallStateChanged(self.__contactHandle, telepathy.constants.CHANNEL_CALL_STATE_RINGING)
97 self.__cancelId = gobject.idle_add(self._on_cancel)
98 self._conn.session.backend.call(contactNumber)
101 streamState = telepathy.constants.MEDIA_STREAM_STATE_DISCONNECTED
102 streamDirection = telepathy.constants.MEDIA_STREAM_DIRECTION_BIDIRECTIONAL
103 pendingSendFlags = telepathy.constants.MEDIA_STREAM_PENDING_REMOTE_SEND
104 return [(streamId, contact, streamTypes[0], streamState, streamDirection, pendingSendFlags)]
106 @gtk_toolbox.log_exception(_moduleLogger)
107 def GetCallStates(self):
109 For org.freedesktop.Telepathy.Channel.Interface.CallState
111 Get the current call states for all contacts involved in this call.
112 @returns {Contact: telepathy.constants.CHANNEL_CALL_STATE_*}
114 return {self.__contactHandle: telepathy.constants.CHANNEL_CALL_STATE_FORWARDED}
116 @gtk_toolbox.log_exception(_moduleLogger)
117 def _on_cancel(self, *args):
118 self.CallStateChanged(self.__contactHandle, telepathy.constants.CHANNEL_CALL_STATE_FORWARDED)
120 self.__cancelId = None