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.

346 lines
14 KiB

  1. /////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 1996-1997 Microsoft Corporation
  4. //
  5. // Module Name:
  6. // ClusItem.h
  7. //
  8. // Abstract:
  9. // Definition of the CClusterItem class.
  10. //
  11. // Implementation File:
  12. // ClusItem.cpp
  13. //
  14. // Author:
  15. // David Potter (davidp) May 3, 1996
  16. //
  17. // Revision History:
  18. //
  19. // Notes:
  20. //
  21. /////////////////////////////////////////////////////////////////////////////
  22. #ifndef _CLUSITEM_H_
  23. #define _CLUSITEM_H_
  24. /////////////////////////////////////////////////////////////////////////////
  25. // Include Files
  26. /////////////////////////////////////////////////////////////////////////////
  27. #ifndef _RESOURCE_H_
  28. #include "resource.h"
  29. #define _RESOURCE_H_
  30. #endif
  31. #ifndef _BASECMDT_H_
  32. #include "BaseCmdT.h" // for CBaseCmdTarget
  33. #endif
  34. #ifndef _TREEITEM_H_
  35. #include "TreeItem.h" // for CTreeItemList;
  36. #endif
  37. #ifndef _LISTITEM_H_
  38. #include "ListItem.h" // for CListItemList
  39. #endif
  40. /////////////////////////////////////////////////////////////////////////////
  41. // Forward Class Declarations
  42. /////////////////////////////////////////////////////////////////////////////
  43. class CClusterItem;
  44. class CClusterItemList;
  45. /////////////////////////////////////////////////////////////////////////////
  46. // External Class Declarations
  47. /////////////////////////////////////////////////////////////////////////////
  48. class CClusterDoc;
  49. class CClusterNotify;
  50. class CClusterNotifyKey;
  51. class CClusPropList;
  52. class CObjectProperty;
  53. #ifdef _DEBUG
  54. class CTraceTag;
  55. #endif
  56. /////////////////////////////////////////////////////////////////////////////
  57. // CClusterItem command target
  58. /////////////////////////////////////////////////////////////////////////////
  59. class CClusterItem : public CBaseCmdTarget
  60. {
  61. DECLARE_DYNCREATE(CClusterItem)
  62. // Construction
  63. public:
  64. CClusterItem(void); // protected constructor used by dynamic creation
  65. CClusterItem(
  66. IN const CString * pstrName,
  67. IN IDS idsType = IDS_ITEMTYPE_CONTAINER,
  68. IN const CString * pstrDescription = NULL
  69. );
  70. void Init(IN OUT CClusterDoc * pdoc, IN LPCTSTR lpszName);
  71. protected:
  72. void CommonConstruct(void);
  73. // Attributes
  74. protected:
  75. HKEY m_hkey;
  76. CString m_strName;
  77. CString m_strType;
  78. CString m_strDescription;
  79. IDS m_idsType;
  80. UINT m_iimgObjectType;
  81. UINT m_iimgState;
  82. CClusterDoc * m_pdoc;
  83. IDM m_idmPopupMenu;
  84. BOOL m_bDocObj;
  85. BOOL m_bChanged;
  86. BOOL m_bReadOnly;
  87. IDM IdmPopupMenu(void) const { return m_idmPopupMenu; }
  88. public:
  89. HKEY Hkey(void) const { return m_hkey; }
  90. const CString & StrName(void) const { return m_strName; }
  91. const CString & StrType(void) const { return m_strType; }
  92. const CString & StrDescription(void) const { return m_strDescription; }
  93. IDS IdsType(void) const { return m_idsType; }
  94. UINT IimgObjectType(void) const { return m_iimgObjectType; }
  95. UINT IimgState(void) const { return m_iimgState; }
  96. CClusterDoc * Pdoc(void) const { return m_pdoc; }
  97. BOOL BDocObj(void) const { return m_bDocObj; }
  98. BOOL BChanged(void) const { return m_bChanged; }
  99. BOOL BReadOnly(void) const { return m_bReadOnly; }
  100. void MarkAsChanged(IN BOOL bChanged = TRUE) { m_bChanged = bChanged; }
  101. #ifndef _DISPLAY_STATE_TEXT_IN_TREE
  102. void GetTreeName(OUT CString & rstrName) const { rstrName = StrName(); }
  103. #endif
  104. // Inline functions defined in ClusItem.inl because they reference
  105. // CClusterDoc, which isn't defined yet when this class is being defined.
  106. HCLUSTER Hcluster(void) const;
  107. HKEY HkeyCluster(void) const;
  108. // Operations
  109. public:
  110. void Delete(void);
  111. void RemoveItem(void);
  112. DWORD DwReadValue(IN LPCTSTR pszValueName, IN LPCTSTR pszKeyName, OUT CString & rstrValue);
  113. DWORD DwReadValue(IN LPCTSTR pszValueName, IN LPCTSTR pszKeyName, OUT CStringList & rlstrValue);
  114. DWORD DwReadValue(IN LPCTSTR pszValueName, IN LPCTSTR pszKeyName, OUT DWORD * pdwValue);
  115. DWORD DwReadValue(IN LPCTSTR pszValueName, IN LPCTSTR pszKeyName, OUT DWORD * pdwValue, IN DWORD dwDefault);
  116. DWORD DwReadValue(IN LPCTSTR pszValueName, IN LPCTSTR pszKeyName, OUT LPBYTE * ppbValue);
  117. DWORD DwReadValue(IN LPCTSTR pszValueName, OUT CString & rstrValue)
  118. { return DwReadValue(pszValueName, NULL, rstrValue); }
  119. DWORD DwReadValue(IN LPCTSTR pszValueName, OUT CStringList & rlstrValue)
  120. { return DwReadValue(pszValueName, NULL, rlstrValue); }
  121. DWORD DwReadValue(IN LPCTSTR pszValueName, OUT DWORD * pdwValue)
  122. { return DwReadValue(pszValueName, NULL, pdwValue); }
  123. DWORD DwReadValue(IN LPCTSTR pszValueName, OUT DWORD * pdwValue, IN DWORD dwDefault)
  124. { return DwReadValue(pszValueName, NULL, pdwValue, dwDefault); }
  125. DWORD DwReadValue(IN LPCTSTR pszValueName, OUT LPBYTE * ppbValue)
  126. { return DwReadValue(pszValueName, NULL, ppbValue); }
  127. void WriteValue(IN LPCTSTR pszValueName, IN LPCTSTR pszKeyName, IN const CString & rstrValue);
  128. void WriteValue(IN LPCTSTR pszValueName, IN LPCTSTR pszKeyName, IN const CStringList & rlstrValue);
  129. void WriteValue(IN LPCTSTR pszValueName, IN LPCTSTR pszKeyName, IN DWORD dwValue);
  130. void WriteValue(
  131. IN LPCTSTR pszValueName,
  132. IN LPCTSTR pszKeyName,
  133. IN const LPBYTE pbValue,
  134. IN DWORD cbValue,
  135. IN OUT LPBYTE * ppbPrevValue,
  136. IN DWORD cbPrevValue
  137. );
  138. void WriteValue(IN LPCTSTR pszValueName, IN const CString & rstrValue)
  139. { WriteValue(pszValueName, NULL, rstrValue); }
  140. void WriteValue(IN LPCTSTR pszValueName, IN const CStringList & rlstrValue)
  141. { WriteValue(pszValueName, NULL, rlstrValue); }
  142. void WriteValue(IN LPCTSTR pszValueName, IN DWORD dwValue)
  143. { WriteValue(pszValueName, NULL, dwValue); }
  144. void WriteValue(
  145. IN LPCTSTR pszValueName,
  146. IN const LPBYTE pbValue,
  147. IN DWORD cbValue,
  148. IN OUT LPBYTE * ppbPrevValue,
  149. IN DWORD cbPrevValue
  150. )
  151. { WriteValue(pszValueName, NULL, pbValue, cbValue, ppbPrevValue, cbPrevValue); }
  152. void DeleteValue(IN LPCTSTR pszValueName, IN LPCTSTR pszKeyName = NULL);
  153. CMenu * PmenuPopup(void);
  154. BOOL BDifferent(IN const CStringList & rlstr1, IN const CStringList & rlstr2);
  155. BOOL BDifferentOrdered(IN const CStringList & rlstr1, IN const CStringList & rlstr2);
  156. // Overrides
  157. public:
  158. virtual LPCTSTR PszTitle(void) const { return m_strName; }
  159. virtual void Cleanup(void) { return; }
  160. virtual void ReadItem(void) { return; }
  161. virtual void WriteItem(void);
  162. virtual void UpdateState(void);
  163. virtual void Rename(IN LPCTSTR pszName) { return; }
  164. virtual BOOL BGetColumnData(IN COLID colid, OUT CString & rstrText);
  165. virtual BOOL BCanBeEdited(void) const { return FALSE; }
  166. virtual void OnBeginLabelEdit(IN OUT CEdit * pedit) { return; }
  167. virtual BOOL BDisplayProperties(IN BOOL bReadOnly = FALSE);
  168. virtual BOOL BIsLabelEditValueValid(IN LPCTSTR pszName) { return TRUE; }
  169. // Drag & Drop
  170. virtual BOOL BCanBeDragged(void) const { return FALSE; }
  171. virtual BOOL BCanBeDropTarget(IN const CClusterItem * pci) const { return FALSE; }
  172. virtual void DropItem(IN OUT CClusterItem * pci)
  173. {
  174. }
  175. virtual const CStringList * PlstrExtensions(void) const;
  176. #ifdef _DISPLAY_STATE_TEXT_IN_TREE
  177. virtual void GetTreeName(OUT CString & rstrName) const;
  178. #endif
  179. // ClassWizard generated virtual function overrides
  180. //{{AFX_VIRTUAL(CClusterItem)
  181. //}}AFX_VIRTUAL
  182. virtual LRESULT OnClusterNotify(IN OUT CClusterNotify * pnotify);
  183. protected:
  184. virtual const CObjectProperty * Pprops(void) const { return NULL; }
  185. virtual DWORD Cprops(void) const { return 0; }
  186. virtual DWORD DwParseProperties(IN const CClusPropList & rcpl);
  187. virtual DWORD DwParseUnknownProperty(
  188. IN LPCWSTR pwszName,
  189. IN const CLUSPROP_BUFFER_HELPER & rvalue,
  190. IN DWORD cbBuf
  191. ) { return ERROR_SUCCESS; }
  192. virtual void SetCommonProperties(IN BOOL bValidateOnly = FALSE);
  193. virtual void BuildPropList(IN OUT CClusPropList & rcpl);
  194. virtual DWORD DwSetCommonProperties(IN const CClusPropList & rcpl, IN BOOL bValidateOnly = FALSE)
  195. { ASSERT(0); return ERROR_INVALID_FUNCTION; }
  196. // Implementation
  197. public:
  198. virtual ~CClusterItem(void);
  199. protected:
  200. CClusterNotifyKey * m_pcnk;
  201. CTreeItemList m_lptiBackPointers;
  202. CListItemList m_lpliBackPointers;
  203. public:
  204. const CClusterNotifyKey * Pcnk(void) const { return m_pcnk; }
  205. CTreeItemList & LptiBackPointers(void) { return m_lptiBackPointers; }
  206. CListItemList & LpliBackPointers(void) { return m_lpliBackPointers; }
  207. void AddTreeItem(CTreeItem * pti);
  208. void AddListItem(CListItem * pli);
  209. void RemoveTreeItem(CTreeItem * pti);
  210. void RemoveListItem(CListItem * pli);
  211. #undef afx_msg
  212. #define afx_msg virtual
  213. // Generated message map functions
  214. //{{AFX_MSG(CClusterItem)
  215. afx_msg void OnUpdateRename(CCmdUI* pCmdUI);
  216. afx_msg void OnUpdateProperties(CCmdUI* pCmdUI);
  217. afx_msg void OnCmdProperties();
  218. //}}AFX_MSG
  219. #undef afx_msg
  220. #define afx_msg
  221. DECLARE_MESSAGE_MAP()
  222. }; //*** class CClusterItem
  223. /////////////////////////////////////////////////////////////////////////////
  224. // CClusterItemList
  225. //
  226. // Every time an item is added to or removed from the list, its reference
  227. // count is updated.
  228. /////////////////////////////////////////////////////////////////////////////
  229. //class CClusterItemList : public CTypedPtrList<CObList, CClusterItem *>
  230. class CClusterItemList : public CList<CClusterItem *, CClusterItem *>
  231. {
  232. public:
  233. // Operations
  234. CClusterItem * PciFromName(
  235. IN LPCTSTR pszName,
  236. OUT POSITION * ppos = NULL
  237. );
  238. // add before head or after tail
  239. POSITION AddHead(CClusterItem * newElement)
  240. {
  241. ASSERT_VALID(newElement);
  242. POSITION pos = CList<CClusterItem *,CClusterItem *>::AddHead(newElement);
  243. if (pos != NULL)
  244. newElement->AddRef();
  245. return pos;
  246. }
  247. POSITION AddTail(CClusterItem * newElement)
  248. {
  249. ASSERT_VALID(newElement);
  250. POSITION pos = CList<CClusterItem *,CClusterItem *>::AddTail(newElement);
  251. if (pos != NULL)
  252. newElement->AddRef();
  253. return pos;
  254. }
  255. // inserting before or after a given position
  256. POSITION InsertBefore(POSITION position, CClusterItem * newElement)
  257. {
  258. ASSERT_VALID(newElement);
  259. POSITION pos = CList<CClusterItem *,CClusterItem *>::InsertBefore(position, newElement);
  260. if (pos != NULL)
  261. newElement->AddRef();
  262. return pos;
  263. }
  264. POSITION InsertAfter(POSITION position, CClusterItem * newElement)
  265. {
  266. ASSERT_VALID(newElement);
  267. POSITION pos = CList<CClusterItem *,CClusterItem *>::InsertAfter(position, newElement);
  268. if (pos != NULL)
  269. newElement->AddRef();
  270. return pos;
  271. }
  272. // void RemoveAll(void);
  273. }; //*** class CClusterItemList
  274. /////////////////////////////////////////////////////////////////////////////
  275. // Global Functions
  276. /////////////////////////////////////////////////////////////////////////////
  277. template<>
  278. void AFXAPI DestructElements(CClusterItem ** pElements, INT_PTR nCount);
  279. void DeleteAllItemData(IN OUT CClusterItemList & rlp);
  280. /////////////////////////////////////////////////////////////////////////////
  281. // Global Variables
  282. /////////////////////////////////////////////////////////////////////////////
  283. #ifdef _DEBUG
  284. extern CTraceTag g_tagClusItemCreate;
  285. extern CTraceTag g_tagClusItemDelete;
  286. extern CTraceTag g_tagClusItemNotify;
  287. #endif
  288. /////////////////////////////////////////////////////////////////////////////
  289. #endif // _CLUSITEM_H_