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.

287 lines
8.2 KiB

  1. // This is a part of the Microsoft Management Console.
  2. // Copyright (C) Microsoft Corporation, 1995 - 1999
  3. // All rights reserved.
  4. //
  5. // This source code is only intended as a supplement to the
  6. // Microsoft Management Console and related
  7. // electronic documentation provided with the interfaces.
  8. // Compdata.h : Declaration of the CComponentDataImpl
  9. #ifndef _COMPDATA_H_
  10. #define _COMPDATA_H_
  11. #include "resource.h" // main symbols
  12. #ifndef __mmc_h__
  13. #include <mmc.h>
  14. #endif
  15. class CFolder;
  16. /////////////////////////////
  17. // File Versions
  18. // current version
  19. // VER_CCOMPDATA_SAVE_STREAM_3 includes dwFlags,
  20. // m_cLastKnownSchema, m_rgLastKnownSchema
  21. #define VER_CCOMPDATA_SAVE_STREAM_3 0x003
  22. // version written through Win2000 beta 3
  23. #define VER_CCOMPDATA_SAVE_STREAM_2 0x002
  24. /////////////////////////////
  25. // CCompDataImpl dwFlags
  26. #define WSZ_MACHINE_OVERRIDE_SWITCH L"/MACHINE:"
  27. #define CERTMMC_PROPERTY_CHANGE_REFRESHVIEWS 0x200
  28. // Note - This is the offset in my image list that represents the folder
  29. enum IMAGE_INDEXES
  30. {
  31. IMGINDEX_FOLDER = 0,
  32. IMGINDEX_FOLDER_OPEN,
  33. IMGINDEX_CRL,
  34. IMGINDEX_CERT,
  35. IMGINDEX_PENDING_CERT,
  36. IMGINDEX_CERTSVR,
  37. IMGINDEX_CERTSVR_RUNNING,
  38. IMGINDEX_CERTSVR_STOPPED,
  39. IMGINDEX_NO_IMAGE,
  40. };
  41. // Event Values
  42. #define IDC_STOPSERVER 0x100
  43. #define IDC_STARTSERVER 0x101
  44. #define IDC_PUBLISHCRL 0x110
  45. #define IDC_REVOKECERT 0x112
  46. #define IDC_RESUBMITREQUEST 0x113
  47. #define IDC_DENYREQUEST 0x114
  48. #define IDC_BACKUP_CA 0x115
  49. #define IDC_RESTORE_CA 0x116
  50. #define IDC_INSTALL_CA 0x117
  51. #define IDC_REQUEST_CA 0x118
  52. #define IDC_ROLLOVER_CA 0x119
  53. #define IDC_SUBMITREQUEST 0x11a
  54. #define IDC_VIEW_CERT_PROPERTIES 0x140
  55. #define IDC_VIEW_ALLRECORDS 0x141
  56. #define IDC_VIEW_FILTER 0x142
  57. #define IDC_VIEW_ATTR_EXT 0x143
  58. #define IDC_RETARGET_SNAPIN 0x150
  59. #define IDC_UNREVOKE_CERT 0x160
  60. #define HTMLHELP_FILENAME L"cs.chm"
  61. #define HTMLHELP_COLLECTION_FILENAME L"\\help\\" HTMLHELP_FILENAME
  62. #define HTMLHELP_COLLECTIONLINK_FILENAME L"\\help\\csconcepts.chm"
  63. #define MFS_HIDDEN 0xFFFFFFFF
  64. #define MAX_RESOURCE_STRLEN 256
  65. typedef struct _MY_CONTEXTMENUITEM
  66. {
  67. CONTEXTMENUITEM item;
  68. UINT uiString1;
  69. UINT uiString2;
  70. WCHAR szString1[MAX_RESOURCE_STRLEN];
  71. WCHAR szString2[MAX_RESOURCE_STRLEN];
  72. } MY_CONTEXTMENUITEM, *PMY_CONTEXTMENUITEM;
  73. #define TASKITEM_FLAG_RESULTITEM 0x1
  74. #define TASKITEM_FLAG_LOCALONLY 0x2
  75. typedef struct _TASKITEM
  76. {
  77. FOLDER_TYPES type;
  78. DWORD dwFlags;
  79. MY_CONTEXTMENUITEM myitem;
  80. } TASKITEM;
  81. MY_CONTEXTMENUITEM menuItems[];
  82. MY_CONTEXTMENUITEM taskStartStop[];
  83. TASKITEM taskItems[];
  84. TASKITEM viewItems[];
  85. TASKITEM topItems[];
  86. // ICompData inserted
  87. TASKITEM taskResultItemsSingleSel[];
  88. MY_CONTEXTMENUITEM viewResultItems[];
  89. // m_dwPersistFlags
  90. #define CCOMPDATAIMPL_FLAGS_ALLOW_MACHINE_OVERRIDE 0x1
  91. class CComponentDataImpl:
  92. public IComponentData,
  93. public IExtendPropertySheet,
  94. public IExtendContextMenu,
  95. public IPersistStream,
  96. public CComObjectRoot,
  97. public ISnapinHelp2
  98. {
  99. BEGIN_COM_MAP(CComponentDataImpl)
  100. COM_INTERFACE_ENTRY(IComponentData)
  101. COM_INTERFACE_ENTRY(IExtendPropertySheet)
  102. COM_INTERFACE_ENTRY(IExtendContextMenu)
  103. COM_INTERFACE_ENTRY(IPersistStream)
  104. COM_INTERFACE_ENTRY(ISnapinHelp2)
  105. END_COM_MAP()
  106. friend class CSnapin;
  107. friend class CDataObject;
  108. CComponentDataImpl();
  109. virtual ~CComponentDataImpl();
  110. public:
  111. virtual const CLSID& GetCoClassID() = 0;
  112. virtual const BOOL IsPrimaryImpl() = 0;
  113. public:
  114. // ISnapinHelp2 interface members
  115. STDMETHOD(GetHelpTopic)(LPOLESTR* lpCompiledHelpFile);
  116. STDMETHOD(GetLinkedTopics)(LPOLESTR* lpCompiledHelpFiles);
  117. // IComponentData interface members
  118. STDMETHOD(Initialize)(LPUNKNOWN pUnknown);
  119. STDMETHOD(CreateComponent)(LPCOMPONENT* ppComponent);
  120. STDMETHOD(Notify)(LPDATAOBJECT lpDataObject, MMC_NOTIFY_TYPE event, LPARAM arg, LPARAM param);
  121. STDMETHOD(Destroy)();
  122. STDMETHOD(QueryDataObject)(MMC_COOKIE cookie, DATA_OBJECT_TYPES type, LPDATAOBJECT* ppDataObject);
  123. STDMETHOD(GetDisplayInfo)(SCOPEDATAITEM* pScopeDataItem);
  124. STDMETHOD(CompareObjects)(LPDATAOBJECT lpDataObjectA, LPDATAOBJECT lpDataObjectB);
  125. // IExtendPropertySheet interface
  126. public:
  127. STDMETHOD(CreatePropertyPages)(LPPROPERTYSHEETCALLBACK lpProvider,
  128. LONG_PTR handle,
  129. LPDATAOBJECT lpIDataObject);
  130. STDMETHOD(QueryPagesFor)(LPDATAOBJECT lpDataObject);
  131. // IExtendContextMenu
  132. public:
  133. STDMETHOD(AddMenuItems)(LPDATAOBJECT pDataObject, LPCONTEXTMENUCALLBACK pCallbackUnknown,
  134. LONG *pInsertionAllowed);
  135. STDMETHOD(Command)(LONG nCommandID, LPDATAOBJECT pDataObject);
  136. public:
  137. // IPersistStream interface members
  138. STDMETHOD(GetClassID)(CLSID *pClassID);
  139. STDMETHOD(IsDirty)();
  140. STDMETHOD(Load)(IStream *pStm);
  141. STDMETHOD(Save)(IStream *pStm, BOOL fClearDirty);
  142. STDMETHOD(GetSizeMax)(ULARGE_INTEGER *pcbSize);
  143. #if DBG
  144. bool m_bInitializedCD;
  145. bool m_bLoadedCD;
  146. bool m_bDestroyedCD;
  147. #endif
  148. // Notify handler declarations
  149. private:
  150. HRESULT OnDelete(MMC_COOKIE cookie);
  151. HRESULT OnRemoveChildren(LPARAM arg);
  152. HRESULT OnRename(MMC_COOKIE cookie, LPARAM arg, LPARAM param);
  153. HRESULT OnExpand(LPDATAOBJECT lpDataObject, LPARAM arg, LPARAM param);
  154. HRESULT OnProperties(LPARAM param);
  155. public:
  156. STDMETHOD_(ULONG, AddRef) ();
  157. STDMETHOD_(ULONG, Release) ();
  158. LONG _cRefs;
  159. // Scope item creation helpers
  160. private:
  161. BOOL AddStartStopTasks(
  162. LPCONTEXTMENUCALLBACK pContextMenuCallback,
  163. BOOL fSvcRunning);
  164. void UpdateScopeIcons();
  165. HRESULT DisplayProperRootNodeName(HSCOPEITEM hScopeItem);
  166. private:
  167. CFolder* FindObject(MMC_COOKIE cookie);
  168. // display synchronization code
  169. HRESULT SynchDisplayedCAList(LPDATAOBJECT lpDataObject);
  170. HRESULT BaseFolderInsertIntoScope(CFolder* pFolder, CertSvrCA* pCA);
  171. HRESULT CreateTemplateFolders(CertSvrCA* pCA);
  172. void EnumerateScopePane(LPDATAOBJECT lpDataObject, HSCOPEITEM pParent);
  173. BOOL IsScopePaneNode(LPDATAOBJECT lpDataObject);
  174. private:
  175. LPCONSOLENAMESPACE2 m_pScope; // My interface pointer to the scope pane
  176. LPCONSOLE2 m_pConsole; // My interface pointer to the console
  177. HSCOPEITEM m_pStaticRoot;
  178. DWORD m_dwNextViewIndex; // assign to CComponent to keep them seperate
  179. BOOL m_bIsDirty;
  180. void SetDirty(BOOL b = TRUE) { m_bIsDirty = b; }
  181. void ClearDirty() { m_bIsDirty = FALSE; }
  182. BOOL ThisIsDirty() { return m_bIsDirty; }
  183. ////////
  184. // persist
  185. // General-purpose flags to be persisted into .msc file
  186. DWORD m_dwFlagsPersist;
  187. CertSvrMachine* m_pCertMachine;
  188. CFolder* m_pCurSelFolder;
  189. GUID m_guidInstance; // keeps column data straight -- new id for each instance
  190. DWORD m_cLastKnownSchema;
  191. CString* m_rgcstrLastKnownSchema;
  192. // end persist
  193. ///////////////
  194. // non-persistent schema info
  195. LONG* m_rgltypeLastKnownSchema;
  196. BOOL* m_rgfindexedLastKnownSchema;
  197. BOOL m_fSchemaWasResolved; // only resolve once
  198. public:
  199. int FindColIdx(IN LPCWSTR szHeading);
  200. DWORD GetSchemaEntries() { return m_cLastKnownSchema; }
  201. HRESULT GetDBSchemaEntry(int iIndex, LPCWSTR* pszHeading, LONG* plType, BOOL* pfIndexed);
  202. HRESULT SetDBSchema(CString* rgcstr, LONG* rgtype, BOOL* rgfIndexed, DWORD cEntries);
  203. void ResetPersistedColumnInformation() { HRESULT hr = UuidCreate(&m_guidInstance); }
  204. private:
  205. CList<CFolder*, CFolder*> m_scopeItemList;
  206. BOOL m_fScopeAlreadyEnumerated;
  207. };
  208. class CComponentDataPrimaryImpl : public CComponentDataImpl,
  209. public CComCoClass<CComponentDataPrimaryImpl, &CLSID_Snapin>
  210. {
  211. public:
  212. DECLARE_REGISTRY(CSnapin, _T("CertSvrAdmin Snapin.Snapin.1"), _T("CertSvrAdmin Snapin.Snapin"), IDS_SNAPIN_DESC, THREADFLAGS_APARTMENT)
  213. virtual const CLSID & GetCoClassID() { return CLSID_Snapin; }
  214. virtual const BOOL IsPrimaryImpl() { return TRUE; }
  215. };
  216. #endif // #define _COMPDATA_H_