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

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: Created 5 years, 10 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
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(
367 return; 362 shill::kDeviceProperty, &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,
367 onc_source_,
368 kCellularWithStateSignature,
369 kCellularDeviceTable);
370 scoped_ptr<base::DictionaryValue> nested_object =
371 nested_translator.CreateTranslatedONCObject();
372 onc_object_->MergeDictionary(nested_object.get());
373
374 /// Get the requires_roaming from the Device dictionary.
375 device_dictionary->GetBooleanWithoutPathExpansion(
376 shill::kProviderRequiresRoamingProperty, &requires_roaming);
368 } 377 }
369 ShillToONCTranslator nested_translator(*device_dictionary, 378 if (requires_roaming) {
370 onc_source_, 379 onc_object_->SetStringWithoutPathExpansion(
371 kCellularWithStateSignature, 380 ::onc::celular::kRoamingState, ::onc::celular::kRoamingAlways);
372 kCellularDeviceTable); 381 } else {
373 scoped_ptr<base::DictionaryValue> nested_object = 382 TranslateWithTableAndSet(shill::kRoamingStateProperty,
374 nested_translator.CreateTranslatedONCObject(); 383 kRoamingStateTable,
375 onc_object_->MergeDictionary(nested_object.get()); 384 ::onc::cellular::kRoamingState);
385 }
376 } 386 }
377 387
378 void ShillToONCTranslator::TranslateCellularDevice() { 388 void ShillToONCTranslator::TranslateCellularDevice() {
379 CopyPropertiesAccordingToSignature(); 389 CopyPropertiesAccordingToSignature();
380 const base::DictionaryValue* shill_sim_lock_status = NULL; 390 const base::DictionaryValue* shill_sim_lock_status = NULL;
381 if (shill_dictionary_->GetDictionaryWithoutPathExpansion( 391 if (shill_dictionary_->GetDictionaryWithoutPathExpansion(
382 shill::kSIMLockStatusProperty, &shill_sim_lock_status)) { 392 shill::kSIMLockStatusProperty, &shill_sim_lock_status)) {
383 TranslateAndAddNestedObject(::onc::cellular::kSIMLockStatus, 393 TranslateAndAddNestedObject(::onc::cellular::kSIMLockStatus,
384 *shill_sim_lock_status); 394 *shill_sim_lock_status);
385 } 395 }
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
700 ::onc::ONCSource onc_source, 710 ::onc::ONCSource onc_source,
701 const OncValueSignature* onc_signature) { 711 const OncValueSignature* onc_signature) {
702 CHECK(onc_signature != NULL); 712 CHECK(onc_signature != NULL);
703 713
704 ShillToONCTranslator translator(shill_dictionary, onc_source, *onc_signature); 714 ShillToONCTranslator translator(shill_dictionary, onc_source, *onc_signature);
705 return translator.CreateTranslatedONCObject(); 715 return translator.CreateTranslatedONCObject();
706 } 716 }
707 717
708 } // namespace onc 718 } // namespace onc
709 } // namespace chromeos 719 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698