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.

886 lines
22 KiB

  1. // ScopeNode.h: Definition of the CScopeNode class
  2. //
  3. //////////////////////////////////////////////////////////////////////
  4. #if !defined(AFX_SCOPENODE_H__DE757919_30DB_11D3_9B2F_00C04FA37E1F__INCLUDED_)
  5. #define AFX_SCOPENODE_H__DE757919_30DB_11D3_9B2F_00C04FA37E1F__INCLUDED_
  6. #if _MSC_VER >= 1000
  7. #pragma once
  8. #endif // _MSC_VER >= 1000
  9. #include <vector>
  10. #include "resource.h" // main symbols
  11. #include "dataobj.h"
  12. #include "notifmap.h"
  13. #include "queryreq.h"
  14. #include "rowitem.h"
  15. #include "menucmd.h"
  16. #include "compont.h"
  17. #include "query.h"
  18. #include <map>
  19. extern const GUID GUID_RootNode;
  20. extern const GUID GUID_GroupNode;
  21. extern const GUID GUID_QueryNode;
  22. //-----------------------------------------------------------------
  23. // struct PropChangeInfo
  24. //
  25. // A pointer to this structure is passed as the lParam in an
  26. // MMCN_PROPERTY_CHANGE notification. It contains a pointer to the
  27. // target data object and the lParam for the notify. This is needed
  28. // because the notify message from MMC has a null data object so
  29. // the componentdata notify handler can't determine where to
  30. // forward the call.
  31. //----------------------------------------------------------------
  32. struct PropChangeInfo
  33. {
  34. IDataObject* pDataObject;
  35. LPARAM lNotifyParam;
  36. };
  37. //------------------------------------------------------------------
  38. // class CMenuRef
  39. //
  40. // This class references a menu command defined at the root node
  41. // The ID is the string table ID of the user assigned menu name.
  42. // Names must be unique within an AD class, so the ID is too.
  43. //------------------------------------------------------------------
  44. class CMenuRef
  45. {
  46. friend IStream& operator>> (IStream& stm, CMenuRef& menuref);
  47. friend IStream& operator<< (IStream& stm, CMenuRef& menuref);
  48. enum
  49. {
  50. MENUREF_ENABLE = 0x0001, // set if enabled at query node
  51. MENUREF_DEFAULT = 0x0002 // set for default menu item
  52. };
  53. public:
  54. CMenuRef() : m_menuID(0), m_flags(0)
  55. {
  56. };
  57. MMC_STRING_ID ID()
  58. {
  59. return m_menuID;
  60. }
  61. BOOL IsEnabled()
  62. {
  63. return(m_flags & MENUREF_ENABLE);
  64. }
  65. BOOL IsDefault()
  66. {
  67. return(m_flags & MENUREF_DEFAULT);
  68. }
  69. void SetEnable(BOOL bState)
  70. {
  71. m_flags = bState ? (m_flags | MENUREF_ENABLE) : (m_flags & ~MENUREF_ENABLE);
  72. };
  73. void SetDefault(BOOL bState)
  74. {
  75. m_flags = bState ? (m_flags | MENUREF_DEFAULT) : (m_flags & ~MENUREF_DEFAULT);
  76. };
  77. // define ID comparison for std algorithms
  78. BOOL operator==(MMC_STRING_ID ID)
  79. {
  80. return m_menuID == ID;
  81. }
  82. MMC_STRING_ID m_menuID; // menu command ID
  83. DWORD m_flags; // state flags
  84. };
  85. typedef std::vector<CMenuRef> menuref_vector;
  86. //------------------------------------------------------------------
  87. // class CClassInfo
  88. //------------------------------------------------------------------
  89. class CClassInfo
  90. {
  91. friend IStream& operator>> (IStream& stm, CClassInfo& classinfo);
  92. friend IStream& operator<< (IStream& stm, CClassInfo& classinfo);
  93. public:
  94. CClassInfo(LPCWSTR pszClassName = NULL)
  95. {
  96. if( pszClassName != NULL )
  97. m_strName = pszClassName;
  98. }
  99. LPCWSTR Name()
  100. {
  101. return m_strName.c_str();
  102. }
  103. string_vector& Columns()
  104. {
  105. return m_vstrColumns;
  106. }
  107. menucmd_vector& Menus()
  108. {
  109. return m_vMenus;
  110. }
  111. HRESULT LoadStrings(IStringTable* pStringTable)
  112. {
  113. VALIDATE_POINTER( pStringTable );
  114. menucmd_vector::iterator itMenuCmd;
  115. for( itMenuCmd = Menus().begin(); itMenuCmd != Menus().end(); ++itMenuCmd )
  116. {
  117. HRESULT hr = (*itMenuCmd)->LoadName(pStringTable);
  118. RETURN_ON_FAILURE(hr);
  119. }
  120. return S_OK;
  121. }
  122. private:
  123. tstring m_strName;
  124. string_vector m_vstrColumns;
  125. menucmd_vector m_vMenus;
  126. };
  127. // atribute map - maps attribute LDAP name to display name
  128. struct attrib_comp
  129. {
  130. bool operator()(const LPCWSTR psz1, const LPCWSTR psz2) const
  131. {
  132. if( !psz1 || !psz2 ) return 0;
  133. return wcscmp(psz1,psz2) < 0;
  134. }
  135. };
  136. typedef std::map<LPCWSTR, LPCWSTR, attrib_comp> attrib_map;
  137. typedef std::vector<CClassInfo> classInfo_vector;
  138. enum NODETYPE
  139. {
  140. NULL_NODETYPE = 0,
  141. ROOT_NODETYPE,
  142. GROUP_NODETYPE,
  143. QUERY_NODETYPE
  144. };
  145. class CRootNode;
  146. class CGroupNnode;
  147. class CQueryNode;
  148. //------------------------------------------------------------------
  149. // class CScopeNode
  150. //------------------------------------------------------------------
  151. class CScopeNode :
  152. public CComObjectRootEx<CComSingleThreadModel>,
  153. public CDataObjectImpl
  154. {
  155. friend class CGroupNode;
  156. friend class CQueryNode;
  157. friend class CRootNode;
  158. public:
  159. CScopeNode() : m_pnodeParent(NULL), m_pnodeNext(NULL), m_pnodeChild(NULL),
  160. m_hScopeItem(0), m_nameID(0), m_lNodeID(1), m_bIgnoreSelect(FALSE)
  161. {
  162. }
  163. virtual ~CScopeNode();
  164. static HRESULT CreateNode(NODETYPE nodetype, CScopeNode** ppnode);
  165. DECLARE_NOT_AGGREGATABLE(CScopeNode)
  166. BEGIN_COM_MAP(CScopeNode)
  167. COM_INTERFACE_ENTRY(IDataObject)
  168. COM_INTERFACE_ENTRY(IBOMObject)
  169. END_COM_MAP()
  170. public:
  171. //
  172. // ScopeNode methods
  173. //
  174. // Attributes
  175. LPCWSTR GetName()
  176. {
  177. return m_strName.c_str();
  178. }
  179. int HasChildren()
  180. {
  181. return(m_pnodeChild != NULL);
  182. }
  183. BOOL IsRootNode()
  184. {
  185. return(m_pnodeParent == NULL);
  186. }
  187. int GetNodeID()
  188. {
  189. return m_lNodeID;
  190. }
  191. virtual NODETYPE NodeType() = 0;
  192. virtual const GUID* NodeTypeGuid() = 0;
  193. virtual int GetImage() = 0;
  194. virtual int GetOpenImage() = 0;
  195. virtual BOOL IsContainer()
  196. {
  197. return FALSE;
  198. }
  199. HRESULT SetName(LPCWSTR);
  200. // Links
  201. CScopeNode* FirstChild()
  202. {
  203. return m_pnodeChild;
  204. }
  205. CScopeNode* Parent()
  206. {
  207. return m_pnodeParent;
  208. }
  209. CScopeNode* Next()
  210. {
  211. return m_pnodeNext;
  212. }
  213. CRootNode* GetRootNode();
  214. CComponentData* GetCompData();
  215. BOOL OwnsConsoleView(LPCONSOLE2 pConsole);
  216. //
  217. // Notification handlers
  218. //
  219. DECLARE_NOTIFY_MAP()
  220. HRESULT OnHelp(LPCONSOLE2 pConsole, LPARAM arg, LPARAM param);
  221. HRESULT OnExpand(LPCONSOLE2 pConsole, BOOL bExpand, HSCOPEITEM hScopeItem);
  222. HRESULT OnRemoveChildren(LPCONSOLE2 pConsole);
  223. HRESULT OnRename(LPCONSOLE2 pConsole, LPCWSTR pszName);
  224. HRESULT OnAddImages(LPCONSOLE2 pConsole, LPIMAGELIST pImageList);
  225. HRESULT OnSelect(LPCONSOLE2 pConsole, BOOL bSelect, BOOL bScope);
  226. virtual HRESULT OnRefresh(LPCONSOLE2 pConsole) = 0;
  227. STDMETHOD(GetDisplayInfo)(RESULTDATAITEM* pRDI);
  228. STDMETHOD(GetResultViewType)(LPOLESTR* ppViewType, long* pViewOptions);
  229. STDMETHOD(AttachComponent)(CComponent* pComponent);
  230. STDMETHOD(DetachComponent)(CComponent* pComponent);
  231. HRESULT Load(IStream& stm);
  232. HRESULT Save(IStream& stm);
  233. HRESULT GetDisplayInfo(SCOPEDATAITEM* pSDI);
  234. HRESULT Insert(LPCONSOLENAMESPACE pNameSpace);
  235. HRESULT AddNewChild(CScopeNode* pnodeChild, LPCWSTR pszName);
  236. HRESULT AddChild(CScopeNode* pnodeChild);
  237. HRESULT RemoveChild(CScopeNode* pnodeDelete);
  238. HRESULT AddQueryNode(LPCONSOLE2 pConsole);
  239. HRESULT AddGroupNode(LPCONSOLE2 pConsole);
  240. //
  241. // IDataObject helper method
  242. //
  243. STDMETHOD(GetDataImpl)(UINT cf, HGLOBAL* hGlobal);
  244. protected:
  245. //
  246. // Implementation
  247. //
  248. virtual HRESULT LoadNode(IStream& stm);
  249. virtual HRESULT SaveNode(IStream& stm);
  250. virtual void EnableVerbs(IConsoleVerb* pConsVerb, BOOL bOwnsView)
  251. {
  252. }
  253. //
  254. // Member variables
  255. //
  256. protected:
  257. MMC_STRING_ID m_nameID;
  258. long m_lNodeID;
  259. tstring m_strName;
  260. HSCOPEITEM m_hScopeItem;
  261. BOOL m_bIgnoreSelect;
  262. GUID m_gColumnID;
  263. CScopeNode* m_pnodeChild;
  264. CScopeNode* m_pnodeNext;
  265. CScopeNode* m_pnodeParent;
  266. std::vector<CComponent*> m_vComponents; // attached components
  267. static UINT m_cfDisplayName; // supported clipboard formats
  268. static UINT m_cfSnapInClsid;
  269. static UINT m_cfNodeType;
  270. static UINT m_cfszNodeType;
  271. static UINT m_cfNodeID2;
  272. static UINT m_cfColumnSetID;
  273. };
  274. typedef CComPtr<CScopeNode> CScopeNodePtr;
  275. //------------------------------------------------------------------
  276. // class CRootNode
  277. //------------------------------------------------------------------
  278. class CRootNode : public CScopeNode
  279. {
  280. public:
  281. CRootNode() : m_commentID(0)
  282. {
  283. };
  284. virtual NODETYPE NodeType()
  285. {
  286. return ROOT_NODETYPE;
  287. }
  288. virtual const GUID* NodeTypeGuid()
  289. {
  290. return &GUID_RootNode;
  291. }
  292. virtual BOOL IsContainer()
  293. {
  294. return TRUE;
  295. }
  296. virtual int GetImage()
  297. {
  298. return ROOT_NODE_IMAGE;
  299. }
  300. virtual int GetOpenImage()
  301. {
  302. return ROOT_NODE_OPENIMAGE;
  303. }
  304. virtual HRESULT LoadNode(IStream& stm);
  305. virtual HRESULT SaveNode(IStream& stm);
  306. void GetCreateTime(FILETIME* pTime)
  307. {
  308. ASSERT(pTime);
  309. if( !pTime ) return;
  310. *pTime = m_ftCreateTime;
  311. }
  312. void GetModifyTime(FILETIME* pTime)
  313. {
  314. ASSERT(pTime);
  315. if( !pTime ) return;
  316. *pTime = m_ftModifyTime;
  317. }
  318. void UpdateModifyTime()
  319. {
  320. GetSystemTimeAsFileTime(&m_ftModifyTime);
  321. }
  322. LPCWSTR GetOwner()
  323. {
  324. return m_strOwner.c_str();
  325. }
  326. HRESULT GetComment(tstring& strComment);
  327. HRESULT SetComment(LPCWSTR psz);
  328. CComponentData* GetRootCompData()
  329. {
  330. ASSERT(m_pCompData != NULL); return m_pCompData;
  331. }
  332. CClassInfo* FindClass(LPCWSTR pszClassName);
  333. void AddClass(CClassInfo* pClass)
  334. {
  335. if( !pClass || (FindClass(pClass->Name()) != NULL) ) return;
  336. m_vClassInfo.push_back(*pClass);
  337. }
  338. HRESULT Initialize(CComponentData* pCompData);
  339. //
  340. // Notification handlers
  341. //
  342. DECLARE_NOTIFY_MAP()
  343. HRESULT OnHelp(LPCONSOLE2 pConsole, LPARAM arg, LPARAM param);
  344. HRESULT OnPropertyChange(LPCONSOLE2 pConsole, LPARAM lParam);
  345. STDMETHOD(GetResultViewType)(LPOLESTR* ppViewType, long* pViewOptions);
  346. virtual HRESULT OnRefresh(LPCONSOLE2 pConsole)
  347. {
  348. return S_OK;
  349. }
  350. //
  351. // IBOMObject methods
  352. //
  353. STDMETHOD(AddMenuItems)(LPCONTEXTMENUCALLBACK pCallback, long* lAllowed);
  354. STDMETHOD(MenuCommand)(LPCONSOLE2 pConsole, long lCommand);
  355. STDMETHOD(SetToolButtons)(LPTOOLBAR pToolbar)
  356. {
  357. return S_FALSE;
  358. }
  359. STDMETHOD(SetVerbs)(LPCONSOLEVERB pConsVerb)
  360. {
  361. return S_OK;
  362. }
  363. STDMETHOD(QueryPagesFor)();
  364. STDMETHOD(CreatePropertyPages)(LPPROPERTYSHEETCALLBACK lpProvider,LONG_PTR handle);
  365. STDMETHOD(GetWatermarks)(HBITMAP* lphWatermark, HBITMAP* lphHeader, HPALETTE* lphPalette, BOOL* bStretch);
  366. private:
  367. CComponentData* m_pCompData;
  368. FILETIME m_ftCreateTime;
  369. FILETIME m_ftModifyTime;
  370. tstring m_strOwner;
  371. MMC_STRING_ID m_commentID;
  372. classInfo_vector m_vClassInfo;
  373. };
  374. typedef CComPtr<CRootNode> CRootNodePtr;
  375. //------------------------------------------------------------------
  376. // CQueryableNode
  377. //
  378. // This is an abstract class which provides methods common to both
  379. // Group nodes and Query nodes.
  380. //------------------------------------------------------------------
  381. class CQueryableNode :
  382. public CScopeNode,
  383. public CQueryCallback
  384. {
  385. public:
  386. CQueryableNode() : m_bQueryChange(TRUE), m_pQueryReq(NULL)
  387. {
  388. }
  389. virtual ~CQueryableNode()
  390. {
  391. if( m_pQueryReq != NULL ) m_pQueryReq->Stop(TRUE);
  392. }
  393. void ClearQueryRowItems();
  394. string_vector& QueryColumns()
  395. {
  396. return m_vstrColumns;
  397. }
  398. HRESULT OnRefresh(LPCONSOLE2 pConsole);
  399. STDMETHOD(AttachComponent)(CComponent* pComponent);
  400. STDMETHOD(DetachComponent)(CComponent* pComponent);
  401. virtual HRESULT GetQueryAttributes(attrib_map& mapAttr) = 0;
  402. virtual HRESULT StartQuery(string_vector& vstrColumns, CQueryCallback* pCallback, CQueryRequest** ppReq) = 0;
  403. virtual BOOL OnClassChange(string_vector& vstrClasses) = 0;
  404. //
  405. // CQueryCallback
  406. //
  407. virtual void QueryCallback(QUERY_NOTIFY event, CQueryRequest* pQueryReq, LPARAM lUserParam);
  408. bool m_bQueryChange;
  409. protected:
  410. CQueryRequest* m_pQueryReq;
  411. string_vector m_vstrColumns;
  412. RowItemVector m_vRowItems;
  413. };
  414. typedef CComPtr<CQueryableNode> CQueryableNodePtr;
  415. //------------------------------------------------------------------
  416. // class CGroupNode
  417. //------------------------------------------------------------------
  418. class CGroupNode : public CQueryableNode
  419. {
  420. public:
  421. CGroupNode() : m_bApplyScope(FALSE), m_bApplyFilter(FALSE), m_bLocalScope(FALSE)
  422. {
  423. };
  424. virtual NODETYPE NodeType()
  425. {
  426. return GROUP_NODETYPE;
  427. }
  428. virtual const GUID* NodeTypeGuid()
  429. {
  430. return &GUID_GroupNode;
  431. }
  432. virtual BOOL IsContainer()
  433. {
  434. return TRUE;
  435. }
  436. virtual int GetImage()
  437. {
  438. return GROUP_NODE_IMAGE;
  439. }
  440. virtual int GetOpenImage()
  441. {
  442. return GROUP_NODE_OPENIMAGE;
  443. }
  444. LPCWSTR ClassName()
  445. {
  446. return m_strClassName.c_str();
  447. }
  448. LPCWSTR Filter()
  449. {
  450. return m_strFilter. c_str();
  451. }
  452. LPCWSTR Scope()
  453. {
  454. return m_bLocalScope ? GetLocalDomain() : m_strScope.c_str();
  455. }
  456. LPCWSTR QueryScope()
  457. {
  458. return m_strScope.c_str();
  459. }
  460. BOOL ApplyScope()
  461. {
  462. return m_bApplyScope;
  463. }
  464. BOOL ApplyFilter()
  465. {
  466. return m_bApplyFilter;
  467. }
  468. //
  469. // Notification handlers
  470. //
  471. DECLARE_NOTIFY_MAP()
  472. HRESULT OnDelete(LPCONSOLE2 pConsole);
  473. HRESULT OnAddImages(LPCONSOLE2 pConsole, LPIMAGELIST pImageList);
  474. STDMETHOD(GetResultViewType)(LPOLESTR* ppViewType, long* pViewOptions);
  475. virtual void EnableVerbs(IConsoleVerb *pConsVerb, BOOL bOwnsView);
  476. virtual HRESULT LoadNode(IStream& stm);
  477. virtual HRESULT SaveNode(IStream& stm);
  478. void SetScope(LPCWSTR pszScope)
  479. {
  480. m_strScope = pszScope;
  481. }
  482. void SetFilter(LPCWSTR pszFilter)
  483. {
  484. m_strFilter = pszFilter;
  485. }
  486. void SetClassName(LPCWSTR pszName)
  487. {
  488. m_strClassName = pszName;
  489. }
  490. void SetApplyScope(bool bState)
  491. {
  492. m_bApplyScope = bState;
  493. }
  494. void SetApplyFilter(bool bState)
  495. {
  496. m_bApplyFilter = bState;
  497. }
  498. //
  499. // CQueryableNode methods
  500. //
  501. virtual HRESULT GetQueryAttributes(attrib_map& mapAttr);
  502. virtual HRESULT StartQuery(string_vector& vstrColumns, CQueryCallback* pCallback, CQueryRequest** ppReq);
  503. virtual BOOL OnClassChange(string_vector& vstrClasses);
  504. //
  505. // IBOMObject methods
  506. //
  507. STDMETHOD(AddMenuItems)(LPCONTEXTMENUCALLBACK pCallback, long* lAllowed);
  508. STDMETHOD(MenuCommand)(LPCONSOLE2 pConsole, long lCommand);
  509. STDMETHOD(SetToolButtons)(LPTOOLBAR pToolbar)
  510. {
  511. return S_FALSE;
  512. }
  513. STDMETHOD(SetVerbs)(LPCONSOLEVERB pConsVerb)
  514. {
  515. return S_OK;
  516. }
  517. STDMETHOD(QueryPagesFor)();
  518. STDMETHOD(CreatePropertyPages)(LPPROPERTYSHEETCALLBACK lpProvider,LONG_PTR handle);
  519. STDMETHOD(GetWatermarks)(HBITMAP* lphWatermark, HBITMAP* lphHeader,
  520. HPALETTE* lphPalette, BOOL* bStretch)
  521. {
  522. return S_FALSE;
  523. }
  524. //
  525. // CQueryCallback
  526. //
  527. virtual void QueryCallback(QUERY_NOTIFY event, CQueryRequest* pQueryReq, LPARAM lUserParam);
  528. private:
  529. tstring m_strClassName;
  530. tstring m_strScope;
  531. tstring m_strFilter;
  532. bool m_bApplyScope;
  533. bool m_bApplyFilter;
  534. bool m_bLocalScope;
  535. CQueryNode* m_pQNodeActive;
  536. };
  537. typedef CComPtr<CGroupNode> CGroupNodePtr;
  538. //------------------------------------------------------------------
  539. // class CQueryObjInfo
  540. //------------------------------------------------------------------
  541. // This class contains AD class information that is define at each
  542. // query node. The query node holds a vector of these structures,
  543. // one for each class that its query can bring back.
  544. class CQueryObjInfo
  545. {
  546. public:
  547. CQueryObjInfo(LPCWSTR pszName = NULL)
  548. {
  549. if( pszName != NULL )
  550. m_strName = pszName;
  551. m_bPropertyMenu = TRUE;
  552. }
  553. LPCWSTR Name()
  554. {
  555. return m_strName.c_str();
  556. }
  557. menuref_vector& MenuRefs()
  558. {
  559. return m_vMenuRefs;
  560. }
  561. string_vector& DisabledColumns()
  562. {
  563. return m_vstrDisabledColumns;
  564. }
  565. BOOL HasPropertyMenu()
  566. {
  567. return m_bPropertyMenu;
  568. }
  569. void SetPropertyMenu(BOOL bEnable)
  570. {
  571. m_bPropertyMenu = bEnable;
  572. }
  573. tstring m_strName;
  574. menuref_vector m_vMenuRefs;
  575. string_vector m_vstrDisabledColumns;
  576. BOOL m_bPropertyMenu;
  577. };
  578. typedef std::vector<CQueryObjInfo> QueryObjVector;
  579. //------------------------------------------------------------------
  580. // class CQueryNode
  581. //------------------------------------------------------------------
  582. class CQueryNode :
  583. public CQueryableNode
  584. {
  585. public:
  586. CQueryNode() : m_bLocalScope(TRUE), m_commentID(0), m_nIconIndex(-1)
  587. {
  588. };
  589. virtual NODETYPE NodeType()
  590. {
  591. return QUERY_NODETYPE;
  592. }
  593. virtual const GUID* NodeTypeGuid()
  594. {
  595. return &GUID_QueryNode;
  596. }
  597. virtual int GetImage()
  598. {
  599. return (m_nIconIndex == -1) ? QUERY_NODE_IMAGE : m_nIconIndex;
  600. }
  601. virtual int GetOpenImage()
  602. {
  603. return (m_nIconIndex == -1) ? QUERY_NODE_OPENIMAGE : m_nIconIndex;
  604. }
  605. void SetImage(int nIcon)
  606. {
  607. m_nIconIndex = nIcon;
  608. }
  609. DECLARE_NOTIFY_MAP()
  610. HRESULT OnDelete(LPCONSOLE2 pConsole);
  611. HRESULT OnAddImages(LPCONSOLE2 pConsole, LPIMAGELIST pImageList);
  612. STDMETHOD(GetResultViewType)(LPOLESTR* ppViewType, long* pViewOptions);
  613. STDMETHOD(GetDisplayInfo)(RESULTDATAITEM* pRDI);
  614. //
  615. // IBOMObject methods
  616. //
  617. STDMETHOD(AddMenuItems)(LPCONTEXTMENUCALLBACK pCallback, long* lAllowed);
  618. STDMETHOD(MenuCommand)(LPCONSOLE2 pConsole, long lCommand);
  619. STDMETHOD(SetToolButtons)(LPTOOLBAR pToolbar);
  620. STDMETHOD(SetVerbs)(LPCONSOLEVERB pConsVerb)
  621. {
  622. return S_OK;
  623. }
  624. STDMETHOD(QueryPagesFor)();
  625. STDMETHOD(CreatePropertyPages)(LPPROPERTYSHEETCALLBACK lpProvider,LONG_PTR handle);
  626. STDMETHOD(GetWatermarks)(HBITMAP* lphWatermark, HBITMAP* lphHeader, HPALETTE* lphPalette, BOOL* bStretch)
  627. {
  628. return S_FALSE;
  629. }
  630. //
  631. // Implementation
  632. //
  633. virtual HRESULT LoadNode(IStream& stm);
  634. virtual HRESULT SaveNode(IStream& stm);
  635. virtual void EnableVerbs(IConsoleVerb *pConsVerb, BOOL bOwnsView);
  636. void SetScope(LPCWSTR pszScope)
  637. {
  638. m_strScope = pszScope;
  639. }
  640. void SetQuery(LPCWSTR pszQuery)
  641. {
  642. m_strQuery = pszQuery;
  643. }
  644. void SetLocalScope(bool bState)
  645. {
  646. m_bLocalScope = bState;
  647. }
  648. LPCWSTR QueryScope()
  649. {
  650. return m_strScope.c_str();
  651. }
  652. bool UseLocalScope()
  653. {
  654. return m_bLocalScope;
  655. }
  656. LPCWSTR Scope()
  657. {
  658. return(m_bLocalScope ? GetLocalDomain() : m_strScope.c_str());
  659. }
  660. LPCWSTR Query()
  661. {
  662. return m_strQuery.c_str();
  663. }
  664. void ExpandQuery(tstring& strIn)
  665. {
  666. strIn = m_strQuery;
  667. ExpandDCWildCard(strIn);
  668. }
  669. HRESULT GetComment(tstring& strComment);
  670. HRESULT SetComment(LPCWSTR pszComment);
  671. QueryObjVector& Objects()
  672. {
  673. return m_vObjInfo;
  674. }
  675. menucmd_vector& Menus()
  676. {
  677. return m_vMenus;
  678. }
  679. HRESULT GetClassMenuItems(LPCWSTR pszClass, menucmd_vector& vMenus, int* piDefault, BOOL* bPropertyMenu);
  680. HRESULT EditQuery(HWND hWndParent);
  681. //
  682. // CQueryableNode methods
  683. //
  684. virtual HRESULT GetQueryAttributes(attrib_map& mapAttr);
  685. virtual HRESULT StartQuery(string_vector& vstrColumns, CQueryCallback* pCallback, CQueryRequest** ppReq);
  686. virtual BOOL OnClassChange(string_vector& vstrClasses);
  687. private:
  688. HRESULT LoadStrings(IStringTable* pStringTable)
  689. {
  690. VALIDATE_POINTER( pStringTable );
  691. menucmd_vector::iterator itMenuCmd;
  692. for( itMenuCmd = Menus().begin(); itMenuCmd != Menus().end(); ++itMenuCmd )
  693. {
  694. HRESULT hr = (*itMenuCmd)->LoadName(pStringTable);
  695. RETURN_ON_FAILURE(hr);
  696. }
  697. return S_OK;
  698. }
  699. tstring m_strScope;
  700. tstring m_strQuery;
  701. byte_string m_bsQueryData;
  702. MMC_STRING_ID m_commentID;
  703. QueryObjVector m_vObjInfo;
  704. bool m_bLocalScope;
  705. menucmd_vector m_vMenus; // Query Nodes now have menus
  706. int m_nIconIndex; // Query Nodes have user-defined icons, too
  707. };
  708. typedef CComPtr<CQueryNode> CQueryNodePtr;
  709. ////////////////////////////////////////////////////////////////
  710. // CQueryLookup
  711. //
  712. // This class provides an implementation of CParamLookup which
  713. // is used to translate shell menu command parameters to the
  714. // corresponding query row item values.
  715. class CQueryLookup : public CParamLookup
  716. {
  717. public:
  718. CQueryLookup(CQueryableNode* pQNode, CRowItem* pRowItem)
  719. : m_pQNode(pQNode), m_pRowItem(pRowItem)
  720. {
  721. }
  722. virtual BOOL operator() (tstring& strParam, tstring& strValue);
  723. CQueryableNode* m_pQNode;
  724. CRowItem* m_pRowItem;
  725. };
  726. #endif // !defined(AFX_SCOPENODE_H__DE757919_30DB_11D3_9B2F_00C04FA37E1F__INCLUDED_)