fso-listen-for-calls.py: use SetFunctionality
[fso-scripts.git] / fso-auth.py
1 #!/usr/bin/env python
2
3 import sys
4 import dbus
5
6 def fso_auth(pin):
7     bus = dbus.SystemBus()
8
9     usage_obj = bus.get_object("org.freesmartphone.ousaged", "/org/freesmartphone/Usage")
10     usage_iface = dbus.Interface(usage_obj, "org.freesmartphone.Usage")
11     usage_iface.RequestResource("GSM")
12
13     gsm_device_obj = bus.get_object("org.freesmartphone.ogsmd", "/org/freesmartphone/GSM/Device")
14     gsm_sim_iface = dbus.Interface(gsm_device_obj, "org.freesmartphone.GSM.SIM")
15
16     if gsm_sim_iface.GetAuthStatus()  == 'SIM PIN':
17         gsm_sim_iface.SendAuthCode(pin)
18         if gsm_sim_iface.GetAuthStatus() == 'READY':
19             print "OK"
20
21     usage_iface.ReleaseResource("GSM")
22
23 if __name__ == "__main__":
24
25     if len(sys.argv) != 2:
26         sys.stderr.write("usage: %s <pin>\n")
27         sys.exit(1)
28
29     pin = sys.argv[1]
30     fso_auth(pin)