Initial commit to Gerrit
[profile/ivi/ofono.git] / test / test-ss-control-cf
1 #!/usr/bin/python
2
3 import gobject
4
5 import dbus
6 import dbus.mainloop.glib
7
8 def property_changed(property, value):
9         print "CallForwarding property %s changed to %s" % (property, value)
10
11 def print_properties(cf):
12         properties = cf.GetProperties()
13
14         for p in properties:
15                 if len(properties[p].__str__()) > 0:
16                         value = properties[p]
17                 else:
18                         value = "disabled"
19
20                 print "%s call forwarding rule: %s" % (p, value)
21
22 if __name__ == "__main__":
23         dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
24
25         bus = dbus.SystemBus()
26
27         manager = dbus.Interface(bus.get_object('org.ofono', '/'),
28                                                         'org.ofono.Manager')
29
30         modems = manager.GetModems()
31
32         cf = dbus.Interface(bus.get_object('org.ofono', modems[0][0]),
33                                 'org.ofono.CallForwarding')
34
35         cf.connect_to_signal("PropertyChanged", property_changed)
36
37         ss = dbus.Interface(bus.get_object('org.ofono', modems[0][0]),
38                                 'org.ofono.SupplementaryServices')
39
40         # Clear everything
41         ss.Initiate("##002#")
42         print_properties(cf)
43
44         # Busy To +155542, for Voice
45         print "Setting Busy Voice rule to +155542"
46         print ss.Initiate("*67*+155542*11#")
47         print_properties(cf)
48
49         # Not Reachable to +155543, Voice
50         print "Setting Voice Not Reachable rule to +155543"
51         print ss.Initiate("**62*+155543*11#")
52
53         # Not Reachable to +155544, Voice service
54         print "Setting Voice No Reply rule to +155544, timeout=30"
55         print ss.Initiate("**61*+155544*11*30#")
56
57         # Unconditional to +155547, Voice
58         print "Setting Unconditional for Voice to +155545"
59         print ss.Initiate("*21*+155545*10#")
60
61         print_properties(cf)
62
63         print "Query all voice forwardings"
64         print ss.Initiate("*#002**11#")
65
66         print "Query no reply voice forwardings"
67         print ss.Initiate("*#61**11#")
68
69         # Deactivate everything
70         print "Deactivating everything"
71         print ss.Initiate("##002#")
72         print_properties(cf)
73
74         mainloop = gobject.MainLoop()
75         mainloop.run()