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

Side by Side Diff: flimflam.cc

Issue 2836076: Use ConfigureWifiService() instead of GetWifiService() (Closed) Base URL: ssh://git@chromiumos-git/entd.git
Patch Set: Created 10 years, 4 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium OS 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 "entd/flimflam.h" 5 #include "entd/flimflam.h"
6 6
7 #include <string> 7 #include <string>
8 #include <list> 8 #include <list>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/string_util.h" 13 #include "base/string_util.h"
14 #include "cros/chromeos_cros_api.h" 14 #include "cros/chromeos_cros_api.h"
15 #include "cros/chromeos_network.h" 15 #include "cros/chromeos_network.h"
16 #include "entd/utils.h" 16 #include "entd/utils.h"
17 17
18 namespace entd { 18 namespace entd {
19 using chromeos::FreeServiceInfo; 19 using chromeos::FreeServiceInfo;
20 using chromeos::GetWifiService; 20 using chromeos::GetWifiService;
21 using chromeos::ConfigureWifiService;
21 using chromeos::ServiceInfo; 22 using chromeos::ServiceInfo;
22 23
23 const char Flimflam::kLibcrosPath[] = 24 const char Flimflam::kLibcrosPath[] =
24 "/opt/google/chrome/chromeos/libcros.so"; 25 "/opt/google/chrome/chromeos/libcros.so";
25 26
26 Flimflam::~Flimflam() { 27 Flimflam::~Flimflam() {
27 CleanupTemplate(); // We only have one Flimflam instance 28 CleanupTemplate(); // We only have one Flimflam instance
28 } 29 }
29 30
30 bool Load(std::string* load_error_string) { 31 bool Load(std::string* load_error_string) {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 cert_path = utils::ValueAsUtf8String(args[3]); 80 cert_path = utils::ValueAsUtf8String(args[3]);
80 if (!IsStringASCII(cert_path)) { 81 if (!IsStringASCII(cert_path)) {
81 return v8_fail( 82 return v8_fail(
82 "cert_path contains illegal characters in call to configNetwork"); 83 "cert_path contains illegal characters in call to configNetwork");
83 } 84 }
84 85
85 std::string error; 86 std::string error;
86 if (!Load(&error)) 87 if (!Load(&error))
87 return v8_fail(error); 88 return v8_fail(error);
88 89
89 ServiceInfo* ssid_info = GetWifiService(ssid.c_str(), 90 if (!ConfigureWifiService(ssid.c_str(),chromeos::SECURITY_8021X,
90 chromeos::SECURITY_8021X); 91 pass.c_str(), user.c_str(), cert_path.c_str()))
91 if (ssid_info) { 92 return v8_fail("Failed to configure wifi service");
92 if (!chromeos::SetIdentity(ssid_info->service_path, user.c_str())) { 93
93 FreeServiceInfo(ssid_info); 94 return v8::True();
94 return v8_fail("Failed to set identity");
95 }
96 if (!chromeos::SetPassphrase(ssid_info->service_path, pass.c_str())) {
97 FreeServiceInfo(ssid_info);
98 return v8_fail("Failed to set passphrase");
99 }
100 if (!chromeos::SetCertPath(ssid_info->service_path, cert_path.c_str())) {
101 FreeServiceInfo(ssid_info);
102 return v8_fail("Failed to set cert path");
103 }
104 return v8::True();
105 }
106 return v8::False();
107 } 95 }
108 96
109 // bool disconnectNetwork(const char* ssid); 97 // bool disconnectNetwork(const char* ssid);
110 static v8::Handle<v8::Value> dispatch_disconnectNetwork( 98 static v8::Handle<v8::Value> dispatch_disconnectNetwork(
111 const v8::Arguments& args) { 99 const v8::Arguments& args) {
112 if (args.Length() != 1) 100 if (args.Length() != 1)
113 return v8_fail("Incorrect number of args to disconnectNetwork"); 101 return v8_fail("Incorrect number of args to disconnectNetwork");
114 102
115 std::string ssid; 103 std::string ssid;
116 104
(...skipping 22 matching lines...) Expand all
139 // static 127 // static
140 void Flimflam::SetTemplateBindings( 128 void Flimflam::SetTemplateBindings(
141 v8::Handle<v8::ObjectTemplate> template_object) { 129 v8::Handle<v8::ObjectTemplate> template_object) {
142 template_object->Set(v8::String::NewSymbol("configNetwork"), 130 template_object->Set(v8::String::NewSymbol("configNetwork"),
143 v8::FunctionTemplate::New(dispatch_configNetwork)); 131 v8::FunctionTemplate::New(dispatch_configNetwork));
144 template_object->Set(v8::String::NewSymbol("disconnectNetwork"), 132 template_object->Set(v8::String::NewSymbol("disconnectNetwork"),
145 v8::FunctionTemplate::New(dispatch_disconnectNetwork)); 133 v8::FunctionTemplate::New(dispatch_disconnectNetwork));
146 } 134 }
147 135
148 } // namespace entd 136 } // namespace entd
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698