2009-05-28 21:13:41 +00:00
|
|
|
#!/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):
|
2010-06-03 17:12:34 +00:00
|
|
|
print "Usage: %s <property> <newvalue> <password>" % (s)
|
|
|
|
print "Usage: %s disableall <password>" % (s)
|
2010-12-16 13:12:55 +00:00
|
|
|
print "Usage: %s passwd <old_password> <new_password>" % (s)
|
2009-05-28 21:13:41 +00:00
|
|
|
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]
|
2010-12-16 13:12:55 +00:00
|
|
|
elif (sys.argv[1] == 'passwd'):
|
|
|
|
old_password = sys.argv[2]
|
|
|
|
new_password = sys.argv[3]
|
2009-05-28 21:13:41 +00:00
|
|
|
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')
|
|
|
|
|
2010-09-09 19:37:37 +00:00
|
|
|
modems = manager.GetModems()
|
2009-05-28 21:13:41 +00:00
|
|
|
|
2010-09-09 19:37:37 +00:00
|
|
|
cb = dbus.Interface(bus.get_object('org.ofono', modems[0][0]),
|
2009-05-28 21:13:41 +00:00
|
|
|
'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)
|
2010-12-16 13:12:55 +00:00
|
|
|
elif (sys.argv[1] == 'passwd'):
|
|
|
|
try:
|
|
|
|
cb.ChangePassword(old_password, new_password)
|
|
|
|
except dbus.DBusException, e:
|
|
|
|
print "Unable to change password: ", e
|
|
|
|
sys.exit(1)
|
|
|
|
print "Password changed"
|
|
|
|
sys.exit(0)
|
2009-05-28 21:13:41 +00:00
|
|
|
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()
|