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