summaryrefslogtreecommitdiffstats
path: root/test/disable-call-forwarding
blob: 811e4fa72aafb989249a803a767d3b44439c2308 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/python3

import sys
from gi.repository import GLib

import dbus
import dbus.mainloop.glib

def property_changed(property, value):
	if len(value.__str__()) > 0:
		print("CF property %s changed to %s" % (property, value))
	else:
		print("CF property %s changed to disabled" % (property))

	if canexit:
		mainloop.quit();

if __name__ == "__main__":
	if len(sys.argv) < 2:
		print("Usage: %s <type>" % (sys.argv[0]))
		print("Type can be: all, conditional")
		sys.exit(1)

	canexit = False

	type = sys.argv[1]

	dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)

	bus = dbus.SystemBus()

	manager = dbus.Interface(bus.get_object('org.ofono', '/'),
							'org.ofono.Manager')

	modems = manager.GetModems()

	cf = dbus.Interface(bus.get_object('org.ofono', modems[0][0]),
				'org.ofono.CallForwarding')

	cf.connect_to_signal("PropertyChanged", property_changed)

	try:
		cf.DisableAll(type, timeout = 100)
	except dbus.DBusException as e:
		print("Unable to DisableAll %s" % e)
		sys.exit(1);

	print("DisableAll successful")

	canexit = True

	mainloop = GLib.MainLoop()
	mainloop.run()