diff --git a/test/set-call-forwarding b/test/set-call-forwarding index 49d1ce0d9..803e18e18 100755 --- a/test/set-call-forwarding +++ b/test/set-call-forwarding @@ -16,28 +16,42 @@ def property_changed(property, value): mainloop.quit(); if __name__ == "__main__": - if len(sys.argv) < 3: - print("Usage: %s " % (sys.argv[0])) + + dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) + bus = dbus.SystemBus() + + if len(sys.argv) == 4: + path = sys.argv[1] + property = sys.argv[2] + value = sys.argv[3] + elif len(sys.argv) == 3: + manager = dbus.Interface(bus.get_object('org.ofono', '/'), + 'org.ofono.Manager') + modems = manager.GetModems() + + path = modems[0][0] + property = sys.argv[1] + value = sys.argv[2] + else: + print("Usage: %s [PATH] " % (sys.argv[0])) print("Properties can be: VoiceUnconditional, VoiceBusy,") print(" VoiceNoReply, VoiceNoReplyTimeout, VoiceNotReachable") print("Value: number to or the timeout") sys.exit(1) - property = sys.argv[1] - value = sys.argv[2] - 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() + if property not in ["VoiceUnconditional", + "VoiceBusy", + "VoiceNoReply", + "VoiceNoReplyTimeout", + "VoiceNotReachable"]: + print("Properties can be: VoiceUnconditional, VoiceBusy,") + print(" VoiceNoReply, VoiceNoReplyTimeout, VoiceNotReachable") + print("Value: number to or the timeout") + sys.exit(1) - cf = dbus.Interface(bus.get_object('org.ofono', modems[0][0]), + cf = dbus.Interface(bus.get_object('org.ofono', path), 'org.ofono.CallForwarding') cf.connect_to_signal("PropertyChanged", property_changed) diff --git a/test/test-call-forwarding b/test/test-call-forwarding index 7db451ae6..d4025fbec 100755 --- a/test/test-call-forwarding +++ b/test/test-call-forwarding @@ -5,6 +5,7 @@ from gi.repository import GLib import argparse import dbus import dbus.mainloop.glib +import sys def property_changed(property, value): print("CallForwarding property %s changed to %s" % (property, value)) @@ -12,7 +13,9 @@ def property_changed(property, value): def print_properties(cf): properties = cf.GetProperties() - for p in properties: + for p in ["VoiceBusy", "VoiceNoReplyTimeout", "VoiceNotReachable", + "VoiceUnconditional", "VoiceNoReply", + "ForwardingFlagOnSim"]: if len(properties[p].__str__()) > 0: print("%s call forwarding rule is: %s" % (p, properties[p])) else: @@ -42,6 +45,16 @@ def parse_arguments(): help="""Specify an unconditional forwarding number""", default="+155555", ) + parser.add_argument("--unreach-num", + dest="unreach_num", + help="""Specify an un-reachable forwarding number""", + default="+155555", + ) + parser.add_argument("--busy-num", + dest="busy_num", + help="""Specify a busy forwarding number""", + default="+155555", + ) parser.add_argument("--noreply-timeout", dest="noreply_timeout", help="""Specify a no-reply timeout""", @@ -140,9 +153,21 @@ def main(args): except dbus.DBusException as e: print("Unable to set Voice Unconditional - Bad") + try: + cf.SetProperty("VoiceBusy", args.busy_num) + except dbus.DBusException as e: + print("Unable to set Voice Busy - Bad") + + try: + cf.SetProperty("VoiceNotReachable", args.unreach_num) + except dbus.DBusException as e: + print("Unable to set Voice Not Reachable - Bad") + properties = cf.GetProperties() print(properties["VoiceUnconditional"]) + print(properties["VoiceBusy"]) + print(properties["VoiceNotReachable"]) try: cf.DisableAll("foobar") @@ -171,4 +196,8 @@ def main(args): if __name__ == "__main__": args = parse_arguments() - main(args) + + try: + main(args) + except KeyboardInterrupt as e: + sys.exit(0)