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
& name
,
49 const std::string
& type
,
50 const std::string
& state
,
51 bool add_to_visible_list
,
52 bool add_to_watch_list
) = 0;
53 virtual void AddServiceWithIPConfig(const std::string
& service_path
,
54 const std::string
& name
,
55 const std::string
& type
,
56 const std::string
& state
,
57 const std::string
& ipconfig_path
,
58 bool add_to_visible_list
,
59 bool add_to_watch_list
) = 0;
61 // Removes a Service to the Manager and Service stubs.
62 virtual void RemoveService(const std::string
& service_path
) = 0;
64 // Returns false if a Service matching |service_path| does not exist.
65 virtual bool SetServiceProperty(const std::string
& service_path
,
66 const std::string
& property
,
67 const base::Value
& value
) = 0;
69 // Returns properties for |service_path| or NULL if no Service matches.
70 virtual const base::DictionaryValue
* GetServiceProperties(
71 const std::string
& service_path
) const = 0;
73 // Clears all Services from the Manager and Service stubs.
74 virtual void ClearServices() = 0;
76 virtual void SetConnectBehavior(const std::string
& service_path
,
77 const base::Closure
& behavior
) = 0;
80 virtual ~TestInterface() {}
82 virtual ~ShillServiceClient();
84 // Factory function, creates a new instance which is owned by the caller.
85 // For normal usage, access the singleton via DBusThreadManager::Get().
86 static ShillServiceClient
* Create();
88 // Adds a property changed |observer| to the service at |service_path|.
89 virtual void AddPropertyChangedObserver(
90 const dbus::ObjectPath
& service_path
,
91 ShillPropertyChangedObserver
* observer
) = 0;
93 // Removes a property changed |observer| to the service at |service_path|.
94 virtual void RemovePropertyChangedObserver(
95 const dbus::ObjectPath
& service_path
,
96 ShillPropertyChangedObserver
* observer
) = 0;
98 // Calls GetProperties method.
99 // |callback| is called after the method call succeeds.
100 virtual void GetProperties(const dbus::ObjectPath
& service_path
,
101 const DictionaryValueCallback
& callback
) = 0;
103 // Calls SetProperty method.
104 // |callback| is called after the method call succeeds.
105 virtual void SetProperty(const dbus::ObjectPath
& service_path
,
106 const std::string
& name
,
107 const base::Value
& value
,
108 const base::Closure
& callback
,
109 const ErrorCallback
& error_callback
) = 0;
111 // Calls SetProperties method.
112 // |callback| is called after the method call succeeds.
113 virtual void SetProperties(const dbus::ObjectPath
& service_path
,
114 const base::DictionaryValue
& properties
,
115 const base::Closure
& callback
,
116 const ErrorCallback
& error_callback
) = 0;
118 // Calls ClearProperty method.
119 // |callback| is called after the method call succeeds.
120 virtual void ClearProperty(const dbus::ObjectPath
& service_path
,
121 const std::string
& name
,
122 const base::Closure
& callback
,
123 const ErrorCallback
& error_callback
) = 0;
125 // Calls ClearProperties method.
126 // |callback| is called after the method call succeeds.
127 virtual void ClearProperties(const dbus::ObjectPath
& service_path
,
128 const std::vector
<std::string
>& names
,
129 const ListValueCallback
& callback
,
130 const ErrorCallback
& error_callback
) = 0;
132 // Calls Connect method.
133 // |callback| is called after the method call succeeds.
134 virtual void Connect(const dbus::ObjectPath
& service_path
,
135 const base::Closure
& callback
,
136 const ErrorCallback
& error_callback
) = 0;
138 // Calls Disconnect method.
139 // |callback| is called after the method call succeeds.
140 virtual void Disconnect(const dbus::ObjectPath
& service_path
,
141 const base::Closure
& callback
,
142 const ErrorCallback
& error_callback
) = 0;
144 // Calls Remove method.
145 // |callback| is called after the method call succeeds.
146 virtual void Remove(const dbus::ObjectPath
& service_path
,
147 const base::Closure
& callback
,
148 const ErrorCallback
& error_callback
) = 0;
150 // Calls ActivateCellularModem method.
151 // |callback| is called after the method call succeeds.
152 virtual void ActivateCellularModem(
153 const dbus::ObjectPath
& service_path
,
154 const std::string
& carrier
,
155 const base::Closure
& callback
,
156 const ErrorCallback
& error_callback
) = 0;
158 // Calls the CompleteCellularActivation method.
159 // |callback| is called after the method call succeeds.
160 virtual void CompleteCellularActivation(
161 const dbus::ObjectPath
& service_path
,
162 const base::Closure
& callback
,
163 const ErrorCallback
& error_callback
) = 0;
165 // Calls the GetLoadableProfileEntries method.
166 // |callback| is called after the method call succeeds.
167 virtual void GetLoadableProfileEntries(
168 const dbus::ObjectPath
& service_path
,
169 const DictionaryValueCallback
& callback
) = 0;
171 // Returns an interface for testing (stub only), or returns NULL.
172 virtual TestInterface
* GetTestInterface() = 0;
175 friend class ShillServiceClientTest
;
177 // Create() should be used instead.
178 ShillServiceClient();
181 DISALLOW_COPY_AND_ASSIGN(ShillServiceClient
);
184 } // namespace chromeos
186 #endif // CHROMEOS_DBUS_SHILL_SERVICE_CLIENT_H_