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_
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/dbus_client_implementation_type.h"
15 #include "chromeos/dbus/shill_client_helper.h"
20 class DictionaryValue;
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 : public DBusClient {
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.
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;
55 virtual std::string GetDevicePathForType(const std::string& type) = 0;
58 virtual ~TestInterface() {}
61 virtual ~ShillDeviceClient();
63 // Factory function, creates a new instance which is owned by the caller.
64 // For normal usage, access the singleton via DBusThreadManager::Get().
65 static ShillDeviceClient* Create(DBusClientImplementationType type);
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 // Calls ProposeScan method.
83 // |callback| is called after the method call finishes.
84 virtual void ProposeScan(const dbus::ObjectPath& device_path,
85 const VoidDBusMethodCallback& callback) = 0;
87 // Calls SetProperty method.
88 // |callback| is called after the method call finishes.
89 virtual void SetProperty(const dbus::ObjectPath& device_path,
90 const std::string& name,
91 const base::Value& value,
92 const base::Closure& callback,
93 const ErrorCallback& error_callback) = 0;
95 // Calls ClearProperty method.
96 // |callback| is called after the method call finishes.
97 virtual void ClearProperty(const dbus::ObjectPath& device_path,
98 const std::string& name,
99 const VoidDBusMethodCallback& callback) = 0;
101 // Calls AddIPConfig method.
102 // |callback| is called after the method call finishes.
103 virtual void AddIPConfig(const dbus::ObjectPath& device_path,
104 const std::string& method,
105 const ObjectPathDBusMethodCallback& callback) = 0;
107 // Calls the RequirePin method.
108 // |callback| is called after the method call finishes.
109 virtual void RequirePin(const dbus::ObjectPath& device_path,
110 const std::string& pin,
112 const base::Closure& callback,
113 const ErrorCallback& error_callback) = 0;
115 // Calls the EnterPin method.
116 // |callback| is called after the method call finishes.
117 virtual void EnterPin(const dbus::ObjectPath& device_path,
118 const std::string& pin,
119 const base::Closure& callback,
120 const ErrorCallback& error_callback) = 0;
122 // Calls the UnblockPin method.
123 // |callback| is called after the method call finishes.
124 virtual void UnblockPin(const dbus::ObjectPath& device_path,
125 const std::string& puk,
126 const std::string& pin,
127 const base::Closure& callback,
128 const ErrorCallback& error_callback) = 0;
130 // Calls the ChangePin method.
131 // |callback| is called after the method call finishes.
132 virtual void ChangePin(const dbus::ObjectPath& device_path,
133 const std::string& old_pin,
134 const std::string& new_pin,
135 const base::Closure& callback,
136 const ErrorCallback& error_callback) = 0;
138 // Calls the Register method.
139 // |callback| is called after the method call finishes.
140 virtual void Register(const dbus::ObjectPath& device_path,
141 const std::string& network_id,
142 const base::Closure& callback,
143 const ErrorCallback& error_callback) = 0;
145 // Calls the SetCarrier method.
146 // |callback| is called after the method call finishes.
147 virtual void SetCarrier(const dbus::ObjectPath& device_path,
148 const std::string& carrier,
149 const base::Closure& callback,
150 const ErrorCallback& error_callback) = 0;
152 // Calls the Reset method.
153 // |callback| is called after the method call finishes.
154 virtual void Reset(const dbus::ObjectPath& device_path,
155 const base::Closure& callback,
156 const ErrorCallback& error_callback) = 0;
158 // Returns an interface for testing (stub only), or returns NULL.
159 virtual TestInterface* GetTestInterface() = 0;
162 friend class ShillDeviceClientTest;
164 // Create() should be used instead.
168 DISALLOW_COPY_AND_ASSIGN(ShillDeviceClient);
171 } // namespace chromeos
173 #endif // CHROMEOS_DBUS_SHILL_DEVICE_CLIENT_H_