Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / chromeos / dbus / shill_device_client.h
blob2d8fb59a684e18cb128d6f87a6f8c376b30dadbd
1 // Copyright (c) 2012 The Chromium 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.
5 #ifndef CHROMEOS_DBUS_SHILL_DEVICE_CLIENT_H_
6 #define CHROMEOS_DBUS_SHILL_DEVICE_CLIENT_H_
8 #include <string>
10 #include "base/basictypes.h"
11 #include "base/callback.h"
12 #include "chromeos/chromeos_export.h"
13 #include "chromeos/dbus/dbus_client.h"
14 #include "chromeos/dbus/shill_client_helper.h"
16 namespace base {
18 class Value;
19 class DictionaryValue;
21 } // namespace base
23 namespace dbus {
25 class ObjectPath;
27 } // namespace dbus
29 namespace net {
31 class IPEndPoint;
33 } // namespace net
35 namespace chromeos {
37 class ShillPropertyChangedObserver;
39 // ShillDeviceClient is used to communicate with the Shill Device service.
40 // All methods should be called from the origin thread which initializes the
41 // DBusThreadManager instance.
42 class CHROMEOS_EXPORT ShillDeviceClient : public DBusClient {
43 public:
44 typedef ShillClientHelper::PropertyChangedHandler PropertyChangedHandler;
45 typedef ShillClientHelper::DictionaryValueCallback DictionaryValueCallback;
46 typedef ShillClientHelper::StringCallback StringCallback;
47 typedef ShillClientHelper::ErrorCallback ErrorCallback;
49 // Interface for setting up devices for testing.
50 // Accessed through GetTestInterface(), only implemented in the Stub Impl.
51 class TestInterface {
52 public:
53 virtual void AddDevice(const std::string& device_path,
54 const std::string& type,
55 const std::string& name) = 0;
56 virtual void RemoveDevice(const std::string& device_path) = 0;
57 virtual void ClearDevices() = 0;
58 virtual void SetDeviceProperty(const std::string& device_path,
59 const std::string& name,
60 const base::Value& value) = 0;
61 virtual std::string GetDevicePathForType(const std::string& type) = 0;
62 virtual void SetTDLSBusyCount(int count) = 0;
63 virtual void SetTDLSState(const std::string& state) = 0;
65 protected:
66 virtual ~TestInterface() {}
69 ~ShillDeviceClient() override;
71 // Factory function, creates a new instance which is owned by the caller.
72 // For normal usage, access the singleton via DBusThreadManager::Get().
73 static ShillDeviceClient* Create();
75 // Adds a property changed |observer| for the device at |device_path|.
76 virtual void AddPropertyChangedObserver(
77 const dbus::ObjectPath& device_path,
78 ShillPropertyChangedObserver* observer) = 0;
80 // Removes a property changed |observer| for the device at |device_path|.
81 virtual void RemovePropertyChangedObserver(
82 const dbus::ObjectPath& device_path,
83 ShillPropertyChangedObserver* observer) = 0;
85 // Calls GetProperties method.
86 // |callback| is called after the method call finishes.
87 virtual void GetProperties(const dbus::ObjectPath& device_path,
88 const DictionaryValueCallback& callback) = 0;
90 // Calls ProposeScan method.
91 // |callback| is called after the method call finishes.
92 virtual void ProposeScan(const dbus::ObjectPath& device_path,
93 const VoidDBusMethodCallback& callback) = 0;
95 // Calls SetProperty method.
96 // |callback| is called after the method call finishes.
97 virtual void SetProperty(const dbus::ObjectPath& device_path,
98 const std::string& name,
99 const base::Value& value,
100 const base::Closure& callback,
101 const ErrorCallback& error_callback) = 0;
103 // Calls ClearProperty method.
104 // |callback| is called after the method call finishes.
105 virtual void ClearProperty(const dbus::ObjectPath& device_path,
106 const std::string& name,
107 const VoidDBusMethodCallback& callback) = 0;
109 // Calls AddIPConfig method.
110 // |callback| is called after the method call finishes.
111 virtual void AddIPConfig(const dbus::ObjectPath& device_path,
112 const std::string& method,
113 const ObjectPathDBusMethodCallback& callback) = 0;
115 // Calls the RequirePin method.
116 // |callback| is called after the method call finishes.
117 virtual void RequirePin(const dbus::ObjectPath& device_path,
118 const std::string& pin,
119 bool require,
120 const base::Closure& callback,
121 const ErrorCallback& error_callback) = 0;
123 // Calls the EnterPin method.
124 // |callback| is called after the method call finishes.
125 virtual void EnterPin(const dbus::ObjectPath& device_path,
126 const std::string& pin,
127 const base::Closure& callback,
128 const ErrorCallback& error_callback) = 0;
130 // Calls the UnblockPin method.
131 // |callback| is called after the method call finishes.
132 virtual void UnblockPin(const dbus::ObjectPath& device_path,
133 const std::string& puk,
134 const std::string& pin,
135 const base::Closure& callback,
136 const ErrorCallback& error_callback) = 0;
138 // Calls the ChangePin method.
139 // |callback| is called after the method call finishes.
140 virtual void ChangePin(const dbus::ObjectPath& device_path,
141 const std::string& old_pin,
142 const std::string& new_pin,
143 const base::Closure& callback,
144 const ErrorCallback& error_callback) = 0;
146 // Calls the Register method.
147 // |callback| is called after the method call finishes.
148 virtual void Register(const dbus::ObjectPath& device_path,
149 const std::string& network_id,
150 const base::Closure& callback,
151 const ErrorCallback& error_callback) = 0;
153 // Calls the SetCarrier method.
154 // |callback| is called after the method call finishes.
155 virtual void SetCarrier(const dbus::ObjectPath& device_path,
156 const std::string& carrier,
157 const base::Closure& callback,
158 const ErrorCallback& error_callback) = 0;
160 // Calls the Reset method.
161 // |callback| is called after the method call finishes.
162 virtual void Reset(const dbus::ObjectPath& device_path,
163 const base::Closure& callback,
164 const ErrorCallback& error_callback) = 0;
166 // Calls the PerformTDLSOperation method.
167 // |callback| is called after the method call finishes.
168 virtual void PerformTDLSOperation(const dbus::ObjectPath& device_path,
169 const std::string& operation,
170 const std::string& peer,
171 const StringCallback& callback,
172 const ErrorCallback& error_callback) = 0;
174 // Adds |ip_endpoint| to the list of tcp connections that the device should
175 // monitor to wake the system from suspend.
176 virtual void AddWakeOnPacketConnection(
177 const dbus::ObjectPath& device_path,
178 const net::IPEndPoint& ip_endpoint,
179 const base::Closure& callback,
180 const ErrorCallback& error_callback) = 0;
182 // Removes |ip_endpoint| from the list of tcp connections that the device
183 // should monitor to wake the system from suspend.
184 virtual void RemoveWakeOnPacketConnection(
185 const dbus::ObjectPath& device_path,
186 const net::IPEndPoint& ip_endpoint,
187 const base::Closure& callback,
188 const ErrorCallback& error_callback) = 0;
190 // Clears the list of tcp connections that the device should monitor to wake
191 // the system from suspend.
192 virtual void RemoveAllWakeOnPacketConnections(
193 const dbus::ObjectPath& device_path,
194 const base::Closure& callback,
195 const ErrorCallback& error_callback) = 0;
197 // Returns an interface for testing (stub only), or returns NULL.
198 virtual TestInterface* GetTestInterface() = 0;
200 protected:
201 friend class ShillDeviceClientTest;
203 // Create() should be used instead.
204 ShillDeviceClient();
206 private:
207 DISALLOW_COPY_AND_ASSIGN(ShillDeviceClient);
210 } // namespace chromeos
212 #endif // CHROMEOS_DBUS_SHILL_DEVICE_CLIENT_H_