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.

5926 lines
152 KiB

  1. // Copyright (c) 1995, Microsoft Corporation, all rights reserved
  2. //
  3. // entryw.c
  4. // Remote Access Common Dialog APIs
  5. // Add Entry wizard
  6. //
  7. // 06/20/95 Steve Cobb
  8. // 11/10/97 Shaun Cox, NT5/Connections rework
  9. #include "rasdlgp.h"
  10. #include "inetcfgp.h"
  11. #include "netcon.h"
  12. #include "rasuip.h"
  13. #include "rassrvp.h"
  14. #include <winscard.h>
  15. #include "hnportmapping.h"
  16. #include <wchar.h>
  17. static int MAX_ENTERCONNECTIONNAME = 200;
  18. DWORD
  19. OpenPhonebookFile(
  20. BOOL fForAllUsers,
  21. PBFILE* pFile )
  22. {
  23. TCHAR pszPhonebookPath [MAX_PATH];
  24. pszPhonebookPath[0] = TEXT('\0');
  25. // Get the correct phonebook file path depending on whether it is
  26. // for all users or the current one.
  27. //
  28. if (fForAllUsers)
  29. {
  30. if(!GetPublicPhonebookPath( pszPhonebookPath ))
  31. {
  32. return ERROR_CANNOT_OPEN_PHONEBOOK;
  33. }
  34. }
  35. else
  36. {
  37. if(!GetPersonalPhonebookPath( NULL, pszPhonebookPath ))
  38. {
  39. return ERROR_CANNOT_OPEN_PHONEBOOK;
  40. }
  41. }
  42. return ReadPhonebookFile( pszPhonebookPath, NULL, NULL, 0, pFile );
  43. }
  44. VOID
  45. ReOpenPhonebookFile(
  46. BOOL fForAllUsers,
  47. PBFILE* pFile )
  48. {
  49. // Close the previous phonebook file.
  50. //
  51. if (pFile)
  52. {
  53. ClosePhonebookFile( pFile );
  54. }
  55. // Open the one corresponding to the selection.
  56. //
  57. OpenPhonebookFile( fForAllUsers, pFile );
  58. }
  59. //----------------------------------------------------------------------------
  60. // Local datatypes (alphabetically)
  61. //----------------------------------------------------------------------------
  62. // Add Entry wizard context block. All property pages refer to the single
  63. // context block associated with the sheet.
  64. //
  65. typedef struct
  66. _AEINFO
  67. {
  68. // Common input arguments.
  69. //
  70. EINFO* pArgs;
  71. // Wizard and page handles.
  72. //
  73. HWND hwndDlg;
  74. HWND hwndLa;
  75. HWND hwndMa;
  76. HWND hwndCn; //Add for bug 328673
  77. HWND hwndPa;
  78. HWND hwndBs;
  79. HWND hwndDa;
  80. HWND hwndPn;
  81. HWND hwndUs;
  82. HWND hwndDt;
  83. HWND hwndEn;
  84. HWND hwndGh;
  85. HWND hwndDn;
  86. HWND hwndSw;
  87. HWND hwndSp;
  88. HWND hwndSc;
  89. // Legacy application page.
  90. //
  91. HFONT hfontBold;
  92. // Modem/Adapter page.
  93. //
  94. HWND hwndLv;
  95. // Connection Name page.
  96. //
  97. HWND hwndCnName;
  98. HWND hwndCnStHMsg;
  99. HWND hwndCnStHMsg2;
  100. HWND hwndCnEbConnectionName; //Add for bug 328673
  101. BOOL fCnWizNext; //if Back button is pressed
  102. // Phone number page.
  103. //
  104. HWND hwndEbNumber;
  105. // Smart Card page
  106. //
  107. HWND hwndScRbYes;
  108. HWND hwndScRbNo;
  109. // Destination page.
  110. //
  111. HWND hwndEbHostName;
  112. // Broadband service page
  113. //
  114. HWND hwndEbBroadbandService;
  115. // Public network page.
  116. //
  117. HWND hwndLbDialFirst;
  118. // Entry Name page.
  119. //
  120. HWND hwndEbEntryName;
  121. // Shared Access private-lan page
  122. //
  123. HWND hwndSpLbPrivateLan;
  124. // User/default connection windows
  125. //
  126. HWND hwndUsRbForAll;
  127. HWND hwndUsRbForMe;
  128. HWND hwndDtCbFirewall; //add for whistler bug 328673
  129. HWND hwndDtCbDefault;
  130. HWND hwndDtCbUseCredentials;
  131. HWND hwndDtEbUserName;
  132. HWND hwndDtEbPassword;
  133. HWND hwndDtEbPassword2;
  134. HWND hwndDtStUserName;
  135. HWND hwndDtStPassword;
  136. HWND hwndDtStPassword2;
  137. // Set true when there is only one meaningful choice of device.
  138. //
  139. BOOL fSkipMa;
  140. // Set true if the selected device is a modem or null modem.
  141. //
  142. BOOL fModem;
  143. // Set to true if there are no connections to show on the public
  144. // network page and therefore no reason to show the page.
  145. //
  146. BOOL fHidePublicNetworkPage;
  147. // Set true if administrator/power user wants the entry available to all
  148. // users.
  149. //
  150. BOOL fCreateForAllUsers;
  151. BOOL fFirewall; //for whistler bug 328673
  152. // The NB_* mask of protocols configured for RAS.
  153. //
  154. DWORD dwfConfiguredProtocols;
  155. // Set true if IP is configured for RAS.
  156. //
  157. BOOL fIpConfigured;
  158. // Area-code and country-code helper context block, and a flag indicating
  159. // if the block has been initialized.
  160. //
  161. CUINFO cuinfo;
  162. BOOL fCuInfoInitialized;
  163. // List of area codes passed CuInit plus all strings retrieved with
  164. // CuGetInfo. The list is an editing duplicate of the one from the
  165. // PBUSER.
  166. //
  167. DTLLIST* pListAreaCodes;
  168. // Scripting utility context block, and a flag indicating if the block has
  169. // been initialized.
  170. //
  171. SUINFO suinfo;
  172. BOOL fSuInfoInitialized;
  173. // Set to true if we want to show the host pages in the dcc wizard, false
  174. // otherwise. If true, rassrvui will administer most of the wizard.
  175. BOOL fDccHost;
  176. // The context used to identify the modifications being made through the
  177. // dcc host wizard
  178. PVOID pvDccHostContext;
  179. // Flags that track whether a smart card reader is installed and whether
  180. // the user has opted to use it.
  181. BOOL fSmartCardInstalled;
  182. BOOL fUseSmartCard;
  183. // Modem device dialog
  184. BOOL fMaAlreadyInitialized;
  185. //For Isdn devices on Ma page, for whislter bug 354542
  186. //
  187. BOOL fMultilinkAllIsdn;
  188. // For whistler bug 453704 gangz
  189. //
  190. BOOL fEnBack;
  191. }
  192. AEINFO;
  193. //----------------------------------------------------------------------------
  194. // Local prototypes (alphabetically)
  195. //----------------------------------------------------------------------------
  196. AEINFO*
  197. AeContext(
  198. IN HWND hwndPage );
  199. void
  200. AeSetContext(
  201. IN HWND hwndPage,
  202. IN LPARAM lparam);
  203. void
  204. AeFinish(
  205. IN AEINFO* pInfo );
  206. DWORD
  207. AeInit(
  208. IN HWND hwndOwner,
  209. IN EINFO* pEinfo,
  210. OUT AEINFO** ppInfo );
  211. VOID
  212. AeTerm(
  213. IN AEINFO* pInfo );
  214. BOOL
  215. ApCommand(
  216. IN AEINFO* pInfo,
  217. IN WORD wNotification,
  218. IN WORD wId,
  219. IN HWND hwndCtrl );
  220. INT_PTR CALLBACK
  221. BsDlgProc(
  222. IN HWND hwnd,
  223. IN UINT unMsg,
  224. IN WPARAM wparam,
  225. IN LPARAM lparam );
  226. BOOL
  227. BsInit(
  228. IN HWND hwndPage );
  229. BOOL
  230. BsKillActive(
  231. IN AEINFO* pInfo );
  232. BOOL
  233. BsSetActive(
  234. IN AEINFO* pInfo );
  235. INT_PTR CALLBACK
  236. CnDlgProc(
  237. IN HWND hwnd,
  238. IN UINT unMsg,
  239. IN WPARAM wparam,
  240. IN LPARAM lparam );
  241. BOOL
  242. CnInit(
  243. IN HWND hwndPage );
  244. BOOL
  245. CnKillActive(
  246. IN AEINFO* pInfo );
  247. BOOL
  248. CnSetActive(
  249. IN AEINFO* pInfo );
  250. BOOL
  251. CnCommand(
  252. IN AEINFO* pInfo,
  253. IN WORD wNotification,
  254. IN WORD wId,
  255. IN HWND hwndCtrl );
  256. INT_PTR CALLBACK
  257. DaDlgProc(
  258. IN HWND hwnd,
  259. IN UINT unMsg,
  260. IN WPARAM wparam,
  261. IN LPARAM lparam );
  262. BOOL
  263. DaInit(
  264. IN HWND hwndPage );
  265. BOOL
  266. DaKillActive(
  267. IN AEINFO* pInfo );
  268. BOOL
  269. DaSetActive(
  270. IN AEINFO* pInfo );
  271. BOOL
  272. DnCommand(
  273. IN AEINFO* pInfo,
  274. IN WORD wNotification,
  275. IN WORD wId,
  276. IN HWND hwndCtrl );
  277. INT_PTR CALLBACK
  278. DnDlgProc(
  279. IN HWND hwnd,
  280. IN UINT unMsg,
  281. IN WPARAM wparam,
  282. IN LPARAM lparam );
  283. BOOL
  284. DtCommand(
  285. IN AEINFO* pInfo,
  286. IN WORD wNotification,
  287. IN WORD wId,
  288. IN HWND hwndCtrl );
  289. BOOL
  290. DnInit(
  291. IN HWND hwndPage );
  292. BOOL
  293. DnKillActive(
  294. IN AEINFO* pInfo );
  295. BOOL
  296. DnSetActive(
  297. IN AEINFO* pInfo );
  298. INT_PTR CALLBACK
  299. DtDlgProc(
  300. IN HWND hwnd,
  301. IN UINT unMsg,
  302. IN WPARAM wparam,
  303. IN LPARAM lparam );
  304. BOOL
  305. DtInit(
  306. IN HWND hwndPage );
  307. BOOL
  308. DtKillActive(
  309. IN AEINFO* pInfo );
  310. BOOL
  311. DtSetActive(
  312. IN AEINFO* pInfo );
  313. INT_PTR CALLBACK
  314. EnDlgProc(
  315. IN HWND hwnd,
  316. IN UINT unMsg,
  317. IN WPARAM wparam,
  318. IN LPARAM lparam );
  319. BOOL
  320. EnInit(
  321. IN HWND hwndPage );
  322. BOOL
  323. EnKillActive(
  324. IN AEINFO* pInfo );
  325. BOOL
  326. EnSetActive(
  327. IN AEINFO* pInfo );
  328. BOOL
  329. GhCommand(
  330. IN AEINFO* pInfo,
  331. IN WORD wNotification,
  332. IN WORD wId,
  333. IN HWND hwndCtrl );
  334. INT_PTR CALLBACK
  335. GhDlgProc(
  336. IN HWND hwnd,
  337. IN UINT unMsg,
  338. IN WPARAM wparam,
  339. IN LPARAM lparam );
  340. BOOL
  341. GhInit(
  342. IN HWND hwndPage );
  343. BOOL
  344. GhKillActive(
  345. IN AEINFO* pInfo );
  346. BOOL
  347. GhSetActive(
  348. IN AEINFO* pInfo );
  349. INT_PTR CALLBACK
  350. LaDlgProc(
  351. IN HWND hwnd,
  352. IN UINT unMsg,
  353. IN WPARAM wparam,
  354. IN LPARAM lparam );
  355. BOOL
  356. LaInit(
  357. IN HWND hwndPage );
  358. BOOL
  359. LaKillActive(
  360. IN AEINFO* pInfo );
  361. BOOL
  362. LaSetActive(
  363. IN AEINFO* pInfo );
  364. INT_PTR CALLBACK
  365. MaDlgProc(
  366. IN HWND hwnd,
  367. IN UINT unMsg,
  368. IN WPARAM wparam,
  369. IN LPARAM lparam );
  370. BOOL
  371. MaInit(
  372. IN HWND hwndPage );
  373. LVXDRAWINFO*
  374. MaLvCallback(
  375. IN HWND hwndLv,
  376. IN DWORD dwItem );
  377. BOOL
  378. MaSetActive(
  379. IN AEINFO* pInfo );
  380. BOOL
  381. MaKillActive(
  382. IN AEINFO* pInfo );
  383. BOOL
  384. PaCommand(
  385. IN AEINFO* pInfo,
  386. IN WORD wNotification,
  387. IN WORD wId,
  388. IN HWND hwndCtrl );
  389. INT_PTR CALLBACK
  390. PaDlgProc(
  391. IN HWND hwnd,
  392. IN UINT unMsg,
  393. IN WPARAM wparam,
  394. IN LPARAM lparam );
  395. BOOL
  396. PaInit(
  397. IN HWND hwndPage );
  398. BOOL
  399. PaKillActive(
  400. IN AEINFO* pInfo );
  401. BOOL
  402. PaSetActive(
  403. IN AEINFO* pInfo );
  404. VOID
  405. PnClearLbDialFirst(
  406. IN HWND hwndLbDialFirst );
  407. INT_PTR CALLBACK
  408. PnDlgProc(
  409. IN HWND hwnd,
  410. IN UINT unMsg,
  411. IN WPARAM wparam,
  412. IN LPARAM lparam );
  413. BOOL
  414. PnInit(
  415. IN HWND hwndPage );
  416. BOOL
  417. PnKillActive(
  418. IN AEINFO* pInfo );
  419. BOOL
  420. PnSetActive(
  421. IN AEINFO* pInfo );
  422. VOID
  423. PnDialAnotherFirstSelChange(
  424. IN AEINFO* pInfo );
  425. VOID
  426. PnUpdateLbDialAnotherFirst(
  427. IN AEINFO* pInfo );
  428. INT_PTR CALLBACK
  429. ScDlgProc(
  430. IN HWND hwnd,
  431. IN UINT unMsg,
  432. IN WPARAM wparam,
  433. IN LPARAM lparam );
  434. BOOL
  435. ScInit(
  436. IN HWND hwndPage );
  437. BOOL
  438. ScKillActive(
  439. IN AEINFO* pInfo );
  440. BOOL
  441. ScSetActive(
  442. IN AEINFO* pInfo );
  443. BOOL
  444. ScSmartCardReaderInstalled(
  445. IN AEINFO* pInfo);
  446. INT_PTR CALLBACK
  447. SpDlgProc(
  448. IN HWND hwnd,
  449. IN UINT unMsg,
  450. IN WPARAM wparam,
  451. IN LPARAM lparam );
  452. BOOL
  453. SpInit(
  454. IN HWND hwndPage );
  455. BOOL
  456. SpKillActive(
  457. IN AEINFO* pInfo );
  458. BOOL
  459. SpSetActive(
  460. IN AEINFO* pInfo );
  461. INT_PTR CALLBACK
  462. StDlgProc(
  463. IN HWND hwnd,
  464. IN UINT unMsg,
  465. IN WPARAM wparam,
  466. IN LPARAM lparam );
  467. BOOL
  468. StInit(
  469. IN HWND hwndPage,
  470. IN OUT AEINFO* pInfo );
  471. BOOL
  472. StKillActive(
  473. IN AEINFO* pInfo );
  474. BOOL
  475. StSetActive(
  476. IN AEINFO* pInfo );
  477. BOOL
  478. SwCommand(
  479. IN AEINFO* pInfo,
  480. IN WORD wNotification,
  481. IN WORD wId,
  482. IN HWND hwndCtrl );
  483. INT_PTR CALLBACK
  484. SwDlgProc(
  485. IN HWND hwnd,
  486. IN UINT unMsg,
  487. IN WPARAM wparam,
  488. IN LPARAM lparam );
  489. BOOL
  490. SwInit(
  491. IN HWND hwndPage );
  492. BOOL
  493. SwKillActive(
  494. IN AEINFO* pInfo );
  495. BOOL
  496. SwSetActive(
  497. IN AEINFO* pInfo );
  498. INT_PTR CALLBACK
  499. UsDlgProc(
  500. IN HWND hwnd,
  501. IN UINT unMsg,
  502. IN WPARAM wparam,
  503. IN LPARAM lparam );
  504. BOOL
  505. UsInit(
  506. IN HWND hwndPage );
  507. BOOL
  508. UsKillActive(
  509. IN AEINFO* pInfo );
  510. BOOL
  511. UsSetActive(
  512. IN AEINFO* pInfo );
  513. // NOTICE-2002/05/20 - DavePr -- found this anonymous comment while cleaning up (DLGPROC)
  514. // This is as good of a hack as I could think of to incorporate the direct
  515. // connect host ui wizard pages without actually exposing the resources and
  516. // functions that implement them (which are in the project, rassrvui)
  517. #define DCC_HOST_PROCID ((DLGPROC)0x1)
  518. struct PAGE_INFO
  519. {
  520. DLGPROC pfnDlgProc;
  521. INT nPageId;
  522. INT nSidTitle;
  523. INT nSidSubtitle;
  524. DWORD dwConnectionFlags;
  525. };
  526. static const struct PAGE_INFO c_aWizInfo [] =
  527. {
  528. {
  529. StDlgProc,
  530. PID_ST_Start,
  531. 0,
  532. 0,
  533. RASEDFLAG_AnyNewEntry | RASEDFLAG_CloneEntry
  534. },
  535. {
  536. LaDlgProc,
  537. PID_LA_NameAndType,
  538. SID_LA_Title,
  539. SID_LA_Subtitle,
  540. RASEDFLAG_NewEntry
  541. },
  542. {
  543. MaDlgProc,
  544. PID_MA_ModemAdapter,
  545. SID_MA_Title,
  546. SID_MA_Subtitle,
  547. RASEDFLAG_NewEntry | RASEDFLAG_NewPhoneEntry
  548. },
  549. //put Guest/Host page before Connection Name page for bug 328673
  550. //
  551. {
  552. GhDlgProc,
  553. PID_GH_GuestHost,
  554. SID_GH_Title,
  555. SID_GH_Subtitle,
  556. RASEDFLAG_NewDirectEntry
  557. },
  558. //Add a new wizard page to get Connection Name, this is not available for rasphone.exe
  559. //for whistler bug 328673 gangz
  560. //
  561. {
  562. CnDlgProc,
  563. PID_CN_ConnectionName,
  564. SID_CN_Title,
  565. SID_CN_SubtitleInternet,
  566. RASEDFLAG_AnyNewEntry | RASEDFLAG_ShellOwned
  567. },
  568. {
  569. PaDlgProc,
  570. PID_PA_PhoneNumber,
  571. SID_PA_Title,
  572. SID_PA_Subtitle,
  573. RASEDFLAG_NewEntry | RASEDFLAG_NewPhoneEntry
  574. },
  575. {
  576. PnDlgProc,
  577. PID_PN_PublicNetwork,
  578. SID_PN_Title,
  579. SID_PN_Subtitle,
  580. RASEDFLAG_NewEntry | RASEDFLAG_NewTunnelEntry
  581. },
  582. {
  583. DaDlgProc,
  584. PID_DA_VpnDestination,
  585. SID_DA_Title,
  586. SID_DA_Subtitle,
  587. RASEDFLAG_NewEntry | RASEDFLAG_NewTunnelEntry
  588. },
  589. {
  590. BsDlgProc,
  591. PID_BS_BroadbandService,
  592. SID_BS_Title,
  593. SID_BS_Subtitle,
  594. RASEDFLAG_NewEntry | RASEDFLAG_NewBroadbandEntry
  595. },
  596. {
  597. ScDlgProc,
  598. PID_SC_SmartCard,
  599. SID_SC_Title,
  600. SID_SC_Subtitle,
  601. RASEDFLAG_NewEntry | RASEDFLAG_NewPhoneEntry | RASEDFLAG_NewTunnelEntry
  602. },
  603. {
  604. DnDlgProc,
  605. PID_DN_DccDevice,
  606. SID_DN_Title,
  607. SID_DN_Subtitle,
  608. RASEDFLAG_NewEntry | RASEDFLAG_NewDirectEntry
  609. },
  610. {
  611. DCC_HOST_PROCID,
  612. 0,
  613. 0,
  614. 0,
  615. RASEDFLAG_NewDirectEntry
  616. },
  617. {
  618. UsDlgProc,
  619. PID_US_Users,
  620. SID_US_Title,
  621. SID_US_Subtitle,
  622. RASEDFLAG_AnyNewEntry | RASEDFLAG_ShellOwned
  623. },
  624. {
  625. DtDlgProc,
  626. PID_DT_DefaultInternet,
  627. SID_DT_Title,
  628. SID_DT_Subtitle,
  629. RASEDFLAG_AnyNewEntry | RASEDFLAG_ShellOwned
  630. },
  631. {
  632. SwDlgProc,
  633. PID_SW_SharedAccess,
  634. SID_SW_Title,
  635. SID_SW_Subtitle,
  636. RASEDFLAG_NewEntry | RASEDFLAG_NewPhoneEntry | RASEDFLAG_NewTunnelEntry | RASEDFLAG_NewBroadbandEntry
  637. },
  638. {
  639. SpDlgProc,
  640. PID_SP_SharedLan,
  641. SID_SP_Title,
  642. SID_SP_Subtitle,
  643. RASEDFLAG_NewEntry | RASEDFLAG_NewPhoneEntry | RASEDFLAG_NewTunnelEntry | RASEDFLAG_NewBroadbandEntry
  644. },
  645. {
  646. EnDlgProc,
  647. PID_EN_EntryName,
  648. SID_EN_Title,
  649. SID_EN_Subtitle,
  650. RASEDFLAG_AnyNewEntry | RASEDFLAG_CloneEntry
  651. },
  652. };
  653. #define c_cWizPages (sizeof (c_aWizInfo) / sizeof(c_aWizInfo[0]))
  654. //----------------------------------------------------------------------------
  655. // Private exports - New client connection wizard
  656. //----------------------------------------------------------------------------
  657. DWORD
  658. APIENTRY
  659. NccCreateNewEntry(
  660. IN LPVOID pvData,
  661. OUT LPWSTR pszwPbkFile,
  662. OUT LPWSTR pszwEntryName,
  663. OUT DWORD* pdwFlags)
  664. {
  665. DWORD dwErr = ERROR_SUCCESS;
  666. BOOL fIcRunning = FALSE;
  667. if (!pvData || !pszwPbkFile || !pszwEntryName || !pdwFlags)
  668. {
  669. dwErr = ERROR_INVALID_PARAMETER;
  670. }
  671. else
  672. {
  673. AEINFO* pInfo = (AEINFO*)pvData;
  674. // If the direct connect wizard went down the host path, then we
  675. // need to instruct the shell to create the "Incoming Connections"
  676. // connection.
  677. if (pInfo->fDccHost)
  678. {
  679. RassrvCommitSettings (pInfo->pvDccHostContext, RASWIZ_TYPE_DIRECT);
  680. *pdwFlags = NCC_FLAG_CREATE_INCOMING;
  681. return NO_ERROR;
  682. }
  683. // Otherwise, create the phone book entry
  684. ASSERT (pInfo->pArgs->file.pszPath);
  685. ASSERT (pInfo->pArgs->pEntry->pszEntryName);
  686. lstrcpynW( pszwPbkFile, pInfo->pArgs->file.pszPath, MAX_PATH );
  687. lstrcpynW( pszwEntryName, pInfo->pArgs->pEntry->pszEntryName, MAX_PATH );
  688. *pdwFlags = (pInfo->fCreateForAllUsers) ? NCC_FLAG_ALL_USERS : 0;
  689. //Add this for the Account and password page, only available for consumer
  690. //platform. for whistler bug 328673 gangz
  691. //
  692. if(pInfo->fFirewall)
  693. {
  694. *pdwFlags |= NCC_FLAG_FIREWALL;
  695. }
  696. AeFinish( pInfo );
  697. EuCommit( pInfo->pArgs );
  698. //Setup port mapping for this new connection
  699. //According to the VPN enable/disable and
  700. // IC exist/non-exist condition and
  701. // if it is a Firewall available platform
  702. //
  703. //Detect if Incoming Connection exists
  704. //If it is a DccHost connection, SetPortMapping
  705. //is already done in RassrvCommitSettings()
  706. //
  707. if ( pInfo->fFirewall && //For bug 342810
  708. (NO_ERROR == RasSrvIsServiceRunning( &fIcRunning )) &&
  709. fIcRunning
  710. )
  711. {
  712. HnPMConfigureSingleConnectionGUIDIfVpnEnabled( pInfo->pArgs->pEntry->pGuid, FALSE, NULL );
  713. }
  714. dwErr = pInfo->pArgs->pApiArgs->dwError;
  715. }
  716. return dwErr;
  717. }
  718. DWORD
  719. APIENTRY
  720. NccGetSuggestedEntryName(
  721. IN LPVOID pvData,
  722. OUT LPWSTR pszwSuggestedName)
  723. {
  724. DWORD dwErr = ERROR_SUCCESS;
  725. if (!pvData || !pszwSuggestedName)
  726. {
  727. dwErr = ERROR_INVALID_PARAMETER;
  728. }
  729. else
  730. {
  731. AEINFO* pInfo = (AEINFO*)pvData;
  732. PBENTRY* pEntry = pInfo->pArgs->pEntry;
  733. LPTSTR pszName;
  734. // If this is a dcc host connection, ask the ras server
  735. // module for the name.
  736. if (pInfo->fDccHost)
  737. {
  738. WCHAR pszBuf[MAX_PATH];
  739. DWORD dwSize = MAX_PATH;
  740. if ((dwErr = RassrvGetDefaultConnectionName(pszBuf, &dwSize)) != NO_ERROR)
  741. return dwErr;
  742. lstrcpynW(pszwSuggestedName, pszBuf, MAX_PATH);
  743. return NO_ERROR;
  744. }
  745. // If pFile is NULL, it probably means that the wizard page
  746. // to determine where the phonebook should be stored was never
  747. // visited.
  748. //
  749. if (!pInfo->pArgs->pFile)
  750. {
  751. dwErr = ERROR_INVALID_PARAMETER;
  752. }
  753. else
  754. {
  755. dwErr = GetDefaultEntryName(
  756. NULL,
  757. pEntry->dwType,
  758. FALSE, &pszName );
  759. if (ERROR_SUCCESS == dwErr)
  760. {
  761. // Whistler bug 224074 use only lstrcpyn's to prevent
  762. // maliciousness
  763. //
  764. lstrcpynW( pszwSuggestedName, pszName, MAX_PATH );
  765. Free( pszName );
  766. }
  767. }
  768. }
  769. return dwErr;
  770. }
  771. DWORD
  772. APIENTRY
  773. NccQueryMaxPageCount()
  774. {
  775. // Return the number of pages in the array We subtract
  776. // 1 from this since DCC_HOST_PROCID takes a space in the array.
  777. return c_cWizPages - 1;
  778. }
  779. //+---------------------------------------------------------------------------
  780. //
  781. // Function: NccSetEntryName
  782. //
  783. // Purpose:
  784. //
  785. // Arguments:
  786. // pvData []
  787. // pszwName []
  788. //
  789. // Returns: ERROR_SUCCESS, ERROR_INVALID_PARAMETER,
  790. // ERROR_NOT_ENOUGH_MEMORY or ERROR_DUP_NAME.
  791. //
  792. // Author: shaunco 21 Jan 1998
  793. //
  794. // Notes:
  795. //
  796. DWORD
  797. APIENTRY
  798. NccSetEntryName(
  799. IN LPVOID pvData,
  800. IN LPCWSTR pszwName)
  801. {
  802. DWORD dwErr = ERROR_SUCCESS;
  803. AEINFO* pInfo = (AEINFO*)pvData;
  804. if (!pvData || !pszwName)
  805. {
  806. dwErr = ERROR_INVALID_PARAMETER;
  807. }
  808. else if (pInfo->fDccHost)
  809. {
  810. // dwErr = ERROR_CAN_NOT_COMPLETE;
  811. dwErr = ERROR_SUCCESS;
  812. }
  813. else if (ERROR_SUCCESS == (dwErr = LoadRasapi32Dll()))
  814. {
  815. // Validate the entry name against the current phonebook.
  816. // If we can't open the phonebook, its okay. It just means
  817. // it hasn't been created yet. The name is valid in this case.
  818. //
  819. dwErr = g_pRasValidateEntryName (pInfo->pArgs->pFile->pszPath,
  820. pszwName);
  821. if (ERROR_ALREADY_EXISTS == dwErr)
  822. {
  823. dwErr = ERROR_DUP_NAME;
  824. }
  825. else if ((ERROR_SUCCESS == dwErr) ||
  826. (ERROR_CANNOT_OPEN_PHONEBOOK == dwErr))
  827. {
  828. PBENTRY* pEntry = pInfo->pArgs->pEntry;
  829. dwErr = ERROR_SUCCESS;
  830. Free( pEntry->pszEntryName );
  831. pEntry->pszEntryName = StrDup( pszwName );
  832. if (!pEntry->pszEntryName)
  833. {
  834. dwErr = ERROR_NOT_ENOUGH_MEMORY;
  835. }
  836. }
  837. }
  838. return dwErr;
  839. }
  840. //+---------------------------------------------------------------------------
  841. //
  842. // Function: NccIsEntryRenamable
  843. //
  844. // Purpose: Returns whether the user should be allowed
  845. // to rename the given connection.
  846. //
  847. // Arguments:
  848. // pvData []
  849. // pfRenamable // Set to TRUE if renamable
  850. //
  851. // Returns: ERROR_SUCCESS, ERROR_INVALID_PARAMETER,
  852. // ERROR_NOT_ENOUGH_MEMORY or ERROR_DUP_NAME.
  853. //
  854. // Author: pmay 2/4/98
  855. //
  856. // Notes:
  857. //
  858. DWORD
  859. APIENTRY
  860. NccIsEntryRenamable(
  861. IN LPVOID pvData,
  862. OUT BOOL* pfRenamable)
  863. {
  864. AEINFO* pInfo = (AEINFO*)pvData;
  865. if (!pInfo || !pfRenamable)
  866. return ERROR_INVALID_PARAMETER;
  867. // Only dcc host connections are non-renamable
  868. *pfRenamable = !pInfo->fDccHost;
  869. return NO_ERROR;
  870. }
  871. DWORD
  872. APIENTRY
  873. RasWizCreateNewEntry(
  874. IN DWORD dwRasWizType,
  875. IN LPVOID pvData,
  876. OUT LPWSTR pszwPbkFile,
  877. OUT LPWSTR pszwEntryName,
  878. OUT DWORD* pdwFlags)
  879. {
  880. switch (dwRasWizType)
  881. {
  882. case RASWIZ_TYPE_DIALUP:
  883. case RASWIZ_TYPE_DIRECT:
  884. case RASWIZ_TYPE_BROADBAND:
  885. return NccCreateNewEntry(pvData, pszwPbkFile, pszwEntryName, pdwFlags);
  886. break;
  887. case RASWIZ_TYPE_INCOMING:
  888. return RassrvCommitSettings((HWND)pvData, RASWIZ_TYPE_INCOMING);
  889. break;
  890. }
  891. return ERROR_INVALID_PARAMETER;
  892. }
  893. // Add for whistler bug 328673
  894. // This is function is called by folder team just before the
  895. // RasWizCreateNewEntry(), because it is only meaningful to call it
  896. // after the rasdlg wizard pages are done
  897. DWORD
  898. APIENTRY
  899. RasWizGetNCCFlags(
  900. IN DWORD dwRasWizType,
  901. IN LPVOID pvData,
  902. OUT DWORD * pdwFlags)
  903. {
  904. DWORD dwErr = NO_ERROR;
  905. if (!pvData || !pdwFlags)
  906. {
  907. dwErr = ERROR_INVALID_PARAMETER;
  908. }
  909. else
  910. {
  911. AEINFO* pInfo = (AEINFO*)pvData;
  912. *pdwFlags = 0;
  913. switch (dwRasWizType)
  914. {
  915. case RASWIZ_TYPE_DIRECT:
  916. case RASWIZ_TYPE_DIALUP:
  917. case RASWIZ_TYPE_BROADBAND:
  918. if (pInfo->fDccHost)
  919. {
  920. *pdwFlags |= NCC_FLAG_CREATE_INCOMING;
  921. dwErr = NO_ERROR;
  922. }
  923. else
  924. {
  925. if ( pInfo->fCreateForAllUsers )
  926. {
  927. //the connecntion is created for all users
  928. //for Us page
  929. //
  930. *pdwFlags |= NCC_FLAG_ALL_USERS;
  931. }
  932. if(pInfo->fFirewall)
  933. {
  934. *pdwFlags |= NCC_FLAG_FIREWALL;
  935. }
  936. if ( IsConsumerPlatform())
  937. {
  938. if (pInfo->pArgs->fGlobalCred)
  939. {
  940. //The password is saved for every users
  941. //for Dt page
  942. //
  943. *pdwFlags |= NCC_FLAG_GLOBALCREDS;
  944. }
  945. }
  946. if ( pInfo->pArgs->fDefInternet )
  947. {
  948. *pdwFlags |= NCC_FLAG_DEFAULT_INTERNET;
  949. }
  950. if ( pInfo->pArgs->fGlobalCred )
  951. {
  952. *pdwFlags |= NCC_FLAG_GLOBALCREDS;
  953. }
  954. dwErr = NO_ERROR;
  955. }
  956. break;
  957. case RASWIZ_TYPE_INCOMING:
  958. *pdwFlags |= NCC_FLAG_CREATE_INCOMING;
  959. dwErr = NO_ERROR;
  960. break;
  961. default:
  962. dwErr = ERROR_INVALID_PARAMETER;
  963. }
  964. }
  965. return dwErr;
  966. }
  967. //This is function is called by folder team just before the
  968. //RasWizCreateNewEntry()
  969. //
  970. DWORD
  971. APIENTRY
  972. RasWizGetUserInputConnectionName (
  973. IN LPVOID pvData,
  974. OUT LPWSTR pszwInputName)
  975. {
  976. DWORD dwErr = ERROR_SUCCESS;
  977. if (!pvData || !pszwInputName)
  978. {
  979. dwErr = ERROR_INVALID_PARAMETER;
  980. }
  981. else
  982. {
  983. AEINFO* pInfo = (AEINFO*)pvData;
  984. WCHAR * pszwTemp = NULL;
  985. if ( pInfo->pArgs->pEntry->pszEntryName )
  986. {
  987. pszwTemp = StrDupWFromT( pInfo->pArgs->pEntry->pszEntryName );
  988. if (!pszwTemp)
  989. {
  990. dwErr = ERROR_NOT_ENOUGH_MEMORY;
  991. }
  992. else
  993. {
  994. // Truncate to maximum name length (including terminating NULL)
  995. // that rest of MAX_PATH can be appened by netcfg
  996. //
  997. lstrcpynW(pszwInputName, pszwTemp, MAX_ENTERCONNECTIONNAME);
  998. Free0(pszwTemp);
  999. }
  1000. }
  1001. else
  1002. {
  1003. dwErr = ERROR_NO_DATA;
  1004. }
  1005. }
  1006. return dwErr;
  1007. }
  1008. DWORD
  1009. APIENTRY
  1010. RasWizGetSuggestedEntryName (
  1011. IN DWORD dwRasWizType,
  1012. IN LPVOID pvData,
  1013. OUT LPWSTR pszwSuggestedName)
  1014. {
  1015. DWORD dwSize = MAX_PATH;
  1016. switch (dwRasWizType)
  1017. {
  1018. case RASWIZ_TYPE_DIALUP:
  1019. case RASWIZ_TYPE_DIRECT:
  1020. case RASWIZ_TYPE_BROADBAND:
  1021. return NccGetSuggestedEntryName(pvData, pszwSuggestedName);
  1022. break;
  1023. case RASWIZ_TYPE_INCOMING:
  1024. return RassrvGetDefaultConnectionName(pszwSuggestedName, &dwSize);
  1025. break;
  1026. }
  1027. return ERROR_INVALID_PARAMETER;
  1028. }
  1029. DWORD
  1030. APIENTRY
  1031. RasWizQueryMaxPageCount (
  1032. IN DWORD dwRasWizType)
  1033. {
  1034. switch (dwRasWizType)
  1035. {
  1036. case RASWIZ_TYPE_DIALUP:
  1037. case RASWIZ_TYPE_BROADBAND:
  1038. return NccQueryMaxPageCount();
  1039. break;
  1040. case RASWIZ_TYPE_DIRECT:
  1041. {
  1042. DWORD dwDirect;
  1043. // Find out whether the dcc wizard option should be disabled
  1044. // based on whether we allow it.
  1045. if (! AllowDccWizard(NULL))
  1046. return 0;
  1047. // Find out how many pages the server library needs for dcc.
  1048. // If 0 pages are returned from RassrvQueryMaxPageCount, it means
  1049. // that we shouldn't display the direct connect wizard (which is
  1050. // true for member nts or dc nts.) By returning 0, we tell the
  1051. // shell that the given type isn't available.
  1052. if ((dwDirect = RassrvQueryMaxPageCount (RASWIZ_TYPE_DIRECT)) == 0)
  1053. return 0;
  1054. return dwDirect + NccQueryMaxPageCount();
  1055. }
  1056. break;
  1057. case RASWIZ_TYPE_INCOMING:
  1058. return RassrvQueryMaxPageCount(RASWIZ_TYPE_INCOMING);
  1059. break;
  1060. }
  1061. return ERROR_INVALID_PARAMETER;
  1062. }
  1063. DWORD
  1064. APIENTRY
  1065. RasWizSetEntryName (
  1066. IN DWORD dwRasWizType,
  1067. IN LPVOID pvData,
  1068. IN LPCWSTR pszwName)
  1069. {
  1070. switch (dwRasWizType)
  1071. {
  1072. case RASWIZ_TYPE_DIALUP:
  1073. case RASWIZ_TYPE_DIRECT:
  1074. case RASWIZ_TYPE_BROADBAND:
  1075. return NccSetEntryName(pvData, pszwName);
  1076. break;
  1077. case RASWIZ_TYPE_INCOMING:
  1078. // We'll accept it even though we don't do anything with it.
  1079. return NOERROR;
  1080. break;
  1081. }
  1082. return ERROR_INVALID_PARAMETER;
  1083. }
  1084. DWORD
  1085. APIENTRY
  1086. RasWizIsEntryRenamable (
  1087. IN DWORD dwRasWizType,
  1088. IN LPVOID pvData,
  1089. OUT BOOL* pfRenamable)
  1090. {
  1091. if (!pfRenamable)
  1092. return ERROR_INVALID_PARAMETER;
  1093. switch (dwRasWizType)
  1094. {
  1095. case RASWIZ_TYPE_DIALUP:
  1096. case RASWIZ_TYPE_DIRECT:
  1097. case RASWIZ_TYPE_BROADBAND:
  1098. return NccIsEntryRenamable(pvData, pfRenamable);
  1099. break;
  1100. case RASWIZ_TYPE_INCOMING:
  1101. *pfRenamable = FALSE;
  1102. return NO_ERROR;
  1103. break;
  1104. }
  1105. return ERROR_INVALID_PARAMETER;
  1106. }
  1107. // 232097: (shaunco) Fix a memory leak in the shell-owned case.
  1108. // For start pages which don't get created, WM_DESTROY won't be called which
  1109. // is where we used to free the memory. Free the memory via a propsheet
  1110. // callback function associated only with the start page in shell-owned mode.
  1111. //
  1112. UINT
  1113. CALLBACK
  1114. DestroyStartPageCallback (
  1115. HWND hwnd,
  1116. UINT unMsg,
  1117. LPPROPSHEETPAGE ppsp)
  1118. {
  1119. if (PSPCB_RELEASE == unMsg)
  1120. {
  1121. AEINFO* pInfo;
  1122. EINFO* pArgs;
  1123. pInfo = (AEINFO*)ppsp->lParam;
  1124. ASSERT( pInfo );
  1125. ASSERT( pInfo->pArgs->pApiArgs->dwFlags & RASEDFLAG_ShellOwned );
  1126. pArgs = pInfo->pArgs;
  1127. AeTerm( pInfo ); // pInfo invalid after this call
  1128. EuFree( pArgs );
  1129. }
  1130. // for PSPCB_CREATE == unMsg, returning non-zero means create the page.
  1131. // Ignored for PSPCB_RELEASE.
  1132. //
  1133. return 1;
  1134. }
  1135. //----------------------------------------------------------------------------
  1136. // Add Entry wizard entry point
  1137. //----------------------------------------------------------------------------
  1138. BOOL
  1139. AeIsWorkPlace(DWORD dwFlags)
  1140. {
  1141. TRACE("AeIsWorkPlace");
  1142. if( RASEDFLAG_InternetEntry & dwFlags ||
  1143. RASEDFLAG_NewDirectEntry & dwFlags)
  1144. {
  1145. return FALSE;
  1146. }
  1147. else
  1148. {
  1149. return TRUE;
  1150. }
  1151. }
  1152. //Add this for whistler 364818 gangz
  1153. //
  1154. AeTitle(RASENTRYDLG * pArgs,
  1155. struct PAGE_INFO c_aPageInfo)
  1156. {
  1157. INT nTitle = 0;
  1158. TRACE("AeTitle");
  1159. if( !pArgs )
  1160. {
  1161. nTitle = c_aPageInfo.nSidTitle;
  1162. }
  1163. else if ( c_aPageInfo.nPageId == PID_DT_DefaultInternet )
  1164. {
  1165. if ( pArgs->dwFlags & RASEDFLAG_InternetEntry )
  1166. {
  1167. nTitle = SID_DT_Title;
  1168. }
  1169. else if( pArgs->dwFlags & RASEDFLAG_NewDirectEntry )
  1170. {
  1171. nTitle = SID_DT_TitleWork;
  1172. }
  1173. else
  1174. {
  1175. nTitle = SID_DT_TitleWork;
  1176. }
  1177. }
  1178. else
  1179. {
  1180. nTitle = c_aPageInfo.nSidTitle;
  1181. }
  1182. return nTitle;
  1183. }
  1184. INT
  1185. AeSubTitle(RASENTRYDLG * pArgs,
  1186. struct PAGE_INFO c_aPageInfo)
  1187. {
  1188. INT nSubTitle = 0;
  1189. TRACE("AeSubTitle");
  1190. if( !pArgs )
  1191. {
  1192. nSubTitle = c_aPageInfo.nSidSubtitle;
  1193. }
  1194. else if ( c_aPageInfo.nPageId == PID_CN_ConnectionName )
  1195. {
  1196. //Return different subtitle for Conneciton Name page
  1197. //
  1198. if( RASEDFLAG_InternetEntry & pArgs->dwFlags )
  1199. {
  1200. nSubTitle = SID_CN_SubtitleInternet;
  1201. }
  1202. else if( RASEDFLAG_NewDirectEntry & pArgs->dwFlags )
  1203. {
  1204. nSubTitle = SID_CN_SubtitleDccGuest;
  1205. }
  1206. else
  1207. {
  1208. nSubTitle = SID_CN_SubtitleWork;
  1209. }
  1210. }
  1211. //Add this for whistler 364818
  1212. //
  1213. else if ( c_aPageInfo.nPageId == PID_DT_DefaultInternet )
  1214. {
  1215. if ( RASEDFLAG_InternetEntry & pArgs->dwFlags )
  1216. {
  1217. nSubTitle = SID_DT_Subtitle;
  1218. }
  1219. else if ( RASEDFLAG_NewDirectEntry & pArgs->dwFlags )
  1220. {
  1221. nSubTitle = SID_DT_SubtitleWork;
  1222. }
  1223. else
  1224. {
  1225. nSubTitle = SID_DT_SubtitleWork;
  1226. }
  1227. }
  1228. //Add this for whistler bug 382701
  1229. //
  1230. else if ( c_aPageInfo.nPageId == PID_PA_PhoneNumber )
  1231. {
  1232. if ( RASEDFLAG_InternetEntry & pArgs->dwFlags )
  1233. {
  1234. nSubTitle = SID_PA_Subtitle;
  1235. }
  1236. else
  1237. {
  1238. nSubTitle = SID_PA_SubtitleWork;
  1239. }
  1240. }
  1241. else
  1242. {
  1243. nSubTitle = c_aPageInfo.nSidSubtitle;
  1244. }
  1245. return nSubTitle;
  1246. }
  1247. VOID
  1248. AeWizard(
  1249. IN OUT EINFO* pEinfo )
  1250. // Runs the Phonebook entry property sheet. 'PEinfo' is an input block
  1251. // with only caller's API arguments filled in.
  1252. //
  1253. {
  1254. AEINFO* pAeinfo;
  1255. RASEDSHELLOWNEDR2* pShellOwnedInfo = NULL;
  1256. BOOL fShellOwned;
  1257. BOOL fShowSharedAccessUi = TRUE;
  1258. HPROPSHEETPAGE ahpage [ c_cWizPages ];
  1259. HPROPSHEETPAGE* phpage = ahpage;
  1260. INT i;
  1261. HRESULT hr;
  1262. INetConnectionUiUtilities * pncuu = NULL;
  1263. TRACE("AeWizard");
  1264. if (0 != AeInit( pEinfo->pApiArgs->hwndOwner, pEinfo, &pAeinfo ))
  1265. {
  1266. return;
  1267. }
  1268. fShellOwned = (pEinfo->pApiArgs->dwFlags & RASEDFLAG_ShellOwned);
  1269. if (fShellOwned)
  1270. {
  1271. pShellOwnedInfo = (RASEDSHELLOWNEDR2*)pEinfo->pApiArgs->reserved2;
  1272. pShellOwnedInfo->pvWizardCtx = pAeinfo;
  1273. }
  1274. if (pEinfo->pApiArgs->dwFlags & RASEDFLAG_NewTunnelEntry)
  1275. {
  1276. EuChangeEntryType (pEinfo, RASET_Vpn);
  1277. }
  1278. else if (pEinfo->pApiArgs->dwFlags & RASEDFLAG_NewDirectEntry)
  1279. {
  1280. EuChangeEntryType (pEinfo, RASET_Direct);
  1281. }
  1282. else if (pEinfo->pApiArgs->dwFlags & RASEDFLAG_NewBroadbandEntry)
  1283. {
  1284. EuChangeEntryType (pEinfo, RASET_Broadband);
  1285. }
  1286. else if (!(pEinfo->pApiArgs->dwFlags & RASEDFLAG_CloneEntry))
  1287. {
  1288. ASSERT (RASET_Phone == pEinfo->pEntry->dwType);
  1289. }
  1290. // Check if ZAW is denying access to the Shared Access UI
  1291. //
  1292. hr = HrCreateNetConnectionUtilities(&pncuu);
  1293. if (SUCCEEDED(hr))
  1294. {
  1295. fShowSharedAccessUi = INetConnectionUiUtilities_UserHasPermission(
  1296. pncuu, NCPERM_ShowSharedAccessUi);
  1297. INetConnectionUiUtilities_Release(pncuu);
  1298. }
  1299. for (i = 0; i < c_cWizPages; i++)
  1300. {
  1301. if (pEinfo->pApiArgs->dwFlags & c_aWizInfo[i].dwConnectionFlags)
  1302. {
  1303. // If the page specifies that it is for shell-owned scenarios
  1304. // only and this is not a shell-owned scenario, then don't add
  1305. // the page to the property sheet. (124654)
  1306. //
  1307. if ((c_aWizInfo[i].dwConnectionFlags & RASEDFLAG_ShellOwned) &&
  1308. !(pEinfo->pApiArgs->dwFlags & RASEDFLAG_ShellOwned))
  1309. {
  1310. continue;
  1311. }
  1312. // HACK: Add the host-side direct connect pages if needed.
  1313. if (c_aWizInfo[i].pfnDlgProc == DCC_HOST_PROCID)
  1314. {
  1315. if (fShellOwned)
  1316. {
  1317. RassrvAddDccWizPages(
  1318. pShellOwnedInfo->pfnAddPage, pShellOwnedInfo->lparam,
  1319. &(pAeinfo->pvDccHostContext) );
  1320. }
  1321. }
  1322. else if ((c_aWizInfo[i].nPageId == PID_SW_SharedAccess) && !fShowSharedAccessUi)
  1323. {
  1324. // Do not add the Shared Access Ui if disallowed by ZAW
  1325. //
  1326. continue;
  1327. }
  1328. else
  1329. {
  1330. // Otherwise, add pages as normal.
  1331. PROPSHEETPAGE page;
  1332. ZeroMemory (&page, sizeof(page));
  1333. page.dwSize = sizeof(PROPSHEETPAGE);
  1334. page.hInstance = g_hinstDll;
  1335. page.pszTemplate = MAKEINTRESOURCE( c_aWizInfo[i].nPageId );
  1336. page.pfnDlgProc = c_aWizInfo[i].pfnDlgProc;
  1337. page.lParam = (LPARAM )pAeinfo;
  1338. if (c_aWizInfo[i].nSidTitle)
  1339. {
  1340. page.dwFlags |= PSP_USEHEADERTITLE;
  1341. page.pszHeaderTitle = PszLoadString( g_hinstDll,
  1342. AeTitle(pEinfo->pApiArgs, c_aWizInfo[i]) ); //For whstler bug 364818
  1343. }
  1344. if(c_aWizInfo[i].nSidSubtitle)
  1345. {
  1346. page.dwFlags |= PSP_USEHEADERSUBTITLE;
  1347. page.pszHeaderSubTitle = PszLoadString( g_hinstDll,
  1348. AeSubTitle(pEinfo->pApiArgs, c_aWizInfo[i]) );
  1349. }
  1350. if (fShellOwned &&
  1351. (PID_ST_Start == c_aWizInfo[i].nPageId))
  1352. {
  1353. page.dwFlags |= PSP_USECALLBACK;
  1354. page.pfnCallback = DestroyStartPageCallback;
  1355. }
  1356. *phpage = CreatePropertySheetPage( &page );
  1357. if (fShellOwned)
  1358. {
  1359. ASSERT (*phpage);
  1360. pShellOwnedInfo->pfnAddPage (*phpage, pShellOwnedInfo->lparam);
  1361. }
  1362. phpage++;
  1363. }
  1364. }
  1365. }
  1366. if (!fShellOwned)
  1367. {
  1368. PROPSHEETHEADER header;
  1369. ZeroMemory( &header, sizeof(header) );
  1370. header.dwSize = sizeof(PROPSHEETHEADER);
  1371. header.dwFlags = PSH_WIZARD | PSH_WIZARD97
  1372. | PSH_WATERMARK | PSH_HEADER
  1373. | PSH_STRETCHWATERMARK;
  1374. header.hwndParent = pEinfo->pApiArgs->hwndOwner;
  1375. header.hInstance = g_hinstDll;
  1376. header.nPages = (ULONG)(phpage - ahpage);
  1377. header.phpage = ahpage;
  1378. header.pszbmHeader = MAKEINTRESOURCE( BID_WizardHeader );
  1379. if (-1 == PropertySheet( &header ))
  1380. {
  1381. TRACE("PropertySheet failed");
  1382. ErrorDlg( pEinfo->pApiArgs->hwndOwner, SID_OP_LoadDlg,
  1383. ERROR_UNKNOWN, NULL );
  1384. }
  1385. AeTerm (pAeinfo);
  1386. }
  1387. }
  1388. //----------------------------------------------------------------------------
  1389. // Add Entry wizard
  1390. // Listed alphabetically
  1391. //----------------------------------------------------------------------------
  1392. AEINFO*
  1393. AeContext(
  1394. IN HWND hwndPage )
  1395. // Retrieve the property sheet context from a wizard page handle.
  1396. //
  1397. {
  1398. return (AEINFO* )GetWindowLongPtr( hwndPage, DWLP_USER );
  1399. }
  1400. void
  1401. AeSetContext(
  1402. IN HWND hwndPage,
  1403. IN LPARAM lparam)
  1404. {
  1405. AEINFO* pInfo = (AEINFO* )(((PROPSHEETPAGE* )lparam)->lParam);
  1406. SetWindowLongPtr( hwndPage, DWLP_USER, (ULONG_PTR )pInfo );
  1407. }
  1408. void
  1409. AeFinish(
  1410. IN AEINFO* pInfo )
  1411. // Saves the contents of the wizard. 'HwndPage is the handle of a
  1412. // property page. Pops up any errors that occur. 'FPropertySheet'
  1413. // indicates the user chose to edit the property sheet directly.
  1414. //
  1415. {
  1416. PBENTRY* pEntry;
  1417. TRACE("AeFinish");
  1418. ASSERT(pInfo);
  1419. pEntry = pInfo->pArgs->pEntry;
  1420. ASSERT(pEntry);
  1421. // Retrieve information from the phone number set of controls.
  1422. //
  1423. if (RASET_Phone == pEntry->dwType)
  1424. {
  1425. PBLINK* pLink;
  1426. DTLNODE* pPhoneNode;
  1427. pLink = (PBLINK* )DtlGetData( pInfo->pArgs->pSharedNode );
  1428. ASSERT( pLink );
  1429. pPhoneNode = FirstPhoneNodeFromPhoneList( pLink->pdtllistPhones );
  1430. if (pPhoneNode)
  1431. {
  1432. CuGetInfo( &pInfo->cuinfo, pPhoneNode );
  1433. FirstPhoneNodeToPhoneList( pLink->pdtllistPhones, pPhoneNode );
  1434. }
  1435. /*
  1436. // Bug #221837: (danielwe) Default to disable file and print sharing
  1437. // for dialup connections.
  1438. //
  1439. pEntry->fShareMsFilePrint = FALSE;
  1440. // Disable File and Print services by default
  1441. //
  1442. EnableOrDisableNetComponent( pEntry, TEXT("ms_server"),
  1443. FALSE);
  1444. */
  1445. }
  1446. // Retrieve the hostname information if this is a Vpn wizard.
  1447. //
  1448. else if (RASET_Vpn == pEntry->dwType)
  1449. {
  1450. // !!! Share code with stuff in PeApply.
  1451. DTLNODE* pNode;
  1452. PBLINK* pLink;
  1453. PBPHONE* pPhone;
  1454. // Save host name, i.e. the VPN phone number.
  1455. //
  1456. pNode = DtlGetFirstNode( pEntry->pdtllistLinks );
  1457. ASSERT( pNode );
  1458. pLink = (PBLINK* )DtlGetData( pNode );
  1459. pNode = FirstPhoneNodeFromPhoneList( pLink->pdtllistPhones );
  1460. if(NULL == pNode)
  1461. {
  1462. return;
  1463. }
  1464. pPhone = (PBPHONE* )DtlGetData( pNode );
  1465. Free0( pPhone->pszPhoneNumber );
  1466. pPhone->pszPhoneNumber = GetText( pInfo->hwndEbHostName );
  1467. FirstPhoneNodeToPhoneList( pLink->pdtllistPhones, pNode );
  1468. // Whistler bug 312921
  1469. //
  1470. // Default the "automatic" setting in the ui to mean
  1471. // "try pptp first". This is because in the Whistler timeframe
  1472. // we found that l2tp/ipsec was not being widely deployed so
  1473. // people were more commonly getting unneccessary timeout delays
  1474. // while the client would attempt l2tp to no avail.
  1475. //
  1476. pEntry->dwVpnStrategy = VS_PptpFirst;
  1477. }
  1478. // Retrieve the service name information if this is a broadband wizard.
  1479. //
  1480. else if (RASET_Broadband == pEntry->dwType)
  1481. {
  1482. // !!! Share code with stuff in PeApply.
  1483. DTLNODE* pNode;
  1484. PBLINK* pLink;
  1485. PBPHONE* pPhone;
  1486. // Save service name, i.e. the broadband phone number.
  1487. //
  1488. pNode = DtlGetFirstNode( pEntry->pdtllistLinks );
  1489. ASSERT( pNode );
  1490. pLink = (PBLINK* )DtlGetData( pNode );
  1491. pNode = FirstPhoneNodeFromPhoneList( pLink->pdtllistPhones );
  1492. if(NULL == pNode)
  1493. {
  1494. return;
  1495. }
  1496. pPhone = (PBPHONE* )DtlGetData( pNode );
  1497. Free0( pPhone->pszPhoneNumber );
  1498. pPhone->pszPhoneNumber = GetText( pInfo->hwndEbBroadbandService );
  1499. FirstPhoneNodeToPhoneList( pLink->pdtllistPhones, pNode );
  1500. // 222177, pppoe connections should default to unsecure
  1501. //
  1502. pEntry->dwTypicalAuth = TA_Unsecure;
  1503. pEntry->dwAuthRestrictions =
  1504. AuthRestrictionsFromTypicalAuth(TA_Unsecure);
  1505. }
  1506. else if ( RASET_Direct == pEntry->dwType )
  1507. {
  1508. PBLINK* pLink = NULL;
  1509. DTLNODE* pNode = NULL;
  1510. // The currently enabled device is the one
  1511. // that should be used for the connection. Only
  1512. // one device will be enabled (DnUpdateSelectedDevice).
  1513. for (pNode = DtlGetFirstNode( pEntry->pdtllistLinks );
  1514. pNode;
  1515. pNode = DtlGetNextNode( pNode ))
  1516. {
  1517. pLink = (PBLINK* )DtlGetData( pNode );
  1518. ASSERT(pLink);
  1519. if ( pLink->fEnabled )
  1520. break;
  1521. }
  1522. // If we found a link successfully, deal with it
  1523. // now.
  1524. if ( pLink && pLink->fEnabled )
  1525. {
  1526. if (pLink->pbport.pbdevicetype == PBDT_ComPort)
  1527. {
  1528. // Install the null modem
  1529. MdmInstallNullModem (pLink->pbport.pszPort);
  1530. // Delete the bogus device name. This will cause
  1531. // the device to automatically be mapped to the
  1532. // null modem we just installed when the phonebook
  1533. // is next read.
  1534. Free0 ( pLink->pbport.pszDevice );
  1535. pLink->pbport.pszDevice = NULL;
  1536. }
  1537. }
  1538. // DCC guest should by default enable LM Hash in MSCHAPv1
  1539. // Whistler bug 216458
  1540. //
  1541. pEntry->dwAuthRestrictions |= AR_F_AuthW95MSCHAP | AR_F_AuthCustom;
  1542. }
  1543. // If the user opted to use his/her smart card for this
  1544. // connection, set up the entry accordingly now.
  1545. if ( ( pInfo->fSmartCardInstalled ) &&
  1546. ( pInfo->fUseSmartCard ) )
  1547. {
  1548. pEntry->dwAuthRestrictions = AR_F_TypicalCardOrCert;
  1549. pEntry->dwTypicalAuth = TA_CardOrCert;
  1550. pEntry->dwCustomAuthKey = EAPCFG_DefaultKey;
  1551. pEntry->dwDataEncryption = DE_Require;
  1552. }
  1553. // Default Software compression ON.
  1554. // For whistler bug 410725 gangz
  1555. // We turn off Sofware compression for PPPoE, RFC 2516
  1556. //
  1557. // Per bug 483599 turn off compression for VPN by default
  1558. //
  1559. if (RASET_Broadband == pEntry->dwType ||
  1560. RASET_Vpn == pEntry->dwType )
  1561. {
  1562. pEntry->fSwCompression = FALSE;
  1563. // For BillG's bug 511663, Enable redial on link failure for VPN and
  1564. // PPPoE connections by default
  1565. //
  1566. pEntry->fRedialOnLinkFailure = TRUE;
  1567. }
  1568. else
  1569. {
  1570. pEntry->fSwCompression = TRUE;
  1571. }
  1572. // Set the appropriate defaults if this is an "Internet"
  1573. // connection
  1574. //
  1575. if ((pInfo->pArgs->pApiArgs->dwFlags & RASEDFLAG_InternetEntry) ||
  1576. (RASET_Broadband == pEntry->dwType)) // all broadband are to Internet
  1577. {
  1578. // IP only
  1579. //
  1580. pEntry->dwfExcludedProtocols |= (NP_Nbf | NP_Ipx);
  1581. // Disable file and print sharing
  1582. //
  1583. pEntry->fShareMsFilePrint = FALSE;
  1584. pEntry->fBindMsNetClient = FALSE;
  1585. EnableOrDisableNetComponent( pEntry, TEXT("ms_server"), FALSE);
  1586. EnableOrDisableNetComponent( pEntry, TEXT("ms_msclient"), FALSE);
  1587. pEntry->dwIpNbtFlags = 0;
  1588. // Add default idle timeout for whistler bug 307969 gangz
  1589. //
  1590. if ( RASET_Phone == pEntry->dwType )
  1591. {
  1592. pEntry->lIdleDisconnectSeconds = 1200;
  1593. }
  1594. else
  1595. {
  1596. pEntry->lIdleDisconnectSeconds = 0;
  1597. }
  1598. // Enable PAP -- most common to ISPs
  1599. //
  1600. pEntry->dwTypicalAuth = TA_Unsecure;
  1601. pEntry->dwAuthRestrictions =
  1602. AuthRestrictionsFromTypicalAuth(pEntry->dwTypicalAuth);
  1603. // Do not include a domain -- not logging into secure domain
  1604. //
  1605. pEntry->fPreviewDomain = FALSE;
  1606. // Record that this is a connection to the Internet
  1607. //
  1608. pEntry->dwUseFlags |= PBK_ENTRY_USE_F_Internet;
  1609. }
  1610. // It's a valid new entry and caller has not chosen to edit properties
  1611. // directly, so mark the entry for commitment.
  1612. //
  1613. if (!pInfo->pArgs->fChainPropertySheet)
  1614. pInfo->pArgs->fCommit = TRUE;
  1615. }
  1616. DWORD
  1617. AeInit(
  1618. IN HWND hwndParent,
  1619. IN EINFO* pArgs,
  1620. OUT AEINFO** ppInfo )
  1621. // Wizard level initialization. 'HwndPage' is the handle of the first
  1622. // page. 'pInfo' is the common entry input argument block.
  1623. //
  1624. // Returns address of the context block if successful, NULL otherwise. If
  1625. // NULL is returned, an appropriate message has been displayed, and the
  1626. // wizard has been cancelled.
  1627. //
  1628. {
  1629. AEINFO* pInfo;
  1630. TRACE("AeInit");
  1631. *ppInfo = NULL;
  1632. pInfo = Malloc( sizeof(AEINFO) );
  1633. if (!pInfo)
  1634. {
  1635. return ERROR_NOT_ENOUGH_MEMORY;
  1636. }
  1637. *ppInfo = pInfo;
  1638. ZeroMemory( pInfo, sizeof(*pInfo) );
  1639. pInfo->pArgs = pArgs;
  1640. if ( pArgs->fRouter )
  1641. {
  1642. INTERNALARGS *pIArgs = (INTERNALARGS *) pArgs->pApiArgs->reserved;
  1643. // Check for installed protocols over router and RasServer if router
  1644. // bit is set.
  1645. //
  1646. pInfo->dwfConfiguredProtocols =
  1647. g_pGetInstalledProtocolsEx((pIArgs) ? pIArgs->hConnection : NULL,
  1648. TRUE, FALSE, TRUE);
  1649. }
  1650. else
  1651. {
  1652. INTERNALARGS *pIArgs = (INTERNALARGS *) pArgs->pApiArgs->reserved;
  1653. // Check over which protocols is dial up client enabled.
  1654. //
  1655. pInfo->dwfConfiguredProtocols = g_pGetInstalledProtocolsEx(
  1656. (pIArgs) ?
  1657. pIArgs->hConnection :
  1658. NULL, FALSE, TRUE, FALSE);
  1659. }
  1660. pInfo->fIpConfigured = (pInfo->dwfConfiguredProtocols & NP_Ip);
  1661. //initialization for RasWizGetNCCFlags()
  1662. //
  1663. pInfo->fCreateForAllUsers = TRUE; //for this for Dt Page
  1664. pInfo->fFirewall = FALSE;
  1665. pInfo->pArgs->fGlobalCred = FALSE;
  1666. pInfo->pArgs->fDefInternet = FALSE;
  1667. // For whistler 506917 gangz
  1668. // Actually, pArgs(EINFO) is already initialized in EuInit(), just in case
  1669. // of some future change
  1670. //
  1671. pInfo->pArgs->pszDefUserName = NULL;
  1672. pInfo->pArgs->pszDefPassword = NULL ;
  1673. return ERROR_SUCCESS;
  1674. }
  1675. VOID
  1676. AeTerm(
  1677. IN AEINFO* pInfo )
  1678. {
  1679. TRACE("AeTerm");
  1680. if (pInfo)
  1681. {
  1682. if (pInfo->hwndLbDialFirst)
  1683. {
  1684. PnClearLbDialFirst( pInfo->hwndLbDialFirst );
  1685. }
  1686. if (pInfo->hfontBold)
  1687. {
  1688. DeleteObject (pInfo->hfontBold);
  1689. }
  1690. if (pInfo->pListAreaCodes)
  1691. {
  1692. DtlDestroyList( pInfo->pListAreaCodes, DestroyPszNode );
  1693. }
  1694. if (pInfo->fCuInfoInitialized)
  1695. {
  1696. CuFree( &pInfo->cuinfo );
  1697. }
  1698. Free (pInfo);
  1699. }
  1700. }
  1701. //This broadband serice page is shared by AiWizard(ifw.c) and AeWizard(in entryw.c)
  1702. //
  1703. //----------------------------------------------------------------------------
  1704. // Broadband service dialog procedure
  1705. // Listed alphabetically following dialog proc
  1706. //----------------------------------------------------------------------------
  1707. INT_PTR CALLBACK
  1708. BsDlgProc(
  1709. IN HWND hwnd,
  1710. IN UINT unMsg,
  1711. IN WPARAM wparam,
  1712. IN LPARAM lparam )
  1713. // DialogProc callback for the broadband service page of the wizard. Parameters
  1714. // and return value are as described for standard windows 'DialogProc's.
  1715. //
  1716. {
  1717. switch (unMsg)
  1718. {
  1719. case WM_INITDIALOG:
  1720. AeSetContext( hwnd, lparam );
  1721. return BsInit( hwnd );
  1722. case WM_NOTIFY:
  1723. {
  1724. switch (((NMHDR* )lparam)->code)
  1725. {
  1726. case PSN_SETACTIVE:
  1727. {
  1728. AEINFO* pInfo;
  1729. BOOL fDisplay;
  1730. TRACE("BsSETACTIVE");
  1731. pInfo = AeContext( hwnd );
  1732. ASSERT(pInfo);
  1733. fDisplay = BsSetActive( pInfo );
  1734. SetWindowLong( hwnd, DWLP_MSGRESULT, (fDisplay) ? 0 : -1 );
  1735. return TRUE;
  1736. }
  1737. case PSN_KILLACTIVE:
  1738. {
  1739. AEINFO* pInfo;
  1740. BOOL fInvalid;
  1741. TRACE("BsKILLACTIVE");
  1742. pInfo = AeContext( hwnd );
  1743. ASSERT(pInfo);
  1744. fInvalid = BsKillActive( pInfo );
  1745. SetWindowLong( hwnd, DWLP_MSGRESULT, fInvalid );
  1746. return TRUE;
  1747. }
  1748. }
  1749. break;
  1750. }
  1751. }
  1752. return FALSE;
  1753. }
  1754. BOOL
  1755. BsInit(
  1756. IN HWND hwndPage )
  1757. // Called on WM_INITDIALOG. 'hwndPage' is the handle of the property
  1758. // page.
  1759. //
  1760. // Return false if focus was set, true otherwise.
  1761. //
  1762. {
  1763. AEINFO* pInfo;
  1764. TRACE("BsInit");
  1765. pInfo = AeContext( hwndPage );
  1766. if (!pInfo)
  1767. return TRUE;
  1768. // Initialize page-specific context information.
  1769. //
  1770. pInfo->hwndBs = hwndPage;
  1771. pInfo->hwndEbBroadbandService =
  1772. GetDlgItem( hwndPage, CID_BS_EB_ServiceName );
  1773. ASSERT(pInfo->hwndEbBroadbandService);
  1774. Edit_LimitText( pInfo->hwndEbBroadbandService, RAS_MaxPhoneNumber );
  1775. return TRUE;
  1776. }
  1777. BOOL
  1778. BsKillActive(
  1779. IN AEINFO* pInfo )
  1780. // Called when PSN_KILLACTIVE is received. 'PInfo' is the wizard context.
  1781. //
  1782. // Returns true if the page is invalid, false is it can be dismissed.
  1783. //
  1784. {
  1785. return FALSE;
  1786. }
  1787. BOOL
  1788. BsSetActive(
  1789. IN AEINFO* pInfo )
  1790. // Called when PSN_SETACTIVE is received. 'PInfo' is the wizard context.
  1791. //
  1792. // Returns true to display the page, false to skip it.
  1793. //
  1794. {
  1795. BOOL fDisplayPage;
  1796. PBENTRY* pEntry;
  1797. ASSERT(pInfo);
  1798. //For bug 364818, we decide to remove Broadband's service name
  1799. //From the NCW gang
  1800. //
  1801. return FALSE;
  1802. /*
  1803. pEntry = pInfo->pArgs->pEntry;
  1804. if (RASET_Broadband != pEntry->dwType)
  1805. {
  1806. fDisplayPage = FALSE;
  1807. }
  1808. else
  1809. {
  1810. LPARAM dwWizButtons = PSWIZB_NEXT;
  1811. DWORD dwFlags = pInfo->pArgs->pApiArgs->dwFlags;
  1812. // Show the back button if we're shell owned or we have the
  1813. // LA page before us.
  1814. //
  1815. if ((dwFlags & RASEDFLAG_ShellOwned) ||
  1816. !(dwFlags & RASEDFLAG_NewTunnelEntry))
  1817. {
  1818. dwWizButtons |= PSWIZB_BACK;
  1819. }
  1820. PropSheet_SetWizButtons( pInfo->hwndDlg, dwWizButtons );
  1821. fDisplayPage = TRUE;
  1822. }
  1823. return fDisplayPage;
  1824. */
  1825. }
  1826. //Add ConnectionName Dialog proc for whistler bug 328673
  1827. //
  1828. //----------------------------------------------------------------------------
  1829. // Connection Name property page, this is only for shellowned, the filtering
  1830. // is already done in AeWizard()
  1831. // Listed alphabetically following dialog proc
  1832. //----------------------------------------------------------------------------
  1833. INT_PTR CALLBACK
  1834. CnDlgProc(
  1835. IN HWND hwnd,
  1836. IN UINT unMsg,
  1837. IN WPARAM wparam,
  1838. IN LPARAM lparam )
  1839. // DialogProc callback for the Connection Name page of the wizard.
  1840. // Parameters and return value are as described for standard windows
  1841. // 'DialogProc's.
  1842. //
  1843. {
  1844. switch (unMsg)
  1845. {
  1846. case WM_INITDIALOG:
  1847. AeSetContext( hwnd, lparam );
  1848. return CnInit( hwnd );
  1849. case WM_NOTIFY:
  1850. {
  1851. switch (((NMHDR* )lparam)->code)
  1852. {
  1853. case PSN_SETACTIVE:
  1854. {
  1855. AEINFO* pInfo;
  1856. BOOL fDisplay;
  1857. TRACE("CnSETACTIVE");
  1858. pInfo = AeContext( hwnd );
  1859. ASSERT(pInfo);
  1860. fDisplay = CnSetActive( pInfo );
  1861. SetWindowLong( hwnd, DWLP_MSGRESULT, (fDisplay) ? 0 : -1 );
  1862. return TRUE;
  1863. }
  1864. case PSN_KILLACTIVE:
  1865. {
  1866. AEINFO* pInfo;
  1867. BOOL fInvalid;
  1868. TRACE("CnKILLACTIVE");
  1869. pInfo = AeContext( hwnd );
  1870. ASSERT(pInfo);
  1871. fInvalid = CnKillActive( pInfo );
  1872. SetWindowLong( hwnd, DWLP_MSGRESULT, fInvalid );
  1873. return TRUE;
  1874. }
  1875. case PSN_WIZNEXT:
  1876. {
  1877. AEINFO* pInfo;
  1878. TRACE("CnNEXT");
  1879. pInfo = AeContext( hwnd );
  1880. ASSERT(pInfo);
  1881. pInfo->fCnWizNext = TRUE;
  1882. SetWindowLong( hwnd, DWLP_MSGRESULT, FALSE );
  1883. return TRUE;
  1884. }
  1885. }
  1886. break;
  1887. }
  1888. }
  1889. return FALSE;
  1890. }
  1891. BOOL
  1892. CnInit(
  1893. IN HWND hwndPage )
  1894. // Called on WM_INITDIALOG. 'hwndPage' is the handle of the property
  1895. // page.
  1896. //
  1897. // Return false if focus was set, true otherwise.
  1898. //
  1899. {
  1900. AEINFO* pInfo;
  1901. TRACE("CnInit");
  1902. pInfo = AeContext( hwndPage );
  1903. if (!pInfo)
  1904. {
  1905. return TRUE;
  1906. }
  1907. // A DCC host conneciton will be forward to the incoming connection path
  1908. //
  1909. if ( pInfo->fDccHost )
  1910. {
  1911. return TRUE;
  1912. }
  1913. //This page wont be available for rasphone.exe
  1914. //the filtering is done in AeWizard
  1915. //
  1916. pInfo->hwndCn = hwndPage;
  1917. pInfo->hwndCnEbConnectionName = GetDlgItem( hwndPage, CID_CN_EB_ConnectionName );
  1918. ASSERT(pInfo->hwndCnEbConnectionName);
  1919. pInfo->hwndCnStHMsg = GetDlgItem( hwndPage, CID_CN_ST_HMsg );
  1920. ASSERT(pInfo->hwndCnStHMsg);
  1921. pInfo->hwndCnStHMsg2 = GetDlgItem( hwndPage, CID_CN_ST_HMsg2 );
  1922. ASSERT(pInfo->hwndCnStHMsg2);
  1923. pInfo->hwndCnName = GetDlgItem( hwndPage, CID_CN_Name );
  1924. ASSERT(pInfo->hwndCnName);
  1925. //the length does NOT include the terminating NULL character
  1926. //in order to match the RasWizGetUserInputConnectionName()
  1927. //we need to minus one from the lenght limit
  1928. //
  1929. //
  1930. //For whistler bug 270255, for the sake of creating short cut which will be placed
  1931. //under "Documents and Setttings\...", we dynamically limit the maximum connection
  1932. //name
  1933. //
  1934. {
  1935. long lPathLen = 0;
  1936. WCHAR szPath[MAX_PATH];
  1937. if (SHGetSpecialFolderPath(hwndPage,
  1938. szPath,
  1939. CSIDL_DESKTOPDIRECTORY,
  1940. FALSE))
  1941. {
  1942. lPathLen = wcslen(szPath);
  1943. }
  1944. if (SHGetSpecialFolderPath(hwndPage,
  1945. szPath,
  1946. CSIDL_COMMON_DESKTOPDIRECTORY,
  1947. FALSE))
  1948. {
  1949. lPathLen = max(lPathLen, (long)wcslen(szPath));
  1950. }
  1951. // We need to take the following lengths into acount:
  1952. // "\\\\?\\" - 4
  1953. // "(path)" - dwPathLen (Desktop path)
  1954. // "\\" - 1
  1955. // "(connection name)" - rest from MAX_PATH
  1956. // "(number)" - 5 (duplicate counter, should not exceed 5 digits)
  1957. // ".lnk" - 4
  1958. // "\0" - 1
  1959. ASSERT( 9 < (MAX_PATH - lPathLen - 15));
  1960. if( 9 >= (MAX_PATH - lPathLen - 15) )
  1961. {
  1962. MAX_ENTERCONNECTIONNAME = 9; //We sacrifice the shortcut for the NCW task
  1963. }
  1964. else
  1965. {
  1966. MAX_ENTERCONNECTIONNAME = min(MAX_ENTERCONNECTIONNAME,
  1967. MAX_PATH - lPathLen - 15);
  1968. }
  1969. }
  1970. Edit_LimitText( pInfo->hwndCnEbConnectionName, MAX_ENTERCONNECTIONNAME-1);//RAS_MaxEntryName );
  1971. // Set the static text box
  1972. //
  1973. {
  1974. DWORD dwFlags;
  1975. TCHAR *pszMsg = NULL, *pszSubTitle = NULL, *pszMsg2 = NULL, *pszName=NULL;
  1976. HWND hwndHMsg = NULL, hwndPageTmp = NULL, hwndHMsg2 = NULL, hwndName = NULL;
  1977. hwndHMsg = pInfo->hwndCnStHMsg;
  1978. hwndHMsg2 = pInfo->hwndCnStHMsg2;
  1979. hwndPageTmp = pInfo->hwndCn;
  1980. hwndName = pInfo->hwndCnName;
  1981. if(!hwndHMsg || !hwndPageTmp || !hwndHMsg2 ||!hwndName)
  1982. {
  1983. return FALSE;
  1984. }
  1985. //Set the message on this page, the subtitle is set in AeWizard
  1986. //by help function AeSubTitle()
  1987. //
  1988. {
  1989. dwFlags = pInfo->pArgs->pApiArgs->dwFlags;
  1990. if (dwFlags & RASEDFLAG_NewDirectEntry)
  1991. {
  1992. pszMsg = PszFromId( g_hinstDll, SID_CN_HMsgDccGuest );
  1993. pszName = PszFromId( g_hinstDll, SID_CN_NameDccGuest );
  1994. }
  1995. else if( dwFlags & RASEDFLAG_InternetEntry)
  1996. {
  1997. pszMsg = PszFromId( g_hinstDll, SID_CN_HMsgInternet );
  1998. pszName = PszFromId( g_hinstDll, SID_CN_NameInternet );
  1999. }
  2000. else
  2001. {
  2002. pszMsg = PszFromId( g_hinstDll, SID_CN_HMsgWork );
  2003. pszMsg2 = PszFromId( g_hinstDll, SID_CN_HMsgWork2 );
  2004. pszName = PszFromId( g_hinstDll, SID_CN_NameWork );
  2005. }
  2006. }
  2007. if(pszMsg)
  2008. {
  2009. if(hwndHMsg)
  2010. {
  2011. SetWindowText(hwndHMsg, pszMsg);
  2012. }
  2013. Free(pszMsg);
  2014. }
  2015. if (pszMsg2)
  2016. {
  2017. if(hwndHMsg2)
  2018. {
  2019. SetWindowText(hwndHMsg2, pszMsg2);
  2020. }
  2021. Free(pszMsg2);
  2022. }
  2023. if (pszName)
  2024. {
  2025. if(hwndName)
  2026. {
  2027. SetWindowText(hwndName, pszName);
  2028. }
  2029. Free(pszName);
  2030. }
  2031. }
  2032. return TRUE;
  2033. }
  2034. //For whistler bug 346886
  2035. //
  2036. BOOL CnValidName(TCHAR * pszSrc)
  2037. {
  2038. WCHAR pszwInvalidChars[] = L"\\/:*?\"<>|\t";
  2039. WCHAR * pszwSrc=NULL;
  2040. BOOL fValid = TRUE;
  2041. if(!pszSrc)
  2042. {
  2043. return FALSE;
  2044. }
  2045. pszwSrc = StrDupWFromT(pszSrc);
  2046. ASSERT(pszwSrc);
  2047. if(!pszwSrc)
  2048. {
  2049. return TRUE;
  2050. }
  2051. fValid= ( !wcspbrk( pszwSrc, pszwInvalidChars ) )?TRUE:FALSE;
  2052. return fValid;
  2053. }
  2054. BOOL
  2055. CnKillActive(
  2056. IN AEINFO* pInfo)
  2057. // Called when PSN_KILLACTIVE is received. 'PInfo' is the wizard context.
  2058. //
  2059. // Returns true if the page is invalid, false is it can be dismissed.
  2060. //
  2061. {
  2062. TCHAR* psz = NULL;
  2063. TRACE("CnKillActive");
  2064. // A DCC host conneciton will be forward to the incoming connection path
  2065. //
  2066. if ( pInfo->fDccHost )
  2067. {
  2068. return FALSE;
  2069. }
  2070. Free0( pInfo->pArgs->pEntry->pszEntryName );
  2071. pInfo->pArgs->pEntry->pszEntryName = NULL;
  2072. //this GetText will always return an allocated buffer if memory
  2073. //is availabe, if user input nothing, it will return a string has
  2074. //only a NULL termination, TEXT('\0');
  2075. //
  2076. psz = GetText( pInfo->hwndCnEbConnectionName );
  2077. if (psz)
  2078. {
  2079. // Update the entry name from the editbox.
  2080. // We wont enfore a name to be entered, we also wont check if the
  2081. // the name entered here is a duplicate, because it is just part
  2082. // of the final name
  2083. //
  2084. // Validate the entry name. It cannot begin with a "."
  2085. //
  2086. if( pInfo->fCnWizNext )
  2087. {
  2088. pInfo->fCnWizNext = FALSE;
  2089. if ( 0 < lstrlen( psz ) &&
  2090. ( (psz[ 0 ] == TEXT('.') ) ||
  2091. !CnValidName(psz) )
  2092. )
  2093. {
  2094. Free0(psz);
  2095. MsgDlg( pInfo->hwndDlg, SID_BadEntryWithDot, NULL );
  2096. SetFocus( pInfo->hwndCnEbConnectionName );
  2097. Edit_SetSel( pInfo->hwndCnEbConnectionName, 0, -1 );
  2098. return TRUE;
  2099. }
  2100. }
  2101. if( TEXT('\0') != psz[0] )
  2102. {
  2103. pInfo->pArgs->pEntry->pszEntryName = psz;
  2104. }
  2105. else
  2106. {
  2107. Free0(psz);
  2108. }
  2109. }
  2110. return FALSE;
  2111. }
  2112. BOOL
  2113. CnSetActive(
  2114. IN AEINFO* pInfo )
  2115. // Called when PSN_SETACTIVE is received. 'PInfo' is the wizard context.
  2116. //
  2117. // Returns true to display the page, false to skip it.
  2118. //
  2119. {
  2120. TRACE("CnSetActive");
  2121. // A DCC host conneciton will be forward to the incoming connection path
  2122. //
  2123. if ( pInfo->fDccHost )
  2124. {
  2125. /*
  2126. //when forwarded to incoming connection path, there is no Connection page
  2127. //beside, the incoming conneciton's name is not changable,
  2128. //so we remove the possible entered connection by previous given path
  2129. //like the DCC guest path
  2130. //
  2131. Free0( pInfo->pArgs->pEntry->pszEntryName );
  2132. pInfo->pArgs->pEntry->pszEntryName = NULL;
  2133. */
  2134. return FALSE;
  2135. }
  2136. PropSheet_SetWizButtons( pInfo->hwndDlg, PSWIZB_BACK | PSWIZB_NEXT );
  2137. return TRUE;
  2138. }
  2139. //----------------------------------------------------------------------------
  2140. // Destination property page
  2141. // Listed alphabetically following dialog proc
  2142. //----------------------------------------------------------------------------
  2143. INT_PTR CALLBACK
  2144. DaDlgProc(
  2145. IN HWND hwnd,
  2146. IN UINT unMsg,
  2147. IN WPARAM wparam,
  2148. IN LPARAM lparam )
  2149. // DialogProc callback for the Destination page of the wizard. Parameters
  2150. // and return value are as described for standard windows 'DialogProc's.
  2151. //
  2152. {
  2153. switch (unMsg)
  2154. {
  2155. case WM_INITDIALOG:
  2156. AeSetContext( hwnd, lparam );
  2157. return DaInit( hwnd );
  2158. case WM_NOTIFY:
  2159. {
  2160. switch (((NMHDR* )lparam)->code)
  2161. {
  2162. case PSN_SETACTIVE:
  2163. {
  2164. AEINFO* pInfo;
  2165. BOOL fDisplay;
  2166. TRACE("DaSETACTIVE");
  2167. pInfo = AeContext( hwnd );
  2168. ASSERT(pInfo);
  2169. fDisplay = DaSetActive( pInfo );
  2170. SetWindowLong( hwnd, DWLP_MSGRESULT, (fDisplay) ? 0 : -1 );
  2171. return TRUE;
  2172. }
  2173. case PSN_KILLACTIVE:
  2174. {
  2175. AEINFO* pInfo;
  2176. BOOL fInvalid;
  2177. TRACE("DaKILLACTIVE");
  2178. pInfo = AeContext( hwnd );
  2179. ASSERT(pInfo);
  2180. fInvalid = DaKillActive( pInfo );
  2181. SetWindowLong( hwnd, DWLP_MSGRESULT, fInvalid );
  2182. return TRUE;
  2183. }
  2184. }
  2185. break;
  2186. }
  2187. }
  2188. return FALSE;
  2189. }
  2190. BOOL
  2191. DaInit(
  2192. IN HWND hwndPage )
  2193. // Called on WM_INITDIALOG. 'hwndPage' is the handle of the property
  2194. // page.
  2195. //
  2196. // Return false if focus was set, true otherwise.
  2197. //
  2198. {
  2199. AEINFO* pInfo;
  2200. TRACE("DaInit");
  2201. pInfo = AeContext( hwndPage );
  2202. if (!pInfo)
  2203. return TRUE;
  2204. // Initialize page-specific context information.
  2205. //
  2206. pInfo->hwndDa = hwndPage;
  2207. pInfo->hwndEbHostName = GetDlgItem( hwndPage, CID_DA_EB_HostName );
  2208. ASSERT(pInfo->hwndEbHostName);
  2209. Edit_LimitText( pInfo->hwndEbHostName, RAS_MaxPhoneNumber );
  2210. return TRUE;
  2211. }
  2212. BOOL
  2213. DaKillActive(
  2214. IN AEINFO* pInfo )
  2215. // Called when PSN_KILLACTIVE is received. 'PInfo' is the wizard context.
  2216. //
  2217. // Returns true if the page is invalid, false is it can be dismissed.
  2218. //
  2219. {
  2220. return FALSE;
  2221. }
  2222. BOOL
  2223. DaSetActive(
  2224. IN AEINFO* pInfo )
  2225. // Called when PSN_SETACTIVE is received. 'PInfo' is the wizard context.
  2226. //
  2227. // Returns true to display the page, false to skip it.
  2228. //
  2229. {
  2230. BOOL fDisplayPage;
  2231. PBENTRY* pEntry;
  2232. ASSERT(pInfo);
  2233. pEntry = pInfo->pArgs->pEntry;
  2234. if (RASET_Vpn != pEntry->dwType)
  2235. {
  2236. fDisplayPage = FALSE;
  2237. }
  2238. else
  2239. {
  2240. LPARAM dwWizButtons = PSWIZB_NEXT;
  2241. DWORD dwFlags = pInfo->pArgs->pApiArgs->dwFlags;
  2242. // Show the back button if we're shell owned or, we have the
  2243. // La page or the Pn page before us.
  2244. //
  2245. if ((dwFlags & RASEDFLAG_ShellOwned) ||
  2246. !(dwFlags & RASEDFLAG_NewTunnelEntry) ||
  2247. !pInfo->fHidePublicNetworkPage)
  2248. {
  2249. dwWizButtons |= PSWIZB_BACK;
  2250. }
  2251. PropSheet_SetWizButtons( pInfo->hwndDlg, dwWizButtons );
  2252. fDisplayPage = TRUE;
  2253. }
  2254. return fDisplayPage;
  2255. }
  2256. //----------------------------------------------------------------------------
  2257. // Default inTernet wizard page
  2258. // This is a personal-sku only page.
  2259. //----------------------------------------------------------------------------
  2260. INT_PTR CALLBACK
  2261. DtDlgProc(
  2262. IN HWND hwnd,
  2263. IN UINT unMsg,
  2264. IN WPARAM wparam,
  2265. IN LPARAM lparam )
  2266. // DialogProc callback for the Default inTernet page of the wizard.
  2267. // Parameters and return value are as described for standard
  2268. // windows 'DialogProc's.
  2269. //
  2270. {
  2271. switch (unMsg)
  2272. {
  2273. case WM_INITDIALOG:
  2274. AeSetContext( hwnd, lparam );
  2275. return DtInit( hwnd );
  2276. case WM_NOTIFY:
  2277. {
  2278. switch (((NMHDR* )lparam)->code)
  2279. {
  2280. case PSN_SETACTIVE:
  2281. {
  2282. AEINFO* pInfo;
  2283. BOOL fDisplay;
  2284. TRACE("DtSETACTIVE");
  2285. pInfo = AeContext( hwnd );
  2286. ASSERT(pInfo);
  2287. fDisplay = DtSetActive( pInfo );
  2288. SetWindowLong( hwnd, DWLP_MSGRESULT, (fDisplay) ? 0 : -1 );
  2289. return TRUE;
  2290. }
  2291. case PSN_KILLACTIVE:
  2292. {
  2293. AEINFO* pInfo;
  2294. BOOL fInvalid;
  2295. TRACE("DtKILLACTIVE");
  2296. pInfo = AeContext( hwnd );
  2297. ASSERT(pInfo);
  2298. fInvalid = DtKillActive( pInfo );
  2299. SetWindowLong( hwnd, DWLP_MSGRESULT, fInvalid );
  2300. return TRUE;
  2301. }
  2302. }
  2303. break;
  2304. }
  2305. }
  2306. return FALSE;
  2307. }
  2308. DWORD
  2309. DtEnableDisableControls(
  2310. IN AEINFO* pInfo,
  2311. IN BOOL fEnable)
  2312. {
  2313. EnableWindow(pInfo->hwndDtEbUserName, fEnable );
  2314. EnableWindow(pInfo->hwndDtEbPassword, fEnable );
  2315. EnableWindow(pInfo->hwndDtEbPassword2, fEnable );
  2316. EnableWindow(pInfo->hwndDtStUserName, fEnable );
  2317. EnableWindow(pInfo->hwndDtStPassword, fEnable );
  2318. EnableWindow(pInfo->hwndDtStPassword2, fEnable );
  2319. return NO_ERROR;
  2320. }
  2321. BOOL
  2322. DtInit(
  2323. IN HWND hwndPage )
  2324. // Called on WM_INITDIALOG. 'hwndPage' is the handle of the property
  2325. // page.
  2326. //
  2327. // Return false if focus was set, true otherwise.
  2328. //
  2329. {
  2330. AEINFO* pInfo;
  2331. BOOL fWork = FALSE;
  2332. TRACE("DtInit");
  2333. pInfo = AeContext( hwndPage );
  2334. if (!pInfo)
  2335. return TRUE;
  2336. // Initialize page-specific context information.
  2337. //
  2338. pInfo->hwndDt = hwndPage;
  2339. pInfo->hwndDtCbFirewall = GetDlgItem( hwndPage, CID_DT_CB_Firewall );
  2340. pInfo->hwndDtCbDefault = GetDlgItem( hwndPage, CID_DT_CB_Default );
  2341. pInfo->hwndDtEbUserName = GetDlgItem( hwndPage, CID_DT_EB_UserName );
  2342. pInfo->hwndDtEbPassword = GetDlgItem( hwndPage, CID_DT_EB_Password );
  2343. pInfo->hwndDtEbPassword2= GetDlgItem( hwndPage, CID_DT_EB_Password2 );
  2344. pInfo->hwndDtStUserName = GetDlgItem( hwndPage, CID_DT_ST_UserName );
  2345. pInfo->hwndDtStPassword = GetDlgItem( hwndPage, CID_DT_ST_Password );
  2346. pInfo->hwndDtStPassword2= GetDlgItem( hwndPage, CID_DT_ST_Password2 );
  2347. pInfo->hwndDtCbUseCredentials =
  2348. GetDlgItem( hwndPage, CID_DT_CB_UseSharedCredentials );
  2349. Edit_LimitText( pInfo->hwndDtEbUserName, UNLEN );
  2350. Edit_LimitText( pInfo->hwndDtEbPassword, PWLEN );
  2351. Edit_LimitText( pInfo->hwndDtEbPassword2, PWLEN );
  2352. {
  2353. DWORD dwFlags = pInfo->pArgs->pApiArgs->dwFlags;
  2354. if ( dwFlags & RASEDFLAG_NewDirectEntry ||
  2355. dwFlags & RASEDFLAG_InternetEntry )
  2356. {
  2357. fWork = FALSE;
  2358. }
  2359. else
  2360. {
  2361. fWork = TRUE;
  2362. }
  2363. }
  2364. //Turn on the Domain bits for workplace path
  2365. //Per the request of Jenellec and approved by Davidei and pmay,
  2366. //we revert this change
  2367. /*
  2368. if(fWork)
  2369. {
  2370. pInfo->pArgs->pEntry->fPreviewDomain = 1;
  2371. }
  2372. */
  2373. //Change the HeadMessage for workplace path
  2374. //For whistler bug 364818 gangz
  2375. //
  2376. if( fWork ||
  2377. (RASEDFLAG_NewDirectEntry & pInfo->pArgs->pApiArgs->dwFlags)
  2378. )
  2379. {
  2380. HWND hwndHeadMsg = GetDlgItem( hwndPage, CID_DT_HeadMessage );
  2381. TCHAR * pszMsg = PszFromId( g_hinstDll, SID_DT_HMsgWork );
  2382. if(pszMsg)
  2383. {
  2384. if(hwndHeadMsg)
  2385. {
  2386. SetWindowText( hwndHeadMsg, pszMsg);
  2387. }
  2388. Free(pszMsg);
  2389. }
  2390. }
  2391. // Intialize the three check buttons, turn them off for the
  2392. // workplace path gangz
  2393. //
  2394. Button_SetCheck( pInfo->hwndDtCbDefault, !fWork );
  2395. Button_SetCheck( pInfo->hwndDtCbUseCredentials, !fWork );
  2396. //Show the Firewall check box according to 3 conditions
  2397. //(1) Admin or Power Users
  2398. //(2) only for Personal, Professional
  2399. //(3) Group Policy enable it(GPA is not configues is viewed as enable)
  2400. if (pInfo->pArgs->fIsUserAdminOrPowerUser &&
  2401. IsFirewallAvailablePlatform() &&
  2402. IsGPAEnableFirewall())
  2403. {
  2404. EnableWindow( pInfo->hwndDtCbFirewall, TRUE );
  2405. Button_SetCheck( pInfo->hwndDtCbFirewall, !fWork );
  2406. }
  2407. else
  2408. {
  2409. EnableWindow( pInfo->hwndDtCbFirewall, FALSE );
  2410. ShowWindow( pInfo->hwndDtCbFirewall, SW_HIDE);
  2411. pInfo->fFirewall = FALSE;
  2412. }
  2413. //Normal user doesnt have the privilege to set a connectoid
  2414. //as a default internet connection
  2415. //
  2416. if ( !pInfo->pArgs->fIsUserAdminOrPowerUser)
  2417. {
  2418. Button_SetCheck( pInfo->hwndDtCbDefault, FALSE);
  2419. EnableWindow(pInfo->hwndDtCbDefault, FALSE);
  2420. }
  2421. // Reset the title and subtitle if this is the work path
  2422. // this is done in AeWizard() by calling AeTitle() and AeSubtitle()
  2423. //
  2424. // This entry is default to be available for all users
  2425. //
  2426. // pInfo->fCreateForAllUsers = TRUE; //this is done in AeInit()
  2427. return TRUE;
  2428. }
  2429. BOOL
  2430. DtKillActive(
  2431. IN AEINFO* pInfo )
  2432. // Called when PSN_KILLACTIVE is received. 'PInfo' is the wizard context.
  2433. //
  2434. // Returns true if the page is invalid, false is it can be dismissed.
  2435. //
  2436. {
  2437. // Remember whether to set this as the default Internet connection
  2438. //
  2439. BOOL fFailed = FALSE;
  2440. //Dont show the Account name page for DCC guest connection
  2441. //for whistler bug 364818 gangz
  2442. //
  2443. if( pInfo->pArgs->pApiArgs->dwFlags & RASEDFLAG_NewDirectEntry )
  2444. {
  2445. return FALSE;
  2446. }
  2447. pInfo->pArgs->fDefInternet =
  2448. Button_GetCheck( pInfo->hwndDtCbDefault );
  2449. //Add firewall check and GlobalCred for whistler bug 328673
  2450. //
  2451. pInfo->fFirewall =
  2452. Button_GetCheck( pInfo->hwndDtCbFirewall );
  2453. pInfo->pArgs->fGlobalCred =
  2454. Button_GetCheck( pInfo->hwndDtCbUseCredentials );
  2455. Free0(pInfo->pArgs->pszDefUserName);
  2456. Free0(pInfo->pArgs->pszDefPassword);
  2457. // For whistler 506917 gangz
  2458. pInfo->pArgs->pszDefUserName = NULL;
  2459. pInfo->pArgs->pszDefPassword = NULL ;
  2460. // Get the credentials
  2461. //
  2462. {
  2463. TCHAR pszUserName[UNLEN + 1];
  2464. TCHAR pszPassword[PWLEN + 1];
  2465. TCHAR pszPassword2[PWLEN + 1];
  2466. INT iLen;
  2467. pszUserName[0] = TEXT('\0');
  2468. pszPassword[0] = TEXT('\0');
  2469. pszPassword2[0] = TEXT('\0');
  2470. // Get the credentials
  2471. //
  2472. do {
  2473. GetWindowText( pInfo->hwndDtEbUserName, pszUserName, UNLEN + 1);
  2474. GetWindowText( pInfo->hwndDtEbPassword, pszPassword, PWLEN + 1);
  2475. GetWindowText( pInfo->hwndDtEbPassword2, pszPassword2, PWLEN + 1);
  2476. // Verify there is a user name
  2477. //
  2478. //Add for whistler bug 328673
  2479. //User can leave the credential blank or must fill a complete
  2480. //credential information
  2481. //
  2482. if ( 0 == lstrlen(pszUserName) &&
  2483. 0 == lstrlen(pszPassword) &&
  2484. 0 == lstrlen(pszPassword2) )
  2485. {
  2486. fFailed = FALSE;
  2487. break;
  2488. }
  2489. if (lstrlen(pszUserName) == 0)
  2490. {
  2491. MsgDlg(pInfo->hwndDt, SID_MissingUserName, NULL);
  2492. fFailed = TRUE;
  2493. break;
  2494. }
  2495. // Verify the passwords match
  2496. //
  2497. if (lstrcmp(pszPassword, pszPassword2) != 0)
  2498. {
  2499. MsgDlg(pInfo->hwndDt, SID_PasswordMismatch, NULL);
  2500. fFailed = TRUE;
  2501. break;
  2502. }
  2503. pInfo->pArgs->pszDefUserName = StrDup(pszUserName);
  2504. if (pInfo->pArgs->pszDefUserName == NULL)
  2505. {
  2506. fFailed = TRUE;
  2507. break;
  2508. }
  2509. pInfo->pArgs->pszDefPassword = StrDup(pszPassword);
  2510. if (pInfo->pArgs->pszDefPassword)
  2511. {
  2512. // Scramble the password
  2513. //
  2514. EncodePassword(pInfo->pArgs->pszDefPassword);
  2515. fFailed = FALSE;
  2516. }
  2517. else if (lstrlen(pszPassword))
  2518. {
  2519. // Copy failed
  2520. fFailed = TRUE;
  2521. }
  2522. else
  2523. {
  2524. fFailed = FALSE;
  2525. }
  2526. }
  2527. while(FALSE);
  2528. // Clear passwords from temporary stack memory
  2529. //
  2530. RtlSecureZeroMemory(pszPassword, sizeof(pszPassword));
  2531. RtlSecureZeroMemory(pszPassword2, sizeof(pszPassword2));
  2532. }
  2533. if ( fFailed )
  2534. {
  2535. Free0(pInfo->pArgs->pszDefUserName);
  2536. Free0(pInfo->pArgs->pszDefPassword);
  2537. // For whistler 506917 gangz
  2538. pInfo->pArgs->pszDefUserName = NULL;
  2539. pInfo->pArgs->pszDefPassword = NULL ;
  2540. }
  2541. return fFailed;
  2542. }
  2543. BOOL
  2544. DtSetActive(
  2545. IN AEINFO* pInfo )
  2546. // Called when PSN_SETACTIVE is received. 'PInfo' is the wizard context.
  2547. //
  2548. // Returns true to display the page, false to skip it.
  2549. //
  2550. {
  2551. if (pInfo->fDccHost)
  2552. {
  2553. return FALSE;
  2554. }
  2555. // Dont show the Account name page for DCC guest connection
  2556. // or workpath connections
  2557. // for whistler bug 364818 383533 gangz
  2558. //
  2559. if( RASEDFLAG_NewDirectEntry & pInfo->pArgs->pApiArgs->dwFlags ||
  2560. !(RASEDFLAG_InternetEntry & pInfo->pArgs->pApiArgs->dwFlags)
  2561. )
  2562. {
  2563. pInfo->pArgs->fDefInternet = FALSE;
  2564. pInfo->fFirewall = FALSE;
  2565. pInfo->pArgs->fGlobalCred = FALSE;
  2566. return FALSE;
  2567. }
  2568. // If this is a singer-user connection then we hide the option to save the
  2569. // password globally.
  2570. //
  2571. if ( !pInfo->fCreateForAllUsers )
  2572. {
  2573. Button_SetCheck( pInfo->hwndDtCbUseCredentials, FALSE );
  2574. EnableWindow( pInfo->hwndDtCbUseCredentials, FALSE );
  2575. ShowWindow( pInfo->hwndDtCbUseCredentials, SW_HIDE );
  2576. }
  2577. else
  2578. {
  2579. ShowWindow( pInfo->hwndDtCbUseCredentials, SW_SHOW );
  2580. EnableWindow( pInfo->hwndDtCbUseCredentials, TRUE );
  2581. }
  2582. PropSheet_SetWizButtons( pInfo->hwndDlg, PSWIZB_BACK | PSWIZB_NEXT );
  2583. return TRUE;
  2584. }
  2585. //----------------------------------------------------------------------------
  2586. // Entry Name property page
  2587. // Listed alphabetically following dialog proc
  2588. //----------------------------------------------------------------------------
  2589. INT_PTR CALLBACK
  2590. EnDlgProc(
  2591. IN HWND hwnd,
  2592. IN UINT unMsg,
  2593. IN WPARAM wparam,
  2594. IN LPARAM lparam )
  2595. // DialogProc callback for the Entry Name page of the wizard. Parameters
  2596. // and return value are as described for standard windows 'DialogProc's.
  2597. //
  2598. {
  2599. switch (unMsg)
  2600. {
  2601. case WM_INITDIALOG:
  2602. AeSetContext( hwnd, lparam );
  2603. return EnInit( hwnd );
  2604. case WM_NOTIFY:
  2605. {
  2606. switch (((NMHDR* )lparam)->code)
  2607. {
  2608. case PSN_RESET:
  2609. {
  2610. TRACE("EnRESET");
  2611. SetWindowLong( hwnd, DWLP_MSGRESULT, FALSE );
  2612. return TRUE;
  2613. }
  2614. case PSN_SETACTIVE:
  2615. {
  2616. AEINFO* pInfo;
  2617. BOOL fDisplay;
  2618. TRACE("EnSETACTIVE");
  2619. pInfo = AeContext( hwnd );
  2620. ASSERT(pInfo);
  2621. fDisplay = EnSetActive( pInfo );
  2622. SetWindowLong( hwnd, DWLP_MSGRESULT, (fDisplay) ? 0 : -1 );
  2623. return TRUE;
  2624. }
  2625. case PSN_KILLACTIVE:
  2626. {
  2627. AEINFO* pInfo;
  2628. BOOL fInvalid;
  2629. TRACE("EnKILLACTIVE");
  2630. pInfo = AeContext( hwnd );
  2631. ASSERT(pInfo);
  2632. fInvalid = EnKillActive( pInfo );
  2633. SetWindowLong( hwnd, DWLP_MSGRESULT, fInvalid );
  2634. return TRUE;
  2635. }
  2636. case PSN_WIZBACK:
  2637. {
  2638. AEINFO* pInfo;
  2639. TRACE("EnWIZBACK");
  2640. pInfo = AeContext( hwnd );
  2641. // For whislter bug 453704 gangz
  2642. //
  2643. pInfo->fEnBack = TRUE;
  2644. PropSheet_SetWizButtons(pInfo->hwndDlg, PSWIZB_NEXT | PSWIZB_BACK);
  2645. return FALSE;
  2646. }
  2647. case PSN_WIZFINISH:
  2648. {
  2649. AEINFO* pInfo;
  2650. BOOL fInvalid;
  2651. TRACE("EnWIZFINISH");
  2652. pInfo = AeContext( hwnd );
  2653. ASSERT(pInfo);
  2654. // You'd think pressing Finish would trigger a KILLACTIVE
  2655. // event, but it doesn't, so we do it ourselves.
  2656. //
  2657. fInvalid = EnKillActive( pInfo );
  2658. if (!fInvalid)
  2659. {
  2660. pInfo->pArgs->pUser->fDirty = TRUE;
  2661. SetUserPreferences(
  2662. NULL, pInfo->pArgs->pUser,
  2663. pInfo->pArgs->fNoUser ? UPM_Logon : UPM_Normal );
  2664. AeFinish( pInfo );
  2665. }
  2666. SetWindowLong( hwnd, DWLP_MSGRESULT, fInvalid );
  2667. return TRUE;
  2668. }
  2669. }
  2670. break;
  2671. }
  2672. }
  2673. return FALSE;
  2674. }
  2675. BOOL
  2676. EnInit(
  2677. IN HWND hwndPage )
  2678. // Called on WM_INITDIALOG. 'hwndPage' is the handle of the property
  2679. // page.
  2680. //
  2681. // Return false if focus was set, true otherwise.
  2682. //
  2683. {
  2684. DWORD dwErr;
  2685. AEINFO* pInfo;
  2686. PBENTRY* pEntry;
  2687. TRACE("EnInit");
  2688. pInfo = AeContext( hwndPage );
  2689. if (!pInfo)
  2690. return TRUE;
  2691. // The shell owns the finished page, so if we're shell owned, don't
  2692. // display ours.
  2693. //
  2694. if (pInfo->pArgs->pApiArgs->dwFlags & RASEDFLAG_ShellOwned)
  2695. {
  2696. return TRUE;
  2697. }
  2698. // Initialize page-specific context information.
  2699. //
  2700. pInfo->hwndEn = hwndPage;
  2701. pInfo->hwndEbEntryName = GetDlgItem( hwndPage, CID_EN_EB_EntryName );
  2702. ASSERT(pInfo->hwndEbEntryName);
  2703. // Initialize the entry name field.
  2704. //
  2705. pEntry = pInfo->pArgs->pEntry;
  2706. if (!pEntry->pszEntryName)
  2707. {
  2708. ASSERT( pInfo->pArgs->pFile );
  2709. // No entry name, so think up a default.
  2710. //
  2711. dwErr = GetDefaultEntryName(
  2712. NULL,
  2713. pEntry->dwType,
  2714. pInfo->pArgs->fRouter,
  2715. &pEntry->pszEntryName );
  2716. }
  2717. Edit_LimitText( pInfo->hwndEbEntryName, RAS_MaxEntryName );
  2718. SetWindowText( pInfo->hwndEbEntryName, pEntry->pszEntryName );
  2719. return TRUE;
  2720. }
  2721. BOOL
  2722. EnKillActive(
  2723. IN AEINFO* pInfo )
  2724. // Called when PSN_KILLACTIVE is received. 'PInfo' is the wizard context.
  2725. //
  2726. // Returns true if the page is invalid, false is it can be dismissed.
  2727. //
  2728. {
  2729. TCHAR* psz;
  2730. // The shell owns the finished page, so if we're shell owned, don't
  2731. // display ours.
  2732. //
  2733. if (pInfo->pArgs->pApiArgs->dwFlags & RASEDFLAG_ShellOwned)
  2734. {
  2735. return FALSE;
  2736. }
  2737. // For whislter bug 453704 gangz
  2738. //
  2739. if ( TRUE == pInfo->fEnBack )
  2740. {
  2741. return FALSE;
  2742. }
  2743. psz = GetText( pInfo->hwndEbEntryName );
  2744. if (psz)
  2745. {
  2746. // Update the entry name from the editbox.
  2747. //
  2748. Free0( pInfo->pArgs->pEntry->pszEntryName );
  2749. pInfo->pArgs->pEntry->pszEntryName = psz;
  2750. // Validate the entry name.
  2751. //
  2752. if (!EuValidateName( pInfo->hwndDlg, pInfo->pArgs ))
  2753. {
  2754. SetFocus( pInfo->hwndEbEntryName );
  2755. Edit_SetSel( pInfo->hwndEbEntryName, 0, -1 );
  2756. return TRUE;
  2757. }
  2758. }
  2759. return FALSE;
  2760. }
  2761. BOOL
  2762. EnSetActive(
  2763. IN AEINFO* pInfo )
  2764. // Called when PSN_SETACTIVE is received. 'PInfo' is the wizard context.
  2765. //
  2766. // Returns true to display the page, false to skip it.
  2767. //
  2768. {
  2769. LPARAM dwWizButtons = PSWIZB_FINISH;
  2770. DWORD dwFlags = pInfo->pArgs->pApiArgs->dwFlags;
  2771. // The shell owns the finished page, so if we're shell owned, don't
  2772. // display ours.
  2773. //
  2774. if (dwFlags & RASEDFLAG_ShellOwned)
  2775. {
  2776. return FALSE;
  2777. }
  2778. if (!(dwFlags & RASEDFLAG_CloneEntry))
  2779. {
  2780. dwWizButtons |= PSWIZB_BACK;
  2781. }
  2782. PropSheet_SetWizButtons( pInfo->hwndDlg, dwWizButtons );
  2783. // For whislter bug 453704 gangz
  2784. //
  2785. pInfo->fEnBack = FALSE;
  2786. return TRUE;
  2787. }
  2788. INT_PTR CALLBACK
  2789. LaDlgProc(
  2790. IN HWND hwnd,
  2791. IN UINT unMsg,
  2792. IN WPARAM wparam,
  2793. IN LPARAM lparam )
  2794. // DialogProc callback for the start page of the wizard. Parameters and
  2795. // return value are as described for standard windows 'DialogProc's.
  2796. //
  2797. {
  2798. switch (unMsg)
  2799. {
  2800. case WM_INITDIALOG:
  2801. AeSetContext( hwnd, lparam );
  2802. return LaInit( hwnd );
  2803. case WM_NOTIFY:
  2804. {
  2805. switch (((NMHDR* )lparam)->code)
  2806. {
  2807. case PSN_SETACTIVE:
  2808. {
  2809. AEINFO* pInfo;
  2810. BOOL fDisplay;
  2811. TRACE("LaSETACTIVE");
  2812. pInfo = AeContext( hwnd );
  2813. ASSERT(pInfo);
  2814. fDisplay = LaSetActive( pInfo );
  2815. SetWindowLong( hwnd, DWLP_MSGRESULT, (fDisplay) ? 0 : -1 );
  2816. return TRUE;
  2817. }
  2818. case PSN_KILLACTIVE:
  2819. {
  2820. AEINFO* pInfo;
  2821. BOOL fInvalid;
  2822. TRACE("LaKILLACTIVE");
  2823. pInfo = AeContext( hwnd );
  2824. ASSERT(pInfo);
  2825. fInvalid = LaKillActive( pInfo );
  2826. SetWindowLong( hwnd, DWLP_MSGRESULT, fInvalid );
  2827. return TRUE;
  2828. }
  2829. }
  2830. break;
  2831. }
  2832. }
  2833. return FALSE;
  2834. }
  2835. BOOL
  2836. LaInit(
  2837. IN HWND hwndPage )
  2838. // Called on WM_INITDIALOG. 'hwndPage' is the handle of the property
  2839. // page. 'pInfo' is the arguments from the PropertySheet caller.
  2840. //
  2841. // Return false if focus was set, true otherwise.
  2842. //
  2843. {
  2844. AEINFO* pInfo;
  2845. DWORD dwType;
  2846. INT nIdButton;
  2847. HFONT hfont;
  2848. TRACE("LaInit");
  2849. pInfo = AeContext( hwndPage );
  2850. if (!pInfo)
  2851. return TRUE;
  2852. // Initialize page-specific context information.
  2853. //
  2854. pInfo->hwndLa = hwndPage;
  2855. // Create the bold font and apply it to the buttons.
  2856. //
  2857. hfont = GetWindowFont (hwndPage);
  2858. if (!hfont)
  2859. {
  2860. // If not found then the dialog is using the system font.
  2861. //
  2862. hfont = (HFONT )GetStockObject (SYSTEM_FONT);
  2863. }
  2864. if (hfont)
  2865. {
  2866. LOGFONT lf;
  2867. // Get the font info so we can generate the bold version.
  2868. //
  2869. if (GetObject (hfont, sizeof(lf), &lf))
  2870. {
  2871. lf.lfWeight = FW_BOLD;
  2872. hfont = CreateFontIndirect (&lf);
  2873. if (hfont)
  2874. {
  2875. // Store this so we can destroy it during cleanup.
  2876. //
  2877. pInfo->hfontBold = hfont;
  2878. // Set the fonts of the radio buttons using this bold font.
  2879. //
  2880. SetWindowFont (GetDlgItem (hwndPage, CID_LA_RB_Phone),
  2881. hfont, FALSE);
  2882. SetWindowFont (GetDlgItem (hwndPage, CID_LA_RB_Tunnel),
  2883. hfont, FALSE);
  2884. SetWindowFont (GetDlgItem (hwndPage, CID_LA_RB_Direct),
  2885. hfont, FALSE);
  2886. SetWindowFont (GetDlgItem (hwndPage, CID_LA_RB_Broadband),
  2887. hfont, FALSE);
  2888. }
  2889. }
  2890. }
  2891. // Set the radio buttons.
  2892. //
  2893. dwType = pInfo->pArgs->pEntry->dwType;
  2894. if (RASET_Phone == dwType)
  2895. {
  2896. nIdButton = CID_LA_RB_Phone;
  2897. }
  2898. else if (RASET_Vpn == dwType)
  2899. {
  2900. nIdButton = CID_LA_RB_Tunnel;
  2901. }
  2902. else if (RASET_Broadband == dwType)
  2903. {
  2904. nIdButton = CID_LA_RB_Broadband;
  2905. }
  2906. else
  2907. {
  2908. nIdButton = CID_LA_RB_Direct;
  2909. }
  2910. CheckDlgButton( hwndPage, nIdButton, BST_CHECKED );
  2911. return TRUE;
  2912. }
  2913. BOOL
  2914. LaKillActive(
  2915. IN AEINFO* pInfo )
  2916. // Called when PSN_KILLACTIVE is received. 'PInfo' is the wizard context.
  2917. //
  2918. // Returns true if the page is invalid, false is it can be dismissed.
  2919. //
  2920. {
  2921. if (BST_CHECKED == IsDlgButtonChecked (pInfo->hwndLa, CID_LA_RB_Phone))
  2922. {
  2923. EuChangeEntryType (pInfo->pArgs, RASET_Phone);
  2924. }
  2925. else if (BST_CHECKED == IsDlgButtonChecked (pInfo->hwndLa, CID_LA_RB_Tunnel))
  2926. {
  2927. EuChangeEntryType (pInfo->pArgs, RASET_Vpn);
  2928. }
  2929. else if (BST_CHECKED == IsDlgButtonChecked (pInfo->hwndLa, CID_LA_RB_Broadband))
  2930. {
  2931. EuChangeEntryType (pInfo->pArgs, RASET_Broadband);
  2932. }
  2933. else
  2934. {
  2935. EuChangeEntryType (pInfo->pArgs, RASET_Direct);
  2936. }
  2937. return FALSE;
  2938. }
  2939. BOOL
  2940. LaSetActive(
  2941. IN AEINFO* pInfo )
  2942. // Called when PSN_SETACTIVE is received. 'PInfo' is the wizard context.
  2943. //
  2944. // Returns true to display the page, false to skip it.
  2945. //
  2946. {
  2947. DWORD dwFlags = pInfo->pArgs->pApiArgs->dwFlags;
  2948. // If we are owned by the shell, then we are not displayed.
  2949. //
  2950. if (dwFlags & RASEDFLAG_ShellOwned)
  2951. {
  2952. return FALSE;
  2953. }
  2954. // If we were told by the caller, which type of entry we should be,
  2955. // then we are not displayed.
  2956. //
  2957. if (dwFlags & (RASEDFLAG_NewPhoneEntry | RASEDFLAG_NewTunnelEntry |
  2958. RASEDFLAG_NewDirectEntry | RASEDFLAG_NewBroadbandEntry)) //Add _NewBroadbandEntry for bug237175
  2959. {
  2960. return FALSE;
  2961. }
  2962. PropSheet_SetWizButtons( pInfo->hwndDlg, PSWIZB_NEXT );
  2963. return TRUE;
  2964. }
  2965. //----------------------------------------------------------------------------
  2966. // Modem/Adapter property page
  2967. // Listed alphabetically following dialog proc
  2968. //----------------------------------------------------------------------------
  2969. INT_PTR CALLBACK
  2970. MaDlgProc(
  2971. IN HWND hwnd,
  2972. IN UINT unMsg,
  2973. IN WPARAM wparam,
  2974. IN LPARAM lparam )
  2975. // DialogProc callback for the Modem/Adapter page of the wizard.
  2976. // Parameters and return value are as described for standard windows
  2977. // 'DialogProc's.
  2978. //
  2979. {
  2980. if (ListView_OwnerHandler(
  2981. hwnd, unMsg, wparam, lparam, MaLvCallback ))
  2982. {
  2983. return TRUE;
  2984. }
  2985. switch (unMsg)
  2986. {
  2987. case WM_INITDIALOG:
  2988. AeSetContext( hwnd, lparam );
  2989. return MaInit( hwnd );
  2990. case WM_NOTIFY:
  2991. {
  2992. switch (((NMHDR* )lparam)->code)
  2993. {
  2994. case PSN_SETACTIVE:
  2995. {
  2996. AEINFO* pInfo;
  2997. BOOL fDisplay;
  2998. TRACE("MaSETACTIVE");
  2999. pInfo = AeContext( hwnd );
  3000. ASSERT(pInfo);
  3001. fDisplay = MaSetActive( pInfo );
  3002. SetWindowLong( hwnd, DWLP_MSGRESULT, (fDisplay) ? 0 : -1 );
  3003. return TRUE;
  3004. }
  3005. case LVXN_SETCHECK:
  3006. {
  3007. AEINFO* pInfo;
  3008. TRACE("MaLVXNSETCHECK");
  3009. pInfo = AeContext( hwnd );
  3010. ASSERT(pInfo);
  3011. if (ListView_GetCheckedCount(pInfo->hwndLv) > 0)
  3012. {
  3013. PropSheet_SetWizButtons(pInfo->hwndDlg,
  3014. PSWIZB_BACK | PSWIZB_NEXT);
  3015. }
  3016. else
  3017. {
  3018. // Disable Next button if no items are checked
  3019. PropSheet_SetWizButtons(pInfo->hwndDlg, PSWIZB_BACK);
  3020. }
  3021. return TRUE;
  3022. }
  3023. case PSN_KILLACTIVE:
  3024. {
  3025. AEINFO* pInfo;
  3026. BOOL fInvalid;
  3027. TRACE("MaKILLACTIVE");
  3028. pInfo = AeContext( hwnd );
  3029. ASSERT(pInfo);
  3030. fInvalid = MaKillActive( pInfo );
  3031. SetWindowLong( hwnd, DWLP_MSGRESULT, fInvalid );
  3032. return TRUE;
  3033. }
  3034. }
  3035. break;
  3036. }
  3037. }
  3038. return FALSE;
  3039. }
  3040. BOOL
  3041. MaInit(
  3042. IN HWND hwndPage )
  3043. // Called on WM_INITDIALOG. 'hwndPage' is the handle of the property
  3044. // page.
  3045. //
  3046. // Return false if focus was set, true otherwise.
  3047. //
  3048. {
  3049. AEINFO* pInfo;
  3050. TRACE("MaInit");
  3051. pInfo = AeContext( hwndPage );
  3052. if (!pInfo)
  3053. return TRUE;
  3054. // Initialize page-specific context information.
  3055. //
  3056. pInfo->hwndMa = hwndPage;
  3057. pInfo->hwndLv = GetDlgItem( hwndPage, CID_MA_LV_Devices );
  3058. ASSERT(pInfo->hwndLv);
  3059. // Add the modem and adapter images.
  3060. //
  3061. ListView_InstallChecks( pInfo->hwndLv, g_hinstDll );
  3062. ListView_SetDeviceImageList( pInfo->hwndLv, g_hinstDll );
  3063. // Add a single column exactly wide enough to fully display
  3064. // the widest member of the list.
  3065. //
  3066. {
  3067. LV_COLUMN col;
  3068. ZeroMemory( &col, sizeof(col) );
  3069. col.mask = LVCF_FMT;
  3070. col.fmt = LVCFMT_LEFT;
  3071. ListView_InsertColumn( pInfo->hwndLv, 0, &col );
  3072. ListView_SetColumnWidth( pInfo->hwndLv, 0, LVSCW_AUTOSIZE_USEHEADER );
  3073. }
  3074. // Don't bother with this page if there's only one device.
  3075. //
  3076. if (DtlGetNodes( pInfo->pArgs->pEntry->pdtllistLinks ) < 2)
  3077. {
  3078. pInfo->fSkipMa = TRUE;
  3079. }
  3080. //For whislter bug 354542
  3081. //
  3082. pInfo->fMultilinkAllIsdn = FALSE;
  3083. return FALSE;
  3084. }
  3085. LVXDRAWINFO*
  3086. MaLvCallback(
  3087. IN HWND hwndLv,
  3088. IN DWORD dwItem )
  3089. // Enhanced list view callback to report drawing information. 'HwndLv' is
  3090. // the handle of the list view control. 'DwItem' is the index of the item
  3091. // being drawn.
  3092. //
  3093. // Returns the address of the column information.
  3094. //
  3095. {
  3096. // Use "wide selection bar" feature and the other recommended options.
  3097. //
  3098. // Fields are 'nCols', 'dxIndent', 'dwFlags', 'adwFlags[]'.
  3099. //
  3100. static LVXDRAWINFO info =
  3101. { 1, 0, LVXDI_DxFill, { 0, 0 } };
  3102. return &info;
  3103. }
  3104. BOOL
  3105. MaKillActive(
  3106. IN AEINFO* pInfo )
  3107. // Called when the modem/adapter page is loosing activation.
  3108. {
  3109. PBENTRY* pEntry;
  3110. ASSERT(pInfo);
  3111. pEntry = pInfo->pArgs->pEntry;
  3112. if (!pInfo->fSkipMa && (RASET_Phone == pEntry->dwType))
  3113. {
  3114. // Initialization of i to -1 is important here. It means start
  3115. // the search beginning with that item.
  3116. //
  3117. INT i = -1;
  3118. //For whistler bug 354542
  3119. //
  3120. pInfo->fMultilinkAllIsdn = FALSE;
  3121. while ((i = ListView_GetNextItem(pInfo->hwndLv, i, LVNI_ALL )) >= 0)
  3122. {
  3123. DTLNODE* pNode;
  3124. pNode = (DTLNODE* )ListView_GetParamPtr( pInfo->hwndLv, i );
  3125. if (pNode)
  3126. {
  3127. PBLINK* pLink = (PBLINK* )DtlGetData( pNode );
  3128. ASSERT( pLink );
  3129. // If we're multilinking all ISDN, we only need to
  3130. // set enabled based on the check state if the device type
  3131. // is not ISDN. (If it is ISDN and we're multilinking, we've
  3132. // already taken care of it below.
  3133. //
  3134. if (!pInfo->fMultilinkAllIsdn ||
  3135. (pLink->pbport.pbdevicetype != PBDT_Isdn))
  3136. {
  3137. pLink->fEnabled = ListView_GetCheck( pInfo->hwndLv, i );
  3138. }
  3139. }
  3140. //Only the Dummy "All available Isdn" item will return the NULL pLink
  3141. //
  3142. else if (ListView_GetCheck( pInfo->hwndLv, i ))
  3143. {
  3144. // ISDN multi-link selected. Enable the ISDN multi-link
  3145. // nodes, move them to the head of the list, and disable
  3146. // all the other links.
  3147. //
  3148. DTLNODE* pNextNode;
  3149. DTLNODE* pAfterNode;
  3150. DTLLIST* pList;
  3151. //For whistler bug 354542
  3152. //
  3153. pInfo->fMultilinkAllIsdn = TRUE;
  3154. pList = pInfo->pArgs->pEntry->pdtllistLinks;
  3155. pInfo->fModem = FALSE;
  3156. pAfterNode = NULL;
  3157. for (pNode = DtlGetFirstNode( pList );
  3158. pNode;
  3159. pNode = pNextNode)
  3160. {
  3161. PBLINK* pLink = (PBLINK* )DtlGetData( pNode );
  3162. ASSERT(pLink);
  3163. pNextNode = DtlGetNextNode( pNode );
  3164. if (pLink->pbport.pbdevicetype == PBDT_Isdn
  3165. && !pLink->fProprietaryIsdn)
  3166. {
  3167. pLink->fEnabled = TRUE;
  3168. DtlRemoveNode( pList, pNode );
  3169. if (pAfterNode)
  3170. DtlAddNodeAfter( pList, pAfterNode, pNode );
  3171. else
  3172. DtlAddNodeFirst( pList, pNode );
  3173. pAfterNode = pNode;
  3174. }
  3175. else
  3176. {
  3177. pLink->fEnabled = FALSE;
  3178. }
  3179. }
  3180. }
  3181. }
  3182. }
  3183. return FALSE;
  3184. }
  3185. BOOL
  3186. MaSetActive(
  3187. IN AEINFO* pInfo )
  3188. // Called when PSN_SETACTIVE is received. 'PInfo' is the wizard context.
  3189. //
  3190. // Returns true to display the page, false to skip it.
  3191. //
  3192. {
  3193. BOOL fDisplayPage;
  3194. PBENTRY* pEntry;
  3195. ASSERT(pInfo);
  3196. pEntry = pInfo->pArgs->pEntry;
  3197. if (pInfo->fSkipMa || (RASET_Phone != pEntry->dwType))
  3198. {
  3199. fDisplayPage = FALSE;
  3200. }
  3201. else
  3202. {
  3203. TCHAR* psz;
  3204. DTLNODE* pNode;
  3205. DWORD cMultilinkableIsdn;
  3206. LV_ITEM item;
  3207. INT iItem, iIndex;
  3208. ListView_DeleteAllItems( pInfo->hwndLv );
  3209. // Fill the list of devices and select the first item.
  3210. //
  3211. iItem = 1;
  3212. cMultilinkableIsdn = 0;
  3213. for (pNode = DtlGetFirstNode( pInfo->pArgs->pEntry->pdtllistLinks );
  3214. pNode;
  3215. pNode = DtlGetNextNode( pNode ))
  3216. {
  3217. PBLINK* pLink;
  3218. DWORD dwImage;
  3219. pLink = (PBLINK* )DtlGetData( pNode );
  3220. ASSERT(pLink);
  3221. if ((pLink->pbport.pbdevicetype == PBDT_Isdn) &&
  3222. !pLink->fProprietaryIsdn)
  3223. {
  3224. ++cMultilinkableIsdn;
  3225. }
  3226. psz = DisplayPszFromPpbport( &pLink->pbport, &dwImage );
  3227. if (psz)
  3228. {
  3229. PBLINK* pLinkTmp = NULL;
  3230. pLinkTmp = (PBLINK* )DtlGetData( pNode );
  3231. ZeroMemory( &item, sizeof(item) );
  3232. item.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM;
  3233. item.iItem = iItem++;
  3234. item.pszText = psz;
  3235. item.iImage = dwImage;
  3236. item.lParam = (LPARAM )pNode;
  3237. iIndex = ListView_InsertItem( pInfo->hwndLv, &item );
  3238. if (pInfo->fMaAlreadyInitialized)
  3239. {
  3240. ListView_SetCheck(pInfo->hwndLv, iIndex, pLinkTmp->fEnabled);
  3241. }
  3242. else
  3243. {
  3244. ListView_SetCheck(pInfo->hwndLv, iIndex, FALSE);
  3245. }
  3246. Free( psz );
  3247. }
  3248. }
  3249. if (cMultilinkableIsdn > 1)
  3250. {
  3251. psz = PszFromId( g_hinstDll, SID_IsdnAdapter );
  3252. if (psz)
  3253. {
  3254. LONG lStyle;
  3255. // Turn off sorting so the special ISDN-multilink item appears
  3256. // at the top of the list.
  3257. //
  3258. lStyle = GetWindowLong( pInfo->hwndLv, GWL_STYLE );
  3259. SetWindowLong( pInfo->hwndLv, GWL_STYLE,
  3260. (lStyle & ~(LVS_SORTASCENDING)) );
  3261. ZeroMemory( &item, sizeof(item) );
  3262. item.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM;
  3263. item.iItem = 0;
  3264. item.pszText = psz;
  3265. item.iImage = DI_Adapter;
  3266. item.lParam = (LPARAM )NULL;
  3267. iIndex = ListView_InsertItem( pInfo->hwndLv, &item );
  3268. //For whislter bug 354542
  3269. //
  3270. ListView_SetCheck(pInfo->hwndLv, iIndex, pInfo->fMultilinkAllIsdn);
  3271. Free( psz );
  3272. }
  3273. }
  3274. // Select the first item.
  3275. //
  3276. ListView_SetItemState( pInfo->hwndLv, 0, LVIS_SELECTED, LVIS_SELECTED );
  3277. if (!pInfo->fMaAlreadyInitialized)
  3278. {
  3279. ListView_SetCheck( pInfo->hwndLv, 0, TRUE );
  3280. {
  3281. LPARAM dwWizButtons = PSWIZB_NEXT;
  3282. DWORD dwFlags = pInfo->pArgs->pApiArgs->dwFlags;
  3283. if ((dwFlags & RASEDFLAG_ShellOwned) ||
  3284. !(dwFlags & RASEDFLAG_NewPhoneEntry))
  3285. {
  3286. dwWizButtons |= PSWIZB_BACK;
  3287. }
  3288. PropSheet_SetWizButtons( pInfo->hwndDlg, dwWizButtons );
  3289. }
  3290. pInfo->fMaAlreadyInitialized = TRUE;
  3291. }
  3292. else
  3293. {
  3294. if (!ListView_GetCheckedCount(pInfo->hwndLv))
  3295. {
  3296. // Disable next button if no items checked
  3297. PropSheet_SetWizButtons( pInfo->hwndDlg, PSWIZB_BACK );
  3298. }
  3299. }
  3300. fDisplayPage = TRUE;
  3301. }
  3302. return fDisplayPage;
  3303. }
  3304. //----------------------------------------------------------------------------
  3305. // Phone Number property page
  3306. // Listed alphabetically following dialog proc
  3307. //----------------------------------------------------------------------------
  3308. INT_PTR CALLBACK
  3309. PaDlgProc(
  3310. IN HWND hwnd,
  3311. IN UINT unMsg,
  3312. IN WPARAM wparam,
  3313. IN LPARAM lparam )
  3314. // DialogProc callback for the Phone Number page of the wizard.
  3315. // Parameters and return value are as described for standard windows
  3316. // 'DialogProc's.
  3317. //
  3318. {
  3319. switch (unMsg)
  3320. {
  3321. case WM_INITDIALOG:
  3322. AeSetContext( hwnd, lparam );
  3323. return PaInit( hwnd );
  3324. case WM_NOTIFY:
  3325. {
  3326. switch (((NMHDR* )lparam)->code)
  3327. {
  3328. case PSN_SETACTIVE:
  3329. {
  3330. AEINFO* pInfo;
  3331. BOOL fDisplay;
  3332. TRACE("PaSETACTIVE");
  3333. pInfo = AeContext( hwnd );
  3334. ASSERT(pInfo);
  3335. fDisplay = PaSetActive( pInfo );
  3336. SetWindowLong( hwnd, DWLP_MSGRESULT, (fDisplay) ? 0 : -1 );
  3337. return TRUE;
  3338. }
  3339. case PSN_KILLACTIVE:
  3340. {
  3341. AEINFO* pInfo;
  3342. BOOL fInvalid;
  3343. TRACE("PaKILLACTIVE");
  3344. pInfo = AeContext( hwnd );
  3345. ASSERT(pInfo);
  3346. fInvalid = PaKillActive( pInfo );
  3347. SetWindowLong( hwnd, DWLP_MSGRESULT, fInvalid );
  3348. return TRUE;
  3349. }
  3350. }
  3351. break;
  3352. }
  3353. }
  3354. return FALSE;
  3355. }
  3356. BOOL
  3357. PaInit(
  3358. IN HWND hwndPage )
  3359. // Called on WM_INITDIALOG. 'hwndPage' is the handle of the property
  3360. // page.
  3361. //
  3362. // Return false if focus was set, true otherwise.
  3363. //
  3364. {
  3365. AEINFO* pInfo;
  3366. CUINFO * pCuInfo = NULL;
  3367. TRACE("PaInit");
  3368. pInfo = AeContext( hwndPage );
  3369. if (!pInfo)
  3370. return TRUE;
  3371. // Initialize page-specific context information.
  3372. //
  3373. pInfo->hwndPa = hwndPage;
  3374. pInfo->hwndEbNumber = GetDlgItem( hwndPage, CID_PA_EB_Number );
  3375. ASSERT(pInfo->hwndEbNumber);
  3376. // Initialize the complex phone number context and use those utilities to
  3377. // set the phone number controls.
  3378. //
  3379. pInfo->pListAreaCodes = DtlDuplicateList(
  3380. pInfo->pArgs->pUser->pdtllistAreaCodes,
  3381. DuplicatePszNode, DestroyPszNode );
  3382. //Modify Phonenumber page for bug 328673 gangz
  3383. //Initialize pInfo->CuInfoCuInfo
  3384. //
  3385. pCuInfo=&pInfo->cuinfo;
  3386. ZeroMemory(pCuInfo, sizeof(*pCuInfo) );
  3387. pCuInfo->hwndStAreaCodes = NULL;
  3388. pCuInfo->hwndClbAreaCodes = NULL;
  3389. pCuInfo->hwndStPhoneNumber = NULL;
  3390. pCuInfo->hwndEbPhoneNumber = pInfo->hwndEbNumber;
  3391. pCuInfo->hwndStCountryCodes = NULL;
  3392. pCuInfo->hwndLbCountryCodes = NULL;
  3393. pCuInfo->hwndCbUseDialingRules = NULL;
  3394. pCuInfo->hwndPbDialingRules = NULL;
  3395. pCuInfo->hwndPbAlternates = NULL;
  3396. pCuInfo->hwndStComment = NULL;
  3397. pCuInfo->hwndEbComment = NULL;
  3398. pCuInfo->pListAreaCodes = pInfo->pListAreaCodes;
  3399. // Disaster defaults only. Not used in normal operation.
  3400. //
  3401. pCuInfo->dwCountryId = 1;
  3402. pCuInfo->dwCountryCode = 1;
  3403. Edit_LimitText( pCuInfo->hwndEbPhoneNumber, RAS_MaxPhoneNumber );
  3404. pInfo->fCuInfoInitialized = TRUE;
  3405. // Load the phone number fields from the shared link.
  3406. //
  3407. {
  3408. PBLINK* pLink;
  3409. DTLNODE* pPhoneNode;
  3410. pLink = (PBLINK* )DtlGetData( pInfo->pArgs->pSharedNode );
  3411. ASSERT( pLink );
  3412. pPhoneNode = FirstPhoneNodeFromPhoneList( pLink->pdtllistPhones );
  3413. if (pPhoneNode)
  3414. {
  3415. CuSetInfo( &pInfo->cuinfo, pPhoneNode, FALSE );
  3416. DestroyPhoneNode( pPhoneNode );
  3417. }
  3418. }
  3419. Edit_SetSel( pInfo->hwndEbNumber, 0, -1 );
  3420. SetFocus( pInfo->hwndEbNumber );
  3421. return FALSE;
  3422. }
  3423. BOOL
  3424. PaKillActive(
  3425. IN AEINFO* pInfo )
  3426. // Called when PSN_KILLACTIVE is received. 'PInfo' is the wizard context.
  3427. //
  3428. // Returns true if the page is invalid, false if it can be dismissed.
  3429. //
  3430. {
  3431. return FALSE;
  3432. }
  3433. BOOL
  3434. PaSetActive(
  3435. IN AEINFO* pInfo )
  3436. // Called when PSN_SETACTIVE is received. 'PInfo' is the wizard context.
  3437. //
  3438. // Returns true to display the page, false to skip it.
  3439. //
  3440. {
  3441. BOOL fDisplayPage;
  3442. PBENTRY* pEntry;
  3443. ASSERT(pInfo);
  3444. pEntry = pInfo->pArgs->pEntry;
  3445. if (RASET_Phone != pEntry->dwType)
  3446. {
  3447. fDisplayPage = FALSE;
  3448. }
  3449. else
  3450. {
  3451. LPARAM dwWizButtons = PSWIZB_NEXT;
  3452. DWORD dwFlags = pInfo->pArgs->pApiArgs->dwFlags;
  3453. // Show the back button if we're shell owned or, we have the
  3454. // La page or the Ma page before us. La page will be shown if
  3455. // not RASEDFLAG_NewPhoneEntry. Ma page will be shown if !fSkipMa.
  3456. //
  3457. if ((dwFlags & RASEDFLAG_ShellOwned) ||
  3458. !(dwFlags & RASEDFLAG_NewPhoneEntry) || !pInfo->fSkipMa)
  3459. {
  3460. dwWizButtons |= PSWIZB_BACK;
  3461. }
  3462. PropSheet_SetWizButtons( pInfo->hwndDlg, dwWizButtons );
  3463. fDisplayPage = TRUE;
  3464. }
  3465. return fDisplayPage;
  3466. }
  3467. //----------------------------------------------------------------------------
  3468. // Public network property page
  3469. // Listed alphabetically following dialog proc
  3470. //----------------------------------------------------------------------------
  3471. INT_PTR CALLBACK
  3472. PnDlgProc(
  3473. IN HWND hwnd,
  3474. IN UINT unMsg,
  3475. IN WPARAM wparam,
  3476. IN LPARAM lparam )
  3477. // DialogProc callback for the Public Network page of the wizard.
  3478. // Parameters and return value are as described for standard windows
  3479. // 'DialogProc's.
  3480. //
  3481. {
  3482. switch (unMsg)
  3483. {
  3484. case WM_INITDIALOG:
  3485. AeSetContext( hwnd, lparam );
  3486. return PnInit( hwnd );
  3487. case WM_COMMAND:
  3488. {
  3489. AEINFO* pInfo = AeContext( hwnd );
  3490. ASSERT (pInfo);
  3491. switch (LOWORD(wparam))
  3492. {
  3493. case CID_PN_LB_DialAnotherFirst:
  3494. {
  3495. if (HIWORD( wparam ) == CBN_SELCHANGE)
  3496. {
  3497. PnDialAnotherFirstSelChange( pInfo );
  3498. return TRUE;
  3499. }
  3500. break;
  3501. }
  3502. // NOTE for the following 2 handlers:
  3503. // For keyboard navigation, we receive 2 BN_CLICKED notifications,
  3504. // one before the button is actually clicked, and one afterwards.
  3505. // Handling both clicks causes problems (unexpected re-entrancy)
  3506. // so make sure each button only handles the latter click. (i.e.
  3507. // the one where it is already checked)
  3508. //
  3509. case CID_PN_RB_DoNotDialFirst:
  3510. {
  3511. switch (HIWORD( wparam))
  3512. {
  3513. case BN_CLICKED:
  3514. {
  3515. if (BST_CHECKED == IsDlgButtonChecked (pInfo->hwndPn,
  3516. CID_PN_RB_DoNotDialFirst))
  3517. {
  3518. PnUpdateLbDialAnotherFirst( pInfo );
  3519. return TRUE;
  3520. }
  3521. }
  3522. }
  3523. break;
  3524. }
  3525. case CID_PN_RB_DialFirst:
  3526. {
  3527. switch (HIWORD( wparam))
  3528. {
  3529. case BN_CLICKED:
  3530. {
  3531. if (BST_CHECKED == IsDlgButtonChecked (pInfo->hwndPn,
  3532. CID_PN_RB_DialFirst))
  3533. {
  3534. PnUpdateLbDialAnotherFirst( pInfo );
  3535. return TRUE;
  3536. }
  3537. }
  3538. }
  3539. break;
  3540. }
  3541. }
  3542. break;
  3543. }
  3544. case WM_NOTIFY:
  3545. {
  3546. switch (((NMHDR* )lparam)->code)
  3547. {
  3548. case PSN_SETACTIVE:
  3549. {
  3550. AEINFO* pInfo;
  3551. BOOL fDisplay;
  3552. TRACE("PnSETACTIVE");
  3553. pInfo = AeContext( hwnd );
  3554. ASSERT(pInfo);
  3555. fDisplay = PnSetActive( pInfo );
  3556. SetWindowLong( hwnd, DWLP_MSGRESULT, (fDisplay) ? 0 : -1 );
  3557. return TRUE;
  3558. }
  3559. case PSN_KILLACTIVE:
  3560. {
  3561. AEINFO* pInfo;
  3562. BOOL fInvalid;
  3563. TRACE("PnKILLACTIVE");
  3564. pInfo = AeContext( hwnd );
  3565. ASSERT(pInfo);
  3566. fInvalid = PnKillActive( pInfo );
  3567. SetWindowLong( hwnd, DWLP_MSGRESULT, fInvalid );
  3568. return TRUE;
  3569. }
  3570. }
  3571. break;
  3572. }
  3573. }
  3574. return FALSE;
  3575. }
  3576. VOID
  3577. PnClearLbDialFirst(
  3578. IN HWND hwndLbDialFirst )
  3579. // Clear prerequisite entry list box. 'hwndLbDialAnotherFirst' is the
  3580. // window handle of the listbox control. context.
  3581. //
  3582. {
  3583. PREREQITEM* pItem;
  3584. while (pItem = ComboBox_GetItemDataPtr( hwndLbDialFirst, 0 ))
  3585. {
  3586. ComboBox_DeleteString( hwndLbDialFirst, 0 );
  3587. Free0( pItem->pszEntry );
  3588. Free0( pItem->pszPbk );
  3589. Free( pItem );
  3590. }
  3591. }
  3592. VOID
  3593. PnDialAnotherFirstSelChange(
  3594. IN AEINFO* pInfo )
  3595. {
  3596. PBENTRY* pEntry;
  3597. PREREQITEM* pItem;
  3598. INT iSel;
  3599. iSel = ComboBox_GetCurSel( pInfo->hwndLbDialFirst );
  3600. if (iSel < 0)
  3601. {
  3602. return;
  3603. }
  3604. pEntry = pInfo->pArgs->pEntry;
  3605. Free0( pEntry->pszPrerequisiteEntry );
  3606. Free0( pEntry->pszPrerequisitePbk );
  3607. pItem = (PREREQITEM* )
  3608. ComboBox_GetItemDataPtr( pInfo->hwndLbDialFirst, iSel );
  3609. if(NULL != pItem)
  3610. {
  3611. pEntry->pszPrerequisiteEntry = StrDup( pItem->pszEntry );
  3612. pEntry->pszPrerequisitePbk = StrDup( pItem->pszPbk );
  3613. }
  3614. }
  3615. // !!! Make this common with GeFillLbDialAnotherFirst
  3616. VOID
  3617. PnUpdateLbDialAnotherFirst(
  3618. IN AEINFO* pInfo )
  3619. // Fill prerequisite entry list box with all non-VPN entries in the
  3620. // phonebook, and select the prerequiste one. 'pInfo' is the property
  3621. // sheet context.
  3622. //
  3623. {
  3624. BOOL fEnabledLb = FALSE;
  3625. ComboBox_ResetContent( pInfo->hwndLbDialFirst );
  3626. if (BST_CHECKED == IsDlgButtonChecked (pInfo->hwndPn,
  3627. CID_PN_RB_DialFirst))
  3628. {
  3629. DWORD i;
  3630. INT iThis;
  3631. INT iSel;
  3632. TCHAR* pszEntry;
  3633. TCHAR* pszPrerequisiteEntry;
  3634. RASENTRYNAME* pRens;
  3635. RASENTRYNAME* pRen;
  3636. DWORD dwRens;
  3637. PnClearLbDialFirst( pInfo->hwndLbDialFirst );
  3638. iSel = 0;
  3639. pszEntry = pInfo->pArgs->pEntry->pszEntryName;
  3640. pszPrerequisiteEntry = pInfo->pArgs->pEntry->pszPrerequisiteEntry;
  3641. if (GetRasEntrynameTable( &pRens, &dwRens ) != 0)
  3642. {
  3643. return;
  3644. }
  3645. for (i = 0, pRen = pRens; i < dwRens; ++i, ++pRen )
  3646. {
  3647. PREREQITEM* pItem;
  3648. if (lstrcmp( pRen->szEntryName, pszEntry ) == 0)
  3649. {
  3650. continue;
  3651. }
  3652. pItem = Malloc( sizeof(PREREQITEM) );
  3653. if (!pItem)
  3654. {
  3655. continue;
  3656. }
  3657. pItem->pszEntry = StrDup( pRen->szEntryName );
  3658. pItem->pszPbk = StrDup( pRen->szPhonebookPath );
  3659. if (!pItem->pszEntry || !pItem->pszPbk)
  3660. {
  3661. Free0( pItem->pszEntry );
  3662. Free( pItem );
  3663. continue;
  3664. }
  3665. iThis = ComboBox_AddItem(
  3666. pInfo->hwndLbDialFirst, pItem->pszEntry, pItem );
  3667. if (pszPrerequisiteEntry && *(pszPrerequisiteEntry)
  3668. && lstrcmp( pItem->pszEntry, pszPrerequisiteEntry ) == 0)
  3669. {
  3670. iSel = iThis;
  3671. ComboBox_SetCurSelNotify( pInfo->hwndLbDialFirst, iSel );
  3672. }
  3673. }
  3674. Free( pRens );
  3675. if (iSel == 0)
  3676. {
  3677. ComboBox_SetCurSelNotify( pInfo->hwndLbDialFirst, iSel );
  3678. }
  3679. fEnabledLb = TRUE;
  3680. }
  3681. else
  3682. {
  3683. // Toss the existing prerequesite entry since its disabled.
  3684. //
  3685. PBENTRY* pEntry = pInfo->pArgs->pEntry;
  3686. Free0( pEntry->pszPrerequisiteEntry );
  3687. pEntry->pszPrerequisiteEntry = NULL;
  3688. Free0( pEntry->pszPrerequisitePbk );
  3689. pEntry->pszPrerequisitePbk = NULL;
  3690. }
  3691. EnableWindow( pInfo->hwndLbDialFirst, fEnabledLb );
  3692. }
  3693. BOOL
  3694. PnInit(
  3695. IN HWND hwndPage )
  3696. // Called on WM_INITDIALOG. 'hwndPage' is the handle of the property
  3697. // page.
  3698. //
  3699. // Return false if focus was set, true otherwise.
  3700. //
  3701. {
  3702. AEINFO* pInfo;
  3703. PBENTRY *pEntry;
  3704. TRACE("PnInit");
  3705. pInfo = AeContext( hwndPage );
  3706. if (!pInfo)
  3707. return TRUE;
  3708. // Initialize page-specific context information.
  3709. //
  3710. pInfo->hwndPn = hwndPage;
  3711. pInfo->hwndLbDialFirst =
  3712. GetDlgItem( hwndPage, CID_PN_LB_DialAnotherFirst );
  3713. ASSERT( pInfo->hwndLbDialFirst );
  3714. pEntry = pInfo->pArgs->pEntry;
  3715. if(RASET_Vpn == pEntry->dwType)
  3716. {
  3717. // Set the dial another first radio button so that the
  3718. // combo box of entries to dial can be filled in. If it
  3719. // turns out that there were no entries we don't need to show the page.
  3720. //
  3721. CheckDlgButton( hwndPage, CID_PN_RB_DialFirst, BST_CHECKED );
  3722. }
  3723. PnUpdateLbDialAnotherFirst( pInfo );
  3724. if (0 == ComboBox_GetCount( pInfo->hwndLbDialFirst ))
  3725. {
  3726. pInfo->fHidePublicNetworkPage = TRUE;
  3727. }
  3728. return TRUE;
  3729. }
  3730. BOOL
  3731. PnKillActive(
  3732. IN AEINFO* pInfo )
  3733. // Called when PSN_KILLACTIVE is received. 'PInfo' is the wizard context.
  3734. //
  3735. // Returns true if the page is invalid, false is it can be dismissed.
  3736. //
  3737. {
  3738. return FALSE;
  3739. }
  3740. BOOL
  3741. PnSetActive(
  3742. IN AEINFO* pInfo )
  3743. // Called when PSN_SETACTIVE is received. 'PInfo' is the wizard context.
  3744. //
  3745. // Returns true to display the page, false to skip it.
  3746. //
  3747. {
  3748. BOOL fDisplayPage;
  3749. PBENTRY* pEntry;
  3750. ASSERT(pInfo);
  3751. pEntry = pInfo->pArgs->pEntry;
  3752. if (pInfo->fHidePublicNetworkPage || (RASET_Vpn != pEntry->dwType))
  3753. {
  3754. fDisplayPage = FALSE;
  3755. }
  3756. else
  3757. {
  3758. LPARAM dwWizButtons = PSWIZB_NEXT;
  3759. DWORD dwFlags = pInfo->pArgs->pApiArgs->dwFlags;
  3760. // Show the back button if we're shell owned or, we have the
  3761. // La page before us. La page will be shown if
  3762. // not RASEDFLAG_NewTunnelEntry.
  3763. //
  3764. if ((dwFlags & RASEDFLAG_ShellOwned) ||
  3765. !(dwFlags & RASEDFLAG_NewTunnelEntry))
  3766. {
  3767. dwWizButtons |= PSWIZB_BACK;
  3768. }
  3769. PropSheet_SetWizButtons( pInfo->hwndDlg, dwWizButtons );
  3770. fDisplayPage = TRUE;
  3771. }
  3772. return fDisplayPage;
  3773. }
  3774. //----------------------------------------------------------------------------
  3775. // Smart card wizard page
  3776. // Listed alphabetically following dialog proc
  3777. //----------------------------------------------------------------------------
  3778. INT_PTR CALLBACK
  3779. ScDlgProc(
  3780. IN HWND hwnd,
  3781. IN UINT unMsg,
  3782. IN WPARAM wparam,
  3783. IN LPARAM lparam )
  3784. // DialogProc callback for the Smart Card page of the wizard.
  3785. // Parameters and return value are as described for standard windows
  3786. // 'DialogProc's.
  3787. //
  3788. {
  3789. switch (unMsg)
  3790. {
  3791. case WM_INITDIALOG:
  3792. AeSetContext( hwnd, lparam );
  3793. return ScInit( hwnd );
  3794. case WM_NOTIFY:
  3795. {
  3796. switch (((NMHDR* )lparam)->code)
  3797. {
  3798. case PSN_SETACTIVE:
  3799. {
  3800. AEINFO* pInfo;
  3801. BOOL fDisplay;
  3802. TRACE("ScSETACTIVE");
  3803. pInfo = AeContext( hwnd );
  3804. ASSERT(pInfo);
  3805. fDisplay = ScSetActive( pInfo );
  3806. SetWindowLong( hwnd, DWLP_MSGRESULT, (fDisplay) ? 0 : -1 );
  3807. return TRUE;
  3808. }
  3809. case PSN_KILLACTIVE:
  3810. {
  3811. AEINFO* pInfo;
  3812. BOOL fInvalid;
  3813. TRACE("MaKILLACTIVE");
  3814. pInfo = AeContext( hwnd );
  3815. ASSERT(pInfo);
  3816. fInvalid = ScKillActive( pInfo );
  3817. SetWindowLong( hwnd, DWLP_MSGRESULT, fInvalid );
  3818. return TRUE;
  3819. }
  3820. }
  3821. break;
  3822. }
  3823. }
  3824. return FALSE;
  3825. }
  3826. BOOL
  3827. ScInit(
  3828. IN HWND hwndPage )
  3829. // Called on WM_INITDIALOG. 'hwndPage' is the handle of the property
  3830. // page.
  3831. //
  3832. // Return false if focus was set, true otherwise.
  3833. //
  3834. {
  3835. AEINFO* pInfo;
  3836. TRACE("ScInit");
  3837. pInfo = AeContext( hwndPage );
  3838. if (!pInfo)
  3839. {
  3840. return TRUE;
  3841. }
  3842. //Smart card page is shown only for workplace path
  3843. //
  3844. if ( !AeIsWorkPlace(pInfo->pArgs->pApiArgs->dwFlags) )
  3845. {
  3846. pInfo->fSmartCardInstalled = FALSE;
  3847. pInfo->fUseSmartCard = FALSE;
  3848. return TRUE;
  3849. }
  3850. // Initialize page-specific context information.
  3851. //
  3852. pInfo->hwndSc = hwndPage;
  3853. pInfo->hwndScRbYes = GetDlgItem ( hwndPage, CID_SC_RB_YesSmartCard );
  3854. pInfo->hwndScRbNo = GetDlgItem ( hwndPage, CID_SC_RB_NoSmartCard );
  3855. // Discover whether a smart card reader is installed. If so, default
  3856. // to not use it.
  3857. //
  3858. pInfo->fSmartCardInstalled = ScSmartCardReaderInstalled( pInfo );
  3859. pInfo->fUseSmartCard = FALSE;
  3860. return FALSE;
  3861. }
  3862. BOOL
  3863. ScKillActive(
  3864. IN AEINFO* pInfo )
  3865. // Called when the smart card page is loosing activation. Records
  3866. // whether the use selected to use his/her smart card.
  3867. {
  3868. //Smart card page is shown only for workplace path
  3869. //
  3870. if ( !AeIsWorkPlace(pInfo->pArgs->pApiArgs->dwFlags) )
  3871. {
  3872. return FALSE;
  3873. }
  3874. pInfo->fUseSmartCard =
  3875. ( SendMessage(pInfo->hwndScRbYes, BM_GETCHECK, 0, 0) == BST_CHECKED );
  3876. return FALSE;
  3877. }
  3878. BOOL
  3879. ScSetActive(
  3880. IN AEINFO* pInfo )
  3881. // Called when PSN_SETACTIVE is received. 'PInfo' is the wizard context.
  3882. //
  3883. // Returns true to display the page, false to skip it.
  3884. //
  3885. {
  3886. //Smart card page is shown only for workplace path
  3887. //
  3888. if ( !AeIsWorkPlace(pInfo->pArgs->pApiArgs->dwFlags) )
  3889. {
  3890. return FALSE;
  3891. }
  3892. // Initialize the "use smart card" check
  3893. SendMessage (
  3894. pInfo->hwndScRbYes,
  3895. BM_SETCHECK,
  3896. (pInfo->fUseSmartCard) ? BST_CHECKED : BST_UNCHECKED,
  3897. 0);
  3898. // Initialize the "use smart card" check
  3899. SendMessage (
  3900. pInfo->hwndScRbNo,
  3901. BM_SETCHECK,
  3902. (pInfo->fUseSmartCard) ? BST_UNCHECKED : BST_CHECKED,
  3903. 0);
  3904. // Only show the page when a smart card reader is installed
  3905. return pInfo->fSmartCardInstalled;
  3906. }
  3907. BOOL
  3908. ScSmartCardReaderInstalled(
  3909. IN AEINFO* pInfo)
  3910. // Returns TRUE iff there is a smart card reader installed.
  3911. // Clone of FSmartCardReaderInstalled in ppp\eaptls\util.c
  3912. //
  3913. {
  3914. LONG lErr;
  3915. DWORD dwLen = 0;
  3916. SCARDCONTEXT hCtx = 0;
  3917. BOOL fReturn = FALSE;
  3918. lErr = SCardListReadersA(0, NULL, NULL, &dwLen);
  3919. fReturn = ( (NO_ERROR == lErr)
  3920. && (2 * sizeof(CHAR) < dwLen));
  3921. if (!fReturn)
  3922. {
  3923. goto LDone;
  3924. }
  3925. fReturn = FALSE;
  3926. lErr = SCardEstablishContext(SCARD_SCOPE_USER, 0, 0, &hCtx);
  3927. if (SCARD_S_SUCCESS != lErr)
  3928. {
  3929. goto LDone;
  3930. }
  3931. lErr = SCardListReadersA(hCtx, NULL, NULL, &dwLen);
  3932. fReturn = ( (NO_ERROR == lErr)
  3933. && (2 * sizeof(CHAR) < dwLen));
  3934. LDone:
  3935. if (0 != hCtx)
  3936. {
  3937. SCardReleaseContext(hCtx);
  3938. }
  3939. return(fReturn);
  3940. }
  3941. INT_PTR CALLBACK
  3942. StDlgProc(
  3943. IN HWND hwnd,
  3944. IN UINT unMsg,
  3945. IN WPARAM wparam,
  3946. IN LPARAM lparam )
  3947. // DialogProc callback for the start page of the wizard. Parameters and
  3948. // return value are as described for standard windows 'DialogProc's.
  3949. //
  3950. {
  3951. switch (unMsg)
  3952. {
  3953. case WM_INITDIALOG:
  3954. {
  3955. AEINFO* pInfo = (AEINFO* )(((PROPSHEETPAGE* )lparam)->lParam);
  3956. SetWindowLongPtr( hwnd, DWLP_USER, (ULONG_PTR )pInfo );
  3957. // Position the dialog per caller's instructions if we're not
  3958. // owned by the shell.
  3959. //
  3960. if (!(pInfo->pArgs->pApiArgs->dwFlags & RASEDFLAG_ShellOwned))
  3961. {
  3962. PositionDlg( GetParent( hwnd ),
  3963. pInfo->pArgs->pApiArgs->dwFlags & RASDDFLAG_PositionDlg,
  3964. pInfo->pArgs->pApiArgs->xDlg,
  3965. pInfo->pArgs->pApiArgs->yDlg );
  3966. }
  3967. return StInit( hwnd, pInfo );
  3968. }
  3969. case WM_NOTIFY:
  3970. {
  3971. switch (((NMHDR* )lparam)->code)
  3972. {
  3973. case PSN_SETACTIVE:
  3974. {
  3975. AEINFO* pInfo;
  3976. BOOL fDisplay;
  3977. TRACE("StSETACTIVE");
  3978. pInfo = AeContext( hwnd );
  3979. ASSERT(pInfo);
  3980. fDisplay = StSetActive( pInfo );
  3981. SetWindowLong( hwnd, DWLP_MSGRESULT, (fDisplay) ? 0 : -1 );
  3982. return TRUE;
  3983. }
  3984. case PSN_KILLACTIVE:
  3985. {
  3986. AEINFO* pInfo;
  3987. BOOL fInvalid;
  3988. TRACE("StKILLACTIVE");
  3989. pInfo = AeContext( hwnd );
  3990. ASSERT(pInfo);
  3991. fInvalid = StKillActive( pInfo );
  3992. SetWindowLong( hwnd, DWLP_MSGRESULT, fInvalid );
  3993. return TRUE;
  3994. }
  3995. }
  3996. break;
  3997. }
  3998. }
  3999. return FALSE;
  4000. }
  4001. BOOL
  4002. StInit(
  4003. IN HWND hwndPage,
  4004. IN OUT AEINFO* pInfo )
  4005. // Called on WM_INITDIALOG. 'hwndPage' is the handle of the property
  4006. // page. 'pInfo' is the arguments from the PropertySheet caller.
  4007. //
  4008. // Return false if focus was set, true otherwise.
  4009. //
  4010. {
  4011. pInfo->hwndDlg = GetParent( hwndPage );
  4012. // Initialize the common controls library for the controls we use.
  4013. //
  4014. {
  4015. INITCOMMONCONTROLSEX icc;
  4016. icc.dwSize = sizeof(icc);
  4017. icc.dwICC = ICC_INTERNET_CLASSES;
  4018. InitCommonControlsEx (&icc);
  4019. }
  4020. return TRUE;
  4021. }
  4022. BOOL
  4023. StKillActive(
  4024. IN AEINFO* pInfo )
  4025. // Called when PSN_KILLACTIVE is received. 'PInfo' is the wizard context.
  4026. //
  4027. // Returns true if the page is invalid, false is it can be dismissed.
  4028. //
  4029. {
  4030. return FALSE;
  4031. }
  4032. BOOL
  4033. StSetActive(
  4034. IN AEINFO* pInfo )
  4035. // Called when PSN_SETACTIVE is received. 'PInfo' is the wizard context.
  4036. //
  4037. // Returns true to display the page, false to skip it.
  4038. //
  4039. {
  4040. return FALSE;
  4041. }
  4042. //----------------------------------------------------------------------------
  4043. // Users property page
  4044. // Listed alphabetically following dialog proc
  4045. //----------------------------------------------------------------------------
  4046. INT_PTR CALLBACK
  4047. UsDlgProc(
  4048. IN HWND hwnd,
  4049. IN UINT unMsg,
  4050. IN WPARAM wparam,
  4051. IN LPARAM lparam )
  4052. // DialogProc callback for the Users page of the wizard. Parameters and
  4053. // return value are as described for standard windows 'DialogProc's.
  4054. //
  4055. {
  4056. switch (unMsg)
  4057. {
  4058. case WM_INITDIALOG:
  4059. AeSetContext( hwnd, lparam );
  4060. return UsInit( hwnd );
  4061. case WM_NOTIFY:
  4062. {
  4063. switch (((NMHDR* )lparam)->code)
  4064. {
  4065. case PSN_SETACTIVE:
  4066. {
  4067. AEINFO* pInfo;
  4068. BOOL fDisplay;
  4069. TRACE("UsSETACTIVE");
  4070. pInfo = AeContext( hwnd );
  4071. ASSERT(pInfo);
  4072. fDisplay = UsSetActive( pInfo );
  4073. SetWindowLong( hwnd, DWLP_MSGRESULT, (fDisplay) ? 0 : -1 );
  4074. return TRUE;
  4075. }
  4076. case PSN_KILLACTIVE:
  4077. {
  4078. AEINFO* pInfo;
  4079. BOOL fInvalid;
  4080. TRACE("UsKILLACTIVE");
  4081. pInfo = AeContext( hwnd );
  4082. ASSERT(pInfo);
  4083. fInvalid = UsKillActive( pInfo );
  4084. SetWindowLong( hwnd, DWLP_MSGRESULT, fInvalid );
  4085. return TRUE;
  4086. }
  4087. }
  4088. break;
  4089. }
  4090. }
  4091. return FALSE;
  4092. }
  4093. BOOL
  4094. UsInit(
  4095. IN HWND hwndPage )
  4096. // Called on WM_INITDIALOG. 'hwndPage' is the handle of the property
  4097. // page.
  4098. //
  4099. // Return false if focus was set, true otherwise.
  4100. //
  4101. {
  4102. AEINFO* pInfo;
  4103. TRACE("UsInit");
  4104. pInfo = AeContext( hwndPage );
  4105. if (!pInfo)
  4106. return TRUE;
  4107. // Don't execute on personal (DT page in this case)
  4108. //
  4109. if (IsConsumerPlatform())
  4110. {
  4111. //For consumer platform, personal or non-domain professional
  4112. //all connections are all-user
  4113. pInfo->fCreateForAllUsers = TRUE;
  4114. return TRUE;
  4115. }
  4116. // Initialize page-specific context information.
  4117. //
  4118. pInfo->hwndUs = hwndPage;
  4119. pInfo->hwndUsRbForAll = GetDlgItem( hwndPage, CID_US_RB_All );
  4120. pInfo->hwndUsRbForMe = GetDlgItem( hwndPage, CID_US_RB_Myself );
  4121. // If the user is an administrator or power user, we want the default
  4122. // to be to create the phone book entry for all users. This
  4123. // must correspond to how ReadPhonebookFile opens the default phonebook.
  4124. //
  4125. //For whistler bug 382795
  4126. //We let the VPN connection default to "My use only"
  4127. //
  4128. if ( RASEDFLAG_NewTunnelEntry & pInfo->pArgs->pApiArgs->dwFlags )
  4129. {
  4130. pInfo->fCreateForAllUsers = FALSE;
  4131. }
  4132. else
  4133. {
  4134. pInfo->fCreateForAllUsers = pInfo->pArgs->fIsUserAdminOrPowerUser;
  4135. }
  4136. return TRUE;
  4137. }
  4138. BOOL
  4139. UsKillActive(
  4140. IN AEINFO* pInfo )
  4141. // Called when PSN_KILLACTIVE is received. 'PInfo' is the wizard context.
  4142. //
  4143. // Returns true if the page is invalid, false is it can be dismissed.
  4144. //
  4145. {
  4146. BOOL fCreateForAllUsers;
  4147. // Don't execute on personal (DT page in this case)
  4148. //
  4149. if (IsConsumerPlatform())
  4150. {
  4151. return FALSE;
  4152. }
  4153. fCreateForAllUsers = Button_GetCheck( pInfo->hwndUsRbForAll );
  4154. // We need to (re)open the phonebook file corresponding to the selection.
  4155. // Only do this if the selection has changed, or we don't have the file
  4156. // open yet. We definitely need to have it open when this page is left
  4157. // because subsequent pages depend on it.
  4158. //
  4159. if ((fCreateForAllUsers != pInfo->fCreateForAllUsers) ||
  4160. !pInfo->pArgs->pFile ||
  4161. (fCreateForAllUsers != IsPublicPhonebook(pInfo->pArgs->pFile->pszPath)))
  4162. {
  4163. pInfo->fCreateForAllUsers = fCreateForAllUsers;
  4164. // Close and re-open the phonebook file since the All Users flag has
  4165. // changed
  4166. ReOpenPhonebookFile(pInfo->fCreateForAllUsers,
  4167. pInfo->pArgs->pFile);
  4168. }
  4169. return FALSE;
  4170. }
  4171. BOOL
  4172. UsSetActive(
  4173. IN AEINFO* pInfo )
  4174. // Called when PSN_SETACTIVE is received. 'PInfo' is the wizard context.
  4175. //
  4176. // Returns true to display the page, false to skip it.
  4177. //
  4178. {
  4179. // Don't execute on personal (DT page in this case)
  4180. //
  4181. if (IsConsumerPlatform())
  4182. {
  4183. return FALSE;
  4184. }
  4185. if (pInfo->fDccHost)
  4186. {
  4187. return FALSE;
  4188. }
  4189. // We don't give the option to create all-user connections to non-admins.
  4190. //
  4191. if (!pInfo->pArgs->fIsUserAdminOrPowerUser)
  4192. {
  4193. EnableWindow( pInfo->hwndUsRbForAll, FALSE );
  4194. //Change for whistler bug 283902 gangz
  4195. //
  4196. Button_SetCheck( pInfo->hwndUsRbForMe, TRUE);
  4197. }
  4198. // Set the radio buttons.
  4199. //
  4200. /*
  4201. //For whistler bug 382795
  4202. //We let the VPN connection default to "My use only"
  4203. //
  4204. if ( RASEDFLAG_NewTunnelEntry & pInfo->pArgs->pApiArgs->dwFlags )
  4205. {
  4206. Button_SetCheck( pInfo->hwndUsRbForAll, FALSE);
  4207. Button_SetCheck( pInfo->hwndUsRbForMe, TRUE );
  4208. }
  4209. else
  4210. */
  4211. {
  4212. Button_SetCheck( pInfo->hwndUsRbForAll, pInfo->fCreateForAllUsers );
  4213. Button_SetCheck( pInfo->hwndUsRbForMe, !pInfo->fCreateForAllUsers );
  4214. }
  4215. PropSheet_SetWizButtons( pInfo->hwndDlg, PSWIZB_BACK | PSWIZB_NEXT );
  4216. return TRUE;
  4217. }
  4218. //----------------------------------------------------------------------------
  4219. // Shared-access property page
  4220. // Listed alphabetically following dialog proc
  4221. //----------------------------------------------------------------------------
  4222. INT_PTR CALLBACK
  4223. SwDlgProc(
  4224. IN HWND hwnd,
  4225. IN UINT unMsg,
  4226. IN WPARAM wparam,
  4227. IN LPARAM lparam )
  4228. // DialogProc callback for the Shared-access page of the wizard. Parameters
  4229. // and return value are as described for standard windows 'DialogProc's.
  4230. //
  4231. {
  4232. switch (unMsg)
  4233. {
  4234. case WM_INITDIALOG:
  4235. AeSetContext( hwnd, lparam );
  4236. return SwInit( hwnd );
  4237. case WM_COMMAND:
  4238. {
  4239. AEINFO* pInfo = AeContext( hwnd );
  4240. ASSERT(pInfo);
  4241. return SwCommand(
  4242. pInfo, HIWORD( wparam ), LOWORD( wparam ),(HWND )lparam );
  4243. }
  4244. case WM_NOTIFY:
  4245. {
  4246. switch (((NMHDR* )lparam)->code)
  4247. {
  4248. case PSN_SETACTIVE:
  4249. {
  4250. AEINFO* pInfo;
  4251. BOOL fDisplay;
  4252. TRACE("SwSETACTIVE");
  4253. pInfo = AeContext( hwnd );
  4254. ASSERT(pInfo);
  4255. fDisplay = SwSetActive( pInfo );
  4256. SetWindowLong( hwnd, DWLP_MSGRESULT, (fDisplay) ? 0 : -1 );
  4257. return TRUE;
  4258. }
  4259. case PSN_KILLACTIVE:
  4260. {
  4261. AEINFO* pInfo;
  4262. BOOL fInvalid;
  4263. TRACE("SwKILLACTIVE");
  4264. pInfo = AeContext( hwnd );
  4265. ASSERT(pInfo);
  4266. fInvalid = SwKillActive( pInfo );
  4267. SetWindowLong( hwnd, DWLP_MSGRESULT, fInvalid );
  4268. return TRUE;
  4269. }
  4270. }
  4271. break;
  4272. }
  4273. }
  4274. return FALSE;
  4275. }
  4276. BOOL
  4277. SwCommand(
  4278. IN AEINFO* pInfo,
  4279. IN WORD wNotification,
  4280. IN WORD wId,
  4281. IN HWND hwndCtrl )
  4282. // Called on WM_COMMAND. 'PInfo' is the dialog context. 'WNotification'
  4283. // is the notification code of the command. 'wId' is the control/menu
  4284. // identifier of the command. 'HwndCtrl' is the control window handle of
  4285. // the command.
  4286. //
  4287. // Returns true if processed message, false otherwise.
  4288. //
  4289. {
  4290. TRACE3( "SwCommand(n=%d,i=%d,c=$%x)",
  4291. (DWORD )wNotification, (DWORD )wId, (ULONG_PTR )hwndCtrl );
  4292. switch (wId)
  4293. {
  4294. case CID_SW_PB_Shared:
  4295. {
  4296. BOOL fShared =
  4297. Button_GetCheck( GetDlgItem(pInfo->hwndSw, CID_SW_PB_Shared) );
  4298. EnableWindow(
  4299. GetDlgItem( pInfo->hwndSw, CID_SW_ST_DemandDial), fShared );
  4300. EnableWindow(
  4301. GetDlgItem( pInfo->hwndSw, CID_SW_PB_DemandDial), fShared );
  4302. return TRUE;
  4303. }
  4304. }
  4305. return FALSE;
  4306. }
  4307. BOOL
  4308. SwInit(
  4309. IN HWND hwndPage )
  4310. // Called on WM_INITDIALOG. 'hwndPage' is the handle of the property
  4311. // page.
  4312. //
  4313. // Return false if focus was set, true otherwise.
  4314. //
  4315. {
  4316. AEINFO* pInfo;
  4317. TRACE("SwInit");
  4318. pInfo = AeContext( hwndPage );
  4319. if (!pInfo)
  4320. return TRUE;
  4321. // Initialize page-specific context information.
  4322. //
  4323. pInfo->hwndSw = hwndPage;
  4324. Button_SetCheck(
  4325. GetDlgItem(pInfo->hwndSw, CID_SW_PB_Shared),
  4326. pInfo->pArgs->fShared );
  4327. Button_SetCheck(
  4328. GetDlgItem(pInfo->hwndSw, CID_SW_PB_DemandDial),
  4329. pInfo->pArgs->fDemandDial );
  4330. SwCommand(
  4331. pInfo, BN_CLICKED, CID_SW_PB_Shared,
  4332. GetDlgItem(pInfo->hwndSw, CID_SW_PB_Shared) );
  4333. return TRUE;
  4334. }
  4335. BOOL
  4336. SwKillActive(
  4337. IN AEINFO* pInfo )
  4338. // Called when PSN_KILLACTIVE is received. 'PInfo' is the wizard context.
  4339. //
  4340. // Returns true if the page is invalid, false is it can be dismissed.
  4341. //
  4342. {
  4343. if (!pInfo->fCreateForAllUsers)
  4344. {
  4345. pInfo->pArgs->fNewShared = pInfo->pArgs->fShared;
  4346. pInfo->pArgs->fNewDemandDial = pInfo->pArgs->fDemandDial;
  4347. }
  4348. else
  4349. {
  4350. pInfo->pArgs->fNewShared =
  4351. Button_GetCheck( GetDlgItem(pInfo->hwndSw, CID_SW_PB_Shared) );
  4352. pInfo->pArgs->fNewDemandDial =
  4353. Button_GetCheck( GetDlgItem(pInfo->hwndSw, CID_SW_PB_DemandDial) );
  4354. if (pInfo->pArgs->fNewShared)
  4355. {
  4356. UINT unId;
  4357. MSGARGS msgargs;
  4358. ZeroMemory( &msgargs, sizeof(msgargs) );
  4359. msgargs.dwFlags = MB_YESNO | MB_ICONINFORMATION;
  4360. unId = MsgDlg( pInfo->hwndDlg, SID_EnableSharedAccess, &msgargs );
  4361. if (unId == IDNO)
  4362. {
  4363. pInfo->pArgs->fNewShared = pInfo->pArgs->fShared;
  4364. pInfo->pArgs->fNewDemandDial = pInfo->pArgs->fDemandDial;
  4365. return TRUE;
  4366. }
  4367. }
  4368. }
  4369. return FALSE;
  4370. }
  4371. BOOL
  4372. SwSetActive(
  4373. IN AEINFO* pInfo )
  4374. // Called when PSN_SETACTIVE is received. 'PInfo' is the wizard context.
  4375. //
  4376. // Returns true to display the page, false to skip it.
  4377. //
  4378. {
  4379. NT_PRODUCT_TYPE ProductType;
  4380. ASSERT(pInfo);
  4381. // skip the page if
  4382. // (a) this is a workstation installation
  4383. // (b) the user does not have administrative privileges
  4384. // (c) the connection is not for all users
  4385. // (d) TCP/IP is not configured
  4386. // (e) there is already a shared connection
  4387. // (f) there are no lan connections
  4388. //
  4389. RtlGetNtProductType(&ProductType);
  4390. if (ProductType == NtProductWinNt ||
  4391. !pInfo->pArgs->fIsUserAdminOrPowerUser ||
  4392. !pInfo->fCreateForAllUsers ||
  4393. !pInfo->fIpConfigured ||
  4394. // pInfo->pArgs->fAnyShared ||
  4395. !pInfo->pArgs->dwLanCount )
  4396. {
  4397. return FALSE;
  4398. }
  4399. else
  4400. {
  4401. EnableWindow(
  4402. GetDlgItem( pInfo->hwndSw, CID_SW_ST_DemandDial ),
  4403. pInfo->pArgs->fNewShared );
  4404. EnableWindow(
  4405. GetDlgItem( pInfo->hwndSw, CID_SW_PB_DemandDial ),
  4406. pInfo->pArgs->fNewShared );
  4407. return TRUE;
  4408. }
  4409. }
  4410. //----------------------------------------------------------------------------
  4411. // Shared private-lan property page
  4412. // Listed alphabetically following dialog proc
  4413. //----------------------------------------------------------------------------
  4414. INT_PTR CALLBACK
  4415. SpDlgProc(
  4416. IN HWND hwnd,
  4417. IN UINT unMsg,
  4418. IN WPARAM wparam,
  4419. IN LPARAM lparam )
  4420. // DialogProc callback for the Shared private-lan page of the wizard.
  4421. // Parameters / and return value are as described for standard windows
  4422. // 'DialogProc's.
  4423. //
  4424. {
  4425. switch (unMsg)
  4426. {
  4427. case WM_INITDIALOG:
  4428. AeSetContext( hwnd, lparam );
  4429. return SpInit( hwnd );
  4430. case WM_NOTIFY:
  4431. {
  4432. switch (((NMHDR* )lparam)->code)
  4433. {
  4434. case PSN_SETACTIVE:
  4435. {
  4436. AEINFO* pInfo;
  4437. BOOL fDisplay;
  4438. TRACE("SpSETACTIVE");
  4439. pInfo = AeContext( hwnd );
  4440. ASSERT(pInfo);
  4441. fDisplay = SpSetActive( pInfo );
  4442. SetWindowLong( hwnd, DWLP_MSGRESULT, (fDisplay) ? 0 : -1 );
  4443. return TRUE;
  4444. }
  4445. case PSN_KILLACTIVE:
  4446. {
  4447. AEINFO* pInfo;
  4448. BOOL fInvalid;
  4449. TRACE("SpKILLACTIVE");
  4450. pInfo = AeContext( hwnd );
  4451. ASSERT(pInfo);
  4452. fInvalid = SpKillActive( pInfo );
  4453. SetWindowLong( hwnd, DWLP_MSGRESULT, fInvalid );
  4454. return TRUE;
  4455. }
  4456. }
  4457. break;
  4458. }
  4459. }
  4460. return FALSE;
  4461. }
  4462. BOOL
  4463. SpInit(
  4464. IN HWND hwndPage )
  4465. // Called on WM_INITDIALOG. 'hwndPage' is the handle of the property
  4466. // page.
  4467. //
  4468. // Return false if focus was set, true otherwise.
  4469. //
  4470. {
  4471. DWORD i;
  4472. INT item;
  4473. AEINFO* pInfo;
  4474. NETCON_PROPERTIES* pLanTable;
  4475. TRACE("SpInit");
  4476. pInfo = AeContext( hwndPage );
  4477. if (!pInfo)
  4478. return TRUE;
  4479. // Initialize page-specific context information.
  4480. //
  4481. pInfo->hwndSp = hwndPage;
  4482. pInfo->hwndSpLbPrivateLan = GetDlgItem( hwndPage, CID_SP_LB_PrivateLan );
  4483. ASSERT( pInfo->hwndSpLbPrivateLan );
  4484. // Fill the drop-list with lan connections
  4485. //
  4486. /* pLanTable = (NETCON_PROPERTIES*)pInfo->pArgs->pLanTable;
  4487. for (i = 0; i < pInfo->pArgs->dwLanCount; i++)
  4488. {
  4489. item =
  4490. ComboBox_AddString(
  4491. pInfo->hwndSpLbPrivateLan, pLanTable[i].pszwName );
  4492. if (item != CB_ERR)
  4493. {
  4494. ComboBox_SetItemData(
  4495. pInfo->hwndSpLbPrivateLan, item, &pLanTable[i].guidId );
  4496. }
  4497. }*/
  4498. ComboBox_SetCurSel( pInfo->hwndSpLbPrivateLan, 0 );
  4499. return TRUE;
  4500. }
  4501. BOOL
  4502. SpKillActive(
  4503. IN AEINFO* pInfo )
  4504. // Called when PSN_KILLACTIVE is received. 'PInfo' is the wizard context.
  4505. //
  4506. // Returns true if the page is invalid, false is it can be dismissed.
  4507. //
  4508. {
  4509. if (!pInfo->pArgs->fNewShared || (pInfo->pArgs->dwLanCount <= 1))
  4510. {
  4511. pInfo->pArgs->pPrivateLanConnection = NULL;
  4512. }
  4513. else
  4514. {
  4515. INT item = ComboBox_GetCurSel( pInfo->hwndSpLbPrivateLan );
  4516. if (item != CB_ERR)
  4517. {
  4518. pInfo->pArgs->pPrivateLanConnection =
  4519. (IHNetConnection*)ComboBox_GetItemData(
  4520. pInfo->hwndSpLbPrivateLan, item );
  4521. }
  4522. }
  4523. return FALSE;
  4524. }
  4525. BOOL
  4526. SpSetActive(
  4527. IN AEINFO* pInfo )
  4528. // Called when PSN_SETACTIVE is received. 'PInfo' is the wizard context.
  4529. //
  4530. // Returns true to display the page, false to skip it.
  4531. //
  4532. {
  4533. ASSERT(pInfo);
  4534. // skip the page if
  4535. // (a) sharing has not been enabled
  4536. // (b) there is less than or equal to one lan interface.
  4537. //
  4538. if (!pInfo->pArgs->fNewShared || (pInfo->pArgs->dwLanCount <= 1))
  4539. {
  4540. return FALSE;
  4541. }
  4542. return TRUE;
  4543. }
  4544. BOOL
  4545. GhCommand(
  4546. IN AEINFO* pInfo,
  4547. IN WORD wNotification,
  4548. IN WORD wId,
  4549. IN HWND hwndCtrl )
  4550. // Called on WM_COMMAND. 'PInfo' is the dialog context. 'WNotification'
  4551. // is the notification code of the command. 'wId' is the control/menu
  4552. // identifier of the command. 'HwndCtrl' is the control window handle of
  4553. // the command.
  4554. //
  4555. // Returns true if processed message, false otherwise.
  4556. //
  4557. {
  4558. TRACE3("GhCommand(n=%d,i=%d,c=$%x)",
  4559. (DWORD)wNotification,(DWORD)wId,(ULONG_PTR )hwndCtrl);
  4560. switch (wId)
  4561. {
  4562. case CID_GH_RB_Host:
  4563. {
  4564. switch (wNotification)
  4565. {
  4566. case BN_CLICKED:
  4567. {
  4568. pInfo->fDccHost = TRUE;
  4569. break;
  4570. }
  4571. }
  4572. break;
  4573. }
  4574. case CID_GH_RB_Guest:
  4575. {
  4576. switch (wNotification)
  4577. {
  4578. case BN_CLICKED:
  4579. {
  4580. pInfo->fDccHost = FALSE;
  4581. break;
  4582. }
  4583. }
  4584. break;
  4585. }
  4586. }
  4587. return FALSE;
  4588. }
  4589. INT_PTR CALLBACK
  4590. GhDlgProc(
  4591. IN HWND hwnd,
  4592. IN UINT unMsg,
  4593. IN WPARAM wparam,
  4594. IN LPARAM lparam )
  4595. // DialogProc callback for the Guest Host page of the Direct Connect wizard.
  4596. // Parameters and return value are as described for standard windows
  4597. // 'DialogProc's.
  4598. //
  4599. {
  4600. switch (unMsg)
  4601. {
  4602. case WM_INITDIALOG:
  4603. AeSetContext( hwnd, lparam );
  4604. return GhInit( hwnd );
  4605. case WM_NOTIFY:
  4606. {
  4607. switch (((NMHDR* )lparam)->code)
  4608. {
  4609. case PSN_SETACTIVE:
  4610. {
  4611. AEINFO* pInfo;
  4612. BOOL fDisplay;
  4613. TRACE("GhSETACTIVE");
  4614. pInfo = AeContext( hwnd );
  4615. ASSERT(pInfo);
  4616. fDisplay = GhSetActive( pInfo );
  4617. SetWindowLong( hwnd, DWLP_MSGRESULT, (fDisplay) ? 0 : -1 );
  4618. return TRUE;
  4619. }
  4620. case PSN_KILLACTIVE:
  4621. {
  4622. AEINFO* pInfo;
  4623. BOOL fInvalid;
  4624. TRACE("PaKILLACTIVE");
  4625. pInfo = AeContext( hwnd );
  4626. ASSERT(pInfo);
  4627. fInvalid = GhKillActive( pInfo );
  4628. SetWindowLong( hwnd, DWLP_MSGRESULT, fInvalid );
  4629. return TRUE;
  4630. }
  4631. }
  4632. break;
  4633. }
  4634. case WM_COMMAND:
  4635. {
  4636. AEINFO* pInfo = AeContext( hwnd );
  4637. ASSERT(pInfo);
  4638. return GhCommand(
  4639. pInfo, HIWORD( wparam ), LOWORD( wparam ), (HWND )lparam );
  4640. }
  4641. }
  4642. return FALSE;
  4643. }
  4644. BOOL
  4645. GhInit(
  4646. IN HWND hwndPage )
  4647. // Called on WM_INITDIALOG. 'hwndPage' is the handle of the property
  4648. // page.
  4649. //
  4650. // Return false if focus was set, true otherwise.
  4651. //
  4652. {
  4653. AEINFO* pInfo;
  4654. HWND hwndHost = GetDlgItem( hwndPage, CID_GH_RB_Host );
  4655. HWND hwndGuest = GetDlgItem( hwndPage, CID_GH_RB_Guest );
  4656. TRACE("GhInit");
  4657. // Initialize page-specific context information.
  4658. //
  4659. pInfo = AeContext( hwndPage );
  4660. if (!pInfo)
  4661. return TRUE;
  4662. pInfo->hwndGh = hwndPage;
  4663. // If the user is an admin or power user, then enable the
  4664. // host control and set focus to it
  4665. //
  4666. if (pInfo->pArgs->fIsUserAdminOrPowerUser)
  4667. {
  4668. pInfo->fDccHost = TRUE;
  4669. SetFocus(hwndHost);
  4670. }
  4671. // Otherwise, this page will be skipped
  4672. //
  4673. else
  4674. {
  4675. pInfo->fDccHost = FALSE;
  4676. EnableWindow(hwndHost, FALSE);
  4677. SetFocus(hwndGuest);
  4678. }
  4679. SendMessage (
  4680. hwndHost,
  4681. BM_SETCHECK,
  4682. (pInfo->fDccHost) ? BST_CHECKED : BST_UNCHECKED,
  4683. 0);
  4684. SendMessage (
  4685. hwndGuest,
  4686. BM_SETCHECK,
  4687. (!pInfo->fDccHost) ? BST_CHECKED : BST_UNCHECKED,
  4688. 0);
  4689. return FALSE;
  4690. }
  4691. BOOL
  4692. GhKillActive(
  4693. IN AEINFO* pInfo )
  4694. // Called when PSN_KILLACTIVE is received. 'PInfo' is the wizard context.
  4695. //
  4696. // Returns true if the page is invalid, false if it can be dismissed.
  4697. //
  4698. {
  4699. // Show the ras-server specific pages according to whether
  4700. // host was selected. Show the ras client pages accordingly.
  4701. RassrvShowWizPages (pInfo->pvDccHostContext, pInfo->fDccHost);
  4702. return FALSE;
  4703. }
  4704. BOOL
  4705. GhSetActive(
  4706. IN AEINFO* pInfo )
  4707. // Called when PSN_SETACTIVE is received. 'PInfo' is the wizard context.
  4708. //
  4709. // Returns true to display the page, false to skip it.
  4710. //
  4711. {
  4712. LPARAM dwWizButtons = PSWIZB_NEXT;
  4713. // If we're not an admin, only the guest path
  4714. // is available.
  4715. //
  4716. if (! pInfo->pArgs->fIsUserAdminOrPowerUser)
  4717. {
  4718. pInfo->fDccHost = FALSE;
  4719. }
  4720. if (pInfo->pArgs->pApiArgs->dwFlags & RASEDFLAG_ShellOwned)
  4721. {
  4722. dwWizButtons |= PSWIZB_BACK;
  4723. }
  4724. PropSheet_SetWizButtons( pInfo->hwndDlg, dwWizButtons );
  4725. return TRUE;
  4726. }
  4727. DWORD
  4728. DnUpdateSelectedDevice(
  4729. IN AEINFO* pInfo,
  4730. IN HWND hwndLv)
  4731. // Called to a handle the fact that a device has changed
  4732. // in the direct connect wizard.
  4733. {
  4734. DTLLIST* pList = NULL;
  4735. DTLNODE* pNode = NULL, *pNode2 = NULL;
  4736. PBLINK * pLink = NULL;
  4737. // pmay: 372661
  4738. //
  4739. // Validate the connection type so that the right logic is
  4740. // applied.
  4741. //
  4742. if (pInfo->pArgs->pEntry->dwType != RASET_Direct)
  4743. {
  4744. return NO_ERROR;
  4745. }
  4746. pList = pInfo->pArgs->pEntry->pdtllistLinks;
  4747. // Get node from current selection
  4748. pNode = (DTLNODE* )ComboBox_GetItemDataPtr(
  4749. hwndLv,
  4750. ComboBox_GetCurSel( hwndLv ) );
  4751. if(NULL == pNode)
  4752. {
  4753. return NO_ERROR;
  4754. }
  4755. // Remove selected item from list of links
  4756. // and disable all other links
  4757. DtlRemoveNode ( pList, pNode );
  4758. for (pNode2 = DtlGetFirstNode (pList);
  4759. pNode2;
  4760. pNode2 = DtlGetNextNode (pNode2))
  4761. {
  4762. pLink = (PBLINK* )DtlGetData( pNode2 );
  4763. pLink->fEnabled = FALSE;
  4764. }
  4765. // Enable selected device and Re-add
  4766. // in list of links at front
  4767. pLink = (PBLINK* )DtlGetData( pNode );
  4768. pLink->fEnabled = TRUE;
  4769. DtlAddNodeFirst( pList, pNode );
  4770. return NO_ERROR;
  4771. }
  4772. BOOL
  4773. DnCommand(
  4774. IN AEINFO* pInfo,
  4775. IN WORD wNotification,
  4776. IN WORD wId,
  4777. IN HWND hwndCtrl )
  4778. // Called on WM_COMMAND. 'PInfo' is the dialog context. 'WNotification'
  4779. // is the notification code of the command. 'wId' is the control/menu
  4780. // identifier of the command. 'HwndCtrl' is the control window handle of
  4781. // the command.
  4782. //
  4783. // Returns true if processed message, false otherwise.
  4784. //
  4785. {
  4786. TRACE3("DnCommand(n=%d,i=%d,c=$%x)",
  4787. (DWORD)wNotification,(DWORD)wId,(ULONG_PTR )hwndCtrl);
  4788. switch (wNotification)
  4789. {
  4790. case CBN_SELCHANGE:
  4791. if (wId == CID_DN_CB_DeviceSelect)
  4792. DnUpdateSelectedDevice(pInfo, hwndCtrl);
  4793. break;
  4794. }
  4795. return FALSE;
  4796. }
  4797. INT_PTR CALLBACK
  4798. DnDlgProc(
  4799. IN HWND hwnd,
  4800. IN UINT unMsg,
  4801. IN WPARAM wparam,
  4802. IN LPARAM lparam )
  4803. // DialogProc callback for the direct connect device page of the Direct Connect wizard.
  4804. // Parameters and return value are as described for standard windows
  4805. // 'DialogProc's.
  4806. //
  4807. {
  4808. switch (unMsg)
  4809. {
  4810. case WM_INITDIALOG:
  4811. AeSetContext( hwnd, lparam );
  4812. return DnInit( hwnd );
  4813. case WM_NOTIFY:
  4814. {
  4815. switch (((NMHDR* )lparam)->code)
  4816. {
  4817. case PSN_SETACTIVE:
  4818. {
  4819. AEINFO* pInfo;
  4820. BOOL fDisplay;
  4821. TRACE("GhSETACTIVE");
  4822. pInfo = AeContext( hwnd );
  4823. ASSERT(pInfo);
  4824. fDisplay = DnSetActive( pInfo );
  4825. SetWindowLong( hwnd, DWLP_MSGRESULT, (fDisplay) ? 0 : -1 );
  4826. return TRUE;
  4827. }
  4828. case PSN_KILLACTIVE:
  4829. {
  4830. AEINFO* pInfo;
  4831. BOOL fInvalid;
  4832. TRACE("PaKILLACTIVE");
  4833. pInfo = AeContext( hwnd );
  4834. ASSERT(pInfo);
  4835. fInvalid = DnKillActive( pInfo );
  4836. SetWindowLong( hwnd, DWLP_MSGRESULT, fInvalid );
  4837. return TRUE;
  4838. }
  4839. }
  4840. break;
  4841. }
  4842. case WM_COMMAND:
  4843. {
  4844. AEINFO* pInfo = AeContext( hwnd );
  4845. ASSERT(pInfo);
  4846. return DnCommand(
  4847. pInfo, HIWORD( wparam ), LOWORD( wparam ), (HWND )lparam );
  4848. }
  4849. }
  4850. return FALSE;
  4851. }
  4852. BOOL
  4853. DnInit(
  4854. IN HWND hwndPage )
  4855. // Called on WM_INITDIALOG. 'hwndPage' is the handle of the property
  4856. // page.
  4857. //
  4858. // Return false if focus was set, true otherwise.
  4859. //
  4860. {
  4861. AEINFO* pInfo;
  4862. HWND hwndCb = GetDlgItem( hwndPage, CID_DN_CB_DeviceSelect );
  4863. TRACE("DnInit");
  4864. // Initialize page-specific context information.
  4865. //
  4866. pInfo = AeContext( hwndPage );
  4867. if (!pInfo)
  4868. return TRUE;
  4869. pInfo->hwndDn = hwndPage;
  4870. // Fill the dropdown list of devices and select the first item.
  4871. //
  4872. {
  4873. TCHAR* psz;
  4874. DTLNODE* pNode;
  4875. INT iItem;
  4876. iItem = 1;
  4877. for (pNode = DtlGetFirstNode( pInfo->pArgs->pEntry->pdtllistLinks );
  4878. pNode;
  4879. pNode = DtlGetNextNode( pNode ))
  4880. {
  4881. PBLINK* pLink = NULL;
  4882. DWORD dwImage;
  4883. pLink = (PBLINK* )DtlGetData( pNode );
  4884. ASSERT(pLink);
  4885. psz = DisplayPszFromPpbport( &pLink->pbport, &dwImage );
  4886. if (psz)
  4887. {
  4888. PBLINK* pLinkTmp = NULL;
  4889. pLinkTmp = (PBLINK* )DtlGetData( pNode );
  4890. ComboBox_AddItem( hwndCb, psz, pNode );
  4891. Free( psz );
  4892. }
  4893. }
  4894. ComboBox_SetCurSelNotify(hwndCb, 0);
  4895. }
  4896. SetFocus( hwndCb );
  4897. return FALSE;
  4898. }
  4899. BOOL
  4900. DnKillActive(
  4901. IN AEINFO* pInfo )
  4902. // Called when PSN_KILLACTIVE is received. 'PInfo' is the wizard context.
  4903. //
  4904. // Returns true if the page is invalid, false if it can be dismissed.
  4905. //
  4906. {
  4907. return FALSE;
  4908. }
  4909. BOOL
  4910. DnSetActive(
  4911. IN AEINFO* pInfo )
  4912. // Called when PSN_SETACTIVE is received. 'PInfo' is the wizard context.
  4913. //
  4914. // Returns true to display the page, false to skip it.
  4915. //
  4916. {
  4917. LPARAM dwWizButtons = PSWIZB_NEXT;
  4918. DWORD dwFlags = pInfo->pArgs->pApiArgs->dwFlags;
  4919. PBENTRY* pEntry = pInfo->pArgs->pEntry;
  4920. // If the "guest" option of the dcc client wasn't selected,
  4921. // don't allow this page to show.
  4922. if ((pInfo->fDccHost) || (RASET_Direct != pEntry->dwType))
  4923. {
  4924. return FALSE;
  4925. }
  4926. // Show the back button if we're shell owned or, we have the
  4927. // La page before us.
  4928. //
  4929. if ((dwFlags & RASEDFLAG_ShellOwned) ||
  4930. !(dwFlags & RASEDFLAG_NewDirectEntry) || !pInfo->fSkipMa)
  4931. {
  4932. dwWizButtons |= PSWIZB_BACK;
  4933. }
  4934. PropSheet_SetWizButtons( pInfo->hwndDlg, dwWizButtons );
  4935. return TRUE;
  4936. }