| Index: chromeos/network/onc/onc_translator_shill_to_onc.cc
|
| diff --git a/chromeos/network/onc/onc_translator_shill_to_onc.cc b/chromeos/network/onc/onc_translator_shill_to_onc.cc
|
| index afdbaafce3c9a16bc58b900834a68af5023493ca..a0969fa02d2463efca3f30d102d5a9d3c2f7aedd 100644
|
| --- a/chromeos/network/onc/onc_translator_shill_to_onc.cc
|
| +++ b/chromeos/network/onc/onc_translator_shill_to_onc.cc
|
| @@ -11,6 +11,7 @@
|
| #include "base/json/json_writer.h"
|
| #include "base/logging.h"
|
| #include "base/values.h"
|
| +#include "chromeos/network/network_state.h"
|
| #include "chromeos/network/onc/onc_constants.h"
|
| #include "chromeos/network/onc/onc_signature.h"
|
| #include "chromeos/network/onc/onc_translation_tables.h"
|
| @@ -147,11 +148,12 @@ void ShillToONCTranslator::TranslateOpenVPN() {
|
|
|
| void ShillToONCTranslator::TranslateVPN() {
|
| TranslateWithTableAndSet(flimflam::kProviderTypeProperty, kVPNTypeTable,
|
| - kType);
|
| + network_config::kType);
|
| CopyPropertiesAccordingToSignature();
|
|
|
| std::string vpn_type;
|
| - if (onc_object_->GetStringWithoutPathExpansion(kType, &vpn_type)) {
|
| + if (onc_object_->GetStringWithoutPathExpansion(network_config::kType,
|
| + &vpn_type)) {
|
| if (vpn_type == vpn::kTypeL2TP_IPsec) {
|
| TranslateAndAddNestedObject(vpn::kIPsec);
|
| TranslateAndAddNestedObject(vpn::kL2TP);
|
| @@ -173,18 +175,31 @@ void ShillToONCTranslator::TranslateAndAddNestedObject(
|
| }
|
|
|
| void ShillToONCTranslator::TranslateNetworkConfiguration() {
|
| - TranslateWithTableAndSet(flimflam::kTypeProperty, kNetworkTypeTable, kType);
|
| + TranslateWithTableAndSet(flimflam::kTypeProperty, kNetworkTypeTable,
|
| + network_config::kType);
|
| CopyPropertiesAccordingToSignature();
|
|
|
| std::string network_type;
|
| - if (onc_object_->GetStringWithoutPathExpansion(kType, &network_type))
|
| + if (onc_object_->GetStringWithoutPathExpansion(network_config::kType,
|
| + &network_type))
|
| TranslateAndAddNestedObject(network_type);
|
|
|
| - if (network_type == kVPN) {
|
| - std::string name;
|
| - shill_dictionary_->GetStringWithoutPathExpansion(flimflam::kNameProperty,
|
| - &name);
|
| - onc_object_->SetStringWithoutPathExpansion(kName, name);
|
| + // Since Name is a read only field in Shill unless it's a VPN, is is copied
|
| + // here, but not when going the other direction (if it's not a VPN).
|
| + std::string name;
|
| + shill_dictionary_->GetStringWithoutPathExpansion(flimflam::kNameProperty,
|
| + &name);
|
| + onc_object_->SetStringWithoutPathExpansion(network_config::kName, name);
|
| +
|
| + std::string state;
|
| + if (shill_dictionary_->GetString(flimflam::kStateProperty, &state)) {
|
| + if (NetworkState::StateIsConnected(state)) {
|
| + onc_object_->SetString(network_config::kState, status::kConnected);
|
| + } else if (NetworkState::StateIsConnecting(state)) {
|
| + onc_object_->SetString(network_config::kState, status::kConnecting);
|
| + } else {
|
| + onc_object_->SetString(network_config::kState, status::kNotConnected);
|
| + }
|
| }
|
| }
|
|
|
| @@ -211,12 +226,9 @@ void ShillToONCTranslator::TranslateWithTableAndSet(
|
| &shill_value)) {
|
| return;
|
| }
|
| -
|
| - for (int i = 0; table[i].onc_value != NULL; ++i) {
|
| - if (shill_value != table[i].shill_value)
|
| - continue;
|
| - onc_object_->SetStringWithoutPathExpansion(onc_field_name,
|
| - table[i].onc_value);
|
| + std::string onc_value;
|
| + if (TranslateStringToONC(table, shill_value, &onc_value)) {
|
| + onc_object_->SetStringWithoutPathExpansion(onc_field_name, onc_value);
|
| return;
|
| }
|
| LOG(ERROR) << "Shill property '" << shill_property_name << "' with value '"
|
|
|