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.

296 lines
7.9 KiB

  1. //+--------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1994 - 1997.
  5. //
  6. // File: data.cpp
  7. //
  8. // Contents: Defines storage class that maintains data for snap-in nodes.
  9. //
  10. // Classes: CAppData
  11. //
  12. // Functions:
  13. //
  14. // History: 05-27-1997 stevebl Created
  15. //
  16. //---------------------------------------------------------------------------
  17. #include "precomp.hxx"
  18. #ifdef _DEBUG
  19. #define new DEBUG_NEW
  20. #undef THIS_FILE
  21. static char THIS_FILE[] = __FILE__;
  22. #endif
  23. APP_DATA::APP_DATA()
  24. {
  25. pProduct = NULL;
  26. pDeploy = NULL;
  27. pLocPkg = NULL;
  28. pCategory = NULL;
  29. pXforms = NULL;
  30. pPkgDetails = NULL;
  31. }
  32. APP_DATA::~APP_DATA()
  33. {
  34. if (pProduct)
  35. {
  36. // NOTE: we only need to send this message to one page because this
  37. // action will close the entire property sheet.
  38. pProduct->SendMessage(WM_USER_CLOSE, 0, 0);
  39. }
  40. }
  41. void APP_DATA::NotifyChange(void)
  42. {
  43. if (pProduct)
  44. {
  45. pProduct->SendMessage(WM_USER_REFRESH, 0, 0);
  46. }
  47. if (pDeploy)
  48. {
  49. pDeploy->SendMessage(WM_USER_REFRESH, 0, 0);
  50. }
  51. if (pLocPkg)
  52. {
  53. pLocPkg->SendMessage(WM_USER_REFRESH, 0, 0);
  54. }
  55. if (pCategory)
  56. {
  57. pCategory->SendMessage(WM_USER_REFRESH, 0, 0);
  58. }
  59. if (pXforms)
  60. {
  61. pXforms->SendMessage(WM_USER_REFRESH, 0, 0);
  62. }
  63. if (pPkgDetails)
  64. {
  65. pPkgDetails->SendMessage(WM_USER_REFRESH, 0, 0);
  66. }
  67. }
  68. void APP_DATA::InitializeExtraInfo(void)
  69. {
  70. MSIHANDLE hProduct;
  71. UINT uiReturn;
  72. return; // BUGBUG - there is apparently some really wierd MSI error that
  73. // pops up here in certain circumstances. I don't pretend to
  74. // really understand it but I'll disable it for now.
  75. uiReturn = MsiOpenPackage(pDetails->pInstallInfo->pszScriptPath,
  76. &hProduct);
  77. if (uiReturn)
  78. {
  79. return;
  80. }
  81. WCHAR buffer[256];
  82. DWORD cch = 256;
  83. MsiGetProductProperty(hProduct,
  84. INSTALLPROPERTY_PUBLISHER,
  85. buffer,
  86. &cch);
  87. szPublisher = buffer;
  88. MsiCloseHandle(hProduct);
  89. }
  90. void APP_DATA::GetSzDeployment(CString &sz)
  91. {
  92. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  93. int id;
  94. if (pDetails->pInstallInfo->dwActFlags & ACTFLG_Assigned)
  95. id = IDS_ASSIGNED;
  96. else
  97. if (!(pDetails->pInstallInfo->dwActFlags & (ACTFLG_OnDemandInstall | ACTFLG_UserInstall)))
  98. id = IDS_DISABLED;
  99. else
  100. id = IDS_PUBLISHED;
  101. sz.LoadString(id);
  102. }
  103. void APP_DATA::GetSzAutoInstall(CString &sz)
  104. {
  105. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  106. sz.LoadString((pDetails->pInstallInfo->dwActFlags & ACTFLG_OnDemandInstall) ? IDS_YES : IDS_NO);
  107. }
  108. void APP_DATA::GetSzLocale(CString &sz)
  109. {
  110. TCHAR szBuffer[256];
  111. sz = "";
  112. UINT i = 0;
  113. while (i < pDetails->pPlatformInfo->cLocales)
  114. {
  115. if (i > 0)
  116. {
  117. sz += ", ";
  118. }
  119. GetLocaleInfo(pDetails->pPlatformInfo->prgLocale[i], LOCALE_SLANGUAGE, szBuffer, 256);
  120. sz += szBuffer;
  121. GetLocaleInfo(pDetails->pPlatformInfo->prgLocale[i], LOCALE_SCOUNTRY, szBuffer, 256);
  122. sz += _T(" - ");
  123. sz += szBuffer;
  124. i++;
  125. }
  126. }
  127. void APP_DATA::GetSzPlatform(CString &sz)
  128. {
  129. TCHAR szBuffer[256];
  130. sz = "";
  131. UINT i = 0;
  132. while (i < pDetails->pPlatformInfo->cPlatforms)
  133. {
  134. if (i > 0)
  135. {
  136. sz += ", ";
  137. }
  138. #if 0 // I'm only going to display the processor to simplify the display
  139. ::LoadString(ghInstance, IDS_OS + pDetails->pPlatformInfo->prgPlatform[i].dwPlatformId + 1, szBuffer, 256);
  140. sz += szBuffer;
  141. wsprintf(szBuffer, _T(" %u.%u/"), pDetails->pPlatformInfo->prgPlatform[i].dwVersionHi, pDetails->pPlatformInfo->prgPlatform[i].dwVersionLo);
  142. sz += szBuffer;
  143. #endif
  144. ::LoadString(ghInstance, IDS_HW + pDetails->pPlatformInfo->prgPlatform[i].dwProcessorArch, szBuffer, 256);
  145. sz += szBuffer;
  146. i++;
  147. }
  148. }
  149. void APP_DATA::GetSzRelation(CString &sz, CComponentDataImpl * pCDI)
  150. {
  151. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  152. UINT n = pDetails->pInstallInfo->cUpgrades;
  153. long cookie = 0;
  154. BOOL fFound = FALSE;
  155. while (n--)
  156. {
  157. // BUGBUG - eventually we'll want to try and look this up on other
  158. // OUs as well.
  159. std::map<CString,long>::iterator i = pCDI->m_ScriptIndex.find(pDetails->pInstallInfo->prgUpgradeScript[n]);
  160. if (pCDI->m_ScriptIndex.end() != i)
  161. {
  162. if (fFound)
  163. {
  164. // found more than one app in this OU that I'm upgrading
  165. sz.LoadString(IDS_MULTIPLE);
  166. return;
  167. }
  168. cookie = i->second;
  169. fFound = TRUE;
  170. }
  171. }
  172. if (fFound)
  173. {
  174. // found exactly one app in this OU that I'm upgrading
  175. sz = pCDI->m_AppData[cookie].pDetails->pszPackageName;
  176. }
  177. else
  178. {
  179. // didn't find any apps in this OU that I'm upgrading
  180. sz.LoadString(IDS_NONE);
  181. }
  182. }
  183. void APP_DATA::GetSzStage(CString &sz, CComponentDataImpl * pCDI)
  184. {
  185. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  186. UINT n = pDetails->pInstallInfo->cUpgrades;
  187. if (n)
  188. {
  189. // Make sure at least one of the upgrade scripts is actually
  190. // deployed in this CS. Otherwise, we have to say the app is
  191. // deployed regardless of its state because we don't know if the
  192. // thing it upgrades has been removed or just exists on another OU.
  193. // BUGBUG - probably want to search other OUs here as well.
  194. while (n--)
  195. {
  196. std::map<CString,long>::iterator i = pCDI->m_ScriptIndex.find(pDetails->pInstallInfo->prgUpgradeScript[n]);
  197. if (pCDI->m_ScriptIndex.end() != i)
  198. {
  199. // found a match
  200. ULONG flags = pDetails->pInstallInfo->dwActFlags;
  201. flags &= ACTFLG_Assigned + ACTFLG_Published + ACTFLG_OnDemandInstall;
  202. if (flags == ACTFLG_Published)
  203. {
  204. // this is only true if the upgrading app is Published and !OnDemandInstall
  205. sz.LoadString(IDS_PILOT);
  206. }
  207. else
  208. {
  209. sz.LoadString(IDS_ROLLOUT);
  210. }
  211. return;
  212. }
  213. }
  214. }
  215. sz.LoadString(IDS_DEPLOYED);
  216. }
  217. void APP_DATA::GetSzVersion(CString &sz)
  218. {
  219. TCHAR szBuffer[256];
  220. wsprintf(szBuffer, _T("%u.%u"), pDetails->pInstallInfo->dwVersionHi, pDetails->pInstallInfo->dwVersionLo);
  221. sz = szBuffer;
  222. }
  223. void APP_DATA::GetSzSource(CString &sz)
  224. {
  225. if (1 <= pDetails->cSources)
  226. {
  227. sz = pDetails->pszSourceList[0];
  228. }
  229. else
  230. sz = "";
  231. }
  232. void APP_DATA::GetSzMods(CString &sz)
  233. {
  234. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  235. if (2 < pDetails->cSources)
  236. {
  237. sz.LoadString(IDS_MULTIPLE);
  238. }
  239. else
  240. {
  241. if (2 == pDetails->cSources)
  242. {
  243. sz = pDetails->pszSourceList[1];
  244. }
  245. else
  246. sz = "";
  247. }
  248. }
  249. int APP_DATA::GetImageIndex(CComponentDataImpl * pCDI)
  250. {
  251. UINT n = pDetails->pInstallInfo->cUpgrades;
  252. BOOL fFound = FALSE;
  253. if (0 < sUpgrades.size())
  254. {
  255. fFound = TRUE;
  256. }
  257. while (n-- && ! fFound)
  258. {
  259. // BUGBUG - eventually we'll want to try and look this up on other
  260. // OUs as well.
  261. std::map<CString,long>::iterator i = pCDI->m_ScriptIndex.find(pDetails->pInstallInfo->prgUpgradeScript[n]);
  262. if (pCDI->m_ScriptIndex.end() != i)
  263. {
  264. fFound = TRUE;
  265. }
  266. }
  267. if (fFound)
  268. {
  269. // I am involed in an upgrade relationship
  270. return IMG_UPGRADE;
  271. }
  272. if (pDetails->pInstallInfo->dwActFlags & ACTFLG_Assigned)
  273. return IMG_ASSIGNED;
  274. else
  275. if (!(pDetails->pInstallInfo->dwActFlags & (ACTFLG_OnDemandInstall | ACTFLG_UserInstall)))
  276. return IMG_DISABLED;
  277. else
  278. return IMG_PUBLISHED;
  279. }