Darin Petkov | 9893d9c | 2012-05-17 15:27:31 -0700 | [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_network_proxy.h" |
| 6 | |
| 7 | #include <base/logging.h> |
| 8 | #include <chromeos/dbus/service_constants.h> |
| 9 | |
| 10 | #include "shill/error.h" |
| 11 | #include "shill/scope_logger.h" |
| 12 | |
| 13 | using std::string; |
| 14 | |
| 15 | namespace shill { |
| 16 | |
| 17 | WiMaxNetworkProxy::WiMaxNetworkProxy(DBus::Connection *connection, |
| 18 | const DBus::Path &path) |
| 19 | : proxy_(connection, path) {} |
| 20 | |
| 21 | WiMaxNetworkProxy::~WiMaxNetworkProxy() {} |
| 22 | |
Ben Chan | 4e5c131 | 2012-05-18 18:45:38 -0700 | [diff] [blame] | 23 | DBus::Path WiMaxNetworkProxy::proxy_object_path() const { |
| 24 | return proxy_.path(); |
| 25 | } |
| 26 | |
Darin Petkov | 9893d9c | 2012-05-17 15:27:31 -0700 | [diff] [blame] | 27 | uint32 WiMaxNetworkProxy::Identifier(Error *error) { |
| 28 | SLOG(DBus, 2) << __func__; |
| 29 | try { |
| 30 | return proxy_.Identifier(); |
| 31 | } catch (const DBus::Error &e) { |
| 32 | FromDBusError(e, error); |
| 33 | } |
| 34 | return 0; |
| 35 | } |
| 36 | |
| 37 | string WiMaxNetworkProxy::Name(Error *error) { |
| 38 | SLOG(DBus, 2) << __func__; |
| 39 | try { |
| 40 | return proxy_.Name(); |
| 41 | } catch (const DBus::Error &e) { |
| 42 | FromDBusError(e, error); |
| 43 | } |
| 44 | return string(); |
| 45 | } |
| 46 | |
| 47 | int WiMaxNetworkProxy::Type(Error *error) { |
| 48 | SLOG(DBus, 2) << __func__; |
| 49 | try { |
| 50 | return proxy_.Type(); |
| 51 | } catch (const DBus::Error &e) { |
| 52 | FromDBusError(e, error); |
| 53 | } |
| 54 | return 0; |
| 55 | } |
| 56 | |
| 57 | int WiMaxNetworkProxy::CINR(Error *error) { |
| 58 | SLOG(DBus, 2) << __func__; |
| 59 | try { |
| 60 | return proxy_.CINR(); |
| 61 | } catch (const DBus::Error &e) { |
| 62 | FromDBusError(e, error); |
| 63 | } |
| 64 | return 0; |
| 65 | } |
| 66 | |
| 67 | int WiMaxNetworkProxy::RSSI(Error *error) { |
| 68 | SLOG(DBus, 2) << __func__; |
| 69 | try { |
| 70 | return proxy_.RSSI(); |
| 71 | } catch (const DBus::Error &e) { |
| 72 | FromDBusError(e, error); |
| 73 | } |
| 74 | return 0; |
| 75 | } |
| 76 | |
Ben Chan | ac6e836 | 2012-05-20 00:39:58 -0700 | [diff] [blame^] | 77 | int WiMaxNetworkProxy::SignalStrength(Error *error) { |
| 78 | SLOG(DBus, 2) << __func__; |
| 79 | try { |
| 80 | return proxy_.SignalStrength(); |
| 81 | } catch (const DBus::Error &e) { |
| 82 | FromDBusError(e, error); |
| 83 | } |
| 84 | return 0; |
| 85 | } |
| 86 | |
Darin Petkov | 9893d9c | 2012-05-17 15:27:31 -0700 | [diff] [blame] | 87 | // static |
| 88 | void WiMaxNetworkProxy::FromDBusError(const DBus::Error &dbus_error, |
| 89 | Error *error) { |
| 90 | if (!error) { |
| 91 | return; |
| 92 | } |
| 93 | if (!dbus_error.is_set()) { |
| 94 | error->Reset(); |
| 95 | return; |
| 96 | } |
| 97 | Error::PopulateAndLog(error, Error::kOperationFailed, dbus_error.what()); |
| 98 | } |
| 99 | |
| 100 | WiMaxNetworkProxy::Proxy::Proxy(DBus::Connection *connection, |
| 101 | const DBus::Path &path) |
| 102 | : DBus::ObjectProxy(*connection, path, |
| 103 | wimax_manager::kWiMaxManagerServiceName) {} |
| 104 | |
| 105 | WiMaxNetworkProxy::Proxy::~Proxy() {} |
| 106 | |
| 107 | } // namespace shill |