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.

499 lines
17 KiB

  1. //*********************************************************************
  2. //* Microsoft Windows **
  3. //* Copyright(c) Microsoft Corp., 1994 **
  4. //*********************************************************************
  5. //
  6. // INTRO.C - Functions for introductory Wizard pages
  7. //
  8. // HISTORY:
  9. //
  10. // 05/13/98 donaldm Created.
  11. //
  12. //*********************************************************************
  13. #include "pre.h"
  14. #include "windowsx.h"
  15. #include "tutor.h"
  16. #include "icwcfg.h"
  17. #include "icwextsn.h"
  18. extern UINT GetDlgIDFromIndex(UINT uPageIndex);
  19. extern CICWTutorApp* g_pICWTutorApp;
  20. extern BOOL g_bNewIspPath;
  21. extern BOOL g_bAutoConfigPath;
  22. extern BOOL g_bManualPath;
  23. extern BOOL g_bLanPath;
  24. extern BOOL g_bSkipIntro;
  25. extern BOOL MyIsSmartStartEx(LPTSTR lpszConnectionName, DWORD dwBufLen);
  26. BOOL g_bExistConnect = FALSE;
  27. BOOL g_bCheckForOEM = FALSE;
  28. TCHAR g_szAnsiName [ICW_MAX_RASNAME + 1] = TEXT("\0");
  29. /*******************************************************************
  30. NAME: ReadOEMOffline
  31. SYNOPSIS: Read OfflineOffers flag from the oeminfo.ini file
  32. ENTRY: None
  33. RETURN: True if OEM offline is read
  34. ********************************************************************/
  35. BOOL ReadOEMOffline(BOOL *bOEMOffline)
  36. {
  37. // OEM code
  38. //
  39. TCHAR szOeminfoPath[MAX_PATH + 1];
  40. TCHAR *lpszTerminator = NULL;
  41. TCHAR *lpszLastChar = NULL;
  42. BOOL bRet = FALSE;
  43. // If we already checked, don't do it again
  44. if (!g_bCheckForOEM)
  45. {
  46. if( 0 != GetSystemDirectory( szOeminfoPath, MAX_PATH + 1 ) )
  47. {
  48. lpszTerminator = &(szOeminfoPath[ lstrlen(szOeminfoPath) ]);
  49. lpszLastChar = CharPrev( szOeminfoPath, lpszTerminator );
  50. if( TEXT('\\') != *lpszLastChar )
  51. {
  52. lpszLastChar = CharNext( lpszLastChar );
  53. *lpszLastChar = '\\';
  54. lpszLastChar = CharNext( lpszLastChar );
  55. *lpszLastChar = '\0';
  56. }
  57. lstrcat( szOeminfoPath, ICW_OEMINFO_FILENAME );
  58. //Default oem code must be NULL if it doesn't exist in oeminfo.ini
  59. if (1 == GetPrivateProfileInt(ICW_OEMINFO_ICWSECTION,
  60. ICW_OEMINFO_OFFLINEOFFERS,
  61. 0,
  62. szOeminfoPath))
  63. {
  64. // Check if file already exists
  65. if (0xFFFFFFFF != GetFileAttributes(ICW_OEMINFOPath))
  66. {
  67. bRet = TRUE;
  68. }
  69. }
  70. }
  71. *bOEMOffline = bRet;
  72. g_bCheckForOEM = TRUE;
  73. }
  74. return TRUE;
  75. }
  76. /*******************************************************************
  77. NAME: SetNextPage
  78. SYNOPSIS: Determine whether we should proceed to icwconn.dll
  79. ********************************************************************/
  80. BOOL SetNextPage(HWND hDlg, UINT* puNextPage, BOOL *pfKeepHistory)
  81. {
  82. BOOL bRetVal = FALSE;
  83. // If we have switched path, then redownload
  84. if (gpWizardState->bDoneRefServDownload)
  85. {
  86. if ( (DWORD) (gpWizardState->cmnStateData.dwFlags & ICW_CFGFLAG_AUTOCONFIG) !=
  87. (DWORD) (gpWizardState->dwLastSelection & ICW_CFGFLAG_AUTOCONFIG) )
  88. {
  89. gpWizardState->bDoneRefServDownload = FALSE;
  90. }
  91. }
  92. // Read OEM offline flag
  93. ReadOEMOffline(&gpWizardState->cmnStateData.bOEMOffline);
  94. //
  95. // Make sure we are not in autoconfig
  96. //
  97. if (!(gpWizardState->cmnStateData.dwFlags & ICW_CFGFLAG_AUTOCONFIG))
  98. {
  99. if (gpWizardState->cmnStateData.bOEMOffline && gpWizardState->cmnStateData.bOEMEntryPt)
  100. gpWizardState->bDoneRefServDownload = TRUE;
  101. }
  102. gpWizardState->dwLastSelection = gpWizardState->cmnStateData.dwFlags;
  103. // If we have completed the download, then list just jump to the next page
  104. if (gpWizardState->bDoneRefServDownload)
  105. //if (TRUE)
  106. {
  107. int iReturnPage = 0;
  108. if (gpWizardState->cmnStateData.dwFlags & ICW_CFGFLAG_BRANDED)
  109. iReturnPage = gpWizardState->uPageHistory[gpWizardState->uPagesCompleted];
  110. else
  111. {
  112. if (gpWizardState->uPagesCompleted > 0)
  113. {
  114. iReturnPage = gpWizardState->uPageHistory[gpWizardState->uPagesCompleted-1];
  115. }
  116. else
  117. {
  118. iReturnPage = gpWizardState->uCurrentPage;
  119. }
  120. }
  121. if (LoadICWCONNUI(GetParent(hDlg), GetDlgIDFromIndex(iReturnPage), IDD_PAGE_DEFAULT, gpWizardState->cmnStateData.dwFlags))
  122. {
  123. if( DialogIDAlreadyInUse( g_uICWCONNUIFirst) )
  124. {
  125. // we're about to jump into the external apprentice, and we don't want
  126. // this page to show up in our history list
  127. *puNextPage = g_uICWCONNUIFirst;
  128. // Backup 1 in the history list, since we the external pages navigate back
  129. // we want this history list to be in the correct spot. Normally
  130. // pressing back would back up the history list, and figure out where to
  131. // go, but in this case, the external DLL just jumps right back in.
  132. // We also don't want to keep histroy.
  133. if (!(gpWizardState->cmnStateData.dwFlags & ICW_CFGFLAG_BRANDED))
  134. {
  135. if (gpWizardState->uPagesCompleted > 0)
  136. {
  137. gpWizardState->uPagesCompleted--;
  138. }
  139. else
  140. {
  141. if (pfKeepHistory)
  142. {
  143. *pfKeepHistory = FALSE;
  144. }
  145. }
  146. }
  147. bRetVal = TRUE;
  148. }
  149. }
  150. }
  151. return bRetVal;
  152. }
  153. /*******************************************************************
  154. NAME: SetIntroNextPage
  155. SYNOPSIS: Determine whether we what is the next page of intro page
  156. ********************************************************************/
  157. void SetIntroNextPage(HWND hDlg, UINT* puNextPage, BOOL *pfKeepHistory)
  158. {
  159. short wNumLocations;
  160. long lCurrLocIndex;
  161. BOOL bRetVal;
  162. *puNextPage = ORD_PAGE_AREACODE;
  163. // Check dialing location here to prevent flashing of areacode page
  164. gpWizardState->pTapiLocationInfo->GetTapiLocationInfo(&bRetVal);
  165. gpWizardState->pTapiLocationInfo->get_wNumberOfLocations(&wNumLocations, &lCurrLocIndex);
  166. if (1 >= wNumLocations)
  167. {
  168. BSTR bstrAreaCode = NULL;
  169. DWORD dwCountryCode;
  170. *puNextPage = ORD_PAGE_REFSERVDIAL;
  171. gpWizardState->pTapiLocationInfo->get_lCountryCode((long *)&dwCountryCode);
  172. gpWizardState->pTapiLocationInfo->get_bstrAreaCode(&bstrAreaCode);
  173. gpWizardState->cmnStateData.dwCountryCode = dwCountryCode;
  174. lstrcpy(gpWizardState->cmnStateData.szAreaCode, W2A(bstrAreaCode));
  175. SysFreeString(bstrAreaCode);
  176. // we can skip area code page
  177. *puNextPage = ORD_PAGE_REFSERVDIAL;
  178. SetNextPage(hDlg, puNextPage, pfKeepHistory);
  179. }
  180. }
  181. INT_PTR CALLBACK ExistingConnectionCmdProc
  182. (
  183. HWND hDlg,
  184. UINT uMsg,
  185. WPARAM wParam,
  186. LPARAM lParam
  187. )
  188. {
  189. switch (uMsg)
  190. {
  191. case WM_INITDIALOG:
  192. {
  193. // put the dialog in the center of the screen
  194. RECT rc;
  195. TCHAR szFmt [MAX_MESSAGE_LEN];
  196. TCHAR *args [1];
  197. LPVOID pszIntro = NULL;
  198. GetWindowRect(hDlg, &rc);
  199. SetWindowPos(hDlg,
  200. NULL,
  201. ((GetSystemMetrics(SM_CXSCREEN) - (rc.right - rc.left)) / 2),
  202. ((GetSystemMetrics(SM_CYSCREEN) - (rc.bottom - rc.top)) / 2),
  203. 0, 0, SWP_NOSIZE | SWP_NOACTIVATE);
  204. args[0] = (LPTSTR) lParam;
  205. LoadString(g_hInstance, IDS_EXIT_CONN, szFmt, ARRAYSIZE(szFmt));
  206. if (FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_ARGUMENT_ARRAY,
  207. szFmt,
  208. 0,
  209. 0,
  210. (LPTSTR)&pszIntro,
  211. 0,
  212. (va_list*)args))
  213. {
  214. SetWindowText(GetDlgItem(hDlg, IDC_EXIT_CONN), (LPTSTR) pszIntro);
  215. }
  216. if (pszIntro)
  217. {
  218. LocalFree(pszIntro);
  219. }
  220. break;
  221. }
  222. case WM_COMMAND:
  223. switch (LOWORD(wParam))
  224. {
  225. case IDOK:
  226. EndDialog(hDlg,TRUE);
  227. break;
  228. case IDCANCEL:
  229. EndDialog(hDlg,FALSE);
  230. break;
  231. }
  232. break;
  233. }
  234. return FALSE;
  235. }
  236. /*******************************************************************
  237. NAME: IntroInitProc
  238. SYNOPSIS: Called when "Intro" page is displayed
  239. ENTRY: hDlg - dialog window
  240. fFirstInit - TRUE if this is the first time the dialog
  241. is initialized, FALSE if this InitProc has been called
  242. before (e.g. went past this page and backed up)
  243. ********************************************************************/
  244. BOOL CALLBACK IntroInitProc
  245. (
  246. HWND hDlg,
  247. BOOL fFirstInit,
  248. UINT *puNextPage
  249. )
  250. {
  251. if (!(gpWizardState->cmnStateData.dwFlags & ICW_CFGFLAG_BRANDED)
  252. &&!(gpWizardState->cmnStateData.bOEMCustom)
  253. )
  254. {
  255. // This is the very first page, so do not allow back
  256. PropSheet_SetWizButtons(GetParent(hDlg),PSWIZB_NEXT);
  257. }
  258. if (fFirstInit)
  259. {
  260. //#ifdef NON_NT5
  261. // Hide the manual option when running in run once
  262. if (g_bRunOnce)
  263. {
  264. ShowWindow(GetDlgItem(hDlg, IDC_ICWMAN), SW_HIDE);
  265. EnableWindow(GetDlgItem(hDlg, IDC_ICWMAN), FALSE);
  266. }
  267. // initialize radio buttons
  268. Button_SetCheck(GetDlgItem(hDlg, IDC_RUNNEW), g_bNewIspPath);
  269. Button_SetCheck(GetDlgItem(hDlg, IDC_RUNAUTO), g_bAutoConfigPath);
  270. Button_SetCheck(GetDlgItem(hDlg, IDC_ICWMAN), g_bManualPath || g_bLanPath);
  271. if (SMART_QUITICW == MyIsSmartStartEx(g_szAnsiName, ARRAYSIZE(g_szAnsiName)))
  272. g_bExistConnect = TRUE;
  273. /* #else
  274. //We only support manual path for NT5 for NT5 beta3 release.
  275. EnableWindow(GetDlgItem(hDlg, IDC_RUNNEW), FALSE);
  276. EnableWindow(GetDlgItem(hDlg, IDC_RUNAUTO), FALSE);
  277. Button_SetCheck(GetDlgItem(hDlg, IDC_ICWMAN), TRUE);
  278. #endif */
  279. }
  280. else
  281. {
  282. // If branded, then our template is intro2
  283. if ((gpWizardState->cmnStateData.dwFlags & ICW_CFGFLAG_BRANDED)
  284. || (gpWizardState->cmnStateData.bOEMCustom)
  285. )
  286. {
  287. gpWizardState->uCurrentPage = ORD_PAGE_INTRO2;
  288. }
  289. else
  290. {
  291. gpWizardState->uCurrentPage = ORD_PAGE_INTRO;
  292. }
  293. // If it is reboot from manual wiz, advance to the manual option page
  294. if (g_bManualPath || g_bLanPath)
  295. {
  296. gpWizardState->uPageHistory[gpWizardState->uPagesCompleted] = gpWizardState->uCurrentPage;
  297. gpWizardState->uPagesCompleted++;
  298. TCHAR szTitle[MAX_TITLE];
  299. LoadString(g_hInstance, IDS_APPNAME, szTitle, ARRAYSIZE(szTitle));
  300. SetWindowText(GetParent(hDlg), szTitle);
  301. *puNextPage = ORD_PAGE_MANUALOPTIONS;
  302. }
  303. if (g_bSkipIntro)
  304. {
  305. PropSheet_PressButton(GetParent(hDlg), PSBTN_NEXT);
  306. g_bSkipIntro = FALSE;
  307. }
  308. }
  309. return TRUE;
  310. }
  311. /*******************************************************************
  312. NAME: IntroOKProc
  313. SYNOPSIS: Called when Next or Back btns pressed from "Intro" page
  314. ENTRY: hDlg - dialog window
  315. fForward - TRUE if 'Next' was pressed, FALSE if 'Back'
  316. puNextPage - if 'Next' was pressed,
  317. proc can fill this in with next page to go to. This
  318. parameter is ingored if 'Back' was pressed.
  319. pfKeepHistory - page will not be kept in history if
  320. proc fills this in with FALSE.
  321. EXIT: returns TRUE to allow page to be turned, FALSE
  322. to keep the same page.
  323. ********************************************************************/
  324. BOOL CALLBACK IntroOKProc
  325. (
  326. HWND hDlg,
  327. BOOL fForward,
  328. UINT *puNextPage,
  329. BOOL *pfKeepHistory
  330. )
  331. {
  332. ASSERT(puNextPage);
  333. if (fForward)
  334. {
  335. gpWizardState->lRefDialTerminateStatus = ERROR_SUCCESS;
  336. gpWizardState->cmnStateData.dwFlags &= ~(DWORD)ICW_CFGFLAG_AUTOCONFIG;
  337. gpWizardState->cmnStateData.dwFlags &= ~(DWORD)ICW_CFGFLAG_SMARTREBOOT_NEWISP;
  338. gpWizardState->cmnStateData.dwFlags &= ~(DWORD)ICW_CFGFLAG_SMARTREBOOT_AUTOCONFIG; // this is seperate from ICW_CFGFLAG_AUTOCONFIG so as not to confuse function of flag
  339. gpWizardState->cmnStateData.dwFlags &= ~(DWORD)ICW_CFGFLAG_SMARTREBOOT_MANUAL;
  340. gpWizardState->cmnStateData.dwFlags &= ~(DWORD)ICW_CFGFLAG_SMARTREBOOT_LAN;
  341. // read radio button state
  342. if( IsDlgButtonChecked(hDlg, IDC_RUNNEW) )
  343. {
  344. gpWizardState->cmnStateData.dwFlags |= ICW_CFGFLAG_SMARTREBOOT_NEWISP;
  345. if (g_bExistConnect)
  346. {
  347. if (!DialogBoxParam(g_hInstance,MAKEINTRESOURCE(IDD_EXISTINGCONNECTION),hDlg,
  348. ExistingConnectionCmdProc, (LPARAM)g_szAnsiName))
  349. {
  350. gfQuitWizard = TRUE; // Quit the wizard
  351. return FALSE;
  352. }
  353. }
  354. // Do the system config checks
  355. if (!gpWizardState->cmnStateData.bSystemChecked && !ConfigureSystem(hDlg))
  356. {
  357. // gfQuitWizard will be set in ConfigureSystem if we need to quit
  358. return FALSE;
  359. }
  360. // OK, give me the next page
  361. SetIntroNextPage(hDlg, puNextPage, pfKeepHistory);
  362. }
  363. else if( IsDlgButtonChecked(hDlg, IDC_RUNAUTO) )
  364. {
  365. gpWizardState->cmnStateData.dwFlags |= ICW_CFGFLAG_SMARTREBOOT_AUTOCONFIG;
  366. // Do the system config checks
  367. if (!gpWizardState->cmnStateData.bSystemChecked && !ConfigureSystem(hDlg))
  368. {
  369. // gfQuitWizard will be set in ConfigureSystem if we need to quit
  370. return FALSE;
  371. }
  372. // The system config check is done in Inetcfg
  373. gpWizardState->cmnStateData.dwFlags |= ICW_CFGFLAG_AUTOCONFIG;
  374. SetIntroNextPage(hDlg, puNextPage, pfKeepHistory);
  375. }
  376. else if( IsDlgButtonChecked(hDlg, IDC_ICWMAN) )
  377. {
  378. *puNextPage = ORD_PAGE_MANUALOPTIONS;
  379. }
  380. }
  381. else if (!(gpWizardState->cmnStateData.dwFlags & ICW_CFGFLAG_BRANDED))
  382. {
  383. // Were are out of here, since we cannot go back from the first page
  384. gpWizardState->uPagesCompleted = 1;
  385. gfUserBackedOut = TRUE;
  386. gfQuitWizard = TRUE;
  387. }
  388. else if (gpWizardState->cmnStateData.dwFlags & ICW_CFGFLAG_BRANDED)
  389. gpWizardState->uPagesCompleted = 1;
  390. return TRUE;
  391. }
  392. BOOL CALLBACK IntroCmdProc(HWND hDlg, WPARAM wParam, LPARAM lParam)
  393. {
  394. switch (GET_WM_COMMAND_CMD(wParam, lParam))
  395. {
  396. case BN_CLICKED:
  397. {
  398. if (GET_WM_COMMAND_ID(wParam, lParam) == IDC_TUTORIAL)
  399. g_pICWTutorApp->LaunchTutorApp();
  400. break;
  401. }
  402. case BN_DBLCLK:
  403. {
  404. switch (GET_WM_COMMAND_ID(wParam, lParam))
  405. {
  406. case IDC_RUNNEW:
  407. case IDC_RUNAUTO:
  408. case IDC_ICWMAN:
  409. {
  410. // somebody double-clicked a radio button
  411. // auto-advance to the next page
  412. PropSheet_PressButton(GetParent(hDlg), PSBTN_NEXT);
  413. break;
  414. }
  415. }
  416. break;
  417. }
  418. }
  419. return TRUE;
  420. }