Darin Petkov | 096b347 | 2012-05-15 10:26: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/wimax_manager_proxy.h" |
| 6 | |
Ben Chan | b879d14 | 2012-05-15 11:10:32 -0700 | [diff] [blame] | 7 | #include <chromeos/dbus/service_constants.h> |
Darin Petkov | 096b347 | 2012-05-15 10:26:22 +0200 | [diff] [blame] | 8 | |
Darin Petkov | 9893d9c | 2012-05-17 15:27:31 -0700 | [diff] [blame] | 9 | #include "shill/dbus_properties.h" |
Darin Petkov | 096b347 | 2012-05-15 10:26:22 +0200 | [diff] [blame] | 10 | #include "shill/error.h" |
Christopher Wiley | b691efd | 2012-08-09 13:51:51 -0700 | [diff] [blame] | 11 | #include "shill/logging.h" |
Darin Petkov | 096b347 | 2012-05-15 10:26:22 +0200 | [diff] [blame] | 12 | |
| 13 | using std::vector; |
| 14 | |
| 15 | namespace shill { |
| 16 | |
Darin Petkov | 096b347 | 2012-05-15 10:26:22 +0200 | [diff] [blame] | 17 | WiMaxManagerProxy::WiMaxManagerProxy(DBus::Connection *connection) |
| 18 | : proxy_(connection) {} |
| 19 | |
| 20 | WiMaxManagerProxy::~WiMaxManagerProxy() {} |
| 21 | |
Darin Petkov | 9893d9c | 2012-05-17 15:27:31 -0700 | [diff] [blame] | 22 | void WiMaxManagerProxy::set_devices_changed_callback( |
| 23 | const DevicesChangedCallback &callback) { |
| 24 | proxy_.set_devices_changed_callback(callback); |
| 25 | } |
| 26 | |
| 27 | RpcIdentifiers WiMaxManagerProxy::Devices(Error *error) { |
Darin Petkov | 096b347 | 2012-05-15 10:26:22 +0200 | [diff] [blame] | 28 | SLOG(DBus, 2) << __func__; |
| 29 | vector<DBus::Path> dbus_devices; |
| 30 | try { |
| 31 | dbus_devices = proxy_.Devices(); |
| 32 | } catch (const DBus::Error &e) { |
| 33 | Error::PopulateAndLog(error, Error::kOperationFailed, e.what()); |
| 34 | } |
Darin Petkov | 9893d9c | 2012-05-17 15:27:31 -0700 | [diff] [blame] | 35 | RpcIdentifiers devices; |
| 36 | DBusProperties::ConvertPathsToRpcIdentifiers(dbus_devices, &devices); |
Darin Petkov | 096b347 | 2012-05-15 10:26:22 +0200 | [diff] [blame] | 37 | return devices; |
| 38 | } |
| 39 | |
| 40 | WiMaxManagerProxy::Proxy::Proxy(DBus::Connection *connection) |
| 41 | : DBus::ObjectProxy(*connection, |
Ben Chan | b879d14 | 2012-05-15 11:10:32 -0700 | [diff] [blame] | 42 | wimax_manager::kWiMaxManagerServicePath, |
| 43 | wimax_manager::kWiMaxManagerServiceName) {} |
Darin Petkov | 096b347 | 2012-05-15 10:26:22 +0200 | [diff] [blame] | 44 | |
| 45 | WiMaxManagerProxy::Proxy::~Proxy() {} |
| 46 | |
Darin Petkov | 9893d9c | 2012-05-17 15:27:31 -0700 | [diff] [blame] | 47 | void WiMaxManagerProxy::Proxy::set_devices_changed_callback( |
| 48 | const DevicesChangedCallback &callback) { |
| 49 | devices_changed_callback_ = callback; |
| 50 | } |
| 51 | |
| 52 | void WiMaxManagerProxy::Proxy::DevicesChanged( |
| 53 | const vector<DBus::Path> &devices) { |
| 54 | SLOG(DBus, 2) << __func__ << "(" << devices.size() << ")"; |
| 55 | if (devices_changed_callback_.is_null()) { |
| 56 | return; |
| 57 | } |
| 58 | RpcIdentifiers rpc_devices; |
| 59 | DBusProperties::ConvertPathsToRpcIdentifiers(devices, &rpc_devices); |
| 60 | devices_changed_callback_.Run(rpc_devices); |
| 61 | } |
| 62 | |
Darin Petkov | 096b347 | 2012-05-15 10:26:22 +0200 | [diff] [blame] | 63 | } // namespace shill |