From 703becb24da166842da1f6082d06f765a9e48610 Mon Sep 17 00:00:00 2001 From: Denis Kenzior Date: Thu, 28 May 2009 16:13:41 -0500 Subject: [PATCH] Add test script for CallBarring interface --- test/test-call-barring | 72 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100755 test/test-call-barring diff --git a/test/test-call-barring b/test/test-call-barring new file mode 100755 index 00000000..d4fbad13 --- /dev/null +++ b/test/test-call-barring @@ -0,0 +1,72 @@ +#!/usr/bin/python + +import gobject +import sys +import dbus +import dbus.mainloop.glib + + +def property_changed(name, value): + print "CallBarring property: '%s' changed to '%s'" % (name, str(value)) + if canexit: + mainloop.quit() + +def print_useage(s): + print "Useage: %s " % (s) + print "Useage: %s disableall " % (s) + sys.exit(1); + +if __name__ == "__main__": + if len(sys.argv) != 3 and len(sys.argv) != 4: + print_useage(sys.argv[0]) + + if (sys.argv[1] == 'disableall'): + pin = sys.argv[2] + else: + if (len(sys.argv) != 4): + print_useage(sys.argv[0]) + property = sys.argv[1] + newvalue = sys.argv[2] + pin = sys.argv[3] + + 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.GetProperties()['Modems'] + + cb = dbus.Interface(bus.get_object('org.ofono', modems[0]), + 'org.ofono.CallBarring') + + cb.connect_to_signal("PropertyChanged", property_changed) + + properties = cb.GetProperties() + + print "Barring settings for Incoming Voice calls: %s" %\ + (properties['VoiceIncoming']) + print "Barring settings for Outgoing Calls: %s" %\ + (properties['VoiceOutgoing']) + + if (sys.argv[1] == 'disableall'): + print "Disabling all barrings" + try: + cb.DisableAll(pin) + except dbus.DBusException, e: + print "Unable to Disable All barrings: ", e + sys.exit(1) + else: + try: + cb.SetProperty(property, newvalue, pin) + except dbus.DBusException, e: + print "Unable to set property: ", e + sys.exit(1) + + canexit = True + + mainloop = gobject.MainLoop() + mainloop.run()