OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_CHROMEOS_CROS_CROS_NETWORK_FUNCTIONS_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_CROS_CROS_NETWORK_FUNCTIONS_H_ |
6 #define CHROME_BROWSER_CHROMEOS_CROS_CROS_NETWORK_FUNCTIONS_H_ | 6 #define CHROME_BROWSER_CHROMEOS_CROS_CROS_NETWORK_FUNCTIONS_H_ |
7 | 7 |
8 // This header is introduced to make it easy to switch from chromeos_network.cc | 8 // This header is introduced to make it easy to switch from chromeos_network.cc |
9 // to Chrome's own DBus code. crosbug.com/16557 | 9 // to Chrome's own DBus code. crosbug.com/16557 |
10 // All calls to functions in chromeos_network.h should be made through | 10 // All calls to functions in chromeos_network.h should be made through |
11 // functions provided by this header. | 11 // functions provided by this header. |
12 | 12 |
13 #include "base/callback.h" | 13 #include "base/callback.h" |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
15 #include "third_party/cros/chromeos_network.h" | 15 #include "third_party/cros/chromeos_network.h" |
16 | 16 |
17 namespace base { | 17 namespace base { |
18 | 18 |
19 class DictionaryValue; | 19 class DictionaryValue; |
20 class Value; | 20 class Value; |
21 | 21 |
22 } // namespace base | 22 } // namespace base |
23 | 23 |
24 namespace chromeos { | 24 namespace chromeos { |
25 | 25 |
26 // Callback for asynchronous getters. | 26 // Callback for asynchronous getters. |
27 typedef base::Callback<void( | 27 typedef base::Callback<void( |
28 const char* path, | 28 const std::string& path, |
29 const base::DictionaryValue* properties)> NetworkPropertiesCallback; | 29 const base::DictionaryValue* properties)> NetworkPropertiesCallback; |
30 | 30 |
31 // Callback for network properties watchers. | 31 // Callback for network properties watchers. |
32 typedef base::Callback<void( | 32 typedef base::Callback<void( |
33 const std::string& path, | 33 const std::string& path, |
34 const std::string& key, | 34 const std::string& key, |
35 const base::Value& value)> NetworkPropertiesWatcherCallback; | 35 const base::Value& value)> NetworkPropertiesWatcherCallback; |
36 | 36 |
37 // Base class of signal watchers. | 37 // Base class of signal watchers. |
38 class CrosNetworkWatcher { | 38 class CrosNetworkWatcher { |
39 public: | 39 public: |
40 virtual ~CrosNetworkWatcher() {} | 40 virtual ~CrosNetworkWatcher() {} |
41 | 41 |
42 protected: | 42 protected: |
43 CrosNetworkWatcher() {} | 43 CrosNetworkWatcher() {} |
44 }; | 44 }; |
45 | 45 |
46 // Enables/Disables Libcros network functions. | 46 // Enables/Disables Libcros network functions. |
47 void SetLibcrosNetworkFunctionsEnabled(bool enabled); | 47 void SetLibcrosNetworkFunctionsEnabled(bool enabled); |
48 | 48 |
49 // Activates the cellular modem specified by |service_path| with carrier | 49 // Activates the cellular modem specified by |service_path| with carrier |
50 // specified by |carrier|. | 50 // specified by |carrier|. |
51 // |carrier| is NULL or an empty string, this will activate with the currently | 51 // |carrier| is NULL or an empty string, this will activate with the currently |
52 // active carrier. | 52 // active carrier. |
53 // Returns false on failure and true on success. | 53 // Returns false on failure and true on success. |
54 bool CrosActivateCellularModem(const char* service_path, const char* carrier); | 54 bool CrosActivateCellularModem(const std::string& service_path, |
| 55 const std::string& carrier); |
55 | 56 |
56 | 57 |
57 // Sets a property of a service to the provided value. | 58 // Sets a property of a service to the provided value. |
58 // Success is indicated by the receipt of a matching PropertyChanged signal. | 59 // Success is indicated by the receipt of a matching PropertyChanged signal. |
59 void CrosSetNetworkServiceProperty(const char* service_path, | 60 void CrosSetNetworkServiceProperty(const std::string& service_path, |
60 const char* property, | 61 const std::string& property, |
61 const base::Value& value); | 62 const base::Value& value); |
62 | 63 |
63 // Clears a property of a service. | 64 // Clears a property of a service. |
64 void CrosClearNetworkServiceProperty(const char* service_path, | 65 void CrosClearNetworkServiceProperty(const std::string& service_path, |
65 const char* property); | 66 const std::string& property); |
66 | 67 |
67 // Sets a property of a device to the provided value. | 68 // Sets a property of a device to the provided value. |
68 // Success is indicated by the receipt of a matching PropertyChanged signal. | 69 // Success is indicated by the receipt of a matching PropertyChanged signal. |
69 void CrosSetNetworkDeviceProperty(const char* device_path, | 70 void CrosSetNetworkDeviceProperty(const std::string& device_path, |
70 const char* property, | 71 const std::string& property, |
71 const base::Value& value); | 72 const base::Value& value); |
72 | 73 |
73 // Sets a property of an ip config to the provided value. | 74 // Sets a property of an ip config to the provided value. |
74 // Success is indicated by the receipt of a matching PropertyChanged signal. | 75 // Success is indicated by the receipt of a matching PropertyChanged signal. |
75 void CrosSetNetworkIPConfigProperty(const char* ipconfig_path, | 76 void CrosSetNetworkIPConfigProperty(const std::string& ipconfig_path, |
76 const char* property, | 77 const std::string& property, |
77 const base::Value& value); | 78 const base::Value& value); |
78 | 79 |
79 // Sets a property of a manager to the provided value. | 80 // Sets a property of a manager to the provided value. |
80 // Success is indicated by the receipt of a matching PropertyChanged signal. | 81 // Success is indicated by the receipt of a matching PropertyChanged signal. |
81 void CrosSetNetworkManagerProperty(const char* property, | 82 void CrosSetNetworkManagerProperty(const std::string& property, |
82 const base::Value& value); | 83 const base::Value& value); |
83 | 84 |
84 // Deletes a remembered service from a profile. | 85 // Deletes a remembered service from a profile. |
85 void CrosDeleteServiceFromProfile(const char* profile_path, | 86 void CrosDeleteServiceFromProfile(const std::string& profile_path, |
86 const char* service_path); | 87 const std::string& service_path); |
87 | 88 |
88 // Requests an update of the data plans. A callback will be received by any | 89 // Requests an update of the data plans. A callback will be received by any |
89 // object that invoked MonitorCellularDataPlan when up to date data is ready. | 90 // object that invoked MonitorCellularDataPlan when up to date data is ready. |
90 void CrosRequestCellularDataPlanUpdate(const char* modem_service_path); | 91 void CrosRequestCellularDataPlanUpdate(const std::string& modem_service_path); |
91 | 92 |
92 // Sets up monitoring of the PropertyChanged signal on the flimflam manager. | 93 // Sets up monitoring of the PropertyChanged signal on the flimflam manager. |
93 // The provided |callback| will be called whenever a manager property changes. | 94 // The provided |callback| will be called whenever a manager property changes. |
94 CrosNetworkWatcher* CrosMonitorNetworkManagerProperties( | 95 CrosNetworkWatcher* CrosMonitorNetworkManagerProperties( |
95 const NetworkPropertiesWatcherCallback& callback); | 96 const NetworkPropertiesWatcherCallback& callback); |
96 | 97 |
97 // Similar to MonitorNetworkManagerProperties for a specified network service. | 98 // Similar to MonitorNetworkManagerProperties for a specified network service. |
98 CrosNetworkWatcher* CrosMonitorNetworkServiceProperties( | 99 CrosNetworkWatcher* CrosMonitorNetworkServiceProperties( |
99 const NetworkPropertiesWatcherCallback& callback, | 100 const NetworkPropertiesWatcherCallback& callback, |
100 const std::string& service_path); | 101 const std::string& service_path); |
(...skipping 11 matching lines...) Expand all Loading... |
112 CrosNetworkWatcher* CrosMonitorSMS(const std::string& modem_device_path, | 113 CrosNetworkWatcher* CrosMonitorSMS(const std::string& modem_device_path, |
113 MonitorSMSCallback callback, | 114 MonitorSMSCallback callback, |
114 void* object); | 115 void* object); |
115 | 116 |
116 // Connects to the service with the |service_path|. | 117 // Connects to the service with the |service_path|. |
117 // Service parameters such as authentication must already be configured. | 118 // Service parameters such as authentication must already be configured. |
118 // Note, a successful invocation of the callback only indicates that | 119 // Note, a successful invocation of the callback only indicates that |
119 // the connection process has started. You will have to query the | 120 // the connection process has started. You will have to query the |
120 // connection state to determine if the connection was established | 121 // connection state to determine if the connection was established |
121 // successfully. | 122 // successfully. |
122 void CrosRequestNetworkServiceConnect(const char* service_path, | 123 void CrosRequestNetworkServiceConnect(const std::string& service_path, |
123 NetworkActionCallback callback, | 124 NetworkActionCallback callback, |
124 void* object); | 125 void* object); |
125 | 126 |
126 // Retrieves the latest info for the manager. | 127 // Retrieves the latest info for the manager. |
127 void CrosRequestNetworkManagerProperties( | 128 void CrosRequestNetworkManagerProperties( |
128 const NetworkPropertiesCallback& callback); | 129 const NetworkPropertiesCallback& callback); |
129 | 130 |
130 // Retrieves the latest info for a service. | 131 // Retrieves the latest info for a service. |
131 void CrosRequestNetworkServiceProperties( | 132 void CrosRequestNetworkServiceProperties( |
132 const char* service_path, | 133 const std::string& service_path, |
133 const NetworkPropertiesCallback& callback); | 134 const NetworkPropertiesCallback& callback); |
134 | 135 |
135 // Retrieves the latest info for a particular device. | 136 // Retrieves the latest info for a particular device. |
136 void CrosRequestNetworkDeviceProperties( | 137 void CrosRequestNetworkDeviceProperties( |
137 const char* device_path, | 138 const std::string& device_path, |
138 const NetworkPropertiesCallback& callback); | 139 const NetworkPropertiesCallback& callback); |
139 | 140 |
140 // Retrieves the list of remembered services for a profile. | 141 // Retrieves the list of remembered services for a profile. |
141 void CrosRequestNetworkProfileProperties( | 142 void CrosRequestNetworkProfileProperties( |
142 const char* profile_path, | 143 const std::string& profile_path, |
143 const NetworkPropertiesCallback& callback); | 144 const NetworkPropertiesCallback& callback); |
144 | 145 |
145 // Retrieves the latest info for a profile service entry. | 146 // Retrieves the latest info for a profile service entry. |
146 void CrosRequestNetworkProfileEntryProperties( | 147 void CrosRequestNetworkProfileEntryProperties( |
147 const char* profile_path, | 148 const std::string& profile_path, |
148 const char* profile_entry_path, | 149 const std::string& profile_entry_path, |
149 const NetworkPropertiesCallback& callback); | 150 const NetworkPropertiesCallback& callback); |
150 | 151 |
151 // Requests a wifi service not in the network list (i.e. hidden). | 152 // Requests a wifi service not in the network list (i.e. hidden). |
152 void CrosRequestHiddenWifiNetworkProperties( | 153 void CrosRequestHiddenWifiNetworkProperties( |
153 const char* ssid, | 154 const std::string& ssid, |
154 const char* security, | 155 const std::string& security, |
155 const NetworkPropertiesCallback& callback); | 156 const NetworkPropertiesCallback& callback); |
156 | 157 |
157 // Requests a new VPN service. | 158 // Requests a new VPN service. |
158 void CrosRequestVirtualNetworkProperties( | 159 void CrosRequestVirtualNetworkProperties( |
159 const char* service_name, | 160 const std::string& service_name, |
160 const char* server_hostname, | 161 const std::string& server_hostname, |
161 const char* provider_type, | 162 const std::string& provider_type, |
162 const NetworkPropertiesCallback& callback); | 163 const NetworkPropertiesCallback& callback); |
163 | 164 |
164 // Disconnects from network service asynchronously. | 165 // Disconnects from network service asynchronously. |
165 void CrosRequestNetworkServiceDisconnect(const char* service_path); | 166 void CrosRequestNetworkServiceDisconnect(const std::string& service_path); |
166 | 167 |
167 // Removes an exisiting network service (e.g. after forgetting a VPN). | 168 // Removes an exisiting network service (e.g. after forgetting a VPN). |
168 void CrosRequestRemoveNetworkService(const char* service_path); | 169 void CrosRequestRemoveNetworkService(const std::string& service_path); |
169 | 170 |
170 // Requests a scan of services of |type|. | 171 // Requests a scan of services of |type|. |
171 // |type| should be is a string recognized by flimflam's Manager API. | 172 // |type| should be is a string recognized by flimflam's Manager API. |
172 void CrosRequestNetworkScan(const char* network_type); | 173 void CrosRequestNetworkScan(const std::string& network_type); |
173 | 174 |
174 // Requests enabling or disabling a device. | 175 // Requests enabling or disabling a device. |
175 void CrosRequestNetworkDeviceEnable(const char* network_type, bool enable); | 176 void CrosRequestNetworkDeviceEnable(const std::string& network_type, |
| 177 bool enable); |
176 | 178 |
177 // Enables or disables PIN protection for a SIM card. | 179 // Enables or disables PIN protection for a SIM card. |
178 void CrosRequestRequirePin(const char* device_path, | 180 void CrosRequestRequirePin(const std::string& device_path, |
179 const char* pin, | 181 const std::string& pin, |
180 bool enable, | 182 bool enable, |
181 NetworkActionCallback callback, | 183 NetworkActionCallback callback, |
182 void* object); | 184 void* object); |
183 | 185 |
184 // Enters a PIN to unlock a SIM card. | 186 // Enters a PIN to unlock a SIM card. |
185 void CrosRequestEnterPin(const char* device_path, | 187 void CrosRequestEnterPin(const std::string& device_path, |
186 const char* pin, | 188 const std::string& pin, |
187 NetworkActionCallback callback, | 189 NetworkActionCallback callback, |
188 void* object); | 190 void* object); |
189 | 191 |
190 // Enters a PUK to unlock a SIM card whose PIN has been entered | 192 // Enters a PUK to unlock a SIM card whose PIN has been entered |
191 // incorrectly too many times. A new |pin| must be supplied | 193 // incorrectly too many times. A new |pin| must be supplied |
192 // along with the |unblock_code| (PUK). | 194 // along with the |unblock_code| (PUK). |
193 void CrosRequestUnblockPin(const char* device_path, | 195 void CrosRequestUnblockPin(const std::string& device_path, |
194 const char* unblock_code, | 196 const std::string& unblock_code, |
195 const char* pin, | 197 const std::string& pin, |
196 NetworkActionCallback callback, | 198 NetworkActionCallback callback, |
197 void* object); | 199 void* object); |
198 | 200 |
199 // Changes the PIN used to unlock a SIM card. | 201 // Changes the PIN used to unlock a SIM card. |
200 void CrosRequestChangePin(const char* device_path, | 202 void CrosRequestChangePin(const std::string& device_path, |
201 const char* old_pin, | 203 const std::string& old_pin, |
202 const char* new_pin, | 204 const std::string& new_pin, |
203 NetworkActionCallback callback, | 205 NetworkActionCallback callback, |
204 void* object); | 206 void* object); |
205 | 207 |
206 // Proposes to trigger a scan transaction. For cellular networks scan result | 208 // Proposes to trigger a scan transaction. For cellular networks scan result |
207 // is set in the property Cellular.FoundNetworks. | 209 // is set in the property Cellular.FoundNetworks. |
208 void CrosProposeScan(const char* device_path); | 210 void CrosProposeScan(const std::string& device_path); |
209 | 211 |
210 // Initiates registration on the network specified by network_id, which is in | 212 // Initiates registration on the network specified by network_id, which is in |
211 // the form MCCMNC. If the network ID is the empty string, then switch back to | 213 // the form MCCMNC. If the network ID is the empty string, then switch back to |
212 // automatic registration mode before initiating registration. | 214 // automatic registration mode before initiating registration. |
213 void CrosRequestCellularRegister(const char* device_path, | 215 void CrosRequestCellularRegister(const std::string& device_path, |
214 const char* network_id, | 216 const std::string& network_id, |
215 NetworkActionCallback callback, | 217 NetworkActionCallback callback, |
216 void* object); | 218 void* object); |
217 | 219 |
218 // Enables or disables the specific network device for connection. | 220 // Enables or disables the specific network device for connection. |
219 // Set offline mode. This will turn off all radios. | 221 // Set offline mode. This will turn off all radios. |
220 // Returns false on failure and true on success. | 222 // Returns false on failure and true on success. |
221 bool CrosSetOfflineMode(bool offline); | 223 bool CrosSetOfflineMode(bool offline); |
222 | 224 |
223 // Gets a list of all the IPConfigs using a given device path | 225 // Gets a list of all the IPConfigs using a given device path |
224 IPConfigStatus* CrosListIPConfigs(const char* device_path); | 226 IPConfigStatus* CrosListIPConfigs(const std::string& device_path); |
225 | 227 |
226 // Adds a IPConfig of the given type to the device | 228 // Adds a IPConfig of the given type to the device |
227 bool CrosAddIPConfig(const char* device_path, IPConfigType type); | 229 bool CrosAddIPConfig(const std::string& device_path, IPConfigType type); |
228 | 230 |
229 // Removes an existing IP Config | 231 // Removes an existing IP Config |
230 bool CrosRemoveIPConfig(IPConfig* config); | 232 bool CrosRemoveIPConfig(IPConfig* config); |
231 | 233 |
232 // Frees out a full status | 234 // Frees out a full status |
233 void CrosFreeIPConfigStatus(IPConfigStatus* status); | 235 void CrosFreeIPConfigStatus(IPConfigStatus* status); |
234 | 236 |
235 // Retrieves the list of visible network objects. This structure is not cached | 237 // Retrieves the list of visible network objects. This structure is not cached |
236 // within the DLL, and is fetched via d-bus on each call. | 238 // within the DLL, and is fetched via d-bus on each call. |
237 // Ownership of the DeviceNetworkList is returned to the caller; use | 239 // Ownership of the DeviceNetworkList is returned to the caller; use |
238 // FreeDeviceNetworkList to release it. | 240 // FreeDeviceNetworkList to release it. |
239 DeviceNetworkList* CrosGetDeviceNetworkList(); | 241 DeviceNetworkList* CrosGetDeviceNetworkList(); |
240 | 242 |
241 // Deletes a DeviceNetworkList type that was allocated in the ChromeOS dll. We | 243 // Deletes a DeviceNetworkList type that was allocated in the ChromeOS dll. We |
242 // need to do this to safely pass data over the dll boundary between our .so | 244 // need to do this to safely pass data over the dll boundary between our .so |
243 // and Chrome. | 245 // and Chrome. |
244 void CrosFreeDeviceNetworkList(DeviceNetworkList* network_list); | 246 void CrosFreeDeviceNetworkList(DeviceNetworkList* network_list); |
245 | 247 |
246 // Configures the network service specified by |properties|. | 248 // Configures the network service specified by |properties|. |
247 void CrosConfigureService(const base::DictionaryValue& properties); | 249 void CrosConfigureService(const base::DictionaryValue& properties); |
248 | 250 |
249 } // namespace chromeos | 251 } // namespace chromeos |
250 | 252 |
251 #endif // CHROME_BROWSER_CHROMEOS_CROS_CROS_NETWORK_FUNCTIONS_H_ | 253 #endif // CHROME_BROWSER_CHROMEOS_CROS_CROS_NETWORK_FUNCTIONS_H_ |
OLD | NEW |