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 | |
Ben Chan | c20ed13 | 2014-10-16 12:25:03 -0700 | [diff] [blame] | 7 | #include <memory> |
| 8 | |
Darin Petkov | c37a9c4 | 2012-09-06 15:28:22 +0200 | [diff] [blame] | 9 | #include <base/bind.h> |
| 10 | |
| 11 | #include "shill/cellular_error.h" |
mukesh agrawal | 0e9e9d1 | 2014-04-18 16:09:58 -0700 | [diff] [blame] | 12 | #include "shill/dbus_async_call_helper.h" |
Darin Petkov | c37a9c4 | 2012-09-06 15:28:22 +0200 | [diff] [blame] | 13 | #include "shill/error.h" |
| 14 | #include "shill/logging.h" |
| 15 | |
| 16 | using base::Bind; |
| 17 | using base::Callback; |
| 18 | using std::string; |
Ben Chan | c20ed13 | 2014-10-16 12:25:03 -0700 | [diff] [blame] | 19 | using std::unique_ptr; |
Darin Petkov | c37a9c4 | 2012-09-06 15:28:22 +0200 | [diff] [blame] | 20 | |
| 21 | namespace shill { |
| 22 | |
| 23 | ModemGobiProxy::ModemGobiProxy(DBus::Connection *connection, |
| 24 | const string &path, |
| 25 | const string &service) |
| 26 | : proxy_(connection, path, service) {} |
| 27 | |
| 28 | ModemGobiProxy::~ModemGobiProxy() {} |
| 29 | |
| 30 | void ModemGobiProxy::SetCarrier(const string &carrier, |
| 31 | Error *error, |
| 32 | const ResultCallback &callback, |
| 33 | int timeout) { |
mukesh agrawal | 0e9e9d1 | 2014-04-18 16:09:58 -0700 | [diff] [blame] | 34 | BeginAsyncDBusCall(__func__, proxy_, &Proxy::SetCarrierAsync, callback, |
| 35 | error, &CellularError::FromDBusError, timeout, |
| 36 | carrier); |
Darin Petkov | c37a9c4 | 2012-09-06 15:28:22 +0200 | [diff] [blame] | 37 | } |
| 38 | |
| 39 | ModemGobiProxy::Proxy::Proxy(DBus::Connection *connection, |
| 40 | const string &path, |
| 41 | const string &service) |
| 42 | : DBus::ObjectProxy(*connection, path, service.c_str()) {} |
| 43 | |
| 44 | ModemGobiProxy::Proxy::~Proxy() {} |
| 45 | |
| 46 | void ModemGobiProxy::Proxy::SetCarrierCallback(const DBus::Error &dberror, |
| 47 | void *data) { |
| 48 | SLOG(DBus, 2) << __func__; |
Ben Chan | c20ed13 | 2014-10-16 12:25:03 -0700 | [diff] [blame] | 49 | unique_ptr<ResultCallback> callback(reinterpret_cast<ResultCallback *>(data)); |
Darin Petkov | c37a9c4 | 2012-09-06 15:28:22 +0200 | [diff] [blame] | 50 | Error error; |
| 51 | CellularError::FromDBusError(dberror, &error); |
| 52 | callback->Run(error); |
| 53 | } |
| 54 | |
| 55 | } // namespace shill |