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 | |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 117 | void ModemProxy::Command(const std::string &cmd, |
| 118 | const uint32_t &user_timeout, |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 119 | Error *error, |
| 120 | const StringCallback &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<StringCallback> cb(new StringCallback(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_.Command(cmd, user_timeout, 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 | |
Arman Uguray | ee464d3 | 2013-02-13 17:14:36 -0800 | [diff] [blame] | 133 | void ModemProxy::SetPowerState(const uint32_t &power_state, |
| 134 | Error *error, |
| 135 | const ResultCallback &callback, |
| 136 | int timeout) { |
| 137 | scoped_ptr<ResultCallback> cb(new ResultCallback(callback)); |
| 138 | try { |
| 139 | SLOG(DBus, 2) << __func__; |
| 140 | proxy_.SetPowerState(power_state, cb.get(), timeout); |
| 141 | cb.release(); |
| 142 | } catch (const DBus::Error &e) { |
| 143 | if (error) |
| 144 | CellularError::FromDBusError(e, error); |
| 145 | } |
| 146 | } |
| 147 | |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 148 | // Inherited properties from ModemProxyInterface. |
| 149 | const ::DBus::Path ModemProxy::Sim() { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame] | 150 | SLOG(DBus, 2) << __func__; |
Gary Morain | 610977f | 2012-05-04 16:03:52 -0700 | [diff] [blame] | 151 | try { |
| 152 | return proxy_.Sim(); |
| 153 | } catch (const DBus::Error &e) { |
| 154 | LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what(); |
| 155 | return ::DBus::Path(); // Make the compiler happy. |
| 156 | } |
Jason Glasgow | 90d216d | 2012-04-04 15:57:14 -0400 | [diff] [blame] | 157 | } |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 158 | uint32_t ModemProxy::CurrentCapabilities() { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame] | 159 | SLOG(DBus, 2) << __func__; |
Gary Morain | 610977f | 2012-05-04 16:03:52 -0700 | [diff] [blame] | 160 | try { |
| 161 | return proxy_.CurrentCapabilities(); |
| 162 | } catch (const DBus::Error &e) { |
| 163 | LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what(); |
| 164 | return 0; // Make the compiler happy. |
| 165 | } |
Jason Glasgow | 90d216d | 2012-04-04 15:57:14 -0400 | [diff] [blame] | 166 | } |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 167 | uint32_t ModemProxy::MaxBearers() { |
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_.MaxBearers(); |
| 171 | } catch (const DBus::Error &e) { |
| 172 | LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what(); |
| 173 | return 0; // 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::MaxActiveBearers() { |
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_.MaxActiveBearers(); |
| 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 | const std::string ModemProxy::Manufacturer() { |
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_.Manufacturer(); |
| 189 | } catch (const DBus::Error &e) { |
| 190 | LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what(); |
| 191 | return std::string(); // 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 | const std::string ModemProxy::Model() { |
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_.Model(); |
| 198 | } catch (const DBus::Error &e) { |
| 199 | LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what(); |
| 200 | return std::string(); // 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 | const std::string ModemProxy::Revision() { |
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_.Revision(); |
| 207 | } catch (const DBus::Error &e) { |
| 208 | LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what(); |
| 209 | return std::string(); // 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::DeviceIdentifier() { |
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_.DeviceIdentifier(); |
| 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::Device() { |
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_.Device(); |
| 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 | } |
Ben Chan | 34e5d68 | 2012-08-24 19:10:49 -0700 | [diff] [blame] | 230 | const std::vector<std::string> ModemProxy::Drivers() { |
| 231 | SLOG(DBus, 2) << __func__; |
| 232 | try { |
| 233 | return proxy_.Drivers(); |
| 234 | } catch (const DBus::Error &e) { |
| 235 | LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what(); |
| 236 | return std::vector<std::string>(); // Make the compiler happy. |
| 237 | } |
| 238 | } |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 239 | const std::string ModemProxy::Plugin() { |
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_.Plugin(); |
| 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::EquipmentIdentifier() { |
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_.EquipmentIdentifier(); |
| 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 | uint32_t ModemProxy::UnlockRequired() { |
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_.UnlockRequired(); |
| 261 | } catch (const DBus::Error &e) { |
| 262 | LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what(); |
| 263 | return 0; // Make the compiler happy. |
| 264 | } |
Jason Glasgow | 90d216d | 2012-04-04 15:57:14 -0400 | [diff] [blame] | 265 | } |
Gary Morain | 610977f | 2012-05-04 16:03:52 -0700 | [diff] [blame] | 266 | const std::map<uint32_t, uint32_t> ModemProxy::UnlockRetries() { |
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_.UnlockRetries(); |
| 270 | } catch (const DBus::Error &e) { |
| 271 | LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what(); |
| 272 | return std::map<uint32_t, uint32_t>(); // 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 | uint32_t ModemProxy::State() { |
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_.State(); |
| 279 | } catch (const DBus::Error &e) { |
| 280 | LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what(); |
| 281 | return 0; // 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::AccessTechnologies() { |
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_.AccessTechnologies(); |
| 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 ::DBus::Struct<uint32_t, bool> ModemProxy::SignalQuality() { |
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_.SignalQuality(); |
| 297 | } catch (const DBus::Error &e) { |
| 298 | LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what(); |
| 299 | return ::DBus::Struct<uint32_t, bool>(); // Make the compiler happy. |
| 300 | } |
Jason Glasgow | 90d216d | 2012-04-04 15:57:14 -0400 | [diff] [blame] | 301 | } |
| 302 | const std::vector<string> ModemProxy::OwnNumbers() { |
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_.OwnNumbers(); |
| 306 | } catch (const DBus::Error &e) { |
| 307 | LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what(); |
| 308 | return std::vector<string>(); // Make the compiler happy. |
| 309 | } |
Jason Glasgow | 90d216d | 2012-04-04 15:57:14 -0400 | [diff] [blame] | 310 | } |
Gary Morain | 610977f | 2012-05-04 16:03:52 -0700 | [diff] [blame] | 311 | const std::vector<uint32_t> ModemProxy::SupportedBands() { |
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_.SupportedBands(); |
| 315 | } catch (const DBus::Error &e) { |
| 316 | LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what(); |
| 317 | return std::vector<uint32_t>(); // Make the compiler happy. |
| 318 | } |
Jason Glasgow | 90d216d | 2012-04-04 15:57:14 -0400 | [diff] [blame] | 319 | } |
Arman Uguray | ee464d3 | 2013-02-13 17:14:36 -0800 | [diff] [blame] | 320 | uint32_t ModemProxy::PowerState() { |
| 321 | SLOG(DBus, 2) << __func__; |
| 322 | try { |
| 323 | return proxy_.PowerState(); |
| 324 | } catch (const DBus::Error &e) { |
| 325 | LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what(); |
| 326 | return 0; // Make the compiler happy. |
| 327 | } |
| 328 | } |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 329 | |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 330 | ModemProxy::Proxy::Proxy(DBus::Connection *connection, |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 331 | const std::string &path, |
| 332 | const std::string &service) |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 333 | : DBus::ObjectProxy(*connection, path, service.c_str()) {} |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 334 | |
| 335 | ModemProxy::Proxy::~Proxy() {} |
| 336 | |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 337 | void ModemProxy::Proxy::set_state_changed_callback( |
| 338 | const ModemStateChangedSignalCallback &callback) { |
| 339 | state_changed_callback_ = callback; |
| 340 | } |
| 341 | |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 342 | // Signal callbacks inherited from Proxy |
Nathan Williams | a31e79c | 2012-03-30 15:07:00 -0400 | [diff] [blame] | 343 | void ModemProxy::Proxy::StateChanged(const int32_t &old, |
| 344 | const int32_t &_new, |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 345 | const uint32_t &reason) { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame] | 346 | SLOG(DBus, 2) << __func__; |
Jason Glasgow | 82f9ab3 | 2012-04-04 14:27:19 -0400 | [diff] [blame] | 347 | if (!state_changed_callback_.is_null()) |
| 348 | state_changed_callback_.Run(old, _new, reason); |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 349 | } |
| 350 | |
| 351 | // Method callbacks inherited from |
| 352 | // org::freedesktop::ModemManager1::ModemProxy |
| 353 | void ModemProxy::Proxy::EnableCallback(const ::DBus::Error& dberror, |
| 354 | void *data) { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame] | 355 | SLOG(DBus, 2) << __func__; |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 356 | scoped_ptr<ResultCallback> callback(reinterpret_cast<ResultCallback *>(data)); |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 357 | Error error; |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 358 | CellularError::FromDBusError(dberror, &error); |
| 359 | callback->Run(error); |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 360 | } |
| 361 | |
| 362 | void ModemProxy::Proxy::ListBearersCallback( |
Gary Morain | 610977f | 2012-05-04 16:03:52 -0700 | [diff] [blame] | 363 | const std::vector< ::DBus::Path> &bearers, |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 364 | const ::DBus::Error& dberror, |
| 365 | void *data) { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame] | 366 | SLOG(DBus, 2) << __func__; |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 367 | scoped_ptr<DBusPathsCallback> callback( |
| 368 | reinterpret_cast<DBusPathsCallback *>(data)); |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 369 | Error error; |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 370 | CellularError::FromDBusError(dberror, &error); |
| 371 | callback->Run(bearers, error); |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 372 | } |
| 373 | |
| 374 | void ModemProxy::Proxy::CreateBearerCallback(const ::DBus::Path &path, |
| 375 | const ::DBus::Error& dberror, |
| 376 | void *data) { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame] | 377 | SLOG(DBus, 2) << __func__; |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 378 | scoped_ptr<ResultCallback> callback(reinterpret_cast<ResultCallback *>(data)); |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 379 | Error error; |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 380 | CellularError::FromDBusError(dberror, &error); |
| 381 | callback->Run(error); |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 382 | } |
| 383 | |
| 384 | void ModemProxy::Proxy::DeleteBearerCallback(const ::DBus::Error& dberror, |
| 385 | void *data) { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame] | 386 | SLOG(DBus, 2) << __func__; |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 387 | scoped_ptr<ResultCallback> callback(reinterpret_cast<ResultCallback *>(data)); |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 388 | Error error; |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 389 | CellularError::FromDBusError(dberror, &error); |
| 390 | callback->Run(error); |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 391 | } |
| 392 | |
| 393 | void ModemProxy::Proxy::ResetCallback(const ::DBus::Error& dberror, |
| 394 | void *data) { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame] | 395 | SLOG(DBus, 2) << __func__; |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 396 | scoped_ptr<ResultCallback> callback(reinterpret_cast<ResultCallback *>(data)); |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 397 | Error error; |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 398 | CellularError::FromDBusError(dberror, &error); |
| 399 | callback->Run(error); |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 400 | } |
| 401 | |
| 402 | void ModemProxy::Proxy::FactoryResetCallback(const ::DBus::Error& dberror, |
| 403 | void *data) { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame] | 404 | SLOG(DBus, 2) << __func__; |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 405 | scoped_ptr<ResultCallback> callback(reinterpret_cast<ResultCallback *>(data)); |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 406 | Error error; |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 407 | CellularError::FromDBusError(dberror, &error); |
| 408 | callback->Run(error); |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 409 | } |
| 410 | |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 411 | void ModemProxy::Proxy::CommandCallback(const std::string &response, |
| 412 | const ::DBus::Error& dberror, |
| 413 | void *data) { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame] | 414 | SLOG(DBus, 2) << __func__; |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 415 | scoped_ptr<ResultCallback> callback(reinterpret_cast<ResultCallback *>(data)); |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 416 | Error error; |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 417 | CellularError::FromDBusError(dberror, &error); |
| 418 | callback->Run(error); |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 419 | } |
| 420 | |
Arman Uguray | ee464d3 | 2013-02-13 17:14:36 -0800 | [diff] [blame] | 421 | void ModemProxy::Proxy::SetPowerStateCallback(const ::DBus::Error &dberror, |
| 422 | void *data) { |
| 423 | SLOG(DBus, 2) << __func__; |
| 424 | scoped_ptr<ResultCallback> callback(reinterpret_cast<ResultCallback *>(data)); |
| 425 | Error error; |
| 426 | CellularError::FromDBusError(dberror, &error); |
| 427 | callback->Run(error); |
| 428 | } |
| 429 | |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 430 | } // namespace mm1 |
| 431 | } // namespace shill |