_moduleLogger = logging.getLogger("channel.call")
-# @todo Test Calls
class CallChannel(
telepathy.server.ChannelTypeStreamedMedia,
telepathy.server.ChannelInterfaceCallState,
+ telepathy.server.ChannelInterfaceGroup,
):
- def __init__(self, connection, contactHandle):
- telepathy.server.ChannelTypeStreamedMedia.__init__(self, connection, None)
+ def __init__(self, connection, manager, props, contactHandle):
+ self._manager = manager
+ self._props = props
+
+ try:
+ # HACK Older python-telepathy way
+ telepathy.server.ChannelTypeStreamedMedia.__init__(self, connection, None)
+ except TypeError:
+ # HACK Newer python-telepathy way
+ telepathy.server.ChannelTypeStreamedMedia.__init__(self, connection, manager, props)
telepathy.server.ChannelInterfaceCallState.__init__(self)
+ telepathy.server.ChannelInterfaceGroup.__init__(self)
self._contactHandle = contactHandle
+ self._implement_property_get(
+ telepathy.interfaces.CHANNEL_TYPE_STREAMED_MEDIA,
+ {
+ "InitialAudio": self.initial_audio,
+ "InitialVideo": self.initial_video,
+ },
+ )
+
+ def initial_audio(self):
+ return False
+
+ def initial_video(self):
+ return False
+
+ @gtk_toolbox.log_exception(_moduleLogger)
+ def Close(self):
+ self.close()
+
+ def close(self):
+ telepathy.server.ChannelTypeStreamedMedia.Close(self)
+ if self._manager.channel_exists(self._props):
+ # HACK Older python-telepathy requires doing this manually
+ self._manager.remove_channel(self)
+ self.remove_from_connection()
@gtk_toolbox.log_exception(_moduleLogger)
def ListStreams(self):
@returns [(Stream ID, contact, stream type, stream state, stream direction, pending send flags)]
"""
- for streamType in streamTypes:
- if streamType != telepathy.constants.MEDIA_STREAM_TYPE_AUDIO:
- raise telepathy.errors.NotImplemented("Audio is the only stream type supported")
-
contact = self._conn.handle(telepathy.constants.HANDLE_TYPE_CONTACT, contactId)
assert self._contactHandle == contact, "%r != %r" % (self._contactHandle, contact)
contactId, contactNumber = handle.ContactHandle.from_handle_name(contact.name)
+ self.CallStateChanged(self._contactHandle, telepathy.constants.CHANNEL_CALL_STATE_RINGING)
self._conn.session.backend.call(contactNumber)
+ self.CallStateChanged(self._contactHandle, telepathy.constants.CHANNEL_CALL_STATE_FORWARDED)
streamId = 0
streamState = telepathy.constants.MEDIA_STREAM_STATE_DISCONNECTED
Get the current call states for all contacts involved in this call.
@returns {Contact: telepathy.constants.CHANNEL_CALL_STATE_*}
"""
- return {}
+ return {self._contactHandle: telepathy.constants.CHANNEL_CALL_STATE_FORWARDED}