Arman Uguray | 6e5639f | 2012-11-15 20:30:19 -0800 | [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_bearer_proxy.h" |
| 6 | |
| 7 | #include "shill/cellular_error.h" |
mukesh agrawal | 0e9e9d1 | 2014-04-18 16:09:58 -0700 | [diff] [blame] | 8 | #include "shill/dbus_async_call_helper.h" |
Arman Uguray | 6e5639f | 2012-11-15 20:30:19 -0800 | [diff] [blame] | 9 | #include "shill/logging.h" |
| 10 | |
| 11 | using std::string; |
| 12 | |
| 13 | namespace shill { |
| 14 | namespace mm1 { |
| 15 | |
| 16 | BearerProxy::BearerProxy(DBus::Connection *connection, |
| 17 | const std::string &path, |
| 18 | const std::string &service) |
| 19 | : proxy_(connection, path, service) {} |
| 20 | |
| 21 | BearerProxy::~BearerProxy() {} |
| 22 | |
| 23 | |
| 24 | // Inherited methods from BearerProxyInterface |
| 25 | void BearerProxy::Connect(Error *error, |
| 26 | const ResultCallback &callback, |
| 27 | int timeout) { |
mukesh agrawal | 0e9e9d1 | 2014-04-18 16:09:58 -0700 | [diff] [blame] | 28 | BeginAsyncDBusCall(__func__, proxy_, &Proxy::ConnectAsync, callback, |
| 29 | error, &CellularError::FromMM1DBusError, timeout); |
Arman Uguray | 6e5639f | 2012-11-15 20:30:19 -0800 | [diff] [blame] | 30 | } |
| 31 | |
| 32 | void BearerProxy::Disconnect(Error *error, |
| 33 | const ResultCallback &callback, |
| 34 | int timeout) { |
mukesh agrawal | 0e9e9d1 | 2014-04-18 16:09:58 -0700 | [diff] [blame] | 35 | BeginAsyncDBusCall(__func__, proxy_, &Proxy::DisconnectAsync, callback, |
| 36 | error, &CellularError::FromMM1DBusError, timeout); |
Arman Uguray | 6e5639f | 2012-11-15 20:30:19 -0800 | [diff] [blame] | 37 | } |
| 38 | |
Arman Uguray | 6e5639f | 2012-11-15 20:30:19 -0800 | [diff] [blame] | 39 | BearerProxy::Proxy::Proxy(DBus::Connection *connection, |
| 40 | const std::string &path, |
| 41 | const std::string &service) |
| 42 | : DBus::ObjectProxy(*connection, path, service.c_str()) {} |
| 43 | |
| 44 | BearerProxy::Proxy::~Proxy() {} |
| 45 | |
| 46 | |
| 47 | // Method callbacks inherited from |
| 48 | // org::freedesktop::ModemManager1::BearerProxy |
| 49 | void BearerProxy::Proxy::ConnectCallback(const ::DBus::Error &dberror, |
| 50 | void *data) { |
| 51 | SLOG(DBus, 2) << __func__; |
| 52 | scoped_ptr<ResultCallback> callback(reinterpret_cast<ResultCallback *>(data)); |
| 53 | Error error; |
Arman Uguray | 763df86 | 2013-07-02 12:49:10 -0700 | [diff] [blame] | 54 | CellularError::FromMM1DBusError(dberror, &error); |
Arman Uguray | 6e5639f | 2012-11-15 20:30:19 -0800 | [diff] [blame] | 55 | callback->Run(error); |
| 56 | } |
| 57 | |
| 58 | void BearerProxy::Proxy::DisconnectCallback(const ::DBus::Error &dberror, |
| 59 | void *data) { |
| 60 | SLOG(DBus, 2) << __func__; |
| 61 | scoped_ptr<ResultCallback> callback(reinterpret_cast<ResultCallback *>(data)); |
| 62 | Error error; |
Arman Uguray | 763df86 | 2013-07-02 12:49:10 -0700 | [diff] [blame] | 63 | CellularError::FromMM1DBusError(dberror, &error); |
Arman Uguray | 6e5639f | 2012-11-15 20:30:19 -0800 | [diff] [blame] | 64 | callback->Run(error); |
| 65 | } |
| 66 | |
| 67 | } // namespace mm1 |
| 68 | } // namespace shill |