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.

196 lines
5.5 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. }
  38. else
  39. {
  40. m_pResult->GetViewMode(&m_lViewMode);
  41. }
  42. return hr;
  43. }
  44. HRESULT CSnapin::OnActivate(long cookie, long arg, long param)
  45. {
  46. return S_OK;
  47. }
  48. HRESULT CSnapin::OnResultItemClkOrDblClk(long cookie, BOOL fDblClick)
  49. {
  50. return S_FALSE;
  51. }
  52. HRESULT CSnapin::OnMinimize(long cookie, long arg, long param)
  53. {
  54. return S_OK;
  55. }
  56. HRESULT CSnapin::OnSelect(DATA_OBJECT_TYPES type, long cookie, long arg, long param)
  57. {
  58. if (m_pConsoleVerb)
  59. {
  60. // If it's in the result pane then "properties" should be the
  61. // default action. Otherwise "open" should be the default action.
  62. if (type == CCT_RESULT)
  63. m_pConsoleVerb->SetDefaultVerb(MMC_VERB_PROPERTIES);
  64. else
  65. m_pConsoleVerb->SetDefaultVerb(MMC_VERB_OPEN);
  66. // Set the default verb to open
  67. // Enable the properties verb.
  68. m_pConsoleVerb->SetVerbState(MMC_VERB_PROPERTIES, ENABLED, TRUE);
  69. }
  70. return S_OK;
  71. }
  72. HRESULT CSnapin::OnPropertyChange(long param) // param is the cookie of the item that changed
  73. {
  74. HRESULT hr = S_OK;
  75. RESULTDATAITEM rd;
  76. memset(&rd, 0, sizeof(rd));
  77. rd.mask = RDI_IMAGE;
  78. rd.itemID = m_pComponentData->m_AppData[param].itemID;
  79. rd.nImage = m_pComponentData->m_AppData[param].GetImageIndex(m_pComponentData);
  80. m_pResult->SetItem(&rd);
  81. m_pResult->Sort(0, 0, -1);
  82. return hr;
  83. }
  84. HRESULT CSnapin::OnUpdateView(LPDATAOBJECT lpDataObject)
  85. {
  86. return S_OK;
  87. }
  88. void CSnapin::Enumerate(long cookie, HSCOPEITEM pParent)
  89. {
  90. EnumerateResultPane(cookie);
  91. }
  92. void CSnapin::EnumerateResultPane(long cookie)
  93. {
  94. // put up an hourglass (this could take a while)
  95. CHourglass hourglass;
  96. ASSERT(m_pResult != NULL); // make sure we QI'ed for the interface
  97. ASSERT(m_pComponentData != NULL);
  98. ASSERT(m_pComponentData->m_pIClassAdmin != NULL);
  99. RESULTDATAITEM resultItem;
  100. memset(&resultItem, 0, sizeof(RESULTDATAITEM));
  101. // Right now we only have one folder and it only
  102. // contains a list of application packages so this is really simple.
  103. if (m_pComponentData->m_AppData.begin() == m_pComponentData->m_AppData.end()) // test to see if the data has been initialized
  104. {
  105. IClassAdmin * pICA = m_pComponentData->m_pIClassAdmin;
  106. m_pIClassAdmin = pICA;
  107. CSPLATFORM csPlatform;
  108. memset(&csPlatform, 0, sizeof(CSPLATFORM));
  109. IEnumPackage * pIPE = NULL;
  110. HRESULT hr = pICA->EnumPackages(
  111. NULL,
  112. NULL,
  113. NULL,
  114. NULL,
  115. NULL,
  116. &pIPE);
  117. if (SUCCEEDED(hr))
  118. {
  119. hr = pIPE->Reset();
  120. while (SUCCEEDED(hr))
  121. {
  122. ULONG nceltFetched;
  123. PACKAGEDETAIL * pd = new PACKAGEDETAIL;
  124. PACKAGEDISPINFO * pi = new PACKAGEDISPINFO;
  125. hr = pIPE->Next(1, pi, &nceltFetched);
  126. if (nceltFetched)
  127. {
  128. pICA->GetPackageDetails(pi->pszPackageName, pd);
  129. APP_DATA data;
  130. data.pDetails = pd;
  131. data.InitializeExtraInfo();
  132. m_pComponentData->m_AppData[++m_pComponentData->m_lLastAllocated] = data;
  133. m_pComponentData->m_ScriptIndex[data.pDetails->pInstallInfo->pszScriptPath] = m_pComponentData->m_lLastAllocated;
  134. }
  135. else
  136. {
  137. delete pd;
  138. break;
  139. }
  140. if (pi)
  141. {
  142. delete pi;
  143. }
  144. }
  145. SAFE_RELEASE(pIPE);
  146. }
  147. if (SUCCEEDED(hr))
  148. {
  149. hr = m_pComponentData->PopulateExtensions();
  150. if (SUCCEEDED(hr))
  151. {
  152. hr = m_pComponentData->PopulateUpgradeLists();
  153. }
  154. }
  155. }
  156. std::map<long, APP_DATA>::iterator i = m_pComponentData->m_AppData.begin();
  157. while (i != m_pComponentData->m_AppData.end())
  158. {
  159. resultItem.mask = RDI_STR | RDI_IMAGE | RDI_PARAM;
  160. resultItem.str = MMC_CALLBACK;
  161. resultItem.nImage = i->second.GetImageIndex(m_pComponentData);
  162. resultItem.lParam = i->first;
  163. m_pResult->InsertItem(&resultItem);
  164. i->second.itemID = resultItem.itemID;
  165. i++;
  166. }
  167. m_pResult->Sort(0, 0, -1);
  168. }