shill_property_util.h revision cedac228d2dd51db4b79ea1e72c7f249408ee061
1// Copyright 2013 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_SHILL_PROPERTY_UTIL_H_
6#define CHROMEOS_NETWORK_SHILL_PROPERTY_UTIL_H_
7
8#include <string>
9
10#include "base/memory/scoped_ptr.h"
11#include "chromeos/chromeos_export.h"
12
13namespace base {
14class DictionaryValue;
15class Value;
16}
17
18namespace chromeos {
19
20class NetworkUIData;
21
22namespace shill_property_util {
23
24// Sets the |ssid| in |properties|.
25CHROMEOS_EXPORT void SetSSID(const std::string ssid,
26                             base::DictionaryValue* properties);
27
28// Returns the SSID from |properties| in UTF-8 encoding. If |unknown_encoding|
29// is not NULL, it is set to whether the SSID is of unknown encoding.
30CHROMEOS_EXPORT std::string GetSSIDFromProperties(
31    const base::DictionaryValue& properties,
32    bool* unknown_encoding);
33
34// Returns the GUID (if available), SSID, or Name from |properties|. Only used
35// for logging and debugging.
36CHROMEOS_EXPORT std::string GetNetworkIdFromProperties(
37    const base::DictionaryValue& properties);
38
39  // Returns the name for the network represented by the Shill |properties|. For
40// WiFi it refers to the HexSSID.
41CHROMEOS_EXPORT std::string GetNameFromProperties(
42    const std::string& service_path,
43    const base::DictionaryValue& properties);
44
45// Returns the UIData specified by |value|. Returns NULL if the value cannot be
46// parsed.
47scoped_ptr<NetworkUIData> GetUIDataFromValue(const base::Value& value);
48
49// Returns the NetworkUIData parsed from the UIData property of
50// |shill_dictionary|. If parsing fails or the field doesn't exist, returns
51// NULL.
52scoped_ptr<NetworkUIData> GetUIDataFromProperties(
53    const base::DictionaryValue& shill_dictionary);
54
55// Sets the UIData property in |shill_dictionary| to the serialization of
56// |ui_data|.
57void SetUIData(const NetworkUIData& ui_data,
58               base::DictionaryValue* shill_dictionary);
59
60// Copy configuration properties required by Shill to identify a network.
61// Only WiFi, VPN, Ethernet and EthernetEAP are supported. Wimax and Cellular
62// are not supported. Returns true only if all required properties could be
63// copied.
64bool CopyIdentifyingProperties(const base::DictionaryValue& service_properties,
65                               base::DictionaryValue* dest);
66
67// Compares the identifying configuration properties of |properties_a| and
68// |properties_b|, returns true if they are identical. See also
69// CopyIdentifyingProperties. Only WiFi, VPN, Ethernet and EthernetEAP are
70// supported. Wimax and Cellular are not supported.
71bool DoIdentifyingPropertiesMatch(const base::DictionaryValue& properties_a,
72                                  const base::DictionaryValue& properties_b);
73
74// Returns true if |key| corresponds to a passphrase property.
75bool IsPassphraseKey(const std::string& key);
76
77// Parses |value| (which should be a Dictionary). Returns true and sets
78// |home_provider_id| if |value| was succesfully parsed.
79bool GetHomeProviderFromProperty(const base::Value& value,
80                                 std::string* home_provider_id);
81
82}  // namespace shill_property_util
83
84}  // namespace chromeos
85
86#endif  // CHROMEOS_NETWORK_SHILL_PROPERTY_UTIL_H_
87