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.

924 lines
32 KiB

  1. //*********************************************************************
  2. //* Microsoft Windows **
  3. //* Copyright(c) Microsoft Corp., 1994 **
  4. //*********************************************************************
  5. //
  6. // ISPSEL.CPP - Functions for
  7. //
  8. // HISTORY:
  9. //
  10. // 05/13/98 donaldm Created.
  11. //
  12. //*********************************************************************
  13. #include "pre.h"
  14. #include "exdisp.h"
  15. #include "shldisp.h"
  16. #include <htiframe.h>
  17. #include <mshtml.h>
  18. #define FIRST_CTL_OFFSET 1 // offset of the first control
  19. // in DLUs. This is used when in
  20. // OEM custom mode to determin how
  21. // much to shift up the other controls
  22. BOOL gbHaveCNSOffer = FALSE;
  23. int g_nIndex = 0;
  24. /*******************************************************************
  25. NAME: SetHeaderFonts
  26. SYNOPSIS: Set the font of the header title
  27. ENTRY: hDlg - dialog window
  28. phFont - font we needed
  29. ********************************************************************/
  30. BOOL SetHeaderFonts(HWND hDlg, HFONT *phFont)
  31. {
  32. HFONT hFont;
  33. LOGFONT LogFont;
  34. GetObject(GetWindowFont(hDlg), sizeof(LogFont), &LogFont);
  35. LogFont.lfWeight = FW_BOLD;
  36. if ((hFont = CreateFontIndirect(&LogFont)) == NULL)
  37. {
  38. *phFont = NULL;
  39. return FALSE;
  40. }
  41. *phFont = hFont;
  42. return TRUE;
  43. }
  44. /*******************************************************************
  45. NAME: WriteISPHeaderTitle
  46. SYNOPSIS: Write the header on the ISP sel page
  47. ENTRY: hDlg - dialog window
  48. hdc - device context
  49. uTitle - IDS constant for the title
  50. ********************************************************************/
  51. void WriteISPHeaderTitle(HWND hDlg, UINT uDlgItem)
  52. {
  53. HGDIOBJ hFontOld = NULL;
  54. HFONT hFont = NULL;
  55. if (!SetHeaderFonts(hDlg, &hFont))
  56. {
  57. hFont = GetWindowFont(hDlg);
  58. }
  59. HDC hdc = GetDC(hDlg);
  60. if (hdc)
  61. {
  62. hFontOld = SelectObject(hdc, hFont);
  63. SendMessage(GetDlgItem(hDlg, uDlgItem),WM_SETFONT,(WPARAM)hFont,MAKELPARAM(TRUE,0));
  64. if (hFontOld)
  65. SelectObject(hdc, hFontOld);
  66. ReleaseDC(hDlg, hdc);
  67. }
  68. return;
  69. }
  70. // Convert a supplied icon from it's GIF format to an ICO format
  71. void ConvertISPIcon(LPTSTR lpszLogoPath, HICON* hIcon)
  72. {
  73. ASSERT(gpWizardSatet->pGifConvert);
  74. TCHAR szPath[MAX_PATH+1] = TEXT("\0");
  75. GetCurrentDirectory(MAX_PATH+1, szPath);
  76. lstrcat(szPath, TEXT("\\"));
  77. lstrcat(szPath, lpszLogoPath);
  78. gpWizardState->pGifConvert->GifToIcon(szPath, 16, hIcon);
  79. }
  80. // Insert an element into the ISP select list view
  81. BOOL AddItemToISPList
  82. (
  83. HWND hListView,
  84. int iItemIndex,
  85. LPTSTR lpszIspName,
  86. int iIspLogoIndex,
  87. BOOL bCNS,
  88. LPARAM lParam,
  89. BOOL bFilterDupe
  90. )
  91. {
  92. LVITEM LVItem;
  93. LVItem.mask = LVIF_IMAGE | LVIF_TEXT | LVIF_PARAM;
  94. LVItem.iItem = iItemIndex;
  95. LVItem.iSubItem = 0;
  96. LVItem.iImage = iIspLogoIndex;
  97. LVItem.pszText = lpszIspName;
  98. LVItem.lParam = lParam;
  99. BOOL bOKToAdd = TRUE;
  100. int nMatch = 0;
  101. if (bFilterDupe)
  102. {
  103. // Find the duplicate
  104. LVITEM CurLVItem;
  105. CISPCSV *pcISPCSV;
  106. int iNum = ListView_GetItemCount(hListView);
  107. LPTSTR szMirCode = ((CISPCSV*)lParam)->get_szMir();
  108. WORD wLCID = ((CISPCSV*)lParam)->get_wLCID();
  109. memset(&CurLVItem, 0, sizeof(CurLVItem));
  110. for ( int i = 0; i < iNum; i++)
  111. {
  112. CurLVItem.mask = LVIF_TEXT | LVIF_PARAM;
  113. CurLVItem.iItem = i;
  114. if (ListView_GetItem(hListView, &CurLVItem))
  115. {
  116. if (NULL != (pcISPCSV = (CISPCSV*) CurLVItem.lParam) )
  117. {
  118. // check for Mir code for duplicate
  119. if (0 == lstrcmp(pcISPCSV->get_szMir(), szMirCode))
  120. {
  121. // Check for LCID, if different LCID, show both offers
  122. if (pcISPCSV->get_wLCID() == wLCID)
  123. {
  124. bOKToAdd = FALSE;
  125. // Replace this one with the current one
  126. nMatch = i;
  127. if (gpWizardState->lpSelectedISPInfo == pcISPCSV)
  128. {
  129. gpWizardState->lpSelectedISPInfo = (CISPCSV*)lParam;
  130. }
  131. delete pcISPCSV;
  132. break;
  133. }
  134. }
  135. }
  136. }
  137. }
  138. }
  139. // Insert the Item if it is not a dupe
  140. if (bOKToAdd)
  141. {
  142. ListView_InsertItem(hListView, &LVItem);
  143. }
  144. else
  145. {
  146. iItemIndex = nMatch;
  147. LVItem.iItem = iItemIndex;
  148. ListView_SetItem(hListView, &LVItem);
  149. }
  150. // Set the ISP name into column 1
  151. ListView_SetItemText(hListView, iItemIndex, 1, lpszIspName);
  152. // If this dude is click and surf, then turn on the CNS graphic, in column 2
  153. if (bCNS)
  154. {
  155. LVItem.mask = LVIF_IMAGE;
  156. LVItem.iItem = iItemIndex;
  157. LVItem.iSubItem = 2;
  158. LVItem.iImage = 0;
  159. ListView_SetItem(hListView, &LVItem);
  160. }
  161. return bOKToAdd;
  162. }
  163. /*******************************************************************
  164. NAME: ParseISPCSV
  165. SYNOPSIS: Called when page is displayed
  166. ENTRY: hDlg - dialog window
  167. fFirstInit - TRUE if this is the first time the dialog
  168. is initialized, FALSE if this InitProc has been called
  169. before (e.g. went past this page and backed up)
  170. ********************************************************************/
  171. BOOL CALLBACK ParseISPCSV
  172. (
  173. HWND hDlg,
  174. TCHAR *pszCSVFileName,
  175. BOOL bCheckDupe
  176. )
  177. {
  178. // we will read the ISPINFO.CSV file, and populate the ISP LISTVIEW
  179. CCSVFile far *pcCSVFile;
  180. CISPCSV far *pcISPCSV;
  181. BOOL bRet = TRUE;
  182. HICON hISPLogo;
  183. int iImage;
  184. HRESULT hr;
  185. // Open and process the CSV file
  186. pcCSVFile = new CCSVFile;
  187. if (!pcCSVFile)
  188. {
  189. // BUGBUG: Show Error Message
  190. goto ISPFileParseError;
  191. }
  192. if (!pcCSVFile->Open(pszCSVFileName))
  193. {
  194. // BUGBUG: Show Error Message
  195. AssertMsg(0,"Can not open ISPINFO.CSV file");
  196. delete pcCSVFile;
  197. pcCSVFile = NULL;
  198. goto ISPFileParseError;
  199. }
  200. // Read the first line, since it contains field headers
  201. pcISPCSV = new CISPCSV;
  202. if (!pcISPCSV)
  203. {
  204. // BUGBUG Show error message
  205. delete pcCSVFile;
  206. goto ISPFileParseError;
  207. }
  208. if (ERROR_SUCCESS != (hr = pcISPCSV->ReadFirstLine(pcCSVFile)))
  209. {
  210. // Handle the error case
  211. delete pcCSVFile;
  212. pcCSVFile = NULL;
  213. gpWizardState->iNumOfValidOffers = 0;
  214. //*puNextPage = g_uExternUINext;
  215. bRet = TRUE;
  216. goto ISPFileParseError;
  217. }
  218. delete pcISPCSV; // Don't need this one any more
  219. do
  220. {
  221. // Allocate a new ISP record
  222. pcISPCSV = new CISPCSV;
  223. if (!pcISPCSV)
  224. {
  225. // BUGBUG Show error message
  226. bRet = FALSE;
  227. break;
  228. }
  229. // Read a line from the ISPINFO file
  230. hr = pcISPCSV->ReadOneLine(pcCSVFile);
  231. if (hr == ERROR_SUCCESS)
  232. {
  233. // If this line contains a nooffer flag, then leave now
  234. if (!(pcISPCSV->get_dwCFGFlag() & ICW_CFGFLAG_OFFERS))
  235. {
  236. // Empty the list view, in case this is not the first line.
  237. // This should always be the first line
  238. ListView_DeleteAllItems(GetDlgItem(hDlg, IDC_ISPLIST));
  239. // Add the entry to the list view
  240. AddItemToISPList( GetDlgItem(hDlg, IDC_ISPLIST),
  241. 0,
  242. pcISPCSV->get_szISPName(),
  243. -1,
  244. FALSE,
  245. (LPARAM)pcISPCSV,
  246. bCheckDupe);
  247. // Set the Current selected ISP to this one. We need this because
  248. // this contains the path to no-offer htm
  249. gpWizardState->lpSelectedISPInfo = pcISPCSV;
  250. // Assigning ISP_INFO_NO_VALIDOFFER means the ispinfo.csv
  251. // contains a no-offer line pointing to the ISP no-offer htm
  252. gpWizardState->iNumOfValidOffers = ISP_INFO_NO_VALIDOFFER;
  253. break;
  254. }
  255. // Increments the number of offers htm
  256. gpWizardState->iNumOfValidOffers++;
  257. if (gpWizardState->bISDNMode ? (pcISPCSV->get_dwCFGFlag() & ICW_CFGFLAG_ISDN_OFFER) : TRUE)
  258. {
  259. // See if this is an OEM tier 1 offer, and if we don't already have
  260. // an OEM tier 1 offer, then set it.
  261. if ((NULL == gpWizardState->lpOEMISPInfo[gpWizardState->uNumTierOffer]) &&
  262. (gpWizardState->uNumTierOffer < MAX_OEM_MUTI_TIER) &&
  263. pcISPCSV->get_dwCFGFlag() & ICW_CFGFLAG_OEM_SPECIAL )
  264. {
  265. gpWizardState->lpOEMISPInfo[gpWizardState->uNumTierOffer] = pcISPCSV;
  266. gpWizardState->uNumTierOffer++;
  267. // Add the Tier logo to the image list
  268. if (pcISPCSV->get_szISPTierLogoPath())
  269. {
  270. TCHAR szURL[INTERNET_MAX_URL_LENGTH];
  271. // Form the URL
  272. pcISPCSV->MakeCompleteURL(szURL, pcISPCSV->get_szISPTierLogoPath());
  273. // Convert GIF to ICON
  274. gpWizardState->pGifConvert->GifToIcon(szURL, 0, &hISPLogo);
  275. pcISPCSV->set_ISPTierLogoIcon(hISPLogo);
  276. }
  277. }
  278. else
  279. {
  280. // Convert the ISP logo from a GIF to an ICON, and add it to the Image List
  281. ConvertISPIcon(pcISPCSV->get_szISPLogoPath(), &hISPLogo);
  282. iImage = ImageList_AddIcon(gpWizardState->himlIspSelect, hISPLogo);
  283. DestroyIcon(hISPLogo);
  284. pcISPCSV->set_ISPLogoImageIndex(iImage);
  285. // Add the entry to the list view
  286. if (AddItemToISPList( GetDlgItem(hDlg, IDC_ISPLIST),
  287. g_nIndex,
  288. pcISPCSV->get_szISPName(),
  289. pcISPCSV->get_ISPLogoIndex(),
  290. pcISPCSV->get_bCNS(),
  291. (LPARAM)pcISPCSV,
  292. bCheckDupe))
  293. {
  294. g_nIndex++;
  295. if (pcISPCSV->get_bCNS())
  296. gbHaveCNSOffer = TRUE;
  297. // Assign a default selection
  298. if (NULL == gpWizardState->lpSelectedISPInfo)
  299. {
  300. gpWizardState->lpSelectedISPInfo = pcISPCSV;
  301. }
  302. }
  303. }
  304. // if we are in ISDN mode, then increment the ISDN offer count
  305. if (gpWizardState->bISDNMode)
  306. gpWizardState->iNumOfISDNOffers++;
  307. }
  308. else
  309. {
  310. // Since this obj is not added to the listview, we need to free
  311. // it here. Listview items are free when message LVN_DELETEITEM
  312. // is posted
  313. delete pcISPCSV;
  314. }
  315. }
  316. else if (hr == ERROR_FILE_NOT_FOUND)
  317. {
  318. // do not show this ISP when its data is invalid
  319. // we don't want to halt everything. Just let it contine
  320. delete pcISPCSV;
  321. }
  322. else if (hr == ERROR_NO_MORE_ITEMS)
  323. {
  324. // There is no more to read. No an error condition.
  325. delete pcISPCSV;
  326. break;
  327. }
  328. else if (hr != ERROR_INVALID_DATA)
  329. {
  330. // Show error message later.
  331. // This should not happen unless we called ICW3's referral or
  332. // a corrupted copy of ispinfo.csv
  333. gpWizardState->iNumOfValidOffers = 0;
  334. delete pcISPCSV;
  335. bRet = FALSE;
  336. break;
  337. }
  338. } while (TRUE);
  339. pcCSVFile->Close();
  340. delete pcCSVFile;
  341. return bRet;
  342. ISPFileParseError:
  343. // Set bParseIspinfo so next time, we'll reparse the CSV file
  344. gpWizardState->cmnStateData.bParseIspinfo = TRUE;
  345. return bRet;
  346. }
  347. // Initialize the ISP select list view
  348. BOOL InitListView(HWND hListView)
  349. {
  350. LV_COLUMN col;
  351. // Set the necessary extended style bits
  352. ListView_SetExtendedListViewStyle(hListView, LVS_EX_FULLROWSELECT | LVS_EX_SUBITEMIMAGES);
  353. ZeroMemory(&col, SIZEOF(LV_COLUMN));
  354. for(int i=0; i<3; i++)
  355. {
  356. if(ListView_InsertColumn(hListView, i, &col) == (-1))
  357. return(FALSE);
  358. }
  359. if (NULL == gpWizardState->himlIspSelect)
  360. {
  361. // Setup the image list
  362. if((gpWizardState->himlIspSelect = ImageList_Create(GetSystemMetrics(SM_CXSMICON),
  363. GetSystemMetrics(SM_CYSMICON),
  364. ILC_COLORDDB , 0, 8)) == (HIMAGELIST)NULL)
  365. return(FALSE);
  366. }
  367. ListView_SetImageList(hListView, gpWizardState->himlIspSelect, LVSIL_SMALL);
  368. // Add the CNS graphic. We add it first, so that it is always image index 0
  369. ImageList_AddIcon(gpWizardState->himlIspSelect, LoadIcon(ghInstanceResDll, MAKEINTRESOURCE(IDI_CNS)));
  370. return(TRUE);
  371. }
  372. // Reset the column size of the ISP select list view
  373. BOOL ResetListView(HWND hListView)
  374. {
  375. LV_COLUMN col;
  376. RECT rc;
  377. // reset 3 columns. ISP LOGO, ISP Name, CNS
  378. GetClientRect(hListView, &rc);
  379. ZeroMemory(&col, SIZEOF(LV_COLUMN));
  380. col.mask = LVCF_FMT | LVCF_WIDTH;
  381. col.fmt = LVCFMT_LEFT;
  382. col.cx = GetSystemMetrics(SM_CXSMICON) + 2;
  383. if(ListView_SetColumn(hListView, 0, &col) == (-1))
  384. return(FALSE);
  385. ZeroMemory(&col, SIZEOF(LV_COLUMN));
  386. col.mask = LVCF_FMT | LVCF_WIDTH;
  387. col.fmt = LVCFMT_LEFT;
  388. col.cx = (rc.right - rc.left) - (2*GetSystemMetrics(SM_CXSMICON)) - 4;
  389. if(ListView_SetColumn(hListView, 1, &col) == (-1))
  390. return(FALSE);
  391. ZeroMemory(&col, SIZEOF(LV_COLUMN));
  392. col.mask = LVCF_FMT | LVCF_WIDTH;
  393. col.fmt = LVCFMT_LEFT;
  394. col.cx = GetSystemMetrics(SM_CXSMICON) + 2;
  395. if(ListView_SetColumn(hListView, 2, &col) == (-1))
  396. return(FALSE);
  397. return TRUE;
  398. }
  399. /*******************************************************************
  400. NAME: ISPSelectInitProc
  401. SYNOPSIS: Called when page is displayed
  402. ENTRY: hDlg - dialog window
  403. fFirstInit - TRUE if this is the first time the dialog
  404. is initialized, FALSE if this InitProc has been called
  405. before (e.g. went past this page and backed up)
  406. ********************************************************************/
  407. BOOL CALLBACK ISPSelectInitProc
  408. (
  409. HWND hDlg,
  410. BOOL fFirstInit,
  411. UINT *puNextPage
  412. )
  413. {
  414. BOOL bRet = TRUE;
  415. if (fFirstInit)
  416. {
  417. // If we are in modeless operation, then we want the app
  418. // to show the title, not the dialog
  419. SetWindowLongPtr(GetDlgItem(hDlg, IDC_ISPLIST_CNSICON), GWLP_USERDATA, 202);
  420. if(gpWizardState->cmnStateData.bOEMCustom)
  421. {
  422. TCHAR szTitle[MAX_RES_LEN];
  423. RECT rcCtl, rcDLU;
  424. HWND hWndCtl = GetDlgItem(hDlg, IDC_ISP_SEL_TITLE);
  425. int iCtlIds[7] = { IDC_ISPSELECT_INTRO,
  426. IDC_ISPLIST_CNSICON,
  427. IDC_ISPLIST_CNSINFO,
  428. IDC_ISPSELECT_LBLISPLIST,
  429. IDC_ISPLIST,
  430. IDC_ISPSELECT_LBLMARKET,
  431. IDC_ISPMARKETING };
  432. int i, iOffset;
  433. // Get the Title
  434. GetWindowText(hWndCtl, szTitle, ARRAYSIZE(szTitle));
  435. // Hide the title
  436. ShowWindow(hWndCtl, SW_HIDE);
  437. // The offset to shift will be based on the number of DLU's from
  438. // top that the controls should be. That amount is converted to
  439. // pixels, and then the top of the first controls is used to compute
  440. // the final offset
  441. rcDLU.top = rcDLU.left = 0;
  442. rcDLU.bottom = rcDLU.right = FIRST_CTL_OFFSET;
  443. MapDialogRect(hDlg, &rcDLU);
  444. // Get the window of the 1st control
  445. hWndCtl = GetDlgItem(hDlg, iCtlIds[0]);
  446. // Get its screen position
  447. GetWindowRect(hWndCtl, &rcCtl);
  448. // Map to client coordinates for the parent
  449. MapWindowPoints(NULL, hDlg, (LPPOINT)&rcCtl, 2);
  450. // compute the offset
  451. iOffset = rcCtl.top - rcDLU.bottom;
  452. // for each control, move the window up by iOffset
  453. for (i = 0; i < ARRAYSIZE(iCtlIds); i++)
  454. {
  455. // Get the window of the control to move
  456. hWndCtl = GetDlgItem(hDlg, iCtlIds[i]);
  457. // Get its screen position
  458. GetWindowRect(hWndCtl, &rcCtl);
  459. // Map to client coordinates for the parent
  460. MapWindowPoints(NULL, hDlg, (LPPOINT)&rcCtl, 2);
  461. // Compute the new position
  462. rcCtl.top -= iOffset;
  463. rcCtl.bottom -= iOffset;
  464. // Move the control window
  465. MoveWindow(hWndCtl,
  466. rcCtl.left,
  467. rcCtl.top,
  468. RECTWIDTH(rcCtl),
  469. RECTHEIGHT(rcCtl),
  470. FALSE);
  471. }
  472. // Set the title
  473. SendMessage(gpWizardState->cmnStateData.hWndApp, WUM_SETTITLE, 0, (LPARAM)szTitle);
  474. }
  475. else
  476. {
  477. WriteISPHeaderTitle(hDlg, IDC_ISP_SEL_TITLE);
  478. }
  479. // Initialize the List View
  480. InitListView(GetDlgItem(hDlg, IDC_ISPLIST));
  481. gpWizardState->cmnStateData.bParseIspinfo = TRUE;
  482. }
  483. else
  484. {
  485. // if we've travelled through external apprentice pages,
  486. // it's easy for our current page pointer to get munged,
  487. // so reset it here for sanity's sake.
  488. gpWizardState->uCurrentPage = ORD_PAGE_ISPSELECT;
  489. gpWizardState->bISDNMode = gpWizardState->cmnStateData.bIsISDNDevice;
  490. if (gpWizardState->cmnStateData.bParseIspinfo)
  491. {
  492. TCHAR szTemp[MAX_RES_LEN];
  493. // If there are items in the list view, clear them
  494. ListView_DeleteAllItems(GetDlgItem(hDlg, IDC_ISPLIST));
  495. for (UINT i=0; i < gpWizardState->uNumTierOffer; i++)
  496. {
  497. if (gpWizardState->lpOEMISPInfo[i])
  498. {
  499. delete gpWizardState->lpOEMISPInfo[i];
  500. gpWizardState->lpOEMISPInfo[i] = NULL;
  501. }
  502. }
  503. gpWizardState->lpSelectedISPInfo = NULL;
  504. // Initialize the number of offers
  505. gpWizardState->iNumOfValidOffers = 0;
  506. gpWizardState->iNumOfISDNOffers = 0;
  507. gpWizardState->uNumTierOffer = 0;
  508. g_nIndex = 0;
  509. // Do not need to reparse next time
  510. gpWizardState->cmnStateData.bParseIspinfo = FALSE;
  511. // When we are in OEM mode, we need to read offline folder no matter where
  512. // we are launched from.
  513. if (gpWizardState->cmnStateData.bOEMOffline)
  514. ParseISPCSV(hDlg, ICW_OEMINFOPath, TRUE);
  515. // Not running from OEM Entry and not offline in oeminfo.ini means we didn't call
  516. // Referral server. We can skip parsing of CSV.
  517. if (!(gpWizardState->cmnStateData.bOEMOffline && gpWizardState->cmnStateData.bOEMEntryPt))
  518. ParseISPCSV(hDlg, ICW_ISPINFOPath, TRUE);
  519. if( gpWizardState->cmnStateData.dwFlags & ICW_CFGFLAG_SBS )
  520. LoadString(ghInstanceResDll, IDS_ISPSELECT_ONLISTSIGNUP, szTemp, MAX_RES_LEN);
  521. else
  522. LoadString(ghInstanceResDll, IDS_ISPSELECT_CNS, szTemp, MAX_RES_LEN);
  523. SetWindowText(GetDlgItem(hDlg, IDC_ISPLIST_CNSINFO), szTemp);
  524. // Hide the CNS legend if there are no CNSoffers
  525. if (!gbHaveCNSOffer)
  526. {
  527. ShowWindow(GetDlgItem(hDlg, IDC_ISPLIST_CNSINFO), SW_HIDE);
  528. ShowWindow(GetDlgItem(hDlg, IDC_ISPLIST_CNSICON), SW_HIDE);
  529. }
  530. ResetListView(GetDlgItem(hDlg, IDC_ISPLIST));
  531. }
  532. // The following 4 Cases can happen at this point:
  533. // 1) The ispinfo.csv contains a line says no offer, we go to nooffer page
  534. // 2) The ispinfo.csv contains no line of valid offer and no no-offer entry
  535. // This may happen in calling the old referral.dll that ICW 3 client calls
  536. // 3) There are many offers but no ISDN offers, and we are in ISDN mode
  537. // we go to ISDN offer pages
  538. // 4) Normal situation, some valid offers where we're in ISDN or not
  539. if (ISP_INFO_NO_VALIDOFFER == gpWizardState->iNumOfValidOffers)
  540. {
  541. // ISPINFO CSV contains a line saying NOOFFER!
  542. // if there are no offers, then we can just go directly to the NoOffers page
  543. ASSERT(gpWizardState->lpSelectedISPInfo);
  544. *puNextPage = ORD_PAGE_NOOFFER;
  545. bRet = TRUE;
  546. }
  547. else if (0 == gpWizardState->iNumOfValidOffers)
  548. {
  549. // Error in ISPINFO.CSV if there is no valid offers and no no-offer entry
  550. // critical error
  551. ListView_DeleteAllItems(GetDlgItem(hDlg, IDC_ISPLIST));
  552. *puNextPage = g_uExternUINext;
  553. gpWizardState->cmnStateData.bParseIspinfo = TRUE;
  554. bRet = TRUE;
  555. }
  556. else if ((0 == gpWizardState->iNumOfISDNOffers) && gpWizardState->bISDNMode)
  557. {
  558. // if we are in ISDN mode and there is no ISDN offers
  559. // go to the ISDN nooffer age
  560. *puNextPage = ORD_PAGE_ISDN_NOOFFER;
  561. bRet = TRUE;
  562. }
  563. else
  564. {
  565. // See if we have an OEM tier 1 offer, and if we should NOT be showing
  566. // the "more" list, then jump to the OEM offer page
  567. if ((gpWizardState->uNumTierOffer > 0) && !gpWizardState->bShowMoreOffers)
  568. {
  569. *puNextPage = ORD_PAGE_OEMOFFER;
  570. }
  571. else
  572. {
  573. gpWizardState->pICWWebView->ConnectToWindow(GetDlgItem(hDlg, IDC_ISPMARKETING), PAGETYPE_MARKETING);
  574. // If there are no selected items, select the first one, otherwise just navigate
  575. // the marketing window to the selected one
  576. if (0 == ListView_GetSelectedCount(GetDlgItem(hDlg, IDC_ISPLIST)))
  577. {
  578. ASSERT(gpWizardState->lpSelectedISPInfo);
  579. // Select the First Item in the Listview
  580. ListView_SetItemState(GetDlgItem(hDlg, IDC_ISPLIST), 0, LVIS_FOCUSED | LVIS_SELECTED, LVIS_FOCUSED | LVIS_SELECTED);
  581. }
  582. else
  583. {
  584. CISPCSV *pcISPCSV = NULL;
  585. int nCurrSel = ListView_GetSelectionMark(GetDlgItem(hDlg, IDC_ISPLIST));
  586. if (-1 != nCurrSel)
  587. {
  588. LVITEM CurLVItem;
  589. memset(&CurLVItem, 0, sizeof(CurLVItem));
  590. CurLVItem.mask = LVIF_TEXT | LVIF_PARAM;
  591. CurLVItem.iItem = nCurrSel;
  592. if (ListView_GetItem(GetDlgItem(hDlg, IDC_ISPLIST), &CurLVItem))
  593. {
  594. if (NULL != (pcISPCSV = (CISPCSV*) CurLVItem.lParam) )
  595. {
  596. gpWizardState->lpSelectedISPInfo = pcISPCSV;
  597. // Navigate, since we are re-activating
  598. pcISPCSV->DisplayHTML(pcISPCSV->get_szISPMarketingHTMPath());
  599. }
  600. }
  601. }
  602. }
  603. // Clear the dial Exact state var so that when we get to the dialing
  604. // page, we will regenerate the dial string
  605. gpWizardState->bDialExact = FALSE;
  606. }
  607. // Set the return code
  608. bRet = TRUE;
  609. }
  610. }
  611. return bRet;
  612. }
  613. /*******************************************************************
  614. NAME: ValidateISP
  615. SYNOPSIS: checks if the ISP provides a valid offer by checking
  616. the existence of the CSV file
  617. ENTRY: hDlg - Window handle
  618. EXIT: returns TRUE if the ISP provides valid CSP,
  619. FALSE otherwise
  620. ********************************************************************/
  621. BOOL CALLBACK ValidateISP(HWND hDlg)
  622. {
  623. CCSVFile far *pcCSVFile;
  624. BOOL bRet = TRUE;
  625. // Read the payment .CSV file.
  626. pcCSVFile = new CCSVFile;
  627. if (!pcCSVFile)
  628. {
  629. return FALSE;
  630. }
  631. if (!pcCSVFile->Open(gpWizardState->lpSelectedISPInfo->get_szPayCSVPath()))
  632. {
  633. TCHAR szErrMsg [MAX_RES_LEN+1] = TEXT("\0");
  634. TCHAR szCaption [MAX_RES_LEN+1] = TEXT("\0");
  635. LPVOID pszErr;
  636. TCHAR *args[1];
  637. args[0] = (LPTSTR) gpWizardState->lpSelectedISPInfo->get_szISPName();
  638. if (!LoadString(ghInstanceResDll, IDS_ISPSELECT_INVALID, szErrMsg, ARRAYSIZE(szErrMsg) ))
  639. return FALSE;
  640. if (!LoadString(ghInstanceResDll, IDS_APPNAME, szCaption, ARRAYSIZE(szCaption) ))
  641. return FALSE;
  642. FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_ARGUMENT_ARRAY,
  643. szErrMsg,
  644. 0,
  645. 0,
  646. (LPTSTR)&pszErr,
  647. 0,
  648. (va_list*)args);
  649. // Show Error Message
  650. MessageBox(hDlg, (LPTSTR)pszErr, szCaption, MB_OK | MB_ICONEXCLAMATION | MB_APPLMODAL);
  651. LocalFree(pszErr);
  652. delete pcCSVFile;
  653. pcCSVFile = NULL;
  654. bRet = FALSE;
  655. }
  656. if (pcCSVFile)
  657. {
  658. pcCSVFile->Close();
  659. delete pcCSVFile;
  660. }
  661. return bRet;
  662. }
  663. /*******************************************************************
  664. NAME: ISPSelectOKProc
  665. SYNOPSIS: Called when Next or Back btns pressed from page
  666. ENTRY: hDlg - dialog window
  667. fForward - TRUE if 'Next' was pressed, FALSE if 'Back'
  668. puNextPage - if 'Next' was pressed,
  669. proc can fill this in with next page to go to. This
  670. parameter is ingored if 'Back' was pressed.
  671. pfKeepHistory - page will not be kept in history if
  672. proc fills this in with FALSE.
  673. EXIT: returns TRUE to allow page to be turned, FALSE
  674. to keep the same page.
  675. ********************************************************************/
  676. BOOL CALLBACK ISPSelectOKProc
  677. (
  678. HWND hDlg,
  679. BOOL fForward,
  680. UINT *puNextPage,
  681. BOOL *pfKeepHistory
  682. )
  683. {
  684. ASSERT(puNextPage);
  685. if (fForward)
  686. {
  687. DWORD dwFlag = gpWizardState->lpSelectedISPInfo->get_dwCFGFlag();
  688. if (ICW_CFGFLAG_SIGNUP_PATH & dwFlag)
  689. {
  690. if (ICW_CFGFLAG_USERINFO & dwFlag)
  691. {
  692. *puNextPage = ORD_PAGE_USERINFO;
  693. return TRUE;
  694. }
  695. if (ICW_CFGFLAG_BILL & dwFlag)
  696. {
  697. *puNextPage = ORD_PAGE_BILLINGOPT;
  698. return TRUE;
  699. }
  700. if (ICW_CFGFLAG_PAYMENT & dwFlag)
  701. {
  702. *puNextPage = ORD_PAGE_PAYMENT;
  703. return TRUE;
  704. }
  705. *puNextPage = ORD_PAGE_ISPDIAL;
  706. return TRUE;
  707. }
  708. else
  709. {
  710. *puNextPage = ORD_PAGE_OLS;
  711. }
  712. }
  713. return TRUE;
  714. }
  715. /*******************************************************************
  716. NAME: ISPSElectNotifyProc
  717. ********************************************************************/
  718. BOOL CALLBACK ISPSelectNotifyProc
  719. (
  720. HWND hDlg,
  721. WPARAM wParam,
  722. LPARAM lParam
  723. )
  724. {
  725. CISPCSV *pcISPCSV;
  726. // Process ListView notifications
  727. switch(((LV_DISPINFO *)lParam)->hdr.code)
  728. {
  729. case NM_DBLCLK:
  730. PropSheet_PressButton(GetParent(hDlg),PSBTN_NEXT);
  731. break;
  732. case NM_SETFOCUS:
  733. case NM_KILLFOCUS:
  734. // update list view
  735. break;
  736. case LVN_ITEMCHANGED:
  737. TraceMsg(TF_ISPSELECT, "ISPSELECT: WM_NOTIFY - LVN_ITEMCHANGED");
  738. if((((NM_LISTVIEW *)lParam)->uChanged & LVIF_STATE) &&
  739. ((NM_LISTVIEW *)lParam)->uNewState & (LVIS_FOCUSED | LVIS_SELECTED))
  740. {
  741. // IF an Item just became selected, then render it's HTML content
  742. pcISPCSV = (CISPCSV *)((NM_LISTVIEW *)lParam)->lParam;
  743. pcISPCSV->DisplayHTML(pcISPCSV->get_szISPMarketingHTMPath());
  744. // Remember the selected item for later use
  745. gpWizardState->lpSelectedISPInfo = pcISPCSV;
  746. //Set the intro text based on the number of isp'
  747. int iNum = ListView_GetItemCount(GetDlgItem(hDlg,IDC_ISPLIST));
  748. if (iNum > 1)
  749. gpWizardState->lpSelectedISPInfo->DisplayTextWithISPName(GetDlgItem(hDlg,IDC_ISPSELECT_INTRO), IDS_ISPSELECT_INTROFMT_MULTIPLE, NULL);
  750. else if (iNum > 0)
  751. gpWizardState->lpSelectedISPInfo->DisplayTextWithISPName(GetDlgItem(hDlg,IDC_ISPSELECT_INTRO), IDS_ISPSELECT_INTROFMT_SINGLE, NULL);
  752. }
  753. break;
  754. // The listview is being emptied, or destroyed, either way, our lpSelectedISPInfo
  755. // is no longer valid, since the list view underlying data will be freed.
  756. case LVN_DELETEALLITEMS:
  757. gpWizardState->lpSelectedISPInfo = NULL;
  758. SetPropSheetResult(hDlg,TRUE);
  759. break;
  760. case LVN_DELETEITEM:
  761. // We were notified that an item was deleted.
  762. // so delete the underlying data that it is pointing
  763. // to.
  764. if (((NM_LISTVIEW*)lParam)->lParam)
  765. delete (CISPCSV *)((NM_LISTVIEW *)lParam)->lParam;
  766. break;
  767. }
  768. return TRUE;
  769. }