Source code of Windows XP (NT5)
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.

728 lines
20 KiB

  1. // ICS Connectivity status.
  2. var ICS_CONN_STARTING = 1;
  3. var ICS_CONN_CONNECTING = 2;
  4. var ICS_CONN_CONNECTED = 3;
  5. var ICS_CONN_DISCONNECTING = 4;
  6. var ICS_CONN_DISCONNECTED = 5;
  7. var ICS_CONN_STOPPED = 6;
  8. var ICS_CONN_PERMANENT = 7;
  9. var ICS_CONN_UNK_DIAL_STATE = 8;
  10. var ICS_CONN_CALLWAITING = 9;
  11. var ICS_CONN_HN_UNAVAILABLE = 1000;
  12. var ICS_CONN_TIMEOUT = 5000;
  13. var oldState = ICS_CONN_DISCONNECTED;
  14. var currentState = ICS_CONN_DISCONNECTED;
  15. // Types of connections to the Internet via ICS
  16. var ICS_CONN_TYPE_REG = 0;
  17. var ICS_CONN_TYPE_ISP = 1;
  18. var ICS_CONN_TYPE_REF = 2;
  19. var ICS_CONN_TYPE_MIG = 3;
  20. var ICS_Error_Id = 0;
  21. var ICS_ERR_HN_UNAVAILABLE = ICS_Error_Id++;
  22. var ICS_ERR_MODEM_DISCONNECTED = ICS_Error_Id++;
  23. var ICS_ERR_MODEM_FAILED_CONNECT = ICS_Error_Id++;
  24. var ICS_ERR_STOPPED = ICS_Error_Id++;
  25. var ICS_ERR_PERM_DISCONNECTED = ICS_Error_Id++;
  26. var ICS_ERR_TIMEOUT = ICS_Error_Id++;
  27. var LAN_ERR_HW_UNAVAILABLE1 = ICS_Error_Id++;
  28. var LAN_ERR_HW_UNAVAILABLE2 = ICS_Error_Id++;
  29. // Connection type bitmasks
  30. //
  31. // No attempt has been made at detecting connections or an attempt was made
  32. // but failed. This is different from CONNECTIONTYPE_NONE in that it
  33. // indicates that another attempt should be made to determine if connections
  34. // exist.
  35. //
  36. var CONNECTIONTYPE_INVALID = 0x00000000;
  37. // No connection devices exist
  38. //
  39. var CONNECTIONTYPE_NONE = 0x00000001;
  40. // A modem is installed
  41. //
  42. var CONNECTIONTYPE_MODEM = 0x00000002;
  43. // A network card is present and the ICS beacon was detected
  44. //
  45. var CONNECTIONTYPE_LAN_ICS = 0x00000004;
  46. // A network card is present but ICS was not detected
  47. //
  48. var CONNECTIONTYPE_LAN_BROADBAND = 0x00000008;
  49. // Multiple network cards were present and ICS was not detected. It is not
  50. // possible to determine which card to use.
  51. //
  52. var CONNECTIONTYPE_LAN_INDETERMINATE = 0x00000010;
  53. // An ISDN, PPPoE connection is present
  54. //
  55. var CONNECTIONTYPE_OTHER = 0x00000020;
  56. var CONNECTIONTYPE_LAN = (CONNECTIONTYPE_LAN_ICS |
  57. CONNECTIONTYPE_LAN_BROADBAND |
  58. CONNECTIONTYPE_LAN_INDETERMINATE);
  59. // Enumeration to indicate whether we can connect to the Internet
  60. //
  61. var INTERNET_UNKNOWN = -1;
  62. var INTERNET_NO = 0;
  63. var INTERNET_YES = 1;
  64. // Enumeration to indicate whether we can configure a machine's Lan,
  65. // including firewalling, setting IP address and etc.
  66. //
  67. var CONFIG_LAN_UNKNOWN = -1;
  68. var CONFIG_LAN_NO = 0;
  69. var CONFIG_LAN_YES = 1;
  70. var g_ConnectionCapabilities = CONNECTIONTYPE_INVALID;
  71. var g_PreferredConnection = null; // This is initialized in InitApplication() in msobshel.htm
  72. var g_Internet = INTERNET_UNKNOWN;
  73. var g_ModemTypes = null;
  74. var g_CanConfigLan = CONFIG_LAN_UNKNOWN;
  75. var g_PublicLanCount = 0;
  76. var L_ERR_HN_UNAVAILABLE_Text = "Your computer is no longer connected to the Internet through your network. <br><br>To restore the connection, make sure that the network cable is securely plugged into your computer as well as the network.";
  77. // var L_ERR_MODEM_DISCONNECTED = "The Shared Internet connection was unexpectedly interrupted. If your shared Internet Connection is a modem connection. It might have been disconnected.";
  78. // var L_ERR_MODEM_FAILED_CONNECT = "The Shared Internet connection was unexpectedly interrupted as it was being established.<br><br>Click <b>Retry</b> to try connecting again.";
  79. var L_ERRSTOPPED_Text = "Internet Connection Sharing is presently not available on your network. Click <b>Retry</b> to try connecting again.";
  80. var L_ERR_PERM_DISCONNECTED_Text = "Internet Connection Sharing has been disconnected. If you're using a high-speed adapter to connect to the Internet (e.g. Broadband), please ensure that the adapter has been correctly configured and that the cables are securely attached.<br><br>Click <b>Retry</b> to try connecting again.";
  81. var L_ERRTIMEOUT_Text = "There is a problem connecting to the Internet. Either your connection has timed out or this computer is not configured correctly to use the Shared Internet Connection. <br><br>Click <b>Retry</b> to try connecting again.";
  82. var L_ERR_LAN_UNAVAILABLE1_Text = "Your computer is not connected to the Internet through your network. <br><br>Please check your network settings and confirm that you are able to connect to the Internet, then try again.";
  83. var L_ERR_LAN_UNAVAILABLE2_Text = "Your computer is not connected to the Internet through your network. <br><br>Please select one of the following methods:";
  84. <!--REQUIRED FUNCTION NAME-->
  85. function OnIcsConnectionStatus(iStatus)
  86. {
  87. oldState = currentState;
  88. currentState = iStatus;
  89. switch (g_CurrentCKPT)
  90. {
  91. case CKPT_REGISTER1:
  92. case CKPT_REGISTER3:
  93. case CKPT_ISPSIGNUP:
  94. case CKPT_REFDIAL:
  95. case CKPT_MIGDIAL:
  96. break;
  97. default:
  98. return;
  99. }
  100. switch(iStatus)
  101. {
  102. case ICS_CONN_TIMEOUT:
  103. ICS_Error_Id = ICS_ERR_TIMEOUT;
  104. Navigate("icserror\\icsdc.htm");
  105. break;
  106. case ICS_CONN_PERMANENT:
  107. break;
  108. case ICS_CONN_STOPPED:
  109. switch (oldState)
  110. {
  111. case ICS_CONN_PERMANENT:
  112. ICS_Error_Id = ICS_ERR_STOPPED;
  113. Navigate("icserror\\icsdc.htm");
  114. break;
  115. default:
  116. break;
  117. }
  118. break;
  119. case ICS_CONN_HN_UNAVAILABLE:
  120. ICS_Error_Id = ICS_ERR_HN_UNAVAILABLE;
  121. Navigate("icserror\\icsdc.htm");
  122. break;
  123. default:
  124. break;
  125. }
  126. }
  127. // one page handles all disconnect errors
  128. function IcsDcError_LoadMe()
  129. {
  130. InitFrameRef();
  131. InitNewButtons();
  132. g.btnNext.onclick = IcsErrorNextBtnHandler;
  133. g.btnSkip.onclick = IcsErrorSkipBtnHandler;
  134. switch (ICS_Error_Id)
  135. {
  136. case ICS_ERR_HN_UNAVAILABLE:
  137. g.ErrorPara1.innerHTML = L_ERR_HN_UNAVAILABLE_Text;
  138. break;
  139. case ICS_ERR_STOPPED:
  140. g.ErrorPara1.innerHTML = L_ERRSTOPPED_Text;
  141. break;
  142. case ICS_ERR_PERM_DISCONNECTED:
  143. g.ErrorPara1.innerHTML = L_ERR_PERM_DISCONNECTED_Text;
  144. break;
  145. case ICS_ERR_TIMEOUT:
  146. g.ErrorPara1.innerHTML = L_ERRTIMEOUT_Text;
  147. break;
  148. case LAN_ERR_HW_UNAVAILABLE1:
  149. case LAN_ERR_HW_UNAVAILABLE2:
  150. g.btnBack.style.visibility = "visible";
  151. g.BackBtnLocalText.style.visibility = "visible";
  152. g.btnBack.onclick = IcsErrorBackBtnHandler;
  153. if (ICS_Error_Id == LAN_ERR_HW_UNAVAILABLE1)
  154. {
  155. g.ErrorPara1.innerHTML = L_ERR_LAN_UNAVAILABLE1_Text;
  156. }
  157. else
  158. {
  159. g.ErrorPara1.innerHTML = L_ERR_LAN_UNAVAILABLE2_Text;
  160. g.ErrorPara2.style.display = "inline";
  161. }
  162. break;
  163. }
  164. g.btnNext.focus();
  165. }
  166. function IcsErrorBackBtnHandler()
  167. {
  168. GoNavigate(g_CurrentCKPT);
  169. }
  170. function IcsErrorNextBtnHandler()
  171. {
  172. DisableAllButtons();
  173. ResetConnectedToInternetEx();
  174. switch (g_CurrentCKPT)
  175. {
  176. case CKPT_REGISTER1:
  177. case CKPT_REGISTER3:
  178. if (ICS_Error_Id == LAN_ERR_HW_UNAVAILABLE1)
  179. {
  180. LanActReg();
  181. }
  182. else if (ICS_Error_Id == LAN_ERR_HW_UNAVAILABLE2)
  183. {
  184. if (g.rb_conn_modem.checked)
  185. {
  186. GoNavigate(CKPT_REGDIAL);
  187. }
  188. else
  189. {
  190. LanActReg();
  191. }
  192. }
  193. else
  194. {
  195. IcsConnect(ICS_CONN_TYPE_REG);
  196. }
  197. break;
  198. case CKPT_ISPSIGNUP:
  199. IcsConnect(ICS_CONN_TYPE_ISP);
  200. break;
  201. case CKPT_REFDIAL:
  202. IcsConnect(ICS_CONN_TYPE_REF);
  203. break;
  204. case CKPT_MIGDIAL:
  205. IcsConnect(ICS_CONN_TYPE_MIG);
  206. break;
  207. default:
  208. break;
  209. }
  210. }
  211. function IcsErrorSkipBtnHandler()
  212. {
  213. switch (g_CurrentCKPT)
  214. {
  215. case CKPT_REGISTER1:
  216. case CKPT_REGISTER3:
  217. // showing icsdc.htm is similar to showing acterror.htm
  218. g_CurrentCKPT = CKPT_ACT_MSG;
  219. break;
  220. default:
  221. break;
  222. }
  223. GoCancel();
  224. }
  225. function LanActReg()
  226. {
  227. if (g_Internet == INTERNET_UNKNOWN)
  228. {
  229. ConnectedToInternetEx(true, "LanActReg2();");
  230. g.document.body.style.cursor = "wait";
  231. }
  232. else
  233. {
  234. LanActReg2();
  235. }
  236. }
  237. function LanActReg2()
  238. {
  239. if (!ConnectedToInternetEx(false))
  240. {
  241. if (HasModem())
  242. {
  243. ICS_Error_Id = LAN_ERR_HW_UNAVAILABLE2;
  244. }
  245. else
  246. {
  247. ICS_Error_Id = LAN_ERR_HW_UNAVAILABLE1;
  248. }
  249. Navigate("icserror\\icsdc.htm");
  250. }
  251. else
  252. {
  253. CommonActReg();
  254. }
  255. }
  256. function IcsConnect(iConnectionType)
  257. {
  258. // REVIEW: How does PPPoE affect the logic flow of this function?
  259. // REVIEW: What happens if a PPPoE connection hasn't been established?
  260. // REVIEW: What happens if a PPPoE connection can't be established?
  261. if (g_Internet == INTERNET_UNKNOWN)
  262. {
  263. ConnectedToInternetEx(true, "IcsConnect2("+iConnectionType+")");
  264. }
  265. else
  266. {
  267. IcsConnect2(iConnectionType);
  268. }
  269. }
  270. function IcsConnect2(iConnectionType)
  271. {
  272. if (!ConnectedToInternetEx(false))
  273. {
  274. OnIcsConnectionStatus ( ICS_CONN_HN_UNAVAILABLE );
  275. return;
  276. }
  277. switch (iConnectionType)
  278. {
  279. case ICS_CONN_TYPE_REG:
  280. CommonActReg();
  281. break;
  282. case ICS_CONN_TYPE_ISP:
  283. // REVIEW: Remove. OOBE should never attempt ISP signup via LAN/ICS.
  284. window.external.Connect(CONNECTED_ISP_SIGNUP, "msobe.isp");
  285. break;
  286. case ICS_CONN_TYPE_REF:
  287. // REVIEW: Remove. OOBE should never attempt ISP signup via LAN/ICS.
  288. window.external.Connect(CONNECTED_REFFERAL, "migrate.isp");
  289. break;
  290. case ICS_CONN_TYPE_MIG:
  291. // REVIEW: Remove. window.external.Connect does not handle ISP index
  292. // parameter. ISP migration is not done via LAN/ICS.
  293. window.external.Connect(CONNECTED_ISP_MIGRATE, gselectedISPIndx);
  294. break;
  295. default:
  296. break;
  297. }
  298. }
  299. function CommonActReg()
  300. {
  301. // REVIEW:Does window.external.Connect do anything useful in this case?
  302. //
  303. window.external.Connect(CONNECTED_REGISTRATION, "reg.isp");
  304. if (g_DoActivation)
  305. {
  306. window.external.AsyncActivate(g_PostToMS);
  307. }
  308. else
  309. {
  310. if (g_PostToMS)
  311. {
  312. window.external.PostRegData(POST_TO_MS);
  313. StatusObj.set_Status(MS_REGISTRATION, true);
  314. }
  315. ActivationComplete();
  316. }
  317. }
  318. function UseIcs()
  319. {
  320. fResult = ((CONNECTIONTYPE_LAN_ICS == GetPreferredConnection())
  321. && HasIcs()) ? true : false;
  322. trace("UseIcs: " + fResult);
  323. return fResult;
  324. } // UseIcs
  325. function HasIcs()
  326. {
  327. fResult = (CONNECTIONTYPE_LAN_ICS & GetConnectionCapabilities()) ? true : false;
  328. trace("HasIcs: " + fResult);
  329. return fResult;
  330. } // HasIcs
  331. function UseBroadband()
  332. {
  333. fResult = (CONNECTIONTYPE_LAN_BROADBAND == GetPreferredConnection() && HasBroadband()) ? true : false;
  334. trace("UseBroadband: " + fResult);
  335. return fResult;
  336. } // UseBroadband
  337. function HasBroadband()
  338. {
  339. fResult = (CONNECTIONTYPE_LAN_BROADBAND & GetConnectionCapabilities()) ? true : false;
  340. trace("HasBroadband: " + fResult);
  341. return fResult;
  342. } // HasBroadband
  343. function HasIndeterminateLan()
  344. {
  345. fResult = (CONNECTIONTYPE_LAN_INDETERMINATE & GetConnectionCapabilities()) ? true : false;
  346. trace("HasIndeterminateLan: " + fResult);
  347. return fResult;
  348. } // HasIndeterminateLan
  349. // This will return true if you have a modem but no NIC. It will return false if you have a modem and a NIC,
  350. // because NIC will always be the preferred connection over a modem.
  351. function UseModem()
  352. {
  353. fResult = (CONNECTIONTYPE_MODEM == GetPreferredConnection() && HasModem()) ? true : false;
  354. trace("UseModem: " + fResult);
  355. return fResult;
  356. } // UseModem
  357. // This will return true if you have a modem regardless if you have a NIC or not.
  358. function HasModem()
  359. {
  360. // For XP, window.external.GetConnectionCapabilities ignores
  361. // modems. Use window.external.CheckDialReady instead.
  362. //
  363. fResult = (CONNECTIONTYPE_MODEM & GetConnectionCapabilities()) ? true : false;
  364. trace("HasModem: " + fResult);
  365. return fResult;
  366. } // HasModem
  367. function HasAnalogModem()
  368. {
  369. GetConnectionCapabilities();
  370. fResult = (g_ModemTypes == ERR_COMM_NO_ERROR);
  371. trace("HasAnalogModem: " + fResult);
  372. return fResult;
  373. } // HasAnalogModem
  374. function UseAnalogModem()
  375. {
  376. fResult = (CONNECTIONTYPE_MODEM == GetPreferredConnection() && HasAnalogModem()) ? true : false;
  377. trace("UseAnalogModem: " + fResult);
  378. return fResult;
  379. } // UseAnalogModem
  380. function UseNetwork()
  381. {
  382. return (UseIcs() || UseBroadband() || HasIndeterminateLan());
  383. } // UseNetwork
  384. function HasNetwork()
  385. {
  386. var fResult = (GetConnectionCapabilities() & CONNECTIONTYPE_LAN) ? true : false;
  387. trace("HasNetwork: " + fResult);
  388. return fResult;
  389. } // HasNetwork
  390. function HasConnection()
  391. {
  392. fResult = (HasNetwork() || HasModem());
  393. trace("HasConnection: " + fResult);
  394. return fResult;
  395. } // HasConnection
  396. function SetPreferredConnection(ctPreferred)
  397. {
  398. // window.external.SetPreferredConnection validates the connection type.
  399. // Only update g_PreferredConnection if the connection type is valid.
  400. //
  401. if (window.external.SetPreferredConnection(ctPreferred))
  402. {
  403. g_PreferredConnection = ctPreferred;
  404. }
  405. else if ((ctPreferred == CONNECTIONTYPE_MODEM) && HasModem())
  406. {
  407. g_PreferredConnection = CONNECTIONTYPE_MODEM;
  408. }
  409. // Save g_PreferredConnection to registry, for use in cases where we cold boot OOBE after ics.htm page.
  410. ApiObj.set_RegValue(HKEY_LOCAL_MACHINE, OOBE_MAIN_REG_KEY + "\\TEMP", PREFCONN_REG_VALUE, g_PreferredConnection);
  411. } // SetConnectionPreferred
  412. function GetPreferredConnection()
  413. {
  414. if (CONNECTIONTYPE_INVALID == g_PreferredConnection
  415. )
  416. {
  417. trace("Calling window.external.GetPreferredConnection");
  418. g_PreferredConnection = window.external.GetPreferredConnection();
  419. // For XP, window.external.GetPreferredConnection ignores
  420. // modems.
  421. //
  422. if (CONNECTIONTYPE_NONE == g_PreferredConnection
  423. && HasModem() )
  424. {
  425. g_PreferredConnection = CONNECTIONTYPE_MODEM;
  426. }
  427. }
  428. trace("GetPreferredConnection: " + g_PreferredConnection);
  429. return g_PreferredConnection;
  430. } // GetPreferredConnection
  431. function GetConnectionCapabilities()
  432. {
  433. // REVIEW: need to return invalid until services have been started.
  434. if (CONNECTIONTYPE_INVALID == g_ConnectionCapabilities)
  435. {
  436. trace("Calling window.external.GetConnectionCapabilities");
  437. g_ConnectionCapabilities = window.external.GetConnectionCapabilities();
  438. // For XP, window.external.GetConnectionCapabilities ignores
  439. // modems.
  440. //
  441. g_ModemTypes = window.external.CheckDialReady();
  442. if (ERR_COMM_NO_ERROR == g_ModemTypes ||
  443. ERR_COMM_ISDN == g_ModemTypes ||
  444. ERR_COMM_PHONE_AND_ISDN == g_ModemTypes)
  445. {
  446. g_ConnectionCapabilities |= CONNECTIONTYPE_MODEM;
  447. }
  448. }
  449. trace("GetConnectionCapabilities: " + g_ConnectionCapabilities);
  450. return g_ConnectionCapabilities;
  451. } // GetConnectionCapabilities
  452. function InternetCapabilityExists()
  453. {
  454. var fExists = false;
  455. // look for network connection first, then modem if that fails
  456. //
  457. if (HasNetwork())
  458. {
  459. fExists = true;
  460. }
  461. if (!fExists && HasModem())
  462. {
  463. fExists = true;
  464. }
  465. trace("InternetCapabilityExists: " + fExists);
  466. return fExists;
  467. } // InternetCapabilityExists
  468. var ICS_MINIMUM_CALLBACK_SLEEP_TIME = 6000;
  469. var ICS_MINIMUM_TIMEOUT = 40;
  470. function AsyncCallback(callback)
  471. {
  472. this._callback = callback;
  473. this._startTime = (new Date()).getTime();
  474. }
  475. function InvokeCallback()
  476. {
  477. if (this._callback != null)
  478. {
  479. var timeRemained = ICS_MINIMUM_CALLBACK_SLEEP_TIME -
  480. ((new Date()).getTime() - this._startTime);
  481. // We need to use setTimeout so that the script won't be
  482. // executed by abitrary application, but the script engine thread.
  483. // Otherwise, the script engine may hang.
  484. //
  485. if (timeRemained < ICS_MINIMUM_TIMEOUT)
  486. {
  487. // The timeout value chosen is arbitrary. It just need to be small.
  488. //
  489. setTimeout(this._callback, ICS_MINIMUM_TIMEOUT);
  490. }
  491. else
  492. {
  493. setTimeout(this._callback, timeRemained);
  494. }
  495. }
  496. }
  497. AsyncCallback.prototype.InvokeCallback = InvokeCallback;
  498. var g_ConnectedToInternetCallback = null;
  499. //
  500. // Return the internet connection status.
  501. //
  502. // If the callback is null, always returns normally (synchronously).
  503. // If callback is not null, always returns using the callback (asynchronously),
  504. // which should check the status by ConnectedToInternetEx(false).
  505. //
  506. function ConnectedToInternetEx(bRefresh, callback)
  507. {
  508. var retval = false;
  509. if (UseModem() && (GetConnectionCapabilities() == CONNECTIONTYPE_MODEM))
  510. {
  511. // Use whatever returned by the old API and don't change the
  512. // global state
  513. if (callback == null)
  514. {
  515. retval = window.external.ConnectedToInternet();
  516. }
  517. else
  518. {
  519. trace("ConnectedToInternetEx("+bRefresh+", "+callback+")");
  520. setTimeout(callback, ICS_MINIMUM_CALLBACK_SLEEP_TIME);
  521. }
  522. }
  523. else if (bRefresh && g_Internet == INTERNET_UNKNOWN)
  524. {
  525. // Refresh the global state about the Internet connection
  526. if (callback == null)
  527. {
  528. retval = window.external.ConnectedToInternetEx()
  529. g_Internet = (retval) ? INTERNET_YES : INTERNET_NO;
  530. }
  531. else
  532. {
  533. g_ConnectedToInternetCallback = new AsyncCallback(callback);
  534. setTimeout("window.external.AsyncConnectedToInternetEx()",
  535. ICS_MINIMUM_TIMEOUT);
  536. // return at ReturnConnectedToInternetEx
  537. }
  538. }
  539. else
  540. {
  541. // Use cached results
  542. if (callback == null)
  543. {
  544. retval = (g_Internet == INTERNET_YES);
  545. }
  546. else
  547. {
  548. setTimeout(callback, ICS_MINIMUM_CALLBACK_SLEEP_TIME);
  549. }
  550. }
  551. return retval;
  552. }
  553. function ResetConnectedToInternetEx()
  554. {
  555. g_Internet = INTERNET_UNKNOWN;
  556. }
  557. <!--REQUIRED FUNCTION NAME-->
  558. function ReturnConnectedToInternetEx(bConnected)
  559. {
  560. g_Internet = (bConnected) ? INTERNET_YES : INTERNET_NO;
  561. if (g_ConnectedToInternetCallback != null)
  562. {
  563. g_ConnectedToInternetCallback.InvokeCallback();
  564. g_ConnectedToInternetCallback = null;
  565. }
  566. }
  567. function CanConfigLan()
  568. {
  569. if (HasBroadband() || HasIndeterminateLan())
  570. {
  571. return g_CanConfigLan;
  572. }
  573. return CONFIG_LAN_NO;
  574. }
  575. function GetPublicLanCount()
  576. {
  577. return g_PublicLanCount;
  578. }
  579. var g_CheckIfConfigInternetCallback = null;
  580. //
  581. // Precondition:
  582. //
  583. // CanConfigLan() != CONFIG_LAN_NO
  584. //
  585. // Description:
  586. //
  587. // The callback will be invoked asynchronously one the
  588. // window.external.AsyncGetPublicLanCount returns through
  589. // ReturnGetPublicLanCount. The UI won't be frozened.
  590. //
  591. // Postcondition:
  592. //
  593. // g_CanConfigLan, g_PublicLanCount and g_Internet are determined.
  594. // callback is invoked.
  595. //
  596. function CheckIfConfigLan(callback)
  597. {
  598. g_CheckIfConfigInternetCallback = new AsyncCallback(callback);
  599. setTimeout("window.external.AsyncGetPublicLanCount()", ICS_MINIMUM_TIMEOUT);
  600. // return at ReturnCheckIfConfigInternet
  601. }
  602. <!--REQUIRED FUNCTION NAME-->
  603. function ReturnGetPublicLanCount(bConnected, cPublicLan)
  604. {
  605. // bConnected and/or cPublicLan can be null if some serious failure occurred.
  606. g_Internet = (bConnected) ? INTERNET_YES : INTERNET_NO;
  607. if (cPublicLan)
  608. {
  609. g_PublicLanCount = cPublicLan;
  610. }
  611. else
  612. {
  613. g_PublicLanCount = 0;
  614. }
  615. // g_Internet and g_PublicLanCount can be inconsistent because
  616. // they rely on the status of different servers on the Internet.
  617. if (g_Internet == INTERNET_YES)
  618. {
  619. if (g_PublicLanCount == 0)
  620. {
  621. if (HasBroadband())
  622. {
  623. g_PublicLanCount = 1;
  624. }
  625. }
  626. }
  627. if (g_PublicLanCount >= 1 || HasBroadband())
  628. {
  629. g_CanConfigLan = CONFIG_LAN_YES;
  630. }
  631. else
  632. {
  633. g_CanConfigLan = CONFIG_LAN_NO;
  634. }
  635. if (g_CheckIfConfigInternetCallback != null)
  636. {
  637. g_CheckIfConfigInternetCallback.InvokeCallback();
  638. g_CheckIfConfigInternetCallback = null;
  639. }
  640. }