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_SERVICE_H_ |
| 6 | #define SHILL_WIMAX_SERVICE_H_ |
| 7 | |
Darin Petkov | e4b2702 | 2012-05-16 13:28:50 +0200 | [diff] [blame] | 8 | #include <gtest/gtest_prod.h> // for FRIEND_TEST |
| 9 | |
Ben Chan | 99c8a4d | 2012-05-01 08:11:53 -0700 | [diff] [blame] | 10 | #include "shill/refptr_types.h" |
| 11 | #include "shill/service.h" |
Darin Petkov | d1cd797 | 2012-05-22 15:26:15 +0200 | [diff] [blame^] | 12 | #include "shill/wimax_network_proxy_interface.h" |
Ben Chan | 99c8a4d | 2012-05-01 08:11:53 -0700 | [diff] [blame] | 13 | |
| 14 | namespace shill { |
| 15 | |
Darin Petkov | 25665aa | 2012-05-21 14:08:12 +0200 | [diff] [blame] | 16 | class KeyValueStore; |
Darin Petkov | 9893d9c | 2012-05-17 15:27:31 -0700 | [diff] [blame] | 17 | |
Ben Chan | 99c8a4d | 2012-05-01 08:11:53 -0700 | [diff] [blame] | 18 | class WiMaxService : public Service { |
| 19 | public: |
Darin Petkov | d1cd797 | 2012-05-22 15:26:15 +0200 | [diff] [blame^] | 20 | static const char kStorageNetworkId[]; |
| 21 | |
| 22 | // TODO(petkov): Declare this in chromeos/dbus/service_constants.h. |
| 23 | static const char kNetworkIdProperty[]; |
| 24 | |
Ben Chan | 99c8a4d | 2012-05-01 08:11:53 -0700 | [diff] [blame] | 25 | WiMaxService(ControlInterface *control, |
| 26 | EventDispatcher *dispatcher, |
| 27 | Metrics *metrics, |
| 28 | Manager *manager, |
| 29 | const WiMaxRefPtr &wimax); |
| 30 | virtual ~WiMaxService(); |
| 31 | |
Ben Chan | 4e5c131 | 2012-05-18 18:45:38 -0700 | [diff] [blame] | 32 | // Returns the parameters to be passed to WiMaxManager.Device.Connect() when |
| 33 | // connecting to the network associated with this service. |
Darin Petkov | 25665aa | 2012-05-21 14:08:12 +0200 | [diff] [blame] | 34 | void GetConnectParameters(KeyValueStore *parameters) const; |
Ben Chan | 4e5c131 | 2012-05-18 18:45:38 -0700 | [diff] [blame] | 35 | |
Darin Petkov | 1e52a1b | 2012-05-21 10:35:56 +0200 | [diff] [blame] | 36 | // Returns the RPC object path for the WiMaxManager.Network object associated |
| 37 | // with this service. Must only be called after |proxy_| is set by Start(). |
Darin Petkov | d1cd797 | 2012-05-22 15:26:15 +0200 | [diff] [blame^] | 38 | virtual RpcIdentifier GetNetworkObjectPath() const; |
Ben Chan | 4e5c131 | 2012-05-18 18:45:38 -0700 | [diff] [blame] | 39 | |
Darin Petkov | d1cd797 | 2012-05-22 15:26:15 +0200 | [diff] [blame^] | 40 | // Starts the service by associating it with the RPC network object |proxy| |
| 41 | // and listening for its signal strength. Returns true on success, false |
| 42 | // otherwise. Takes ownership of proxy, regardless of the result of the |
| 43 | // operation. The proxy will be destroyed on failure. |
| 44 | virtual bool Start(WiMaxNetworkProxyInterface *proxy); |
| 45 | |
| 46 | // Stops the service by disassociating it from |proxy_| and resetting its |
| 47 | // signal strength to 0. |
| 48 | virtual void Stop(); |
| 49 | |
| 50 | virtual bool IsStarted() const; |
Darin Petkov | 9893d9c | 2012-05-17 15:27:31 -0700 | [diff] [blame] | 51 | |
| 52 | const std::string &network_name() const { return network_name_; } |
Darin Petkov | d1cd797 | 2012-05-22 15:26:15 +0200 | [diff] [blame^] | 53 | const WiMaxNetworkId &network_id() const { return network_id_; } |
| 54 | void set_network_id(const WiMaxNetworkId &id) { network_id_ = id; } |
| 55 | |
| 56 | static WiMaxNetworkId ConvertIdentifierToNetworkId(uint32 identifier); |
| 57 | |
| 58 | // Initializes the storage identifier. Note that the friendly service name and |
| 59 | // the |network_id_| must already be initialized. |
| 60 | void InitStorageIdentifier(); |
| 61 | static std::string CreateStorageIdentifier(const WiMaxNetworkId &id, |
| 62 | const std::string &name); |
Darin Petkov | 9893d9c | 2012-05-17 15:27:31 -0700 | [diff] [blame] | 63 | |
Ben Chan | 99c8a4d | 2012-05-01 08:11:53 -0700 | [diff] [blame] | 64 | // Inherited from Service. |
| 65 | virtual bool TechnologyIs(const Technology::Identifier type) const; |
| 66 | virtual void Connect(Error *error); |
| 67 | virtual void Disconnect(Error *error); |
Ben Chan | c07362b | 2012-05-12 10:54:11 -0700 | [diff] [blame] | 68 | virtual std::string GetStorageIdentifier() const; |
Darin Petkov | 8021e7f | 2012-05-21 12:15:00 +0200 | [diff] [blame] | 69 | virtual bool Is8021x() const; |
| 70 | virtual void set_eap(const EapCredentials &eap); |
Darin Petkov | d1cd797 | 2012-05-22 15:26:15 +0200 | [diff] [blame^] | 71 | virtual bool Save(StoreInterface *storage); |
Ben Chan | 99c8a4d | 2012-05-01 08:11:53 -0700 | [diff] [blame] | 72 | |
| 73 | private: |
Darin Petkov | e4b2702 | 2012-05-16 13:28:50 +0200 | [diff] [blame] | 74 | FRIEND_TEST(WiMaxServiceTest, GetDeviceRpcId); |
Darin Petkov | 1e52a1b | 2012-05-21 10:35:56 +0200 | [diff] [blame] | 75 | FRIEND_TEST(WiMaxServiceTest, OnSignalStrengthChanged); |
Darin Petkov | 8021e7f | 2012-05-21 12:15:00 +0200 | [diff] [blame] | 76 | FRIEND_TEST(WiMaxServiceTest, SetEAP); |
Darin Petkov | d1cd797 | 2012-05-22 15:26:15 +0200 | [diff] [blame^] | 77 | FRIEND_TEST(WiMaxServiceTest, StartStop); |
Darin Petkov | e4b2702 | 2012-05-16 13:28:50 +0200 | [diff] [blame] | 78 | |
Ben Chan | c07362b | 2012-05-12 10:54:11 -0700 | [diff] [blame] | 79 | virtual std::string GetDeviceRpcId(Error *error); |
| 80 | |
Darin Petkov | 1e52a1b | 2012-05-21 10:35:56 +0200 | [diff] [blame] | 81 | void OnSignalStrengthChanged(int strength); |
| 82 | |
Darin Petkov | 8021e7f | 2012-05-21 12:15:00 +0200 | [diff] [blame] | 83 | void UpdateConnectable(); |
| 84 | |
Ben Chan | 99c8a4d | 2012-05-01 08:11:53 -0700 | [diff] [blame] | 85 | WiMaxRefPtr wimax_; |
Darin Petkov | 9893d9c | 2012-05-17 15:27:31 -0700 | [diff] [blame] | 86 | scoped_ptr<WiMaxNetworkProxyInterface> proxy_; |
Darin Petkov | e4b2702 | 2012-05-16 13:28:50 +0200 | [diff] [blame] | 87 | std::string storage_id_; |
Ben Chan | 99c8a4d | 2012-05-01 08:11:53 -0700 | [diff] [blame] | 88 | |
Darin Petkov | d1cd797 | 2012-05-22 15:26:15 +0200 | [diff] [blame^] | 89 | WiMaxNetworkId network_id_; |
Darin Petkov | 9893d9c | 2012-05-17 15:27:31 -0700 | [diff] [blame] | 90 | std::string network_name_; |
Ben Chan | 4e5c131 | 2012-05-18 18:45:38 -0700 | [diff] [blame] | 91 | bool need_passphrase_; |
Darin Petkov | 9893d9c | 2012-05-17 15:27:31 -0700 | [diff] [blame] | 92 | |
Ben Chan | 99c8a4d | 2012-05-01 08:11:53 -0700 | [diff] [blame] | 93 | DISALLOW_COPY_AND_ASSIGN(WiMaxService); |
| 94 | }; |
| 95 | |
| 96 | } // namespace shill |
| 97 | |
| 98 | #endif // SHILL_WIMAX_SERVICE_H_ |