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 "chromeos/network/network_sms_handler.h" | 5 #include "chromeos/network/network_sms_handler.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <deque> | 8 #include <deque> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
371 void NetworkSmsHandler::AddObserver(Observer* observer) { | 371 void NetworkSmsHandler::AddObserver(Observer* observer) { |
372 observers_.AddObserver(observer); | 372 observers_.AddObserver(observer); |
373 } | 373 } |
374 | 374 |
375 void NetworkSmsHandler::RemoveObserver(Observer* observer) { | 375 void NetworkSmsHandler::RemoveObserver(Observer* observer) { |
376 observers_.RemoveObserver(observer); | 376 observers_.RemoveObserver(observer); |
377 } | 377 } |
378 | 378 |
379 void NetworkSmsHandler::OnPropertyChanged(const std::string& name, | 379 void NetworkSmsHandler::OnPropertyChanged(const std::string& name, |
380 const base::Value& value) { | 380 const base::Value& value) { |
381 if (name != flimflam::kDevicesProperty) | 381 if (name != shill::kDevicesProperty) |
382 return; | 382 return; |
383 const base::ListValue* devices = NULL; | 383 const base::ListValue* devices = NULL; |
384 if (!value.GetAsList(&devices) || !devices) | 384 if (!value.GetAsList(&devices) || !devices) |
385 return; | 385 return; |
386 UpdateDevices(devices); | 386 UpdateDevices(devices); |
387 } | 387 } |
388 | 388 |
389 // Private methods | 389 // Private methods |
390 | 390 |
391 void NetworkSmsHandler::AddReceivedMessage( | 391 void NetworkSmsHandler::AddReceivedMessage( |
(...skipping 15 matching lines...) Expand all Loading... |
407 } | 407 } |
408 | 408 |
409 void NetworkSmsHandler::ManagerPropertiesCallback( | 409 void NetworkSmsHandler::ManagerPropertiesCallback( |
410 DBusMethodCallStatus call_status, | 410 DBusMethodCallStatus call_status, |
411 const base::DictionaryValue& properties) { | 411 const base::DictionaryValue& properties) { |
412 if (call_status != DBUS_METHOD_CALL_SUCCESS) { | 412 if (call_status != DBUS_METHOD_CALL_SUCCESS) { |
413 LOG(ERROR) << "NetworkSmsHandler: Failed to get manager properties."; | 413 LOG(ERROR) << "NetworkSmsHandler: Failed to get manager properties."; |
414 return; | 414 return; |
415 } | 415 } |
416 const base::Value* value; | 416 const base::Value* value; |
417 if (!properties.GetWithoutPathExpansion(flimflam::kDevicesProperty, &value) || | 417 if (!properties.GetWithoutPathExpansion(shill::kDevicesProperty, &value) || |
418 value->GetType() != base::Value::TYPE_LIST) { | 418 value->GetType() != base::Value::TYPE_LIST) { |
419 LOG(ERROR) << "NetworkSmsHandler: No list value for: " | 419 LOG(ERROR) << "NetworkSmsHandler: No list value for: " |
420 << flimflam::kDevicesProperty; | 420 << shill::kDevicesProperty; |
421 return; | 421 return; |
422 } | 422 } |
423 const base::ListValue* devices = static_cast<const base::ListValue*>(value); | 423 const base::ListValue* devices = static_cast<const base::ListValue*>(value); |
424 UpdateDevices(devices); | 424 UpdateDevices(devices); |
425 } | 425 } |
426 | 426 |
427 void NetworkSmsHandler::UpdateDevices(const base::ListValue* devices) { | 427 void NetworkSmsHandler::UpdateDevices(const base::ListValue* devices) { |
428 for (base::ListValue::const_iterator iter = devices->begin(); | 428 for (base::ListValue::const_iterator iter = devices->begin(); |
429 iter != devices->end(); ++iter) { | 429 iter != devices->end(); ++iter) { |
430 std::string device_path; | 430 std::string device_path; |
(...skipping 15 matching lines...) Expand all Loading... |
446 DBusMethodCallStatus call_status, | 446 DBusMethodCallStatus call_status, |
447 const base::DictionaryValue& properties) { | 447 const base::DictionaryValue& properties) { |
448 if (call_status != DBUS_METHOD_CALL_SUCCESS) { | 448 if (call_status != DBUS_METHOD_CALL_SUCCESS) { |
449 LOG(ERROR) << "NetworkSmsHandler: ERROR: " << call_status | 449 LOG(ERROR) << "NetworkSmsHandler: ERROR: " << call_status |
450 << " For: " << device_path; | 450 << " For: " << device_path; |
451 return; | 451 return; |
452 } | 452 } |
453 | 453 |
454 std::string device_type; | 454 std::string device_type; |
455 if (!properties.GetStringWithoutPathExpansion( | 455 if (!properties.GetStringWithoutPathExpansion( |
456 flimflam::kTypeProperty, &device_type)) { | 456 shill::kTypeProperty, &device_type)) { |
457 LOG(ERROR) << "NetworkSmsHandler: No type for: " << device_path; | 457 LOG(ERROR) << "NetworkSmsHandler: No type for: " << device_path; |
458 return; | 458 return; |
459 } | 459 } |
460 if (device_type != flimflam::kTypeCellular) | 460 if (device_type != shill::kTypeCellular) |
461 return; | 461 return; |
462 | 462 |
463 std::string dbus_connection; | 463 std::string dbus_connection; |
464 if (!properties.GetStringWithoutPathExpansion( | 464 if (!properties.GetStringWithoutPathExpansion( |
465 flimflam::kDBusConnectionProperty, &dbus_connection)) { | 465 shill::kDBusConnectionProperty, &dbus_connection)) { |
466 LOG(ERROR) << "Device has no DBusConnection Property: " << device_path; | 466 LOG(ERROR) << "Device has no DBusConnection Property: " << device_path; |
467 return; | 467 return; |
468 } | 468 } |
469 | 469 |
470 std::string object_path_string; | 470 std::string object_path_string; |
471 if (!properties.GetStringWithoutPathExpansion( | 471 if (!properties.GetStringWithoutPathExpansion( |
472 flimflam::kDBusObjectProperty, &object_path_string)) { | 472 shill::kDBusObjectProperty, &object_path_string)) { |
473 LOG(ERROR) << "Device has no DBusObject Property: " << device_path; | 473 LOG(ERROR) << "Device has no DBusObject Property: " << device_path; |
474 return; | 474 return; |
475 } | 475 } |
476 dbus::ObjectPath object_path(object_path_string); | 476 dbus::ObjectPath object_path(object_path_string); |
477 if (object_path_string.compare( | 477 if (object_path_string.compare( |
478 0, sizeof(modemmanager::kModemManager1ServicePath) - 1, | 478 0, sizeof(modemmanager::kModemManager1ServicePath) - 1, |
479 modemmanager::kModemManager1ServicePath) == 0) { | 479 modemmanager::kModemManager1ServicePath) == 0) { |
480 device_handlers_.push_back( | 480 device_handlers_.push_back( |
481 new ModemManager1NetworkSmsDeviceHandler( | 481 new ModemManager1NetworkSmsDeviceHandler( |
482 this, dbus_connection, object_path)); | 482 this, dbus_connection, object_path)); |
483 } else { | 483 } else { |
484 device_handlers_.push_back( | 484 device_handlers_.push_back( |
485 new ModemManagerNetworkSmsDeviceHandler( | 485 new ModemManagerNetworkSmsDeviceHandler( |
486 this, dbus_connection, object_path)); | 486 this, dbus_connection, object_path)); |
487 } | 487 } |
488 } | 488 } |
489 | 489 |
490 | 490 |
491 } // namespace chromeos | 491 } // namespace chromeos |
OLD | NEW |