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.

336 lines
12 KiB

  1. //*********************************************************************
  2. //* Microsoft Windows **
  3. //* Copyright(c) Microsoft Corp., 1994 **
  4. //*********************************************************************
  5. //
  6. // ISPDIAL.CPP - Functions for
  7. //
  8. // HISTORY:
  9. //
  10. // 05/13/98 donaldm Created.
  11. //
  12. //*********************************************************************
  13. #include "pre.h"
  14. #include <raserror.h>
  15. BOOL DoOfferDownload();
  16. /*******************************************************************
  17. NAME: ISPDialInitProc
  18. SYNOPSIS: Called when page is displayed
  19. ENTRY: hDlg - dialog window
  20. fFirstInit - TRUE if this is the first time the dialog
  21. is initialized, FALSE if this InitProc has been called
  22. before (e.g. went past this page and backed up)
  23. ********************************************************************/
  24. BOOL CALLBACK ISPDialInitProc
  25. (
  26. HWND hDlg,
  27. BOOL fFirstInit,
  28. UINT *puNextPage
  29. )
  30. {
  31. // Disable Back and Next
  32. PropSheet_SetWizButtons(GetParent(hDlg), 0);
  33. gpWizardState->bRefDialTerminate = FALSE;
  34. gfISPDialCancel = FALSE;
  35. if (fFirstInit)
  36. {
  37. //Are we in IEAK Mode
  38. if(gpWizardState->cmnStateData.dwFlags & ICW_CFGFLAG_IEAKMODE)
  39. {
  40. // Do the system config checks
  41. if (!gpWizardState->cmnStateData.bSystemChecked && !(*gpWizardState->cmnStateData.lpfnConfigSys)(hDlg))
  42. {
  43. // gfQuitWizard will be set in ConfigureSystem if we need to quit
  44. return FALSE;
  45. }
  46. }
  47. CRefDialEvent *pRefDialEvent;
  48. CWebGateEvent *pWebGateEvent;
  49. // Blank out the status text initially
  50. SetWindowText(GetDlgItem(hDlg, IDC_ISPDIAL_STATUS), TEXT(""));
  51. gpWizardState->iRedialCount = 0;
  52. // Setup an Event Handler for RefDial and Webgate
  53. pRefDialEvent = new CRefDialEvent(hDlg);
  54. if (NULL != pRefDialEvent)
  55. {
  56. HRESULT hr;
  57. gpWizardState->pRefDialEvents = pRefDialEvent;
  58. gpWizardState->pRefDialEvents->AddRef();
  59. hr = ConnectToConnectionPoint((IUnknown *)gpWizardState->pRefDialEvents,
  60. DIID__RefDialEvents,
  61. TRUE,
  62. (IUnknown *)gpWizardState->pRefDial,
  63. &gpWizardState->pRefDialEvents->m_dwCookie,
  64. NULL);
  65. }
  66. pWebGateEvent = new CWebGateEvent(hDlg);
  67. if (NULL != pWebGateEvent)
  68. {
  69. HRESULT hr;
  70. gpWizardState->pWebGateEvents = pWebGateEvent;
  71. gpWizardState->pWebGateEvents->AddRef();
  72. hr = ConnectToConnectionPoint((IUnknown *)gpWizardState->pWebGateEvents,
  73. DIID__WebGateEvents,
  74. TRUE,
  75. (IUnknown *)gpWizardState->pWebGate,
  76. &gpWizardState->pWebGateEvents->m_dwCookie,
  77. NULL);
  78. }
  79. }
  80. else
  81. {
  82. // if we've travelled through external apprentice pages,
  83. // it's easy for our current page pointer to get munged,
  84. // so reset it here for sanity's sake.
  85. gpWizardState->uCurrentPage = ORD_PAGE_ISPDIAL;
  86. ResetEvent(gpWizardState->hEventWebGateDone);
  87. // Cleanup the ISPPageCache for this ISP, since we are about to connect
  88. gpWizardState->lpSelectedISPInfo->CleanupISPPageCache(FALSE);
  89. TCHAR szTemp[MAX_MESSAGE_LEN];
  90. if (gpWizardState->cmnStateData.dwFlags & ICW_CFGFLAG_AUTOCONFIG)
  91. {
  92. // hide this text for autoconfig
  93. ShowWindow(GetDlgItem(hDlg, IDC_ISPDIAL_INSTRUCT), SW_HIDE);
  94. LoadString(ghInstanceResDll, IDS_STEP2A_TITLE, szTemp, MAX_MESSAGE_LEN);
  95. }
  96. else
  97. {
  98. // show this text for new signup
  99. ShowWindow(GetDlgItem(hDlg, IDC_ISPDIAL_INSTRUCT), SW_SHOW);
  100. LoadString(ghInstanceResDll, IDS_STEP2_TITLE, szTemp, MAX_MESSAGE_LEN);
  101. }
  102. PropSheet_SetHeaderTitle(GetParent(hDlg), EXE_NUM_WIZARD_PAGES + ORD_PAGE_ISPDIAL, szTemp);
  103. // Initialize the RefDial Object before we dial
  104. gpWizardState->pRefDial->DoInit();
  105. }
  106. return TRUE;
  107. }
  108. /*******************************************************************
  109. NAME: ISPDialPostInitProc
  110. SYNOPSIS:
  111. ENTRY: hDlg - dialog window
  112. fFirstInit - TRUE if this is the first time the dialog
  113. is initialized, FALSE if this InitProc has been called
  114. before (e.g. went past this page and backed up)
  115. ********************************************************************/
  116. BOOL CALLBACK ISPDialPostInitProc
  117. (
  118. HWND hDlg,
  119. BOOL fFirstInit,
  120. UINT *puNextPage
  121. )
  122. {
  123. BOOL bRet;
  124. if (!fFirstInit)
  125. {
  126. // Force the Window to update
  127. UpdateWindow(GetParent(hDlg));
  128. if(!gpWizardState->iRedialCount)
  129. {
  130. // Clear the phone number and status fields
  131. SetWindowText(GetDlgItem(hDlg, IDC_ISPDIAL_STATUS), TEXT(""));
  132. SetWindowText(GetDlgItem(hDlg, IDC_ISPDIAL_PHONENUM), TEXT(""));
  133. }
  134. // Set the intro text
  135. ASSERT(gpWizardState->lpSelectedISPInfo);
  136. gpWizardState->lpSelectedISPInfo->DisplayTextWithISPName(GetDlgItem(hDlg,IDC_ISPDIAL_INTRO), IDS_ISPDIAL_INTROFMT, NULL);
  137. if (!gpWizardState->bDialExact)
  138. {
  139. BSTR bstrPhoneNum = NULL;
  140. BOOL bRetVal;
  141. // Setup for Dialing. This will ensure that we are ready to dial.
  142. gpWizardState->pRefDial->SetupForDialing(A2W(gpWizardState->lpSelectedISPInfo->get_szISPFilePath()), //
  143. gpWizardState->cmnStateData.dwCountryCode,
  144. A2W(gpWizardState->cmnStateData.szAreaCode),
  145. 0,
  146. &bRetVal);
  147. if (bRetVal)
  148. {
  149. // Show the phone Number
  150. gpWizardState->pRefDial->get_DialPhoneNumber(&bstrPhoneNum);
  151. SetWindowText(GetDlgItem(hDlg, IDC_ISPDIAL_PHONENUM), W2A(bstrPhoneNum));
  152. // Initialize all the variables
  153. gpWizardState->bDoneWebServDownload = FALSE;
  154. gpWizardState->bDoneWebServRAS = FALSE;
  155. // Show the Initial Status
  156. if(!gpWizardState->iRedialCount)
  157. gpWizardState->lpSelectedISPInfo->DisplayTextWithISPName(GetDlgItem(hDlg,IDC_ISPDIAL_STATUS),
  158. IDS_ISPDIAL_STATUSDIALINGFMT, NULL);
  159. else
  160. gpWizardState->lpSelectedISPInfo->DisplayTextWithISPName(GetDlgItem(hDlg,IDC_ISPDIAL_STATUS),
  161. IDS_ISPDIAL_STATUSREDIALINGFMT, NULL);
  162. //This flag is only to be used by ICWDEBUG.EXE
  163. if (gpWizardState->cmnStateData.dwFlags & ICW_CFGFLAG_MODEMOVERRIDE)
  164. gpWizardState->pRefDial->put_ModemOverride(TRUE);
  165. gpWizardState->pRefDial->DoConnect(&bRetVal);
  166. }
  167. else
  168. {
  169. gpWizardState->pRefDial->get_QuitWizard(&bRetVal);
  170. if (bRetVal)
  171. {
  172. gfQuitWizard = TRUE;
  173. bRet = FALSE;
  174. }
  175. else
  176. {
  177. gpWizardState->pRefDial->get_TryAgain(&bRetVal);
  178. if (bRetVal)
  179. {
  180. PropSheet_PressButton(GetParent(hDlg),PSBTN_BACK);
  181. }
  182. else
  183. {
  184. PropSheet_PressButton(GetParent(hDlg),PSBTN_NEXT);
  185. }
  186. }
  187. }
  188. SysFreeString(bstrPhoneNum);
  189. }
  190. else // Dialing exact. We get here if the user changes the number on the dial error page
  191. {
  192. BSTR bstrPhoneNum = NULL;
  193. BOOL bRet;
  194. int iCurrent = 0;
  195. // Show the phone Number
  196. gpWizardState->pRefDial->get_DialPhoneNumber(&bstrPhoneNum);
  197. SetWindowText(GetDlgItem(hDlg, IDC_ISPDIAL_PHONENUM), W2A(bstrPhoneNum));
  198. SysFreeString(bstrPhoneNum);
  199. //This flag is only to be used by ICWDEBUG.EXE
  200. if (gpWizardState->cmnStateData.dwFlags & ICW_CFGFLAG_MODEMOVERRIDE)
  201. gpWizardState->pRefDial->put_ModemOverride(TRUE);
  202. gpWizardState->pRefDial->DoConnect(&bRet);
  203. }
  204. }
  205. return bRet;
  206. }
  207. /*******************************************************************
  208. NAME: ISPDialOKProc
  209. SYNOPSIS: Called when Next or Back btns pressed from page
  210. ENTRY: hDlg - dialog window
  211. fForward - TRUE if 'Next' was pressed, FALSE if 'Back'
  212. puNextPage - if 'Next' was pressed,
  213. proc can fill this in with next page to go to. This
  214. parameter is ingored if 'Back' was pressed.
  215. pfKeepHistory - page will not be kept in history if
  216. proc fills this in with FALSE.
  217. EXIT: returns TRUE to allow page to be turned, FALSE
  218. to keep the same page.
  219. ********************************************************************/
  220. BOOL CALLBACK ISPDialOKProc
  221. (
  222. HWND hDlg,
  223. BOOL fForward,
  224. UINT *puNextPage,
  225. BOOL *pfKeepHistory
  226. )
  227. {
  228. ASSERT(puNextPage);
  229. *pfKeepHistory = FALSE;
  230. if (fForward)
  231. {
  232. if (!gpWizardState->bDoneWebServRAS)
  233. {
  234. //OK so we had a dialing error but let's figure out which one...
  235. HRESULT hrDialErr;
  236. gpWizardState->pRefDial->get_DialError(&hrDialErr);
  237. switch (hrDialErr)
  238. {
  239. case ERROR_LINE_BUSY: //Line is engaged
  240. {
  241. if (gpWizardState->iRedialCount < NUM_MAX_REDIAL)
  242. {
  243. //Redial
  244. *puNextPage = ORD_PAGE_ISPDIAL;
  245. gpWizardState->iRedialCount++;
  246. break;
  247. }
  248. gpWizardState->iRedialCount = 0;
  249. }
  250. default:
  251. {
  252. // nothing special just goto the dialing error page
  253. *puNextPage = ORD_PAGE_DIALERROR;
  254. break;
  255. }
  256. }
  257. }
  258. else if (!gpWizardState->bDoneWebServDownload)
  259. {
  260. gpWizardState->pRefDial->DoHangup();
  261. *puNextPage = ORD_PAGE_SERVERR;
  262. }
  263. }
  264. else // a retry is simulated when BACK is pressed
  265. {
  266. *puNextPage = ORD_PAGE_ISPDIAL;
  267. }
  268. return TRUE;
  269. }
  270. BOOL CALLBACK ISPDialCancelProc(HWND hDlg)
  271. {
  272. //User has canceled so reset the redial count
  273. gpWizardState->iRedialCount = 0;
  274. if (gpWizardState->pRefDial)
  275. {
  276. gpWizardState->pRefDial->DoHangup();
  277. //We should make sure the wiz thinks it's a dialerr to avoid
  278. //the server error page
  279. gpWizardState->bDoneWebServDownload = FALSE;
  280. gpWizardState->bDoneWebServRAS = FALSE;
  281. }
  282. return TRUE;
  283. }