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.

335 lines
11 KiB

  1. /*******************************************************************************
  2. *
  3. * admindoc.h
  4. *
  5. * interface of the CWinAdminDoc class
  6. *
  7. * copyright notice: Copyright 1997, Citrix Systems Inc.
  8. * Copyright (c) 1998 - 1999 Microsoft Corporation
  9. *
  10. * $Author: donm $ Don Messerli
  11. *
  12. * $Log: N:\nt\private\utils\citrix\winutils\tsadmin\VCS\admindoc.h $
  13. *
  14. * Rev 1.8 19 Feb 1998 17:39:36 donm
  15. * removed latest extension DLL support
  16. *
  17. * Rev 1.6 19 Jan 1998 16:45:32 donm
  18. * new ui behavior for domains and servers
  19. *
  20. * Rev 1.5 03 Nov 1997 15:17:26 donm
  21. * Added Domains
  22. *
  23. * Rev 1.4 22 Oct 1997 21:06:10 donm
  24. * update
  25. *
  26. * Rev 1.3 18 Oct 1997 18:49:30 donm
  27. * update
  28. *
  29. * Rev 1.2 13 Oct 1997 18:41:42 donm
  30. * update
  31. *
  32. * Rev 1.1 26 Aug 1997 19:13:28 donm
  33. * bug fixes/changes from WinFrame 1.7
  34. *
  35. * Rev 1.0 30 Jul 1997 17:10:14 butchd
  36. * Initial revision.
  37. *
  38. *******************************************************************************/
  39. #ifndef _ADMINDOC_H
  40. #define _ADMINDOC_H
  41. #include <afxmt.h>
  42. #define TV_THISCOMP 0x1
  43. #define TV_FAVS 0x2
  44. #define TV_ALLSERVERS 0x4
  45. enum FOCUS_STATE { TREE_VIEW , TAB_CTRL , PAGED_ITEM };
  46. class CWinAdminDoc : public CDocument
  47. {
  48. protected: // create from serialization only
  49. CWinAdminDoc();
  50. DECLARE_DYNCREATE(CWinAdminDoc)
  51. // Attributes
  52. public:
  53. // Operations
  54. public:
  55. // Overrides
  56. // ClassWizard generated virtual function overrides
  57. //{{AFX_VIRTUAL(CWinAdminDoc)
  58. public:
  59. virtual BOOL OnNewDocument();
  60. virtual BOOL CanCloseFrame(CFrameWnd *pFW);
  61. virtual void Serialize(CArchive& ar);
  62. //}}AFX_VIRTUAL
  63. // Implementation
  64. public:
  65. virtual ~CWinAdminDoc();
  66. #ifdef _DEBUG
  67. virtual void AssertValid() const;
  68. virtual void Dump(CDumpContext& dc) const;
  69. #endif
  70. // return a pointer to the server linked list
  71. CObList *GetServerList() { return &m_ServerList; }
  72. // return a pointer to the Wd linked list
  73. CObList *GetWdList() { return &m_WdList; }
  74. // return a pointer to the domain linked list
  75. CObList *GetDomainList() { return &m_DomainList; }
  76. // remember currently selected node in tree
  77. void SetTreeCurrent(CObject* selected, NODETYPE type);
  78. // remember a temporary tree item (for some context menus)
  79. void SetTreeTemp(CObject* selected, NODETYPE type) {
  80. m_pTempSelectedNode = selected;
  81. m_TempSelectedType = type;
  82. }
  83. // Returns the current view
  84. VIEW GetCurrentView() { return m_CurrentView; }
  85. // sets the current view
  86. void SetCurrentView(VIEW view) { m_CurrentView = view; }
  87. // Returns the current page
  88. int GetCurrentPage() { return m_CurrentPage; }
  89. // sets the current page
  90. void SetCurrentPage(int page) { m_CurrentPage = page; }
  91. // Returns a pointer to the currently selected tree node
  92. CObject *GetCurrentSelectedNode() { return m_CurrentSelectedNode; }
  93. // Returns a pointer to the temp selected tree node
  94. CObject *GetTempSelectedNode() { return m_pTempSelectedNode; }
  95. // send a message to selected WinStations
  96. void SendWinStationMessage(BOOL bTemp, MessageParms* pParms);
  97. // connect to selected WinStation
  98. void ConnectWinStation(BOOL bTemp, BOOL bUser); // TRUE if User, FALSE if WinStation
  99. // disconnect selected WinStations
  100. void DisconnectWinStation(BOOL bTemp);
  101. // reset selected WinStations
  102. void ResetWinStation(BOOL bTemp, BOOL bReset); // TRUE if Reset, FALSE if Logoff
  103. // shadow selected WinStations
  104. void ShadowWinStation(BOOL bTemp);
  105. // show status dialog for selected WinStations
  106. void StatusWinStation(BOOL bTemp);
  107. // terminate selected processes
  108. void TerminateProcess();
  109. // do a refresh
  110. void Refresh();
  111. // Connect to selected Server(s)
  112. void ServerConnect();
  113. // Disconnect from the selected Server(s)
  114. void ServerDisconnect();
  115. // Connect to all the servers in temporarily selected Domain
  116. void TempDomainConnectAllServers();
  117. // Disconnect from all servers in temporarily selected Domain
  118. void TempDomainDisconnectAllServers();
  119. // Find all the servers in a Domain
  120. void DomainFindServers();
  121. // Connect to all the servers in currently selected Domain
  122. void CurrentDomainConnectAllServers();
  123. // Disconnect from all servers in currently selected Domain
  124. void CurrentDomainDisconnectAllServers();
  125. // Connect to all servers
  126. void ConnectToAllServers();
  127. // Disconnect from all servers
  128. void DisconnectFromAllServers();
  129. // Find all servers in all domains
  130. void FindAllServers();
  131. // lock the server linked list
  132. void LockServerList() { m_ServerListCriticalSection.Lock(); }
  133. // unlock the server linked list
  134. void UnlockServerList() { m_ServerListCriticalSection.Unlock(); }
  135. // lock the Wd linked list
  136. void LockWdList() { m_WdListCriticalSection.Lock(); }
  137. // unlock the Wd linked list
  138. void UnlockWdList() { m_WdListCriticalSection.Unlock(); }
  139. // returns a pointer to a given CServer object if it is in our list
  140. CServer *FindServerByName(TCHAR *pServerName);
  141. // returns a pointer to a given CWd object if it is in our list
  142. CWd *FindWdByName(TCHAR *pWdName);
  143. // sets the AllViewsReady variable
  144. void SetAllViewsReady() {
  145. if(m_pMainWnd && ::IsWindow(m_pMainWnd->GetSafeHwnd())) {
  146. m_pMainWnd->SendMessage(WM_ADMIN_VIEWS_READY, 0, 0);
  147. }
  148. m_AllViewsReady = TRUE;
  149. }
  150. // returns TRUE if all the views are ready
  151. BOOL AreAllViewsReady() { return m_AllViewsReady; }
  152. // sets the m_pMainWnd variable
  153. void SetMainWnd(CWnd *pWnd) { m_pMainWnd = pWnd; }
  154. // returns the m_pMainWnd variable
  155. CWnd *GetMainWnd() { return m_pMainWnd; }
  156. // returns TRUE as long as the process enum thread should keep running
  157. static BOOL ShouldProcessContinue() { return m_ProcessContinue; }
  158. // Add a Server to ServerList in sorted order
  159. void AddServer(CServer *pServer);
  160. // Inform the document that the Process List Refresh Time has changed
  161. void ProcessListRefreshChanged(UINT refresh) { m_ProcessWakeUpEvent.SetEvent(); }
  162. void FixUnknownString(TCHAR *string) { if(!wcscmp(string, m_UnknownString)) wcscpy(string,TEXT(" ")); }
  163. ULONG GetCurrentSubNet() { return m_CurrentSubNet; }
  164. void SetCurrentSubNet(ULONG sn) { m_CurrentSubNet = sn; }
  165. ExtServerInfo *GetDefaultExtServerInfo() { return m_pDefaultExtServerInfo; }
  166. ExtGlobalInfo *GetExtGlobalInfo() { return m_pExtGlobalInfo; }
  167. // Returns a pointer to the current domain object
  168. CDomain *GetCurrentDomain() { return m_pCurrentDomain; }
  169. // Returns a pointer to the current server object
  170. CServer *GetCurrentServer() { return m_pCurrentServer; }
  171. // Functions to check whether certain actions can be performed on the
  172. // currently selected items in the views
  173. BOOL CanConnect();
  174. BOOL CanDisconnect();
  175. BOOL CanRefresh() { return !m_InRefresh; }
  176. BOOL CanReset();
  177. BOOL CanShadow();
  178. BOOL CanSendMessage();
  179. BOOL CanStatus();
  180. BOOL CanLogoff();
  181. BOOL CanTerminate();
  182. BOOL CanServerConnect();
  183. BOOL CanServerDisconnect();
  184. BOOL CanTempConnect();
  185. BOOL CanTempDisconnect();
  186. BOOL CanTempReset();
  187. BOOL CanTempShadow();
  188. BOOL CanTempSendMessage();
  189. BOOL CanTempStatus();
  190. BOOL CanTempDomainConnect();
  191. BOOL CanTempDomainFindServers();
  192. BOOL CanDomainConnect();
  193. BOOL IsAlreadyFavorite( );
  194. void SetOnTabFlag( ){ m_fOnTab = TRUE; }
  195. void ResetOnTabFlag( ) { m_fOnTab = FALSE; }
  196. BOOL IsOnTabFlagged( ) { return m_fOnTab; }
  197. // Background thread to enumerate processes for the current server
  198. // Called with AfxBeginThread
  199. static UINT ProcessThreadProc(LPVOID);
  200. CWinThread *m_pProcessThread;
  201. static BOOL m_ProcessContinue;
  202. // Event to wakeup process thread so that
  203. // he can exit (WaitForSingleEvent instead of Sleep)
  204. // or enumerate processes
  205. CEvent m_ProcessWakeUpEvent;
  206. // Function to terminate a process
  207. // Called with AfxBeginThread
  208. static UINT TerminateProc(LPVOID);
  209. // Set the connections persistent preference
  210. void SetConnectionsPersistent(BOOL p) { m_ConnectionsPersistent = p; }
  211. // Should connections be persistent?
  212. BOOL AreConnectionsPersistent() { return(m_ConnectionsPersistent == TRUE); }
  213. // Should we connect to a particular server?
  214. BOOL ShouldConnect(LPWSTR pServerName);
  215. BOOL ShouldAddToFav( LPTSTR pServerName );
  216. // Are we shutting down
  217. BOOL IsInShutdown() { return m_bInShutdown; }
  218. void ServerAddToFavorites( BOOL );
  219. FOCUS_STATE GetLastRegisteredFocus( ){ return m_focusstate; }
  220. void RegisterLastFocus( FOCUS_STATE x ) { m_focusstate = x; }
  221. FOCUS_STATE GetPrevFocus( ) { return m_prevFocusState; }
  222. void SetPrevFocus( FOCUS_STATE x ) { m_prevFocusState = x; }
  223. void AddToFavoritesNow();
  224. // Add a Domain to DomainList in sorted order
  225. void AddDomain(CDomain *pDomain);
  226. private:
  227. // Read the list of trusted domains and builds linked list of domains
  228. void BuildDomainList();
  229. // builds the list of CWd objects
  230. void BuildWdList();
  231. // Helper function for the above
  232. BOOL CheckActionAllowed(BOOL (*CheckFunction)(CWinStation *pWinStation), BOOL AllowMultileSelected);
  233. // Callbacks passed to CheckActionAllowed
  234. static BOOL CheckConnectAllowed(CWinStation *pWinStation);
  235. static BOOL CheckDisconnectAllowed(CWinStation *pWinStation);
  236. static BOOL CheckResetAllowed(CWinStation *pWinStation);
  237. static BOOL CheckSendMessageAllowed(CWinStation *pWinStation);
  238. static BOOL CheckShadowAllowed(CWinStation *pWinStation);
  239. static BOOL CheckStatusAllowed(CWinStation *pWinStation);
  240. // Called when the CMainFrame is about to close
  241. // Does what the destructor used to do
  242. void Shutdown(CDialog *pDlg);
  243. // Display message string in shutdown dialog
  244. void ShutdownMessage(UINT id, CDialog *dlg);
  245. // Read the user preferences
  246. void ReadPreferences();
  247. // Write the user preferences
  248. void WritePreferences();
  249. // Function to Enumerate the Hydra Servers on the Network.
  250. static LPWSTR EnumHydraServers(LPWSTR pDomain, DWORD VerMajor, DWORD VerMinor);
  251. CObList m_ServerList; // List of CServer objects
  252. CCriticalSection m_ServerListCriticalSection;
  253. CObList m_WdList; // List of CWd objects
  254. CCriticalSection m_WdListCriticalSection;
  255. // List of Domains
  256. // This list does not have a critical section (and lock/unlock functions)
  257. // because it is never used by two different threads at the same time
  258. CObList m_DomainList;
  259. CObject* m_CurrentSelectedNode;
  260. NODETYPE m_CurrentSelectedType;
  261. // TempSelected are for server context menus in the tree
  262. // so that tree item doesn't have to be selected to
  263. // make popup menu work
  264. CObject* m_pTempSelectedNode;
  265. NODETYPE m_TempSelectedType;
  266. void UpdateAllProcesses();
  267. LPCTSTR m_UnknownString; // Pointer to the "(unknown)" string from UTILDLL.DLL
  268. ULONG m_CurrentSubNet; // Subnet of the current server
  269. VIEW m_CurrentView;
  270. int m_CurrentPage;
  271. BOOL m_AllViewsReady;
  272. BOOL m_InRefresh;
  273. BOOL m_bInShutdown;
  274. CWnd *m_pMainWnd;
  275. CDomain *m_pCurrentDomain;
  276. CServer *m_pCurrentServer;
  277. ExtServerInfo *m_pDefaultExtServerInfo;
  278. ExtGlobalInfo *m_pExtGlobalInfo;
  279. // user preferences
  280. UINT m_ConnectionsPersistent;
  281. LPWSTR m_pPersistentConnections;
  282. LPWSTR m_pszFavList;
  283. FOCUS_STATE m_focusstate;
  284. FOCUS_STATE m_prevFocusState;
  285. BOOL m_fOnTab;
  286. // Generated message map functions
  287. protected:
  288. //{{AFX_MSG(CWinAdminDoc)
  289. // NOTE - the ClassWizard will add and remove member functions here.
  290. // DO NOT EDIT what you see in these blocks of generated code !
  291. //}}AFX_MSG
  292. DECLARE_MESSAGE_MAP()
  293. };
  294. /////////////////////////////////////////////////////////////////////////////
  295. #endif // _ADMINDOC_H