Darin Petkov | 096b347 | 2012-05-15 10:26:22 +0200 | [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 | #ifndef SHILL_WIMAX_DEVICE_PROXY_H_ |
| 6 | #define SHILL_WIMAX_DEVICE_PROXY_H_ |
| 7 | |
| 8 | #include <base/callback.h> |
| 9 | |
| 10 | #include "shill/dbus_bindings/wimax_manager-device.h" |
| 11 | #include "shill/wimax_device_proxy_interface.h" |
| 12 | |
| 13 | namespace shill { |
| 14 | |
| 15 | class WiMaxDeviceProxy : public WiMaxDeviceProxyInterface { |
| 16 | public: |
| 17 | // Constructs a WiMaxManager.Device DBus object proxy at |path|. |
| 18 | WiMaxDeviceProxy(DBus::Connection *connection, |
| 19 | const DBus::Path &path); |
| 20 | virtual ~WiMaxDeviceProxy(); |
| 21 | |
| 22 | // Inherited from WiMaxDeviceProxyInterface. |
| 23 | virtual void Enable(Error *error, |
| 24 | const ResultCallback &callback, |
| 25 | int timeout); |
| 26 | virtual void Disable(Error *error, |
| 27 | const ResultCallback &callback, |
| 28 | int timeout); |
Darin Petkov | 9893d9c | 2012-05-17 15:27:31 -0700 | [diff] [blame] | 29 | virtual void ScanNetworks(Error *error, |
| 30 | const ResultCallback &callback, |
| 31 | int timeout); |
Darin Petkov | 25665aa | 2012-05-21 14:08:12 +0200 | [diff] [blame] | 32 | virtual void Connect(const RpcIdentifier &network, |
| 33 | const KeyValueStore ¶meters, |
Ben Chan | 4e5c131 | 2012-05-18 18:45:38 -0700 | [diff] [blame] | 34 | Error *error, |
Darin Petkov | 096b347 | 2012-05-15 10:26:22 +0200 | [diff] [blame] | 35 | const ResultCallback &callback, |
| 36 | int timeout); |
| 37 | virtual void Disconnect(Error *error, |
| 38 | const ResultCallback &callback, |
| 39 | int timeout); |
Darin Petkov | 9893d9c | 2012-05-17 15:27:31 -0700 | [diff] [blame] | 40 | virtual void set_networks_changed_callback( |
| 41 | const NetworksChangedCallback &callback); |
Darin Petkov | 096b347 | 2012-05-15 10:26:22 +0200 | [diff] [blame] | 42 | virtual uint8 Index(Error *error); |
| 43 | virtual std::string Name(Error *error); |
| 44 | |
| 45 | private: |
| 46 | class Proxy : public org::chromium::WiMaxManager::Device_proxy, |
| 47 | public DBus::ObjectProxy { |
| 48 | public: |
Darin Petkov | 9893d9c | 2012-05-17 15:27:31 -0700 | [diff] [blame] | 49 | Proxy(DBus::Connection *connection, const DBus::Path &path); |
Darin Petkov | 096b347 | 2012-05-15 10:26:22 +0200 | [diff] [blame] | 50 | virtual ~Proxy(); |
| 51 | |
Darin Petkov | 9893d9c | 2012-05-17 15:27:31 -0700 | [diff] [blame] | 52 | void set_networks_changed_callback(const NetworksChangedCallback &callback); |
| 53 | |
Darin Petkov | 096b347 | 2012-05-15 10:26:22 +0200 | [diff] [blame] | 54 | private: |
| 55 | // Signal callbacks inherited from WiMaxManager::Device_proxy. |
Darin Petkov | 9893d9c | 2012-05-17 15:27:31 -0700 | [diff] [blame] | 56 | virtual void NetworksChanged(const std::vector<DBus::Path> &networks); |
Darin Petkov | 096b347 | 2012-05-15 10:26:22 +0200 | [diff] [blame] | 57 | |
| 58 | // Method callbacks inherited from WiMaxManager::Device_proxy. |
| 59 | virtual void EnableCallback(const DBus::Error &error, void *data); |
| 60 | virtual void DisableCallback(const DBus::Error &error, void *data); |
Darin Petkov | 9893d9c | 2012-05-17 15:27:31 -0700 | [diff] [blame] | 61 | virtual void ScanNetworksCallback(const DBus::Error &error, void *data); |
Darin Petkov | 096b347 | 2012-05-15 10:26:22 +0200 | [diff] [blame] | 62 | virtual void ConnectCallback(const DBus::Error &error, void *data); |
| 63 | virtual void DisconnectCallback(const DBus::Error &error, void *data); |
| 64 | |
| 65 | static void HandleCallback(const DBus::Error &error, void *data); |
| 66 | |
Darin Petkov | 9893d9c | 2012-05-17 15:27:31 -0700 | [diff] [blame] | 67 | NetworksChangedCallback networks_changed_callback_; |
| 68 | |
Darin Petkov | 096b347 | 2012-05-15 10:26:22 +0200 | [diff] [blame] | 69 | DISALLOW_COPY_AND_ASSIGN(Proxy); |
| 70 | }; |
| 71 | |
| 72 | void Invoke(const base::Callback<void(void *, int)> &method, |
| 73 | Error *error, |
| 74 | const ResultCallback &callback, |
| 75 | int timeout); |
| 76 | |
| 77 | static void FromDBusError(const DBus::Error &dbus_error, Error *error); |
| 78 | |
| 79 | Proxy proxy_; |
| 80 | |
| 81 | DISALLOW_COPY_AND_ASSIGN(WiMaxDeviceProxy); |
| 82 | }; |
| 83 | |
| 84 | } // namespace shill |
| 85 | |
| 86 | #endif // SHILL_WIMAX_DEVICE_PROXY_H_ |