X-Git-Url: http://git.maemo.org/git/?p=theonering;a=blobdiff_plain;f=src%2Fchannel_manager.py;h=1f732e177b8efe76010300c189276e2ed60b27fc;hp=bce767ba9a8bf75521918479fc6180de18e6e87e;hb=4f32f7a5b10392a945a30f48891a5828af8b5395;hpb=54fb3d0f7f39e6446e1771cc29483a4d6138f8dd diff --git a/src/channel_manager.py b/src/channel_manager.py index bce767b..1f732e1 100644 --- a/src/channel_manager.py +++ b/src/channel_manager.py @@ -5,10 +5,10 @@ import telepathy import tp import channel -import util.misc as util_misc +import util.misc as misc_utils -_moduleLogger = logging.getLogger("channel_manager") +_moduleLogger = logging.getLogger(__name__) class ChannelManager(tp.ChannelManager): @@ -16,36 +16,78 @@ class ChannelManager(tp.ChannelManager): def __init__(self, connection): tp.ChannelManager.__init__(self, connection) - fixed = { - telepathy.CHANNEL_INTERFACE + '.ChannelType': telepathy.CHANNEL_TYPE_TEXT, - telepathy.CHANNEL_INTERFACE + '.TargetHandleType': dbus.UInt32(telepathy.HANDLE_TYPE_CONTACT) - } - self._implement_channel_class( + classes = [ + ( + { + telepathy.CHANNEL_INTERFACE + '.ChannelType': telepathy.CHANNEL_TYPE_CONTACT_LIST, + telepathy.CHANNEL_INTERFACE + '.TargetHandleType': dbus.UInt32(telepathy.HANDLE_TYPE_LIST), + }, + [ + telepathy.CHANNEL_INTERFACE + '.TargetHandle', + telepathy.CHANNEL_INTERFACE + '.TargetID', + ], + ), + ] + self.implement_channel_classes( + telepathy.CHANNEL_TYPE_CONTACT_LIST, + self._get_list_channel, + classes, + ) + + classes = [ + ( + { + telepathy.CHANNEL_INTERFACE + '.ChannelType': telepathy.CHANNEL_TYPE_TEXT, + telepathy.CHANNEL_INTERFACE + '.TargetHandleType': dbus.UInt32(telepathy.HANDLE_TYPE_CONTACT) + }, + [ + telepathy.CHANNEL_INTERFACE + '.TargetHandle', + telepathy.CHANNEL_INTERFACE + '.TargetID', + ], + ), + ] + self.implement_channel_classes( telepathy.CHANNEL_TYPE_TEXT, self._get_text_channel, - fixed, - [] + classes, ) - fixed = { - telepathy.CHANNEL_INTERFACE + '.ChannelType': telepathy.CHANNEL_TYPE_CONTACT_LIST - } - self._implement_channel_class( - telepathy.CHANNEL_TYPE_CONTACT_LIST, - self._get_list_channel, - fixed, - [] + classes = [ + ( + { + telepathy.CHANNEL_INTERFACE + '.ChannelType': telepathy.CHANNEL_TYPE_FILE_TRANSFER, + telepathy.CHANNEL_INTERFACE + '.TargetHandleType': dbus.UInt32(telepathy.HANDLE_TYPE_CONTACT) + }, + [ + telepathy.CHANNEL_INTERFACE + '.TargetHandle', + telepathy.CHANNEL_INTERFACE + '.TargetID', + ], + ), + ] + self.implement_channel_classes( + telepathy.CHANNEL_TYPE_FILE_TRANSFER, + self._get_file_transfer_channel, + classes, ) - fixed = { - telepathy.CHANNEL_INTERFACE + '.ChannelType': telepathy.CHANNEL_TYPE_STREAMED_MEDIA, - telepathy.CHANNEL_INTERFACE + '.TargetHandleType': dbus.UInt32(telepathy.HANDLE_TYPE_CONTACT) - } - self._implement_channel_class( + classes = [ + ( + { + telepathy.CHANNEL_INTERFACE + '.ChannelType': telepathy.CHANNEL_TYPE_STREAMED_MEDIA, + telepathy.CHANNEL_INTERFACE + '.TargetHandleType': dbus.UInt32(telepathy.HANDLE_TYPE_CONTACT) + }, + [ + telepathy.CHANNEL_INTERFACE + '.TargetHandle', + telepathy.CHANNEL_INTERFACE + '.TargetID', + telepathy.CHANNEL_TYPE_STREAMED_MEDIA + '.InitialAudio', + telepathy.CHANNEL_TYPE_STREAMED_MEDIA + '.InitialVideo', + ], + ), + ] + self.implement_channel_classes( telepathy.CHANNEL_TYPE_STREAMED_MEDIA, self._get_media_channel, - fixed, - [telepathy.CHANNEL_INTERFACE + '.TargetHandle'] + classes, ) def _get_list_channel(self, props): @@ -58,7 +100,7 @@ class ChannelManager(tp.ChannelManager): def _get_text_channel(self, props): _, surpress_handler, h = self._get_type_requested_handle(props) - accountNumber = util_misc.normalize_number(self._conn.session.backend.get_account_number()) + accountNumber = misc_utils.normalize_number(self._conn.session.backend.get_account_number()) if h.phoneNumber == accountNumber: _moduleLogger.debug('New Debug channel') chan = channel.debug_prompt.DebugPromptChannel(self._conn, self, props, h) @@ -67,6 +109,13 @@ class ChannelManager(tp.ChannelManager): chan = channel.text.TextChannel(self._conn, self, props, h) return chan + def _get_file_transfer_channel(self, props): + _, surpress_handler, h = self._get_type_requested_handle(props) + + _moduleLogger.debug('New file transfer channel') + chan = channel.debug_log.DebugLogChannel(self._conn, self, props, h) + return chan + def _get_media_channel(self, props): _, surpress_handler, h = self._get_type_requested_handle(props)