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