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