8 import util.misc as misc_utils
11 _moduleLogger = logging.getLogger(__name__)
14 class ChannelManager(tp.ChannelManager):
16 def __init__(self, connection):
17 tp.ChannelManager.__init__(self, connection)
22 telepathy.CHANNEL_INTERFACE + '.ChannelType': telepathy.CHANNEL_TYPE_CONTACT_LIST,
23 telepathy.CHANNEL_INTERFACE + '.TargetHandleType': dbus.UInt32(telepathy.HANDLE_TYPE_LIST),
26 telepathy.CHANNEL_INTERFACE + '.TargetHandle',
27 telepathy.CHANNEL_INTERFACE + '.TargetID',
31 self.implement_channel_classes(
32 telepathy.CHANNEL_TYPE_CONTACT_LIST,
33 self._get_list_channel,
40 telepathy.CHANNEL_INTERFACE + '.ChannelType': telepathy.CHANNEL_TYPE_TEXT,
41 telepathy.CHANNEL_INTERFACE + '.TargetHandleType': dbus.UInt32(telepathy.HANDLE_TYPE_CONTACT)
44 telepathy.CHANNEL_INTERFACE + '.TargetHandle',
45 telepathy.CHANNEL_INTERFACE + '.TargetID',
49 self.implement_channel_classes(
50 telepathy.CHANNEL_TYPE_TEXT,
51 self._get_text_channel,
58 telepathy.CHANNEL_INTERFACE + '.ChannelType': telepathy.CHANNEL_TYPE_FILE_TRANSFER,
59 telepathy.CHANNEL_INTERFACE + '.TargetHandleType': dbus.UInt32(telepathy.HANDLE_TYPE_CONTACT)
62 telepathy.CHANNEL_INTERFACE + '.TargetHandle',
63 telepathy.CHANNEL_INTERFACE + '.TargetID',
67 self.implement_channel_classes(
68 telepathy.CHANNEL_TYPE_FILE_TRANSFER,
69 self._get_file_transfer_channel,
76 telepathy.CHANNEL_INTERFACE + '.ChannelType': telepathy.CHANNEL_TYPE_STREAMED_MEDIA,
77 telepathy.CHANNEL_INTERFACE + '.TargetHandleType': dbus.UInt32(telepathy.HANDLE_TYPE_CONTACT)
80 telepathy.CHANNEL_INTERFACE + '.TargetHandle',
81 telepathy.CHANNEL_INTERFACE + '.TargetID',
82 telepathy.CHANNEL_TYPE_STREAMED_MEDIA + '.InitialAudio',
83 telepathy.CHANNEL_TYPE_STREAMED_MEDIA + '.InitialVideo',
87 self.implement_channel_classes(
88 telepathy.CHANNEL_TYPE_STREAMED_MEDIA,
89 self._get_media_channel,
93 def _get_list_channel(self, props):
94 _, surpress_handler, h = self._get_type_requested_handle(props)
96 _moduleLogger.debug('New contact list channel')
97 chan = channel.contact_list.create_contact_list_channel(self._conn, self, props, h)
100 def _get_text_channel(self, props):
101 _, surpress_handler, h = self._get_type_requested_handle(props)
103 accountNumber = misc_utils.normalize_number(self._conn.session.backend.get_account_number())
104 if h.phoneNumber == accountNumber:
105 _moduleLogger.debug('New Debug channel')
106 chan = channel.debug_prompt.DebugPromptChannel(self._conn, self, props, h)
108 _moduleLogger.debug('New text channel')
109 chan = channel.text.TextChannel(self._conn, self, props, h)
112 def _get_file_transfer_channel(self, props):
113 _, surpress_handler, h = self._get_type_requested_handle(props)
115 _moduleLogger.debug('New file transfer channel')
116 chan = channel.debug_log.DebugLogChannel(self._conn, self, props, h)
119 def _get_media_channel(self, props):
120 _, surpress_handler, h = self._get_type_requested_handle(props)
122 _moduleLogger.debug('New media channel')
123 chan = channel.call.CallChannel(self._conn, self, props, h)