Home | History | Annotate | Download | only in onc
      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
      3 // found in the LICENSE file.
      4 
      5 #ifndef CHROMEOS_NETWORK_ONC_ONC_TRANSLATOR_H_
      6 #define CHROMEOS_NETWORK_ONC_ONC_TRANSLATOR_H_
      7 
      8 #include "base/memory/scoped_ptr.h"
      9 #include "chromeos/chromeos_export.h"
     10 #include "components/onc/onc_constants.h"
     11 
     12 namespace base {
     13 class DictionaryValue;
     14 }
     15 
     16 namespace chromeos {
     17 namespace onc {
     18 
     19 struct OncValueSignature;
     20 
     21 // Translates a hierarchical ONC dictionary |onc_object| to a flat Shill
     22 // dictionary. The |signature| declares the type of |onc_object| and must point
     23 // to one of the signature objects in "onc_signature.h". The resulting Shill
     24 // dictionary is returned.
     25 //
     26 // This function is used to translate network settings from ONC to Shill's
     27 // format before sending them to Shill.
     28 CHROMEOS_EXPORT
     29 scoped_ptr<base::DictionaryValue> TranslateONCObjectToShill(
     30     const OncValueSignature* signature,
     31     const base::DictionaryValue& onc_object);
     32 
     33 // Translates a |shill_dictionary| to an ONC object according to the given
     34 // |onc_signature|. |onc_signature| must point to a signature object in
     35 // "onc_signature.h". The resulting ONC object is returned.
     36 //
     37 // This function is used to translate network settings coming from Shill to ONC
     38 // before sending them to the UI. The result doesn't have to be valid ONC, but
     39 // only a subset of it and includes only the values that are actually required
     40 // by the UI. If |onc_source| != ONC_SOURCE_UNKNOWN then the 'Source' property
     41 // of the ONC dictionary will be set accordingly. Note: ONC_SOURCE_USER_IMPORT
     42 // is treated the same as ONC_SOURCE_NONE.
     43 CHROMEOS_EXPORT
     44 scoped_ptr<base::DictionaryValue> TranslateShillServiceToONCPart(
     45     const base::DictionaryValue& shill_dictionary,
     46     ::onc::ONCSource onc_source,
     47     const OncValueSignature* onc_signature);
     48 
     49 }  // namespace onc
     50 }  // namespace chromeos
     51 
     52 #endif  // CHROMEOS_NETWORK_ONC_ONC_TRANSLATOR_H_
     53