| 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 // The implementation of TranslateONCObjectToShill is structured in two parts: | 5 // The implementation of TranslateONCObjectToShill is structured in two parts: |
| 6 // - The recursion through the existing ONC hierarchy | 6 // - The recursion through the existing ONC hierarchy |
| 7 // see TranslateONCHierarchy | 7 // see TranslateONCHierarchy |
| 8 // - The local translation of an object depending on the associated signature | 8 // - The local translation of an object depending on the associated signature |
| 9 // see LocalTranslator::TranslateFields | 9 // see LocalTranslator::TranslateFields |
| 10 | 10 |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 if (authentication == ::onc::ethernet::k8021X) | 135 if (authentication == ::onc::ethernet::k8021X) |
| 136 shill_type = shill::kTypeEthernetEap; | 136 shill_type = shill::kTypeEthernetEap; |
| 137 shill_dictionary_->SetStringWithoutPathExpansion(shill::kTypeProperty, | 137 shill_dictionary_->SetStringWithoutPathExpansion(shill::kTypeProperty, |
| 138 shill_type); | 138 shill_type); |
| 139 | 139 |
| 140 CopyFieldsAccordingToSignature(); | 140 CopyFieldsAccordingToSignature(); |
| 141 } | 141 } |
| 142 | 142 |
| 143 | 143 |
| 144 void LocalTranslator::TranslateStaticIPConfig() { | 144 void LocalTranslator::TranslateStaticIPConfig() { |
| 145 const base::ListValue* onc_nameservers = NULL; | 145 const base::ListValue* onc_nameservers_list = NULL; |
| 146 if (onc_object_->GetListWithoutPathExpansion(::onc::ipconfig::kNameServers, | 146 onc_object_->GetListWithoutPathExpansion(::onc::ipconfig::kNameServers, |
| 147 &onc_nameservers)) { | 147 &onc_nameservers_list); |
| 148 std::vector<std::string> onc_nameservers_vector; | 148 if (onc_nameservers_list) { |
| 149 ConvertListValueToStringVector(*onc_nameservers, &onc_nameservers_vector); | 149 if (!onc_nameservers_list->empty()) { |
| 150 std::string shill_nameservers = JoinString(onc_nameservers_vector, ','); | 150 std::vector<std::string> onc_nameservers_vector; |
| 151 shill_dictionary_->SetStringWithoutPathExpansion( | 151 ConvertListValueToStringVector(*onc_nameservers_list, |
| 152 shill::kStaticIPNameServersProperty, shill_nameservers); | 152 &onc_nameservers_vector); |
| 153 std::string shill_nameservers = JoinString(onc_nameservers_vector, ','); |
| 154 shill_dictionary_->SetStringWithoutPathExpansion( |
| 155 shill::kStaticIPNameServersProperty, shill_nameservers); |
| 156 } else { |
| 157 // Empty NameServers entry clears the value. |
| 158 shill_dictionary_->SetWithoutPathExpansion( |
| 159 shill::kStaticIPNameServersProperty, base::Value::CreateNullValue()); |
| 160 } |
| 153 } | 161 } |
| 154 | 162 |
| 155 CopyFieldsAccordingToSignature(); | 163 CopyFieldsAccordingToSignature(); |
| 164 |
| 165 // An empty IP Address string indicates 'automatic' configuration; clear all |
| 166 // Static IP config properties in Shill. |
| 167 std::string address_value; |
| 168 if (onc_object_->GetStringWithoutPathExpansion(::onc::ipconfig::kIPAddress, |
| 169 &address_value) && |
| 170 address_value.empty()) { |
| 171 shill_dictionary_->SetWithoutPathExpansion(shill::kStaticIPAddressProperty, |
| 172 base::Value::CreateNullValue()); |
| 173 shill_dictionary_->SetWithoutPathExpansion(shill::kStaticIPGatewayProperty, |
| 174 base::Value::CreateNullValue()); |
| 175 shill_dictionary_->SetWithoutPathExpansion( |
| 176 shill::kStaticIPPrefixlenProperty, base::Value::CreateNullValue()); |
| 177 } |
| 156 } | 178 } |
| 157 | 179 |
| 158 void LocalTranslator::TranslateOpenVPN() { | 180 void LocalTranslator::TranslateOpenVPN() { |
| 159 // SaveCredentials needs special handling when translating from Shill -> ONC | 181 // SaveCredentials needs special handling when translating from Shill -> ONC |
| 160 // so handle it explicitly here. | 182 // so handle it explicitly here. |
| 161 CopyFieldFromONCToShill(::onc::vpn::kSaveCredentials, | 183 CopyFieldFromONCToShill(::onc::vpn::kSaveCredentials, |
| 162 shill::kSaveCredentialsProperty); | 184 shill::kSaveCredentialsProperty); |
| 163 | 185 |
| 164 std::string user_auth_type; | 186 std::string user_auth_type; |
| 165 onc_object_->GetStringWithoutPathExpansion( | 187 onc_object_->GetStringWithoutPathExpansion( |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 402 const OncValueSignature* onc_signature, | 424 const OncValueSignature* onc_signature, |
| 403 const base::DictionaryValue& onc_object) { | 425 const base::DictionaryValue& onc_object) { |
| 404 CHECK(onc_signature != NULL); | 426 CHECK(onc_signature != NULL); |
| 405 scoped_ptr<base::DictionaryValue> shill_dictionary(new base::DictionaryValue); | 427 scoped_ptr<base::DictionaryValue> shill_dictionary(new base::DictionaryValue); |
| 406 TranslateONCHierarchy(*onc_signature, onc_object, shill_dictionary.get()); | 428 TranslateONCHierarchy(*onc_signature, onc_object, shill_dictionary.get()); |
| 407 return shill_dictionary.Pass(); | 429 return shill_dictionary.Pass(); |
| 408 } | 430 } |
| 409 | 431 |
| 410 } // namespace onc | 432 } // namespace onc |
| 411 } // namespace chromeos | 433 } // namespace chromeos |
| OLD | NEW |