OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/win/rdp_client_window.h" | 5 #include "remoting/host/win/rdp_client_window.h" |
6 | 6 |
7 #include <wtsdefs.h> | 7 #include <wtsdefs.h> |
8 | 8 |
9 #include <list> | 9 #include <list> |
10 | 10 |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 // Create the child window that actually hosts the ActiveX control. | 271 // Create the child window that actually hosts the ActiveX control. |
272 RECT rect = {0, 0, screen_resolution_.dimensions().width(), | 272 RECT rect = {0, 0, screen_resolution_.dimensions().width(), |
273 screen_resolution_.dimensions().height()}; | 273 screen_resolution_.dimensions().height()}; |
274 activex_window.Create(m_hWnd, rect, nullptr, | 274 activex_window.Create(m_hWnd, rect, nullptr, |
275 WS_CHILD | WS_VISIBLE | WS_BORDER); | 275 WS_CHILD | WS_VISIBLE | WS_BORDER); |
276 if (activex_window.m_hWnd == nullptr) | 276 if (activex_window.m_hWnd == nullptr) |
277 return LogOnCreateError(HRESULT_FROM_WIN32(GetLastError())); | 277 return LogOnCreateError(HRESULT_FROM_WIN32(GetLastError())); |
278 | 278 |
279 // Instantiate the RDP ActiveX control. | 279 // Instantiate the RDP ActiveX control. |
280 result = activex_window.CreateControlEx( | 280 result = activex_window.CreateControlEx( |
281 OLESTR("MsTscAx.MsTscAx"), | 281 OLESTR("MsTscAx.MsTscAx"), nullptr, nullptr, control.GetAddressOf(), |
282 nullptr, | |
283 nullptr, | |
284 control.Receive(), | |
285 __uuidof(mstsc::IMsTscAxEvents), | 282 __uuidof(mstsc::IMsTscAxEvents), |
286 reinterpret_cast<IUnknown*>(static_cast<RdpEventsSink*>(this))); | 283 reinterpret_cast<IUnknown*>(static_cast<RdpEventsSink*>(this))); |
287 if (FAILED(result)) | 284 if (FAILED(result)) |
288 return LogOnCreateError(result); | 285 return LogOnCreateError(result); |
289 | 286 |
290 result = control.CopyTo(client_.Receive()); | 287 result = control.CopyTo(client_.GetAddressOf()); |
291 if (FAILED(result)) | 288 if (FAILED(result)) |
292 return LogOnCreateError(result); | 289 return LogOnCreateError(result); |
293 | 290 |
294 // Use 32-bit color. | 291 // Use 32-bit color. |
295 result = client_->put_ColorDepth(32); | 292 result = client_->put_ColorDepth(32); |
296 if (FAILED(result)) | 293 if (FAILED(result)) |
297 return LogOnCreateError(result); | 294 return LogOnCreateError(result); |
298 | 295 |
299 // Set dimensions of the remote desktop. | 296 // Set dimensions of the remote desktop. |
300 result = client_->put_DesktopWidth(screen_resolution_.dimensions().width()); | 297 result = client_->put_DesktopWidth(screen_resolution_.dimensions().width()); |
301 if (FAILED(result)) | 298 if (FAILED(result)) |
302 return LogOnCreateError(result); | 299 return LogOnCreateError(result); |
303 result = client_->put_DesktopHeight(screen_resolution_.dimensions().height()); | 300 result = client_->put_DesktopHeight(screen_resolution_.dimensions().height()); |
304 if (FAILED(result)) | 301 if (FAILED(result)) |
305 return LogOnCreateError(result); | 302 return LogOnCreateError(result); |
306 | 303 |
307 // Check to see if the platform exposes the interface used for resizing. | 304 // Check to see if the platform exposes the interface used for resizing. |
308 result = client_.CopyTo(client_9_.Receive()); | 305 result = client_.CopyTo(client_9_.GetAddressOf()); |
309 if (FAILED(result) && result != E_NOINTERFACE) { | 306 if (FAILED(result) && result != E_NOINTERFACE) { |
310 return LogOnCreateError(result); | 307 return LogOnCreateError(result); |
311 } | 308 } |
312 | 309 |
313 // Set the server name to connect to. | 310 // Set the server name to connect to. |
314 result = client_->put_Server(server_name); | 311 result = client_->put_Server(server_name); |
315 if (FAILED(result)) | 312 if (FAILED(result)) |
316 return LogOnCreateError(result); | 313 return LogOnCreateError(result); |
317 | 314 |
318 // Fetch IMsRdpClientAdvancedSettings interface for the client. | 315 // Fetch IMsRdpClientAdvancedSettings interface for the client. |
319 result = client_->get_AdvancedSettings2(client_settings_.Receive()); | 316 result = client_->get_AdvancedSettings2(client_settings_.GetAddressOf()); |
320 if (FAILED(result)) | 317 if (FAILED(result)) |
321 return LogOnCreateError(result); | 318 return LogOnCreateError(result); |
322 | 319 |
323 // Disable background input mode. | 320 // Disable background input mode. |
324 result = client_settings_->put_allowBackgroundInput(0); | 321 result = client_settings_->put_allowBackgroundInput(0); |
325 if (FAILED(result)) | 322 if (FAILED(result)) |
326 return LogOnCreateError(result); | 323 return LogOnCreateError(result); |
327 | 324 |
328 // Do not use bitmap cache. | 325 // Do not use bitmap cache. |
329 result = client_settings_->put_BitmapPersistence(0); | 326 result = client_settings_->put_BitmapPersistence(0); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
363 WTS_PERF_ENABLE_DESKTOP_COMPOSITION; | 360 WTS_PERF_ENABLE_DESKTOP_COMPOSITION; |
364 result = client_settings_->put_PerformanceFlags(kDesiredFlags); | 361 result = client_settings_->put_PerformanceFlags(kDesiredFlags); |
365 if (FAILED(result)) | 362 if (FAILED(result)) |
366 return LogOnCreateError(result); | 363 return LogOnCreateError(result); |
367 | 364 |
368 // Set the port to connect to. | 365 // Set the port to connect to. |
369 result = client_settings_->put_RDPPort(server_endpoint_.port()); | 366 result = client_settings_->put_RDPPort(server_endpoint_.port()); |
370 if (FAILED(result)) | 367 if (FAILED(result)) |
371 return LogOnCreateError(result); | 368 return LogOnCreateError(result); |
372 | 369 |
373 result = client_->get_SecuredSettings2(secured_settings2.Receive()); | 370 result = client_->get_SecuredSettings2(secured_settings2.GetAddressOf()); |
374 if (SUCCEEDED(result)) { | 371 if (SUCCEEDED(result)) { |
375 result = | 372 result = |
376 secured_settings2->put_AudioRedirectionMode(kRdpAudioModeRedirect); | 373 secured_settings2->put_AudioRedirectionMode(kRdpAudioModeRedirect); |
377 if (FAILED(result)) | 374 if (FAILED(result)) |
378 return LogOnCreateError(result); | 375 return LogOnCreateError(result); |
379 } | 376 } |
380 | 377 |
381 result = client_->get_SecuredSettings(secured_settings.Receive()); | 378 result = client_->get_SecuredSettings(secured_settings.GetAddressOf()); |
382 if (FAILED(result)) | 379 if (FAILED(result)) |
383 return LogOnCreateError(result); | 380 return LogOnCreateError(result); |
384 | 381 |
385 // Set the terminal ID as the working directory for the initial program. It is | 382 // Set the terminal ID as the working directory for the initial program. It is |
386 // observed that |WorkDir| is used only if an initial program is also | 383 // observed that |WorkDir| is used only if an initial program is also |
387 // specified, but is still passed to the RDP server and can then be read back | 384 // specified, but is still passed to the RDP server and can then be read back |
388 // from the session parameters. This makes it possible to use |WorkDir| to | 385 // from the session parameters. This makes it possible to use |WorkDir| to |
389 // match the RDP connection with the session it is attached to. | 386 // match the RDP connection with the session it is attached to. |
390 // | 387 // |
391 // This code should be in sync with WtsTerminalMonitor::LookupTerminalId(). | 388 // This code should be in sync with WtsTerminalMonitor::LookupTerminalId(). |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
462 | 459 |
463 // Get the extended disconnect reason code. | 460 // Get the extended disconnect reason code. |
464 mstsc::ExtendedDisconnectReasonCode extended_code; | 461 mstsc::ExtendedDisconnectReasonCode extended_code; |
465 HRESULT result = client_->get_ExtendedDisconnectReason(&extended_code); | 462 HRESULT result = client_->get_ExtendedDisconnectReason(&extended_code); |
466 if (FAILED(result)) | 463 if (FAILED(result)) |
467 extended_code = mstsc::exDiscReasonNoInfo; | 464 extended_code = mstsc::exDiscReasonNoInfo; |
468 | 465 |
469 // Get the error message as well. | 466 // Get the error message as well. |
470 base::win::ScopedBstr error_message; | 467 base::win::ScopedBstr error_message; |
471 base::win::ScopedComPtr<mstsc::IMsRdpClient5> client5; | 468 base::win::ScopedComPtr<mstsc::IMsRdpClient5> client5; |
472 result = client_.CopyTo(client5.Receive()); | 469 result = client_.CopyTo(client5.GetAddressOf()); |
473 if (SUCCEEDED(result)) { | 470 if (SUCCEEDED(result)) { |
474 result = client5->GetErrorDescription(reason, extended_code, | 471 result = client5->GetErrorDescription(reason, extended_code, |
475 error_message.Receive()); | 472 error_message.Receive()); |
476 if (FAILED(result)) | 473 if (FAILED(result)) |
477 error_message.Reset(); | 474 error_message.Reset(); |
478 } | 475 } |
479 | 476 |
480 LOG(ERROR) << "RDP: disconnected from " << server_endpoint_.ToString() | 477 LOG(ERROR) << "RDP: disconnected from " << server_endpoint_.ToString() |
481 << ": " << error_message << " (reason=" << reason | 478 << ": " << error_message << " (reason=" << reason |
482 << ", extended_code=" << extended_code << ")"; | 479 << ", extended_code=" << extended_code << ")"; |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
609 } | 606 } |
610 | 607 |
611 // Close the window once all pending window messages are processed. | 608 // Close the window once all pending window messages are processed. |
612 HWND window = reinterpret_cast<HWND>(wparam); | 609 HWND window = reinterpret_cast<HWND>(wparam); |
613 LOG(WARNING) << "RDP: closing a window: " << std::hex << window; | 610 LOG(WARNING) << "RDP: closing a window: " << std::hex << window; |
614 ::PostMessage(window, WM_CLOSE, 0, 0); | 611 ::PostMessage(window, WM_CLOSE, 0, 0); |
615 return 0; | 612 return 0; |
616 } | 613 } |
617 | 614 |
618 } // namespace remoting | 615 } // namespace remoting |
OLD | NEW |