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 // This is an application of a minimal host process in a Chromoting | 5 // This is an application of a minimal host process in a Chromoting |
6 // system. It serves the purpose of gluing different pieces together | 6 // system. It serves the purpose of gluing different pieces together |
7 // to make a functional host process for testing. | 7 // to make a functional host process for testing. |
8 // | 8 // |
9 // It peforms the following functionality: | 9 // It peforms the following functionality: |
10 // 1. Connect to the GTalk network and register the machine as a host. | 10 // 1. Connect to the GTalk network and register the machine as a host. |
11 // 2. Accepts connection through libjingle. | 11 // 2. Accepts connection through libjingle. |
12 // 3. Receive mouse / keyboard events through libjingle. | 12 // 3. Receive mouse / keyboard events through libjingle. |
13 // 4. Sends screen capture through libjingle. | 13 // 4. Sends screen capture through libjingle. |
14 | 14 |
15 #include <iostream> | 15 #include <iostream> |
16 #include <string> | 16 #include <string> |
17 | 17 |
18 #include "build/build_config.h" | 18 #include "build/build_config.h" |
19 | 19 |
20 #include "base/at_exit.h" | 20 #include "base/at_exit.h" |
21 #include "base/bind.h" | 21 #include "base/bind.h" |
22 #include "base/callback.h" | 22 #include "base/callback.h" |
23 #include "base/command_line.h" | 23 #include "base/command_line.h" |
24 #include "base/environment.h" | |
25 #include "base/file_path.h" | 24 #include "base/file_path.h" |
25 #include "base/file_util.h" | |
26 #include "base/logging.h" | 26 #include "base/logging.h" |
27 #include "base/message_loop.h" | 27 #include "base/message_loop.h" |
28 #include "base/path_service.h" | 28 #include "base/path_service.h" |
29 #include "base/string_number_conversions.h" | 29 #include "base/string_number_conversions.h" |
30 #include "base/utf_string_conversions.h" | 30 #include "base/utf_string_conversions.h" |
31 #include "base/threading/thread.h" | 31 #include "base/threading/thread.h" |
32 #include "crypto/nss_util.h" | 32 #include "crypto/nss_util.h" |
33 #include "net/base/network_change_notifier.h" | 33 #include "net/base/network_change_notifier.h" |
34 #include "remoting/base/constants.h" | 34 #include "remoting/base/constants.h" |
35 #include "remoting/host/capturer_fake.h" | 35 #include "remoting/host/capturer_fake.h" |
(...skipping 26 matching lines...) Expand all Loading... | |
62 | 62 |
63 using remoting::protocol::CandidateSessionConfig; | 63 using remoting::protocol::CandidateSessionConfig; |
64 using remoting::protocol::ChannelConfig; | 64 using remoting::protocol::ChannelConfig; |
65 using remoting::protocol::NetworkSettings; | 65 using remoting::protocol::NetworkSettings; |
66 | 66 |
67 namespace { | 67 namespace { |
68 | 68 |
69 const FilePath::CharType kDefaultConfigPath[] = | 69 const FilePath::CharType kDefaultConfigPath[] = |
70 FILE_PATH_LITERAL(".ChromotingConfig.json"); | 70 FILE_PATH_LITERAL(".ChromotingConfig.json"); |
71 | 71 |
72 const char kHomeDrive[] = "HOMEDRIVE"; | |
73 const char kHomePath[] = "HOMEPATH"; | |
74 | |
75 const char kFakeSwitchName[] = "fake"; | 72 const char kFakeSwitchName[] = "fake"; |
76 const char kIT2MeSwitchName[] = "it2me"; | 73 const char kIT2MeSwitchName[] = "it2me"; |
77 const char kConfigSwitchName[] = "config"; | 74 const char kConfigSwitchName[] = "config"; |
78 const char kVideoSwitchName[] = "video"; | 75 const char kVideoSwitchName[] = "video"; |
79 const char kDisableNatTraversalSwitchName[] = "disable-nat-traversal"; | 76 const char kDisableNatTraversalSwitchName[] = "disable-nat-traversal"; |
80 const char kMinPortSwitchName[] = "min-port"; | 77 const char kMinPortSwitchName[] = "min-port"; |
81 const char kMaxPortSwitchName[] = "max-port"; | 78 const char kMaxPortSwitchName[] = "max-port"; |
82 | 79 |
83 const char kVideoSwitchValueVerbatim[] = "verbatim"; | 80 const char kVideoSwitchValueVerbatim[] = "verbatim"; |
84 const char kVideoSwitchValueZip[] = "zip"; | 81 const char kVideoSwitchValueZip[] = "zip"; |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
184 } else { | 181 } else { |
185 LOG(ERROR) << "If you haven't done so recently, try running" | 182 LOG(ERROR) << "If you haven't done so recently, try running" |
186 << " remoting/tools/register_host.py."; | 183 << " remoting/tools/register_host.py."; |
187 } | 184 } |
188 } | 185 } |
189 | 186 |
190 FilePath GetConfigPath() { | 187 FilePath GetConfigPath() { |
191 if (!config_path_.empty()) | 188 if (!config_path_.empty()) |
192 return config_path_; | 189 return config_path_; |
193 | 190 |
194 scoped_ptr<base::Environment> env(base::Environment::Create()); | 191 FilePath config_path; |
195 | 192 |
196 #if defined(OS_WIN) | 193 #if defined(OS_WIN) |
197 std::string home_drive; | 194 PathService::Get(base::DIR_PROFILE, &config_path); |
Wez
2012/03/01 18:03:06
This change moves the config from the home directo
Jamie
2012/03/01 18:22:32
Better still, unless that change is required for t
alexeypa (please no reviews)
2012/03/01 20:33:58
This change does not change the location. There is
Wez
2012/03/01 21:11:36
The home-grown code was using HOMEDRIVE and HOMEPA
alexeypa (please no reviews)
2012/03/01 22:32:41
Yes, I saw that. They can only be different if you
Wez
2012/03/01 22:46:30
Nope. The home directory and profile directory ca
| |
198 env->GetVar(kHomeDrive, &home_drive); | |
199 std::string home_path; | |
200 env->GetVar(kHomePath, &home_path); | |
201 return FilePath(UTF8ToWide(home_drive)) | |
202 .Append(UTF8ToWide(home_path)) | |
203 .Append(kDefaultConfigPath); | |
204 #else | 195 #else |
205 std::string home_path; | 196 config_path = file_util::GetHomeDir(); |
206 env->GetVar(base::env_vars::kHome, &home_path); | |
207 return FilePath(home_path).Append(kDefaultConfigPath); | |
208 #endif | 197 #endif |
198 | |
199 return config_path.Append(kDefaultConfigPath); | |
209 } | 200 } |
210 | 201 |
211 void StartHost() { | 202 void StartHost() { |
212 signal_strategy_.reset( | 203 signal_strategy_.reset( |
213 new XmppSignalStrategy(context_.jingle_thread(), xmpp_login_, | 204 new XmppSignalStrategy(context_.jingle_thread(), xmpp_login_, |
214 xmpp_auth_token_, xmpp_auth_service_)); | 205 xmpp_auth_token_, xmpp_auth_service_)); |
215 signaling_connector_.reset(new SignalingConnector(signal_strategy_.get())); | 206 signaling_connector_.reset(new SignalingConnector(signal_strategy_.get())); |
216 | 207 |
217 if (fake_) { | 208 if (fake_) { |
218 Capturer* capturer = new CapturerFake(); | 209 Capturer* capturer = new CapturerFake(); |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
368 max_port < 0 || max_port > 65535) { | 359 max_port < 0 || max_port > 65535) { |
369 LOG(ERROR) << "Invalid max-port value: " << max_port | 360 LOG(ERROR) << "Invalid max-port value: " << max_port |
370 << ". Expected integer in range [0, 65535]."; | 361 << ". Expected integer in range [0, 65535]."; |
371 return 1; | 362 return 1; |
372 } | 363 } |
373 simple_host.network_settings()->max_port = max_port; | 364 simple_host.network_settings()->max_port = max_port; |
374 } | 365 } |
375 | 366 |
376 return simple_host.Run(); | 367 return simple_host.Run(); |
377 } | 368 } |
OLD | NEW |