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