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.

390 lines
11 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows/NT **/
  3. /** Copyright(c) Microsoft Corporation, 1997 - 1999 **/
  4. /**********************************************************************/
  5. /*
  6. machine.h
  7. Machine node information.
  8. FILE HISTORY:
  9. Wei Jiang : 5/7/98 --- SECURE_ROUTERINFO
  10. new funciton SecureRouterInfo is added to MachineHandler
  11. */
  12. #ifndef _MACHINE_H
  13. #define _MACHINE_H
  14. #ifndef _BASEHAND_H
  15. #include "basehand.h"
  16. #endif
  17. #ifndef _BASERTR_H
  18. #include "basertr.h"
  19. #endif
  20. #ifndef _QUERYOBJ_H
  21. #include "queryobj.h"
  22. #endif
  23. #ifndef _INFO_H
  24. #include "info.h"
  25. #endif
  26. #define MACHINE_SYNCHRONIZE_ICON 100
  27. //
  28. // Possible states for the machine information (not necessarily for
  29. // the data in the IRouterInfo).
  30. //
  31. typedef enum _MACHINE_STATES
  32. {
  33. // These are the unloaded states
  34. machine_not_connected, // haven't tried to connect
  35. machine_connecting, // trying to connect
  36. machine_unable_to_connect, // connect failed! unknown reason
  37. machine_access_denied, // connect failed! access denied
  38. machine_bad_net_path, // bad machine name (cannot find the name)
  39. // All states added after this should be considered loaded.
  40. machine_connected, // connected!
  41. // end of valid machine states
  42. // this is a sentinel value, do not use this as a possible
  43. // machine state
  44. machine_enum_end
  45. } MACHINE_STATES;
  46. /*---------------------------------------------------------------------------
  47. Possible service states.
  48. The is orthogonal to our access level (you can read, but not change).
  49. ---------------------------------------------------------------------------*/
  50. typedef enum _SERVICE_STATES
  51. {
  52. service_unknown,
  53. service_access_denied,
  54. service_bad_net_path,
  55. service_not_a_server,
  56. service_started,
  57. service_stopped,
  58. service_rasadmin,
  59. // end of valid machine states
  60. // this is a sentinel value, do not use this as a possible
  61. // machine state
  62. service_enum_end
  63. } SERVICE_STATES;
  64. //
  65. // These are the possible states for the IRouterInfo
  66. //
  67. typedef enum _DATA_STATES
  68. {
  69. data_not_loaded, // IRouterInfo not loaded
  70. data_unable_to_load, // Unable to connect to the server
  71. data_loading, // Still loading
  72. data_loaded // IRouterInfo::Load() succeeded
  73. } DATA_STATES;
  74. // forward declartions
  75. class RouterAdminConfigStream;
  76. struct SMachineNodeMenu;
  77. class DomainStatusHandler;
  78. /*---------------------------------------------------------------------------
  79. Struct: MachineNodeData
  80. This is machine node specific data. A pointer to this structure is stored
  81. as the machine node user data.
  82. This is an AddRef'd data structure!
  83. ---------------------------------------------------------------------------*/
  84. enum ServerRouterType
  85. {
  86. ServerType_Unknown = 0, // don't know what kind of machine this is.
  87. ServerType_Uninstalled, // NT4 - nothing installed
  88. ServerType_Workstation, // This is a workstation (no admin allowed)
  89. ServerType_Ras, // NT4 (non-Steelhead) (RAS only)
  90. ServerType_Rras, // NT4 Steelhead and NT5 and up.
  91. // This differs from the regular Uninstalled case, this means
  92. // that the bits are there, just that the config needs to get run.
  93. ServerType_RrasUninstalled, // NT5 and up, not installed
  94. };
  95. // forward delaration
  96. struct MachineNodeData;
  97. // Structure used to pass data to callbacks - used as a way of
  98. // avoiding recomputation
  99. struct MachineConfig
  100. {
  101. public:
  102. MachineConfig()
  103. : m_fReachable(FALSE),
  104. m_fNt4(FALSE),
  105. m_fConfigured(FALSE),
  106. m_dwServiceStatus(0),
  107. m_fLocalMachine(FALSE)
  108. {};
  109. MachineConfig& operator= (const MachineConfig& m)
  110. {
  111. m_fReachable = m.m_fReachable;
  112. m_fNt4 = m.m_fNt4;
  113. m_fConfigured = m.m_fConfigured;
  114. m_dwServiceStatus = m.m_dwServiceStatus;
  115. m_fLocalMachine = m.m_fLocalMachine;
  116. return *this;
  117. };
  118. BOOL m_fReachable; // can we connect?
  119. BOOL m_fNt4; // NT4 or not?
  120. BOOL m_fConfigured; // has install been run?
  121. DWORD m_dwServiceStatus; // GetRouterServiceStatus()
  122. BOOL m_fLocalMachine;
  123. // Loads some basic machine config information
  124. HRESULT GetMachineConfig(MachineNodeData *pData);
  125. };
  126. struct MachineNodeData
  127. {
  128. MachineNodeData();
  129. ~MachineNodeData();
  130. // AddRef/Release info
  131. ULONG AddRef();
  132. ULONG Release();
  133. LONG m_cRef;
  134. HRESULT Init(LPCTSTR pszMachineName);
  135. HRESULT Merge(const MachineNodeData& data);
  136. // Load/unload/reload/etc....
  137. // Note: Calling Load() twice in a row will not reload
  138. // the data. A refresh requires that an Unload() be called first.
  139. HRESULT Load();
  140. HRESULT Unload();
  141. HRESULT SetDefault();
  142. #ifdef DEBUG
  143. char m_szDebug[32];
  144. #endif
  145. // Static data (this data does not get reloaded)
  146. BOOL m_fLocalMachine;
  147. BOOL m_fAddedAsLocal;
  148. CString m_stMachineName; // name of the machine (duh)
  149. DWORD m_dwServerHandle;
  150. LONG_PTR m_ulRefreshConnId;
  151. MMC_COOKIE m_cookie;
  152. // This data does get reloaded
  153. BOOL m_fExtension;
  154. // Depending on the state of the service, this will return
  155. // the appropriate image index for the service.
  156. LPARAM GetServiceImageIndex();
  157. SERVICE_STATES m_serviceState;
  158. MACHINE_STATES m_machineState;
  159. DATA_STATES m_dataState;
  160. // The m_stState must be kept up-to-date with the machine state
  161. // variable
  162. CString m_stState; // "started", "stopped", ...
  163. CString m_stServerType; // Actually the router version
  164. CString m_stBuildNo; // OS Build no.
  165. DWORD m_dwPortsInUse;
  166. DWORD m_dwPortsTotal;
  167. DWORD m_dwUpTime;
  168. BOOL m_fStatsRetrieved;
  169. BOOL m_fIsServer; // Is this a server or a workstation?
  170. // This is the hProcess of RASADMIN (this is so we only have one running)
  171. HANDLE m_hRasAdmin;
  172. ServerRouterType m_routerType;
  173. RouterVersionInfo m_routerVersion;
  174. MachineConfig m_MachineConfig;
  175. HRESULT FetchServerState(CString& stState);
  176. protected:
  177. HRESULT LoadServerVersion();
  178. };
  179. #define GET_MACHINENODEDATA(pNode) \
  180. ((MachineNodeData *) pNode->GetData(TFS_DATA_USER))
  181. #define SET_MACHINENODEDATA(pNode, pData) \
  182. pNode->SetData(TFS_DATA_USER, (LONG_PTR) pData)
  183. DeclareSmartPointer(SPMachineNodeData, MachineNodeData, if(m_p) m_p->Release());
  184. /*---------------------------------------------------------------------------
  185. Class: MachineHandler
  186. This is the handler for all "server" nodes.
  187. ---------------------------------------------------------------------------*/
  188. class MachineHandler :
  189. public BaseRouterHandler
  190. {
  191. public:
  192. void ExpandNode(ITFSNode * pNode,BOOL fExpand);
  193. MachineHandler(ITFSComponentData *pCompData);
  194. ~MachineHandler()
  195. {
  196. m_spRouterInfo.Release();
  197. m_spDataObject.Release(); // cached data object
  198. DEBUG_DECREMENT_INSTANCE_COUNTER(MachineHandler);
  199. }
  200. HRESULT Init(LPCTSTR pszMachineName,
  201. RouterAdminConfigStream *pConfigStream,
  202. ITFSNodeHandler* pSumNodeHandler = NULL,
  203. ITFSNode* pSumNode = NULL );
  204. // Override QI to handle embedded interface
  205. STDMETHOD(QueryInterface)(REFIID iid, LPVOID *ppv);
  206. // Embedded interface to deal with refresh callbacks
  207. DeclareEmbeddedInterface(IRtrAdviseSink, IUnknown)
  208. //
  209. // base handler functionality we override
  210. //
  211. OVERRIDE_NodeHandler_GetString();
  212. OVERRIDE_NodeHandler_CreatePropertyPages();
  213. OVERRIDE_NodeHandler_HasPropertyPages();
  214. OVERRIDE_NodeHandler_OnAddMenuItems();
  215. OVERRIDE_NodeHandler_OnCommand();
  216. // result handler overrides -- result pane message
  217. OVERRIDE_BaseResultHandlerNotify_OnResultSelect();
  218. OVERRIDE_ResultHandler_AddMenuItems();
  219. OVERRIDE_ResultHandler_Command();
  220. OVERRIDE_ResultHandler_OnGetResultViewType();
  221. OVERRIDE_ResultHandler_UserResultNotify();
  222. //
  223. // override to provide the specific RouterInfo Dataobject
  224. //
  225. OVERRIDE_NodeHandler_OnCreateDataObject();
  226. //
  227. // override to clean up our per-node data structures
  228. //
  229. OVERRIDE_NodeHandler_DestroyHandler();
  230. OVERRIDE_NodeHandler_UserNotify();
  231. //
  232. // Notification overrides (not part of an interface)
  233. //
  234. OVERRIDE_BaseHandlerNotify_OnExpand();
  235. OVERRIDE_BaseHandlerNotify_OnExpandSync();
  236. OVERRIDE_BaseHandlerNotify_OnDelete();
  237. OVERRIDE_BaseResultHandlerNotify_OnResultRefresh();
  238. HRESULT ConstructNode(ITFSNode *pNode, LPCTSTR szMachine, MachineNodeData *pData);
  239. //
  240. OVERRIDE_BaseResultHandlerNotify_OnResultShow();
  241. //
  242. // Structure used to pass data to callbacks - used as a way of
  243. // avoiding recomputation
  244. struct SMenuData
  245. {
  246. SPITFSNode m_spNode;
  247. SPIRouterInfo m_spRouterInfo;
  248. MachineConfig * m_pMachineConfig;
  249. };
  250. HRESULT OnNewRtrRASConfigWiz(ITFSNode *pNode, BOOL fTest);
  251. static ULONG MachineRtrConfWizFlags(const SRouterNodeMenu *pMenuData,
  252. INT_PTR pData /* SMenuData * */);
  253. static ULONG GetAutoRefreshFlags(const SRouterNodeMenu *pMenuData,
  254. INT_PTR pData /* SMenuData * */);
  255. static ULONG GetPauseFlags(const SRouterNodeMenu *pMenuData,
  256. INT_PTR pData /* SMenuData * */);
  257. HRESULT SetExternalRefreshObject(IRouterRefresh *pRefresh);
  258. // This is static so that the other nodes can use it.
  259. static ULONG GetServiceFlags(const SRouterNodeMenu *pMenuData,
  260. INT_PTR pData /* SMenuData * */);
  261. static ULONG QueryService(const SRouterNodeMenu *pMenuData,
  262. INT_PTR pData /* SMenuData * */);
  263. HRESULT ChgService(ITFSNode *pNode, const CString& szServer, ULONG menuId);
  264. HRESULT SynchronizeIcon(ITFSNode *pNode);
  265. HRESULT SetExtensionStatus(ITFSNode * pNode, BOOL bExtension);
  266. // result message view helper
  267. void UpdateResultMessage(ITFSNode * pNode);
  268. protected:
  269. // to postpone the loading of RouterInfo from Init, till it's used
  270. // function SecureRouterInfo is introduced to make sure RouterInfo is Loaded
  271. HRESULT SecureRouterInfo(ITFSNode *pNode, BOOL fShowUI);
  272. // Add remove node update support
  273. HRESULT AddRemoveRoutingInterfacesNode(ITFSNode *, DWORD, DWORD);
  274. HRESULT AddRemovePortsNode(ITFSNode *, DWORD, DWORD);
  275. HRESULT AddRemoveDialinNode(ITFSNode *, DWORD, DWORD);
  276. // RasAdmin.Exe support for Windows NT 4 RAS administration
  277. HRESULT StartRasAdminExe(MachineNodeData *pData);
  278. ITFSNodeHandler* m_pSumNodeHandler;
  279. ITFSNode* m_pSumNode;
  280. BOOL m_bExpanded;
  281. BOOL m_fCreateNewDataObj;
  282. BOOL m_fNoConnectingUI;
  283. BOOL m_bRouterInfoAddedToAutoRefresh;
  284. BOOL m_bMergeRequired;
  285. // This is set to FALSE after the connect in the OnExpand()
  286. // fails. This is a hack to fix the two connect attempts,
  287. // one in the OnExpand() and one in the OnResultShow().
  288. BOOL m_fTryToConnect;
  289. CString m_stNodeTitle;
  290. SPIDataObject m_spDataObject; // cached data object
  291. RouterAdminConfigStream * m_pConfigStream;
  292. DWORD m_EventId;
  293. };
  294. #endif _MACHINE_H