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