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, |
Darin Petkov | c63dcf0 | 2012-05-24 11:51:43 +0200 | [diff] [blame] | 28 | Manager *manager); |
Ben Chan | 99c8a4d | 2012-05-01 08:11:53 -0700 | [diff] [blame] | 29 | virtual ~WiMaxService(); |
| 30 | |
Ben Chan | 4e5c131 | 2012-05-18 18:45:38 -0700 | [diff] [blame] | 31 | // Returns the parameters to be passed to WiMaxManager.Device.Connect() when |
| 32 | // connecting to the network associated with this service. |
Darin Petkov | 25665aa | 2012-05-21 14:08:12 +0200 | [diff] [blame] | 33 | void GetConnectParameters(KeyValueStore *parameters) const; |
Ben Chan | 4e5c131 | 2012-05-18 18:45:38 -0700 | [diff] [blame] | 34 | |
Darin Petkov | 1e52a1b | 2012-05-21 10:35:56 +0200 | [diff] [blame] | 35 | // Returns the RPC object path for the WiMaxManager.Network object associated |
| 36 | // 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] | 37 | virtual RpcIdentifier GetNetworkObjectPath() const; |
Ben Chan | 4e5c131 | 2012-05-18 18:45:38 -0700 | [diff] [blame] | 38 | |
Darin Petkov | d1cd797 | 2012-05-22 15:26:15 +0200 | [diff] [blame] | 39 | // Starts the service by associating it with the RPC network object |proxy| |
| 40 | // and listening for its signal strength. Returns true on success, false |
| 41 | // otherwise. Takes ownership of proxy, regardless of the result of the |
| 42 | // operation. The proxy will be destroyed on failure. |
| 43 | virtual bool Start(WiMaxNetworkProxyInterface *proxy); |
| 44 | |
| 45 | // Stops the service by disassociating it from |proxy_| and resetting its |
Darin Petkov | c63dcf0 | 2012-05-24 11:51:43 +0200 | [diff] [blame] | 46 | // signal strength to 0. If the service is connected, it notifies the carrier |
| 47 | // device that the service is stopped. |
Darin Petkov | d1cd797 | 2012-05-22 15:26:15 +0200 | [diff] [blame] | 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; } |
Darin Petkov | c1e5273 | 2012-05-25 15:23:45 +0200 | [diff] [blame] | 55 | bool is_default() const { return is_default_; } |
| 56 | void set_is_default(bool is_default) { is_default_ = is_default; } |
Darin Petkov | d1cd797 | 2012-05-22 15:26:15 +0200 | [diff] [blame] | 57 | |
| 58 | static WiMaxNetworkId ConvertIdentifierToNetworkId(uint32 identifier); |
| 59 | |
| 60 | // Initializes the storage identifier. Note that the friendly service name and |
| 61 | // the |network_id_| must already be initialized. |
| 62 | void InitStorageIdentifier(); |
| 63 | static std::string CreateStorageIdentifier(const WiMaxNetworkId &id, |
| 64 | const std::string &name); |
Darin Petkov | 9893d9c | 2012-05-17 15:27:31 -0700 | [diff] [blame] | 65 | |
Darin Petkov | a3f9f77 | 2012-05-31 12:11:28 +0200 | [diff] [blame] | 66 | virtual void ClearPassphrase(); |
| 67 | |
Ben Chan | 99c8a4d | 2012-05-01 08:11:53 -0700 | [diff] [blame] | 68 | // Inherited from Service. |
mukesh agrawal | dc7b844 | 2012-09-27 13:48:14 -0700 | [diff] [blame] | 69 | virtual void Connect(Error *error, const char *reason); |
Ben Chan | 99c8a4d | 2012-05-01 08:11:53 -0700 | [diff] [blame] | 70 | virtual void Disconnect(Error *error); |
Ben Chan | c07362b | 2012-05-12 10:54:11 -0700 | [diff] [blame] | 71 | virtual std::string GetStorageIdentifier() const; |
Darin Petkov | 8021e7f | 2012-05-21 12:15:00 +0200 | [diff] [blame] | 72 | virtual bool Is8021x() const; |
Ben Chan | f4647d4 | 2013-05-02 22:01:01 -0700 | [diff] [blame] | 73 | virtual bool IsVisible() const; |
Paul Stewart | c43cbbe | 2013-04-11 06:29:30 -0700 | [diff] [blame] | 74 | virtual void OnEapCredentialsChanged(); |
Darin Petkov | d1cd797 | 2012-05-22 15:26:15 +0200 | [diff] [blame] | 75 | virtual bool Save(StoreInterface *storage); |
Darin Petkov | c1e5273 | 2012-05-25 15:23:45 +0200 | [diff] [blame] | 76 | virtual bool Unload(); |
Darin Petkov | 8ea0eaf | 2012-05-29 11:21:33 +0200 | [diff] [blame] | 77 | virtual void SetState(ConnectState state); |
Darin Petkov | c63dcf0 | 2012-05-24 11:51:43 +0200 | [diff] [blame] | 78 | |
Ben Chan | 99c8a4d | 2012-05-01 08:11:53 -0700 | [diff] [blame] | 79 | private: |
Darin Petkov | c63dcf0 | 2012-05-24 11:51:43 +0200 | [diff] [blame] | 80 | friend class WiMaxServiceTest; |
Ben Chan | a289f66 | 2013-05-03 15:12:01 -0700 | [diff] [blame] | 81 | FRIEND_TEST(WiMaxServiceTest, Connect); |
| 82 | FRIEND_TEST(WiMaxServiceTest, Connectable); |
Darin Petkov | e4b2702 | 2012-05-16 13:28:50 +0200 | [diff] [blame] | 83 | FRIEND_TEST(WiMaxServiceTest, GetDeviceRpcId); |
Darin Petkov | 6b9b2e1 | 2012-07-10 15:51:42 +0200 | [diff] [blame] | 84 | FRIEND_TEST(WiMaxServiceTest, IsAutoConnectable); |
Darin Petkov | 1e52a1b | 2012-05-21 10:35:56 +0200 | [diff] [blame] | 85 | FRIEND_TEST(WiMaxServiceTest, OnSignalStrengthChanged); |
Darin Petkov | 8ea0eaf | 2012-05-29 11:21:33 +0200 | [diff] [blame] | 86 | FRIEND_TEST(WiMaxServiceTest, SetState); |
Darin Petkov | d1cd797 | 2012-05-22 15:26:15 +0200 | [diff] [blame] | 87 | FRIEND_TEST(WiMaxServiceTest, StartStop); |
Darin Petkov | e4b2702 | 2012-05-16 13:28:50 +0200 | [diff] [blame] | 88 | |
Darin Petkov | 6b9b2e1 | 2012-07-10 15:51:42 +0200 | [diff] [blame] | 89 | // Inherited from Service. |
Ben Chan | c07362b | 2012-05-12 10:54:11 -0700 | [diff] [blame] | 90 | virtual std::string GetDeviceRpcId(Error *error); |
Darin Petkov | 6b9b2e1 | 2012-07-10 15:51:42 +0200 | [diff] [blame] | 91 | virtual bool IsAutoConnectable(const char **reason) const; |
Ben Chan | c07362b | 2012-05-12 10:54:11 -0700 | [diff] [blame] | 92 | |
Darin Petkov | 1e52a1b | 2012-05-21 10:35:56 +0200 | [diff] [blame] | 93 | void OnSignalStrengthChanged(int strength); |
| 94 | |
Darin Petkov | 8021e7f | 2012-05-21 12:15:00 +0200 | [diff] [blame] | 95 | void UpdateConnectable(); |
| 96 | |
mukesh agrawal | cbfb34e | 2013-04-17 19:33:25 -0700 | [diff] [blame] | 97 | // Update |device_|, and inform RPC listeners of the change. |
| 98 | void SetDevice(WiMaxRefPtr new_device); |
| 99 | |
| 100 | WiMaxRefPtr device_; // Update via SetDevice(). |
Darin Petkov | 9893d9c | 2012-05-17 15:27:31 -0700 | [diff] [blame] | 101 | scoped_ptr<WiMaxNetworkProxyInterface> proxy_; |
Darin Petkov | e4b2702 | 2012-05-16 13:28:50 +0200 | [diff] [blame] | 102 | std::string storage_id_; |
Ben Chan | 99c8a4d | 2012-05-01 08:11:53 -0700 | [diff] [blame] | 103 | |
Darin Petkov | d1cd797 | 2012-05-22 15:26:15 +0200 | [diff] [blame] | 104 | WiMaxNetworkId network_id_; |
Darin Petkov | 9893d9c | 2012-05-17 15:27:31 -0700 | [diff] [blame] | 105 | std::string network_name_; |
Ben Chan | 4e5c131 | 2012-05-18 18:45:38 -0700 | [diff] [blame] | 106 | bool need_passphrase_; |
Darin Petkov | c1e5273 | 2012-05-25 15:23:45 +0200 | [diff] [blame] | 107 | bool is_default_; |
Darin Petkov | 9893d9c | 2012-05-17 15:27:31 -0700 | [diff] [blame] | 108 | |
Ben Chan | 99c8a4d | 2012-05-01 08:11:53 -0700 | [diff] [blame] | 109 | DISALLOW_COPY_AND_ASSIGN(WiMaxService); |
| 110 | }; |
| 111 | |
| 112 | } // namespace shill |
| 113 | |
| 114 | #endif // SHILL_WIMAX_SERVICE_H_ |