blob: bd94611d7a80d353b6650c7ef50f0db8f7c4dabb [file] [log] [blame]
Darin Petkov096b3472012-05-15 10:26:22 +02001// 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 Chanb879d142012-05-15 11:10:32 -07007#include <chromeos/dbus/service_constants.h>
Darin Petkov096b3472012-05-15 10:26:22 +02008
Darin Petkov9893d9c2012-05-17 15:27:31 -07009#include "shill/dbus_properties.h"
Darin Petkov096b3472012-05-15 10:26:22 +020010#include "shill/error.h"
Christopher Wileyb691efd2012-08-09 13:51:51 -070011#include "shill/logging.h"
Darin Petkov096b3472012-05-15 10:26:22 +020012
13using std::vector;
14
15namespace shill {
16
Darin Petkov096b3472012-05-15 10:26:22 +020017WiMaxManagerProxy::WiMaxManagerProxy(DBus::Connection *connection)
18 : proxy_(connection) {}
19
20WiMaxManagerProxy::~WiMaxManagerProxy() {}
21
Darin Petkov9893d9c2012-05-17 15:27:31 -070022void WiMaxManagerProxy::set_devices_changed_callback(
23 const DevicesChangedCallback &callback) {
24 proxy_.set_devices_changed_callback(callback);
25}
26
27RpcIdentifiers WiMaxManagerProxy::Devices(Error *error) {
Darin Petkov096b3472012-05-15 10:26:22 +020028 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 Petkov9893d9c2012-05-17 15:27:31 -070035 RpcIdentifiers devices;
36 DBusProperties::ConvertPathsToRpcIdentifiers(dbus_devices, &devices);
Darin Petkov096b3472012-05-15 10:26:22 +020037 return devices;
38}
39
40WiMaxManagerProxy::Proxy::Proxy(DBus::Connection *connection)
41 : DBus::ObjectProxy(*connection,
Ben Chanb879d142012-05-15 11:10:32 -070042 wimax_manager::kWiMaxManagerServicePath,
43 wimax_manager::kWiMaxManagerServiceName) {}
Darin Petkov096b3472012-05-15 10:26:22 +020044
45WiMaxManagerProxy::Proxy::~Proxy() {}
46
Darin Petkov9893d9c2012-05-17 15:27:31 -070047void WiMaxManagerProxy::Proxy::set_devices_changed_callback(
48 const DevicesChangedCallback &callback) {
49 devices_changed_callback_ = callback;
50}
51
52void 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 Petkov096b3472012-05-15 10:26:22 +020063} // namespace shill