Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

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