ofono/test/test-voicecall

95 lines
2.2 KiB
Plaintext
Raw Normal View History

2009-05-21 21:21:15 +00:00
#!/usr/bin/python
import gobject
import dbus
import dbus.mainloop.glib
2009-05-21 23:57:44 +00:00
import sys
def hangup_all():
print "Hanging up"
vcmanager.HangupAll()
2009-05-21 21:21:15 +00:00
def print_calls():
calls = vcmanager.GetCalls()
if (len(calls) != 0):
print "No calls available"
2009-05-21 21:21:15 +00:00
else:
for path, properties in calls:
print " [ %s ]" % (path)
for key in properties.keys():
val = str(properties[key])
print " %s = %s" % (key, val)
print
def voicecalls_call_added(path, properties):
print " Voice Call [ %s ] Added" % (path)
for key in properties.keys():
val = str(properties[key])
print " %s = %s" % (key, val)
print
def voicecalls_call_removed(path):
print " Voice Call [ %s ] Removed" % (path)
2009-05-21 21:21:15 +00:00
def voicecall_property_changed(name, value):
print "Voicecall property: '%s' changed to '%s'" % (name, value)
def voicecall_disconnect_reason(reason):
print "Voicecall disconnect reason: '%s'" % (reason)
2009-05-21 21:21:15 +00:00
if __name__ == "__main__":
global vcmanager
2009-05-21 23:57:44 +00:00
if (len(sys.argv) < 2):
2010-06-03 17:12:34 +00:00
print "Usage: %s [modem] <number>" % (sys.argv[0])
2009-05-21 23:57:44 +00:00
sys.exit(1)
2009-05-21 21:21:15 +00:00
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
bus = dbus.SystemBus()
manager = dbus.Interface(bus.get_object('org.ofono', '/'),
'org.ofono.Manager')
2010-09-09 19:37:37 +00:00
modems = manager.GetModems()
modem = modems[0][0]
2009-05-21 21:21:15 +00:00
if (len(sys.argv) == 3):
modem = sys.argv[1]
number = sys.argv[2]
else:
number = sys.argv[1]
print "Using modem %s" % modem
vcmanager = dbus.Interface(bus.get_object('org.ofono', modem),
2009-05-21 21:21:15 +00:00
'org.ofono.VoiceCallManager')
vcmanager.connect_to_signal("CallAdded", voicecalls_call_added)
2009-05-21 21:21:15 +00:00
vcmanager.connect_to_signal("CallRemoved", voicecalls_call_removed)
2009-05-21 21:21:15 +00:00
print_calls()
2009-05-21 21:21:15 +00:00
2010-02-24 19:14:27 +00:00
print "Dialing %s..." % number
2009-05-21 23:57:44 +00:00
obj = vcmanager.Dial(number, "")
2009-05-21 21:21:15 +00:00
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)
call.connect_to_signal("DisconnectReason", voicecall_disconnect_reason)
2009-05-21 21:21:15 +00:00
gobject.timeout_add(1000000, hangup_all)
2009-05-21 23:57:44 +00:00
2009-05-21 21:21:15 +00:00
mainloop = gobject.MainLoop()
mainloop.run()