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_implementation_type.h"
14 #include "chromeos/dbus/shill_client_helper.h"
19 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
{
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
,
68 // Adds a property changed |observer| for the device at |device_path|.
69 virtual void AddPropertyChangedObserver(
70 const dbus::ObjectPath
& device_path
,
71 ShillPropertyChangedObserver
* observer
) = 0;
73 // Removes a property changed |observer| for the device at |device_path|.
74 virtual void RemovePropertyChangedObserver(
75 const dbus::ObjectPath
& device_path
,
76 ShillPropertyChangedObserver
* observer
) = 0;
78 // Calls GetProperties method.
79 // |callback| is called after the method call finishes.
80 virtual void GetProperties(const dbus::ObjectPath
& device_path
,
81 const DictionaryValueCallback
& callback
) = 0;
83 // DEPRECATED DO NOT USE: Calls GetProperties method and blocks until the
84 // method call finishes. The caller is responsible to delete the result.
85 // Thie method returns NULL when method call fails.
87 // TODO(hashimoto): Refactor CrosGetDeviceNetworkList and remove this method.
89 virtual base::DictionaryValue
* CallGetPropertiesAndBlock(
90 const dbus::ObjectPath
& device_path
) = 0;
92 // Calls ProposeScan method.
93 // |callback| is called after the method call finishes.
94 virtual void ProposeScan(const dbus::ObjectPath
& device_path
,
95 const VoidDBusMethodCallback
& callback
) = 0;
97 // Calls SetProperty method.
98 // |callback| is called after the method call finishes.
99 virtual void SetProperty(const dbus::ObjectPath
& device_path
,
100 const std::string
& name
,
101 const base::Value
& value
,
102 const base::Closure
& callback
,
103 const ErrorCallback
& error_callback
) = 0;
105 // Calls ClearProperty method.
106 // |callback| is called after the method call finishes.
107 virtual void ClearProperty(const dbus::ObjectPath
& device_path
,
108 const std::string
& name
,
109 const VoidDBusMethodCallback
& callback
) = 0;
111 // Calls AddIPConfig method.
112 // |callback| is called after the method call finishes.
113 virtual void AddIPConfig(const dbus::ObjectPath
& device_path
,
114 const std::string
& method
,
115 const ObjectPathDBusMethodCallback
& callback
) = 0;
117 // Calls the RequirePin method.
118 // |callback| is called after the method call finishes.
119 virtual void RequirePin(const dbus::ObjectPath
& device_path
,
120 const std::string
& pin
,
122 const base::Closure
& callback
,
123 const ErrorCallback
& error_callback
) = 0;
125 // Calls the EnterPin method.
126 // |callback| is called after the method call finishes.
127 virtual void EnterPin(const dbus::ObjectPath
& device_path
,
128 const std::string
& pin
,
129 const base::Closure
& callback
,
130 const ErrorCallback
& error_callback
) = 0;
132 // Calls the UnblockPin method.
133 // |callback| is called after the method call finishes.
134 virtual void UnblockPin(const dbus::ObjectPath
& device_path
,
135 const std::string
& puk
,
136 const std::string
& pin
,
137 const base::Closure
& callback
,
138 const ErrorCallback
& error_callback
) = 0;
140 // Calls the ChangePin method.
141 // |callback| is called after the method call finishes.
142 virtual void ChangePin(const dbus::ObjectPath
& device_path
,
143 const std::string
& old_pin
,
144 const std::string
& new_pin
,
145 const base::Closure
& callback
,
146 const ErrorCallback
& error_callback
) = 0;
148 // Calls the Register method.
149 // |callback| is called after the method call finishes.
150 virtual void Register(const dbus::ObjectPath
& device_path
,
151 const std::string
& network_id
,
152 const base::Closure
& callback
,
153 const ErrorCallback
& error_callback
) = 0;
155 // Calls the SetCarrier method.
156 // |callback| is called after the method call finishes.
157 virtual void SetCarrier(const dbus::ObjectPath
& device_path
,
158 const std::string
& carrier
,
159 const base::Closure
& callback
,
160 const ErrorCallback
& error_callback
) = 0;
162 // Calls the Reset method.
163 // |callback| is called after the method call finishes.
164 virtual void Reset(const dbus::ObjectPath
& device_path
,
165 const base::Closure
& callback
,
166 const ErrorCallback
& error_callback
) = 0;
168 // Returns an interface for testing (stub only), or returns NULL.
169 virtual TestInterface
* GetTestInterface() = 0;
172 // Create() should be used instead.
176 DISALLOW_COPY_AND_ASSIGN(ShillDeviceClient
);
179 } // namespace chromeos
181 #endif // CHROMEOS_DBUS_SHILL_DEVICE_CLIENT_H_