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.

518 lines
13 KiB

  1. //+--------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1994 - 1998.
  5. //
  6. // File: data.cpp
  7. //
  8. // Contents: Defines storage class that maintains data for snap-in nodes.
  9. //
  10. // Classes: CAppData
  11. //
  12. // History: 05-27-1997 stevebl Created
  13. //
  14. //---------------------------------------------------------------------------
  15. #include "precomp.hxx"
  16. #ifdef _DEBUG
  17. #define new DEBUG_NEW
  18. #undef THIS_FILE
  19. static char THIS_FILE[] = __FILE__;
  20. #endif
  21. CAppData::CAppData()
  22. {
  23. m_pDetails = NULL;
  24. m_itemID = 0;
  25. m_fVisible = 0;
  26. m_fHide = FALSE;
  27. m_pProduct = NULL;
  28. m_pDeploy = NULL;
  29. m_pCategory = NULL;
  30. m_pXforms = NULL;
  31. m_pPkgDetails = NULL;
  32. m_pUpgradeList = NULL;
  33. m_pErrorInfo = NULL;
  34. m_pCause = NULL;
  35. m_fRSoP = FALSE;
  36. m_psd = NULL;
  37. m_dwApplyCause = 0;
  38. m_dwLanguageMatch = 0;
  39. m_szOnDemandFileExtension = L"";
  40. m_szOnDemandClsid = L"";
  41. m_szOnDemandProgid = L"";
  42. m_dwRemovalCause = 0;
  43. m_dwRemovalType = 0;
  44. m_szRemovingApplication = L"";
  45. m_szEventSource = L"";
  46. m_szEventLogName = L"";
  47. m_dwEventID = 0;
  48. m_szEventTime = L"";
  49. m_szEventLogText = L"";
  50. m_hrErrorCode = 0;
  51. m_nStatus = 0;
  52. }
  53. CAppData::~CAppData()
  54. {
  55. if (m_pProduct)
  56. {
  57. m_pProduct->SendMessage(WM_USER_CLOSE, 0, 0);
  58. }
  59. if (m_pDeploy)
  60. {
  61. m_pDeploy->SendMessage(WM_USER_CLOSE, 0, 0);
  62. }
  63. if (m_pCategory)
  64. {
  65. m_pCategory->SendMessage(WM_USER_CLOSE, 0, 0);
  66. }
  67. if (m_pUpgradeList)
  68. {
  69. m_pUpgradeList->SendMessage(WM_USER_CLOSE, 0, 0);
  70. }
  71. if (m_pXforms)
  72. {
  73. m_pXforms->SendMessage(WM_USER_CLOSE, 0, 0);
  74. }
  75. if (m_pPkgDetails)
  76. {
  77. m_pPkgDetails->SendMessage(WM_USER_CLOSE, 0, 0);
  78. }
  79. if (m_pErrorInfo)
  80. {
  81. m_pErrorInfo->SendMessage(WM_USER_CLOSE, 0, 0);
  82. }
  83. }
  84. void CAppData::NotifyChange(void)
  85. {
  86. if (m_pProduct)
  87. {
  88. m_pProduct->SendMessage(WM_USER_REFRESH, 0, 0);
  89. }
  90. if (m_pDeploy)
  91. {
  92. m_pDeploy->SendMessage(WM_USER_REFRESH, 0, 0);
  93. }
  94. if (m_pCategory)
  95. {
  96. m_pCategory->SendMessage(WM_USER_REFRESH, 0, 0);
  97. }
  98. if (m_pUpgradeList)
  99. {
  100. m_pUpgradeList->SendMessage(WM_USER_REFRESH, 0, 0);
  101. }
  102. if (m_pXforms)
  103. {
  104. m_pXforms->SendMessage(WM_USER_REFRESH, 0, 0);
  105. }
  106. if (m_pPkgDetails)
  107. {
  108. m_pPkgDetails->SendMessage(WM_USER_REFRESH, 0, 0);
  109. }
  110. if (m_pErrorInfo)
  111. {
  112. m_pErrorInfo->SendMessage(WM_USER_REFRESH, 0, 0);
  113. }
  114. }
  115. void CAppData::InitializeExtraInfo(void)
  116. {
  117. // at the moment, there is no extra info
  118. return;
  119. }
  120. void CAppData::GetSzPublisher(CString &sz)
  121. {
  122. sz = m_pDetails->pszPublisher;
  123. }
  124. void CAppData::GetSzOOSUninstall(CString &sz)
  125. {
  126. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  127. sz.LoadString((m_pDetails->pInstallInfo->dwActFlags & ACTFLG_UninstallOnPolicyRemoval) ? IDS_YES : IDS_NO);
  128. }
  129. void CAppData::GetSzShowARP(CString &sz)
  130. {
  131. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  132. sz.LoadString((m_pDetails->pInstallInfo->dwActFlags & ACTFLG_UserInstall) ? IDS_YES : IDS_NO);
  133. }
  134. void CAppData::GetSzUIType(CString &sz)
  135. {
  136. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  137. sz.LoadString((m_pDetails->pInstallInfo->InstallUiLevel == INSTALLUILEVEL_FULL) ? IDS_MAXIMUM : IDS_BASIC);
  138. }
  139. void CAppData::GetSzIgnoreLoc(CString &sz)
  140. {
  141. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  142. sz.LoadString((m_pDetails->pInstallInfo->dwActFlags & ACTFLG_IgnoreLanguage) ? IDS_YES : IDS_NO);
  143. }
  144. void CAppData::GetSzRemovePrev(CString &sz)
  145. {
  146. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  147. sz.LoadString((m_pDetails->pInstallInfo->dwActFlags & ACTFLG_UninstallUnmanaged) ? IDS_YES : IDS_NO);
  148. }
  149. void CAppData::GetSzX86onIA64(CString &sz)
  150. {
  151. BOOL fYes = 0;
  152. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  153. //
  154. // Check this only for 32-bit apps
  155. //
  156. if ( ! Is64Bit() )
  157. {
  158. fYes = 0 != (m_pDetails->pInstallInfo->dwActFlags & ACTFLG_ExcludeX86OnIA64);
  159. }
  160. if ( ! Is64Bit() )
  161. {
  162. if (m_pDetails->pInstallInfo->PathType == SetupNamePath)
  163. {
  164. //reverse the sense for legacy apps
  165. // (this flag has the opposite meaning for legacy apps)
  166. fYes = !fYes;
  167. }
  168. }
  169. sz.LoadString(fYes ? IDS_YES : IDS_NO);
  170. }
  171. void CAppData::GetSzFullInstall(CString &sz)
  172. {
  173. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  174. if (m_pDetails->pInstallInfo->dwActFlags & ACTFLG_Assigned)
  175. {
  176. sz.LoadString((m_pDetails->pInstallInfo->dwActFlags & ACTFLG_InstallUserAssign) ? IDS_YES : IDS_NO);
  177. }
  178. else
  179. {
  180. sz.LoadString(IDS_NA);
  181. }
  182. }
  183. void CAppData::GetSzProductCode(CString &sz)
  184. {
  185. // szA = dataA.m_pDetails->pInstallInfo->ProductCode
  186. OLECHAR szTemp[80];
  187. StringFromGUID2(m_pDetails->pInstallInfo->ProductCode,
  188. szTemp,
  189. sizeof(szTemp) / sizeof(szTemp[0]));
  190. sz = szTemp;
  191. }
  192. void CAppData::GetSzOrigin(CString &sz)
  193. {
  194. sz = m_szGPOName;
  195. }
  196. void CAppData::GetSzSOM(CString &sz)
  197. {
  198. sz = m_szSOMID;
  199. }
  200. void CAppData::GetSzDeployment(CString &sz)
  201. {
  202. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  203. int id;
  204. if (m_pDetails->pInstallInfo->dwActFlags & ACTFLG_Assigned)
  205. id = IDS_ASSIGNED;
  206. else
  207. if (m_pDetails->pInstallInfo->dwActFlags & ACTFLG_Published)
  208. id = IDS_PUBLISHED;
  209. else
  210. id = IDS_DISABLED;
  211. sz.LoadString(id);
  212. }
  213. void CAppData::GetSzAutoInstall(CString &sz)
  214. {
  215. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  216. sz.LoadString((m_pDetails->pInstallInfo->dwActFlags & ACTFLG_OnDemandInstall) ? IDS_YES : IDS_NO);
  217. }
  218. void CAppData::GetSzLocale(CString &sz)
  219. {
  220. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  221. TCHAR szBuffer[256];
  222. sz = "";
  223. UINT i = 0;
  224. while (i < m_pDetails->pPlatformInfo->cLocales)
  225. {
  226. if (i > 0)
  227. {
  228. sz += ", ";
  229. }
  230. if (m_pDetails->pPlatformInfo->prgLocale[i])
  231. {
  232. GetLocaleInfo(m_pDetails->pPlatformInfo->prgLocale[i], LOCALE_SLANGUAGE, szBuffer, 256);
  233. sz += szBuffer;
  234. #ifdef SHOWCOUNTRY
  235. GetLocaleInfo(m_pDetails->pPlatformInfo->prgLocale[i], LOCALE_SCOUNTRY, szBuffer, 256);
  236. sz += _T(" - ");
  237. sz += szBuffer;
  238. #endif
  239. }
  240. else
  241. {
  242. // neutral locale
  243. CString szNeutral;
  244. szNeutral.LoadString(IDS_NEUTRAL_LOCALE);
  245. sz += szNeutral;
  246. }
  247. i++;
  248. }
  249. }
  250. void CAppData::GetSzPlatform(CString &sz)
  251. {
  252. TCHAR szBuffer[256];
  253. sz = "";
  254. UINT i = 0;
  255. while (i < m_pDetails->pPlatformInfo->cPlatforms)
  256. {
  257. if (i > 0)
  258. {
  259. sz += ", ";
  260. }
  261. #if 0 // I'm only going to display the processor to simplify the display
  262. ::LoadString(ghInstance, IDS_OS + m_pDetails->pPlatformInfo->prgPlatform[i].dwPlatformId + 1, szBuffer, 256);
  263. sz += szBuffer;
  264. wsprintf(szBuffer, _T(" %u.%u/"), m_pDetails->pPlatformInfo->prgPlatform[i].dwVersionHi, pDetails->pPlatformInfo->prgPlatform[i].dwVersionLo);
  265. sz += szBuffer;
  266. #endif
  267. ::LoadString(ghInstance, IDS_HW + m_pDetails->pPlatformInfo->prgPlatform[i].dwProcessorArch, szBuffer, 256);
  268. sz += szBuffer;
  269. i++;
  270. }
  271. }
  272. void CAppData::GetSzUpgrades(CString &sz, CScopePane * pScopePane)
  273. {
  274. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  275. if (!m_szUpgrades.IsEmpty())
  276. {
  277. sz = m_szUpgrades;
  278. return;
  279. }
  280. if (m_fRSoP)
  281. {
  282. switch (m_setUpgrade.size() + m_setReplace.size())
  283. {
  284. case 0:
  285. sz.LoadString(IDS_NONE);
  286. break;
  287. case 1:
  288. if (1 == m_setUpgrade.size())
  289. {
  290. sz = *m_setUpgrade.begin();
  291. }
  292. else
  293. {
  294. sz = *m_setReplace.begin();
  295. }
  296. break;
  297. default:
  298. sz.LoadString(IDS_MULTIPLE);
  299. break;
  300. }
  301. }
  302. else
  303. {
  304. sz="";
  305. CString szName;
  306. UINT n = m_pDetails->pInstallInfo->cUpgrades;
  307. while (n--)
  308. {
  309. if (0 == (UPGFLG_UpgradedBy & m_pDetails->pInstallInfo->prgUpgradeInfoList[n].Flag))
  310. {
  311. HRESULT hr = pScopePane->GetPackageNameFromUpgradeInfo(szName, m_pDetails->pInstallInfo->prgUpgradeInfoList[n].PackageGuid, m_pDetails->pInstallInfo->prgUpgradeInfoList[n].szClassStore);
  312. if (SUCCEEDED(hr))
  313. {
  314. if (sz.GetLength())
  315. {
  316. // We'd already found one
  317. sz.LoadString(IDS_MULTIPLE);
  318. m_szUpgrades = sz;
  319. return;
  320. }
  321. sz = szName;
  322. }
  323. }
  324. }
  325. if (0 == sz.GetLength())
  326. {
  327. sz.LoadString(IDS_NONE);
  328. }
  329. }
  330. m_szUpgrades = sz;
  331. }
  332. void CAppData::GetSzUpgradedBy(CString &sz, CScopePane * pScopePane)
  333. {
  334. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  335. if (m_fRSoP)
  336. {
  337. switch (m_setUpgradedBy.size())
  338. {
  339. case 0:
  340. sz.LoadString(IDS_NONE);
  341. break;
  342. case 1:
  343. sz = *m_setUpgradedBy.begin();
  344. break;
  345. default:
  346. sz.LoadString(IDS_MULTIPLE);
  347. break;
  348. }
  349. }
  350. else
  351. {
  352. UINT n = m_pDetails->pInstallInfo->cUpgrades;
  353. CString szName;
  354. sz="";
  355. while (n--)
  356. {
  357. if (0 != (UPGFLG_UpgradedBy & m_pDetails->pInstallInfo->prgUpgradeInfoList[n].Flag))
  358. {
  359. HRESULT hr = pScopePane->GetPackageNameFromUpgradeInfo(szName, m_pDetails->pInstallInfo->prgUpgradeInfoList[n].PackageGuid, m_pDetails->pInstallInfo->prgUpgradeInfoList[n].szClassStore);
  360. if (SUCCEEDED(hr))
  361. {
  362. if (sz.GetLength())
  363. {
  364. // We'd already found one
  365. sz.LoadString(IDS_MULTIPLE);
  366. return;
  367. }
  368. sz = szName;
  369. }
  370. }
  371. }
  372. if (0 == sz.GetLength())
  373. {
  374. sz.LoadString(IDS_NONE);
  375. }
  376. }
  377. }
  378. void CAppData::GetSzStage(CString &sz)
  379. {
  380. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  381. BOOL fUpgrades = FALSE;
  382. if (m_fRSoP)
  383. {
  384. fUpgrades = (m_setUpgrade.size() + m_setReplace.size()) != 0;
  385. }
  386. else
  387. {
  388. UINT n = m_pDetails->pInstallInfo->cUpgrades;
  389. while (n-- && !fUpgrades)
  390. {
  391. if (0 == (UPGFLG_UpgradedBy & m_pDetails->pInstallInfo->prgUpgradeInfoList[n].Flag))
  392. {
  393. fUpgrades = TRUE;
  394. }
  395. }
  396. }
  397. if (!fUpgrades)
  398. {
  399. sz.LoadString(IDS_NONE);
  400. }
  401. else
  402. if (ACTFLG_ForceUpgrade & m_pDetails->pInstallInfo->dwActFlags)
  403. sz.LoadString(IDS_REQUIRED);
  404. else
  405. sz.LoadString(IDS_OPTIONAL);
  406. }
  407. void CAppData::GetSzVersion(CString &sz)
  408. {
  409. TCHAR szBuffer[256];
  410. wsprintf(szBuffer, _T("%u.%u"), m_pDetails->pInstallInfo->dwVersionHi, m_pDetails->pInstallInfo->dwVersionLo);
  411. sz = szBuffer;
  412. }
  413. void CAppData::GetSzSource(CString &sz)
  414. {
  415. if (1 <= m_pDetails->cSources)
  416. {
  417. sz = m_pDetails->pszSourceList[0];
  418. }
  419. else
  420. sz = "";
  421. }
  422. void CAppData::GetSzMods(CString &sz)
  423. {
  424. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  425. if (2 < m_pDetails->cSources)
  426. {
  427. sz.LoadString(IDS_MULTIPLE);
  428. }
  429. else
  430. {
  431. if (2 == m_pDetails->cSources)
  432. {
  433. sz = m_pDetails->pszSourceList[1];
  434. }
  435. else
  436. sz = "";
  437. }
  438. }
  439. int CAppData::GetImageIndex(CScopePane * pScopePane)
  440. {
  441. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  442. if (m_nStatus == 3)
  443. {
  444. // RSoP setting failed status
  445. return IMG_OPEN_FAILED;
  446. }
  447. CString sz;
  448. GetSzUpgrades(sz, pScopePane);
  449. CString sz2;
  450. sz2.LoadString(IDS_NONE);
  451. // gonna use the upgrade icon but it's only gonna be used when
  452. // m_szUpgrades doesn't read "none"
  453. if (0 != sz2.Compare(sz))
  454. {
  455. // we must be upgrading something
  456. return IMG_UPGRADE;
  457. }
  458. if (m_pDetails->pInstallInfo->dwActFlags & ACTFLG_Assigned)
  459. return IMG_ASSIGNED;
  460. else
  461. if (m_pDetails->pInstallInfo->dwActFlags & ACTFLG_Published)
  462. return IMG_PUBLISHED;
  463. else
  464. return IMG_DISABLED;
  465. }
  466. BOOL CAppData::Is64Bit( PACKAGEDETAIL* pPackageDetails )
  467. {
  468. UINT n = pPackageDetails->pPlatformInfo->cPlatforms;
  469. while (n--)
  470. {
  471. if (pPackageDetails->pPlatformInfo->prgPlatform[n].dwProcessorArch == PROCESSOR_ARCHITECTURE_IA64)
  472. {
  473. return TRUE;
  474. }
  475. }
  476. return FALSE;
  477. }
  478. BOOL CAppData::Is64Bit(void)
  479. {
  480. return Is64Bit( m_pDetails );
  481. }