OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 |
| 3 # Copyright (c) 2011 The Chromium OS Authors. All rights reserved. |
| 4 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. |
| 6 |
2 # | 7 # |
3 # Call the Simple.Connect API. | 8 # Call the Simple.Connect API. |
4 # | 9 # |
5 | 10 |
6 import gobject | 11 import gobject |
7 import dbus | 12 import dbus |
8 import dbus.mainloop.glib | 13 import dbus.mainloop.glib |
9 import mm | 14 import mm |
10 import sys | 15 import sys |
11 from optparse import OptionParser | 16 from optparse import OptionParser |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 props['apn'] = options.apn | 81 props['apn'] = options.apn |
77 if options.username: | 82 if options.username: |
78 props['username'] = options.username | 83 props['username'] = options.username |
79 if options.password: | 84 if options.password: |
80 props['password'] = options.password | 85 props['password'] = options.password |
81 if options.number: | 86 if options.number: |
82 props['number'] = options.number | 87 props['number'] = options.number |
83 | 88 |
84 dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) | 89 dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) |
85 | 90 |
86 manager = mm.ModemManager() | 91 manager, path = mm.PickOneModem(modem_pattern) |
| 92 modem = manager.CdmaModem(path) |
87 | 93 |
88 target = mm.PickOneModem(manager, modem_pattern) | 94 print "Connecting", path |
89 | |
90 print "Connecting", target | |
91 | 95 |
92 if options.wait: | 96 if options.wait: |
93 bus = dbus.SystemBus() | 97 bus = dbus.SystemBus() |
94 bus.add_signal_receiver(state_changed, | 98 bus.add_signal_receiver(state_changed, |
95 » » » bus_name="org.chromium.ModemManager", | 99 » » » bus_name=manager.provider, |
96 signal_name="StateChanged", | 100 signal_name="StateChanged", |
97 path_keyword="path") | 101 path_keyword="path") |
98 | 102 |
99 modem = manager.SimpleModem(target) | 103 modem = manager.SimpleModem(path) |
100 try: | 104 try: |
101 modem.Connect(props) | 105 modem.Connect(props) |
102 options.wait = False | 106 options.wait = False |
103 except dbus.exceptions.DBusException, e: | 107 except dbus.exceptions.DBusException, e: |
104 if e._dbus_error_name != "org.chromium.ModemManager.Error.OperationIniti
ated": | 108 if e._dbus_error_name != "org.chromium.ModemManager.Error.OperationIniti
ated": |
105 raise e | 109 raise e |
106 | 110 |
107 if options.wait: | 111 if options.wait: |
108 mainloop = gobject.MainLoop() | 112 mainloop = gobject.MainLoop() |
109 mainloop.run() | 113 mainloop.run() |
OLD | NEW |