summaryrefslogtreecommitdiffstats
path: root/test/test-call-settings
blob: 8e5d3d5ce7c36a2ed92741485cee93f871f3f05a (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
#!/usr/bin/python

import gobject

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 <property> <newvalue>" % (sys.argv[0])
		print "Properties can be: VoiceCallWaiting, HideCallerId"
		sys.exit(1)

	canexit = False

	property = sys.argv[1]
	newvalue = sys.argv[2]

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

	bus = dbus.SystemBus()

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

	modems = manager.GetProperties()['Modems']

	cs = dbus.Interface(bus.get_object('org.ofono', modems[0]),
						'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 Called Line Restriction: %s" %\
		(properties['CalledLineRestriction'])
	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 "Hide my Caller Id: %s" % (properties['HideCallerId'])

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

	print "Setting successful"

	canexit = True

	mainloop = gobject.MainLoop()
	mainloop.run()