Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

166 lines
2.9 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. RemoteDesktopClientEventSink
  5. Abstract:
  6. This listens to the events from the IRemoteDesktopClient so
  7. we can find out when the server connects.
  8. Author:
  9. Marc Reyhner 7/11/2000
  10. --*/
  11. #include "stdafx.h"
  12. #ifdef TRC_FILE
  13. #undef TRC_FILE
  14. #endif
  15. #define TRC_FILE "rcrdces"
  16. #include "rcontrol.h"
  17. #include "RemoteDesktopClientSession.h"
  18. #include "RemoteDesktopClientEventSink.h"
  19. #include "Resource.h"
  20. CRemoteDesktopClientEventSink::CRemoteDesktopClientEventSink(
  21. IN OUT CRemoteDesktopClientSession *obj
  22. )
  23. /*++
  24. Routine Description:
  25. Create a new event sink and save the pointer back to the
  26. CRemoteDesktopClientSession we are monitoring.
  27. Arguments:
  28. obj - The CRemoteDesktopClientSession we are monitoring events for
  29. Return Value:
  30. None
  31. --*/
  32. {
  33. DC_BEGIN_FN("CRemoteDesktopClientEventSink::CRemoteDesktopClientEventSink");
  34. m_Obj = obj;
  35. DC_END_FN();
  36. }
  37. VOID __stdcall
  38. CRemoteDesktopClientEventSink::OnConnected(
  39. )
  40. /*++
  41. Routine Description:
  42. We are connected to the server so we want to remote control the desktop.
  43. Arguments:
  44. None
  45. Return Value:
  46. None
  47. --*/
  48. {
  49. DC_BEGIN_FN("CRemoteDesktopClientEventSink::OnConnected");
  50. m_Obj->ConnectRemoteDesktop();
  51. DC_END_FN();
  52. }
  53. VOID __stdcall
  54. CRemoteDesktopClientEventSink::OnDisconnected(
  55. IN LONG reason
  56. )
  57. /*++
  58. Routine Description:
  59. We've been disconnected. We currently don't do
  60. anything here.
  61. Arguments:
  62. reason - Why we were disconnected.
  63. Return Value:
  64. None
  65. --*/
  66. {
  67. TCHAR dlgTitle[MAX_STR_LEN];
  68. TCHAR dlgText[MAX_STR_LEN];
  69. DC_BEGIN_FN("CRemoteDesktopClientEventSink::OnDisconnected");
  70. if (reason != S_OK) {
  71. TRC_ERR((TB,TEXT("We were disconnected with code 0x%0X"),reason));
  72. }
  73. LoadStringSimple(IDS_CLIENTREMOTEDISCONNECT,dlgText);
  74. LoadStringSimple(IDS_CLIENTWNDTITLE,dlgTitle);
  75. MessageBox(m_Obj->m_hWnd,dlgText,dlgTitle,MB_OK);
  76. DestroyWindow(m_Obj->m_hWnd);
  77. DC_END_FN();
  78. }
  79. VOID __stdcall
  80. CRemoteDesktopClientEventSink::OnRemoteControlRequestComplete(
  81. IN LONG status
  82. )
  83. /*++
  84. Routine Description:
  85. This never gets called so we can't do anything here.
  86. Arguments:
  87. status - The status of our request.
  88. Return Value:
  89. None
  90. --*/
  91. {
  92. TCHAR dlgTitle[MAX_STR_LEN];
  93. TCHAR dlgText[MAX_STR_LEN];
  94. DC_BEGIN_FN("CRemoteDesktopClientEventSink::OnRemoteControlRequestComplete");
  95. if (status != S_OK) {
  96. TRC_ERR((TB,TEXT("Remote control failed with code 0x%0X"),status));
  97. LoadStringSimple(IDS_CLIENTWNDTITLE,dlgTitle);
  98. LoadStringSimple(IDS_CLIENTREMOTEFAIL,dlgText);
  99. MessageBox(m_Obj->m_hWnd,dlgText,dlgTitle,MB_OK|MB_ICONWARNING);
  100. DestroyWindow(m_Obj->m_hWnd);
  101. } else {
  102. // this isn't getting called but it should be.
  103. m_Obj->m_ApprovalDlg.DestroyDialog();
  104. }
  105. DC_END_FN();
  106. }