summaryrefslogtreecommitdiffstats
path: root/test/test-call-settings
blob: 435594c91ebdcc6544c9f3e284a6284df3598afc (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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/usr/bin/python3

from gi.repository import GLib

import dbus
import dbus.mainloop.glib
import sys

def property_changed(name, value):
	print("CallSettings property: '%s' changed to '%s'" % (name, value))

	if canexit:
		mainloop.quit();

if __name__ == "__main__":
	if len(sys.argv) < 3:
		print("Usage: %s [modem] <property> <newvalue>" % (sys.argv[0]))
		print("Properties can be: VoiceCallWaiting,")
		print("	ConnectedLineRestriction, CallingLineRestriction,")
		print("	CallingLinePresentation, CalledLinePresentation,")
		print("	ConnectedLinePresentation, HideCallerId")
		sys.exit(1)

	canexit = False

	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()
	modem = modems[0][0]

	if (len(sys.argv) == 4):
		modem = sys.argv[1]
		property = sys.argv[2]
		newvalue = sys.argv[3]
	else:
		property = sys.argv[1]
		newvalue = sys.argv[2]

	print("Using modem %s" % modem)

	cs = dbus.Interface(bus.get_object('org.ofono', modem),
						'org.ofono.CallSettings')

	cs.connect_to_signal("PropertyChanged", property_changed)

	properties = cs.GetProperties()

	print("Current Property values:")
	print("Network Status of Call Waiting - Voice: %s" %\
		(properties['VoiceCallWaiting']))
	print("Network Status of Connected Line Restriction: %s" %\
		(properties['ConnectedLineRestriction']))
	print("Network Status of Calling Line Restriction: %s" %\
		(properties['CallingLineRestriction']))
	print("Network Status of Calling Line Presentation: %s" %\
		(properties['CallingLinePresentation']))
	print("Network Status of Called Line Presentation: %s" %\
		(properties['CalledLinePresentation']))
	print("Network Status of Connected Line Presentation: %s" %\
		(properties['ConnectedLinePresentation']))
	print("Hide my Caller Id: %s" % (properties['HideCallerId']))

	try:
		cs.SetProperty(property, newvalue)
	except dbus.DBusException as e:
		print("Unable to set property: %s" % e)
		sys.exit(1);

	print("Setting successful")

	if (properties[property] == newvalue):
		print("Setting was already set to this value")
		sys.exit(1);

	canexit = True

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