| 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 #include "chrome/browser/chromeos/cros/cros_network_functions.h" | 5 #include "chrome/browser/chromeos/cros/cros_network_functions.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/values.h" | 9 #include "base/values.h" |
| 10 #include "chrome/browser/chromeos/cros/gvalue_util.h" | 10 #include "chrome/browser/chromeos/cros/gvalue_util.h" |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 } | 160 } |
| 161 | 161 |
| 162 private: | 162 private: |
| 163 SMSMonitor monitor_; | 163 SMSMonitor monitor_; |
| 164 }; | 164 }; |
| 165 | 165 |
| 166 // Does nothing. Used as a callback. | 166 // Does nothing. Used as a callback. |
| 167 void DoNothing(DBusMethodCallStatus call_status) {} | 167 void DoNothing(DBusMethodCallStatus call_status) {} |
| 168 | 168 |
| 169 // Callback used by OnRequestNetworkProperties. | 169 // Callback used by OnRequestNetworkProperties. |
| 170 typedef base::Callback<void(const char* path, | 170 typedef base::Callback<void(const std::string& path, |
| 171 const base::DictionaryValue* properties) | 171 const base::DictionaryValue* properties) |
| 172 > OnRequestNetworkPropertiesCallback; | 172 > OnRequestNetworkPropertiesCallback; |
| 173 | 173 |
| 174 // Handles responses for RequestNetwork*Properties functions. | 174 // Handles responses for RequestNetwork*Properties functions. |
| 175 void OnRequestNetworkProperties(void* object, | 175 void OnRequestNetworkProperties(void* object, |
| 176 const char* path, | 176 const char* path, |
| 177 GHashTable* properties) { | 177 GHashTable* properties) { |
| 178 OnRequestNetworkPropertiesCallback* callback = | 178 OnRequestNetworkPropertiesCallback* callback = |
| 179 static_cast<OnRequestNetworkPropertiesCallback*>(object); | 179 static_cast<OnRequestNetworkPropertiesCallback*>(object); |
| 180 DictionaryValue* properties_dictionary = NULL; | 180 DictionaryValue* properties_dictionary = NULL; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 198 if (key == NULL || gvalue == NULL || path == NULL || object == NULL) | 198 if (key == NULL || gvalue == NULL || path == NULL || object == NULL) |
| 199 return; | 199 return; |
| 200 NetworkPropertiesWatcherCallback* callback = | 200 NetworkPropertiesWatcherCallback* callback = |
| 201 static_cast<NetworkPropertiesWatcherCallback*>(object); | 201 static_cast<NetworkPropertiesWatcherCallback*>(object); |
| 202 scoped_ptr<Value> value(ConvertGValueToValue(gvalue)); | 202 scoped_ptr<Value> value(ConvertGValueToValue(gvalue)); |
| 203 callback->Run(path, key, *value); | 203 callback->Run(path, key, *value); |
| 204 } | 204 } |
| 205 | 205 |
| 206 // A callback used to implement CrosRequest*Properties functions. | 206 // A callback used to implement CrosRequest*Properties functions. |
| 207 void RunCallbackWithDictionaryValue(const NetworkPropertiesCallback& callback, | 207 void RunCallbackWithDictionaryValue(const NetworkPropertiesCallback& callback, |
| 208 const char* path, | 208 const std::string& path, |
| 209 DBusMethodCallStatus call_status, | 209 DBusMethodCallStatus call_status, |
| 210 const base::DictionaryValue& value) { | 210 const base::DictionaryValue& value) { |
| 211 callback.Run(path, call_status == DBUS_METHOD_CALL_SUCCESS ? &value : NULL); | 211 callback.Run(path, call_status == DBUS_METHOD_CALL_SUCCESS ? &value : NULL); |
| 212 } | 212 } |
| 213 | 213 |
| 214 // Used as a callback for chromeos::ConfigureService. | 214 // Used as a callback for chromeos::ConfigureService. |
| 215 void OnConfigureService(void* object, | 215 void OnConfigureService(void* object, |
| 216 const char* service_path, | 216 const char* service_path, |
| 217 NetworkMethodErrorType error, | 217 NetworkMethodErrorType error, |
| 218 const char* error_message) { | 218 const char* error_message) { |
| 219 if (error != NETWORK_METHOD_ERROR_NONE) { | 219 if (error != NETWORK_METHOD_ERROR_NONE) { |
| 220 LOG(WARNING) << "Error from ConfigureService callback: " | 220 LOG(WARNING) << "Error from ConfigureService callback: " |
| 221 << " Error: " << error << " Message: " << error_message; | 221 << " Error: " << error << " Message: " << error_message; |
| 222 } | 222 } |
| 223 } | 223 } |
| 224 | 224 |
| 225 // A bool to remember whether we are using Libcros network functions or not. | 225 // A bool to remember whether we are using Libcros network functions or not. |
| 226 bool g_libcros_network_functions_enabled = true; | 226 bool g_libcros_network_functions_enabled = true; |
| 227 | 227 |
| 228 } // namespace | 228 } // namespace |
| 229 | 229 |
| 230 void SetLibcrosNetworkFunctionsEnabled(bool enabled) { | 230 void SetLibcrosNetworkFunctionsEnabled(bool enabled) { |
| 231 g_libcros_network_functions_enabled = enabled; | 231 g_libcros_network_functions_enabled = enabled; |
| 232 } | 232 } |
| 233 | 233 |
| 234 bool CrosActivateCellularModem(const char* service_path, const char* carrier) { | 234 bool CrosActivateCellularModem(const std::string& service_path, |
| 235 return chromeos::ActivateCellularModem(service_path, carrier); | 235 const std::string& carrier) { |
| 236 return chromeos::ActivateCellularModem(service_path.c_str(), carrier.c_str()); |
| 236 } | 237 } |
| 237 | 238 |
| 238 void CrosSetNetworkServiceProperty(const char* service_path, | 239 void CrosSetNetworkServiceProperty(const std::string& service_path, |
| 239 const char* property, | 240 const std::string& property, |
| 240 const base::Value& value) { | 241 const base::Value& value) { |
| 241 if (g_libcros_network_functions_enabled) { | 242 if (g_libcros_network_functions_enabled) { |
| 242 ScopedGValue gvalue(ConvertValueToGValue(value)); | 243 ScopedGValue gvalue(ConvertValueToGValue(value)); |
| 243 chromeos::SetNetworkServicePropertyGValue(service_path, property, | 244 chromeos::SetNetworkServicePropertyGValue(service_path.c_str(), |
| 245 property.c_str(), |
| 244 gvalue.get()); | 246 gvalue.get()); |
| 245 } else { | 247 } else { |
| 246 DBusThreadManager::Get()->GetFlimflamServiceClient()->SetProperty( | 248 DBusThreadManager::Get()->GetFlimflamServiceClient()->SetProperty( |
| 247 dbus::ObjectPath(service_path), property, value, | 249 dbus::ObjectPath(service_path), property, value, |
| 248 base::Bind(&DoNothing)); | 250 base::Bind(&DoNothing)); |
| 249 } | 251 } |
| 250 } | 252 } |
| 251 | 253 |
| 252 void CrosClearNetworkServiceProperty(const char* service_path, | 254 void CrosClearNetworkServiceProperty(const std::string& service_path, |
| 253 const char* property) { | 255 const std::string& property) { |
| 254 if (g_libcros_network_functions_enabled) { | 256 if (g_libcros_network_functions_enabled) { |
| 255 chromeos::ClearNetworkServiceProperty(service_path, property); | 257 chromeos::ClearNetworkServiceProperty(service_path.c_str(), |
| 258 property.c_str()); |
| 256 } else { | 259 } else { |
| 257 DBusThreadManager::Get()->GetFlimflamServiceClient()->ClearProperty( | 260 DBusThreadManager::Get()->GetFlimflamServiceClient()->ClearProperty( |
| 258 dbus::ObjectPath(service_path), property, base::Bind(&DoNothing)); | 261 dbus::ObjectPath(service_path), property, base::Bind(&DoNothing)); |
| 259 } | 262 } |
| 260 } | 263 } |
| 261 | 264 |
| 262 void CrosSetNetworkDeviceProperty(const char* device_path, | 265 void CrosSetNetworkDeviceProperty(const std::string& device_path, |
| 263 const char* property, | 266 const std::string& property, |
| 264 const base::Value& value) { | 267 const base::Value& value) { |
| 265 if (g_libcros_network_functions_enabled) { | 268 if (g_libcros_network_functions_enabled) { |
| 266 ScopedGValue gvalue(ConvertValueToGValue(value)); | 269 ScopedGValue gvalue(ConvertValueToGValue(value)); |
| 267 chromeos::SetNetworkDevicePropertyGValue(device_path, property, | 270 chromeos::SetNetworkDevicePropertyGValue(device_path.c_str(), |
| 271 property.c_str(), |
| 268 gvalue.get()); | 272 gvalue.get()); |
| 269 } else { | 273 } else { |
| 270 DBusThreadManager::Get()->GetFlimflamDeviceClient()->SetProperty( | 274 DBusThreadManager::Get()->GetFlimflamDeviceClient()->SetProperty( |
| 271 dbus::ObjectPath(device_path), property, value, base::Bind(&DoNothing)); | 275 dbus::ObjectPath(device_path), property, value, base::Bind(&DoNothing)); |
| 272 } | 276 } |
| 273 } | 277 } |
| 274 | 278 |
| 275 void CrosSetNetworkIPConfigProperty(const char* ipconfig_path, | 279 void CrosSetNetworkIPConfigProperty(const std::string& ipconfig_path, |
| 276 const char* property, | 280 const std::string& property, |
| 277 const base::Value& value) { | 281 const base::Value& value) { |
| 278 if (g_libcros_network_functions_enabled) { | 282 if (g_libcros_network_functions_enabled) { |
| 279 ScopedGValue gvalue(ConvertValueToGValue(value)); | 283 ScopedGValue gvalue(ConvertValueToGValue(value)); |
| 280 chromeos::SetNetworkIPConfigPropertyGValue(ipconfig_path, property, | 284 chromeos::SetNetworkIPConfigPropertyGValue(ipconfig_path.c_str(), |
| 285 property.c_str(), |
| 281 gvalue.get()); | 286 gvalue.get()); |
| 282 } else { | 287 } else { |
| 283 DBusThreadManager::Get()->GetFlimflamIPConfigClient()->SetProperty( | 288 DBusThreadManager::Get()->GetFlimflamIPConfigClient()->SetProperty( |
| 284 dbus::ObjectPath(ipconfig_path), property, value, | 289 dbus::ObjectPath(ipconfig_path), property, value, |
| 285 base::Bind(&DoNothing)); | 290 base::Bind(&DoNothing)); |
| 286 } | 291 } |
| 287 } | 292 } |
| 288 | 293 |
| 289 void CrosSetNetworkManagerProperty(const char* property, | 294 void CrosSetNetworkManagerProperty(const std::string& property, |
| 290 const base::Value& value) { | 295 const base::Value& value) { |
| 291 if (g_libcros_network_functions_enabled) { | 296 if (g_libcros_network_functions_enabled) { |
| 292 ScopedGValue gvalue(ConvertValueToGValue(value)); | 297 ScopedGValue gvalue(ConvertValueToGValue(value)); |
| 293 chromeos::SetNetworkManagerPropertyGValue(property, gvalue.get()); | 298 chromeos::SetNetworkManagerPropertyGValue(property.c_str(), gvalue.get()); |
| 294 } else { | 299 } else { |
| 295 DBusThreadManager::Get()->GetFlimflamManagerClient()->SetProperty( | 300 DBusThreadManager::Get()->GetFlimflamManagerClient()->SetProperty( |
| 296 property, value, base::Bind(&DoNothing)); | 301 property, value, base::Bind(&DoNothing)); |
| 297 } | 302 } |
| 298 } | 303 } |
| 299 | 304 |
| 300 void CrosDeleteServiceFromProfile(const char* profile_path, | 305 void CrosDeleteServiceFromProfile(const std::string& profile_path, |
| 301 const char* service_path) { | 306 const std::string& service_path) { |
| 302 if (g_libcros_network_functions_enabled) { | 307 if (g_libcros_network_functions_enabled) { |
| 303 chromeos::DeleteServiceFromProfile(profile_path, service_path); | 308 chromeos::DeleteServiceFromProfile(profile_path.c_str(), |
| 309 service_path.c_str()); |
| 304 } else { | 310 } else { |
| 305 DBusThreadManager::Get()->GetFlimflamProfileClient()->DeleteEntry( | 311 DBusThreadManager::Get()->GetFlimflamProfileClient()->DeleteEntry( |
| 306 dbus::ObjectPath(profile_path), service_path, base::Bind(&DoNothing)); | 312 dbus::ObjectPath(profile_path), service_path, base::Bind(&DoNothing)); |
| 307 } | 313 } |
| 308 } | 314 } |
| 309 | 315 |
| 310 void CrosRequestCellularDataPlanUpdate(const char* modem_service_path) { | 316 void CrosRequestCellularDataPlanUpdate(const std::string& modem_service_path) { |
| 311 if (g_libcros_network_functions_enabled) { | 317 if (g_libcros_network_functions_enabled) { |
| 312 chromeos::RequestCellularDataPlanUpdate(modem_service_path); | 318 chromeos::RequestCellularDataPlanUpdate(modem_service_path.c_str()); |
| 313 } else { | 319 } else { |
| 314 DBusThreadManager::Get()->GetCashewClient()->RequestDataPlansUpdate( | 320 DBusThreadManager::Get()->GetCashewClient()->RequestDataPlansUpdate( |
| 315 modem_service_path); | 321 modem_service_path); |
| 316 } | 322 } |
| 317 } | 323 } |
| 318 | 324 |
| 319 CrosNetworkWatcher* CrosMonitorNetworkManagerProperties( | 325 CrosNetworkWatcher* CrosMonitorNetworkManagerProperties( |
| 320 const NetworkPropertiesWatcherCallback& callback) { | 326 const NetworkPropertiesWatcherCallback& callback) { |
| 321 if (g_libcros_network_functions_enabled) | 327 if (g_libcros_network_functions_enabled) |
| 322 return new CrosNetworkManagerPropertiesWatcher(callback); | 328 return new CrosNetworkManagerPropertiesWatcher(callback); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 346 MonitorDataPlanCallback callback, void* object) { | 352 MonitorDataPlanCallback callback, void* object) { |
| 347 return new CrosDataPlanUpdateWatcher(callback, object); | 353 return new CrosDataPlanUpdateWatcher(callback, object); |
| 348 } | 354 } |
| 349 | 355 |
| 350 CrosNetworkWatcher* CrosMonitorSMS(const std::string& modem_device_path, | 356 CrosNetworkWatcher* CrosMonitorSMS(const std::string& modem_device_path, |
| 351 MonitorSMSCallback callback, | 357 MonitorSMSCallback callback, |
| 352 void* object) { | 358 void* object) { |
| 353 return new CrosSMSWatcher(modem_device_path, callback, object); | 359 return new CrosSMSWatcher(modem_device_path, callback, object); |
| 354 } | 360 } |
| 355 | 361 |
| 356 void CrosRequestNetworkServiceConnect(const char* service_path, | 362 void CrosRequestNetworkServiceConnect(const std::string& service_path, |
| 357 NetworkActionCallback callback, | 363 NetworkActionCallback callback, |
| 358 void* object) { | 364 void* object) { |
| 359 chromeos::RequestNetworkServiceConnect(service_path, callback, object); | 365 chromeos::RequestNetworkServiceConnect(service_path.c_str(), callback, |
| 366 object); |
| 360 } | 367 } |
| 361 | 368 |
| 362 void CrosRequestNetworkManagerProperties( | 369 void CrosRequestNetworkManagerProperties( |
| 363 const NetworkPropertiesCallback& callback) { | 370 const NetworkPropertiesCallback& callback) { |
| 364 if (g_libcros_network_functions_enabled) { | 371 if (g_libcros_network_functions_enabled) { |
| 365 // The newly allocated callback will be deleted in | 372 // The newly allocated callback will be deleted in |
| 366 // OnRequestNetworkProperties. | 373 // OnRequestNetworkProperties. |
| 367 chromeos::RequestNetworkManagerProperties( | 374 chromeos::RequestNetworkManagerProperties( |
| 368 &OnRequestNetworkProperties, | 375 &OnRequestNetworkProperties, |
| 369 new OnRequestNetworkPropertiesCallback(callback)); | 376 new OnRequestNetworkPropertiesCallback(callback)); |
| 370 } else { | 377 } else { |
| 371 DBusThreadManager::Get()->GetFlimflamManagerClient()->GetProperties( | 378 DBusThreadManager::Get()->GetFlimflamManagerClient()->GetProperties( |
| 372 base::Bind(&RunCallbackWithDictionaryValue, | 379 base::Bind(&RunCallbackWithDictionaryValue, |
| 373 callback, | 380 callback, |
| 374 flimflam::kFlimflamServicePath)); | 381 flimflam::kFlimflamServicePath)); |
| 375 } | 382 } |
| 376 } | 383 } |
| 377 | 384 |
| 378 void CrosRequestNetworkServiceProperties( | 385 void CrosRequestNetworkServiceProperties( |
| 379 const char* service_path, | 386 const std::string& service_path, |
| 380 const NetworkPropertiesCallback& callback) { | 387 const NetworkPropertiesCallback& callback) { |
| 381 if (g_libcros_network_functions_enabled) { | 388 if (g_libcros_network_functions_enabled) { |
| 382 // The newly allocated callback will be deleted in | 389 // The newly allocated callback will be deleted in |
| 383 // OnRequestNetworkProperties. | 390 // OnRequestNetworkProperties. |
| 384 chromeos::RequestNetworkServiceProperties( | 391 chromeos::RequestNetworkServiceProperties( |
| 385 service_path, | 392 service_path.c_str(), |
| 386 &OnRequestNetworkProperties, | 393 &OnRequestNetworkProperties, |
| 387 new OnRequestNetworkPropertiesCallback(callback)); | 394 new OnRequestNetworkPropertiesCallback(callback)); |
| 388 } else { | 395 } else { |
| 389 DBusThreadManager::Get()->GetFlimflamServiceClient()->GetProperties( | 396 DBusThreadManager::Get()->GetFlimflamServiceClient()->GetProperties( |
| 390 dbus::ObjectPath(service_path), | 397 dbus::ObjectPath(service_path), |
| 391 base::Bind(&RunCallbackWithDictionaryValue, callback, service_path)); | 398 base::Bind(&RunCallbackWithDictionaryValue, callback, service_path)); |
| 392 } | 399 } |
| 393 } | 400 } |
| 394 | 401 |
| 395 void CrosRequestNetworkDeviceProperties( | 402 void CrosRequestNetworkDeviceProperties( |
| 396 const char* device_path, | 403 const std::string& device_path, |
| 397 const NetworkPropertiesCallback& callback) { | 404 const NetworkPropertiesCallback& callback) { |
| 398 if (g_libcros_network_functions_enabled) { | 405 if (g_libcros_network_functions_enabled) { |
| 399 // The newly allocated callback will be deleted in | 406 // The newly allocated callback will be deleted in |
| 400 // OnRequestNetworkProperties. | 407 // OnRequestNetworkProperties. |
| 401 chromeos::RequestNetworkDeviceProperties( | 408 chromeos::RequestNetworkDeviceProperties( |
| 402 device_path, | 409 device_path.c_str(), |
| 403 &OnRequestNetworkProperties, | 410 &OnRequestNetworkProperties, |
| 404 new OnRequestNetworkPropertiesCallback(callback)); | 411 new OnRequestNetworkPropertiesCallback(callback)); |
| 405 } else { | 412 } else { |
| 406 DBusThreadManager::Get()->GetFlimflamDeviceClient()->GetProperties( | 413 DBusThreadManager::Get()->GetFlimflamDeviceClient()->GetProperties( |
| 407 dbus::ObjectPath(device_path), | 414 dbus::ObjectPath(device_path), |
| 408 base::Bind(&RunCallbackWithDictionaryValue, callback, device_path)); | 415 base::Bind(&RunCallbackWithDictionaryValue, callback, device_path)); |
| 409 } | 416 } |
| 410 } | 417 } |
| 411 | 418 |
| 412 void CrosRequestNetworkProfileProperties( | 419 void CrosRequestNetworkProfileProperties( |
| 413 const char* profile_path, | 420 const std::string& profile_path, |
| 414 const NetworkPropertiesCallback& callback) { | 421 const NetworkPropertiesCallback& callback) { |
| 415 if (g_libcros_network_functions_enabled) { | 422 if (g_libcros_network_functions_enabled) { |
| 416 // The newly allocated callback will be deleted in | 423 // The newly allocated callback will be deleted in |
| 417 // OnRequestNetworkProperties. | 424 // OnRequestNetworkProperties. |
| 418 chromeos::RequestNetworkProfileProperties( | 425 chromeos::RequestNetworkProfileProperties( |
| 419 profile_path, | 426 profile_path.c_str(), |
| 420 &OnRequestNetworkProperties, | 427 &OnRequestNetworkProperties, |
| 421 new OnRequestNetworkPropertiesCallback(callback)); | 428 new OnRequestNetworkPropertiesCallback(callback)); |
| 422 } else { | 429 } else { |
| 423 DBusThreadManager::Get()->GetFlimflamProfileClient()->GetProperties( | 430 DBusThreadManager::Get()->GetFlimflamProfileClient()->GetProperties( |
| 424 dbus::ObjectPath(profile_path), | 431 dbus::ObjectPath(profile_path), |
| 425 base::Bind(&RunCallbackWithDictionaryValue, callback, profile_path)); | 432 base::Bind(&RunCallbackWithDictionaryValue, callback, profile_path)); |
| 426 } | 433 } |
| 427 } | 434 } |
| 428 | 435 |
| 429 void CrosRequestNetworkProfileEntryProperties( | 436 void CrosRequestNetworkProfileEntryProperties( |
| 430 const char* profile_path, | 437 const std::string& profile_path, |
| 431 const char* profile_entry_path, | 438 const std::string& profile_entry_path, |
| 432 const NetworkPropertiesCallback& callback) { | 439 const NetworkPropertiesCallback& callback) { |
| 433 if (g_libcros_network_functions_enabled) { | 440 if (g_libcros_network_functions_enabled) { |
| 434 // The newly allocated callback will be deleted in | 441 // The newly allocated callback will be deleted in |
| 435 // OnRequestNetworkProperties. | 442 // OnRequestNetworkProperties. |
| 436 chromeos::RequestNetworkProfileEntryProperties( | 443 chromeos::RequestNetworkProfileEntryProperties( |
| 437 profile_path, | 444 profile_path.c_str(), |
| 438 profile_entry_path, | 445 profile_entry_path.c_str(), |
| 439 &OnRequestNetworkProperties, | 446 &OnRequestNetworkProperties, |
| 440 new OnRequestNetworkPropertiesCallback(callback)); | 447 new OnRequestNetworkPropertiesCallback(callback)); |
| 441 } else { | 448 } else { |
| 442 DBusThreadManager::Get()->GetFlimflamProfileClient()->GetEntry( | 449 DBusThreadManager::Get()->GetFlimflamProfileClient()->GetEntry( |
| 443 dbus::ObjectPath(profile_path), | 450 dbus::ObjectPath(profile_path), |
| 444 profile_entry_path, | 451 profile_entry_path, |
| 445 base::Bind(&RunCallbackWithDictionaryValue, | 452 base::Bind(&RunCallbackWithDictionaryValue, |
| 446 callback, | 453 callback, |
| 447 profile_entry_path)); | 454 profile_entry_path)); |
| 448 } | 455 } |
| 449 } | 456 } |
| 450 | 457 |
| 451 void CrosRequestHiddenWifiNetworkProperties( | 458 void CrosRequestHiddenWifiNetworkProperties( |
| 452 const char* ssid, | 459 const std::string& ssid, |
| 453 const char* security, | 460 const std::string& security, |
| 454 const NetworkPropertiesCallback& callback) { | 461 const NetworkPropertiesCallback& callback) { |
| 455 // The newly allocated callback will be deleted in OnRequestNetworkProperties. | 462 // The newly allocated callback will be deleted in OnRequestNetworkProperties. |
| 456 chromeos::RequestHiddenWifiNetworkProperties( | 463 chromeos::RequestHiddenWifiNetworkProperties( |
| 457 ssid, | 464 ssid.c_str(), |
| 458 security, | 465 security.c_str(), |
| 459 &OnRequestNetworkProperties, | 466 &OnRequestNetworkProperties, |
| 460 new OnRequestNetworkPropertiesCallback(callback)); | 467 new OnRequestNetworkPropertiesCallback(callback)); |
| 461 } | 468 } |
| 462 | 469 |
| 463 void CrosRequestVirtualNetworkProperties( | 470 void CrosRequestVirtualNetworkProperties( |
| 464 const char* service_name, | 471 const std::string& service_name, |
| 465 const char* server_hostname, | 472 const std::string& server_hostname, |
| 466 const char* provider_type, | 473 const std::string& provider_type, |
| 467 const NetworkPropertiesCallback& callback) { | 474 const NetworkPropertiesCallback& callback) { |
| 468 // The newly allocated callback will be deleted in OnRequestNetworkProperties. | 475 // The newly allocated callback will be deleted in OnRequestNetworkProperties. |
| 469 chromeos::RequestVirtualNetworkProperties( | 476 chromeos::RequestVirtualNetworkProperties( |
| 470 service_name, | 477 service_name.c_str(), |
| 471 server_hostname, | 478 server_hostname.c_str(), |
| 472 provider_type, | 479 provider_type.c_str(), |
| 473 &OnRequestNetworkProperties, | 480 &OnRequestNetworkProperties, |
| 474 new OnRequestNetworkPropertiesCallback(callback)); | 481 new OnRequestNetworkPropertiesCallback(callback)); |
| 475 } | 482 } |
| 476 | 483 |
| 477 void CrosRequestNetworkServiceDisconnect(const char* service_path) { | 484 void CrosRequestNetworkServiceDisconnect(const std::string& service_path) { |
| 478 if (g_libcros_network_functions_enabled) { | 485 if (g_libcros_network_functions_enabled) { |
| 479 chromeos::RequestNetworkServiceDisconnect(service_path); | 486 chromeos::RequestNetworkServiceDisconnect(service_path.c_str()); |
| 480 } else { | 487 } else { |
| 481 DBusThreadManager::Get()->GetFlimflamServiceClient()->Disconnect( | 488 DBusThreadManager::Get()->GetFlimflamServiceClient()->Disconnect( |
| 482 dbus::ObjectPath(service_path), base::Bind(&DoNothing)); | 489 dbus::ObjectPath(service_path), base::Bind(&DoNothing)); |
| 483 } | 490 } |
| 484 } | 491 } |
| 485 | 492 |
| 486 void CrosRequestRemoveNetworkService(const char* service_path) { | 493 void CrosRequestRemoveNetworkService(const std::string& service_path) { |
| 487 if (g_libcros_network_functions_enabled) { | 494 if (g_libcros_network_functions_enabled) { |
| 488 chromeos::RequestRemoveNetworkService(service_path); | 495 chromeos::RequestRemoveNetworkService(service_path.c_str()); |
| 489 } else { | 496 } else { |
| 490 DBusThreadManager::Get()->GetFlimflamServiceClient()->Remove( | 497 DBusThreadManager::Get()->GetFlimflamServiceClient()->Remove( |
| 491 dbus::ObjectPath(service_path), base::Bind(&DoNothing)); | 498 dbus::ObjectPath(service_path), base::Bind(&DoNothing)); |
| 492 } | 499 } |
| 493 } | 500 } |
| 494 | 501 |
| 495 void CrosRequestNetworkScan(const char* network_type) { | 502 void CrosRequestNetworkScan(const std::string& network_type) { |
| 496 if (g_libcros_network_functions_enabled) { | 503 if (g_libcros_network_functions_enabled) { |
| 497 chromeos::RequestNetworkScan(network_type); | 504 chromeos::RequestNetworkScan(network_type.c_str()); |
| 498 } else { | 505 } else { |
| 499 DBusThreadManager::Get()->GetFlimflamManagerClient()->RequestScan( | 506 DBusThreadManager::Get()->GetFlimflamManagerClient()->RequestScan( |
| 500 network_type, base::Bind(&DoNothing)); | 507 network_type, base::Bind(&DoNothing)); |
| 501 } | 508 } |
| 502 } | 509 } |
| 503 | 510 |
| 504 void CrosRequestNetworkDeviceEnable(const char* network_type, bool enable) { | 511 void CrosRequestNetworkDeviceEnable(const std::string& network_type, |
| 512 bool enable) { |
| 505 if (g_libcros_network_functions_enabled) { | 513 if (g_libcros_network_functions_enabled) { |
| 506 chromeos::RequestNetworkDeviceEnable(network_type, enable); | 514 chromeos::RequestNetworkDeviceEnable(network_type.c_str(), enable); |
| 507 } else { | 515 } else { |
| 508 if (enable) { | 516 if (enable) { |
| 509 DBusThreadManager::Get()->GetFlimflamManagerClient()->EnableTechnology( | 517 DBusThreadManager::Get()->GetFlimflamManagerClient()->EnableTechnology( |
| 510 network_type, base::Bind(&DoNothing)); | 518 network_type, base::Bind(&DoNothing)); |
| 511 } else { | 519 } else { |
| 512 DBusThreadManager::Get()->GetFlimflamManagerClient()->DisableTechnology( | 520 DBusThreadManager::Get()->GetFlimflamManagerClient()->DisableTechnology( |
| 513 network_type, base::Bind(&DoNothing)); | 521 network_type, base::Bind(&DoNothing)); |
| 514 } | 522 } |
| 515 } | 523 } |
| 516 } | 524 } |
| 517 | 525 |
| 518 void CrosRequestRequirePin(const char* device_path, | 526 void CrosRequestRequirePin(const std::string& device_path, |
| 519 const char* pin, | 527 const std::string& pin, |
| 520 bool enable, | 528 bool enable, |
| 521 NetworkActionCallback callback, | 529 NetworkActionCallback callback, |
| 522 void* object) { | 530 void* object) { |
| 523 chromeos::RequestRequirePin(device_path, pin, enable, callback, object); | 531 chromeos::RequestRequirePin(device_path.c_str(), pin.c_str(), enable, |
| 532 callback, object); |
| 524 } | 533 } |
| 525 | 534 |
| 526 void CrosRequestEnterPin(const char* device_path, | 535 void CrosRequestEnterPin(const std::string& device_path, |
| 527 const char* pin, | 536 const std::string& pin, |
| 528 NetworkActionCallback callback, | 537 NetworkActionCallback callback, |
| 529 void* object) { | 538 void* object) { |
| 530 chromeos::RequestEnterPin(device_path, pin, callback, object); | 539 chromeos::RequestEnterPin(device_path.c_str(), pin.c_str(), callback, object); |
| 531 } | 540 } |
| 532 | 541 |
| 533 void CrosRequestUnblockPin(const char* device_path, | 542 void CrosRequestUnblockPin(const std::string& device_path, |
| 534 const char* unblock_code, | 543 const std::string& unblock_code, |
| 535 const char* pin, | 544 const std::string& pin, |
| 536 NetworkActionCallback callback, | 545 NetworkActionCallback callback, |
| 537 void* object) { | 546 void* object) { |
| 538 chromeos::RequestUnblockPin(device_path, unblock_code, pin, callback, object); | 547 chromeos::RequestUnblockPin(device_path.c_str(), unblock_code.c_str(), |
| 548 pin.c_str(), callback, object); |
| 539 } | 549 } |
| 540 | 550 |
| 541 void CrosRequestChangePin(const char* device_path, | 551 void CrosRequestChangePin(const std::string& device_path, |
| 542 const char* old_pin, | 552 const std::string& old_pin, |
| 543 const char* new_pin, | 553 const std::string& new_pin, |
| 544 NetworkActionCallback callback, | 554 NetworkActionCallback callback, |
| 545 void* object) { | 555 void* object) { |
| 546 chromeos::RequestChangePin(device_path, old_pin, new_pin, callback, object); | 556 chromeos::RequestChangePin(device_path.c_str(), old_pin.c_str(), |
| 557 new_pin.c_str(), callback, object); |
| 547 } | 558 } |
| 548 | 559 |
| 549 void CrosProposeScan(const char* device_path) { | 560 void CrosProposeScan(const std::string& device_path) { |
| 550 chromeos::ProposeScan(device_path); | 561 chromeos::ProposeScan(device_path.c_str()); |
| 551 } | 562 } |
| 552 | 563 |
| 553 void CrosRequestCellularRegister(const char* device_path, | 564 void CrosRequestCellularRegister(const std::string& device_path, |
| 554 const char* network_id, | 565 const std::string& network_id, |
| 555 chromeos::NetworkActionCallback callback, | 566 chromeos::NetworkActionCallback callback, |
| 556 void* object) { | 567 void* object) { |
| 557 chromeos::RequestCellularRegister(device_path, network_id, callback, object); | 568 chromeos::RequestCellularRegister(device_path.c_str(), network_id.c_str(), |
| 569 callback, object); |
| 558 } | 570 } |
| 559 | 571 |
| 560 bool CrosSetOfflineMode(bool offline) { | 572 bool CrosSetOfflineMode(bool offline) { |
| 561 return chromeos::SetOfflineMode(offline); | 573 return chromeos::SetOfflineMode(offline); |
| 562 } | 574 } |
| 563 | 575 |
| 564 IPConfigStatus* CrosListIPConfigs(const char* device_path) { | 576 IPConfigStatus* CrosListIPConfigs(const std::string& device_path) { |
| 565 return chromeos::ListIPConfigs(device_path); | 577 return chromeos::ListIPConfigs(device_path.c_str()); |
| 566 } | 578 } |
| 567 | 579 |
| 568 bool CrosAddIPConfig(const char* device_path, IPConfigType type) { | 580 bool CrosAddIPConfig(const std::string& device_path, IPConfigType type) { |
| 569 return chromeos::AddIPConfig(device_path, type); | 581 return chromeos::AddIPConfig(device_path.c_str(), type); |
| 570 } | 582 } |
| 571 | 583 |
| 572 bool CrosRemoveIPConfig(IPConfig* config) { | 584 bool CrosRemoveIPConfig(IPConfig* config) { |
| 573 if (g_libcros_network_functions_enabled) { | 585 if (g_libcros_network_functions_enabled) { |
| 574 return chromeos::RemoveIPConfig(config); | 586 return chromeos::RemoveIPConfig(config); |
| 575 } else { | 587 } else { |
| 576 return DBusThreadManager::Get()->GetFlimflamIPConfigClient()-> | 588 return DBusThreadManager::Get()->GetFlimflamIPConfigClient()-> |
| 577 CallRemoveAndBlock(dbus::ObjectPath(config->path)); | 589 CallRemoveAndBlock(dbus::ObjectPath(config->path)); |
| 578 } | 590 } |
| 579 } | 591 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 595 ScopedGHashTable ghash( | 607 ScopedGHashTable ghash( |
| 596 ConvertDictionaryValueToStringValueGHashTable(properties)); | 608 ConvertDictionaryValueToStringValueGHashTable(properties)); |
| 597 chromeos::ConfigureService("", ghash.get(), OnConfigureService, NULL); | 609 chromeos::ConfigureService("", ghash.get(), OnConfigureService, NULL); |
| 598 } else { | 610 } else { |
| 599 DBusThreadManager::Get()->GetFlimflamManagerClient()->ConfigureService( | 611 DBusThreadManager::Get()->GetFlimflamManagerClient()->ConfigureService( |
| 600 properties, base::Bind(&DoNothing)); | 612 properties, base::Bind(&DoNothing)); |
| 601 } | 613 } |
| 602 } | 614 } |
| 603 | 615 |
| 604 } // namespace chromeos | 616 } // namespace chromeos |
| OLD | NEW |