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 | |
| 9 | #include "cellular_error.h" |
| 10 | |
| 11 | using std::string; |
| 12 | |
| 13 | namespace shill { |
| 14 | namespace mm1 { |
| 15 | |
| 16 | ModemProxy::ModemProxy(ModemProxyDelegate *delegate, |
| 17 | DBus::Connection *connection, |
| 18 | const string &path, |
| 19 | const string &service) |
| 20 | : proxy_(delegate, connection, path, service) {} |
| 21 | |
| 22 | ModemProxy::~ModemProxy() {} |
| 23 | |
| 24 | void ModemProxy::Enable(const bool &enable, |
| 25 | AsyncCallHandler *call_handler, |
| 26 | int timeout) { |
| 27 | proxy_.Enable(enable, call_handler, timeout); |
| 28 | } |
| 29 | |
| 30 | void ModemProxy::ListBearers(AsyncCallHandler *call_handler, |
| 31 | int timeout) { |
| 32 | proxy_.ListBearers(call_handler, timeout); |
| 33 | } |
| 34 | |
| 35 | void ModemProxy::CreateBearer( |
| 36 | const DBusPropertiesMap &properties, |
| 37 | AsyncCallHandler *call_handler, |
| 38 | int timeout) { |
| 39 | proxy_.CreateBearer(properties, call_handler, timeout); |
| 40 | } |
| 41 | |
| 42 | void ModemProxy::DeleteBearer(const ::DBus::Path &bearer, |
| 43 | AsyncCallHandler *call_handler, |
| 44 | int timeout) { |
| 45 | proxy_.DeleteBearer(bearer, call_handler, timeout); |
| 46 | } |
| 47 | |
| 48 | void ModemProxy::Reset(AsyncCallHandler *call_handler, int timeout) { |
| 49 | proxy_.Reset(call_handler, timeout); |
| 50 | } |
| 51 | |
| 52 | void ModemProxy::FactoryReset(const std::string &code, |
| 53 | AsyncCallHandler *call_handler, |
| 54 | int timeout) { |
| 55 | proxy_.FactoryReset(code, call_handler, timeout); |
| 56 | } |
| 57 | |
| 58 | void ModemProxy::SetAllowedModes(const uint32_t &modes, |
| 59 | const uint32_t &preferred, |
| 60 | AsyncCallHandler *call_handler, |
| 61 | int timeout) { |
| 62 | proxy_.SetAllowedModes(modes, preferred, call_handler, timeout); |
| 63 | } |
| 64 | |
| 65 | void ModemProxy::SetBands(const std::vector< uint32_t > &bands, |
| 66 | AsyncCallHandler *call_handler, |
| 67 | int timeout) { |
| 68 | proxy_.SetBands(bands, call_handler, timeout); |
| 69 | } |
| 70 | |
| 71 | void ModemProxy::Command(const std::string &cmd, |
| 72 | const uint32_t &user_timeout, |
| 73 | AsyncCallHandler *call_handler, |
| 74 | int timeout) { |
| 75 | proxy_.Command(cmd, user_timeout, call_handler, timeout); |
| 76 | } |
| 77 | |
| 78 | // Inherited properties from ModemProxyInterface. |
| 79 | const ::DBus::Path ModemProxy::Sim() { |
| 80 | return proxy_.Sim(); |
| 81 | }; |
| 82 | uint32_t ModemProxy::ModemCapabilities() { |
| 83 | return proxy_.ModemCapabilities(); |
| 84 | }; |
| 85 | uint32_t ModemProxy::CurrentCapabilities() { |
| 86 | return proxy_.CurrentCapabilities(); |
| 87 | }; |
| 88 | uint32_t ModemProxy::MaxBearers() { |
| 89 | return proxy_.MaxBearers(); |
| 90 | }; |
| 91 | uint32_t ModemProxy::MaxActiveBearers() { |
| 92 | return proxy_.MaxActiveBearers(); |
| 93 | }; |
| 94 | const std::string ModemProxy::Manufacturer() { |
| 95 | return proxy_.Manufacturer(); |
| 96 | }; |
| 97 | const std::string ModemProxy::Model() { |
| 98 | return proxy_.Model(); |
| 99 | }; |
| 100 | const std::string ModemProxy::Revision() { |
| 101 | return proxy_.Revision(); |
| 102 | }; |
| 103 | const std::string ModemProxy::DeviceIdentifier() { |
| 104 | return proxy_.DeviceIdentifier(); |
| 105 | }; |
| 106 | const std::string ModemProxy::Device() { |
| 107 | return proxy_.Device(); |
| 108 | }; |
| 109 | const std::string ModemProxy::Driver() { |
| 110 | return proxy_.Driver(); |
| 111 | }; |
| 112 | const std::string ModemProxy::Plugin() { |
| 113 | return proxy_.Plugin(); |
| 114 | }; |
| 115 | const std::string ModemProxy::EquipmentIdentifier() { |
| 116 | return proxy_.EquipmentIdentifier(); |
| 117 | }; |
| 118 | uint32_t ModemProxy::UnlockRequired() { |
| 119 | return proxy_.UnlockRequired(); |
| 120 | }; |
| 121 | const std::map< uint32_t, uint32_t > ModemProxy::UnlockRetries() { |
| 122 | return proxy_.UnlockRetries(); |
| 123 | }; |
| 124 | uint32_t ModemProxy::State() { |
| 125 | return proxy_.State(); |
| 126 | }; |
| 127 | uint32_t ModemProxy::AccessTechnologies() { |
| 128 | return proxy_.AccessTechnologies(); |
| 129 | }; |
| 130 | const ::DBus::Struct< uint32_t, bool > ModemProxy::SignalQuality() { |
| 131 | return proxy_.SignalQuality(); |
| 132 | }; |
| 133 | uint32_t ModemProxy::SupportedModes() { |
| 134 | return proxy_.SupportedModes(); |
| 135 | }; |
| 136 | uint32_t ModemProxy::AllowedModes() { |
| 137 | return proxy_.AllowedModes(); |
| 138 | }; |
| 139 | uint32_t ModemProxy::PreferredMode() { |
| 140 | return proxy_.PreferredMode(); |
| 141 | }; |
| 142 | const std::vector< uint32_t > ModemProxy::SupportedBands() { |
| 143 | return proxy_.SupportedBands(); |
| 144 | }; |
| 145 | const std::vector< uint32_t > ModemProxy::Bands() { |
| 146 | return proxy_.Bands(); |
| 147 | }; |
| 148 | |
| 149 | ModemProxy::Proxy::Proxy(ModemProxyDelegate *delegate, |
| 150 | DBus::Connection *connection, |
| 151 | const std::string &path, |
| 152 | const std::string &service) |
| 153 | : DBus::ObjectProxy(*connection, path, service.c_str()), |
| 154 | delegate_(delegate) {} |
| 155 | |
| 156 | ModemProxy::Proxy::~Proxy() {} |
| 157 | |
| 158 | // Signal callbacks inherited from Proxy |
| 159 | void ModemProxy::Proxy::StateChanged(const uint32_t &old, |
| 160 | const uint32_t &_new, |
| 161 | const uint32_t &reason) { |
| 162 | delegate_->OnStateChanged(old, _new, reason); |
| 163 | } |
| 164 | |
| 165 | // Method callbacks inherited from |
| 166 | // org::freedesktop::ModemManager1::ModemProxy |
| 167 | void ModemProxy::Proxy::EnableCallback(const ::DBus::Error& dberror, |
| 168 | void *data) { |
| 169 | AsyncCallHandler *call_handler = reinterpret_cast<AsyncCallHandler *>(data); |
| 170 | Error error; |
| 171 | CellularError::FromDBusError(dberror, &error), |
| 172 | delegate_->OnEnableCallback(error, call_handler); |
| 173 | } |
| 174 | |
| 175 | void ModemProxy::Proxy::ListBearersCallback( |
| 176 | const std::vector< ::DBus::Path > &bearers, |
| 177 | const ::DBus::Error& dberror, |
| 178 | void *data) { |
| 179 | AsyncCallHandler *call_handler = reinterpret_cast<AsyncCallHandler *>(data); |
| 180 | Error error; |
| 181 | CellularError::FromDBusError(dberror, &error), |
| 182 | delegate_->OnListBearersCallback(bearers, error, call_handler); |
| 183 | } |
| 184 | |
| 185 | void ModemProxy::Proxy::CreateBearerCallback(const ::DBus::Path &path, |
| 186 | const ::DBus::Error& dberror, |
| 187 | void *data) { |
| 188 | AsyncCallHandler *call_handler = reinterpret_cast<AsyncCallHandler *>(data); |
| 189 | Error error; |
| 190 | CellularError::FromDBusError(dberror, &error), |
| 191 | delegate_->OnCreateBearerCallback(path, error, call_handler); |
| 192 | } |
| 193 | |
| 194 | void ModemProxy::Proxy::DeleteBearerCallback(const ::DBus::Error& dberror, |
| 195 | void *data) { |
| 196 | AsyncCallHandler *call_handler = reinterpret_cast<AsyncCallHandler *>(data); |
| 197 | Error error; |
| 198 | CellularError::FromDBusError(dberror, &error), |
| 199 | delegate_->OnDeleteBearerCallback(error, call_handler); |
| 200 | } |
| 201 | |
| 202 | void ModemProxy::Proxy::ResetCallback(const ::DBus::Error& dberror, |
| 203 | void *data) { |
| 204 | AsyncCallHandler *call_handler = reinterpret_cast<AsyncCallHandler *>(data); |
| 205 | Error error; |
| 206 | CellularError::FromDBusError(dberror, &error), |
| 207 | delegate_->OnResetCallback(error, call_handler); |
| 208 | } |
| 209 | |
| 210 | void ModemProxy::Proxy::FactoryResetCallback(const ::DBus::Error& dberror, |
| 211 | void *data) { |
| 212 | AsyncCallHandler *call_handler = reinterpret_cast<AsyncCallHandler *>(data); |
| 213 | Error error; |
| 214 | CellularError::FromDBusError(dberror, &error), |
| 215 | delegate_->OnFactoryResetCallback(error, call_handler); |
| 216 | } |
| 217 | |
| 218 | void ModemProxy::Proxy::SetAllowedModesCallback( |
| 219 | const ::DBus::Error& dberror, |
| 220 | void *data) { |
| 221 | AsyncCallHandler *call_handler = reinterpret_cast<AsyncCallHandler *>(data); |
| 222 | Error error; |
| 223 | CellularError::FromDBusError(dberror, &error), |
| 224 | delegate_->OnSetAllowedModesCallback(error, call_handler); |
| 225 | } |
| 226 | |
| 227 | void ModemProxy::Proxy::SetBandsCallback(const ::DBus::Error& dberror, |
| 228 | void *data) { |
| 229 | AsyncCallHandler *call_handler = reinterpret_cast<AsyncCallHandler *>(data); |
| 230 | Error error; |
| 231 | CellularError::FromDBusError(dberror, &error), |
| 232 | delegate_->OnSetBandsCallback(error, call_handler); |
| 233 | } |
| 234 | |
| 235 | void ModemProxy::Proxy::CommandCallback(const std::string &response, |
| 236 | const ::DBus::Error& dberror, |
| 237 | void *data) { |
| 238 | AsyncCallHandler *call_handler = reinterpret_cast<AsyncCallHandler *>(data); |
| 239 | Error error; |
| 240 | CellularError::FromDBusError(dberror, &error), |
| 241 | delegate_->OnCommandCallback(response, error, call_handler); |
| 242 | } |
| 243 | |
| 244 | } // namespace mm1 |
| 245 | } // namespace shill |