[telepathy-python/master] Add create_channel helper method to client.Connection.
Jonny Lamb
jonny.lamb at collabora.co.uk
Wed Jul 15 05:03:14 PDT 2009
Signed-off-by: Jonny Lamb <jonny.lamb at collabora.co.uk>
---
examples/message.py | 12 +++---------
src/client/conn.py | 8 +++++++-
2 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/examples/message.py b/examples/message.py
index ca009b4..f6461ff 100644
--- a/examples/message.py
+++ b/examples/message.py
@@ -12,8 +12,7 @@ from telepathy.constants import (
CONNECTION_HANDLE_TYPE_CONTACT, CONNECTION_STATUS_CONNECTED,
CHANNEL_TEXT_MESSAGE_TYPE_NORMAL)
from telepathy.interfaces import (
- CHANNEL_TYPE_TEXT, CONN_INTERFACE, CHANNEL_INTERFACE,
- CONNECTION_INTERFACE_REQUESTS, CONNECTION_INTERFACE_SIMPLE_PRESENCE)
+ CHANNEL_TYPE_TEXT, CONN_INTERFACE, CHANNEL_INTERFACE)
logging.basicConfig()
@@ -41,18 +40,13 @@ class Message:
print 'got handle %d for %s' % (handle, self.contact)
- object_path, props = self.conn[CONNECTION_INTERFACE_REQUESTS].CreateChannel(dbus.Dictionary(
- {
+ channel = self.conn.create_channel(dbus.Dictionary({
CHANNEL_INTERFACE + '.ChannelType': CHANNEL_TYPE_TEXT,
CHANNEL_INTERFACE + '.TargetHandleType': CONNECTION_HANDLE_TYPE_CONTACT,
CHANNEL_INTERFACE + '.TargetHandle': handle
}, signature='sv'))
- handle_type = props[CHANNEL_INTERFACE + '.TargetHandleType']
- handle = props[CHANNEL_INTERFACE + '.TargetHandle']
-
- print 'got text channel with handle (%d,%d)' % (handle_type, handle)
- channel = Channel(self.conn.service_name, object_path)
+ print 'got text channel with handle (%d,%d)' % (CONNECTION_HANDLE_TYPE_CONTACT, handle)
channel[CHANNEL_TYPE_TEXT].connect_to_signal('Sent', self.sent_cb)
channel[CHANNEL_TYPE_TEXT].connect_to_signal('Received', self.recvd_cb)
diff --git a/src/client/conn.py b/src/client/conn.py
index a37a11d..e46c3ea 100644
--- a/src/client/conn.py
+++ b/src/client/conn.py
@@ -22,9 +22,11 @@ import dbus
from telepathy.client.channel import Channel
from telepathy.client.interfacefactory import (
InterfaceFactory, default_error_handler)
-from telepathy.interfaces import CONN_INTERFACE
+from telepathy.interfaces import (
+ CONN_INTERFACE, CONNECTION_INTERFACE_REQUESTS)
from telepathy.constants import CONNECTION_STATUS_CONNECTED
+
class Connection(InterfaceFactory):
def __init__(self, service_name, object_path=None, bus=None,
ready_handler=None, error_handler=default_error_handler):
@@ -99,6 +101,10 @@ class Connection(InterfaceFactory):
path = self.RequestChannel(type, handle_type, handle, suppress_handler)
return Channel(self.service_name, path, self.bus)
+ def create_channel(self, props):
+ object_path, props = self[CONNECTION_INTERFACE_REQUESTS].CreateChannel(props)
+ return Channel(self.service_name, object_path, self.bus)
+
def call_when_ready(self, handler):
if self._ready:
handler(self)
--
1.5.6.5
More information about the telepathy-commits
mailing list