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_state.h" | 5 #include "chromeos/network/network_state.h" |
6 | 6 |
7 #include "base/i18n/icu_encoding_detection.h" | 7 #include "base/i18n/icu_encoding_detection.h" |
8 #include "base/i18n/icu_string_conversions.h" | 8 #include "base/i18n/icu_string_conversions.h" |
9 #include "base/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 return GetStringValue(key, value, &connection_state_); | 110 return GetStringValue(key, value, &connection_state_); |
111 } else if (key == flimflam::kConnectableProperty) { | 111 } else if (key == flimflam::kConnectableProperty) { |
112 return GetBooleanValue(key, value, &connectable_); | 112 return GetBooleanValue(key, value, &connectable_); |
113 } else if (key == flimflam::kErrorProperty) { | 113 } else if (key == flimflam::kErrorProperty) { |
114 if (!GetStringValue(key, value, &error_)) | 114 if (!GetStringValue(key, value, &error_)) |
115 return false; | 115 return false; |
116 // Shill uses "Unknown" to indicate an unset error state. | 116 // Shill uses "Unknown" to indicate an unset error state. |
117 if (error_ == kErrorUnknown) | 117 if (error_ == kErrorUnknown) |
118 error_.clear(); | 118 error_.clear(); |
119 return true; | 119 return true; |
120 } else if (key == shill::kErrorDetailsProperty) { | |
121 return GetStringValue(key, value, &error_details_); | |
122 } else if (key == IPConfigProperty(flimflam::kAddressProperty)) { | 120 } else if (key == IPConfigProperty(flimflam::kAddressProperty)) { |
123 return GetStringValue(key, value, &ip_address_); | 121 return GetStringValue(key, value, &ip_address_); |
124 } else if (key == IPConfigProperty(flimflam::kGatewayProperty)) { | 122 } else if (key == IPConfigProperty(flimflam::kGatewayProperty)) { |
125 return GetStringValue(key, value, &gateway_); | 123 return GetStringValue(key, value, &gateway_); |
126 } else if (key == IPConfigProperty(flimflam::kNameServersProperty)) { | 124 } else if (key == IPConfigProperty(flimflam::kNameServersProperty)) { |
127 const base::ListValue* dns_servers; | 125 const base::ListValue* dns_servers; |
128 if (!value.GetAsList(&dns_servers)) | 126 if (!value.GetAsList(&dns_servers)) |
129 return false; | 127 return false; |
130 dns_servers_.clear(); | 128 dns_servers_.clear(); |
131 ConvertListValueToStringVector(*dns_servers, &dns_servers_); | 129 ConvertListValueToStringVector(*dns_servers, &dns_servers_); |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 dictionary->SetStringWithoutPathExpansion(flimflam::kTypeProperty, type()); | 236 dictionary->SetStringWithoutPathExpansion(flimflam::kTypeProperty, type()); |
239 dictionary->SetIntegerWithoutPathExpansion(flimflam::kSignalStrengthProperty, | 237 dictionary->SetIntegerWithoutPathExpansion(flimflam::kSignalStrengthProperty, |
240 signal_strength_); | 238 signal_strength_); |
241 dictionary->SetStringWithoutPathExpansion(flimflam::kStateProperty, | 239 dictionary->SetStringWithoutPathExpansion(flimflam::kStateProperty, |
242 connection_state_); | 240 connection_state_); |
243 dictionary->SetBooleanWithoutPathExpansion(flimflam::kConnectableProperty, | 241 dictionary->SetBooleanWithoutPathExpansion(flimflam::kConnectableProperty, |
244 connectable_); | 242 connectable_); |
245 | 243 |
246 dictionary->SetStringWithoutPathExpansion(flimflam::kErrorProperty, | 244 dictionary->SetStringWithoutPathExpansion(flimflam::kErrorProperty, |
247 error_); | 245 error_); |
248 dictionary->SetStringWithoutPathExpansion(shill::kErrorDetailsProperty, | |
249 error_details_); | |
250 | 246 |
251 // IPConfig properties | 247 // IPConfig properties |
252 base::DictionaryValue* ipconfig_properties = new base::DictionaryValue; | 248 base::DictionaryValue* ipconfig_properties = new base::DictionaryValue; |
253 ipconfig_properties->SetStringWithoutPathExpansion(flimflam::kAddressProperty, | 249 ipconfig_properties->SetStringWithoutPathExpansion(flimflam::kAddressProperty, |
254 ip_address_); | 250 ip_address_); |
255 ipconfig_properties->SetStringWithoutPathExpansion(flimflam::kGatewayProperty, | 251 ipconfig_properties->SetStringWithoutPathExpansion(flimflam::kGatewayProperty, |
256 gateway_); | 252 gateway_); |
257 base::ListValue* name_servers = new base::ListValue; | 253 base::ListValue* name_servers = new base::ListValue; |
258 name_servers->AppendStrings(dns_servers_); | 254 name_servers->AppendStrings(dns_servers_); |
259 ipconfig_properties->SetWithoutPathExpansion(flimflam::kNameServersProperty, | 255 ipconfig_properties->SetWithoutPathExpansion(flimflam::kNameServersProperty, |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
348 set_name(updated_name); | 344 set_name(updated_name); |
349 return true; | 345 return true; |
350 } | 346 } |
351 return false; | 347 return false; |
352 } | 348 } |
353 | 349 |
354 // static | 350 // static |
355 std::string NetworkState::GetNameFromProperties( | 351 std::string NetworkState::GetNameFromProperties( |
356 const std::string& service_path, | 352 const std::string& service_path, |
357 const base::DictionaryValue& properties) { | 353 const base::DictionaryValue& properties) { |
358 std::string name; | 354 std::string name, hex_ssid; |
359 properties.GetStringWithoutPathExpansion(flimflam::kNameProperty, &name); | 355 properties.GetStringWithoutPathExpansion(flimflam::kNameProperty, &name); |
360 | |
361 std::string hex_ssid; | |
362 properties.GetStringWithoutPathExpansion(flimflam::kWifiHexSsid, &hex_ssid); | 356 properties.GetStringWithoutPathExpansion(flimflam::kWifiHexSsid, &hex_ssid); |
363 | 357 |
364 if (hex_ssid.empty()) { | 358 if (hex_ssid.empty()) { |
| 359 if (name.empty()) |
| 360 return name; |
365 // Validate name for UTF8. | 361 // Validate name for UTF8. |
366 std::string valid_ssid = ValidateUTF8(name); | 362 std::string valid_ssid = ValidateUTF8(name); |
367 if (valid_ssid != name) { | 363 if (valid_ssid != name) { |
368 NET_LOG_DEBUG("GetNameFromProperties", base::StringPrintf( | 364 NET_LOG_DEBUG("GetNameFromProperties", base::StringPrintf( |
369 "%s: UTF8: %s", service_path.c_str(), valid_ssid.c_str())); | 365 "%s: UTF8: %s", service_path.c_str(), valid_ssid.c_str())); |
370 } | 366 } |
371 return valid_ssid; | 367 return valid_ssid; |
372 } | 368 } |
373 | 369 |
374 std::string ssid; | 370 std::string ssid; |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
456 } | 452 } |
457 scoped_ptr<base::DictionaryValue> ui_data_dict( | 453 scoped_ptr<base::DictionaryValue> ui_data_dict( |
458 chromeos::onc::ReadDictionaryFromJson(ui_data_str)); | 454 chromeos::onc::ReadDictionaryFromJson(ui_data_str)); |
459 if (!ui_data_dict) | 455 if (!ui_data_dict) |
460 return false; | 456 return false; |
461 *out = NetworkUIData(*ui_data_dict); | 457 *out = NetworkUIData(*ui_data_dict); |
462 return true; | 458 return true; |
463 } | 459 } |
464 | 460 |
465 } // namespace chromeos | 461 } // namespace chromeos |
OLD | NEW |