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 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 &type); | 250 &type); |
251 | 251 |
252 // Set the type except for Ethernet which is set in TranslateEthernet. | 252 // Set the type except for Ethernet which is set in TranslateEthernet. |
253 if (type != ::onc::network_type::kEthernet) | 253 if (type != ::onc::network_type::kEthernet) |
254 TranslateWithTableAndSet(type, kNetworkTypeTable, shill::kTypeProperty); | 254 TranslateWithTableAndSet(type, kNetworkTypeTable, shill::kTypeProperty); |
255 | 255 |
256 // Shill doesn't allow setting the name for non-VPN networks. | 256 // Shill doesn't allow setting the name for non-VPN networks. |
257 if (type == ::onc::network_type::kVPN) | 257 if (type == ::onc::network_type::kVPN) |
258 CopyFieldFromONCToShill(::onc::network_config::kName, shill::kNameProperty); | 258 CopyFieldFromONCToShill(::onc::network_config::kName, shill::kNameProperty); |
259 | 259 |
| 260 std::string ipconfig_type; |
| 261 onc_object_->GetStringWithoutPathExpansion( |
| 262 ::onc::network_config::kIPConfigType, &ipconfig_type); |
| 263 |
| 264 if (ipconfig_type == ::onc::network_config::kIPConfigTypeDHCP) { |
| 265 // Clear the properties of StaticIPConfig. |
| 266 scoped_ptr<base::DictionaryValue> static_ipconfig( |
| 267 new base::DictionaryValue); |
| 268 static_ipconfig->SetWithoutPathExpansion(shill::kAddressProperty, |
| 269 base::Value::CreateNullValue()); |
| 270 static_ipconfig->SetWithoutPathExpansion(shill::kGatewayProperty, |
| 271 base::Value::CreateNullValue()); |
| 272 static_ipconfig->SetWithoutPathExpansion(shill::kPrefixlenProperty, |
| 273 base::Value::CreateNullValue()); |
| 274 shill_dictionary_->SetWithoutPathExpansion(shill::kStaticIPConfigProperty, |
| 275 static_ipconfig.release()); |
| 276 } |
| 277 // Otherwise, the StaticIPConfig is set and translated. |
| 278 |
260 CopyFieldsAccordingToSignature(); | 279 CopyFieldsAccordingToSignature(); |
261 } | 280 } |
262 | 281 |
263 void LocalTranslator::CopyFieldsAccordingToSignature() { | 282 void LocalTranslator::CopyFieldsAccordingToSignature() { |
264 for (base::DictionaryValue::Iterator it(*onc_object_); !it.IsAtEnd(); | 283 for (base::DictionaryValue::Iterator it(*onc_object_); !it.IsAtEnd(); |
265 it.Advance()) { | 284 it.Advance()) { |
266 AddValueAccordingToSignature(it.key(), | 285 AddValueAccordingToSignature(it.key(), |
267 make_scoped_ptr(it.value().DeepCopy())); | 286 make_scoped_ptr(it.value().DeepCopy())); |
268 } | 287 } |
269 } | 288 } |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
374 const OncValueSignature* onc_signature, | 393 const OncValueSignature* onc_signature, |
375 const base::DictionaryValue& onc_object) { | 394 const base::DictionaryValue& onc_object) { |
376 CHECK(onc_signature != NULL); | 395 CHECK(onc_signature != NULL); |
377 scoped_ptr<base::DictionaryValue> shill_dictionary(new base::DictionaryValue); | 396 scoped_ptr<base::DictionaryValue> shill_dictionary(new base::DictionaryValue); |
378 TranslateONCHierarchy(*onc_signature, onc_object, shill_dictionary.get()); | 397 TranslateONCHierarchy(*onc_signature, onc_object, shill_dictionary.get()); |
379 return shill_dictionary.Pass(); | 398 return shill_dictionary.Pass(); |
380 } | 399 } |
381 | 400 |
382 } // namespace onc | 401 } // namespace onc |
383 } // namespace chromeos | 402 } // namespace chromeos |
OLD | NEW |