Adding support for coroutines for async ops through trampolines
[theonering] / hand_tests / hand_conic.py
1 #!/usr/bin/env python
2
3 import gtk
4 import conic
5
6
7 def on_connection_change(connection, event):
8         status = event.get_status()
9         error = event.get_error()
10         iap_id = event.get_iap_id()
11         bearer = event.get_bearer_type()
12         if status == conic.STATUS_DISCONNECTED:
13                 print "Disconnected"
14         elif status == conic.STATUS_DISCONNECTING:
15                 print "Disconnecting"
16         elif status == conic.STATUS_CONNECTED:
17                 print "Connected"
18         elif status == conic.STATUS_NETWORK_UP:
19                 print "Network Up"
20
21
22 if __name__ == "__main__":
23         connection = conic.Connection()
24         connectionEventId = connection.connect("connection-event", on_connection_change)
25         print connectionEventId
26         try:
27                 gtk.main()
28         except:
29                 connection.disconnect()
30                 raise