diff options
author | Guillaume Desmottes <cassidy@cass-wks.(none)> | 2007-04-16 16:01:41 (GMT) |
---|---|---|
committer | Guillaume Desmottes <cassidy@cass-wks.(none)> | 2007-04-16 16:01:41 (GMT) |
commit | fd7816aa914860da6c8482d58dca577af96bab18 (patch) | |
tree | f337aab04a097d663f06a0157ca7b45e3ff42cc5 /chat.py | |
parent | a4797fcd78aa8a1086a50d5647d55b46c487e6cd (diff) |
catch connection status changes
Diffstat (limited to 'chat.py')
-rw-r--r-- | chat.py | 14 |
1 files changed, 6 insertions, 8 deletions
@@ -73,23 +73,17 @@ class Chat(Activity): bus = dbus.Bus() name, path = pservice.get_preferred_connection() conn = Connection(name, path) - #conn[CONN_INTERFACE].('StatusChanged', self.status_changed_cb) + conn[CONN_INTERFACE].connect_to_signal('StatusChanged', self.status_changed_cb) self.conn = conn self.conn_name = name self.chan = None - self.connect('destroy', self.destroy_cb) - status = conn[CONN_INTERFACE].GetStatus() if status == CONNECTION_STATUS_CONNECTED: print "connected" self.join_room () - - def destroy_cb(self, _): - print 'destroy' - def received_cb(self, id, timestamp, sender, type, flags, text): try: # XXX: Shoule use PS instead of directly use TP @@ -126,10 +120,12 @@ class Chat(Activity): def status_changed_cb(self, status, reason): - if status == CONNECTION_STATUS_CONNECTED: + if status == CONNECTION_STATUS_CONNECTED and not self.chan: self.join_room() elif status == CONNECTION_STATUS_DISCONNECTED: print 'disconnected' + self.chan.Close() + self.chan = None def make_root(self): text = hippo.CanvasText( @@ -141,6 +137,8 @@ class Chat(Activity): self.conversation = conversation entry = Entry(padding=5) + # XXX make this entry unsensitive while we're not + # connected. entry.connect('activated', self.entry_activated_cb) hbox = hippo.CanvasBox(orientation=hippo.ORIENTATION_HORIZONTAL) |