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.

200 lines
4.4 KiB

  1. //////////////////////////////////////////////////////////////////////////////
  2. /*++
  3. Copyright (C) Microsoft Corporation, 1997 - 1999
  4. Module Name:
  5. ConectionToServer.h
  6. Abstract:
  7. Header file for class which manages connection to a remote server.
  8. The connect action takes place in a worker thread.
  9. See ConnectionToServer.cpp for implementation.
  10. Revision History:
  11. mmaguire 02/09/98 - created
  12. byao 04/24/98 - Modified for NAPMMC.DLL (Remote Access Policies snap-in)
  13. --*/
  14. //////////////////////////////////////////////////////////////////////////////
  15. #if !defined(_NAP_CONNECTION_TO_SERVER_H_)
  16. #define _NAP_CONNECTION_TO_SERVER_H_
  17. //////////////////////////////////////////////////////////////////////////////
  18. // BEGIN INCLUDES
  19. //
  20. // where we can find what this class derives from:
  21. //
  22. #include "DialogWithWorkerThread.h"
  23. //
  24. //
  25. // where we can find what this class has or uses:
  26. //
  27. #include "sdoias.h"
  28. //
  29. // END INCLUDES
  30. //////////////////////////////////////////////////////////////////////////////
  31. // return value for connection
  32. #define CONNECT_NO_ERROR 0
  33. #define CONNECT_SERVER_NOT_SUPPORTED 1
  34. #define CONNECT_FAILED (-1)
  35. typedef
  36. enum _TAG_CONNECTION_STATUS
  37. {
  38. NO_CONNECTION_ATTEMPTED = 0,
  39. CONNECTING,
  40. CONNECTED,
  41. CONNECTION_ATTEMPT_FAILED,
  42. CONNECTION_INTERRUPTED,
  43. UNKNOWN
  44. } CONNECTION_STATUS;
  45. class CMachineNode;
  46. class CLoggingMachineNode;
  47. class CConnectionToServer : public CDialogWithWorkerThread<CConnectionToServer>
  48. {
  49. public:
  50. CConnectionToServer( CMachineNode *pServerNode,
  51. BSTR bstrServerAddress,
  52. BOOL fExtendingIAS );
  53. ~CConnectionToServer( void );
  54. public:
  55. // This is the ID of the dialog resource we want for this class.
  56. // An enum is used here because the correct value of
  57. // IDD must be initialized before the base class's constructor is called
  58. enum { IDD = IDD_CONNECT_TO_MACHINE };
  59. BEGIN_MSG_MAP(CConnectionToServer)
  60. MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
  61. COMMAND_ID_HANDLER( IDCANCEL, OnCancel )
  62. CHAIN_MSG_MAP(CDialogWithWorkerThread<CConnectionToServer>)
  63. END_MSG_MAP()
  64. LRESULT OnCancel(
  65. UINT uMsg
  66. , WPARAM wParam
  67. , HWND hwnd
  68. , BOOL& bHandled
  69. );
  70. LRESULT OnInitDialog(
  71. UINT uMsg
  72. , WPARAM wParam
  73. , LPARAM lParam
  74. , BOOL& bHandled
  75. );
  76. LRESULT OnReceiveThreadMessage(
  77. UINT uMsg
  78. , WPARAM wParam
  79. , LPARAM lParam
  80. , BOOL& bHandled
  81. );
  82. void CleanupMachineRelated( void )
  83. {
  84. m_pMachineNode = NULL;
  85. }
  86. CONNECTION_STATUS GetConnectionStatus( void );
  87. HRESULT GetSdoService( ISdo **ppSdo );
  88. // happening in the main thread
  89. HRESULT ReloadSdo(ISdo** ppSdoService, ISdoDictionaryOld **ppSdoDictionaryOld);
  90. HRESULT GetSdoDictionaryOld( ISdoDictionaryOld **ppSdoDictionaryOld );
  91. DWORD DoWorkerThreadAction();
  92. protected:
  93. CONNECTION_STATUS m_ConnectionStatus;
  94. // Pointer to stream into which the worker thread
  95. // this class creates will marshal the Sdo interface pointer it gets.
  96. LPSTREAM m_pStreamSdoMachineMarshal;
  97. LPSTREAM m_pStreamSdoServiceMarshal;
  98. LPSTREAM m_pStreamSdoDictionaryOldMarshal;
  99. // SDO pointers for use in the main thread's context.
  100. CComPtr<ISdo> m_spSdo;
  101. CComPtr<ISdoDictionaryOld> m_spSdoDictionaryOld;
  102. CComPtr<ISdoMachine> m_spSdoMachine;
  103. //
  104. CMachineNode* m_pMachineNode;
  105. CComBSTR m_bstrServerAddress;
  106. BOOL m_fExtendingIAS;
  107. BOOL m_fDSAvailable; // is DS avilable for this machine?
  108. // DS is only available for NT5 domain
  109. void WriteTrace(char* info, HRESULT hr)
  110. {
  111. ::CString str = info;
  112. ::CString str1;
  113. str1.Format(str, hr);
  114. TracePrintf(g_dwTraceHandle, str1);
  115. };
  116. //
  117. // local computer name.
  118. // We need this name to call ServerInfo->GetDomainInfo(), as well as showing
  119. // it in connecting message
  120. //
  121. TCHAR m_szLocalComputerName[IAS_MAX_COMPUTERNAME_LENGTH];
  122. };
  123. class CLoggingConnectionToServer : public CConnectionToServer
  124. {
  125. public:
  126. CLoggingConnectionToServer( CLoggingMachineNode * pServerNode,
  127. BSTR bstrServerAddress,
  128. BOOL fExtendingIAS );
  129. ~CLoggingConnectionToServer( void );
  130. public:
  131. BEGIN_MSG_MAP(CLoggingConnectionToServer)
  132. MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
  133. CHAIN_MSG_MAP(CConnectionToServer)
  134. END_MSG_MAP()
  135. LRESULT OnInitDialog(
  136. UINT uMsg
  137. , WPARAM wParam
  138. , LPARAM lParam
  139. , BOOL& bHandled
  140. );
  141. LRESULT OnReceiveThreadMessage(
  142. UINT uMsg
  143. , WPARAM wParam
  144. , LPARAM lParam
  145. , BOOL& bHandled
  146. );
  147. DWORD DoWorkerThreadAction();
  148. private:
  149. CLoggingMachineNode * m_pMachineNode;
  150. };
  151. #endif // _IAS_CONNECTION_TO_SERVER_H_