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.

6635 lines
236 KiB

  1. #include "precomp.h"
  2. #include <webcheck.h>
  3. #include <intshcut.h>
  4. #include <mlang.h>
  5. #include "ie4comp.h"
  6. #include "updates.h"
  7. extern TCHAR g_szCustIns[];
  8. extern TCHAR g_szTitle[];
  9. extern TCHAR g_szBuildTemp[];
  10. extern TCHAR g_szJobVersion[];
  11. extern HANDLE g_hLogFile;
  12. extern TCHAR g_aszLang[][16];
  13. extern int g_nLangs, g_iDownloadState;
  14. TCHAR g_szCustInf[MAX_PATH];
  15. HANDLE g_hDownloadEvent = 0;
  16. TCHAR g_szCifVer[MAX_PATH];
  17. TCHAR g_szDestCif[MAX_PATH];
  18. TCHAR g_szCif[MAX_PATH];
  19. TCHAR g_szCustCif[MAX_PATH];
  20. TCHAR g_szCustItems[MAX_PATH];
  21. TCHAR g_szMyCptrPath[MAX_PATH];
  22. TCHAR g_szCtlPanelPath[MAX_PATH];
  23. TCHAR g_szCustIcmPro[MAX_PATH];
  24. static TCHAR s_aszLangDesc[NUMLANG][64];
  25. UINT g_uiNumCabs = 0;
  26. COMPONENT g_aCustComponents[MAXCUST+1];
  27. int g_nCustComp;
  28. int g_iSelOpt;
  29. int g_nModes;
  30. SITEDATA g_aCustSites[NUMSITES];
  31. int g_iSelSite;
  32. int g_nDownloadUrls;
  33. TCHAR g_szAllModes[16];
  34. TCHAR g_szMastInf[MAX_PATH];
  35. TCHAR g_szDefInf[MAX_PATH];
  36. static DWORD s_dwTotalSize = 0;
  37. extern BOOL g_fCancelled;
  38. extern BOOL g_fDone;
  39. extern BOOL g_fLangInit;
  40. extern RECT g_dtRect;
  41. extern BOOL g_fMailNews95;
  42. extern int g_iCurPage;
  43. extern HWND g_hDlg;
  44. extern PROPSHEETPAGE g_psp[];
  45. extern TCHAR g_szBuildRoot[];
  46. extern TCHAR g_szSrcRoot[];
  47. extern TCHAR g_szWizRoot[];
  48. extern TCHAR g_szLanguage[];
  49. extern BOOL g_fIntranet;
  50. extern TCHAR szHtmlHelp[];
  51. #define NUM_BITMAPS 2
  52. #define CX_BITMAP 16
  53. #define CY_BITMAP 16
  54. PCOMPONENT g_paComp = NULL;
  55. PCOMPONENT g_pMNComp = NULL;
  56. PCOMP_VERSION g_rgCompVer = NULL;
  57. HANDLE g_hAVSThread = NULL;
  58. BOOL g_fOptCompInit = FALSE;
  59. static BOOL s_fCustCompInit = FALSE;
  60. TCHAR g_szActLang[4];
  61. static TCHAR s_szCifNew[MAX_PATH];
  62. static TCHAR s_szCifCabURL[MAX_PATH];
  63. TCHAR g_szIEAKProg[MAX_PATH] = TEXT("");
  64. TCHAR g_szBaseURL[MAX_URL];
  65. TCHAR g_szUpdateData[MAX_URL] = TEXT("");
  66. TCHAR g_szUpdateURL[MAX_URL] = TEXT("");
  67. TCHAR g_szFailedCompsMsg[MAX_PATH];
  68. TCHAR g_szFailedComps[MAX_BUF];
  69. TCHAR g_szFailedCompsBox[MAX_PATH + MAX_BUF];
  70. BOOL g_fFailedComp = FALSE;
  71. HIMAGELIST s_hImgList = 0;
  72. static int s_iSelComp = 0;
  73. static PCOMPONENT s_pSelComp;
  74. static int s_nNewCust = 1;
  75. static TCHAR s_szNewTpl[80];
  76. static WORD s_aCustStaticTextFieldID[] =
  77. {
  78. IDC_LOC1, IDC_PARAM1, IDC_LOC3, IDC_LOC4, IDC_PARAM2, IDC_SIZE2, IDC_TITLE1, IDC_COMPDESC
  79. };
  80. #define NCUSTSTATICTEXTFIELDS sizeof(s_aCustStaticTextFieldID)/sizeof(WORD)
  81. static WORD s_aCustTextFieldID[] =
  82. {
  83. IDE_COMPFILENAME, IDE_COMPPARAM, /* IDE_COMPSIZE,*/ IDE_COMPGUID,
  84. IDE_COMPCOMMAND, IDE_UNINSTALLKEY, IDE_COMPVERSION, IDC_COMPTITLE, IDE_COMPDESC
  85. };
  86. #define NCUSTTEXTFIELDS sizeof(s_aCustTextFieldID)/sizeof(WORD)
  87. static WORD s_aCustFieldID[] =
  88. {
  89. IDE_COMPFILENAME, IDE_COMPPARAM, /* IDE_COMPSIZE,*/ IDE_COMPGUID,
  90. IDE_COMPCOMMAND, IDE_UNINSTALLKEY, IDE_COMPVERSION, IDC_COMPTITLE,
  91. IDC_VERIFY, IDC_REMOVECOMP, IDC_BROWSEFILE, IDE_COMPDESC, IDC_PREINSTALL, IDC_POSTINSTALL,
  92. IDC_REBOOTINSTALL, IDC_INSTALLSUCCESS
  93. };
  94. void updateCifVersions32(PCOMPONENT pComp, BOOL fIgnore, BOOL fUpdate = FALSE);
  95. #define NCUSTFIELDS sizeof(s_aCustFieldID)/sizeof(WORD)
  96. void UpdateInf(LPTSTR szMasterInf, LPTSTR szUserInf);
  97. static BOOL s_fNoCore;
  98. TCHAR g_szTempSign[MAX_PATH] = TEXT("");
  99. static TCHAR s_szSiteData[MAX_URL];
  100. extern BOOL g_fBatch;
  101. extern BOOL g_fBatch2;
  102. BOOL g_fInteg = FALSE;
  103. extern void CheckBatchAdvance(HWND hDlg);
  104. extern void DoBatchAdvance(HWND hDlg);
  105. extern DWORD GetRootFree(LPCTSTR pcszPath);
  106. extern BOOL g_fSilent, g_fStealth;
  107. extern void UpdateIEAK(HWND hDlg);
  108. // trust key defines, this are bit fields to determine which one to add/delete
  109. struct TrustKey
  110. {
  111. TCHAR szCompanyName[MAX_PATH];
  112. TCHAR szTrustString[MAX_PATH];
  113. BOOL fSet;
  114. };
  115. static TrustKey s_tkTrustArray[] =
  116. {{TEXT("Microsoft Corporation"), TEXT("bhhphijojgfcdocagmhjgjbhmieinfap jpjmcfmhckkdfknkfemjikfiodeelkbd"), TRUE},
  117. {TEXT("Microsoft Corporation"), TEXT("bhhphijojgfcdocagmhjgjbhmieinfap immbkmbpjfdkajbkncahcedfmndgehba"), TRUE},
  118. {TEXT("Microsoft Corporation (Europe)"), TEXT("bhhphijojgfcdocagmhjgjbhmieinfap doamnolbnlpmdlpnkcnpckgfimpaaicl"), TRUE},
  119. {TEXT("Microsoft Corporation"), TEXT("bhhphijojgfcdocagmhjgjbhmieinfap hbgflemajngobcablgnalaidgojggghj"), TRUE},
  120. {TEXT("Microsoft Corporation"), TEXT("bhhphijojgfcdocagmhjgjbhmieinfap debgjcefniaahdamnhbggedppfiianff"), TRUE}, // new MS cert effective from 4/16/99
  121. {TEXT("Microsoft Corporation (Europe)"), TEXT("bhhphijojgfcdocagmhjgjbhmieinfap kefdggbdmbmgbogjdcnmkoodcknmmghc"), TRUE}, // new MS Europe cert effective from 4/16/99
  122. {TEXT("VDOnet Corporation"), TEXT("bhhphijojgfcdocagmhjgjbhmieinfap moambfklemnlbmhfoomjdignnbkjfkek"), TRUE},
  123. {TEXT("Progressive Networks, Inc."), TEXT("bhhphijojgfcdocagmhjgjbhmieinfap cdikdekkiddcimdmcgedabijgpeobdhd"), TRUE},
  124. {TEXT("Macromedia, Inc."), TEXT("bhhphijojgfcdocagmhjgjbhmieinfap akhlecfpbbjjngidddpgifggcplpcego"), TRUE}
  125. };
  126. extern BOOL g_fSrcDirChanged;
  127. extern HINSTANCE hBrand;
  128. extern BOOL g_fCD, g_fLAN, g_fDownload, g_fBrandingOnly;
  129. BOOL g_fLocalMode = FALSE;
  130. DWORD BuildCDandMflop(LPVOID);
  131. HANDLE g_hProcessInfEvent = 0;
  132. HANDLE g_hCifEvent = 0;
  133. extern BOOL g_fOCW;
  134. // core section component names for base
  135. #define BASEWIN32 TEXT("BASEIE40_WIN")
  136. // returns the component structure for base IE4 component, if for some
  137. // weird reason its not there just return the first component structure
  138. // in the list
  139. PCOMPONENT FindComp(LPCTSTR szID, BOOL fCore)
  140. {
  141. PCOMPONENT pComp;
  142. UINT i;
  143. for (pComp = g_paComp, i=0; ((i < g_uiNumCabs) && (*pComp->szSection)); pComp++)
  144. {
  145. if (fCore)
  146. {
  147. // Note: we are depending on the section name of core IE4 here
  148. if (StrCmpI(pComp->szSection, BASEWIN32) == 0)
  149. return pComp;
  150. }
  151. else
  152. {
  153. if (StrCmpI(pComp->szSection, szID) == 0)
  154. return pComp;
  155. }
  156. }
  157. if (fCore)
  158. return g_paComp;
  159. else
  160. return NULL;
  161. }
  162. PCOMPONENT FindVisibleComponentName(LPCTSTR pcszCompName)
  163. {
  164. PCOMPONENT pComp;
  165. for (pComp = g_paComp; *pComp->szSection; pComp++ )
  166. {
  167. if ((StrCmpI(pComp->szDisplayName, pcszCompName) == 0) && pComp->fVisible &&
  168. !pComp->fAddOnOnly)
  169. return(pComp);
  170. }
  171. return(NULL);
  172. }
  173. PCOMPONENT FindCustComp(LPCTSTR szID)
  174. {
  175. PCOMPONENT pComp;
  176. for (pComp = g_aCustComponents; *pComp->szSection; pComp++)
  177. {
  178. if (StrCmpI(pComp->szSection, szID) == 0)
  179. return pComp;
  180. }
  181. return NULL;
  182. }
  183. PCOMPONENT FindCustComponentName(LPTSTR szCompName)
  184. {
  185. int i;
  186. PCOMPONENT pComp;
  187. for (i = 0, pComp = g_aCustComponents; i < g_nCustComp; i++, pComp++ )
  188. {
  189. if (StrCmp(pComp->szDisplayName, szCompName) == 0) return(pComp);
  190. }
  191. return(NULL);
  192. }
  193. PCOMPONENT FindCustComponentIndex(int iList)
  194. {
  195. int i;
  196. PCOMPONENT pComp;
  197. for (i = 0, pComp = g_aCustComponents; i < g_nCustComp; i++, pComp++ )
  198. {
  199. if (pComp->iList == iList) return(pComp);
  200. }
  201. return(NULL);
  202. }
  203. int GetActiveSetupURL( LPTSTR pSection, LPTSTR szUrl, int /*iSize*/, LPTSTR szCif)
  204. {
  205. TCHAR szUrlWrk[MAX_URL];
  206. GetPrivateProfileString( pSection, TEXT("URL1"), TEXT(""), szUrlWrk, MAX_URL, szCif );
  207. if (*szUrlWrk != TEXT('"')) StrCpy(szUrl, szUrlWrk);
  208. else
  209. StrCpy(szUrl, szUrlWrk + 1);
  210. StrTok(szUrl + 1, TEXT("\" ,"));
  211. return(lstrlen(szUrl));
  212. }
  213. void WriteActiveSetupURL(PCOMPONENT pComp, LPTSTR szCif)
  214. {
  215. TCHAR szUrlWrk[MAX_URL] = TEXT("\"");
  216. StrCat(szUrlWrk, pComp->szUrl);
  217. StrCat(szUrlWrk, (pComp->iType != INST_CAB) ? TEXT("\",2") : TEXT("\",3"));
  218. WritePrivateProfileString(pComp->szSection, TEXT("URL1"), szUrlWrk, szCif);
  219. }
  220. //
  221. // FUNCTION: GetCustComponent(HWND, int)
  222. //
  223. // PURPOSE: Gets custom component data entered in the dialog boxes,
  224. // and saves it in memory
  225. //
  226. void GetCustComponent(HWND hDlg, int iList)
  227. {
  228. PCOMPONENT pComp = FindCustComponentIndex(iList);
  229. if (pComp == NULL) return;
  230. GetDlgItemText( hDlg, IDE_COMPFILENAME, pComp->szPath, countof(pComp->szPath) );
  231. GetDlgItemText( hDlg, IDE_COMPCOMMAND, pComp->szCommand, countof(pComp->szCommand) );
  232. GetDlgItemText( hDlg, IDE_COMPPARAM, pComp->szSwitches, countof(pComp->szSwitches) );
  233. GetDlgItemText( hDlg, IDE_COMPGUID, pComp->szGUID, countof(pComp->szGUID) );
  234. GetDlgItemText( hDlg, IDE_UNINSTALLKEY, pComp->szUninstall, countof(pComp->szUninstall) );
  235. GetDlgItemText( hDlg, IDE_COMPVERSION, pComp->szVersion, countof(pComp->szVersion) );
  236. SendDlgItemMessage( hDlg, IDC_COMPTITLE, CB_GETLBTEXT, pComp->iList,(LPARAM) pComp->szDisplayName );
  237. GetDlgItemText( hDlg, IDE_COMPDESC, pComp->szDesc, countof(pComp->szDesc) );
  238. if (IsDlgButtonChecked(hDlg, IDC_POSTINSTALL) == BST_CHECKED)
  239. pComp->iInstallType = 0;
  240. else
  241. {
  242. if (IsDlgButtonChecked(hDlg, IDC_PREINSTALL) == BST_CHECKED)
  243. pComp->iInstallType = 1;
  244. else
  245. pComp->iInstallType = 2;
  246. }
  247. pComp->fIEDependency = (IsDlgButtonChecked(hDlg, IDC_INSTALLSUCCESS) == BST_CHECKED);
  248. }
  249. void CheckCompType(HWND hDlg, PCOMPONENT pComp )
  250. {
  251. HANDLE hFile;
  252. DWORD dwSize = 0;
  253. LPTSTR pDot, pBack;
  254. if (!pComp) return;
  255. GetDlgItemText( hDlg, IDE_COMPFILENAME, pComp->szPath, countof(pComp->szPath) );
  256. pComp->dwSize = 0;
  257. if ((hFile = CreateFile(pComp->szPath, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE,
  258. NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)) != INVALID_HANDLE_VALUE)
  259. {
  260. pComp->dwSize = ((dwSize = GetFileSize(hFile, NULL)) != 0xffffffff) ? (dwSize >> 10) : 0;
  261. CloseHandle(hFile);
  262. }
  263. //SetDlgItemInt( hDlg, IDE_COMPSIZE, dwSize, FALSE);
  264. pDot = StrRChr(pComp->szPath, NULL, TEXT('.'));
  265. pBack = StrRChr(pComp->szPath, NULL, TEXT('\\'));
  266. if ((pDot != NULL) && (StrCmpI(pDot, TEXT(".cab")) == 0))
  267. {
  268. EnableDlgItem(hDlg, IDE_COMPCOMMAND);
  269. pComp->iType = INST_CAB;
  270. if (pBack != NULL)
  271. {
  272. StrCpy(pComp->szUrl, pBack + 1);
  273. }
  274. return;
  275. }
  276. DisableDlgItem(hDlg, IDE_COMPCOMMAND);
  277. if ((pDot != NULL) && (StrCmpI(pDot, TEXT(".exe")) == 0))
  278. {
  279. pComp->iType = INST_EXE;
  280. if (pBack != NULL)
  281. {
  282. StrCpy(pComp->szCommand, pBack + 1);
  283. StrCpy(pComp->szUrl, pBack + 1);
  284. SetDlgItemText( hDlg, IDE_COMPCOMMAND, pComp->szCommand );
  285. }
  286. }
  287. }
  288. //
  289. // FUNCTION: SetCustComponent(HWND, int)
  290. //
  291. // PURPOSE: Gets custom component data from memory,
  292. // and displays it on the screen
  293. //
  294. void SetCustComponent(HWND hDlg, int iList)
  295. {
  296. PCOMPONENT pComp = FindCustComponentIndex(iList);
  297. if (!pComp)
  298. {
  299. int i;
  300. SendDlgItemMessage( hDlg, IDC_COMPTITLE, CB_SETCURSEL, 0, 0L );
  301. for (i = 0; i < NCUSTFIELDS ; i++ )
  302. {
  303. EnsureDialogFocus(hDlg, s_aCustFieldID[i], IDC_ADDNEWCOMP);
  304. DisableDlgItem(hDlg, s_aCustFieldID[i]);
  305. }
  306. for (i = 0; i < NCUSTTEXTFIELDS ; i++ )
  307. {
  308. SetDlgItemText( hDlg, s_aCustTextFieldID[i] , TEXT("") );
  309. }
  310. for (i = 0; i < NCUSTSTATICTEXTFIELDS ; i++ )
  311. DisableDlgItem(hDlg, s_aCustStaticTextFieldID[i]);
  312. CheckDlgButton(hDlg, IDC_PREINSTALL, BST_UNCHECKED);
  313. return;
  314. }
  315. SetDlgItemText( hDlg, IDE_COMPFILENAME, pComp->szPath );
  316. CheckCompType(hDlg, pComp);
  317. SetDlgItemText( hDlg, IDE_COMPCOMMAND, pComp->szCommand );
  318. if (ISNULL(pComp->szGUID))
  319. {
  320. GUID guid;
  321. if (CoCreateGuid(&guid) == NOERROR)
  322. CoStringFromGUID(guid, pComp->szGUID, countof(pComp->szGUID));
  323. else
  324. wnsprintf(pComp->szGUID, countof(pComp->szGUID), TEXT("CUSTOM%i"),iList);
  325. }
  326. SetDlgItemText( hDlg, IDE_COMPGUID, pComp->szGUID );
  327. SetDlgItemText( hDlg, IDE_COMPPARAM, pComp->szSwitches );
  328. SetDlgItemText( hDlg, IDE_UNINSTALLKEY, pComp->szUninstall );
  329. SetDlgItemText( hDlg, IDE_COMPVERSION, pComp->szVersion);
  330. SendDlgItemMessage( hDlg, IDC_COMPTITLE, CB_SETCURSEL, pComp->iList, 0L );
  331. SetDlgItemText( hDlg, IDC_COMPTITLE, pComp->szDisplayName);
  332. SetDlgItemText(hDlg, IDE_COMPDESC, pComp->szDesc);
  333. CheckRadioButton(hDlg, IDC_POSTINSTALL, IDC_REBOOTINSTALL, IDC_POSTINSTALL + pComp->iInstallType);
  334. CheckDlgButton( hDlg, IDC_INSTALLSUCCESS, pComp->fIEDependency ? BST_CHECKED : BST_UNCHECKED);
  335. EnableDlgItem2(hDlg, IDC_INSTALLSUCCESS, (pComp->iInstallType != 1));
  336. if (g_nCustComp < MAXCUST)
  337. EnableDlgItem(hDlg, IDC_ADDNEWCOMP);
  338. else
  339. {
  340. EnsureDialogFocus(hDlg, IDC_ADDNEWCOMP, IDC_REMOVECOMP);
  341. DisableDlgItem(hDlg, IDC_ADDNEWCOMP);
  342. }
  343. SetFocus(GetDlgItem( hDlg, IDC_COMPTITLE ));
  344. }
  345. void InitCustComponents(HWND hDlg)
  346. {
  347. TCHAR szSectBuf[2048];
  348. LPTSTR pSection = szSectBuf;
  349. HWND hCompList;
  350. PCOMPONENT pComp;
  351. TCHAR szCustCifName[32];
  352. if (hDlg) hCompList = GetDlgItem(hDlg, IDC_COMPTITLE);
  353. StrCpy(szCustCifName, TEXT("CUSTOM.CIF"));
  354. PathCombine(g_szCustCif, g_szBuildRoot, TEXT("INS"));
  355. PathAppend(g_szCustCif, GetOutputPlatformDir());
  356. PathAppend(g_szCustCif, g_szLanguage);
  357. PathAppend(g_szCustCif, szCustCifName);
  358. LoadString( g_rvInfo.hInst, IDS_NEWCUST, s_szNewTpl, countof(s_szNewTpl) );
  359. ZeroMemory(szSectBuf, sizeof(szSectBuf));
  360. GetPrivateProfileString( NULL, NULL, TEXT(""), szSectBuf, countof(szSectBuf), g_szCustCif );
  361. pComp = g_aCustComponents;
  362. g_nCustComp = 0;
  363. s_nNewCust = 1;
  364. while (*pSection)
  365. {
  366. int i;
  367. if (StrCmp(pSection, CUSTCMSECT) == 0)
  368. {
  369. pSection += lstrlen(pSection) + 1;
  370. continue;
  371. }
  372. StrCpy(pComp->szSection, pSection);
  373. GetPrivateProfileString( pSection, TEXT("Switches1"), TEXT(""), pComp->szSwitches, countof(pComp->szSwitches), g_szCustCif );
  374. GetPrivateProfileString( pSection, TEXT("DisplayName"), TEXT(""), pComp->szDisplayName, countof(pComp->szDisplayName), g_szCustCif );
  375. GetPrivateProfileString( pSection, TEXT("GUID"), TEXT(""), pComp->szGUID, countof(pComp->szGUID), g_szCustCif );
  376. GetPrivateProfileString( pSection, TEXT("UninstallKey"), TEXT(""), pComp->szUninstall, countof(pComp->szUninstall), g_szCustCif );
  377. GetActiveSetupURL( pSection, pComp->szUrl, countof(pComp->szUrl), g_szCustCif );
  378. GetPrivateProfileString( pSection, TEXT("Version"), TEXT(""), pComp->szVersion, countof(pComp->szVersion), g_szCustCif );
  379. GetPrivateProfileString( pSection, TEXT("Command1"), TEXT(""), pComp->szCommand, countof(pComp->szVersion), g_szCustCif );
  380. GetPrivateProfileString( pSection, TEXT("Path"), TEXT(""), pComp->szPath, countof(pComp->szPath), g_szCustCif );
  381. pComp->dwSize = GetPrivateProfileInt( pSection, TEXT("Size"), 0, g_szCustCif );
  382. pComp->iType = GetPrivateProfileInt( pSection, TEXT("Type1"), 0, g_szCustCif );
  383. pComp->iInstallType = GetPrivateProfileInt( pSection, TEXT("PreInstall"), 0, g_szCustCif);
  384. if (hDlg != NULL)
  385. pComp->iList = (int) SendDlgItemMessage( hDlg, IDC_COMPTITLE, CB_ADDSTRING, 0, (LPARAM) pComp->szDisplayName );
  386. GetPrivateProfileString( pSection, TEXT("Details"), TEXT(""), pComp->szDesc, countof(pComp->szDesc), g_szCustCif );
  387. pComp->fVisible = TRUE;
  388. pComp->fIEDependency = InsGetBool(pSection, TEXT("Dependency"), 0, g_szCustCif);
  389. if (StrCmpN(pComp->szDisplayName, s_szNewTpl, lstrlen(s_szNewTpl)) == 0)
  390. {
  391. i = StrToInt(pComp->szDisplayName + lstrlen(s_szNewTpl));
  392. if (i >= s_nNewCust) s_nNewCust = i + 1;
  393. }
  394. i = StrToInt(pSection + countof("CUSTOM")-1);
  395. if (i >= s_nNewCust) s_nNewCust = i + 1;
  396. pSection += StrLen(pSection) + 1;
  397. pComp++;
  398. g_nCustComp++;
  399. }
  400. s_iSelComp = 0;
  401. s_pSelComp = g_aCustComponents;
  402. if (hDlg != NULL)
  403. s_fCustCompInit = TRUE;
  404. if (g_nCustComp == 0)
  405. {
  406. if (hDlg != NULL)
  407. {
  408. int i;
  409. for (i = 0; i < NCUSTFIELDS ; i++ )
  410. {
  411. EnsureDialogFocus(hDlg, s_aCustFieldID[i], IDC_ADDNEWCOMP);
  412. DisableDlgItem(hDlg, s_aCustFieldID[i]);
  413. }
  414. for (i = 0; i < NCUSTSTATICTEXTFIELDS ; i++ )
  415. DisableDlgItem(hDlg, s_aCustStaticTextFieldID[i]);
  416. }
  417. }
  418. else
  419. {
  420. int i, iComp;
  421. if (hDlg != NULL)
  422. SetCustComponent(hDlg, 0);
  423. for (pComp = g_aCustComponents, iComp = 0; iComp < g_nCustComp ; pComp++, iComp++ )
  424. {
  425. TCHAR szModesParam[80] = TEXT("Cust0Modes");
  426. TCHAR szModes[16] = TEXT("\"");
  427. if (ISNULL(pComp->szSection)) break;
  428. szModesParam[4] = (TCHAR)(iComp + TEXT('0'));
  429. ZeroMemory(pComp->afInstall, sizeof(pComp->afInstall));
  430. GetPrivateProfileString(IS_STRINGS, szModesParam, TEXT(""), szModes, countof(szModes), g_szCustInf);
  431. StrCpy(pComp->szModes, szModes);
  432. if (StrCmpI(szModes, UNUSED) != 0)
  433. {
  434. for (i = 0; i < lstrlen(szModes) ; i++ )
  435. {
  436. int j = szModes[i] - TEXT('0');
  437. pComp->afInstall[j] = TRUE;
  438. }
  439. }
  440. }
  441. }
  442. }
  443. void SaveCustComponents()
  444. {
  445. PCOMPONENT pComp;
  446. int i;
  447. TCHAR szSize[8];
  448. TCHAR szType[8];
  449. TCHAR szModesParam[80] = TEXT("Cust0Modes");
  450. TCHAR szTemp[80];
  451. for (pComp = g_aCustComponents, i = 0; i < g_nCustComp ; pComp++, i++)
  452. {
  453. LPTSTR pSection = pComp->szSection;
  454. wnsprintf(pSection, countof(pComp->szSection), TEXT("CUSTOM%i"), i);
  455. wnsprintf(szTemp, 80, TEXT("\"%s\""), pComp->szSwitches);
  456. StrCpy(pComp->szSwitches, szTemp);
  457. WritePrivateProfileString( pSection, TEXT("Switches1"), pComp->szSwitches, g_szCustCif );
  458. WritePrivateProfileString( pSection, TEXT("DisplayName"), pComp->szDisplayName, g_szCustCif );
  459. pComp->fVisible = TRUE;
  460. if (ISNULL(pComp->szGUID))
  461. {
  462. GUID guid;
  463. if (CoCreateGuid(&guid) == NOERROR)
  464. CoStringFromGUID(guid, pComp->szGUID, countof(pComp->szGUID));
  465. else
  466. wnsprintf(pComp->szGUID, countof(pComp->szGUID), TEXT("CUSTOM%i"),i);
  467. }
  468. WritePrivateProfileString( pSection, TEXT("GUID"), pComp->szGUID, g_szCustCif );
  469. WritePrivateProfileString( pSection, TEXT("UninstallKey"), pComp->szUninstall, g_szCustCif );
  470. WriteActiveSetupURL(pComp, g_szCustCif );
  471. WritePrivateProfileString( pSection, TEXT("Version"), pComp->szVersion, g_szCustCif );
  472. WritePrivateProfileString( pSection, TEXT("Command1"), pComp->szCommand, g_szCustCif );
  473. WritePrivateProfileString( pSection, TEXT("Path"), pComp->szPath, g_szCustCif );
  474. wnsprintf(szSize, countof(szSize), TEXT("%i"), (int) pComp->dwSize);
  475. wnsprintf(szType, countof(szType), TEXT("%i"), pComp->iType);
  476. WritePrivateProfileString( pSection, TEXT("Size"), szSize, g_szCustCif );
  477. WritePrivateProfileString( pSection, TEXT("Type1"), szType, g_szCustCif );
  478. WritePrivateProfileString( pSection, TEXT("Details"), pComp->szDesc, g_szCustCif );
  479. InsWriteInt( pSection, TEXT("PreInstall"), pComp->iInstallType, g_szCustCif );
  480. InsWriteBool( pSection, TEXT("Dependency"), pComp->fIEDependency, g_szCustCif );
  481. szModesParam[4] = (TCHAR)(i + TEXT('0'));
  482. WritePrivateProfileString(IS_STRINGS, szModesParam, pComp->szModes, g_szCustInf);
  483. }
  484. for (; i <= MAXCUST ; i++ )
  485. {
  486. TCHAR szSection[16];
  487. wnsprintf(szSection, countof(szSection), TEXT("CUSTOM%i"), i);
  488. WritePrivateProfileString( szSection, NULL, NULL, g_szCustCif );
  489. szModesParam[4] = (TCHAR)(i + TEXT('0'));
  490. WritePrivateProfileString(IS_STRINGS, szModesParam, NULL, g_szCustInf);
  491. }
  492. WritePrivateProfileString(NULL, NULL, NULL, g_szCustCif);
  493. WritePrivateProfileString(NULL, NULL, NULL, g_szCustInf);
  494. }
  495. // validate version info so that it can either contain a '.' char or numbers 0 - 9.
  496. BOOL IsValidVersion(HWND hDlg, UINT nVersionCtrlID)
  497. {
  498. TCHAR szVersion[MAX_PATH];
  499. int nInvalidCharPos = -1;
  500. int nLen = 0;
  501. int nNumLen = 0;
  502. int nComma = 0;
  503. ZeroMemory(szVersion, sizeof(szVersion));
  504. GetDlgItemText(hDlg, nVersionCtrlID, szVersion, countof(szVersion));
  505. if (*szVersion == TEXT('\0'))
  506. return TRUE;
  507. nLen = StrLen(szVersion);
  508. for(int i = 0; (i < nLen && nInvalidCharPos == -1); i++)
  509. {
  510. if (szVersion[i] != TEXT(',') && !(szVersion[i] >= TEXT('0') && szVersion[i] <= TEXT('9')))
  511. nInvalidCharPos = i;
  512. else if (szVersion[i] == TEXT(','))
  513. {
  514. nComma++;
  515. if (i == 0 || szVersion[i - 1] == TEXT(',') || nComma > 3)
  516. nInvalidCharPos = i;
  517. nNumLen = 0;
  518. }
  519. else
  520. {
  521. nNumLen++;
  522. if (nNumLen > 4)
  523. nInvalidCharPos = i;
  524. }
  525. }
  526. if (nInvalidCharPos == -1 && (nNumLen == 0 || nComma < 3))
  527. nInvalidCharPos = nLen;
  528. if (nInvalidCharPos >= 0)
  529. {
  530. ErrorMessageBox(hDlg, IDS_INVALID_VERSION);
  531. SetFocus(GetDlgItem(hDlg, nVersionCtrlID));
  532. SendMessage(GetDlgItem(hDlg, nVersionCtrlID), EM_SETSEL, (WPARAM)nInvalidCharPos, (LPARAM)nLen);
  533. return FALSE;
  534. }
  535. return TRUE;
  536. }
  537. //
  538. // FUNCTION: CustomComponents(HWND, UINT, UINT, LONG)
  539. //
  540. // PURPOSE: Processes messages for "CustomComponents" page
  541. //
  542. // MESSAGES:
  543. //
  544. // WM_INITDIALOG - intializes the page
  545. // WM_NOTIFY - processes the notifications sent to the page
  546. // WM_COMMAND - saves the id of the choice selected
  547. //
  548. INT_PTR CALLBACK CustomComponents(
  549. HWND hDlg,
  550. UINT message,
  551. WPARAM wParam,
  552. LPARAM lParam)
  553. {
  554. int iComp, iNewSel, i;
  555. HRESULT res;
  556. HWND hComplist;
  557. DWORD dwFlags;
  558. switch (message)
  559. {
  560. case WM_INITDIALOG:
  561. EnableDBCSChars( hDlg, IDE_COMPFILENAME);
  562. EnableDBCSChars( hDlg, IDC_COMPTITLE);
  563. EnableDBCSChars( hDlg, IDE_COMPCOMMAND);
  564. EnableDBCSChars( hDlg, IDE_UNINSTALLKEY);
  565. EnableDBCSChars( hDlg, IDE_COMPPARAM);
  566. EnableDBCSChars( hDlg, IDE_COMPDESC);
  567. DisableDBCSChars(hDlg, IDE_COMPGUID);
  568. DisableDBCSChars(hDlg, IDE_COMPVERSION);
  569. // format for version field is XXXX,XXXX,XXXX,XXXX
  570. Edit_LimitText(GetDlgItem(hDlg, IDE_COMPVERSION), 19);
  571. Edit_LimitText(GetDlgItem(hDlg, IDC_COMPTITLE), countof(g_paComp->szDisplayName)-1);
  572. Edit_LimitText(GetDlgItem(hDlg, IDE_COMPDESC), countof(g_paComp->szDesc)-1);
  573. g_hWizard = hDlg;
  574. break;
  575. case IDM_BATCHADVANCE:
  576. DoBatchAdvance(hDlg);
  577. break;
  578. case WM_HELP:
  579. IeakPageHelp(hDlg, g_psp[g_iCurPage].pszTemplate);
  580. break;
  581. case WM_COMMAND:
  582. switch(HIWORD(wParam))
  583. {
  584. TCHAR szBuf[MAX_PATH];
  585. case BN_CLICKED:
  586. switch (LOWORD(wParam))
  587. {
  588. case IDC_ADDNEWCOMP:
  589. iComp = g_nCustComp;
  590. if (iComp != 0)
  591. {
  592. GetCustComponent(hDlg, s_iSelComp);
  593. if (ISNULL(g_aCustComponents[s_iSelComp].szDisplayName))
  594. {
  595. ErrorMessageBox(hDlg, IDS_NOCUSTCOMPNAME);
  596. return TRUE;
  597. }
  598. dwFlags = FC_NONNULL | FC_FILE | FC_EXISTS;
  599. if (!CheckField(hDlg, IDE_COMPFILENAME, dwFlags)
  600. || !IsValidVersion(hDlg, IDE_COMPVERSION))
  601. return TRUE;
  602. }
  603. else
  604. {
  605. for (i = 0; i < NCUSTFIELDS ; i++ )
  606. {
  607. EnableDlgItem(hDlg, s_aCustFieldID[i]);
  608. }
  609. for (i = 0; i < NCUSTSTATICTEXTFIELDS ; i++ )
  610. EnableDlgItem(hDlg, s_aCustStaticTextFieldID[i]);
  611. }
  612. g_nCustComp++;
  613. s_pSelComp = &g_aCustComponents[iComp];
  614. ZeroMemory(s_pSelComp, sizeof(COMPONENT));
  615. wnsprintf(s_pSelComp->szSection, countof(s_pSelComp->szSection), TEXT("CUSTOM%i"), s_nNewCust);
  616. wnsprintf(s_pSelComp->szDisplayName, countof(s_pSelComp->szDisplayName), TEXT("%s%i"), s_szNewTpl, s_nNewCust++);
  617. StrCpy(s_pSelComp->szModes, g_szAllModes);
  618. s_pSelComp->iList = (int) SendDlgItemMessage( hDlg, IDC_COMPTITLE, CB_ADDSTRING, 0, (LPARAM) s_pSelComp->szDisplayName );
  619. SendDlgItemMessage( hDlg, IDC_COMPTITLE, CB_SETCURSEL, s_pSelComp->iList, 0L);
  620. s_iSelComp = s_pSelComp->iList;
  621. SetCustComponent(hDlg, s_pSelComp->iList);
  622. SendMessage(GetDlgItem( hDlg, IDC_COMPTITLE ), CB_SETEDITSEL,
  623. 0, MAKELPARAM(0, -1));
  624. break;
  625. case IDC_VERIFY:
  626. dwFlags = FC_NONNULL | FC_FILE | FC_EXISTS;
  627. if (!CheckField(hDlg, IDE_COMPFILENAME, dwFlags))
  628. break;
  629. s_pSelComp = &g_aCustComponents[s_iSelComp];
  630. res = CheckTrustExWrap(NULL, s_pSelComp->szPath, hDlg, FALSE, NULL);
  631. switch (res)
  632. {
  633. case NOERROR:
  634. // note that the following means that the idiot hit 'no':
  635. case TRUST_E_SUBJECT_NOT_TRUSTED:
  636. case E_ABORT:
  637. ErrorMessageBox(hDlg, IDS_SIGNEDMSG, MB_OK | MB_SETFOREGROUND | MB_ICONINFORMATION);
  638. break;
  639. case TRUST_E_NOSIGNATURE:
  640. ErrorMessageBox(hDlg, IDS_PLEASESIGNMSG);
  641. break;
  642. case CERT_E_EXPIRED:
  643. ErrorMessageBox(hDlg, IDS_CERTEXPIREDMSG);
  644. break;
  645. case TRUST_E_PROVIDER_UNKNOWN:
  646. case CERT_E_UNTRUSTEDROOT:
  647. ErrorMessageBox(hDlg, IDS_BADPROVIDERMSG);
  648. break;
  649. case CERT_E_MALFORMED:
  650. case CERT_E_ISSUERCHAINING:
  651. case CERT_E_CHAINING:
  652. case CERT_E_CRITICAL:
  653. case CERT_E_PATHLENCONST:
  654. case CERT_E_ROLE:
  655. case DIGSIG_E_DECODE:
  656. case DIGSIG_E_ENCODE:
  657. case DIGSIG_E_CRYPTO:
  658. case DIGSIG_E_EXTENSIBILITY:
  659. default:
  660. ErrorMessageBox(hDlg, IDS_CERTERRORMSG);
  661. break;
  662. }
  663. break;
  664. case IDC_REMOVECOMP:
  665. s_iSelComp = (int) SendDlgItemMessage( hDlg, IDC_COMPTITLE, CB_GETCURSEL, 0, 0L);
  666. SendDlgItemMessage( hDlg, IDC_COMPTITLE, CB_DELETESTRING, s_iSelComp, 0L );
  667. WritePrivateProfileString( g_aCustComponents[s_iSelComp].szSection, NULL, NULL, g_szCustCif );
  668. for (i = s_iSelComp; i < g_nCustComp ; i++ )
  669. {
  670. g_aCustComponents[i] = g_aCustComponents[i + 1];
  671. g_aCustComponents[i].iList--;
  672. }
  673. ZeroMemory(&g_aCustComponents[g_nCustComp--], sizeof(COMPONENT));
  674. if (s_iSelComp >= g_nCustComp) s_iSelComp = g_nCustComp - 1;
  675. SetCustComponent(hDlg, s_iSelComp);
  676. break;
  677. case IDC_BROWSEFILE:
  678. GetDlgItemText(hDlg, IDE_COMPFILENAME, szBuf, countof(szBuf));
  679. if (BrowseForFile(hDlg, szBuf, countof(szBuf), GFN_EXE | GFN_CAB))
  680. SetDlgItemText(hDlg, IDE_COMPFILENAME, szBuf);
  681. break;
  682. case IDC_POSTINSTALL:
  683. case IDC_REBOOTINSTALL:
  684. if (HIWORD(wParam) == BN_CLICKED)
  685. {
  686. EnableDlgItem(hDlg, IDC_INSTALLSUCCESS);
  687. break;
  688. }
  689. return FALSE;
  690. case IDC_PREINSTALL:
  691. if (HIWORD(wParam) == BN_CLICKED)
  692. {
  693. CheckDlgButton(hDlg, IDC_INSTALLSUCCESS, BST_UNCHECKED);
  694. DisableDlgItem(hDlg, IDC_INSTALLSUCCESS);
  695. break;
  696. }
  697. return FALSE;
  698. default:
  699. return FALSE;
  700. }
  701. break;
  702. case CBN_SELENDOK:
  703. hComplist = GetDlgItem(hDlg, IDC_COMPTITLE);
  704. iNewSel = (int) SendMessage( hComplist, CB_GETCURSEL, 0, 0L);
  705. if (iNewSel != s_iSelComp)
  706. {
  707. if (ISNULL(g_aCustComponents[s_iSelComp].szDisplayName))
  708. {
  709. ErrorMessageBox(hDlg, IDS_NOCUSTCOMPNAME);
  710. return TRUE;
  711. }
  712. dwFlags = FC_NONNULL | FC_FILE | FC_EXISTS;
  713. if (!CheckField(hDlg, IDE_COMPFILENAME, dwFlags))
  714. {
  715. return TRUE;
  716. }
  717. if (!IsValidVersion(hDlg, IDE_COMPVERSION))
  718. return TRUE;
  719. }
  720. GetWindowText( hComplist, s_pSelComp->szDisplayName, 80 );
  721. SendMessage( hComplist, CB_DELETESTRING, s_iSelComp, 0L );
  722. SendMessage( hComplist, CB_INSERTSTRING, s_iSelComp,
  723. (LPARAM) s_pSelComp->szDisplayName);
  724. if ((iNewSel != CB_ERR) && (iNewSel != s_iSelComp))
  725. {
  726. GetCustComponent(hDlg, s_iSelComp);
  727. s_iSelComp = iNewSel;
  728. s_pSelComp = &g_aCustComponents[s_iSelComp];
  729. SetCustComponent(hDlg, s_iSelComp);
  730. }
  731. if (iNewSel < 0) iNewSel = 0;
  732. SendMessage( hComplist, CB_SETCURSEL, iNewSel, 0L );
  733. break;
  734. case CBN_EDITCHANGE:
  735. GetWindowText( (HWND) lParam, s_pSelComp->szDisplayName, 80 );
  736. break;
  737. case CBN_CLOSEUP:
  738. case CBN_SELENDCANCEL:
  739. case CBN_DROPDOWN:
  740. case CBN_KILLFOCUS:
  741. if (s_iSelComp >= 0)
  742. {
  743. hComplist = GetDlgItem(hDlg, IDC_COMPTITLE);
  744. GetWindowText( hComplist, s_pSelComp->szDisplayName, countof(s_pSelComp->szDisplayName) );
  745. SendMessage( hComplist, CB_DELETESTRING, s_iSelComp, 0L );
  746. SendMessage( hComplist, CB_INSERTSTRING, s_iSelComp,
  747. (LPARAM) s_pSelComp->szDisplayName);
  748. SendMessage( hComplist, CB_SETCURSEL, s_iSelComp, 0L );
  749. }
  750. break;
  751. case EN_CHANGE:
  752. switch (LOWORD(wParam))
  753. {
  754. case IDE_COMPFILENAME:
  755. if (s_pSelComp) CheckCompType(hDlg, s_pSelComp);
  756. break;
  757. }
  758. break;
  759. }
  760. break;
  761. case WM_NOTIFY:
  762. switch (((NMHDR FAR *) lParam)->code)
  763. {
  764. case PSN_HELP:
  765. IeakPageHelp(hDlg, g_psp[g_iCurPage].pszTemplate);
  766. break;
  767. case PSN_SETACTIVE:
  768. SetBannerText(hDlg);
  769. if (!s_fCustCompInit)
  770. InitCustComponents(hDlg);
  771. else
  772. SetCustComponent(hDlg, s_iSelComp);
  773. PropSheet_SetWizButtons(GetParent(hDlg), PSWIZB_BACK | PSWIZB_NEXT);
  774. CheckBatchAdvance(hDlg);
  775. break;
  776. case PSN_WIZBACK:
  777. case PSN_WIZNEXT:
  778. GetCustComponent(hDlg, s_iSelComp);
  779. if (g_nCustComp > 0)
  780. {
  781. if (ISNULL(g_aCustComponents[s_iSelComp].szDisplayName))
  782. {
  783. ErrorMessageBox(hDlg, IDS_NOCUSTCOMPNAME);
  784. SetWindowLongPtr(hDlg, DWLP_MSGRESULT, -1);
  785. return TRUE;
  786. }
  787. dwFlags = FC_NONNULL | FC_FILE | FC_EXISTS;
  788. if (!CheckField(hDlg, IDE_COMPFILENAME, dwFlags))
  789. {
  790. SetWindowLongPtr(hDlg, DWLP_MSGRESULT, -1);
  791. return TRUE;
  792. }
  793. if (!IsValidVersion(hDlg, IDE_COMPVERSION))
  794. {
  795. SetWindowLongPtr(hDlg, DWLP_MSGRESULT, -1);
  796. return TRUE;
  797. }
  798. }
  799. SaveCustComponents();
  800. g_iCurPage = PPAGE_CUSTCOMP;
  801. EnablePages();
  802. if (((NMHDR FAR *) lParam)->code == PSN_WIZNEXT) PageNext(hDlg);
  803. else
  804. {
  805. PagePrev(hDlg);
  806. }
  807. break;
  808. case PSN_QUERYCANCEL:
  809. QueryCancel(hDlg);
  810. break;
  811. default:
  812. return FALSE;
  813. }
  814. break;
  815. default:
  816. return FALSE;
  817. }
  818. return TRUE;
  819. }
  820. int s_aiIcon[7];
  821. HWND s_hStat,s_hStatus;
  822. extern HWND g_hProgress;
  823. static BOOL s_fComponent = FALSE;
  824. static BOOL s_fNoNet = FALSE;
  825. HWND g_hWait = NULL;
  826. INT_PTR CALLBACK DownloadStatusDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM)
  827. {
  828. RECT dlgRect;
  829. DWORD width, height, left, top;
  830. switch (uMsg)
  831. {
  832. case WM_INITDIALOG:
  833. if (s_fComponent)
  834. {
  835. Animate_Open( GetDlgItem( hDlg, IDC_ANIM ), IDA_DOWNLOAD );
  836. Animate_Play( GetDlgItem( hDlg, IDC_ANIM ), 0, -1, -1 );
  837. InitSysFont(hDlg, IDC_DOWNCOMPNAMD);
  838. InitSysFont(hDlg, IDC_DOWNSTATUS);
  839. g_hProgress = GetDlgItem( hDlg, IDC_PROGRESS );
  840. s_hStatus = GetDlgItem( hDlg, IDC_DOWNSTATUS );
  841. SendMessage(g_hProgress, PBM_SETRANGE, 0, MAKELPARAM(0, 100));
  842. SendMessage(g_hProgress, PBM_SETPOS, 0, 0L);
  843. }
  844. else
  845. {
  846. Animate_Open( GetDlgItem( hDlg, IDC_ANIM ), IDA_GEARS );
  847. Animate_Play( GetDlgItem( hDlg, IDC_ANIM ), 0, -1, -1 );
  848. }
  849. GetWindowRect(hDlg, &dlgRect);
  850. width = dlgRect.right - dlgRect.left;
  851. height = dlgRect.bottom - dlgRect.top;
  852. left = (g_dtRect.right - width)/2;
  853. top = (g_dtRect.bottom - height)/2;
  854. MoveWindow(hDlg, left, top, width, height, TRUE);
  855. break;
  856. case WM_COMMAND:
  857. if ((LOWORD(wParam) == IDCANCEL) && (HIWORD(wParam) == BN_CLICKED)) g_fCancelled = TRUE;
  858. break;
  859. case WM_CLOSE:
  860. g_hProgress = NULL;
  861. s_hStatus = NULL;
  862. EndDialog(hDlg, 0);
  863. break;
  864. default:
  865. return(FALSE);
  866. }
  867. return(TRUE);
  868. }
  869. static HINTERNET s_hInet = NULL;
  870. DWORD g_nTotDown = 0;
  871. HRESULT InetDownloadFile(LPTSTR szTempfile, LPTSTR szUrl, HWND hProgress, int sDownload, LPTSTR szFilename)
  872. {
  873. HRESULT res = NOERROR;
  874. HINTERNET hInetFile = 0;
  875. DWORD dwTotDown = 0;
  876. if (s_hInet == NULL)
  877. s_hInet = InternetOpen(TEXT("Mozilla/4.0 (compatible; MSIE 4.01; Windows NT);IEAKWIZ"),
  878. INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
  879. hInetFile = InternetOpenUrl(s_hInet, szUrl, TEXT("Accept: */*\r\n"), (DWORD)-1,
  880. INTERNET_FLAG_DONT_CACHE, 0);
  881. if (hInetFile != NULL)
  882. {
  883. CHAR szBuf[4096];
  884. DWORD nRead, nWritten;
  885. MSG msg;
  886. DeleteFile(szTempfile);
  887. HANDLE hFile = CreateFile(szTempfile, GENERIC_WRITE, 0, NULL, CREATE_NEW,
  888. FILE_ATTRIBUTE_NORMAL, NULL);
  889. if (hFile != INVALID_HANDLE_VALUE) while (1)
  890. {
  891. if (g_fCancelled)
  892. {
  893. res = -1;
  894. break;
  895. }
  896. while (PeekMessage( &msg, s_hStat, 0, 0, PM_REMOVE ))
  897. {
  898. TranslateMessage(&msg);
  899. DispatchMessage(&msg);
  900. }
  901. if (InternetReadFile(hInetFile, szBuf, sizeof(szBuf), &nRead))
  902. {
  903. if (nRead == 0) break;
  904. WriteFile( hFile, szBuf, nRead, &nWritten, NULL );
  905. dwTotDown += nWritten;
  906. g_nTotDown += nWritten;
  907. if (hProgress != NULL)
  908. {
  909. int iPercent = g_nTotDown / (sDownload * 10);
  910. SendMessage(hProgress, PBM_SETPOS, iPercent, 0L);
  911. SetWindowTextSmart( s_hStatus, szFilename );
  912. }
  913. }
  914. else
  915. {
  916. res = -1;
  917. break;
  918. }
  919. }
  920. //Code Path never called under NT build environment
  921. //causes build error under MSDev: pFilename not defined
  922. /*
  923. #ifdef _DEBUG
  924. if (g_nTotDown)
  925. {
  926. TCHAR szMsg[MAX_PATH];
  927. wnsprintf(szMsg, countof(szMsg), "BRANDME: Wrote %i bytes to %s\r\n", g_nTotDown, pFilename);
  928. OutputDebugString(szMsg);
  929. }
  930. #endif
  931. */
  932. CloseHandle(hFile);
  933. InternetCloseHandle(hInetFile);
  934. }
  935. else res = -1;
  936. if (dwTotDown < 512)
  937. res = -1;
  938. return(res);
  939. }
  940. INT_PTR CALLBACK DupeSynchDlgProc (HWND hDlg, UINT iMsg, WPARAM wParam, LPARAM lParam)
  941. {
  942. int nResult;
  943. switch (iMsg)
  944. {
  945. case WM_INITDIALOG:
  946. SetWindowText(hDlg, (TCHAR *)lParam);
  947. SetTimer(hDlg, 0, 300000, NULL);
  948. return TRUE;
  949. case WM_TIMER:
  950. EndDialog(hDlg, IDIGNORE);
  951. return TRUE;
  952. case WM_COMMAND:
  953. switch (LOWORD (wParam))
  954. {
  955. case IDC_NOTOALL:
  956. nResult = IDIGNORE;
  957. break;
  958. case IDC_YESSYNCH:
  959. nResult = IDYES;
  960. break;
  961. case IDC_NOSYNCH:
  962. default:
  963. nResult = IDNO;
  964. break;
  965. }
  966. EndDialog(hDlg, nResult);
  967. return TRUE;
  968. }
  969. return FALSE;
  970. }
  971. INT_PTR CALLBACK ErrDlgProc (HWND hDlg, UINT iMsg, WPARAM wParam, LPARAM lParam)
  972. {
  973. int nResult;
  974. switch (iMsg)
  975. {
  976. case WM_INITDIALOG:
  977. if (GetDlgItem(hDlg, IDC_BADCOMP))
  978. SetDlgItemText(hDlg, IDC_BADCOMP, (TCHAR *)lParam);
  979. else
  980. {
  981. if (GetDlgItem(hDlg, IDC_BADCOMPSEC))
  982. SetDlgItemText(hDlg, IDC_BADCOMPSEC, (TCHAR *)lParam);
  983. }
  984. SetTimer(hDlg, 0, 300000, NULL);
  985. return TRUE;
  986. case WM_TIMER:
  987. EndDialog(hDlg, IDIGNORE);
  988. return TRUE;
  989. case WM_COMMAND:
  990. switch (LOWORD (wParam))
  991. {
  992. case IDC_ERRDLABORT:
  993. nResult = IDABORT;
  994. break;
  995. case IDC_ERRDLRETRY:
  996. case IDC_SECERRYES:
  997. nResult = IDRETRY;
  998. break;
  999. case IDC_SECERRNO:
  1000. case IDC_ERRDLIGNORE:
  1001. default:
  1002. nResult = IDIGNORE;
  1003. break;
  1004. }
  1005. EndDialog(hDlg, nResult);
  1006. return TRUE;
  1007. }
  1008. return FALSE;
  1009. }
  1010. int DownloadErrMsg(HWND hWnd, LPTSTR szFilename, LPCTSTR lpTemplateName)
  1011. {
  1012. return (int) DialogBoxParam(g_rvInfo.hInst, lpTemplateName, hWnd, ErrDlgProc, LPARAM(szFilename));
  1013. }
  1014. HRESULT DownloadCab(HWND hDlg, LPTSTR szUrl, LPTSTR szFilename, LPCTSTR pcszDisplayname, int sComponent, BOOL &fIgnore)
  1015. {
  1016. HRESULT res = NOERROR;
  1017. TCHAR szTempfile[MAX_PATH];
  1018. LPTSTR pBack, pDot, pFile, pSlash;
  1019. int i, iMsgRes;
  1020. StrCpy( szTempfile, szFilename );
  1021. pBack = StrRChr(szTempfile, NULL, TEXT('\\'));
  1022. pDot = StrRChr(szUrl, NULL, TEXT('.'));
  1023. pSlash = StrRChr(szUrl, NULL, TEXT('/'));
  1024. StrCpy(pBack, TEXT("\\TEMPFILE"));
  1025. if (pDot > pSlash)
  1026. StrCat(szTempfile, pDot);
  1027. DeleteFile( szTempfile );
  1028. if (pcszDisplayname)
  1029. {
  1030. s_fComponent = TRUE;
  1031. SetDlgItemText( s_hStat, IDC_DOWNCOMPNAMD, pcszDisplayname );
  1032. }
  1033. pFile = StrRChr(szUrl, NULL, TEXT('/'));
  1034. if (pFile)
  1035. pFile++;
  1036. else
  1037. pFile = szUrl;
  1038. for (i=0; i < 3; i++)
  1039. {
  1040. res = InetDownloadFile(szTempfile, szUrl, g_hProgress, sComponent, szFilename);
  1041. if ((res == NOERROR)||(g_fCancelled))
  1042. {
  1043. break;
  1044. }
  1045. }
  1046. if ((res != NOERROR)&&(!g_fCancelled))
  1047. {
  1048. while( (iMsgRes = DownloadErrMsg(hDlg, pFile, MAKEINTRESOURCE(IDD_DOWNLOADERR))) == IDRETRY)
  1049. {
  1050. res = InetDownloadFile(szTempfile, szUrl, g_hProgress, sComponent, szFilename);
  1051. if (res == NOERROR)
  1052. {
  1053. break;
  1054. }
  1055. }
  1056. if (res != NOERROR)
  1057. {
  1058. if (iMsgRes == IDABORT)
  1059. return res;
  1060. else
  1061. {
  1062. res = NOERROR;
  1063. fIgnore = TRUE;
  1064. StrCat(g_szFailedComps, pFile);
  1065. StrCat(g_szFailedComps, TEXT("\r\n"));
  1066. g_fFailedComp = TRUE;
  1067. }
  1068. }
  1069. }
  1070. if ((!fIgnore)&&(!g_fCancelled))
  1071. {
  1072. DeleteFile(szFilename);
  1073. res = CheckTrustExWrap(szUrl, szTempfile, hDlg, FALSE, NULL);
  1074. if (res != NOERROR)
  1075. {
  1076. iMsgRes = DownloadErrMsg(hDlg, pFile, MAKEINTRESOURCE(IDD_DOWNLOADSEC));
  1077. if (iMsgRes == IDRETRY)
  1078. res = NOERROR;
  1079. else
  1080. {
  1081. StrCat(g_szFailedComps, pFile);
  1082. StrCat(g_szFailedComps, TEXT("\r\n"));
  1083. g_fFailedComp = TRUE;
  1084. res = DONT_SHOW_UPDATES;
  1085. }
  1086. }
  1087. if (res == NOERROR)
  1088. {
  1089. if (!MoveFile( szTempfile, szFilename ))
  1090. {
  1091. res = 0xffffffff;
  1092. }
  1093. }
  1094. }
  1095. DeleteFile(szTempfile);
  1096. return(res);
  1097. }
  1098. void NeedToSetMSTrustKey()
  1099. {
  1100. static BOOL s_fFirst = TRUE;
  1101. HKEY hKey;
  1102. DWORD dwTmp;
  1103. if (!s_fFirst)
  1104. return;
  1105. s_fFirst = FALSE;
  1106. // Check MS Vendor trust key and set
  1107. if (RegOpenKeyEx(HKEY_CURRENT_USER, RK_TRUSTKEY, 0, KEY_READ, &hKey) == ERROR_SUCCESS)
  1108. {
  1109. for (int i=0; i < countof(s_tkTrustArray); i++)
  1110. {
  1111. if (RegQueryValueEx( hKey, s_tkTrustArray[i].szTrustString, 0, NULL, NULL, &dwTmp ) == ERROR_SUCCESS)
  1112. s_tkTrustArray[i].fSet = FALSE;
  1113. }
  1114. RegCloseKey(hKey);
  1115. }
  1116. }
  1117. void WriteMSTrustKey(BOOL bSet)
  1118. {
  1119. HKEY hKey;
  1120. if (RegCreateKeyEx(HKEY_CURRENT_USER, RK_TRUSTKEY, 0, NULL, REG_OPTION_NON_VOLATILE,
  1121. KEY_WRITE, NULL, &hKey, NULL) == ERROR_SUCCESS)
  1122. {
  1123. if (bSet)
  1124. {
  1125. for (int i=0; i < countof(s_tkTrustArray); i++)
  1126. {
  1127. if (s_tkTrustArray[i].fSet)
  1128. RegSetValueEx( hKey, s_tkTrustArray[i].szTrustString, 0, REG_SZ,
  1129. (LPBYTE)s_tkTrustArray[i].szCompanyName, sizeof(s_tkTrustArray[i].szCompanyName) );
  1130. }
  1131. }
  1132. else
  1133. {
  1134. for (int i=0; i < countof(s_tkTrustArray); i++)
  1135. {
  1136. if (s_tkTrustArray[i].fSet)
  1137. RegDeleteValue( hKey, s_tkTrustArray[i].szTrustString );
  1138. }
  1139. }
  1140. RegCloseKey(hKey);
  1141. }
  1142. }
  1143. void AnyCompSelected(HWND hDlg, BOOL &fSel, BOOL &fSizeChange) //---- Blue and Brown components change size, and
  1144. { // need to know to grey out synchronize button
  1145. HWND hCompList = GetDlgItem(hDlg, IDC_COMPLIST);
  1146. fSel = FALSE;
  1147. fSizeChange = FALSE;
  1148. PCOMPONENT pComp;
  1149. for (pComp = g_paComp; ; pComp++ )
  1150. {
  1151. if (!pComp || (!(*pComp->szSection))) break;
  1152. if (ListView_GetItemState(hCompList, pComp->iList, LVIS_SELECTED) & LVIS_SELECTED)
  1153. if ((BLUE2 == pComp->iImage) || (BROWN2 == pComp->iImage))
  1154. fSizeChange = TRUE;
  1155. else
  1156. fSel = TRUE;
  1157. }
  1158. }
  1159. BOOL AnyCompSelected(HWND hDlg)
  1160. {
  1161. HWND hCompList = GetDlgItem(hDlg, IDC_COMPLIST);
  1162. PCOMPONENT pComp;
  1163. for (pComp = g_paComp; ; pComp++ )
  1164. {
  1165. if (!pComp || (!(*pComp->szSection))) break;
  1166. if ((BLUE2 != pComp->iImage) && (BROWN2 != pComp->iImage))
  1167. if (ListView_GetItemState(hCompList, pComp->iList, LVIS_SELECTED) & LVIS_SELECTED)
  1168. return TRUE;
  1169. }
  1170. return FALSE;
  1171. }
  1172. void WriteModesToCif(CCifRWComponent_t * pCifRWComponent_t, LPCTSTR pcszModes)
  1173. {
  1174. int i;
  1175. TCHAR szCommaModes[32];
  1176. if (pcszModes == NULL || ISNULL(pcszModes))
  1177. szCommaModes[0] = TEXT('\0');
  1178. else
  1179. {
  1180. for (i = 0; pcszModes[i]; i++)
  1181. {
  1182. szCommaModes[i*2] = pcszModes[i];
  1183. szCommaModes[(i*2)+1] = TEXT(',');
  1184. }
  1185. szCommaModes[(i*2)-1] = TEXT('\0');
  1186. }
  1187. pCifRWComponent_t->SetModes(szCommaModes);
  1188. }
  1189. void writeToCifFile(PCOMPONENT pComp, LPTSTR szCifNew)
  1190. {
  1191. ICifRWComponent* pCifRWComponent;
  1192. CCifRWComponent_t* pCifRWComponent_t;
  1193. LPTSTR pszSection;
  1194. DWORD dwVer, dwBuild;
  1195. g_lpCifRWFile->CreateComponent(pComp->szSection, &pCifRWComponent);
  1196. pCifRWComponent_t = new CCifRWComponent_t(pCifRWComponent);
  1197. pCifRWComponent_t->CopyComponent(szCifNew);
  1198. WriteModesToCif(pCifRWComponent_t, pComp->szModes);
  1199. delete pCifRWComponent_t;
  1200. g_lpCifRWFileVer->CreateComponent(pComp->szSection, &pCifRWComponent);
  1201. pCifRWComponent_t = new CCifRWComponent_t(pCifRWComponent);
  1202. pCifRWComponent_t->CopyComponent(szCifNew);
  1203. pCifRWComponent_t->GetVersion(&dwVer, &dwBuild);
  1204. delete pCifRWComponent_t;
  1205. ConvertDwordsToVersionStr(pComp->szVersion, dwVer, dwBuild);
  1206. pszSection = pComp->pszAVSDupeSections;
  1207. while (pszSection != NULL)
  1208. {
  1209. if ((pComp = FindComp(pszSection, FALSE)) != NULL)
  1210. {
  1211. g_lpCifRWFile->CreateComponent(pComp->szSection, &pCifRWComponent);
  1212. pCifRWComponent_t = new CCifRWComponent_t(pCifRWComponent);
  1213. pCifRWComponent_t->CopyComponent(szCifNew);
  1214. WriteModesToCif(pCifRWComponent_t, pComp->szModes);
  1215. delete pCifRWComponent_t;
  1216. g_lpCifRWFileVer->CreateComponent(pComp->szSection, &pCifRWComponent);
  1217. pCifRWComponent_t = new CCifRWComponent_t(pCifRWComponent);
  1218. pCifRWComponent_t->CopyComponent(szCifNew);
  1219. pCifRWComponent_t->GetVersion(&dwVer, &dwBuild);
  1220. delete pCifRWComponent_t;
  1221. ConvertDwordsToVersionStr(pComp->szVersion, dwVer, dwBuild);
  1222. }
  1223. pszSection = StrChr(pszSection, TEXT(','));
  1224. if (pszSection != NULL)
  1225. pszSection++;
  1226. }
  1227. }
  1228. void updateCifVersions32(PCOMPONENT pComp, BOOL fIgnore, BOOL fUpdate)
  1229. {
  1230. TCHAR szCifPath[MAX_PATH];
  1231. if ((!fUpdate) && (BLUE2 != pComp->iImage) && (BROWN2 != pComp->iImage))
  1232. if (fIgnore)
  1233. pComp->iImage = YELLOW;
  1234. else
  1235. pComp->iImage = GREEN;
  1236. //---- use other ieupdate.cif for updates
  1237. if ((fUpdate) || (BLUE2 == pComp->iImage) || (BROWN2 == pComp->iImage)) {
  1238. PathCombine(szCifPath, g_szIEAKProg, TEXT("update\\ieupdate.cif"));
  1239. writeToCifFile(pComp, szCifPath);
  1240. }
  1241. else
  1242. writeToCifFile(pComp, s_szCifNew);
  1243. }
  1244. static s_fNoToAllSynch;
  1245. void DownloadComponent32(HWND hDlg, PCOMPONENT pComp, HWND hCompList, BOOL &g_fCancelled,
  1246. BOOL &fOk, BOOL &fDownloaded, BOOL &fIgnore, BOOL fAll)
  1247. {
  1248. TCHAR szUrl[INTERNET_MAX_URL_LENGTH];
  1249. TCHAR szCompUrl[INTERNET_MAX_URL_LENGTH];
  1250. TCHAR szLocalPath[MAX_PATH];
  1251. TCHAR szUpdateCif[MAX_PATH];
  1252. LPTSTR pCab;
  1253. LV_ITEM lvItem;
  1254. CCifFile_t* pCifFile = NULL;
  1255. ICifComponent * pCifComponent = NULL;
  1256. CCifComponent_t * pCifComponent_t;
  1257. UINT uiIndex = 0;
  1258. DWORD dwFlags;
  1259. TCHAR tchType = '\0';
  1260. int iRet = IDYES;
  1261. UNREFERENCED_PARAMETER(tchType);
  1262. if ((BLUE2 == pComp->iImage) || (BROWN2 == pComp->iImage)) {
  1263. StrCpy(szUpdateCif, g_szIEAKProg);
  1264. PathAppend(szUpdateCif, TEXT("\\update\\ieupdate.cif"));
  1265. if (!PathFileExists(szUpdateCif))
  1266. return;
  1267. GetICifFileFromFile_t(&pCifFile, szUpdateCif);
  1268. if (g_fCancelled || (FAILED(pCifFile->FindComponent(pComp->szSection, &pCifComponent))))
  1269. return;
  1270. }
  1271. else
  1272. if (g_fCancelled || (FAILED(g_lpCifFileNew->FindComponent(pComp->szSection, &pCifComponent))))
  1273. return;
  1274. pCifComponent_t = new CCifComponent_t((ICifRWComponent *)pCifComponent);
  1275. // pComp->fIEDependency is used as a guard against circular dependencies here
  1276. if (!pComp->fIEDependency && !pComp->fAVSDupe)
  1277. {
  1278. pComp->fIEDependency = TRUE;
  1279. //--- now BLUE2 and BROWN2 also mean that the component has already been downloaded
  1280. if (((pComp->iImage != GREEN) && (pComp->iImage != BLUE2) && (pComp->iImage != BROWN2)) ||
  1281. (!fAll && !s_fNoToAllSynch && (( iRet = (int) DialogBoxParam(g_rvInfo.hInst, MAKEINTRESOURCE(IDD_DUPESYNCH),
  1282. s_hStat, DupeSynchDlgProc, (LPARAM)pComp->szDisplayName)) == IDYES)))
  1283. {
  1284. while (SUCCEEDED(pCifComponent_t->GetUrl(uiIndex, szUrl, countof(szUrl), &dwFlags)))
  1285. {
  1286. if (dwFlags & URLF_RELATIVEURL)
  1287. {
  1288. StrCpy(szCompUrl, g_szBaseURL);
  1289. StrCat(szCompUrl, TEXT("/"));
  1290. StrCat(szCompUrl, szUrl);
  1291. pCab = szUrl;
  1292. }
  1293. else
  1294. {
  1295. StrCpy(szCompUrl, szUrl);
  1296. pCab = StrRChr(szUrl, NULL, TEXT('/'));
  1297. if (pCab)
  1298. pCab++;
  1299. else
  1300. pCab = szUrl;
  1301. }
  1302. PathCombine(szLocalPath, g_szIEAKProg, pCab);
  1303. if (pComp->dwSize)
  1304. {
  1305. if(StrCmpI(pCab, TEXT("oem.cab"))) //special case out the OEMInstall cab
  1306. {
  1307. if (DownloadCab(s_hStat, szCompUrl, szLocalPath, pComp->szDisplayName, pComp->dwSize, fIgnore)
  1308. != NOERROR)
  1309. {
  1310. fOk = FALSE;
  1311. g_fCancelled = TRUE;
  1312. }
  1313. else
  1314. if ((BLUE2 == pComp->iImage) || (BROWN2 == pComp->iImage)) {
  1315. pComp->iImage = GREEN;
  1316. updateCifVersions32(pComp, fIgnore);
  1317. }
  1318. fDownloaded = TRUE;
  1319. }
  1320. }
  1321. if (g_fCancelled) break;
  1322. uiIndex++;
  1323. }
  1324. }
  1325. else //we are not downloading this cab because it's already downloaded
  1326. {
  1327. //process window messages, so we pick up messages like cancel for download status popup
  1328. MSG msg;
  1329. while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
  1330. {
  1331. TranslateMessage(&msg);
  1332. DispatchMessage(&msg);
  1333. }
  1334. }
  1335. if (iRet == IDIGNORE)
  1336. s_fNoToAllSynch = TRUE;
  1337. if (!g_fCancelled)
  1338. {
  1339. if (fIgnore)
  1340. pComp->iImage = YELLOW;
  1341. else
  1342. if ((BLUE2 != pComp->iImage) && (BROWN2 != pComp->iImage))
  1343. pComp->iImage = GREEN;
  1344. uiIndex = 0;
  1345. while (SUCCEEDED(pCifComponent_t->GetDependency(uiIndex, szLocalPath, countof(szLocalPath), &tchType, NULL, NULL)))
  1346. {
  1347. PCOMPONENT pDepComp;
  1348. pDepComp = FindComp(szLocalPath, FALSE);
  1349. if (pDepComp && (pDepComp->iCompType == COMP_OPTIONAL))
  1350. {
  1351. DownloadComponent32(hDlg, pDepComp, hCompList, g_fCancelled, fOk, fDownloaded, fIgnore, fAll);
  1352. if (g_fCancelled)
  1353. break;
  1354. }
  1355. uiIndex++;
  1356. }
  1357. }
  1358. if (g_fCancelled)
  1359. {
  1360. pComp->iImage = RED;
  1361. if ((pComp->iCompType == COMP_OPTIONAL) && (pComp->iPlatform <= PLAT_W98)
  1362. && pComp->fVisible)
  1363. {
  1364. ZeroMemory(&lvItem, sizeof(lvItem));
  1365. lvItem.mask = LVIF_IMAGE;
  1366. lvItem.iItem = pComp->iList;
  1367. ListView_GetItem(hCompList, &lvItem);
  1368. lvItem.iImage = RED;
  1369. lvItem.mask = LVIF_IMAGE;
  1370. lvItem.iItem = pComp->iList;
  1371. ListView_SetItem(hCompList, &lvItem);
  1372. ListView_SetItemText(hCompList, pComp->iList, 1, TEXT(""));
  1373. }
  1374. if (SUCCEEDED(pCifComponent_t->GetUrl(0, szUrl, countof(szUrl), &dwFlags)))
  1375. {
  1376. if (dwFlags & URLF_RELATIVEURL)
  1377. {
  1378. pCab = szUrl;
  1379. }
  1380. else
  1381. {
  1382. pCab = StrRChr(szUrl, NULL, TEXT('/'));
  1383. if (pCab)
  1384. pCab++;
  1385. else
  1386. pCab = szUrl;
  1387. }
  1388. PathCombine(szLocalPath, g_szIEAKProg, pCab);
  1389. DeleteFile(szLocalPath);
  1390. }
  1391. return;
  1392. }
  1393. updateCifVersions32(pComp, fIgnore);
  1394. if (pComp->fVisible && ((pComp->iCompType != COMP_OPTIONAL) || (pComp->iPlatform <= PLAT_W98)))
  1395. {
  1396. ZeroMemory(&lvItem, sizeof(lvItem));
  1397. lvItem.mask = LVIF_IMAGE;
  1398. lvItem.iItem = pComp->iList;
  1399. ListView_GetItem(hCompList, &lvItem);
  1400. if ((BLUE2 == pComp->iImage) || (BROWN2 == pComp->iImage))
  1401. lvItem.iImage = pComp->iImage;
  1402. else
  1403. if (fIgnore)
  1404. lvItem.iImage = YELLOW;
  1405. else
  1406. lvItem.iImage = GREEN;
  1407. lvItem.mask = LVIF_IMAGE;
  1408. lvItem.iItem = pComp->iList;
  1409. ListView_SetItem(hCompList, &lvItem);
  1410. ListView_SetItemText(hCompList, pComp->iList, 1, pComp->szVersion);
  1411. }
  1412. }
  1413. delete pCifComponent_t;
  1414. }
  1415. void DownloadComponent(HWND hDlg, PCOMPONENT pComp, HWND hCompList, BOOL &g_fCancelled,
  1416. BOOL &fOk, BOOL &fDownloaded, BOOL &fIgnore, BOOL fAll)
  1417. {
  1418. PCOMPONENT pCompTemp;
  1419. for (pCompTemp = g_paComp; *pCompTemp->szSection; pCompTemp++)
  1420. pCompTemp->fIEDependency = FALSE;
  1421. DownloadComponent32(hDlg, pComp, hCompList, g_fCancelled, fOk, fDownloaded, fIgnore, fAll);
  1422. }
  1423. BOOL IsCheyenneSoftwareRunning(HWND hDlg)
  1424. {
  1425. if (FindWindow(NULL, TEXT("Inoculan Realtime Manager")) ||
  1426. FindWindow(NULL, TEXT("Cheyenne ANtiVirus Realtime Monitor")))
  1427. {
  1428. TCHAR szMsgBoxText[MAX_PATH];
  1429. LoadString( g_rvInfo.hInst, IDS_VIRUSPROGRAMRUNNING, szMsgBoxText, countof(szMsgBoxText) );
  1430. MessageBox(hDlg, szMsgBoxText, g_szTitle, MB_OK);
  1431. return TRUE;
  1432. }
  1433. return FALSE;
  1434. }
  1435. void ProcessDownload(HWND hDlg, BOOL fAll)
  1436. {
  1437. HWND hCompList = GetDlgItem(hDlg, IDC_COMPLIST);
  1438. TCHAR szWrk[MAX_PATH];
  1439. PCOMPONENT pComp;
  1440. BOOL fDownloaded;
  1441. BOOL fIgnore = FALSE;
  1442. if (IsCheyenneSoftwareRunning(hDlg))
  1443. return;
  1444. g_fCancelled = FALSE;
  1445. s_fComponent = TRUE;
  1446. PropSheet_SetWizButtons(GetParent(hDlg), PSWIZB_BACK);
  1447. s_hStat = CreateDialog( g_rvInfo.hInst, MAKEINTRESOURCE(IDD_DOWNLOAD), NULL,
  1448. DownloadStatusDlgProc );
  1449. ShowWindow( s_hStat, SW_SHOWNORMAL );
  1450. g_fFailedComp = FALSE;
  1451. LoadString( g_rvInfo.hInst, IDS_DOWNLOADLIST_ERROR, g_szFailedCompsMsg, countof(g_szFailedCompsMsg) );
  1452. for (pComp = g_paComp; ; pComp++ )
  1453. if ((BROWN2 != pComp->iImage) && (BLUE2 != pComp->iImage))
  1454. {
  1455. LV_ITEM lvItem;
  1456. BOOL fOk = TRUE;
  1457. DWORD dwDestFree;
  1458. PCOMPONENT pSearchComp;
  1459. fDownloaded = FALSE;
  1460. ZeroMemory(&lvItem,sizeof(lvItem));
  1461. if (ISNULL(pComp->szSection)) break;
  1462. lvItem.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_STATE;
  1463. lvItem.stateMask = LVIS_SELECTED;
  1464. lvItem.iItem = pComp->iList;
  1465. ListView_GetItem(hCompList, &lvItem);
  1466. if (!fAll)
  1467. {
  1468. if ((pComp->iList == 0) && (pComp->iCompType == COMP_OPTIONAL)) continue;
  1469. if ((lvItem.state & LVIS_SELECTED) == 0) continue;
  1470. }
  1471. // BUGBUG fix once we do Alpha version
  1472. if (pComp->iPlatform == PLAT_ALPHA) continue;
  1473. SetDlgItemText( s_hStat, IDC_DOWNCOMPNAMD, pComp->szDisplayName );
  1474. g_nTotDown = 0;
  1475. StrCpy(szWrk, g_szIEAKProg);
  1476. dwDestFree = GetRootFree(szWrk);
  1477. if (dwDestFree < pComp->dwSize)
  1478. {
  1479. TCHAR szTitle[MAX_PATH];
  1480. TCHAR szTemplate[MAX_PATH];
  1481. TCHAR szMsg[MAX_PATH];
  1482. LoadString( g_rvInfo.hInst, IDS_DISKERROR, szTitle, MAX_PATH );
  1483. LoadString( g_rvInfo.hInst, IDS_TEMPDISKMSG, szTemplate, MAX_PATH );
  1484. wnsprintf(szMsg, countof(szMsg), szTemplate, dwDestFree, (pComp->dwSize));
  1485. MessageBox(NULL, szMsg, szTitle, MB_OK | MB_SETFOREGROUND);
  1486. DestroyWindow(s_hStat);
  1487. return;
  1488. }
  1489. fIgnore = FALSE;
  1490. DownloadComponent(hDlg, pComp, hCompList, g_fCancelled, fOk, fDownloaded, fIgnore, fAll);
  1491. /*
  1492. if (*(pComp->piPatchInfo.szSection)) // download patch files
  1493. {
  1494. DownloadComponent(pComp->piPatchInfo.szSection, pComp->szDisplayName, pComp->piPatchInfo.dwSize, g_fCancelled, fOk, fDownloaded, fIgnore, fAll);
  1495. if (fOk)
  1496. {
  1497. TCHAR szSectBuf[1024];
  1498. GetPrivateProfileSection( pComp->piPatchInfo.szSection, szSectBuf, countof(szSectBuf), s_szCifNew );
  1499. WritePrivateProfileSection( pComp->piPatchInfo.szSection, szSectBuf, g_szCif );
  1500. }
  1501. }
  1502. */
  1503. if (!fAll && fDownloaded && !g_fCancelled && (pComp->iCompType == COMP_OPTIONAL))
  1504. {
  1505. // search to download comp on other platforms
  1506. for (pSearchComp = g_paComp; ; pSearchComp++)
  1507. {
  1508. if (ISNULL(pSearchComp->szSection)) break;
  1509. if ((StrCmpI(pSearchComp->szDisplayName, pComp->szDisplayName) == 0)
  1510. && (pSearchComp != pComp))
  1511. {
  1512. SetDlgItemText( s_hStat, IDC_DOWNCOMPNAMD, pSearchComp->szDisplayName );
  1513. g_nTotDown = 0;
  1514. StrCpy(szWrk, g_szIEAKProg);
  1515. dwDestFree = GetRootFree(szWrk);
  1516. if (dwDestFree < pSearchComp->dwSize)
  1517. {
  1518. TCHAR szTitle[MAX_PATH];
  1519. TCHAR szTemplate[MAX_PATH];
  1520. TCHAR szMsg[MAX_PATH];
  1521. LoadString( g_rvInfo.hInst, IDS_DISKERROR, szTitle, MAX_PATH );
  1522. LoadString( g_rvInfo.hInst, IDS_TEMPDISKMSG, szTemplate, MAX_PATH );
  1523. wnsprintf(szMsg, countof(szMsg), szTemplate, dwDestFree, (pSearchComp->dwSize));
  1524. MessageBox(NULL, szMsg, szTitle, MB_OK | MB_SETFOREGROUND);
  1525. DestroyWindow(s_hStat);
  1526. return;
  1527. }
  1528. DownloadComponent(hDlg, pSearchComp, hCompList, g_fCancelled, fOk, fDownloaded, fIgnore, fAll);
  1529. if (g_fCancelled) break;
  1530. /* if (*(pSearchComp->piPatchInfo.szSection)) // download patch files
  1531. {
  1532. DownloadComponent(pSearchComp->piPatchInfo.szSection, pSearchComp->szDisplayName,
  1533. pSearchComp->piPatchInfo.dwSize, g_fCancelled, fOk, fDownloaded, fIgnore);
  1534. if (fOk)
  1535. {
  1536. TCHAR szSectBuf[1024];
  1537. GetPrivateProfileSection( pSearchComp->piPatchInfo.szSection, szSectBuf, countof(szSectBuf), s_szCifNew );
  1538. WritePrivateProfileSection( pSearchComp->piPatchInfo.szSection, szSectBuf, g_szCif );
  1539. }
  1540. }*/
  1541. if (g_fCancelled) break;
  1542. if (fOk)
  1543. updateCifVersions32(pSearchComp, fIgnore);
  1544. }
  1545. }
  1546. }
  1547. if (fOk && !g_fCancelled)
  1548. {
  1549. PCOMPONENT pListComp = pComp;
  1550. if (pComp->iCompType != COMP_OPTIONAL)
  1551. {
  1552. s_fNoCore = FALSE;
  1553. pListComp = FindComp(NULL, TRUE);
  1554. }
  1555. if (fIgnore)
  1556. lvItem.iImage = pComp->iImage = YELLOW;
  1557. else
  1558. if ((BLUE2 == pComp->iImage) || (BROWN2 == pComp->iImage))
  1559. lvItem.iImage = pComp->iImage;
  1560. else
  1561. lvItem.iImage = pComp->iImage = GREEN;
  1562. lvItem.mask = LVIF_IMAGE;
  1563. lvItem.iItem = pListComp->iList;
  1564. ListView_SetItem(hCompList, &lvItem);
  1565. updateCifVersions32(pComp, fIgnore);
  1566. // Do not try to set the version field for NT optional components or invisible
  1567. // components for win32 since their iList fields will be zeroed
  1568. if (((pComp->fVisible || (StrCmpI(pComp->szSection, BASEWIN32) == 0)) &&
  1569. ((pComp->iCompType != COMP_OPTIONAL) || (pComp->iPlatform <= PLAT_W98))))
  1570. ListView_SetItemText(hCompList, pListComp->iList, 1, pListComp->szVersion);
  1571. }
  1572. else
  1573. {
  1574. TCHAR szUrl[MAX_PATH];
  1575. LPTSTR pUrl = szUrl;
  1576. TCHAR szLocalPath[MAX_PATH];
  1577. ICifComponent * pCifComponent;
  1578. CCifComponent_t * pCifComponent_t;
  1579. HRESULT hr;
  1580. DWORD dwFlags;
  1581. if (pComp->iCompType != COMP_OPTIONAL)
  1582. {
  1583. s_fNoCore = TRUE;
  1584. pComp = FindComp(NULL, TRUE);
  1585. }
  1586. if ((pComp->iImage != BROWN2) && (pComp->iImage != BLUE2)) {
  1587. lvItem.iImage = pComp->iImage = RED;
  1588. lvItem.mask = LVIF_IMAGE;
  1589. lvItem.iItem = pComp->iList;
  1590. ListView_SetItem(hCompList, &lvItem);
  1591. ListView_SetItemText(hCompList, pComp->iList, 1, TEXT(""));
  1592. }
  1593. if (!(SUCCEEDED(g_lpCifFileNew->FindComponent(pComp->szSection, &pCifComponent))))
  1594. break;
  1595. pCifComponent_t = new CCifComponent_t((ICifRWComponent *)pCifComponent);
  1596. hr = pCifComponent_t->GetUrl(0, szUrl, countof(szUrl), &dwFlags);
  1597. delete pCifComponent_t;
  1598. if (!(SUCCEEDED(hr)))
  1599. break;
  1600. if (!(dwFlags & URLF_RELATIVEURL))
  1601. {
  1602. pUrl = StrRChr(szUrl, NULL, TEXT('/'));
  1603. if (pUrl)
  1604. pUrl++;
  1605. else
  1606. pUrl = szUrl;
  1607. }
  1608. PathCombine(szLocalPath, g_szIEAKProg, pUrl);
  1609. DeleteFile(szLocalPath);
  1610. break;
  1611. }
  1612. }
  1613. DestroyWindow(s_hStat);
  1614. }
  1615. void SetCompRevDependList(PCOMPONENT pComp, CCifComponent_t * pCifComponent_t)
  1616. {
  1617. UINT uiIndex = 0;
  1618. PCOMPONENT pCompTemp;
  1619. ICifComponent * pCifCompNew;
  1620. TCHAR szID[128];
  1621. TCHAR tchType;
  1622. while (SUCCEEDED(pCifComponent_t->GetDependency(uiIndex, szID, countof(szID), &tchType, NULL, NULL)))
  1623. {
  1624. if ((pComp->iCompType != COMP_OPTIONAL) ||
  1625. (StrCmpNI(szID, TEXT("BASEIE40"), 8) == 0))
  1626. {
  1627. uiIndex++;
  1628. continue;
  1629. }
  1630. pCompTemp = FindComp(szID, FALSE);
  1631. if (pCompTemp)
  1632. {
  1633. int i;
  1634. BOOL fSet = FALSE;
  1635. if (pCompTemp->fIEDependency)
  1636. {
  1637. uiIndex++;
  1638. continue;
  1639. }
  1640. pCompTemp->fIEDependency = TRUE;
  1641. for (i=0; (i < 10) && pCompTemp->paCompRevDeps[i]; i++)
  1642. {
  1643. if (pCompTemp->paCompRevDeps[i] == pComp)
  1644. fSet = TRUE;
  1645. }
  1646. if (!fSet && i < 10)
  1647. pCompTemp->paCompRevDeps[i] = pComp;
  1648. }
  1649. if (SUCCEEDED(g_lpCifFileNew->FindComponent(szID, &pCifCompNew)))
  1650. {
  1651. CCifComponent_t * pCifCompNew_t =
  1652. new CCifComponent_t((ICifRWComponent *)pCifCompNew);
  1653. SetCompRevDependList(pComp, pCifCompNew_t);
  1654. delete pCifCompNew_t;
  1655. }
  1656. uiIndex++;
  1657. }
  1658. }
  1659. void BuildReverseDependencyList(IEnumCifComponents * pEnumCifComponents)
  1660. {
  1661. PCOMPONENT pComp;
  1662. ICifComponent * pCifComponent;
  1663. TCHAR szID[128];
  1664. while (pEnumCifComponents->Next(&pCifComponent) == S_OK)
  1665. {
  1666. CCifComponent_t * pCifComponent_t =
  1667. new CCifComponent_t((ICifRWComponent *)pCifComponent);
  1668. pCifComponent_t->GetID(szID, countof(szID));
  1669. pComp = FindComp(szID, FALSE);
  1670. if (pComp)
  1671. {
  1672. PCOMPONENT pCompTemp;
  1673. for (pCompTemp = g_paComp; *pCompTemp->szSection; pCompTemp++)
  1674. pCompTemp->fIEDependency = FALSE;
  1675. pComp->fIEDependency = TRUE;
  1676. SetCompRevDependList(pComp, pCifComponent_t);
  1677. }
  1678. delete pCifComponent_t;
  1679. }
  1680. }
  1681. void GetUpdateSite() {
  1682. TCHAR szLang[8], szURL[MAX_URL], szMsg[MAX_PATH];
  1683. CHAR szSiteDataA[MAX_PATH];
  1684. int i, j;
  1685. DWORD dwErr;
  1686. IDownloadSiteMgr* pSiteMgr = NULL;
  1687. IDownloadSite* pISite = NULL;
  1688. DOWNLOADSITE* pSite;
  1689. LoadString(g_rvInfo.hInst, IDS_AVSUPDATEINITFAIL, szMsg, countof(szMsg));
  1690. for (j=0; s_szSiteData[j]; j++);
  1691. for (i=j; (i>0) && ('/' != s_szSiteData[i]); i--);
  1692. StrNCpy(g_szUpdateData, (LPCWSTR) s_szSiteData, i+1);
  1693. StrCat(g_szUpdateData, TEXT("/IEUPDATE.DAT"));
  1694. dwErr = CoCreateInstance(CLSID_DownloadSiteMgr, NULL, CLSCTX_INPROC_SERVER,
  1695. IID_IDownloadSiteMgr, (void **) &pSiteMgr);
  1696. do {
  1697. dwErr = pSiteMgr->Initialize(T2Abux(g_szUpdateData, szSiteDataA), NULL);
  1698. }
  1699. while ((dwErr != NOERROR) && (MessageBox(g_hDlg, szMsg, g_szTitle, MB_RETRYCANCEL) == IDRETRY));
  1700. for (i=0; i<NUMSITES; i++) {
  1701. pSiteMgr->EnumSites(i, &pISite);
  1702. if (!pISite) break;
  1703. pISite->GetData(&pSite);
  1704. A2Tbux(pSite->pszLang, szLang);
  1705. if (0 == StrCmpI(szLang, g_szActLang)) {
  1706. A2Tbux(pSite->pszUrl, szURL);
  1707. StrCpy(g_szUpdateURL, szURL);
  1708. break;
  1709. }
  1710. }
  1711. if (pSiteMgr)
  1712. pSiteMgr->Release();
  1713. if (pISite)
  1714. pISite->Release();
  1715. }
  1716. DWORD InitOptComponents32(LPVOID)
  1717. {
  1718. HWND hDlg = g_hWizard;
  1719. int iItem = 0;
  1720. HWND hCompList = GetDlgItem(hDlg, IDC_COMPLIST);
  1721. LV_ITEM lvItemMessage;
  1722. TCHAR szBuf[8];
  1723. DWORD dwType;
  1724. HRESULT hr;
  1725. PCOMPONENT pComp;
  1726. PCOMP_VERSION pCompVer;
  1727. BOOL fNeedCore = TRUE;
  1728. TCHAR szCifName[32];
  1729. TCHAR * lpszProgressMsg;
  1730. CoInitialize(NULL);
  1731. lpszProgressMsg=(TCHAR *) LocalAlloc(LPTR, MAX_PATH * sizeof(TCHAR));
  1732. ResetEvent(g_hCifEvent);
  1733. NeedToSetMSTrustKey();
  1734. WriteMSTrustKey(TRUE); // Mark MS as a trusted provider
  1735. if(!g_fOCW)
  1736. {
  1737. CreateDirectory( g_szIEAKProg, NULL );
  1738. }
  1739. StrCpy(szCifName, TEXT("IESetup.CIF"));
  1740. PathCombine(g_szCif, g_szBuildRoot, TEXT("INS"));
  1741. PathAppend(g_szCif, GetOutputPlatformDir());
  1742. PathAppend(g_szCif, g_szLanguage);
  1743. PathAppend(g_szCif, szCifName);
  1744. s_dwTotalSize = 0;
  1745. ListView_DeleteAllItems(hCompList);
  1746. ListView_DeleteColumn(hCompList, 1);
  1747. ListView_DeleteColumn(hCompList, 0);
  1748. s_fNoCore = FALSE;
  1749. InitAVSListView(hCompList); //----- assign image list and create columns
  1750. LoadString(g_rvInfo.hInst,IDS_COMPINITDOWNLOAD,lpszProgressMsg,MAX_PATH);
  1751. ZeroMemory(&lvItemMessage, sizeof(lvItemMessage));
  1752. lvItemMessage.mask = LVIF_TEXT | LVIF_IMAGE;
  1753. lvItemMessage.iItem = iItem;
  1754. lvItemMessage.pszText = lpszProgressMsg;
  1755. lvItemMessage.iImage = YELLOW;
  1756. ListView_InsertItem(hCompList, &lvItemMessage);
  1757. StrCpy(szBuf, g_szLanguage + 1);
  1758. szBuf[lstrlen(szBuf) - 1] = 0;
  1759. StrCpy(s_szCifCabURL, g_szBaseURL);
  1760. StrCat(s_szCifCabURL, TEXT("/IECIF.CAB"));
  1761. StrCpy(g_szCifVer, g_szIEAKProg);
  1762. PathAppend(g_szCifVer, TEXT("IEsetup.cif"));
  1763. StrCpy(s_szCifNew, g_szIEAKProg);
  1764. PathAppend(s_szCifNew, TEXT("new"));
  1765. CreateDirectory( s_szCifNew, NULL );
  1766. PathAppend(s_szCifNew, TEXT("IEsetup.cif"));
  1767. if ((!s_fNoNet)&&(!g_fLocalMode))
  1768. {
  1769. BOOL fIgnore = FALSE;
  1770. TCHAR szCifCabDest[MAX_PATH * 4]; //part of fix for bug 13454--trap on long file path. Rest of fix is not to allow ridiculous paths.
  1771. if (g_fBatch2)
  1772. {
  1773. //batch2 mode we don't download the cab, we copy the cif.
  1774. PathCombine(s_szCifCabURL, g_szBaseURL, TEXT("INS"));
  1775. PathAppend(s_szCifCabURL, GetOutputPlatformDir());
  1776. PathAppend(s_szCifCabURL, g_szLanguage);
  1777. PathAppend(s_szCifCabURL, szCifName);
  1778. PathCombine(szCifCabDest, g_szIEAKProg, TEXT("new\\IEsetup.cif"));
  1779. if (CopyFile(s_szCifCabURL, szCifCabDest, FALSE))
  1780. hr = NOERROR;
  1781. else
  1782. hr = -1;
  1783. }
  1784. else
  1785. {
  1786. if (!PathCombine(szCifCabDest, g_szIEAKProg, TEXT("new\\IECIF.CAB")))
  1787. {
  1788. //error in path combine, probably due to overly long path on win98
  1789. //user can't continue
  1790. ErrorMessageBox(hDlg, IDS_ERR_PATH);
  1791. ListView_DeleteItem(hCompList, iItem);
  1792. LocalFree(lpszProgressMsg);
  1793. SetEvent(g_hCifEvent);
  1794. PropSheet_SetWizButtons(GetParent(hDlg), PSWIZB_BACK);
  1795. PostMessage( g_hDlg, IDM_INITIALIZE, 0, 0 );
  1796. g_fOptCompInit = TRUE;
  1797. s_fNoCore = TRUE;
  1798. CoUninitialize();
  1799. return(0);
  1800. }
  1801. hr = DownloadCab(hDlg, s_szCifCabURL, szCifCabDest, NULL, 0, fIgnore);
  1802. if (hr == NOERROR)
  1803. {
  1804. TCHAR szCifCabFilesDest[MAX_PATH * 4];
  1805. PathCombine(szCifCabFilesDest, g_szIEAKProg, TEXT("new"));
  1806. hr = ExtractFilesWrap(szCifCabDest, szCifCabFilesDest, 0, NULL, NULL, 0);
  1807. }
  1808. }
  1809. if (hr != NOERROR)
  1810. {
  1811. if (!PathFileExists(g_szCifVer))
  1812. {
  1813. ListView_DeleteItem(hCompList, iItem);
  1814. LocalFree(lpszProgressMsg);
  1815. SetEvent(g_hCifEvent);
  1816. PropSheet_SetWizButtons(GetParent(hDlg), PSWIZB_BACK);
  1817. PostMessage( g_hDlg, IDM_INITIALIZE, 0, 0 );
  1818. g_fOptCompInit = TRUE;
  1819. s_fNoCore = TRUE;
  1820. CoUninitialize();
  1821. return(0);
  1822. }
  1823. s_fNoNet = TRUE;
  1824. g_fLocalMode = TRUE;
  1825. }
  1826. }
  1827. if (!PathFileExists(g_szCifVer))
  1828. {
  1829. TCHAR szVerCifCab[MAX_PATH* 4];
  1830. PathCombine(szVerCifCab, g_szIEAKProg, TEXT("IECIF.CAB"));
  1831. // if there is an iecif.cab in the source dir then extract the cif and assume it's valid
  1832. if (!PathFileExists(szVerCifCab) ||
  1833. (ExtractFilesWrap(szVerCifCab, g_szIEAKProg, 0, NULL, NULL, 0) != NOERROR))
  1834. {
  1835. TCHAR szTemp[MAX_PATH* 4];
  1836. WIN32_FIND_DATA fd;
  1837. HANDLE hFind;
  1838. PathCombine(szTemp, g_szIEAKProg, TEXT("*.cab"));
  1839. if ((hFind = FindFirstFile(szTemp, &fd)) != INVALID_HANDLE_VALUE)
  1840. {
  1841. // delete all files in download directory if no versioning cif found, this is for
  1842. // overinstalls
  1843. LoadString(g_rvInfo.hInst, IDS_OLD_CABS, szTemp, countof(szTemp));
  1844. FindClose(hFind);
  1845. if (MessageBox(hDlg, szTemp, g_szTitle, MB_YESNO) == IDYES)
  1846. {
  1847. PathRemovePath(g_szIEAKProg, ADN_DONT_DEL_SUBDIRS);
  1848. }
  1849. else
  1850. {
  1851. ListView_DeleteItem(hCompList, iItem);
  1852. LocalFree(lpszProgressMsg);
  1853. SetEvent(g_hCifEvent);
  1854. PropSheet_SetWizButtons(GetParent(hDlg), PSWIZB_BACK);
  1855. PostMessage( g_hDlg, IDM_INITIALIZE, 0, 0 );
  1856. g_fOptCompInit = g_fLocalMode = TRUE;
  1857. s_fNoCore = TRUE;
  1858. CoUninitialize();
  1859. return(0);
  1860. }
  1861. }
  1862. CopyFile(s_szCifNew, g_szCifVer, FALSE);
  1863. }
  1864. }
  1865. if (!PathFileExists(g_szCif))
  1866. CopyFile(g_szCifVer, g_szCif, FALSE);
  1867. if (s_fNoNet||g_fLocalMode)
  1868. StrCpy(s_szCifNew, g_szCifVer);
  1869. ListView_DeleteItem(hCompList, iItem);
  1870. LoadString(g_rvInfo.hInst,IDS_COMPINITPROCESSING,lpszProgressMsg,MAX_PATH);
  1871. lvItemMessage.pszText = lpszProgressMsg;
  1872. ListView_InsertItem(hCompList, &lvItemMessage);
  1873. // create our cif objects
  1874. if (g_lpCifFileNew)
  1875. {
  1876. delete g_lpCifFileNew;
  1877. g_lpCifFileNew = NULL;
  1878. }
  1879. hr = GetICifFileFromFile_t(&g_lpCifFileNew, s_szCifNew);
  1880. if (SUCCEEDED(hr))
  1881. {
  1882. if (g_lpCifRWFile)
  1883. {
  1884. delete g_lpCifRWFile;
  1885. g_lpCifRWFile = NULL;
  1886. }
  1887. hr = GetICifRWFileFromFile_t(&g_lpCifRWFile, g_szCif);
  1888. if (SUCCEEDED(hr))
  1889. {
  1890. if (g_lpCifRWFileVer)
  1891. {
  1892. delete g_lpCifRWFileVer;
  1893. g_lpCifRWFileVer = NULL;
  1894. }
  1895. hr = GetICifRWFileFromFile_t(&g_lpCifRWFileVer, g_szCifVer);
  1896. }
  1897. }
  1898. SetEvent(g_hCifEvent);
  1899. // wait for the opt cab download attempt so we can block if there were problems
  1900. while (MsgWaitForMultipleObjects(1, &g_hProcessInfEvent, FALSE, INFINITE, QS_ALLINPUT) != WAIT_OBJECT_0)
  1901. {
  1902. MSG msg;
  1903. while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
  1904. {
  1905. TranslateMessage(&msg);
  1906. DispatchMessage(&msg);
  1907. }
  1908. }
  1909. if (!PathFileExists(g_szMastInf)) // if iesetup.inf doesn't exist in the opt dir, then it
  1910. { // means the opt cab was not downloaded/extracted successfully
  1911. // we should not let the user continue
  1912. ErrorMessageBox(hDlg, IDS_OPTCAB_ERROR);
  1913. ListView_DeleteItem(hCompList, iItem);
  1914. LocalFree(lpszProgressMsg);
  1915. PropSheet_SetWizButtons(GetParent(hDlg), PSWIZB_BACK);
  1916. PostMessage( g_hDlg, IDM_INITIALIZE, 0, 0 );
  1917. g_fOptCompInit = g_fLocalMode = TRUE;
  1918. s_fNoCore = TRUE;
  1919. CoUninitialize();
  1920. return(0);
  1921. }
  1922. ListView_DeleteItem(hCompList, iItem);
  1923. if (SUCCEEDED(hr))
  1924. {
  1925. IEnumCifComponents *pEnumCifComponents = NULL;
  1926. ICifRWComponent * pCifRWComponent;
  1927. ICifComponent *pCifComponent = NULL;
  1928. if (SUCCEEDED(hr))
  1929. {
  1930. // currently not showing alpha comps
  1931. hr = g_lpCifFileNew->EnumComponents(&pEnumCifComponents,
  1932. PLATFORM_WIN98 | PLATFORM_NT4 | PLATFORM_NT5 | PLATFORM_MILLEN, NULL);
  1933. if (0 != g_uiNumCabs)
  1934. g_uiNumCabs = 0;
  1935. while (pEnumCifComponents->Next(&pCifComponent) == S_OK)
  1936. g_uiNumCabs++;
  1937. //bug 17727: we need to allocate enough memory to hold the updated components as well, which is
  1938. //why there is so much extra
  1939. pComp=g_paComp=(PCOMPONENT) LocalAlloc(LPTR, ((g_uiNumCabs*3) + 100) * sizeof(COMPONENT));
  1940. pCompVer=g_rgCompVer=(PCOMP_VERSION) LocalAlloc(LPTR, ((g_uiNumCabs*3) + 100) * sizeof(COMP_VERSION));
  1941. iItem=0; //reset iItem for filling in the list box
  1942. pEnumCifComponents->Reset();
  1943. while(pEnumCifComponents->Next(&pCifComponent) == S_OK)
  1944. {
  1945. ICifComponent * pCifComponentTemp;
  1946. TCHAR szVerNew[32];
  1947. TCHAR szPatchVerNew[32];
  1948. TCHAR szIEAKVer[32] = TEXT("");
  1949. TCHAR szIEAKVerNew[32];
  1950. TCHAR szCustData[MAX_PATH];
  1951. TCHAR szID[128];
  1952. TCHAR szMode[MAX_PATH];
  1953. UINT uiIndex;
  1954. DWORD dwVer, dwBuild, dwPlatform;
  1955. CCifComponent_t * pCifComponent_t =
  1956. new CCifComponent_t((ICifRWComponent *)pCifComponent);
  1957. // ignore components that aren't in a group
  1958. if (FAILED(pCifComponent_t->GetGroup(szID, countof(szID))))
  1959. {
  1960. delete pCifComponent_t;
  1961. g_uiNumCabs--;
  1962. continue;
  1963. }
  1964. pComp->fVisible = (pCifComponent_t->IsUIVisible() == S_FALSE) ? FALSE : TRUE;
  1965. dwPlatform = pCifComponent_t->GetPlatform();
  1966. if (dwPlatform & PLATFORM_WIN98)
  1967. {
  1968. if (dwPlatform & PLATFORM_NT4)
  1969. pComp->iPlatform = PLAT_I386;
  1970. else
  1971. pComp->iPlatform = PLAT_W98;
  1972. }
  1973. else
  1974. pComp->iPlatform = PLAT_NTx86;
  1975. pCifComponent_t->GetID(szID, countof(szID));
  1976. StrCpy(pCompVer->szID, szID);
  1977. // do not read in the branding.cab entry for microsoft.com
  1978. if (StrCmpI(szID, TEXT("BRANDING.CAB")) == 0)
  1979. {
  1980. ZeroMemory(pComp, sizeof(COMPONENT));
  1981. delete pCifComponent_t;
  1982. g_uiNumCabs--;
  1983. continue;
  1984. }
  1985. // do not read in exluded components in all modes(128Update) or
  1986. // ISP excluded components(IE4SHELL) or corp excluded comps
  1987. if (((SUCCEEDED(pCifComponent_t->GetCustomData(TEXT("IEAKExclude"), szCustData, countof(szCustData))))
  1988. && (szCustData[0] == TEXT('1'))) ||
  1989. (!g_fIntranet && (SUCCEEDED(pCifComponent_t->GetCustomData(TEXT("IEAKISPExclude"), szCustData, countof(szCustData))))
  1990. && (szCustData[0] == TEXT('1'))) ||
  1991. (g_fIntranet && (SUCCEEDED(pCifComponent_t->GetCustomData(TEXT("IEAKCorpExclude"), szCustData, countof(szCustData))))
  1992. && (szCustData[0] == TEXT('1'))))
  1993. {
  1994. ZeroMemory(pComp, sizeof(COMPONENT));
  1995. delete pCifComponent_t;
  1996. continue;
  1997. }
  1998. // add on only components or IEAK show only components
  1999. if ((SUCCEEDED(pCifComponent_t->GetCustomData(TEXT("AddOnOnly"), szCustData, countof(szCustData))))
  2000. && (szCustData[0] == TEXT('1')))
  2001. {
  2002. pComp->fAddOnOnly = TRUE;
  2003. pComp->fVisible = TRUE;
  2004. }
  2005. if ((SUCCEEDED(pCifComponent_t->GetCustomData(TEXT("IEAKVisible"), szCustData, countof(szCustData))))
  2006. && (szCustData[0] == TEXT('1')))
  2007. pComp->fVisible = TRUE;
  2008. pCifComponent_t->GetCustomData(TEXT("IEAKVersion"), szIEAKVerNew, countof(szIEAKVerNew));
  2009. if (SUCCEEDED(g_lpCifRWFileVer->FindComponent(szID, &pCifComponentTemp)))
  2010. {
  2011. CCifComponent_t * pCifComponentTemp_t =
  2012. new CCifComponent_t((ICifRWComponent *)pCifComponentTemp);
  2013. pCifComponentTemp_t->GetVersion(&dwVer, &dwBuild);
  2014. ConvertDwordsToVersionStr(pComp->szVersion, dwVer, dwBuild);
  2015. pCifComponentTemp_t->GetCustomData(TEXT("IEAKVersion"), szIEAKVer, countof(szIEAKVer));
  2016. }
  2017. pCifComponent_t->GetVersion(&dwVer, &dwBuild);
  2018. ConvertDwordsToVersionStr(szVerNew, dwVer, dwBuild);
  2019. StrCpy(pCompVer->szVersion, szVerNew);
  2020. uiIndex = 0;
  2021. szMode[0] = TEXT('\0');
  2022. if (SUCCEEDED(g_lpCifRWFile->FindComponent(szID, &pCifComponentTemp)))
  2023. {
  2024. CCifComponent_t * pCifComponentTemp_t =
  2025. new CCifComponent_t((ICifRWComponent *)pCifComponentTemp);
  2026. while (SUCCEEDED(pCifComponentTemp_t->GetMode(uiIndex, szMode, countof(szMode))))
  2027. {
  2028. pComp->szModes[uiIndex] = szMode[0];
  2029. pComp->afInstall[szMode[0] - TEXT('0')] = TRUE;
  2030. uiIndex++;
  2031. }
  2032. delete pCifComponentTemp_t;
  2033. }
  2034. else
  2035. {
  2036. while (SUCCEEDED(pCifComponent_t->GetMode(uiIndex, szMode, countof(szMode))))
  2037. {
  2038. pComp->szModes[uiIndex] = szMode[0];
  2039. pComp->afInstall[szMode[0] - TEXT('0')] = TRUE;
  2040. uiIndex++;
  2041. }
  2042. }
  2043. pComp->szModes[uiIndex] = TEXT('\0');
  2044. if ((SUCCEEDED(pCifComponent_t->GetCustomData(TEXT("IEAKCore"), szCustData, countof(szCustData))))
  2045. && (szCustData[0] == TEXT('1')))
  2046. {
  2047. pComp->iCompType = COMP_CORE;
  2048. pComp->fVisible = FALSE;
  2049. }
  2050. // pick up special core comps for OCW
  2051. if (g_fOCW && (SUCCEEDED(pCifComponent_t->GetCustomData(TEXT("IEAKOCWCore"), szCustData, countof(szCustData))))
  2052. && (szCustData[0] == TEXT('1')))
  2053. {
  2054. pComp->iCompType = COMP_CORE;
  2055. pComp->fVisible = FALSE;
  2056. }
  2057. if ((SUCCEEDED(pCifComponent_t->GetCustomData(TEXT("IEAKServer"), szCustData, countof(szCustData))))
  2058. && (szCustData[0] == TEXT('1')))
  2059. pComp->iCompType = COMP_SERVER;
  2060. // IEAK should ignore these components since they point to the same cabs as
  2061. // another section
  2062. if ((SUCCEEDED(pCifComponent_t->GetCustomData(TEXT("IEAKAVSIgnore"), szCustData, countof(szCustData))))
  2063. && (szCustData[0] == TEXT('1')))
  2064. {
  2065. pComp->fAVSDupe = TRUE;
  2066. pComp->fVisible = FALSE;
  2067. }
  2068. // pick up components which point to the same cabs as this section
  2069. if ((SUCCEEDED(pCifComponent_t->GetCustomData(TEXT("IEAKAVSLinks"), szCustData, countof(szCustData))))
  2070. && ISNONNULL(szCustData))
  2071. {
  2072. StrRemoveWhitespace(szCustData);
  2073. if ((pComp->pszAVSDupeSections =
  2074. (LPTSTR)CoTaskMemAlloc((StrLen(szCustData)+1) * sizeof(TCHAR))) != NULL)
  2075. StrCpy(pComp->pszAVSDupeSections, szCustData);
  2076. }
  2077. else
  2078. pComp->pszAVSDupeSections = NULL;
  2079. StrCpy(pComp->szSection, szID);
  2080. if (StrCmpI(szID, TEXT("MAILNEWS")) == 0)
  2081. g_pMNComp = pComp;
  2082. pCifComponent_t->GetGUID(pComp->szGUID, countof(pComp->szGUID));
  2083. pCifComponent_t->GetDescription(pComp->szDisplayName, countof(pComp->szDisplayName));
  2084. pCifComponent_t->GetUrl(0, pComp->szUrl, countof(pComp->szUrl), &dwType);
  2085. if (!(dwType & URLF_RELATIVEURL))
  2086. {
  2087. LPTSTR pUrl;
  2088. TCHAR szTempUrl[MAX_PATH];
  2089. pUrl = StrRChr(pComp->szUrl, NULL, TEXT('/'));
  2090. if (pUrl)
  2091. pUrl++;
  2092. else
  2093. pUrl = pComp->szUrl;
  2094. StrCpy(szTempUrl, pUrl);
  2095. StrCpy(pComp->szUrl, szTempUrl);
  2096. }
  2097. pComp->dwSize = pCifComponent_t->GetDownloadSize();
  2098. if (!pComp->fAVSDupe)
  2099. s_dwTotalSize += pComp->dwSize;
  2100. // take out patch processing for now
  2101. /*
  2102. // look for a patch entry, special case out patches from 4.0 to 4.01
  2103. if (SUCCEEDED(pCifComponent_t->GetPatchID(pComp->piPatchInfo.szSection, countof(pComp->piPatchInfo.szSection))))
  2104. {
  2105. CHAR szPatchSect[2048];
  2106. BOOL fBadPatch = FALSE;
  2107. if (GetPrivateProfileSection("Patches", szPatchSect, countof(szPatchSect), g_szDefInf))
  2108. {
  2109. LPSTR pSectID;
  2110. for (pSectID = szPatchSect; *pSectID; pSectID += (lstrlen(pSectID)+1))
  2111. {
  2112. if (StrCmpI(pSectID, pComp->piPatchInfo.szSection) == 0)
  2113. {
  2114. fBadPatch = TRUE;
  2115. break;
  2116. }
  2117. }
  2118. }
  2119. if (fBadPatch)
  2120. {
  2121. WritePrivateProfileString(pComp->piPatchInfo.szSection, NULL, NULL, g_szCif);
  2122. WritePrivateProfileString(pComp->piPatchInfo.szSection, NULL, NULL, s_szCifNew);
  2123. WritePrivateProfileString(szID, "PatchID", NULL, g_szCif);
  2124. WritePrivateProfileString(szID, "PatchID", NULL, s_szCifNew);
  2125. *pComp->piPatchInfo.szSection = '\0';
  2126. }
  2127. else
  2128. {
  2129. if (SUCCEEDED(g_lpCifFile->FindComponent(pComp->piPatchInfo.szSection, &pCifComponentTemp)))
  2130. {
  2131. pCifComponentTemp->GetVersion(&dwVer, &dwBuild);
  2132. ConvertDwordsToVersionStr(pComp->piPatchInfo.szVersion, dwVer, dwBuild);
  2133. }
  2134. g_lpCifFileNew->FindComponent(pComp->piPatchInfo.szSection, &pCifComponentTemp);
  2135. pCifComponentTemp->GetVersion(&dwVer, &dwBuild);
  2136. ConvertDwordsToVersionStr(szPatchVerNew, dwVer, dwBuild);
  2137. pComp->piPatchInfo.dwSize = pCifComponentTemp->GetDownloadSize();
  2138. }
  2139. }
  2140. */
  2141. // Note: we are depending on the section name of core IE4 here.
  2142. if ((fNeedCore && (StrCmpI(szID, BASEWIN32) == 0))
  2143. || ((pComp->iCompType == COMP_OPTIONAL) && (pComp->iPlatform <= PLAT_W98)
  2144. && pComp->fVisible))
  2145. {
  2146. LV_ITEM lvItem;
  2147. LVFINDINFO lvFind;
  2148. TCHAR szLocalPath[MAX_PATH];
  2149. if (StrCmpI(szID, BASEWIN32) == 0)
  2150. {
  2151. fNeedCore = FALSE;
  2152. StrCpy(g_szJobVersion, pComp->szVersion);
  2153. }
  2154. ZeroMemory(&lvItem, sizeof(lvItem));
  2155. lvItem.mask = LVIF_TEXT | LVIF_IMAGE;
  2156. // BUGBUG: <oliverl> we should adjust iItem here to make sure core browser
  2157. // is always on top
  2158. lvItem.iItem = pComp->iList = iItem++;
  2159. lvItem.pszText = pComp->szDisplayName;
  2160. StrCpy(szLocalPath, g_szIEAKProg);
  2161. StrCat(szLocalPath, pComp->szUrl);
  2162. if (!PathFileExists(szLocalPath))
  2163. {
  2164. g_lpCifRWFile->CreateComponent(szID, &pCifRWComponent);
  2165. pCifRWComponent->SetGroup(NULL);
  2166. lvItem.iImage = pComp->iImage = RED;
  2167. }
  2168. else
  2169. {
  2170. CCifRWComponent_t * pCifRWComponent_t;
  2171. g_lpCifFileNew->FindComponent(szID, &pCifComponent);
  2172. pCifComponent_t->GetGroup(szLocalPath, countof(szLocalPath));
  2173. g_lpCifRWFile->CreateComponent(szID, &pCifRWComponent);
  2174. pCifRWComponent_t = new CCifRWComponent_t(pCifRWComponent);
  2175. pCifRWComponent_t->SetGroup(szLocalPath);
  2176. delete pCifRWComponent_t;
  2177. if (s_fNoNet || g_fLocalMode || (CheckVer(pComp->szVersion, szVerNew) < 0)
  2178. || (CheckVer(szIEAKVer, szIEAKVerNew) < 0)
  2179. || ((ISNONNULL(pComp->piPatchInfo.szSection))
  2180. && (CheckVer(pComp->piPatchInfo.szVersion, szPatchVerNew) < 0)))
  2181. lvItem.iImage = pComp->iImage = YELLOW;
  2182. else lvItem.iImage = pComp->iImage = GREEN;
  2183. }
  2184. ZeroMemory(&lvFind, sizeof(lvFind));
  2185. lvFind.flags = LVFI_STRING;
  2186. lvFind.psz = pComp->szDisplayName;
  2187. if (ListView_FindItem(hCompList, -1, &lvFind) == -1)
  2188. {
  2189. ListView_InsertItem(hCompList, &lvItem);
  2190. if ((pComp->iCompType == COMP_OPTIONAL) && (pComp->iImage != RED))
  2191. ListView_SetItemText(hCompList, pComp->iList, 1, pComp->szVersion);
  2192. }
  2193. }
  2194. else
  2195. {
  2196. TCHAR szLocalPath[MAX_PATH];
  2197. PathCombine(szLocalPath, g_szIEAKProg, pComp->szUrl);
  2198. if (GetFileAttributes(szLocalPath) == 0xFFFFFFFF)
  2199. {
  2200. g_lpCifRWFile->CreateComponent(szID, &pCifRWComponent);
  2201. pCifRWComponent->SetGroup(NULL);
  2202. pComp->iImage = RED;
  2203. }
  2204. else
  2205. {
  2206. CCifRWComponent_t * pCifRWComponent_t;
  2207. g_lpCifFileNew->FindComponent(szID, &pCifComponent);
  2208. pCifComponent_t->GetGroup(szLocalPath, countof(szLocalPath));
  2209. g_lpCifRWFile->CreateComponent(szID, &pCifRWComponent);
  2210. pCifRWComponent_t = new CCifRWComponent_t(pCifRWComponent);
  2211. pCifRWComponent_t->SetGroup(szLocalPath);
  2212. delete pCifRWComponent_t;
  2213. if (s_fNoNet || g_fLocalMode || (CheckVer(pComp->szVersion, szVerNew) < 0)
  2214. || (CheckVer(szIEAKVer, szIEAKVerNew) < 0)
  2215. || ((ISNONNULL(pComp->piPatchInfo.szSection))
  2216. && (CheckVer(pComp->piPatchInfo.szVersion, szPatchVerNew) < 0)))
  2217. pComp->iImage = YELLOW;
  2218. else pComp->iImage = GREEN;
  2219. }
  2220. }
  2221. pComp++;
  2222. pCompVer++;
  2223. delete pCifComponent_t;
  2224. }
  2225. pEnumCifComponents->Reset();
  2226. BuildReverseDependencyList(pEnumCifComponents);
  2227. pEnumCifComponents->Release();
  2228. for (pComp = g_paComp; (pComp && ISNONNULL(pComp->szSection)); pComp++)
  2229. {
  2230. if ((pComp->iCompType != COMP_OPTIONAL) &&
  2231. (pComp->iImage == RED))
  2232. s_fNoCore = TRUE;
  2233. }
  2234. if (s_fNoCore)
  2235. {
  2236. LV_ITEM lvItem;
  2237. lvItem.mask = LVIF_IMAGE;
  2238. lvItem.iItem = 0;
  2239. lvItem.iImage = RED;
  2240. ListView_SetItem(hCompList, &lvItem);
  2241. PropSheet_SetWizButtons(GetParent(hDlg), PSWIZB_BACK);
  2242. }
  2243. else
  2244. {
  2245. pComp = FindComp(NULL, TRUE);
  2246. if (pComp)
  2247. ListView_SetItemText(hCompList, pComp->iList, 1, pComp->szVersion);
  2248. PropSheet_SetWizButtons(GetParent(hDlg), PSWIZB_BACK | PSWIZB_NEXT);
  2249. }
  2250. }
  2251. }
  2252. ProcessUpdateIcons(hDlg);
  2253. if (FAILED(hr))
  2254. {
  2255. s_fNoCore = TRUE;
  2256. g_fLocalMode = TRUE;
  2257. PropSheet_SetWizButtons(GetParent(hDlg), PSWIZB_BACK);
  2258. }
  2259. else
  2260. {
  2261. IEnumCifModes * pEnumCifModes;
  2262. int i, j;
  2263. // initialize modes
  2264. // currently not getting alpha modes
  2265. if (SUCCEEDED(g_lpCifRWFile->EnumModes(&pEnumCifModes,
  2266. PLATFORM_WIN98 | PLATFORM_NT4 | PLATFORM_NT5 | PLATFORM_MILLEN, NULL)))
  2267. {
  2268. ICifMode * pCifMode;
  2269. TCHAR szModeID[64];
  2270. i = 0;
  2271. while (SUCCEEDED(pEnumCifModes->Next(&pCifMode)))
  2272. {
  2273. CCifMode_t * pCifMode_t = new CCifMode_t((ICifRWMode *)pCifMode);
  2274. pCifMode_t->GetID(szModeID, countof(szModeID));
  2275. delete pCifMode_t;
  2276. g_szAllModes[i] = szModeID[0];
  2277. i++;
  2278. }
  2279. pEnumCifModes->Release();
  2280. }
  2281. g_nModes = lstrlen(g_szAllModes);
  2282. for (pComp = g_paComp; ; pComp++ )
  2283. {
  2284. if (*pComp->szSection == '\0') break;
  2285. if (pComp->iCompType == COMP_CORE)
  2286. {
  2287. for (i = 0; i < g_nModes ; i++ )
  2288. {
  2289. pComp->afInstall[i] = TRUE;
  2290. }
  2291. }
  2292. else
  2293. {
  2294. for (i = 0; i < g_nModes; i++)
  2295. {
  2296. for (j=0; j < lstrlen(pComp->szModes); j++)
  2297. {
  2298. if (pComp->szModes[j] == g_szAllModes[i])
  2299. pComp->afInstall[i] = TRUE;
  2300. }
  2301. }
  2302. // for invisible comps, set them to the same modes as the visible components
  2303. // that depend on them
  2304. if (!pComp->fVisible)
  2305. {
  2306. for (i = 0; pComp->paCompRevDeps[i] && (i < 10); i++)
  2307. {
  2308. for (j=0; j < MAX_INSTALL_OPTS; j++)
  2309. {
  2310. if (pComp->paCompRevDeps[i]->afInstall[j])
  2311. pComp->afInstall[j] = TRUE;
  2312. }
  2313. }
  2314. }
  2315. }
  2316. }
  2317. InitCustComponents(NULL);
  2318. }
  2319. g_fOptCompInit = TRUE;
  2320. if (!g_fLocalMode)
  2321. {
  2322. EnableDlgItem2(hDlg, IDC_DOWNLOAD, AnyCompSelected(hDlg));
  2323. EnableDlgItem(hDlg, IDC_DOWNLOADALL);
  2324. EnableDlgItem(hDlg, IDC_UPDATE);
  2325. }
  2326. LocalFree(lpszProgressMsg);
  2327. PostMessage( g_hDlg, IDM_INITIALIZE, 0, 0 );
  2328. CoUninitialize();
  2329. return(0);
  2330. }
  2331. BOOL AnySelection(PCOMPONENT pComp)
  2332. {
  2333. int i;
  2334. if (!pComp)
  2335. return FALSE;
  2336. for (i = 0; i < 10 ; i++ )
  2337. {
  2338. if (pComp->afInstall[i]) return(TRUE);
  2339. }
  2340. return(FALSE);
  2341. }
  2342. DWORD GetCompDownloadSize(PCOMPONENT pComp)
  2343. {
  2344. PCOMPONENT pCompDep;
  2345. DWORD dwSize = 0;
  2346. ICifComponent * pCifComponent;
  2347. TCHAR szID[128];
  2348. TCHAR tchType;
  2349. UINT uiIndex;
  2350. if (pComp->fIEDependency || pComp->fAVSDupe)
  2351. return 0;
  2352. pComp->fIEDependency = TRUE;
  2353. if (SUCCEEDED(g_lpCifFileNew->FindComponent(pComp->szSection, &pCifComponent)))
  2354. {
  2355. CCifComponent_t * pCifComponent_t =
  2356. new CCifComponent_t((ICifRWComponent *)pCifComponent);
  2357. uiIndex = 0;
  2358. while (SUCCEEDED(pCifComponent_t->GetDependency(uiIndex, szID, countof(szID), &tchType, NULL, NULL)))
  2359. {
  2360. if (StrCmpNI(szID, TEXT("BASEIE40"), 8) != 0)
  2361. {
  2362. if ((pCompDep = FindComp(szID, FALSE)) != NULL)
  2363. dwSize += GetCompDownloadSize(pCompDep);
  2364. }
  2365. uiIndex++;
  2366. }
  2367. delete pCifComponent_t;
  2368. }
  2369. dwSize += pComp->dwSize;
  2370. return dwSize;
  2371. }
  2372. void GetDownloadSize(HWND hCompList, HWND hStatusField)
  2373. {
  2374. PCOMPONENT pComp, pSearchComp;
  2375. LV_ITEM lvItem;
  2376. DWORD dwSizeNeeded = 0;
  2377. TCHAR szSizeNeeded[32];
  2378. BOOL fCore = FALSE;
  2379. for (pComp = g_paComp; *pComp->szSection; pComp++)
  2380. {
  2381. ZeroMemory(&lvItem,sizeof(lvItem));
  2382. lvItem.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_STATE;
  2383. lvItem.stateMask = LVIS_SELECTED;
  2384. lvItem.iItem = pComp->iList;
  2385. ListView_GetItem(hCompList, &lvItem);
  2386. if (((lvItem.state & LVIS_SELECTED) == 0) || (pComp->fIEDependency))
  2387. continue;
  2388. if (!pComp->fVisible || pComp->fAVSDupe)
  2389. continue;
  2390. if (pComp->iCompType != COMP_OPTIONAL)
  2391. {
  2392. fCore = TRUE;
  2393. continue;
  2394. }
  2395. // REVIEW: <oliverl> we need this check so we don't count NT comps twice
  2396. if (pComp->iList == 0)
  2397. continue;
  2398. dwSizeNeeded += GetCompDownloadSize(pComp);
  2399. // check other platforms
  2400. for (pSearchComp = g_paComp; *pSearchComp->szSection; pSearchComp++)
  2401. {
  2402. if ((pComp != pSearchComp) &&
  2403. (StrCmpI(pComp->szDisplayName, pSearchComp->szDisplayName) == 0))
  2404. dwSizeNeeded += GetCompDownloadSize(pSearchComp);
  2405. }
  2406. }
  2407. if (fCore)
  2408. {
  2409. for (pComp = g_paComp; *pComp->szSection; pComp++)
  2410. {
  2411. if (!pComp->fIEDependency && !pComp->fAVSDupe && (pComp->iCompType != COMP_OPTIONAL))
  2412. dwSizeNeeded += pComp->dwSize;
  2413. }
  2414. // REVIEW: <oliverl> fudge factor for rounding
  2415. dwSizeNeeded += 15;
  2416. }
  2417. for (pComp = g_paComp; *pComp->szSection; pComp++)
  2418. pComp->fIEDependency = FALSE;
  2419. wnsprintf(szSizeNeeded, countof(szSizeNeeded), TEXT("%lu KB"), dwSizeNeeded);
  2420. InsertCommas(szSizeNeeded);
  2421. SetWindowText(hStatusField, szSizeNeeded);
  2422. }
  2423. //
  2424. // FUNCTION: OptionalDownload(HWND, UINT, UINT, LONG)
  2425. //
  2426. // PURPOSE: Processes messages for "OptionalDownload" page
  2427. //
  2428. // MESSAGES:
  2429. //
  2430. // WM_INITDIALOG - intializes the page
  2431. // WM_NOTIFY - processes the notifications sent to the page
  2432. // WM_COMMAND - saves the id of the choice selected
  2433. //
  2434. INT_PTR CALLBACK OptionalDownload(
  2435. HWND hDlg,
  2436. UINT message,
  2437. WPARAM wParam,
  2438. LPARAM lParam)
  2439. {
  2440. static TCHAR s_szTotalSize[32];
  2441. TCHAR szWrk[MAX_PATH];
  2442. TCHAR szFreeSpace[64];
  2443. DWORD dwFreeSpace;
  2444. BOOL fSel, fSizeChange = FALSE;
  2445. static HCURSOR hOldCur = NULL;
  2446. static s_fInit = FALSE;
  2447. PCOMPONENT* ppCompUpdateList = NULL;
  2448. switch (message)
  2449. {
  2450. case WM_INITDIALOG:
  2451. InitSysFont( hDlg, IDC_COMPLIST);
  2452. g_hWizard = hDlg;
  2453. break;
  2454. case WM_SETCURSOR:
  2455. if (hOldCur == NULL)
  2456. hOldCur = SetCursor(LoadCursor(NULL, IDC_WAIT));
  2457. else
  2458. {
  2459. if (!s_fInit)
  2460. SetCursor(LoadCursor(NULL, IDC_WAIT));
  2461. }
  2462. break;
  2463. case IDM_INITIALIZE:
  2464. s_fInit = TRUE;
  2465. // REVIEW: <oliverl> fudge factor for rounding
  2466. s_dwTotalSize += 15;
  2467. wnsprintf(s_szTotalSize, countof(s_szTotalSize), TEXT("%lu KB"), s_dwTotalSize);
  2468. InsertCommas(s_szTotalSize);
  2469. SetDlgItemText(hDlg, IDC_DISKSPACENEEDED, s_szTotalSize);
  2470. StrCpy(szWrk, g_szIEAKProg);
  2471. dwFreeSpace = GetRootFree(szWrk);
  2472. wnsprintf(szFreeSpace, countof(szFreeSpace), TEXT("%lu KB"), dwFreeSpace);
  2473. InsertCommas(szFreeSpace);
  2474. SetDlgItemText(hDlg, IDC_DISKSPACE, szFreeSpace);
  2475. SetCursor(hOldCur);
  2476. while (MsgWaitForMultipleObjects(1, &g_hAVSThread, FALSE, INFINITE, QS_ALLINPUT) != WAIT_OBJECT_0)
  2477. {
  2478. MSG msg;
  2479. while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
  2480. {
  2481. TranslateMessage(&msg);
  2482. DispatchMessage(&msg);
  2483. }
  2484. }
  2485. if (!g_fLocalMode)
  2486. {
  2487. s_fComponent = FALSE;
  2488. UpdateIEAK(hDlg);
  2489. if (g_fLocalMode)
  2490. {
  2491. DisableDlgItem(hDlg, IDC_DOWNLOAD);
  2492. DisableDlgItem(hDlg, IDC_DOWNLOADALL);
  2493. }
  2494. }
  2495. break;
  2496. case IDM_BATCHADVANCE:
  2497. EnableDlgItem2(hDlg, IDC_DOWNLOAD, AnyCompSelected(hDlg));
  2498. DoBatchAdvance(hDlg);
  2499. break;
  2500. case WM_HELP:
  2501. IeakPageHelp(hDlg, g_psp[g_iCurPage].pszTemplate);
  2502. break;
  2503. case WM_COMMAND:
  2504. if (HIWORD(wParam) == BN_CLICKED)
  2505. {
  2506. switch (LOWORD(wParam))
  2507. {
  2508. TCHAR szTitle[MAX_PATH];
  2509. case IDC_DOWNLOAD:
  2510. s_fNoToAllSynch = FALSE;
  2511. ProcessDownload(hDlg, FALSE);
  2512. if (g_fFailedComp)
  2513. {
  2514. LoadString( g_rvInfo.hInst, IDS_DOWNLOADERR, szTitle, MAX_PATH );
  2515. wnsprintf(g_szFailedCompsBox, countof(g_szFailedCompsBox), g_szFailedCompsMsg, g_szFailedComps);
  2516. MessageBox(hDlg, g_szFailedCompsBox, szTitle, MB_OK | MB_SETFOREGROUND | MB_ICONEXCLAMATION);
  2517. g_szFailedComps[0] = TEXT('\0');
  2518. }
  2519. break;
  2520. case IDC_DOWNLOADALL:
  2521. ProcessDownload(hDlg, TRUE);
  2522. if (g_fFailedComp)
  2523. {
  2524. LoadString( g_rvInfo.hInst, IDS_DOWNLOADERR, szTitle, MAX_PATH );
  2525. wnsprintf(g_szFailedCompsBox, countof(g_szFailedCompsBox), g_szFailedCompsMsg, g_szFailedComps);
  2526. MessageBox(hDlg, g_szFailedCompsBox, szTitle, MB_OK | MB_SETFOREGROUND | MB_ICONEXCLAMATION);
  2527. g_szFailedComps[0] = TEXT('\0');
  2528. }
  2529. break;
  2530. case IDC_UPDATE:
  2531. DisableDlgItem(hDlg, IDC_UPDATE);
  2532. g_hProgress = NULL;
  2533. PCOMPONENT *pCompList,
  2534. *pCompEnum;
  2535. HRESULT hr;
  2536. INT_PTR iResult;
  2537. pCompList = NULL;
  2538. iResult = DialogBoxParam(g_rvInfo.hInst, MAKEINTRESOURCE(IDD_OPTUPDATE), hDlg,
  2539. UpdateDlgProc, (LPARAM)&pCompList);
  2540. if (IDOK == iResult) {
  2541. ASSERT(NULL != pCompList);
  2542. if (IsCheyenneSoftwareRunning(hDlg))
  2543. ErrDlgProc(hDlg, IDC_ERRDLABORT, NULL,
  2544. LPARAM(TEXT("Please turn of all Cheyenne Software")));
  2545. s_hStat = CreateDialog( g_rvInfo.hInst, MAKEINTRESOURCE(IDD_DOWNLOAD), NULL,
  2546. DownloadStatusDlgProc );
  2547. ShowWindow( s_hStat, SW_SHOWNORMAL );
  2548. HWND hCompList = GetDlgItem(hDlg, IDC_COMPLIST);
  2549. LVITEM lvi;
  2550. for (pCompEnum = pCompList; NULL != pCompEnum && NULL != (*pCompEnum); pCompEnum++) {
  2551. hr = DownloadUpdate(*pCompEnum);
  2552. ZeroMemory(&lvi, sizeof(lvi));
  2553. if (DONT_SHOW_UPDATES != hr)
  2554. if (BLUE == (*pCompEnum)->iImage)
  2555. UpdateBlueIcon(hCompList, *pCompEnum);
  2556. else
  2557. UpdateBrownIcon(hCompList, *pCompEnum);
  2558. LocalFree(*pCompEnum);
  2559. }
  2560. DestroyWindow(s_hStat);
  2561. }
  2562. EnableDlgItem(hDlg, IDC_UPDATE);
  2563. break;
  2564. }
  2565. ShowWindow(GetDlgItem(hDlg, IDC_DISKSPACETEXT), SW_SHOW);
  2566. ShowWindow(GetDlgItem(hDlg, IDC_DISKSPACETEXT2), SW_HIDE);
  2567. SetDlgItemText(hDlg, IDC_DISKSPACENEEDED, s_szTotalSize);
  2568. StrCpy(szWrk, g_szIEAKProg);
  2569. dwFreeSpace = GetRootFree(szWrk);
  2570. wnsprintf(szFreeSpace, countof(szFreeSpace), TEXT("%lu KB"), dwFreeSpace);
  2571. InsertCommas(szFreeSpace);
  2572. SetDlgItemText(hDlg, IDC_DISKSPACE, szFreeSpace);
  2573. if (!g_fLocalMode) EnableDlgItem2(hDlg, IDC_DOWNLOAD, AnyCompSelected(hDlg));
  2574. if (!s_fNoCore)
  2575. PropSheet_SetWizButtons(GetParent(hDlg), PSWIZB_BACK | PSWIZB_NEXT);
  2576. }
  2577. break;
  2578. case WM_NOTIFY:
  2579. switch (((NMHDR FAR *) lParam)->code)
  2580. {
  2581. case PSN_HELP:
  2582. IeakPageHelp(hDlg, g_psp[g_iCurPage].pszTemplate);
  2583. break;
  2584. case PSN_SETACTIVE:
  2585. SetBannerText(hDlg);
  2586. //processing that was formerly in the downloads page has to go here
  2587. g_iDownloadState = DOWN_STATE_SAVE_URL;
  2588. SetEvent(g_hDownloadEvent);
  2589. if (!g_fBatch && !g_fBatch2 && (!g_fOptCompInit || g_fSrcDirChanged))
  2590. {
  2591. DWORD dwTid;
  2592. g_hWizard = hDlg;
  2593. g_hDlg = hDlg;
  2594. g_fSrcDirChanged = FALSE;
  2595. DisableDlgItem(hDlg, IDC_DOWNLOAD);
  2596. DisableDlgItem(hDlg, IDC_DOWNLOADALL);
  2597. DisableDlgItem(hDlg, IDC_UPDATE);
  2598. g_hAVSThread = CreateThread(NULL, 4096, InitOptComponents32, &g_hWizard, 0, &dwTid);
  2599. PropSheet_SetWizButtons(GetParent(hDlg), 0);
  2600. }
  2601. else
  2602. {
  2603. if (s_fNoCore)
  2604. PropSheet_SetWizButtons(GetParent(hDlg), PSWIZB_BACK);
  2605. else PropSheet_SetWizButtons(GetParent(hDlg), PSWIZB_BACK | PSWIZB_NEXT);
  2606. if (!g_fLocalMode)
  2607. EnableDlgItem2(hDlg, IDC_DOWNLOAD, AnyCompSelected(hDlg));
  2608. }
  2609. CheckBatchAdvance(hDlg);
  2610. break;
  2611. case LVN_ITEMCHANGED:
  2612. if (hOldCur == NULL)
  2613. hOldCur = SetCursor(LoadCursor(NULL, IDC_WAIT));
  2614. else
  2615. {
  2616. if (!s_fInit)
  2617. SetCursor(LoadCursor(NULL, IDC_WAIT));
  2618. }
  2619. AnyCompSelected(hDlg, fSel, fSizeChange);
  2620. if (!g_fLocalMode && g_fOptCompInit) EnableDlgItem2(hDlg, IDC_DOWNLOAD, fSel);
  2621. if (g_fOptCompInit)
  2622. {
  2623. if (fSizeChange || fSel)
  2624. {
  2625. ShowWindow(GetDlgItem(hDlg, IDC_DISKSPACETEXT), SW_HIDE);
  2626. GetDownloadSize(GetDlgItem(hDlg, IDC_COMPLIST), GetDlgItem(hDlg, IDC_DISKSPACENEEDED));
  2627. ShowWindow(GetDlgItem(hDlg, IDC_DISKSPACETEXT2), SW_SHOW);
  2628. }
  2629. else
  2630. {
  2631. ShowWindow(GetDlgItem(hDlg, IDC_DISKSPACETEXT), SW_SHOW);
  2632. ShowWindow(GetDlgItem(hDlg, IDC_DISKSPACETEXT2), SW_HIDE);
  2633. SetDlgItemText(hDlg, IDC_DISKSPACENEEDED, s_szTotalSize);
  2634. }
  2635. }
  2636. break;
  2637. case PSN_WIZBACK:
  2638. case PSN_WIZNEXT:
  2639. if (!g_fOptCompInit && !g_fBatch && !g_fBatch2)
  2640. {
  2641. SetWindowLongPtr(hDlg, DWLP_MSGRESULT, -1);
  2642. g_fCancelled = FALSE;
  2643. return(TRUE);
  2644. }
  2645. // show OE pages if OE is synchronized for win32
  2646. if (g_pMNComp)
  2647. g_fMailNews95 = (g_pMNComp->iImage != RED);
  2648. g_iCurPage = PPAGE_OPTDOWNLOAD;
  2649. EnablePages();
  2650. if (((NMHDR FAR *) lParam)->code == PSN_WIZNEXT) PageNext(hDlg);
  2651. else
  2652. {
  2653. PagePrev(hDlg);
  2654. }
  2655. break;
  2656. case PSN_QUERYCANCEL:
  2657. QueryCancel(hDlg);
  2658. break;
  2659. default:
  2660. return FALSE;
  2661. }
  2662. break;
  2663. case WM_LV_GETITEMS:
  2664. LVGetItems(GetDlgItem(hDlg, IDC_COMPLIST));
  2665. break;
  2666. default:
  2667. return FALSE;
  2668. }
  2669. return TRUE;
  2670. }
  2671. void InstallComp(PCOMPONENT pComp, INT iOpt, BOOL fInstall)
  2672. {
  2673. PCOMPONENT pSearchComp;
  2674. for (pSearchComp = g_paComp; *pSearchComp->szSection; pSearchComp++)
  2675. {
  2676. if (!pSearchComp->fAddOnOnly &&
  2677. (StrCmpI(pSearchComp->szDisplayName, pComp->szDisplayName) == 0))
  2678. pSearchComp->afInstall[iOpt] = fInstall;
  2679. }
  2680. for (pSearchComp = g_aCustComponents; *pSearchComp->szSection; pSearchComp++)
  2681. {
  2682. if (StrCmpI(pSearchComp->szDisplayName, pComp->szDisplayName) == 0)
  2683. pSearchComp->afInstall[iOpt] = fInstall;
  2684. }
  2685. }
  2686. void SetInstallOption(HWND hDlg, int iOpt)
  2687. {
  2688. TCHAR szOptName[80];
  2689. TCHAR szOptDesc[MAX_PATH];
  2690. TCHAR szOptDescParam[16] = TEXT("0_DESC");
  2691. TCHAR szOpt[2];
  2692. int iComp;
  2693. PCOMPONENT pComp, pCoreComp;
  2694. ICifMode * pCifMode;
  2695. CCifMode_t * pCifMode_t;
  2696. szOpt[1] = 0;
  2697. SendDlgItemMessage( hDlg, IDC_LISTAVAIL, LB_RESETCONTENT, 0, 0 );
  2698. SendDlgItemMessage( hDlg, IDC_LISTINSTALL, LB_RESETCONTENT, 0, 0 );
  2699. SendDlgItemMessage( hDlg, g_fOCW ? IDC_OPTLISTOCW : IDC_OPTLIST, CB_SETCURSEL, iOpt, 0 );
  2700. SendDlgItemMessage( hDlg, g_fOCW ? IDC_OPTLISTOCW : IDC_OPTLIST, CB_GETLBTEXT, iOpt, (LPARAM) szOptName );
  2701. szOptDescParam[0] = szOpt[0]= (TCHAR)(iOpt + TEXT('0'));
  2702. WritePrivateProfileString( STRINGS, INSTALLMODE, szOpt, g_szCustInf );
  2703. g_lpCifRWFile->FindMode(szOpt, &pCifMode);
  2704. pCifMode_t = new CCifMode_t((ICifRWMode *)pCifMode);
  2705. pCifMode_t->GetDetails(szOptDesc, countof(szOptDesc));
  2706. delete pCifMode_t;
  2707. SetDlgItemText( hDlg, IDC_OPTDESC, szOptDesc );
  2708. pCoreComp = FindComp(NULL, TRUE);
  2709. for (pComp = g_paComp; ; pComp++ )
  2710. {
  2711. if (ISNULL(pComp->szSection)) break;
  2712. if (pComp->fAddOnOnly) continue;
  2713. if (pComp->iImage == RED)
  2714. {
  2715. int i;
  2716. for (i = 0; i < MAX_INSTALL_OPTS ; i++ )
  2717. {
  2718. pComp->afInstall[i] = FALSE;
  2719. }
  2720. continue;
  2721. }
  2722. if (pComp == pCoreComp)
  2723. {
  2724. InstallComp(pComp, iOpt, TRUE);
  2725. SendDlgItemMessage( hDlg, IDC_LISTINSTALL, LB_INSERTSTRING, 0, (LPARAM) pComp->szDisplayName );
  2726. }
  2727. else if ((pComp->iCompType != COMP_CORE) && (pComp->iPlatform <= PLAT_W98))
  2728. {
  2729. if (pComp->fVisible)
  2730. {
  2731. SendDlgItemMessage( hDlg, pComp->afInstall[iOpt] ? IDC_LISTINSTALL : IDC_LISTAVAIL,
  2732. LB_ADDSTRING, 0, (LPARAM) pComp->szDisplayName );
  2733. }
  2734. }
  2735. }
  2736. for (pComp = g_aCustComponents, iComp = 0; iComp < g_nCustComp ; pComp++, iComp++ )
  2737. {
  2738. if ((pComp->iCompType == COMP_OPTIONAL) && (pComp->iPlatform <= PLAT_W98))
  2739. {
  2740. SendDlgItemMessage( hDlg, pComp->afInstall[iOpt] ? IDC_LISTINSTALL : IDC_LISTAVAIL,
  2741. LB_ADDSTRING, 0, (LPARAM) pComp->szDisplayName );
  2742. }
  2743. }
  2744. if (!g_fOCW)
  2745. {
  2746. // if not silent or stealth and we are under the max number of install options then
  2747. // enable new button
  2748. if (!(g_fIntranet && (g_fSilent || g_fStealth)) && (g_nModes < 10))
  2749. EnableDlgItem(hDlg, IDC_NEWOPT);
  2750. else
  2751. {
  2752. EnsureDialogFocus(hDlg, IDC_NEWOPT, IDC_DELOPT);
  2753. DisableDlgItem(hDlg, IDC_NEWOPT);
  2754. }
  2755. if (g_nModes > 1)
  2756. EnableDlgItem(hDlg, IDC_DELOPT);
  2757. else
  2758. {
  2759. EnsureDialogFocus(hDlg, IDC_DELOPT,
  2760. (g_fIntranet && (g_fSilent || g_fStealth)) ? IDC_OPTLIST : IDC_NEWOPT);
  2761. DisableDlgItem(hDlg, IDC_DELOPT);
  2762. }
  2763. }
  2764. EnableWindow(GetDlgItem(hDlg, IDC_ADDCOMP), 0 < SendMessage( GetDlgItem(hDlg, IDC_LISTAVAIL), LB_GETCOUNT, 0, 0 ));
  2765. EnableWindow(GetDlgItem(hDlg, IDC_ADDALLCOMP), 0 < SendMessage( GetDlgItem(hDlg, IDC_LISTAVAIL), LB_GETCOUNT, 0, 0 ));
  2766. EnableWindow(GetDlgItem(hDlg, IDC_REMCOMP), 1 < SendMessage( GetDlgItem(hDlg, IDC_LISTINSTALL), LB_GETCOUNT, 0, 0 ));
  2767. EnableWindow(GetDlgItem(hDlg, IDC_REMALLCOMP), 1 < SendMessage( GetDlgItem(hDlg, IDC_LISTINSTALL), LB_GETCOUNT, 0, 0 ));
  2768. SetLBWidth(GetDlgItem(hDlg, IDC_LISTAVAIL));
  2769. SetLBWidth(GetDlgItem(hDlg, IDC_LISTINSTALL));
  2770. }
  2771. void InitSelection32(HWND hDlg)
  2772. {
  2773. int i, j, iComp;
  2774. PCOMPONENT pComp;
  2775. IEnumCifModes * pEnumCifModes;
  2776. if (g_fBatch) return;
  2777. SendDlgItemMessage(hDlg, g_fOCW ? IDC_OPTLISTOCW : IDC_OPTLIST, CB_RESETCONTENT, 0, 0 );
  2778. // currently not getting alpha modes
  2779. if (SUCCEEDED(g_lpCifRWFile->EnumModes(&pEnumCifModes,
  2780. PLATFORM_WIN98 | PLATFORM_NT4 | PLATFORM_NT5 | PLATFORM_MILLEN, NULL)))
  2781. {
  2782. ICifMode * pCifMode;
  2783. TCHAR szModeID[64];
  2784. TCHAR szOptName[96];
  2785. i = 0;
  2786. while (SUCCEEDED(pEnumCifModes->Next(&pCifMode)))
  2787. {
  2788. CCifMode_t * pCifMode_t = new CCifMode_t((ICifRWMode *)pCifMode);
  2789. pCifMode_t->GetID(szModeID, countof(szModeID));
  2790. g_szAllModes[i] = szModeID[0];
  2791. pCifMode_t->GetDescription(szOptName, countof(szOptName));
  2792. SendDlgItemMessage( hDlg, g_fOCW ? IDC_OPTLISTOCW : IDC_OPTLIST, CB_ADDSTRING, 0, (LPARAM) szOptName );
  2793. i++;
  2794. delete pCifMode_t;
  2795. }
  2796. pEnumCifModes->Release();
  2797. g_szAllModes[i] = TEXT('\0');
  2798. }
  2799. g_nModes = lstrlen(g_szAllModes);
  2800. for (pComp = g_paComp; ; pComp++ )
  2801. {
  2802. if (ISNULL(pComp->szSection)) break;
  2803. ZeroMemory(pComp->afInstall, sizeof(pComp->afInstall));
  2804. if (pComp->iCompType == COMP_CORE)
  2805. {
  2806. for (i = 0; i < g_nModes ; i++ )
  2807. {
  2808. pComp->afInstall[i] = TRUE;
  2809. }
  2810. }
  2811. else
  2812. {
  2813. for (i = 0; i < g_nModes; i++)
  2814. {
  2815. for (j=0; j < lstrlen(pComp->szModes); j++)
  2816. {
  2817. if (pComp->szModes[j] == g_szAllModes[i])
  2818. pComp->afInstall[i] = TRUE;
  2819. }
  2820. }
  2821. // for invisible comps, set them to the same modes as the visible components
  2822. // that depend on them
  2823. if (!pComp->fVisible)
  2824. {
  2825. for (i = 0; pComp->paCompRevDeps[i] && (i < 10); i++)
  2826. {
  2827. for (j=0; j < MAX_INSTALL_OPTS; j++)
  2828. {
  2829. if (pComp->paCompRevDeps[i]->afInstall[j])
  2830. pComp->afInstall[j] = TRUE;
  2831. }
  2832. }
  2833. }
  2834. }
  2835. }
  2836. for (pComp = g_aCustComponents, iComp = 0; iComp < g_nCustComp ; pComp++, iComp++ )
  2837. {
  2838. TCHAR szModesParam[80] = TEXT("Cust0Modes");
  2839. TCHAR szModes[16] = TEXT("\"");
  2840. if (ISNULL(pComp->szSection)) break;
  2841. szModesParam[4] = (TCHAR)(iComp + TEXT('0'));
  2842. ZeroMemory(pComp->afInstall, sizeof(pComp->afInstall));
  2843. GetPrivateProfileString(IS_STRINGS, szModesParam, TEXT(""), szModes, countof(szModes), g_szCustInf);
  2844. if (StrCmpI(szModes, UNUSED) != 0)
  2845. {
  2846. for (i = 0; i < lstrlen(szModes) ; i++ )
  2847. {
  2848. int j = szModes[i] - TEXT('0');
  2849. pComp->afInstall[j] = TRUE;
  2850. }
  2851. }
  2852. }
  2853. if (g_iSelOpt > g_nModes - 1) g_iSelOpt = g_nModes ? g_nModes - 1 : 0;
  2854. SetInstallOption(hDlg, g_iSelOpt);
  2855. }
  2856. void SaveSelection()
  2857. {
  2858. int i, iComp;
  2859. PCOMPONENT pComp;
  2860. TCHAR szQuotedModes[16] = TEXT("\"");
  2861. ICifRWComponent * pCifRWComponent;
  2862. CCifRWComponent_t * pCifRWComponent_t;
  2863. StrCat(szQuotedModes, g_szAllModes);
  2864. StrCat(szQuotedModes, TEXT("\""));
  2865. for (pComp = g_aCustComponents, iComp = 0; iComp < MAXCUST ; pComp++, iComp++ )
  2866. {
  2867. TCHAR szModesParam[80] = TEXT("Cust0Modes");
  2868. TCHAR szModesNameParam[80] = TEXT("Cust0Name");
  2869. TCHAR szModes[16] = TEXT("");
  2870. TCHAR szQuotedSection[32] = TEXT("\"");
  2871. StrCat(szQuotedSection, pComp->szSection);
  2872. StrCat(szQuotedSection, TEXT("\""));
  2873. szModesParam[4] = szModesNameParam[4] = (TCHAR)(iComp + TEXT('0'));
  2874. if (ISNULL(pComp->szSection))
  2875. {
  2876. InsWriteQuotedString(IS_STRINGS, szModesNameParam, UNUSED, g_szCustInf);
  2877. InsWriteQuotedString(IS_STRINGS, szModesParam, TEXT("\"\""), g_szCustInf);
  2878. continue;
  2879. }
  2880. for (i = 0; i < g_nModes ; i++ )
  2881. {
  2882. TCHAR szAddMode[2] = TEXT("0");
  2883. szAddMode[0] = (TCHAR)(i + TEXT('0'));
  2884. if (pComp->afInstall[i]) StrCat(szModes, szAddMode);
  2885. }
  2886. StrCpy(pComp->szModes, szModes);
  2887. InsWriteQuotedString(IS_STRINGS, szModesNameParam, szQuotedSection, g_szCustInf);
  2888. InsWriteQuotedString(IS_STRINGS, szModesParam, szModes, g_szCustInf);
  2889. }
  2890. for (pComp = g_paComp; ; pComp++ )
  2891. {
  2892. TCHAR szModesParam[80];
  2893. TCHAR szModes[16] = TEXT("");
  2894. if (ISNULL(pComp->szSection)) break;
  2895. //BUGBUG fix for alpha release
  2896. if (pComp->iPlatform == PLAT_ALPHA) continue;
  2897. for (i = 0; i < g_nModes ; i++ )
  2898. {
  2899. TCHAR szAddMode[2] = TEXT("0");
  2900. szAddMode[0] = (TCHAR)(i + TEXT('0'));
  2901. if (pComp->afInstall[i]) StrCat(szModes, szAddMode);
  2902. }
  2903. StrCpy(szModesParam, pComp->szModes);
  2904. g_lpCifRWFile->CreateComponent(pComp->szSection, &pCifRWComponent);
  2905. pCifRWComponent_t = new CCifRWComponent_t(pCifRWComponent);
  2906. if (pComp->iCompType == COMP_CORE)
  2907. {
  2908. int j;
  2909. if ((StrCmpNI(pComp->szSection, TEXT("IE4SHELL"), 8) == 0) ||
  2910. (StrCmpNI(pComp->szSection, TEXT("MFC"), 3) == 0))
  2911. continue;
  2912. WriteModesToCif(pCifRWComponent_t, g_szAllModes);
  2913. StrCpy(pComp->szModes, g_szAllModes);
  2914. for (j = 0; g_szAllModes[j]; j++)
  2915. pComp->afInstall[j] = TRUE;
  2916. }
  2917. else
  2918. {
  2919. if (pComp->fVisible)
  2920. WriteModesToCif(pCifRWComponent_t, szModes);
  2921. // BUGBUG: <oliverl> take out this assert for now because we'd have to totally
  2922. // change the way we handle adding and removing comps from modes to
  2923. // prevent this from asserting
  2924. /* else
  2925. ASSERT(ISNULL(pComp->szModes)); */
  2926. StrCpy(pComp->szModes, szModes);
  2927. }
  2928. delete pCifRWComponent_t;
  2929. pCifRWComponent_t = NULL;
  2930. }
  2931. WritePrivateProfileString(NULL, NULL, NULL, g_szCustInf);
  2932. g_lpCifRWFile->Flush();
  2933. }
  2934. BOOL AddDependencies32(HWND hDlg, LPCTSTR pcszSectName, INT &nComp)
  2935. {
  2936. HWND hSource = GetDlgItem(hDlg, IDC_LISTAVAIL);
  2937. HWND hDest = GetDlgItem(hDlg, IDC_LISTINSTALL);
  2938. int iComp;
  2939. PCOMPONENT pComp;
  2940. ICifComponent * pCifComponent;
  2941. BOOL fCust = FALSE;
  2942. if (StrCmpNI(pcszSectName, TEXT("BASEIE40"), 8) == 0)
  2943. return TRUE;
  2944. pComp = FindComp(pcszSectName, FALSE);
  2945. if (pComp == NULL)
  2946. {
  2947. fCust = TRUE;
  2948. pComp = FindCustComp(pcszSectName);
  2949. if (pComp == NULL)
  2950. return FALSE;
  2951. }
  2952. InstallComp(pComp, g_iSelOpt, TRUE);
  2953. if (pComp->fVisible)
  2954. {
  2955. if ((iComp = (int) SendMessage( hSource, LB_FINDSTRINGEXACT, 0, (LPARAM)pComp->szDisplayName )) == -1 )
  2956. return FALSE;
  2957. SendMessage( hSource, LB_DELETESTRING, iComp, 0 );
  2958. SendMessage( hDest, LB_ADDSTRING, 0, (LPARAM) pComp->szDisplayName);
  2959. nComp--;
  2960. SetLBWidth(GetDlgItem(hDlg, IDC_LISTAVAIL));
  2961. SetLBWidth(GetDlgItem(hDlg, IDC_LISTINSTALL));
  2962. }
  2963. if (!fCust)
  2964. {
  2965. if (SUCCEEDED(g_lpCifRWFile->FindComponent(pComp->szSection, &pCifComponent)))
  2966. {
  2967. TCHAR tchType;
  2968. TCHAR szDepID[96];
  2969. UINT uiIndex = 0;
  2970. PCOMPONENT pDepComp;
  2971. CCifComponent_t * pCifComponent_t =
  2972. new CCifComponent_t((ICifRWComponent *)pCifComponent);
  2973. while (SUCCEEDED(pCifComponent_t->GetDependency(uiIndex, szDepID, countof(szDepID), &tchType, NULL, NULL)))
  2974. {
  2975. pDepComp = FindComp(szDepID, FALSE);
  2976. // check to see if we've already seen this dependency
  2977. if (pDepComp && !pDepComp->afInstall[g_iSelOpt])
  2978. {
  2979. if (!AddDependencies32(hDlg, szDepID, nComp))
  2980. return FALSE;
  2981. }
  2982. uiIndex++;
  2983. }
  2984. delete pCifComponent_t;
  2985. }
  2986. }
  2987. return TRUE;
  2988. }
  2989. void RemoveSilentDeps32(PCOMPONENT pComp, INT iSelOpt)
  2990. {
  2991. ICifComponent * pCifComponent;
  2992. PCOMPONENT pDepComp;
  2993. UINT uiIndex = 0;
  2994. TCHAR szDepID[32];
  2995. TCHAR tchType;
  2996. if (SUCCEEDED(g_lpCifRWFile->FindComponent(pComp->szSection, &pCifComponent)))
  2997. {
  2998. CCifComponent_t * pCifComponent_t =
  2999. new CCifComponent_t((ICifRWComponent *)pCifComponent);
  3000. while (SUCCEEDED(pCifComponent_t->GetDependency(uiIndex, szDepID, countof(szDepID), &tchType, NULL, NULL)))
  3001. {
  3002. pDepComp = FindComp(szDepID, FALSE);
  3003. if (pDepComp && !pDepComp->fVisible && pDepComp->afInstall[iSelOpt])
  3004. {
  3005. InstallComp(pDepComp, iSelOpt, FALSE);
  3006. RemoveSilentDeps32(pDepComp, iSelOpt);
  3007. }
  3008. uiIndex++;
  3009. }
  3010. delete pCifComponent_t;
  3011. }
  3012. }
  3013. BOOL RemoveDependencies32(HWND hDlg, PCOMPONENT pComp, INT &nComp, BOOL fCust)
  3014. {
  3015. int i, k, j = 0;
  3016. BOOL fAdd;
  3017. TCHAR szCompList[MAX_BUF];
  3018. TCHAR szHeader[MAX_PATH];
  3019. TCHAR szMsgBoxText[MAX_BUF];
  3020. HWND hSource = GetDlgItem(hDlg, IDC_LISTINSTALL);
  3021. HWND hDest = GetDlgItem(hDlg, IDC_LISTAVAIL);
  3022. if (!fCust)
  3023. {
  3024. ZeroMemory(szCompList, sizeof(szCompList));
  3025. StrCat(szCompList, TEXT("\r\n"));
  3026. for (i = 0, j = 0; pComp->paCompRevDeps[i] && (i < 10); i++)
  3027. {
  3028. if (((pComp->paCompRevDeps[i])->fVisible) &&
  3029. ((pComp->paCompRevDeps[i])->afInstall[g_iSelOpt]))
  3030. {
  3031. fAdd = TRUE;
  3032. for (k = 0; pComp->paCompRevDeps[k] && (k < i); k++)
  3033. {
  3034. if (0 == (strcmp((const char*)(pComp->paCompRevDeps[k])->szDisplayName,
  3035. (const char*)(pComp->paCompRevDeps[i])->szDisplayName)))
  3036. fAdd = FALSE;
  3037. }
  3038. if (fAdd)
  3039. {
  3040. StrCat(szCompList, (pComp->paCompRevDeps[i])->szDisplayName);
  3041. StrCat(szCompList, TEXT("\r\n"));
  3042. }
  3043. j++;
  3044. }
  3045. }
  3046. if (j != 0)
  3047. {
  3048. LoadString(g_rvInfo.hInst, IDS_DEPEND_WARNING , szHeader, countof(szHeader));
  3049. wnsprintf(szMsgBoxText, countof(szMsgBoxText), szHeader, pComp->szDisplayName, szCompList);
  3050. }
  3051. }
  3052. if (fCust || (j == 0) || (MessageBox(hDlg, szMsgBoxText, TEXT(""), MB_OKCANCEL) == IDOK))
  3053. {
  3054. InstallComp(pComp, g_iSelOpt, FALSE);
  3055. if (!fCust)
  3056. {
  3057. for (i = 0; pComp->paCompRevDeps[i] && (i < 10); i++)
  3058. {
  3059. InstallComp(pComp->paCompRevDeps[i], g_iSelOpt, FALSE);
  3060. if ((pComp->paCompRevDeps[i])->fVisible)
  3061. {
  3062. if ((j = (int) SendMessage( hSource, LB_FINDSTRINGEXACT, 1, (LPARAM)(pComp->paCompRevDeps[i])->szDisplayName )) != -1 )
  3063. {
  3064. SendMessage( hSource, LB_DELETESTRING, j, 0 );
  3065. SendMessage( hDest, LB_ADDSTRING, 0, (LPARAM) (pComp->paCompRevDeps[i])->szDisplayName );
  3066. nComp--;
  3067. SetLBWidth(GetDlgItem(hDlg, IDC_LISTAVAIL));
  3068. SetLBWidth(GetDlgItem(hDlg, IDC_LISTINSTALL));
  3069. }
  3070. }
  3071. }
  3072. RemoveSilentDeps32(pComp, g_iSelOpt);
  3073. }
  3074. if ((i = (int) SendMessage( hSource, LB_FINDSTRINGEXACT, 1, (LPARAM)pComp->szDisplayName )) != -1 )
  3075. {
  3076. SendMessage( hSource, LB_DELETESTRING, i, 0 );
  3077. SendMessage( hDest, LB_ADDSTRING, 0, (LPARAM) pComp->szDisplayName );
  3078. nComp--;
  3079. SetLBWidth(GetDlgItem(hDlg, IDC_LISTAVAIL));
  3080. SetLBWidth(GetDlgItem(hDlg, IDC_LISTINSTALL));
  3081. }
  3082. }
  3083. else
  3084. return FALSE;
  3085. return TRUE;
  3086. }
  3087. void AddRemoveComponents(HWND hDlg, BOOL fAll, BOOL fAdd)
  3088. {
  3089. HWND hSource = GetDlgItem(hDlg, fAdd ? IDC_LISTAVAIL : IDC_LISTINSTALL);
  3090. HWND hDest = GetDlgItem(hDlg, fAdd ? IDC_LISTINSTALL : IDC_LISTAVAIL);
  3091. TCHAR szCompName[MAX_PATH];
  3092. PCOMPONENT pComp;
  3093. int iComp,iStart;
  3094. int nComp = (int) SendMessage(hSource, LB_GETCOUNT, 0, 0);
  3095. BOOL fCust;
  3096. BOOL fSomeSel = FALSE;
  3097. if(!fAdd)
  3098. {
  3099. iStart=1; //We don't want to remove the browser itself;
  3100. }
  3101. else
  3102. {
  3103. iStart=0;
  3104. }
  3105. if (fAll)
  3106. {
  3107. for (pComp = g_paComp; *pComp->szSection; pComp++)
  3108. {
  3109. pComp->afInstall[g_iSelOpt] = fAdd && (!pComp->fAddOnOnly);
  3110. }
  3111. for (pComp = g_aCustComponents; *pComp->szSection; pComp++ )
  3112. {
  3113. pComp->afInstall[g_iSelOpt] = fAdd;
  3114. }
  3115. }
  3116. for (iComp = iStart; iComp < nComp; iComp++ )
  3117. {
  3118. BOOL fSel = (SendMessage( hSource, LB_GETSEL, iComp, 0 ) > 0) ? TRUE : FALSE;
  3119. if (!fSel && !fAll) continue;
  3120. fSomeSel = TRUE;
  3121. SendMessage( hSource, LB_GETTEXT, iComp, (LPARAM) szCompName );
  3122. if (!fAll)
  3123. {
  3124. pComp = FindVisibleComponentName(szCompName);
  3125. if (!pComp)
  3126. {
  3127. pComp = FindCustComponentName(szCompName);
  3128. fCust = TRUE;
  3129. }
  3130. else
  3131. fCust = FALSE;
  3132. if (pComp)
  3133. {
  3134. if (fAdd)
  3135. {
  3136. AddDependencies32(hDlg, pComp->szSection, nComp);
  3137. iComp = iStart-1;
  3138. }
  3139. else
  3140. {
  3141. if (RemoveDependencies32(hDlg, pComp, nComp, fCust))
  3142. iComp = iStart-1;
  3143. }
  3144. }
  3145. continue;
  3146. }
  3147. SendMessage( hSource, LB_DELETESTRING, iComp, 0 );
  3148. SendMessage( hDest, LB_ADDSTRING, 0, (LPARAM) szCompName );
  3149. iComp--;
  3150. nComp--;
  3151. }
  3152. if (fSomeSel)
  3153. {
  3154. BOOL fEnableAdd = (0 < SendMessage( fAdd ? hSource : hDest, LB_GETCOUNT, 0, 0 ));
  3155. BOOL fEnableRem = (iStart < SendMessage( fAdd ? hDest : hSource, LB_GETCOUNT, 0, 0 ));
  3156. EnableWindow(GetDlgItem(hDlg, IDC_ADDCOMP), fEnableAdd);
  3157. EnableWindow(GetDlgItem(hDlg, IDC_ADDALLCOMP), fEnableAdd);
  3158. EnableWindow(GetDlgItem(hDlg, IDC_REMCOMP), fEnableRem);
  3159. EnableWindow(GetDlgItem(hDlg, IDC_REMALLCOMP), fEnableRem);
  3160. if (fEnableAdd)
  3161. SetFocus(GetDlgItem(hDlg,IDC_LISTINSTALL));
  3162. else
  3163. SetFocus(GetDlgItem(hDlg,IDC_LISTAVAIL));
  3164. }
  3165. SetLBWidth(GetDlgItem(hDlg, IDC_LISTAVAIL));
  3166. SetLBWidth(GetDlgItem(hDlg, IDC_LISTINSTALL));
  3167. }
  3168. DWORD GotRoom(HWND hDlg)
  3169. {
  3170. PCOMPONENT pComp;
  3171. TCHAR szDestRoot[MAX_PATH];
  3172. TCHAR szTempRoot[MAX_PATH];
  3173. int iComp;
  3174. DWORD dwDestMul = 1, dwTempMul = 0;
  3175. DWORD dwDestFree, dwTempFree, dwDestNeed, dwTempNeed;
  3176. if (g_fCD) dwDestMul++;
  3177. if (g_fLAN) dwDestMul++;
  3178. if (g_fBrandingOnly) dwDestMul++;
  3179. StrCpy(szDestRoot, g_szBuildRoot);
  3180. StrCpy(szTempRoot, g_szBuildTemp);
  3181. CharUpper(szDestRoot);
  3182. CharUpper(szTempRoot);
  3183. dwDestFree = GetRootFree(szDestRoot);
  3184. dwTempFree = GetRootFree(szTempRoot);
  3185. dwDestNeed = dwTempNeed = 4096;
  3186. for (pComp = g_paComp; ; pComp++ )
  3187. {
  3188. if (ISNULL(pComp->szSection)) break;
  3189. dwDestNeed += pComp->dwSize * dwDestMul;
  3190. dwTempNeed += pComp->dwSize * dwTempMul;
  3191. }
  3192. for (pComp = g_aCustComponents, iComp = 0; iComp < g_nCustComp ; pComp++, iComp++ )
  3193. {
  3194. DWORD dwSize = FolderSize(pComp->szPath) >> 10;
  3195. dwDestNeed += dwSize * dwDestMul;
  3196. dwTempNeed += dwSize * dwTempMul;
  3197. }
  3198. if (*szDestRoot == *szTempRoot)
  3199. {
  3200. dwDestNeed += dwTempNeed;
  3201. }
  3202. else if (dwTempFree < dwTempNeed)
  3203. {
  3204. TCHAR szTitle[MAX_PATH];
  3205. TCHAR szTemplate[MAX_PATH];
  3206. TCHAR szMsg[MAX_PATH];
  3207. LoadString( g_rvInfo.hInst, IDS_DISKERROR, szTitle, MAX_PATH );
  3208. LoadString( g_rvInfo.hInst, IDS_TEMPDISKMSG2, szTemplate, MAX_PATH );
  3209. wnsprintf(szMsg, countof(szMsg), szTemplate, dwTempFree, dwTempNeed);
  3210. if (MessageBox(hDlg, szMsg, szTitle, MB_OKCANCEL | MB_SETFOREGROUND) == IDCANCEL)
  3211. {
  3212. LoadString( g_rvInfo.hInst, IDS_ERROREXIT, szMsg, countof(szMsg) );
  3213. MessageBox(hDlg, szMsg, szTitle, MB_OK | MB_SETFOREGROUND);
  3214. DoCancel();
  3215. return (DWORD)-1;
  3216. }
  3217. else
  3218. {
  3219. SetWindowLongPtr(hDlg, DWLP_MSGRESULT, -1);
  3220. return (DWORD)-1;
  3221. }
  3222. }
  3223. if (dwDestFree < dwDestNeed)
  3224. {
  3225. TCHAR szTitle[MAX_PATH];
  3226. TCHAR szTemplate[MAX_PATH];
  3227. TCHAR szMsg[MAX_PATH];
  3228. LoadString( g_rvInfo.hInst, IDS_DISKERROR, szTitle, MAX_PATH );
  3229. LoadString( g_rvInfo.hInst, IDS_DESTDISKMSG2, szTemplate, MAX_PATH );
  3230. wnsprintf(szMsg, countof(szMsg), szTemplate, dwDestFree, dwDestNeed);
  3231. if (MessageBox(hDlg, szMsg, szTitle, MB_OKCANCEL | MB_SETFOREGROUND) == IDCANCEL)
  3232. {
  3233. LoadString( g_rvInfo.hInst, IDS_ERROREXIT, szMsg, countof(szMsg) );
  3234. MessageBox(hDlg, szMsg, szTitle, MB_OK | MB_SETFOREGROUND);
  3235. DoCancel();
  3236. return (DWORD)-1;
  3237. }
  3238. else
  3239. {
  3240. SetWindowLongPtr(hDlg, DWLP_MSGRESULT, -1);
  3241. return (DWORD)-1;
  3242. }
  3243. }
  3244. return(0);
  3245. }
  3246. BOOL SaveOption(HWND hDlg, HWND hOptlist)
  3247. {
  3248. TCHAR szOptName[80] = TEXT("");
  3249. TCHAR szOptNameParam[8] = TEXT("0_Name");
  3250. TCHAR szOptDesc[MAX_PATH] = TEXT("");
  3251. TCHAR szOptDescParam[8] = TEXT("0_DESC");
  3252. TCHAR szOptNum[2] = TEXT("0");
  3253. ICifRWMode * pCifRWMode;
  3254. CCifRWMode_t * pCifRWMode_t;
  3255. GetWindowText( hOptlist, szOptName, 80 );
  3256. GetDlgItemText( hDlg, IDC_OPTDESC, szOptDesc, countof(szOptDesc));
  3257. if (ISNULL(szOptName) || ISNULL(szOptDesc))
  3258. {
  3259. ErrorMessageBox(hDlg, IDS_BLANKOPTION);
  3260. return FALSE;
  3261. }
  3262. SendMessage( hOptlist, CB_DELETESTRING, g_iSelOpt, 0L );
  3263. SendMessage( hOptlist, CB_INSERTSTRING, g_iSelOpt, (LPARAM) szOptName);
  3264. SendMessage( hOptlist, CB_SETCURSEL, g_iSelOpt, 0L );
  3265. szOptNum[0] = (TCHAR)(g_iSelOpt + TEXT('0'));
  3266. g_lpCifRWFile->CreateMode(szOptNum, &pCifRWMode);
  3267. pCifRWMode_t = new CCifRWMode_t(pCifRWMode);
  3268. pCifRWMode_t->SetDescription(szOptName);
  3269. pCifRWMode_t->SetDetails(szOptDesc);
  3270. delete pCifRWMode_t;
  3271. return TRUE;
  3272. }
  3273. void ReinitModes(HWND hDlg)
  3274. {
  3275. PCOMPONENT pComp;
  3276. IEnumCifModes * pEnumCifModes;
  3277. INT iComp;
  3278. // delete the cif structure before copying over the versioning cif to the target dir
  3279. if (g_lpCifRWFile)
  3280. {
  3281. delete g_lpCifRWFile;
  3282. g_lpCifRWFile = NULL;
  3283. }
  3284. CopyFile(g_szCifVer, g_szCif, FALSE);
  3285. GetICifRWFileFromFile_t(&g_lpCifRWFile, g_szCif);
  3286. if (g_fOCW)
  3287. {
  3288. g_lpCifRWFile->DeleteMode(TEXT("2"));
  3289. g_lpCifRWFile->Flush();
  3290. }
  3291. // reread the modes for the components from the cif
  3292. for (pComp = g_paComp; *pComp->szSection; pComp++)
  3293. {
  3294. ICifComponent * pCifComponent;
  3295. ZeroMemory(pComp->szModes, sizeof(pComp->szModes));
  3296. ZeroMemory(pComp->afInstall, sizeof(pComp->afInstall));
  3297. if (SUCCEEDED(g_lpCifRWFile->FindComponent(pComp->szSection, &pCifComponent)))
  3298. {
  3299. UINT uiIndex = 0;
  3300. TCHAR szMode[MAX_PATH];
  3301. CCifComponent_t * pCifComponent_t =
  3302. new CCifComponent_t((ICifRWComponent *)pCifComponent);
  3303. while (SUCCEEDED(pCifComponent_t->GetMode(uiIndex, szMode, countof(szMode))))
  3304. {
  3305. pComp->szModes[uiIndex] = szMode[0];
  3306. pComp->afInstall[szMode[0] - TEXT('0')] = TRUE;
  3307. uiIndex++;
  3308. }
  3309. delete pCifComponent_t;
  3310. }
  3311. }
  3312. if (SUCCEEDED(g_lpCifRWFile->EnumModes(&pEnumCifModes,
  3313. PLATFORM_WIN98 | PLATFORM_NT4 | PLATFORM_NT5 | PLATFORM_MILLEN, NULL)))
  3314. {
  3315. ICifMode * pCifMode;
  3316. TCHAR szModeID[64];
  3317. int i = 0;
  3318. while (SUCCEEDED(pEnumCifModes->Next(&pCifMode)))
  3319. {
  3320. CCifMode_t * pCifMode_t = new CCifMode_t((ICifRWMode *)pCifMode);
  3321. pCifMode_t->GetID(szModeID, countof(szModeID));
  3322. g_szAllModes[i] = szModeID[0];
  3323. i++;
  3324. delete pCifMode_t;
  3325. }
  3326. pEnumCifModes->Release();
  3327. g_szAllModes[i] = TEXT('\0');
  3328. }
  3329. g_nModes = lstrlen(g_szAllModes);
  3330. // reset custom components to be in all modes
  3331. for (iComp = 0, pComp = g_aCustComponents; iComp < g_nCustComp; iComp++, pComp++ )
  3332. {
  3333. if (ISNULL(pComp->szSection)) break;
  3334. StrCpy(pComp->szModes, g_szAllModes);
  3335. }
  3336. InitSelection32(hDlg);
  3337. }
  3338. //
  3339. // FUNCTION: ComponentSelect(HWND, UINT, UINT, LONG)
  3340. //
  3341. // PURPOSE: Processes messages for "ComponentSelect" page
  3342. //
  3343. // MESSAGES:
  3344. //
  3345. // WM_INITDIALOG - intializes the page
  3346. // WM_NOTIFY - processes the notifications sent to the page
  3347. // WM_COMMAND - saves the id of the choice selected
  3348. //
  3349. //
  3350. INT_PTR CALLBACK ComponentSelect(
  3351. HWND hDlg,
  3352. UINT message,
  3353. WPARAM wParam,
  3354. LPARAM lParam)
  3355. {
  3356. TCHAR szOptName[80];
  3357. TCHAR szOptTpl[80];
  3358. TCHAR szOptNameParam[8] = TEXT("0_Name");
  3359. TCHAR szOptDesc[160]; // weird limit imposed by size of window control in ie6setup
  3360. TCHAR szOptDescParam[8] = TEXT("0_DESC");
  3361. TCHAR szOptNum[2] = TEXT("0");
  3362. TCHAR szNextNameParam[8] = TEXT("0_Name");
  3363. TCHAR szNextDescParam[8] = TEXT("0_Desc");
  3364. TCHAR szModeNameParm[10] = TEXT("%0_Name%");
  3365. TCHAR szModeDescParm[10] = TEXT("%0_Desc%");
  3366. TCHAR szModeSect[8] = TEXT("0.Win");
  3367. int iComp, iOpt, iNewSel;
  3368. PCOMPONENT pComp;
  3369. TCHAR szModeChar[4] = TEXT("0");
  3370. BOOL s_fFirst = TRUE;
  3371. HWND hOptlist;
  3372. static BOOL s_fEditChange = FALSE;
  3373. switch (message)
  3374. {
  3375. case WM_INITDIALOG:
  3376. g_hWizard = hDlg;
  3377. EnableDBCSChars( hDlg, IDC_LISTAVAIL);
  3378. EnableDBCSChars( hDlg, IDC_LISTINSTALL);
  3379. EnableDBCSChars( hDlg, IDC_OPTLIST);
  3380. EnableDBCSChars( hDlg, IDC_OPTLISTOCW);
  3381. EnableDBCSChars( hDlg, IDC_OPTDESC);
  3382. Edit_LimitText(GetDlgItem(hDlg, IDC_OPTDESC), countof(szOptDesc)-1);
  3383. Edit_LimitText(GetDlgItem(hDlg, IDC_OPTLIST), countof(szOptName)-1);
  3384. break;
  3385. case IDM_BATCHADVANCE:
  3386. DoBatchAdvance(hDlg);
  3387. break;
  3388. case WM_HELP:
  3389. IeakPageHelp(hDlg, g_psp[g_iCurPage].pszTemplate);
  3390. break;
  3391. case WM_COMMAND:
  3392. switch (LOWORD(wParam))
  3393. {
  3394. case IDC_OPTLIST:
  3395. case IDC_OPTLISTOCW:
  3396. switch (HIWORD(wParam))
  3397. {
  3398. case CBN_EDITCHANGE:
  3399. s_fEditChange = TRUE;
  3400. break;
  3401. case CBN_SELENDOK:
  3402. hOptlist = GetDlgItem(hDlg, g_fOCW ? IDC_OPTLISTOCW : IDC_OPTLIST);
  3403. iNewSel = ComboBox_GetCurSel(hOptlist);
  3404. if (s_fEditChange)
  3405. {
  3406. GetWindowText(hOptlist, szOptName, countof(szOptName));
  3407. ComboBox_DeleteString(hOptlist, g_iSelOpt);
  3408. ComboBox_InsertString(hOptlist, g_iSelOpt, szOptName);
  3409. if (!SaveOption(hDlg, hOptlist))
  3410. {
  3411. ComboBox_SetCurSel(hOptlist, g_iSelOpt);
  3412. SetWindowLongPtr(hDlg, DWLP_MSGRESULT, -1);
  3413. break;
  3414. }
  3415. s_fEditChange = FALSE;
  3416. }
  3417. if ((iNewSel != CB_ERR) && (iNewSel != g_iSelOpt))
  3418. {
  3419. g_iSelOpt = iNewSel;
  3420. SetInstallOption(hDlg, g_iSelOpt);
  3421. }
  3422. if (iNewSel < 0) iNewSel = 0;
  3423. ComboBox_SetCurSel(hOptlist, iNewSel);
  3424. break;
  3425. case CBN_DROPDOWN:
  3426. hOptlist = GetDlgItem(hDlg, g_fOCW ? IDC_OPTLISTOCW : IDC_OPTLIST);
  3427. GetWindowText(hOptlist, szOptName, countof(szOptName));
  3428. ComboBox_DeleteString(hOptlist, g_iSelOpt);
  3429. ComboBox_InsertString(hOptlist, g_iSelOpt, szOptName);
  3430. ComboBox_SetCurSel(hOptlist, g_iSelOpt);
  3431. break;
  3432. default:
  3433. return FALSE;
  3434. }
  3435. break;
  3436. case IDC_OPTDESC:
  3437. s_fEditChange = TRUE;
  3438. break;
  3439. case IDC_NEWOPT:
  3440. if (s_fEditChange)
  3441. {
  3442. if (!SaveOption(hDlg, GetDlgItem(hDlg, g_fOCW ? IDC_OPTLISTOCW : IDC_OPTLIST)))
  3443. {
  3444. SetWindowLongPtr(hDlg, DWLP_MSGRESULT, -1);
  3445. break;
  3446. }
  3447. }
  3448. g_iSelOpt = g_nModes++;
  3449. LoadString( g_rvInfo.hInst, IDS_NEWINSTALLOPT, szOptTpl, countof(szOptTpl) );
  3450. *szOptNum = *szOptNameParam = *szModeChar = *szModeSect =
  3451. szModeNameParm[1] = szModeDescParm[1] = (TCHAR)(g_iSelOpt + TEXT('0'));
  3452. wnsprintf(szOptName, countof(szOptName), TEXT("%s %s"), szOptTpl, szOptNum);
  3453. {
  3454. ICifRWMode * pCifRWMode;
  3455. CCifRWMode_t * pCifRWMode_t;
  3456. szOptNum[0] = (TCHAR)(g_iSelOpt + TEXT('0'));
  3457. g_lpCifRWFile->CreateMode(szOptNum, &pCifRWMode);
  3458. pCifRWMode_t = new CCifRWMode_t(pCifRWMode);
  3459. pCifRWMode_t->SetDescription(szOptName);
  3460. delete pCifRWMode_t;
  3461. }
  3462. SendDlgItemMessage( hDlg, g_fOCW ? IDC_OPTLISTOCW : IDC_OPTLIST, CB_ADDSTRING, 0, (LPARAM) szOptName );
  3463. StrCat(g_szAllModes, szModeChar);
  3464. // add custom components to mode by default
  3465. for (iComp = 0, pComp = g_aCustComponents; iComp < g_nCustComp ; iComp++, pComp++ )
  3466. {
  3467. if (ISNULL(pComp->szSection)) break;
  3468. pComp->afInstall[g_nModes-1] = TRUE;
  3469. StrCat(pComp->szModes, szOptNum);
  3470. }
  3471. SetInstallOption(hDlg, g_iSelOpt);
  3472. s_fEditChange = TRUE;
  3473. break;
  3474. case IDC_DELOPT:
  3475. SendDlgItemMessage( hDlg, g_fOCW ? IDC_OPTLISTOCW : IDC_OPTLIST, CB_DELETESTRING, g_iSelOpt, 0 );
  3476. if (g_iSelOpt != (g_nModes - 1))
  3477. {
  3478. ICifRWMode * pCifRWMode;
  3479. CCifRWMode_t * pCifRWMode_t;
  3480. ICifMode * pCifMode;
  3481. CCifMode_t * pCifMode_t;
  3482. TCHAR szOptCurrent[2];
  3483. TCHAR szOptNext[2];
  3484. for (iOpt = g_iSelOpt; iOpt < (g_nModes-1) ; iOpt++ )
  3485. {
  3486. *szNextNameParam = *szNextDescParam = (TCHAR)(iOpt + TEXT('1'));
  3487. *szOptDescParam = *szOptNameParam = (TCHAR)(iOpt + TEXT('0'));
  3488. StrCpy(szOptCurrent, TEXT("0"));
  3489. StrCpy(szOptNext, TEXT("0"));
  3490. szOptCurrent[0] = (TCHAR)(iOpt + TEXT('0'));
  3491. szOptNext[0] = (TCHAR)(iOpt + TEXT('1'));
  3492. g_lpCifRWFile->DeleteMode(szOptCurrent);
  3493. g_lpCifRWFile->CreateMode(szOptCurrent, &pCifRWMode);
  3494. pCifRWMode_t = new CCifRWMode_t(pCifRWMode);
  3495. g_lpCifRWFile->FindMode(szOptNext, &pCifMode);
  3496. pCifMode_t = new CCifMode_t((ICifRWMode *)pCifMode);
  3497. pCifMode_t->GetDescription(szOptName, countof(szOptName));
  3498. pCifRWMode_t->SetDescription(szOptName);
  3499. pCifMode_t->GetDetails(szOptDesc, countof(szOptDesc));
  3500. pCifRWMode_t->SetDetails(szOptDesc);
  3501. delete pCifRWMode_t;
  3502. delete pCifMode_t;
  3503. pCifRWMode_t = NULL;
  3504. pCifMode_t = NULL;
  3505. for (pComp = g_paComp; ; pComp++ )
  3506. {
  3507. if (ISNULL(pComp->szSection)) break;
  3508. pComp->afInstall[iOpt] = pComp->afInstall[iOpt + 1];
  3509. }
  3510. for (iComp = 0, pComp = g_aCustComponents; iComp < g_nCustComp ; iComp++, pComp++ )
  3511. {
  3512. if (ISNULL(pComp->szSection)) break;
  3513. pComp->afInstall[iOpt] = pComp->afInstall[iOpt + 1];
  3514. }
  3515. }
  3516. }
  3517. *szOptDescParam = *szOptNameParam = szOptNum[0] = (TCHAR)((g_nModes-1) + TEXT('0'));
  3518. szOptNum[1] = TEXT('\0');
  3519. g_lpCifRWFile->DeleteMode(szOptNum);
  3520. for (pComp = g_paComp; ; pComp++ )
  3521. {
  3522. if (ISNULL(pComp->szSection)) break;
  3523. pComp->afInstall[g_nModes-1] = FALSE;
  3524. }
  3525. for (iComp = 0, pComp = g_aCustComponents; iComp < g_nCustComp ; iComp++, pComp++ )
  3526. {
  3527. if (ISNULL(pComp->szSection)) break;
  3528. pComp->afInstall[g_nModes-1] = FALSE;
  3529. }
  3530. g_nModes--;
  3531. g_szAllModes[g_nModes] = TEXT('\0');
  3532. if (g_iSelOpt >= g_nModes) g_iSelOpt--;
  3533. SetInstallOption(hDlg, g_iSelOpt);
  3534. break;
  3535. case IDC_ADDCOMP:
  3536. AddRemoveComponents(hDlg, FALSE, TRUE);
  3537. break;
  3538. case IDC_REMCOMP:
  3539. AddRemoveComponents(hDlg, FALSE, FALSE);
  3540. break;
  3541. case IDC_ADDALLCOMP:
  3542. AddRemoveComponents(hDlg, TRUE, TRUE);
  3543. break;
  3544. case IDC_REMALLCOMP:
  3545. AddRemoveComponents(hDlg, TRUE, FALSE);
  3546. break;
  3547. case IDC_RESETCOMPS:
  3548. ReinitModes(hDlg);
  3549. break;
  3550. }
  3551. break;
  3552. case WM_NOTIFY:
  3553. switch (((NMHDR FAR *) lParam)->code)
  3554. {
  3555. case PSN_HELP:
  3556. IeakPageHelp(hDlg, g_psp[g_iCurPage].pszTemplate);
  3557. break;
  3558. case PSN_SETACTIVE:
  3559. SetBannerText(hDlg);
  3560. g_iSelOpt = GetPrivateProfileInt( STRINGS, INSTALLMODE, 0, g_szCustInf );
  3561. if (g_fOCW)
  3562. {
  3563. PCOMPONENT pComp;
  3564. DisableDlgItem(hDlg, IDC_NEWOPT);
  3565. DisableDlgItem(hDlg, IDC_DELOPT);
  3566. ShowWindow(GetDlgItem(hDlg, IDC_OPTLIST), SW_HIDE);
  3567. LoadString(g_rvInfo.hInst, IDS_OCWOPTDESC, szOptDesc, countof(szOptDesc));
  3568. SetWindowText(GetDlgItem(hDlg, IDC_OPTIONTEXT3), szOptDesc);
  3569. // do not offer full mode for OCW
  3570. g_lpCifRWFile->DeleteMode(TEXT("2"));
  3571. g_lpCifRWFile->Flush();
  3572. for (pComp = g_paComp; ; pComp++ )
  3573. {
  3574. if (ISNULL(pComp->szSection)) break;
  3575. pComp->afInstall[2] = FALSE;
  3576. }
  3577. }
  3578. else
  3579. ShowWindow(GetDlgItem(hDlg, IDC_OPTLISTOCW), SW_HIDE);
  3580. if (s_fFirst)
  3581. {
  3582. InitSelection32(hDlg);
  3583. s_fFirst = FALSE;
  3584. }
  3585. PropSheet_SetWizButtons(GetParent(hDlg), PSWIZB_BACK | PSWIZB_NEXT);
  3586. CheckBatchAdvance(hDlg);
  3587. break;
  3588. case PSN_WIZNEXT:
  3589. if (GotRoom(hDlg) != 0) return(TRUE);
  3590. case PSN_WIZBACK:
  3591. if (!g_fBatch)
  3592. {
  3593. CNewCursor cur(IDC_WAIT);
  3594. if (s_fEditChange)
  3595. {
  3596. if (!SaveOption(hDlg, GetDlgItem(hDlg, g_fOCW ? IDC_OPTLISTOCW : IDC_OPTLIST)))
  3597. {
  3598. SetWindowLongPtr(hDlg, DWLP_MSGRESULT, -1);
  3599. break;
  3600. }
  3601. s_fEditChange = FALSE;
  3602. }
  3603. SaveSelection();
  3604. for (iOpt = 0; iOpt < g_nModes ; iOpt++ )
  3605. {
  3606. *szModeChar = *szModeSect = szModeNameParm[1] = szModeDescParm[1] =
  3607. *szOptNameParam = *szOptDescParam = *szOptNum = (TCHAR)(iOpt + TEXT('0'));
  3608. {
  3609. ICifMode * pCifMode;
  3610. CCifMode_t * pCifMode_t;
  3611. g_lpCifRWFile->FindMode(szOptNum, &pCifMode);
  3612. pCifMode_t = new CCifMode_t((ICifRWMode *)pCifMode);
  3613. if (FAILED(pCifMode_t->GetDescription(szOptName, countof(szOptName))) ||
  3614. FAILED(pCifMode_t->GetDetails(szOptDesc, countof(szOptDesc))))
  3615. {
  3616. delete pCifMode_t;
  3617. ErrorMessageBox(hDlg, IDS_BLANKOPTION);
  3618. SetWindowLongPtr(hDlg, DWLP_MSGRESULT, -1);
  3619. break;
  3620. }
  3621. delete pCifMode_t;
  3622. }
  3623. }
  3624. InsFlushChanges(g_szCustInf);
  3625. }
  3626. else
  3627. {
  3628. g_fMailNews95 = FALSE;
  3629. }
  3630. g_iCurPage = PPAGE_COMPSEL;
  3631. EnablePages();
  3632. if (((NMHDR FAR *) lParam)->code == PSN_WIZNEXT) PageNext(hDlg);
  3633. else
  3634. {
  3635. PagePrev(hDlg);
  3636. }
  3637. break;
  3638. case PSN_QUERYCANCEL:
  3639. QueryCancel(hDlg);
  3640. break;
  3641. default:
  3642. return FALSE;
  3643. }
  3644. break;
  3645. default:
  3646. return FALSE;
  3647. }
  3648. return TRUE;
  3649. }
  3650. BOOL InitList(HWND hwnd, UINT id)
  3651. {
  3652. HIMAGELIST himl; // handle of image list
  3653. HBITMAP hbmp; // handle of bitmap
  3654. HWND hwndList;
  3655. LVCOLUMN lvCol;
  3656. hwndList = GetDlgItem(hwnd, id);
  3657. // Create the image list.
  3658. if ((himl = ImageList_Create(CX_BITMAP, CY_BITMAP, 0, NUM_BITMAPS, 0)) == NULL)
  3659. return FALSE;
  3660. hbmp = LoadBitmap(g_rvInfo.hInst, MAKEINTRESOURCE(IDB_UNSELECT));
  3661. ImageList_Add(himl, hbmp, (HBITMAP) NULL);
  3662. DeleteObject(hbmp);
  3663. hbmp = LoadBitmap(g_rvInfo.hInst, MAKEINTRESOURCE(IDB_SELECT));
  3664. ImageList_Add(himl, hbmp, (HBITMAP) NULL);
  3665. DeleteObject(hbmp);
  3666. if (ImageList_GetImageCount(himl) < NUM_BITMAPS)
  3667. return FALSE;
  3668. // Associate the image list with the control.
  3669. ListView_SetImageList(hwndList, himl, LVSIL_SMALL);
  3670. ZeroMemory(&lvCol, sizeof(lvCol));
  3671. lvCol.mask = LVCF_FMT;
  3672. lvCol.fmt = LVCFMT_LEFT;
  3673. lvCol.cx = 280;
  3674. ListView_InsertColumn(hwndList, 0, &lvCol);
  3675. return TRUE;
  3676. }
  3677. void InitHiddenItems(UINT uListId)
  3678. {
  3679. TCHAR szBuf[8];
  3680. PCOMPONENT pComp;
  3681. if (uListId == IDC_COPYCOMP)
  3682. {
  3683. for (pComp = g_aCustComponents; *pComp->szSection; pComp++)
  3684. {
  3685. if (GetPrivateProfileString(IS_NOCOPYCUST, pComp->szGUID, TEXT(""), szBuf, countof(szBuf), g_szCustIns))
  3686. pComp->fNoCopy = TRUE;
  3687. }
  3688. for (pComp = g_paComp; *pComp->szSection; pComp++)
  3689. {
  3690. if (GetPrivateProfileString(IS_NOCOPYCUST, pComp->szGUID, TEXT(""), szBuf, countof(szBuf), g_szCustIns))
  3691. pComp->fNoCopy = TRUE;
  3692. }
  3693. }
  3694. else
  3695. {
  3696. for (pComp = g_aCustComponents; *pComp->szSection; pComp++)
  3697. {
  3698. if ((GetPrivateProfileString(IS_HIDECUST, pComp->szGUID, TEXT(""), szBuf, countof(szBuf), g_szCustIns)
  3699. && (*szBuf == TEXT('1'))) || (ISNULL(szBuf) && !AnySelection(pComp)))
  3700. pComp->fCustomHide = TRUE;
  3701. }
  3702. for (pComp = g_paComp; *pComp->szSection; pComp++)
  3703. {
  3704. if (pComp->fAddOnOnly ||
  3705. (GetPrivateProfileString(IS_HIDECUST, pComp->szGUID, TEXT(""), szBuf, countof(szBuf), g_szCustIns)
  3706. && (*szBuf == TEXT('1'))) || (ISNULL(szBuf) && !AnySelection(pComp)))
  3707. pComp->fCustomHide = TRUE;
  3708. }
  3709. }
  3710. }
  3711. // BUGBUG: <oliverl> should probably persist this server side only info in a server side file for IEAK6
  3712. void SaveHiddenItems(UINT uListId)
  3713. {
  3714. PCOMPONENT pComp;
  3715. if (uListId == IDC_COPYCOMP)
  3716. {
  3717. for (pComp = g_aCustComponents; *pComp->szSection; pComp++)
  3718. WritePrivateProfileString(IS_NOCOPYCUST, pComp->szGUID, pComp->fNoCopy ? TEXT("1") : NULL, g_szCustIns);
  3719. for (pComp = g_paComp; *pComp->szSection; pComp++)
  3720. WritePrivateProfileString(IS_NOCOPYCUST, pComp->szGUID, pComp->fNoCopy ? TEXT("1") : NULL, g_szCustIns);
  3721. }
  3722. else
  3723. {
  3724. for (pComp = g_aCustComponents; *pComp->szSection; pComp++)
  3725. WritePrivateProfileString(IS_HIDECUST, pComp->szGUID, pComp->fCustomHide ? TEXT("1") : TEXT("0"), g_szCustIns);
  3726. for (pComp = g_paComp; *pComp->szSection; pComp++)
  3727. WritePrivateProfileString(IS_HIDECUST, pComp->szGUID, (pComp->fCustomHide && !pComp->fAddOnOnly) ? TEXT("1") : TEXT("0"), g_szCustIns);
  3728. }
  3729. }
  3730. BOOL AddItemToList(PCOMPONENT pComp, HWND hDlg, UINT uListID, int& iItem)
  3731. {
  3732. LVITEM lvItem;
  3733. LVFINDINFO lvFind;
  3734. TCHAR szStatus[64];
  3735. HWND hwndList = GetDlgItem(hDlg, uListID);
  3736. if ((uListID == IDC_COPYCOMP) &&
  3737. (AnySelection(pComp) || (!pComp->fCustomHide)))
  3738. return FALSE;
  3739. ZeroMemory(&lvItem, sizeof(lvItem));
  3740. lvItem.mask = LVIF_TEXT | LVIF_IMAGE;
  3741. lvItem.iItem = iItem;
  3742. lvItem.pszText = pComp->szDisplayName;
  3743. if (uListID == IDC_COPYCOMP)
  3744. lvItem.iImage = pComp->fNoCopy ? 0 : 1;
  3745. else
  3746. lvItem.iImage = pComp->fCustomHide ? 0 : 1;
  3747. ZeroMemory(&lvFind, sizeof(lvFind));
  3748. lvFind.flags = LVFI_STRING;
  3749. lvFind.psz = pComp->szDisplayName;
  3750. if (ListView_FindItem(hwndList, -1, &lvFind) == -1)
  3751. {
  3752. ListView_InsertItem(hwndList, &lvItem);
  3753. if (uListID == IDC_HIDECOMP)
  3754. {
  3755. if (pComp->fCustomHide)
  3756. {
  3757. if (AnySelection(pComp))
  3758. LoadString(g_rvInfo.hInst, IDS_STATUSFORCE, szStatus, countof(szStatus));
  3759. else
  3760. LoadString(g_rvInfo.hInst, IDS_STATUSNOSHOW, szStatus, countof(szStatus));
  3761. }
  3762. else
  3763. LoadString(g_rvInfo.hInst, IDS_STATUSSHOW, szStatus, countof(szStatus));
  3764. ListView_SetItemText(hwndList, iItem, 1, szStatus);
  3765. }
  3766. iItem++;
  3767. }
  3768. return TRUE;
  3769. }
  3770. BOOL InitListControl(HWND hDlg, UINT uListID, BOOL fInit)
  3771. {
  3772. HWND hwndList = GetDlgItem(hDlg, uListID);
  3773. PCOMPONENT pComp;
  3774. LV_COLUMN lvCol;
  3775. TCHAR szHeader[MAX_PATH];
  3776. int iItem = 0;
  3777. BOOL bRet = FALSE;
  3778. ListView_DeleteAllItems(hwndList);
  3779. if (uListID == IDC_HIDECOMP)
  3780. {
  3781. ListView_DeleteColumn(hwndList, 1);
  3782. ListView_DeleteColumn(hwndList, 0);
  3783. }
  3784. if (!fInit)
  3785. return TRUE;
  3786. if (uListID == IDC_HIDECOMP)
  3787. {
  3788. ZeroMemory(&lvCol, sizeof(lvCol));
  3789. lvCol.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT;
  3790. lvCol.fmt = LVCFMT_LEFT;
  3791. lvCol.cx = 280;
  3792. LoadString(g_rvInfo.hInst, IDS_COMPNAME, szHeader, countof(szHeader));
  3793. lvCol.pszText = szHeader;
  3794. ListView_InsertColumn(hwndList, 0, &lvCol);
  3795. ZeroMemory(&lvCol, sizeof(lvCol));
  3796. lvCol.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT;
  3797. lvCol.fmt = LVCFMT_LEFT;
  3798. lvCol.cx = 140;
  3799. LoadString(g_rvInfo.hInst, IDS_STATUS, szHeader, countof(szHeader));
  3800. lvCol.pszText = szHeader;
  3801. ListView_InsertColumn(hwndList, 1, &lvCol);
  3802. }
  3803. for (pComp = g_paComp; *pComp->szSection; pComp++)
  3804. {
  3805. if ((pComp->iImage != RED) && pComp->fVisible && !pComp->fAddOnOnly &&
  3806. ((pComp->iCompType != COMP_OPTIONAL) ||
  3807. ((pComp->iCompType == COMP_OPTIONAL) && (pComp->iPlatform <= PLAT_W98))) &&
  3808. (StrCmpI(pComp->szSection, TEXT("DCOM95")) != 0)) // dcom should always be hidden in custom mode
  3809. bRet |= AddItemToList(pComp, hDlg, uListID, iItem);
  3810. }
  3811. for (pComp = g_aCustComponents; *pComp->szSection; pComp++)
  3812. bRet |= AddItemToList(pComp, hDlg, uListID, iItem);
  3813. ListView_SetColumnWidth(hwndList, 0, LVSCW_AUTOSIZE);
  3814. return bRet;
  3815. }
  3816. void CheckItem(HWND hDlg, UINT uListID, LVITEM * plvItem, int iCheck)
  3817. {
  3818. HWND hwndList = GetDlgItem(hDlg, uListID);
  3819. PCOMPONENT pComp;
  3820. BOOL fFound = FALSE;
  3821. BOOL fCustomHide = FALSE;
  3822. BOOL fForce = FALSE;
  3823. for (pComp = g_aCustComponents; *pComp->szSection; pComp++)
  3824. {
  3825. if (StrCmpI(plvItem->pszText, pComp->szDisplayName) == 0)
  3826. {
  3827. fForce = AnySelection(pComp);
  3828. if (uListID == IDC_COPYCOMP)
  3829. fCustomHide = (pComp->fNoCopy = ((iCheck == -1) ? !pComp->fNoCopy : (iCheck == 0)));
  3830. else
  3831. fCustomHide = (pComp->fCustomHide = ((iCheck == -1) ? !pComp->fCustomHide : (iCheck == 0)));
  3832. fFound = TRUE;
  3833. break;
  3834. }
  3835. }
  3836. if (!fFound)
  3837. {
  3838. for (pComp = g_paComp; *pComp->szSection; pComp++)
  3839. {
  3840. if (StrCmpI(plvItem->pszText, pComp->szDisplayName) == 0)
  3841. {
  3842. fForce = AnySelection(pComp);
  3843. if (uListID == IDC_COPYCOMP)
  3844. fCustomHide = (pComp->fNoCopy = ((iCheck == -1) ? !pComp->fNoCopy : (iCheck == 0)));
  3845. else
  3846. fCustomHide = (pComp->fCustomHide = ((iCheck == -1) ? !pComp->fCustomHide : (iCheck == 0)));
  3847. }
  3848. }
  3849. }
  3850. plvItem->mask = LVIF_IMAGE;
  3851. plvItem->iImage = fCustomHide ? 0 : 1;
  3852. ListView_SetItem(hwndList, plvItem);
  3853. if (uListID == IDC_HIDECOMP)
  3854. {
  3855. TCHAR szStatus[64];
  3856. if (fCustomHide)
  3857. {
  3858. if (fForce)
  3859. LoadString(g_rvInfo.hInst, IDS_STATUSFORCE, szStatus, countof(szStatus));
  3860. else
  3861. LoadString(g_rvInfo.hInst, IDS_STATUSNOSHOW, szStatus, countof(szStatus));
  3862. }
  3863. else
  3864. LoadString(g_rvInfo.hInst, IDS_STATUSSHOW, szStatus, countof(szStatus));
  3865. ListView_SetItemText(hwndList, plvItem->iItem, 1, szStatus);
  3866. }
  3867. }
  3868. void MaintToggleCheckItem(HWND hDlg, UINT uListID, int iItem)
  3869. {
  3870. LVITEM lvItem;
  3871. TCHAR szDisplayName[MAX_PATH];
  3872. ZeroMemory(&lvItem, sizeof(lvItem));
  3873. lvItem.iItem = iItem;
  3874. lvItem.pszText = szDisplayName;
  3875. lvItem.cchTextMax = countof(szDisplayName);
  3876. lvItem.mask = LVIF_TEXT;
  3877. if (ListView_GetItem(GetDlgItem(hDlg, uListID), &lvItem))
  3878. {
  3879. CheckItem(hDlg, uListID, &lvItem, -1);
  3880. }
  3881. }
  3882. void ListViewSelectAll(HWND hDlg, UINT uListID, BOOL fSet)
  3883. {
  3884. HWND hwndList = GetDlgItem(hDlg, uListID);
  3885. LVITEM lvItem;
  3886. TCHAR szDisplayName[MAX_PATH];
  3887. DWORD dwNumItems, dwIndex;
  3888. dwNumItems = ListView_GetItemCount(hwndList);
  3889. for (dwIndex=0; dwIndex < dwNumItems; dwIndex++)
  3890. {
  3891. lvItem.mask = LVIF_TEXT;
  3892. lvItem.iItem = (int) dwIndex;
  3893. lvItem.iSubItem = 0;
  3894. ZeroMemory(szDisplayName, sizeof(szDisplayName));
  3895. lvItem.pszText = szDisplayName;
  3896. lvItem.cchTextMax = countof(szDisplayName);
  3897. ListView_GetItem(hwndList, &lvItem);
  3898. CheckItem(hDlg, uListID, &lvItem, fSet ? 1 : 0);
  3899. }
  3900. }
  3901. //
  3902. // FUNCTION: CustomizeCustom(HWND, UINT, UINT, LONG)
  3903. //
  3904. // PURPOSE: Processes messages for "Customize Custom" page
  3905. //
  3906. // MESSAGES:
  3907. //
  3908. // WM_INITDIALOG - intializes the page
  3909. // WM_NOTIFY - processes the notifications sent to the page
  3910. // WM_COMMAND - saves the id of the choice selected
  3911. //
  3912. INT_PTR CALLBACK CustomizeCustom(
  3913. HWND hDlg,
  3914. UINT message,
  3915. WPARAM wParam,
  3916. LPARAM lParam)
  3917. {
  3918. HWND hwndList = GetDlgItem(hDlg, IDC_HIDECOMP);
  3919. int iItem;
  3920. switch (message)
  3921. {
  3922. case WM_INITDIALOG:
  3923. EnableDBCSChars(hDlg, IDC_HIDECOMP);
  3924. InitList(hDlg, IDC_HIDECOMP);
  3925. break;
  3926. case IDM_BATCHADVANCE:
  3927. DoBatchAdvance(hDlg);
  3928. break;
  3929. case WM_HELP:
  3930. IeakPageHelp(hDlg, g_psp[g_iCurPage].pszTemplate);
  3931. break;
  3932. case WM_COMMAND:
  3933. if (HIWORD(wParam) == BN_CLICKED)
  3934. {
  3935. switch (LOWORD(wParam))
  3936. {
  3937. case IDC_HIDECHECKALL:
  3938. ListViewSelectAll(hDlg, IDC_HIDECOMP, TRUE);
  3939. break;
  3940. case IDC_HIDEUNCHECKALL:
  3941. ListViewSelectAll(hDlg, IDC_HIDECOMP, FALSE);
  3942. break;
  3943. }
  3944. }
  3945. break;
  3946. case WM_NOTIFY:
  3947. switch (((NMHDR FAR *) lParam)->code)
  3948. {
  3949. case LVN_KEYDOWN:
  3950. {
  3951. NMLVKEYDOWN *pnm = (NMLVKEYDOWN*) lParam;
  3952. if ( pnm->wVKey == VK_SPACE )
  3953. {
  3954. iItem = ListView_GetSelectionMark(hwndList);
  3955. MaintToggleCheckItem(hDlg, IDC_HIDECOMP, iItem);
  3956. }
  3957. break;
  3958. }
  3959. case NM_CLICK:
  3960. {
  3961. POINT pointScreen, pointLVClient;
  3962. DWORD dwPos;
  3963. LVHITTESTINFO HitTest;
  3964. dwPos = GetMessagePos();
  3965. pointScreen.x = LOWORD (dwPos);
  3966. pointScreen.y = HIWORD (dwPos);
  3967. pointLVClient = pointScreen;
  3968. // Convert the point from screen to client coordinates,
  3969. // relative to the Listview
  3970. ScreenToClient (hwndList, &pointLVClient);
  3971. HitTest.pt = pointLVClient;
  3972. ListView_HitTest(hwndList, &HitTest);
  3973. // Only if the user clicked on the checkbox icon/bitmap, change
  3974. if (HitTest.flags == LVHT_ONITEMICON)
  3975. MaintToggleCheckItem(hDlg, IDC_HIDECOMP, HitTest.iItem);
  3976. }
  3977. break;
  3978. case NM_DBLCLK:
  3979. if ( ((LPNMHDR)lParam)->idFrom == IDC_HIDECOMP)
  3980. {
  3981. iItem = ListView_GetSelectionMark(hwndList);
  3982. MaintToggleCheckItem(hDlg, IDC_HIDECOMP, iItem);
  3983. }
  3984. break;
  3985. case PSN_HELP:
  3986. IeakPageHelp(hDlg, g_psp[g_iCurPage].pszTemplate);
  3987. break;
  3988. case PSN_SETACTIVE:
  3989. SetBannerText(hDlg);
  3990. if (!g_fBatch)
  3991. {
  3992. BOOL fEnable = (!g_fSilent && !g_fStealth && !GetPrivateProfileInt(IS_BRANDING, TEXT("HideCustom"), 0, g_szCustIns));
  3993. EnableDlgItem2(hDlg, IDC_HIDECOMP, fEnable);
  3994. EnableDlgItem2(hDlg, IDC_HIDECHECKALL, fEnable);
  3995. EnableDlgItem2(hDlg, IDC_HIDEUNCHECKALL, fEnable);
  3996. InitHiddenItems(IDC_HIDECOMP);
  3997. InitListControl(hDlg, IDC_HIDECOMP, fEnable);
  3998. EnableDlgItem2(hDlg, IDC_WEBDLOPT, g_fDownload);
  3999. if (g_fDownload)
  4000. {
  4001. CheckDlgButton(hDlg, IDC_WEBDLOPT,
  4002. GetPrivateProfileInt(BRANDING, TEXT("NoIELite"), 1, g_szCustIns) ? BST_UNCHECKED : BST_CHECKED);
  4003. }
  4004. }
  4005. CheckBatchAdvance(hDlg);
  4006. break;
  4007. case PSN_WIZNEXT:
  4008. case PSN_WIZBACK:
  4009. if (!g_fBatch)
  4010. {
  4011. BOOL fNoIELite;
  4012. SaveHiddenItems(IDC_HIDECOMP);
  4013. if (g_fDownload)
  4014. {
  4015. fNoIELite = (IsDlgButtonChecked(hDlg, IDC_WEBDLOPT) == BST_CHECKED) ? FALSE : TRUE;
  4016. WritePrivateProfileString(BRANDING, TEXT("NoIELite"),
  4017. fNoIELite ? TEXT("1") : TEXT("0"), g_szCustIns);
  4018. }
  4019. }
  4020. g_iCurPage = PPAGE_CUSTOMCUSTOM;
  4021. EnablePages();
  4022. if (((NMHDR FAR *) lParam)->code == PSN_WIZNEXT) PageNext(hDlg);
  4023. else
  4024. {
  4025. PagePrev(hDlg);
  4026. }
  4027. break;
  4028. case PSN_QUERYCANCEL:
  4029. QueryCancel(hDlg);
  4030. break;
  4031. default:
  4032. return FALSE;
  4033. }
  4034. break;
  4035. case WM_LV_GETITEMS:
  4036. LVGetItems(GetDlgItem(hDlg, IDC_HIDECOMP));
  4037. break;
  4038. default:
  4039. return FALSE;
  4040. }
  4041. return TRUE;
  4042. }
  4043. //
  4044. // FUNCTION: CopyComp(HWND, UINT, WPARAM, LPARAM)
  4045. //
  4046. // PURPOSE: Processes messages for "Copy Custom" page
  4047. //
  4048. // MESSAGES:
  4049. //
  4050. // WM_INITDIALOG - intializes the page
  4051. // WM_NOTIFY - processes the notifications sent to the page
  4052. // WM_COMMAND - saves the id of the choice selected
  4053. //
  4054. INT_PTR CALLBACK CopyComp(
  4055. HWND hDlg,
  4056. UINT message,
  4057. WPARAM wParam,
  4058. LPARAM lParam)
  4059. {
  4060. HWND hwndList = GetDlgItem(hDlg, IDC_COPYCOMP);
  4061. static BOOL s_fNext = TRUE;
  4062. int iItem;
  4063. switch (message)
  4064. {
  4065. case WM_INITDIALOG:
  4066. EnableDBCSChars(hDlg, IDC_COPYCOMP);
  4067. InitList(hDlg, IDC_COPYCOMP);
  4068. break;
  4069. case IDM_BATCHADVANCE:
  4070. DoBatchAdvance(hDlg);
  4071. break;
  4072. case WM_HELP:
  4073. IeakPageHelp(hDlg, g_psp[g_iCurPage].pszTemplate);
  4074. break;
  4075. case WM_COMMAND:
  4076. if (HIWORD(wParam) == BN_CLICKED)
  4077. {
  4078. switch (LOWORD(wParam))
  4079. {
  4080. case IDC_COPYCHECKALL:
  4081. ListViewSelectAll(hDlg, IDC_COPYCOMP, TRUE);
  4082. break;
  4083. case IDC_COPYUNCHECKALL:
  4084. ListViewSelectAll(hDlg, IDC_COPYCOMP, FALSE);
  4085. break;
  4086. }
  4087. }
  4088. break;
  4089. case WM_NOTIFY:
  4090. switch (((NMHDR FAR *) lParam)->code)
  4091. {
  4092. case LVN_KEYDOWN:
  4093. {
  4094. NMLVKEYDOWN *pnm = (NMLVKEYDOWN*) lParam;
  4095. if ( pnm->wVKey == VK_SPACE )
  4096. {
  4097. iItem = ListView_GetSelectionMark(hwndList);
  4098. MaintToggleCheckItem(hDlg, IDC_COPYCOMP, iItem);
  4099. }
  4100. break;
  4101. }
  4102. case NM_CLICK:
  4103. {
  4104. POINT pointScreen, pointLVClient;
  4105. DWORD dwPos;
  4106. LVHITTESTINFO HitTest;
  4107. dwPos = GetMessagePos();
  4108. pointScreen.x = LOWORD (dwPos);
  4109. pointScreen.y = HIWORD (dwPos);
  4110. pointLVClient = pointScreen;
  4111. // Convert the point from screen to client coordinates,
  4112. // relative to the Listview
  4113. ScreenToClient (hwndList, &pointLVClient);
  4114. HitTest.pt = pointLVClient;
  4115. ListView_HitTest(hwndList, &HitTest);
  4116. // Only if the user clicked on the checkbox icon/bitmap, change
  4117. if (HitTest.flags == LVHT_ONITEMICON)
  4118. MaintToggleCheckItem(hDlg, IDC_COPYCOMP, HitTest.iItem);
  4119. }
  4120. break;
  4121. case NM_DBLCLK:
  4122. if ( ((LPNMHDR)lParam)->idFrom == IDC_COPYCOMP)
  4123. {
  4124. iItem = ListView_GetSelectionMark(hwndList);
  4125. MaintToggleCheckItem(hDlg, IDC_COPYCOMP, iItem);
  4126. }
  4127. break;
  4128. case PSN_HELP:
  4129. IeakPageHelp(hDlg, g_psp[g_iCurPage].pszTemplate);
  4130. break;
  4131. case PSN_SETACTIVE:
  4132. SetBannerText(hDlg);
  4133. if (!g_fBatch)
  4134. {
  4135. InitHiddenItems(IDC_COPYCOMP);
  4136. if (!g_fDownload && (g_fSilent || g_fStealth || InsGetBool(IS_BRANDING, TEXT("HideCustom"), FALSE, g_szCustIns)))
  4137. InitHiddenItems(IDC_HIDECOMP);
  4138. if (!InitListControl(hDlg, IDC_COPYCOMP, TRUE))
  4139. {
  4140. if (s_fNext)
  4141. PostMessage(GetParent(hDlg), PSM_PRESSBUTTON, PSBTN_NEXT, 0);
  4142. else
  4143. PostMessage(GetParent(hDlg), PSM_PRESSBUTTON, PSBTN_BACK, 0);
  4144. }
  4145. }
  4146. CheckBatchAdvance(hDlg);
  4147. break;
  4148. case PSN_WIZNEXT:
  4149. case PSN_WIZBACK:
  4150. if (!g_fBatch)
  4151. SaveHiddenItems(IDC_COPYCOMP);
  4152. g_iCurPage = PPAGE_COPYCOMP;
  4153. EnablePages();
  4154. if (((NMHDR FAR *) lParam)->code == PSN_WIZNEXT)
  4155. {
  4156. s_fNext = FALSE;
  4157. PageNext(hDlg);
  4158. }
  4159. else
  4160. {
  4161. s_fNext = TRUE;
  4162. PagePrev(hDlg);
  4163. }
  4164. break;
  4165. case PSN_QUERYCANCEL:
  4166. QueryCancel(hDlg);
  4167. break;
  4168. default:
  4169. return FALSE;
  4170. }
  4171. break;
  4172. case WM_LV_GETITEMS:
  4173. LVGetItems(GetDlgItem(hDlg, IDC_COPYCOMP));
  4174. break;
  4175. default:
  4176. return FALSE;
  4177. }
  4178. return TRUE;
  4179. }
  4180. BOOL g_fUrlsInit = FALSE;
  4181. static IDownloadSiteMgr * s_pSiteMgr = NULL;
  4182. static int s_aiSites[NUMSITES];
  4183. static BOOL s_fInChange = FALSE;
  4184. void SetCustSite(HWND hDlg, int iSite)
  4185. {
  4186. PSITEDATA psd = &g_aCustSites[iSite];
  4187. HWND hBaseUList = GetDlgItem(hDlg, IDC_BASEURLLIST);
  4188. LV_ITEM lvItem;
  4189. s_fInChange = TRUE;
  4190. ZeroMemory(&lvItem, sizeof(lvItem));
  4191. lvItem.mask = LVIF_TEXT;
  4192. lvItem.iItem = iSite;
  4193. lvItem.pszText = psd->szName;
  4194. ListView_SetItem(hBaseUList, &lvItem);
  4195. lvItem.iSubItem = 1;
  4196. lvItem.pszText = psd->szUrl;
  4197. ListView_SetItem(hBaseUList, &lvItem);
  4198. lvItem.pszText = psd->szRegion;
  4199. lvItem.iSubItem = 2;
  4200. ListView_SetItem(hBaseUList, &lvItem);
  4201. s_fInChange = FALSE;
  4202. }
  4203. void CopyAdmFiles()
  4204. {
  4205. TCHAR szAdmSrcPath[MAX_PATH];
  4206. TCHAR szAdmSrcFile[MAX_PATH];
  4207. TCHAR szAdmDestFile[MAX_PATH];
  4208. HANDLE hFind = NULL;
  4209. WIN32_FIND_DATA wfdFind;
  4210. BOOL bDirCreated = FALSE;
  4211. PathCombine(szAdmSrcPath, g_szWizRoot, TEXT("iebin"));
  4212. PathAppend(szAdmSrcPath, g_szLanguage);
  4213. PathAppend(szAdmSrcPath, TEXT("optional"));
  4214. PathAppend(szAdmSrcPath, TEXT("*.adm"));
  4215. hFind = FindFirstFile( szAdmSrcPath, &wfdFind );
  4216. if( hFind == INVALID_HANDLE_VALUE )
  4217. return;
  4218. do
  4219. {
  4220. StrCpy(szAdmSrcFile, szAdmSrcPath);
  4221. PathRemoveFileSpec(szAdmSrcFile);
  4222. PathAppend(szAdmSrcFile, wfdFind.cFileName);
  4223. PathCombine(szAdmDestFile, g_szWizRoot, TEXT("policies"));
  4224. PathAppend(szAdmDestFile, g_szLanguage);
  4225. if(!bDirCreated)
  4226. {
  4227. PathCreatePath(szAdmDestFile);
  4228. bDirCreated = TRUE;
  4229. }
  4230. PathAppend(szAdmDestFile, wfdFind.cFileName);
  4231. CopyFile(szAdmSrcFile, szAdmDestFile, FALSE);
  4232. DeleteFile(szAdmSrcFile);
  4233. }while( FindNextFile( hFind, &wfdFind ));
  4234. FindClose(hFind);
  4235. }
  4236. void SaveDownloadUrls()
  4237. {
  4238. int iBase = s_aiSites[0];
  4239. TCHAR szIEAKCabUrl[MAX_URL];
  4240. TCHAR szCabPath[MAX_PATH];
  4241. BOOL fDownloadOpt = TRUE;
  4242. BOOL fIgnore = FALSE;
  4243. static BOOL s_fFirst = TRUE;
  4244. TCHAR szVersionNew[32];
  4245. TCHAR szOptIniFile[MAX_PATH];
  4246. s_fNoNet = FALSE;
  4247. ICifComponent * pCifComponent;
  4248. ResetEvent(g_hProcessInfEvent);
  4249. if (!g_fBatch2)
  4250. {
  4251. if (s_pSiteMgr)
  4252. {
  4253. DOWNLOADSITE *pSite;
  4254. IDownloadSite *pISite;
  4255. TCHAR szLang[8];
  4256. for (int i=0; i<NUMSITES; i++)
  4257. {
  4258. s_pSiteMgr->EnumSites(i, &pISite);
  4259. if (!pISite) break;
  4260. pISite->GetData(&pSite);
  4261. A2Tbux(pSite->pszLang, szLang);
  4262. if (0 == StrCmpI(szLang, g_szActLang)) {
  4263. A2Tbux(pSite->pszUrl, g_szBaseURL);
  4264. break;
  4265. }
  4266. pISite->Release();
  4267. }
  4268. }
  4269. PathCombine(g_szMastInf, g_szWizRoot, TEXT("iebin"));
  4270. PathAppend(g_szMastInf, g_szLanguage);
  4271. PathAppend(g_szMastInf, TEXT("Optional"));
  4272. PathCreatePath(g_szMastInf);
  4273. PathRemoveBackslash(g_szMastInf);
  4274. }
  4275. // wait for cif to be downloaded so we can check version
  4276. while (MsgWaitForMultipleObjects(1, &g_hCifEvent, FALSE, INFINITE, QS_ALLINPUT) != WAIT_OBJECT_0)
  4277. {
  4278. MSG msg;
  4279. while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
  4280. {
  4281. TranslateMessage(&msg);
  4282. DispatchMessage(&msg);
  4283. }
  4284. }
  4285. if (g_lpCifFileNew != NULL)
  4286. {
  4287. if (!g_fLocalMode)
  4288. {
  4289. // check version before downloading opt cab
  4290. if (SUCCEEDED(g_lpCifFileNew->FindComponent(TEXT("IEAK6OPT"), &pCifComponent)))
  4291. {
  4292. DWORD dwVer, dwBuild;
  4293. TCHAR szVersion[32];
  4294. PathCombine(szOptIniFile, g_szMastInf, TEXT("ieak6opt.ini"));
  4295. pCifComponent->GetVersion(&dwVer, &dwBuild);
  4296. ConvertDwordsToVersionStr(szVersionNew, dwVer, dwBuild);
  4297. GetPrivateProfileString(TEXT("ieak6OPT"), VERSION, TEXT("-1"), szVersion, countof(szVersion), szOptIniFile);
  4298. if ((StrCmp(szVersion, TEXT("-1")) != 0) &&
  4299. (StrCmpI(szVersion, szVersionNew) == 0)) // is opt cab up to date ?
  4300. fDownloadOpt = FALSE;
  4301. }
  4302. }
  4303. }
  4304. if (!g_fLocalMode && s_fFirst)
  4305. {
  4306. s_fFirst = FALSE;
  4307. wnsprintf(szIEAKCabUrl, countof(szIEAKCabUrl), TEXT("%s/ieak6opt.cab"), g_szBaseURL);
  4308. PathCombine(szCabPath, g_szBuildTemp, TEXT("ieak6opt.cab"));
  4309. if (fDownloadOpt)
  4310. {
  4311. // if we are attempting to download the opt cab, delete iesetup.inf in the opt dir
  4312. // first and we'll use this as a flag to determine whether or not download &
  4313. // extraction succeeded
  4314. // Also delete ieak6opt.ini. In case the download fails, this will force a download
  4315. // next time ieak runs. Otherwise iesetup.inf never get created.
  4316. // See bug 13467-IEv60
  4317. DeleteFileInDir(TEXT("iesetup.inf"), g_szMastInf);
  4318. DeleteFileInDir(TEXT("ieak6opt.ini"), g_szMastInf);
  4319. if (DownloadCab(g_hWizard, szIEAKCabUrl, szCabPath, NULL, 0, fIgnore) == NOERROR)
  4320. {
  4321. if (ExtractFilesWrap(szCabPath, g_szMastInf, 0, NULL, NULL, 0) != NOERROR)
  4322. DeleteFileInDir(TEXT("iesetup.inf"), g_szMastInf);
  4323. else
  4324. {
  4325. SetCurrentDirectory( g_szMastInf);
  4326. SetAttribAllEx(g_szMastInf, TEXT("*.*"), FILE_ATTRIBUTE_NORMAL, TRUE);
  4327. CopyAdmFiles();
  4328. WritePrivateProfileString(TEXT("ieak6OPT"), VERSION, szVersionNew, szOptIniFile);
  4329. }
  4330. // delete the downloaded ieak6opt.cab from the temp dir so we don't copy
  4331. // it to the target folder during the build process later
  4332. DeleteFile(szCabPath);
  4333. }
  4334. }
  4335. }
  4336. PathCombine(g_szDefInf, g_szMastInf, TEXT("DefFav.inf"));
  4337. PathAppend(g_szMastInf, TEXT("IeSetup.Inf"));
  4338. PathCombine(g_szCustInf, g_szBuildRoot, TEXT("INS"));
  4339. PathAppend(g_szCustInf, GetOutputPlatformDir());
  4340. PathAppend(g_szCustInf, g_szLanguage);
  4341. PathAppend(g_szCustInf, TEXT("IESetup.inf"));
  4342. if (GetFileAttributes(g_szCustInf) == 0xFFFFFFFF)
  4343. {
  4344. CopyFile(g_szMastInf, g_szCustInf, FALSE);
  4345. }
  4346. else
  4347. {
  4348. UpdateInf(g_szMastInf, g_szCustInf);
  4349. }
  4350. SetEvent(g_hProcessInfEvent);
  4351. }
  4352. void GetSiteDataPath(void)
  4353. {
  4354. TCHAR szIEAKIni[MAX_PATH];
  4355. PathCombine(szIEAKIni, g_szWizRoot, TEXT("ieak.ini"));
  4356. switch (g_dwPlatformId)
  4357. {
  4358. case PLATFORM_WIN32:
  4359. default:
  4360. GetPrivateProfileString(TEXT("IEAK"), TEXT("Win32"), TEXT(""), s_szSiteData, countof(s_szSiteData), szIEAKIni);
  4361. break;
  4362. }
  4363. }
  4364. void IE4BatchSetup()
  4365. {
  4366. TCHAR szSectBuf[1024];
  4367. TCHAR szSrcCustInf[MAX_PATH];
  4368. DWORD sWrk, sCif;
  4369. PCOMPONENT pComp;
  4370. HANDLE hFind;
  4371. WIN32_FIND_DATA fd;
  4372. LPTSTR pBack;
  4373. int nComp;
  4374. PathCombine(g_szCustInf, g_szBuildRoot, TEXT("INS"));
  4375. PathAppend(g_szCustInf, GetOutputPlatformDir());
  4376. PathAppend(g_szCustInf, g_szLanguage);
  4377. PathCreatePath(g_szCustInf);
  4378. PathCombine(szSrcCustInf, g_szSrcRoot, TEXT("INS"));
  4379. PathAppend(szSrcCustInf, GetOutputPlatformDir());
  4380. PathAppend(szSrcCustInf, g_szLanguage);
  4381. if (g_fBatch2)
  4382. {
  4383. StrCpy(g_szBaseURL,g_szSrcRoot);
  4384. StrCpy(g_szMastInf,g_szCustInf);
  4385. s_fNoNet = FALSE;
  4386. }
  4387. if (g_fBatch2 && PathFileExists(szSrcCustInf) && PathFileExists(g_szCustInf))
  4388. {
  4389. CopyFilesSrcToDest(szSrcCustInf, TEXT("*.inf"), g_szCustInf);
  4390. CopyFilesSrcToDest(szSrcCustInf, TEXT("*.ins"), g_szCustInf);
  4391. CopyFilesSrcToDest(szSrcCustInf, TEXT("*.cif"), g_szCustInf);
  4392. CopyFilesSrcToDest(szSrcCustInf, TEXT("*.in_"), g_szCustInf);
  4393. }
  4394. PathAppend(g_szCustInf, TEXT("IESetup.inf"));
  4395. // initialize deffav.inf path
  4396. PathCombine(g_szDefInf, g_szWizRoot, TEXT("IEBIN"));
  4397. PathAppend(g_szDefInf, g_szLanguage);
  4398. PathAppend(g_szDefInf, TEXT("OPTIONAL\\DEFFAV.INF"));
  4399. PathCombine(g_szMastInf, g_szWizRoot, TEXT("IESetup.inf"));
  4400. if ((hFind = FindFirstFile( g_szCustInf, &fd )) == INVALID_HANDLE_VALUE)
  4401. {
  4402. CopyFile(g_szMastInf, g_szCustInf, FALSE);
  4403. }
  4404. else
  4405. FindClose(hFind);
  4406. GetSiteDataPath();
  4407. InitCustComponents(NULL);
  4408. sWrk = MAX_PATH;
  4409. GetModuleFileName( NULL, g_szIEAKProg, MAX_PATH );
  4410. pBack = StrRChr(g_szIEAKProg, NULL, TEXT('\\'));
  4411. if (pBack)
  4412. *pBack = TEXT('\0');
  4413. PathAppend(g_szIEAKProg, TEXT("Download"));
  4414. PathAppend(g_szIEAKProg, g_szLanguage);
  4415. PathCreatePath(g_szIEAKProg);
  4416. PathCombine(g_szCif, g_szBuildRoot, TEXT("INS"));
  4417. PathAppend(g_szCif, GetOutputPlatformDir());
  4418. PathAppend(g_szCif, g_szLanguage);
  4419. PathAppend(g_szCif, TEXT("IESetup.cif"));
  4420. if (!PathFileExists(g_szCif))
  4421. {
  4422. TCHAR szCifFile[MAX_PATH];
  4423. PathCombine(szCifFile, g_szIEAKProg, TEXT("IESetup.cif"));
  4424. CopyFile(szCifFile, g_szCif, FALSE);
  4425. }
  4426. StrCpy(s_szCifCabURL, g_szBaseURL);
  4427. StrCat(s_szCifCabURL, TEXT("/IECIF.CAB"));
  4428. StrCpy(s_szCifNew, g_szIEAKProg);
  4429. PathAppend(s_szCifNew, TEXT("new"));
  4430. PathCreatePath(s_szCifNew);
  4431. PathAppend(s_szCifNew, TEXT("IEsetup.cif"));
  4432. {
  4433. IEnumCifModes * pEnumCifModes;
  4434. ICifComponent * pCifComponent;
  4435. GetICifFileFromFile_t(&g_lpCifFileNew, s_szCifNew);
  4436. GetICifRWFileFromFile_t(&g_lpCifRWFile, g_szCif);
  4437. if (!g_lpCifRWFile)
  4438. {
  4439. if (g_hLogFile)
  4440. {
  4441. TCHAR szError[MAX_PATH];
  4442. DWORD dwNumWritten;
  4443. LoadString(g_rvInfo.hInst,IDS_ERROR_CIFRWFILE,szError,MAX_PATH);
  4444. WriteFile(g_hLogFile,szError,StrLen(szError),&dwNumWritten,NULL);
  4445. }
  4446. return;
  4447. }
  4448. // initialie set of modes
  4449. if (SUCCEEDED(g_lpCifRWFile->EnumModes(&pEnumCifModes,
  4450. PLATFORM_WIN98 | PLATFORM_NT4 | PLATFORM_NT5 | PLATFORM_MILLEN, NULL)))
  4451. {
  4452. TCHAR szModeID[64];
  4453. ICifMode * pCifMode;
  4454. int i=0;
  4455. while (SUCCEEDED(pEnumCifModes->Next(&pCifMode)))
  4456. {
  4457. CCifMode_t * pCifMode_t = new CCifMode_t((ICifRWMode *)pCifMode);
  4458. pCifMode_t->GetID(szModeID, countof(szModeID));
  4459. g_szAllModes[i] = szModeID[0];
  4460. i++;
  4461. delete pCifMode_t;
  4462. }
  4463. pEnumCifModes->Release();
  4464. }
  4465. // initialize version number
  4466. if (SUCCEEDED(g_lpCifRWFile->FindComponent(BASEWIN32, &pCifComponent)) ||
  4467. SUCCEEDED(g_lpCifRWFile->FindComponent(TEXT("BASEIE40_NTAlpha"), &pCifComponent)))
  4468. {
  4469. DWORD dwVer, dwBuild;
  4470. pCifComponent->GetVersion(&dwVer, &dwBuild);
  4471. ConvertDwordsToVersionStr(g_szJobVersion, dwVer, dwBuild);
  4472. }
  4473. }
  4474. sCif = GetPrivateProfileString( NULL, NULL, NULL, szSectBuf, countof(szSectBuf), s_szCifNew );
  4475. nComp = 20 + sCif/4;
  4476. pComp = g_paComp = (PCOMPONENT) LocalAlloc(LPTR, nComp * sizeof(COMPONENT) );
  4477. ZeroMemory(g_paComp, nComp * sizeof(COMPONENT));
  4478. }
  4479. void UpdateInf(LPTSTR szMasterInf, LPTSTR szUserInf)
  4480. {
  4481. TCHAR szInfBack[MAX_PATH];
  4482. LPTSTR pDot, pBuf, pParm;
  4483. SetFileAttributes(szUserInf, FILE_ATTRIBUTE_NORMAL);
  4484. StrCpy(szInfBack, szUserInf);
  4485. pDot = StrRChr(szInfBack, NULL, TEXT('.'));
  4486. if (!pDot) return;
  4487. StrCpy(pDot, TEXT(".bak"));
  4488. DeleteFile( szInfBack );
  4489. MoveFile( szUserInf, szInfBack );
  4490. CopyFile(szMasterInf, szUserInf, FALSE);
  4491. SetFileAttributes(szUserInf, FILE_ATTRIBUTE_NORMAL);
  4492. pBuf = (LPTSTR) LocalAlloc(LPTR, INF_BUF_SIZE);
  4493. if (pBuf)
  4494. {
  4495. GetPrivateProfileString( STRINGS, NULL, TEXT(""), pBuf, ARRAYSIZE(pBuf), szInfBack );
  4496. pParm = pBuf;
  4497. while (*pParm)
  4498. {
  4499. TCHAR szValBuf[MAX_PATH];
  4500. GetPrivateProfileString( STRINGS, pParm, TEXT(""), szValBuf, countof(szValBuf), szInfBack );
  4501. InsWriteQuotedString( STRINGS, pParm, szValBuf, szUserInf );
  4502. pParm += lstrlen(pParm) + 1;
  4503. }
  4504. LocalFree(pBuf);
  4505. }
  4506. }
  4507. BOOL GotLang(LPTSTR szLang)
  4508. {
  4509. int i;
  4510. for (i = 0; i < g_nLangs ; i++ )
  4511. {
  4512. if (StrCmpI(szLang, g_aszLang[i]) == 0) return(TRUE);
  4513. }
  4514. return(FALSE);
  4515. }
  4516. extern DWORD g_aLangId[];
  4517. extern DWORD g_wCurLang;
  4518. DWORD DownloadSiteThreadProc(LPVOID)
  4519. {
  4520. int i;
  4521. TCHAR szBuf[8];
  4522. TCHAR szLang[8];
  4523. TCHAR szLocaleIni[MAX_PATH];
  4524. DWORD dwErr;
  4525. HWND hBaseUList;
  4526. WIN32_FIND_DATA fd;
  4527. DWORD dwRet = WAIT_OBJECT_0;
  4528. MSG msg;
  4529. LPMULTILANGUAGE pMLang = NULL;
  4530. int iEnglish = 0, iCurLang = 0;
  4531. USES_CONVERSION;
  4532. CoInitialize(NULL);
  4533. g_fCancelled = FALSE;
  4534. dwErr = CoCreateInstance(CLSID_DownloadSiteMgr, NULL, CLSCTX_INPROC_SERVER,
  4535. IID_IDownloadSiteMgr, (void **) &s_pSiteMgr);
  4536. if(!s_pSiteMgr)
  4537. {
  4538. dwErr = GetLastError();
  4539. g_fLangInit = TRUE;
  4540. SendMessage( g_hDlg, IDM_INITIALIZE, 0, 0 );
  4541. PropSheet_SetWizButtons(GetParent(g_hDlg), PSWIZB_BACK | PSWIZB_NEXT);
  4542. CoUninitialize();
  4543. return(dwErr);
  4544. }
  4545. g_hDownloadEvent = CreateEvent( NULL, FALSE, FALSE, TEXT("SiteMgrEvent") );
  4546. g_hProcessInfEvent = CreateEvent( NULL, TRUE, FALSE, TEXT("ProcessInfEvent") );
  4547. g_hCifEvent = CreateEvent( NULL, TRUE, FALSE, TEXT("CifEvent") );
  4548. GetSiteDataPath();
  4549. while (!(g_fDone || g_fCancelled))
  4550. {
  4551. if (dwRet == WAIT_OBJECT_0) switch (g_iDownloadState)
  4552. {
  4553. case DOWN_STATE_IDLE:
  4554. break;
  4555. case DOWN_STATE_ENUM_LANG:
  4556. wnsprintf(szBuf, countof(szBuf), TEXT("%04lx"), g_wCurLang);
  4557. PathCombine(szLocaleIni, g_szWizRoot, TEXT("Locale.INI"));
  4558. if (GetPrivateProfileString( IS_ACTIVESETUP, szBuf, TEXT(""), g_szActLang,
  4559. countof(g_szActLang), szLocaleIni ) == 0)
  4560. {
  4561. // check for sublocale defaults
  4562. GetPrivateProfileString( TEXT("SubLocales"), szBuf, TEXT("EN"), g_szActLang,
  4563. countof(g_szActLang), szLocaleIni );
  4564. }
  4565. iCurLang = -1;
  4566. dwErr = CoCreateInstance(CLSID_CMultiLanguage, NULL, CLSCTX_INPROC_SERVER,
  4567. IID_IMultiLanguage, (void **) &pMLang);
  4568. if (!g_fLocalMode)
  4569. {
  4570. TCHAR szMsg[MAX_PATH];
  4571. LoadString(g_rvInfo.hInst, IDS_AVSINITFAIL, szMsg, countof(szMsg));
  4572. do
  4573. {
  4574. CHAR szSiteDataA[MAX_PATH];
  4575. dwErr = s_pSiteMgr->Initialize(T2Abux(s_szSiteData, szSiteDataA), NULL);
  4576. }
  4577. while ((dwErr != NOERROR) && (MessageBox(g_hDlg, szMsg, g_szTitle, MB_RETRYCANCEL) == IDRETRY));
  4578. }
  4579. if (dwErr != NOERROR)
  4580. {
  4581. s_pSiteMgr->Release();
  4582. s_pSiteMgr = NULL;
  4583. g_fLocalMode = TRUE;
  4584. }
  4585. if (!g_fLocalMode)
  4586. {
  4587. for (i = 0, g_nLangs = 0; ; i++ )
  4588. {
  4589. DOWNLOADSITE *pSite;
  4590. IDownloadSite *pISite;
  4591. if (!s_pSiteMgr) break;
  4592. s_pSiteMgr->EnumSites(i, &pISite);
  4593. if (!pISite) break;
  4594. pISite->GetData(&pSite);
  4595. A2Tbux(pSite->pszLang, szLang);
  4596. if (StrCmpI(szLang, TEXT("US")) == 0)
  4597. StrCpy(szLang, TEXT("EN"));
  4598. if (!GotLang(szLang))
  4599. {
  4600. if (StrCmpI(szLang, g_szActLang) == 0) iCurLang = g_nLangs;
  4601. if (StrCmpI(szLang, TEXT("EN")) == 0) iEnglish = g_nLangs;
  4602. StrCpy(g_aszLang[g_nLangs], szLang);
  4603. GetPrivateProfileString(IS_STRINGS, szLang, TEXT(""), s_aszLangDesc[g_nLangs], 64, szLocaleIni);
  4604. if (pMLang)
  4605. {
  4606. RFC1766INFO rInfo;
  4607. LCID lcid;
  4608. CharLower(szLang);
  4609. if ((dwErr = GetLcid(&lcid, szLang, szLocaleIni)) == NOERROR)
  4610. {
  4611. g_aLangId[g_nLangs] = lcid;
  4612. if (ISNULL(s_aszLangDesc[g_nLangs]))
  4613. {
  4614. dwErr = pMLang->GetRfc1766Info(lcid, &rInfo);
  4615. W2Tbux(rInfo.wszLocaleName, s_aszLangDesc[g_nLangs]);
  4616. }
  4617. }
  4618. }
  4619. if (dwErr == NOERROR)
  4620. SendDlgItemMessage(g_hDlg, IDC_LANGUAGE, CB_ADDSTRING, 0, (LPARAM)s_aszLangDesc[g_nLangs++] );
  4621. if (g_nLangs >= NUMLANG) break;
  4622. }
  4623. }
  4624. if (iCurLang == -1) iCurLang = iEnglish;
  4625. if (pMLang) pMLang->Release();
  4626. }
  4627. else
  4628. {
  4629. TCHAR szDownloadDir[MAX_PATH];
  4630. BOOL fNoMore = FALSE;
  4631. HANDLE hFind = NULL;
  4632. for (i = 0, g_nLangs = 0; ; i++ )
  4633. {
  4634. if (hFind == NULL)
  4635. {
  4636. PathCombine(szDownloadDir, g_szIEAKProg, TEXT("*.*"));
  4637. hFind = FindFirstFile(szDownloadDir, &fd);
  4638. }
  4639. else
  4640. fNoMore = FindNextFile(hFind, &fd) ? FALSE : TRUE;
  4641. while (!fNoMore && (hFind != INVALID_HANDLE_VALUE) && (!(fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
  4642. || (StrCmp(fd.cFileName, TEXT(".")) == 0) || (StrCmp(fd.cFileName, TEXT("..")) == 0)))
  4643. {
  4644. if (!FindNextFile(hFind, &fd))
  4645. {
  4646. fNoMore = TRUE;
  4647. break;
  4648. }
  4649. }
  4650. if (fNoMore)
  4651. {
  4652. FindClose(hFind);
  4653. break;
  4654. }
  4655. if (hFind == INVALID_HANDLE_VALUE)
  4656. break;
  4657. if (StrCmpI(fd.cFileName, g_szActLang) == 0) iCurLang = g_nLangs;
  4658. if (StrCmpI(fd.cFileName, TEXT("EN")) == 0) iEnglish = g_nLangs;
  4659. StrCpy(g_aszLang[g_nLangs], fd.cFileName);
  4660. GetPrivateProfileString(IS_STRINGS, fd.cFileName, TEXT(""), s_aszLangDesc[g_nLangs], 64, szLocaleIni);
  4661. if (pMLang)
  4662. {
  4663. RFC1766INFO rInfo;
  4664. LCID lcid;
  4665. CharLower(fd.cFileName);
  4666. if ((dwErr = GetLcid(&lcid, fd.cFileName, szLocaleIni)) == NOERROR)
  4667. {
  4668. g_aLangId[g_nLangs] = lcid;
  4669. if (ISNULL(s_aszLangDesc[g_nLangs]))
  4670. {
  4671. dwErr = pMLang->GetRfc1766Info(lcid, &rInfo);
  4672. W2Tbux(rInfo.wszLocaleName, s_aszLangDesc[g_nLangs]);
  4673. }
  4674. }
  4675. }
  4676. if (dwErr == NOERROR)
  4677. SendDlgItemMessage(g_hDlg, IDC_LANGUAGE, CB_ADDSTRING, 0, (LPARAM)s_aszLangDesc[g_nLangs++] );
  4678. if (g_nLangs >= NUMLANG) break;
  4679. }
  4680. if (iCurLang == -1) iCurLang = iEnglish;
  4681. }
  4682. SendDlgItemMessage( g_hDlg, IDC_LANGUAGE, CB_SETCURSEL, iCurLang, 0 );
  4683. g_fLangInit = TRUE;
  4684. SendMessage( g_hDlg, IDM_INITIALIZE, 0, 0 );
  4685. PropSheet_SetWizButtons(GetParent(g_hDlg), PSWIZB_BACK | PSWIZB_NEXT);
  4686. g_iDownloadState = DOWN_STATE_IDLE;
  4687. break;
  4688. case DOWN_STATE_ENUM_URL:
  4689. hBaseUList = GetDlgItem(g_hDlg, IDC_BASEURLLIST);
  4690. if (*g_szLanguage == TEXT('\\'))
  4691. StrCpy(szBuf, g_szLanguage + 1);
  4692. else
  4693. StrCpy(szBuf, g_szLanguage);
  4694. szBuf[2] = TEXT('\0');
  4695. if (s_pSiteMgr)
  4696. {
  4697. int iSite = 0;
  4698. SendDlgItemMessage(g_hDlg, IDC_DOWNLOADLIST, CB_RESETCONTENT, 0, 0);
  4699. for (i = 0; ; i++)
  4700. {
  4701. DOWNLOADSITE *pSite;
  4702. IDownloadSite *pISite;
  4703. if (!s_pSiteMgr)
  4704. break;
  4705. s_pSiteMgr->EnumSites(i, &pISite);
  4706. if (!pISite)
  4707. break;
  4708. pISite->GetData(&pSite);
  4709. A2Tbux(pSite->pszLang, szLang);
  4710. if (StrCmpI(szLang, szBuf) == 0)
  4711. {
  4712. TCHAR szFriendlyName[MAX_PATH];
  4713. s_aiSites[iSite++] = i;
  4714. A2Tbux(pSite->pszFriendlyName, szFriendlyName);
  4715. SendDlgItemMessage(g_hDlg, IDC_DOWNLOADLIST, CB_ADDSTRING,
  4716. 0, (LPARAM) szFriendlyName );
  4717. }
  4718. pISite->Release();
  4719. if (iSite >= NUMSITES)
  4720. break;
  4721. }
  4722. }
  4723. g_fUrlsInit = TRUE;
  4724. SendDlgItemMessage( g_hDlg, IDC_DOWNLOADLIST, CB_SETCURSEL, 0, 0L );
  4725. SetFocus( hBaseUList );
  4726. SendMessage(g_hDlg, IDM_INITIALIZE, 0, 0 );
  4727. PropSheet_SetWizButtons(GetParent(g_hDlg), PSWIZB_BACK | PSWIZB_NEXT);
  4728. g_iDownloadState = DOWN_STATE_IDLE;
  4729. break;
  4730. case DOWN_STATE_SAVE_URL:
  4731. SaveDownloadUrls();
  4732. g_iDownloadState = DOWN_STATE_IDLE;
  4733. break;
  4734. }
  4735. while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
  4736. {
  4737. TranslateMessage(&msg);
  4738. DispatchMessage(&msg);
  4739. }
  4740. dwRet = MsgWaitForMultipleObjects(1, &g_hDownloadEvent, FALSE, INFINITE, QS_ALLINPUT);
  4741. }
  4742. if (s_pSiteMgr) s_pSiteMgr->Release();
  4743. s_pSiteMgr = 0;
  4744. if (s_hInet)
  4745. {
  4746. InternetCloseHandle(s_hInet);
  4747. s_hInet = NULL;
  4748. }
  4749. CloseHandle(g_hDownloadEvent);
  4750. CloseHandle(g_hProcessInfEvent);
  4751. CloseHandle(g_hCifEvent);
  4752. g_hDownloadEvent = 0;
  4753. g_hProcessInfEvent = 0;
  4754. g_hCifEvent = 0;
  4755. CoUninitialize();
  4756. return(0);
  4757. }
  4758. void InitializeUserDownloadSites(HWND hDlg)
  4759. {
  4760. int i;
  4761. HWND hBaseUList = GetDlgItem(hDlg, IDC_BASEURLLIST);
  4762. LV_COLUMN lvCol;
  4763. TCHAR szColHead[80];
  4764. PSITEDATA psd;
  4765. if (hDlg != NULL)
  4766. {
  4767. ZeroMemory(&lvCol, sizeof(lvCol));
  4768. lvCol.mask = LVCF_FMT | LVCF_SUBITEM | LVCF_TEXT | LVCF_WIDTH;
  4769. lvCol.fmt = LVCFMT_LEFT;
  4770. lvCol.cx = 80;
  4771. lvCol.pszText = szColHead;
  4772. LoadString( g_rvInfo.hInst, IDS_DOWNSITEREGION, szColHead, countof(szColHead) );
  4773. lvCol.iSubItem = 3;
  4774. ListView_InsertColumn(hBaseUList, 0, &lvCol);
  4775. lvCol.cx = 125;
  4776. lvCol.iSubItem = 2;
  4777. LoadString( g_rvInfo.hInst, IDS_DOWNSITEURL, szColHead, countof(szColHead) );
  4778. ListView_InsertColumn(hBaseUList, 0, &lvCol);
  4779. lvCol.cx = 125;
  4780. lvCol.iSubItem = 1;
  4781. LoadString( g_rvInfo.hInst, IDS_DOWNSITENAME, szColHead, countof(szColHead) );
  4782. ListView_InsertColumn(hBaseUList, 0, &lvCol);
  4783. }
  4784. for (i = 0, psd = g_aCustSites; ; i++, psd++ )
  4785. {
  4786. TCHAR szBaseUrlParm[32];
  4787. LV_ITEM lvItem;
  4788. LPTSTR pSlash;
  4789. ZeroMemory(psd, sizeof(SITEDATA));
  4790. wnsprintf(szBaseUrlParm, countof(szBaseUrlParm), TEXT("SiteName%i"), i);
  4791. GetPrivateProfileString(IS_ACTIVESETUP_SITES, szBaseUrlParm, TEXT(""), psd->szName, 80, g_szCustIns );
  4792. if (ISNULL(psd->szName)) break;
  4793. wnsprintf(szBaseUrlParm, countof(szBaseUrlParm), TEXT("SiteUrl%i"), i);
  4794. GetPrivateProfileString(IS_ACTIVESETUP_SITES, szBaseUrlParm, TEXT(""), psd->szUrl, MAX_URL, g_szCustIns );
  4795. pSlash = StrRChr(psd->szUrl, NULL, TEXT('/'));
  4796. if (pSlash != NULL)
  4797. {
  4798. if (StrCmpI(pSlash, TEXT("/WIN32")) == 0)
  4799. {
  4800. LPTSTR pOld = pSlash;
  4801. *pSlash = TEXT('\0');
  4802. pSlash = StrRChr(psd->szUrl, NULL, TEXT('/'));
  4803. if (pSlash != NULL)
  4804. {
  4805. if (StrCmpI(pSlash, TEXT("/DOWNLOAD")) == 0)
  4806. {
  4807. *pSlash = TEXT('\0');
  4808. }
  4809. else
  4810. *pOld = TEXT('/');
  4811. }
  4812. }
  4813. }
  4814. wnsprintf(szBaseUrlParm, countof(szBaseUrlParm), TEXT("SiteRegion%i"), i);
  4815. GetPrivateProfileString(IS_ACTIVESETUP_SITES, szBaseUrlParm, TEXT(""), psd->szRegion, 80, g_szCustIns );
  4816. g_nDownloadUrls++;
  4817. if (hDlg != NULL)
  4818. {
  4819. ZeroMemory(&lvItem, sizeof(lvItem));
  4820. lvItem.mask = LVIF_TEXT;
  4821. lvItem.iItem = i;
  4822. lvItem.pszText = psd->szName;
  4823. ListView_InsertItem(hBaseUList, &lvItem);
  4824. lvItem.iSubItem = 1;
  4825. lvItem.pszText = psd->szUrl;
  4826. ListView_SetItem(hBaseUList, &lvItem);
  4827. lvItem.pszText = psd->szRegion;
  4828. lvItem.iSubItem = 2;
  4829. ListView_SetItem(hBaseUList, &lvItem);
  4830. }
  4831. }
  4832. if (hDlg != NULL)
  4833. {
  4834. if (g_nDownloadUrls)
  4835. {
  4836. SetDlgItemText( hDlg, IDE_DOWNSITENAME, g_aCustSites->szName );
  4837. SetDlgItemText( hDlg, IDE_DOWNSITEURL, g_aCustSites->szUrl );
  4838. SetDlgItemText( hDlg, IDE_DOWNSITEREGION, g_aCustSites->szRegion );
  4839. }
  4840. else
  4841. {
  4842. DisableDlgItem(hDlg, IDE_DOWNSITENAME);
  4843. DisableDlgItem(hDlg, IDE_DOWNSITEURL);
  4844. DisableDlgItem(hDlg, IDE_DOWNSITEREGION);
  4845. DisableDlgItem(hDlg, IDC_DOWNSITENAME_TXT);
  4846. DisableDlgItem(hDlg, IDC_DOWNSITEURL_TXT);
  4847. DisableDlgItem(hDlg, IDC_DOWNSITEREGION_TXT);
  4848. }
  4849. ListView_SetItemState(hBaseUList, 0, LVIS_SELECTED | LVIS_FOCUSED,
  4850. LVIS_SELECTED | LVIS_FOCUSED);
  4851. }
  4852. }
  4853. void SetDownloadSiteEditControls(HWND hDlg, int nSite)
  4854. {
  4855. if (nSite >= 0)
  4856. {
  4857. PSITEDATA psd = &g_aCustSites[nSite];
  4858. SetDlgItemText( hDlg, IDE_DOWNSITENAME, psd->szName );
  4859. SetDlgItemText( hDlg, IDE_DOWNSITEURL, psd->szUrl );
  4860. SetDlgItemText( hDlg, IDE_DOWNSITEREGION, psd->szRegion );
  4861. }
  4862. else
  4863. {
  4864. SetDlgItemText( hDlg, IDE_DOWNSITENAME, TEXT("") );
  4865. SetDlgItemText( hDlg, IDE_DOWNSITEURL, TEXT("") );
  4866. SetDlgItemText( hDlg, IDE_DOWNSITEREGION, TEXT("") );
  4867. }
  4868. }
  4869. //
  4870. // FUNCTION: ComponentSelect(HWND, UINT, UINT, LONG)
  4871. //
  4872. // PURPOSE: Processes messages for "ComponentSelect" page
  4873. //
  4874. // MESSAGES:
  4875. //
  4876. // WM_INITDIALOG - intializes the page
  4877. // WM_NOTIFY - processes the notifications sent to the page
  4878. // WM_COMMAND - saves the id of the choice selected
  4879. //
  4880. //
  4881. INT_PTR CALLBACK ComponentUrls(
  4882. HWND hDlg,
  4883. UINT message,
  4884. WPARAM wParam,
  4885. LPARAM lParam)
  4886. {
  4887. TCHAR szDownTpl[MAX_PATH];
  4888. LV_ITEM lvItem;
  4889. HWND hUrlList = GetDlgItem( hDlg, IDC_BASEURLLIST);
  4890. PSITEDATA psd = &g_aCustSites[g_iSelSite];
  4891. static BOOL s_fNext = TRUE;
  4892. static BOOL s_fUserSitesInit = FALSE;
  4893. static BOOL s_fErrMessageShown = FALSE;
  4894. switch (message)
  4895. {
  4896. case WM_INITDIALOG:
  4897. g_hWizard = hDlg;
  4898. EnableDBCSChars( hDlg, IDC_BASEURLLIST);
  4899. EnableDBCSChars( hDlg, IDE_DOWNSITENAME);
  4900. EnableDBCSChars( hDlg, IDE_DOWNSITEREGION);
  4901. EnableDBCSChars( hDlg, IDE_DOWNSITEURL );
  4902. break;
  4903. case IDM_INITIALIZE:
  4904. if ((g_hWait != NULL) && g_fUrlsInit)
  4905. {
  4906. SendMessage(g_hWait, WM_CLOSE, 0, 0);
  4907. g_hWait = NULL;
  4908. }
  4909. break;
  4910. case WM_DESTROY:
  4911. break;
  4912. case IDM_BATCHADVANCE:
  4913. DoBatchAdvance(hDlg);
  4914. break;
  4915. case WM_HELP:
  4916. IeakPageHelp(hDlg, g_psp[g_iCurPage].pszTemplate);
  4917. break;
  4918. case WM_COMMAND:
  4919. if (HIWORD(wParam) == BN_CLICKED)
  4920. {
  4921. int i;
  4922. switch (LOWORD(wParam))
  4923. {
  4924. case IDC_ADDBASEURL:
  4925. if (g_nDownloadUrls &&
  4926. IsWindowEnabled(GetDlgItem(hDlg, IDE_DOWNSITENAME)) &&
  4927. (!CheckField(hDlg, IDE_DOWNSITENAME, FC_NONNULL) ||
  4928. !CheckField(hDlg, IDE_DOWNSITEURL, FC_NONNULL | FC_URL) ||
  4929. !CheckField(hDlg, IDE_DOWNSITEREGION, FC_NONNULL)))
  4930. {
  4931. SetWindowLongPtr(hDlg, DWLP_MSGRESULT, -1);
  4932. break;
  4933. }
  4934. ZeroMemory(&lvItem, sizeof(lvItem));
  4935. lvItem.mask = LVIF_TEXT;
  4936. ListView_SetItemState(hUrlList, g_iSelSite, LVIS_SELECTED | LVIS_FOCUSED, 0);
  4937. lvItem.iItem = g_iSelSite = g_nDownloadUrls;
  4938. psd = &g_aCustSites[g_nDownloadUrls];
  4939. lvItem.pszText = psd->szName;
  4940. LoadString( g_rvInfo.hInst, IDS_DOWNLOADURL, szDownTpl, 80 );
  4941. wnsprintf(psd->szUrl, countof(psd->szUrl), TEXT("http://%s%i"), szDownTpl, g_nDownloadUrls);
  4942. LoadString( g_rvInfo.hInst, IDS_DOWNLOADSITE, szDownTpl, 80 );
  4943. wnsprintf(psd->szName, countof(psd->szName), TEXT("%s%i"), szDownTpl, g_nDownloadUrls++);
  4944. LoadString( g_rvInfo.hInst, IDS_NORTHAMERICA, psd->szRegion, 80 );
  4945. ListView_InsertItem(hUrlList, &lvItem);
  4946. SetCustSite(hDlg, g_iSelSite);
  4947. ListView_SetItemState(hUrlList, g_iSelSite,
  4948. LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED);
  4949. if (!IsWindowEnabled(GetDlgItem(GetParent(hDlg), IDC_NEXT)))
  4950. PropSheet_SetWizButtons(GetParent(hDlg), PSWIZB_BACK | PSWIZB_NEXT);
  4951. EnableDlgItem(hDlg, IDE_DOWNSITENAME);
  4952. EnableDlgItem(hDlg, IDE_DOWNSITEURL);
  4953. EnableDlgItem(hDlg, IDE_DOWNSITEREGION);
  4954. EnableDlgItem(hDlg, IDC_REMOVEBASEURL);
  4955. EnableDlgItem(hDlg, IDC_DOWNSITENAME_TXT);
  4956. EnableDlgItem(hDlg, IDC_DOWNSITEURL_TXT);
  4957. EnableDlgItem(hDlg, IDC_DOWNSITEREGION_TXT);
  4958. SetFocus(GetDlgItem( hDlg, IDE_DOWNSITENAME));
  4959. EnableDlgItem2(hDlg, IDC_ADDBASEURL, (g_nDownloadUrls < ((g_fIntranet && (g_fSilent || g_fStealth)) ? 1 : 10)));
  4960. SendMessage(GetDlgItem( hDlg, IDE_DOWNSITENAME), EM_SETSEL, 0, -1);
  4961. break;
  4962. case IDC_REMOVEBASEURL:
  4963. s_fInChange = TRUE;
  4964. if(ListView_DeleteItem(hUrlList, g_iSelSite))
  4965. {
  4966. for (i = g_iSelSite; i <= g_nDownloadUrls ; i++)
  4967. {
  4968. g_aCustSites[i] = g_aCustSites[i + 1];
  4969. }
  4970. g_nDownloadUrls--;
  4971. }
  4972. s_fInChange = FALSE;
  4973. EnableDlgItem2(hDlg, IDC_ADDBASEURL, (g_nDownloadUrls < ((g_fIntranet && (g_fSilent || g_fStealth)) ? 1 : 10)));
  4974. if (g_nDownloadUrls == 0) {
  4975. int rgids[] = { IDE_DOWNSITENAME, IDE_DOWNSITEURL, IDE_DOWNSITEREGION, IDC_REMOVEBASEURL };
  4976. int rgtxtids[] = { IDC_DOWNSITENAME_TXT, IDC_DOWNSITEURL_TXT, IDC_DOWNSITEREGION_TXT };
  4977. ZeroMemory(g_aCustSites, sizeof(COMPONENT));
  4978. EnsureDialogFocus(hDlg, rgids, countof(rgids), IDC_ADDBASEURL);
  4979. DisableDlgItems (hDlg, rgids, countof(rgids));
  4980. DisableDlgItems (hDlg, rgtxtids, countof(rgtxtids));
  4981. PropSheet_SetWizButtons(GetParent(hDlg), PSWIZB_BACK);
  4982. }
  4983. if (g_iSelSite >= g_nDownloadUrls) g_iSelSite--;
  4984. SetDownloadSiteEditControls(hDlg, g_iSelSite);
  4985. ListView_SetItemState(hUrlList, g_iSelSite,
  4986. LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED);
  4987. break;
  4988. }
  4989. }
  4990. else if (HIWORD(wParam) == EN_CHANGE)
  4991. {
  4992. switch (LOWORD(wParam))
  4993. {
  4994. case IDE_DOWNSITENAME:
  4995. GetDlgItemText( hDlg, IDE_DOWNSITENAME, psd->szName, countof(psd->szName) );
  4996. break;
  4997. case IDE_DOWNSITEURL:
  4998. GetDlgItemText( hDlg, IDE_DOWNSITEURL, psd->szUrl, countof(psd->szUrl) );
  4999. break;
  5000. case IDE_DOWNSITEREGION:
  5001. GetDlgItemText( hDlg, IDE_DOWNSITEREGION, psd->szRegion, countof(psd->szRegion) );
  5002. break;
  5003. }
  5004. SetCustSite(hDlg, g_iSelSite);
  5005. }
  5006. break;
  5007. case WM_NOTIFY:
  5008. switch (((NMHDR FAR *) lParam)->code)
  5009. {
  5010. int i;
  5011. case LVN_ITEMCHANGED:
  5012. case LVN_ITEMCHANGING:
  5013. if (s_fInChange) break;
  5014. // BUGBUG: <oliverl> crazy hack to eat up the second LVN_ITEMCHANGING
  5015. // msg we get in the error case. I can't figure out any way
  5016. // to distinguish the two.
  5017. if ((g_nDownloadUrls > 1) && s_fErrMessageShown &&
  5018. (!GetDlgItemText(hDlg, IDE_DOWNSITENAME, szDownTpl, countof(szDownTpl)) ||
  5019. !GetDlgItemText(hDlg, IDE_DOWNSITEURL, szDownTpl, countof(szDownTpl)) ||
  5020. !PathIsURL(szDownTpl) ||
  5021. !GetDlgItemText(hDlg, IDE_DOWNSITEREGION, szDownTpl, countof(szDownTpl))))
  5022. {
  5023. s_fErrMessageShown = FALSE;
  5024. SetWindowLongPtr(hDlg, DWLP_MSGRESULT, -1);
  5025. break;
  5026. }
  5027. if ((g_nDownloadUrls > 1) &&
  5028. (!CheckField(hDlg, IDE_DOWNSITENAME, FC_NONNULL) ||
  5029. !CheckField(hDlg, IDE_DOWNSITENAME, FC_NONNULL) ||
  5030. !CheckField(hDlg, IDE_DOWNSITENAME, FC_NONNULL)))
  5031. {
  5032. s_fErrMessageShown = TRUE;
  5033. SetWindowLongPtr(hDlg, DWLP_MSGRESULT, -1);
  5034. break;
  5035. }
  5036. for (i = 0; i < g_nDownloadUrls ; i++ )
  5037. {
  5038. DWORD dwState = ListView_GetItemState(hUrlList, i, LVIS_SELECTED | LVIS_FOCUSED);
  5039. if (dwState == (LVIS_FOCUSED | LVIS_SELECTED))
  5040. {
  5041. g_iSelSite = i;
  5042. SetDownloadSiteEditControls(hDlg, g_iSelSite);
  5043. }
  5044. }
  5045. break;
  5046. case PSN_HELP:
  5047. IeakPageHelp(hDlg, g_psp[g_iCurPage].pszTemplate);
  5048. break;
  5049. case PSN_SETACTIVE:
  5050. if (!s_fUserSitesInit)
  5051. {
  5052. InitializeUserDownloadSites(hDlg);
  5053. s_fUserSitesInit = TRUE;
  5054. }
  5055. if (!PageEnabled(PPAGE_COMPURLS))
  5056. PostMessage(GetParent(hDlg), PSM_PRESSBUTTON, s_fNext ? PSBTN_NEXT : PSBTN_BACK, 0);
  5057. else
  5058. {
  5059. SetBannerText(hDlg);
  5060. EnableDlgItem2(hDlg, IDC_ADDBASEURL, (g_nDownloadUrls < ((g_fIntranet && (g_fSilent || g_fStealth)) ? 1 : 10)));
  5061. EnableDlgItem2(hDlg, IDC_REMOVEBASEURL, (g_nDownloadUrls != 0));
  5062. PropSheet_SetWizButtons(GetParent(hDlg), (g_nDownloadUrls == 0) ? PSWIZB_BACK : PSWIZB_BACK | PSWIZB_NEXT);
  5063. CheckBatchAdvance(hDlg);
  5064. }
  5065. break;
  5066. case PSN_WIZNEXT:
  5067. case PSN_WIZBACK:
  5068. WritePrivateProfileString( IS_ACTIVESETUP_SITES, NULL, NULL, g_szCustIns );
  5069. for (i = 0, psd = g_aCustSites; i < 10 ; i++, psd++ )
  5070. {
  5071. TCHAR szBaseUrlParm[32];
  5072. LPTSTR pSlash;
  5073. if (ISNONNULL(psd->szUrl) && !PathIsURL(psd->szUrl))
  5074. {
  5075. ErrorMessageBox(hDlg, IDS_INVALID_URL);
  5076. SetCustSite(hDlg, i);
  5077. SetFocus(hUrlList);
  5078. ListView_SetItemState(hUrlList, i, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED);
  5079. SetWindowLongPtr(hDlg, DWLP_MSGRESULT, -1);
  5080. break;
  5081. }
  5082. pSlash = StrRChr(psd->szUrl, NULL, TEXT('/'));
  5083. if (pSlash != NULL)
  5084. {
  5085. if (StrCmpI(pSlash, TEXT("/WIN32")) == 0)
  5086. {
  5087. LPTSTR pOld = pSlash;
  5088. *pSlash = TEXT('\0');
  5089. pSlash = StrRChr(psd->szUrl, NULL, TEXT('/'));
  5090. if (pSlash != NULL)
  5091. {
  5092. if (StrCmpI(pSlash, TEXT("/DOWNLOAD")) == 0)
  5093. {
  5094. *pSlash = TEXT('\0');
  5095. }
  5096. else
  5097. *pOld = TEXT('/');
  5098. }
  5099. }
  5100. }
  5101. if (!g_fBatch && (i < g_nDownloadUrls) && (ISNULL(psd->szUrl)
  5102. || ISNULL(psd->szName) || ISNULL(psd->szRegion)))
  5103. {
  5104. ErrorMessageBox(hDlg, IDS_BLANKSITE);
  5105. SetWindowLongPtr(hDlg, DWLP_MSGRESULT, -1);
  5106. return TRUE;
  5107. }
  5108. if ((StrChr(psd->szName, TEXT(',')) != NULL) ||
  5109. (StrChr(psd->szRegion, TEXT(',')) != NULL))
  5110. {
  5111. ErrorMessageBox(hDlg, IDS_ERROR_COMMA);
  5112. SetCustSite(hDlg, i);
  5113. SetFocus(hUrlList);
  5114. ListView_SetItemState(hUrlList, i, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED);
  5115. SetWindowLongPtr(hDlg, DWLP_MSGRESULT, -1);
  5116. return TRUE;
  5117. }
  5118. if (psd->szUrl[lstrlen(psd->szUrl)-1] == TEXT('/'))
  5119. psd->szUrl[lstrlen(psd->szUrl)-1] = TEXT('\0');
  5120. if(!g_fOCW && ISNONNULL(psd->szUrl))
  5121. {
  5122. StrCat(psd->szUrl, TEXT("/DOWNLOAD/"));
  5123. StrCat(psd->szUrl, GetOutputPlatformDir());
  5124. psd->szUrl[lstrlen(psd->szUrl)-1] = TEXT('\0');
  5125. }
  5126. wnsprintf(szBaseUrlParm, countof(szBaseUrlParm), TEXT("SiteUrl%i"), i);
  5127. WritePrivateProfileString( IS_ACTIVESETUP_SITES, szBaseUrlParm, psd->szUrl, g_szCustIns );
  5128. wnsprintf(szBaseUrlParm, countof(szBaseUrlParm), TEXT("SiteName%i"), i);
  5129. WritePrivateProfileString( IS_ACTIVESETUP_SITES, szBaseUrlParm, psd->szName, g_szCustIns );
  5130. wnsprintf(szBaseUrlParm, countof(szBaseUrlParm), TEXT("SiteRegion%i"), i);
  5131. WritePrivateProfileString( IS_ACTIVESETUP_SITES, szBaseUrlParm, psd->szRegion, g_szCustIns );
  5132. }
  5133. g_iCurPage = PPAGE_COMPURLS;
  5134. EnablePages();
  5135. if (((NMHDR FAR *) lParam)->code == PSN_WIZNEXT)
  5136. {
  5137. s_fNext = FALSE;
  5138. PageNext(hDlg);
  5139. }
  5140. else
  5141. {
  5142. s_fNext = TRUE;
  5143. PagePrev(hDlg);
  5144. }
  5145. break;
  5146. case PSN_QUERYCANCEL:
  5147. QueryCancel(hDlg);
  5148. break;
  5149. default:
  5150. return FALSE;
  5151. }
  5152. break;
  5153. default:
  5154. return FALSE;
  5155. }
  5156. return TRUE;
  5157. }
  5158. INT_PTR CALLBACK AddOnDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
  5159. {
  5160. BOOL fNoAddon,
  5161. fDefAddon,
  5162. fCustAddon,
  5163. fUseMSSite;
  5164. TCHAR szAddOnUrl[INTERNET_MAX_URL_LENGTH],
  5165. szMenuText[128];
  5166. INT id;
  5167. switch (uMsg)
  5168. {
  5169. case WM_INITDIALOG:
  5170. EnableDBCSChars(hDlg, IDE_ADDONURL);
  5171. Edit_LimitText(GetDlgItem(hDlg, IDE_ADDONURL), countof(szAddOnUrl) - 1);
  5172. EnableDBCSChars(hDlg, IDE_MENUTEXT);
  5173. Edit_LimitText(GetDlgItem(hDlg, IDE_MENUTEXT), countof(szMenuText) - 1);
  5174. break;
  5175. case WM_NOTIFY:
  5176. switch (((NMHDR FAR *) lParam)->code)
  5177. {
  5178. case PSN_SETACTIVE:
  5179. SetBannerText(hDlg);
  5180. // no addon menu is available only in the corp mode
  5181. if (g_fIntranet)
  5182. {
  5183. fNoAddon = InsGetBool(IS_BRANDING, IK_NO_ADDON, FALSE, g_szCustIns);
  5184. ShowWindow(GetDlgItem(hDlg, IDC_NO_ADDON), SW_SHOW);
  5185. }
  5186. else
  5187. {
  5188. fNoAddon = FALSE;
  5189. ShowWindow(GetDlgItem(hDlg, IDC_NO_ADDON), SW_HIDE);
  5190. }
  5191. fDefAddon = InsGetBool(IS_BRANDING, IK_DEF_ADDON, FALSE, g_szCustIns);
  5192. fCustAddon = InsGetBool(IS_BRANDING, IK_CUST_ADDON, FALSE, g_szCustIns);
  5193. if (fNoAddon)
  5194. id = IDC_NO_ADDON;
  5195. else if (fDefAddon)
  5196. id = IDC_DEF_ADDON;
  5197. else if (fCustAddon)
  5198. id = IDC_CUST_ADDON;
  5199. else
  5200. id = IDC_DEF_ADDON; // default radio button
  5201. CheckRadioButton(hDlg, IDC_NO_ADDON, IDC_CUST_ADDON, id);
  5202. GetPrivateProfileString(IS_BRANDING, IK_HELP_MENU_TEXT, TEXT(""), szMenuText, countof(szMenuText), g_szCustIns);
  5203. SetDlgItemText(hDlg, IDE_MENUTEXT, szMenuText);
  5204. GetPrivateProfileString(IS_BRANDING, IK_ADDONURL, TEXT(""), szAddOnUrl, countof(szAddOnUrl), g_szCustIns);
  5205. SetDlgItemText(hDlg, IDE_ADDONURL, szAddOnUrl);
  5206. EnableDlgItem2(hDlg, IDC_MENUTEXT, fCustAddon);
  5207. EnableDlgItem2(hDlg, IDE_MENUTEXT, fCustAddon);
  5208. EnableDlgItem2(hDlg, IDC_ADDONURL, fCustAddon);
  5209. EnableDlgItem2(hDlg, IDE_ADDONURL, fCustAddon);
  5210. fUseMSSite = InsGetBool(IS_BRANDING, IK_ALT_SITES_URL, FALSE, g_szCustIns);
  5211. CheckDlgButton(hDlg, IDC_MSDL, fUseMSSite ? BST_CHECKED : BST_UNCHECKED);
  5212. CheckBatchAdvance(hDlg);
  5213. break;
  5214. case PSN_WIZBACK:
  5215. case PSN_WIZNEXT:
  5216. if (IsDlgButtonChecked(hDlg, IDC_CUST_ADDON) == BST_CHECKED)
  5217. if (!CheckField(hDlg, IDE_MENUTEXT, FC_NONNULL) ||
  5218. !CheckField(hDlg, IDE_ADDONURL, FC_NONNULL | FC_URL))
  5219. {
  5220. SetWindowLongPtr(hDlg, DWLP_MSGRESULT, -1);
  5221. return TRUE;
  5222. }
  5223. if (g_fIntranet)
  5224. fNoAddon = (IsDlgButtonChecked(hDlg, IDC_NO_ADDON) == BST_CHECKED);
  5225. else
  5226. fNoAddon = FALSE;
  5227. fDefAddon = (IsDlgButtonChecked(hDlg, IDC_DEF_ADDON) == BST_CHECKED);
  5228. fCustAddon = (IsDlgButtonChecked(hDlg, IDC_CUST_ADDON) == BST_CHECKED);
  5229. if ((!g_fBatch) && (!g_fBatch2))
  5230. {
  5231. InsWriteBool(IS_BRANDING, IK_NO_ADDON, fNoAddon, g_szCustIns);
  5232. InsWriteBool(IS_BRANDING, IK_DEF_ADDON, fDefAddon, g_szCustIns);
  5233. InsWriteBool(IS_BRANDING, IK_CUST_ADDON, fCustAddon, g_szCustIns);
  5234. }
  5235. GetDlgItemText(hDlg, IDE_MENUTEXT, szMenuText, countof(szMenuText));
  5236. InsWriteString(IS_BRANDING, IK_HELP_MENU_TEXT, szMenuText, g_szCustIns);
  5237. GetDlgItemText(hDlg, IDE_ADDONURL, szAddOnUrl, countof(szAddOnUrl));
  5238. InsWriteString(IS_BRANDING, IK_ADDONURL, szAddOnUrl, g_szCustIns);
  5239. fUseMSSite = (IsDlgButtonChecked(hDlg, IDC_MSDL) == BST_CHECKED);
  5240. InsWriteBool(IS_BRANDING, IK_ALT_SITES_URL, fUseMSSite, g_szCustIns);
  5241. g_iCurPage = PPAGE_ADDON;
  5242. EnablePages();
  5243. (((NMHDR FAR *) lParam)->code == PSN_WIZNEXT) ? PageNext(hDlg) : PagePrev(hDlg);
  5244. break;
  5245. case PSN_HELP:
  5246. IeakPageHelp(hDlg, g_psp[g_iCurPage].pszTemplate);
  5247. break;
  5248. case PSN_QUERYCANCEL:
  5249. QueryCancel(hDlg);
  5250. break;
  5251. default:
  5252. return FALSE;
  5253. }
  5254. break;
  5255. case WM_COMMAND:
  5256. switch (HIWORD(wParam))
  5257. {
  5258. case BN_CLICKED:
  5259. switch(LOWORD(wParam))
  5260. {
  5261. case IDC_NO_ADDON:
  5262. case IDC_DEF_ADDON:
  5263. case IDC_CUST_ADDON:
  5264. fCustAddon = (IsDlgButtonChecked(hDlg, IDC_CUST_ADDON) == BST_CHECKED);
  5265. EnableDlgItem2(hDlg, IDC_MENUTEXT, fCustAddon);
  5266. EnableDlgItem2(hDlg, IDE_MENUTEXT, fCustAddon);
  5267. EnableDlgItem2(hDlg, IDC_ADDONURL, fCustAddon);
  5268. EnableDlgItem2(hDlg, IDE_ADDONURL, fCustAddon);
  5269. break;
  5270. }
  5271. break;
  5272. }
  5273. break;
  5274. case WM_HELP:
  5275. IeakPageHelp(hDlg, g_psp[g_iCurPage].pszTemplate);
  5276. break;
  5277. case IDM_BATCHADVANCE:
  5278. DoBatchAdvance(hDlg);
  5279. break;
  5280. default:
  5281. return FALSE;
  5282. }
  5283. return TRUE;
  5284. }
  5285. //
  5286. // FUNCTION: UserAgentString(HWND, UINT, UINT, LONG)
  5287. //
  5288. // PURPOSE: Processes messages for "UserAgentString" page
  5289. //
  5290. // MESSAGES:
  5291. //
  5292. // WM_INITDIALOG - intializes the page
  5293. // WM_NOTIFY - processes the notifications sent to the page
  5294. // WM_COMMAND - saves the id of the choice selected
  5295. //
  5296. //
  5297. INT_PTR CALLBACK UserAgentString( HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam )
  5298. {
  5299. BOOL fChecked = FALSE;
  5300. switch( msg )
  5301. {
  5302. case WM_INITDIALOG:
  5303. EnableDBCSChars(hDlg, IDC_UASTRING);
  5304. Edit_LimitText(GetDlgItem(hDlg, IDC_UASTRING), MAX_PATH - 1);
  5305. g_hWizard = hDlg;
  5306. break;
  5307. case IDM_BATCHADVANCE:
  5308. DoBatchAdvance(hDlg);
  5309. break;
  5310. case WM_HELP:
  5311. IeakPageHelp(hDlg, g_psp[g_iCurPage].pszTemplate);
  5312. break;
  5313. case WM_COMMAND:
  5314. if (GET_WM_COMMAND_CMD(wParam, lParam) != BN_CLICKED)
  5315. return FALSE;
  5316. switch (GET_WM_COMMAND_ID(wParam, lParam))
  5317. {
  5318. case IDC_UASTRINGCHECK:
  5319. fChecked = (IsDlgButtonChecked(hDlg, IDC_UASTRINGCHECK) == BST_CHECKED);
  5320. EnableDlgItem2(hDlg, IDC_UASTRING, fChecked);
  5321. EnableDlgItem2(hDlg, IDC_UASTRING_TXT, fChecked);
  5322. break;
  5323. default:
  5324. return FALSE;
  5325. }
  5326. break;
  5327. case WM_NOTIFY:
  5328. switch (((NMHDR FAR *) lParam)->code)
  5329. {
  5330. case PSN_HELP:
  5331. IeakPageHelp(hDlg, g_psp[g_iCurPage].pszTemplate);
  5332. break;
  5333. case PSN_SETACTIVE:
  5334. SetBannerText(hDlg);
  5335. SetDlgItemTextFromIns(hDlg, IDC_UASTRING, IDC_UASTRINGCHECK, IS_BRANDING,
  5336. USER_AGENT, g_szCustIns, NULL, INSIO_TRISTATE);
  5337. EnableDlgItem2(hDlg, IDC_UASTRING_TXT, (IsDlgButtonChecked(hDlg, IDC_UASTRINGCHECK) == BST_CHECKED));
  5338. CheckBatchAdvance(hDlg);
  5339. break;
  5340. case PSN_WIZBACK:
  5341. case PSN_WIZNEXT:
  5342. g_iCurPage = PPAGE_UASTRDLG;
  5343. WriteDlgItemTextToIns(hDlg, IDC_UASTRING, IDC_UASTRINGCHECK, IS_BRANDING,
  5344. USER_AGENT, g_szCustIns, NULL, INSIO_TRISTATE);
  5345. EnablePages();
  5346. (((LPNMHDR)lParam)->code == PSN_WIZNEXT) ? PageNext(hDlg) : PagePrev(hDlg);
  5347. break;
  5348. case PSN_QUERYCANCEL:
  5349. QueryCancel(hDlg);
  5350. break;
  5351. default:
  5352. return FALSE;
  5353. }
  5354. break;
  5355. default:
  5356. return FALSE;
  5357. }
  5358. return TRUE;
  5359. }
  5360. INT_PTR CALLBACK ActiveSetupDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
  5361. {
  5362. TCHAR szActSetupTitle[50];
  5363. switch (uMsg)
  5364. {
  5365. case WM_INITDIALOG:
  5366. EnableDBCSChars(hDlg, IDE_TITLE);
  5367. EnableDBCSChars(hDlg, IDE_WIZBITMAPPATH);
  5368. EnableDBCSChars(hDlg, IDE_WIZBITMAPPATH2);
  5369. EnableDBCSChars(hDlg, IDC_CCTITLE);
  5370. Edit_LimitText(GetDlgItem(hDlg, IDE_TITLE), countof(szActSetupTitle) - 1);
  5371. Edit_LimitText(GetDlgItem(hDlg, IDE_WIZBITMAPPATH), MAX_PATH - 1);
  5372. Edit_LimitText(GetDlgItem(hDlg, IDE_WIZBITMAPPATH2), MAX_PATH - 1);
  5373. Edit_LimitText(GetDlgItem(hDlg, IDC_CCTITLE), countof(g_szCustItems) - 1);
  5374. break;
  5375. case WM_NOTIFY:
  5376. switch (((NMHDR FAR *) lParam)->code)
  5377. {
  5378. case PSN_SETACTIVE:
  5379. {
  5380. TCHAR szActSetupBitmap[MAX_PATH];
  5381. SetBannerText(hDlg);
  5382. // IEAKLite mode clean-up: delete the bmp files from the temp dir
  5383. DeleteFileInDir(TEXT("actsetup.bmp"), g_szBuildTemp);
  5384. DeleteFileInDir(TEXT("topsetup.bmp"), g_szBuildTemp);
  5385. // read title
  5386. GetPrivateProfileString(IS_ACTIVESETUP, IK_WIZTITLE, TEXT(""), szActSetupTitle, countof(szActSetupTitle), g_szCustIns);
  5387. SetDlgItemText(hDlg, IDE_TITLE, szActSetupTitle);
  5388. // read left bitmap path
  5389. GetPrivateProfileString(IS_ACTIVESETUP, IK_WIZBMP, TEXT(""), szActSetupBitmap, countof(szActSetupBitmap), g_szCustIns);
  5390. SetDlgItemText(hDlg, IDE_WIZBITMAPPATH, szActSetupBitmap);
  5391. // read top banner bitmap path
  5392. if (IsWindowEnabled(GetDlgItem(hDlg, IDE_WIZBITMAPPATH2)))
  5393. {
  5394. GetPrivateProfileString(IS_ACTIVESETUP, IK_WIZBMP2, TEXT(""), szActSetupBitmap, countof(szActSetupBitmap), g_szCustIns);
  5395. SetDlgItemText(hDlg, IDE_WIZBITMAPPATH2, szActSetupBitmap);
  5396. }
  5397. // read cutom components title
  5398. if (g_nCustComp)
  5399. {
  5400. GetPrivateProfileString(STRINGS, CUSTITEMS, TEXT(""), g_szCustItems, countof(g_szCustItems), g_szCustInf);
  5401. if (*g_szCustItems == TEXT('\0'))
  5402. LoadString(g_rvInfo.hInst, IDS_CUSTOMCOMPTITLE, g_szCustItems, countof(g_szCustItems));
  5403. }
  5404. else
  5405. *g_szCustItems = TEXT('\0');
  5406. SetDlgItemText(hDlg, IDC_CCTITLE, g_szCustItems);
  5407. EnableDlgItem2(hDlg, IDC_CCTITLE, *g_szCustItems ? TRUE : FALSE);
  5408. EnableDlgItem2(hDlg, IDC_CCTITLE_TXT, *g_szCustItems ? TRUE : FALSE);
  5409. PropSheet_SetWizButtons(GetParent(hDlg), PSWIZB_NEXT | PSWIZB_BACK);
  5410. CheckBatchAdvance(hDlg);
  5411. break;
  5412. }
  5413. case PSN_WIZBACK:
  5414. case PSN_WIZNEXT:
  5415. {
  5416. TCHAR szActSetupBitmap[MAX_PATH] = TEXT(""),
  5417. szActSetupBitmap2[MAX_PATH] = TEXT("");
  5418. LPCTSTR pszTmp;
  5419. if (!IsBitmapFileValid(hDlg, IDE_WIZBITMAPPATH, szActSetupBitmap, NULL, 164, 312, IDS_TOOBIG164x312, IDS_TOOSMALL164x312))
  5420. {
  5421. SetWindowLongPtr(hDlg, DWLP_MSGRESULT, -1);
  5422. return TRUE;
  5423. }
  5424. // error checking for top bitmap
  5425. if (IsWindowEnabled(GetDlgItem(hDlg, IDE_WIZBITMAPPATH2)))
  5426. {
  5427. if (!IsBitmapFileValid(hDlg, IDE_WIZBITMAPPATH2, szActSetupBitmap2, NULL, 496, 56, IDS_TOOBIG496x56, IDS_TOOSMALL496x56))
  5428. {
  5429. SetWindowLongPtr(hDlg, DWLP_MSGRESULT, -1);
  5430. return TRUE;
  5431. }
  5432. }
  5433. else
  5434. *szActSetupBitmap2 = TEXT('\0');
  5435. // error checking for custom components title
  5436. if (IsWindowEnabled(GetDlgItem(hDlg, IDC_CCTITLE)))
  5437. {
  5438. GetDlgItemText(hDlg, IDC_CCTITLE, g_szCustItems, countof(g_szCustItems));
  5439. if (*g_szCustItems == TEXT('\0'))
  5440. {
  5441. ErrorMessageBox(hDlg, IDS_CUSTOMCOMPTITLE_ERROR);
  5442. SetFocus(GetDlgItem(hDlg, IDC_CCTITLE));
  5443. SetWindowLongPtr(hDlg, DWLP_MSGRESULT, -1);
  5444. return TRUE;
  5445. }
  5446. }
  5447. else
  5448. *g_szCustItems = TEXT('\0');
  5449. // write title
  5450. GetDlgItemText(hDlg, IDE_TITLE, szActSetupTitle, countof(szActSetupTitle));
  5451. pszTmp = (*szActSetupTitle ? szActSetupTitle : NULL);
  5452. WritePrivateProfileString(IS_ACTIVESETUP, IK_WIZTITLE, pszTmp, g_szCustIns);
  5453. InsWriteQuotedString(BRANDING, IK_WIZTITLE, pszTmp, g_szCustInf);
  5454. // write left bitmap path
  5455. if (*szActSetupBitmap)
  5456. {
  5457. TCHAR szDest[MAX_PATH];
  5458. pszTmp = szActSetupBitmap;
  5459. PathCombine(szDest, g_szBuildTemp, TEXT("actsetup.bmp"));
  5460. CopyFile(szActSetupBitmap, szDest, FALSE);
  5461. }
  5462. else
  5463. pszTmp = NULL;
  5464. InsWriteQuotedString(IS_ACTIVESETUP, IK_WIZBMP, pszTmp, g_szCustIns);
  5465. InsWriteQuotedString(BRANDING, IK_WIZBMP, pszTmp != NULL ? TEXT("actsetup.bmp") : NULL, g_szCustInf);
  5466. // write top bitmap path
  5467. if (*szActSetupBitmap2)
  5468. {
  5469. TCHAR szDest[MAX_PATH];
  5470. pszTmp = szActSetupBitmap2;
  5471. PathCombine(szDest, g_szBuildTemp, TEXT("topsetup.bmp"));
  5472. CopyFile(szActSetupBitmap2, szDest, FALSE);
  5473. }
  5474. else
  5475. pszTmp = NULL;
  5476. InsWriteQuotedString(IS_ACTIVESETUP, IK_WIZBMP2, pszTmp, g_szCustIns);
  5477. InsWriteQuotedString(BRANDING, IK_WIZBMP2, pszTmp != NULL ? TEXT("topsetup.bmp") : NULL, g_szCustInf);
  5478. // write custom components title
  5479. pszTmp = (*g_szCustItems ? g_szCustItems : NULL);
  5480. InsWriteQuotedString(STRINGS, CUSTITEMS, pszTmp, g_szCustInf);
  5481. g_iCurPage = PPAGE_SETUPWIZARD;
  5482. EnablePages();
  5483. (((NMHDR FAR *) lParam)->code == PSN_WIZNEXT) ? PageNext(hDlg) : PagePrev(hDlg);
  5484. break;
  5485. }
  5486. case PSN_HELP:
  5487. IeakPageHelp(hDlg, g_psp[g_iCurPage].pszTemplate);
  5488. break;
  5489. case PSN_QUERYCANCEL:
  5490. QueryCancel(hDlg);
  5491. break;
  5492. default:
  5493. return FALSE;
  5494. }
  5495. break;
  5496. case WM_COMMAND:
  5497. switch (HIWORD(wParam))
  5498. {
  5499. case BN_CLICKED:
  5500. switch(LOWORD(wParam))
  5501. {
  5502. TCHAR szActSetupBitmap[MAX_PATH];
  5503. case IDC_BROWSEWIZPATH:
  5504. GetDlgItemText(hDlg, IDE_WIZBITMAPPATH, szActSetupBitmap, countof(szActSetupBitmap));
  5505. if (BrowseForFile(hDlg, szActSetupBitmap, countof(szActSetupBitmap), GFN_BMP))
  5506. SetDlgItemText(hDlg, IDE_WIZBITMAPPATH, szActSetupBitmap);
  5507. break;
  5508. case IDC_BROWSEWIZPATH2:
  5509. GetDlgItemText(hDlg, IDE_WIZBITMAPPATH2, szActSetupBitmap, countof(szActSetupBitmap));
  5510. if (BrowseForFile(hDlg, szActSetupBitmap, countof(szActSetupBitmap), GFN_BMP))
  5511. SetDlgItemText(hDlg, IDE_WIZBITMAPPATH2, szActSetupBitmap);
  5512. break;
  5513. }
  5514. break;
  5515. }
  5516. break;
  5517. case WM_HELP:
  5518. IeakPageHelp(hDlg, g_psp[g_iCurPage].pszTemplate);
  5519. break;
  5520. case IDM_BATCHADVANCE:
  5521. DoBatchAdvance(hDlg);
  5522. break;
  5523. default:
  5524. return FALSE;
  5525. }
  5526. return TRUE;
  5527. }
  5528. #define MINCMAKVER TEXT("4.71.0819.0")
  5529. BOOL g_fCustomICMPro = FALSE;
  5530. INT_PTR CALLBACK InternetConnMgr(
  5531. HWND hDlg,
  5532. UINT message,
  5533. WPARAM wParam,
  5534. LPARAM lParam)
  5535. {
  5536. TCHAR szCmd[MAX_PATH+8];
  5537. LPTSTR pName;
  5538. DWORD dwSize;
  5539. switch (message)
  5540. {
  5541. case WM_INITDIALOG:
  5542. g_hWizard = hDlg;
  5543. InitSysFont( hDlg, IDE_ICMPRO);
  5544. //BUGBUG: (a-saship) for now disable CMAK and once its confirmed remove all references to CMAK
  5545. DisableDlgItem(hDlg, IDC_STARTCMAK);
  5546. HideDlgItem(hDlg, IDC_STARTCMAK);
  5547. HideDlgItem(hDlg, IDC_CMAKICON);
  5548. break;
  5549. case IDM_BATCHADVANCE:
  5550. DoBatchAdvance(hDlg);
  5551. break;
  5552. case WM_HELP:
  5553. IeakPageHelp(hDlg, g_psp[g_iCurPage].pszTemplate);
  5554. break;
  5555. case WM_COMMAND:
  5556. if (HIWORD(wParam) == BN_CLICKED)
  5557. switch(LOWORD(wParam))
  5558. {
  5559. case IDC_BROWSEICMPRO:
  5560. GetDlgItemText(hDlg, IDE_ICMPRO, g_szCustIcmPro, countof(g_szCustIcmPro));
  5561. if (BrowseForFile(hDlg, g_szCustIcmPro, countof(g_szCustIcmPro), GFN_EXE))
  5562. SetDlgItemText(hDlg, IDE_ICMPRO, g_szCustIcmPro);
  5563. break;
  5564. case IDC_ICMPROCHECK:
  5565. g_fCustomICMPro = (IsDlgButtonChecked( hDlg, IDC_ICMPROCHECK ) == BST_CHECKED);
  5566. EnableDlgItem2(hDlg, IDE_ICMPRO, g_fCustomICMPro);
  5567. EnableDlgItem2(hDlg, IDC_BROWSEICMPRO, g_fCustomICMPro);
  5568. EnableDlgItem2(hDlg, IDC_ICMPRO_TXT, g_fCustomICMPro);
  5569. break;
  5570. case IDC_STARTCMAK:
  5571. dwSize = sizeof(szCmd);
  5572. if (SHGetValue(HKEY_LOCAL_MACHINE, CURRENTVERSIONKEY TEXT("\\App Paths\\cmak.exe"), NULL, NULL,
  5573. (LPVOID)szCmd, &dwSize) == ERROR_SUCCESS)
  5574. {
  5575. DWORD dwExitCode;
  5576. StrCat(szCmd, TEXT(" /i"));
  5577. if (RunAndWait(szCmd, g_szWizRoot, SW_SHOW, &dwExitCode) && (dwExitCode == IDOK))
  5578. {
  5579. dwSize = sizeof(g_szCustIcmPro);
  5580. if (SHGetValue(HKEY_LOCAL_MACHINE, TEXT("Software\\Microsoft\\Connection Manager Administration Kit"),
  5581. TEXT("Output"), NULL, (LPVOID)g_szCustIcmPro, &dwSize) == ERROR_SUCCESS)
  5582. {
  5583. g_fCustomICMPro = TRUE;
  5584. EnableDlgItem2(hDlg, IDE_ICMPRO, g_fCustomICMPro);
  5585. EnableDlgItem2(hDlg, IDC_BROWSEICMPRO, g_fCustomICMPro);
  5586. EnableDlgItem2(hDlg, IDC_ICMPRO_TXT, g_fCustomICMPro);
  5587. SetDlgItemText(hDlg, IDE_ICMPRO, g_szCustIcmPro);
  5588. CheckDlgButton(hDlg, IDC_ICMPROCHECK, BST_CHECKED);
  5589. }
  5590. }
  5591. }
  5592. else
  5593. ErrorMessageBox(hDlg, IDS_NOCMAK);
  5594. break;
  5595. }
  5596. break;
  5597. case WM_NOTIFY:
  5598. switch (((NMHDR FAR *) lParam)->code)
  5599. {
  5600. case PSN_HELP:
  5601. IeakPageHelp(hDlg, g_psp[g_iCurPage].pszTemplate);
  5602. break;
  5603. case PSN_SETACTIVE:
  5604. SetBannerText(hDlg);
  5605. g_fCustomICMPro = GetPrivateProfileInt( BRANDING, CMUSECUSTOM, 0, g_szCustIns );
  5606. CheckDlgButton( hDlg, IDC_ICMPROCHECK, g_fCustomICMPro );
  5607. GetPrivateProfileString( BRANDING, CMPROFILEPATH, TEXT(""),
  5608. g_szCustIcmPro, countof(g_szCustIcmPro), g_szCustIns );
  5609. SetDlgItemText( hDlg, IDE_ICMPRO, g_szCustIcmPro );
  5610. EnableDlgItem2(hDlg, IDE_ICMPRO, g_fCustomICMPro);
  5611. EnableDlgItem2(hDlg, IDC_BROWSEICMPRO, g_fCustomICMPro);
  5612. EnableDlgItem2(hDlg, IDC_ICMPRO_TXT, g_fCustomICMPro);
  5613. PropSheet_SetWizButtons(GetParent(hDlg), PSWIZB_NEXT | PSWIZB_BACK);
  5614. CheckBatchAdvance(hDlg);
  5615. break;
  5616. case PSN_WIZBACK:
  5617. case PSN_WIZNEXT:
  5618. GetDlgItemText( hDlg, IDE_ICMPRO, g_szCustIcmPro, countof(g_szCustIcmPro) );
  5619. if(IsDlgButtonChecked(hDlg, IDC_ICMPROCHECK) == BST_CHECKED && !CheckField(hDlg, IDE_ICMPRO, FC_NONNULL | FC_FILE | FC_EXISTS))
  5620. {
  5621. SetWindowLongPtr(hDlg, DWLP_MSGRESULT, -1);
  5622. return TRUE;
  5623. }
  5624. WritePrivateProfileString( BRANDING, CMPROFILEPATH, g_szCustIcmPro, g_szCustIns );
  5625. pName = StrRChr(g_szCustIcmPro, NULL, TEXT('\\'));
  5626. if (pName) pName++;
  5627. else pName = g_szCustIcmPro;
  5628. WritePrivateProfileString( BRANDING, CMPROFILENAME, pName, g_szCustIns );
  5629. WritePrivateProfileString( BRANDING, CMUSECUSTOM, (g_fCustomICMPro ? TEXT("1") : TEXT("0")), g_szCustIns);
  5630. if (g_fCustomICMPro)
  5631. {
  5632. TCHAR szDisplayName[MAX_PATH];
  5633. TCHAR szGUID[MAX_PATH];
  5634. TCHAR szUrl[80];
  5635. TCHAR szVersion[64];
  5636. LPTSTR pFile, pDot;
  5637. DWORD dwVer, dwBuild;
  5638. GUID guid;
  5639. GetVersionFromFileWrap(g_szCustIcmPro, &dwVer, &dwBuild, TRUE);
  5640. ConvertDwordsToVersionStr(szVersion, dwVer, dwBuild);
  5641. if (CheckVer(szVersion, MINCMAKVER) <= 0)
  5642. {
  5643. ErrorMessageBox(hDlg, IDS_ERROR_CMAKVER);
  5644. SetWindowLongPtr(hDlg, DWLP_MSGRESULT, -1);
  5645. return TRUE;
  5646. }
  5647. GetPrivateProfileString( CUSTCMSECT, TEXT("GUID"), TEXT(""), szGUID, countof(szGUID), g_szCustCif );
  5648. if (ISNULL(szGUID))
  5649. {
  5650. if (CoCreateGuid(&guid) == NOERROR)
  5651. CoStringFromGUID(guid, szGUID, countof(szGUID));
  5652. }
  5653. LoadString( g_rvInfo.hInst, IDS_CUSTICMPRO, szDisplayName, countof(szDisplayName) );
  5654. InsWriteQuotedString( CUSTCMSECT, TEXT("DisplayName"), szDisplayName, g_szCustCif );
  5655. InsWriteQuotedString( CUSTCMSECT, TEXT("GUID"), szGUID, g_szCustCif );
  5656. InsWriteQuotedString( CUSTCMSECT, TEXT("Command1"), pName, g_szCustCif );
  5657. wnsprintf(szUrl, countof(szUrl), TEXT("%s"), pName);
  5658. WritePrivateProfileString( CUSTCMSECT, TEXT("URL1"), szUrl, g_szCustCif );
  5659. pFile = PathFindFileName(g_szCustIcmPro);
  5660. pDot = StrChr(pFile, TEXT('.'));
  5661. if (pDot)
  5662. *pDot = TEXT('\0');
  5663. wnsprintf(szDisplayName, countof(szDisplayName), TEXT("/q:a /r:n /c:\"cmstp.exe /i %s.inf\""), pFile);
  5664. if (pDot)
  5665. *pDot = TEXT('.');
  5666. InsWriteQuotedString( CUSTCMSECT, TEXT("Switches1"), szDisplayName, g_szCustCif );
  5667. WritePrivateProfileString( CUSTCMSECT, TEXT("Type1"), TEXT("2"), g_szCustCif );
  5668. // bump up the version number if it already exists, otherwise use the defined version in
  5669. // iedkbrnd.h
  5670. if (GetPrivateProfileString( CUSTCMSECT, VERSION, g_szJobVersion, szVersion, countof(szVersion), g_szCustCif ))
  5671. {
  5672. LPTSTR pComma;
  5673. INT iVer;
  5674. pComma = StrRChr(szVersion, NULL, TEXT(','));
  5675. if (pComma == NULL)
  5676. pComma = szVersion;
  5677. iVer = StrToInt( pComma + 1 );
  5678. iVer++;
  5679. wnsprintf(pComma, MAX_PATH, TEXT(",%i"), iVer);
  5680. WritePrivateProfileString(CUSTCMSECT, VERSION, szVersion, g_szCustCif);
  5681. }
  5682. }
  5683. else
  5684. {
  5685. WritePrivateProfileString( CUSTCMSECT, NULL, NULL, g_szCustCif );
  5686. }
  5687. g_iCurPage = PPAGE_ICM;
  5688. EnablePages();
  5689. if (((NMHDR FAR *) lParam)->code == PSN_WIZNEXT) PageNext(hDlg);
  5690. else
  5691. {
  5692. PagePrev(hDlg);
  5693. }
  5694. break;
  5695. case PSN_QUERYCANCEL:
  5696. QueryCancel(hDlg);
  5697. break;
  5698. default:
  5699. return FALSE;
  5700. }
  5701. break;
  5702. default:
  5703. return FALSE;
  5704. }
  5705. return TRUE;
  5706. }