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_implementation_type.h"
14 #include "chromeos/dbus/shill_client_helper.h"
19 class DictionaryValue
;
32 // ShillServiceClient is used to communicate with the Shill Service
34 // All methods should be called from the origin thread which initializes the
35 // DBusThreadManager instance.
36 class CHROMEOS_EXPORT ShillServiceClient
{
38 typedef ShillClientHelper::PropertyChangedHandler PropertyChangedHandler
;
39 typedef ShillClientHelper::DictionaryValueCallback DictionaryValueCallback
;
40 typedef ShillClientHelper::ListValueCallback ListValueCallback
;
41 typedef ShillClientHelper::ErrorCallback ErrorCallback
;
43 // Interface for setting up services for testing. Accessed through
44 // GetTestInterface(), only implemented in the stub implementation.
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_watch_list
) = 0;
52 virtual void AddServiceWithIPConfig(const std::string
& service_path
,
53 const std::string
& name
,
54 const std::string
& type
,
55 const std::string
& state
,
56 const std::string
& ipconfig_path
,
57 bool add_to_watch_list
) = 0;
58 virtual void RemoveService(const std::string
& service_path
) = 0;
59 virtual void SetServiceProperty(const std::string
& service_path
,
60 const std::string
& property
,
61 const base::Value
& value
) = 0;
62 virtual const base::DictionaryValue
* GetServiceProperties(
63 const std::string
& service_path
) const = 0;
64 virtual void ClearServices() = 0;
69 virtual ~ShillServiceClient();
71 // Factory function, creates a new instance which is owned by the caller.
72 // For normal usage, access the singleton via DBusThreadManager::Get().
73 static ShillServiceClient
* Create(DBusClientImplementationType type
,
76 // Adds a property changed |observer| to the service at |service_path|.
77 virtual void AddPropertyChangedObserver(
78 const dbus::ObjectPath
& service_path
,
79 ShillPropertyChangedObserver
* observer
) = 0;
81 // Removes a property changed |observer| to the service at |service_path|.
82 virtual void RemovePropertyChangedObserver(
83 const dbus::ObjectPath
& service_path
,
84 ShillPropertyChangedObserver
* observer
) = 0;
86 // Calls GetProperties method.
87 // |callback| is called after the method call succeeds.
88 virtual void GetProperties(const dbus::ObjectPath
& service_path
,
89 const DictionaryValueCallback
& callback
) = 0;
91 // Calls SetProperty method.
92 // |callback| is called after the method call succeeds.
93 virtual void SetProperty(const dbus::ObjectPath
& service_path
,
94 const std::string
& name
,
95 const base::Value
& value
,
96 const base::Closure
& callback
,
97 const ErrorCallback
& error_callback
) = 0;
99 // Calls ClearProperty method.
100 // |callback| is called after the method call succeeds.
101 virtual void ClearProperty(const dbus::ObjectPath
& service_path
,
102 const std::string
& name
,
103 const base::Closure
& callback
,
104 const ErrorCallback
& error_callback
) = 0;
106 // Calls ClearProperties method.
107 // |callback| is called after the method call succeeds.
108 virtual void ClearProperties(const dbus::ObjectPath
& service_path
,
109 const std::vector
<std::string
>& names
,
110 const ListValueCallback
& callback
,
111 const ErrorCallback
& error_callback
) = 0;
113 // Calls Connect method.
114 // |callback| is called after the method call succeeds.
115 virtual void Connect(const dbus::ObjectPath
& service_path
,
116 const base::Closure
& callback
,
117 const ErrorCallback
& error_callback
) = 0;
119 // Calls Disconnect method.
120 // |callback| is called after the method call succeeds.
121 virtual void Disconnect(const dbus::ObjectPath
& service_path
,
122 const base::Closure
& callback
,
123 const ErrorCallback
& error_callback
) = 0;
125 // Calls Remove method.
126 // |callback| is called after the method call succeeds.
127 virtual void Remove(const dbus::ObjectPath
& service_path
,
128 const base::Closure
& callback
,
129 const ErrorCallback
& error_callback
) = 0;
131 // Calls ActivateCellularModem method.
132 // |callback| is called after the method call succeeds.
133 virtual void ActivateCellularModem(
134 const dbus::ObjectPath
& service_path
,
135 const std::string
& carrier
,
136 const base::Closure
& callback
,
137 const ErrorCallback
& error_callback
) = 0;
139 // Calls the CompleteCellularActivation method.
140 // |callback| is called after the method call succeeds.
141 virtual void CompleteCellularActivation(
142 const dbus::ObjectPath
& service_path
,
143 const base::Closure
& callback
,
144 const ErrorCallback
& error_callback
) = 0;
146 // DEPRECATED DO NOT USE: Calls ActivateCellularModem method and blocks until
147 // the method call finishes.
149 // TODO(hashimoto): Refactor CrosActivateCellularModem and remove this method.
151 virtual bool CallActivateCellularModemAndBlock(
152 const dbus::ObjectPath
& service_path
,
153 const std::string
& carrier
) = 0;
155 // Returns an interface for testing (stub only), or returns NULL.
156 virtual TestInterface
* GetTestInterface() = 0;
159 // Create() should be used instead.
160 ShillServiceClient();
163 DISALLOW_COPY_AND_ASSIGN(ShillServiceClient
);
166 } // namespace chromeos
168 #endif // CHROMEOS_DBUS_SHILL_SERVICE_CLIENT_H_