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