- add sources.
[platform/framework/web/crosswalk.git] / src / chromeos / dbus / shill_device_client.h
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.
4
5 #ifndef CHROMEOS_DBUS_SHILL_DEVICE_CLIENT_H_
6 #define CHROMEOS_DBUS_SHILL_DEVICE_CLIENT_H_
7
8 #include <string>
9
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"
16
17 namespace base {
18
19 class Value;
20 class DictionaryValue;
21
22 }  // namespace base
23
24 namespace dbus {
25
26 class ObjectPath;
27
28 }  // namespace dbus
29
30 namespace chromeos {
31
32 class ShillPropertyChangedObserver;
33
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 {
38  public:
39   typedef ShillClientHelper::PropertyChangedHandler PropertyChangedHandler;
40   typedef ShillClientHelper::DictionaryValueCallback DictionaryValueCallback;
41   typedef ShillClientHelper::ErrorCallback ErrorCallback;
42
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;
55     virtual std::string GetDevicePathForType(const std::string& type) = 0;
56
57    protected:
58     virtual ~TestInterface() {}
59   };
60
61   virtual ~ShillDeviceClient();
62
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);
66
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;
71
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;
76
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;
81
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;
86
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;
94
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;
100
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;
106
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,
111                           bool require,
112                           const base::Closure& callback,
113                           const ErrorCallback& error_callback) = 0;
114
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;
121
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;
129
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;
137
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;
144
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;
151
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;
157
158   // Returns an interface for testing (stub only), or returns NULL.
159   virtual TestInterface* GetTestInterface() = 0;
160
161  protected:
162   friend class ShillDeviceClientTest;
163
164   // Create() should be used instead.
165   ShillDeviceClient();
166
167  private:
168   DISALLOW_COPY_AND_ASSIGN(ShillDeviceClient);
169 };
170
171 }  // namespace chromeos
172
173 #endif  // CHROMEOS_DBUS_SHILL_DEVICE_CLIENT_H_