ofono/test/set-call-forwarding

65 lines
1.5 KiB
Plaintext
Raw Permalink Normal View History

#!/usr/bin/python3
2011-01-12 09:14:39 +00:00
import sys
from gi.repository import GLib
2011-01-12 09:14:39 +00:00
import dbus
import dbus.mainloop.glib
def property_changed(property, value):
if len(value.__str__()) > 0:
print("CF property %s changed to %s" % (property, value))
2011-01-12 09:14:39 +00:00
else:
print("CF property %s changed to disabled" % (property))
2011-01-12 09:14:39 +00:00
if canexit:
mainloop.quit();
if __name__ == "__main__":
if len(sys.argv) < 3:
print("Usage: %s <property> <value>" % (sys.argv[0]))
print("Properties can be: VoiceUnconditional, VoiceBusy,")
print(" VoiceNoReply, VoiceNoReplyTimeout, VoiceNotReachable")
print("Value: number to or the timeout")
2011-01-12 09:14:39 +00:00
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()
cf = dbus.Interface(bus.get_object('org.ofono', modems[0][0]),
'org.ofono.CallForwarding')
cf.connect_to_signal("PropertyChanged", property_changed)
if (property == "VoiceNoReplyTimeout"):
try:
cf.SetProperty(property, dbus.UInt16(value),
timeout = 100)
except dbus.DBusException as e:
print("Unable SetProperty %s" % e)
2011-01-12 09:14:39 +00:00
sys.exit(1);
else:
try:
cf.SetProperty(property, value, timeout = 100)
except dbus.DBusException as e:
print("Unable SetProperty %s" % e)
2011-01-12 09:14:39 +00:00
sys.exit(1);
print("Set Property successful")
2011-01-12 09:14:39 +00:00
canexit = True
mainloop = GLib.MainLoop()
2011-01-12 09:14:39 +00:00
mainloop.run()