Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium OS Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "shill/mm1_modem_proxy.h" |
| 6 | |
| 7 | #include <base/logging.h> |
| 8 | |
Ben Chan | fad4a0b | 2012-04-18 15:49:59 -0700 | [diff] [blame] | 9 | #include "shill/cellular_error.h" |
| 10 | #include "shill/scope_logger.h" |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 11 | |
| 12 | using std::string; |
| 13 | |
| 14 | namespace shill { |
| 15 | namespace mm1 { |
| 16 | |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 17 | ModemProxy::ModemProxy(DBus::Connection *connection, |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 18 | const string &path, |
| 19 | const string &service) |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 20 | : proxy_(connection, path, service) {} |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 21 | |
| 22 | ModemProxy::~ModemProxy() {} |
| 23 | |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 24 | void ModemProxy::set_state_changed_callback( |
| 25 | const ModemStateChangedSignalCallback &callback) { |
| 26 | proxy_.set_state_changed_callback(callback); |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 27 | } |
| 28 | |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 29 | void ModemProxy::Enable(bool enable, |
| 30 | Error *error, |
| 31 | const ResultCallback &callback, |
| 32 | int timeout) { |
Ben Chan | fad4a0b | 2012-04-18 15:49:59 -0700 | [diff] [blame] | 33 | SLOG(Modem, 2) << __func__ << "(" << enable << ", " << timeout << ")"; |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 34 | scoped_ptr<ResultCallback> cb(new ResultCallback(callback)); |
| 35 | try { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame] | 36 | SLOG(DBus, 2) << __func__; |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 37 | proxy_.Enable(enable, cb.get(), timeout); |
| 38 | cb.release(); |
Ben Chan | 80326f3 | 2012-05-04 17:51:32 -0700 | [diff] [blame] | 39 | } catch (const DBus::Error &e) { |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 40 | if (error) |
| 41 | CellularError::FromDBusError(e, error); |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | void ModemProxy::ListBearers(Error *error, |
| 46 | const DBusPathsCallback &callback, |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 47 | int timeout) { |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 48 | scoped_ptr<DBusPathsCallback> cb(new DBusPathsCallback(callback)); |
| 49 | try { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame] | 50 | SLOG(DBus, 2) << __func__; |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 51 | proxy_.ListBearers(cb.get(), timeout); |
| 52 | cb.release(); |
Ben Chan | 80326f3 | 2012-05-04 17:51:32 -0700 | [diff] [blame] | 53 | } catch (const DBus::Error &e) { |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 54 | if (error) |
| 55 | CellularError::FromDBusError(e, error); |
| 56 | } |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 57 | } |
| 58 | |
| 59 | void ModemProxy::CreateBearer( |
| 60 | const DBusPropertiesMap &properties, |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 61 | Error *error, |
| 62 | const DBusPathCallback &callback, |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 63 | int timeout) { |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 64 | scoped_ptr<DBusPathCallback> cb(new DBusPathCallback(callback)); |
| 65 | try { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame] | 66 | SLOG(DBus, 2) << __func__; |
| 67 | proxy_.CreateBearer(properties, cb.get(), timeout); |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 68 | cb.release(); |
Ben Chan | 80326f3 | 2012-05-04 17:51:32 -0700 | [diff] [blame] | 69 | } catch (const DBus::Error &e) { |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 70 | if (error) |
| 71 | CellularError::FromDBusError(e, error); |
| 72 | } |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 73 | } |
| 74 | |
| 75 | void ModemProxy::DeleteBearer(const ::DBus::Path &bearer, |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 76 | Error *error, |
| 77 | const ResultCallback &callback, |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 78 | int timeout) { |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 79 | scoped_ptr<ResultCallback> cb(new ResultCallback(callback)); |
| 80 | try { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame] | 81 | SLOG(DBus, 2) << __func__; |
| 82 | proxy_.DeleteBearer(bearer, cb.get(), timeout); |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 83 | cb.release(); |
Ben Chan | 80326f3 | 2012-05-04 17:51:32 -0700 | [diff] [blame] | 84 | } catch (const DBus::Error &e) { |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 85 | if (error) |
| 86 | CellularError::FromDBusError(e, error); |
| 87 | } |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 88 | } |
| 89 | |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 90 | void ModemProxy::Reset(Error *error, |
| 91 | const ResultCallback &callback, |
| 92 | int timeout) { |
| 93 | scoped_ptr<ResultCallback> cb(new ResultCallback(callback)); |
| 94 | try { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame] | 95 | SLOG(DBus, 2) << __func__; |
| 96 | proxy_.Reset(cb.get(), timeout); |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 97 | cb.release(); |
Ben Chan | 80326f3 | 2012-05-04 17:51:32 -0700 | [diff] [blame] | 98 | } catch (const DBus::Error &e) { |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 99 | if (error) |
| 100 | CellularError::FromDBusError(e, error); |
| 101 | } |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 102 | } |
| 103 | |
| 104 | void ModemProxy::FactoryReset(const std::string &code, |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 105 | Error *error, |
| 106 | const ResultCallback &callback, |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 107 | int timeout) { |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 108 | scoped_ptr<ResultCallback> cb(new ResultCallback(callback)); |
| 109 | try { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame] | 110 | SLOG(DBus, 2) << __func__; |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 111 | proxy_.FactoryReset(code, cb.get(), timeout); |
| 112 | cb.release(); |
Ben Chan | 80326f3 | 2012-05-04 17:51:32 -0700 | [diff] [blame] | 113 | } catch (const DBus::Error &e) { |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 114 | if (error) |
| 115 | CellularError::FromDBusError(e, error); |
| 116 | } |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 117 | } |
| 118 | |
| 119 | void ModemProxy::SetAllowedModes(const uint32_t &modes, |
| 120 | const uint32_t &preferred, |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 121 | Error *error, |
| 122 | const ResultCallback &callback, |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 123 | int timeout) { |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 124 | scoped_ptr<ResultCallback> cb(new ResultCallback(callback)); |
| 125 | try { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame] | 126 | SLOG(DBus, 2) << __func__; |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 127 | proxy_.SetAllowedModes(modes, preferred, cb.get(), timeout); |
| 128 | cb.release(); |
Ben Chan | 80326f3 | 2012-05-04 17:51:32 -0700 | [diff] [blame] | 129 | } catch (const DBus::Error &e) { |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 130 | if (error) |
| 131 | CellularError::FromDBusError(e, error); |
| 132 | } |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 133 | } |
| 134 | |
Gary Morain | 610977f | 2012-05-04 16:03:52 -0700 | [diff] [blame] | 135 | void ModemProxy::SetBands(const std::vector<uint32_t> &bands, |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 136 | Error *error, |
| 137 | const ResultCallback &callback, |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 138 | int timeout) { |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 139 | scoped_ptr<ResultCallback> cb(new ResultCallback(callback)); |
| 140 | try { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame] | 141 | SLOG(DBus, 2) << __func__; |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 142 | proxy_.SetBands(bands, cb.get(), timeout); |
| 143 | cb.release(); |
Ben Chan | 80326f3 | 2012-05-04 17:51:32 -0700 | [diff] [blame] | 144 | } catch (const DBus::Error &e) { |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 145 | if (error) |
| 146 | CellularError::FromDBusError(e, error); |
| 147 | } |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 148 | } |
| 149 | |
| 150 | void ModemProxy::Command(const std::string &cmd, |
| 151 | const uint32_t &user_timeout, |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 152 | Error *error, |
| 153 | const StringCallback &callback, |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 154 | int timeout) { |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 155 | scoped_ptr<StringCallback> cb(new StringCallback(callback)); |
| 156 | try { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame] | 157 | SLOG(DBus, 2) << __func__; |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 158 | proxy_.Command(cmd, user_timeout, cb.get(), timeout); |
| 159 | cb.release(); |
Ben Chan | 80326f3 | 2012-05-04 17:51:32 -0700 | [diff] [blame] | 160 | } catch (const DBus::Error &e) { |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 161 | if (error) |
| 162 | CellularError::FromDBusError(e, error); |
| 163 | } |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 164 | } |
| 165 | |
| 166 | // Inherited properties from ModemProxyInterface. |
| 167 | const ::DBus::Path ModemProxy::Sim() { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame] | 168 | SLOG(DBus, 2) << __func__; |
Gary Morain | 610977f | 2012-05-04 16:03:52 -0700 | [diff] [blame] | 169 | try { |
| 170 | return proxy_.Sim(); |
| 171 | } catch (const DBus::Error &e) { |
| 172 | LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what(); |
| 173 | return ::DBus::Path(); // Make the compiler happy. |
| 174 | } |
Jason Glasgow | 90d216d | 2012-04-04 15:57:14 -0400 | [diff] [blame] | 175 | } |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 176 | uint32_t ModemProxy::ModemCapabilities() { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame] | 177 | SLOG(DBus, 2) << __func__; |
Gary Morain | 610977f | 2012-05-04 16:03:52 -0700 | [diff] [blame] | 178 | try { |
| 179 | return proxy_.ModemCapabilities(); |
| 180 | } catch (const DBus::Error &e) { |
| 181 | LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what(); |
| 182 | return 0; // Make the compiler happy. |
| 183 | } |
Jason Glasgow | 90d216d | 2012-04-04 15:57:14 -0400 | [diff] [blame] | 184 | } |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 185 | uint32_t ModemProxy::CurrentCapabilities() { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame] | 186 | SLOG(DBus, 2) << __func__; |
Gary Morain | 610977f | 2012-05-04 16:03:52 -0700 | [diff] [blame] | 187 | try { |
| 188 | return proxy_.CurrentCapabilities(); |
| 189 | } catch (const DBus::Error &e) { |
| 190 | LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what(); |
| 191 | return 0; // Make the compiler happy. |
| 192 | } |
Jason Glasgow | 90d216d | 2012-04-04 15:57:14 -0400 | [diff] [blame] | 193 | } |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 194 | uint32_t ModemProxy::MaxBearers() { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame] | 195 | SLOG(DBus, 2) << __func__; |
Gary Morain | 610977f | 2012-05-04 16:03:52 -0700 | [diff] [blame] | 196 | try { |
| 197 | return proxy_.MaxBearers(); |
| 198 | } catch (const DBus::Error &e) { |
| 199 | LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what(); |
| 200 | return 0; // Make the compiler happy. |
| 201 | } |
Jason Glasgow | 90d216d | 2012-04-04 15:57:14 -0400 | [diff] [blame] | 202 | } |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 203 | uint32_t ModemProxy::MaxActiveBearers() { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame] | 204 | SLOG(DBus, 2) << __func__; |
Gary Morain | 610977f | 2012-05-04 16:03:52 -0700 | [diff] [blame] | 205 | try { |
| 206 | return proxy_.MaxActiveBearers(); |
| 207 | } catch (const DBus::Error &e) { |
| 208 | LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what(); |
| 209 | return 0; // Make the compiler happy. |
| 210 | } |
Jason Glasgow | 90d216d | 2012-04-04 15:57:14 -0400 | [diff] [blame] | 211 | } |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 212 | const std::string ModemProxy::Manufacturer() { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame] | 213 | SLOG(DBus, 2) << __func__; |
Gary Morain | 610977f | 2012-05-04 16:03:52 -0700 | [diff] [blame] | 214 | try { |
| 215 | return proxy_.Manufacturer(); |
| 216 | } catch (const DBus::Error &e) { |
| 217 | LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what(); |
| 218 | return std::string(); // Make the compiler happy. |
| 219 | } |
Jason Glasgow | 90d216d | 2012-04-04 15:57:14 -0400 | [diff] [blame] | 220 | } |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 221 | const std::string ModemProxy::Model() { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame] | 222 | SLOG(DBus, 2) << __func__; |
Gary Morain | 610977f | 2012-05-04 16:03:52 -0700 | [diff] [blame] | 223 | try { |
| 224 | return proxy_.Model(); |
| 225 | } catch (const DBus::Error &e) { |
| 226 | LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what(); |
| 227 | return std::string(); // Make the compiler happy. |
| 228 | } |
Jason Glasgow | 90d216d | 2012-04-04 15:57:14 -0400 | [diff] [blame] | 229 | } |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 230 | const std::string ModemProxy::Revision() { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame] | 231 | SLOG(DBus, 2) << __func__; |
Gary Morain | 610977f | 2012-05-04 16:03:52 -0700 | [diff] [blame] | 232 | try { |
| 233 | return proxy_.Revision(); |
| 234 | } catch (const DBus::Error &e) { |
| 235 | LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what(); |
| 236 | return std::string(); // Make the compiler happy. |
| 237 | } |
Jason Glasgow | 90d216d | 2012-04-04 15:57:14 -0400 | [diff] [blame] | 238 | } |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 239 | const std::string ModemProxy::DeviceIdentifier() { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame] | 240 | SLOG(DBus, 2) << __func__; |
Gary Morain | 610977f | 2012-05-04 16:03:52 -0700 | [diff] [blame] | 241 | try { |
| 242 | return proxy_.DeviceIdentifier(); |
| 243 | } catch (const DBus::Error &e) { |
| 244 | LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what(); |
| 245 | return std::string(); // Make the compiler happy. |
| 246 | } |
Jason Glasgow | 90d216d | 2012-04-04 15:57:14 -0400 | [diff] [blame] | 247 | } |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 248 | const std::string ModemProxy::Device() { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame] | 249 | SLOG(DBus, 2) << __func__; |
Gary Morain | 610977f | 2012-05-04 16:03:52 -0700 | [diff] [blame] | 250 | try { |
| 251 | return proxy_.Device(); |
| 252 | } catch (const DBus::Error &e) { |
| 253 | LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what(); |
| 254 | return std::string(); // Make the compiler happy. |
| 255 | } |
Jason Glasgow | 90d216d | 2012-04-04 15:57:14 -0400 | [diff] [blame] | 256 | } |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 257 | const std::string ModemProxy::Driver() { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame] | 258 | SLOG(DBus, 2) << __func__; |
Gary Morain | 610977f | 2012-05-04 16:03:52 -0700 | [diff] [blame] | 259 | try { |
| 260 | return proxy_.Driver(); |
| 261 | } catch (const DBus::Error &e) { |
| 262 | LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what(); |
| 263 | return std::string(); // Make the compiler happy. |
| 264 | } |
Jason Glasgow | 90d216d | 2012-04-04 15:57:14 -0400 | [diff] [blame] | 265 | } |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 266 | const std::string ModemProxy::Plugin() { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame] | 267 | SLOG(DBus, 2) << __func__; |
Gary Morain | 610977f | 2012-05-04 16:03:52 -0700 | [diff] [blame] | 268 | try { |
| 269 | return proxy_.Plugin(); |
| 270 | } catch (const DBus::Error &e) { |
| 271 | LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what(); |
| 272 | return std::string(); // Make the compiler happy. |
| 273 | } |
Jason Glasgow | 90d216d | 2012-04-04 15:57:14 -0400 | [diff] [blame] | 274 | } |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 275 | const std::string ModemProxy::EquipmentIdentifier() { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame] | 276 | SLOG(DBus, 2) << __func__; |
Gary Morain | 610977f | 2012-05-04 16:03:52 -0700 | [diff] [blame] | 277 | try { |
| 278 | return proxy_.EquipmentIdentifier(); |
| 279 | } catch (const DBus::Error &e) { |
| 280 | LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what(); |
| 281 | return std::string(); // Make the compiler happy. |
| 282 | } |
Jason Glasgow | 90d216d | 2012-04-04 15:57:14 -0400 | [diff] [blame] | 283 | } |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 284 | uint32_t ModemProxy::UnlockRequired() { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame] | 285 | SLOG(DBus, 2) << __func__; |
Gary Morain | 610977f | 2012-05-04 16:03:52 -0700 | [diff] [blame] | 286 | try { |
| 287 | return proxy_.UnlockRequired(); |
| 288 | } catch (const DBus::Error &e) { |
| 289 | LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what(); |
| 290 | return 0; // Make the compiler happy. |
| 291 | } |
Jason Glasgow | 90d216d | 2012-04-04 15:57:14 -0400 | [diff] [blame] | 292 | } |
Gary Morain | 610977f | 2012-05-04 16:03:52 -0700 | [diff] [blame] | 293 | const std::map<uint32_t, uint32_t> ModemProxy::UnlockRetries() { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame] | 294 | SLOG(DBus, 2) << __func__; |
Gary Morain | 610977f | 2012-05-04 16:03:52 -0700 | [diff] [blame] | 295 | try { |
| 296 | return proxy_.UnlockRetries(); |
| 297 | } catch (const DBus::Error &e) { |
| 298 | LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what(); |
| 299 | return std::map<uint32_t, uint32_t>(); // Make the compiler happy. |
| 300 | } |
Jason Glasgow | 90d216d | 2012-04-04 15:57:14 -0400 | [diff] [blame] | 301 | } |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 302 | uint32_t ModemProxy::State() { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame] | 303 | SLOG(DBus, 2) << __func__; |
Gary Morain | 610977f | 2012-05-04 16:03:52 -0700 | [diff] [blame] | 304 | try { |
| 305 | return proxy_.State(); |
| 306 | } catch (const DBus::Error &e) { |
| 307 | LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what(); |
| 308 | return 0; // Make the compiler happy. |
| 309 | } |
Jason Glasgow | 90d216d | 2012-04-04 15:57:14 -0400 | [diff] [blame] | 310 | } |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 311 | uint32_t ModemProxy::AccessTechnologies() { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame] | 312 | SLOG(DBus, 2) << __func__; |
Gary Morain | 610977f | 2012-05-04 16:03:52 -0700 | [diff] [blame] | 313 | try { |
| 314 | return proxy_.AccessTechnologies(); |
| 315 | } catch (const DBus::Error &e) { |
| 316 | LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what(); |
| 317 | return 0; // Make the compiler happy. |
| 318 | } |
Jason Glasgow | 90d216d | 2012-04-04 15:57:14 -0400 | [diff] [blame] | 319 | } |
Gary Morain | 610977f | 2012-05-04 16:03:52 -0700 | [diff] [blame] | 320 | const ::DBus::Struct<uint32_t, bool> ModemProxy::SignalQuality() { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame] | 321 | SLOG(DBus, 2) << __func__; |
Gary Morain | 610977f | 2012-05-04 16:03:52 -0700 | [diff] [blame] | 322 | try { |
| 323 | return proxy_.SignalQuality(); |
| 324 | } catch (const DBus::Error &e) { |
| 325 | LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what(); |
| 326 | return ::DBus::Struct<uint32_t, bool>(); // Make the compiler happy. |
| 327 | } |
Jason Glasgow | 90d216d | 2012-04-04 15:57:14 -0400 | [diff] [blame] | 328 | } |
| 329 | const std::vector<string> ModemProxy::OwnNumbers() { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame] | 330 | SLOG(DBus, 2) << __func__; |
Gary Morain | 610977f | 2012-05-04 16:03:52 -0700 | [diff] [blame] | 331 | try { |
| 332 | return proxy_.OwnNumbers(); |
| 333 | } catch (const DBus::Error &e) { |
| 334 | LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what(); |
| 335 | return std::vector<string>(); // Make the compiler happy. |
| 336 | } |
Jason Glasgow | 90d216d | 2012-04-04 15:57:14 -0400 | [diff] [blame] | 337 | } |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 338 | uint32_t ModemProxy::SupportedModes() { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame] | 339 | SLOG(DBus, 2) << __func__; |
Gary Morain | 610977f | 2012-05-04 16:03:52 -0700 | [diff] [blame] | 340 | try { |
| 341 | return proxy_.SupportedModes(); |
| 342 | } catch (const DBus::Error &e) { |
| 343 | LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what(); |
| 344 | return 0; // Make the compiler happy. |
| 345 | } |
Jason Glasgow | 90d216d | 2012-04-04 15:57:14 -0400 | [diff] [blame] | 346 | } |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 347 | uint32_t ModemProxy::AllowedModes() { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame] | 348 | SLOG(DBus, 2) << __func__; |
Gary Morain | 610977f | 2012-05-04 16:03:52 -0700 | [diff] [blame] | 349 | try { |
| 350 | return proxy_.AllowedModes(); |
| 351 | } catch (const DBus::Error &e) { |
| 352 | LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what(); |
| 353 | return 0; // Make the compiler happy. |
| 354 | } |
Jason Glasgow | 90d216d | 2012-04-04 15:57:14 -0400 | [diff] [blame] | 355 | } |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 356 | uint32_t ModemProxy::PreferredMode() { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame] | 357 | SLOG(DBus, 2) << __func__; |
Gary Morain | 610977f | 2012-05-04 16:03:52 -0700 | [diff] [blame] | 358 | try { |
| 359 | return proxy_.PreferredMode(); |
| 360 | } catch (const DBus::Error &e) { |
| 361 | LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what(); |
| 362 | return 0; // Make the compiler happy. |
| 363 | } |
Jason Glasgow | 90d216d | 2012-04-04 15:57:14 -0400 | [diff] [blame] | 364 | } |
Gary Morain | 610977f | 2012-05-04 16:03:52 -0700 | [diff] [blame] | 365 | const std::vector<uint32_t> ModemProxy::SupportedBands() { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame] | 366 | SLOG(DBus, 2) << __func__; |
Gary Morain | 610977f | 2012-05-04 16:03:52 -0700 | [diff] [blame] | 367 | try { |
| 368 | return proxy_.SupportedBands(); |
| 369 | } catch (const DBus::Error &e) { |
| 370 | LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what(); |
| 371 | return std::vector<uint32_t>(); // Make the compiler happy. |
| 372 | } |
Jason Glasgow | 90d216d | 2012-04-04 15:57:14 -0400 | [diff] [blame] | 373 | } |
Gary Morain | 610977f | 2012-05-04 16:03:52 -0700 | [diff] [blame] | 374 | const std::vector<uint32_t> ModemProxy::Bands() { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame] | 375 | SLOG(DBus, 2) << __func__; |
Gary Morain | 610977f | 2012-05-04 16:03:52 -0700 | [diff] [blame] | 376 | try { |
| 377 | return proxy_.Bands(); |
| 378 | } catch (const DBus::Error &e) { |
| 379 | LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what(); |
| 380 | return std::vector<uint32_t>(); // Make the compiler happy. |
| 381 | } |
Jason Glasgow | 90d216d | 2012-04-04 15:57:14 -0400 | [diff] [blame] | 382 | } |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 383 | |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 384 | ModemProxy::Proxy::Proxy(DBus::Connection *connection, |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 385 | const std::string &path, |
| 386 | const std::string &service) |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 387 | : DBus::ObjectProxy(*connection, path, service.c_str()) {} |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 388 | |
| 389 | ModemProxy::Proxy::~Proxy() {} |
| 390 | |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 391 | void ModemProxy::Proxy::set_state_changed_callback( |
| 392 | const ModemStateChangedSignalCallback &callback) { |
| 393 | state_changed_callback_ = callback; |
| 394 | } |
| 395 | |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 396 | // Signal callbacks inherited from Proxy |
Nathan Williams | a31e79c | 2012-03-30 15:07:00 -0400 | [diff] [blame] | 397 | void ModemProxy::Proxy::StateChanged(const int32_t &old, |
| 398 | const int32_t &_new, |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 399 | const uint32_t &reason) { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame] | 400 | SLOG(DBus, 2) << __func__; |
Jason Glasgow | 82f9ab3 | 2012-04-04 14:27:19 -0400 | [diff] [blame] | 401 | if (!state_changed_callback_.is_null()) |
| 402 | state_changed_callback_.Run(old, _new, reason); |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 403 | } |
| 404 | |
| 405 | // Method callbacks inherited from |
| 406 | // org::freedesktop::ModemManager1::ModemProxy |
| 407 | void ModemProxy::Proxy::EnableCallback(const ::DBus::Error& dberror, |
| 408 | void *data) { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame] | 409 | SLOG(DBus, 2) << __func__; |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 410 | scoped_ptr<ResultCallback> callback(reinterpret_cast<ResultCallback *>(data)); |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 411 | Error error; |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 412 | CellularError::FromDBusError(dberror, &error); |
| 413 | callback->Run(error); |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 414 | } |
| 415 | |
| 416 | void ModemProxy::Proxy::ListBearersCallback( |
Gary Morain | 610977f | 2012-05-04 16:03:52 -0700 | [diff] [blame] | 417 | const std::vector< ::DBus::Path> &bearers, |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 418 | const ::DBus::Error& dberror, |
| 419 | void *data) { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame] | 420 | SLOG(DBus, 2) << __func__; |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 421 | scoped_ptr<DBusPathsCallback> callback( |
| 422 | reinterpret_cast<DBusPathsCallback *>(data)); |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 423 | Error error; |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 424 | CellularError::FromDBusError(dberror, &error); |
| 425 | callback->Run(bearers, error); |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 426 | } |
| 427 | |
| 428 | void ModemProxy::Proxy::CreateBearerCallback(const ::DBus::Path &path, |
| 429 | const ::DBus::Error& dberror, |
| 430 | void *data) { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame] | 431 | SLOG(DBus, 2) << __func__; |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 432 | scoped_ptr<ResultCallback> callback(reinterpret_cast<ResultCallback *>(data)); |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 433 | Error error; |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 434 | CellularError::FromDBusError(dberror, &error); |
| 435 | callback->Run(error); |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 436 | } |
| 437 | |
| 438 | void ModemProxy::Proxy::DeleteBearerCallback(const ::DBus::Error& dberror, |
| 439 | void *data) { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame] | 440 | SLOG(DBus, 2) << __func__; |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 441 | scoped_ptr<ResultCallback> callback(reinterpret_cast<ResultCallback *>(data)); |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 442 | Error error; |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 443 | CellularError::FromDBusError(dberror, &error); |
| 444 | callback->Run(error); |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 445 | } |
| 446 | |
| 447 | void ModemProxy::Proxy::ResetCallback(const ::DBus::Error& dberror, |
| 448 | void *data) { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame] | 449 | SLOG(DBus, 2) << __func__; |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 450 | scoped_ptr<ResultCallback> callback(reinterpret_cast<ResultCallback *>(data)); |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 451 | Error error; |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 452 | CellularError::FromDBusError(dberror, &error); |
| 453 | callback->Run(error); |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 454 | } |
| 455 | |
| 456 | void ModemProxy::Proxy::FactoryResetCallback(const ::DBus::Error& dberror, |
| 457 | void *data) { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame] | 458 | SLOG(DBus, 2) << __func__; |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 459 | scoped_ptr<ResultCallback> callback(reinterpret_cast<ResultCallback *>(data)); |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 460 | Error error; |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 461 | CellularError::FromDBusError(dberror, &error); |
| 462 | callback->Run(error); |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 463 | } |
| 464 | |
| 465 | void ModemProxy::Proxy::SetAllowedModesCallback( |
| 466 | const ::DBus::Error& dberror, |
| 467 | void *data) { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame] | 468 | SLOG(DBus, 2) << __func__; |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 469 | scoped_ptr<ResultCallback> callback(reinterpret_cast<ResultCallback *>(data)); |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 470 | Error error; |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 471 | CellularError::FromDBusError(dberror, &error); |
| 472 | callback->Run(error); |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 473 | } |
| 474 | |
| 475 | void ModemProxy::Proxy::SetBandsCallback(const ::DBus::Error& dberror, |
| 476 | void *data) { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame] | 477 | SLOG(DBus, 2) << __func__; |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 478 | scoped_ptr<ResultCallback> callback(reinterpret_cast<ResultCallback *>(data)); |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 479 | Error error; |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 480 | CellularError::FromDBusError(dberror, &error); |
| 481 | callback->Run(error); |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 482 | } |
| 483 | |
| 484 | void ModemProxy::Proxy::CommandCallback(const std::string &response, |
| 485 | const ::DBus::Error& dberror, |
| 486 | void *data) { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame] | 487 | SLOG(DBus, 2) << __func__; |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 488 | scoped_ptr<ResultCallback> callback(reinterpret_cast<ResultCallback *>(data)); |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 489 | Error error; |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 490 | CellularError::FromDBusError(dberror, &error); |
| 491 | callback->Run(error); |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 492 | } |
| 493 | |
| 494 | } // namespace mm1 |
| 495 | } // namespace shill |