fso-listen-for-calls.py: use SetFunctionality
[fso-scripts.git] / fso-print-info.py
1 #!/usr/bin/env python
2
3 import dbus
4 from pprint import pprint
5
6 # Taken from telepathy-gabble:
7 # http://git.collabora.co.uk/?p=user/wjt/telepathy-gabble-wjt.git;a=blob;f=tests/twisted/servicetest.py;h=476c2e171dc7d535f70fa49827892a4cfb5d8402;hb=HEAD#l265
8 def unwrap(x):
9     """Hack to unwrap D-Bus values, so that they're easier to read when
10     printed."""
11
12     if isinstance(x, list):
13         return map(unwrap, x)
14
15     if isinstance(x, tuple):
16         return tuple(map(unwrap, x))
17
18     if isinstance(x, dict):
19         return dict([(unwrap(k), unwrap(v)) for k, v in x.iteritems()])
20
21     if isinstance(x, dbus.Boolean):
22         return bool(x)
23
24     for t in [unicode, str, long, int, float]:
25         if isinstance(x, t):
26             return t(x)
27
28     return x
29
30 def fso_print_info():
31     # Get proxies and add signal handlers
32     bus = dbus.SystemBus()
33     usage_obj = bus.get_object("org.freesmartphone.ousaged", "/org/freesmartphone/Usage")
34     usage_iface = dbus.Interface(usage_obj, "org.freesmartphone.Usage")
35     usage_iface.RequestResource("GSM")
36
37     gsm_device_obj = bus.get_object("org.freesmartphone.ogsmd", "/org/freesmartphone/GSM/Device")
38
39     gsm_info_iface = dbus.Interface(gsm_device_obj, "org.freesmartphone.Info")
40     gsm_device_iface = dbus.Interface(gsm_device_obj, "org.freesmartphone.GSM.Device")
41     gsm_sim_iface = dbus.Interface(gsm_device_obj, "org.freesmartphone.GSM.SIM")
42     gsm_network_iface = dbus.Interface(gsm_device_obj, "org.freesmartphone.GSM.Network")
43
44     info = gsm_info_iface.GetInfo()
45     pprint(unwrap(info))
46     print
47
48     device_status = gsm_device_iface.GetDeviceStatus()
49     pprint(unwrap(device_status))
50     print
51
52     features = gsm_device_iface.GetFeatures()
53     pprint(unwrap(features))
54     print
55
56     functionality = gsm_device_iface.GetFunctionality()
57     pprint(unwrap(functionality))
58     print
59
60     auth_code = gsm_sim_iface.GetAuthCodeRequired()
61     pprint(unwrap(auth_code))
62     print
63
64     auth_status = gsm_sim_iface.GetAuthStatus()
65     pprint(unwrap(auth_status))
66     print
67
68     service_center = gsm_sim_iface.GetServiceCenterNumber()
69     pprint(unwrap(service_center))
70     print
71
72     sim_info = gsm_sim_iface.GetSimInfo()
73     pprint(unwrap(sim_info))
74     print
75
76     net_status = gsm_network_iface.GetStatus()
77     pprint(unwrap(net_status))
78     print
79
80     usage_iface.ReleaseResource("GSM")
81
82 if __name__ == "__main__":
83     fso_print_info()