blob: 2d8c7258108809c956c428a55e4537ab8ec0fd9b [file] [log] [blame]
Ben Chan99c8a4d2012-05-01 08:11:53 -07001// 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 Vakulenko8a532292014-06-16 17:18:44 -07008#include <string>
9
Darin Petkove4b27022012-05-16 13:28:50 +020010#include <gtest/gtest_prod.h> // for FRIEND_TEST
11
Ben Chan99c8a4d2012-05-01 08:11:53 -070012#include "shill/refptr_types.h"
13#include "shill/service.h"
Darin Petkovd1cd7972012-05-22 15:26:15 +020014#include "shill/wimax_network_proxy_interface.h"
Ben Chan99c8a4d2012-05-01 08:11:53 -070015
16namespace shill {
17
Darin Petkov25665aa2012-05-21 14:08:12 +020018class KeyValueStore;
Darin Petkov9893d9c2012-05-17 15:27:31 -070019
Ben Chan99c8a4d2012-05-01 08:11:53 -070020class WiMaxService : public Service {
21 public:
Darin Petkovd1cd7972012-05-22 15:26:15 +020022 static const char kStorageNetworkId[];
23
24 // TODO(petkov): Declare this in chromeos/dbus/service_constants.h.
25 static const char kNetworkIdProperty[];
26
Ben Chan99c8a4d2012-05-01 08:11:53 -070027 WiMaxService(ControlInterface *control,
28 EventDispatcher *dispatcher,
29 Metrics *metrics,
Darin Petkovc63dcf02012-05-24 11:51:43 +020030 Manager *manager);
Ben Chan99c8a4d2012-05-01 08:11:53 -070031 virtual ~WiMaxService();
32
Ben Chan4e5c1312012-05-18 18:45:38 -070033 // Returns the parameters to be passed to WiMaxManager.Device.Connect() when
34 // connecting to the network associated with this service.
Darin Petkov25665aa2012-05-21 14:08:12 +020035 void GetConnectParameters(KeyValueStore *parameters) const;
Ben Chan4e5c1312012-05-18 18:45:38 -070036
Darin Petkov1e52a1b2012-05-21 10:35:56 +020037 // 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 Petkovd1cd7972012-05-22 15:26:15 +020039 virtual RpcIdentifier GetNetworkObjectPath() const;
Ben Chan4e5c1312012-05-18 18:45:38 -070040
Darin Petkovd1cd7972012-05-22 15:26:15 +020041 // 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 Petkovc63dcf02012-05-24 11:51:43 +020048 // signal strength to 0. If the service is connected, it notifies the carrier
49 // device that the service is stopped.
Darin Petkovd1cd7972012-05-22 15:26:15 +020050 virtual void Stop();
51
52 virtual bool IsStarted() const;
Darin Petkov9893d9c2012-05-17 15:27:31 -070053
54 const std::string &network_name() const { return network_name_; }
Darin Petkovd1cd7972012-05-22 15:26:15 +020055 const WiMaxNetworkId &network_id() const { return network_id_; }
56 void set_network_id(const WiMaxNetworkId &id) { network_id_ = id; }
Darin Petkovc1e52732012-05-25 15:23:45 +020057 bool is_default() const { return is_default_; }
58 void set_is_default(bool is_default) { is_default_ = is_default; }
Darin Petkovd1cd7972012-05-22 15:26:15 +020059
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 Petkov9893d9c2012-05-17 15:27:31 -070067
Darin Petkova3f9f772012-05-31 12:11:28 +020068 virtual void ClearPassphrase();
69
Ben Chan99c8a4d2012-05-01 08:11:53 -070070 // Inherited from Service.
mukesh agrawaldc7b8442012-09-27 13:48:14 -070071 virtual void Connect(Error *error, const char *reason);
Samuel Tan0d061192014-07-07 15:45:15 -070072 virtual void Disconnect(Error *error, const char *reason);
Ben Chanc07362b2012-05-12 10:54:11 -070073 virtual std::string GetStorageIdentifier() const;
Darin Petkov8021e7f2012-05-21 12:15:00 +020074 virtual bool Is8021x() const;
Ben Chanf4647d42013-05-02 22:01:01 -070075 virtual bool IsVisible() const;
Paul Stewartc43cbbe2013-04-11 06:29:30 -070076 virtual void OnEapCredentialsChanged();
Darin Petkovd1cd7972012-05-22 15:26:15 +020077 virtual bool Save(StoreInterface *storage);
Darin Petkovc1e52732012-05-25 15:23:45 +020078 virtual bool Unload();
Darin Petkov8ea0eaf2012-05-29 11:21:33 +020079 virtual void SetState(ConnectState state);
Darin Petkovc63dcf02012-05-24 11:51:43 +020080
Ben Chan99c8a4d2012-05-01 08:11:53 -070081 private:
Darin Petkovc63dcf02012-05-24 11:51:43 +020082 friend class WiMaxServiceTest;
Ben Chana289f662013-05-03 15:12:01 -070083 FRIEND_TEST(WiMaxServiceTest, Connect);
84 FRIEND_TEST(WiMaxServiceTest, Connectable);
Darin Petkove4b27022012-05-16 13:28:50 +020085 FRIEND_TEST(WiMaxServiceTest, GetDeviceRpcId);
Darin Petkov6b9b2e12012-07-10 15:51:42 +020086 FRIEND_TEST(WiMaxServiceTest, IsAutoConnectable);
Darin Petkov1e52a1b2012-05-21 10:35:56 +020087 FRIEND_TEST(WiMaxServiceTest, OnSignalStrengthChanged);
Darin Petkov8ea0eaf2012-05-29 11:21:33 +020088 FRIEND_TEST(WiMaxServiceTest, SetState);
Darin Petkovd1cd7972012-05-22 15:26:15 +020089 FRIEND_TEST(WiMaxServiceTest, StartStop);
Darin Petkove4b27022012-05-16 13:28:50 +020090
Darin Petkov6b9b2e12012-07-10 15:51:42 +020091 // Inherited from Service.
Paul Stewart1cf7eb82013-12-03 19:34:36 -080092 virtual std::string GetDeviceRpcId(Error *error) const;
Darin Petkov6b9b2e12012-07-10 15:51:42 +020093 virtual bool IsAutoConnectable(const char **reason) const;
Ben Chanc07362b2012-05-12 10:54:11 -070094
Darin Petkov1e52a1b2012-05-21 10:35:56 +020095 void OnSignalStrengthChanged(int strength);
96
Darin Petkov8021e7f2012-05-21 12:15:00 +020097 void UpdateConnectable();
98
mukesh agrawalcbfb34e2013-04-17 19:33:25 -070099 // Update |device_|, and inform RPC listeners of the change.
100 void SetDevice(WiMaxRefPtr new_device);
101
102 WiMaxRefPtr device_; // Update via SetDevice().
Darin Petkov9893d9c2012-05-17 15:27:31 -0700103 scoped_ptr<WiMaxNetworkProxyInterface> proxy_;
Darin Petkove4b27022012-05-16 13:28:50 +0200104 std::string storage_id_;
Ben Chan99c8a4d2012-05-01 08:11:53 -0700105
Darin Petkovd1cd7972012-05-22 15:26:15 +0200106 WiMaxNetworkId network_id_;
Darin Petkov9893d9c2012-05-17 15:27:31 -0700107 std::string network_name_;
Ben Chan4e5c1312012-05-18 18:45:38 -0700108 bool need_passphrase_;
Darin Petkovc1e52732012-05-25 15:23:45 +0200109 bool is_default_;
Darin Petkov9893d9c2012-05-17 15:27:31 -0700110
Ben Chan99c8a4d2012-05-01 08:11:53 -0700111 DISALLOW_COPY_AND_ASSIGN(WiMaxService);
112};
113
114} // namespace shill
115
116#endif // SHILL_WIMAX_SERVICE_H_