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_MANAGER_CLIENT_H_
6 #define CHROMEOS_DBUS_SHILL_MANAGER_CLIENT_H_
10 #include "base/basictypes.h"
11 #include "chromeos/chromeos_export.h"
12 #include "chromeos/dbus/dbus_client_implementation_type.h"
13 #include "chromeos/dbus/dbus_method_call_status.h"
14 #include "chromeos/dbus/shill_client_helper.h"
25 class ShillPropertyChangedObserver
;
27 // ShillManagerClient is used to communicate with the Shill Manager
28 // service. All methods should be called from the origin thread which
29 // initializes the DBusThreadManager instance.
30 class CHROMEOS_EXPORT ShillManagerClient
{
32 typedef ShillClientHelper::PropertyChangedHandler PropertyChangedHandler
;
33 typedef ShillClientHelper::DictionaryValueCallback DictionaryValueCallback
;
34 typedef ShillClientHelper::ErrorCallback ErrorCallback
;
35 typedef ShillClientHelper::StringCallback StringCallback
;
36 typedef ShillClientHelper::BooleanCallback BooleanCallback
;
38 // Interface for setting up devices, services, and technologies for testing.
39 // Accessed through GetTestInterface(), only implemented in the Stub Impl.
42 virtual void AddDevice(const std::string
& device_path
) = 0;
43 virtual void RemoveDevice(const std::string
& device_path
) = 0;
44 virtual void ClearDevices() = 0;
45 virtual void AddTechnology(const std::string
& type
, bool enabled
) = 0;
46 virtual void RemoveTechnology(const std::string
& type
) = 0;
47 virtual void SetTechnologyInitializing(const std::string
& type
,
48 bool initializing
) = 0;
49 virtual void AddGeoNetwork(const std::string
& technology
,
50 const base::DictionaryValue
& network
) = 0;
52 // Does not create an actual profile in the ProfileClient but update the
53 // profiles list and sends a notification to observers. This should only be
54 // called by the ProfileStub. In all other cases, use
55 // ShillProfileClient::TestInterface::AddProfile.
56 virtual void AddProfile(const std::string
& profile_path
) = 0;
58 // Used to reset all properties; does not notify observers.
59 virtual void ClearProperties() = 0;
61 // Move an existing service to a different index, e.g. to simulate the
62 // result of a successful connect.
63 virtual void MoveServiceToIndex(const std::string
& service_path
,
65 bool add_to_watch_list
) = 0;
67 // Add/Remove/ClearService should only be called from ShillServiceClient.
68 virtual void AddManagerService(const std::string
& service_path
,
69 bool add_to_watch_list
) = 0;
70 virtual void RemoveManagerService(const std::string
& service_path
) = 0;
71 virtual void ClearManagerServices() = 0;
74 virtual ~TestInterface() {}
77 // Properties used to verify the origin device.
78 struct VerificationProperties
{
79 VerificationProperties();
80 ~VerificationProperties();
82 // A string containing a PEM-encoded X.509 certificate for use in verifying
84 std::string certificate
;
86 // A string containing a PEM-encoded RSA public key to be used to compare
87 // with the one in signedData
88 std::string public_key
;
90 // A string containing a base64-encoded random binary data for use in
91 // verifying the signed data.
94 // A string containing the identifying data string signed by the device.
95 std::string signed_data
;
97 // A string containing the serial number of the device.
98 std::string device_serial
;
100 // A string containing the SSID of the device. Only set if the device has
101 // already been setup once.
102 std::string device_ssid
;
104 // A string containing the BSSID of the device. Only set if the device has
105 // already been setup.
106 std::string device_bssid
;
109 virtual ~ShillManagerClient();
111 // Factory function, creates a new instance which is owned by the caller.
112 // For normal usage, access the singleton via DBusThreadManager::Get().
113 static ShillManagerClient
* Create(DBusClientImplementationType type
,
116 // Adds a property changed |observer|.
117 virtual void AddPropertyChangedObserver(
118 ShillPropertyChangedObserver
* observer
) = 0;
120 // Removes a property changed |observer|.
121 virtual void RemovePropertyChangedObserver(
122 ShillPropertyChangedObserver
* observer
) = 0;
124 // Calls GetProperties method.
125 // |callback| is called after the method call succeeds.
126 virtual void GetProperties(const DictionaryValueCallback
& callback
) = 0;
128 // DEPRECATED DO NOT USE: Calls GetProperties method and blocks until the
129 // method call finishes. The caller is responsible to delete the result.
130 // Thie method returns NULL when method call fails.
132 // TODO(hashimoto): Refactor blocking calls and remove this method.
134 virtual base::DictionaryValue
* CallGetPropertiesAndBlock() = 0;
136 // Calls GetNetworksForGeolocation method.
137 // |callback| is called after the method call succeeds.
138 virtual void GetNetworksForGeolocation(
139 const DictionaryValueCallback
& callback
) = 0;
141 // Calls SetProperty method.
142 // |callback| is called after the method call succeeds.
143 virtual void SetProperty(const std::string
& name
,
144 const base::Value
& value
,
145 const base::Closure
& callback
,
146 const ErrorCallback
& error_callback
) = 0;
148 // Calls RequestScan method.
149 // |callback| is called after the method call succeeds.
150 virtual void RequestScan(const std::string
& type
,
151 const base::Closure
& callback
,
152 const ErrorCallback
& error_callback
) = 0;
154 // Calls EnableTechnology method.
155 // |callback| is called after the method call succeeds.
156 virtual void EnableTechnology(const std::string
& type
,
157 const base::Closure
& callback
,
158 const ErrorCallback
& error_callback
) = 0;
160 // Calls DisableTechnology method.
161 // |callback| is called after the method call succeeds.
162 virtual void DisableTechnology(const std::string
& type
,
163 const base::Closure
& callback
,
164 const ErrorCallback
& error_callback
) = 0;
166 // Calls ConfigureService method.
167 // |callback| is called after the method call succeeds.
168 virtual void ConfigureService(const base::DictionaryValue
& properties
,
169 const ObjectPathCallback
& callback
,
170 const ErrorCallback
& error_callback
) = 0;
172 // Calls ConfigureServiceForProfile method.
173 // |callback| is called with the created service if the method call succeeds.
174 virtual void ConfigureServiceForProfile(
175 const dbus::ObjectPath
& profile_path
,
176 const base::DictionaryValue
& properties
,
177 const ObjectPathCallback
& callback
,
178 const ErrorCallback
& error_callback
) = 0;
180 // Calls GetService method.
181 // |callback| is called after the method call succeeds.
182 virtual void GetService(const base::DictionaryValue
& properties
,
183 const ObjectPathCallback
& callback
,
184 const ErrorCallback
& error_callback
) = 0;
186 // Verify that the given data corresponds to a trusted device, and return true
187 // to the callback if it is.
188 virtual void VerifyDestination(const VerificationProperties
& properties
,
189 const BooleanCallback
& callback
,
190 const ErrorCallback
& error_callback
) = 0;
192 // Verify that the given data corresponds to a trusted device, and if it is,
193 // return the encrypted credentials for connecting to the network represented
194 // by the given |service_path|, encrypted using the |public_key| for the
195 // trusted device. If the device is not trusted, return the empty string.
196 virtual void VerifyAndEncryptCredentials(
197 const VerificationProperties
& properties
,
198 const std::string
& service_path
,
199 const StringCallback
& callback
,
200 const ErrorCallback
& error_callback
) = 0;
202 // Verify that the given data corresponds to a trusted device, and return the
203 // |data| encrypted using the |public_key| for the trusted device. If the
204 // device is not trusted, return the empty string.
205 virtual void VerifyAndEncryptData(const VerificationProperties
& properties
,
206 const std::string
& data
,
207 const StringCallback
& callback
,
208 const ErrorCallback
& error_callback
) = 0;
210 // For each technology present, connect to the "best" service available.
211 // Called once the user is logged in and certificates are loaded.
212 virtual void ConnectToBestServices(const base::Closure
& callback
,
213 const ErrorCallback
& error_callback
) = 0;
215 // Returns an interface for testing (stub only), or returns NULL.
216 virtual TestInterface
* GetTestInterface() = 0;
219 // Create() should be used instead.
220 ShillManagerClient();
223 DISALLOW_COPY_AND_ASSIGN(ShillManagerClient
);
226 } // namespace chromeos
228 #endif // CHROMEOS_DBUS_SHILL_MANAGER_CLIENT_H_