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 | |
| 23 | uint32 WiMaxNetworkProxy::Identifier(Error *error) { |
| 24 | SLOG(DBus, 2) << __func__; |
| 25 | try { |
| 26 | return proxy_.Identifier(); |
| 27 | } catch (const DBus::Error &e) { |
| 28 | FromDBusError(e, error); |
| 29 | } |
| 30 | return 0; |
| 31 | } |
| 32 | |
| 33 | string WiMaxNetworkProxy::Name(Error *error) { |
| 34 | SLOG(DBus, 2) << __func__; |
| 35 | try { |
| 36 | return proxy_.Name(); |
| 37 | } catch (const DBus::Error &e) { |
| 38 | FromDBusError(e, error); |
| 39 | } |
| 40 | return string(); |
| 41 | } |
| 42 | |
| 43 | int WiMaxNetworkProxy::Type(Error *error) { |
| 44 | SLOG(DBus, 2) << __func__; |
| 45 | try { |
| 46 | return proxy_.Type(); |
| 47 | } catch (const DBus::Error &e) { |
| 48 | FromDBusError(e, error); |
| 49 | } |
| 50 | return 0; |
| 51 | } |
| 52 | |
| 53 | int WiMaxNetworkProxy::CINR(Error *error) { |
| 54 | SLOG(DBus, 2) << __func__; |
| 55 | try { |
| 56 | return proxy_.CINR(); |
| 57 | } catch (const DBus::Error &e) { |
| 58 | FromDBusError(e, error); |
| 59 | } |
| 60 | return 0; |
| 61 | } |
| 62 | |
| 63 | int WiMaxNetworkProxy::RSSI(Error *error) { |
| 64 | SLOG(DBus, 2) << __func__; |
| 65 | try { |
| 66 | return proxy_.RSSI(); |
| 67 | } catch (const DBus::Error &e) { |
| 68 | FromDBusError(e, error); |
| 69 | } |
| 70 | return 0; |
| 71 | } |
| 72 | |
| 73 | // static |
| 74 | void WiMaxNetworkProxy::FromDBusError(const DBus::Error &dbus_error, |
| 75 | Error *error) { |
| 76 | if (!error) { |
| 77 | return; |
| 78 | } |
| 79 | if (!dbus_error.is_set()) { |
| 80 | error->Reset(); |
| 81 | return; |
| 82 | } |
| 83 | Error::PopulateAndLog(error, Error::kOperationFailed, dbus_error.what()); |
| 84 | } |
| 85 | |
| 86 | WiMaxNetworkProxy::Proxy::Proxy(DBus::Connection *connection, |
| 87 | const DBus::Path &path) |
| 88 | : DBus::ObjectProxy(*connection, path, |
| 89 | wimax_manager::kWiMaxManagerServiceName) {} |
| 90 | |
| 91 | WiMaxNetworkProxy::Proxy::~Proxy() {} |
| 92 | |
| 93 | } // namespace shill |