blob: 582f2dd177fa0cc0880a67337b19928e1dde1a7a [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,
28 Manager *manager,
29 const WiMaxRefPtr &wimax);
30 virtual ~WiMaxService();
31
Ben Chan4e5c1312012-05-18 18:45:38 -070032 // Returns the parameters to be passed to WiMaxManager.Device.Connect() when
33 // connecting to the network associated with this service.
Darin Petkov25665aa2012-05-21 14:08:12 +020034 void GetConnectParameters(KeyValueStore *parameters) const;
Ben Chan4e5c1312012-05-18 18:45:38 -070035
Darin Petkov1e52a1b2012-05-21 10:35:56 +020036 // Returns the RPC object path for the WiMaxManager.Network object associated
37 // with this service. Must only be called after |proxy_| is set by Start().
Darin Petkovd1cd7972012-05-22 15:26:15 +020038 virtual RpcIdentifier GetNetworkObjectPath() const;
Ben Chan4e5c1312012-05-18 18:45:38 -070039
Darin Petkovd1cd7972012-05-22 15:26:15 +020040 // Starts the service by associating it with the RPC network object |proxy|
41 // and listening for its signal strength. Returns true on success, false
42 // otherwise. Takes ownership of proxy, regardless of the result of the
43 // operation. The proxy will be destroyed on failure.
44 virtual bool Start(WiMaxNetworkProxyInterface *proxy);
45
46 // Stops the service by disassociating it from |proxy_| and resetting its
47 // signal strength to 0.
48 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; }
55
56 static WiMaxNetworkId ConvertIdentifierToNetworkId(uint32 identifier);
57
58 // Initializes the storage identifier. Note that the friendly service name and
59 // the |network_id_| must already be initialized.
60 void InitStorageIdentifier();
61 static std::string CreateStorageIdentifier(const WiMaxNetworkId &id,
62 const std::string &name);
Darin Petkov9893d9c2012-05-17 15:27:31 -070063
Ben Chan99c8a4d2012-05-01 08:11:53 -070064 // Inherited from Service.
65 virtual bool TechnologyIs(const Technology::Identifier type) const;
66 virtual void Connect(Error *error);
67 virtual void Disconnect(Error *error);
Ben Chanc07362b2012-05-12 10:54:11 -070068 virtual std::string GetStorageIdentifier() const;
Darin Petkov8021e7f2012-05-21 12:15:00 +020069 virtual bool Is8021x() const;
70 virtual void set_eap(const EapCredentials &eap);
Darin Petkovd1cd7972012-05-22 15:26:15 +020071 virtual bool Save(StoreInterface *storage);
Ben Chan99c8a4d2012-05-01 08:11:53 -070072
73 private:
Darin Petkove4b27022012-05-16 13:28:50 +020074 FRIEND_TEST(WiMaxServiceTest, GetDeviceRpcId);
Darin Petkov1e52a1b2012-05-21 10:35:56 +020075 FRIEND_TEST(WiMaxServiceTest, OnSignalStrengthChanged);
Darin Petkov8021e7f2012-05-21 12:15:00 +020076 FRIEND_TEST(WiMaxServiceTest, SetEAP);
Darin Petkovd1cd7972012-05-22 15:26:15 +020077 FRIEND_TEST(WiMaxServiceTest, StartStop);
Darin Petkove4b27022012-05-16 13:28:50 +020078
Ben Chanc07362b2012-05-12 10:54:11 -070079 virtual std::string GetDeviceRpcId(Error *error);
80
Darin Petkov1e52a1b2012-05-21 10:35:56 +020081 void OnSignalStrengthChanged(int strength);
82
Darin Petkov8021e7f2012-05-21 12:15:00 +020083 void UpdateConnectable();
84
Ben Chan99c8a4d2012-05-01 08:11:53 -070085 WiMaxRefPtr wimax_;
Darin Petkov9893d9c2012-05-17 15:27:31 -070086 scoped_ptr<WiMaxNetworkProxyInterface> proxy_;
Darin Petkove4b27022012-05-16 13:28:50 +020087 std::string storage_id_;
Ben Chan99c8a4d2012-05-01 08:11:53 -070088
Darin Petkovd1cd7972012-05-22 15:26:15 +020089 WiMaxNetworkId network_id_;
Darin Petkov9893d9c2012-05-17 15:27:31 -070090 std::string network_name_;
Ben Chan4e5c1312012-05-18 18:45:38 -070091 bool need_passphrase_;
Darin Petkov9893d9c2012-05-17 15:27:31 -070092
Ben Chan99c8a4d2012-05-01 08:11:53 -070093 DISALLOW_COPY_AND_ASSIGN(WiMaxService);
94};
95
96} // namespace shill
97
98#endif // SHILL_WIMAX_SERVICE_H_