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.

413 lines
14 KiB

  1. //*********************************************************************
  2. //* Microsoft Windows **
  3. //* Copyright(c) Microsoft Corp., 1994 **
  4. //*********************************************************************
  5. //
  6. // OEMOFFER.CPP - Functions for
  7. //
  8. // HISTORY:
  9. //
  10. // 09/03/98 donaldm Created.
  11. //
  12. //*********************************************************************
  13. #include "pre.h"
  14. #include "webvwids.h"
  15. #define NO_TIER_SELECT -1
  16. UINT IDC_OEM_TIER[] =
  17. {
  18. IDC_OEM_TIER1,
  19. IDC_OEM_TIER2,
  20. IDC_OEM_TIER3
  21. };
  22. UINT IDC_OEM_TEASER_HTML[] =
  23. {
  24. IDC_OEM_TEASER_HTML1,
  25. IDC_OEM_TEASER_HTML2,
  26. IDC_OEM_TEASER_HTML3
  27. };
  28. int g_nCurrOEMTier = NO_TIER_SELECT;
  29. extern IICWWebView *gpICWWebView[2];
  30. /*******************************************************************
  31. NAME: DoCreateTooltip
  32. SYNOPSIS: creates a tooltip control
  33. ENTRY: hDlg - dialog window
  34. ********************************************************************/
  35. void DoCreateTooltip(HWND hWnd)
  36. {
  37. HWND hwndToolTip; // handle of tooltip
  38. TOOLINFO ti; // tool information
  39. // create a tooltip control.
  40. hwndToolTip = CreateWindowEx( 0,
  41. TOOLTIPS_CLASS,
  42. NULL,
  43. WS_POPUP | TTS_ALWAYSTIP,
  44. CW_USEDEFAULT,
  45. CW_USEDEFAULT,
  46. 10,
  47. 10,
  48. hWnd,
  49. NULL,
  50. ghInstanceResDll, //g_hInst,
  51. NULL);
  52. // add the OK button to the tooltip. TTF_SUBCLASS causes the
  53. // tooltip to automatically subclass the window and look for the
  54. // messages it is interested in.
  55. ZeroMemory(&ti, sizeof(ti));
  56. ti.cbSize = sizeof(ti);
  57. ti.uFlags = TTF_IDISHWND | TTF_SUBCLASS;
  58. ti.hwnd = hWnd;
  59. TCHAR szTemp[MAX_MESSAGE_LEN];
  60. LoadString(ghInstanceResDll, IDS_OEM_TIER_TOOLTIP, szTemp, MAX_MESSAGE_LEN);
  61. ti.lpszText = szTemp;
  62. ti.uId = (UINT_PTR)GetDlgItem(hWnd, IDC_OEM_TIER1);
  63. SendMessage(hwndToolTip, TTM_ADDTOOL, 0, (LPARAM)&ti);
  64. ti.uId = (UINT_PTR)GetDlgItem(hWnd, IDC_OEM_TIER2);
  65. SendMessage(hwndToolTip, TTM_ADDTOOL, 0, (LPARAM)&ti);
  66. ti.uId = (UINT_PTR)GetDlgItem(hWnd, IDC_OEM_TIER3);
  67. SendMessage(hwndToolTip, TTM_ADDTOOL, 0, (LPARAM)&ti);
  68. }
  69. /*******************************************************************
  70. NAME: DisplayTierOffer
  71. SYNOPSIS: Display Current controls for the tier page
  72. ENTRY: hDlg - dialog window
  73. ********************************************************************/
  74. void DisplayTierOffer(HWND hDlg)
  75. {
  76. if (NO_TIER_SELECT == g_nCurrOEMTier)
  77. {
  78. // Hide the marketing page
  79. EnableWindow(GetDlgItem(hDlg, IDC_OEM_MULTI_TIER_OFFER_HTML), FALSE);
  80. ShowWindow(GetDlgItem(hDlg, IDC_OEM_MULTI_TIER_OFFER_HTML), SW_HIDE);
  81. // Show Teaser htm
  82. for(UINT i = 0 ; i < gpWizardState->uNumTierOffer; i++)
  83. {
  84. EnableWindow(GetDlgItem(hDlg, IDC_OEM_TEASER_HTML[i]), TRUE);
  85. ShowWindow(GetDlgItem(hDlg, IDC_OEM_TEASER_HTML[i]), SW_SHOW);
  86. }
  87. gpWizardState->pICWWebView->ConnectToWindow(GetDlgItem(hDlg, IDC_OEM_TEASER_HTML1), PAGETYPE_ISP_NORMAL);
  88. gpWizardState->lpOEMISPInfo[0]->DisplayHTML(gpWizardState->lpOEMISPInfo[0]->get_szISPTeaserPath());
  89. TCHAR szURL[INTERNET_MAX_URL_LENGTH];
  90. if (gpWizardState->uNumTierOffer > 1)
  91. {
  92. // Make the URL
  93. gpWizardState->lpOEMISPInfo[1]->MakeCompleteURL(szURL, gpWizardState->lpOEMISPInfo[1]->get_szISPTeaserPath());
  94. gpICWWebView[0]->DisplayHTML(szURL);
  95. }
  96. if (gpWizardState->uNumTierOffer > 2)
  97. {
  98. gpWizardState->lpOEMISPInfo[2]->MakeCompleteURL(szURL, gpWizardState->lpOEMISPInfo[2]->get_szISPTeaserPath());
  99. gpICWWebView[1]->DisplayHTML(szURL);
  100. }
  101. PropSheet_SetWizButtons(GetParent(hDlg), PSWIZB_BACK);
  102. }
  103. else
  104. {
  105. // Hide all the teaser htmls
  106. for(UINT i = 0 ; i < gpWizardState->uNumTierOffer; i++)
  107. {
  108. EnableWindow(GetDlgItem(hDlg, IDC_OEM_TEASER_HTML[i]), FALSE);
  109. ShowWindow(GetDlgItem(hDlg, IDC_OEM_TEASER_HTML[i]), SW_HIDE);
  110. }
  111. // Show the marketing page
  112. EnableWindow(GetDlgItem(hDlg, IDC_OEM_MULTI_TIER_OFFER_HTML), TRUE);
  113. ShowWindow(GetDlgItem(hDlg, IDC_OEM_MULTI_TIER_OFFER_HTML), SW_SHOW);
  114. gpWizardState->pICWWebView->ConnectToWindow(GetDlgItem(hDlg, IDC_OEM_MULTI_TIER_OFFER_HTML), PAGETYPE_MARKETING);
  115. CISPCSV *pISPInfo;
  116. pISPInfo = gpWizardState->lpOEMISPInfo[g_nCurrOEMTier];
  117. pISPInfo->DisplayHTML(pISPInfo->get_szISPMarketingHTMPath());
  118. PropSheet_SetWizButtons(GetParent(hDlg), PSWIZB_NEXT | PSWIZB_BACK);
  119. }
  120. }
  121. /*******************************************************************
  122. NAME: OEMOfferInitProc
  123. SYNOPSIS: Called when page is displayed
  124. ENTRY: hDlg - dialog window
  125. fFirstInit - TRUE if this is the first time the dialog
  126. is initialized, FALSE if this InitProc has been called
  127. before (e.g. went past this page and backed up)
  128. ********************************************************************/
  129. BOOL CALLBACK OEMOfferInitProc
  130. (
  131. HWND hDlg,
  132. BOOL fFirstInit,
  133. UINT *puNextPage
  134. )
  135. {
  136. // if we've travelled through external apprentice pages,
  137. // it's easy for our current page pointer to get munged,
  138. // so reset it here for sanity's sake.
  139. gpWizardState->uCurrentPage = ORD_PAGE_OEMOFFER;
  140. if (fFirstInit)
  141. {
  142. DoCreateTooltip(hDlg);
  143. if (gpWizardState->uNumTierOffer > 1)
  144. {
  145. HRESULT hr;
  146. for(UINT i = 0; i < MAX_OEM_MUTI_TIER - 1; i++)
  147. {
  148. hr = CoCreateInstance(CLSID_ICWWEBVIEW,NULL,CLSCTX_INPROC_SERVER,
  149. IID_IICWWebView,(LPVOID *)&gpICWWebView[i]);
  150. if (FAILED(hr))
  151. return FALSE;
  152. }
  153. }
  154. }
  155. else
  156. {
  157. // initialize this state variable
  158. gpWizardState->bShowMoreOffers = FALSE;
  159. EnableWindow(GetDlgItem(hDlg, IDC_OEM_TIER1), FALSE);
  160. ShowWindow(GetDlgItem(hDlg, IDC_OEM_TIER1), SW_HIDE);
  161. EnableWindow(GetDlgItem(hDlg, IDC_OEM_TIER2), FALSE);
  162. ShowWindow(GetDlgItem(hDlg, IDC_OEM_TIER2), SW_HIDE);
  163. EnableWindow(GetDlgItem(hDlg, IDC_OEM_TIER3), FALSE);
  164. ShowWindow(GetDlgItem(hDlg, IDC_OEM_TIER3), SW_HIDE);
  165. // If more than one tier offer, show the multi tier page
  166. if (1 == gpWizardState->uNumTierOffer)
  167. {
  168. // Hide multi tier controls
  169. EnableWindow(GetDlgItem(hDlg, IDC_OEM_MULTI_TIER_INTRO), FALSE);
  170. ShowWindow(GetDlgItem(hDlg, IDC_OEM_MULTI_TIER_INTRO), SW_HIDE);
  171. EnableWindow(GetDlgItem(hDlg, IDC_OEM_MULTI_TIER_OFFER_HTML), FALSE);
  172. ShowWindow(GetDlgItem(hDlg, IDC_OEM_MULTI_TIER_OFFER_HTML), SW_HIDE);
  173. // Show Tier one controls
  174. EnableWindow(GetDlgItem(hDlg, IDC_OEMOFFER_HTML), TRUE);
  175. ShowWindow(GetDlgItem(hDlg, IDC_OEMOFFER_HTML), SW_SHOW);
  176. CISPCSV FAR *lpISP;
  177. g_nCurrOEMTier = 0;
  178. // Use a local reference for convienience
  179. lpISP = gpWizardState->lpOEMISPInfo[0];
  180. ASSERT(lpISP);
  181. gpWizardState->pICWWebView->ConnectToWindow(GetDlgItem(hDlg, IDC_OEMOFFER_HTML), PAGETYPE_MARKETING);
  182. // Navigate to the OEM offer marketing HTML
  183. lpISP->DisplayHTML(lpISP->get_szISPMarketingHTMPath());
  184. // Set the text for the instructions
  185. if ((gpWizardState->bISDNMode && (1 == gpWizardState->iNumOfISDNOffers)) ||
  186. (1 == gpWizardState->iNumOfValidOffers) )
  187. {
  188. lpISP->DisplayTextWithISPName(GetDlgItem(hDlg,IDC_OEMOFFER_INSTRUCTION), IDS_OEMOFFER_INSTFMT_SINGLE, NULL);
  189. ShowWindow(GetDlgItem(hDlg, IDC_OEMOFFER_MORE), SW_HIDE);
  190. }
  191. else
  192. {
  193. lpISP->DisplayTextWithISPName(GetDlgItem(hDlg,IDC_OEMOFFER_INSTRUCTION), IDS_OEMOFFER_INSTFMT_MULTIPLE, NULL);
  194. ShowWindow(GetDlgItem(hDlg, IDC_OEMOFFER_MORE), SW_SHOW);
  195. }
  196. }
  197. else
  198. {
  199. // Hide Tier one controls
  200. EnableWindow(GetDlgItem(hDlg, IDC_OEMOFFER_HTML), FALSE);
  201. ShowWindow(GetDlgItem(hDlg, IDC_OEMOFFER_HTML), SW_HIDE);
  202. // Show common multi tier controls - intro text
  203. EnableWindow(GetDlgItem(hDlg, IDC_OEM_MULTI_TIER_INTRO), TRUE);
  204. ShowWindow(GetDlgItem(hDlg, IDC_OEM_MULTI_TIER_INTRO), SW_SHOW);
  205. for(UINT i = 0 ; i < gpWizardState->uNumTierOffer; i++)
  206. {
  207. EnableWindow(GetDlgItem(hDlg, IDC_OEM_TIER[i]), TRUE);
  208. ShowWindow(GetDlgItem(hDlg, IDC_OEM_TIER[i]), SW_SHOW);
  209. SendMessage(GetDlgItem(hDlg, IDC_OEM_TIER[i]),
  210. BM_SETIMAGE,
  211. IMAGE_ICON,
  212. (LPARAM)gpWizardState->lpOEMISPInfo[i]->get_ISPTierLogoIcon());
  213. }
  214. gpWizardState->pICWWebView->ConnectToWindow(GetDlgItem(hDlg, IDC_OEM_TEASER_HTML1), PAGETYPE_ISP_NORMAL);
  215. switch (gpWizardState->uNumTierOffer)
  216. {
  217. case 3:
  218. gpICWWebView[1]->ConnectToWindow(GetDlgItem(hDlg, IDC_OEM_TEASER_HTML3), PAGETYPE_ISP_NORMAL);
  219. case 2:
  220. gpICWWebView[0]->ConnectToWindow(GetDlgItem(hDlg, IDC_OEM_TEASER_HTML2), PAGETYPE_ISP_NORMAL);
  221. break;
  222. }
  223. DisplayTierOffer(hDlg);
  224. if ((gpWizardState->bISDNMode && (gpWizardState->iNumOfISDNOffers <= (int)gpWizardState->uNumTierOffer)) ||
  225. (gpWizardState->iNumOfValidOffers <= (int)gpWizardState->uNumTierOffer) )
  226. {
  227. ShowWindow(GetDlgItem(hDlg, IDC_OEMOFFER_MORE), SW_HIDE);
  228. ShowWindow(GetDlgItem(hDlg, IDC_OEMOFFER_INSTRUCTION), SW_HIDE);
  229. EnableWindow(GetDlgItem(hDlg, IDC_OEMOFFER_MORE), FALSE);
  230. }
  231. else
  232. {
  233. TCHAR szTemp [MAX_RES_LEN];
  234. LoadString(ghInstanceResDll, IDS_OEMOFFER_INSTR_MULTITIER, szTemp, ARRAYSIZE(szTemp));
  235. SetWindowText(GetDlgItem(hDlg,IDC_OEMOFFER_INSTRUCTION), szTemp);
  236. ShowWindow(GetDlgItem(hDlg, IDC_OEMOFFER_MORE), SW_SHOW);
  237. EnableWindow(GetDlgItem(hDlg, IDC_OEMOFFER_MORE), TRUE);
  238. }
  239. }
  240. }
  241. return TRUE;
  242. }
  243. BOOL CALLBACK OEMOfferOKProc
  244. (
  245. HWND hDlg,
  246. BOOL fForward,
  247. UINT *puNextPage,
  248. BOOL *pfKeepHistory
  249. )
  250. {
  251. if (fForward)
  252. {
  253. // We will keep this page in the history
  254. *pfKeepHistory = TRUE;
  255. // We either need to go to the true ISP select page because the more button was pressed
  256. // or we move on based on the selected ISP settings
  257. if (gpWizardState->bShowMoreOffers)
  258. {
  259. *puNextPage = ORD_PAGE_ISPSELECT;
  260. }
  261. else
  262. {
  263. // Get the config flags, and figure out where to go next
  264. gpWizardState->lpSelectedISPInfo = gpWizardState->lpOEMISPInfo[g_nCurrOEMTier];
  265. DWORD dwFlags = gpWizardState->lpSelectedISPInfo->get_dwCFGFlag();
  266. if (ICW_CFGFLAG_SIGNUP_PATH & dwFlags)
  267. {
  268. if (ICW_CFGFLAG_USERINFO & dwFlags)
  269. {
  270. *puNextPage = ORD_PAGE_USERINFO;
  271. return TRUE;
  272. }
  273. if (ICW_CFGFLAG_BILL & dwFlags)
  274. {
  275. *puNextPage = ORD_PAGE_BILLINGOPT;
  276. return TRUE;
  277. }
  278. if (ICW_CFGFLAG_PAYMENT & dwFlags)
  279. {
  280. *puNextPage = ORD_PAGE_PAYMENT;
  281. return TRUE;
  282. }
  283. *puNextPage = ORD_PAGE_ISPDIAL;
  284. return TRUE;
  285. }
  286. else
  287. {
  288. *puNextPage = ORD_PAGE_OLS;
  289. }
  290. }
  291. }
  292. else
  293. {
  294. // Reset the current selection
  295. g_nCurrOEMTier = NO_TIER_SELECT;
  296. }
  297. return TRUE;
  298. }
  299. /*******************************************************************
  300. NAME: OEMOfferCmdProc
  301. ********************************************************************/
  302. BOOL CALLBACK OEMOfferCmdProc
  303. (
  304. HWND hDlg,
  305. WPARAM wParam,
  306. LPARAM lParam
  307. )
  308. {
  309. switch (GET_WM_COMMAND_CMD(wParam, lParam))
  310. {
  311. case BN_CLICKED:
  312. switch (GET_WM_COMMAND_ID(wParam, lParam))
  313. {
  314. case IDC_OEMOFFER_MORE:
  315. {
  316. // Set the state variable so that we can shore more offers
  317. gpWizardState->bShowMoreOffers = TRUE;
  318. // Fake a press of the next button
  319. PropSheet_PressButton(GetParent(hDlg),PSBTN_NEXT);
  320. break;
  321. }
  322. case IDC_OEM_TIER1:
  323. {
  324. g_nCurrOEMTier = 0;
  325. DisplayTierOffer(hDlg);
  326. break;
  327. }
  328. case IDC_OEM_TIER2:
  329. {
  330. g_nCurrOEMTier = 1;
  331. DisplayTierOffer(hDlg);
  332. break;
  333. }
  334. case IDC_OEM_TIER3:
  335. {
  336. g_nCurrOEMTier = 2;
  337. DisplayTierOffer(hDlg);
  338. break;
  339. }
  340. }
  341. break;
  342. }
  343. return 1;
  344. }