Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chromeos / dbus / shill_device_client.h
blob06949deb489ce96269d3e83b57071112772698ea
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;
64 // If |lock_type| is true, sets Cellular.SIMLockStatus.LockType to sim-pin,
65 // otherwise clears LockType. (This will unblock a PUK locked SIM).
66 // Sets RetriesLeft to the PIN retry default. LockEnabled is unaffected.
67 virtual void SetSimLocked(const std::string& device_path, bool enabled) = 0;
69 protected:
70 virtual ~TestInterface() {}
73 ~ShillDeviceClient() override;
75 // Factory function, creates a new instance which is owned by the caller.
76 // For normal usage, access the singleton via DBusThreadManager::Get().
77 static ShillDeviceClient* Create();
79 // Adds a property changed |observer| for the device at |device_path|.
80 virtual void AddPropertyChangedObserver(
81 const dbus::ObjectPath& device_path,
82 ShillPropertyChangedObserver* observer) = 0;
84 // Removes a property changed |observer| for the device at |device_path|.
85 virtual void RemovePropertyChangedObserver(
86 const dbus::ObjectPath& device_path,
87 ShillPropertyChangedObserver* observer) = 0;
89 // Calls GetProperties method.
90 // |callback| is called after the method call finishes.
91 virtual void GetProperties(const dbus::ObjectPath& device_path,
92 const DictionaryValueCallback& callback) = 0;
94 // Calls ProposeScan method.
95 // |callback| is called after the method call finishes.
96 virtual void ProposeScan(const dbus::ObjectPath& device_path,
97 const VoidDBusMethodCallback& callback) = 0;
99 // Calls SetProperty method.
100 // |callback| is called after the method call finishes.
101 virtual void SetProperty(const dbus::ObjectPath& device_path,
102 const std::string& name,
103 const base::Value& value,
104 const base::Closure& callback,
105 const ErrorCallback& error_callback) = 0;
107 // Calls ClearProperty method.
108 // |callback| is called after the method call finishes.
109 virtual void ClearProperty(const dbus::ObjectPath& device_path,
110 const std::string& name,
111 const VoidDBusMethodCallback& callback) = 0;
113 // Calls AddIPConfig method.
114 // |callback| is called after the method call finishes.
115 virtual void AddIPConfig(const dbus::ObjectPath& device_path,
116 const std::string& method,
117 const ObjectPathDBusMethodCallback& callback) = 0;
119 // Calls the RequirePin method.
120 // |callback| is called after the method call finishes.
121 virtual void RequirePin(const dbus::ObjectPath& device_path,
122 const std::string& pin,
123 bool require,
124 const base::Closure& callback,
125 const ErrorCallback& error_callback) = 0;
127 // Calls the EnterPin method.
128 // |callback| is called after the method call finishes.
129 virtual void EnterPin(const dbus::ObjectPath& device_path,
130 const std::string& pin,
131 const base::Closure& callback,
132 const ErrorCallback& error_callback) = 0;
134 // Calls the UnblockPin method.
135 // |callback| is called after the method call finishes.
136 virtual void UnblockPin(const dbus::ObjectPath& device_path,
137 const std::string& puk,
138 const std::string& pin,
139 const base::Closure& callback,
140 const ErrorCallback& error_callback) = 0;
142 // Calls the ChangePin method.
143 // |callback| is called after the method call finishes.
144 virtual void ChangePin(const dbus::ObjectPath& device_path,
145 const std::string& old_pin,
146 const std::string& new_pin,
147 const base::Closure& callback,
148 const ErrorCallback& error_callback) = 0;
150 // Calls the Register method.
151 // |callback| is called after the method call finishes.
152 virtual void Register(const dbus::ObjectPath& device_path,
153 const std::string& network_id,
154 const base::Closure& callback,
155 const ErrorCallback& error_callback) = 0;
157 // Calls the SetCarrier method.
158 // |callback| is called after the method call finishes.
159 virtual void SetCarrier(const dbus::ObjectPath& device_path,
160 const std::string& carrier,
161 const base::Closure& callback,
162 const ErrorCallback& error_callback) = 0;
164 // Calls the Reset method.
165 // |callback| is called after the method call finishes.
166 virtual void Reset(const dbus::ObjectPath& device_path,
167 const base::Closure& callback,
168 const ErrorCallback& error_callback) = 0;
170 // Calls the PerformTDLSOperation method.
171 // |callback| is called after the method call finishes.
172 virtual void PerformTDLSOperation(const dbus::ObjectPath& device_path,
173 const std::string& operation,
174 const std::string& peer,
175 const StringCallback& callback,
176 const ErrorCallback& error_callback) = 0;
178 // Adds |ip_endpoint| to the list of tcp connections that the device should
179 // monitor to wake the system from suspend.
180 virtual void AddWakeOnPacketConnection(
181 const dbus::ObjectPath& device_path,
182 const net::IPEndPoint& ip_endpoint,
183 const base::Closure& callback,
184 const ErrorCallback& error_callback) = 0;
186 // Removes |ip_endpoint| from the list of tcp connections that the device
187 // should monitor to wake the system from suspend.
188 virtual void RemoveWakeOnPacketConnection(
189 const dbus::ObjectPath& device_path,
190 const net::IPEndPoint& ip_endpoint,
191 const base::Closure& callback,
192 const ErrorCallback& error_callback) = 0;
194 // Clears the list of tcp connections that the device should monitor to wake
195 // the system from suspend.
196 virtual void RemoveAllWakeOnPacketConnections(
197 const dbus::ObjectPath& device_path,
198 const base::Closure& callback,
199 const ErrorCallback& error_callback) = 0;
201 // Returns an interface for testing (stub only), or returns NULL.
202 virtual TestInterface* GetTestInterface() = 0;
204 protected:
205 friend class ShillDeviceClientTest;
207 // Create() should be used instead.
208 ShillDeviceClient();
210 private:
211 DISALLOW_COPY_AND_ASSIGN(ShillDeviceClient);
214 } // namespace chromeos
216 #endif // CHROMEOS_DBUS_SHILL_DEVICE_CLIENT_H_