| 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 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 359 observers_.RemoveObserver(observer); | 359 observers_.RemoveObserver(observer); |
| 360 } | 360 } |
| 361 | 361 |
| 362 void NetworkSmsHandler::NotifyMessageReceived( | 362 void NetworkSmsHandler::NotifyMessageReceived( |
| 363 const base::DictionaryValue& message) { | 363 const base::DictionaryValue& message) { |
| 364 FOR_EACH_OBSERVER(Observer, observers_, MessageReceived(message)); | 364 FOR_EACH_OBSERVER(Observer, observers_, MessageReceived(message)); |
| 365 } | 365 } |
| 366 | 366 |
| 367 void NetworkSmsHandler::ManagerPropertiesCallback( | 367 void NetworkSmsHandler::ManagerPropertiesCallback( |
| 368 DBusMethodCallStatus call_status, | 368 DBusMethodCallStatus call_status, |
| 369 const base::DictionaryValue& properties) { | 369 scoped_ptr<base::DictionaryValue> properties) { |
| 370 if (call_status != DBUS_METHOD_CALL_SUCCESS) { | 370 if (call_status != DBUS_METHOD_CALL_SUCCESS) { |
| 371 LOG(ERROR) << "NetworkSmsHandler: Failed to get manager properties."; | 371 LOG(ERROR) << "NetworkSmsHandler: Failed to get manager properties."; |
| 372 return; | 372 return; |
| 373 } | 373 } |
| 374 const base::Value* value; | 374 const base::Value* value; |
| 375 if (!properties.GetWithoutPathExpansion(flimflam::kDevicesProperty, &value) || | 375 if (!properties->GetWithoutPathExpansion( |
| 376 flimflam::kDevicesProperty, &value) || |
| 376 value->GetType() != base::Value::TYPE_LIST) { | 377 value->GetType() != base::Value::TYPE_LIST) { |
| 377 LOG(ERROR) << "NetworkSmsHandler: No list value for: " | 378 LOG(ERROR) << "NetworkSmsHandler: No list value for: " |
| 378 << flimflam::kDevicesProperty; | 379 << flimflam::kDevicesProperty; |
| 379 return; | 380 return; |
| 380 } | 381 } |
| 381 const base::ListValue* devices = static_cast<const base::ListValue*>(value); | 382 const base::ListValue* devices = static_cast<const base::ListValue*>(value); |
| 382 for (base::ListValue::const_iterator iter = devices->begin(); | 383 for (base::ListValue::const_iterator iter = devices->begin(); |
| 383 iter != devices->end(); ++iter) { | 384 iter != devices->end(); ++iter) { |
| 384 std::string device_path; | 385 std::string device_path; |
| 385 (*iter)->GetAsString(&device_path); | 386 (*iter)->GetAsString(&device_path); |
| 386 if (!device_path.empty()) { | 387 if (!device_path.empty()) { |
| 387 // Request device properties. | 388 // Request device properties. |
| 388 VLOG(1) << "GetDeviceProperties: " << device_path; | 389 VLOG(1) << "GetDeviceProperties: " << device_path; |
| 389 DBusThreadManager::Get()->GetShillDeviceClient()->GetProperties( | 390 DBusThreadManager::Get()->GetShillDeviceClient()->GetProperties( |
| 390 dbus::ObjectPath(device_path), | 391 dbus::ObjectPath(device_path), |
| 391 base::Bind(&NetworkSmsHandler::DevicePropertiesCallback, | 392 base::Bind(&NetworkSmsHandler::DevicePropertiesCallback, |
| 392 weak_ptr_factory_.GetWeakPtr(), | 393 weak_ptr_factory_.GetWeakPtr(), |
| 393 device_path)); | 394 device_path)); |
| 394 } | 395 } |
| 395 } | 396 } |
| 396 } | 397 } |
| 397 | 398 |
| 398 void NetworkSmsHandler::DevicePropertiesCallback( | 399 void NetworkSmsHandler::DevicePropertiesCallback( |
| 399 const std::string& device_path, | 400 const std::string& device_path, |
| 400 DBusMethodCallStatus call_status, | 401 DBusMethodCallStatus call_status, |
| 401 const base::DictionaryValue& properties) { | 402 scoped_ptr<base::DictionaryValue> properties) { |
| 402 if (call_status != DBUS_METHOD_CALL_SUCCESS) { | 403 if (call_status != DBUS_METHOD_CALL_SUCCESS) { |
| 403 LOG(ERROR) << "NetworkSmsHandler: ERROR: " << call_status | 404 LOG(ERROR) << "NetworkSmsHandler: ERROR: " << call_status |
| 404 << " For: " << device_path; | 405 << " For: " << device_path; |
| 405 return; | 406 return; |
| 406 } | 407 } |
| 407 | 408 |
| 408 std::string device_type; | 409 std::string device_type; |
| 409 if (!properties.GetStringWithoutPathExpansion( | 410 if (!properties->GetStringWithoutPathExpansion( |
| 410 flimflam::kTypeProperty, &device_type)) { | 411 flimflam::kTypeProperty, &device_type)) { |
| 411 LOG(ERROR) << "NetworkSmsHandler: No type for: " << device_path; | 412 LOG(ERROR) << "NetworkSmsHandler: No type for: " << device_path; |
| 412 return; | 413 return; |
| 413 } | 414 } |
| 414 if (device_type != flimflam::kTypeCellular) | 415 if (device_type != flimflam::kTypeCellular) |
| 415 return; | 416 return; |
| 416 | 417 |
| 417 std::string dbus_connection; | 418 std::string dbus_connection; |
| 418 if (!properties.GetStringWithoutPathExpansion( | 419 if (!properties->GetStringWithoutPathExpansion( |
| 419 flimflam::kDBusConnectionProperty, &dbus_connection)) { | 420 flimflam::kDBusConnectionProperty, &dbus_connection)) { |
| 420 LOG(ERROR) << "Device has no DBusConnection Property: " << device_path; | 421 LOG(ERROR) << "Device has no DBusConnection Property: " << device_path; |
| 421 return; | 422 return; |
| 422 } | 423 } |
| 423 | 424 |
| 424 std::string object_path_string; | 425 std::string object_path_string; |
| 425 if (!properties.GetStringWithoutPathExpansion( | 426 if (!properties->GetStringWithoutPathExpansion( |
| 426 flimflam::kDBusObjectProperty, &object_path_string)) { | 427 flimflam::kDBusObjectProperty, &object_path_string)) { |
| 427 LOG(ERROR) << "Device has no DBusObject Property: " << device_path; | 428 LOG(ERROR) << "Device has no DBusObject Property: " << device_path; |
| 428 return; | 429 return; |
| 429 } | 430 } |
| 430 dbus::ObjectPath object_path(object_path_string); | 431 dbus::ObjectPath object_path(object_path_string); |
| 431 if (object_path_string.compare( | 432 if (object_path_string.compare( |
| 432 0, sizeof(modemmanager::kModemManager1ServicePath) - 1, | 433 0, sizeof(modemmanager::kModemManager1ServicePath) - 1, |
| 433 modemmanager::kModemManager1ServicePath) == 0) { | 434 modemmanager::kModemManager1ServicePath) == 0) { |
| 434 device_handlers_.push_back( | 435 device_handlers_.push_back( |
| 435 new ModemManager1NetworkSmsDeviceHandler( | 436 new ModemManager1NetworkSmsDeviceHandler( |
| 436 this, dbus_connection, object_path)); | 437 this, dbus_connection, object_path)); |
| 437 } else { | 438 } else { |
| 438 device_handlers_.push_back( | 439 device_handlers_.push_back( |
| 439 new ModemManagerNetworkSmsDeviceHandler( | 440 new ModemManagerNetworkSmsDeviceHandler( |
| 440 this, dbus_connection, object_path)); | 441 this, dbus_connection, object_path)); |
| 441 } | 442 } |
| 442 } | 443 } |
| 443 | 444 |
| 444 | 445 |
| 445 } // namespace chromeos | 446 } // namespace chromeos |
| OLD | NEW |