Eric Shienbrood | 5de44ab | 2011-12-05 10:46:27 -0500 | [diff] [blame^] | 1 | // Copyright (c) 2012 The Chromium OS Authors. All rights reserved. |
Darin Petkov | e604f70 | 2011-07-28 15:51:17 -0700 | [diff] [blame] | 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_simple_proxy.h" |
| 6 | |
Eric Shienbrood | 5de44ab | 2011-12-05 10:46:27 -0500 | [diff] [blame^] | 7 | #include "shill/cellular_error.h" |
| 8 | #include "shill/error.h" |
| 9 | |
Darin Petkov | e604f70 | 2011-07-28 15:51:17 -0700 | [diff] [blame] | 10 | using std::string; |
| 11 | |
| 12 | namespace shill { |
| 13 | |
Eric Shienbrood | 5de44ab | 2011-12-05 10:46:27 -0500 | [diff] [blame^] | 14 | ModemSimpleProxy::ModemSimpleProxy(ModemSimpleProxyDelegate *delegate, |
| 15 | DBus::Connection *connection, |
Darin Petkov | e604f70 | 2011-07-28 15:51:17 -0700 | [diff] [blame] | 16 | const string &path, |
| 17 | const string &service) |
Eric Shienbrood | 5de44ab | 2011-12-05 10:46:27 -0500 | [diff] [blame^] | 18 | : proxy_(delegate, connection, path, service) {} |
Darin Petkov | e604f70 | 2011-07-28 15:51:17 -0700 | [diff] [blame] | 19 | |
| 20 | ModemSimpleProxy::~ModemSimpleProxy() {} |
| 21 | |
Eric Shienbrood | 5de44ab | 2011-12-05 10:46:27 -0500 | [diff] [blame^] | 22 | void ModemSimpleProxy::GetModemStatus(AsyncCallHandler *call_handler, |
| 23 | int timeout) { |
| 24 | proxy_.GetStatus(call_handler, timeout); |
Darin Petkov | e604f70 | 2011-07-28 15:51:17 -0700 | [diff] [blame] | 25 | } |
| 26 | |
Eric Shienbrood | 5de44ab | 2011-12-05 10:46:27 -0500 | [diff] [blame^] | 27 | void ModemSimpleProxy::Connect(const DBusPropertiesMap &properties, |
| 28 | AsyncCallHandler *call_handler, int timeout) { |
| 29 | proxy_.Connect(properties, call_handler, timeout); |
Darin Petkov | c5f5656 | 2011-08-06 16:40:05 -0700 | [diff] [blame] | 30 | } |
| 31 | |
Eric Shienbrood | 5de44ab | 2011-12-05 10:46:27 -0500 | [diff] [blame^] | 32 | ModemSimpleProxy::Proxy::Proxy(ModemSimpleProxyDelegate *delegate, |
| 33 | DBus::Connection *connection, |
Darin Petkov | e604f70 | 2011-07-28 15:51:17 -0700 | [diff] [blame] | 34 | const string &path, |
| 35 | const string &service) |
Eric Shienbrood | 5de44ab | 2011-12-05 10:46:27 -0500 | [diff] [blame^] | 36 | : DBus::ObjectProxy(*connection, path, service.c_str()), |
| 37 | delegate_(delegate) {} |
Darin Petkov | e604f70 | 2011-07-28 15:51:17 -0700 | [diff] [blame] | 38 | |
| 39 | ModemSimpleProxy::Proxy::~Proxy() {} |
| 40 | |
Eric Shienbrood | 5de44ab | 2011-12-05 10:46:27 -0500 | [diff] [blame^] | 41 | void ModemSimpleProxy::Proxy::GetStatusCallback(const DBusPropertiesMap &props, |
| 42 | const DBus::Error &dberror, |
| 43 | void *data) { |
| 44 | AsyncCallHandler *call_handler = reinterpret_cast<AsyncCallHandler *>(data); |
| 45 | Error error; |
| 46 | CellularError::FromDBusError(dberror, &error); |
| 47 | delegate_->OnGetModemStatusCallback(props, error, call_handler); |
| 48 | } |
| 49 | |
| 50 | void ModemSimpleProxy::Proxy::ConnectCallback(const DBus::Error &dberror, |
| 51 | void *data) { |
| 52 | AsyncCallHandler *call_handler = reinterpret_cast<AsyncCallHandler *>(data); |
| 53 | Error error; |
| 54 | CellularError::FromDBusError(dberror, &error); |
| 55 | delegate_->OnConnectCallback(error, call_handler); |
| 56 | } |
| 57 | |
Darin Petkov | e604f70 | 2011-07-28 15:51:17 -0700 | [diff] [blame] | 58 | } // namespace shill |