blob: c796acb35fa1c6a39cf47fa1917bc911c4f00f2d [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
Darin Petkove4b27022012-05-16 13:28:50 +02008#include <gtest/gtest_prod.h> // for FRIEND_TEST
9
Ben Chan99c8a4d2012-05-01 08:11:53 -070010#include "shill/refptr_types.h"
11#include "shill/service.h"
Darin Petkovd1cd7972012-05-22 15:26:15 +020012#include "shill/wimax_network_proxy_interface.h"
Ben Chan99c8a4d2012-05-01 08:11:53 -070013
14namespace shill {
15
Darin Petkov25665aa2012-05-21 14:08:12 +020016class KeyValueStore;
Darin Petkov9893d9c2012-05-17 15:27:31 -070017
Ben Chan99c8a4d2012-05-01 08:11:53 -070018class WiMaxService : public Service {
19 public:
Darin Petkovd1cd7972012-05-22 15:26:15 +020020 static const char kStorageNetworkId[];
21
22 // TODO(petkov): Declare this in chromeos/dbus/service_constants.h.
23 static const char kNetworkIdProperty[];
24
Ben Chan99c8a4d2012-05-01 08:11:53 -070025 WiMaxService(ControlInterface *control,
26 EventDispatcher *dispatcher,
27 Metrics *metrics,
Darin Petkovc63dcf02012-05-24 11:51:43 +020028 Manager *manager);
Ben Chan99c8a4d2012-05-01 08:11:53 -070029 virtual ~WiMaxService();
30
Ben Chan4e5c1312012-05-18 18:45:38 -070031 // Returns the parameters to be passed to WiMaxManager.Device.Connect() when
32 // connecting to the network associated with this service.
Darin Petkov25665aa2012-05-21 14:08:12 +020033 void GetConnectParameters(KeyValueStore *parameters) const;
Ben Chan4e5c1312012-05-18 18:45:38 -070034
Darin Petkov1e52a1b2012-05-21 10:35:56 +020035 // 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 Petkovd1cd7972012-05-22 15:26:15 +020037 virtual RpcIdentifier GetNetworkObjectPath() const;
Ben Chan4e5c1312012-05-18 18:45:38 -070038
Darin Petkovd1cd7972012-05-22 15:26:15 +020039 // 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 Petkovc63dcf02012-05-24 11:51:43 +020046 // signal strength to 0. If the service is connected, it notifies the carrier
47 // device that the service is stopped.
Darin Petkovd1cd7972012-05-22 15:26:15 +020048 virtual void Stop();
49
50 virtual bool IsStarted() const;
Darin Petkov9893d9c2012-05-17 15:27:31 -070051
52 const std::string &network_name() const { return network_name_; }
Darin Petkovd1cd7972012-05-22 15:26:15 +020053 const WiMaxNetworkId &network_id() const { return network_id_; }
54 void set_network_id(const WiMaxNetworkId &id) { network_id_ = id; }
Darin Petkovc1e52732012-05-25 15:23:45 +020055 bool is_default() const { return is_default_; }
56 void set_is_default(bool is_default) { is_default_ = is_default; }
Darin Petkovd1cd7972012-05-22 15:26:15 +020057
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 Petkov9893d9c2012-05-17 15:27:31 -070065
Darin Petkova3f9f772012-05-31 12:11:28 +020066 virtual void ClearPassphrase();
67
Ben Chan99c8a4d2012-05-01 08:11:53 -070068 // Inherited from Service.
mukesh agrawaldc7b8442012-09-27 13:48:14 -070069 virtual void Connect(Error *error, const char *reason);
Ben Chan99c8a4d2012-05-01 08:11:53 -070070 virtual void Disconnect(Error *error);
Ben Chanc07362b2012-05-12 10:54:11 -070071 virtual std::string GetStorageIdentifier() const;
Darin Petkov8021e7f2012-05-21 12:15:00 +020072 virtual bool Is8021x() const;
Ben Chanf4647d42013-05-02 22:01:01 -070073 virtual bool IsVisible() const;
Paul Stewartc43cbbe2013-04-11 06:29:30 -070074 virtual void OnEapCredentialsChanged();
Darin Petkovd1cd7972012-05-22 15:26:15 +020075 virtual bool Save(StoreInterface *storage);
Darin Petkovc1e52732012-05-25 15:23:45 +020076 virtual bool Unload();
Darin Petkov8ea0eaf2012-05-29 11:21:33 +020077 virtual void SetState(ConnectState state);
Darin Petkovc63dcf02012-05-24 11:51:43 +020078
Ben Chan99c8a4d2012-05-01 08:11:53 -070079 private:
Darin Petkovc63dcf02012-05-24 11:51:43 +020080 friend class WiMaxServiceTest;
Ben Chana289f662013-05-03 15:12:01 -070081 FRIEND_TEST(WiMaxServiceTest, Connect);
82 FRIEND_TEST(WiMaxServiceTest, Connectable);
Darin Petkove4b27022012-05-16 13:28:50 +020083 FRIEND_TEST(WiMaxServiceTest, GetDeviceRpcId);
Darin Petkov6b9b2e12012-07-10 15:51:42 +020084 FRIEND_TEST(WiMaxServiceTest, IsAutoConnectable);
Darin Petkov1e52a1b2012-05-21 10:35:56 +020085 FRIEND_TEST(WiMaxServiceTest, OnSignalStrengthChanged);
Darin Petkov8ea0eaf2012-05-29 11:21:33 +020086 FRIEND_TEST(WiMaxServiceTest, SetState);
Darin Petkovd1cd7972012-05-22 15:26:15 +020087 FRIEND_TEST(WiMaxServiceTest, StartStop);
Darin Petkove4b27022012-05-16 13:28:50 +020088
Darin Petkov6b9b2e12012-07-10 15:51:42 +020089 // Inherited from Service.
Ben Chanc07362b2012-05-12 10:54:11 -070090 virtual std::string GetDeviceRpcId(Error *error);
Darin Petkov6b9b2e12012-07-10 15:51:42 +020091 virtual bool IsAutoConnectable(const char **reason) const;
Ben Chanc07362b2012-05-12 10:54:11 -070092
Darin Petkov1e52a1b2012-05-21 10:35:56 +020093 void OnSignalStrengthChanged(int strength);
94
Darin Petkov8021e7f2012-05-21 12:15:00 +020095 void UpdateConnectable();
96
mukesh agrawalcbfb34e2013-04-17 19:33:25 -070097 // Update |device_|, and inform RPC listeners of the change.
98 void SetDevice(WiMaxRefPtr new_device);
99
100 WiMaxRefPtr device_; // Update via SetDevice().
Darin Petkov9893d9c2012-05-17 15:27:31 -0700101 scoped_ptr<WiMaxNetworkProxyInterface> proxy_;
Darin Petkove4b27022012-05-16 13:28:50 +0200102 std::string storage_id_;
Ben Chan99c8a4d2012-05-01 08:11:53 -0700103
Darin Petkovd1cd7972012-05-22 15:26:15 +0200104 WiMaxNetworkId network_id_;
Darin Petkov9893d9c2012-05-17 15:27:31 -0700105 std::string network_name_;
Ben Chan4e5c1312012-05-18 18:45:38 -0700106 bool need_passphrase_;
Darin Petkovc1e52732012-05-25 15:23:45 +0200107 bool is_default_;
Darin Petkov9893d9c2012-05-17 15:27:31 -0700108
Ben Chan99c8a4d2012-05-01 08:11:53 -0700109 DISALLOW_COPY_AND_ASSIGN(WiMaxService);
110};
111
112} // namespace shill
113
114#endif // SHILL_WIMAX_SERVICE_H_