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.

473 lines
12 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows/NT **/
  3. /** Copyright(c) Microsoft Corporation, 1997 - 1999 **/
  4. /**********************************************************************/
  5. /*
  6. ACSHand.h
  7. Root node information (the root node is not displayed
  8. in the MMC framework but contains information such as
  9. all of the subnodes in this snapin).
  10. FILE HISTORY:
  11. 11/05/97 Wei Jiang Created
  12. */
  13. #ifndef _ACSHAND_H
  14. #define _ACSHAND_H
  15. #ifndef _HANDLERS_H
  16. #include "handlers.h"
  17. #endif
  18. #include "acscomp.h"
  19. #ifndef _STATSDLG_H
  20. #include "statsdlg.h"
  21. #endif
  22. #include <list>
  23. #include "helper.h"
  24. #include "resource.h"
  25. #define GETHANDLER(classname, node) (reinterpret_cast<classname *>(node->GetData(TFS_DATA_USER)))
  26. extern UINT g_col_strid_name[];
  27. extern int g_col_width_name[];
  28. extern UINT g_col_strid_name_type[];
  29. extern int g_col_width_name_type[];
  30. extern UINT g_col_strid_name_type_desc[];
  31. extern int g_col_width_name_type_desc[];
  32. extern UINT g_col_strid_policy[];
  33. extern int g_col_width_policy[];
  34. extern const UINT g_col_count_policy;
  35. extern UINT g_col_strid_subnet[];
  36. extern int g_col_width_subnet[];
  37. extern const UINT g_col_count_subnet;
  38. // type of ACS nodes
  39. enum NodeTypes {
  40. ND_ACSROOT = 1,
  41. ND_GLOBALCONFIG,
  42. ND_SUBNETCONFIGS,
  43. ND_USERS,
  44. ND_PROFILES,
  45. ND_SUBNET,
  46. ND_SUBNET_CONFIG,
  47. ND_POLICY
  48. };
  49. class CACSDataObject;
  50. // defined ACS index for the MMC verbs
  51. enum ACS_MMC_VERBS {
  52. ACS_MMC_VERB_OPEN = 0,
  53. ACS_MMC_VERB_COPY,
  54. ACS_MMC_VERB_PASTE,
  55. ACS_MMC_VERB_DELETE,
  56. ACS_MMC_VERB_PROPERTIES,
  57. ACS_MMC_VERB_RENAME,
  58. ACS_MMC_VERB_REFRESH,
  59. ACS_MMC_VERB_PRINT,
  60. ACS_TOTAL_MMC_VERBS
  61. };
  62. // keep a public map of MMC verbs -- value defined in ACSHand.cpp
  63. extern const MMC_CONSOLE_VERB g_mmc_verbs[ACS_TOTAL_MMC_VERBS];
  64. //============================================================================
  65. // Class: CACSGenericHandle
  66. //
  67. // Generic handler class for ACS handlers
  68. //
  69. // Author: WeiJiang
  70. //
  71. struct CACSUIInfo
  72. {
  73. const UINT* m_aStaticStrIds; // if names are static, the stringIDs appear hear
  74. UINT m_nTotalStrs; // for the UI's own's result pane
  75. UINT* m_aColumnIds; // IDS used for columns in result pane
  76. int* m_aColumnWidths; // column widths in result pane
  77. bool m_bPropertyPage; // if this node has property pages
  78. bool m_bContainer; // if this is an container
  79. const UINT* m_aNewMenuTextIds; // array of menu items for New
  80. const UINT* m_aNewMenuIds; // optional menu Ids for items for New
  81. const UINT* m_aTaskMenuTextIds; // array of menu items for Task
  82. const UINT* m_aTaskMenuIds; // optional menu Ids for items for Task
  83. MMC_BUTTON_STATE* m_pVerbStates; // VERB STATE
  84. const GUID* m_pGUID;
  85. };
  86. #define BRANCH_FLAG_GLOBAL 0x00000001
  87. extern CACSUIInfo g_RootUIInfo;
  88. extern CACSUIInfo g_GlobalUIInfo;
  89. extern CACSUIInfo g_SubnetworksUIInfo;
  90. extern CACSUIInfo g_ProfilesUIInfo;
  91. extern CACSUIInfo g_UsersUIInfo;
  92. extern CACSUIInfo g_PolicyUIInfo;
  93. extern CACSUIInfo g_SubnetUIInfo;
  94. class CDSObject;
  95. //============================================================================
  96. // Class: CACSGenericHandle
  97. //
  98. // Generic handler class for ACS handlers
  99. //
  100. // Author: WeiJiang
  101. //
  102. class CACSHandle : public CHandler
  103. {
  104. public:
  105. CACSHandle(ITFSComponentData *pCompData, CDSObject* pDSObject, CACSUIInfo* pUIInfo);
  106. virtual ~CACSHandle();
  107. // base handler functionality we override
  108. OVERRIDE_NodeHandler_HasPropertyPages();
  109. OVERRIDE_NodeHandler_GetString();
  110. OVERRIDE_NodeHandler_OnAddMenuItems();
  111. OVERRIDE_NodeHandler_OnCommand();
  112. // Node Id 2 support
  113. OVERRIDE_BaseHandlerNotify_OnCreateNodeId2();
  114. OVERRIDE_BaseHandlerNotify_OnDelete(); // handles delete menu item
  115. OVERRIDE_BaseHandlerNotify_OnRename();
  116. OVERRIDE_BaseHandlerNotify_OnExpand();
  117. OVERRIDE_ResultHandler_GetString();
  118. OVERRIDE_ResultHandler_HasPropertyPages();
  119. OVERRIDE_BaseResultHandlerNotify_OnResultSelect();
  120. OVERRIDE_BaseResultHandlerNotify_OnResultContextHelp();
  121. OVERRIDE_BaseResultHandlerNotify_OnResultRefresh();
  122. OVERRIDE_BaseResultHandlerNotify_OnResultDelete();
  123. OVERRIDE_BaseResultHandlerNotify_OnResultRename();
  124. OVERRIDE_ResultHandler_CompareItems();
  125. OVERRIDE_ResultHandler_AddMenuItems();
  126. OVERRIDE_ResultHandler_Command();
  127. // base handler virtual function over-rides
  128. virtual HRESULT SaveColumns(ITFSComponent *, MMC_COOKIE, LPARAM, LPARAM);
  129. HRESULT UpdateStrings(); // should call the data object to get the latest dynamic strings
  130. virtual HRESULT ShowState(DWORD state) {m_dwShownState = state; return S_OK;};
  131. DWORD GetShownState() { return m_dwShownState;};
  132. // when data is changed on property page
  133. static HRESULT NotifyDataChange(LPARAM param);
  134. // Initialize function is called after handle is created
  135. virtual HRESULT InitializeNode(ITFSNode * pNode);
  136. virtual HRESULT ListChildren(std::list<CACSHandle*>& children){ return S_FALSE;};
  137. virtual HRESULT GetNamesForCommandNew(int nCommandId, CStrArray& Names) SAYOK;
  138. bool IfContainer() { return m_pUIInfo->m_bContainer;};
  139. HRESULT AddChild(ITFSNode* pNode, CACSHandle* pHandle, ITFSNode** ppNewNode);
  140. virtual HRESULT EditProperties() SAYOK;
  141. virtual HRESULT Delete(ITFSNode *pNode, ITFSComponent* pComponent, BOOL bCheckPropertyPage);
  142. // bring up the property page if it's open
  143. HRESULT BringUpPropertyPageIfOpen(ITFSNode *pNode, ITFSComponent* pComponent);
  144. //
  145. // override to clean up our per-node data structures
  146. //
  147. OVERRIDE_NodeHandler_DestroyHandler();
  148. OVERRIDE_ResultHandler_DestroyResultHandler();
  149. HRESULT IsOkToDelete()
  150. {
  151. if(m_nBranchFlag & BRANCH_FLAG_GLOBAL)
  152. {
  153. // unknown and default can not be deleted
  154. if(wcsstr(m_pDSObject->GetName(), ACS_NAME_DEFAULTUSER))
  155. return S_FALSE;
  156. if(wcsstr(m_pDSObject->GetName(), ACS_NAME_UNKNOWNUSER))
  157. return S_FALSE;
  158. }
  159. return S_OK;
  160. };
  161. void SetBranch(UINT flag) { m_nBranchFlag = flag;};
  162. UINT m_nBranchFlag; // glocal defined as 0x0001
  163. public:
  164. // ICON INDEX
  165. ULONG m_ulIconIndex;
  166. ULONG m_ulIconIndexOpen;
  167. protected:
  168. // UI Information such as Column info, if property page, context menu, if container
  169. CACSUIInfo* m_pUIInfo;
  170. // Handlers get strings, expand node, data object query, and menu..
  171. CDSObject* m_pDSObject;
  172. CStrArray m_aStaticStrings; // string used for get name
  173. CStrArray m_aDynStrings; // string used for get name
  174. UINT m_nFirstDynCol;
  175. DWORD m_dwShownState;
  176. ITFSNode* m_pNode; // ref counted, releasd in Destroy
  177. BOOL m_bACSHandleExpanded;
  178. BOOL m_bCheckPropertyPageOpen;
  179. };
  180. #ifndef _TASK_H
  181. #include <task.h>
  182. #endif
  183. #define COMPUTERNAME_LEN_MAX 255
  184. typedef enum _ROOT_TASKS
  185. {
  186. ROOT_TASK_LAUNCH_ACS,
  187. ROOT_TASK_MAX
  188. } ROOT_TASKS;
  189. class CRootTasks : public CTaskList
  190. {
  191. public:
  192. HRESULT Init(BOOL bExtension, BOOL bThisMachine, BOOL bNetServices);
  193. private:
  194. CStringArray m_arrayMouseOverBitmaps;
  195. CStringArray m_arrayMouseOffBitmaps;
  196. CStringArray m_arrayTaskText;
  197. CStringArray m_arrayTaskHelp;
  198. };
  199. //============================================================================
  200. //
  201. // Class: CACSRootHandle
  202. //
  203. // Handler class for ACS Root Node
  204. //
  205. // Author: WeiJiang
  206. //
  207. class CACSRootHandle : public CACSHandle
  208. {
  209. public:
  210. CACSRootHandle(ITFSComponentData *pCompData, CDSObject* pDSObject)
  211. : CACSHandle(pCompData, pDSObject, &g_RootUIInfo)
  212. {
  213. m_ulIconIndex = IMAGE_IDX_CLOSEDFOLDER;
  214. m_ulIconIndexOpen = IMAGE_IDX_OPENFOLDER;
  215. };
  216. // for task pad to extend network console
  217. OVERRIDE_ResultHandler_TaskPadNotify();
  218. OVERRIDE_ResultHandler_EnumTasks();
  219. virtual HRESULT ListChildren(std::list<CACSHandle*>& children);
  220. protected:
  221. };
  222. //============================================================================
  223. //
  224. // Class: CACSPolicyContainerHandle
  225. //
  226. // Handler class for ACS Policy Containers like Users and Profiles Node
  227. //
  228. // Author: WeiJiang
  229. //
  230. class CACSPolicyContainerHandle :
  231. public CACSHandle
  232. {
  233. public:
  234. CACSPolicyContainerHandle(ITFSComponentData *pCompData, CDSObject* pDSObject, CACSUIInfo* pUIInfo)
  235. : CACSHandle(pCompData, pDSObject, pUIInfo){};
  236. OVERRIDE_NodeHandler_OnCommand();
  237. OVERRIDE_BaseHandlerNotify_OnExpand();
  238. virtual HRESULT ListChildren(std::list<CACSHandle*>& children);
  239. virtual HRESULT GetNamesForCommandNew(int nCommandId, CStrArray& Names);
  240. protected:
  241. };
  242. //============================================================================
  243. //
  244. // Class: CACSGlobalHandle
  245. //
  246. // Handler class for ACS Global Configuration Node
  247. //
  248. // Author: WeiJiang
  249. //
  250. class CACSGlobalHandle :
  251. public CACSPolicyContainerHandle
  252. {
  253. public:
  254. CACSGlobalHandle(ITFSComponentData *pCompData, CDSObject* pDSObject)
  255. : CACSPolicyContainerHandle(pCompData, pDSObject, &g_GlobalUIInfo)
  256. {
  257. SetBranch(BRANCH_FLAG_GLOBAL);
  258. m_ulIconIndex = IMAGE_IDX_CLOSEDFOLDER;
  259. m_ulIconIndexOpen = IMAGE_IDX_OPENFOLDER;
  260. };
  261. protected:
  262. };
  263. //============================================================================
  264. //
  265. // Class: CACSSubnetContainerHandle
  266. //
  267. // Handler class for ACS Subnetwork Configurations Node
  268. //
  269. // Author: WeiJiang
  270. //
  271. class CACSSubnetContainerHandle :
  272. public CACSHandle
  273. {
  274. public:
  275. CACSSubnetContainerHandle(ITFSComponentData *pCompData, CDSObject* pDSObject)
  276. : CACSHandle(pCompData, pDSObject, &g_SubnetworksUIInfo)
  277. {
  278. m_ulIconIndex = IMAGE_IDX_CLOSEDFOLDER;
  279. m_ulIconIndexOpen = IMAGE_IDX_OPENFOLDER;
  280. };
  281. OVERRIDE_NodeHandler_OnCommand();
  282. virtual HRESULT ListChildren(std::list<CACSHandle*>& children);
  283. virtual HRESULT GetNamesForCommandNew(int nCommandId, CStrArray& Names);
  284. protected:
  285. };
  286. //============================================================================
  287. //
  288. // Class: CACSSubnetHandle
  289. //
  290. // Handler class for ACS Subnetwork
  291. //
  292. // Author: WeiJiang
  293. //
  294. class CACSSubnetHandle :
  295. public CACSPolicyContainerHandle
  296. {
  297. public:
  298. CACSSubnetHandle(ITFSComponentData *pCompData, CDSObject* pDSObject)
  299. : CACSPolicyContainerHandle(pCompData, pDSObject, &g_SubnetUIInfo)
  300. {
  301. if ((pDSObject->GetState() & ACSDATA_STATE_NOOBJECT) != 0)
  302. {
  303. m_ulIconIndexOpen = m_ulIconIndex = IMAGE_IDX_SUBNETWORK_NO_ACSPOLICY;
  304. }
  305. else
  306. {
  307. m_ulIconIndexOpen = m_ulIconIndex = IMAGE_IDX_SUBNETWORK;
  308. }
  309. };
  310. OVERRIDE_NodeHandler_OnCommand();
  311. OVERRIDE_NodeHandler_CreatePropertyPages();
  312. // show if the data is conflict
  313. virtual HRESULT ShowState(DWORD state);
  314. protected:
  315. };
  316. //============================================================================
  317. //
  318. // Class: CACSPolicyHandle
  319. //
  320. // Handler class for ACS Policy Node
  321. //
  322. // Author: WeiJiang
  323. //
  324. class CACSPolicyHandle :
  325. public CACSHandle
  326. {
  327. public:
  328. CACSPolicyHandle(ITFSComponentData *pCompData, CDSObject* pDSObject)
  329. : CACSHandle(pCompData, pDSObject, &g_PolicyUIInfo)
  330. {
  331. m_ulIconIndex = IMAGE_IDX_POLICY;
  332. m_ulIconIndexOpen = IMAGE_IDX_POLICY;
  333. m_bDeleteUponCancel = FALSE;
  334. };
  335. OVERRIDE_NodeHandler_CreatePropertyPages();
  336. OVERRIDE_ResultHandler_CreatePropertyPages();
  337. OVERRIDE_BaseResultHandlerNotify_OnResultDelete();
  338. void SetDeleteOnCancelPropertyPage(ITFSNode* pNode)
  339. {
  340. m_bDeleteUponCancel = TRUE;
  341. };
  342. void OnPropertyPageApply()
  343. {
  344. m_bDeleteUponCancel = FALSE;
  345. CACSPolicyElement* pObj = dynamic_cast<CACSPolicyElement*>(m_pDSObject);
  346. ASSERT(pObj);
  347. };
  348. void OnPropertyPageOK()
  349. {
  350. m_bDeleteUponCancel = FALSE;
  351. };
  352. void OnPropertyPageCancel()
  353. {
  354. if(m_bDeleteUponCancel)
  355. {
  356. ASSERT(m_pNode);
  357. m_bCheckPropertyPageOpen = FALSE;
  358. Delete(m_pNode, NULL, FALSE);
  359. }
  360. };
  361. // show if the data is conflict
  362. virtual HRESULT ShowState(DWORD state);
  363. protected:
  364. bool m_bDeleteUponCancel; // set to true when new create policy
  365. };
  366. #endif // _ACSHAND_H
  367. //////////////////////////////////////////