Separate Simple Backend creation from initialization.
[chromium-blink-merge.git] / chromeos / dbus / shill_device_client.h
blobe7490f53310cd578ab2027d72593121f8acf8c1e
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_implementation_type.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 Bus;
26 class ObjectPath;
28 } // namespace dbus
30 namespace chromeos {
32 class ShillPropertyChangedObserver;
34 // ShillDeviceClient is used to communicate with the Shill Device service.
35 // All methods should be called from the origin thread which initializes the
36 // DBusThreadManager instance.
37 class CHROMEOS_EXPORT ShillDeviceClient {
38 public:
39 typedef ShillClientHelper::PropertyChangedHandler PropertyChangedHandler;
40 typedef ShillClientHelper::DictionaryValueCallback DictionaryValueCallback;
41 typedef ShillClientHelper::ErrorCallback ErrorCallback;
43 // Interface for setting up devices for testing.
44 // Accessed through GetTestInterface(), only implemented in the Stub Impl.
45 class TestInterface {
46 public:
47 virtual void AddDevice(const std::string& device_path,
48 const std::string& type,
49 const std::string& object_path) = 0;
50 virtual void RemoveDevice(const std::string& device_path) = 0;
51 virtual void ClearDevices() = 0;
52 virtual void SetDeviceProperty(const std::string& device_path,
53 const std::string& name,
54 const base::Value& value) = 0;
56 protected:
57 ~TestInterface() {}
60 virtual ~ShillDeviceClient();
62 // Factory function, creates a new instance which is owned by the caller.
63 // For normal usage, access the singleton via DBusThreadManager::Get().
64 static ShillDeviceClient* Create(DBusClientImplementationType type,
65 dbus::Bus* bus);
67 // Adds a property changed |observer| for the device at |device_path|.
68 virtual void AddPropertyChangedObserver(
69 const dbus::ObjectPath& device_path,
70 ShillPropertyChangedObserver* observer) = 0;
72 // Removes a property changed |observer| for the device at |device_path|.
73 virtual void RemovePropertyChangedObserver(
74 const dbus::ObjectPath& device_path,
75 ShillPropertyChangedObserver* observer) = 0;
77 // Calls GetProperties method.
78 // |callback| is called after the method call finishes.
79 virtual void GetProperties(const dbus::ObjectPath& device_path,
80 const DictionaryValueCallback& callback) = 0;
82 // DEPRECATED DO NOT USE: Calls GetProperties method and blocks until the
83 // method call finishes. The caller is responsible to delete the result.
84 // Thie method returns NULL when method call fails.
86 // TODO(hashimoto): Refactor CrosGetDeviceNetworkList and remove this method.
87 // crosbug.com/29902
88 virtual base::DictionaryValue* CallGetPropertiesAndBlock(
89 const dbus::ObjectPath& device_path) = 0;
91 // Calls ProposeScan method.
92 // |callback| is called after the method call finishes.
93 virtual void ProposeScan(const dbus::ObjectPath& device_path,
94 const VoidDBusMethodCallback& callback) = 0;
96 // Calls SetProperty method.
97 // |callback| is called after the method call finishes.
98 virtual void SetProperty(const dbus::ObjectPath& device_path,
99 const std::string& name,
100 const base::Value& value,
101 const base::Closure& callback,
102 const ErrorCallback& error_callback) = 0;
104 // Calls ClearProperty method.
105 // |callback| is called after the method call finishes.
106 virtual void ClearProperty(const dbus::ObjectPath& device_path,
107 const std::string& name,
108 const VoidDBusMethodCallback& callback) = 0;
110 // Calls AddIPConfig method.
111 // |callback| is called after the method call finishes.
112 virtual void AddIPConfig(const dbus::ObjectPath& device_path,
113 const std::string& method,
114 const ObjectPathDBusMethodCallback& callback) = 0;
116 // Calls the RequirePin method.
117 // |callback| is called after the method call finishes.
118 virtual void RequirePin(const dbus::ObjectPath& device_path,
119 const std::string& pin,
120 bool require,
121 const base::Closure& callback,
122 const ErrorCallback& error_callback) = 0;
124 // Calls the EnterPin method.
125 // |callback| is called after the method call finishes.
126 virtual void EnterPin(const dbus::ObjectPath& device_path,
127 const std::string& pin,
128 const base::Closure& callback,
129 const ErrorCallback& error_callback) = 0;
131 // Calls the UnblockPin method.
132 // |callback| is called after the method call finishes.
133 virtual void UnblockPin(const dbus::ObjectPath& device_path,
134 const std::string& puk,
135 const std::string& pin,
136 const base::Closure& callback,
137 const ErrorCallback& error_callback) = 0;
139 // Calls the ChangePin method.
140 // |callback| is called after the method call finishes.
141 virtual void ChangePin(const dbus::ObjectPath& device_path,
142 const std::string& old_pin,
143 const std::string& new_pin,
144 const base::Closure& callback,
145 const ErrorCallback& error_callback) = 0;
147 // Calls the Register method.
148 // |callback| is called after the method call finishes.
149 virtual void Register(const dbus::ObjectPath& device_path,
150 const std::string& network_id,
151 const base::Closure& callback,
152 const ErrorCallback& error_callback) = 0;
154 // Calls the SetCarrier method.
155 // |callback| is called after the method call finishes.
156 virtual void SetCarrier(const dbus::ObjectPath& device_path,
157 const std::string& carrier,
158 const base::Closure& callback,
159 const ErrorCallback& error_callback) = 0;
161 // Calls the Reset method.
162 // |callback| is called after the method call finishes.
163 virtual void Reset(const dbus::ObjectPath& device_path,
164 const base::Closure& callback,
165 const ErrorCallback& error_callback) = 0;
167 // Returns an interface for testing (stub only), or returns NULL.
168 virtual TestInterface* GetTestInterface() = 0;
170 protected:
171 // Create() should be used instead.
172 ShillDeviceClient();
174 private:
175 DISALLOW_COPY_AND_ASSIGN(ShillDeviceClient);
178 } // namespace chromeos
180 #endif // CHROMEOS_DBUS_SHILL_DEVICE_CLIENT_H_