diff options
author | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2007-10-01 16:00:52 +0000 |
---|---|---|
committer | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2007-10-01 16:00:52 +0000 |
commit | d3a154a890c76cdb9fc9a817b79cefb7b2eeea15 (patch) | |
tree | 4f051d0120bb78b3101d857b1525320b17aef147 | |
parent | 25ea34b357a711de691e063e0a392b924d0c5fad (diff) |
move muc and private tubes client specific class to tube-stream-{muc,private}.py
-rw-r--r-- | examples/stream_tube_client.py | 50 | ||||
-rw-r--r-- | examples/tube-stream-muc.py | 25 | ||||
-rw-r--r-- | examples/tube-stream-private.py | 36 |
3 files changed, 57 insertions, 54 deletions
diff --git a/examples/stream_tube_client.py b/examples/stream_tube_client.py index d2a003b..c114ff0 100644 --- a/examples/stream_tube_client.py +++ b/examples/stream_tube_client.py @@ -160,36 +160,6 @@ class StreamTubeInitiatorClient(StreamTubeClient): params, SOCKET_ADDRESS_TYPE_UNIX, dbus.ByteArray(self.socket_path), SOCKET_ACCESS_CONTROL_LOCALHOST, "") -class StreamTubeInitiatorMucClient(StreamTubeInitiatorClient): - def __init__(self, account_file, muc_id, socket_path=None): - StreamTubeInitiatorClient.__init__(self, account_file, muc_id, None, socket_path) - - def connected_cb(self): - StreamTubeInitiatorClient.connected_cb(self) - - self.join_muc() - self.offer_tube() - -class StreamTubeInitiatorPrivateClient(StreamTubeInitiatorClient): - def __init__(self, account_file, contact_id, socket_path=None): - StreamTubeInitiatorClient.__init__(self, account_file, None, contact_id, socket_path) - - def connected_cb(self): - StreamTubeInitiatorClient.connected_cb(self) - - self.tubes_with_contact() - self.offer_tube() - - def tubes_with_contact(self): - handle = self.conn[CONN_INTERFACE].RequestHandles( - CONNECTION_HANDLE_TYPE_CONTACT, [self.contact_id])[0] - - chan_path = self.conn[CONN_INTERFACE].RequestChannel( - CHANNEL_TYPE_TUBES, CONNECTION_HANDLE_TYPE_CONTACT, - handle, True) - self.channel_tubes = Channel(self.conn.dbus_proxy.bus_name, chan_path) - - class StreamTubeJoinerClient(StreamTubeClient): def __init__(self, account_file, muc_id, contact_id, connect_trivial_client): StreamTubeClient.__init__(self, account_file, muc_id, contact_id) @@ -219,26 +189,6 @@ class StreamTubeJoinerClient(StreamTubeClient): self.client = TrivialStreamClient(address) self.client.connect() -class StreamTubeJoinerMucClient(StreamTubeJoinerClient): - def __init__(self, account_file, muc_id, connect_trivial_client): - StreamTubeJoinerClient.__init__(self, account_file, muc_id, None, - connect_trivial_client) - - def connected_cb(self): - StreamTubeJoinerClient.connected_cb(self) - - self.join_muc() - -class StreamTubeJoinerPrivateClient(StreamTubeJoinerClient): - def __init__(self, account_file, connect_trivial_client): - StreamTubeJoinerClient.__init__(self, account_file, None, None, - connect_trivial_client) - - def connected_cb(self): - StreamTubeJoinerClient.connected_cb(self) - - print "waiting for a tube offer from contacts" - class TrivialStream: def __init__(self, socket_path): self.socket_path = socket_path diff --git a/examples/tube-stream-muc.py b/examples/tube-stream-muc.py index 1a158ae..2175a63 100644 --- a/examples/tube-stream-muc.py +++ b/examples/tube-stream-muc.py @@ -1,7 +1,28 @@ import sys -from stream_tube_client import StreamTubeJoinerMucClient, \ - StreamTubeInitiatorMucClient +from stream_tube_client import StreamTubeJoinerClient, \ + StreamTubeInitiatorClient + +class StreamTubeInitiatorMucClient(StreamTubeInitiatorClient): + def __init__(self, account_file, muc_id, socket_path=None): + StreamTubeInitiatorClient.__init__(self, account_file, muc_id, None, socket_path) + + def connected_cb(self): + StreamTubeInitiatorClient.connected_cb(self) + + self.join_muc() + self.offer_tube() + +class StreamTubeJoinerMucClient(StreamTubeJoinerClient): + def __init__(self, account_file, muc_id, connect_trivial_client): + StreamTubeJoinerClient.__init__(self, account_file, muc_id, None, + connect_trivial_client) + + def connected_cb(self): + StreamTubeJoinerClient.connected_cb(self) + + self.join_muc() + def usage(): print "Usage:\n" \ diff --git a/examples/tube-stream-private.py b/examples/tube-stream-private.py index a1f9cf2..5328bfe 100644 --- a/examples/tube-stream-private.py +++ b/examples/tube-stream-private.py @@ -1,7 +1,39 @@ import sys +from telepathy.client import (Connection, Channel) +from telepathy.interfaces import (CONN_INTERFACE, CHANNEL_TYPE_TUBES) +from telepathy.constants import (CONNECTION_HANDLE_TYPE_CONTACT) -from stream_tube_client import StreamTubeJoinerPrivateClient, \ - StreamTubeInitiatorPrivateClient +from stream_tube_client import StreamTubeJoinerClient, \ + StreamTubeInitiatorClient + +class StreamTubeInitiatorPrivateClient(StreamTubeInitiatorClient): + def __init__(self, account_file, contact_id, socket_path=None): + StreamTubeInitiatorClient.__init__(self, account_file, None, contact_id, socket_path) + + def connected_cb(self): + StreamTubeInitiatorClient.connected_cb(self) + + self.tubes_with_contact() + self.offer_tube() + + def tubes_with_contact(self): + handle = self.conn[CONN_INTERFACE].RequestHandles( + CONNECTION_HANDLE_TYPE_CONTACT, [self.contact_id])[0] + + chan_path = self.conn[CONN_INTERFACE].RequestChannel( + CHANNEL_TYPE_TUBES, CONNECTION_HANDLE_TYPE_CONTACT, + handle, True) + self.channel_tubes = Channel(self.conn.dbus_proxy.bus_name, chan_path) + +class StreamTubeJoinerPrivateClient(StreamTubeJoinerClient): + def __init__(self, account_file, connect_trivial_client): + StreamTubeJoinerClient.__init__(self, account_file, None, None, + connect_trivial_client) + + def connected_cb(self): + StreamTubeJoinerClient.connected_cb(self) + + print "waiting for a tube offer from contacts" def usage(): print "Usage:\n" \ |