2014-03-11 16:39:22 +00:00
|
|
|
#!/usr/bin/python3
|
2009-10-24 15:57:32 +00:00
|
|
|
|
|
|
|
import sys
|
|
|
|
import dbus
|
|
|
|
|
|
|
|
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-10-24 15:57:32 +00:00
|
|
|
|
2010-09-09 19:37:37 +00:00
|
|
|
for path, properties in modems:
|
2010-08-19 18:24:09 +00:00
|
|
|
if "org.ofono.ConnectionManager" not in properties["Interfaces"]:
|
2009-10-24 15:57:32 +00:00
|
|
|
continue
|
|
|
|
|
2010-08-19 18:24:09 +00:00
|
|
|
connman = dbus.Interface(bus.get_object('org.ofono', path),
|
|
|
|
'org.ofono.ConnectionManager')
|
2009-10-24 15:57:32 +00:00
|
|
|
|
2010-08-19 18:24:09 +00:00
|
|
|
contexts = connman.GetContexts()
|
2010-10-26 20:25:09 +00:00
|
|
|
path = "";
|
2009-10-24 15:57:32 +00:00
|
|
|
|
2010-10-26 20:25:09 +00:00
|
|
|
for i, properties in contexts:
|
|
|
|
if properties["Type"] == "mms":
|
|
|
|
path = i
|
|
|
|
break
|
|
|
|
|
|
|
|
if path == "":
|
|
|
|
path = connman.AddContext("mms")
|
2014-03-11 16:39:18 +00:00
|
|
|
print("Created new context %s" % (path))
|
2009-10-24 15:57:32 +00:00
|
|
|
else:
|
2014-03-11 16:39:18 +00:00
|
|
|
print("Found context %s" % (path))
|
2009-10-24 15:57:32 +00:00
|
|
|
|
|
|
|
context = dbus.Interface(bus.get_object('org.ofono', path),
|
2010-08-19 18:24:09 +00:00
|
|
|
'org.ofono.ConnectionContext')
|
2009-10-24 15:57:32 +00:00
|
|
|
|
2010-10-26 20:25:09 +00:00
|
|
|
if len(sys.argv) > 1:
|
2010-04-16 19:42:27 +00:00
|
|
|
context.SetProperty("AccessPointName", sys.argv[1])
|
2014-03-11 16:39:18 +00:00
|
|
|
print("Setting APN to %s" % (sys.argv[1]))
|
2010-10-26 20:25:09 +00:00
|
|
|
|
|
|
|
if len(sys.argv) > 2:
|
|
|
|
context.SetProperty("Username", sys.argv[2])
|
2014-03-11 16:39:18 +00:00
|
|
|
print("Setting username to %s" % (sys.argv[2]))
|
2009-10-24 15:57:32 +00:00
|
|
|
|
2010-10-26 20:25:09 +00:00
|
|
|
if len(sys.argv) > 3:
|
|
|
|
context.SetProperty("Password", sys.argv[3])
|
2014-03-11 16:39:18 +00:00
|
|
|
print("Setting password to %s" % (sys.argv[3]))
|