7 from dbus.mainloop.glib import DBusGMainLoop
8 DBusGMainLoop(set_as_default=True)
11 gsm_device_iface = None
12 loop = gobject.MainLoop()
14 def onDeviceStatus(status):
15 print "DeviceStatus:", status
16 if status == "alive-sim-locked":
17 gsm_device_iface.SetFunctionality("full", True, pin)
18 elif status == "alive-sim-ready":
22 global gsm_device_iface
25 bus = dbus.SystemBus()
27 usage_obj = bus.get_object("org.freesmartphone.ousaged", "/org/freesmartphone/Usage")
28 usage_iface = dbus.Interface(usage_obj, "org.freesmartphone.Usage")
30 gsm_device_obj = bus.get_object("org.freesmartphone.ogsmd", "/org/freesmartphone/GSM/Device")
31 gsm_device_iface = dbus.Interface(gsm_device_obj, "org.freesmartphone.GSM.Device")
33 gsm_device_iface.connect_to_signal('DeviceStatus', onDeviceStatus)
35 usage_iface.RequestResource("GSM")
37 print "starting the main loop"
40 except KeyboardInterrupt:
44 gsm_device_iface.SetFunctionality("minimal", True, "")
45 usage_iface.ReleaseResource("GSM")
47 if __name__ == "__main__":
49 if len(sys.argv) != 2:
50 sys.stderr.write("usage: %s <pin>\n")