Darin Petkov | c37a9c4 | 2012-09-06 15:28:22 +0200 | [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/modem_gobi_proxy.h" |
| 6 | |
| 7 | #include <base/bind.h> |
| 8 | |
| 9 | #include "shill/cellular_error.h" |
| 10 | #include "shill/error.h" |
| 11 | #include "shill/logging.h" |
| 12 | |
| 13 | using base::Bind; |
| 14 | using base::Callback; |
| 15 | using std::string; |
| 16 | |
| 17 | namespace shill { |
| 18 | |
| 19 | ModemGobiProxy::ModemGobiProxy(DBus::Connection *connection, |
| 20 | const string &path, |
| 21 | const string &service) |
| 22 | : proxy_(connection, path, service) {} |
| 23 | |
| 24 | ModemGobiProxy::~ModemGobiProxy() {} |
| 25 | |
| 26 | void ModemGobiProxy::SetCarrier(const string &carrier, |
| 27 | Error *error, |
| 28 | const ResultCallback &callback, |
| 29 | int timeout) { |
| 30 | scoped_ptr<ResultCallback> cb(new ResultCallback(callback)); |
| 31 | try { |
| 32 | SLOG(DBus, 2) << __func__; |
| 33 | proxy_.SetCarrier(carrier, cb.get(), timeout); |
| 34 | cb.release(); |
| 35 | } catch (const DBus::Error &e) { |
| 36 | if (error) { |
| 37 | CellularError::FromDBusError(e, error); |
| 38 | } |
| 39 | } |
| 40 | } |
| 41 | |
| 42 | ModemGobiProxy::Proxy::Proxy(DBus::Connection *connection, |
| 43 | const string &path, |
| 44 | const string &service) |
| 45 | : DBus::ObjectProxy(*connection, path, service.c_str()) {} |
| 46 | |
| 47 | ModemGobiProxy::Proxy::~Proxy() {} |
| 48 | |
| 49 | void ModemGobiProxy::Proxy::SetCarrierCallback(const DBus::Error &dberror, |
| 50 | void *data) { |
| 51 | SLOG(DBus, 2) << __func__; |
| 52 | scoped_ptr<ResultCallback> callback(reinterpret_cast<ResultCallback *>(data)); |
| 53 | Error error; |
| 54 | CellularError::FromDBusError(dberror, &error); |
| 55 | callback->Run(error); |
| 56 | } |
| 57 | |
| 58 | } // namespace shill |