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)
20 telepathy.CHANNEL_INTERFACE + '.ChannelType': telepathy.CHANNEL_TYPE_CONTACT_LIST
22 self._implement_channel_class(
23 telepathy.CHANNEL_TYPE_CONTACT_LIST,
24 self._get_list_channel,
30 telepathy.CHANNEL_INTERFACE + '.ChannelType': telepathy.CHANNEL_TYPE_TEXT,
31 telepathy.CHANNEL_INTERFACE + '.TargetHandleType': dbus.UInt32(telepathy.HANDLE_TYPE_CONTACT)
33 self._implement_channel_class(
34 telepathy.CHANNEL_TYPE_TEXT,
35 self._get_text_channel,
41 telepathy.CHANNEL_INTERFACE + '.ChannelType': telepathy.CHANNEL_TYPE_FILE_TRANSFER,
42 telepathy.CHANNEL_INTERFACE + '.TargetHandleType': dbus.UInt32(telepathy.HANDLE_TYPE_CONTACT)
44 self._implement_channel_class(
45 telepathy.CHANNEL_TYPE_FILE_TRANSFER,
46 self._get_file_transfer_channel,
52 telepathy.CHANNEL_INTERFACE + '.ChannelType': telepathy.CHANNEL_TYPE_STREAMED_MEDIA,
53 telepathy.CHANNEL_INTERFACE + '.TargetHandleType': dbus.UInt32(telepathy.HANDLE_TYPE_CONTACT)
55 self._implement_channel_class(
56 telepathy.CHANNEL_TYPE_STREAMED_MEDIA,
57 self._get_media_channel,
59 [telepathy.CHANNEL_INTERFACE + '.TargetHandle']
62 def _get_list_channel(self, props):
63 _, surpress_handler, h = self._get_type_requested_handle(props)
65 _moduleLogger.debug('New contact list channel')
66 chan = channel.contact_list.create_contact_list_channel(self._conn, self, props, h)
69 def _get_text_channel(self, props):
70 _, surpress_handler, h = self._get_type_requested_handle(props)
72 accountNumber = misc_utils.normalize_number(self._conn.session.backend.get_account_number())
73 if h.phoneNumber == accountNumber:
74 _moduleLogger.debug('New Debug channel')
75 chan = channel.debug_prompt.DebugPromptChannel(self._conn, self, props, h)
77 _moduleLogger.debug('New text channel')
78 chan = channel.text.TextChannel(self._conn, self, props, h)
81 def _get_file_transfer_channel(self, props):
82 _, surpress_handler, h = self._get_type_requested_handle(props)
84 _moduleLogger.debug('New file transfer channel')
85 chan = channel.debug_log.DebugLogChannel(self._conn, self, props, h)
88 def _get_media_channel(self, props):
89 _, surpress_handler, h = self._get_type_requested_handle(props)
91 _moduleLogger.debug('New media channel')
92 chan = channel.call.CallChannel(self._conn, self, props, h)