/usr/share/doc/python-telepathy/examples/tube-stream-muc.py is in python-telepathy 0.15.19-2.1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | import sys
import dbus
from telepathy.constants import CONNECTION_HANDLE_TYPE_ROOM
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 ready_cb(self, conn):
StreamTubeInitiatorClient.ready_cb(self, conn)
self.join_muc()
def muc_joined(self):
StreamTubeInitiatorClient.muc_joined(self)
print "muc joined. Create the tube"
self.create_tube(CONNECTION_HANDLE_TYPE_ROOM, self.muc_id)
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 ready_cb(self, conn):
StreamTubeJoinerClient.ready_cb(self, conn)
self.join_muc()
def usage():
print "Usage:\n" \
"Offer a stream tube to [muc] using the trivial stream server:\n" \
"\tpython %s [account-file] [muc] --initiator\n" \
"Accept a stream tube from [muc] and connect it to the trivial stream client:\n" \
"\tpython %s [account-file] [muc]\n" \
"Offer a stream tube to [muc] using the socket [IP]:[port]:\n" \
"\tpython %s [account-file] [muc] [IP] [port]\n" \
"Accept a stream tube from [muc] and wait for connections from an external client:\n" \
"\tpython %s [account-file] [muc] --no-trivial-client\n" \
% (sys.argv[0], sys.argv[0], sys.argv[0], sys.argv[0])
if __name__ == '__main__':
args = sys.argv[1:]
if len(args) == 3 and args[2] == '--initiator':
client = StreamTubeInitiatorMucClient(args[0], args[1])
elif len(args) == 2:
client = StreamTubeJoinerMucClient(args[0], args[1], True)
elif len(args) == 4:
client = StreamTubeInitiatorMucClient(args[0], args[1], (args[2], dbus.UInt16(args[3])))
elif len(args) == 3 and args[2] == '--no-trivial-client':
client = StreamTubeJoinerMucClient(args[0], args[1], False)
else:
usage()
sys.exit(0)
client.run()
|