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.

195 lines
5.4 KiB

  1. /*======================================================================================//
  2. | Process Control //
  3. | //
  4. |Copyright (c) 1998 Sequent Computer Systems, Incorporated. All rights reserved. //
  5. | //
  6. |File Name: RuleFolder.cpp //
  7. | //
  8. |Description: Implementation of rules node //
  9. | //
  10. |Created: Paul Skoglund 08-1998 //
  11. | //
  12. |Rev History: //
  13. | //
  14. |=======================================================================================*/
  15. #include "StdAfx.h"
  16. #include "BaseNode.h"
  17. using std::list<CBaseNode *>;
  18. //////////////////////////////////////////////////////////////////////////////////////////
  19. //
  20. // The "Rules" folder...
  21. //
  22. const GUID CRuleFolder::m_GUID = {0xff9baf61,0x064e,0x11d2,{0x80, 0x14,0x00,0x10,0x4b,0x9a,0x31,0x06} };
  23. const TCHAR *const CRuleFolder::m_szGUID = _T("{ff9baf61-064e-11d2-8014-00104b9a3106}");
  24. CRuleFolder::CRuleFolder(CBaseNode *pParent) : CBaseNode(MANAGEMENTRULE_NODE, pParent),
  25. m_ID(0), m_NodeList(0)
  26. {
  27. LoadStringHelper(m_name, IDS_RULES_FOLDER);
  28. }
  29. CRuleFolder::~CRuleFolder()
  30. {
  31. FreeNodes();
  32. }
  33. void CRuleFolder::FreeNodes()
  34. {
  35. ATLTRACE(_T("CRuleFolder::FreeNodes()\n") );
  36. for (list<CBaseNode *>::iterator i = m_NodeList.begin(); i != m_NodeList.end(); ++i)
  37. {
  38. (*i)->Release();
  39. //delete *i;
  40. }
  41. m_NodeList.clear();
  42. }
  43. LPCTSTR CRuleFolder::GetNodeName()
  44. {
  45. return m_name;
  46. }
  47. HRESULT CRuleFolder::GetDisplayInfo(RESULTDATAITEM &ResultItem)
  48. {
  49. if (ResultItem.bScopeItem)
  50. {
  51. if( ResultItem.mask & RDI_STR )
  52. {
  53. if (0 == ResultItem.nCol)
  54. ResultItem.str = const_cast<LPOLESTR>(GetNodeName());
  55. else
  56. ResultItem.str = _T("");
  57. }
  58. if (ResultItem.mask & RDI_IMAGE)
  59. ResultItem.nImage = sImage();
  60. return S_OK;
  61. }
  62. return E_UNEXPECTED;
  63. }
  64. HRESULT CRuleFolder::OnShow(BOOL bSelecting, HSCOPEITEM hItem, IHeaderCtrl2* ipHeaderCtrl, IConsole2* ipConsole2)
  65. {
  66. ASSERT(hItem == GetID());
  67. if (!bSelecting)
  68. return S_OK;
  69. ITEM_STR str;
  70. LoadStringHelper(str, IDS_NAME_HDR);
  71. VERIFY(S_OK == ipHeaderCtrl->InsertColumn( NAME_COLUMN, str, 0, NAME_COLUMN_WIDTH ));
  72. return SendViewChange(ipConsole2, NULL, PC_VIEW_UPDATEALL);
  73. }
  74. HRESULT CRuleFolder::OnExpand(BOOL bExpand, HSCOPEITEM hItem, IConsoleNameSpace2 *ipConsoleNameSpace2)
  75. {
  76. ASSERT(ipConsoleNameSpace2);
  77. if(!ipConsoleNameSpace2)
  78. return E_UNEXPECTED;
  79. if (bExpand)
  80. {
  81. VERIFY( S_OK == AddNode(ipConsoleNameSpace2, new CNameRuleFolder(this) ) );
  82. VERIFY( S_OK == AddNode(ipConsoleNameSpace2, new CProcessRuleFolder(this) ) );
  83. VERIFY( S_OK == AddNode(ipConsoleNameSpace2, new CJobRuleFolder(this) ) );
  84. }
  85. return S_OK;
  86. }
  87. HRESULT CRuleFolder::AddNode(IConsoleNameSpace2 *ipConsoleNameSpace2, CBaseNode *pSubNode)
  88. {
  89. HRESULT hr = S_OK;
  90. SCOPEDATAITEM sdi = {0};
  91. if (!pSubNode)
  92. return E_OUTOFMEMORY;
  93. // Place our folder into the scope pane
  94. sdi.mask = SDI_STR | // Displayname is valid
  95. SDI_PARAM | // lParam is valid
  96. SDI_IMAGE | // nImage is valid
  97. SDI_OPENIMAGE | // nOpenImage is valid
  98. SDI_CHILDREN | // cChildren is valid
  99. SDI_PARENT;
  100. sdi.displayname = (LPOLESTR)MMC_CALLBACK;
  101. sdi.nImage = pSubNode->sImage();
  102. sdi.nOpenImage = pSubNode->sOpenImage();
  103. //sdi.nState = ???
  104. sdi.cChildren = pSubNode->GetChildrenCount();
  105. sdi.lParam = reinterpret_cast <LPARAM> (pSubNode);
  106. sdi.relativeID = m_ID;
  107. hr = ipConsoleNameSpace2->InsertItem( &sdi );
  108. if (SUCCEEDED(hr))
  109. {
  110. pSubNode->SetID(sdi.ID);
  111. m_NodeList.push_front( pSubNode );
  112. }
  113. else
  114. {
  115. pSubNode->Release();
  116. //delete pSubNode;
  117. }
  118. return hr;
  119. }
  120. HRESULT CRuleFolder::OnHelpCmd(IDisplayHelp *ipDisplayHelp)
  121. {
  122. if (!ipDisplayHelp)
  123. return E_UNEXPECTED;
  124. ipDisplayHelp->ShowTopic(const_cast<TCHAR *>(HELP_ru_overview));
  125. return S_OK;
  126. }
  127. HRESULT CRuleFolder::OnSelect(BOOL bScope, BOOL bSelect, IConsoleVerb* ipConsoleVerb)
  128. {
  129. ASSERT(bScope);
  130. return S_OK;
  131. }
  132. HRESULT CRuleFolder::OnSelect(BOOL bScope, BOOL bSelect, IConsoleVerb* ipConsoleVerb, LPARAM Cookie)
  133. {
  134. ASSERT(!bScope);
  135. return S_OK;
  136. }
  137. HRESULT CRuleFolder::OnViewChange(IResultData *ipResultData, LPARAM thing, LONG_PTR hint)
  138. {
  139. ASSERT(ipResultData);
  140. if (!ipResultData)
  141. return E_UNEXPECTED;
  142. VERIFY(ipResultData->ModifyViewStyle(MMC_SINGLESEL, MMC_NOSORTHEADER) == S_OK);
  143. return ShowAllItems(ipResultData, FALSE);
  144. }
  145. HRESULT CRuleFolder::ShowAllItems(IResultData* ipResultData, BOOL bCacheValid)
  146. {
  147. // should be nothing to delete...
  148. return ipResultData->DeleteAllRsltItems();
  149. }