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_SERVICE_CLIENT_H_
6 #define CHROMEOS_DBUS_SHILL_SERVICE_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/shill_client_helper.h"
19 class DictionaryValue
;
31 // ShillServiceClient is used to communicate with the Shill Service
33 // All methods should be called from the origin thread which initializes the
34 // DBusThreadManager instance.
35 class CHROMEOS_EXPORT ShillServiceClient
: public DBusClient
{
37 typedef ShillClientHelper::PropertyChangedHandler PropertyChangedHandler
;
38 typedef ShillClientHelper::DictionaryValueCallback DictionaryValueCallback
;
39 typedef ShillClientHelper::ListValueCallback ListValueCallback
;
40 typedef ShillClientHelper::ErrorCallback ErrorCallback
;
42 // Interface for setting up services for testing. Accessed through
43 // GetTestInterface(), only implemented in the stub implementation.
46 // Adds a Service to the Manager and Service stubs.
47 virtual void AddService(const std::string
& service_path
,
48 const std::string
& guid
,
49 const std::string
& name
,
50 const std::string
& type
,
51 const std::string
& state
,
53 virtual void AddServiceWithIPConfig(const std::string
& service_path
,
54 const std::string
& guid
,
55 const std::string
& name
,
56 const std::string
& type
,
57 const std::string
& state
,
58 const std::string
& ipconfig_path
,
60 // Sets the properties for a service but does not add it to the Manager
61 // or Profile. Returns the properties for the service.
62 virtual base::DictionaryValue
* SetServiceProperties(
63 const std::string
& service_path
,
64 const std::string
& guid
,
65 const std::string
& name
,
66 const std::string
& type
,
67 const std::string
& state
,
70 // Removes a Service to the Manager and Service stubs.
71 virtual void RemoveService(const std::string
& service_path
) = 0;
73 // Returns false if a Service matching |service_path| does not exist.
74 virtual bool SetServiceProperty(const std::string
& service_path
,
75 const std::string
& property
,
76 const base::Value
& value
) = 0;
78 // Returns properties for |service_path| or NULL if no Service matches.
79 virtual const base::DictionaryValue
* GetServiceProperties(
80 const std::string
& service_path
) const = 0;
82 // Clears all Services from the Manager and Service stubs.
83 virtual void ClearServices() = 0;
85 virtual void SetConnectBehavior(const std::string
& service_path
,
86 const base::Closure
& behavior
) = 0;
89 virtual ~TestInterface() {}
91 ~ShillServiceClient() override
;
93 // Factory function, creates a new instance which is owned by the caller.
94 // For normal usage, access the singleton via DBusThreadManager::Get().
95 static ShillServiceClient
* Create();
97 // Adds a property changed |observer| to the service at |service_path|.
98 virtual void AddPropertyChangedObserver(
99 const dbus::ObjectPath
& service_path
,
100 ShillPropertyChangedObserver
* observer
) = 0;
102 // Removes a property changed |observer| to the service at |service_path|.
103 virtual void RemovePropertyChangedObserver(
104 const dbus::ObjectPath
& service_path
,
105 ShillPropertyChangedObserver
* observer
) = 0;
107 // Calls GetProperties method.
108 // |callback| is called after the method call succeeds.
109 virtual void GetProperties(const dbus::ObjectPath
& service_path
,
110 const DictionaryValueCallback
& callback
) = 0;
112 // Calls SetProperty method.
113 // |callback| is called after the method call succeeds.
114 virtual void SetProperty(const dbus::ObjectPath
& service_path
,
115 const std::string
& name
,
116 const base::Value
& value
,
117 const base::Closure
& callback
,
118 const ErrorCallback
& error_callback
) = 0;
120 // Calls SetProperties method.
121 // |callback| is called after the method call succeeds.
122 virtual void SetProperties(const dbus::ObjectPath
& service_path
,
123 const base::DictionaryValue
& properties
,
124 const base::Closure
& callback
,
125 const ErrorCallback
& error_callback
) = 0;
127 // Calls ClearProperty method.
128 // |callback| is called after the method call succeeds.
129 virtual void ClearProperty(const dbus::ObjectPath
& service_path
,
130 const std::string
& name
,
131 const base::Closure
& callback
,
132 const ErrorCallback
& error_callback
) = 0;
134 // Calls ClearProperties method.
135 // |callback| is called after the method call succeeds.
136 virtual void ClearProperties(const dbus::ObjectPath
& service_path
,
137 const std::vector
<std::string
>& names
,
138 const ListValueCallback
& callback
,
139 const ErrorCallback
& error_callback
) = 0;
141 // Calls Connect method.
142 // |callback| is called after the method call succeeds.
143 virtual void Connect(const dbus::ObjectPath
& service_path
,
144 const base::Closure
& callback
,
145 const ErrorCallback
& error_callback
) = 0;
147 // Calls Disconnect method.
148 // |callback| is called after the method call succeeds.
149 virtual void Disconnect(const dbus::ObjectPath
& service_path
,
150 const base::Closure
& callback
,
151 const ErrorCallback
& error_callback
) = 0;
153 // Calls Remove method.
154 // |callback| is called after the method call succeeds.
155 virtual void Remove(const dbus::ObjectPath
& service_path
,
156 const base::Closure
& callback
,
157 const ErrorCallback
& error_callback
) = 0;
159 // Calls ActivateCellularModem method.
160 // |callback| is called after the method call succeeds.
161 virtual void ActivateCellularModem(
162 const dbus::ObjectPath
& service_path
,
163 const std::string
& carrier
,
164 const base::Closure
& callback
,
165 const ErrorCallback
& error_callback
) = 0;
167 // Calls the CompleteCellularActivation method.
168 // |callback| is called after the method call succeeds.
169 virtual void CompleteCellularActivation(
170 const dbus::ObjectPath
& service_path
,
171 const base::Closure
& callback
,
172 const ErrorCallback
& error_callback
) = 0;
174 // Calls the GetLoadableProfileEntries method.
175 // |callback| is called after the method call succeeds.
176 virtual void GetLoadableProfileEntries(
177 const dbus::ObjectPath
& service_path
,
178 const DictionaryValueCallback
& callback
) = 0;
180 // Returns an interface for testing (stub only), or returns NULL.
181 virtual TestInterface
* GetTestInterface() = 0;
184 friend class ShillServiceClientTest
;
186 // Create() should be used instead.
187 ShillServiceClient();
190 DISALLOW_COPY_AND_ASSIGN(ShillServiceClient
);
193 } // namespace chromeos
195 #endif // CHROMEOS_DBUS_SHILL_SERVICE_CLIENT_H_