summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorJonny Lamb <jonny.lamb@collabora.co.uk>2009-01-07 17:23:16 +0000
committerJonny Lamb <jonny.lamb@collabora.co.uk>2009-01-07 17:23:16 +0000
commit2f5c89afb31bfc71146c61af5e76c383483e96c0 (patch)
tree2fee75ab754e746107c7d750468e1a77cc3c3b4d /examples
parentbdaad6a28ec9627a63bd6c48abd89c8f3c0636fb (diff)
Added a timeout to make sure contacts are ready before sending messages.
Signed-off-by: Jonny Lamb <jonny.lamb@collabora.co.uk>
Diffstat (limited to 'examples')
-rw-r--r--examples/requests-message.py22
1 files changed, 13 insertions, 9 deletions
diff --git a/examples/requests-message.py b/examples/requests-message.py
index 90a9708..1952d6d 100644
--- a/examples/requests-message.py
+++ b/examples/requests-message.py
@@ -34,6 +34,7 @@ class Message:
self.conn[CONN_INTERFACE].Connect()
def ready_cb(self, conn):
+ print "connected"
conn[CONNECTION_INTERFACE_REQUESTS].connect_to_signal('NewChannels',
self.new_channels_cb)
@@ -41,17 +42,20 @@ class Message:
conn[CONNECTION_INTERFACE_SIMPLE_PRESENCE].SetPresence('available', '')
if self.contact is not None:
- handle = self.conn[CONN_INTERFACE].RequestHandles(
- CONNECTION_HANDLE_TYPE_CONTACT, [self.contact])[0]
+ gobject.timeout_add(1000, self.send_message)
- print 'got handle %d for %s' % (handle, self.contact)
+ def send_message(self):
+ handle = self.conn[CONN_INTERFACE].RequestHandles(
+ CONNECTION_HANDLE_TYPE_CONTACT, [self.contact])[0]
- self.conn[CONNECTION_INTERFACE_REQUESTS].CreateChannel(dbus.Dictionary(
- {
- CHANNEL_INTERFACE + '.ChannelType': CHANNEL_TYPE_TEXT,
- CHANNEL_INTERFACE + '.TargetHandleType': CONNECTION_HANDLE_TYPE_CONTACT,
- CHANNEL_INTERFACE + '.TargetHandle': handle
- }, signature='sv'))
+ print 'got handle %d for %s' % (handle, self.contact)
+
+ self.conn[CONNECTION_INTERFACE_REQUESTS].CreateChannel(dbus.Dictionary(
+ {
+ CHANNEL_INTERFACE + '.ChannelType': CHANNEL_TYPE_TEXT,
+ CHANNEL_INTERFACE + '.TargetHandleType': CONNECTION_HANDLE_TYPE_CONTACT,
+ CHANNEL_INTERFACE + '.TargetHandle': handle
+ }, signature='sv'))
def run(self):
print "main loop running"