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.

5675 lines
141 KiB

  1. /* Copyright (c) 1995, Microsoft Corporation, all rights reserved
  2. **
  3. ** ifw.c
  4. ** Remote Access Common Dialog APIs
  5. ** Add Interface wizard
  6. **
  7. ** 02/11/97 Abolade Gbadegesin (based on entryw.c, by Steve Cobb).
  8. */
  9. #include "rasdlgp.h"
  10. #include "entry.h"
  11. #include <winsock.h> //got in for inet_addr
  12. //
  13. // Definitions for flags tracked by the interface wizard.
  14. // See the dwFlags member of AIINFO.
  15. //
  16. #define AI_F_HasPhysDevs 0x1 // router has phys ports available
  17. #define AI_F_HasTunlDevs 0x2 // router has tunnel ports available
  18. #define AI_F_HasPptpDevs 0x4 // router has Pptp ports available
  19. #define AI_F_HasL2tpDevs 0x8 // router has L2tp ports available
  20. #define AI_F_HasPPPoEDevs 0x10 // router has PPPoE ports available //for whistler bug 345068 349087
  21. /*----------------------------------------------------------------------------
  22. ** Local datatypes
  23. **----------------------------------------------------------------------------
  24. */
  25. #define EMPTY_IPADDRESS L"0.0.0.0"
  26. #define SROUTEINFO struct tagSROUTEINFO
  27. SROUTEINFO
  28. {
  29. TCHAR * pszDestIP;
  30. TCHAR * pszNetworkMask;
  31. TCHAR * pszMetric;
  32. };
  33. #define SROUTEINFOLIST struct tagSROUTEINFOLIST
  34. SROUTEINFOLIST
  35. {
  36. SROUTEINFOLIST * pNext;
  37. SROUTEINFO RouteInfo;
  38. };
  39. /* Add Interface wizard context block. All property pages refer to the single
  40. ** context block associated with the sheet.
  41. */
  42. #define AIINFO struct tagAIINFO
  43. AIINFO
  44. {
  45. /* Common input arguments.
  46. */
  47. EINFO* pArgs;
  48. /* Wizard and page handles. 'hwndFirstPage' is the handle of the first
  49. ** property page initialized. This is the page that allocates and frees
  50. ** the context block.
  51. */
  52. HWND hwndDlg;
  53. HWND hwndFirstPage;
  54. HWND hwndRb; //Add for DOD wizard 345068 349087
  55. HWND hwndRw;
  56. HWND hwndIn;
  57. HWND hwndSr;
  58. HWND hwndSs;
  59. HWND hwndRn;
  60. HWND hwndRp;
  61. HWND hwndRc;
  62. HWND hwndRa;
  63. HWND hwndNs;
  64. HWND hwndDo;
  65. HWND hwndDi;
  66. HWND hwndRf;
  67. HWND hwndVd;
  68. /* Interface Name page.
  69. */
  70. HWND hwndEbInterfaceName;
  71. /* Modem/Adapter page.
  72. */
  73. HWND hwndLv;
  74. /* Connection type page
  75. */
  76. HWND hwndRbTypePhys;
  77. HWND hwndRbTypeTunl;
  78. HWND hwndRbBroadband; //Add for DOD wizard
  79. /* Phone number page.
  80. */
  81. HWND hwndStNumber;
  82. HWND hwndEbNumber; //Share by VpnDestination, PhoneNumber, PPPoE
  83. HWND hwndPbAlternates;
  84. /* Login script page.
  85. */
  86. HWND hwndCbRunScript;
  87. HWND hwndLbScripts;
  88. HWND hwndCbTerminal;
  89. HWND hwndPbEdit;
  90. HWND hwndPbBrowse;
  91. /* IP address page.
  92. */
  93. HWND hwndCcIp;
  94. /* Name server page.
  95. */
  96. HWND hwndCcDns;
  97. HWND hwndCcWins;
  98. /* Vpn type page
  99. */
  100. HWND hwndVtRbAutomatic;
  101. HWND hwndVtRbPptp;
  102. HWND hwndVtRbL2tp;
  103. /* Dial-out credentials page.
  104. */
  105. HWND hwndDoEbUserName;
  106. HWND hwndDoEbDomain;
  107. HWND hwndDoEbPassword;
  108. HWND hwndDoEbConfirm;
  109. /* Dial-in credentials page.
  110. */
  111. HWND hwndDiEbUserName;
  112. HWND hwndDiEbDomain;
  113. HWND hwndDiEbPassword;
  114. HWND hwndDiEbConfirm;
  115. /* Router welcome page
  116. */
  117. HWND hwndRwStWelcome;
  118. /* Router finish page
  119. */
  120. HWND hwndRfStFinish;
  121. /* Static Route Page
  122. */
  123. HWND hwndLvStaticRoutes;
  124. /* Static Route Add Dialog
  125. */
  126. HWND hwndDest;
  127. HWND hwndNetMask;
  128. HWND hwndMetric;
  129. /* The phone number stash. This allows user to change the port to another
  130. ** link without losing the phone number he typed. Initialized to empty in
  131. ** AiInit and saved to entry in AiFinish.
  132. */
  133. DTLLIST* pListPhoneNumbers;
  134. BOOL fPromoteHuntNumbers;
  135. /* Checkbox options chosen by user.
  136. */
  137. BOOL fIp;
  138. BOOL fIpx;
  139. BOOL fClearPwOk;
  140. BOOL fNotNt;
  141. /*For connection type page, For whistler bug 349807
  142. */
  143. DWORD dwCtDeviceNum;
  144. /* Set true when there is only one meaningful choice of device.
  145. */
  146. BOOL fSkipMa;
  147. /* Set true if the selected device is a modem or null modem.
  148. */
  149. BOOL fModem;
  150. /* The NP_* mask of protocols configured for RAS.
  151. */
  152. DWORD dwfConfiguredProtocols;
  153. /* Set true if IP is configured for RAS.
  154. */
  155. BOOL fIpConfigured;
  156. //IPX is not supported on IA64
  157. //
  158. BOOL fIpxConfigured;
  159. /* Set to true of Add Interface wizard is skipped.
  160. */
  161. BOOL fSkipWizard;
  162. // After dial scripting helper context block, and a flag indicating if the
  163. // block has been initialized.
  164. //
  165. SUINFO suinfo;
  166. BOOL fSuInfoInitialized;
  167. // Handle to a bold font for use with start and finish wizard pages
  168. HFONT hBoldFont;
  169. // Flags that track the configuration of the machine that the
  170. // wizard is currently focused on. See AI_F_*
  171. DWORD dwFlags;
  172. // Set to the vpn type when one is configured.
  173. DWORD dwVpnStrategy;
  174. // Index of the selected device on the RN page
  175. //
  176. DWORD dwSelectedDeviceIndex;
  177. // List of all static routes
  178. //
  179. SROUTEINFOLIST * pRouteInfoListHead;
  180. };
  181. /*----------------------------------------------------------------------------
  182. ** Local prototypes (alphabetically)
  183. **----------------------------------------------------------------------------
  184. */
  185. int CALLBACK
  186. AiCallbackFunc(
  187. IN HWND hwndDlg,
  188. IN UINT unMsg,
  189. IN LPARAM lparam );
  190. VOID
  191. AiCancel(
  192. IN HWND hwndPage );
  193. AIINFO*
  194. AiContext(
  195. IN HWND hwndPage );
  196. VOID
  197. AiExit(
  198. IN AIINFO* pInfo,
  199. IN DWORD dwError );
  200. VOID
  201. AiExitInit(
  202. IN HWND hwndDlg );
  203. BOOL
  204. AiFinish(
  205. IN HWND hwndPage );
  206. AIINFO*
  207. AiInit(
  208. IN HWND hwndFirstPage,
  209. IN EINFO* pArgs );
  210. VOID
  211. AiTerm(
  212. IN HWND hwndPage );
  213. INT_PTR CALLBACK
  214. RbDlgProc(
  215. IN HWND hwnd,
  216. IN UINT unMsg,
  217. IN WPARAM wparam,
  218. IN LPARAM lparam );
  219. BOOL
  220. RbInit(
  221. IN HWND hwndPage );
  222. BOOL
  223. RbKillActive(
  224. IN AIINFO* pInfo );
  225. BOOL
  226. RbSetActive(
  227. IN AIINFO* pInfo );
  228. INT_PTR CALLBACK
  229. CtDlgProc(
  230. IN HWND hwnd,
  231. IN UINT unMsg,
  232. IN WPARAM wparam,
  233. IN LPARAM lparam );
  234. BOOL
  235. CtInit(
  236. IN HWND hwndPage );
  237. BOOL
  238. CtKillActive(
  239. IN AIINFO* pInfo );
  240. BOOL
  241. CtSetActive(
  242. IN AIINFO* pInfo );
  243. INT_PTR CALLBACK
  244. DiDlgProc(
  245. IN HWND hwnd,
  246. IN UINT unMsg,
  247. IN WPARAM wparam,
  248. IN LPARAM lparam );
  249. BOOL
  250. DiInit(
  251. IN HWND hwndPage );
  252. BOOL
  253. DiKillActive(
  254. IN AIINFO* pInfo );
  255. BOOL
  256. DiNext(
  257. IN AIINFO* pInfo );
  258. BOOL
  259. DiSetActive(
  260. IN AIINFO* pInfo );
  261. INT_PTR CALLBACK
  262. DoDlgProc(
  263. IN HWND hwnd,
  264. IN UINT unMsg,
  265. IN WPARAM wparam,
  266. IN LPARAM lparam );
  267. BOOL
  268. DoCommand(
  269. IN AIINFO* pInfo,
  270. IN WORD wNotification,
  271. IN WORD wId,
  272. IN HWND hwndCtrl );
  273. BOOL
  274. DoInit(
  275. IN HWND hwndPage );
  276. BOOL
  277. DoKillActive(
  278. IN AIINFO* pInfo );
  279. BOOL
  280. DoNext(
  281. IN AIINFO* pInfo );
  282. BOOL
  283. DoSetActive(
  284. IN AIINFO* pInfo );
  285. DWORD
  286. GetPhysicDeviceOtherThanLPT1(
  287. IN AIINFO * pInfo );
  288. BOOL
  289. InCommand(
  290. IN AIINFO* pInfo,
  291. IN WORD wNotification,
  292. IN WORD wId,
  293. IN HWND hwndCtrl );
  294. INT_PTR CALLBACK
  295. InDlgProc(
  296. IN HWND hwnd,
  297. IN UINT unMsg,
  298. IN WPARAM wparam,
  299. IN LPARAM lparam );
  300. BOOL
  301. InInit(
  302. IN HWND hwndPage);
  303. BOOL
  304. InKillActive(
  305. IN AIINFO* pInfo );
  306. BOOL
  307. InSetActive(
  308. IN AIINFO* pInfo );
  309. INT_PTR CALLBACK
  310. NsDlgProc(
  311. IN HWND hwnd,
  312. IN UINT unMsg,
  313. IN WPARAM wparam,
  314. IN LPARAM lparam );
  315. BOOL
  316. NsInit(
  317. IN HWND hwndPage );
  318. BOOL
  319. NsKillActive(
  320. IN AIINFO* pInfo );
  321. BOOL
  322. NsSetActive(
  323. IN AIINFO* pInfo );
  324. INT_PTR CALLBACK
  325. RaDlgProc(
  326. IN HWND hwnd,
  327. IN UINT unMsg,
  328. IN WPARAM wparam,
  329. IN LPARAM lparam );
  330. BOOL
  331. RaInit(
  332. IN HWND hwndPage );
  333. BOOL
  334. RaKillActive(
  335. IN AIINFO* pInfo );
  336. BOOL
  337. RaSetActive(
  338. IN AIINFO* pInfo );
  339. BOOL
  340. RcCommand(
  341. IN AIINFO* pInfo,
  342. IN WORD wNotification,
  343. IN WORD wId,
  344. IN HWND hwndCtrl );
  345. INT_PTR CALLBACK
  346. RcDlgProc(
  347. IN HWND hwnd,
  348. IN UINT unMsg,
  349. IN WPARAM wparam,
  350. IN LPARAM lparam );
  351. BOOL
  352. RcInit(
  353. IN HWND hwndPage );
  354. BOOL
  355. RcKillActive(
  356. IN AIINFO* pInfo );
  357. BOOL
  358. RcSetActive(
  359. IN AIINFO* pInfo );
  360. BOOL
  361. RfCommand(
  362. IN AIINFO* pInfo,
  363. IN WORD wNotification,
  364. IN WORD wId,
  365. IN HWND hwndCtrl );
  366. INT_PTR CALLBACK
  367. RfDlgProc(
  368. IN HWND hwnd,
  369. IN UINT unMsg,
  370. IN WPARAM wparam,
  371. IN LPARAM lparam );
  372. BOOL
  373. RfInit(
  374. IN HWND hwndPage );
  375. BOOL
  376. RfKillActive(
  377. IN AIINFO* pInfo );
  378. BOOL
  379. RfSetActive(
  380. IN AIINFO* pInfo );
  381. INT_PTR CALLBACK
  382. RnDlgProc(
  383. IN HWND hwnd,
  384. IN UINT unMsg,
  385. IN WPARAM wparam,
  386. IN LPARAM lparam );
  387. BOOL
  388. RnInit(
  389. IN HWND hwndPage );
  390. LVXDRAWINFO*
  391. RnLvCallback(
  392. IN HWND hwndLv,
  393. IN DWORD dwItem );
  394. VOID
  395. RnLvItemChanged(
  396. IN AIINFO* pInfo );
  397. BOOL
  398. RnLvRefresh(
  399. IN AIINFO* pInfo);
  400. BOOL
  401. RnSetActive(
  402. IN AIINFO* pInfo );
  403. VOID
  404. RpAlternates(
  405. IN AIINFO* pInfo );
  406. BOOL
  407. RpCommand(
  408. IN AIINFO* pInfo,
  409. IN WORD wNotification,
  410. IN WORD wId,
  411. IN HWND hwndCtrl );
  412. INT_PTR CALLBACK
  413. RpDlgProc(
  414. IN HWND hwnd,
  415. IN UINT unMsg,
  416. IN WPARAM wparam,
  417. IN LPARAM lparam );
  418. BOOL
  419. RpInit(
  420. IN HWND hwndPage );
  421. BOOL
  422. RpKillActive(
  423. IN AIINFO* pInfo );
  424. VOID
  425. RpPhoneNumberToStash(
  426. IN AIINFO* pInfo );
  427. BOOL
  428. RpSetActive(
  429. IN AIINFO* pInfo );
  430. INT_PTR CALLBACK
  431. RwDlgProc(
  432. IN HWND hwnd,
  433. IN UINT unMsg,
  434. IN WPARAM wparam,
  435. IN LPARAM lparam );
  436. BOOL
  437. RwInit(
  438. IN HWND hwndPage,
  439. IN OUT EINFO* pArgs );
  440. BOOL
  441. RwKillActive(
  442. IN AIINFO* pInfo );
  443. BOOL
  444. RwSetActive(
  445. IN AIINFO* pInfo );
  446. BOOL
  447. SrCommand(
  448. IN AIINFO* pInfo,
  449. IN WORD wNotification,
  450. IN WORD wId,
  451. IN HWND hwndCtrl );
  452. VOID
  453. SrLvItemChanged(
  454. IN AIINFO* pInfo );
  455. INT_PTR CALLBACK
  456. SrDlgProc(
  457. IN HWND hwnd,
  458. IN UINT unMsg,
  459. IN WPARAM wparam,
  460. IN LPARAM lparam );
  461. BOOL
  462. SrInit(
  463. IN HWND hwndPage );
  464. BOOL
  465. SrKillActive(
  466. IN AIINFO* pInfo );
  467. BOOL
  468. SrSetActive(
  469. IN AIINFO* pInfo );
  470. BOOL
  471. SsCommand(
  472. IN AIINFO* pInfo,
  473. IN WORD wNotification,
  474. IN WORD wId,
  475. IN HWND hwndCtrl );
  476. INT_PTR CALLBACK
  477. SsDlgProc(
  478. IN HWND hwnd,
  479. IN UINT unMsg,
  480. IN WPARAM wparam,
  481. IN LPARAM lparam );
  482. BOOL
  483. SsInit(
  484. IN HWND hwndPage );
  485. BOOL
  486. SsKillActive(
  487. IN AIINFO* pInfo );
  488. BOOL
  489. SsSetActive(
  490. IN AIINFO* pInfo );
  491. INT_PTR CALLBACK
  492. VdDlgProc(
  493. IN HWND hwnd,
  494. IN UINT unMsg,
  495. IN WPARAM wparam,
  496. IN LPARAM lparam );
  497. BOOL
  498. VdInit(
  499. IN HWND hwndPage );
  500. BOOL
  501. VdKillActive(
  502. IN AIINFO* pInfo );
  503. BOOL
  504. VdSetActive(
  505. IN AIINFO* pInfo );
  506. INT_PTR CALLBACK
  507. VtDlgProc(
  508. IN HWND hwnd,
  509. IN UINT unMsg,
  510. IN WPARAM wparam,
  511. IN LPARAM lparam );
  512. BOOL
  513. VtInit(
  514. IN HWND hwndPage );
  515. BOOL
  516. VtKillActive(
  517. IN AIINFO* pInfo );
  518. BOOL
  519. VtSetActive(
  520. IN AIINFO* pInfo );
  521. /* Demand dial wizard page definitions.
  522. */
  523. struct DD_WIZ_PAGE_INFO
  524. {
  525. DLGPROC pfnDlgProc;
  526. INT nPageId;
  527. INT nSidTitle;
  528. INT nSidSubtitle;
  529. DWORD dwFlags;
  530. };
  531. static const struct DD_WIZ_PAGE_INFO c_aDdWizInfo [] =
  532. {
  533. { RwDlgProc, PID_RW_RouterWelcome, 0, 0, PSP_HIDEHEADER},
  534. { InDlgProc, PID_IN_InterfaceName, SID_IN_Title, SID_IN_Subtitle, 0},
  535. { CtDlgProc, PID_CT_RouterConnectionType, SID_CT_Title, SID_CT_Subtitle, 0},
  536. { VtDlgProc, PID_VT_RouterVpnType, SID_VT_Title, SID_VT_Subtitle, 0},
  537. { RnDlgProc, PID_RN_RouterModemAdapter, SID_RN_Title, SID_RN_Subtitle, 0},
  538. { RbDlgProc, PID_BS_BroadbandService, SID_BS_Title, SID_BS_Subtitle, 0},
  539. { RpDlgProc, PID_RP_RouterPhoneNumber, SID_RP_Title, SID_RP_Subtitle, 0},
  540. { VdDlgProc, PID_VD_RouterVpnDestination, SID_VD_Title, SID_VD_Subtitle, 0},
  541. { SsDlgProc, PID_SS_ServerSettings, SID_SS_Title, SID_SS_Subtitle, 0},
  542. { SrDlgProc, PID_SR_StaticRoute, SID_SR_Title, SID_SR_SubTitle, 0},
  543. { RaDlgProc, PID_RA_RouterIpAddress, SID_RA_Title, SID_RA_Subtitle, 0},
  544. { NsDlgProc, PID_NS_RouterNameServers, SID_NS_Title, SID_NS_Subtitle, 0},
  545. { RcDlgProc, PID_RC_RouterScripting, SID_RC_Title, SID_RC_Subtitle, 0},
  546. { DiDlgProc, PID_DI_RouterDialIn, SID_DI_Title, SID_DI_Subtitle, 0},
  547. { DoDlgProc, PID_DO_RouterDialOut, SID_DO_Title, SID_DO_Subtitle, 0},
  548. { RfDlgProc, PID_RF_RouterFinish, 0, 0, PSP_HIDEHEADER},
  549. };
  550. #define c_cDdWizPages (sizeof (c_aDdWizInfo) / sizeof(c_aDdWizInfo[0]))
  551. /*----------------------------------------------------------------------------
  552. ** Add Interface wizard entry point
  553. **----------------------------------------------------------------------------
  554. */
  555. VOID
  556. AiWizard(
  557. IN OUT EINFO* pEinfo )
  558. /* Runs the Phonebook entry property sheet. 'PEinfo' is an input block
  559. ** with only caller's API arguments filled in.
  560. */
  561. {
  562. DWORD dwErr, i;
  563. PROPSHEETHEADER header;
  564. PROPSHEETPAGE apage[ c_cDdWizPages ];
  565. PROPSHEETPAGE* ppage;
  566. TRACE("AiWizard");
  567. ZeroMemory( &header, sizeof(header) );
  568. // Prepare the header
  569. //
  570. header.dwSize = sizeof(PROPSHEETHEADER);
  571. header.hwndParent = pEinfo->pApiArgs->hwndOwner;
  572. header.hInstance = g_hinstDll;
  573. header.nPages = c_cDdWizPages;
  574. header.pszbmHeader = MAKEINTRESOURCE( BID_WizardHeader );
  575. header.ppsp = apage;
  576. header.pfnCallback = AiCallbackFunc;
  577. header.dwFlags =
  578. (
  579. PSH_WIZARD | PSH_WIZARD97 |
  580. PSH_WATERMARK | PSH_HEADER |
  581. PSH_STRETCHWATERMARK | PSH_USECALLBACK |
  582. PSH_PROPSHEETPAGE
  583. );
  584. // Prepare the array of pages
  585. //
  586. ZeroMemory( apage, sizeof(apage) );
  587. for (i = 0; i < c_cDdWizPages; i++)
  588. {
  589. // Initialize page data
  590. //
  591. ppage = &apage[i];
  592. ppage->dwSize = sizeof(PROPSHEETPAGE);
  593. ppage->hInstance = g_hinstDll;
  594. ppage->pszTemplate = MAKEINTRESOURCE(c_aDdWizInfo[i].nPageId);
  595. ppage->pfnDlgProc = c_aDdWizInfo[i].pfnDlgProc;
  596. ppage->lParam = (LPARAM )pEinfo;
  597. ppage->dwFlags = c_aDdWizInfo[i].dwFlags;
  598. // Initialize title and subtitle information.
  599. //
  600. if (c_aDdWizInfo[i].nSidTitle)
  601. {
  602. ppage->dwFlags |= PSP_USEHEADERTITLE;
  603. ppage->pszHeaderTitle = PszLoadString( g_hinstDll,
  604. c_aDdWizInfo[i].nSidTitle );
  605. }
  606. if (c_aDdWizInfo[i].nSidSubtitle)
  607. {
  608. ppage->dwFlags |= PSP_USEHEADERSUBTITLE;
  609. ppage->pszHeaderSubTitle = PszLoadString( g_hinstDll,
  610. c_aDdWizInfo[i].nSidSubtitle );
  611. }
  612. }
  613. if (PropertySheet( &header ) == -1)
  614. {
  615. TRACE("PropertySheet failed");
  616. ErrorDlg( pEinfo->pApiArgs->hwndOwner, SID_OP_LoadDlg, ERROR_UNKNOWN,
  617. NULL );
  618. }
  619. }
  620. /*----------------------------------------------------------------------------
  621. ** Add Interface wizard
  622. ** Listed alphabetically
  623. **----------------------------------------------------------------------------
  624. */
  625. int CALLBACK
  626. AiCallbackFunc(
  627. IN HWND hwndDlg,
  628. IN UINT unMsg,
  629. IN LPARAM lparam )
  630. /* A standard Win32 commctrl PropSheetProc. See MSDN documentation.
  631. **
  632. ** Returns 0 always.
  633. */
  634. {
  635. TRACE2("AiCallbackFunc(m=%d,l=%08x)",unMsg,lparam);
  636. if (unMsg == PSCB_PRECREATE)
  637. {
  638. DLGTEMPLATE* pDlg = (DLGTEMPLATE* )lparam;
  639. pDlg->style &= ~(DS_CONTEXTHELP);
  640. }
  641. return 0;
  642. }
  643. VOID
  644. AiCancel(
  645. IN HWND hwndPage )
  646. /* Cancel was pressed. 'HwndPage' is the handle of a wizard page.
  647. */
  648. {
  649. TRACE("AiCancel");
  650. }
  651. AIINFO*
  652. AiContext(
  653. IN HWND hwndPage )
  654. /* Retrieve the property sheet context from a wizard page handle.
  655. */
  656. {
  657. return (AIINFO* )GetProp( GetParent( hwndPage ), g_contextId );
  658. }
  659. VOID
  660. AiExit(
  661. IN AIINFO* pInfo,
  662. IN DWORD dwError )
  663. /* Forces an exit from the dialog, reporting 'dwError' to the caller.
  664. ** 'PInfo' is the dialog context.
  665. **
  666. ** Note: This cannot be called during initialization of the first page.
  667. ** See AiExitInit.
  668. */
  669. {
  670. TRACE("AiExit");
  671. pInfo->pArgs->pApiArgs->dwError = dwError;
  672. PropSheet_PressButton( pInfo->hwndDlg, PSBTN_CANCEL );
  673. }
  674. VOID
  675. AiExitInit(
  676. IN HWND hwndDlg )
  677. /* Utility to report errors within AiInit and other first page
  678. ** initialization. 'HwndDlg' is the dialog window.
  679. */
  680. {
  681. SetOffDesktop( hwndDlg, SOD_MoveOff, NULL );
  682. SetOffDesktop( hwndDlg, SOD_Free, NULL );
  683. PostMessage( hwndDlg, WM_COMMAND,
  684. MAKEWPARAM( IDCANCEL , BN_CLICKED ),
  685. (LPARAM )GetDlgItem( hwndDlg, IDCANCEL ) );
  686. }
  687. BOOL
  688. AiFinish(
  689. IN HWND hwndPage )
  690. /* Saves the contents of the wizard. 'HwndPage is the handle of a
  691. ** property page. Pops up any errors that occur. 'FPropertySheet'
  692. ** indicates the user chose to edit the property sheet directly.
  693. **
  694. ** Returns true is page can be dismissed, false otherwise.
  695. */
  696. {
  697. const TCHAR* pszIp0 = TEXT("0.0.0.0");
  698. AIINFO* pInfo;
  699. PBENTRY* pEntry;
  700. TRACE("AiFinish");
  701. pInfo = AiContext( hwndPage );
  702. ASSERT(pInfo);
  703. if (pInfo == NULL)
  704. {
  705. return ERROR_CAN_NOT_COMPLETE;
  706. }
  707. pEntry = pInfo->pArgs->pEntry;
  708. ASSERT(pEntry);
  709. // Update the entry type to match the selected port(s), which are assumed
  710. // to have been moved to the head of the list. This does not happen
  711. // automatically because "all types" is used initially.
  712. //
  713. {
  714. DTLNODE* pNode;
  715. PBLINK* pLink;
  716. pNode = DtlGetFirstNode( pEntry->pdtllistLinks );
  717. ASSERT( pNode );
  718. pLink = (PBLINK* )DtlGetData( pNode );
  719. ChangeEntryType( pEntry, pLink->pbport.dwType );
  720. }
  721. // Replace phone number settings of all enabled links (or the shared link,
  722. // if applicable) from the stashed phone number list.
  723. //
  724. {
  725. DTLLIST* pList;
  726. DTLNODE* pNodeL;
  727. PBLINK* pLink;
  728. ASSERT( pInfo->pListPhoneNumbers );
  729. if (pEntry->fSharedPhoneNumbers)
  730. {
  731. pLink = (PBLINK* )DtlGetData( pInfo->pArgs->pSharedNode );
  732. ASSERT( pLink );
  733. CopyPszListToPhoneList( pLink, pInfo->pListPhoneNumbers );
  734. }
  735. else
  736. {
  737. for (pNodeL = DtlGetFirstNode( pEntry->pdtllistLinks );
  738. pNodeL;
  739. pNodeL = DtlGetNextNode( pNodeL ))
  740. {
  741. pLink = (PBLINK* )DtlGetData( pNodeL );
  742. ASSERT( pLink );
  743. if (pLink->fEnabled)
  744. {
  745. CopyPszListToPhoneList( pLink, pInfo->pListPhoneNumbers );
  746. }
  747. }
  748. }
  749. }
  750. /* Update some settings based on user selections.
  751. */
  752. if (pInfo->fClearPwOk)
  753. {
  754. pEntry->dwTypicalAuth = TA_Unsecure;
  755. }
  756. else
  757. {
  758. pEntry->dwTypicalAuth = TA_Secure;
  759. }
  760. pEntry->dwAuthRestrictions =
  761. AuthRestrictionsFromTypicalAuth(pEntry->dwTypicalAuth);
  762. if ( !pInfo->fSkipWizard
  763. && !pInfo->fIp)
  764. pEntry->dwfExcludedProtocols |= NP_Ip;
  765. if ( !pInfo->fSkipWizard
  766. && !pInfo->fIpx)
  767. pEntry->dwfExcludedProtocols |= NP_Ipx;
  768. if (pEntry->pszIpAddress
  769. && lstrcmp( pEntry->pszIpAddress, pszIp0 ) != 0)
  770. {
  771. pEntry->dwIpAddressSource = ASRC_RequireSpecific;
  772. }
  773. if ((pEntry->pszIpDnsAddress
  774. && lstrcmp( pEntry->pszIpDnsAddress, pszIp0 ) != 0)
  775. || (pEntry->pszIpWinsAddress
  776. && lstrcmp( pEntry->pszIpWinsAddress, pszIp0 ) != 0))
  777. {
  778. pEntry->dwIpNameSource = ASRC_RequireSpecific;
  779. }
  780. if ( pEntry->dwType == RASET_Vpn )
  781. {
  782. pEntry->dwVpnStrategy = pInfo->dwVpnStrategy;
  783. }
  784. // pmay: 234964
  785. // Default the idle disconnect to five minutes
  786. //
  787. pEntry->lIdleDisconnectSeconds = 5 * 60;
  788. // pmay: 389632
  789. //
  790. // Default DD connections to not register their names (CreateEntryNode
  791. // defaults this value to primary+inform)
  792. //
  793. pEntry->dwIpDnsFlags = 0;
  794. // Whistler bug:
  795. //
  796. // By default, DD connections should share file+print, nor be msclient,
  797. // nor permit NBT over tcp.
  798. //
  799. pEntry->fShareMsFilePrint = FALSE;
  800. pEntry->fBindMsNetClient = FALSE;
  801. EnableOrDisableNetComponent( pEntry, TEXT("ms_server"), FALSE);
  802. EnableOrDisableNetComponent( pEntry, TEXT("ms_msclient"), FALSE);
  803. pEntry->dwIpNbtFlags = 0;
  804. /* It's a valid new entry and caller has not chosen to edit properties
  805. ** directly, so mark the entry for commitment.
  806. */
  807. if (!pInfo->pArgs->fChainPropertySheet)
  808. pInfo->pArgs->fCommit = TRUE;
  809. /*
  810. ** Assign the Router list pointer to
  811. ** Internal Args...
  812. */
  813. {
  814. INTERNALARGS *pIArgs = (INTERNALARGS *) pInfo->pArgs->pApiArgs->reserved;
  815. pIArgs->pvSRouteInfo = (VOID *) ( pInfo->pRouteInfoListHead );
  816. }
  817. return TRUE;
  818. }
  819. AIINFO*
  820. AiInit(
  821. IN HWND hwndFirstPage,
  822. IN EINFO* pArgs )
  823. /* Wizard level initialization. 'HwndPage' is the handle of the first
  824. ** page. 'PArgs' is the common entry input argument block.
  825. **
  826. ** Returns address of the context block if successful, NULL otherwise. If
  827. ** NULL is returned, an appropriate message has been displayed, and the
  828. ** wizard has been cancelled.
  829. */
  830. {
  831. DWORD dwErr;
  832. DWORD dwOp;
  833. AIINFO* pInfo;
  834. HWND hwndDlg;
  835. BOOL bNt4;
  836. TRACE("AiInit");
  837. hwndDlg = GetParent( hwndFirstPage );
  838. /* Allocate the context information block. Initialize it enough so that
  839. ** it can be destroyed properly, and associate the context with the
  840. ** window.
  841. */
  842. {
  843. pInfo = Malloc( sizeof(*pInfo) );
  844. if (!pInfo)
  845. {
  846. TRACE("Context NOT allocated");
  847. ErrorDlg( hwndDlg, SID_OP_LoadDlg, ERROR_NOT_ENOUGH_MEMORY, NULL );
  848. pArgs->pApiArgs->dwError = ERROR_NOT_ENOUGH_MEMORY;
  849. AiExitInit( hwndDlg );
  850. return NULL;
  851. }
  852. ZeroMemory( pInfo, sizeof(AIINFO) );
  853. pInfo->pArgs = pArgs;
  854. pInfo->hwndDlg = hwndDlg;
  855. pInfo->hwndFirstPage = hwndFirstPage;
  856. if (!SetProp( hwndDlg, g_contextId, pInfo ))
  857. {
  858. TRACE("Context NOT set");
  859. ErrorDlg( hwndDlg, SID_OP_LoadDlg, ERROR_UNKNOWN, NULL );
  860. pArgs->pApiArgs->dwError = ERROR_UNKNOWN;
  861. Free( pInfo );
  862. AiExitInit( hwndDlg );
  863. return NULL;
  864. }
  865. TRACE("Context set");
  866. }
  867. /* Position the dialog per caller's instructions.
  868. */
  869. PositionDlg( hwndDlg,
  870. pArgs->pApiArgs->dwFlags & RASDDFLAG_PositionDlg,
  871. pArgs->pApiArgs->xDlg, pArgs->pApiArgs->yDlg );
  872. // Do here instead of LibMain because otherwise it leaks resources into
  873. // WinLogon according to ShaunCo.
  874. //
  875. {
  876. InitCommonControls();
  877. IpAddrInit( g_hinstDll, SID_PopupTitle, SID_BadIpAddrRange );
  878. }
  879. /* Initialize these meta-flags that are not actually stored.
  880. */
  881. pInfo->fNotNt = FALSE;
  882. pInfo->fSkipMa = FALSE;
  883. pInfo->fModem = FALSE;
  884. pInfo->pArgs->fPadSelected = FALSE;
  885. {
  886. INTERNALARGS *pIArgs = (INTERNALARGS *) pArgs->pApiArgs->reserved;
  887. pInfo->dwfConfiguredProtocols =
  888. g_pGetInstalledProtocolsEx(
  889. (pIArgs) ? pIArgs->hConnection : NULL,
  890. TRUE, FALSE, TRUE);
  891. }
  892. pInfo->fIpConfigured = (pInfo->dwfConfiguredProtocols & NP_Ip);
  893. //for whistler bug 213901 .Net server 605988, remove IPX
  894. //
  895. pInfo->fIpxConfigured = FALSE;
  896. // Set up common phone number list storage.
  897. //
  898. {
  899. pInfo->pListPhoneNumbers = DtlCreateList( 0 );
  900. if (!pInfo->pListPhoneNumbers)
  901. {
  902. ErrorDlg( hwndDlg, SID_OP_LoadDlg, ERROR_NOT_ENOUGH_MEMORY, NULL );
  903. pArgs->pApiArgs->dwError = ERROR_NOT_ENOUGH_MEMORY;
  904. AiExitInit( hwndDlg );
  905. return NULL;
  906. }
  907. }
  908. // Load links for all port types.
  909. //
  910. EuChangeEntryType( pArgs, (DWORD )-1 );
  911. // Convert the PBPHONE phone list for the first link to a TAPI-disabled
  912. // PSZ stash list of phone numbers. The stash list is edited rather than
  913. // the list in the entry so user can change active links without losing
  914. // the phone number he entered.
  915. //
  916. {
  917. DTLNODE* pNode;
  918. PBLINK* pLink;
  919. ASSERT( pInfo->pListPhoneNumbers );
  920. pNode = DtlGetFirstNode( pArgs->pEntry->pdtllistLinks );
  921. ASSERT( pNode );
  922. pLink = (PBLINK* )DtlGetData( pNode );
  923. ASSERT( pLink );
  924. for (pNode = DtlGetFirstNode( pLink->pdtllistPhones );
  925. pNode;
  926. pNode = DtlGetNextNode( pNode ))
  927. {
  928. PBPHONE* pPhone;
  929. DTLNODE* pNodeP;
  930. pPhone = (PBPHONE* )DtlGetData( pNode );
  931. ASSERT( pPhone );
  932. pNodeP = CreatePszNode( pPhone->pszPhoneNumber );
  933. if (pNodeP)
  934. {
  935. DtlAddNodeLast( pInfo->pListPhoneNumbers, pNodeP );
  936. }
  937. }
  938. }
  939. // Get the bold font for the start and finish pages
  940. //
  941. GetBoldWindowFont(hwndFirstPage, TRUE, &(pInfo->hBoldFont));
  942. // Initlialize the flags for this wizard based on the
  943. // ports loaded in.
  944. //
  945. {
  946. DTLNODE* pNode;
  947. PBLINK* pLink;
  948. for (pNode = DtlGetFirstNode( pArgs->pEntry->pdtllistLinks );
  949. pNode;
  950. pNode = DtlGetNextNode( pNode ))
  951. {
  952. pLink = (PBLINK* )DtlGetData( pNode );
  953. ASSERT( pLink );
  954. if ( pLink->pbport.dwType == RASET_Vpn )
  955. {
  956. pInfo->dwFlags |= AI_F_HasTunlDevs;
  957. }
  958. // pmay: 233287
  959. // Do not count bogus devices as physical devices.
  960. //
  961. else if (! (pLink->pbport.dwFlags & PBP_F_BogusDevice))
  962. {
  963. pInfo->dwFlags |= AI_F_HasPhysDevs;
  964. }
  965. if ( pLink->pbport.dwFlags & PBP_F_PptpDevice )
  966. {
  967. pInfo->dwFlags |= AI_F_HasPptpDevs;
  968. }
  969. else if ( pLink->pbport.dwFlags & PBP_F_L2tpDevice )
  970. {
  971. pInfo->dwFlags |= AI_F_HasL2tpDevs;
  972. }
  973. //For whistler bug 345068 349087
  974. //
  975. if ( pLink->pbport.dwFlags & PBP_F_PPPoEDevice )
  976. {
  977. pInfo->dwFlags |= AI_F_HasPPPoEDevs;
  978. }
  979. }
  980. }
  981. //
  982. //Set the static route list pointer to null
  983. //
  984. pInfo->pRouteInfoListHead = NULL;
  985. return pInfo;
  986. }
  987. VOID
  988. AiTerm(
  989. IN HWND hwndPage )
  990. /* Wizard level termination. Releases the context block. 'HwndPage' is
  991. ** the handle of a property page.
  992. */
  993. {
  994. AIINFO* pInfo;
  995. TRACE("AiTerm");
  996. pInfo = AiContext( hwndPage );
  997. if (pInfo)
  998. {
  999. if (pInfo->hBoldFont)
  1000. {
  1001. DeleteObject(pInfo->hBoldFont);
  1002. }
  1003. if (pInfo->pListPhoneNumbers)
  1004. {
  1005. DtlDestroyList( pInfo->pListPhoneNumbers, DestroyPszNode );
  1006. }
  1007. if (pInfo->fSuInfoInitialized)
  1008. {
  1009. SuFree( &pInfo->suinfo );
  1010. }
  1011. Free( pInfo );
  1012. TRACE("Context freed");
  1013. }
  1014. RemoveProp( GetParent( hwndPage ), g_contextId );
  1015. }
  1016. /*----------------------------------------------------------------------------
  1017. ** AI Info Utiltity functions aroudn route info structure.
  1018. **----------------------------------------------------------------------------
  1019. */
  1020. DWORD AIInfoSRouteGetNode(SROUTEINFOLIST ** pNode )
  1021. {
  1022. DWORD dwRetCode = NO_ERROR;
  1023. TRACE("AIInfoSRouteGetNode");
  1024. *pNode = Malloc( sizeof(SROUTEINFOLIST) );
  1025. if ( !*pNode )
  1026. {
  1027. dwRetCode = GetLastError();
  1028. goto done;
  1029. }
  1030. ZeroMemory(*pNode, sizeof(SROUTEINFOLIST) );
  1031. done:
  1032. return dwRetCode;
  1033. }
  1034. DWORD AIInfoSRouteSetDestIP(SROUTEINFOLIST * pNode, LPTSTR lpszDestIP )
  1035. {
  1036. DWORD dwRetCode = NO_ERROR;
  1037. TRACE("AIInfoSRouteSetDestIP");
  1038. if ( !lpszDestIP || !pNode )
  1039. {
  1040. dwRetCode = ERROR_INVALID_PARAMETER;
  1041. goto done;
  1042. }
  1043. if ( pNode->RouteInfo.pszDestIP )
  1044. Free(pNode->RouteInfo.pszDestIP );
  1045. pNode->RouteInfo.pszDestIP = Malloc( ( lstrlen(lpszDestIP) * sizeof(TCHAR) )+ sizeof(TCHAR) );
  1046. if ( !pNode->RouteInfo.pszDestIP )
  1047. {
  1048. dwRetCode = GetLastError();
  1049. goto done;
  1050. }
  1051. lstrcpy ( pNode->RouteInfo.pszDestIP, lpszDestIP );
  1052. done:
  1053. return dwRetCode;
  1054. }
  1055. DWORD AIInfoSRouteSetNetworkMask (SROUTEINFOLIST * pNode, LPTSTR lpszNetMask )
  1056. {
  1057. DWORD dwRetCode = NO_ERROR;
  1058. TRACE("AIInfoSRouteSetNetworkMask");
  1059. if ( !lpszNetMask || !pNode )
  1060. {
  1061. dwRetCode = ERROR_INVALID_PARAMETER;
  1062. goto done;
  1063. }
  1064. if ( pNode->RouteInfo.pszNetworkMask )
  1065. Free(pNode->RouteInfo.pszNetworkMask );
  1066. pNode->RouteInfo.pszNetworkMask = Malloc( ( lstrlen(lpszNetMask) * sizeof(TCHAR) ) + sizeof(TCHAR) );
  1067. if ( !pNode->RouteInfo.pszNetworkMask )
  1068. {
  1069. dwRetCode = GetLastError();
  1070. goto done;
  1071. }
  1072. lstrcpy ( pNode->RouteInfo.pszNetworkMask, lpszNetMask );
  1073. done:
  1074. return dwRetCode;
  1075. }
  1076. DWORD AIInfoSRouteSetMetric (SROUTEINFOLIST * pNode, LPTSTR lpszMetric )
  1077. {
  1078. DWORD dwRetCode = NO_ERROR;
  1079. TRACE("AIInfoSRouteSetMetric");
  1080. if ( !lpszMetric || !pNode )
  1081. {
  1082. dwRetCode = ERROR_INVALID_PARAMETER;
  1083. goto done;
  1084. }
  1085. if ( pNode->RouteInfo.pszMetric )
  1086. Free(pNode->RouteInfo.pszMetric );
  1087. pNode->RouteInfo.pszMetric = Malloc( ( lstrlen(lpszMetric) * sizeof(TCHAR)) + sizeof(TCHAR) );
  1088. if ( !pNode->RouteInfo.pszMetric )
  1089. {
  1090. dwRetCode = GetLastError();
  1091. goto done;
  1092. }
  1093. lstrcpy ( pNode->RouteInfo.pszMetric, lpszMetric );
  1094. done:
  1095. return dwRetCode;
  1096. }
  1097. DWORD AIInfoAddNewSRouteNode( SROUTEINFOLIST ** ppList, SROUTEINFOLIST * pNewNode )
  1098. {
  1099. DWORD dwRetCode = NO_ERROR;
  1100. //
  1101. //Add Node at the head of the list
  1102. //
  1103. if ( NULL == *ppList )
  1104. {
  1105. *ppList = pNewNode;
  1106. }
  1107. else
  1108. {
  1109. pNewNode->pNext = *ppList;
  1110. *ppList = pNewNode;
  1111. }
  1112. return dwRetCode;
  1113. }
  1114. DWORD AIInfoRemoveSRouteNode ( AIINFO * pInfo, SROUTEINFOLIST * pNode )
  1115. {
  1116. DWORD dwRetCode = NO_ERROR;
  1117. SROUTEINFOLIST * pCurNode = pInfo->pRouteInfoListHead;
  1118. SROUTEINFOLIST * pPrevNode = NULL;
  1119. //
  1120. //Iterate the list and remove node.
  1121. //
  1122. while ( pCurNode )
  1123. {
  1124. if ( pCurNode == pNode )
  1125. {
  1126. //
  1127. //This is the node to delete
  1128. //
  1129. if ( pPrevNode == NULL)
  1130. {
  1131. //
  1132. //This is the head node being deleted
  1133. //
  1134. pInfo->pRouteInfoListHead = pCurNode->pNext;
  1135. }
  1136. else
  1137. {
  1138. pPrevNode->pNext = pCurNode->pNext;
  1139. }
  1140. }
  1141. pPrevNode = pCurNode;
  1142. pCurNode = pCurNode->pNext;
  1143. }
  1144. Free( pNode->RouteInfo.pszDestIP );
  1145. Free( pNode->RouteInfo.pszNetworkMask );
  1146. Free( pNode->RouteInfo.pszMetric );
  1147. Free(pNode);
  1148. return dwRetCode;
  1149. }
  1150. DWORD AIInfoSRouteCreateEntry(AIINFO * pInfo, LPTSTR pszDest, LPTSTR pszNetMask, LPTSTR pszMetric )
  1151. {
  1152. DWORD dwRetCode = NO_ERROR;
  1153. SROUTEINFOLIST * pNode = NULL;
  1154. dwRetCode = AIInfoSRouteGetNode (&pNode );
  1155. if ( pNode )
  1156. {
  1157. AIInfoSRouteSetDestIP(pNode, pszDest );
  1158. AIInfoSRouteSetNetworkMask (pNode, pszNetMask );
  1159. AIInfoSRouteSetMetric (pNode, pszMetric );
  1160. AIInfoAddNewSRouteNode( & ( pInfo->pRouteInfoListHead ), pNode );
  1161. }
  1162. return dwRetCode;
  1163. }
  1164. SROUTEINFOLIST * AiInfoSRouteGetFirstNode(AIINFO * pInfo)
  1165. {
  1166. return ( pInfo->pRouteInfoListHead);
  1167. }
  1168. SROUTEINFOLIST * AiInfoSRouteGetNextNode(SROUTEINFOLIST * pNode)
  1169. {
  1170. return pNode->pNext;
  1171. }
  1172. BOOL
  1173. AIInfoSRouteIsRouteinList
  1174. (
  1175. AIINFO * pInfo,
  1176. LPCTSTR pszDest,
  1177. LPCTSTR pszMask,
  1178. LPCTSTR pszMetric
  1179. )
  1180. {
  1181. BOOL fRet = FALSE;
  1182. SROUTEINFOLIST * pNode = pInfo->pRouteInfoListHead;
  1183. while ( pNode )
  1184. {
  1185. if ( !lstrcmp(pNode->RouteInfo.pszDestIP, pszDest ) &&
  1186. !lstrcmp(pNode->RouteInfo.pszNetworkMask, pszMask ) &&
  1187. !lstrcmp(pNode->RouteInfo.pszMetric, pszMetric)
  1188. )
  1189. {
  1190. fRet = TRUE;
  1191. break;
  1192. }
  1193. pNode = pNode->pNext;
  1194. }
  1195. return fRet;
  1196. }
  1197. DWORD
  1198. inet_addrw(
  1199. LPCWSTR szAddressW
  1200. ) {
  1201. CHAR szAddressA[16];
  1202. wcstombs(szAddressA, szAddressW, 16);
  1203. return inet_addr(szAddressA);
  1204. }
  1205. // Add Broadband service name page for router wizard
  1206. // For whistler 345068 349087 gangz
  1207. // This broadband serice page is shared by AiWizard(ifw.c) and AeWizard(in entryw.c)
  1208. //
  1209. /*----------------------------------------------------------------------------
  1210. ** Broadband service dialog procedure
  1211. ** Listed alphabetically following dialog proc
  1212. **----------------------------------------------------------------------------
  1213. */
  1214. INT_PTR CALLBACK
  1215. RbDlgProc(
  1216. IN HWND hwnd,
  1217. IN UINT unMsg,
  1218. IN WPARAM wparam,
  1219. IN LPARAM lparam )
  1220. // DialogProc callback for the broadband service page of the wizard.
  1221. // Parameters and return value are as described for
  1222. // standard windows 'DialogProc's.
  1223. //
  1224. {
  1225. switch (unMsg)
  1226. {
  1227. case WM_INITDIALOG:
  1228. return RbInit( hwnd );
  1229. case WM_NOTIFY:
  1230. {
  1231. switch (((NMHDR* )lparam)->code)
  1232. {
  1233. case PSN_SETACTIVE:
  1234. {
  1235. AIINFO* pInfo;
  1236. BOOL fDisplay;
  1237. TRACE("RbSetActive");
  1238. pInfo = AiContext( hwnd );
  1239. ASSERT(pInfo);
  1240. if ( NULL == pInfo )
  1241. {
  1242. break;
  1243. }
  1244. fDisplay = RbSetActive( pInfo );
  1245. SetWindowLong( hwnd, DWLP_MSGRESULT, (fDisplay) ? 0 : -1 );
  1246. return TRUE;
  1247. }
  1248. case PSN_KILLACTIVE:
  1249. {
  1250. AIINFO* pInfo;
  1251. BOOL fInvalid;
  1252. TRACE("RbKillActive");
  1253. pInfo = AiContext( hwnd );
  1254. ASSERT(pInfo);
  1255. if ( NULL == pInfo )
  1256. {
  1257. break;
  1258. }
  1259. fInvalid = RbKillActive( pInfo );
  1260. SetWindowLong( hwnd, DWLP_MSGRESULT, fInvalid );
  1261. return TRUE;
  1262. }
  1263. }
  1264. break;
  1265. }
  1266. }
  1267. return FALSE;
  1268. }
  1269. BOOL
  1270. RbInit(
  1271. IN HWND hwndPage )
  1272. // Called on WM_INITDIALOG. 'hwndPage' is the handle of the property
  1273. // page.
  1274. //
  1275. // Return false if focus was set, true otherwise.
  1276. //
  1277. {
  1278. AIINFO* pInfo;
  1279. TRACE("RbInit");
  1280. pInfo = AiContext( hwndPage );
  1281. if (!pInfo)
  1282. {
  1283. return TRUE;
  1284. }
  1285. // Initialize page-specific context information.
  1286. //
  1287. pInfo->hwndRb = hwndPage;
  1288. pInfo->hwndEbNumber =
  1289. GetDlgItem( hwndPage, CID_BS_EB_ServiceName );
  1290. ASSERT(pInfo->hwndEbNumber);
  1291. Edit_LimitText( pInfo->hwndEbNumber, RAS_MaxPhoneNumber );
  1292. SetWindowText( pInfo->hwndEbNumber,
  1293. FirstPszFromList( pInfo->pListPhoneNumbers ) );
  1294. return FALSE;
  1295. }
  1296. //For whistler bug 349807
  1297. //The RbXXX, VdXXX, RpXXX three sets of functions share the same pInfo->hwndEbNumber
  1298. //to store phone number/Vpn destionation/PPPPoE service name
  1299. //
  1300. BOOL
  1301. RbKillActive(
  1302. IN AIINFO* pInfo )
  1303. // Called when PSN_KILLACTIVE is received. 'PInfo' is the wizard context.
  1304. //
  1305. // Returns true if the page is invalid, false is it can be dismissed.
  1306. //
  1307. {
  1308. // If we're focused on an nt4 box, then this page is
  1309. // invalid (pptp was the only type)
  1310. if ( pInfo->pArgs->fNt4Router )
  1311. {
  1312. return FALSE;
  1313. }
  1314. // If we have no PPPoE devices, then this page is invalid
  1315. else if ( ! (pInfo->dwFlags & AI_F_HasPPPoEDevs) )
  1316. {
  1317. return FALSE;
  1318. }
  1319. // If the connection type is not broadband, skip this page since the
  1320. // destination will be gotten from the phone number/VPN page.
  1321. if ( pInfo->pArgs->pEntry->dwType != RASET_Broadband )
  1322. {
  1323. return FALSE;
  1324. }
  1325. RpPhoneNumberToStash(pInfo);
  1326. return FALSE;
  1327. }
  1328. BOOL
  1329. RbSetActive(
  1330. IN AIINFO* pInfo )
  1331. // Called when PSN_SETACTIVE is received. 'PInfo' is the wizard context.
  1332. //
  1333. // Returns true to display the page, false to skip it.
  1334. //
  1335. {
  1336. BOOL fDisplayPage;
  1337. PBENTRY* pEntry;
  1338. TRACE("RbSetActive");
  1339. ASSERT(pInfo);
  1340. pEntry = pInfo->pArgs->pEntry;
  1341. if ( pInfo->pArgs->fNt4Router )
  1342. {
  1343. return FALSE;
  1344. }
  1345. // If we have no PPPoE devices, then this page is invalid
  1346. //
  1347. if ( ! (pInfo->dwFlags & AI_F_HasPPPoEDevs) )
  1348. {
  1349. return FALSE;
  1350. }
  1351. if (RASET_Broadband != pEntry->dwType)
  1352. {
  1353. return FALSE;
  1354. }
  1355. else
  1356. {
  1357. PropSheet_SetWizButtons( pInfo->hwndDlg, PSWIZB_BACK | PSWIZB_NEXT );
  1358. fDisplayPage = TRUE;
  1359. }
  1360. pInfo->hwndEbNumber =
  1361. GetDlgItem( pInfo->hwndRb, CID_BS_EB_ServiceName );
  1362. ASSERT(pInfo->hwndEbNumber);
  1363. Edit_LimitText( pInfo->hwndEbNumber, RAS_MaxPhoneNumber );
  1364. SetWindowText( pInfo->hwndEbNumber,
  1365. FirstPszFromList( pInfo->pListPhoneNumbers ) );
  1366. return fDisplayPage;
  1367. }
  1368. /*----------------------------------------------------------------------------
  1369. ** Connection type property page
  1370. ** Listed alphabetically following dialog proc
  1371. **----------------------------------------------------------------------------
  1372. */
  1373. INT_PTR CALLBACK
  1374. CtDlgProc(
  1375. IN HWND hwnd,
  1376. IN UINT unMsg,
  1377. IN WPARAM wparam,
  1378. IN LPARAM lparam )
  1379. /* DialogProc callback for the vpn type page of the wizard.
  1380. ** Parameters and return value are as described for standard windows
  1381. ** 'DialogProc's.
  1382. */
  1383. {
  1384. switch (unMsg)
  1385. {
  1386. case WM_INITDIALOG:
  1387. return CtInit( hwnd );
  1388. case WM_NOTIFY:
  1389. {
  1390. switch (((NMHDR* )lparam)->code)
  1391. {
  1392. case PSN_SETACTIVE:
  1393. {
  1394. AIINFO* pInfo;
  1395. BOOL fDisplay;
  1396. TRACE("CtSETACTIVE");
  1397. pInfo = AiContext( hwnd );
  1398. ASSERT(pInfo);
  1399. if (pInfo == NULL)
  1400. {
  1401. break;
  1402. }
  1403. fDisplay = CtSetActive( pInfo );
  1404. SetWindowLong( hwnd, DWLP_MSGRESULT, (fDisplay) ? 0 : -1 );
  1405. return TRUE;
  1406. }
  1407. case PSN_KILLACTIVE:
  1408. {
  1409. AIINFO* pInfo;
  1410. BOOL fInvalid;
  1411. TRACE("CtKILLACTIVE");
  1412. pInfo = AiContext( hwnd );
  1413. ASSERT(pInfo);
  1414. if (pInfo == NULL)
  1415. {
  1416. break;
  1417. }
  1418. fInvalid = CtKillActive( pInfo );
  1419. SetWindowLong( hwnd, DWLP_MSGRESULT, fInvalid );
  1420. return TRUE;
  1421. }
  1422. }
  1423. break;
  1424. }
  1425. }
  1426. return FALSE;
  1427. }
  1428. BOOL
  1429. CtInit(
  1430. IN HWND hwndPage )
  1431. /* Called on WM_INITDIALOG. 'hwndPage' is the handle of the property
  1432. ** page.
  1433. **
  1434. ** Return false if focus was set, true otherwise.
  1435. */
  1436. {
  1437. AIINFO * pInfo;
  1438. DWORD dwPhysicDeviceOtherThanLPT1 = 0;
  1439. // Get the context
  1440. pInfo = AiContext( hwndPage );
  1441. ASSERT ( pInfo );
  1442. if (pInfo == NULL)
  1443. {
  1444. return FALSE;
  1445. }
  1446. // Initialize the checks
  1447. pInfo->hwndRbTypePhys = GetDlgItem( hwndPage, CID_CT_RB_Physical );
  1448. ASSERT(pInfo->hwndRbTypePhys);
  1449. pInfo->hwndRbTypeTunl = GetDlgItem( hwndPage, CID_CT_RB_Virtual );
  1450. ASSERT(pInfo->hwndRbTypeTunl);
  1451. //for whistler 345068 349087 gangz
  1452. //
  1453. pInfo->hwndRbBroadband = GetDlgItem( hwndPage, CID_CT_RB_Broadband );
  1454. ASSERT(pInfo->hwndRbBroadband);
  1455. // pmay: 233287
  1456. //for whistler 345068 349087 gangz
  1457. // Likewise, if there are only one devices available among
  1458. // phys devices, tunel devices and broadband devices , then force the
  1459. // user to configure dd interface with that device.
  1460. //
  1461. //If no valid device availabe, stop the wizard
  1462. //
  1463. pInfo->dwCtDeviceNum = 0;
  1464. // Get the number of Physic Devices other that LPT1 because DoD interfaces
  1465. // just do not use LPT1
  1466. //
  1467. if (pInfo->dwFlags &AI_F_HasPhysDevs )
  1468. {
  1469. dwPhysicDeviceOtherThanLPT1 = GetPhysicDeviceOtherThanLPT1( pInfo );
  1470. if( 0 < dwPhysicDeviceOtherThanLPT1 )
  1471. {
  1472. pInfo->dwCtDeviceNum++;
  1473. }
  1474. }
  1475. if (pInfo->dwFlags & AI_F_HasTunlDevs )
  1476. {
  1477. pInfo->dwCtDeviceNum++;
  1478. }
  1479. if (pInfo->dwFlags & AI_F_HasPPPoEDevs)
  1480. {
  1481. pInfo->dwCtDeviceNum++;
  1482. }
  1483. if ( 0 == pInfo->dwCtDeviceNum )
  1484. {
  1485. ErrorDlg( pInfo->hwndDlg, SID_NoDevices, ERROR_UNKNOWN, NULL);
  1486. AiExit ( pInfo, ERROR_DEVICE_NOT_AVAILABLE );
  1487. return TRUE;
  1488. }
  1489. if ( 1 == pInfo->dwCtDeviceNum )
  1490. {
  1491. if ( ( pInfo->dwFlags & AI_F_HasPhysDevs ) &&
  1492. ( 0 < dwPhysicDeviceOtherThanLPT1 )
  1493. )
  1494. {
  1495. EuChangeEntryType(
  1496. pInfo->pArgs,
  1497. RASET_P_NonVpnTypes);
  1498. }
  1499. else if (pInfo->dwFlags & AI_F_HasTunlDevs)
  1500. {
  1501. EuChangeEntryType(
  1502. pInfo->pArgs,
  1503. RASET_Vpn);
  1504. }
  1505. else if (pInfo->dwFlags & AI_F_HasPPPoEDevs)
  1506. {
  1507. EuChangeEntryType(
  1508. pInfo->pArgs,
  1509. RASET_Broadband);
  1510. }
  1511. else
  1512. {
  1513. ErrorDlg( pInfo->hwndDlg, SID_NoDevices, ERROR_UNKNOWN, NULL);
  1514. AiExit ( pInfo, ERROR_DEVICE_NOT_AVAILABLE );
  1515. return TRUE;
  1516. }
  1517. }
  1518. //Set radio buttons
  1519. //
  1520. if( pInfo->hwndRbTypePhys )
  1521. {
  1522. Button_SetCheck(pInfo->hwndRbTypePhys, FALSE);
  1523. }
  1524. if( pInfo->hwndRbTypeTunl )
  1525. {
  1526. Button_SetCheck(pInfo->hwndRbTypeTunl, FALSE);
  1527. }
  1528. if( pInfo->hwndRbBroadband )
  1529. {
  1530. Button_SetCheck(pInfo->hwndRbBroadband, FALSE);
  1531. }
  1532. //Enable/Disable buttons
  1533. //
  1534. if( pInfo->hwndRbTypePhys )
  1535. {
  1536. if ( !(pInfo->dwFlags & AI_F_HasPhysDevs) ||
  1537. 0 == dwPhysicDeviceOtherThanLPT1 )
  1538. {
  1539. EnableWindow(pInfo->hwndRbTypePhys, FALSE);
  1540. }
  1541. else
  1542. {
  1543. EnableWindow(pInfo->hwndRbTypePhys, TRUE );
  1544. }
  1545. }
  1546. if( pInfo->hwndRbTypeTunl )
  1547. {
  1548. if ( !(pInfo->dwFlags & AI_F_HasTunlDevs) )
  1549. {
  1550. EnableWindow(pInfo->hwndRbTypeTunl, FALSE);
  1551. }
  1552. else
  1553. {
  1554. EnableWindow(pInfo->hwndRbTypeTunl, TRUE );
  1555. }
  1556. }
  1557. if( pInfo->hwndRbBroadband )
  1558. {
  1559. if ( !(pInfo->dwFlags & AI_F_HasPPPoEDevs) )
  1560. {
  1561. EnableWindow(pInfo->hwndRbBroadband, FALSE);
  1562. }
  1563. else
  1564. {
  1565. EnableWindow(pInfo->hwndRbBroadband, TRUE );
  1566. }
  1567. }
  1568. if ( pInfo->hwndRbTypePhys &&
  1569. IsWindowEnabled( pInfo->hwndRbTypePhys )
  1570. )
  1571. {
  1572. Button_SetCheck(pInfo->hwndRbTypePhys, TRUE);
  1573. }
  1574. else if( pInfo->hwndRbTypeTunl &&
  1575. IsWindowEnabled( pInfo->hwndRbTypeTunl )
  1576. )
  1577. {
  1578. Button_SetCheck(pInfo->hwndRbTypeTunl, TRUE);
  1579. }
  1580. else
  1581. {
  1582. if( pInfo->hwndRbBroadband )
  1583. {
  1584. Button_SetCheck(pInfo->hwndRbBroadband, TRUE);
  1585. }
  1586. }
  1587. return FALSE;
  1588. }
  1589. BOOL
  1590. CtKillActive(
  1591. IN AIINFO* pInfo )
  1592. /* Called when PSN_KILLACTIVE is received. 'PInfo' is the wizard context.
  1593. **
  1594. ** Returns true if the page is invalid, false is it can be dismissed.
  1595. */
  1596. {
  1597. BOOL bPhys, bTunnel;
  1598. // Change the entry type based on the type
  1599. // selected from this page
  1600. //For whistler 345068 349087 gangz
  1601. //
  1602. bPhys = Button_GetCheck( pInfo->hwndRbTypePhys );
  1603. bTunnel = Button_GetCheck( pInfo->hwndRbTypeTunl );
  1604. if(bPhys)
  1605. {
  1606. EuChangeEntryType(
  1607. pInfo->pArgs,
  1608. RASET_P_NonVpnTypes);
  1609. }
  1610. else if(bTunnel)
  1611. {
  1612. EuChangeEntryType(
  1613. pInfo->pArgs,
  1614. RASET_Vpn);
  1615. }
  1616. else
  1617. {
  1618. EuChangeEntryType(
  1619. pInfo->pArgs,
  1620. RASET_Broadband);
  1621. }
  1622. return FALSE;
  1623. }
  1624. DWORD GetPhysicDeviceOtherThanLPT1(
  1625. IN AIINFO * pInfo )
  1626. {
  1627. DTLNODE* pNode = NULL;
  1628. PBLINK* pLink = NULL;
  1629. DWORD dwItem = 0;
  1630. do
  1631. {
  1632. if( NULL == pInfo ||
  1633. NULL == pInfo->pArgs ||
  1634. NULL == pInfo->pArgs->pEntry ||
  1635. NULL == pInfo->pArgs->pEntry->pdtllistLinks
  1636. )
  1637. {
  1638. break;
  1639. }
  1640. for (pNode = DtlGetFirstNode( pInfo->pArgs->pEntry->pdtllistLinks );
  1641. pNode;
  1642. pNode = DtlGetNextNode( pNode ))
  1643. {
  1644. PBDEVICETYPE pbType ;
  1645. pLink = (PBLINK* )DtlGetData( pNode );
  1646. ASSERT(pLink);
  1647. // For whistler bug 448251
  1648. // for whistler DCR 524304 gangz
  1649. // Filter out LPT1, because the DoD only happens in a NAT or NAT/VPN
  1650. // which won't use this LPT1 port
  1651. pbType = pLink->pbport.pbdevicetype;
  1652. if ( PBDT_Modem == pbType ||
  1653. PBDT_Pad == pbType ||
  1654. PBDT_Switch == pbType ||
  1655. PBDT_Isdn == pbType ||
  1656. PBDT_Atm == pbType ||
  1657. PBDT_FrameRelay == pbType
  1658. )
  1659. {
  1660. dwItem ++;
  1661. }
  1662. }// End of for loop
  1663. }
  1664. while(FALSE);
  1665. return dwItem;
  1666. }
  1667. BOOL
  1668. CtSetActive(
  1669. IN AIINFO* pInfo )
  1670. /* Called when PSN_SETACTIVE is received. 'PInfo' is the wizard context.
  1671. **
  1672. ** Returns true to display the page, false to skip it.
  1673. */
  1674. {
  1675. // If we're focused on an nt4 box, then this page is
  1676. // invalid (type of connection is inferred from the
  1677. // device that gets selected.)
  1678. if ( pInfo->pArgs->fNt4Router )
  1679. {
  1680. return FALSE;
  1681. }
  1682. // Only allow this page to display if there are at least two of
  1683. // physical, tunnel and broadband devices configured. Otherwise,
  1684. // it makes no sense to allow the user to choose which
  1685. // type he/she wants.
  1686. if ( 2 <= pInfo->dwCtDeviceNum )
  1687. {
  1688. PropSheet_SetWizButtons( pInfo->hwndDlg, PSWIZB_BACK | PSWIZB_NEXT );
  1689. return TRUE;
  1690. }
  1691. return FALSE;
  1692. }
  1693. /*----------------------------------------------------------------------------
  1694. ** Dial-In Credentials property page
  1695. ** Listed alphabetically following dialog proc
  1696. **----------------------------------------------------------------------------
  1697. */
  1698. INT_PTR CALLBACK
  1699. DiDlgProc(
  1700. IN HWND hwnd,
  1701. IN UINT unMsg,
  1702. IN WPARAM wparam,
  1703. IN LPARAM lparam )
  1704. /* DialogProc callback for the Dial-in Credentials page of the wizard.
  1705. ** Parameters and return values are as described for standard windows
  1706. ** 'DialogProc's.
  1707. */
  1708. {
  1709. switch (unMsg)
  1710. {
  1711. case WM_INITDIALOG:
  1712. {
  1713. return
  1714. DiInit( hwnd );
  1715. }
  1716. case WM_NOTIFY:
  1717. {
  1718. switch (((NMHDR* )lparam)->code)
  1719. {
  1720. case PSN_SETACTIVE:
  1721. {
  1722. AIINFO* pInfo;
  1723. BOOL fDisplay;
  1724. TRACE("DiSETACTIVE");
  1725. pInfo = AiContext( hwnd );
  1726. ASSERT(pInfo);
  1727. if (pInfo == NULL)
  1728. {
  1729. break;
  1730. }
  1731. fDisplay = DiSetActive( pInfo );
  1732. SetWindowLong( hwnd, DWLP_MSGRESULT, (fDisplay) ? 0 : -1 );
  1733. return TRUE;
  1734. }
  1735. case PSN_KILLACTIVE:
  1736. {
  1737. AIINFO* pInfo;
  1738. BOOL fInvalid;
  1739. TRACE("DiKILLACTIVE");
  1740. pInfo = AiContext( hwnd );
  1741. ASSERT(pInfo);
  1742. if (pInfo == NULL)
  1743. {
  1744. break;
  1745. }
  1746. fInvalid = DiKillActive( pInfo );
  1747. SetWindowLong( hwnd, DWLP_MSGRESULT, fInvalid );
  1748. return TRUE;
  1749. }
  1750. case PSN_WIZNEXT:
  1751. {
  1752. AIINFO* pInfo;
  1753. BOOL fInvalid;
  1754. TRACE("DoNEXT");
  1755. pInfo = AiContext( hwnd );
  1756. ASSERT(pInfo);
  1757. if (pInfo == NULL)
  1758. {
  1759. break;
  1760. }
  1761. fInvalid = DiNext( pInfo );
  1762. SetWindowLong( hwnd, DWLP_MSGRESULT, (fInvalid) ? -1 : 0 );
  1763. return TRUE;
  1764. }
  1765. }
  1766. break;
  1767. }
  1768. }
  1769. return FALSE;
  1770. }
  1771. BOOL
  1772. DiInit(
  1773. IN HWND hwndPage )
  1774. /* Called on WM_INITDIALOG. 'hwndPage' is the handle of the property
  1775. ** page. 'PArgs' is the arguments from the PropertySheet caller.
  1776. **
  1777. ** Return false if focus was set, true otherwise.
  1778. */
  1779. {
  1780. AIINFO* pInfo;
  1781. TRACE("DiInit");
  1782. pInfo = AiContext( hwndPage );
  1783. if (!pInfo)
  1784. return TRUE;
  1785. /* Initialize page-specific context information.
  1786. */
  1787. pInfo->hwndDi = hwndPage;
  1788. pInfo->hwndDiEbUserName = GetDlgItem( hwndPage, CID_DI_EB_UserName );
  1789. Edit_LimitText( pInfo->hwndDiEbUserName, UNLEN );
  1790. pInfo->hwndDiEbPassword = GetDlgItem( hwndPage, CID_DI_EB_Password );
  1791. Edit_LimitText( pInfo->hwndDiEbPassword, PWLEN );
  1792. pInfo->hwndDiEbConfirm = GetDlgItem( hwndPage, CID_DI_EB_Confirm );
  1793. Edit_LimitText( pInfo->hwndDiEbConfirm, PWLEN );
  1794. // pmay: 222622: Since we only configure local users, we removed
  1795. // the domain field from the dial in credentials page.
  1796. return FALSE;
  1797. }
  1798. BOOL
  1799. DiKillActive(
  1800. IN AIINFO* pInfo )
  1801. /* Called when PSN_KILLACTIVE is received. 'PInfo' is the wizard context.
  1802. **
  1803. ** Returns true if the page is invalid, false is it can be dismissed.
  1804. */
  1805. {
  1806. return FALSE;
  1807. }
  1808. BOOL
  1809. DiNext(
  1810. IN AIINFO* pInfo )
  1811. /* Called when PSN_WIZNEXT is received. 'PInfo' is the wizard context.
  1812. **
  1813. ** Returns true if the page is invalid, false is it can be dismissed.
  1814. */
  1815. {
  1816. TCHAR* psz;
  1817. /* Whistler bug 254385 encode password when not being used
  1818. */
  1819. psz = GetText(pInfo->hwndDiEbPassword);
  1820. EncodePassword(psz);
  1821. if (psz)
  1822. {
  1823. TCHAR* psz2;
  1824. psz2 = GetText(pInfo->hwndDiEbConfirm);
  1825. if(NULL != psz2)
  1826. {
  1827. /* Whistler bug 254385 encode password when not being used
  1828. */
  1829. DecodePassword(psz);
  1830. if (lstrcmp(psz, psz2))
  1831. {
  1832. ZeroMemory(psz, (lstrlen(psz) + 1) * sizeof(TCHAR));
  1833. ZeroMemory(psz2, (lstrlen(psz2) + 1) * sizeof(TCHAR));
  1834. Free(psz);
  1835. Free(psz2);
  1836. MsgDlg(pInfo->hwndDlg, SID_PasswordMismatch, NULL);
  1837. SetFocus(pInfo->hwndDiEbPassword);
  1838. return TRUE;
  1839. }
  1840. EncodePassword(psz);
  1841. ZeroMemory(psz2, (lstrlen(psz2) + 1) * sizeof(TCHAR));
  1842. Free(psz2);
  1843. }
  1844. /* Whistler bug 254385 encode password when not being used
  1845. ** Whistler bug 275526 NetVBL BVT Break: Routing BVT broken
  1846. */
  1847. if (pInfo->pArgs->pszRouterDialInPassword)
  1848. {
  1849. ZeroMemory(
  1850. pInfo->pArgs->pszRouterDialInPassword,
  1851. (lstrlen(pInfo->pArgs->pszRouterDialInPassword) + 1) *
  1852. sizeof(TCHAR));
  1853. }
  1854. Free0(pInfo->pArgs->pszRouterDialInPassword);
  1855. pInfo->pArgs->pszRouterDialInPassword = psz;
  1856. }
  1857. return FALSE;
  1858. }
  1859. BOOL
  1860. DiSetActive(
  1861. IN AIINFO* pInfo )
  1862. /* Called when PSN_SETACTIVE is received. 'PInfo' is the wizard context.
  1863. **
  1864. ** Returns true to display the page, false to skip it.
  1865. */
  1866. {
  1867. /* The dialog is only displayed if the user is adding a dial-in account.
  1868. */
  1869. if (!pInfo->pArgs->fAddUser)
  1870. return FALSE;
  1871. /* Display the interface name in the disabled edit-box
  1872. */
  1873. SetWindowText(
  1874. pInfo->hwndDiEbUserName, pInfo->pArgs->pEntry->pszEntryName );
  1875. PropSheet_SetWizButtons( pInfo->hwndDlg, PSWIZB_BACK | PSWIZB_NEXT );
  1876. return TRUE;
  1877. }
  1878. /*----------------------------------------------------------------------------
  1879. ** Dial-Out Credentials property page
  1880. ** Listed alphabetically following dialog proc
  1881. **----------------------------------------------------------------------------
  1882. */
  1883. INT_PTR CALLBACK
  1884. DoDlgProc(
  1885. IN HWND hwnd,
  1886. IN UINT unMsg,
  1887. IN WPARAM wparam,
  1888. IN LPARAM lparam )
  1889. /* DialogProc callback for the Dial-Out Credentials page of the wizard.
  1890. ** Parameters and return values are as described for standard windows
  1891. ** 'DialogProc's.
  1892. */
  1893. {
  1894. switch (unMsg)
  1895. {
  1896. case WM_INITDIALOG:
  1897. {
  1898. return
  1899. DoInit( hwnd );
  1900. }
  1901. case WM_NOTIFY:
  1902. {
  1903. switch (((NMHDR* )lparam)->code)
  1904. {
  1905. case PSN_SETACTIVE:
  1906. {
  1907. AIINFO* pInfo;
  1908. BOOL fDisplay;
  1909. TRACE("DoSETACTIVE");
  1910. pInfo = AiContext( hwnd );
  1911. ASSERT(pInfo);
  1912. if (pInfo == NULL)
  1913. {
  1914. break;
  1915. }
  1916. fDisplay = DoSetActive( pInfo );
  1917. SetWindowLong( hwnd, DWLP_MSGRESULT, (fDisplay) ? 0 : -1 );
  1918. return TRUE;
  1919. }
  1920. case PSN_KILLACTIVE:
  1921. {
  1922. AIINFO* pInfo;
  1923. BOOL fInvalid;
  1924. TRACE("DoKILLACTIVE");
  1925. pInfo = AiContext( hwnd );
  1926. ASSERT(pInfo);
  1927. if (pInfo == NULL)
  1928. {
  1929. break;
  1930. }
  1931. fInvalid = DoKillActive( pInfo );
  1932. SetWindowLong( hwnd, DWLP_MSGRESULT, fInvalid );
  1933. return TRUE;
  1934. }
  1935. case PSN_WIZNEXT:
  1936. {
  1937. AIINFO* pInfo;
  1938. BOOL fInvalid;
  1939. TRACE("DoNEXT");
  1940. pInfo = AiContext( hwnd );
  1941. ASSERT(pInfo);
  1942. if (pInfo == NULL)
  1943. {
  1944. break;
  1945. }
  1946. fInvalid = DoNext( pInfo );
  1947. SetWindowLong( hwnd, DWLP_MSGRESULT, (fInvalid) ? -1 : 0 );
  1948. return TRUE;
  1949. }
  1950. }
  1951. break;
  1952. }
  1953. // For whistler DCR bug 524304 gangz
  1954. case WM_COMMAND:
  1955. {
  1956. AIINFO* pInfo = AiContext( hwnd );
  1957. ASSERT(pInfo);
  1958. if (pInfo == NULL)
  1959. {
  1960. break;
  1961. }
  1962. return DoCommand(
  1963. pInfo, HIWORD( wparam ), LOWORD( wparam ), (HWND )lparam );
  1964. }
  1965. }
  1966. return FALSE;
  1967. }
  1968. BOOL
  1969. DoCommand(
  1970. IN AIINFO* pInfo,
  1971. IN WORD wNotification,
  1972. IN WORD wId,
  1973. IN HWND hwndCtrl )
  1974. /* Called on WM_COMMAND. 'pInfo' is the dialog context. 'WNotification'
  1975. ** is the notification code of the command. 'wId' is the control/menu
  1976. ** identifier of the command. 'HwndCtrl' is the control window handle of
  1977. ** the command.
  1978. **
  1979. ** Returns true if processed message, false otherwise.
  1980. */
  1981. {
  1982. //TRACE3("DoCommand(n=%d,i=%d,c=$%x)",
  1983. // (DWORD)wNotification,(DWORD)wId,(ULONG_PTR )hwndCtrl);
  1984. TCHAR* psz = NULL;
  1985. switch( wId )
  1986. {
  1987. case CID_DO_EB_UserName:
  1988. {
  1989. if( EN_CHANGE == wNotification )
  1990. {
  1991. if( pInfo->hwndDoEbUserName )
  1992. {
  1993. if( 0 < GetWindowTextLength(pInfo->hwndDoEbUserName) )
  1994. {
  1995. PropSheet_SetWizButtons( pInfo->hwndDlg, PSWIZB_BACK | PSWIZB_NEXT );
  1996. }
  1997. else
  1998. {
  1999. PropSheet_SetWizButtons( pInfo->hwndDlg, PSWIZB_BACK );
  2000. }
  2001. }
  2002. }
  2003. break;
  2004. }
  2005. }
  2006. return FALSE;
  2007. }
  2008. BOOL
  2009. DoInit(
  2010. IN HWND hwndPage )
  2011. /* Called on WM_INITDIALOG. 'hwndPage' is the handle of the property
  2012. ** page. 'PArgs' is the arguments from the PropertySheet caller.
  2013. **
  2014. ** Return false if focus was set, true otherwise.
  2015. */
  2016. {
  2017. AIINFO* pInfo;
  2018. TRACE("DoInit");
  2019. pInfo = AiContext( hwndPage );
  2020. if (!pInfo)
  2021. return TRUE;
  2022. /* Initialize page-specific context information.
  2023. */
  2024. pInfo->hwndDo = hwndPage;
  2025. pInfo->hwndDoEbUserName = GetDlgItem( hwndPage, CID_DO_EB_UserName );
  2026. Edit_LimitText( pInfo->hwndDoEbUserName, UNLEN );
  2027. pInfo->hwndDoEbDomain = GetDlgItem( hwndPage, CID_DO_EB_Domain );
  2028. Edit_LimitText( pInfo->hwndDoEbDomain, DNLEN );
  2029. pInfo->hwndDoEbPassword = GetDlgItem( hwndPage, CID_DO_EB_Password );
  2030. Edit_LimitText( pInfo->hwndDoEbPassword, PWLEN );
  2031. pInfo->hwndDoEbConfirm = GetDlgItem( hwndPage, CID_DO_EB_Confirm );
  2032. Edit_LimitText( pInfo->hwndDoEbConfirm, PWLEN );
  2033. /* Use the target router name as the default "User name",
  2034. */
  2035. if (pInfo->pArgs->pszRouter)
  2036. {
  2037. if (pInfo->pArgs->pszRouter[0] == TEXT('\\') &&
  2038. pInfo->pArgs->pszRouter[1] == TEXT('\\'))
  2039. SetWindowText(pInfo->hwndDoEbUserName, pInfo->pArgs->pszRouter+2);
  2040. else
  2041. SetWindowText(pInfo->hwndDoEbUserName, pInfo->pArgs->pszRouter);
  2042. }
  2043. return FALSE;
  2044. }
  2045. BOOL
  2046. DoKillActive(
  2047. IN AIINFO* pInfo )
  2048. /* Called when PSN_KILLACTIVE is received. 'PInfo' is the wizard context.
  2049. **
  2050. ** Returns true if the page is invalid, false is it can be dismissed.
  2051. */
  2052. {
  2053. // for whistler DCR 524304 gangz
  2054. PropSheet_SetWizButtons( pInfo->hwndDlg, PSWIZB_BACK | PSWIZB_NEXT );
  2055. return FALSE;
  2056. }
  2057. BOOL
  2058. DoNext(
  2059. IN AIINFO* pInfo )
  2060. /* Called when PSN_WIZNEXT is received. 'PInfo' is the wizard context.
  2061. **
  2062. ** Returns true if the page is invalid, false is it can be dismissed.
  2063. */
  2064. {
  2065. TCHAR* psz;
  2066. psz = GetText(pInfo->hwndDoEbUserName);
  2067. if (psz)
  2068. {
  2069. if (!lstrlen(psz))
  2070. {
  2071. Free(psz);
  2072. MsgDlg(pInfo->hwndDlg, SID_DialOutUserName, NULL);
  2073. SetFocus(pInfo->hwndDoEbUserName);
  2074. return TRUE;
  2075. }
  2076. Free0(pInfo->pArgs->pszRouterUserName);
  2077. pInfo->pArgs->pszRouterUserName = psz;
  2078. }
  2079. psz = GetText(pInfo->hwndDoEbDomain);
  2080. if (psz)
  2081. {
  2082. Free0(pInfo->pArgs->pszRouterDomain);
  2083. pInfo->pArgs->pszRouterDomain = psz;
  2084. }
  2085. /* Whistler bug 254385 encode password when not being used
  2086. */
  2087. psz = GetText(pInfo->hwndDoEbPassword);
  2088. EncodePassword(psz);
  2089. if (psz)
  2090. {
  2091. TCHAR* psz2;
  2092. psz2 = GetText(pInfo->hwndDoEbConfirm);
  2093. if(NULL != psz2)
  2094. {
  2095. /* Whistler bug 254385 encode password when not being used
  2096. */
  2097. DecodePassword(psz);
  2098. if (lstrcmp(psz, psz2))
  2099. {
  2100. ZeroMemory(psz, (lstrlen(psz) + 1) * sizeof(TCHAR));
  2101. ZeroMemory(psz2, (lstrlen(psz2) + 1) * sizeof(TCHAR));
  2102. Free(psz);
  2103. Free(psz2);
  2104. MsgDlg(pInfo->hwndDlg, SID_PasswordMismatch, NULL);
  2105. SetFocus(pInfo->hwndDoEbPassword);
  2106. return TRUE;
  2107. }
  2108. EncodePassword(psz);
  2109. ZeroMemory(psz2, (lstrlen(psz2) + 1) * sizeof(TCHAR));
  2110. Free(psz2);
  2111. }
  2112. /* Whistler bug 254385 encode password when not being used
  2113. ** Whistler bug 275526 NetVBL BVT Break: Routing BVT broken
  2114. */
  2115. if (pInfo->pArgs->pszRouterPassword)
  2116. {
  2117. ZeroMemory(
  2118. pInfo->pArgs->pszRouterPassword,
  2119. (lstrlen(pInfo->pArgs->pszRouterPassword) + 1) * sizeof(TCHAR));
  2120. }
  2121. Free0(pInfo->pArgs->pszRouterPassword);
  2122. pInfo->pArgs->pszRouterPassword = psz;
  2123. }
  2124. return FALSE;
  2125. }
  2126. BOOL
  2127. DoSetActive(
  2128. IN AIINFO* pInfo )
  2129. /* Called when PSN_SETACTIVE is received. 'PInfo' is the wizard context.
  2130. **
  2131. ** Returns true to display the page, false to skip it.
  2132. */
  2133. {
  2134. #if 0
  2135. TCHAR* psz;
  2136. /* Fill in the interface name in the explanatory text.
  2137. */
  2138. psz = PszFromId( g_hinstDll, SID_RouterDialOut );
  2139. if (psz)
  2140. {
  2141. MSGARGS msgargs;
  2142. ZeroMemory( &msgargs, sizeof(msgargs) );
  2143. msgargs.apszArgs[ 0 ] = pInfo->pArgs->pEntry->pszEntryName;
  2144. msgargs.fStringOutput = TRUE;
  2145. msgargs.pszString = psz;
  2146. MsgDlgUtil( NULL, 0, &msgargs, g_hinstDll, 0 );
  2147. if (msgargs.pszOutput)
  2148. {
  2149. SetDlgItemText( pInfo->hwndDo, CID_DO_ST_Explain,
  2150. msgargs.pszOutput );
  2151. Free( msgargs.pszOutput );
  2152. }
  2153. Free( psz );
  2154. }
  2155. #endif
  2156. // For whistler DCR bug 524304 gangz
  2157. // won't enable Next button until user input a user name
  2158. //
  2159. if( pInfo->hwndDoEbUserName &&
  2160. pInfo->hwndDlg )
  2161. {
  2162. if( 0 < GetWindowTextLength(pInfo->hwndDoEbUserName) )
  2163. {
  2164. PropSheet_SetWizButtons( pInfo->hwndDlg, PSWIZB_BACK | PSWIZB_NEXT );
  2165. }
  2166. else
  2167. {
  2168. PropSheet_SetWizButtons( pInfo->hwndDlg, PSWIZB_BACK );
  2169. }
  2170. }
  2171. return TRUE;
  2172. }
  2173. /*----------------------------------------------------------------------------
  2174. ** Interface Name property page
  2175. ** Listed alphabetically following dialog proc
  2176. **----------------------------------------------------------------------------
  2177. */
  2178. INT_PTR CALLBACK
  2179. InDlgProc(
  2180. IN HWND hwnd,
  2181. IN UINT unMsg,
  2182. IN WPARAM wparam,
  2183. IN LPARAM lparam )
  2184. /* DialogProc callback for the Interface Name page of the wizard.
  2185. ** Parameters and return values are as described for standard windows
  2186. ** 'DialogProc's.
  2187. */
  2188. {
  2189. switch (unMsg)
  2190. {
  2191. case WM_INITDIALOG:
  2192. {
  2193. return
  2194. InInit( hwnd );
  2195. }
  2196. case WM_NOTIFY:
  2197. {
  2198. switch (((NMHDR* )lparam)->code)
  2199. {
  2200. case PSN_RESET:
  2201. {
  2202. TRACE("InRESET");
  2203. AiCancel( hwnd );
  2204. SetWindowLong( hwnd, DWLP_MSGRESULT, FALSE );
  2205. return TRUE;
  2206. }
  2207. case PSN_SETACTIVE:
  2208. {
  2209. AIINFO* pInfo;
  2210. BOOL fDisplay;
  2211. TRACE("InSETACTIVE");
  2212. pInfo = AiContext( hwnd );
  2213. ASSERT(pInfo);
  2214. if (pInfo == NULL)
  2215. {
  2216. break;
  2217. }
  2218. fDisplay = InSetActive( pInfo );
  2219. SetWindowLong( hwnd, DWLP_MSGRESULT, (fDisplay) ? 0 : -1 );
  2220. return TRUE;
  2221. }
  2222. case PSN_KILLACTIVE:
  2223. {
  2224. AIINFO* pInfo;
  2225. BOOL fInvalid;
  2226. TRACE("InKILLACTIVE");
  2227. pInfo = AiContext( hwnd );
  2228. ASSERT(pInfo);
  2229. if (pInfo == NULL)
  2230. {
  2231. break;
  2232. }
  2233. fInvalid = InKillActive( pInfo );
  2234. SetWindowLong( hwnd, DWLP_MSGRESULT, fInvalid );
  2235. return TRUE;
  2236. }
  2237. case PSN_WIZFINISH:
  2238. {
  2239. AIINFO* pInfo;
  2240. TRACE("InWIZFINISH");
  2241. pInfo = AiContext( hwnd );
  2242. ASSERT(pInfo);
  2243. if (pInfo == NULL)
  2244. {
  2245. break;
  2246. }
  2247. /* You'd think pressing Finish would trigger a KILLACTIVE
  2248. ** event, but it doesn't, so we do it ourselves.
  2249. */
  2250. InKillActive( pInfo );
  2251. /* Set "no wizard" user preference, per user's check.
  2252. */
  2253. pInfo->pArgs->pUser->fNewEntryWizard = FALSE;
  2254. pInfo->pArgs->pUser->fDirty = TRUE;
  2255. g_pSetUserPreferences(
  2256. NULL,
  2257. pInfo->pArgs->pUser,
  2258. pInfo->pArgs->fNoUser ? UPM_Logon : UPM_Normal );
  2259. pInfo->pArgs->fPadSelected = FALSE;
  2260. pInfo->pArgs->fChainPropertySheet = TRUE;
  2261. AiFinish( hwnd );
  2262. SetWindowLong( hwnd, DWLP_MSGRESULT, 0 );
  2263. return TRUE;
  2264. }
  2265. }
  2266. break;
  2267. }
  2268. case WM_COMMAND:
  2269. {
  2270. AIINFO* pInfo = AiContext( hwnd );
  2271. ASSERT(pInfo);
  2272. if (pInfo == NULL)
  2273. {
  2274. break;
  2275. }
  2276. return InCommand(
  2277. pInfo, HIWORD( wparam ), LOWORD( wparam ), (HWND )lparam );
  2278. }
  2279. case WM_DESTROY:
  2280. {
  2281. AiTerm( hwnd );
  2282. break;
  2283. }
  2284. }
  2285. return FALSE;
  2286. }
  2287. BOOL
  2288. InCommand(
  2289. IN AIINFO* pInfo,
  2290. IN WORD wNotification,
  2291. IN WORD wId,
  2292. IN HWND hwndCtrl )
  2293. /* Called on WM_COMMAND. 'PInfo' is the dialog context. 'WNotification'
  2294. ** is the notification code of the command. 'wId' is the control/menu
  2295. ** identifier of the command. 'HwndCtrl' is the control window handle of
  2296. ** the command.
  2297. **
  2298. ** Returns true if processed message, false otherwise.
  2299. */
  2300. {
  2301. //TRACE3("InCommand(n=%d,i=%d,c=$%x)",
  2302. // (DWORD)wNotification,(DWORD)wId,(ULONG_PTR )hwndCtrl);
  2303. return FALSE;
  2304. }
  2305. BOOL
  2306. InInit(
  2307. IN HWND hwndPage)
  2308. /* Called on WM_INITDIALOG. 'hwndPage' is the handle of the property
  2309. ** page. 'PArgs' is the arguments from the PropertySheet caller.
  2310. **
  2311. ** Return false if focus was set, true otherwise.
  2312. */
  2313. {
  2314. DWORD dwErr;
  2315. AIINFO* pInfo;
  2316. PBENTRY* pEntry;
  2317. TRACE("InInit");
  2318. // Get the context of this page
  2319. pInfo = AiContext( hwndPage );
  2320. ASSERT ( pInfo );
  2321. if (pInfo == NULL)
  2322. {
  2323. return FALSE;
  2324. }
  2325. // Set up the interface name stuff
  2326. //
  2327. pInfo->hwndEbInterfaceName =
  2328. GetDlgItem( hwndPage, CID_IN_EB_InterfaceName );
  2329. ASSERT(pInfo->hwndEbInterfaceName);
  2330. pEntry = pInfo->pArgs->pEntry;
  2331. if (!pEntry->pszEntryName)
  2332. {
  2333. /* No entry name, so think up a default.
  2334. */
  2335. dwErr = GetDefaultEntryName(
  2336. pInfo->pArgs->pFile,
  2337. pEntry->dwType,
  2338. pInfo->pArgs->fRouter,
  2339. &pEntry->pszEntryName );
  2340. if (dwErr != 0)
  2341. {
  2342. ErrorDlg( pInfo->hwndDlg, SID_OP_LoadPage, dwErr, NULL );
  2343. AiExit( pInfo, dwErr );
  2344. return TRUE;
  2345. }
  2346. }
  2347. Edit_LimitText( pInfo->hwndEbInterfaceName, RAS_MaxEntryName );
  2348. SetWindowText( pInfo->hwndEbInterfaceName, pEntry->pszEntryName );
  2349. /* Initialize page-specific context information.
  2350. */
  2351. pInfo->hwndIn = hwndPage;
  2352. return TRUE;
  2353. }
  2354. BOOL
  2355. InKillActive(
  2356. IN AIINFO* pInfo )
  2357. /* Called when PSN_KILLACTIVE is received. 'PInfo' is the wizard context.
  2358. **
  2359. ** Returns true if the page is invalid, false is it can be dismissed.
  2360. */
  2361. {
  2362. TCHAR* psz;
  2363. psz = GetText( pInfo->hwndEbInterfaceName );
  2364. if (psz)
  2365. {
  2366. /* Update the entry name from the editbox.
  2367. */
  2368. Free0( pInfo->pArgs->pEntry->pszEntryName );
  2369. pInfo->pArgs->pEntry->pszEntryName = psz;
  2370. /* Validate the entry name.
  2371. */
  2372. if (!EuValidateName( pInfo->hwndDlg, pInfo->pArgs ))
  2373. {
  2374. SetFocus( pInfo->hwndEbInterfaceName );
  2375. Edit_SetSel( pInfo->hwndEbInterfaceName, 0, -1 );
  2376. return TRUE;
  2377. }
  2378. }
  2379. return FALSE;
  2380. }
  2381. BOOL
  2382. InSetActive(
  2383. IN AIINFO* pInfo )
  2384. /* Called when PSN_SETACTIVE is received. 'PInfo' is the wizard context.
  2385. **
  2386. ** Returns true to display the page, false to skip it.
  2387. */
  2388. {
  2389. TCHAR* psz;
  2390. // for whistler DCR 524304 gangz
  2391. PropSheet_SetWizButtons( pInfo->hwndDlg, PSWIZB_BACK | PSWIZB_NEXT );
  2392. return TRUE;
  2393. }
  2394. /*----------------------------------------------------------------------------
  2395. ** Name Servers property page
  2396. ** Listed alphabetically following dialog proc
  2397. **----------------------------------------------------------------------------
  2398. */
  2399. INT_PTR CALLBACK
  2400. NsDlgProc(
  2401. IN HWND hwnd,
  2402. IN UINT unMsg,
  2403. IN WPARAM wparam,
  2404. IN LPARAM lparam )
  2405. /* DialogProc callback for the Name Servers page of the wizard.
  2406. ** Parameters and return values are as described for standard windows
  2407. ** 'DialogProc's.
  2408. */
  2409. {
  2410. switch (unMsg)
  2411. {
  2412. case WM_INITDIALOG:
  2413. {
  2414. return
  2415. NsInit( hwnd );
  2416. }
  2417. case WM_NOTIFY:
  2418. {
  2419. switch (((NMHDR* )lparam)->code)
  2420. {
  2421. case PSN_SETACTIVE:
  2422. {
  2423. AIINFO* pInfo;
  2424. BOOL fDisplay;
  2425. TRACE("NsSETACTIVE");
  2426. pInfo = AiContext( hwnd );
  2427. ASSERT(pInfo);
  2428. if (pInfo == NULL)
  2429. {
  2430. break;
  2431. }
  2432. fDisplay = NsSetActive( pInfo );
  2433. SetWindowLong( hwnd, DWLP_MSGRESULT, (fDisplay) ? 0 : -1 );
  2434. return TRUE;
  2435. }
  2436. case PSN_KILLACTIVE:
  2437. {
  2438. AIINFO* pInfo;
  2439. BOOL fInvalid;
  2440. TRACE("NsKILLACTIVE");
  2441. pInfo = AiContext( hwnd );
  2442. ASSERT(pInfo);
  2443. if (pInfo == NULL)
  2444. {
  2445. break;
  2446. }
  2447. fInvalid = NsKillActive( pInfo );
  2448. SetWindowLong( hwnd, DWLP_MSGRESULT, fInvalid );
  2449. return TRUE;
  2450. }
  2451. }
  2452. break;
  2453. }
  2454. }
  2455. return FALSE;
  2456. }
  2457. BOOL
  2458. NsInit(
  2459. IN HWND hwndPage )
  2460. /* Called on WM_INITDIALOG. 'hwndPage' is the handle of the property
  2461. ** page. 'PArgs' is the arguments from the PropertySheet caller.
  2462. **
  2463. ** Return false if focus was set, true otherwise.
  2464. */
  2465. {
  2466. AIINFO* pInfo;
  2467. TRACE("NsInit");
  2468. pInfo = AiContext( hwndPage );
  2469. if (!pInfo)
  2470. return TRUE;
  2471. /* Initialize page-specific context information.
  2472. */
  2473. pInfo->hwndNs = hwndPage;
  2474. pInfo->hwndCcDns = GetDlgItem( hwndPage, CID_NS_CC_Dns );
  2475. ASSERT(pInfo->hwndCcDns);
  2476. pInfo->hwndCcWins = GetDlgItem( hwndPage, CID_NS_CC_Wins );
  2477. ASSERT(pInfo->hwndCcWins);
  2478. /* Set the IP address fields.
  2479. */
  2480. SetWindowText( pInfo->hwndCcDns, pInfo->pArgs->pEntry->pszIpDnsAddress );
  2481. SetWindowText( pInfo->hwndCcWins, pInfo->pArgs->pEntry->pszIpWinsAddress );
  2482. return FALSE;
  2483. }
  2484. BOOL
  2485. NsKillActive(
  2486. IN AIINFO* pInfo )
  2487. /* Called when PSN_KILLACTIVE is received. 'PInfo' is the wizard context.
  2488. **
  2489. ** Returns true if the page is invalid, false is it can be dismissed.
  2490. */
  2491. {
  2492. TCHAR* psz;
  2493. PBENTRY* pEntry = pInfo->pArgs->pEntry;
  2494. psz = GetText( pInfo->hwndCcDns );
  2495. if (psz)
  2496. {
  2497. Free0( pEntry->pszIpDnsAddress );
  2498. pEntry->pszIpDnsAddress = psz;
  2499. }
  2500. psz = GetText( pInfo->hwndCcWins );
  2501. if (psz)
  2502. {
  2503. Free0( pEntry->pszIpWinsAddress );
  2504. pEntry->pszIpWinsAddress = psz;
  2505. }
  2506. return FALSE;
  2507. }
  2508. BOOL
  2509. NsSetActive(
  2510. IN AIINFO* pInfo )
  2511. /* Called when PSN_SETACTIVE is received. 'PInfo' is the wizard context.
  2512. **
  2513. ** Returns true to display the page, false to skip it.
  2514. */
  2515. {
  2516. PBENTRY* pEntry;
  2517. pEntry = pInfo->pArgs->pEntry;
  2518. // In NT5, we always skip this page
  2519. return FALSE;
  2520. if (!pInfo->fNotNt || !pInfo->fIpConfigured)
  2521. {
  2522. return FALSE;
  2523. }
  2524. PropSheet_SetWizButtons( pInfo->hwndDlg, PSWIZB_BACK | PSWIZB_NEXT );
  2525. return TRUE;
  2526. }
  2527. /*----------------------------------------------------------------------------
  2528. ** IP Address property page
  2529. ** Listed alphabetically following dialog proc
  2530. **----------------------------------------------------------------------------
  2531. */
  2532. INT_PTR CALLBACK
  2533. RaDlgProc(
  2534. IN HWND hwnd,
  2535. IN UINT unMsg,
  2536. IN WPARAM wparam,
  2537. IN LPARAM lparam )
  2538. /* DialogProc callback for the IP Address page of the wizard. Parameters
  2539. ** and return value are as described for standard windows 'DialogProc's.
  2540. */
  2541. {
  2542. #if 0
  2543. TRACE4("RaDlgProc(h=$%x,m=$%x,w=$%x,l=$%x)",
  2544. (DWORD)hwnd,(DWORD)unMsg,(DWORD)wparam,(DWORD)lparam);
  2545. #endif
  2546. switch (unMsg)
  2547. {
  2548. case WM_INITDIALOG:
  2549. return RaInit( hwnd );
  2550. case WM_NOTIFY:
  2551. {
  2552. switch (((NMHDR* )lparam)->code)
  2553. {
  2554. case PSN_SETACTIVE:
  2555. {
  2556. AIINFO* pInfo;
  2557. BOOL fDisplay;
  2558. TRACE("RaSETACTIVE");
  2559. pInfo = AiContext( hwnd );
  2560. ASSERT(pInfo);
  2561. if (pInfo == NULL)
  2562. {
  2563. break;
  2564. }
  2565. fDisplay = RaSetActive( pInfo );
  2566. SetWindowLong( hwnd, DWLP_MSGRESULT, (fDisplay) ? 0 : -1 );
  2567. return TRUE;
  2568. }
  2569. case PSN_KILLACTIVE:
  2570. {
  2571. AIINFO* pInfo;
  2572. BOOL fInvalid;
  2573. TRACE("RaKILLACTIVE");
  2574. pInfo = AiContext( hwnd );
  2575. ASSERT(pInfo);
  2576. if (pInfo == NULL)
  2577. {
  2578. break;
  2579. }
  2580. fInvalid = RaKillActive( pInfo );
  2581. SetWindowLong( hwnd, DWLP_MSGRESULT, fInvalid );
  2582. return TRUE;
  2583. }
  2584. }
  2585. break;
  2586. }
  2587. }
  2588. return FALSE;
  2589. }
  2590. BOOL
  2591. RaInit(
  2592. IN HWND hwndPage )
  2593. /* Called on WM_INITDIALOG. 'hwndPage' is the handle of the property
  2594. ** page.
  2595. **
  2596. ** Return false if focus was set, true otherwise.
  2597. */
  2598. {
  2599. AIINFO* pInfo;
  2600. TRACE("RaInit");
  2601. pInfo = AiContext( hwndPage );
  2602. if (!pInfo)
  2603. return TRUE;
  2604. /* Initialize page-specific context information.
  2605. */
  2606. pInfo->hwndRa = hwndPage;
  2607. pInfo->hwndCcIp = GetDlgItem( hwndPage, CID_RA_CC_Ip );
  2608. ASSERT(pInfo->hwndCcIp);
  2609. /* Set the IP address field to '0.0.0.0'.
  2610. */
  2611. SetWindowText( pInfo->hwndCcIp, pInfo->pArgs->pEntry->pszIpAddress );
  2612. return FALSE;
  2613. }
  2614. BOOL
  2615. RaKillActive(
  2616. IN AIINFO* pInfo )
  2617. /* Called when PSN_KILLACTIVE is received. 'PInfo' is the wizard context.
  2618. **
  2619. ** Returns true if the page is invalid, false is it can be dismissed.
  2620. */
  2621. {
  2622. TCHAR* psz;
  2623. psz = GetText( pInfo->hwndCcIp );
  2624. if (psz)
  2625. {
  2626. PBENTRY* pEntry = pInfo->pArgs->pEntry;
  2627. Free0( pEntry->pszIpAddress );
  2628. pEntry->pszIpAddress = psz;
  2629. }
  2630. return FALSE;
  2631. }
  2632. BOOL
  2633. RaSetActive(
  2634. IN AIINFO* pInfo )
  2635. /* Called when PSN_SETACTIVE is received. 'PInfo' is the wizard context.
  2636. **
  2637. ** Returns true to display the page, false to skip it.
  2638. */
  2639. {
  2640. PBENTRY* pEntry;
  2641. pEntry = pInfo->pArgs->pEntry;
  2642. // In NT5, we always skip this page
  2643. return FALSE;
  2644. if (!pInfo->fNotNt || !pInfo->fIpConfigured)
  2645. {
  2646. return FALSE;
  2647. }
  2648. PropSheet_SetWizButtons( pInfo->hwndDlg, PSWIZB_BACK | PSWIZB_NEXT );
  2649. return TRUE;
  2650. }
  2651. /*----------------------------------------------------------------------------
  2652. ** Logon Script property page
  2653. ** Listed alphabetically following dialog proc
  2654. **----------------------------------------------------------------------------
  2655. */
  2656. INT_PTR CALLBACK
  2657. RcDlgProc(
  2658. IN HWND hwnd,
  2659. IN UINT unMsg,
  2660. IN WPARAM wparam,
  2661. IN LPARAM lparam )
  2662. /* DialogProc callback for the Logon Script page of the wizard.
  2663. ** Parameters and return value are as described for standard windows
  2664. ** 'DialogProc's.
  2665. */
  2666. {
  2667. #if 0
  2668. TRACE4("RcDlgProc(h=$%x,m=$%x,w=$%x,l=$%x)",
  2669. (DWORD)hwnd,(DWORD)unMsg,(DWORD)wparam,(DWORD)lparam);
  2670. #endif
  2671. switch (unMsg)
  2672. {
  2673. case WM_INITDIALOG:
  2674. return RcInit( hwnd );
  2675. case WM_NOTIFY:
  2676. {
  2677. switch (((NMHDR* )lparam)->code)
  2678. {
  2679. case PSN_SETACTIVE:
  2680. {
  2681. AIINFO* pInfo;
  2682. BOOL fDisplay;
  2683. TRACE("RcSETACTIVE");
  2684. pInfo = AiContext( hwnd );
  2685. ASSERT(pInfo);
  2686. if (pInfo == NULL)
  2687. {
  2688. break;
  2689. }
  2690. fDisplay = RcSetActive( pInfo );
  2691. SetWindowLong( hwnd, DWLP_MSGRESULT, (fDisplay) ? 0 : -1 );
  2692. return TRUE;
  2693. }
  2694. case PSN_KILLACTIVE:
  2695. {
  2696. AIINFO* pInfo;
  2697. BOOL fInvalid;
  2698. TRACE("RcKILLACTIVE");
  2699. pInfo = AiContext( hwnd );
  2700. ASSERT(pInfo);
  2701. if (pInfo == NULL)
  2702. {
  2703. break;
  2704. }
  2705. fInvalid = RcKillActive( pInfo );
  2706. SetWindowLong( hwnd, DWLP_MSGRESULT, fInvalid );
  2707. return TRUE;
  2708. }
  2709. }
  2710. break;
  2711. }
  2712. case WM_COMMAND:
  2713. {
  2714. AIINFO* pInfo = AiContext( hwnd );
  2715. ASSERT(pInfo);
  2716. if (pInfo == NULL)
  2717. {
  2718. break;
  2719. }
  2720. return RcCommand(
  2721. pInfo, HIWORD( wparam ), LOWORD( wparam ), (HWND )lparam );
  2722. }
  2723. }
  2724. return FALSE;
  2725. }
  2726. BOOL
  2727. RcCommand(
  2728. IN AIINFO* pInfo,
  2729. IN WORD wNotification,
  2730. IN WORD wId,
  2731. IN HWND hwndCtrl )
  2732. /* Called on WM_COMMAND. 'PInfo' is the dialog context. 'WNotification'
  2733. ** is the notification code of the command. 'wId' is the control/menu
  2734. ** identifier of the command. 'HwndCtrl' is the control window handle of
  2735. ** the command.
  2736. **
  2737. ** Returns true if processed message, false otherwise.
  2738. */
  2739. {
  2740. TRACE3("RcCommand(n=%d,i=%d,c=$%x)",
  2741. (DWORD)wNotification,(DWORD)wId,(ULONG_PTR )hwndCtrl);
  2742. switch (wId)
  2743. {
  2744. case CID_RC_CB_RunScript:
  2745. {
  2746. if (SuScriptsCbHandler( &pInfo->suinfo, wNotification ))
  2747. {
  2748. return TRUE;
  2749. }
  2750. break;
  2751. }
  2752. case CID_RC_PB_Edit:
  2753. {
  2754. if (SuEditPbHandler( &pInfo->suinfo, wNotification ))
  2755. {
  2756. return TRUE;
  2757. }
  2758. break;
  2759. }
  2760. case CID_RC_PB_Browse:
  2761. {
  2762. if (SuBrowsePbHandler( &pInfo->suinfo, wNotification ))
  2763. {
  2764. return TRUE;
  2765. }
  2766. break;
  2767. }
  2768. }
  2769. return FALSE;
  2770. }
  2771. BOOL
  2772. RcInit(
  2773. IN HWND hwndPage )
  2774. /* Called on WM_INITDIALOG. 'hwndPage' is the handle of the property
  2775. ** page.
  2776. **
  2777. ** Return false if focus was set, true otherwise.
  2778. */
  2779. {
  2780. AIINFO* pInfo;
  2781. PBENTRY* pEntry;
  2782. TRACE("RcInit");
  2783. pInfo = AiContext( hwndPage );
  2784. if (!pInfo)
  2785. return TRUE;
  2786. /* Initialize page-specific context information.
  2787. */
  2788. pInfo->hwndRc = hwndPage;
  2789. pInfo->hwndCbTerminal = GetDlgItem( hwndPage, CID_RC_CB_Terminal );
  2790. ASSERT( pInfo->hwndCbTerminal );
  2791. pInfo->hwndCbRunScript = GetDlgItem( hwndPage, CID_RC_CB_RunScript );
  2792. ASSERT( pInfo->hwndCbRunScript );
  2793. pInfo->hwndLbScripts = GetDlgItem( hwndPage, CID_RC_LB_Scripts );
  2794. ASSERT( pInfo->hwndLbScripts );
  2795. pInfo->hwndPbEdit = GetDlgItem( hwndPage, CID_RC_PB_Edit );
  2796. ASSERT( pInfo->hwndPbEdit );
  2797. pInfo->hwndPbBrowse = GetDlgItem( hwndPage, CID_RC_PB_Browse );
  2798. ASSERT( pInfo->hwndPbBrowse );
  2799. pEntry = pInfo->pArgs->pEntry;
  2800. pInfo->suinfo.hConnection =
  2801. ((INTERNALARGS *) pInfo->pArgs->pApiArgs->reserved)->hConnection;
  2802. // We don't allow the script window for dd interfaces
  2803. //
  2804. ShowWindow(pInfo->hwndCbTerminal, SW_HIDE);
  2805. // Set up the after-dial scripting controls.
  2806. //
  2807. SuInit( &pInfo->suinfo,
  2808. pInfo->hwndCbRunScript,
  2809. pInfo->hwndCbTerminal,
  2810. pInfo->hwndLbScripts,
  2811. pInfo->hwndPbEdit,
  2812. pInfo->hwndPbBrowse,
  2813. SU_F_DisableTerminal);
  2814. pInfo->fSuInfoInitialized = TRUE;
  2815. SuSetInfo( &pInfo->suinfo,
  2816. pEntry->fScriptAfter,
  2817. pEntry->fScriptAfterTerminal,
  2818. pEntry->pszScriptAfter );
  2819. return FALSE;
  2820. }
  2821. BOOL
  2822. RcKillActive(
  2823. IN AIINFO* pInfo )
  2824. /* Called when PSN_KILLACTIVE is received. 'PInfo' is the wizard context.
  2825. **
  2826. ** Returns true if the page is invalid, false is it can be dismissed.
  2827. */
  2828. {
  2829. PBENTRY* pEntry;
  2830. pEntry = pInfo->pArgs->pEntry;
  2831. Free0( pEntry->pszScriptAfter );
  2832. SuGetInfo( &pInfo->suinfo,
  2833. &pEntry->fScriptAfter,
  2834. &pEntry->fScriptAfterTerminal,
  2835. &pEntry->pszScriptAfter );
  2836. return FALSE;
  2837. }
  2838. BOOL
  2839. RcSetActive(
  2840. IN AIINFO* pInfo )
  2841. /* Called when PSN_SETACTIVE is received. 'PInfo' is the wizard context.
  2842. **
  2843. ** Returns true to display the page, false to skip it.
  2844. */
  2845. {
  2846. HWND hwndRb;
  2847. if (!pInfo->fNotNt || !pInfo->fModem)
  2848. return FALSE;
  2849. PropSheet_SetWizButtons( pInfo->hwndDlg, PSWIZB_BACK | PSWIZB_NEXT );
  2850. return TRUE;
  2851. }
  2852. /*----------------------------------------------------------------------------
  2853. ** Finish property page
  2854. ** Listed alphabetically following dialog proc
  2855. **----------------------------------------------------------------------------
  2856. */
  2857. INT_PTR CALLBACK
  2858. RfDlgProc(
  2859. IN HWND hwnd,
  2860. IN UINT unMsg,
  2861. IN WPARAM wparam,
  2862. IN LPARAM lparam )
  2863. /* DialogProc callback for the Finish page of the wizard.
  2864. ** Parameters and return value are as described for standard windows
  2865. ** 'DialogProc's.
  2866. */
  2867. {
  2868. #if 0
  2869. TRACE4("RfDlgProc(h=$%x,m=$%x,w=$%x,l=$%x)",
  2870. (DWORD)hwnd,(DWORD)unMsg,(DWORD)wparam,(DWORD)lparam);
  2871. #endif
  2872. switch (unMsg)
  2873. {
  2874. case WM_INITDIALOG:
  2875. return RfInit( hwnd );
  2876. case WM_NOTIFY:
  2877. {
  2878. switch (((NMHDR* )lparam)->code)
  2879. {
  2880. case PSN_SETACTIVE:
  2881. {
  2882. AIINFO* pInfo;
  2883. BOOL fDisplay;
  2884. TRACE("RfSETACTIVE");
  2885. pInfo = AiContext( hwnd );
  2886. ASSERT(pInfo);
  2887. if (pInfo == NULL)
  2888. {
  2889. break;
  2890. }
  2891. fDisplay = RfSetActive( pInfo );
  2892. SetWindowLong( hwnd, DWLP_MSGRESULT, (fDisplay) ? 0 : -1 );
  2893. return TRUE;
  2894. }
  2895. case PSN_KILLACTIVE:
  2896. {
  2897. AIINFO* pInfo;
  2898. BOOL fInvalid;
  2899. TRACE("RfKILLACTIVE");
  2900. pInfo = AiContext( hwnd );
  2901. ASSERT(pInfo);
  2902. if (pInfo == NULL)
  2903. {
  2904. break;
  2905. }
  2906. fInvalid = RfKillActive( pInfo );
  2907. SetWindowLong( hwnd, DWLP_MSGRESULT, fInvalid );
  2908. return TRUE;
  2909. }
  2910. case PSN_WIZFINISH:
  2911. {
  2912. TRACE("RfWIZFINISH");
  2913. AiFinish( hwnd );
  2914. SetWindowLong( hwnd, DWLP_MSGRESULT, 0 );
  2915. return TRUE;
  2916. }
  2917. }
  2918. break;
  2919. }
  2920. case WM_COMMAND:
  2921. {
  2922. AIINFO* pInfo = AiContext( hwnd );
  2923. ASSERT(pInfo);
  2924. if (pInfo == NULL)
  2925. {
  2926. break;
  2927. }
  2928. return RfCommand(
  2929. pInfo, HIWORD( wparam ), LOWORD( wparam ), (HWND )lparam );
  2930. }
  2931. }
  2932. return FALSE;
  2933. }
  2934. BOOL
  2935. RfCommand(
  2936. IN AIINFO* pInfo,
  2937. IN WORD wNotification,
  2938. IN WORD wId,
  2939. IN HWND hwndCtrl )
  2940. /* Called on WM_COMMAND. 'PInfo' is the dialog context. 'WNotification'
  2941. ** is the notification code of the command. 'wId' is the control/menu
  2942. ** identifier of the command. 'HwndCtrl' is the control window handle of
  2943. ** the command.
  2944. **
  2945. ** Returns true if processed message, false otherwise.
  2946. */
  2947. {
  2948. TRACE3("RfCommand(n=%d,i=%d,c=$%x)",
  2949. (DWORD)wNotification,(DWORD)wId,(ULONG_PTR )hwndCtrl);
  2950. #if 0
  2951. switch (wId)
  2952. {
  2953. case CID_RF_PB_Properties:
  2954. {
  2955. pInfo->pArgs->fChainPropertySheet = TRUE;
  2956. PropSheet_PressButton( pInfo->hwndDlg, PSBTN_FINISH );
  2957. return TRUE;
  2958. }
  2959. }
  2960. #endif
  2961. return FALSE;
  2962. }
  2963. BOOL
  2964. RfInit(
  2965. IN HWND hwndPage )
  2966. /* Called on WM_INITDIALOG. 'hwndPage' is the handle of the property
  2967. ** page.
  2968. **
  2969. ** Return false if focus was set, true otherwise.
  2970. */
  2971. {
  2972. AIINFO* pInfo;
  2973. PBENTRY* pEntry;
  2974. DWORD dwErr;
  2975. TRACE("RfInit");
  2976. pInfo = AiContext( hwndPage );
  2977. if (!pInfo)
  2978. return TRUE;
  2979. /* Initialize page-specific context information.
  2980. */
  2981. pInfo->hwndRf = hwndPage;
  2982. // Set up a bold font if we can.
  2983. //
  2984. pInfo->hwndRfStFinish = GetDlgItem( hwndPage, CID_RF_ST_Explain );
  2985. if (pInfo->hBoldFont && pInfo->hwndRfStFinish)
  2986. {
  2987. SendMessage(
  2988. pInfo->hwndRfStFinish,
  2989. WM_SETFONT,
  2990. (WPARAM)pInfo->hBoldFont,
  2991. MAKELPARAM(TRUE, 0));
  2992. }
  2993. /* Create and display the wizard bitmap.
  2994. */
  2995. CreateWizardBitmap( hwndPage, TRUE );
  2996. return FALSE;
  2997. }
  2998. BOOL
  2999. RfSetActive(
  3000. IN AIINFO* pInfo )
  3001. /* Called when PSN_SETACTIVE is received. 'PInfo' is the wizard context.
  3002. **
  3003. ** Returns true to display the page, false to skip it.
  3004. */
  3005. {
  3006. PropSheet_SetWizButtons( pInfo->hwndDlg, PSWIZB_BACK | PSWIZB_FINISH );
  3007. return TRUE;
  3008. }
  3009. BOOL
  3010. RfKillActive(
  3011. IN AIINFO* pInfo )
  3012. {
  3013. /* Called when PSN_KILLACTIVE is received. 'PInfo' is the wizard context.
  3014. **
  3015. ** Returns true if the page is invalid, false is it can be dismissed.
  3016. */
  3017. return FALSE;
  3018. }
  3019. /*----------------------------------------------------------------------------
  3020. ** Modem/Adapter property page
  3021. ** Listed alphabetically following dialog proc
  3022. **----------------------------------------------------------------------------
  3023. */
  3024. INT_PTR CALLBACK
  3025. RnDlgProc(
  3026. IN HWND hwnd,
  3027. IN UINT unMsg,
  3028. IN WPARAM wparam,
  3029. IN LPARAM lparam )
  3030. /* DialogProc callback for the Modem/Adapter page of the wizard.
  3031. ** Parameters and return value are as described for standard windows
  3032. ** 'DialogProc's.
  3033. */
  3034. {
  3035. #if 0
  3036. TRACE4("RnDlgProc(h=$%x,m=$%x,w=$%x,l=$%x)",
  3037. (DWORD)hwnd,(DWORD)unMsg,(DWORD)wparam,(DWORD)lparam);
  3038. #endif
  3039. if (ListView_OwnerHandler(
  3040. hwnd, unMsg, wparam, lparam, RnLvCallback ))
  3041. {
  3042. return TRUE;
  3043. }
  3044. switch (unMsg)
  3045. {
  3046. case WM_INITDIALOG:
  3047. return RnInit( hwnd );
  3048. case WM_NOTIFY:
  3049. {
  3050. switch (((NMHDR* )lparam)->code)
  3051. {
  3052. case PSN_SETACTIVE:
  3053. {
  3054. AIINFO* pInfo;
  3055. BOOL fDisplay;
  3056. TRACE("RnSETACTIVE");
  3057. pInfo = AiContext( hwnd );
  3058. ASSERT(pInfo);
  3059. fDisplay = RnSetActive( pInfo );
  3060. SetWindowLong( hwnd, DWLP_MSGRESULT, (fDisplay) ? 0 : -1 );
  3061. return TRUE;
  3062. }
  3063. case LVN_ITEMCHANGED:
  3064. {
  3065. AIINFO* pInfo;
  3066. pInfo = AiContext( hwnd );
  3067. ASSERT(pInfo);
  3068. RnLvItemChanged( pInfo );
  3069. return TRUE;
  3070. }
  3071. }
  3072. break;
  3073. }
  3074. }
  3075. return FALSE;
  3076. }
  3077. BOOL
  3078. RnInit(
  3079. IN HWND hwndPage )
  3080. /* Called on WM_INITDIALOG. 'hwndPage' is the handle of the property
  3081. ** page.
  3082. **
  3083. ** Return false if focus was set, true otherwise.
  3084. */
  3085. {
  3086. DWORD dwErr;
  3087. AIINFO* pInfo;
  3088. TRACE("RnInit");
  3089. pInfo = AiContext( hwndPage );
  3090. if (!pInfo)
  3091. return TRUE;
  3092. /* Initialize page-specific context information.
  3093. */
  3094. pInfo->hwndRn = hwndPage;
  3095. pInfo->hwndLv = GetDlgItem( hwndPage, CID_RN_LV_Devices );
  3096. ASSERT(pInfo->hwndLv);
  3097. /* Add the modem and adapter images.
  3098. */
  3099. ListView_SetDeviceImageList( pInfo->hwndLv, g_hinstDll );
  3100. /* Add a single column exactly wide enough to fully display the
  3101. ** widest member of the list.
  3102. */
  3103. {
  3104. LV_COLUMN col;
  3105. ZeroMemory( &col, sizeof(col) );
  3106. col.mask = LVCF_FMT;
  3107. col.fmt = LVCFMT_LEFT;
  3108. ListView_InsertColumn( pInfo->hwndLv, 0, &col );
  3109. ListView_SetColumnWidth(
  3110. pInfo->hwndLv, 0, LVSCW_AUTOSIZE_USEHEADER );
  3111. }
  3112. /* Don't bother with this page if there's only one device, not counting
  3113. ** the bogus "uninstalled" standard modem that's added by EuInit so
  3114. ** entries can be edited when there are no ports.
  3115. */
  3116. if (!pInfo->pArgs->fNoPortsConfigured
  3117. && ListView_GetItemCount( pInfo->hwndLv ) == 1)
  3118. {
  3119. pInfo->fSkipMa = TRUE;
  3120. }
  3121. return FALSE;
  3122. }
  3123. LVXDRAWINFO*
  3124. RnLvCallback(
  3125. IN HWND hwndLv,
  3126. IN DWORD dwItem )
  3127. /* Enhanced list view callback to report drawing information. 'HwndLv' is
  3128. ** the handle of the list view control. 'DwItem' is the index of the item
  3129. ** being drawn.
  3130. **
  3131. ** Returns the address of the column information.
  3132. */
  3133. {
  3134. /* Use "wide selection bar" feature and the other recommended options.
  3135. **
  3136. ** Fields are 'nCols', 'dxIndent', 'dwFlags', 'adwFlags[]'.
  3137. */
  3138. static LVXDRAWINFO info =
  3139. { 1, 0, LVXDI_DxFill, { 0, 0 } };
  3140. return &info;
  3141. }
  3142. VOID
  3143. RnLvItemChanged(
  3144. IN AIINFO* pInfo )
  3145. /* Called when the combobox selection changes. 'PInfo' is the wizard
  3146. ** context.
  3147. */
  3148. {
  3149. INT iSel;
  3150. DTLNODE* pNode;
  3151. DTLLIST* pList;
  3152. TRACE("RnLvItemChanged");
  3153. pList = pInfo->pArgs->pEntry->pdtllistLinks;
  3154. ASSERT(pList);
  3155. pNode = (DTLNODE* )ListView_GetSelectedParamPtr( pInfo->hwndLv );
  3156. pInfo->dwSelectedDeviceIndex =
  3157. (DWORD) ListView_GetNextItem( pInfo->hwndLv, -1, LVNI_SELECTED );
  3158. if (pNode)
  3159. {
  3160. PBLINK* pLink;
  3161. /* Single device selected. Enable it, move it to the head of the list
  3162. ** of links, and disable all the other links.
  3163. */
  3164. pLink = (PBLINK* )DtlGetData( pNode );
  3165. pLink->fEnabled = TRUE;
  3166. pInfo->fModem =
  3167. (pLink->pbport.pbdevicetype == PBDT_Modem
  3168. || pLink->pbport.pbdevicetype == PBDT_Null);
  3169. /* If the device selected is an X25 PAD, we will drop the user into
  3170. ** the phonebook entry-dialog after this wizard, so that the X25
  3171. ** address can be entered there.
  3172. */
  3173. pInfo->pArgs->fPadSelected = (pLink->pbport.pbdevicetype == PBDT_Pad);
  3174. DtlRemoveNode( pList, pNode );
  3175. DtlAddNodeFirst( pList, pNode );
  3176. for (pNode = DtlGetNextNode( pNode );
  3177. pNode;
  3178. pNode = DtlGetNextNode( pNode ))
  3179. {
  3180. //For whstler 522872
  3181. PBLINK* pLinkTmp = (PBLINK* )DtlGetData( pNode );
  3182. ASSERT(pLinkTmp);
  3183. pLinkTmp->fEnabled = FALSE;
  3184. }
  3185. }
  3186. else
  3187. {
  3188. DTLNODE* pNextNode;
  3189. DTLNODE* pAfterNode;
  3190. pInfo->fModem = FALSE;
  3191. /* ISDN multi-link selected. Enable the ISDN multi-link nodes, move
  3192. ** them to the head of the list, and disable all the other links.
  3193. */
  3194. pAfterNode = NULL;
  3195. for (pNode = DtlGetFirstNode( pList );
  3196. pNode;
  3197. pNode = pNextNode)
  3198. {
  3199. PBLINK* pLink = (PBLINK* )DtlGetData( pNode );
  3200. ASSERT(pLink);
  3201. pNextNode = DtlGetNextNode( pNode );
  3202. if (pLink->pbport.pbdevicetype == PBDT_Isdn
  3203. && !pLink->fProprietaryIsdn)
  3204. {
  3205. pLink->fEnabled = TRUE;
  3206. DtlRemoveNode( pList, pNode );
  3207. if (pAfterNode)
  3208. DtlAddNodeAfter( pList, pAfterNode, pNode );
  3209. else
  3210. DtlAddNodeFirst( pList, pNode );
  3211. pAfterNode = pNode;
  3212. }
  3213. else
  3214. {
  3215. pLink->fEnabled = FALSE;
  3216. }
  3217. }
  3218. }
  3219. }
  3220. BOOL
  3221. RnLvRefresh(
  3222. IN AIINFO* pInfo)
  3223. {
  3224. DWORD dwErr = NO_ERROR;
  3225. TCHAR* psz;
  3226. DTLNODE* pNode;
  3227. DWORD cMultilinkableIsdn;
  3228. INT iItem;
  3229. ListView_DeleteAllItems( pInfo->hwndLv );
  3230. iItem = 1;
  3231. cMultilinkableIsdn = 0;
  3232. for (pNode = DtlGetFirstNode( pInfo->pArgs->pEntry->pdtllistLinks );
  3233. pNode;
  3234. pNode = DtlGetNextNode( pNode ))
  3235. {
  3236. PBLINK* pLink;
  3237. pLink = (PBLINK* )DtlGetData( pNode );
  3238. ASSERT(pLink);
  3239. // For whistler bug 448251
  3240. // for whistler DCR 524304 gangz
  3241. // Filter out LPT1, because the DoD only happens in a NAT or NAT/VPN
  3242. // which won't use this LPT1 port
  3243. if ( PBDT_PPPoE == pLink->pbport.pbdevicetype ||
  3244. PBDT_Parallel == pLink->pbport.pbdevicetype )
  3245. {
  3246. continue;
  3247. }
  3248. if (pLink->pbport.pbdevicetype == PBDT_Isdn
  3249. && !pLink->fProprietaryIsdn)
  3250. {
  3251. ++cMultilinkableIsdn;
  3252. }
  3253. psz = DisplayPszFromDeviceAndPort(
  3254. pLink->pbport.pszDevice, pLink->pbport.pszPort );
  3255. if (psz)
  3256. {
  3257. PBLINK* pLinkTmp = NULL;
  3258. LV_ITEM item;
  3259. pLinkTmp = (PBLINK* )DtlGetData( pNode );
  3260. ZeroMemory( &item, sizeof(item) );
  3261. item.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM;
  3262. item.iItem = iItem++;
  3263. item.pszText = psz;
  3264. // I noticed that the device bitmaps were
  3265. // inconsistent with connections, so I'm
  3266. // matching them up here.
  3267. //
  3268. if (pLinkTmp->pbport.dwType == RASET_Direct)
  3269. {
  3270. item.iImage = DI_Direct;
  3271. }
  3272. else if (pLinkTmp->pbport.pbdevicetype == PBDT_Modem)
  3273. {
  3274. item.iImage = DI_Modem;
  3275. }
  3276. else
  3277. {
  3278. item.iImage = DI_Adapter;
  3279. }
  3280. item.lParam = (LPARAM )pNode;
  3281. ListView_InsertItem( pInfo->hwndLv, &item );
  3282. Free( psz );
  3283. }
  3284. }
  3285. if (cMultilinkableIsdn > 1)
  3286. {
  3287. psz = PszFromId( g_hinstDll, SID_IsdnAdapter );
  3288. if (psz)
  3289. {
  3290. LONG lStyle;
  3291. LV_ITEM item;
  3292. /* Turn off sorting so the special ISDN-multilink item appears
  3293. ** at the top of the list.
  3294. */
  3295. lStyle = GetWindowLong( pInfo->hwndLv, GWL_STYLE );
  3296. SetWindowLong( pInfo->hwndLv, GWL_STYLE,
  3297. (lStyle & ~(LVS_SORTASCENDING)) );
  3298. ZeroMemory( &item, sizeof(item) );
  3299. item.mask = LVIF_TEXT + LVIF_IMAGE + LVIF_PARAM;
  3300. item.iItem = 0;
  3301. item.pszText = psz;
  3302. item.iImage = DI_Adapter;
  3303. item.lParam = (LPARAM )NULL;
  3304. ListView_InsertItem( pInfo->hwndLv, &item );
  3305. Free( psz );
  3306. }
  3307. }
  3308. return NO_ERROR;
  3309. }
  3310. BOOL
  3311. RnSetActive(
  3312. IN AIINFO* pInfo )
  3313. /* Called when PSN_SETACTIVE is received. 'PInfo' is the wizard context.
  3314. **
  3315. ** Returns true to display the page, false to skip it.
  3316. */
  3317. {
  3318. INT cDevices;
  3319. // pmay: 233295.
  3320. // This page does not apply to VPN connections
  3321. //
  3322. if (
  3323. ((pInfo->pArgs->pEntry->dwType == RASET_Vpn
  3324. && !pInfo->pArgs->fNt4Router)
  3325. || (pInfo->fSkipMa)
  3326. || (pInfo->pArgs->pEntry->dwType == RASET_Broadband)) //For whistler 349807
  3327. )
  3328. {
  3329. return FALSE;
  3330. }
  3331. // If we have no physical devices, then this page is invalid
  3332. // unless we're focused on an nt4 machine in which case the
  3333. // tunneling adapters are selected from here.
  3334. if ( ! (pInfo->dwFlags & AI_F_HasPhysDevs) )
  3335. {
  3336. if ( ! pInfo->pArgs->fNt4Router )
  3337. return FALSE;
  3338. }
  3339. // Refresh the list view and make the correct selection
  3340. //
  3341. RnLvRefresh(pInfo);
  3342. // for whistler DCR 524304 gangz
  3343. // If there is no device, just skip this page
  3344. //
  3345. if( 0 == ListView_GetItemCount( pInfo->hwndLv ) )
  3346. {
  3347. return FALSE;
  3348. }
  3349. ListView_SetItemState(
  3350. pInfo->hwndLv,
  3351. pInfo->dwSelectedDeviceIndex,
  3352. LVIS_SELECTED, LVIS_SELECTED );
  3353. PropSheet_SetWizButtons( pInfo->hwndDlg, PSWIZB_BACK | PSWIZB_NEXT );
  3354. return TRUE;
  3355. }
  3356. /*----------------------------------------------------------------------------
  3357. ** Phone Number property page
  3358. ** Listed alphabetically following dialog proc
  3359. **----------------------------------------------------------------------------
  3360. */
  3361. INT_PTR CALLBACK
  3362. RpDlgProc(
  3363. IN HWND hwnd,
  3364. IN UINT unMsg,
  3365. IN WPARAM wparam,
  3366. IN LPARAM lparam )
  3367. /* DialogProc callback for the Phone Number page of the wizard.
  3368. ** Parameters and return value are as described for standard windows
  3369. ** 'DialogProc's.
  3370. */
  3371. {
  3372. #if 0
  3373. TRACE4("RpDlgProc(h=$%x,m=$%x,w=$%x,l=$%x)",
  3374. (DWORD)hwnd,(DWORD)unMsg,(DWORD)wparam,(DWORD)lparam);
  3375. #endif
  3376. switch (unMsg)
  3377. {
  3378. case WM_INITDIALOG:
  3379. return RpInit( hwnd );
  3380. case WM_NOTIFY:
  3381. {
  3382. switch (((NMHDR* )lparam)->code)
  3383. {
  3384. case PSN_SETACTIVE:
  3385. {
  3386. AIINFO* pInfo;
  3387. BOOL fDisplay;
  3388. TRACE("RpSETACTIVE");
  3389. pInfo = AiContext( hwnd );
  3390. ASSERT(pInfo);
  3391. if (pInfo == NULL)
  3392. {
  3393. break;
  3394. }
  3395. fDisplay = RpSetActive( pInfo );
  3396. SetWindowLong( hwnd, DWLP_MSGRESULT, (fDisplay) ? 0 : -1 );
  3397. return TRUE;
  3398. }
  3399. case PSN_KILLACTIVE:
  3400. {
  3401. AIINFO* pInfo;
  3402. BOOL fInvalid;
  3403. TRACE("RpKILLACTIVE");
  3404. pInfo = AiContext( hwnd );
  3405. ASSERT(pInfo);
  3406. if (pInfo == NULL)
  3407. {
  3408. break;
  3409. }
  3410. fInvalid = RpKillActive( pInfo );
  3411. SetWindowLong( hwnd, DWLP_MSGRESULT, fInvalid );
  3412. return TRUE;
  3413. }
  3414. }
  3415. break;
  3416. }
  3417. case WM_COMMAND:
  3418. {
  3419. AIINFO* pInfo = AiContext( hwnd );
  3420. ASSERT(pInfo);
  3421. if (pInfo == NULL)
  3422. {
  3423. break;
  3424. }
  3425. return RpCommand(
  3426. pInfo, HIWORD( wparam ), LOWORD( wparam ), (HWND )lparam );
  3427. }
  3428. }
  3429. return FALSE;
  3430. }
  3431. VOID
  3432. RpAlternates(
  3433. IN AIINFO* pInfo )
  3434. /* Popup the Alternate Phone Numbers dialog. 'PInfo' is the property
  3435. ** sheet context.
  3436. */
  3437. {
  3438. RpPhoneNumberToStash( pInfo );
  3439. if (PhoneNumberDlg(
  3440. pInfo->hwndRp,
  3441. pInfo->pArgs->fRouter,
  3442. pInfo->pListPhoneNumbers,
  3443. &pInfo->fPromoteHuntNumbers ))
  3444. {
  3445. TCHAR* pszPhoneNumber;
  3446. pszPhoneNumber = FirstPszFromList( pInfo->pListPhoneNumbers );
  3447. SetWindowText( pInfo->hwndEbNumber, pszPhoneNumber );
  3448. }
  3449. }
  3450. BOOL
  3451. RpCommand(
  3452. IN AIINFO* pInfo,
  3453. IN WORD wNotification,
  3454. IN WORD wId,
  3455. IN HWND hwndCtrl )
  3456. /* Called on WM_COMMAND. 'PInfo' is the dialog context. 'WNotification'
  3457. ** is the notification code of the command. 'wId' is the control/menu
  3458. ** identifier of the command. 'HwndCtrl' is the control window handle of
  3459. ** the command.
  3460. **
  3461. ** Returns true if processed message, false otherwise.
  3462. */
  3463. {
  3464. TRACE3("RpCommand(n=%d,i=%d,c=$%x)",
  3465. (DWORD)wNotification,(DWORD)wId,(ULONG_PTR )hwndCtrl);
  3466. switch (wId)
  3467. {
  3468. case CID_RP_PB_Alternates:
  3469. RpAlternates( pInfo );
  3470. return TRUE;
  3471. }
  3472. return FALSE;
  3473. }
  3474. BOOL
  3475. RpInit(
  3476. IN HWND hwndPage )
  3477. /* Called on WM_INITDIALOG. 'hwndPage' is the handle of the property
  3478. ** page.
  3479. **
  3480. ** Return false if focus was set, true otherwise.
  3481. */
  3482. {
  3483. AIINFO* pInfo;
  3484. TRACE("RpInit");
  3485. pInfo = AiContext( hwndPage );
  3486. if (!pInfo)
  3487. return TRUE;
  3488. /* Initialize page-specific context information.
  3489. */
  3490. pInfo->hwndRp = hwndPage;
  3491. pInfo->hwndStNumber = GetDlgItem( hwndPage, CID_RP_ST_Number );
  3492. ASSERT(pInfo->hwndStNumber);
  3493. pInfo->hwndEbNumber = GetDlgItem( hwndPage, CID_RP_EB_Number );
  3494. ASSERT(pInfo->hwndEbNumber);
  3495. pInfo->hwndPbAlternates = GetDlgItem( hwndPage, CID_RP_PB_Alternates );
  3496. ASSERT(pInfo->hwndPbAlternates);
  3497. /* Fill the phone number field from the stash created earlier.
  3498. */
  3499. Edit_LimitText( pInfo->hwndEbNumber, RAS_MaxPhoneNumber );
  3500. SetWindowText( pInfo->hwndEbNumber,
  3501. FirstPszFromList( pInfo->pListPhoneNumbers ) );
  3502. return FALSE;
  3503. }
  3504. BOOL
  3505. RpKillActive(
  3506. IN AIINFO* pInfo )
  3507. /* Called when PSN_KILLACTIVE is received. 'PInfo' is the wizard context.
  3508. **
  3509. ** Returns true if the page is invalid, false is it can be dismissed.
  3510. */
  3511. {
  3512. // pmay: 226610. Call RpPhoneNumberToStash if we were successfully
  3513. // activated.
  3514. /* Update the stashed phone number from the editbox.
  3515. */
  3516. if ( (! pInfo->pArgs->fNt4Router) &&
  3517. ( (pInfo->pArgs->pEntry->dwType == RASET_Vpn) ||
  3518. (pInfo->pArgs->pEntry->dwType == RASET_Broadband) ) //For whistler 349807
  3519. )
  3520. {
  3521. return FALSE;
  3522. }
  3523. RpPhoneNumberToStash( pInfo );
  3524. return FALSE;
  3525. }
  3526. VOID
  3527. RpPhoneNumberToStash(
  3528. IN AIINFO* pInfo )
  3529. /* Replace the first phone number in the stashed list with the contents of
  3530. ** the phone number field. 'pInfo' is the property sheet context.
  3531. */
  3532. {
  3533. DWORD dwErr;
  3534. TCHAR* pszPhoneNumber;
  3535. TRACE("RpPhoneNumberToStash");
  3536. pszPhoneNumber = GetText( pInfo->hwndEbNumber );
  3537. if (pszPhoneNumber)
  3538. {
  3539. dwErr = FirstPszToList( pInfo->pListPhoneNumbers, pszPhoneNumber );
  3540. Free( pszPhoneNumber );
  3541. }
  3542. else
  3543. dwErr = ERROR_NOT_ENOUGH_MEMORY;
  3544. if (dwErr != 0)
  3545. {
  3546. ErrorDlg( pInfo->hwndDlg, SID_OP_RetrievingData, dwErr, NULL );
  3547. AiExit( pInfo, dwErr );
  3548. }
  3549. }
  3550. BOOL
  3551. RpSetActive(
  3552. IN AIINFO* pInfo )
  3553. /* Called when PSN_SETACTIVE is received. 'PInfo' is the wizard context.
  3554. **
  3555. ** Returns true to display the page, false to skip it.
  3556. */
  3557. {
  3558. INT iSel;
  3559. DTLNODE* pNode;
  3560. DTLLIST* pList;
  3561. PBLINK* pLink;
  3562. if (! pInfo->pArgs->fNt4Router)
  3563. {
  3564. // If we're focused on an nt5 machine, then skip this page
  3565. // if the connection type is virtual because the phone number will
  3566. // be gotten from the vpn destination page.
  3567. if (pInfo->pArgs->pEntry->dwType == RASET_Vpn ||
  3568. pInfo->pArgs->pEntry->dwType == RASET_Broadband) //Add this for whistler 349087
  3569. {
  3570. return FALSE;
  3571. }
  3572. // pmay: 233287
  3573. //
  3574. // No phone number is requred if the device is dcc. Skip
  3575. // this page if that is the case.
  3576. //
  3577. pList = pInfo->pArgs->pEntry->pdtllistLinks;
  3578. ASSERT(pList);
  3579. pNode = (DTLNODE* )ListView_GetSelectedParamPtr( pInfo->hwndLv );
  3580. if (pNode)
  3581. {
  3582. // Single device selected. See if its dcc
  3583. pLink = (PBLINK* )DtlGetData( pNode );
  3584. if (pLink->pbport.dwType == RASET_Direct)
  3585. {
  3586. return FALSE;
  3587. }
  3588. }
  3589. }
  3590. // Instruct the wizard to use the destination editbox for the
  3591. // phone number of this connection
  3592. pInfo->hwndEbNumber = GetDlgItem(pInfo->hwndRp, CID_RP_EB_Number);
  3593. PropSheet_SetWizButtons( pInfo->hwndDlg, PSWIZB_BACK | PSWIZB_NEXT );
  3594. return TRUE;
  3595. }
  3596. /*----------------------------------------------------------------------------
  3597. ** Router welcome property page
  3598. ** Listed alphabetically following dialog proc
  3599. **----------------------------------------------------------------------------
  3600. */
  3601. INT_PTR CALLBACK
  3602. RwDlgProc(
  3603. IN HWND hwnd,
  3604. IN UINT unMsg,
  3605. IN WPARAM wparam,
  3606. IN LPARAM lparam )
  3607. /* DialogProc callback for the Router Welcome page of the wizard.
  3608. ** Parameters and return values are as described for standard windows
  3609. ** 'DialogProc's.
  3610. */
  3611. {
  3612. switch (unMsg)
  3613. {
  3614. case WM_INITDIALOG:
  3615. {
  3616. return
  3617. RwInit( hwnd, (EINFO* )(((PROPSHEETPAGE* )lparam)->lParam) );
  3618. }
  3619. case WM_NOTIFY:
  3620. {
  3621. switch (((NMHDR* )lparam)->code)
  3622. {
  3623. case PSN_RESET:
  3624. {
  3625. TRACE("RwRESET");
  3626. AiCancel( hwnd );
  3627. SetWindowLong( hwnd, DWLP_MSGRESULT, FALSE );
  3628. return TRUE;
  3629. }
  3630. case PSN_SETACTIVE:
  3631. {
  3632. AIINFO* pInfo;
  3633. BOOL fDisplay;
  3634. TRACE("RwSETACTIVE");
  3635. pInfo = AiContext( hwnd );
  3636. ASSERT(pInfo);
  3637. if (pInfo == NULL)
  3638. {
  3639. break;
  3640. }
  3641. fDisplay = RwSetActive( pInfo );
  3642. SetWindowLong( hwnd, DWLP_MSGRESULT, (fDisplay) ? 0 : -1 );
  3643. return TRUE;
  3644. }
  3645. case PSN_KILLACTIVE:
  3646. {
  3647. AIINFO* pInfo;
  3648. BOOL fInvalid;
  3649. TRACE("InKILLACTIVE");
  3650. pInfo = AiContext( hwnd );
  3651. ASSERT(pInfo);
  3652. if (pInfo == NULL)
  3653. {
  3654. break;
  3655. }
  3656. fInvalid = RwKillActive( pInfo );
  3657. SetWindowLong( hwnd, DWLP_MSGRESULT, fInvalid );
  3658. return TRUE;
  3659. }
  3660. case PSN_WIZFINISH:
  3661. {
  3662. AIINFO* pInfo;
  3663. TRACE("InWIZFINISH");
  3664. pInfo = AiContext( hwnd );
  3665. ASSERT(pInfo);
  3666. if (pInfo == NULL)
  3667. {
  3668. break;
  3669. }
  3670. /* You'd think pressing Finish would trigger a KILLACTIVE
  3671. ** event, but it doesn't, so we do it ourselves.
  3672. */
  3673. RwKillActive( pInfo );
  3674. /* Set "no wizard" user preference, per user's check.
  3675. */
  3676. pInfo->pArgs->pUser->fNewEntryWizard = FALSE;
  3677. pInfo->pArgs->pUser->fDirty = TRUE;
  3678. g_pSetUserPreferences(
  3679. NULL,
  3680. pInfo->pArgs->pUser,
  3681. pInfo->pArgs->fNoUser ? UPM_Logon : UPM_Normal );
  3682. pInfo->pArgs->fPadSelected = FALSE;
  3683. pInfo->pArgs->fChainPropertySheet = TRUE;
  3684. AiFinish( hwnd );
  3685. SetWindowLong( hwnd, DWLP_MSGRESULT, 0 );
  3686. return TRUE;
  3687. }
  3688. }
  3689. break;
  3690. }
  3691. case WM_DESTROY:
  3692. {
  3693. AiTerm( hwnd );
  3694. break;
  3695. }
  3696. }
  3697. return FALSE;
  3698. }
  3699. BOOL
  3700. RwInit(
  3701. IN HWND hwndPage,
  3702. IN OUT EINFO* pArgs )
  3703. /* Called on WM_INITDIALOG. 'hwndPage' is the handle of the property
  3704. ** page. 'PArgs' is the arguments from the PropertySheet caller.
  3705. **
  3706. ** Return false if focus was set, true otherwise.
  3707. */
  3708. {
  3709. DWORD dwErr;
  3710. AIINFO* pInfo;
  3711. TRACE("RwInit");
  3712. /* We're first page, so initialize the wizard.
  3713. */
  3714. pInfo = AiInit( hwndPage, pArgs );
  3715. if (!pInfo)
  3716. return TRUE;
  3717. /* Initialize page-specific context information.
  3718. */
  3719. pInfo->hwndRw = hwndPage;
  3720. pInfo->hwndRwStWelcome = GetDlgItem( hwndPage, CID_RW_ST_Welcome);
  3721. // Set up a bold font if we can.
  3722. //
  3723. if (pInfo->hBoldFont)
  3724. {
  3725. SendMessage(
  3726. pInfo->hwndRwStWelcome,
  3727. WM_SETFONT,
  3728. (WPARAM)pInfo->hBoldFont,
  3729. MAKELPARAM(TRUE, 0));
  3730. }
  3731. /* Create and display the wizard bitmap.
  3732. */
  3733. CreateWizardBitmap( hwndPage, TRUE );
  3734. return TRUE;
  3735. }
  3736. BOOL
  3737. RwKillActive(
  3738. IN AIINFO* pInfo )
  3739. /* Called when PSN_KILLACTIVE is received. 'PInfo' is the wizard context.
  3740. **
  3741. ** Returns true if the page is invalid, false is it can be dismissed.
  3742. */
  3743. {
  3744. return FALSE;
  3745. }
  3746. BOOL
  3747. RwSetActive(
  3748. IN AIINFO* pInfo )
  3749. /* Called when PSN_SETACTIVE is received. 'PInfo' is the wizard context.
  3750. **
  3751. ** Returns true to display the page, false to skip it.
  3752. */
  3753. {
  3754. PropSheet_SetWizButtons( pInfo->hwndDlg, PSWIZB_NEXT );
  3755. return TRUE;
  3756. }
  3757. INT_PTR CALLBACK
  3758. SrAddDlgProc(
  3759. IN HWND hwnd,
  3760. IN UINT unMsg,
  3761. IN WPARAM wparam,
  3762. IN LPARAM lparam )
  3763. {
  3764. AIINFO * pInfo;
  3765. switch (unMsg)
  3766. {
  3767. case WM_INITDIALOG:
  3768. {
  3769. pInfo = (AIINFO *)lparam;
  3770. //
  3771. //Set the ip addresses to "0.0.0.0"
  3772. //
  3773. pInfo->hwndDest = GetDlgItem(hwnd, CID_SR_Dest_Ip);
  3774. pInfo->hwndNetMask = GetDlgItem(hwnd, CID_SR_NetMask_Ip);
  3775. pInfo->hwndMetric = GetDlgItem(hwnd, CID_SR_Metric);
  3776. //
  3777. //Initialize Controls
  3778. //
  3779. SetWindowText( pInfo->hwndDest , EMPTY_IPADDRESS );
  3780. SetWindowText( pInfo->hwndNetMask , EMPTY_IPADDRESS );
  3781. SetWindowText( pInfo->hwndMetric , L"1" );
  3782. //
  3783. //Set text limit for metric control
  3784. //
  3785. SendMessage(pInfo->hwndMetric,
  3786. EM_LIMITTEXT,
  3787. 2,
  3788. 0
  3789. );
  3790. SetWindowLongPtr( hwnd, DWLP_USER, (ULONG_PTR )pInfo );
  3791. }
  3792. case WM_COMMAND:
  3793. {
  3794. //
  3795. //id is in loword of wparam and
  3796. //notification is in hiword of wparam
  3797. //
  3798. switch (LOWORD( wparam ))
  3799. {
  3800. case IDOK:
  3801. {
  3802. TCHAR * pszDest = NULL;
  3803. TCHAR * pszMask = NULL;
  3804. TCHAR * pszMetric = NULL;
  3805. SROUTEINFOLIST * pNode = NULL;
  3806. ULONG ulDestIP, ulMask;
  3807. pInfo = (AIINFO *)GetWindowLongPtr( hwnd, DWLP_USER);
  3808. pszDest = GetText( pInfo->hwndDest );
  3809. // For whistler 492089
  3810. if( NULL == pszDest )
  3811. {
  3812. break;
  3813. }
  3814. //
  3815. // Check to see if the ip,mask and metric
  3816. // are still empty.
  3817. //
  3818. pszMetric = GetText(pInfo->hwndMetric);
  3819. if( NULL == pszMetric )
  3820. {
  3821. Free( pszDest );
  3822. break;
  3823. }
  3824. if ( !lstrcmp ( pszMetric, L"0" ) )
  3825. {
  3826. MsgDlg( hwnd, SID_SR_MetricRequired, NULL );
  3827. Free(pszDest);
  3828. Free(pszMetric);
  3829. return TRUE;
  3830. }
  3831. pszMask = GetText( pInfo->hwndNetMask );
  3832. ulDestIP = inet_addrw(pszDest);
  3833. ulMask = inet_addrw(pszMask);
  3834. if ( ulDestIP != (ulMask & ulDestIP) )
  3835. {
  3836. MsgDlg( hwnd, SID_SR_InvalidMask, NULL );
  3837. Free(pszDest);
  3838. Free(pszMask);
  3839. Free(pszMetric);
  3840. return TRUE;
  3841. }
  3842. //
  3843. //Check to see if this entry has already been added
  3844. //
  3845. if ( AIInfoSRouteIsRouteinList(pInfo, pszDest, pszMask, pszMetric ) )
  3846. {
  3847. Free(pszDest);
  3848. Free(pszMask);
  3849. Free(pszMetric);
  3850. MsgDlg(hwnd, SID_SR_DuplicateRoute, NULL);
  3851. return TRUE;
  3852. }
  3853. AIInfoSRouteCreateEntry(pInfo, pszDest, pszMask, pszMetric );
  3854. Free(pszDest);
  3855. Free(pszMask);
  3856. Free(pszMetric);
  3857. }
  3858. // ...fall thru...
  3859. case IDCANCEL:
  3860. {
  3861. EndDialog( hwnd, TRUE );
  3862. return TRUE;
  3863. }
  3864. }
  3865. }
  3866. }
  3867. return FALSE;
  3868. }
  3869. DWORD
  3870. SrRefresSRouteList(
  3871. IN AIINFO * pInfo
  3872. )
  3873. {
  3874. DWORD dwRetCode = ERROR_SUCCESS;
  3875. SROUTEINFOLIST * pNode = AiInfoSRouteGetFirstNode(pInfo);
  3876. LVITEM lvItem;
  3877. SHORT nIndex = 0;
  3878. ListView_DeleteAllItems (pInfo->hwndLvStaticRoutes);
  3879. while ( pNode )
  3880. {
  3881. ZeroMemory(&lvItem, sizeof(lvItem));
  3882. lvItem.iItem = nIndex;
  3883. lvItem.mask = LVIF_TEXT | LVIF_STATE | LVIF_PARAM;
  3884. lvItem.lParam = (LPARAM)pNode;
  3885. lvItem.pszText = pNode->RouteInfo.pszDestIP;
  3886. ListView_InsertItem(pInfo->hwndLvStaticRoutes, &lvItem );
  3887. ListView_SetItemText( pInfo->hwndLvStaticRoutes,
  3888. nIndex,
  3889. 1,
  3890. pNode->RouteInfo.pszNetworkMask
  3891. );
  3892. ListView_SetItemText( pInfo->hwndLvStaticRoutes,
  3893. nIndex,
  3894. 2,
  3895. pNode->RouteInfo.pszMetric
  3896. );
  3897. pNode = AiInfoSRouteGetNextNode(pNode);
  3898. nIndex++;
  3899. }
  3900. SrLvItemChanged(pInfo);
  3901. return dwRetCode;
  3902. }
  3903. void SrRemoveRoute (AIINFO * pInfo)
  3904. {
  3905. int nSelIndex = -1;
  3906. SROUTEINFOLIST * pNode = NULL;
  3907. LVITEM lvItem;
  3908. nSelIndex = ListView_GetNextItem(
  3909. pInfo->hwndLvStaticRoutes,
  3910. -1,
  3911. LVNI_SELECTED
  3912. );
  3913. //
  3914. //Check to see if any items are selected
  3915. //
  3916. if ( nSelIndex == -1 )
  3917. return;
  3918. //
  3919. //Now delete the entry from list box and from the list
  3920. //
  3921. ZeroMemory( &lvItem, sizeof(lvItem) );
  3922. lvItem.mask = LVIF_PARAM;
  3923. lvItem.iItem = nSelIndex;
  3924. ListView_GetItem(pInfo->hwndLvStaticRoutes, &lvItem);
  3925. pNode = (SROUTEINFOLIST *)lvItem.lParam;
  3926. AIInfoRemoveSRouteNode ( pInfo, pNode );
  3927. SrRefresSRouteList ( pInfo );
  3928. }
  3929. /*------------------------------------------------------------------------
  3930. ** Static Routes property page
  3931. **
  3932. **------------------------------------------------------------------------
  3933. */
  3934. BOOL
  3935. SrCommand(
  3936. IN AIINFO* pInfo,
  3937. IN WORD wNotification,
  3938. IN WORD wId,
  3939. IN HWND hwndCtrl )
  3940. {
  3941. INT_PTR nStatus;
  3942. TRACE( "SrCommand" );
  3943. switch (wId)
  3944. {
  3945. case CID_SR_PB_Add:
  3946. //
  3947. //Show the dialog here to add a new
  3948. //static route
  3949. //
  3950. nStatus =
  3951. (BOOL )DialogBoxParam(
  3952. g_hinstDll,
  3953. MAKEINTRESOURCE( DID_SR_StaticRoute ),
  3954. pInfo->hwndSr,
  3955. SrAddDlgProc,
  3956. (LPARAM )pInfo );
  3957. SrRefresSRouteList(pInfo);
  3958. return TRUE;
  3959. case CID_SR_PB_Remove:
  3960. //
  3961. //Check to see if we have any items selected.
  3962. //
  3963. SrRemoveRoute ( pInfo );
  3964. return TRUE;
  3965. }
  3966. return FALSE;
  3967. }
  3968. INT_PTR CALLBACK
  3969. SrDlgProc(
  3970. IN HWND hwnd,
  3971. IN UINT unMsg,
  3972. IN WPARAM wparam,
  3973. IN LPARAM lparam )
  3974. {
  3975. switch (unMsg)
  3976. {
  3977. case WM_INITDIALOG:
  3978. return SrInit( hwnd );
  3979. case WM_NOTIFY:
  3980. {
  3981. switch (((NMHDR* )lparam)->code)
  3982. {
  3983. case PSN_SETACTIVE:
  3984. {
  3985. AIINFO* pInfo;
  3986. BOOL fDisplay;
  3987. TRACE("SrSETACTIVE");
  3988. pInfo = AiContext( hwnd );
  3989. ASSERT(pInfo);
  3990. if (pInfo == NULL)
  3991. {
  3992. break;
  3993. }
  3994. fDisplay = SrSetActive( pInfo );
  3995. SetWindowLong( hwnd, DWLP_MSGRESULT, (fDisplay) ? 0 : -1 );
  3996. return TRUE;
  3997. }
  3998. case PSN_KILLACTIVE:
  3999. {
  4000. AIINFO* pInfo;
  4001. BOOL fInvalid;
  4002. TRACE("SrKILLACTIVE");
  4003. pInfo = AiContext( hwnd );
  4004. ASSERT(pInfo);
  4005. if (pInfo == NULL)
  4006. {
  4007. break;
  4008. }
  4009. fInvalid = SrKillActive( pInfo );
  4010. SetWindowLong( hwnd, DWLP_MSGRESULT, fInvalid );
  4011. return TRUE;
  4012. }
  4013. case LVN_ITEMCHANGED:
  4014. {
  4015. AIINFO* pInfo;
  4016. pInfo = AiContext( hwnd );
  4017. ASSERT(pInfo);
  4018. SrLvItemChanged( pInfo );
  4019. return TRUE;
  4020. }
  4021. }
  4022. break;
  4023. }
  4024. case WM_COMMAND:
  4025. {
  4026. AIINFO* pInfo = AiContext( hwnd );
  4027. ASSERT(pInfo);
  4028. if (pInfo == NULL)
  4029. {
  4030. break;
  4031. }
  4032. return SrCommand(
  4033. pInfo, HIWORD( wparam ), LOWORD( wparam ), (HWND )lparam );
  4034. }
  4035. }
  4036. return FALSE;
  4037. }
  4038. VOID
  4039. SrLvItemChanged(
  4040. IN AIINFO* pInfo )
  4041. {
  4042. HWND hwnd;
  4043. int nSelIndex;
  4044. hwnd = GetDlgItem(pInfo->hwndSr, CID_SR_PB_Remove);
  4045. if(hwnd){
  4046. nSelIndex = ListView_GetNextItem(
  4047. pInfo->hwndLvStaticRoutes,
  4048. -1,
  4049. LVNI_SELECTED);
  4050. if(nSelIndex == -1){
  4051. //Disable the remove button
  4052. EnableWindow(hwnd, FALSE);
  4053. }
  4054. else {
  4055. //Enable remove button
  4056. EnableWindow(hwnd, TRUE);
  4057. }
  4058. }
  4059. }
  4060. BOOL
  4061. SrInit(
  4062. IN HWND hwndPage )
  4063. {
  4064. AIINFO* pInfo;
  4065. HWND hwnd;
  4066. TRACE("SrInit");
  4067. pInfo = AiContext( hwndPage );
  4068. if (!pInfo)
  4069. return TRUE;
  4070. //Disable the Remove button
  4071. hwnd = GetDlgItem(hwndPage, CID_SR_PB_Remove);
  4072. if(hwnd){
  4073. EnableWindow(hwnd, FALSE);
  4074. }
  4075. /* Initialize page-specific context information.
  4076. */
  4077. pInfo->hwndSr = hwndPage;
  4078. pInfo->hwndLvStaticRoutes = GetDlgItem(hwndPage, CID_SR_LV_StaticRoutes );
  4079. ListView_SetExtendedListViewStyle( pInfo->hwndLvStaticRoutes,
  4080. ListView_GetExtendedListViewStyle(pInfo->hwndLvStaticRoutes)
  4081. | LVS_EX_FULLROWSELECT
  4082. );
  4083. //
  4084. // Add columns.
  4085. //
  4086. {
  4087. LV_COLUMN col;
  4088. TCHAR* pszHeader0 = NULL;
  4089. TCHAR* pszHeader1 = NULL;
  4090. TCHAR* pszHeader2 = NULL;
  4091. RECT rc;
  4092. LONG lColWidth;
  4093. pszHeader0 = PszFromId( g_hinstDll, SID_SR_Destination );
  4094. pszHeader1 = PszFromId( g_hinstDll, SID_SR_Netmask );
  4095. pszHeader2 = PszFromId( g_hinstDll, SID_SR_Metric );
  4096. ZeroMemory( &col, sizeof(col) );
  4097. col.mask = LVCF_FMT + LVCF_TEXT + LVCF_SUBITEM;
  4098. col.fmt = LVCFMT_LEFT;
  4099. col.pszText = (pszHeader0) ? pszHeader0 : TEXT("");
  4100. ListView_InsertColumn( pInfo->hwndLvStaticRoutes, 0, &col );
  4101. ZeroMemory( &col, sizeof(col) );
  4102. col.mask = LVCF_FMT + LVCF_SUBITEM + LVCF_TEXT;
  4103. col.fmt = LVCFMT_LEFT;
  4104. col.pszText = (pszHeader1) ? pszHeader1 : TEXT("");
  4105. col.iSubItem = 1;
  4106. ListView_InsertColumn( pInfo->hwndLvStaticRoutes, 1, &col );
  4107. ZeroMemory( &col, sizeof(col) );
  4108. col.mask = LVCF_FMT + LVCF_SUBITEM + LVCF_TEXT ;
  4109. col.fmt = LVCFMT_LEFT;
  4110. col.pszText = (pszHeader2) ? pszHeader2 : TEXT("");
  4111. col.iSubItem = 2;
  4112. ListView_InsertColumn( pInfo->hwndLvStaticRoutes, 2, &col );
  4113. //
  4114. //Now Set the column headers
  4115. //
  4116. Free0( pszHeader0 );
  4117. Free0( pszHeader1 );
  4118. Free0( pszHeader2 );
  4119. //
  4120. //Set column width
  4121. //
  4122. GetClientRect(pInfo->hwndLvStaticRoutes, &rc);
  4123. lColWidth = ( rc.right - rc.left ) / 3;
  4124. ListView_SetColumnWidth ( pInfo->hwndLvStaticRoutes,
  4125. 0,
  4126. lColWidth
  4127. );
  4128. ListView_SetColumnWidth ( pInfo->hwndLvStaticRoutes,
  4129. 1,
  4130. lColWidth
  4131. );
  4132. ListView_SetColumnWidth ( pInfo->hwndLvStaticRoutes,
  4133. 2,
  4134. lColWidth
  4135. );
  4136. }
  4137. // for whistler DCR 524304 gangz
  4138. PropSheet_SetWizButtons( pInfo->hwndSr, PSWIZB_BACK | PSWIZB_NEXT );
  4139. return TRUE;
  4140. }
  4141. BOOL
  4142. SrKillActive(
  4143. IN AIINFO* pInfo )
  4144. {
  4145. return FALSE;
  4146. }
  4147. BOOL
  4148. SrSetActive(
  4149. IN AIINFO* pInfo )
  4150. {
  4151. BOOL fDisplay = FALSE;
  4152. if (pInfo->fIp)
  4153. {
  4154. //
  4155. //Check to see if there are existing routes.
  4156. //If so, add them to the list.
  4157. //
  4158. SrRefresSRouteList(pInfo);
  4159. fDisplay = TRUE;
  4160. }
  4161. else
  4162. {
  4163. fDisplay = FALSE;
  4164. }
  4165. // for whistler DCR 524304 gangz
  4166. PropSheet_SetWizButtons( pInfo->hwndSr, PSWIZB_BACK | PSWIZB_NEXT );
  4167. // Won't show this for NAT path
  4168. //
  4169. if( RASEDFLAG_NAT & pInfo->pArgs->pApiArgs->dwFlags )
  4170. {
  4171. // Add a default static route
  4172. TCHAR pszDest[] = TEXT("0.0.0.0");
  4173. TCHAR pszMask[] = TEXT("0.0.0.0");
  4174. TCHAR pszMetric[] = TEXT("1");
  4175. if ( !AIInfoSRouteIsRouteinList(pInfo, pszDest, pszMask, pszMetric ) )
  4176. {
  4177. AIInfoSRouteCreateEntry(pInfo, pszDest, pszMask, pszMetric );
  4178. }
  4179. //Return No Display flag
  4180. fDisplay = FALSE;
  4181. }
  4182. return fDisplay;
  4183. }
  4184. /*----------------------------------------------------------------------------
  4185. ** Server settings property page
  4186. ** Listed alphabetically following dialog proc
  4187. **----------------------------------------------------------------------------
  4188. */
  4189. INT_PTR CALLBACK
  4190. SsDlgProc(
  4191. IN HWND hwnd,
  4192. IN UINT unMsg,
  4193. IN WPARAM wparam,
  4194. IN LPARAM lparam )
  4195. /* DialogProc callback for the 5 checkboxes page of the wizard.
  4196. ** Parameters and return value are as described for standard windows
  4197. ** 'DialogProc's.
  4198. */
  4199. {
  4200. #if 0
  4201. TRACE4("SsDlgProc(h=$%x,m=$%x,w=$%x,l=$%x)",
  4202. (DWORD)hwnd,(DWORD)unMsg,(DWORD)wparam,(DWORD)lparam);
  4203. #endif
  4204. switch (unMsg)
  4205. {
  4206. case WM_INITDIALOG:
  4207. return SsInit( hwnd );
  4208. case WM_NOTIFY:
  4209. {
  4210. switch (((NMHDR* )lparam)->code)
  4211. {
  4212. case PSN_SETACTIVE:
  4213. {
  4214. AIINFO* pInfo;
  4215. BOOL fDisplay;
  4216. TRACE("SsSETACTIVE");
  4217. pInfo = AiContext( hwnd );
  4218. ASSERT(pInfo);
  4219. if (pInfo == NULL)
  4220. {
  4221. break;
  4222. }
  4223. fDisplay = SsSetActive( pInfo );
  4224. SetWindowLong( hwnd, DWLP_MSGRESULT, (fDisplay) ? 0 : -1 );
  4225. return TRUE;
  4226. }
  4227. case PSN_KILLACTIVE:
  4228. {
  4229. AIINFO* pInfo;
  4230. BOOL fInvalid;
  4231. TRACE("SsKILLACTIVE");
  4232. pInfo = AiContext( hwnd );
  4233. ASSERT(pInfo);
  4234. if (pInfo == NULL)
  4235. {
  4236. break;
  4237. }
  4238. fInvalid = SsKillActive( pInfo );
  4239. SetWindowLong( hwnd, DWLP_MSGRESULT, fInvalid );
  4240. return TRUE;
  4241. }
  4242. }
  4243. break;
  4244. }
  4245. case WM_COMMAND:
  4246. {
  4247. AIINFO* pInfo = AiContext( hwnd );
  4248. ASSERT(pInfo);
  4249. if (pInfo == NULL)
  4250. {
  4251. break;
  4252. }
  4253. return SsCommand(
  4254. pInfo, HIWORD( wparam ), LOWORD( wparam ), (HWND )lparam );
  4255. }
  4256. }
  4257. return FALSE;
  4258. }
  4259. BOOL
  4260. SsCommand(
  4261. IN AIINFO* pInfo,
  4262. IN WORD wNotification,
  4263. IN WORD wId,
  4264. IN HWND hwndCtrl )
  4265. /* Called on WM_COMMAND. 'PInfo' is the dialog context. 'WNotification'
  4266. ** is the notification code of the command. 'wId' is the control/menu
  4267. ** identifier of the command. 'HwndCtrl' is the control window handle of
  4268. ** the command.
  4269. **
  4270. ** Returns true if processed message, false otherwise.
  4271. */
  4272. {
  4273. TRACE3("SsCommand(n=%d,i=%d,c=$%x)",
  4274. (DWORD)wNotification,(DWORD)wId,(ULONG_PTR )hwndCtrl);
  4275. switch (wId)
  4276. {
  4277. case CID_SS_CB_AddUser:
  4278. return TRUE;
  4279. }
  4280. return FALSE;
  4281. }
  4282. BOOL
  4283. SsInit(
  4284. IN HWND hwndPage )
  4285. /* Called on WM_INITDIALOG. 'hwndPage' is the handle of the property
  4286. ** page.
  4287. **
  4288. ** Return false if focus was set, true otherwise.
  4289. */
  4290. {
  4291. AIINFO* pInfo;
  4292. TRACE("SsInit");
  4293. pInfo = AiContext( hwndPage );
  4294. if (!pInfo)
  4295. return TRUE;
  4296. /* Initialize page-specific context information.
  4297. */
  4298. pInfo->hwndSs = hwndPage;
  4299. if (pInfo->fIpConfigured)
  4300. CheckDlgButton( hwndPage, CID_SS_CB_RouteIp, BST_CHECKED );
  4301. //for whistler bug 213901
  4302. //Hide the IPX checkbox
  4303. //move other check boxes to cover the hole made by hiding
  4304. // For .Net server bug 605988 remove IPX for all versions
  4305. return FALSE;
  4306. }
  4307. BOOL
  4308. SsKillActive(
  4309. IN AIINFO* pInfo )
  4310. /* Called when PSN_KILLACTIVE is received. 'PInfo' is the wizard context.
  4311. **
  4312. ** Returns true if the page is invalid, false is it can be dismissed.
  4313. */
  4314. {
  4315. pInfo->fIp =
  4316. IsDlgButtonChecked( pInfo->hwndSs, CID_SS_CB_RouteIp );
  4317. //for whistler bug 213901, .Net 605988, remove IPX
  4318. //
  4319. pInfo->fIpx = FALSE;
  4320. pInfo->pArgs->fAddUser =
  4321. IsDlgButtonChecked( pInfo->hwndSs, CID_SS_CB_AddUser );
  4322. pInfo->pArgs->pEntry->fAuthenticateServer = FALSE;
  4323. pInfo->fClearPwOk =
  4324. IsDlgButtonChecked( pInfo->hwndSs, CID_SS_CB_PlainPw );
  4325. pInfo->fNotNt =
  4326. IsDlgButtonChecked( pInfo->hwndSs, CID_SS_CB_NotNt );
  4327. if (pInfo->fIp && !pInfo->fIpConfigured)
  4328. {
  4329. MsgDlg( pInfo->hwndDlg, SID_ConfigureIp, NULL );
  4330. SetFocus( GetDlgItem( pInfo->hwndSs, CID_SS_CB_RouteIp) );
  4331. return TRUE;
  4332. }
  4333. return FALSE;
  4334. }
  4335. BOOL
  4336. SsSetActive(
  4337. IN AIINFO* pInfo )
  4338. /* Called when PSN_SETACTIVE is received. 'PInfo' is the wizard context.
  4339. **
  4340. ** Returns true to display the page, false to skip it.
  4341. */
  4342. {
  4343. HWND hwndScript = GetDlgItem( pInfo->hwndSs, CID_SS_CB_NotNt );
  4344. HWND hwndPw = GetDlgItem( pInfo->hwndSs, CID_SS_CB_PlainPw );
  4345. HWND hwndUser = GetDlgItem( pInfo->hwndSs, CID_SS_CB_AddUser );
  4346. //
  4347. // We only allow interactive scripting on modem devices
  4348. //
  4349. // (pmay: 378432. Same for PAP/SPAP)
  4350. //
  4351. if ( pInfo->pArgs->pEntry->dwType == RASET_Vpn )
  4352. {
  4353. Button_SetCheck( hwndScript, FALSE );
  4354. Button_SetCheck( hwndPw, FALSE );
  4355. EnableWindow( hwndScript, FALSE );
  4356. EnableWindow( hwndPw, FALSE );
  4357. }
  4358. else
  4359. {
  4360. EnableWindow( hwndScript, TRUE );
  4361. EnableWindow( hwndPw, TRUE );
  4362. }
  4363. //For PPPoE dont add a dial-in user account whistler 345068 349087 gangz
  4364. //
  4365. // For whistler bug 522292, Enable the AddUser check box if it is not a
  4366. // PPPoE connections
  4367. //
  4368. if (hwndUser)
  4369. {
  4370. Button_SetCheck( hwndUser, FALSE );
  4371. if ( RASET_Broadband == pInfo->pArgs->pEntry->dwType )
  4372. {
  4373. EnableWindow( hwndUser, FALSE);
  4374. }
  4375. else
  4376. {
  4377. //For whistler bug 522292
  4378. EnableWindow( hwndUser, TRUE);
  4379. }
  4380. }
  4381. PropSheet_SetWizButtons( pInfo->hwndDlg, PSWIZB_BACK | PSWIZB_NEXT );
  4382. return TRUE;
  4383. }
  4384. /*----------------------------------------------------------------------------
  4385. ** Vpn destination property page
  4386. ** Listed alphabetically following dialog proc
  4387. **----------------------------------------------------------------------------
  4388. */
  4389. INT_PTR CALLBACK
  4390. VdDlgProc(
  4391. IN HWND hwnd,
  4392. IN UINT unMsg,
  4393. IN WPARAM wparam,
  4394. IN LPARAM lparam )
  4395. /* DialogProc callback for the vpn destination page of the wizard.
  4396. ** Parameters and return value are as described for standard windows
  4397. ** 'DialogProc's.
  4398. */
  4399. {
  4400. switch (unMsg)
  4401. {
  4402. case WM_INITDIALOG:
  4403. return VdInit( hwnd );
  4404. case WM_NOTIFY:
  4405. {
  4406. switch (((NMHDR* )lparam)->code)
  4407. {
  4408. case PSN_SETACTIVE:
  4409. {
  4410. AIINFO* pInfo;
  4411. BOOL fDisplay;
  4412. TRACE("VdSETACTIVE");
  4413. pInfo = AiContext( hwnd );
  4414. ASSERT(pInfo);
  4415. if (pInfo == NULL)
  4416. {
  4417. break;
  4418. }
  4419. fDisplay = VdSetActive( pInfo );
  4420. SetWindowLong( hwnd, DWLP_MSGRESULT, (fDisplay) ? 0 : -1 );
  4421. return TRUE;
  4422. }
  4423. case PSN_KILLACTIVE:
  4424. {
  4425. AIINFO* pInfo;
  4426. BOOL fInvalid;
  4427. TRACE("VdKILLACTIVE");
  4428. pInfo = AiContext( hwnd );
  4429. ASSERT(pInfo);
  4430. if (pInfo == NULL)
  4431. {
  4432. break;
  4433. }
  4434. fInvalid = VdKillActive( pInfo );
  4435. SetWindowLong( hwnd, DWLP_MSGRESULT, fInvalid );
  4436. return TRUE;
  4437. }
  4438. }
  4439. break;
  4440. }
  4441. }
  4442. return FALSE;
  4443. }
  4444. BOOL
  4445. VdInit(
  4446. IN HWND hwndPage )
  4447. /* Called on WM_INITDIALOG. 'hwndPage' is the handle of the property
  4448. ** page.
  4449. **
  4450. ** Return false if focus was set, true otherwise.
  4451. */
  4452. {
  4453. DWORD dwErr;
  4454. AIINFO* pInfo = NULL;
  4455. PBENTRY* pEntry;
  4456. TRACE("InInit");
  4457. // Get the context of this page
  4458. pInfo = AiContext( hwndPage );
  4459. ASSERT ( pInfo );
  4460. // Set up the interface name stuff
  4461. //
  4462. //For prefix bug 226336 to validate the pInfo gangz
  4463. //
  4464. if(pInfo)
  4465. {
  4466. pInfo->hwndEbNumber =
  4467. GetDlgItem( hwndPage, CID_VD_EB_NameOrAddress );
  4468. // ASSERT(pInfo->hwndEbInterfaceName);
  4469. ASSERT(pInfo->hwndEbNumber);
  4470. Edit_LimitText( pInfo->hwndEbNumber, RAS_MaxPhoneNumber );
  4471. SetWindowText( pInfo->hwndEbNumber,
  4472. FirstPszFromList( pInfo->pListPhoneNumbers ) );
  4473. /* Initialize page-specific context information.
  4474. */
  4475. pInfo->hwndVd = hwndPage;
  4476. return TRUE;
  4477. }
  4478. else
  4479. {
  4480. return FALSE;
  4481. }
  4482. }
  4483. BOOL
  4484. VdKillActive(
  4485. IN AIINFO* pInfo )
  4486. /* Called when PSN_KILLACTIVE is received. 'PInfo' is the wizard context.
  4487. **
  4488. ** Returns true if the page is invalid, false is it can be dismissed.
  4489. */
  4490. {
  4491. // pmay: 226610. Call RpPhoneNumberToStash if we were successfully
  4492. // activated.
  4493. // If we're focused on an nt4 box, then this page is
  4494. // invalid (pptp was the only type)
  4495. if ( pInfo->pArgs->fNt4Router )
  4496. {
  4497. return FALSE;
  4498. }
  4499. // If we have no tunnel devices, then this page is invalid
  4500. else if ( ! (pInfo->dwFlags & AI_F_HasTunlDevs) )
  4501. {
  4502. return FALSE;
  4503. }
  4504. // If the connection type is not virtual, skip this page since the
  4505. // destination will be gotten from the phone number/PPPoE page.
  4506. if ( pInfo->pArgs->pEntry->dwType != RASET_Vpn )
  4507. {
  4508. return FALSE;
  4509. }
  4510. RpPhoneNumberToStash(pInfo);
  4511. return FALSE;
  4512. }
  4513. BOOL
  4514. VdSetActive(
  4515. IN AIINFO* pInfo )
  4516. /* Called when PSN_SETACTIVE is received. 'PInfo' is the wizard context.
  4517. **
  4518. ** Returns true to display the page, false to skip it.
  4519. */
  4520. {
  4521. // If we're focused on an nt4 box, then this page is
  4522. // invalid (pptp was the only type)
  4523. if ( pInfo->pArgs->fNt4Router )
  4524. {
  4525. return FALSE;
  4526. }
  4527. // If we have no tunnel devices, then this page is invalid
  4528. else if ( ! (pInfo->dwFlags & AI_F_HasTunlDevs) )
  4529. {
  4530. return FALSE;
  4531. }
  4532. // If the connection type is not virtual, skip this page since the
  4533. // destination will be gotten from the phone number page.
  4534. if ( pInfo->pArgs->pEntry->dwType != RASET_Vpn )
  4535. {
  4536. return FALSE;
  4537. }
  4538. // Instruct the wizard to use the destination editbox for the
  4539. // phone number of this connection
  4540. pInfo->hwndEbNumber = GetDlgItem(pInfo->hwndVd, CID_VD_EB_NameOrAddress);
  4541. PropSheet_SetWizButtons( pInfo->hwndDlg, PSWIZB_BACK | PSWIZB_NEXT );
  4542. return TRUE;
  4543. }
  4544. /*----------------------------------------------------------------------------
  4545. ** Vpn type property page
  4546. ** Listed alphabetically following dialog proc
  4547. **----------------------------------------------------------------------------
  4548. */
  4549. INT_PTR CALLBACK
  4550. VtDlgProc(
  4551. IN HWND hwnd,
  4552. IN UINT unMsg,
  4553. IN WPARAM wparam,
  4554. IN LPARAM lparam )
  4555. /* DialogProc callback for the vpn type page of the wizard.
  4556. ** Parameters and return value are as described for standard windows
  4557. ** 'DialogProc's.
  4558. */
  4559. {
  4560. switch (unMsg)
  4561. {
  4562. case WM_INITDIALOG:
  4563. return VtInit( hwnd );
  4564. case WM_NOTIFY:
  4565. {
  4566. switch (((NMHDR* )lparam)->code)
  4567. {
  4568. case PSN_SETACTIVE:
  4569. {
  4570. AIINFO* pInfo;
  4571. BOOL fDisplay;
  4572. TRACE("VtSETACTIVE");
  4573. pInfo = AiContext( hwnd );
  4574. ASSERT(pInfo);
  4575. if (pInfo == NULL)
  4576. {
  4577. break;
  4578. }
  4579. fDisplay = VtSetActive( pInfo );
  4580. SetWindowLong( hwnd, DWLP_MSGRESULT, (fDisplay) ? 0 : -1 );
  4581. return TRUE;
  4582. }
  4583. case PSN_KILLACTIVE:
  4584. {
  4585. AIINFO* pInfo;
  4586. BOOL fInvalid;
  4587. TRACE("VtKILLACTIVE");
  4588. pInfo = AiContext( hwnd );
  4589. ASSERT(pInfo);
  4590. if (pInfo == NULL)
  4591. {
  4592. break;
  4593. }
  4594. fInvalid = VtKillActive( pInfo );
  4595. SetWindowLong( hwnd, DWLP_MSGRESULT, fInvalid );
  4596. return TRUE;
  4597. }
  4598. }
  4599. break;
  4600. }
  4601. }
  4602. return FALSE;
  4603. }
  4604. BOOL
  4605. VtInit(
  4606. IN HWND hwndPage )
  4607. /* Called on WM_INITDIALOG. 'hwndPage' is the handle of the property
  4608. ** page.
  4609. **
  4610. ** Return false if focus was set, true otherwise.
  4611. */
  4612. {
  4613. AIINFO * pInfo;
  4614. // Get the context
  4615. pInfo = AiContext( hwndPage );
  4616. ASSERT ( pInfo );
  4617. if (pInfo == NULL)
  4618. {
  4619. return FALSE;
  4620. }
  4621. // Initialize the checks
  4622. pInfo->hwndVtRbAutomatic = GetDlgItem( hwndPage, CID_VT_RB_Automatic );
  4623. pInfo->hwndVtRbPptp = GetDlgItem( hwndPage, CID_VT_RB_Pptp );
  4624. pInfo->hwndVtRbL2tp = GetDlgItem( hwndPage, CID_VT_RB_L2tp );
  4625. ASSERT( pInfo->hwndVtRbAutomatic );
  4626. ASSERT( pInfo->hwndVtRbPptp );
  4627. ASSERT( pInfo->hwndVtRbL2tp );
  4628. // Default to automatic
  4629. Button_SetCheck( pInfo->hwndVtRbAutomatic, TRUE );
  4630. return FALSE;
  4631. }
  4632. BOOL
  4633. VtKillActive(
  4634. IN AIINFO* pInfo )
  4635. /* Called when PSN_KILLACTIVE is received. 'PInfo' is the wizard context.
  4636. **
  4637. ** Returns true if the page is invalid, false is it can be dismissed.
  4638. */
  4639. {
  4640. if ( Button_GetCheck( pInfo->hwndVtRbAutomatic ) )
  4641. {
  4642. pInfo->dwVpnStrategy = VS_Default;
  4643. }
  4644. else if ( Button_GetCheck( pInfo->hwndVtRbPptp ) )
  4645. {
  4646. pInfo->dwVpnStrategy = VS_PptpOnly;
  4647. }
  4648. else if ( Button_GetCheck( pInfo->hwndVtRbL2tp ) )
  4649. {
  4650. pInfo->dwVpnStrategy = VS_L2tpOnly;
  4651. }
  4652. return FALSE;
  4653. }
  4654. BOOL
  4655. VtSetActive(
  4656. IN AIINFO* pInfo )
  4657. /* Called when PSN_SETACTIVE is received. 'PInfo' is the wizard context.
  4658. **
  4659. ** Returns true to display the page, false to skip it.
  4660. */
  4661. {
  4662. // If we're focused on an nt4 box, then this page is
  4663. // invalid (pptp was the only type)
  4664. if ( pInfo->pArgs->fNt4Router )
  4665. {
  4666. return FALSE;
  4667. }
  4668. // If we have no tunnel devices, then this page is invalid
  4669. else if ( ! (pInfo->dwFlags & AI_F_HasTunlDevs) )
  4670. {
  4671. return FALSE;
  4672. }
  4673. // If the connection type is not virtual, skip this page since the
  4674. // destination will be gotten from the phone number page.
  4675. if ( pInfo->pArgs->pEntry->dwType != RASET_Vpn )
  4676. {
  4677. return FALSE;
  4678. }
  4679. PropSheet_SetWizButtons( pInfo->hwndDlg, PSWIZB_BACK | PSWIZB_NEXT );
  4680. return TRUE;
  4681. }