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 #include "chromeos/network/network_state.h" | 5 #include "chromeos/network/network_state.h" |
6 | 6 |
7 #include "base/i18n/icu_encoding_detection.h" | 7 #include "base/i18n/icu_encoding_detection.h" |
8 #include "base/i18n/icu_string_conversions.h" | 8 #include "base/i18n/icu_string_conversions.h" |
9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
10 #include "base/stringprintf.h" | 10 #include "base/stringprintf.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 } // namespace | 52 } // namespace |
53 | 53 |
54 namespace chromeos { | 54 namespace chromeos { |
55 | 55 |
56 NetworkState::NetworkState(const std::string& path) | 56 NetworkState::NetworkState(const std::string& path) |
57 : ManagedState(MANAGED_TYPE_NETWORK, path), | 57 : ManagedState(MANAGED_TYPE_NETWORK, path), |
58 auto_connect_(false), | 58 auto_connect_(false), |
59 favorite_(false), | 59 favorite_(false), |
60 priority_(0), | 60 priority_(0), |
61 signal_strength_(0), | 61 signal_strength_(0), |
| 62 connectable_(false), |
| 63 passphrase_required_(false), |
62 activate_over_non_cellular_networks_(false), | 64 activate_over_non_cellular_networks_(false), |
63 cellular_out_of_credits_(false) { | 65 cellular_out_of_credits_(false) { |
64 } | 66 } |
65 | 67 |
66 NetworkState::~NetworkState() { | 68 NetworkState::~NetworkState() { |
67 } | 69 } |
68 | 70 |
69 bool NetworkState::PropertyChanged(const std::string& key, | 71 bool NetworkState::PropertyChanged(const std::string& key, |
70 const base::Value& value) { | 72 const base::Value& value) { |
71 // Keep care that these properties are the same as in |GetProperties|. | 73 // Keep care that these properties are the same as in |GetProperties|. |
72 if (ManagedStatePropertyChanged(key, value)) | 74 if (ManagedStatePropertyChanged(key, value)) |
73 return true; | 75 return true; |
74 if (key == flimflam::kSignalStrengthProperty) { | 76 if (key == flimflam::kSignalStrengthProperty) { |
75 return GetIntegerValue(key, value, &signal_strength_); | 77 return GetIntegerValue(key, value, &signal_strength_); |
76 } else if (key == flimflam::kStateProperty) { | 78 } else if (key == flimflam::kStateProperty) { |
77 return GetStringValue(key, value, &connection_state_); | 79 return GetStringValue(key, value, &connection_state_); |
| 80 } else if (key == flimflam::kConnectableProperty) { |
| 81 return GetBooleanValue(key, value, &connectable_); |
| 82 } else if (key == flimflam::kPassphraseRequiredProperty) { |
| 83 return GetBooleanValue(key, value, &passphrase_required_); |
78 } else if (key == flimflam::kErrorProperty) { | 84 } else if (key == flimflam::kErrorProperty) { |
79 return GetStringValue(key, value, &error_); | 85 return GetStringValue(key, value, &error_); |
80 } else if (key == IPConfigProperty(flimflam::kAddressProperty)) { | 86 } else if (key == IPConfigProperty(flimflam::kAddressProperty)) { |
81 return GetStringValue(key, value, &ip_address_); | 87 return GetStringValue(key, value, &ip_address_); |
82 } else if (key == IPConfigProperty(flimflam::kNameServersProperty)) { | 88 } else if (key == IPConfigProperty(flimflam::kNameServersProperty)) { |
83 dns_servers_.clear(); | 89 dns_servers_.clear(); |
84 const base::ListValue* dns_servers; | 90 const base::ListValue* dns_servers; |
85 if (value.GetAsList(&dns_servers) && | 91 if (value.GetAsList(&dns_servers) && |
86 ConvertListValueToStringVector(*dns_servers, &dns_servers_)) | 92 ConvertListValueToStringVector(*dns_servers, &dns_servers_)) |
87 return true; | 93 return true; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 | 129 |
124 void NetworkState::InitialPropertiesReceived() { | 130 void NetworkState::InitialPropertiesReceived() { |
125 UpdateName(); | 131 UpdateName(); |
126 } | 132 } |
127 | 133 |
128 void NetworkState::GetProperties(base::DictionaryValue* dictionary) const { | 134 void NetworkState::GetProperties(base::DictionaryValue* dictionary) const { |
129 // Keep care that these properties are the same as in |PropertyChanged|. | 135 // Keep care that these properties are the same as in |PropertyChanged|. |
130 dictionary->SetStringWithoutPathExpansion(flimflam::kNameProperty, name()); | 136 dictionary->SetStringWithoutPathExpansion(flimflam::kNameProperty, name()); |
131 dictionary->SetStringWithoutPathExpansion(flimflam::kTypeProperty, type()); | 137 dictionary->SetStringWithoutPathExpansion(flimflam::kTypeProperty, type()); |
132 dictionary->SetIntegerWithoutPathExpansion(flimflam::kSignalStrengthProperty, | 138 dictionary->SetIntegerWithoutPathExpansion(flimflam::kSignalStrengthProperty, |
133 signal_strength()); | 139 signal_strength_); |
134 dictionary->SetStringWithoutPathExpansion(flimflam::kStateProperty, | 140 dictionary->SetStringWithoutPathExpansion(flimflam::kStateProperty, |
135 connection_state()); | 141 connection_state_); |
| 142 dictionary->SetBooleanWithoutPathExpansion(flimflam::kConnectableProperty, |
| 143 connectable_); |
| 144 dictionary->SetBooleanWithoutPathExpansion( |
| 145 flimflam::kPassphraseRequiredProperty, passphrase_required_); |
136 dictionary->SetStringWithoutPathExpansion(flimflam::kErrorProperty, | 146 dictionary->SetStringWithoutPathExpansion(flimflam::kErrorProperty, |
137 error()); | 147 error_); |
138 base::DictionaryValue* ipconfig_properties = new DictionaryValue; | 148 base::DictionaryValue* ipconfig_properties = new DictionaryValue; |
139 ipconfig_properties->SetStringWithoutPathExpansion(flimflam::kAddressProperty, | 149 ipconfig_properties->SetStringWithoutPathExpansion(flimflam::kAddressProperty, |
140 ip_address()); | 150 ip_address_); |
141 base::ListValue* name_servers = new ListValue; | 151 base::ListValue* name_servers = new ListValue; |
142 name_servers->AppendStrings(dns_servers()); | 152 name_servers->AppendStrings(dns_servers_); |
143 ipconfig_properties->SetWithoutPathExpansion(flimflam::kNameServersProperty, | 153 ipconfig_properties->SetWithoutPathExpansion(flimflam::kNameServersProperty, |
144 name_servers); | 154 name_servers); |
145 dictionary->SetWithoutPathExpansion(shill::kIPConfigProperty, | 155 dictionary->SetWithoutPathExpansion(shill::kIPConfigProperty, |
146 ipconfig_properties); | 156 ipconfig_properties); |
147 | 157 |
148 dictionary->SetStringWithoutPathExpansion(flimflam::kActivationStateProperty, | 158 dictionary->SetStringWithoutPathExpansion(flimflam::kActivationStateProperty, |
149 activation_state()); | 159 activation_state_); |
150 dictionary->SetStringWithoutPathExpansion(flimflam::kRoamingStateProperty, | 160 dictionary->SetStringWithoutPathExpansion(flimflam::kRoamingStateProperty, |
151 roaming()); | 161 roaming_); |
152 dictionary->SetStringWithoutPathExpansion(flimflam::kSecurityProperty, | 162 dictionary->SetStringWithoutPathExpansion(flimflam::kSecurityProperty, |
153 security()); | 163 security_); |
154 dictionary->SetBooleanWithoutPathExpansion(flimflam::kAutoConnectProperty, | 164 dictionary->SetBooleanWithoutPathExpansion(flimflam::kAutoConnectProperty, |
155 auto_connect()); | 165 auto_connect_); |
156 dictionary->SetBooleanWithoutPathExpansion(flimflam::kFavoriteProperty, | 166 dictionary->SetBooleanWithoutPathExpansion(flimflam::kFavoriteProperty, |
157 favorite()); | 167 favorite_); |
158 dictionary->SetIntegerWithoutPathExpansion(flimflam::kPriorityProperty, | 168 dictionary->SetIntegerWithoutPathExpansion(flimflam::kPriorityProperty, |
159 priority()); | 169 priority_); |
160 dictionary->SetStringWithoutPathExpansion( | 170 dictionary->SetStringWithoutPathExpansion( |
161 flimflam::kNetworkTechnologyProperty, | 171 flimflam::kNetworkTechnologyProperty, |
162 technology()); | 172 technology_); |
163 dictionary->SetStringWithoutPathExpansion(flimflam::kDeviceProperty, | 173 dictionary->SetStringWithoutPathExpansion(flimflam::kDeviceProperty, |
164 device_path()); | 174 device_path_); |
165 dictionary->SetStringWithoutPathExpansion(flimflam::kGuidProperty, guid()); | 175 dictionary->SetStringWithoutPathExpansion(flimflam::kGuidProperty, guid_); |
166 dictionary->SetStringWithoutPathExpansion(flimflam::kProfileProperty, | 176 dictionary->SetStringWithoutPathExpansion(flimflam::kProfileProperty, |
167 profile_path()); | 177 profile_path_); |
168 dictionary->SetBooleanWithoutPathExpansion( | 178 dictionary->SetBooleanWithoutPathExpansion( |
169 shill::kActivateOverNonCellularNetworkProperty, | 179 shill::kActivateOverNonCellularNetworkProperty, |
170 activate_over_non_cellular_networks()); | 180 activate_over_non_cellular_networks_); |
171 dictionary->SetBooleanWithoutPathExpansion(shill::kOutOfCreditsProperty, | 181 dictionary->SetBooleanWithoutPathExpansion(shill::kOutOfCreditsProperty, |
172 cellular_out_of_credits()); | 182 cellular_out_of_credits_); |
173 } | 183 } |
174 | 184 |
175 bool NetworkState::IsConnectedState() const { | 185 bool NetworkState::IsConnectedState() const { |
176 return StateIsConnected(connection_state_); | 186 return StateIsConnected(connection_state_); |
177 } | 187 } |
178 | 188 |
179 bool NetworkState::IsConnectingState() const { | 189 bool NetworkState::IsConnectingState() const { |
180 return StateIsConnecting(connection_state_); | 190 return StateIsConnecting(connection_state_); |
181 } | 191 } |
182 | 192 |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 connection_state == flimflam::kStateConfiguration || | 266 connection_state == flimflam::kStateConfiguration || |
257 connection_state == flimflam::kStateCarrier); | 267 connection_state == flimflam::kStateCarrier); |
258 } | 268 } |
259 | 269 |
260 // static | 270 // static |
261 std::string NetworkState::IPConfigProperty(const char* key) { | 271 std::string NetworkState::IPConfigProperty(const char* key) { |
262 return base::StringPrintf("%s.%s", shill::kIPConfigProperty, key); | 272 return base::StringPrintf("%s.%s", shill::kIPConfigProperty, key); |
263 } | 273 } |
264 | 274 |
265 } // namespace chromeos | 275 } // namespace chromeos |
OLD | NEW |