summaryrefslogtreecommitdiffstats
path: root/test/test-voicecall
blob: 13f371a4b7d2f024650bd9957bbdfb6abc5fb564 (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
84
85
86
#!/usr/bin/python

import gobject

import dbus
import dbus.mainloop.glib
import sys

def hangup_all():
	print "Hanging up"
	vcmanager.HangupAll()

def print_calls(value):
	for p in value:
		call = dbus.Interface(bus.get_object('org.ofono', p),
						'org.ofono.VoiceCall')
		properties = call.GetProperties()
		status = properties['State']
		lineid = properties['LineIdentification']

		print "Call %s, Status: %s, LineId: %s" %\
			(p, status, lineid)

def voicecalls_property_changed(name, value):
	if name == 'Calls':
		print "Call list modification>"
		if len(value) == 0:
			print "No calls in systems"
		else:
			print_calls(value)
	else:
		print "VoiceCallManager property: '%s' changed to '%s'" %\
			(name, value)

def voicecall_property_changed(name, value):
	print "Voicecall property: '%s' changed to '%s'" % (name, value)

if __name__ == "__main__":
	global vcmanager

	if (len(sys.argv) < 2):
		print "Useage: %s <number>" % (sys.argv[0])
		sys.exit(1)

	number = 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.GetProperties()['Modems']
	print modems

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

	vcmanager.connect_to_signal("PropertyChanged",
					voicecalls_property_changed)

	properties = vcmanager.GetProperties()

	print properties['Calls']

	voicecalls_property_changed('Calls', properties['Calls'])

	print "Dialing...."
	obj = vcmanager.Dial(number, "")
	print "Dialing in progress, got obj: %s" % (obj)

	call = dbus.Interface(bus.get_object('org.ofono', obj),
						'org.ofono.VoiceCall')

	properties = call.GetProperties()

	print "State: %s, Number: %s" %\
		(properties['State'], properties['LineIdentification'])

	call.connect_to_signal("PropertyChanged", voicecall_property_changed)

	gobject.timeout_add(10000, hangup_all)

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