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.

536 lines
14 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::GetSzX86OnWin64(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_ExcludeX86OnWin64);
  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. ::LoadString(ghInstance, IDS_HW + m_pDetails->pPlatformInfo->prgPlatform[i].dwProcessorArch, szBuffer, 256);
  262. sz += szBuffer;
  263. i++;
  264. }
  265. }
  266. void CAppData::GetSzUpgrades(CString &sz, CScopePane * pScopePane)
  267. {
  268. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  269. if (!m_szUpgrades.IsEmpty())
  270. {
  271. sz = m_szUpgrades;
  272. return;
  273. }
  274. if (m_fRSoP)
  275. {
  276. switch (m_setUpgrade.size() + m_setReplace.size())
  277. {
  278. case 0:
  279. sz.LoadString(IDS_NONE);
  280. break;
  281. case 1:
  282. if (1 == m_setUpgrade.size())
  283. {
  284. sz = *m_setUpgrade.begin();
  285. }
  286. else
  287. {
  288. sz = *m_setReplace.begin();
  289. }
  290. break;
  291. default:
  292. sz.LoadString(IDS_MULTIPLE);
  293. break;
  294. }
  295. }
  296. else
  297. {
  298. sz="";
  299. CString szName;
  300. UINT n = m_pDetails->pInstallInfo->cUpgrades;
  301. while (n--)
  302. {
  303. if (0 == (UPGFLG_UpgradedBy & m_pDetails->pInstallInfo->prgUpgradeInfoList[n].Flag))
  304. {
  305. HRESULT hr = pScopePane->GetPackageNameFromUpgradeInfo(szName, m_pDetails->pInstallInfo->prgUpgradeInfoList[n].PackageGuid, m_pDetails->pInstallInfo->prgUpgradeInfoList[n].szClassStore);
  306. if (SUCCEEDED(hr))
  307. {
  308. if (sz.GetLength())
  309. {
  310. // We'd already found one
  311. sz.LoadString(IDS_MULTIPLE);
  312. m_szUpgrades = sz;
  313. return;
  314. }
  315. sz = szName;
  316. }
  317. }
  318. }
  319. if (0 == sz.GetLength())
  320. {
  321. sz.LoadString(IDS_NONE);
  322. }
  323. }
  324. m_szUpgrades = sz;
  325. }
  326. void CAppData::GetSzUpgradedBy(CString &sz, CScopePane * pScopePane)
  327. {
  328. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  329. if (m_fRSoP)
  330. {
  331. switch (m_setUpgradedBy.size())
  332. {
  333. case 0:
  334. sz.LoadString(IDS_NONE);
  335. break;
  336. case 1:
  337. sz = *m_setUpgradedBy.begin();
  338. break;
  339. default:
  340. sz.LoadString(IDS_MULTIPLE);
  341. break;
  342. }
  343. }
  344. else
  345. {
  346. UINT n = m_pDetails->pInstallInfo->cUpgrades;
  347. CString szName;
  348. sz="";
  349. while (n--)
  350. {
  351. if (0 != (UPGFLG_UpgradedBy & m_pDetails->pInstallInfo->prgUpgradeInfoList[n].Flag))
  352. {
  353. HRESULT hr = pScopePane->GetPackageNameFromUpgradeInfo(szName, m_pDetails->pInstallInfo->prgUpgradeInfoList[n].PackageGuid, m_pDetails->pInstallInfo->prgUpgradeInfoList[n].szClassStore);
  354. if (SUCCEEDED(hr))
  355. {
  356. if (sz.GetLength())
  357. {
  358. // We'd already found one
  359. sz.LoadString(IDS_MULTIPLE);
  360. return;
  361. }
  362. sz = szName;
  363. }
  364. }
  365. }
  366. if (0 == sz.GetLength())
  367. {
  368. sz.LoadString(IDS_NONE);
  369. }
  370. }
  371. }
  372. void CAppData::GetSzStage(CString &sz)
  373. {
  374. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  375. BOOL fUpgrades = FALSE;
  376. if (m_fRSoP)
  377. {
  378. fUpgrades = (m_setUpgrade.size() + m_setReplace.size()) != 0;
  379. }
  380. else
  381. {
  382. UINT n = m_pDetails->pInstallInfo->cUpgrades;
  383. while (n-- && !fUpgrades)
  384. {
  385. if (0 == (UPGFLG_UpgradedBy & m_pDetails->pInstallInfo->prgUpgradeInfoList[n].Flag))
  386. {
  387. fUpgrades = TRUE;
  388. }
  389. }
  390. }
  391. if (!fUpgrades)
  392. {
  393. sz.LoadString(IDS_NONE);
  394. }
  395. else
  396. if (ACTFLG_ForceUpgrade & m_pDetails->pInstallInfo->dwActFlags)
  397. sz.LoadString(IDS_REQUIRED);
  398. else
  399. sz.LoadString(IDS_OPTIONAL);
  400. }
  401. void CAppData::GetSzVersion(CString &sz)
  402. {
  403. TCHAR szBuffer[256];
  404. (void) StringCchPrintf(szBuffer,
  405. sizeof(szBuffer)/sizeof(szBuffer[0]),
  406. _T("%u.%u"),
  407. m_pDetails->pInstallInfo->dwVersionHi,
  408. m_pDetails->pInstallInfo->dwVersionLo);
  409. sz = szBuffer;
  410. }
  411. void CAppData::GetSzSource(CString &sz)
  412. {
  413. if (1 <= m_pDetails->cSources)
  414. {
  415. sz = m_pDetails->pszSourceList[0];
  416. }
  417. else
  418. sz = "";
  419. }
  420. void CAppData::GetSzMods(CString &sz)
  421. {
  422. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  423. if (2 < m_pDetails->cSources)
  424. {
  425. sz.LoadString(IDS_MULTIPLE);
  426. }
  427. else
  428. {
  429. if (2 == m_pDetails->cSources)
  430. {
  431. sz = m_pDetails->pszSourceList[1];
  432. }
  433. else
  434. sz = "";
  435. }
  436. }
  437. int CAppData::GetImageIndex(CScopePane * pScopePane)
  438. {
  439. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  440. if (m_nStatus == 3)
  441. {
  442. // RSoP setting failed status
  443. return IMG_OPEN_FAILED;
  444. }
  445. CString sz;
  446. GetSzUpgrades(sz, pScopePane);
  447. CString sz2;
  448. sz2.LoadString(IDS_NONE);
  449. // gonna use the upgrade icon but it's only gonna be used when
  450. // m_szUpgrades doesn't read "none"
  451. if (0 != sz2.Compare(sz))
  452. {
  453. // we must be upgrading something
  454. return IMG_UPGRADE;
  455. }
  456. if (m_pDetails->pInstallInfo->dwActFlags & ACTFLG_Assigned)
  457. return IMG_ASSIGNED;
  458. else
  459. if (m_pDetails->pInstallInfo->dwActFlags & ACTFLG_Published)
  460. return IMG_PUBLISHED;
  461. else
  462. return IMG_DISABLED;
  463. }
  464. DWORD CAppData::Get64BitMsiArchFlags( PACKAGEDETAIL* pPackageDetails )
  465. {
  466. UINT n = pPackageDetails->pPlatformInfo->cPlatforms;
  467. while (n--)
  468. {
  469. if (pPackageDetails->pPlatformInfo->prgPlatform[n].dwProcessorArch == PROCESSOR_ARCHITECTURE_AMD64)
  470. {
  471. return MSIARCHITECTUREFLAGS_AMD64;
  472. }
  473. if (pPackageDetails->pPlatformInfo->prgPlatform[n].dwProcessorArch == PROCESSOR_ARCHITECTURE_IA64)
  474. {
  475. return MSIARCHITECTUREFLAGS_IA64;
  476. }
  477. }
  478. return 0;
  479. }
  480. BOOL CAppData::Is64Bit( PACKAGEDETAIL* pPackageDetails )
  481. {
  482. UINT n = pPackageDetails->pPlatformInfo->cPlatforms;
  483. while (n--)
  484. {
  485. if ((pPackageDetails->pPlatformInfo->prgPlatform[n].dwProcessorArch == PROCESSOR_ARCHITECTURE_AMD64) ||
  486. (pPackageDetails->pPlatformInfo->prgPlatform[n].dwProcessorArch == PROCESSOR_ARCHITECTURE_IA64))
  487. {
  488. return TRUE;
  489. }
  490. }
  491. return FALSE;
  492. }
  493. BOOL CAppData::Is64Bit(void)
  494. {
  495. return Is64Bit( m_pDetails );
  496. }