| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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. |
| (...skipping 23 matching lines...) Expand all Loading... |
| 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" |
| 36 #include "remoting/host/chromoting_host.h" | 36 #include "remoting/host/chromoting_host.h" |
| 37 #include "remoting/host/chromoting_host_context.h" | 37 #include "remoting/host/chromoting_host_context.h" |
| 38 #include "remoting/host/continue_window.h" | 38 #include "remoting/host/continue_window.h" |
| 39 #include "remoting/host/curtain.h" | 39 #include "remoting/host/curtain.h" |
| 40 #include "remoting/host/desktop_environment.h" | 40 #include "remoting/host/desktop_environment.h" |
| 41 #include "remoting/host/disconnect_window.h" | 41 #include "remoting/host/disconnect_window.h" |
| 42 #include "remoting/host/event_executor.h" | 42 #include "remoting/host/event_executor.h" |
| 43 #include "remoting/host/heartbeat_sender.h" | 43 #include "remoting/host/heartbeat_sender.h" |
| 44 #include "remoting/host/host_secret.h" |
| 44 #include "remoting/host/local_input_monitor.h" | 45 #include "remoting/host/local_input_monitor.h" |
| 45 #include "remoting/host/log_to_server.h" | 46 #include "remoting/host/log_to_server.h" |
| 46 #include "remoting/host/json_host_config.h" | 47 #include "remoting/host/json_host_config.h" |
| 47 #include "remoting/host/register_support_host_request.h" | 48 #include "remoting/host/register_support_host_request.h" |
| 48 #include "remoting/host/self_access_verifier.h" | |
| 49 #include "remoting/host/support_access_verifier.h" | |
| 50 #include "remoting/proto/video.pb.h" | 49 #include "remoting/proto/video.pb.h" |
| 51 | 50 |
| 52 #if defined(TOOLKIT_USES_GTK) | 51 #if defined(TOOLKIT_USES_GTK) |
| 53 #include "ui/gfx/gtk_util.h" | 52 #include "ui/gfx/gtk_util.h" |
| 54 #elif defined(OS_MACOSX) | 53 #elif defined(OS_MACOSX) |
| 55 #include "base/mac/scoped_nsautorelease_pool.h" | 54 #include "base/mac/scoped_nsautorelease_pool.h" |
| 56 #elif defined(OS_WIN) | 55 #elif defined(OS_WIN) |
| 57 // TODO(garykac) Make simple host into a proper GUI app on Windows so that we | 56 // TODO(garykac) Make simple host into a proper GUI app on Windows so that we |
| 58 // have an hModule for the dialog resource. | 57 // have an hModule for the dialog resource. |
| 59 HMODULE g_hModule = NULL; | 58 HMODULE g_hModule = NULL; |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 // the account. | 125 // the account. |
| 127 config->SetString(kXmppAuthServiceConfigPath, | 126 config->SetString(kXmppAuthServiceConfigPath, |
| 128 kChromotingTokenDefaultServiceName); | 127 kChromotingTokenDefaultServiceName); |
| 129 | 128 |
| 130 // Initialize AccessVerifier. | 129 // Initialize AccessVerifier. |
| 131 // TODO(jamiewalch): For the IT2Me case, the access verifier is passed to | 130 // TODO(jamiewalch): For the IT2Me case, the access verifier is passed to |
| 132 // RegisterSupportHostRequest::Init, so transferring ownership of it to the | 131 // RegisterSupportHostRequest::Init, so transferring ownership of it to the |
| 133 // ChromotingHost could cause a crash condition if SetIT2MeAccessCode is | 132 // ChromotingHost could cause a crash condition if SetIT2MeAccessCode is |
| 134 // called after the ChromotingHost is destroyed (for example, at shutdown). | 133 // called after the ChromotingHost is destroyed (for example, at shutdown). |
| 135 // Fix this. | 134 // Fix this. |
| 136 scoped_ptr<remoting::AccessVerifier> access_verifier; | |
| 137 scoped_ptr<remoting::RegisterSupportHostRequest> register_request; | 135 scoped_ptr<remoting::RegisterSupportHostRequest> register_request; |
| 138 scoped_ptr<remoting::HeartbeatSender> heartbeat_sender; | 136 scoped_ptr<remoting::HeartbeatSender> heartbeat_sender; |
| 139 scoped_ptr<remoting::LogToServer> log_to_server; | 137 scoped_ptr<remoting::LogToServer> log_to_server; |
| 140 if (is_it2me_) { | 138 if (is_it2me_) { |
| 141 scoped_ptr<remoting::SupportAccessVerifier> support_access_verifier( | |
| 142 new remoting::SupportAccessVerifier()); | |
| 143 register_request.reset(new remoting::RegisterSupportHostRequest()); | 139 register_request.reset(new remoting::RegisterSupportHostRequest()); |
| 144 if (!register_request->Init( | 140 if (!register_request->Init( |
| 145 config, base::Bind(&SimpleHost::SetIT2MeAccessCode, | 141 config, base::Bind(&SimpleHost::SetIT2MeAccessCode, |
| 146 base::Unretained(this), | 142 base::Unretained(this)))) { |
| 147 support_access_verifier.get()))) { | |
| 148 return 1; | 143 return 1; |
| 149 } | 144 } |
| 150 access_verifier.reset(support_access_verifier.release()); | |
| 151 } else { | |
| 152 scoped_ptr<remoting::SelfAccessVerifier> self_access_verifier( | |
| 153 new remoting::SelfAccessVerifier()); | |
| 154 if (!self_access_verifier->Init(config)) | |
| 155 return 1; | |
| 156 access_verifier.reset(self_access_verifier.release()); | |
| 157 } | 145 } |
| 158 log_to_server.reset(new remoting::LogToServer( | 146 log_to_server.reset(new remoting::LogToServer( |
| 159 context.network_message_loop())); | 147 context.network_message_loop())); |
| 160 | 148 |
| 161 // Construct a chromoting host. | 149 // Construct a chromoting host. |
| 162 scoped_ptr<DesktopEnvironment> desktop_environment; | 150 scoped_ptr<DesktopEnvironment> desktop_environment; |
| 163 if (fake_) { | 151 if (fake_) { |
| 164 remoting::Capturer* capturer = | 152 remoting::Capturer* capturer = |
| 165 new remoting::CapturerFake(); | 153 new remoting::CapturerFake(); |
| 166 remoting::EventExecutor* event_executor = | 154 remoting::EventExecutor* event_executor = |
| 167 remoting::EventExecutor::Create(context.desktop_message_loop(), | 155 remoting::EventExecutor::Create(context.desktop_message_loop(), |
| 168 capturer); | 156 capturer); |
| 169 remoting::Curtain* curtain = remoting::Curtain::Create(); | 157 remoting::Curtain* curtain = remoting::Curtain::Create(); |
| 170 remoting::DisconnectWindow* disconnect_window = | 158 remoting::DisconnectWindow* disconnect_window = |
| 171 remoting::DisconnectWindow::Create(); | 159 remoting::DisconnectWindow::Create(); |
| 172 remoting::ContinueWindow* continue_window = | 160 remoting::ContinueWindow* continue_window = |
| 173 remoting::ContinueWindow::Create(); | 161 remoting::ContinueWindow::Create(); |
| 174 remoting::LocalInputMonitor* local_input_monitor = | 162 remoting::LocalInputMonitor* local_input_monitor = |
| 175 remoting::LocalInputMonitor::Create(); | 163 remoting::LocalInputMonitor::Create(); |
| 176 desktop_environment.reset( | 164 desktop_environment.reset( |
| 177 new DesktopEnvironment(&context, capturer, event_executor, curtain, | 165 new DesktopEnvironment(&context, capturer, event_executor, curtain, |
| 178 disconnect_window, continue_window, | 166 disconnect_window, continue_window, |
| 179 local_input_monitor)); | 167 local_input_monitor)); |
| 180 } else { | 168 } else { |
| 181 desktop_environment.reset(DesktopEnvironment::Create(&context)); | 169 desktop_environment.reset(DesktopEnvironment::Create(&context)); |
| 182 } | 170 } |
| 183 | 171 |
| 184 host_ = ChromotingHost::Create(&context, config, desktop_environment.get(), | 172 host_ = ChromotingHost::Create( |
| 185 access_verifier.release(), false); | 173 &context, config, desktop_environment.get(), false); |
| 186 host_->set_it2me(is_it2me_); | 174 host_->set_it2me(is_it2me_); |
| 187 | 175 |
| 188 if (protocol_config_.get()) { | 176 if (protocol_config_.get()) { |
| 189 host_->set_protocol_config(protocol_config_.release()); | 177 host_->set_protocol_config(protocol_config_.release()); |
| 190 } | 178 } |
| 191 | 179 |
| 192 if (is_it2me_) { | 180 if (is_it2me_) { |
| 193 host_->AddStatusObserver(register_request.get()); | 181 host_->AddStatusObserver(register_request.get()); |
| 194 } else { | 182 } else { |
| 195 // Initialize HeartbeatSender. | 183 // Initialize HeartbeatSender. |
| (...skipping 24 matching lines...) Expand all Loading... |
| 220 } | 208 } |
| 221 void set_fake(bool fake) { fake_ = fake; } | 209 void set_fake(bool fake) { fake_ = fake; } |
| 222 void set_is_it2me(bool is_it2me) { is_it2me_ = is_it2me; } | 210 void set_is_it2me(bool is_it2me) { is_it2me_ = is_it2me; } |
| 223 void set_protocol_config(CandidateSessionConfig* protocol_config) { | 211 void set_protocol_config(CandidateSessionConfig* protocol_config) { |
| 224 protocol_config_.reset(protocol_config); | 212 protocol_config_.reset(protocol_config); |
| 225 } | 213 } |
| 226 | 214 |
| 227 private: | 215 private: |
| 228 // TODO(wez): This only needs to be a member because it needs access to the | 216 // TODO(wez): This only needs to be a member because it needs access to the |
| 229 // ChromotingHost, which has to be created after the SupportAccessVerifier. | 217 // ChromotingHost, which has to be created after the SupportAccessVerifier. |
| 230 void SetIT2MeAccessCode(remoting::SupportAccessVerifier* access_verifier, | 218 void SetIT2MeAccessCode(bool successful, const std::string& support_id, |
| 231 bool successful, const std::string& support_id, | |
| 232 const base::TimeDelta& lifetime) { | 219 const base::TimeDelta& lifetime) { |
| 233 access_verifier->OnIT2MeHostRegistered(successful, support_id); | |
| 234 if (successful) { | 220 if (successful) { |
| 235 std::string access_code = support_id + access_verifier->host_secret(); | 221 std::string host_secret = remoting::GenerateSupportHostSecret(); |
| 222 std::string access_code = support_id + host_secret; |
| 236 std::cout << "Support id: " << access_code << std::endl; | 223 std::cout << "Support id: " << access_code << std::endl; |
| 237 | 224 |
| 238 // Tell the ChromotingHost the access code, to use as shared-secret. | 225 // Tell the ChromotingHost the access code, to use as shared-secret. |
| 239 host_->set_access_code(access_code); | 226 host_->set_access_code(access_code); |
| 240 } else { | 227 } else { |
| 241 LOG(ERROR) << "If you haven't done so recently, try running" | 228 LOG(ERROR) << "If you haven't done so recently, try running" |
| 242 << " remoting/tools/register_host.py."; | 229 << " remoting/tools/register_host.py."; |
| 243 } | 230 } |
| 244 } | 231 } |
| 245 | 232 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 LOG(ERROR) << "Unknown video codec: " << video_codec; | 298 LOG(ERROR) << "Unknown video codec: " << video_codec; |
| 312 return 1; | 299 return 1; |
| 313 } | 300 } |
| 314 config->mutable_video_configs()->push_back(ChannelConfig( | 301 config->mutable_video_configs()->push_back(ChannelConfig( |
| 315 transport, remoting::protocol::kDefaultStreamVersion, codec)); | 302 transport, remoting::protocol::kDefaultStreamVersion, codec)); |
| 316 simple_host.set_protocol_config(config.release()); | 303 simple_host.set_protocol_config(config.release()); |
| 317 } | 304 } |
| 318 | 305 |
| 319 return simple_host.Run(); | 306 return simple_host.Run(); |
| 320 } | 307 } |
| OLD | NEW |