blob: f97689acfc2b0376091268f06f1d330b180b4157 [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.
Ben Chan99c8a4d2012-05-01 08:11:53 -070069 virtual void Connect(Error *error);
70 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;
73 virtual void set_eap(const EapCredentials &eap);
Darin Petkovd1cd7972012-05-22 15:26:15 +020074 virtual bool Save(StoreInterface *storage);
Darin Petkovc1e52732012-05-25 15:23:45 +020075 virtual bool Unload();
Darin Petkov8ea0eaf2012-05-29 11:21:33 +020076 virtual void SetState(ConnectState state);
Darin Petkovc63dcf02012-05-24 11:51:43 +020077
Ben Chan99c8a4d2012-05-01 08:11:53 -070078 private:
Darin Petkovc63dcf02012-05-24 11:51:43 +020079 friend class WiMaxServiceTest;
Darin Petkove4b27022012-05-16 13:28:50 +020080 FRIEND_TEST(WiMaxServiceTest, GetDeviceRpcId);
Darin Petkov6b9b2e12012-07-10 15:51:42 +020081 FRIEND_TEST(WiMaxServiceTest, IsAutoConnectable);
Darin Petkov1e52a1b2012-05-21 10:35:56 +020082 FRIEND_TEST(WiMaxServiceTest, OnSignalStrengthChanged);
Darin Petkov8021e7f2012-05-21 12:15:00 +020083 FRIEND_TEST(WiMaxServiceTest, SetEAP);
Darin Petkov8ea0eaf2012-05-29 11:21:33 +020084 FRIEND_TEST(WiMaxServiceTest, SetState);
Darin Petkovd1cd7972012-05-22 15:26:15 +020085 FRIEND_TEST(WiMaxServiceTest, StartStop);
Darin Petkove4b27022012-05-16 13:28:50 +020086
Darin Petkov6b9b2e12012-07-10 15:51:42 +020087 // Inherited from Service.
Ben Chanc07362b2012-05-12 10:54:11 -070088 virtual std::string GetDeviceRpcId(Error *error);
Darin Petkov6b9b2e12012-07-10 15:51:42 +020089 virtual bool IsAutoConnectable(const char **reason) const;
Ben Chanc07362b2012-05-12 10:54:11 -070090
Darin Petkov1e52a1b2012-05-21 10:35:56 +020091 void OnSignalStrengthChanged(int strength);
92
Darin Petkov8021e7f2012-05-21 12:15:00 +020093 void UpdateConnectable();
94
Darin Petkovc63dcf02012-05-24 11:51:43 +020095 WiMaxRefPtr device_;
Darin Petkov9893d9c2012-05-17 15:27:31 -070096 scoped_ptr<WiMaxNetworkProxyInterface> proxy_;
Darin Petkove4b27022012-05-16 13:28:50 +020097 std::string storage_id_;
Ben Chan99c8a4d2012-05-01 08:11:53 -070098
Darin Petkovd1cd7972012-05-22 15:26:15 +020099 WiMaxNetworkId network_id_;
Darin Petkov9893d9c2012-05-17 15:27:31 -0700100 std::string network_name_;
Ben Chan4e5c1312012-05-18 18:45:38 -0700101 bool need_passphrase_;
Darin Petkovc1e52732012-05-25 15:23:45 +0200102 bool is_default_;
Darin Petkov9893d9c2012-05-17 15:27:31 -0700103
Ben Chan99c8a4d2012-05-01 08:11:53 -0700104 DISALLOW_COPY_AND_ASSIGN(WiMaxService);
105};
106
107} // namespace shill
108
109#endif // SHILL_WIMAX_SERVICE_H_