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.

322 lines
8.0 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows/NT **/
  3. /** Copyright(c) Microsoft Corporation, 1997 - 1999 **/
  4. /**********************************************************************/
  5. /*
  6. server.h
  7. WINS server node information.
  8. FILE HISTORY:
  9. */
  10. #ifndef _SERVER_H
  11. #define _SERVER_H
  12. #ifndef _WINSHAND_H
  13. #include "winshand.h"
  14. #endif
  15. #ifndef _CONFIG_H
  16. #include "config.h"
  17. #endif
  18. #ifndef _SVRSTATS_H
  19. #include "svrstats.h"
  20. #endif
  21. #ifndef _TASK_H
  22. #include <task.h>
  23. #endif
  24. #ifndef _WINSMON_H
  25. #include "winsmon.h"
  26. #endif
  27. class CServerStatsFrame;
  28. #define WINS_QDATA_SERVER_INFO 0x00000001
  29. #define WINS_SERVER_FLAGS_DEFAULT FLAG_LANMAN_COMPATIBLE | FLAG_STATUS_BAR | FLAG_AUTO_REFRESH
  30. #define WINS_SERVER_REFRESH_DEFAULT 600
  31. // this structure contains all of the info the background thread enumerates about
  32. // the server and posts to the main thread
  33. class CServerData
  34. {
  35. public:
  36. CString m_strServerName;
  37. DWORD m_dwServerIp;
  38. CConfiguration m_config;
  39. handle_t m_hBinding;
  40. };
  41. /*---------------------------------------------------------------------------
  42. Class: CNameCacheEntry
  43. ---------------------------------------------------------------------------*/
  44. class CNameCacheEntry
  45. {
  46. public:
  47. DWORD m_dwIp;
  48. CString m_strName;
  49. CTime m_timeLastUpdate;
  50. };
  51. typedef CArray<CNameCacheEntry, CNameCacheEntry&> CNameCache;
  52. /*---------------------------------------------------------------------------
  53. Class: CNameThread
  54. ---------------------------------------------------------------------------*/
  55. class CNameThread : public CWinThread
  56. {
  57. public:
  58. CNameThread();
  59. ~CNameThread();
  60. public:
  61. void Init(CServerInfoArray * pServerInfoArray);
  62. BOOL Start();
  63. void Abort(BOOL fAutoDelete = TRUE);
  64. void AbortAndWait();
  65. BOOL FCheckForAbort();
  66. BOOL IsRunning();
  67. void UpdateNameCache();
  68. BOOL GetNameFromCache(DWORD dwIp, CString & strName);
  69. virtual BOOL InitInstance() { return TRUE; } // MFC override
  70. virtual int Run();
  71. private:
  72. HANDLE m_hEventHandle;
  73. CServerInfoArray * m_pServerInfoArray;
  74. };
  75. /*---------------------------------------------------------------------------
  76. Class: CWinsServerHandler
  77. ---------------------------------------------------------------------------*/
  78. class CWinsServerHandler : public CMTWinsHandler//public CWinsHandler
  79. {
  80. public:
  81. CWinsServerHandler(ITFSComponentData* pTFSComponentData,
  82. LPCWSTR pServerName = NULL,
  83. BOOL fConnected = TRUE,
  84. DWORD dwIP = 0,
  85. DWORD dwFlags = WINS_SERVER_FLAGS_DEFAULT,
  86. DWORD dwRefreshInterval = WINS_SERVER_REFRESH_DEFAULT);
  87. ~CWinsServerHandler();
  88. // Interface
  89. public:
  90. // base handler functionality we override
  91. OVERRIDE_NodeHandler_HasPropertyPages();
  92. OVERRIDE_NodeHandler_CreatePropertyPages();
  93. OVERRIDE_NodeHandler_OnAddMenuItems();
  94. OVERRIDE_NodeHandler_OnCommand();
  95. OVERRIDE_NodeHandler_GetString()
  96. {
  97. if(nCol == 0 || nCol == -1)
  98. return GetDisplayName();
  99. else if(nCol == 1)
  100. return m_strConnected;
  101. else
  102. return NULL;
  103. }
  104. OVERRIDE_BaseHandlerNotify_OnCreateNodeId2();
  105. // Result handler functionality we override
  106. OVERRIDE_BaseHandlerNotify_OnDelete();
  107. OVERRIDE_BaseResultHandlerNotify_OnResultRefresh();
  108. virtual DWORD UpdateStatistics(ITFSNode * pNode);
  109. HRESULT LoadColumns(ITFSComponent * pComponent, MMC_COOKIE cookie, LPARAM arg, LPARAM lParam);
  110. OVERRIDE_ResultHandler_AddMenuItems();
  111. OVERRIDE_ResultHandler_Command();
  112. public:
  113. // CMTWinsHandler functionality
  114. ITFSQueryObject* OnCreateQuery(ITFSNode * pNode);
  115. virtual void GetErrorInfo(CString & strTitle, CString & strBody, IconIdentifier * pIcon);
  116. // implementation
  117. BOOL GetConnected()
  118. {
  119. return m_fConnected;
  120. };
  121. const CString& GetServerAddress()
  122. {
  123. return m_strServerAddress;
  124. }
  125. const DWORD GetServerIP()
  126. {
  127. return m_dwIPAdd;
  128. }
  129. void SetServerIP(DWORD dwIPAdd)
  130. {
  131. m_dwIPAdd = dwIPAdd;
  132. }
  133. HRESULT GetActiveRegNode(ITFSNode ** ppNode)
  134. {
  135. Assert(ppNode);
  136. SetI((LPUNKNOWN *) ppNode, m_spActiveReg);
  137. return hrOK;
  138. }
  139. CConfiguration& GetConfig()
  140. {
  141. return m_cConfig;
  142. }
  143. void SetConfig(CConfiguration & configNew)
  144. {
  145. m_cConfig = configNew;
  146. }
  147. DWORD GetStatus()
  148. {
  149. return m_dwStatus;
  150. }
  151. handle_t GetBinding()
  152. {
  153. return m_hBinding;
  154. }
  155. DWORD GetFlags()
  156. {
  157. return m_dwFlags;
  158. }
  159. DWORD GetStatsRefreshInterval()
  160. {
  161. return m_dwRefreshInterval;
  162. }
  163. BOOL IsLocalConnection();
  164. virtual HRESULT InitializeNode(ITFSNode * pNode);
  165. virtual int GetImageIndex(BOOL bOpenImage);
  166. virtual void OnHaveData(ITFSNode * pParentNode, ITFSNode * pNode);
  167. virtual void OnHaveData(ITFSNode * pParentNode, LPARAM Data, LPARAM Type);
  168. OVERRIDE_BaseHandlerNotify_OnPropertyChange();
  169. DWORD ConnectToWinsServer(ITFSNode *pNode);
  170. BOOL IsValidNetBIOSName(CString & strAddress,
  171. BOOL fLanmanCompatible,
  172. BOOL fWackwack // expand slashes if not present
  173. );
  174. DWORD GetStatistics(ITFSNode * pNode, PWINSINTF_RESULTS_T * ppStats);
  175. DWORD ClearStatistics(ITFSNode *pNode);
  176. // for the owner dilaog
  177. DWORD GetOwnerConfig(PWINSINTF_RESULTS_NEW_T pResults, CString strIP);
  178. DWORD DeleteWinsServer(DWORD dwIpAddress);
  179. BOOL CheckIfNT351Server();
  180. void SetExtensionName();
  181. void SetDisplay(ITFSNode * pNode, BOOL fFQDN);
  182. public:
  183. // holds both the server name and the IP Address
  184. CString m_strServerAddress;
  185. // stores whether the server is connected to or not
  186. CString m_strConnected;
  187. // holds the IP Address of the server
  188. DWORD m_dwIPAdd;
  189. // holds the monitoring IP address, case whrwe the server is not yet connected
  190. // so IP not known.
  191. DWORD m_dwIPMon;
  192. char szIPMon[MAX_PATH];
  193. // to be made persistent, those in the Preferences dialog
  194. // of the admin tool
  195. DWORD m_dwFlags;
  196. DWORD m_dwRefreshInterval;
  197. // monitoring stuff
  198. DWORD m_dwMsgCount;
  199. char m_szNameToQry[STR_BUF_SIZE]; // the name to use in the queries
  200. char m_nbtFrameBuf[MAX_NBT_PACKET_SIZE]; // buffer to store the NetBT frame
  201. WINSINTF_RESULTS_T m_wrResults;
  202. CServerStatsFrame m_dlgStats;
  203. CString m_strTaskpadTitle;
  204. // Owner info array
  205. CServerInfoArray m_ServerInfoArray;
  206. // Implementation
  207. private:
  208. // helper functions
  209. HRESULT ShowServerStatDialog(ITFSNode* pNode);
  210. // Task menu for the server
  211. HRESULT DoDBBackup(ITFSNode * pNode);
  212. HRESULT DoDBCompact(ITFSNode * pNode);
  213. HRESULT DoDBRestore(ITFSNode * pNode);
  214. HRESULT DoDBScavenge(ITFSNode * pNode);
  215. HRESULT OnDoConsistencyCheck(ITFSNode * pNode);
  216. HRESULT OnDoVersionConsistencyCheck(ITFSNode * pNode);
  217. HRESULT OnSendPushTrigger(ITFSNode * pNode);
  218. HRESULT OnSendPullTrigger(ITFSNode * pNode);
  219. HRESULT OnControlService(ITFSNode * pNode, BOOL fStart);
  220. HRESULT OnPauseResumeService(ITFSNode * pNode, BOOL fPause);
  221. HRESULT OnRestartService(ITFSNode * pNode);
  222. // Helpers
  223. DWORD BackupDatabase(CString strBackupPath);
  224. BOOL GetFolderName(CString & strPath, CString & strHelpText);
  225. void DisConnectFromWinsServer();
  226. // used for compacting the DB
  227. DWORD RunApp(LPCTSTR input, LPCTSTR startingDirectory, LPSTR * output);
  228. private:
  229. SPITFSNode m_spActiveReg;
  230. SPITFSNode m_spReplicationPartner;
  231. CConfiguration m_cConfig;
  232. handle_t m_hBinding;
  233. DWORD m_dwStatus;
  234. BOOL m_fConnected;
  235. BOOL m_bExtension;
  236. CNameThread * m_pNameThread;
  237. };
  238. /*---------------------------------------------------------------------------
  239. Class: CWinsServerQueryObj
  240. ---------------------------------------------------------------------------*/
  241. class CWinsServerQueryObj : public CWinsQueryObj
  242. {
  243. public:
  244. CWinsServerQueryObj(ITFSComponentData * pTFSComponentData,
  245. ITFSNodeMgr * pNodeMgr)
  246. : CWinsQueryObj(pTFSComponentData, pNodeMgr) {};
  247. STDMETHODIMP Execute();
  248. virtual void OnEventAbort(DWORD dwData, DWORD dwType);
  249. void AddNodes(handle_t handle);
  250. public:
  251. CNameThread * m_pNameThread;
  252. CServerInfoArray * m_pServerInfoArray;
  253. DWORD m_dwIPAdd;
  254. };
  255. #endif _SERVER_H