--- /dev/null
+import weakref
+import logging
+
+import telepathy
+
+
+class CallChannel(
+ telepathy.server.ChannelTypeStreamedMedia,
+ telepathy.server.ChannelInterfaceCallState,
+ ):
+
+ def __init__(self, connection, conversation):
+ self._recv_id = 0
+ self._conversation = conversation
+ self._connRef = weakref.ref(connection)
+
+ telepathy.server.ChannelTypeText.__init__(self, connection, None)
+ telepathy.server.ChannelInterfaceGroup.__init__(self)
+ telepathy.server.ChannelInterfaceChatState.__init__(self)
+
+ self.GroupFlagsChanged(telepathy.CHANNEL_GROUP_FLAG_CAN_ADD, 0)
+ self.__add_initial_participants()
+
+ def ListStreams(self):
+ """
+ For org.freedesktop.Telepathy.Channel.Type.StreamedMedia
+ """
+ pass
+
+ def RemoveStreams(self, streams):
+ """
+ For org.freedesktop.Telepathy.Channel.Type.StreamedMedia
+ """
+ pass
+
+ def RequestStreamDirection(self, stream, streamDirection):
+ """
+ For org.freedesktop.Telepathy.Channel.Type.StreamedMedia
+
+ @note Since streams are short lived, not bothering to implement this
+ """
+ logging.info("A request was made to change the stream direction")
+
+ def RequestStreams(self, contact, streamType):
+ """
+ For org.freedesktop.Telepathy.Channel.Type.StreamedMedia
+
+ @returns [(Stream ID, contact, stream type, stream state, stream direction, pending send flags)]
+ """
+ pass
+
+ def GetCallStates(self):
+ """
+ For org.freedesktop.Telepathy.Channel.Interface.CallState
+
+ Get the current call states for all contacts involved in this call.
+ @returns {Contact: telepathy.constants.CHANNEL_CALL_STATE_*}
+ """
+ pass
def create_contact_list_channel(connection, h):
if h.get_name() == 'subscribe':
- channel_class = TheOneRingSubscribeListChannel
+ channel_class = SubscribeListChannel
elif h.get_name() == 'publish':
- channel_class = TheOneRingPublishListChannel
+ channel_class = PublishListChannel
elif h.get_name() == 'hide':
logging.warn("Unsuported type %s" % h.get_name())
elif h.get_name() == 'allow':
return channel_class(connection, h)
-class TheOneRingListChannel(
+class AbstractListChannel(
telepathy.server.ChannelTypeContactList,
telepathy.server.ChannelInterfaceGroup,
):
return []
-class TheOneRingSubscribeListChannel(TheOneRingListChannel):
+class SubscribeListChannel(AbstractListChannel):
"""
Subscribe List channel.
"""
def __init__(self, connection, h):
- TheOneRingListChannel.__init__(self, connection, h)
+ AbstractListChannel.__init__(self, connection, h)
self.GroupFlagsChanged(
telepathy.CHANNEL_GROUP_FLAG_CAN_ADD |
telepathy.CHANNEL_GROUP_FLAG_CAN_REMOVE,
addressBook.delete_contact(contact)
-class TheOneRingPublishListChannel(TheOneRingListChannel):
+class PublishListChannel(AbstractListChannel):
def __init__(self, connection, h):
- TheOneRingListChannel.__init__(self, connection, h)
+ AbstractListChannel.__init__(self, connection, h)
self.GroupFlagsChanged(0, 0)
def AddMembers(self, contacts, message):
return result
-class TheOneRingGroupChannel(TheOneRingListChannel):
+class GroupChannel(AbstractListChannel):
def __init__(self, connection, h):
self.__pending_add = []
self.__pending_remove = []
- TheOneRingListChannel.__init__(self, connection, h)
+ AbstractListChannel.__init__(self, connection, h)
self.GroupFlagsChanged(
telepathy.CHANNEL_GROUP_FLAG_CAN_ADD | telepathy.CHANNEL_GROUP_FLAG_CAN_REMOVE,
0,
import telepathy
-class TheOneRingChannelText(
- telepathy.server.ChannelTypeText,
- ):
+class TextChannel(telepathy.server.ChannelTypeText):
+ """
+ Look into implementing ChannelInterfaceMessages for rich text formatting
+ """
def __init__(self, connection, conversation):
self._recv_id = 0
self._conversation = conversation
- self._conn_ref = weakref.ref(connection)
+ self._connRef = weakref.ref(connection)
telepathy.server.ChannelTypeText.__init__(self, connection, None)
- telepathy.server.ChannelInterfaceGroup.__init__(self)
- telepathy.server.ChannelInterfaceChatState.__init__(self)
self.GroupFlagsChanged(telepathy.CHANNEL_GROUP_FLAG_CAN_ADD, 0)
self.__add_initial_participants()
self._connRef = weakref.ref(connection)
self._listChannels = weakref.WeakValueDictionary()
self._textChannels = weakref.WeakValueDictionary()
+ self._callChannels = weakref.WeakValueDictionary()
def close(self):
for chan in self._listChannels.values():
chan.remove_from_connection()# so that dbus lets it die.
for chan in self._textChannels.values():
chan.Close()
+ for chan in self._callChannels.values():
+ chan.Close()
def channel_for_list(self, handle, suppress_handler=False):
if handle in self._listChannels:
chan = self._listChannels[handle]
else:
if handle.get_type() == telepathy.HANDLE_TYPE_GROUP:
- chan = channel.group.GroupChannel(self._connRef(), handle)
+ chan = channel.contact_list.GroupChannel(self._connRef(), handle)
elif handle.get_type() == telepathy.HANDLE_TYPE_CONTACT:
chan = channel.contact_list.creat_contact_list_channel(self._connRef(), handle)
else:
self._textChannels[handle] = chan
self._connRef().add_channel(chan, handle, suppress_handler)
return chan
+
+ def channel_forcall(self, handle, conversation=None, suppress_handler=False):
+ if handle in self._callChannels:
+ chan = self._callChannels[handle]
+ else:
+ logging.debug("Requesting new call channel")
+ contact = handle.contact
+
+ if conversation is None:
+ client = self._connRef().msn_client
+ conversation = None
+ chan = channel.call.CallChannel(self._connRef(), conversation)
+ self._callChannels[handle] = chan
+ self._connRef().add_channel(chan, handle, suppress_handler)
+ return chan
For org.freedesktop.telepathy.Connection
"""
try:
+ self.StatusChanged(
+ telepathy.CONNECTION_STATUS_CONNECTING,
+ telepathy.CONNECTION_STATUS_REASON_REQUESTED
+ )
self._backend.login(*self._credentials)
self.StatusChanged(
telepathy.CONNECTION_STATUS_CONNECTED,
telepathy.CONNECTION_STATUS_REASON_REQUESTED
)
- logging.info("Connected")
except Exception:
self.StatusChanged(
telepathy.CONNECTION_STATUS_DISCONNECTED,
telepathy.CONNECTION_STATUS_REASON_AUTHENTICATION_FAILED
)
- logging.exception("Connecting Failed")
def Disconnect(self):
"""