Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(120)

Side by Side Diff: chromeos/network/onc/onc_translator_shill_to_onc.cc

Issue 948943003: Better support for Cellular roaming state in ONC (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Nits Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chromeos/network/onc/onc_translation_tables.cc ('k') | components/onc/docs/onc_spec.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 void ShillToONCTranslator::TranslateWiMAXWithState() { 336 void ShillToONCTranslator::TranslateWiMAXWithState() {
337 CopyPropertiesAccordingToSignature(); 337 CopyPropertiesAccordingToSignature();
338 TranslateAndAddNestedObject(::onc::wimax::kEAP); 338 TranslateAndAddNestedObject(::onc::wimax::kEAP);
339 } 339 }
340 340
341 void ShillToONCTranslator::TranslateCellularWithState() { 341 void ShillToONCTranslator::TranslateCellularWithState() {
342 CopyPropertiesAccordingToSignature(); 342 CopyPropertiesAccordingToSignature();
343 TranslateWithTableAndSet(shill::kActivationStateProperty, 343 TranslateWithTableAndSet(shill::kActivationStateProperty,
344 kActivationStateTable, 344 kActivationStateTable,
345 ::onc::cellular::kActivationState); 345 ::onc::cellular::kActivationState);
346 TranslateWithTableAndSet(shill::kRoamingStateProperty,
347 kRoamingStateTable,
348 ::onc::cellular::kRoamingState);
349 const base::DictionaryValue* dictionary = NULL; 346 const base::DictionaryValue* dictionary = NULL;
350 if (shill_dictionary_->GetDictionaryWithoutPathExpansion( 347 if (shill_dictionary_->GetDictionaryWithoutPathExpansion(
351 shill::kServingOperatorProperty, &dictionary)) { 348 shill::kServingOperatorProperty, &dictionary)) {
352 TranslateAndAddNestedObject(::onc::cellular::kServingOperator, *dictionary); 349 TranslateAndAddNestedObject(::onc::cellular::kServingOperator, *dictionary);
353 } 350 }
354 if (shill_dictionary_->GetDictionaryWithoutPathExpansion( 351 if (shill_dictionary_->GetDictionaryWithoutPathExpansion(
355 shill::kCellularApnProperty, &dictionary)) { 352 shill::kCellularApnProperty, &dictionary)) {
356 TranslateAndAddNestedObject(::onc::cellular::kAPN, *dictionary); 353 TranslateAndAddNestedObject(::onc::cellular::kAPN, *dictionary);
357 } 354 }
358 if (shill_dictionary_->GetDictionaryWithoutPathExpansion( 355 if (shill_dictionary_->GetDictionaryWithoutPathExpansion(
359 shill::kCellularLastGoodApnProperty, &dictionary)) { 356 shill::kCellularLastGoodApnProperty, &dictionary)) {
360 TranslateAndAddNestedObject(::onc::cellular::kLastGoodAPN, *dictionary); 357 TranslateAndAddNestedObject(::onc::cellular::kLastGoodAPN, *dictionary);
361 } 358 }
362 // Merge the Device dictionary with this one (Cellular) using the
363 // CellularDevice signature.
364 const base::DictionaryValue* device_dictionary = NULL; 359 const base::DictionaryValue* device_dictionary = NULL;
365 if (!shill_dictionary_->GetDictionaryWithoutPathExpansion( 360 bool requires_roaming = false;
366 shill::kDeviceProperty, &device_dictionary)) { 361 shill_dictionary_->GetDictionaryWithoutPathExpansion(shill::kDeviceProperty,
367 return; 362 &device_dictionary);
363 if (device_dictionary) {
364 // Merge the Device dictionary with this one (Cellular) using the
365 // CellularDevice signature.
366 ShillToONCTranslator nested_translator(*device_dictionary, onc_source_,
367 kCellularWithStateSignature,
368 kCellularDeviceTable);
369 scoped_ptr<base::DictionaryValue> nested_object =
370 nested_translator.CreateTranslatedONCObject();
371 onc_object_->MergeDictionary(nested_object.get());
372
373 /// Get the requires_roaming from the Device dictionary.
374 device_dictionary->GetBooleanWithoutPathExpansion(
375 shill::kProviderRequiresRoamingProperty, &requires_roaming);
368 } 376 }
369 ShillToONCTranslator nested_translator(*device_dictionary, 377 if (requires_roaming) {
370 onc_source_, 378 onc_object_->SetStringWithoutPathExpansion(
371 kCellularWithStateSignature, 379 ::onc::cellular::kRoamingState, ::onc::cellular::kRoamingRequired);
372 kCellularDeviceTable); 380 } else {
373 scoped_ptr<base::DictionaryValue> nested_object = 381 TranslateWithTableAndSet(shill::kRoamingStateProperty, kRoamingStateTable,
374 nested_translator.CreateTranslatedONCObject(); 382 ::onc::cellular::kRoamingState);
375 onc_object_->MergeDictionary(nested_object.get()); 383 }
376 } 384 }
377 385
378 void ShillToONCTranslator::TranslateCellularDevice() { 386 void ShillToONCTranslator::TranslateCellularDevice() {
379 CopyPropertiesAccordingToSignature(); 387 CopyPropertiesAccordingToSignature();
380 const base::DictionaryValue* shill_sim_lock_status = NULL; 388 const base::DictionaryValue* shill_sim_lock_status = NULL;
381 if (shill_dictionary_->GetDictionaryWithoutPathExpansion( 389 if (shill_dictionary_->GetDictionaryWithoutPathExpansion(
382 shill::kSIMLockStatusProperty, &shill_sim_lock_status)) { 390 shill::kSIMLockStatusProperty, &shill_sim_lock_status)) {
383 TranslateAndAddNestedObject(::onc::cellular::kSIMLockStatus, 391 TranslateAndAddNestedObject(::onc::cellular::kSIMLockStatus,
384 *shill_sim_lock_status); 392 *shill_sim_lock_status);
385 } 393 }
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
700 ::onc::ONCSource onc_source, 708 ::onc::ONCSource onc_source,
701 const OncValueSignature* onc_signature) { 709 const OncValueSignature* onc_signature) {
702 CHECK(onc_signature != NULL); 710 CHECK(onc_signature != NULL);
703 711
704 ShillToONCTranslator translator(shill_dictionary, onc_source, *onc_signature); 712 ShillToONCTranslator translator(shill_dictionary, onc_source, *onc_signature);
705 return translator.CreateTranslatedONCObject(); 713 return translator.CreateTranslatedONCObject();
706 } 714 }
707 715
708 } // namespace onc 716 } // namespace onc
709 } // namespace chromeos 717 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/network/onc/onc_translation_tables.cc ('k') | components/onc/docs/onc_spec.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698