blob: 2d3c04e1fdcaa9a69d4c58384f4c290327e1a97a [file] [log] [blame]
Darin Petkov9893d9c2012-05-17 15:27:31 -07001// 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_network_proxy.h"
6
Darin Petkov9893d9c2012-05-17 15:27:31 -07007#include <chromeos/dbus/service_constants.h>
8
9#include "shill/error.h"
Christopher Wileyb691efd2012-08-09 13:51:51 -070010#include "shill/logging.h"
Darin Petkov9893d9c2012-05-17 15:27:31 -070011
12using std::string;
13
14namespace shill {
15
16WiMaxNetworkProxy::WiMaxNetworkProxy(DBus::Connection *connection,
17 const DBus::Path &path)
18 : proxy_(connection, path) {}
19
20WiMaxNetworkProxy::~WiMaxNetworkProxy() {}
21
Darin Petkov1e52a1b2012-05-21 10:35:56 +020022RpcIdentifier WiMaxNetworkProxy::path() const {
Ben Chan4e5c1312012-05-18 18:45:38 -070023 return proxy_.path();
24}
25
Darin Petkov1e52a1b2012-05-21 10:35:56 +020026void WiMaxNetworkProxy::set_signal_strength_changed_callback(
27 const SignalStrengthChangedCallback &callback) {
28 proxy_.set_signal_strength_changed_callback(callback);
29}
30
Darin Petkov9893d9c2012-05-17 15:27:31 -070031uint32 WiMaxNetworkProxy::Identifier(Error *error) {
32 SLOG(DBus, 2) << __func__;
33 try {
34 return proxy_.Identifier();
35 } catch (const DBus::Error &e) {
36 FromDBusError(e, error);
37 }
38 return 0;
39}
40
41string WiMaxNetworkProxy::Name(Error *error) {
42 SLOG(DBus, 2) << __func__;
43 try {
44 return proxy_.Name();
45 } catch (const DBus::Error &e) {
46 FromDBusError(e, error);
47 }
48 return string();
49}
50
51int WiMaxNetworkProxy::Type(Error *error) {
52 SLOG(DBus, 2) << __func__;
53 try {
54 return proxy_.Type();
55 } catch (const DBus::Error &e) {
56 FromDBusError(e, error);
57 }
58 return 0;
59}
60
61int WiMaxNetworkProxy::CINR(Error *error) {
62 SLOG(DBus, 2) << __func__;
63 try {
64 return proxy_.CINR();
65 } catch (const DBus::Error &e) {
66 FromDBusError(e, error);
67 }
68 return 0;
69}
70
71int WiMaxNetworkProxy::RSSI(Error *error) {
72 SLOG(DBus, 2) << __func__;
73 try {
74 return proxy_.RSSI();
75 } catch (const DBus::Error &e) {
76 FromDBusError(e, error);
77 }
78 return 0;
79}
80
Ben Chanac6e8362012-05-20 00:39:58 -070081int WiMaxNetworkProxy::SignalStrength(Error *error) {
82 SLOG(DBus, 2) << __func__;
83 try {
84 return proxy_.SignalStrength();
85 } catch (const DBus::Error &e) {
86 FromDBusError(e, error);
87 }
88 return 0;
89}
90
Darin Petkov9893d9c2012-05-17 15:27:31 -070091// static
92void WiMaxNetworkProxy::FromDBusError(const DBus::Error &dbus_error,
93 Error *error) {
94 if (!error) {
95 return;
96 }
97 if (!dbus_error.is_set()) {
98 error->Reset();
99 return;
100 }
101 Error::PopulateAndLog(error, Error::kOperationFailed, dbus_error.what());
102}
103
104WiMaxNetworkProxy::Proxy::Proxy(DBus::Connection *connection,
105 const DBus::Path &path)
106 : DBus::ObjectProxy(*connection, path,
107 wimax_manager::kWiMaxManagerServiceName) {}
108
109WiMaxNetworkProxy::Proxy::~Proxy() {}
110
Darin Petkov1e52a1b2012-05-21 10:35:56 +0200111void WiMaxNetworkProxy::Proxy::set_signal_strength_changed_callback(
112 const SignalStrengthChangedCallback &callback) {
113 signal_strength_changed_callback_ = callback;
114}
115
116void WiMaxNetworkProxy::Proxy::SignalStrengthChanged(
117 const int32 &signal_strength) {
118 SLOG(DBus, 2) << __func__ << "(" << signal_strength << ")";
119 if (!signal_strength_changed_callback_.is_null()) {
120 signal_strength_changed_callback_.Run(signal_strength);
121 }
122}
123
Darin Petkov9893d9c2012-05-17 15:27:31 -0700124} // namespace shill