Adding support for coroutines for async ops through trampolines
[theonering] / hand_tests / params.py
1 #!/usr/bin/env python
2
3 import gobject
4 import dbus.mainloop.glib
5 dbus.mainloop.glib.DBusGMainLoop(set_as_default = True)
6
7 import telepathy
8 from telepathy.interfaces import CONN_MGR_INTERFACE
9 from telepathy.constants import CONN_MGR_PARAM_FLAG_DBUS_PROPERTY, \
10                                                                 CONN_MGR_PARAM_FLAG_HAS_DEFAULT, \
11                                                                 CONN_MGR_PARAM_FLAG_REGISTER, \
12                                                                 CONN_MGR_PARAM_FLAG_REQUIRED, \
13                                                                 CONN_MGR_PARAM_FLAG_SECRET
14
15 def print_params (params):
16         for name, flags, signature, default in params:
17                 print "%s (%s)" % (name, signature),
18
19                 if flags & CONN_MGR_PARAM_FLAG_REQUIRED: print "required",
20                 if flags & CONN_MGR_PARAM_FLAG_REGISTER: print "register",
21                 if flags & CONN_MGR_PARAM_FLAG_SECRET: print "secret",
22                 if flags & CONN_MGR_PARAM_FLAG_DBUS_PROPERTY: print "dbus-property",
23                 if flags & CONN_MGR_PARAM_FLAG_HAS_DEFAULT: print "has-default(%s)" % default,
24
25                 print ""
26
27         loop.quit ()
28
29 def error_cb (*args):
30         print "Error:", args
31         loop.quit ()
32
33
34 if __name__ == "__main__":
35         reg = telepathy.client.ManagerRegistry()
36         reg.LoadManagers()
37
38         # get the gabble Connection Manager
39         cm = reg.GetManager('theonering')
40
41         # get the parameters required to make a Jabber connection
42         cm[CONN_MGR_INTERFACE].GetParameters('gv',
43                 reply_handler = print_params, error_handler = error_cb)
44
45         loop = gobject.MainLoop()
46         loop.run()