diff options
author | Jonny Lamb <jonny.lamb@collabora.co.uk> | 2010-03-08 15:40:52 +0000 |
---|---|---|
committer | Olivier Le Thanh Duong <olivier@lethanh.be> | 2010-03-09 15:28:11 +0100 |
commit | 279a118d68a734b828f0226b2202d795883a1a71 (patch) | |
tree | 33fdb8eebc5c798424783e50643426b97789b8cc /src | |
parent | b369206860bbf09ca8d211024841939aefc45d2f (diff) |
channel: add named parameter "object_path" to Channel, and similar for its child classes
Use this parameter as the object path suffix when given, as opposed to
just /channelN.
Signed-off-by: Jonny Lamb <jonny.lamb@collabora.co.uk>
Diffstat (limited to 'src')
-rw-r--r-- | src/server/channel.py | 30 | ||||
-rw-r--r-- | src/server/conn.py | 9 |
2 files changed, 24 insertions, 15 deletions
diff --git a/src/server/channel.py b/src/server/channel.py index 52e750a..ed83ee3 100644 --- a/src/server/channel.py +++ b/src/server/channel.py @@ -44,7 +44,7 @@ from telepathy.server.properties import DBusProperties class Channel(_Channel, DBusProperties): - def __init__(self, connection, manager, props): + def __init__(self, connection, manager, props, object_path=None): """ Initialise the base channel object. @@ -54,7 +54,8 @@ class Channel(_Channel, DBusProperties): """ self._conn = connection self._chan_manager = manager - object_path = self._conn.get_channel_path() + + object_path = self._conn.get_channel_path(object_path) _Channel.__init__(self, self._conn._name, object_path) self._type = props[CHANNEL_INTERFACE + '.ChannelType'] @@ -144,14 +145,15 @@ from telepathy._generated.Channel_Type_Contact_List \ class ChannelTypeContactList(Channel, _ChannelTypeContactListIface): __doc__ = _ChannelTypeContactListIface.__doc__ - def __init__(self, connection, manager, props): + def __init__(self, connection, manager, props, object_path=None): """ Initialise the channel. Parameters: connection - the parent Telepathy Connection object """ - Channel.__init__(self, connection, manager, props) + Channel.__init__(self, connection, manager, props, + object_path=object_path) from telepathy._generated.Channel_Type_File_Transfer \ @@ -160,14 +162,15 @@ from telepathy._generated.Channel_Type_File_Transfer \ class ChannelTypeFileTransfer(Channel, _ChannelTypeFileTransferIface): __doc__ = _ChannelTypeFileTransferIface.__doc__ - def __init__(self, connection, manager, props): + def __init__(self, connection, manager, props, object_path=None): """ Initialise the channel. Parameters: connection - the parent Telepathy Connection object """ - Channel.__init__(self, connection, manager, props) + Channel.__init__(self, connection, manager, props, + object_path=object_path) from telepathy._generated.Channel_Type_Streamed_Media \ @@ -176,14 +179,15 @@ from telepathy._generated.Channel_Type_Streamed_Media \ class ChannelTypeStreamedMedia(Channel, _ChannelTypeStreamedMediaIface): __doc__ = _ChannelTypeStreamedMediaIface.__doc__ - def __init__(self, connection, manager, props): + def __init__(self, connection, manager, props, object_path=None): """ Initialise the channel. Parameters: connection - the parent Telepathy Connection object """ - Channel.__init__(self, connection, manager, props) + Channel.__init__(self, connection, manager, props, + object_path=object_path) from telepathy._generated.Channel_Type_Room_List \ @@ -192,14 +196,15 @@ from telepathy._generated.Channel_Type_Room_List \ class ChannelTypeRoomList(Channel, _ChannelTypeRoomListIface): __doc__ = _ChannelTypeRoomListIface.__doc__ - def __init__(self, connection, manager, props): + def __init__(self, connection, manager, props, object_path=None): """ Initialise the channel. Parameters: connection - the parent Telepathy Connection object """ - Channel.__init__(self, connection, manager, props) + Channel.__init__(self, connection, manager, props, + object_path=object_path) self._listing_rooms = False self._rooms = {} @@ -220,14 +225,15 @@ from telepathy._generated.Channel_Type_Text \ class ChannelTypeText(Channel, _ChannelTypeTextIface): __doc__ = _ChannelTypeTextIface.__doc__ - def __init__(self, connection, manager, props): + def __init__(self, connection, manager, props, object_path=None): """ Initialise the channel. Parameters: connection - the parent Telepathy Connection object """ - Channel.__init__(self, connection, manager, props) + Channel.__init__(self, connection, manager, props, + object_path=object_path) self._pending_messages = {} self._message_types = [CHANNEL_TEXT_MESSAGE_TYPE_NORMAL] diff --git a/src/server/conn.py b/src/server/conn.py index 979641a..54fbb82 100644 --- a/src/server/conn.py +++ b/src/server/conn.py @@ -178,9 +178,12 @@ class Connection(_Connection, DBusProperties): def set_self_handle(self, handle): self._self_handle = handle - def get_channel_path(self): - ret = '%s/channel%d' % (self._object_path, self._next_channel_id) - self._next_channel_id += 1 + def get_channel_path(self, suffix): + if not suffix: + ret = '%s/channel%d' % (self._object_path, self._next_channel_id) + self._next_channel_id += 1 + else: + ret = '%s/%s' % (self._object_path, suffix) return ret def add_channels(self, channels, signal=True): |