fd6cb9421741c782f1240b2dae675c213aea22ff
[theonering] / src / channel / call.py
1 import logging
2
3 import telepathy
4
5 import gtk_toolbox
6 import handle
7
8
9 _moduleLogger = logging.getLogger("channel.call")
10
11
12 # @todo Test Calls
13 class CallChannel(
14                 telepathy.server.ChannelTypeStreamedMedia,
15                 telepathy.server.ChannelInterfaceCallState,
16         ):
17
18         def __init__(self, connection):
19                 telepathy.server.ChannelTypeStreamedMedia.__init__(self, connection, None)
20                 telepathy.server.ChannelInterfaceGroup.__init__(self)
21                 telepathy.server.ChannelInterfaceChatState.__init__(self)
22
23         @gtk_toolbox.log_exception(_moduleLogger)
24         def ListStreams(self):
25                 """
26                 For org.freedesktop.Telepathy.Channel.Type.StreamedMedia
27                 """
28                 return ()
29
30         @gtk_toolbox.log_exception(_moduleLogger)
31         def RemoveStreams(self, streams):
32                 """
33                 For org.freedesktop.Telepathy.Channel.Type.StreamedMedia
34                 """
35                 raise telepathy.errors.NotImplemented("Cannot remove a stream")
36
37         @gtk_toolbox.log_exception(_moduleLogger)
38         def RequestStreamDirection(self, stream, streamDirection):
39                 """
40                 For org.freedesktop.Telepathy.Channel.Type.StreamedMedia
41
42                 @note Since streams are short lived, not bothering to implement this
43                 """
44                 _moduleLogger.info("A request was made to change the stream direction")
45                 raise telepathy.errors.NotImplemented("Cannot change directions")
46
47         @gtk_toolbox.log_exception(_moduleLogger)
48         def RequestStreams(self, contact, streamTypes):
49                 """
50                 For org.freedesktop.Telepathy.Channel.Type.StreamedMedia
51
52                 @returns [(Stream ID, contact, stream type, stream state, stream direction, pending send flags)]
53                 """
54                 for streamType in streamTypes:
55                         if streamType != telepathy.constants.MEDIA_STREAM_TYPE_AUDIO:
56                                 raise telepathy.errors.NotImplemented("Audio is the only stream type supported")
57
58                 contactId, contactNumber = handle.ContactHandle.from_handle_name(contact.name)
59
60                 self._conn.session.backend.call(contactNumber)
61
62                 streamId = 0
63                 streamState = telepathy.constants.MEDIA_STREAM_STATE_DISCONNECTED
64                 streamDirection = telepathy.constants.MEDIA_STREAM_DIRECTION_BIDIRECTIONAL
65                 pendingSendFlags = telepathy.constants.MEDIA_STREAM_PENDING_REMOTE_SEND
66                 return [(streamId, contact, streamTypes[0], streamState, streamDirection, pendingSendFlags)]
67
68         @gtk_toolbox.log_exception(_moduleLogger)
69         def GetCallStates(self):
70                 """
71                 For org.freedesktop.Telepathy.Channel.Interface.CallState
72
73                 Get the current call states for all contacts involved in this call. 
74                 @returns {Contact: telepathy.constants.CHANNEL_CALL_STATE_*}
75                 """
76                 return {}