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.

904 lines
25 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Windows NT Directory Service Administration SnapIn
  4. //
  5. // Microsoft Windows
  6. // Copyright (C) Microsoft Corporation, 1992 - 1999
  7. //
  8. // File: dssnap.h
  9. //
  10. // Contents: DS App
  11. //
  12. // History: 02-Oct-96 WayneSc Created
  13. //
  14. //--------------------------------------------------------------------------
  15. #ifndef __DSSNAP_H__
  16. #define __DSSNAP_H__
  17. #ifndef __DSCOOKIE_H__
  18. #include "dscookie.h"
  19. #endif
  20. #ifndef __DSCACHE_H__
  21. #include "dscache.h" // CDSCache
  22. #endif
  23. #define OPCODE_MOVE 0x00000001L
  24. #define OPCODE_DELETE 0x00000002L
  25. // this isn't really a context menu op code, its a flag we use to know
  26. // which icon to return for this object if the enumberation failed
  27. // see dssnap.cpp->ChangeScopeItemIcon()
  28. #define OPCODE_ENUM_FAILED 0x00000004L
  29. // another pseudo opcode, to track whether we're enumerating or
  30. // expanding
  31. #define OPCODE_EXPAND_IN_PROGRESS 0x00000008L
  32. #define DS_DELETE_OCCURRED 900
  33. #define DS_RENAME_OCCURRED 901
  34. #define DS_MOVE_OCCURRED 902
  35. #define DS_CREATE_OCCURRED 903
  36. #define DS_REFRESH_REQUESTED 904
  37. #define DS_VERB_UPDATE 905
  38. #define DS_ICON_STRIP_UPDATE 907
  39. #define DS_HAVE_DATA 908
  40. #define DS_UPDATE_OCCURRED 909
  41. #define DS_MULTIPLE_DELETE_OCCURRED 910
  42. #define DS_MULTIPLE_MOVE_OCCURRED 911
  43. #define DS_CHECK_COLUMN_WIDTHS 912
  44. #define DS_IS_COOKIE_SELECTION 913
  45. #define DS_CREATE_OCCURRED_RESULT_PANE 914
  46. #define DS_DELAYED_EXPAND 915
  47. #define DS_SORT_RESULT_PANE 916
  48. #define DS_UPDATE_VISIBLE_COLUMNS 917
  49. #define DS_UPDATE_OBJECT_COUNT 918
  50. #define DS_UNSELECT_OBJECT 919
  51. #define DS_DEFAULT_COLUMN_COUNT 3
  52. #define DEFAULT_NAME_COL_WIDTH 125
  53. #define DEFAULT_TYPE_COL_WIDTH 175
  54. #define DEFAULT_DESC_COL_WIDTH 400
  55. #define NARROW_DESC_COL_WIDTH 200
  56. // forward declarations
  57. class CDSCookie;
  58. class CDSQueryFilter;
  59. class CHiddenWnd;
  60. class CDSQueryResult;
  61. class CWorkerThread;
  62. struct CBackgroundThreadInfo;
  63. class CFavoritesNodesHolder;
  64. /////////////////////////////////////////////////////////////////////////////
  65. // CTargetingInfo
  66. class CTargetingInfo
  67. {
  68. public:
  69. CTargetingInfo()
  70. {
  71. m_dwFlags = 0x0;
  72. _InitFromCommandLine();
  73. }
  74. HRESULT Load(IStream* pStm);
  75. HRESULT Save(IStream* pStm, LPCWSTR lpszCurrentTargetName);
  76. BOOL GetSaveCurrent()
  77. {
  78. return (m_dwFlags & m_dwSaveDomainFlag) != 0;
  79. }
  80. void SetSaveCurrent(BOOL bSave)
  81. {
  82. if (bSave)
  83. m_dwFlags |= m_dwSaveDomainFlag;
  84. else
  85. m_dwFlags &= ~m_dwSaveDomainFlag;
  86. }
  87. LPCWSTR GetTargetString() { return m_szStoredTargetName; }
  88. LPCWSTR GetRootRDN() { return m_szRootRDN;}
  89. #ifdef _MMC_ISNAPIN_PROPERTY
  90. HRESULT InitFromSnapinProperties(long cProps, //property count
  91. MMC_SNAPIN_PROPERTY* pProps //properties array
  92. );
  93. #endif // _MMC_ISNAPIN_PROPERTY
  94. private:
  95. void _InitFromCommandLine();
  96. DWORD m_dwFlags;
  97. CString m_szStoredTargetName;
  98. CString m_szRootRDN;
  99. static const DWORD m_dwSaveDomainFlag;
  100. };
  101. /////////////////////////////////////////////////////////////////////////////
  102. // CIconManager
  103. class CIconManager
  104. {
  105. public:
  106. CIconManager()
  107. {
  108. m_pScpImageList = NULL;
  109. // set the special indexes to invalid values
  110. m_iRootIconIndex = m_iRootIconErrIndex =
  111. m_iWaitIconIndex = m_iWarnIconIndex =
  112. m_iFavoritesIconIndex = m_iQueryIconIndex =
  113. m_iQueryInvalidIconIndex = 0;
  114. }
  115. ~CIconManager()
  116. {
  117. }
  118. HRESULT Init(IImageList* pScpImageList, SnapinType snapintype);
  119. HRESULT FillInIconStrip(IImageList* pImageList);
  120. HRESULT AddClassIcon(IN LPCWSTR lpszClass,
  121. IN MyBasePathsInfo* pPathInfo,
  122. IN DWORD dwFlags,
  123. INOUT int* pnIndex);
  124. HRESULT AddIcon(IN HICON hiClass16, IN HICON hiClass32, INOUT int* pnIndex);
  125. int GetRootIndex() { return m_iRootIconIndex;}
  126. int GetRootErrIndex() { return m_iRootIconErrIndex;}
  127. int GetWaitIndex() { return m_iWaitIconIndex;}
  128. int GetWarnIndex() { return m_iWarnIconIndex;}
  129. int GetFavoritesIndex() { return m_iFavoritesIconIndex;}
  130. int GetQueryIndex() { return m_iQueryIconIndex;}
  131. int GetQueryInvalidIndex() { return m_iQueryInvalidIconIndex; }
  132. private:
  133. IImageList* m_pScpImageList; // no addref, lifetime of IComponentData
  134. class CIconInfo
  135. {
  136. public:
  137. CIconInfo() { m_hiClass16 = m_hiClass32 = NULL;}
  138. HICON m_hiClass16;
  139. HICON m_hiClass32;
  140. };
  141. class CIconInfoList : public CList <CIconInfo*, CIconInfo*>
  142. {
  143. public:
  144. ~CIconInfoList()
  145. {
  146. while (!IsEmpty())
  147. delete RemoveHead();
  148. }
  149. };
  150. CIconInfoList m_IconInfoList; // list of icon handles
  151. // special icon indexes we need to know about
  152. int m_iRootIconIndex;
  153. int m_iRootIconErrIndex;
  154. int m_iWaitIconIndex;
  155. int m_iWarnIconIndex;
  156. int m_iFavoritesIconIndex;
  157. int m_iQueryIconIndex;
  158. int m_iQueryInvalidIconIndex;
  159. HRESULT _LoadIconFromResource(IN UINT nIconResID, INOUT int* pnIndex);
  160. int _GetBaseIndex() { return 1;}
  161. int _GetNextFreeIndex()
  162. { return (int)(m_IconInfoList.GetCount() + _GetBaseIndex());}
  163. };
  164. /////////////////////////////////////////////////////////////////////////////
  165. // CInternalFormatCracker
  166. class CInternalFormatCracker
  167. {
  168. public:
  169. CInternalFormatCracker()
  170. {
  171. m_pInternalFormat = NULL;
  172. }
  173. ~CInternalFormatCracker()
  174. {
  175. _Free();
  176. }
  177. BOOL HasData() { return m_pInternalFormat != NULL;}
  178. HRESULT Extract(LPDATAOBJECT lpDataObject);
  179. LPDATAOBJECT ExtractMultiSelect(LPDATAOBJECT lpDataObject);
  180. CUINode* GetCookie(UINT nIndex = 0)
  181. {
  182. ASSERT(m_pInternalFormat != NULL);
  183. if (nIndex == 0)
  184. {
  185. return m_pInternalFormat->m_cookie;
  186. }
  187. else if ( (m_pInternalFormat->m_p_cookies != NULL) &&
  188. (nIndex < m_pInternalFormat->m_cookie_count))
  189. {
  190. return m_pInternalFormat->m_p_cookies[nIndex-1];
  191. }
  192. ASSERT(FALSE);
  193. return NULL;
  194. }
  195. UINT GetCookieCount()
  196. {
  197. ASSERT(m_pInternalFormat != NULL);
  198. return m_pInternalFormat->m_cookie_count;
  199. }
  200. DATA_OBJECT_TYPES GetType()
  201. {
  202. ASSERT(m_pInternalFormat != NULL);
  203. return m_pInternalFormat->m_type;
  204. }
  205. SnapinType GetSnapinType()
  206. {
  207. ASSERT(m_pInternalFormat != NULL);
  208. return m_pInternalFormat->m_snapintype;
  209. }
  210. private:
  211. INTERNAL* m_pInternalFormat;
  212. void _Free()
  213. {
  214. if (m_pInternalFormat != NULL)
  215. {
  216. ::GlobalFree(m_pInternalFormat);
  217. m_pInternalFormat = NULL;
  218. }
  219. }
  220. };
  221. //
  222. // this is just a function to make sure we have
  223. // consistent node types in the object cracker
  224. //
  225. template <class T>
  226. BOOL AreAllNodesOfType(CInternalFormatCracker* pInternalObjectCracker)
  227. {
  228. UINT nCount = pInternalObjectCracker->GetCookieCount();
  229. for (UINT k=0; k<nCount; k++)
  230. {
  231. if (!IS_CLASS(*(pInternalObjectCracker->GetCookie(k)), T))
  232. return FALSE;
  233. }
  234. return TRUE;
  235. }
  236. /////////////////////////////////////////////////////////////////////
  237. // CObjectNamesFormatCracker
  238. class CObjectNamesFormatCracker
  239. {
  240. public:
  241. CObjectNamesFormatCracker()
  242. {
  243. m_pDsObjectNames = NULL;
  244. }
  245. ~CObjectNamesFormatCracker()
  246. {
  247. _Free();
  248. }
  249. BOOL HasData() { return m_pDsObjectNames != NULL;}
  250. HRESULT Extract(LPDATAOBJECT lpDataObject);
  251. UINT GetCount()
  252. {
  253. ASSERT(m_pDsObjectNames != NULL);
  254. return m_pDsObjectNames->cItems;
  255. }
  256. LPCWSTR GetName(UINT nIndex)
  257. {
  258. ASSERT(nIndex < GetCount());
  259. return (LPCWSTR)ByteOffset(m_pDsObjectNames, m_pDsObjectNames->aObjects[nIndex].offsetName);
  260. }
  261. LPCWSTR GetClass(UINT nIndex)
  262. {
  263. ASSERT(nIndex < GetCount());
  264. return (LPCWSTR)ByteOffset(m_pDsObjectNames, m_pDsObjectNames->aObjects[nIndex].offsetClass);
  265. }
  266. DWORD GetProviderFlags(UINT nIndex)
  267. {
  268. ASSERT(nIndex < GetCount());
  269. return m_pDsObjectNames->aObjects[nIndex].dwProviderFlags;
  270. }
  271. DWORD GetFlags(UINT nIndex)
  272. {
  273. ASSERT(nIndex < GetCount());
  274. return m_pDsObjectNames->aObjects[nIndex].dwFlags;
  275. }
  276. BOOL IsContainer(UINT nIndex)
  277. {
  278. ASSERT(nIndex < GetCount());
  279. return (GetFlags((nIndex) & DSOBJECT_ISCONTAINER) != 0);
  280. }
  281. void Reset() { _Free();}
  282. // Property Page Clipboard formats
  283. static CLIPFORMAT m_cfDsObjectNames;
  284. private:
  285. LPDSOBJECTNAMES m_pDsObjectNames;
  286. void _Free()
  287. {
  288. if (m_pDsObjectNames != NULL)
  289. {
  290. ::GlobalFree(m_pDsObjectNames);
  291. m_pDsObjectNames = NULL;
  292. }
  293. }
  294. };
  295. /////////////////////////////////////////////////////////////////////
  296. // CTopLevelCNInfo
  297. class CTopLevelCNInfo
  298. {
  299. public:
  300. CTopLevelCNInfo()
  301. {
  302. m_nCount = 0;
  303. m_pStringArr = NULL;
  304. m_pdwFlags = NULL;
  305. }
  306. ~CTopLevelCNInfo()
  307. {
  308. Free();
  309. }
  310. BOOL Alloc(UINT nCount)
  311. {
  312. CString* pstr = new CString[nCount];
  313. if (pstr == NULL)
  314. return FALSE;
  315. DWORD* pdw = new DWORD[nCount];
  316. if (pdw == NULL)
  317. {
  318. delete[] pstr;
  319. return FALSE;
  320. }
  321. ZeroMemory( pdw, nCount*sizeof(DWORD) );
  322. m_pStringArr = pstr;
  323. m_pdwFlags = pdw;
  324. m_nCount = nCount;
  325. return TRUE;
  326. }
  327. void Free()
  328. {
  329. m_nCount = 0;
  330. if (m_pStringArr != NULL)
  331. {
  332. delete[] m_pStringArr;
  333. m_pStringArr = NULL;
  334. }
  335. if (m_pdwFlags != NULL)
  336. {
  337. delete[] m_pdwFlags;
  338. m_pdwFlags = NULL;
  339. }
  340. }
  341. UINT m_nCount;
  342. CString* m_pStringArr;
  343. DWORD* m_pdwFlags;
  344. };
  345. #define TOPLEVEL_FLAG_SERVICES_NODE 0x1
  346. /////////////////////////////////////////////////////////////////////
  347. // CDSNotifyHandlerManager
  348. class CDSNotifyHandlerManager
  349. {
  350. private:
  351. class CDSNotifyHandlerInfo
  352. {
  353. public:
  354. CDSNotifyHandlerInfo()
  355. {
  356. m_nRegisteredEvents = 0;
  357. m_nFlags = 0;
  358. m_bTransactionPending = FALSE;
  359. m_bNeedsNotify = FALSE;
  360. }
  361. CComPtr<IDsAdminNotifyHandler> m_spIDsAdminNotifyHandler;
  362. ULONG m_nRegisteredEvents;
  363. ULONG m_nFlags;
  364. CString m_szDisplayString;
  365. BOOL m_bTransactionPending;
  366. BOOL m_bNeedsNotify;
  367. };
  368. public:
  369. CDSNotifyHandlerManager()
  370. {
  371. m_nArrSize = 0;
  372. m_pInfoArr = NULL;
  373. m_state = uninitialized;
  374. }
  375. ~CDSNotifyHandlerManager()
  376. {
  377. _Free();
  378. }
  379. BOOL HasHandlers() { return m_state == hasHandlers;}
  380. HRESULT Init();
  381. HRESULT Load(MyBasePathsInfo* pBasePathInfo); // do the actual extension loading and initialization
  382. // mapping to COM notification interfaces
  383. void Begin(ULONG uEvent, IDataObject* pArg1, IDataObject* pArg2);
  384. void Notify(ULONG nItem, ULONG uEvent);
  385. void End(ULONG uEvent);
  386. // state veriables check
  387. UINT NeedNotifyCount(ULONG uEvent);
  388. // handlers for visualization in confirnation dialog
  389. void SetCheckListBox(CCheckListBox* pCheckListBox, ULONG uEvent);
  390. void ReadFromCheckListBox(CCheckListBox* pCheckListBox, ULONG uEvent);
  391. private:
  392. CDSNotifyHandlerInfo* m_pInfoArr;
  393. UINT m_nArrSize;
  394. enum HandlerState { uninitialized, hasHandlers, noHandlers};
  395. HandlerState m_state;
  396. void _Free()
  397. {
  398. if (m_pInfoArr != NULL)
  399. {
  400. ASSERT(m_nArrSize >0);
  401. delete[] m_pInfoArr;
  402. }
  403. m_nArrSize = 0;
  404. m_pInfoArr = NULL;
  405. m_state = uninitialized;
  406. }
  407. };
  408. /////////////////////////////////////////////////////////////////////
  409. // CDSComponentData
  410. typedef struct _UINODESELECTIONP {
  411. CUINode* pUINode;
  412. BOOL IsSelection;
  413. } UINODESELECTION, * PUINODESELECTION;
  414. class CDSComponentData:
  415. public IComponentData,
  416. public IExtendPropertySheet,
  417. public IExtendContextMenu,
  418. public IPersistStream,
  419. #ifdef _MMC_ISNAPIN_PROPERTY
  420. public ISnapinProperties,
  421. #endif
  422. public ISnapinHelp2,
  423. public CComObjectRoot
  424. {
  425. BEGIN_COM_MAP(CDSComponentData)
  426. COM_INTERFACE_ENTRY(IComponentData)
  427. COM_INTERFACE_ENTRY(IExtendPropertySheet)
  428. COM_INTERFACE_ENTRY(IExtendContextMenu)
  429. COM_INTERFACE_ENTRY(IPersistStream)
  430. #ifdef _MMC_ISNAPIN_PROPERTY
  431. COM_INTERFACE_ENTRY(ISnapinProperties)
  432. #endif
  433. COM_INTERFACE_ENTRY(ISnapinHelp)
  434. COM_INTERFACE_ENTRY(ISnapinHelp2)
  435. END_COM_MAP()
  436. friend class CDSClassCacheItemBase;
  437. friend class CDSEvent;
  438. friend class CDSDataObject;
  439. friend class CDSDirect;
  440. friend class CDSContextMenu;
  441. CDSComponentData();
  442. HRESULT FinalConstruct();
  443. void FinalRelease();
  444. ~CDSComponentData();
  445. public:
  446. // IComponentData interface members
  447. STDMETHOD(Initialize)(LPUNKNOWN pUnknown);
  448. STDMETHOD(CreateComponent)(LPCOMPONENT* ppComponent);
  449. STDMETHOD(Notify)(LPDATAOBJECT lpDataObject, MMC_NOTIFY_TYPE event, LPARAM arg, LPARAM param);
  450. STDMETHOD(Destroy)();
  451. STDMETHOD(QueryDataObject)(MMC_COOKIE cookie, DATA_OBJECT_TYPES type, LPDATAOBJECT* ppDataObject);
  452. STDMETHOD(GetDisplayInfo)(LPSCOPEDATAITEM scopeInfo);
  453. STDMETHOD(CompareObjects) (IDataObject * pDataObject, IDataObject * pDataObject2);
  454. // IExtendPropertySheet interface
  455. public:
  456. STDMETHOD(CreatePropertyPages)(LPPROPERTYSHEETCALLBACK lpProvider,
  457. LONG_PTR handle,
  458. LPDATAOBJECT lpIDataObject);
  459. STDMETHOD(QueryPagesFor)(LPDATAOBJECT lpDataObject);
  460. // IExtendContextMenu
  461. public:
  462. STDMETHOD(AddMenuItems)(LPDATAOBJECT pDataObject,
  463. LPCONTEXTMENUCALLBACK pCallbackUnknown,
  464. long *pInsertionAllowed);
  465. STDMETHOD(Command)(long nCommandID, LPDATAOBJECT pDataObject);
  466. public:
  467. // IPersistStream interface members
  468. STDMETHOD(GetClassID)(CLSID *pClassID);
  469. STDMETHOD(IsDirty)();
  470. STDMETHOD(Load)(IStream *pStm);
  471. STDMETHOD(Save)(IStream *pStm, BOOL fClearDirty);
  472. STDMETHOD(GetSizeMax)(ULARGE_INTEGER *pcbSize);
  473. // ISnapinHelp2 interface members
  474. STDMETHOD(GetHelpTopic)(LPOLESTR* lpCompiledHelpFile);
  475. STDMETHOD(GetLinkedTopics)(LPOLESTR* lpCompiledHelpFile);
  476. #ifdef _MMC_ISNAPIN_PROPERTY
  477. // ISnapinProperties
  478. STDMETHOD(Initialize) (Properties* pProperties);
  479. STDMETHOD(QueryPropertyNames) (ISnapinPropertiesCallback* pCallback);
  480. STDMETHOD(PropertiesChanged) (long cProperties, MMC_SNAPIN_PROPERTY* pProperties);
  481. #endif //_MMC_ISNAPIN_PROPERTY
  482. public:
  483. virtual SnapinType QuerySnapinType() = 0;
  484. LPCWSTR GetRootPath(void) { return m_RootNode.GetPath(); }
  485. PDSDISPLAYSPECOPTIONS GetDsDisplaySpecOptions()
  486. {
  487. return m_DsDisplaySpecOptionsCFHolder.Get();
  488. }
  489. HRESULT AddClassIcon(IN LPCWSTR lpszClass, IN DWORD dwFlags, INOUT int* pnIndex);
  490. HRESULT FillInIconStrip(IImageList* pImageList);
  491. HWND GetHWnd() { return m_hwnd;}
  492. CRootNode* GetRootNode() { return &m_RootNode;}
  493. CDSDirect* GetActiveDS() { return m_ActiveDS;}
  494. BOOL ExpandComputers();
  495. BOOL IsAdvancedView();
  496. BOOL ViewServicesNode();
  497. HRESULT ToggleDisabled(CDSUINode* pDSUINode, BOOL bDisable);
  498. void AddScopeItemToUI(CUINode* pUINode, BOOL bSetSelected = FALSE);
  499. void AddListOfNodesToUI(CUINode* pUINode, CUINodeList* pNodeList);
  500. HRESULT ReadUINodeFromLdapPath(IN CDSUINode* pContainerDSUINode,
  501. IN LPCWSTR lpszLdapPath,
  502. OUT CDSUINode** ppSUINodeNew);
  503. HRESULT UpdateItem(CUINode* pNode);
  504. private:
  505. HRESULT _OnExpand(CUINode* pNode, HSCOPEITEM hParent, MMC_NOTIFY_TYPE event);
  506. HRESULT _OnPreload(HSCOPEITEM hRoot);
  507. HRESULT BuildDsDisplaySpecOptionsStruct()
  508. {
  509. return m_DsDisplaySpecOptionsCFHolder.Init(GetBasePathsInfo());
  510. }
  511. HRESULT _AddScopeItem(CUINode* pUINode, HSCOPEITEM hParent, BOOL bSetSelected = FALSE);
  512. HRESULT _ChangeRootItemIcon(int nImage);
  513. HRESULT _ChangeResultItemIcon(CUINode* pUINode);
  514. HRESULT _UpdateScopeItem(CUINode* pNode);
  515. // command helpers (called from Command())
  516. HRESULT _CommandNewDSObject(long nCommandID, LPDATAOBJECT pDataObject);
  517. HRESULT _CommandShellExtension(long nCommandID, LPDATAOBJECT pDataObject);
  518. // create object handler
  519. HRESULT _CreateDSObject(IN CDSUINode* pContainerDSUINode,
  520. IN LPCWSTR lpszObjectClass,
  521. IN CDSUINode* pCopyFromSUINode,
  522. OUT CDSUINode** ppSUINodeNew);
  523. // copy object handler
  524. HRESULT _CanCopyDSObject(IDataObject* pCopyFromDsObject);
  525. HRESULT _CopyDSObject(IDataObject* pCopyFromDsObject);
  526. // deletion helpers
  527. HRESULT _DeleteFromBackendAndUI(IDataObject* pDataObject, CDSUINode* pDSUINode);
  528. HRESULT _DeleteFromBackEnd(IDataObject* pDataObject, CDSCookie* pCookie);
  529. public: // expose to other objects
  530. HRESULT ChangeScopeItemIcon(CUINode* pUINode);
  531. HRESULT _DeleteSubtreeFromBackEnd(CDSCookie* pCookie);
  532. HRESULT RemoveContainerFromUI(CUINode* pUINode);
  533. HRESULT SetRenameMode(CUINode* pUINode);
  534. BOOL CanAddCookieToGroup(CDSCookie* pCookie, INT iGroupType, BOOL bMixedMode);
  535. HRESULT SelectScopeNode(CUINode* pUINode);
  536. void SortResultPane(CUINode* pUINode);
  537. CDSColumnSet* FindColumnSet(LPCWSTR lpszColumnID)
  538. {
  539. return (CDSColumnSet*)m_pClassCache->FindColumnSet(lpszColumnID);
  540. }
  541. HRESULT ColumnsChanged(CDSEvent* pDSEvent,
  542. CUINode* pUINode,
  543. MMC_VISIBLE_COLUMNS* pVisibleColumns,
  544. BOOL bRefresh);
  545. void ForceRefreshAll();
  546. HRESULT Refresh(CUINode* pNode, BOOL bFlushCache = FALSE, BOOL bFlushColumns = FALSE);
  547. HRESULT UpdateFromDS(CUINode* pUINode);
  548. BOOL IsSelectionAnywhere(CUINode* pUINode);
  549. // JonN 7/23/99
  550. // 373806: Site&Svcs: Renaming an auto-generated connection should make it admin owned
  551. BOOL RenameConnectionFixup(CDSCookie* pCookie);
  552. void ClearSubtreeHelperForRename(CUINode* pUINode);
  553. CDSCache* GetClassCache() { return m_pClassCache; }
  554. HRESULT FillInChildList(CDSCookie * pCookie);
  555. CDSQueryFilter* GetQueryFilter() { return m_pQueryFilter; }
  556. BOOL IsPrimarySnapin() { return m_bRunAsPrimarySnapin; }
  557. void GetDomain();
  558. void GetDC();
  559. BOOL CanRefreshAll();
  560. void RefreshAll();
  561. void EditFSMO();
  562. void RaiseVersion(void);
  563. CUINode* MoveObjectInUI(CDSUINode* pDSUINode);
  564. HRESULT FindParentCookie(LPCWSTR lpszCookieDN, CUINode** ppParentUINode);
  565. BOOL FindUINodeByDN(CUINode* pContainerNode,
  566. PCWSTR pszDN,
  567. CUINode** ppFoundNode);
  568. void InvalidateSavedQueriesContainingObjects(const CUINodeList& refUINodeList);
  569. void InvalidateSavedQueriesContainingObjects(const CStringList& refPathList);
  570. private:
  571. HRESULT _Rename(CUINode* pNode, LPWSTR NewName);
  572. HRESULT CommitRenameToDS(CUINode* pUINode, CDSCookie* pCookie, LPCWSTR NewName);
  573. HRESULT RenameUser(CUINode* pUINode, CDSCookie* pCookie, LPCWSTR NewName);
  574. HRESULT RenameGroup(CUINode* pUINode, CDSCookie* pCookie, LPCWSTR NewName);
  575. HRESULT RenameNTDSConnection(CUINode* pUINode, CDSCookie* pCookie, LPCWSTR NewName);
  576. HRESULT RenameSubnet(CUINode* pUINode, CDSCookie* pCookie, LPCWSTR NewName);
  577. HRESULT RenameSite(CUINode* pUINode, CDSCookie* pCookie, LPCWSTR NewName);
  578. HRESULT RenameContact(CUINode* pUINode, CDSCookie* pCookie, LPCWSTR NewName);
  579. HRESULT _MoveObject(CDSUINode* pDSUINode);
  580. void ClearClassCacheAndRefreshRoot();
  581. STDMETHOD(_OnPropertyChange)(LPDATAOBJECT pDataObject, BOOL bScope);
  582. BOOL SortChildList (LPWSTR *ppszChildList, UINT cChildCount);
  583. int InsertAtTopContextMenu(LPCWSTR pwszParentClass, LPCWSTR pwszChildClass);
  584. BOOL IsNotHiddenClass (LPWSTR pwszClass, CDSCookie* pParentCookie);
  585. #ifdef FIXUPDC
  586. HRESULT _FixupDC(LPCWSTR pwszPath);
  587. #endif // FIXUPDC
  588. HRESULT _RunKCC(LPCWSTR pwszPath);
  589. // Memory reclamation routines
  590. void ReclaimCookies();
  591. void AddToLRUList (CUINode* pUINode);
  592. // namespace extension API's
  593. HRESULT _OnNamespaceExtensionExpand(LPDATAOBJECT lpDataObject, HSCOPEITEM pParent);
  594. // thread API's
  595. BOOL _StartBackgroundThread();
  596. void _WaitForBackGroundThreadStartAck();
  597. void _ShutDownBackgroundThread();
  598. BOOL _PostQueryToBackgroundThread(CUINode* pUINode);
  599. BOOL _PostMessageToBackgroundThread(UINT Msg, WPARAM wParam, LPARAM lParam);
  600. void _OnTooMuchData(CUINode* pUINode);
  601. void _OnHaveData(CUINode* pUINode, CThreadQueryResult* pResult);
  602. void _OnDone(CUINode* pUINode, HRESULT hr);
  603. void _OnSheetClose(CUINode* pUINode);
  604. void _OnSheetCreate(PDSA_SEC_PAGE_INFO pDsaSecondaryPageInfo);
  605. // sheet API's
  606. void _SheetLockCookie(CUINode* pNode);
  607. void _SheetUnlockCookie(CUINode* pNode);
  608. BOOL _WarningOnSheetsUp(CUINode* pNode, BOOL bShowMessage = TRUE, BOOL bActivate = TRUE);
  609. BOOL _WarningOnSheetsUp(CInternalFormatCracker* pInternalFormatCracker);
  610. public:
  611. STDMETHOD(QueryFromWorkerThread)(CThreadQueryInfo* pQueryInfo,
  612. CWorkerThread* pWorkerThread);
  613. BOOL CanEnableVerb(CUINode* pUINode);
  614. int GetImage(CUINode* pNode, BOOL bOpen);
  615. UINT GetSerialNumber() {return m_SerialNumber++;}
  616. void Lock() { ::EnterCriticalSection(&m_cs);}
  617. void Unlock() { ::LeaveCriticalSection(&m_cs);}
  618. HWND GetHiddenWindow();
  619. MyBasePathsInfo* GetBasePathsInfo() { return &m_basePathsInfo;}
  620. CDSNotifyHandlerManager* GetNotifyHandlerManager() { return &m_notifyHandlerManager;}
  621. CFavoritesNodesHolder* GetFavoritesNodeHolder() { return m_pFavoritesNodesHolder; }
  622. CTargetingInfo* GetTargetingInfo() { return &m_targetingInfo; }
  623. void SetDirty(BOOL bDirty = TRUE) { m_bDirty = bDirty; }
  624. private:
  625. // InitFunctions
  626. HRESULT _InitRootFromCurrentTargetInfo();
  627. HRESULT _InitRootFromBasePathsInfo(MyBasePathsInfo* pBasePathsInfo);
  628. HRESULT _InitRootFromValidBasePathsInfo();
  629. private:
  630. CTargetingInfo m_targetingInfo; // manage serialized targeting info
  631. CIconManager m_iconManager; // manage icon strip
  632. MyBasePathsInfo m_basePathsInfo; // container of base path info
  633. CDSNotifyHandlerManager m_notifyHandlerManager;
  634. protected:
  635. CRootNode m_RootNode; // Root node for the snapin
  636. BOOL m_InitSuccess; // successfully contacted DC for naming info?
  637. BOOL m_InitAttempted; // already attempted to contact DC for naming info, don't show errors
  638. CDSDirect* m_ActiveDS;
  639. CDSCache* m_pClassCache;
  640. LPCONSOLENAMESPACE2 m_pScope; // My interface pointer to the scope pane
  641. IConsole3* m_pFrame;
  642. #ifdef _MMC_ISNAPIN_PROPERTY
  643. Properties* m_pProperties; // pointer to MMC properties interface
  644. #endif //_MMC_ISNAPIN_PROPERTY
  645. HWND m_hwnd; // window handle of main window
  646. IImageList* m_pScpImageList;
  647. CStringList m_CreateInfo;
  648. IShellExtInit * m_pShlInit; // Property sheet COM object pointer.
  649. CDsDisplaySpecOptionsCFHolder m_DsDisplaySpecOptionsCFHolder; // cached clipbard format.
  650. UINT m_SerialNumber; // monotonically increasing number used for tracking
  651. // cookies to determine LRU
  652. CUINodeList m_LRUList; // node list for LRU reclamation
  653. BOOL m_bDirty; // dirty flag for serialization on MMC stream
  654. INT m_ColumnWidths[DS_DEFAULT_COLUMN_COUNT]; //save column widths here.
  655. BOOL m_bRunAsPrimarySnapin; // TRUE if the snapin is not an extension
  656. BOOL m_bAddRootWhenExtended; // TRUE adds root node folder
  657. CDSQueryFilter* m_pQueryFilter;
  658. LPCWSTR m_lpszSnapinHelpFile;
  659. CFavoritesNodesHolder* m_pFavoritesNodesHolder;
  660. // thread related variables
  661. private:
  662. CRITICAL_SECTION m_cs;
  663. protected:
  664. void _DeleteHiddenWnd();
  665. CHiddenWnd* m_pHiddenWnd;
  666. CBackgroundThreadInfo* m_pBackgroundThreadInfo; // info about dispatcher thread state
  667. CUINodeQueryTable m_queryNodeTable; // table of cookies having a pending query
  668. // property sheet related variables
  669. private:
  670. CUINodeSheetTable m_sheetNodeTable; // table of cookies having a sheet up
  671. friend class CHiddenWnd; // to access thread notification handlers
  672. };
  673. /////////////////////////////////////////////////////////////////////
  674. // CDSSnapin (DS standalone)
  675. class CDSSnapin:
  676. public CDSComponentData,
  677. public CComCoClass<CDSSnapin, &CLSID_DSSnapin>
  678. {
  679. public:
  680. DECLARE_REGISTRY_CLSID()
  681. //DECLARE_REGISTRY(CDSSnapin, _T("DSSnap.SnapinObj.1"), _T("DSSnap.SnapinObj"), IDS_DSSNAPINNAME, THREADFLAGS_BOTH)
  682. CDSSnapin();
  683. virtual SnapinType QuerySnapinType();
  684. };
  685. /////////////////////////////////////////////////////////////////////
  686. // CDSSnapinEx (DS namespace extension)
  687. class CDSSnapinEx:
  688. public CDSComponentData,
  689. public CComCoClass<CDSSnapinEx, &CLSID_DSSnapinEx>
  690. {
  691. public:
  692. DECLARE_REGISTRY_CLSID()
  693. //DECLARE_REGISTRY(CDSSnapin, _T("DSSnapEx.SnapinObj.1"), _T("DSSnapEx.SnapinObj"), IDS_DSSNAPINNAMEEX, THREADFLAGS_BOTH)
  694. CDSSnapinEx();
  695. virtual SnapinType QuerySnapinType();
  696. };
  697. /////////////////////////////////////////////////////////////////////
  698. // CSiteSnapin (Site manager standalone)
  699. class CSiteSnapin:
  700. public CDSComponentData,
  701. public CComCoClass<CSiteSnapin, &CLSID_SiteSnapin>
  702. {
  703. public:
  704. DECLARE_REGISTRY_CLSID()
  705. //DECLARE_REGISTRY(CSiteSnapin, _T("SiteSnap.SnapinObj.1"), _T("SiteSnap.SnapinObj"), IDS_SITESNAPINNAME, THREADFLAGS_BOTH)
  706. CSiteSnapin();
  707. virtual SnapinType QuerySnapinType();
  708. };
  709. //////////////////////////////////////////////////////////////////////////
  710. // CDSSnapinAbout
  711. class CDSSnapinAbout :
  712. public CSnapinAbout,
  713. public CComCoClass<CDSSnapinAbout, &CLSID_DSAboutSnapin>
  714. {
  715. public:
  716. DECLARE_REGISTRY_CLSID()
  717. CDSSnapinAbout();
  718. };
  719. //////////////////////////////////////////////////////////////////////////
  720. // CSitesSnapinAbout
  721. class CSitesSnapinAbout :
  722. public CSnapinAbout,
  723. public CComCoClass<CSitesSnapinAbout, &CLSID_SitesAboutSnapin>
  724. {
  725. public:
  726. DECLARE_REGISTRY_CLSID()
  727. CSitesSnapinAbout();
  728. };
  729. #endif //__DSSNAP_H__