Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2009-04-16 10:00:27 (GMT)
committer Guillaume Desmottes <guillaume.desmottes@collabora.co.uk>2009-04-16 10:43:17 (GMT)
commit0f22a40ee65ae6b886cdeb4de68b2780579bc169 (patch)
treeebb1eb22cb80ab0d31ac6e388005968bb426cf1d
parentd2d2ba1338dc92b94c6e8de48cd5e11d2c8391a2 (diff)
make AcceptStreamTube asynctube-new-api
-rw-r--r--readactivity.py49
1 files changed, 28 insertions, 21 deletions
diff --git a/readactivity.py b/readactivity.py
index 5714ae8..8e8b09c 100644
--- a/readactivity.py
+++ b/readactivity.py
@@ -400,29 +400,36 @@ class ReadActivity(activity.Activity):
conn = self.shared_activity.telepathy_conn
tube_chan = Channel(conn.dbus_proxy.bus_name, tube_path)
- # FIXME: async
+ def accept_stream_tube_reply_cb(addr):
+ _logger.debug('Accepted stream tube: listening address is %r', addr)
+
+ # SOCKET_ADDRESS_TYPE_IPV4 is defined to have addresses of type '(sq)'
+ assert isinstance(addr, dbus.Struct)
+ assert len(addr) == 2
+ assert isinstance(addr[0], str)
+ assert isinstance(addr[1], (int, long))
+ assert addr[1] > 0 and addr[1] < 65536
+ port = int(addr[1])
+
+ getter = ReadURLDownloader("http://%s:%d/document"
+ % (addr[0], port))
+ getter.connect("finished", self._download_result_cb, tube_path)
+ getter.connect("progress", self._download_progress_cb, tube_path)
+ getter.connect("error", self._download_error_cb, tube_path)
+ _logger.debug("Starting download to %s...", path)
+ getter.start(path)
+ self._download_content_length = getter.get_content_length()
+ self._download_content_type = getter.get_content_type()
+
+ def accept_stream_tube_error_cb(e):
+ _logger.error('OfferStreamTube failed: %s' % e)
+
addr = tube_chan[CHANNEL_TYPE_STREAM_TUBE].AcceptStreamTube(
SOCKET_ADDRESS_TYPE_IPV4, SOCKET_ACCESS_CONTROL_LOCALHOST, 0,
- utf8_strings=True)
- _logger.debug('Accepted stream tube: listening address is %r', addr)
-
- # SOCKET_ADDRESS_TYPE_IPV4 is defined to have addresses of type '(sq)'
- assert isinstance(addr, dbus.Struct)
- assert len(addr) == 2
- assert isinstance(addr[0], str)
- assert isinstance(addr[1], (int, long))
- assert addr[1] > 0 and addr[1] < 65536
- port = int(addr[1])
-
- getter = ReadURLDownloader("http://%s:%d/document"
- % (addr[0], port))
- getter.connect("finished", self._download_result_cb, tube_path)
- getter.connect("progress", self._download_progress_cb, tube_path)
- getter.connect("error", self._download_error_cb, tube_path)
- _logger.debug("Starting download to %s...", path)
- getter.start(path)
- self._download_content_length = getter.get_content_length()
- self._download_content_type = getter.get_content_type()
+ utf8_strings=True,
+ reply_handler=accept_stream_tube_reply_cb,
+ error_handler=accept_stream_tube_error_cb)
+
return False
def _get_document(self):