Random bug fixes, advancing the channels, unit tests, seperating contacts not just...
[theonering] / src / channel / call.py
index 29b56b1..d8ab0a1 100644 (file)
@@ -12,8 +12,7 @@ class CallChannel(
        ):
 
        def __init__(self, connection):
-               h = None
-               telepathy.server.ChannelTypeStreamedMedia.__init__(self, connection, h)
+               telepathy.server.ChannelTypeStreamedMedia.__init__(self, connection, None)
                telepathy.server.ChannelInterfaceGroup.__init__(self)
                telepathy.server.ChannelInterfaceChatState.__init__(self)
 
@@ -21,13 +20,13 @@ class CallChannel(
                """
                For org.freedesktop.Telepathy.Channel.Type.StreamedMedia
                """
-               pass
+               return ()
 
        def RemoveStreams(self, streams):
                """
                For org.freedesktop.Telepathy.Channel.Type.StreamedMedia
                """
-               pass
+               raise telepathy.NotImplemented("Cannot remove a stream")
 
        def RequestStreamDirection(self, stream, streamDirection):
                """
@@ -36,14 +35,30 @@ class CallChannel(
                @note Since streams are short lived, not bothering to implement this
                """
                _moduleLogger.info("A request was made to change the stream direction")
+               raise telepathy.NotImplemented("Cannot change directions")
 
-       def RequestStreams(self, contact, streamType):
+       def RequestStreams(self, contact, streamTypes):
                """
                For org.freedesktop.Telepathy.Channel.Type.StreamedMedia
 
                @returns [(Stream ID, contact, stream type, stream state, stream direction, pending send flags)]
                """
-               pass
+               for streamType in streamTypes:
+                       if streamType != telepathy.constants.MEDIA_STREAM_TYPE_AUDIO:
+                               raise telepathy.NotImplemented("Audio is the only stream type supported")
+
+               contactId = contact.name
+
+               addressbook = self._conn.session.addressbook
+               phones = addressbook.get_contact_details(contactId)
+               firstNumber = phones.next()
+               self._conn.session.backend.dial(firstNumber)
+
+               streamId = 0
+               streamState = telepathy.constants.MEDIA_STREAM_STATE_DISCONNECTED
+               streamDirection = telepathy.constants.MEDIA_STREAM_DIRECTION_BIDIRECTIONAL
+               pendingSendFlags = telepathy.constants.MEDIA_STREAM_PENDING_REMOTE_SEND
+               return [(streamId, contact, streamTypes[0], streamState, streamDirection, pendingSendFlags)]
 
        def GetCallStates(self):
                """
@@ -52,4 +67,4 @@ class CallChannel(
                Get the current call states for all contacts involved in this call. 
                @returns {Contact: telepathy.constants.CHANNEL_CALL_STATE_*}
                """
-               pass
+               return {}