Upgrade ofono to 1.2
[profile/ivi/ofono.git] / test / disable-call-forwarding
1 #!/usr/bin/python
2
3 import sys
4 import gobject
5
6 import dbus
7 import dbus.mainloop.glib
8
9 def property_changed(property, value):
10         if len(value.__str__()) > 0:
11                 print "CF property %s changed to %s" % (property, value)
12         else:
13                 print "CF property %s changed to disabled" % (property)
14
15         if canexit:
16                 mainloop.quit();
17
18 if __name__ == "__main__":
19         if len(sys.argv) < 2:
20                 print "Usage: %s <type>" % (sys.argv[0])
21                 print "Type can be: all, conditional"
22                 sys.exit(1)
23
24         canexit = False
25
26         type = sys.argv[1]
27
28         dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
29
30         bus = dbus.SystemBus()
31
32         manager = dbus.Interface(bus.get_object('org.ofono', '/'),
33                                                         'org.ofono.Manager')
34
35         modems = manager.GetModems()
36
37         cf = dbus.Interface(bus.get_object('org.ofono', modems[0][0]),
38                                 'org.ofono.CallForwarding')
39
40         cf.connect_to_signal("PropertyChanged", property_changed)
41
42         try:
43                 cf.DisableAll(type, timeout = 100)
44         except dbus.DBusException, e:
45                 print "Unable to DisableAll", e
46                 sys.exit(1);
47
48         print "DisableAll successful"
49
50         canexit = True
51
52         mainloop = gobject.MainLoop()
53         mainloop.run()