| 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/onc/onc_translator.h" | 5 #include "chromeos/network/onc/onc_translator.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 shill::kSecurityProperty, kWiFiSecurityTable, ::onc::wifi::kSecurity); | 308 shill::kSecurityProperty, kWiFiSecurityTable, ::onc::wifi::kSecurity); |
| 309 std::string ssid = shill_property_util::GetSSIDFromProperties( | 309 std::string ssid = shill_property_util::GetSSIDFromProperties( |
| 310 *shill_dictionary_, NULL /* ignore unknown encoding */); | 310 *shill_dictionary_, NULL /* ignore unknown encoding */); |
| 311 if (!ssid.empty()) | 311 if (!ssid.empty()) |
| 312 onc_object_->SetStringWithoutPathExpansion(::onc::wifi::kSSID, ssid); | 312 onc_object_->SetStringWithoutPathExpansion(::onc::wifi::kSSID, ssid); |
| 313 CopyPropertiesAccordingToSignature(); | 313 CopyPropertiesAccordingToSignature(); |
| 314 } | 314 } |
| 315 | 315 |
| 316 void ShillToONCTranslator::TranslateCellularWithState() { | 316 void ShillToONCTranslator::TranslateCellularWithState() { |
| 317 CopyPropertiesAccordingToSignature(); | 317 CopyPropertiesAccordingToSignature(); |
| 318 TranslateWithTableAndSet(shill::kActivationStateProperty, |
| 319 kActivationStateTable, |
| 320 ::onc::cellular::kActivationState); |
| 321 TranslateWithTableAndSet(shill::kRoamingStateProperty, |
| 322 kRoamingStateTable, |
| 323 ::onc::cellular::kRoamingState); |
| 318 const base::DictionaryValue* dictionary = NULL; | 324 const base::DictionaryValue* dictionary = NULL; |
| 319 if (shill_dictionary_->GetDictionaryWithoutPathExpansion( | 325 if (shill_dictionary_->GetDictionaryWithoutPathExpansion( |
| 320 shill::kServingOperatorProperty, &dictionary)) { | 326 shill::kServingOperatorProperty, &dictionary)) { |
| 321 TranslateAndAddNestedObject(::onc::cellular::kServingOperator, *dictionary); | 327 TranslateAndAddNestedObject(::onc::cellular::kServingOperator, *dictionary); |
| 322 } | 328 } |
| 323 if (shill_dictionary_->GetDictionaryWithoutPathExpansion( | 329 if (shill_dictionary_->GetDictionaryWithoutPathExpansion( |
| 324 shill::kCellularApnProperty, &dictionary)) { | 330 shill::kCellularApnProperty, &dictionary)) { |
| 325 TranslateAndAddNestedObject(::onc::cellular::kAPN, *dictionary); | 331 TranslateAndAddNestedObject(::onc::cellular::kAPN, *dictionary); |
| 326 } | 332 } |
| 327 if (shill_dictionary_->GetDictionaryWithoutPathExpansion( | 333 if (shill_dictionary_->GetDictionaryWithoutPathExpansion( |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 395 if (shill_dictionary_->GetStringWithoutPathExpansion(shill::kStateProperty, | 401 if (shill_dictionary_->GetStringWithoutPathExpansion(shill::kStateProperty, |
| 396 &state)) { | 402 &state)) { |
| 397 std::string onc_state = ::onc::connection_state::kNotConnected; | 403 std::string onc_state = ::onc::connection_state::kNotConnected; |
| 398 if (NetworkState::StateIsConnected(state)) { | 404 if (NetworkState::StateIsConnected(state)) { |
| 399 onc_state = ::onc::connection_state::kConnected; | 405 onc_state = ::onc::connection_state::kConnected; |
| 400 } else if (NetworkState::StateIsConnecting(state)) { | 406 } else if (NetworkState::StateIsConnecting(state)) { |
| 401 onc_state = ::onc::connection_state::kConnecting; | 407 onc_state = ::onc::connection_state::kConnecting; |
| 402 } | 408 } |
| 403 onc_object_->SetStringWithoutPathExpansion( | 409 onc_object_->SetStringWithoutPathExpansion( |
| 404 ::onc::network_config::kConnectionState, onc_state); | 410 ::onc::network_config::kConnectionState, onc_state); |
| 411 // Only set 'RestrictedConnectivity' if true. |
| 412 if (state == shill::kStatePortal) { |
| 413 onc_object_->SetBooleanWithoutPathExpansion( |
| 414 ::onc::network_config::kRestrictedConnectivity, true); |
| 415 } |
| 405 } | 416 } |
| 406 | 417 |
| 407 // Use a human-readable aa:bb format for any hardware MAC address. Note: | 418 // Use a human-readable aa:bb format for any hardware MAC address. Note: |
| 408 // this property is provided by the caller but is not part of the Shill | 419 // this property is provided by the caller but is not part of the Shill |
| 409 // Service properties (it is copied from the Device properties). | 420 // Service properties (it is copied from the Device properties). |
| 410 std::string address; | 421 std::string address; |
| 411 if (shill_dictionary_->GetStringWithoutPathExpansion(shill::kAddressProperty, | 422 if (shill_dictionary_->GetStringWithoutPathExpansion(shill::kAddressProperty, |
| 412 &address)) { | 423 &address)) { |
| 413 onc_object_->SetStringWithoutPathExpansion( | 424 onc_object_->SetStringWithoutPathExpansion( |
| 414 ::onc::network_config::kMacAddress, | 425 ::onc::network_config::kMacAddress, |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 621 const base::DictionaryValue& shill_dictionary, | 632 const base::DictionaryValue& shill_dictionary, |
| 622 const OncValueSignature* onc_signature) { | 633 const OncValueSignature* onc_signature) { |
| 623 CHECK(onc_signature != NULL); | 634 CHECK(onc_signature != NULL); |
| 624 | 635 |
| 625 ShillToONCTranslator translator(shill_dictionary, *onc_signature); | 636 ShillToONCTranslator translator(shill_dictionary, *onc_signature); |
| 626 return translator.CreateTranslatedONCObject(); | 637 return translator.CreateTranslatedONCObject(); |
| 627 } | 638 } |
| 628 | 639 |
| 629 } // namespace onc | 640 } // namespace onc |
| 630 } // namespace chromeos | 641 } // namespace chromeos |
| OLD | NEW |