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

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

Issue 24348002: Migrate DBus service constants from flimflam namespace to shill namespace. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased to ToT Created 7 years, 3 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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 } else if (onc_signature_ == &kCellularWithStateSignature) { 121 } else if (onc_signature_ == &kCellularWithStateSignature) {
122 TranslateCellularWithState(); 122 TranslateCellularWithState();
123 } else { 123 } else {
124 CopyPropertiesAccordingToSignature(); 124 CopyPropertiesAccordingToSignature();
125 } 125 }
126 return onc_object_.Pass(); 126 return onc_object_.Pass();
127 } 127 }
128 128
129 void ShillToONCTranslator::TranslateEthernet() { 129 void ShillToONCTranslator::TranslateEthernet() {
130 std::string shill_network_type; 130 std::string shill_network_type;
131 shill_dictionary_->GetStringWithoutPathExpansion(flimflam::kTypeProperty, 131 shill_dictionary_->GetStringWithoutPathExpansion(shill::kTypeProperty,
132 &shill_network_type); 132 &shill_network_type);
133 const char* onc_auth = ethernet::kNone; 133 const char* onc_auth = ethernet::kNone;
134 if (shill_network_type == shill::kTypeEthernetEap) 134 if (shill_network_type == shill::kTypeEthernetEap)
135 onc_auth = ethernet::k8021X; 135 onc_auth = ethernet::k8021X;
136 onc_object_->SetStringWithoutPathExpansion(ethernet::kAuthentication, 136 onc_object_->SetStringWithoutPathExpansion(ethernet::kAuthentication,
137 onc_auth); 137 onc_auth);
138 } 138 }
139 139
140 void ShillToONCTranslator::TranslateOpenVPN() { 140 void ShillToONCTranslator::TranslateOpenVPN() {
141 // Shill supports only one RemoteCertKU but ONC requires a list. If existing, 141 // Shill supports only one RemoteCertKU but ONC requires a list. If existing,
142 // wraps the value into a list. 142 // wraps the value into a list.
143 std::string certKU; 143 std::string certKU;
144 if (shill_dictionary_->GetStringWithoutPathExpansion( 144 if (shill_dictionary_->GetStringWithoutPathExpansion(
145 flimflam::kOpenVPNRemoteCertKUProperty, &certKU)) { 145 shill::kOpenVPNRemoteCertKUProperty, &certKU)) {
146 scoped_ptr<base::ListValue> certKUs(new base::ListValue); 146 scoped_ptr<base::ListValue> certKUs(new base::ListValue);
147 certKUs->AppendString(certKU); 147 certKUs->AppendString(certKU);
148 onc_object_->SetWithoutPathExpansion(openvpn::kRemoteCertKU, 148 onc_object_->SetWithoutPathExpansion(openvpn::kRemoteCertKU,
149 certKUs.release()); 149 certKUs.release());
150 } 150 }
151 151
152 for (const OncFieldSignature* field_signature = onc_signature_->fields; 152 for (const OncFieldSignature* field_signature = onc_signature_->fields;
153 field_signature->onc_field_name != NULL; ++field_signature) { 153 field_signature->onc_field_name != NULL; ++field_signature) {
154 const std::string& onc_field_name = field_signature->onc_field_name; 154 const std::string& onc_field_name = field_signature->onc_field_name;
155 if (onc_field_name == vpn::kSaveCredentials || 155 if (onc_field_name == vpn::kSaveCredentials ||
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 } 190 }
191 } else { 191 } else {
192 LOG(ERROR) << "Shill property '" << shill_property_name 192 LOG(ERROR) << "Shill property '" << shill_property_name
193 << "' has value " << *shill_value 193 << "' has value " << *shill_value
194 << ", but expected a string"; 194 << ", but expected a string";
195 } 195 }
196 } 196 }
197 } 197 }
198 198
199 void ShillToONCTranslator::TranslateVPN() { 199 void ShillToONCTranslator::TranslateVPN() {
200 TranslateWithTableAndSet(flimflam::kProviderTypeProperty, kVPNTypeTable, 200 TranslateWithTableAndSet(shill::kProviderTypeProperty, kVPNTypeTable,
201 vpn::kType); 201 vpn::kType);
202 CopyPropertiesAccordingToSignature(); 202 CopyPropertiesAccordingToSignature();
203 203
204 std::string vpn_type; 204 std::string vpn_type;
205 if (onc_object_->GetStringWithoutPathExpansion(vpn::kType, 205 if (onc_object_->GetStringWithoutPathExpansion(vpn::kType,
206 &vpn_type)) { 206 &vpn_type)) {
207 if (vpn_type == vpn::kTypeL2TP_IPsec) { 207 if (vpn_type == vpn::kTypeL2TP_IPsec) {
208 TranslateAndAddNestedObject(vpn::kIPsec); 208 TranslateAndAddNestedObject(vpn::kIPsec);
209 TranslateAndAddNestedObject(vpn::kL2TP); 209 TranslateAndAddNestedObject(vpn::kL2TP);
210 } else { 210 } else {
211 TranslateAndAddNestedObject(vpn_type); 211 TranslateAndAddNestedObject(vpn_type);
212 } 212 }
213 } 213 }
214 } 214 }
215 215
216 void ShillToONCTranslator::TranslateWiFiWithState() { 216 void ShillToONCTranslator::TranslateWiFiWithState() {
217 TranslateWithTableAndSet(flimflam::kSecurityProperty, kWiFiSecurityTable, 217 TranslateWithTableAndSet(shill::kSecurityProperty, kWiFiSecurityTable,
218 wifi::kSecurity); 218 wifi::kSecurity);
219 CopyPropertiesAccordingToSignature(); 219 CopyPropertiesAccordingToSignature();
220 } 220 }
221 221
222 void ShillToONCTranslator::TranslateCellularWithState() { 222 void ShillToONCTranslator::TranslateCellularWithState() {
223 CopyPropertiesAccordingToSignature(); 223 CopyPropertiesAccordingToSignature();
224 const base::DictionaryValue* dictionary = NULL; 224 const base::DictionaryValue* dictionary = NULL;
225 if (shill_dictionary_->GetDictionaryWithoutPathExpansion( 225 if (shill_dictionary_->GetDictionaryWithoutPathExpansion(
226 flimflam::kServingOperatorProperty, &dictionary)) { 226 shill::kServingOperatorProperty, &dictionary)) {
227 TranslateAndAddNestedObject(cellular::kServingOperator, *dictionary); 227 TranslateAndAddNestedObject(cellular::kServingOperator, *dictionary);
228 } 228 }
229 if (shill_dictionary_->GetDictionaryWithoutPathExpansion( 229 if (shill_dictionary_->GetDictionaryWithoutPathExpansion(
230 flimflam::kCellularApnProperty, &dictionary)) { 230 shill::kCellularApnProperty, &dictionary)) {
231 TranslateAndAddNestedObject(cellular::kAPN, *dictionary); 231 TranslateAndAddNestedObject(cellular::kAPN, *dictionary);
232 } 232 }
233 } 233 }
234 234
235 void ShillToONCTranslator::TranslateNetworkWithState() { 235 void ShillToONCTranslator::TranslateNetworkWithState() {
236 CopyPropertiesAccordingToSignature(); 236 CopyPropertiesAccordingToSignature();
237 237
238 std::string shill_network_type; 238 std::string shill_network_type;
239 shill_dictionary_->GetStringWithoutPathExpansion(flimflam::kTypeProperty, 239 shill_dictionary_->GetStringWithoutPathExpansion(shill::kTypeProperty,
240 &shill_network_type); 240 &shill_network_type);
241 std::string onc_network_type = network_type::kEthernet; 241 std::string onc_network_type = network_type::kEthernet;
242 if (shill_network_type != flimflam::kTypeEthernet && 242 if (shill_network_type != shill::kTypeEthernet &&
243 shill_network_type != shill::kTypeEthernetEap) { 243 shill_network_type != shill::kTypeEthernetEap) {
244 TranslateStringToONC( 244 TranslateStringToONC(
245 kNetworkTypeTable, shill_network_type, &onc_network_type); 245 kNetworkTypeTable, shill_network_type, &onc_network_type);
246 } 246 }
247 if (!onc_network_type.empty()) { 247 if (!onc_network_type.empty()) {
248 onc_object_->SetStringWithoutPathExpansion(network_config::kType, 248 onc_object_->SetStringWithoutPathExpansion(network_config::kType,
249 onc_network_type); 249 onc_network_type);
250 TranslateAndAddNestedObject(onc_network_type); 250 TranslateAndAddNestedObject(onc_network_type);
251 } 251 }
252 252
253 // Since Name is a read only field in Shill unless it's a VPN, it is copied 253 // Since Name is a read only field in Shill unless it's a VPN, it is copied
254 // here, but not when going the other direction (if it's not a VPN). 254 // here, but not when going the other direction (if it's not a VPN).
255 std::string name; 255 std::string name;
256 shill_dictionary_->GetStringWithoutPathExpansion(flimflam::kNameProperty, 256 shill_dictionary_->GetStringWithoutPathExpansion(shill::kNameProperty,
257 &name); 257 &name);
258 onc_object_->SetStringWithoutPathExpansion(network_config::kName, name); 258 onc_object_->SetStringWithoutPathExpansion(network_config::kName, name);
259 259
260 std::string state; 260 std::string state;
261 if (shill_dictionary_->GetStringWithoutPathExpansion(flimflam::kStateProperty, 261 if (shill_dictionary_->GetStringWithoutPathExpansion(shill::kStateProperty,
262 &state)) { 262 &state)) {
263 std::string onc_state = connection_state::kNotConnected; 263 std::string onc_state = connection_state::kNotConnected;
264 if (NetworkState::StateIsConnected(state)) { 264 if (NetworkState::StateIsConnected(state)) {
265 onc_state = connection_state::kConnected; 265 onc_state = connection_state::kConnected;
266 } else if (NetworkState::StateIsConnecting(state)) { 266 } else if (NetworkState::StateIsConnecting(state)) {
267 onc_state = connection_state::kConnecting; 267 onc_state = connection_state::kConnecting;
268 } 268 }
269 onc_object_->SetStringWithoutPathExpansion(network_config::kConnectionState, 269 onc_object_->SetStringWithoutPathExpansion(network_config::kConnectionState,
270 onc_state); 270 onc_state);
271 } 271 }
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 const base::DictionaryValue& shill_dictionary, 355 const base::DictionaryValue& shill_dictionary,
356 const OncValueSignature* onc_signature) { 356 const OncValueSignature* onc_signature) {
357 CHECK(onc_signature != NULL); 357 CHECK(onc_signature != NULL);
358 358
359 ShillToONCTranslator translator(shill_dictionary, *onc_signature); 359 ShillToONCTranslator translator(shill_dictionary, *onc_signature);
360 return translator.CreateTranslatedONCObject(); 360 return translator.CreateTranslatedONCObject();
361 } 361 }
362 362
363 } // namespace onc 363 } // namespace onc
364 } // namespace chromeos 364 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/network/onc/onc_translator_onc_to_shill.cc ('k') | chromeos/network/policy_applicator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698