From 35521aee4581dbd82ffea500a800570f5807937c Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Thu, 08 May 2008 13:08:24 +0000 Subject: wait that the Connection is ready before use it --- 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) -- cgit v0.9.1