fso-auth.py: quit the loop after network registration
[fso-scripts.git] / fso-make-call.py
1 #!/usr/bin/env python
2
3 import sys
4 import time
5 import dbus
6
7 from dbus.mainloop.glib import DBusGMainLoop
8 DBusGMainLoop(set_as_default=True)
9
10 def onCallStatus(sender = "", *args, **kwargs):
11     status = str(args[0])
12     if (args[1].has_key("peer")):
13         caller = str(args[1]["peer"])
14     else:
15         caller = "unknown"
16
17     print "onCallStatus"
18     print sender
19     print status
20     print caller
21     print
22
23 def fso_dial(number):
24     bus = dbus.SystemBus()
25
26     usage_obj = bus.get_object("org.freesmartphone.ousaged", "/org/freesmartphone/Usage")
27     usage_iface = dbus.Interface(usage_obj, "org.freesmartphone.Usage")
28     usage_iface.RequestResource("GSM")
29
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")
32     gsm_call_iface = dbus.Interface(gsm_device_obj, "org.freesmartphone.GSM.Call")
33
34     print "Set Functionality: full"
35     gsm_device_iface.SetFunctionality("full", True, "")
36
37     gsm_call_iface.connect_to_signal('CallStatus', onCallStatus)
38
39     id = gsm_call_iface.Initiate(number, "voice")
40     print "Call id:", id
41     time.sleep(30)
42     gsm_call_iface.Release(id)
43
44     gsm_device_iface.SetFunctionality("minimal", True, "")
45     usage_iface.ReleaseResource("GSM")
46
47 if __name__ == "__main__":
48
49     if len(sys.argv) != 2:
50         sys.stderr.write("usage: %s <number>\n")
51         sys.exit(1)
52
53     number = sys.argv[1]
54     fso_dial(number)