Leaked source code of windows server 2003
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.

137 lines
2.3 KiB

  1. // SAFRemoteDesktopManager.cpp : Implementation of CSAFRemoteDesktopManager
  2. #include "stdafx.h"
  3. #include "SAFrdm.h"
  4. #include "SAFRemoteDesktopManager.h"
  5. #define MODULE_NAME L"SAFrdm"
  6. /////////////////////////////////////////////////////////////////////////////
  7. // CSAFRemoteDesktopManager
  8. STDMETHODIMP CSAFRemoteDesktopManager::Accepted()
  9. {
  10. HRESULT hr=E_FAIL;
  11. if (m_boolConnectionValid)
  12. {
  13. /*
  14. * Place our WTS Session ID in the registry
  15. */
  16. m_hkSession.SetValue(m_bstrSessionEnum, L"RCSession");
  17. /*
  18. * Then we signal the session resolver
  19. */
  20. SignalResolver();
  21. hr = S_OK;
  22. }
  23. return hr;
  24. }
  25. STDMETHODIMP CSAFRemoteDesktopManager::Rejected()
  26. {
  27. HRESULT hr=E_FAIL;
  28. if (m_boolConnectionValid)
  29. {
  30. /*
  31. * Mark our response in the registry
  32. */
  33. m_hkSession.SetValue(L"NO", L"RCSession");
  34. /*
  35. * Then we signal the session resolver
  36. */
  37. SignalResolver();
  38. hr = S_OK;
  39. }
  40. return hr;
  41. }
  42. STDMETHODIMP CSAFRemoteDesktopManager::Aborted(BSTR reason)
  43. {
  44. HRESULT hr=E_FAIL;
  45. if (m_boolConnectionValid)
  46. {
  47. /*
  48. * Mark our response in the registry
  49. */
  50. m_hkSession.SetValue(L"NO", L"RCSession");
  51. /*
  52. * Write out an NT Event with the "reason" in it.
  53. */
  54. HANDLE hEvent = RegisterEventSource(NULL, MODULE_NAME);
  55. LPCWSTR ArgsArray[1]={reason};
  56. if (hEvent)
  57. {
  58. ReportEvent(hEvent, EVENTLOG_INFORMATION_TYPE,
  59. 0,
  60. SAFRDM_I_ABORT,
  61. NULL,
  62. 1,
  63. 0,
  64. ArgsArray,
  65. NULL);
  66. DeregisterEventSource(hEvent);
  67. }
  68. /*
  69. * Then we signal the session resolver
  70. */
  71. SignalResolver();
  72. hr = S_OK;
  73. }
  74. return hr;
  75. }
  76. STDMETHODIMP CSAFRemoteDesktopManager::get_RCTicket(BSTR *pVal)
  77. {
  78. if (!pVal)
  79. return E_INVALIDARG;
  80. *pVal = m_bstrRCTicket.Copy();
  81. return S_OK;
  82. }
  83. STDMETHODIMP CSAFRemoteDesktopManager::get_DesktopUnknown(BOOL *pVal)
  84. {
  85. if (!pVal)
  86. return E_INVALIDARG;
  87. *pVal = m_boolDesktopUnknown;
  88. return S_OK;
  89. }
  90. STDMETHODIMP CSAFRemoteDesktopManager::get_SupportEngineer(BSTR *pVal)
  91. {
  92. if (!pVal)
  93. return E_INVALIDARG;
  94. *pVal = m_bstrSupportEngineer.Copy();
  95. return S_OK;
  96. }
  97. void CSAFRemoteDesktopManager::SignalResolver()
  98. {
  99. HANDLE hEvent = OpenEvent(EVENT_MODIFY_STATE, FALSE, m_bstrEventName);
  100. if (hEvent)
  101. {
  102. SetEvent(hEvent);
  103. CloseHandle(hEvent);
  104. }
  105. }