Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(194)

Side by Side Diff: chrome/browser/chromeos/cros/cros_network_functions.cc

Issue 10915106: Renaming instances of "flimflam" with "shill", now that we're only (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Upload after merge Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/string_tokenizer.h" 9 #include "base/string_tokenizer.h"
10 #include "base/stringprintf.h" 10 #include "base/stringprintf.h"
11 #include "base/values.h" 11 #include "base/values.h"
12 #include "chrome/browser/chromeos/cros/sms_watcher.h" 12 #include "chrome/browser/chromeos/cros/sms_watcher.h"
13 #include "chromeos/dbus/cashew_client.h" 13 #include "chromeos/dbus/cashew_client.h"
14 #include "chromeos/dbus/dbus_thread_manager.h" 14 #include "chromeos/dbus/dbus_thread_manager.h"
15 #include "chromeos/dbus/flimflam_device_client.h" 15 #include "chromeos/dbus/shill_device_client.h"
16 #include "chromeos/dbus/flimflam_ipconfig_client.h" 16 #include "chromeos/dbus/shill_ipconfig_client.h"
17 #include "chromeos/dbus/flimflam_manager_client.h" 17 #include "chromeos/dbus/shill_manager_client.h"
18 #include "chromeos/dbus/flimflam_network_client.h" 18 #include "chromeos/dbus/shill_network_client.h"
19 #include "chromeos/dbus/flimflam_profile_client.h" 19 #include "chromeos/dbus/shill_profile_client.h"
20 #include "chromeos/dbus/flimflam_service_client.h" 20 #include "chromeos/dbus/shill_service_client.h"
21 #include "dbus/object_path.h" 21 #include "dbus/object_path.h"
22 #include "third_party/cros_system_api/dbus/service_constants.h" 22 #include "third_party/cros_system_api/dbus/service_constants.h"
23 23
24 namespace chromeos { 24 namespace chromeos {
25 25
26 namespace { 26 namespace {
27 27
28 // Class to watch network manager's properties without Libcros. 28 // Class to watch network manager's properties without Libcros.
29 class NetworkManagerPropertiesWatcher : public CrosNetworkWatcher { 29 class NetworkManagerPropertiesWatcher : public CrosNetworkWatcher {
30 public: 30 public:
31 NetworkManagerPropertiesWatcher( 31 NetworkManagerPropertiesWatcher(
32 const NetworkPropertiesWatcherCallback& callback) { 32 const NetworkPropertiesWatcherCallback& callback) {
33 DBusThreadManager::Get()->GetFlimflamManagerClient()-> 33 DBusThreadManager::Get()->GetShillManagerClient()->
34 SetPropertyChangedHandler(base::Bind(callback, 34 SetPropertyChangedHandler(base::Bind(callback,
35 flimflam::kFlimflamServicePath)); 35 flimflam::kFlimflamServicePath));
36 } 36 }
37 virtual ~NetworkManagerPropertiesWatcher() { 37 virtual ~NetworkManagerPropertiesWatcher() {
38 DBusThreadManager::Get()->GetFlimflamManagerClient()-> 38 DBusThreadManager::Get()->GetShillManagerClient()->
39 ResetPropertyChangedHandler(); 39 ResetPropertyChangedHandler();
40 } 40 }
41 }; 41 };
42 42
43 // Class to watch network service's properties without Libcros. 43 // Class to watch network service's properties without Libcros.
44 class NetworkServicePropertiesWatcher : public CrosNetworkWatcher { 44 class NetworkServicePropertiesWatcher : public CrosNetworkWatcher {
45 public: 45 public:
46 NetworkServicePropertiesWatcher( 46 NetworkServicePropertiesWatcher(
47 const NetworkPropertiesWatcherCallback& callback, 47 const NetworkPropertiesWatcherCallback& callback,
48 const std::string& service_path) : service_path_(service_path) { 48 const std::string& service_path) : service_path_(service_path) {
49 DBusThreadManager::Get()->GetFlimflamServiceClient()-> 49 DBusThreadManager::Get()->GetShillServiceClient()->
50 SetPropertyChangedHandler(dbus::ObjectPath(service_path), 50 SetPropertyChangedHandler(dbus::ObjectPath(service_path),
51 base::Bind(callback, service_path)); 51 base::Bind(callback, service_path));
52 } 52 }
53 virtual ~NetworkServicePropertiesWatcher() { 53 virtual ~NetworkServicePropertiesWatcher() {
54 DBusThreadManager::Get()->GetFlimflamServiceClient()-> 54 DBusThreadManager::Get()->GetShillServiceClient()->
55 ResetPropertyChangedHandler(dbus::ObjectPath(service_path_)); 55 ResetPropertyChangedHandler(dbus::ObjectPath(service_path_));
56 } 56 }
57 57
58 private: 58 private:
59 std::string service_path_; 59 std::string service_path_;
60 }; 60 };
61 61
62 // Class to watch network device's properties without Libcros. 62 // Class to watch network device's properties without Libcros.
63 class NetworkDevicePropertiesWatcher : public CrosNetworkWatcher { 63 class NetworkDevicePropertiesWatcher : public CrosNetworkWatcher {
64 public: 64 public:
65 NetworkDevicePropertiesWatcher( 65 NetworkDevicePropertiesWatcher(
66 const NetworkPropertiesWatcherCallback& callback, 66 const NetworkPropertiesWatcherCallback& callback,
67 const std::string& device_path) : device_path_(device_path) { 67 const std::string& device_path) : device_path_(device_path) {
68 DBusThreadManager::Get()->GetFlimflamDeviceClient()-> 68 DBusThreadManager::Get()->GetShillDeviceClient()->
69 SetPropertyChangedHandler(dbus::ObjectPath(device_path), 69 SetPropertyChangedHandler(dbus::ObjectPath(device_path),
70 base::Bind(callback, device_path)); 70 base::Bind(callback, device_path));
71 } 71 }
72 virtual ~NetworkDevicePropertiesWatcher() { 72 virtual ~NetworkDevicePropertiesWatcher() {
73 DBusThreadManager::Get()->GetFlimflamDeviceClient()-> 73 DBusThreadManager::Get()->GetShillDeviceClient()->
74 ResetPropertyChangedHandler(dbus::ObjectPath(device_path_)); 74 ResetPropertyChangedHandler(dbus::ObjectPath(device_path_));
75 } 75 }
76 76
77 private: 77 private:
78 std::string device_path_; 78 std::string device_path_;
79 }; 79 };
80 80
81 // Converts a string to a CellularDataPlanType. 81 // Converts a string to a CellularDataPlanType.
82 CellularDataPlanType ParseCellularDataPlanType(const std::string& type) { 82 CellularDataPlanType ParseCellularDataPlanType(const std::string& type) {
83 if (type == cashew::kCellularDataPlanUnlimited) 83 if (type == cashew::kCellularDataPlanUnlimited)
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 void DoNothing(DBusMethodCallStatus call_status) {} 183 void DoNothing(DBusMethodCallStatus call_status) {}
184 184
185 // A callback used to implement CrosRequest*Properties functions. 185 // A callback used to implement CrosRequest*Properties functions.
186 void RunCallbackWithDictionaryValue(const NetworkPropertiesCallback& callback, 186 void RunCallbackWithDictionaryValue(const NetworkPropertiesCallback& callback,
187 const std::string& path, 187 const std::string& path,
188 DBusMethodCallStatus call_status, 188 DBusMethodCallStatus call_status,
189 const base::DictionaryValue& value) { 189 const base::DictionaryValue& value) {
190 callback.Run(path, call_status == DBUS_METHOD_CALL_SUCCESS ? &value : NULL); 190 callback.Run(path, call_status == DBUS_METHOD_CALL_SUCCESS ? &value : NULL);
191 } 191 }
192 192
193 // Used as a callback for FlimflamManagerClient::GetService 193 // Used as a callback for ShillManagerClient::GetService
194 void OnGetService(const NetworkPropertiesCallback& callback, 194 void OnGetService(const NetworkPropertiesCallback& callback,
195 DBusMethodCallStatus call_status, 195 DBusMethodCallStatus call_status,
196 const dbus::ObjectPath& service_path) { 196 const dbus::ObjectPath& service_path) {
197 if (call_status == DBUS_METHOD_CALL_SUCCESS) { 197 if (call_status == DBUS_METHOD_CALL_SUCCESS) {
198 VLOG(1) << "OnGetServiceService: " << service_path.value(); 198 VLOG(1) << "OnGetServiceService: " << service_path.value();
199 DBusThreadManager::Get()->GetFlimflamServiceClient()->GetProperties( 199 DBusThreadManager::Get()->GetShillServiceClient()->GetProperties(
200 service_path, base::Bind(&RunCallbackWithDictionaryValue, 200 service_path, base::Bind(&RunCallbackWithDictionaryValue,
201 callback, 201 callback,
202 service_path.value())); 202 service_path.value()));
203 } 203 }
204 } 204 }
205 205
206 // A callback used to call a NetworkOperationCallback on error. 206 // A callback used to call a NetworkOperationCallback on error.
207 void OnNetworkActionError(const NetworkOperationCallback& callback, 207 void OnNetworkActionError(const NetworkOperationCallback& callback,
208 const std::string& path, 208 const std::string& path,
209 const std::string& error_name, 209 const std::string& error_name,
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 return result; 248 return result;
249 } 249 }
250 250
251 // Gets NetworkIPConfigVector populated with data from a 251 // Gets NetworkIPConfigVector populated with data from a
252 // given DBus object path. 252 // given DBus object path.
253 // 253 //
254 // returns true on success. 254 // returns true on success.
255 bool ParseIPConfig(const std::string& device_path, 255 bool ParseIPConfig(const std::string& device_path,
256 const std::string& ipconfig_path, 256 const std::string& ipconfig_path,
257 NetworkIPConfigVector* ipconfig_vector) { 257 NetworkIPConfigVector* ipconfig_vector) {
258 FlimflamIPConfigClient* ipconfig_client = 258 ShillIPConfigClient* ipconfig_client =
259 DBusThreadManager::Get()->GetFlimflamIPConfigClient(); 259 DBusThreadManager::Get()->GetShillIPConfigClient();
260 // TODO(hashimoto): Remove this blocking D-Bus method call. crosbug.com/29902 260 // TODO(hashimoto): Remove this blocking D-Bus method call. crosbug.com/29902
261 scoped_ptr<base::DictionaryValue> properties( 261 scoped_ptr<base::DictionaryValue> properties(
262 ipconfig_client->CallGetPropertiesAndBlock( 262 ipconfig_client->CallGetPropertiesAndBlock(
263 dbus::ObjectPath(ipconfig_path))); 263 dbus::ObjectPath(ipconfig_path)));
264 if (!properties.get()) 264 if (!properties.get())
265 return false; 265 return false;
266 266
267 std::string type_string; 267 std::string type_string;
268 properties->GetStringWithoutPathExpansion(flimflam::kMethodProperty, 268 properties->GetStringWithoutPathExpansion(flimflam::kMethodProperty,
269 &type_string); 269 &type_string);
(...skipping 29 matching lines...) Expand all
299 299
300 SMS::SMS() 300 SMS::SMS()
301 : validity(0), 301 : validity(0),
302 msgclass(0) { 302 msgclass(0) {
303 } 303 }
304 304
305 SMS::~SMS() {} 305 SMS::~SMS() {}
306 306
307 bool CrosActivateCellularModem(const std::string& service_path, 307 bool CrosActivateCellularModem(const std::string& service_path,
308 const std::string& carrier) { 308 const std::string& carrier) {
309 return DBusThreadManager::Get()->GetFlimflamServiceClient()-> 309 return DBusThreadManager::Get()->GetShillServiceClient()->
310 CallActivateCellularModemAndBlock(dbus::ObjectPath(service_path), 310 CallActivateCellularModemAndBlock(dbus::ObjectPath(service_path),
311 carrier); 311 carrier);
312 } 312 }
313 313
314 void CrosSetNetworkServiceProperty(const std::string& service_path, 314 void CrosSetNetworkServiceProperty(const std::string& service_path,
315 const std::string& property, 315 const std::string& property,
316 const base::Value& value) { 316 const base::Value& value) {
317 DBusThreadManager::Get()->GetFlimflamServiceClient()->SetProperty( 317 DBusThreadManager::Get()->GetShillServiceClient()->SetProperty(
318 dbus::ObjectPath(service_path), property, value, 318 dbus::ObjectPath(service_path), property, value,
319 base::Bind(&DoNothing)); 319 base::Bind(&DoNothing));
320 } 320 }
321 321
322 void CrosClearNetworkServiceProperty(const std::string& service_path, 322 void CrosClearNetworkServiceProperty(const std::string& service_path,
323 const std::string& property) { 323 const std::string& property) {
324 DBusThreadManager::Get()->GetFlimflamServiceClient()->ClearProperty( 324 DBusThreadManager::Get()->GetShillServiceClient()->ClearProperty(
325 dbus::ObjectPath(service_path), property, base::Bind(&DoNothing)); 325 dbus::ObjectPath(service_path), property, base::Bind(&DoNothing));
326 } 326 }
327 327
328 void CrosSetNetworkDeviceProperty(const std::string& device_path, 328 void CrosSetNetworkDeviceProperty(const std::string& device_path,
329 const std::string& property, 329 const std::string& property,
330 const base::Value& value) { 330 const base::Value& value) {
331 DBusThreadManager::Get()->GetFlimflamDeviceClient()->SetProperty( 331 DBusThreadManager::Get()->GetShillDeviceClient()->SetProperty(
332 dbus::ObjectPath(device_path), property, value, base::Bind(&DoNothing)); 332 dbus::ObjectPath(device_path), property, value, base::Bind(&DoNothing));
333 } 333 }
334 334
335 void CrosSetNetworkIPConfigProperty(const std::string& ipconfig_path, 335 void CrosSetNetworkIPConfigProperty(const std::string& ipconfig_path,
336 const std::string& property, 336 const std::string& property,
337 const base::Value& value) { 337 const base::Value& value) {
338 DBusThreadManager::Get()->GetFlimflamIPConfigClient()->SetProperty( 338 DBusThreadManager::Get()->GetShillIPConfigClient()->SetProperty(
339 dbus::ObjectPath(ipconfig_path), property, value, 339 dbus::ObjectPath(ipconfig_path), property, value,
340 base::Bind(&DoNothing)); 340 base::Bind(&DoNothing));
341 } 341 }
342 342
343 void CrosSetNetworkManagerProperty(const std::string& property, 343 void CrosSetNetworkManagerProperty(const std::string& property,
344 const base::Value& value) { 344 const base::Value& value) {
345 DBusThreadManager::Get()->GetFlimflamManagerClient()->SetProperty( 345 DBusThreadManager::Get()->GetShillManagerClient()->SetProperty(
346 property, value, base::Bind(&DoNothing)); 346 property, value, base::Bind(&DoNothing));
347 } 347 }
348 348
349 void CrosDeleteServiceFromProfile(const std::string& profile_path, 349 void CrosDeleteServiceFromProfile(const std::string& profile_path,
350 const std::string& service_path) { 350 const std::string& service_path) {
351 DBusThreadManager::Get()->GetFlimflamProfileClient()->DeleteEntry( 351 DBusThreadManager::Get()->GetShillProfileClient()->DeleteEntry(
352 dbus::ObjectPath(profile_path), service_path, base::Bind(&DoNothing)); 352 dbus::ObjectPath(profile_path), service_path, base::Bind(&DoNothing));
353 } 353 }
354 354
355 void CrosRequestCellularDataPlanUpdate(const std::string& modem_service_path) { 355 void CrosRequestCellularDataPlanUpdate(const std::string& modem_service_path) {
356 DBusThreadManager::Get()->GetCashewClient()->RequestDataPlansUpdate( 356 DBusThreadManager::Get()->GetCashewClient()->RequestDataPlansUpdate(
357 modem_service_path); 357 modem_service_path);
358 } 358 }
359 359
360 CrosNetworkWatcher* CrosMonitorNetworkManagerProperties( 360 CrosNetworkWatcher* CrosMonitorNetworkManagerProperties(
361 const NetworkPropertiesWatcherCallback& callback) { 361 const NetworkPropertiesWatcherCallback& callback) {
(...skipping 18 matching lines...) Expand all
380 } 380 }
381 381
382 CrosNetworkWatcher* CrosMonitorSMS(const std::string& modem_device_path, 382 CrosNetworkWatcher* CrosMonitorSMS(const std::string& modem_device_path,
383 MonitorSMSCallback callback) { 383 MonitorSMSCallback callback) {
384 return new SMSWatcher(modem_device_path, callback); 384 return new SMSWatcher(modem_device_path, callback);
385 } 385 }
386 386
387 void CrosRequestNetworkServiceConnect( 387 void CrosRequestNetworkServiceConnect(
388 const std::string& service_path, 388 const std::string& service_path,
389 const NetworkOperationCallback& callback) { 389 const NetworkOperationCallback& callback) {
390 DBusThreadManager::Get()->GetFlimflamServiceClient()->Connect( 390 DBusThreadManager::Get()->GetShillServiceClient()->Connect(
391 dbus::ObjectPath(service_path), 391 dbus::ObjectPath(service_path),
392 base::Bind(callback, service_path, NETWORK_METHOD_ERROR_NONE, 392 base::Bind(callback, service_path, NETWORK_METHOD_ERROR_NONE,
393 std::string()), 393 std::string()),
394 base::Bind(&OnNetworkActionError, callback, service_path)); 394 base::Bind(&OnNetworkActionError, callback, service_path));
395 } 395 }
396 396
397 void CrosRequestNetworkManagerProperties( 397 void CrosRequestNetworkManagerProperties(
398 const NetworkPropertiesCallback& callback) { 398 const NetworkPropertiesCallback& callback) {
399 DBusThreadManager::Get()->GetFlimflamManagerClient()->GetProperties( 399 DBusThreadManager::Get()->GetShillManagerClient()->GetProperties(
400 base::Bind(&RunCallbackWithDictionaryValue, 400 base::Bind(&RunCallbackWithDictionaryValue,
401 callback, 401 callback,
402 flimflam::kFlimflamServicePath)); 402 flimflam::kFlimflamServicePath));
403 } 403 }
404 404
405 void CrosRequestNetworkServiceProperties( 405 void CrosRequestNetworkServiceProperties(
406 const std::string& service_path, 406 const std::string& service_path,
407 const NetworkPropertiesCallback& callback) { 407 const NetworkPropertiesCallback& callback) {
408 DBusThreadManager::Get()->GetFlimflamServiceClient()->GetProperties( 408 DBusThreadManager::Get()->GetShillServiceClient()->GetProperties(
409 dbus::ObjectPath(service_path), 409 dbus::ObjectPath(service_path),
410 base::Bind(&RunCallbackWithDictionaryValue, callback, service_path)); 410 base::Bind(&RunCallbackWithDictionaryValue, callback, service_path));
411 } 411 }
412 412
413 void CrosRequestNetworkDeviceProperties( 413 void CrosRequestNetworkDeviceProperties(
414 const std::string& device_path, 414 const std::string& device_path,
415 const NetworkPropertiesCallback& callback) { 415 const NetworkPropertiesCallback& callback) {
416 DBusThreadManager::Get()->GetFlimflamDeviceClient()->GetProperties( 416 DBusThreadManager::Get()->GetShillDeviceClient()->GetProperties(
417 dbus::ObjectPath(device_path), 417 dbus::ObjectPath(device_path),
418 base::Bind(&RunCallbackWithDictionaryValue, callback, device_path)); 418 base::Bind(&RunCallbackWithDictionaryValue, callback, device_path));
419 } 419 }
420 420
421 void CrosRequestNetworkProfileProperties( 421 void CrosRequestNetworkProfileProperties(
422 const std::string& profile_path, 422 const std::string& profile_path,
423 const NetworkPropertiesCallback& callback) { 423 const NetworkPropertiesCallback& callback) {
424 DBusThreadManager::Get()->GetFlimflamProfileClient()->GetProperties( 424 DBusThreadManager::Get()->GetShillProfileClient()->GetProperties(
425 dbus::ObjectPath(profile_path), 425 dbus::ObjectPath(profile_path),
426 base::Bind(&RunCallbackWithDictionaryValue, callback, profile_path)); 426 base::Bind(&RunCallbackWithDictionaryValue, callback, profile_path));
427 } 427 }
428 428
429 void CrosRequestNetworkProfileEntryProperties( 429 void CrosRequestNetworkProfileEntryProperties(
430 const std::string& profile_path, 430 const std::string& profile_path,
431 const std::string& profile_entry_path, 431 const std::string& profile_entry_path,
432 const NetworkPropertiesCallback& callback) { 432 const NetworkPropertiesCallback& callback) {
433 DBusThreadManager::Get()->GetFlimflamProfileClient()->GetEntry( 433 DBusThreadManager::Get()->GetShillProfileClient()->GetEntry(
434 dbus::ObjectPath(profile_path), 434 dbus::ObjectPath(profile_path),
435 profile_entry_path, 435 profile_entry_path,
436 base::Bind(&RunCallbackWithDictionaryValue, 436 base::Bind(&RunCallbackWithDictionaryValue,
437 callback, 437 callback,
438 profile_entry_path)); 438 profile_entry_path));
439 } 439 }
440 440
441 void CrosRequestHiddenWifiNetworkProperties( 441 void CrosRequestHiddenWifiNetworkProperties(
442 const std::string& ssid, 442 const std::string& ssid,
443 const std::string& security, 443 const std::string& security,
444 const NetworkPropertiesCallback& callback) { 444 const NetworkPropertiesCallback& callback) {
445 base::DictionaryValue properties; 445 base::DictionaryValue properties;
446 properties.SetWithoutPathExpansion( 446 properties.SetWithoutPathExpansion(
447 flimflam::kModeProperty, 447 flimflam::kModeProperty,
448 base::Value::CreateStringValue(flimflam::kModeManaged)); 448 base::Value::CreateStringValue(flimflam::kModeManaged));
449 properties.SetWithoutPathExpansion( 449 properties.SetWithoutPathExpansion(
450 flimflam::kTypeProperty, 450 flimflam::kTypeProperty,
451 base::Value::CreateStringValue(flimflam::kTypeWifi)); 451 base::Value::CreateStringValue(flimflam::kTypeWifi));
452 properties.SetWithoutPathExpansion( 452 properties.SetWithoutPathExpansion(
453 flimflam::kSSIDProperty, 453 flimflam::kSSIDProperty,
454 base::Value::CreateStringValue(ssid)); 454 base::Value::CreateStringValue(ssid));
455 properties.SetWithoutPathExpansion( 455 properties.SetWithoutPathExpansion(
456 flimflam::kSecurityProperty, 456 flimflam::kSecurityProperty,
457 base::Value::CreateStringValue(security)); 457 base::Value::CreateStringValue(security));
458 // flimflam.Manger.GetService() will apply the property changes in 458 // shill.Manger.GetService() will apply the property changes in
459 // |properties| and return a new or existing service to OnGetService(). 459 // |properties| and return a new or existing service to OnGetService().
460 // OnGetService will then call GetProperties which will then call callback. 460 // OnGetService will then call GetProperties which will then call callback.
461 DBusThreadManager::Get()->GetFlimflamManagerClient()->GetService( 461 DBusThreadManager::Get()->GetShillManagerClient()->GetService(
462 properties, base::Bind(&OnGetService, callback)); 462 properties, base::Bind(&OnGetService, callback));
463 } 463 }
464 464
465 void CrosRequestVirtualNetworkProperties( 465 void CrosRequestVirtualNetworkProperties(
466 const std::string& service_name, 466 const std::string& service_name,
467 const std::string& server_hostname, 467 const std::string& server_hostname,
468 const std::string& provider_type, 468 const std::string& provider_type,
469 const NetworkPropertiesCallback& callback) { 469 const NetworkPropertiesCallback& callback) {
470 base::DictionaryValue properties; 470 base::DictionaryValue properties;
471 properties.SetWithoutPathExpansion( 471 properties.SetWithoutPathExpansion(
472 flimflam::kTypeProperty, 472 flimflam::kTypeProperty,
473 base::Value::CreateStringValue(flimflam::kTypeVPN)); 473 base::Value::CreateStringValue(flimflam::kTypeVPN));
474 properties.SetWithoutPathExpansion( 474 properties.SetWithoutPathExpansion(
475 flimflam::kProviderNameProperty, 475 flimflam::kProviderNameProperty,
476 base::Value::CreateStringValue(service_name)); 476 base::Value::CreateStringValue(service_name));
477 properties.SetWithoutPathExpansion( 477 properties.SetWithoutPathExpansion(
478 flimflam::kProviderHostProperty, 478 flimflam::kProviderHostProperty,
479 base::Value::CreateStringValue(server_hostname)); 479 base::Value::CreateStringValue(server_hostname));
480 properties.SetWithoutPathExpansion( 480 properties.SetWithoutPathExpansion(
481 flimflam::kProviderTypeProperty, 481 flimflam::kProviderTypeProperty,
482 base::Value::CreateStringValue(provider_type)); 482 base::Value::CreateStringValue(provider_type));
483 // The actual value of Domain does not matter, so just use service_name. 483 // The actual value of Domain does not matter, so just use service_name.
484 properties.SetWithoutPathExpansion( 484 properties.SetWithoutPathExpansion(
485 flimflam::kVPNDomainProperty, 485 flimflam::kVPNDomainProperty,
486 base::Value::CreateStringValue(service_name)); 486 base::Value::CreateStringValue(service_name));
487 487
488 // flimflam.Manger.GetService() will apply the property changes in 488 // shill.Manger.GetService() will apply the property changes in
489 // |properties| and pass a new or existing service to OnGetService(). 489 // |properties| and pass a new or existing service to OnGetService().
490 // OnGetService will then call GetProperties which will then call callback. 490 // OnGetService will then call GetProperties which will then call callback.
491 DBusThreadManager::Get()->GetFlimflamManagerClient()->GetService( 491 DBusThreadManager::Get()->GetShillManagerClient()->GetService(
492 properties, base::Bind(&OnGetService, callback)); 492 properties, base::Bind(&OnGetService, callback));
493 } 493 }
494 494
495 void CrosRequestNetworkServiceDisconnect(const std::string& service_path) { 495 void CrosRequestNetworkServiceDisconnect(const std::string& service_path) {
496 DBusThreadManager::Get()->GetFlimflamServiceClient()->Disconnect( 496 DBusThreadManager::Get()->GetShillServiceClient()->Disconnect(
497 dbus::ObjectPath(service_path), base::Bind(&DoNothing)); 497 dbus::ObjectPath(service_path), base::Bind(&DoNothing));
498 } 498 }
499 499
500 void CrosRequestRemoveNetworkService(const std::string& service_path) { 500 void CrosRequestRemoveNetworkService(const std::string& service_path) {
501 DBusThreadManager::Get()->GetFlimflamServiceClient()->Remove( 501 DBusThreadManager::Get()->GetShillServiceClient()->Remove(
502 dbus::ObjectPath(service_path), base::Bind(&DoNothing)); 502 dbus::ObjectPath(service_path), base::Bind(&DoNothing));
503 } 503 }
504 504
505 void CrosRequestNetworkScan(const std::string& network_type) { 505 void CrosRequestNetworkScan(const std::string& network_type) {
506 DBusThreadManager::Get()->GetFlimflamManagerClient()->RequestScan( 506 DBusThreadManager::Get()->GetShillManagerClient()->RequestScan(
507 network_type, base::Bind(&DoNothing)); 507 network_type, base::Bind(&DoNothing));
508 } 508 }
509 509
510 void CrosRequestNetworkDeviceEnable(const std::string& network_type, 510 void CrosRequestNetworkDeviceEnable(const std::string& network_type,
511 bool enable) { 511 bool enable) {
512 if (enable) { 512 if (enable) {
513 DBusThreadManager::Get()->GetFlimflamManagerClient()->EnableTechnology( 513 DBusThreadManager::Get()->GetShillManagerClient()->EnableTechnology(
514 network_type, base::Bind(&DoNothing)); 514 network_type, base::Bind(&DoNothing));
515 } else { 515 } else {
516 DBusThreadManager::Get()->GetFlimflamManagerClient()->DisableTechnology( 516 DBusThreadManager::Get()->GetShillManagerClient()->DisableTechnology(
517 network_type, base::Bind(&DoNothing)); 517 network_type, base::Bind(&DoNothing));
518 } 518 }
519 } 519 }
520 520
521 void CrosRequestRequirePin(const std::string& device_path, 521 void CrosRequestRequirePin(const std::string& device_path,
522 const std::string& pin, 522 const std::string& pin,
523 bool enable, 523 bool enable,
524 const NetworkOperationCallback& callback) { 524 const NetworkOperationCallback& callback) {
525 DBusThreadManager::Get()->GetFlimflamDeviceClient()->RequirePin( 525 DBusThreadManager::Get()->GetShillDeviceClient()->RequirePin(
526 dbus::ObjectPath(device_path), pin, enable, 526 dbus::ObjectPath(device_path), pin, enable,
527 base::Bind(callback, device_path, NETWORK_METHOD_ERROR_NONE, 527 base::Bind(callback, device_path, NETWORK_METHOD_ERROR_NONE,
528 std::string()), 528 std::string()),
529 base::Bind(&OnNetworkActionError, callback, device_path)); 529 base::Bind(&OnNetworkActionError, callback, device_path));
530 } 530 }
531 531
532 void CrosRequestEnterPin(const std::string& device_path, 532 void CrosRequestEnterPin(const std::string& device_path,
533 const std::string& pin, 533 const std::string& pin,
534 const NetworkOperationCallback& callback) { 534 const NetworkOperationCallback& callback) {
535 DBusThreadManager::Get()->GetFlimflamDeviceClient()->EnterPin( 535 DBusThreadManager::Get()->GetShillDeviceClient()->EnterPin(
536 dbus::ObjectPath(device_path), pin, 536 dbus::ObjectPath(device_path), pin,
537 base::Bind(callback, device_path, NETWORK_METHOD_ERROR_NONE, 537 base::Bind(callback, device_path, NETWORK_METHOD_ERROR_NONE,
538 std::string()), 538 std::string()),
539 base::Bind(&OnNetworkActionError, callback, device_path)); 539 base::Bind(&OnNetworkActionError, callback, device_path));
540 } 540 }
541 541
542 void CrosRequestUnblockPin(const std::string& device_path, 542 void CrosRequestUnblockPin(const std::string& device_path,
543 const std::string& unblock_code, 543 const std::string& unblock_code,
544 const std::string& pin, 544 const std::string& pin,
545 const NetworkOperationCallback& callback) { 545 const NetworkOperationCallback& callback) {
546 DBusThreadManager::Get()->GetFlimflamDeviceClient()->UnblockPin( 546 DBusThreadManager::Get()->GetShillDeviceClient()->UnblockPin(
547 dbus::ObjectPath(device_path), unblock_code, pin, 547 dbus::ObjectPath(device_path), unblock_code, pin,
548 base::Bind(callback, device_path, NETWORK_METHOD_ERROR_NONE, 548 base::Bind(callback, device_path, NETWORK_METHOD_ERROR_NONE,
549 std::string()), 549 std::string()),
550 base::Bind(&OnNetworkActionError, callback, device_path)); 550 base::Bind(&OnNetworkActionError, callback, device_path));
551 } 551 }
552 552
553 void CrosRequestChangePin(const std::string& device_path, 553 void CrosRequestChangePin(const std::string& device_path,
554 const std::string& old_pin, 554 const std::string& old_pin,
555 const std::string& new_pin, 555 const std::string& new_pin,
556 const NetworkOperationCallback& callback) { 556 const NetworkOperationCallback& callback) {
557 DBusThreadManager::Get()->GetFlimflamDeviceClient()->ChangePin( 557 DBusThreadManager::Get()->GetShillDeviceClient()->ChangePin(
558 dbus::ObjectPath(device_path), old_pin, new_pin, 558 dbus::ObjectPath(device_path), old_pin, new_pin,
559 base::Bind(callback, device_path, NETWORK_METHOD_ERROR_NONE, 559 base::Bind(callback, device_path, NETWORK_METHOD_ERROR_NONE,
560 std::string()), 560 std::string()),
561 base::Bind(&OnNetworkActionError, callback, device_path)); 561 base::Bind(&OnNetworkActionError, callback, device_path));
562 } 562 }
563 563
564 void CrosProposeScan(const std::string& device_path) { 564 void CrosProposeScan(const std::string& device_path) {
565 DBusThreadManager::Get()->GetFlimflamDeviceClient()->ProposeScan( 565 DBusThreadManager::Get()->GetShillDeviceClient()->ProposeScan(
566 dbus::ObjectPath(device_path), base::Bind(&DoNothing)); 566 dbus::ObjectPath(device_path), base::Bind(&DoNothing));
567 } 567 }
568 568
569 void CrosRequestCellularRegister(const std::string& device_path, 569 void CrosRequestCellularRegister(const std::string& device_path,
570 const std::string& network_id, 570 const std::string& network_id,
571 const NetworkOperationCallback& callback) { 571 const NetworkOperationCallback& callback) {
572 DBusThreadManager::Get()->GetFlimflamDeviceClient()->Register( 572 DBusThreadManager::Get()->GetShillDeviceClient()->Register(
573 dbus::ObjectPath(device_path), network_id, 573 dbus::ObjectPath(device_path), network_id,
574 base::Bind(callback, device_path, NETWORK_METHOD_ERROR_NONE, 574 base::Bind(callback, device_path, NETWORK_METHOD_ERROR_NONE,
575 std::string()), 575 std::string()),
576 base::Bind(&OnNetworkActionError, callback, device_path)); 576 base::Bind(&OnNetworkActionError, callback, device_path));
577 } 577 }
578 578
579 bool CrosSetOfflineMode(bool offline) { 579 bool CrosSetOfflineMode(bool offline) {
580 base::FundamentalValue value(offline); 580 base::FundamentalValue value(offline);
581 DBusThreadManager::Get()->GetFlimflamManagerClient()->SetProperty( 581 DBusThreadManager::Get()->GetShillManagerClient()->SetProperty(
582 flimflam::kOfflineModeProperty, value, base::Bind(&DoNothing)); 582 flimflam::kOfflineModeProperty, value, base::Bind(&DoNothing));
583 return true; 583 return true;
584 } 584 }
585 585
586 bool CrosListIPConfigs(const std::string& device_path, 586 bool CrosListIPConfigs(const std::string& device_path,
587 NetworkIPConfigVector* ipconfig_vector, 587 NetworkIPConfigVector* ipconfig_vector,
588 std::vector<std::string>* ipconfig_paths, 588 std::vector<std::string>* ipconfig_paths,
589 std::string* hardware_address) { 589 std::string* hardware_address) {
590 if (hardware_address) 590 if (hardware_address)
591 hardware_address->clear(); 591 hardware_address->clear();
592 const dbus::ObjectPath device_object_path(device_path); 592 const dbus::ObjectPath device_object_path(device_path);
593 FlimflamDeviceClient* device_client = 593 ShillDeviceClient* device_client =
594 DBusThreadManager::Get()->GetFlimflamDeviceClient(); 594 DBusThreadManager::Get()->GetShillDeviceClient();
595 // TODO(hashimoto): Remove this blocking D-Bus method call. 595 // TODO(hashimoto): Remove this blocking D-Bus method call.
596 // crosbug.com/29902 596 // crosbug.com/29902
597 scoped_ptr<base::DictionaryValue> properties( 597 scoped_ptr<base::DictionaryValue> properties(
598 device_client->CallGetPropertiesAndBlock(device_object_path)); 598 device_client->CallGetPropertiesAndBlock(device_object_path));
599 if (!properties.get()) 599 if (!properties.get())
600 return false; 600 return false;
601 601
602 ListValue* ips = NULL; 602 ListValue* ips = NULL;
603 if (!properties->GetListWithoutPathExpansion( 603 if (!properties->GetListWithoutPathExpansion(
604 flimflam::kIPConfigsProperty, &ips)) 604 flimflam::kIPConfigsProperty, &ips))
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
642 case IPCONFIG_TYPE_DHCP6: 642 case IPCONFIG_TYPE_DHCP6:
643 type_str = flimflam::kTypeDHCP6; 643 type_str = flimflam::kTypeDHCP6;
644 break; 644 break;
645 case IPCONFIG_TYPE_PPP: 645 case IPCONFIG_TYPE_PPP:
646 type_str = flimflam::kTypePPP; 646 type_str = flimflam::kTypePPP;
647 break; 647 break;
648 default: 648 default:
649 return false; 649 return false;
650 }; 650 };
651 const dbus::ObjectPath result = 651 const dbus::ObjectPath result =
652 DBusThreadManager::Get()->GetFlimflamDeviceClient()-> 652 DBusThreadManager::Get()->GetShillDeviceClient()->
653 CallAddIPConfigAndBlock(dbus::ObjectPath(device_path), type_str); 653 CallAddIPConfigAndBlock(dbus::ObjectPath(device_path), type_str);
654 if (result.value().empty()) { 654 if (result.value().empty()) {
655 LOG(ERROR) << "Add IPConfig failed for device path " << device_path 655 LOG(ERROR) << "Add IPConfig failed for device path " << device_path
656 << " and type " << type_str; 656 << " and type " << type_str;
657 return false; 657 return false;
658 } 658 }
659 return true; 659 return true;
660 } 660 }
661 661
662 bool CrosRemoveIPConfig(const std::string& ipconfig_path) { 662 bool CrosRemoveIPConfig(const std::string& ipconfig_path) {
663 return DBusThreadManager::Get()->GetFlimflamIPConfigClient()-> 663 return DBusThreadManager::Get()->GetShillIPConfigClient()->
664 CallRemoveAndBlock(dbus::ObjectPath(ipconfig_path)); 664 CallRemoveAndBlock(dbus::ObjectPath(ipconfig_path));
665 } 665 }
666 666
667 void CrosRequestIPConfigRefresh(const std::string& ipconfig_path) { 667 void CrosRequestIPConfigRefresh(const std::string& ipconfig_path) {
668 DBusThreadManager::Get()->GetFlimflamIPConfigClient()->Refresh( 668 DBusThreadManager::Get()->GetShillIPConfigClient()->Refresh(
669 dbus::ObjectPath(ipconfig_path), 669 dbus::ObjectPath(ipconfig_path),
670 base::Bind(&DoNothing)); 670 base::Bind(&DoNothing));
671 } 671 }
672 672
673 bool CrosGetWifiAccessPoints(WifiAccessPointVector* result) { 673 bool CrosGetWifiAccessPoints(WifiAccessPointVector* result) {
674 scoped_ptr<base::DictionaryValue> manager_properties( 674 scoped_ptr<base::DictionaryValue> manager_properties(
675 DBusThreadManager::Get()->GetFlimflamManagerClient()-> 675 DBusThreadManager::Get()->GetShillManagerClient()->
676 CallGetPropertiesAndBlock()); 676 CallGetPropertiesAndBlock());
677 if (!manager_properties.get()) { 677 if (!manager_properties.get()) {
678 LOG(WARNING) << "Couldn't read managers's properties"; 678 LOG(WARNING) << "Couldn't read managers's properties";
679 return false; 679 return false;
680 } 680 }
681 681
682 base::ListValue* devices = NULL; 682 base::ListValue* devices = NULL;
683 if (!manager_properties->GetListWithoutPathExpansion( 683 if (!manager_properties->GetListWithoutPathExpansion(
684 flimflam::kDevicesProperty, &devices)) { 684 flimflam::kDevicesProperty, &devices)) {
685 LOG(WARNING) << flimflam::kDevicesProperty << " property not found"; 685 LOG(WARNING) << flimflam::kDevicesProperty << " property not found";
686 return false; 686 return false;
687 } 687 }
688 const base::Time now = base::Time::Now(); 688 const base::Time now = base::Time::Now();
689 bool found_at_least_one_device = false; 689 bool found_at_least_one_device = false;
690 result->clear(); 690 result->clear();
691 for (size_t i = 0; i < devices->GetSize(); i++) { 691 for (size_t i = 0; i < devices->GetSize(); i++) {
692 std::string device_path; 692 std::string device_path;
693 if (!devices->GetString(i, &device_path)) { 693 if (!devices->GetString(i, &device_path)) {
694 LOG(WARNING) << "Couldn't get devices[" << i << "]"; 694 LOG(WARNING) << "Couldn't get devices[" << i << "]";
695 continue; 695 continue;
696 } 696 }
697 scoped_ptr<base::DictionaryValue> device_properties( 697 scoped_ptr<base::DictionaryValue> device_properties(
698 DBusThreadManager::Get()->GetFlimflamDeviceClient()-> 698 DBusThreadManager::Get()->GetShillDeviceClient()->
699 CallGetPropertiesAndBlock(dbus::ObjectPath(device_path))); 699 CallGetPropertiesAndBlock(dbus::ObjectPath(device_path)));
700 if (!device_properties.get()) { 700 if (!device_properties.get()) {
701 LOG(WARNING) << "Couldn't read device's properties " << device_path; 701 LOG(WARNING) << "Couldn't read device's properties " << device_path;
702 continue; 702 continue;
703 } 703 }
704 704
705 base::ListValue* networks = NULL; 705 base::ListValue* networks = NULL;
706 if (!device_properties->GetListWithoutPathExpansion( 706 if (!device_properties->GetListWithoutPathExpansion(
707 flimflam::kNetworksProperty, &networks)) 707 flimflam::kNetworksProperty, &networks))
708 continue; // Some devices do not list networks, e.g. ethernet. 708 continue; // Some devices do not list networks, e.g. ethernet.
(...skipping 12 matching lines...) Expand all
721 721
722 found_at_least_one_device = true; 722 found_at_least_one_device = true;
723 for (size_t j = 0; j < networks->GetSize(); j++) { 723 for (size_t j = 0; j < networks->GetSize(); j++) {
724 std::string network_path; 724 std::string network_path;
725 if (!networks->GetString(j, &network_path)) { 725 if (!networks->GetString(j, &network_path)) {
726 LOG(WARNING) << "Couldn't get networks[" << j << "]"; 726 LOG(WARNING) << "Couldn't get networks[" << j << "]";
727 continue; 727 continue;
728 } 728 }
729 729
730 scoped_ptr<base::DictionaryValue> network_properties( 730 scoped_ptr<base::DictionaryValue> network_properties(
731 DBusThreadManager::Get()->GetFlimflamNetworkClient()-> 731 DBusThreadManager::Get()->GetShillNetworkClient()->
732 CallGetPropertiesAndBlock(dbus::ObjectPath(network_path))); 732 CallGetPropertiesAndBlock(dbus::ObjectPath(network_path)));
733 if (!network_properties.get()) { 733 if (!network_properties.get()) {
734 LOG(WARNING) << "Couldn't read network's properties " << network_path; 734 LOG(WARNING) << "Couldn't read network's properties " << network_path;
735 continue; 735 continue;
736 } 736 }
737 737
738 // Using the scan interval as a proxy for approximate age. 738 // Using the scan interval as a proxy for approximate age.
739 // TODO(joth): Replace with actual age, when available from dbus. 739 // TODO(joth): Replace with actual age, when available from dbus.
740 const int age_seconds = scan_interval; 740 const int age_seconds = scan_interval;
741 WifiAccessPoint ap; 741 WifiAccessPoint ap;
742 network_properties->GetStringWithoutPathExpansion( 742 network_properties->GetStringWithoutPathExpansion(
743 flimflam::kAddressProperty, &ap.mac_address); 743 flimflam::kAddressProperty, &ap.mac_address);
744 network_properties->GetStringWithoutPathExpansion( 744 network_properties->GetStringWithoutPathExpansion(
745 flimflam::kNameProperty, &ap.name); 745 flimflam::kNameProperty, &ap.name);
746 ap.timestamp = now - base::TimeDelta::FromSeconds(age_seconds); 746 ap.timestamp = now - base::TimeDelta::FromSeconds(age_seconds);
747 network_properties->GetIntegerWithoutPathExpansion( 747 network_properties->GetIntegerWithoutPathExpansion(
748 flimflam::kSignalStrengthProperty, &ap.signal_strength); 748 flimflam::kSignalStrengthProperty, &ap.signal_strength);
749 network_properties->GetIntegerWithoutPathExpansion( 749 network_properties->GetIntegerWithoutPathExpansion(
750 flimflam::kWifiChannelProperty, &ap.channel); 750 flimflam::kWifiChannelProperty, &ap.channel);
751 result->push_back(ap); 751 result->push_back(ap);
752 } 752 }
753 } 753 }
754 if (!found_at_least_one_device) 754 if (!found_at_least_one_device)
755 return false; // No powered device found that has a 'Networks' array. 755 return false; // No powered device found that has a 'Networks' array.
756 return true; 756 return true;
757 } 757 }
758 758
759 void CrosConfigureService(const base::DictionaryValue& properties) { 759 void CrosConfigureService(const base::DictionaryValue& properties) {
760 DBusThreadManager::Get()->GetFlimflamManagerClient()->ConfigureService( 760 DBusThreadManager::Get()->GetShillManagerClient()->ConfigureService(
761 properties, base::Bind(&DoNothing)); 761 properties, base::Bind(&DoNothing));
762 } 762 }
763 763
764 std::string CrosPrefixLengthToNetmask(int32 prefix_length) { 764 std::string CrosPrefixLengthToNetmask(int32 prefix_length) {
765 std::string netmask; 765 std::string netmask;
766 // Return the empty string for invalid inputs. 766 // Return the empty string for invalid inputs.
767 if (prefix_length < 0 || prefix_length > 32) 767 if (prefix_length < 0 || prefix_length > 32)
768 return netmask; 768 return netmask;
769 for (int i = 0; i < 4; i++) { 769 for (int i = 0; i < 4; i++) {
770 int remainder = 8; 770 int remainder = 8;
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
821 return -1; 821 return -1;
822 } 822 }
823 count++; 823 count++;
824 } 824 }
825 if (count < 4) 825 if (count < 4)
826 return -1; 826 return -1;
827 return prefix_length; 827 return prefix_length;
828 } 828 }
829 829
830 } // namespace chromeos 830 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/cros/cros_network_functions.h ('k') | chrome/browser/chromeos/cros/cros_network_functions_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698