4 from pprint import pprint
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
9 """Hack to unwrap D-Bus values, so that they're easier to read when
12 if isinstance(x, list):
15 if isinstance(x, tuple):
16 return tuple(map(unwrap, x))
18 if isinstance(x, dict):
19 return dict([(unwrap(k), unwrap(v)) for k, v in x.iteritems()])
21 if isinstance(x, dbus.Boolean):
24 for t in [unicode, str, long, int, float]:
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")
37 gsm_device_obj = bus.get_object("org.freesmartphone.ogsmd", "/org/freesmartphone/GSM/Device")
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")
44 info = gsm_info_iface.GetInfo()
48 device_status = gsm_device_iface.GetDeviceStatus()
49 pprint(unwrap(device_status))
52 features = gsm_device_iface.GetFeatures()
53 pprint(unwrap(features))
56 functionality = gsm_device_iface.GetFunctionality()
57 pprint(unwrap(functionality))
60 auth_code = gsm_sim_iface.GetAuthCodeRequired()
61 pprint(unwrap(auth_code))
64 auth_status = gsm_sim_iface.GetAuthStatus()
65 pprint(unwrap(auth_status))
68 service_center = gsm_sim_iface.GetServiceCenterNumber()
69 pprint(unwrap(service_center))
72 sim_info = gsm_sim_iface.GetSimInfo()
73 pprint(unwrap(sim_info))
76 net_status = gsm_network_iface.GetStatus()
77 pprint(unwrap(net_status))
80 usage_iface.ReleaseResource("GSM")
82 if __name__ == "__main__":