Ben Chan | 99c8a4d | 2012-05-01 08:11:53 -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 | #ifndef SHILL_WIMAX_H_ |
| 6 | #define SHILL_WIMAX_H_ |
| 7 | |
Darin Petkov | c63dcf0 | 2012-05-24 11:51:43 +0200 | [diff] [blame] | 8 | #include <set> |
| 9 | |
Darin Petkov | 8ea0eaf | 2012-05-29 11:21:33 +0200 | [diff] [blame] | 10 | #include <chromeos/dbus/service_constants.h> |
Darin Petkov | b72b62e | 2012-05-15 16:55:36 +0200 | [diff] [blame] | 11 | #include <gtest/gtest_prod.h> // for FRIEND_TEST |
| 12 | |
Ben Chan | 99c8a4d | 2012-05-01 08:11:53 -0700 | [diff] [blame] | 13 | #include "shill/device.h" |
| 14 | |
| 15 | namespace shill { |
| 16 | |
Darin Petkov | b72b62e | 2012-05-15 16:55:36 +0200 | [diff] [blame] | 17 | class ProxyFactory; |
| 18 | class WiMaxDeviceProxyInterface; |
| 19 | |
Ben Chan | 99c8a4d | 2012-05-01 08:11:53 -0700 | [diff] [blame] | 20 | class WiMax : public Device { |
| 21 | public: |
| 22 | WiMax(ControlInterface *control, |
| 23 | EventDispatcher *dispatcher, |
| 24 | Metrics *metrics, |
| 25 | Manager *manager, |
| 26 | const std::string &link_name, |
Ben Chan | 4e64d2d | 2012-05-16 00:02:25 -0700 | [diff] [blame] | 27 | const std::string &address, |
Darin Petkov | b72b62e | 2012-05-15 16:55:36 +0200 | [diff] [blame] | 28 | int interface_index, |
| 29 | const RpcIdentifier &path); |
Ben Chan | 99c8a4d | 2012-05-01 08:11:53 -0700 | [diff] [blame] | 30 | |
| 31 | virtual ~WiMax(); |
| 32 | |
Darin Petkov | 9893d9c | 2012-05-17 15:27:31 -0700 | [diff] [blame] | 33 | // Inherited from Device. |
Ben Chan | 99c8a4d | 2012-05-01 08:11:53 -0700 | [diff] [blame] | 34 | virtual void Start(Error *error, const EnabledStateChangedCallback &callback); |
| 35 | virtual void Stop(Error *error, const EnabledStateChangedCallback &callback); |
Ben Chan | 99c8a4d | 2012-05-01 08:11:53 -0700 | [diff] [blame] | 36 | virtual bool TechnologyIs(const Technology::Identifier type) const; |
Darin Petkov | 9893d9c | 2012-05-17 15:27:31 -0700 | [diff] [blame] | 37 | virtual void Scan(Error *error); |
Ben Chan | 99c8a4d | 2012-05-01 08:11:53 -0700 | [diff] [blame] | 38 | |
Darin Petkov | 9893d9c | 2012-05-17 15:27:31 -0700 | [diff] [blame] | 39 | virtual void ConnectTo(const WiMaxServiceRefPtr &service, Error *error); |
Darin Petkov | c63dcf0 | 2012-05-24 11:51:43 +0200 | [diff] [blame] | 40 | virtual void DisconnectFrom(const ServiceRefPtr &service, Error *error); |
Ben Chan | 99c8a4d | 2012-05-01 08:11:53 -0700 | [diff] [blame] | 41 | |
Darin Petkov | c63dcf0 | 2012-05-24 11:51:43 +0200 | [diff] [blame] | 42 | // Signaled by |service| when stopped. |
| 43 | virtual void OnServiceStopped(const WiMaxServiceRefPtr &service); |
Darin Petkov | d1cd797 | 2012-05-22 15:26:15 +0200 | [diff] [blame] | 44 | |
Darin Petkov | b72b62e | 2012-05-15 16:55:36 +0200 | [diff] [blame] | 45 | const RpcIdentifier &path() const { return path_; } |
Darin Petkov | 9893d9c | 2012-05-17 15:27:31 -0700 | [diff] [blame] | 46 | bool scanning() const { return scanning_; } |
Darin Petkov | c63dcf0 | 2012-05-24 11:51:43 +0200 | [diff] [blame] | 47 | const std::set<RpcIdentifier> &networks() const { return networks_; } |
Darin Petkov | b72b62e | 2012-05-15 16:55:36 +0200 | [diff] [blame] | 48 | |
Ben Chan | 99c8a4d | 2012-05-01 08:11:53 -0700 | [diff] [blame] | 49 | private: |
Darin Petkov | b72b62e | 2012-05-15 16:55:36 +0200 | [diff] [blame] | 50 | friend class WiMaxTest; |
Darin Petkov | c63dcf0 | 2012-05-24 11:51:43 +0200 | [diff] [blame] | 51 | FRIEND_TEST(WiMaxProviderTest, OnNetworksChanged); |
Darin Petkov | 8ea0eaf | 2012-05-29 11:21:33 +0200 | [diff] [blame] | 52 | FRIEND_TEST(WiMaxTest, OnConnectComplete); |
Darin Petkov | 9893d9c | 2012-05-17 15:27:31 -0700 | [diff] [blame] | 53 | FRIEND_TEST(WiMaxTest, OnNetworksChanged); |
Darin Petkov | c63dcf0 | 2012-05-24 11:51:43 +0200 | [diff] [blame] | 54 | FRIEND_TEST(WiMaxTest, OnServiceStopped); |
Darin Petkov | b72b62e | 2012-05-15 16:55:36 +0200 | [diff] [blame] | 55 | FRIEND_TEST(WiMaxTest, StartStop); |
| 56 | |
Darin Petkov | 912f0de | 2012-05-16 14:12:14 +0200 | [diff] [blame] | 57 | static const int kTimeoutDefault; |
| 58 | |
Darin Petkov | 9893d9c | 2012-05-17 15:27:31 -0700 | [diff] [blame] | 59 | void OnScanNetworksComplete(const Error &error); |
Darin Petkov | 912f0de | 2012-05-16 14:12:14 +0200 | [diff] [blame] | 60 | void OnConnectComplete(const Error &error); |
| 61 | void OnDisconnectComplete(const Error &error); |
| 62 | void OnEnableComplete(const EnabledStateChangedCallback &callback, |
| 63 | const Error &error); |
| 64 | void OnDisableComplete(const EnabledStateChangedCallback &callback, |
| 65 | const Error &error); |
| 66 | |
Darin Petkov | 9893d9c | 2012-05-17 15:27:31 -0700 | [diff] [blame] | 67 | void OnNetworksChanged(const RpcIdentifiers &networks); |
Darin Petkov | 8ea0eaf | 2012-05-29 11:21:33 +0200 | [diff] [blame] | 68 | void OnStatusChanged(wimax_manager::DeviceStatus status); |
Darin Petkov | 9893d9c | 2012-05-17 15:27:31 -0700 | [diff] [blame] | 69 | |
Darin Petkov | c63dcf0 | 2012-05-24 11:51:43 +0200 | [diff] [blame] | 70 | void DropConnection(); |
Darin Petkov | 9893d9c | 2012-05-17 15:27:31 -0700 | [diff] [blame] | 71 | |
Darin Petkov | b72b62e | 2012-05-15 16:55:36 +0200 | [diff] [blame] | 72 | const RpcIdentifier path_; |
| 73 | |
| 74 | scoped_ptr<WiMaxDeviceProxyInterface> proxy_; |
Darin Petkov | 9893d9c | 2012-05-17 15:27:31 -0700 | [diff] [blame] | 75 | bool scanning_; |
Darin Petkov | 9893d9c | 2012-05-17 15:27:31 -0700 | [diff] [blame] | 76 | WiMaxServiceRefPtr pending_service_; |
Darin Petkov | c63dcf0 | 2012-05-24 11:51:43 +0200 | [diff] [blame] | 77 | std::set<RpcIdentifier> networks_; |
Darin Petkov | b72b62e | 2012-05-15 16:55:36 +0200 | [diff] [blame] | 78 | |
| 79 | ProxyFactory *proxy_factory_; |
| 80 | |
Ben Chan | 99c8a4d | 2012-05-01 08:11:53 -0700 | [diff] [blame] | 81 | DISALLOW_COPY_AND_ASSIGN(WiMax); |
| 82 | }; |
| 83 | |
| 84 | } // namespace shill |
| 85 | |
| 86 | #endif // SHILL_WIMAX_H_ |