diff options
author | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2008-05-08 13:08:24 (GMT) |
---|---|---|
committer | Morgan Collett <morgan.collett@gmail.com> | 2008-06-13 14:53:15 (GMT) |
commit | 35521aee4581dbd82ffea500a800570f5807937c (patch) | |
tree | c56b465bdb8c6f152a2deda80da72c47df7e527c | |
parent | dd73eee0a555a7b8eb798556da284b57c073e3f4 (diff) |
wait that the Connection is ready before use it
-rw-r--r-- | pippy_app.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/pippy_app.py b/pippy_app.py index 11aea7c..4eba9a2 100644 --- a/pippy_app.py +++ b/pippy_app.py @@ -33,7 +33,7 @@ from sugar.graphics.xocolor import XoColor from sugar.graphics.palette import Palette, CanvasInvoker from sugar.graphics.menuitem import MenuItem -from telepathy.client import Connection +from telepathy.client import Connection, Channel from telepathy.interfaces import ( CHANNEL_INTERFACE_GROUP, CHANNEL_TYPE_TEXT, CONN_INTERFACE_ALIASING) @@ -92,13 +92,15 @@ class Chat(ViewSourceActivity): def _one_to_one_connection(self, tp_channel): """Handle a private invite from a non-Sugar XMPP client.""" - from telepathy.client import Channel if self._shared_activity or self.text_channel: return bus_name, connection, channel = json.read(tp_channel) logger.debug('GOT XMPP: %s %s %s', bus_name, connection, channel) # XXX - conn = Connection(bus_name, connection) + conn = Connection(bus_name, connection, ready_handler=lambda conn: \ + self._connection_ready_cb(bus_name, channel, conn)) + + def _connection_ready_cb(self, bus_name, channel, conn): text_channel = Channel(bus_name, channel) self.text_channel = TextChannelWrapper(text_channel, conn) self.text_channel.set_received_callback(self._received_cb) |