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

Side by Side Diff: remoting/host/setup/start_host_main.cc

Issue 2930543002: [remoting start-host] Make --name optional, and other tweaks. (Closed)
Patch Set: Created 3 years, 6 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) 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 "remoting/host/setup/start_host_main.h" 5 #include "remoting/host/setup/start_host_main.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdio.h> 8 #include <stdio.h>
9 9
10 #include "base/at_exit.h" 10 #include "base/at_exit.h"
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 150
151 #if defined(OS_WIN) 151 #if defined(OS_WIN)
152 // The tool must be run elevated on Windows so the host has access to the 152 // The tool must be run elevated on Windows so the host has access to the
153 // directories used to store the configuration JSON files. 153 // directories used to store the configuration JSON files.
154 if (!remoting::IsProcessElevated()) { 154 if (!remoting::IsProcessElevated()) {
155 fprintf(stderr, "Error: %s must be run as an elevated process.", argv[0]); 155 fprintf(stderr, "Error: %s must be run as an elevated process.", argv[0]);
156 return 1; 156 return 1;
157 } 157 }
158 #endif // defined(OS_WIN) 158 #endif // defined(OS_WIN)
159 159
160 if (host_name.empty()) { 160 if (command_line->HasSwitch("help") || command_line->HasSwitch("h") ||
161 command_line->HasSwitch("?") || !command_line->GetArgs().empty()) {
161 fprintf(stderr, 162 fprintf(stderr,
162 "Usage: %s --name=<hostname> [--code=<auth-code>] [--pin=<PIN>] " 163 "Usage: %s [--name=<hostname>] [--code=<auth-code>] [--pin=<PIN>] "
163 "[--redirect-url=<redirectURL>]\n", 164 "[--redirect-url=<redirectURL>]\n",
164 argv[0]); 165 argv[0]);
165 fprintf(stderr, "\nAuthorization URL for Production services:\n");
166 fprintf(stderr, "%s\n", GetAuthorizationCodeUri().c_str());
167 return 1; 166 return 1;
168 } 167 }
169 168
169 if (host_name.empty()) {
170 fprintf(stdout, "Enter a name for this computer: ");
171 fflush(stdout);
172 host_name = ReadString(false);
173 }
174
170 if (host_pin.empty()) { 175 if (host_pin.empty()) {
171 while (true) { 176 while (true) {
172 fprintf(stdout, "Enter a PIN of at least six digits: "); 177 fprintf(stdout, "Enter a PIN of at least six digits: ");
173 fflush(stdout); 178 fflush(stdout);
174 host_pin = ReadString(true); 179 host_pin = ReadString(true);
175 if (!remoting::IsPinValid(host_pin)) { 180 if (!remoting::IsPinValid(host_pin)) {
176 fprintf(stdout, 181 fprintf(stdout,
177 "Please use a PIN consisting of at least six digits.\n"); 182 "Please use a PIN consisting of at least six digits.\n");
178 fflush(stdout); 183 fflush(stdout);
179 continue; 184 continue;
(...skipping 10 matching lines...) Expand all
190 break; 195 break;
191 } 196 }
192 } else { 197 } else {
193 if (!remoting::IsPinValid(host_pin)) { 198 if (!remoting::IsPinValid(host_pin)) {
194 fprintf(stderr, "Please use a PIN consisting of at least six digits.\n"); 199 fprintf(stderr, "Please use a PIN consisting of at least six digits.\n");
195 return 1; 200 return 1;
196 } 201 }
197 } 202 }
198 203
199 if (auth_code.empty()) { 204 if (auth_code.empty()) {
205 fprintf(stdout, "\nAuthorization URL for Production services:\n");
206 fprintf(stdout, "%s\n\n", GetAuthorizationCodeUri().c_str());
200 fprintf(stdout, "Enter an authorization code: "); 207 fprintf(stdout, "Enter an authorization code: ");
201 fflush(stdout); 208 fflush(stdout);
202 auth_code = ReadString(true); 209 auth_code = ReadString(true);
203 } 210 }
204 211
205 // Provide message loops and threads for the URLRequestContextGetter. 212 // Provide message loops and threads for the URLRequestContextGetter.
206 base::MessageLoop message_loop; 213 base::MessageLoop message_loop;
207 g_message_loop = &message_loop; 214 g_message_loop = &message_loop;
208 base::Thread::Options io_thread_options(base::MessageLoop::TYPE_IO, 0); 215 base::Thread::Options io_thread_options(base::MessageLoop::TYPE_IO, 0);
209 base::Thread io_thread("IO thread"); 216 base::Thread io_thread("IO thread");
(...skipping 28 matching lines...) Expand all
238 // IO thread. 245 // IO thread.
239 host_starter.reset(); 246 host_starter.reset();
240 url_request_context_getter = nullptr; 247 url_request_context_getter = nullptr;
241 248
242 io_thread.Stop(); 249 io_thread.Stop();
243 250
244 return g_started ? 0 : 1; 251 return g_started ? 0 : 1;
245 } 252 }
246 253
247 } // namespace remoting 254 } // namespace remoting
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