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.

260 lines
6.7 KiB

  1. // This is a part of the Microsoft Management Console.
  2. // Copyright (C) 1995-1996 Microsoft Corporation
  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. #include "precomp.hxx"
  9. #ifdef _DEBUG
  10. #define new DEBUG_NEW
  11. #undef THIS_FILE
  12. static char THIS_FILE[] = __FILE__;
  13. #endif
  14. /////////////////////////////////////////////////////////////////////////////
  15. // Event handlers for IFrame::Notify
  16. HRESULT CSnapin::OnFolder(long cookie, long arg, long param)
  17. {
  18. ASSERT(FALSE);
  19. return S_OK;
  20. }
  21. HRESULT CSnapin::OnShow(long cookie, long arg, long param)
  22. {
  23. HRESULT hr = S_OK;
  24. // Note - arg is TRUE when it is time to enumerate
  25. if (arg == TRUE)
  26. {
  27. // Show the headers for this nodetype
  28. ASSERT(m_pComponentData != NULL);
  29. hr = m_pComponentData->InitializeClassAdmin();
  30. if (SUCCEEDED(hr))
  31. {
  32. m_pResult->SetViewMode(m_lViewMode);
  33. InitializeHeaders(cookie);
  34. InitializeBitmaps(cookie);
  35. Enumerate(cookie, param);
  36. }
  37. // BUBBUG - Demonstration to should how you can attach
  38. // and a toolbar when a particular nodes gets focus.
  39. // warning this needs to be here as the toolbars are
  40. // currently hidden when the previous node looses focus.
  41. // This should be update to show the user how to hide
  42. // and show toolbars. (Detach and Attach).
  43. //m_pControlbar->Attach(TOOLBAR, (LPUNKNOWN) m_pToolbar1);
  44. //m_pControlbar->Attach(TOOLBAR, (LPUNKNOWN) m_pToolbar2);
  45. }
  46. else
  47. {
  48. m_pResult->GetViewMode(&m_lViewMode);
  49. // BUGBUG - Demonstration this to show how to hide toolbars that
  50. // could be particular to a single node.
  51. // currently this is used to hide the toolbars the console
  52. // does not do any toolbar clean up.
  53. //m_pControlbar->Detach(m_pToolbar1);
  54. //m_pControlbar->Detach(m_pToolbar2);
  55. // Free data associated with the result pane items, because
  56. // your node is no longer being displayed.
  57. // Note: The console will remove the items from the result pane
  58. }
  59. return hr;
  60. }
  61. HRESULT CSnapin::OnActivate(long cookie, long arg, long param)
  62. {
  63. return S_OK;
  64. }
  65. HRESULT CSnapin::OnResultItemClkOrDblClk(long cookie, BOOL fDblClick)
  66. {
  67. return S_OK;
  68. }
  69. HRESULT CSnapin::OnMinimize(long cookie, long arg, long param)
  70. {
  71. return S_OK;
  72. }
  73. HRESULT CSnapin::OnSelect(DATA_OBJECT_TYPES type, long cookie, long arg, long param)
  74. {
  75. if (m_pConsoleVerb)
  76. {
  77. // Set the default verb to open
  78. m_pConsoleVerb->SetDefaultVerb(MMC_VERB_OPEN);
  79. // If this is one of our items, enable the properties verb.
  80. if (type == CCT_RESULT)
  81. m_pConsoleVerb->SetVerbState(MMC_VERB_PROPERTIES, ENABLED, TRUE);
  82. }
  83. return S_OK;
  84. }
  85. HRESULT CSnapin::OnPropertyChange(long param) // param is the cookie of the item that changed
  86. {
  87. HRESULT hr = S_OK;
  88. m_pResult->Sort(0, 0, -1);
  89. // EnumerateResultPane(0);
  90. return hr;
  91. }
  92. HRESULT CSnapin::OnUpdateView(LPDATAOBJECT lpDataObject)
  93. {
  94. return S_OK;
  95. }
  96. void CSnapin::Enumerate(long cookie, HSCOPEITEM pParent)
  97. {
  98. EnumerateResultPane(cookie);
  99. }
  100. #define NUM_APPS 6
  101. char * rgName[] = {
  102. "Application 1",
  103. "Application 2",
  104. "Word",
  105. "XL",
  106. "Access",
  107. "Notepad"
  108. };
  109. char * rgPath[] = {
  110. "c:\\foo\\bar",
  111. "c:\\bar\\foo",
  112. "c:\\program files\\word",
  113. "c:\\program files\\excel",
  114. "c:\\program files\\access",
  115. "c:\\winnt\\notepad"
  116. };
  117. long rgSize[] = {
  118. 1000,
  119. 2000,
  120. 23000,
  121. 34000,
  122. 12034,
  123. 100
  124. };
  125. char * rgDescription[] = {
  126. "Description of app 1",
  127. "Description of app 2",
  128. "Word stuff",
  129. "Excel stuff",
  130. "Database stuff",
  131. "yeah, right"
  132. };
  133. LCID rgLcid[] = {
  134. 0,
  135. 0,
  136. 100,
  137. 32,
  138. 45,
  139. 123,
  140. 45
  141. };
  142. DEPLOYMENT_TYPE rgDT[] = {
  143. DT_PUBLISHED,
  144. DT_PUBLISHED,
  145. DT_ASSIGNED,
  146. DT_ASSIGNED,
  147. DT_PUBLISHED,
  148. DT_ASSIGNED
  149. };
  150. void CSnapin::EnumerateResultPane(long cookie)
  151. {
  152. // put up an hourglass (this could take a while)
  153. CHourglass hourglass;
  154. ASSERT(m_pResult != NULL); // make sure we QI'ed for the interface
  155. ASSERT(m_pComponentData != NULL);
  156. ASSERT(m_pComponentData->m_pIClassAdmin != NULL);
  157. RESULTDATAITEM resultItem;
  158. memset(&resultItem, 0, sizeof(RESULTDATAITEM));
  159. // Right now we only have one folder and it only
  160. // contains a list of application packages so this is really simple.
  161. if (m_pComponentData->m_AppData.begin() == m_pComponentData->m_AppData.end()) // test to see if the data has been initialized
  162. {
  163. IClassAdmin * pICA = m_pComponentData->m_pIClassAdmin;
  164. m_pIClassAdmin = pICA;
  165. CSPLATFORM csPlatform;
  166. memset(&csPlatform, 0, sizeof(CSPLATFORM));
  167. IEnumPackage * pIPE = NULL;
  168. HRESULT hr = pICA->GetPackagesEnum(
  169. GUID_NULL,
  170. NULL,
  171. csPlatform,
  172. 0,
  173. 0,
  174. &pIPE);
  175. if (SUCCEEDED(hr))
  176. {
  177. hr = pIPE->Reset();
  178. while (SUCCEEDED(hr))
  179. {
  180. ULONG nceltFetched;
  181. PACKAGEDETAIL * pd = new PACKAGEDETAIL;
  182. hr = pIPE->Next(1, pd, &nceltFetched);
  183. if (nceltFetched)
  184. {
  185. APP_DATA data;
  186. data.szName = pd->pszPackageName;
  187. if (pd->dwActFlags & ACTFLG_Assigned)
  188. {
  189. data.type = DT_ASSIGNED;
  190. }
  191. else
  192. {
  193. data.type = DT_PUBLISHED;
  194. }
  195. data.szPath = pd->pszPath;
  196. data.szIconPath = pd->pszIconPath;
  197. data.szDesc = pd->pszProductName;
  198. data.pDetails = pd;
  199. data.fBlockDeletion = FALSE;
  200. SetStringData(&data);
  201. m_pComponentData->m_AppData[++m_pComponentData->m_lLastAllocated] = data;
  202. }
  203. else
  204. {
  205. break;
  206. }
  207. }
  208. SAFE_RELEASE(pIPE);
  209. }
  210. }
  211. std::map<long, APP_DATA>::iterator i = m_pComponentData->m_AppData.begin();
  212. while (i != m_pComponentData->m_AppData.end())
  213. {
  214. resultItem.mask = RDI_STR | RDI_IMAGE | RDI_PARAM;
  215. resultItem.str = MMC_CALLBACK;
  216. resultItem.nImage = 1;
  217. resultItem.lParam = i->first;
  218. m_pResult->InsertItem(&resultItem);
  219. i->second.itemID = resultItem.itemID;
  220. i++;
  221. }
  222. m_pResult->Sort(0, 0, -1);
  223. }