blob: 9b93cfeb7be869f89367fefabf1e114b090e9181 [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
7#include <base/logging.h>
Ben Chanb879d142012-05-15 11:10:32 -07008#include <chromeos/dbus/service_constants.h>
Darin Petkov096b3472012-05-15 10:26:22 +02009
Darin Petkov9893d9c2012-05-17 15:27:31 -070010#include "shill/dbus_properties.h"
Darin Petkov096b3472012-05-15 10:26:22 +020011#include "shill/error.h"
12#include "shill/scope_logger.h"
13
14using std::vector;
15
16namespace shill {
17
Darin Petkov096b3472012-05-15 10:26:22 +020018WiMaxManagerProxy::WiMaxManagerProxy(DBus::Connection *connection)
19 : proxy_(connection) {}
20
21WiMaxManagerProxy::~WiMaxManagerProxy() {}
22
Darin Petkov9893d9c2012-05-17 15:27:31 -070023void WiMaxManagerProxy::set_devices_changed_callback(
24 const DevicesChangedCallback &callback) {
25 proxy_.set_devices_changed_callback(callback);
26}
27
28RpcIdentifiers WiMaxManagerProxy::Devices(Error *error) {
Darin Petkov096b3472012-05-15 10:26:22 +020029 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 Petkov9893d9c2012-05-17 15:27:31 -070036 RpcIdentifiers devices;
37 DBusProperties::ConvertPathsToRpcIdentifiers(dbus_devices, &devices);
Darin Petkov096b3472012-05-15 10:26:22 +020038 return devices;
39}
40
41WiMaxManagerProxy::Proxy::Proxy(DBus::Connection *connection)
42 : DBus::ObjectProxy(*connection,
Ben Chanb879d142012-05-15 11:10:32 -070043 wimax_manager::kWiMaxManagerServicePath,
44 wimax_manager::kWiMaxManagerServiceName) {}
Darin Petkov096b3472012-05-15 10:26:22 +020045
46WiMaxManagerProxy::Proxy::~Proxy() {}
47
Darin Petkov9893d9c2012-05-17 15:27:31 -070048void WiMaxManagerProxy::Proxy::set_devices_changed_callback(
49 const DevicesChangedCallback &callback) {
50 devices_changed_callback_ = callback;
51}
52
53void 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 Petkov096b3472012-05-15 10:26:22 +020064} // namespace shill