Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

6360 lines
181 KiB

  1. // Copyright (c) 1995, Microsoft Corporation, all rights reserved
  2. //
  3. // entryps.c
  4. // Remote Access Common Dialog APIs
  5. // Phonebook Entry property sheet
  6. //
  7. // 06/20/95 Steve Cobb
  8. //
  9. #include "rasdlgp.h"
  10. #include "entryps.h"
  11. #include "uiinfo.h"
  12. #include "inetcfgp.h"
  13. #include "netcon.h"
  14. #include "rassrvrc.h"
  15. #include "shlobjp.h"
  16. #include "shellapi.h"
  17. #include "iphlpapi.h"
  18. #include "prsht.h"
  19. #include "pbkp.h"
  20. // Page definitions.
  21. //
  22. #define PE_GePage 0
  23. #define PE_OePage 1
  24. #define PE_LoPage 2
  25. #define PE_NePage 3
  26. #define PE_SaPage 4
  27. #define PE_PageCount 5
  28. // (Router) Callback context block.
  29. //
  30. #define CRINFO struct tagCRINFO
  31. CRINFO
  32. {
  33. /* Caller's argument to the stub API.
  34. */
  35. EINFO* pArgs;
  36. /* Dialog and control handles.
  37. */
  38. HWND hwndDlg;
  39. HWND hwndRbNo;
  40. HWND hwndRbYes;
  41. HWND hwndLvNumbers;
  42. HWND hwndPbEdit;
  43. HWND hwndPbDelete;
  44. };
  45. static TCHAR g_pszFirewallRegKey[] = TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\HomeNetworking\\PersonalFirewall");
  46. static TCHAR g_pszDisableFirewallWarningValue[] = TEXT("ShowDisableFirewallWarning");
  47. //----------------------------------------------------------------------------
  48. // Help maps
  49. //----------------------------------------------------------------------------
  50. static const DWORD g_adwGeHelp[] =
  51. {
  52. CID_GE_GB_ConnectUsing, HID_GE_LV_Device, //HID_GE_GB_ConnectUsing,
  53. CID_GE_LV_Device, HID_GE_LV_Device,
  54. CID_GE_LV_Devices, HID_GE_LV_Devices,
  55. CID_GE_PB_MoveUp, HID_GE_PB_MoveUp,
  56. CID_GE_PB_MoveDown, HID_GE_PB_MoveDown,
  57. CID_GE_CB_SharedPhoneNumber, HID_GE_CB_SharedPhoneNumber,
  58. CID_GE_PB_Configure, HID_GE_PB_Configure,
  59. CID_GE_ST_AreaCodes, HID_GE_CLB_AreaCodes,
  60. CID_GE_CLB_AreaCodes, HID_GE_CLB_AreaCodes,
  61. CID_GE_ST_PhoneNumber, HID_GE_EB_PhoneNumber,
  62. CID_GE_EB_PhoneNumber, HID_GE_EB_PhoneNumber,
  63. CID_GE_ST_CountryCodes, HID_GE_LB_CountryCodes,
  64. CID_GE_LB_CountryCodes, HID_GE_LB_CountryCodes,
  65. CID_GE_CB_UseDialingRules, HID_GE_CB_UseDialingRules,
  66. CID_GE_PB_Alternates, HID_GE_PB_Alternates,
  67. CID_GE_CB_ShowIcon, HID_GE_CB_ShowIcon,
  68. CID_GE_ST_HostName, HID_GE_EB_HostName,
  69. CID_GE_EB_HostName, HID_GE_EB_HostName,
  70. CID_GE_ST_ServiceName, HID_GE_EB_ServiceName, //Add for whistler bug 343249
  71. CID_GE_EB_ServiceName, HID_GE_EB_ServiceName,
  72. CID_GE_GB_FirstConnect, -1, //HID_GE_GB_FirstConnect,
  73. CID_GE_ST_Explain, HID_GE_GB_FirstConnect,
  74. CID_GE_CB_DialAnotherFirst, HID_GE_CB_DialAnotherFirst,
  75. CID_GE_LB_DialAnotherFirst, HID_GE_LB_DialAnotherFirst,
  76. CID_GE_ST_Devices, HID_GE_LB_Devices,
  77. CID_GE_LB_Devices, HID_GE_LB_Devices,
  78. CID_GE_PB_DialingRules, HID_GE_PB_DialingRules,
  79. CID_GE_GB_PhoneNumber, -1,
  80. 0, 0
  81. };
  82. static const DWORD g_adwOeHelp[] =
  83. {
  84. CID_OE_GB_Progress, -1, //commented for bug 15738//HID_OE_GB_Progress,
  85. CID_OE_CB_DisplayProgress, HID_OE_CB_DisplayProgress,
  86. CID_OE_CB_PreviewUserPw, HID_OE_CB_PreviewUserPw,
  87. CID_OE_CB_PreviewDomain, HID_OE_CB_PreviewDomain,
  88. CID_OE_CB_PreviewNumber, HID_OE_CB_PreviewNumber,
  89. CID_OE_GB_Redial, -1, //commented for bug 15738//HID_OE_GB_Redial,
  90. CID_OE_ST_RedialAttempts, HID_OE_EB_RedialAttempts,
  91. CID_OE_EB_RedialAttempts, HID_OE_EB_RedialAttempts,
  92. CID_OE_ST_RedialTimes, HID_OE_LB_RedialTimes,
  93. CID_OE_LB_RedialTimes, HID_OE_LB_RedialTimes,
  94. CID_OE_ST_IdleTimes, HID_OE_LB_IdleTimes,
  95. CID_OE_LB_IdleTimes, HID_OE_LB_IdleTimes,
  96. CID_OE_CB_RedialOnDrop, HID_OE_CB_RedialOnDrop,
  97. CID_OE_GB_MultipleDevices, -1, //commented for bug 15738//HID_OE_GB_MultipleDevices,
  98. CID_OE_LB_MultipleDevices, HID_OE_LB_MultipleDevices,
  99. CID_OE_PB_Configure, HID_OE_PB_Configure,
  100. CID_OE_PB_X25, HID_OE_PB_X25,
  101. CID_OE_PB_Tunnel, HID_OE_PB_Tunnel,
  102. CID_OE_RB_DemandDial, HID_OE_RB_DemandDial,
  103. CID_OE_RB_Persistent, HID_OE_RB_Persistent,
  104. 0, 0
  105. };
  106. static const DWORD g_adwOeRouterHelp[] =
  107. {
  108. CID_OE_GB_Progress, -1, //commented for bug 15738//HID_OE_GB_Progress,
  109. CID_OE_CB_DisplayProgress, HID_OE_CB_DisplayProgress,
  110. CID_OE_CB_PreviewUserPw, HID_OE_CB_PreviewUserPw,
  111. CID_OE_CB_PreviewDomain, HID_OE_CB_PreviewDomain,
  112. CID_OE_CB_PreviewNumber, HID_OE_CB_PreviewNumber,
  113. CID_OE_GB_Redial, -1, //commented for bug 15738//HID_OE_GB_Redial,
  114. CID_OE_ST_RedialAttempts, HID_OE_EB_RedialAttempts,
  115. CID_OE_EB_RedialAttempts, HID_OE_EB_RedialAttempts,
  116. CID_OE_ST_RedialTimes, HID_OE_LB_RedialTimes,
  117. CID_OE_LB_RedialTimes, HID_OE_LB_RedialTimes,
  118. CID_OE_ST_IdleTimes, HID_OE_LB_IdleTimesRouter,
  119. CID_OE_LB_IdleTimes, HID_OE_LB_IdleTimesRouter,
  120. CID_OE_CB_RedialOnDrop, HID_OE_CB_RedialOnDrop,
  121. CID_OE_GB_MultipleDevices, -1, //commented for bug 15738//HID_OE_GB_MultipleDevices,
  122. CID_OE_LB_MultipleDevices, HID_OE_LB_MultipleDevices,
  123. CID_OE_PB_Configure, HID_OE_PB_Configure,
  124. CID_OE_PB_X25, HID_OE_PB_X25,
  125. CID_OE_PB_Tunnel, HID_OE_PB_Tunnel,
  126. CID_OE_RB_DemandDial, HID_OE_RB_DemandDial,
  127. CID_OE_RB_Persistent, HID_OE_RB_Persistent,
  128. CID_OE_PB_Callback, HID_OE_PB_Callback,
  129. 0, 0
  130. };
  131. //Get rid of the const qualifire for whistler bug#276452
  132. static DWORD g_adwLoHelp[] =
  133. {
  134. CID_LO_GB_SecurityOptions, -1, //commented for bug 15738//HID_LO_GB_SecurityOptions,
  135. CID_LO_RB_TypicalSecurity, HID_LO_RB_TypicalSecurity,
  136. CID_LO_ST_Auths, HID_LO_LB_Auths,
  137. CID_LO_LB_Auths, HID_LO_LB_Auths,
  138. CID_LO_CB_UseWindowsPw, HID_LO_CB_UseWindowsPw,
  139. CID_LO_CB_Encryption, HID_LO_CB_Encryption,
  140. CID_LO_RB_AdvancedSecurity, HID_LO_RB_AdvancedSecurity,
  141. CID_LO_ST_AdvancedText, HID_LO_PB_Advanced,
  142. CID_LO_PB_Advanced, HID_LO_PB_Advanced,
  143. CID_LO_GB_Scripting, -1, //commented for bug 15738//HID_LO_GB_Scripting,
  144. CID_LO_CB_RunScript, HID_LO_CB_RunScript,
  145. CID_LO_CB_Terminal, HID_LO_CB_Terminal,
  146. CID_LO_LB_Scripts, HID_LO_LB_Scripts,
  147. CID_LO_PB_Edit, HID_LO_PB_Edit,
  148. CID_LO_PB_Browse, HID_LO_PB_Browse,
  149. CID_LO_ST_IPSecText, HID_LO_PB_IPSec,
  150. CID_LO_PB_IPSec, HID_LO_PB_IPSec,//On Server, this help ID will be HID_LO_PB_IPSecServer
  151. 0, 0
  152. };
  153. static const DWORD g_adwNeHelp[] =
  154. {
  155. CID_NE_ST_ServerType, HID_NE_LB_ServerType,
  156. CID_NE_LB_ServerType, HID_NE_LB_ServerType,
  157. CID_NE_PB_Settings, HID_NE_PB_Settings,
  158. CID_NE_ST_Components, HID_NE_LV_Components,
  159. CID_NE_LV_Components, HID_NE_LV_Components,
  160. CID_NE_PB_Add, HID_NE_PB_Add,
  161. CID_NE_PB_Remove, HID_NE_PB_Remove,
  162. CID_NE_PB_Properties, HID_NE_PB_Properties,
  163. CID_NE_GB_Description, -1, //commented for bug 15738//HID_NE_LB_ComponentDesc,
  164. CID_NE_LB_ComponentDesc, HID_NE_LB_ComponentDesc,
  165. 0, 0
  166. };
  167. static const DWORD g_adwPpHelp[] =
  168. {
  169. CID_NE_EnableLcp, HID_NE_EnableLcp,
  170. CID_NE_EnableCompression, HID_NE_EnableCompression,
  171. CID_NE_NegotiateMultilinkAlways,HID_NE_NegotiateMultilinkAlways,
  172. 0, 0
  173. };
  174. static DWORD g_adwCrHelp[] =
  175. {
  176. CID_CR_RB_No, HID_CR_RB_No,
  177. CID_CR_RB_Yes, HID_CR_RB_Yes,
  178. CID_CR_PB_Edit, HID_CR_PB_Edit,
  179. CID_CR_PB_Delete, HID_CR_PB_Delete,
  180. CID_CR_LV_Numbers, HID_CR_LV_Numbers,
  181. 0, 0
  182. };
  183. static DWORD g_adwSaHelp[] =
  184. {
  185. CID_SA_PB_Shared, HID_SA_PB_Shared,
  186. CID_SA_GB_Shared, -1,
  187. CID_SA_PB_DemandDial, HID_SA_PB_DemandDial,
  188. CID_SA_ST_DemandDial, HID_SA_PB_DemandDial,
  189. CID_SA_PB_Settings, HID_SA_PB_Settings,
  190. CID_SA_GB_PrivateLan, -1,
  191. CID_SA_ST_PrivateLan, HID_SA_LB_PrivateLan,
  192. CID_SA_LB_PrivateLan, HID_SA_LB_PrivateLan,
  193. 0, 0
  194. };
  195. //-----------------------------------------------------------------------------
  196. // Local prototypes (alphabetically)
  197. //-----------------------------------------------------------------------------
  198. BOOL
  199. RouterCallbackDlg(
  200. IN HWND hwndOwner,
  201. IN OUT EINFO* pEinfo );
  202. INT_PTR CALLBACK
  203. CrDlgProc(
  204. IN HWND hwnd,
  205. IN UINT unMsg,
  206. IN WPARAM wparam,
  207. IN LPARAM lparam );
  208. BOOL
  209. CrCommand(
  210. IN CRINFO* pInfo,
  211. IN WORD wNotification,
  212. IN WORD wId,
  213. IN HWND hwndCtrl );
  214. BOOL
  215. CrInit(
  216. IN HWND hwndDlg,
  217. IN EINFO* pArgs );
  218. VOID
  219. CrSave(
  220. IN CRINFO* pInfo );
  221. VOID
  222. CrTerm(
  223. IN HWND hwndDlg );
  224. VOID
  225. CrUpdateLvAndPbState(
  226. IN CRINFO* pInfo );
  227. VOID
  228. GeAlternates(
  229. IN PEINFO* pInfo );
  230. VOID
  231. GeDialingRules(
  232. IN PEINFO* pInfo );
  233. INT_PTR CALLBACK
  234. GeDlgProc(
  235. IN HWND hwnd,
  236. IN UINT unMsg,
  237. IN WPARAM wparam,
  238. IN LPARAM lparam );
  239. INT_PTR CALLBACK
  240. GeDlgProcMultiple(
  241. IN HWND hwnd,
  242. IN UINT unMsg,
  243. IN WPARAM wparam,
  244. IN LPARAM lparam );
  245. INT_PTR CALLBACK
  246. GeDlgProcSingle(
  247. IN HWND hwnd,
  248. IN UINT unMsg,
  249. IN WPARAM wparam,
  250. IN LPARAM lparam );
  251. VOID
  252. GeClearLbDialAnotherFirst(
  253. IN HWND hwndLbDialAnotherFirst );
  254. BOOL
  255. GeCommand(
  256. IN PEINFO* pInfo,
  257. IN WORD wNotification,
  258. IN WORD wId,
  259. IN HWND hwndCtrl );
  260. VOID
  261. GeConfigure(
  262. IN PEINFO* pInfo );
  263. VOID
  264. GeDialAnotherFirstSelChange(
  265. IN PEINFO* pInfo );
  266. BOOL
  267. GeFillLbDialAnotherFirst(
  268. IN PEINFO* pInfo,
  269. IN BOOL fAbortIfPrereqNotFound );
  270. VOID
  271. GeGetPhoneFields(
  272. IN PEINFO* pInfo,
  273. OUT DTLNODE* pDstLinkNode );
  274. BOOL
  275. GeInit(
  276. IN HWND hwndPage,
  277. IN OUT EINFO* pArgs );
  278. LVXDRAWINFO*
  279. GeLvDevicesCallbackMultiple(
  280. IN HWND hwndLv,
  281. IN DWORD dwItem );
  282. LVXDRAWINFO*
  283. GeLvDevicesCallbackSingle(
  284. IN HWND hwndLv,
  285. IN DWORD dwItem );
  286. VOID
  287. GeMoveDevice(
  288. IN PEINFO* pInfo,
  289. IN BOOL fUp );
  290. DWORD
  291. GeSaveLvDeviceChecks(
  292. IN PEINFO* pInfo );
  293. VOID
  294. GeUpdateDialAnotherFirstState(
  295. IN PEINFO* pInfo );
  296. VOID
  297. GeSetPhoneFields(
  298. IN PEINFO* pInfo,
  299. IN DTLNODE* pSrcLinkNode,
  300. IN BOOL fDisableAll );
  301. VOID
  302. GeUpdatePhoneNumberFields(
  303. IN PEINFO* pInfo,
  304. IN BOOL fSharedToggle );
  305. VOID
  306. GeUpdatePhoneNumberTitle(
  307. IN PEINFO* pInfo,
  308. IN TCHAR* pszDevice );
  309. VOID
  310. GeUpdateUpDownButtons(
  311. IN PEINFO* pInfo );
  312. BOOL
  313. LoCommand(
  314. IN PEINFO* pInfo,
  315. IN WORD wNotification,
  316. IN WORD wId,
  317. IN HWND hwndCtrl );
  318. INT_PTR CALLBACK
  319. LoDlgProc(
  320. IN HWND hwnd,
  321. IN UINT unMsg,
  322. IN WPARAM wparam,
  323. IN LPARAM lparam );
  324. VOID
  325. LoEnableSecuritySettings(
  326. IN PEINFO* pInfo,
  327. IN BOOL fTypical,
  328. IN BOOL fAdvanced );
  329. VOID
  330. LoFillLbAuths(
  331. IN PEINFO* pInfo );
  332. BOOL
  333. LoInit(
  334. IN HWND hwndPage );
  335. VOID
  336. LoLbAuthsSelChange(
  337. IN PEINFO* pInfo );
  338. VOID
  339. LoRefreshSecuritySettings(
  340. IN PEINFO* pInfo );
  341. VOID
  342. LoSaveTypicalAuthSettings(
  343. IN PEINFO* pInfo );
  344. INT_PTR CALLBACK
  345. NeDlgProc(
  346. IN HWND hwnd,
  347. IN UINT unMsg,
  348. IN WPARAM wparam,
  349. IN LPARAM lparam );
  350. BOOL
  351. NeInit(
  352. IN HWND hwndPage );
  353. void
  354. NeServerTypeSelChange (
  355. IN PEINFO* pInfo);
  356. void
  357. NeAddComponent (
  358. IN PEINFO* pInfo);
  359. void
  360. NeEnsureNetshellLoaded (
  361. IN PEINFO* pInfo);
  362. void
  363. NeRemoveComponent (
  364. IN PEINFO* pInfo);
  365. void
  366. NeLvClick (
  367. IN PEINFO* pInfo,
  368. IN BOOL fDoubleClick);
  369. void
  370. NeLvItemChanged (
  371. IN PEINFO* pInfo);
  372. void
  373. NeSaveBindingChanges (
  374. IN PEINFO* pInfo);
  375. void
  376. NeLvDeleteItem (
  377. IN PEINFO* pInfo,
  378. IN NM_LISTVIEW* pnmlv);
  379. BOOL
  380. OeCommand(
  381. IN PEINFO* pInfo,
  382. IN WORD wNotification,
  383. IN WORD wId,
  384. IN HWND hwndCtrl );
  385. INT_PTR CALLBACK
  386. OeDlgProc(
  387. IN HWND hwnd,
  388. IN UINT unMsg,
  389. IN WPARAM wparam,
  390. IN LPARAM lparam );
  391. VOID
  392. OeEnableMultipleDeviceGroup(
  393. IN PEINFO* pInfo,
  394. IN BOOL fEnable );
  395. BOOL
  396. OeInit(
  397. IN HWND hwndPage );
  398. VOID
  399. OeTunnel(
  400. IN PEINFO* pInfo );
  401. VOID
  402. OeUpdateUserPwState(
  403. IN PEINFO* pInfo );
  404. VOID
  405. OeX25(
  406. IN PEINFO* pInfo );
  407. BOOL
  408. PeApply(
  409. IN HWND hwndPage );
  410. PEINFO*
  411. PeContext(
  412. IN HWND hwndPage );
  413. DWORD
  414. PeCountEnabledLinks(
  415. IN PEINFO* pInfo );
  416. VOID
  417. PeExit(
  418. IN PEINFO* pInfo,
  419. IN DWORD dwError );
  420. VOID
  421. PeExitInit(
  422. IN HWND hwndDlg,
  423. IN EINFO* pEinfo,
  424. IN DWORD dwError );
  425. PEINFO*
  426. PeInit(
  427. IN HWND hwndFirstPage,
  428. IN EINFO* pArgs );
  429. VOID
  430. PeTerm(
  431. IN HWND hwndPage );
  432. INT_PTR CALLBACK
  433. PpDlgProc(
  434. IN HWND hwnd,
  435. IN UINT unMsg,
  436. IN WPARAM wparam,
  437. IN LPARAM lparam );
  438. INT_PTR CALLBACK
  439. RdDlgProc(
  440. IN HWND hwnd,
  441. IN UINT unMsg,
  442. IN WPARAM wparam,
  443. IN LPARAM lparam );
  444. BOOL
  445. SaCommand(
  446. IN PEINFO* pInfo,
  447. IN WORD wNotification,
  448. IN WORD wId,
  449. IN HWND hwndCtrl );
  450. INT_PTR CALLBACK
  451. SaDlgProc(
  452. IN HWND hwnd,
  453. IN UINT unMsg,
  454. IN WPARAM wparam,
  455. IN LPARAM lparam );
  456. INT_PTR CALLBACK
  457. SaUnavailDlgProc(
  458. IN HWND hwnd,
  459. IN UINT unMsg,
  460. IN WPARAM wparam,
  461. IN LPARAM lparam );
  462. BOOL
  463. SaInit(
  464. IN HWND hwndDlg );
  465. INT_PTR CALLBACK
  466. SaDisableFirewallWarningDlgProc(
  467. IN HWND hwnd,
  468. IN UINT unMsg,
  469. IN WPARAM wparam,
  470. IN LPARAM lparam );
  471. BOOL SaIsAdapterDHCPEnabled(
  472. IN IHNetConnection* pConnection);
  473. // wrapper to load homenet page: used in PePropertySheet(...)
  474. HRESULT HrLoadHNetGetFirewallSettingsPage (PROPSHEETPAGEW * ppsp, EINFO* pInfo)
  475. {
  476. PROPSHEETPAGEW psp;
  477. HRESULT hr;
  478. HNET_CONN_PROPERTIES *pProps;
  479. IHNetConnection *pHNetConn = NULL;
  480. IHNetCfgMgr *pHNetCfgMgr = NULL;
  481. // _asm int 3
  482. ZeroMemory (&psp, sizeof(PROPSHEETPAGEW));
  483. psp.dwSize = sizeof(PROPSHEETPAGEW);
  484. *ppsp = psp;
  485. // Make sure COM is initialized on this thread.
  486. //
  487. hr = CoInitializeEx(
  488. NULL,
  489. COINIT_MULTITHREADED | COINIT_DISABLE_OLE1DDE
  490. );
  491. if (SUCCEEDED(hr))
  492. {
  493. pInfo->fComInitialized = TRUE;
  494. }
  495. else if (RPC_E_CHANGED_MODE == hr)
  496. {
  497. hr = S_OK;
  498. }
  499. if (SUCCEEDED(hr)) {
  500. // pass the Guid to the export from hnetcfg ("HNetGetFirewallSettingsPage").
  501. HINSTANCE hinstDll = LoadLibrary (TEXT("hnetcfg.dll"));
  502. if (hinstDll == NULL)
  503. hr = HRESULT_FROM_WIN32 (GetLastError());
  504. else {
  505. HRESULT (*pfnGetPage) (PROPSHEETPAGEW *, GUID *);
  506. pfnGetPage = (HRESULT (*)(PROPSHEETPAGEW *, GUID *))GetProcAddress (hinstDll, "HNetGetFirewallSettingsPage");
  507. if (!pfnGetPage)
  508. hr = HRESULT_FROM_WIN32 (GetLastError());
  509. else
  510. hr = pfnGetPage (&psp, pInfo->pEntry->pGuid);
  511. FreeLibrary (hinstDll);
  512. }
  513. if (hr == S_OK)
  514. *ppsp = psp;
  515. }
  516. return pInfo->hShowHNetPagesResult = hr;
  517. }
  518. //----------------------------------------------------------------------------
  519. // Phonebook Entry property sheet entrypoint
  520. //----------------------------------------------------------------------------
  521. VOID
  522. PePropertySheet(
  523. IN OUT EINFO* pEinfo )
  524. // Runs the Phonebook entry property sheet. 'PEinfo' is the API caller's
  525. // arguments.
  526. //
  527. {
  528. PROPSHEETPAGE apage[ PE_PageCount ];
  529. PROPSHEETPAGE* ppage;
  530. INT nPages;
  531. INT nPageIndex;
  532. TRACE( "PePropertySheet" );
  533. nPages = PE_PageCount;
  534. ZeroMemory( apage, sizeof(apage) );
  535. // General page.
  536. //
  537. ppage = &apage[ PE_GePage ];
  538. ppage->dwSize = sizeof(PROPSHEETPAGE);
  539. ppage->hInstance = g_hinstDll;
  540. if (pEinfo->pEntry->dwType == RASET_Vpn)
  541. {
  542. ppage->pszTemplate = MAKEINTRESOURCE( PID_GE_GeneralVpn );
  543. ppage->pfnDlgProc = GeDlgProc;
  544. }
  545. else if (pEinfo->pEntry->dwType == RASET_Broadband)
  546. {
  547. ppage->pszTemplate = MAKEINTRESOURCE( PID_GE_GeneralBroadband );
  548. ppage->pfnDlgProc = GeDlgProc;
  549. }
  550. else if (pEinfo->pEntry->dwType == RASET_Phone)
  551. {
  552. if (pEinfo->fMultipleDevices)
  553. {
  554. if (pEinfo->fRouter)
  555. {
  556. ppage->pszTemplate =
  557. MAKEINTRESOURCE( PID_GE_RouterGeneralMultiple );
  558. }
  559. else
  560. {
  561. ppage->pszTemplate =
  562. MAKEINTRESOURCE( PID_GE_GeneralMultiple );
  563. }
  564. ppage->pfnDlgProc = GeDlgProcMultiple;
  565. }
  566. else
  567. {
  568. if (pEinfo->fRouter)
  569. {
  570. ppage->pszTemplate =
  571. MAKEINTRESOURCE( PID_GE_RouterGeneralSingle );
  572. }
  573. else
  574. {
  575. ppage->pszTemplate =
  576. MAKEINTRESOURCE( PID_GE_GeneralSingle );
  577. }
  578. ppage->pfnDlgProc = GeDlgProcSingle;
  579. }
  580. }
  581. else
  582. {
  583. ASSERT( pEinfo->pEntry->dwType == RASET_Direct );
  584. ppage->pszTemplate = MAKEINTRESOURCE( PID_GE_GeneralDirect );
  585. ppage->pfnDlgProc = GeDlgProc;
  586. }
  587. ppage->lParam = (LPARAM )pEinfo;
  588. // Options page.
  589. //
  590. ppage = &apage[ PE_OePage ];
  591. ppage->dwSize = sizeof(PROPSHEETPAGE);
  592. ppage->hInstance = g_hinstDll;
  593. ppage->pszTemplate =
  594. (pEinfo->fRouter)
  595. ? MAKEINTRESOURCE( PID_OE_OptionsRouter )
  596. : ((pEinfo->pEntry->dwType == RASET_Phone)
  597. ? MAKEINTRESOURCE( PID_OE_Options )
  598. : MAKEINTRESOURCE( PID_OE_OptionsVD ));
  599. ppage->pfnDlgProc = OeDlgProc;
  600. // Security page.
  601. //
  602. ppage = &apage[ PE_LoPage ];
  603. ppage->dwSize = sizeof(PROPSHEETPAGE);
  604. ppage->hInstance = g_hinstDll;
  605. //
  606. //Add new Security Page for bug 193987 PSK
  607. //
  608. if ( pEinfo->pEntry->dwType == RASET_Vpn )
  609. {
  610. ppage->pszTemplate = MAKEINTRESOURCE( PID_LO_SecurityVpn );
  611. }
  612. else
  613. {
  614. ppage->pszTemplate = MAKEINTRESOURCE( PID_LO_Security );
  615. }
  616. ppage->pfnDlgProc = LoDlgProc;
  617. // Network page.
  618. //
  619. ppage = &apage[ PE_NePage ];
  620. ppage->dwSize = sizeof(PROPSHEETPAGE);
  621. ppage->hInstance = g_hinstDll;
  622. ppage->pszTemplate = MAKEINTRESOURCE( PID_NE_Network );
  623. ppage->pfnDlgProc = NeDlgProc;
  624. // Advanced page.
  625. // (AboladeG) The page is shown if the user is admin and
  626. // there is at least one LAN connection, or if this phonebook entry
  627. // is already shared.
  628. //
  629. nPageIndex = PE_SaPage;
  630. if((!pEinfo->fIsUserAdminOrPowerUser) || (pEinfo->fRouter))
  631. {
  632. --nPages;
  633. }
  634. else
  635. {
  636. HRESULT hr;
  637. BOOL fShowAdvancedUi = TRUE;
  638. INetConnectionUiUtilities* pncuu = NULL;
  639. // Check if ZAW is denying access to the Shared Access UI
  640. //
  641. hr = HrCreateNetConnectionUtilities(&pncuu);
  642. if (SUCCEEDED(hr))
  643. {
  644. if(FALSE == INetConnectionUiUtilities_UserHasPermission(pncuu, NCPERM_ShowSharedAccessUi) &&
  645. FALSE == INetConnectionUiUtilities_UserHasPermission(pncuu, NCPERM_PersonalFirewallConfig))
  646. fShowAdvancedUi = FALSE;
  647. INetConnectionUiUtilities_Release(pncuu);
  648. }
  649. if (!fShowAdvancedUi)
  650. {
  651. --nPages;
  652. }
  653. else
  654. {
  655. // Finally, check whether TCP/IP is installed or not.
  656. //
  657. if (!FIsTcpipInstalled())
  658. {
  659. --nPages;
  660. }
  661. else
  662. {
  663. ppage = &apage[ nPageIndex++ ];
  664. ppage->dwSize = sizeof(PROPSHEETPAGE);
  665. ppage->hInstance = g_hinstDll;
  666. {
  667. PROPSHEETPAGEW psp;
  668. hr = HrLoadHNetGetFirewallSettingsPage (&psp, pEinfo);
  669. if (hr == S_OK)
  670. *ppage = psp;
  671. }
  672. if (hr != S_OK)
  673. {
  674. ppage->pszTemplate = MAKEINTRESOURCE( PID_SA_HomenetUnavailable );
  675. ppage->pfnDlgProc = SaUnavailDlgProc;
  676. }
  677. }
  678. }
  679. }
  680. if (pEinfo->pApiArgs->dwFlags & RASEDFLAG_ShellOwned)
  681. {
  682. INT i;
  683. BOOL fStatus;
  684. RASEDSHELLOWNEDR2* pShellOwnedInfo;
  685. pShellOwnedInfo = (RASEDSHELLOWNEDR2*)pEinfo->pApiArgs->reserved2;
  686. // The property sheet is to be invoked by the shell, using the shell
  687. // convention of adding pages via callback.
  688. //
  689. for (i = 0; i < nPages; ++i)
  690. {
  691. HPROPSHEETPAGE h;
  692. h = CreatePropertySheetPage( &apage[ i ] );
  693. if (!h)
  694. {
  695. TRACE( "CreatePage failed" );
  696. break;
  697. }
  698. fStatus = pShellOwnedInfo->pfnAddPage( h, pShellOwnedInfo->lparam );
  699. if (!fStatus)
  700. {
  701. TRACE( "AddPage failed" );
  702. DestroyPropertySheetPage( h );
  703. break;
  704. }
  705. }
  706. if (i < nPages)
  707. {
  708. ErrorDlg( pEinfo->pApiArgs->hwndOwner,
  709. SID_OP_LoadDlg, ERROR_UNKNOWN, NULL );
  710. }
  711. }
  712. else
  713. {
  714. PROPSHEETHEADER header;
  715. PWSTR pszBuf = NULL;
  716. PWSTR pszHeader;
  717. DWORD cb;
  718. HICON hIcon = NULL;
  719. DWORD dwDisplayIcon = 0;
  720. int i;
  721. HPROPSHEETPAGE hPages[PE_PageCount];
  722. //For whistler bug 382720 349866 gangz
  723. //to fusionalize well for both rasdlg pages in NCW and
  724. //property pages launched by pressing "Property" button
  725. //besides following the normal fusion steps: we have to
  726. // (1) add _WIN32_WINNT=0x501 in the file sources
  727. // (2) use the phpage member in PROPSHEETHEADER structure, that is
  728. // use CreatePropertySheetPage() to create page handles
  729. for (i = 0; i < nPages; ++i)
  730. {
  731. hPages[i] = CreatePropertySheetPage( &apage[ i ] );
  732. if ( !hPages[i] )
  733. {
  734. TRACE( "CreatePage failed" );
  735. break;
  736. }
  737. }
  738. if (i < nPages)
  739. {
  740. ErrorDlg( pEinfo->pApiArgs->hwndOwner,
  741. SID_OP_LoadDlg, ERROR_UNKNOWN, NULL );
  742. }
  743. else
  744. {
  745. // Create the correct properties header
  746. pszHeader = PszFromId(g_hinstDll, SID_PropertiesHeader);
  747. if (pszHeader)
  748. {
  749. cb = lstrlenW(pEinfo->pEntry->pszEntryName) +
  750. 1 +
  751. lstrlenW(pszHeader) +
  752. 1;
  753. pszBuf = Malloc(cb * sizeof(TCHAR));
  754. if (!pszBuf)
  755. {
  756. TRACE("Properties header allocation failed");
  757. }
  758. else
  759. {
  760. lstrcpyW(pszBuf, pEinfo->pEntry->pszEntryName);
  761. lstrcatW(pszBuf, L" ");
  762. lstrcatW(pszBuf, pszHeader);
  763. }
  764. Free(pszHeader);
  765. }
  766. //For whistler bug 372078 364876 gangz
  767. //
  768. hIcon = GetCurrentIconEntryType(pEinfo->pEntry->dwType,
  769. TRUE); //TRUE means small Icon
  770. if (hIcon)
  771. {
  772. dwDisplayIcon = PSH_USEHICON;
  773. }
  774. // The property sheet is to be invoked directly.
  775. //
  776. ZeroMemory( &header, sizeof(header) );
  777. header.dwSize = sizeof(PROPSHEETHEADER);
  778. // header.dwFlags = PSH_PROPSHEETPAGE | PSH_NOAPPLYNOW | PSH_USECALLBACK | dwDisplayIcon;
  779. header.dwFlags = PSH_NOAPPLYNOW | PSH_USECALLBACK | dwDisplayIcon;
  780. header.hwndParent = pEinfo->pApiArgs->hwndOwner;
  781. header.hInstance = g_hinstDll;
  782. header.pszCaption = (pszBuf)?(pszBuf):(pEinfo->pEntry->pszEntryName);
  783. header.nPages = nPages;
  784. // header.ppsp = apage;
  785. header.phpage = hPages;
  786. header.hIcon = hIcon;
  787. header.pfnCallback = UnHelpCallbackFunc;
  788. if (PropertySheet( &header ) == -1)
  789. {
  790. TRACE( "PropertySheet failed" );
  791. ErrorDlg( pEinfo->pApiArgs->hwndOwner,
  792. SID_OP_LoadDlg, ERROR_UNKNOWN, NULL );
  793. }
  794. Free0(pszBuf);
  795. //For whistler bug 372078
  796. //GetCurrentIconEntryType() loads Icon from netshell where the icon is loaded
  797. //by LoadImage() without LR_SHARED, so I have to destroy it when we are done
  798. //with it
  799. //
  800. if (hIcon)
  801. {
  802. DestroyIcon( hIcon );
  803. }
  804. }
  805. }
  806. }
  807. //----------------------------------------------------------------------------
  808. // Phonebook Entry property sheet
  809. // Listed alphabetically
  810. //----------------------------------------------------------------------------
  811. BOOL
  812. PeApply(
  813. IN HWND hwndPage )
  814. // Saves the contents of the property sheet. 'HwndPage is the handle of a
  815. // property page. Pops up any errors that occur.
  816. //
  817. // Returns true is page can be dismissed, false otherwise.
  818. //
  819. {
  820. DWORD dwErr;
  821. PEINFO* pInfo;
  822. PBENTRY* pEntry;
  823. TRACE( "PeApply" );
  824. pInfo = PeContext( hwndPage );
  825. ASSERT( pInfo );
  826. if (pInfo == NULL)
  827. {
  828. return ERROR_CAN_NOT_COMPLETE;
  829. }
  830. pEntry = pInfo->pArgs->pEntry;
  831. ASSERT( pEntry );
  832. // Save General page fields.
  833. //
  834. ASSERT( pInfo->hwndGe );
  835. {
  836. DTLNODE* pNode;
  837. // Retrieve the lone common control.
  838. //
  839. pEntry->fShowMonitorIconInTaskBar =
  840. Button_GetCheck( pInfo->hwndCbShowIcon );
  841. if (pEntry->dwType == RASET_Phone)
  842. {
  843. DWORD dwCount;
  844. dwCount = GeSaveLvDeviceChecks( pInfo );
  845. // Don't allow the user to deselect all of the
  846. // devices
  847. if ( (pInfo->pArgs->fMultipleDevices) && (dwCount == 0) )
  848. {
  849. MsgDlg( hwndPage, SID_SelectDevice, NULL );
  850. PropSheet_SetCurSel ( pInfo->hwndDlg, pInfo->hwndGe, 0 );
  851. SetFocus ( pInfo->hwndLvDevices );
  852. return FALSE;
  853. }
  854. // Save the "shared phone number" setting. As usual, single
  855. // device mode implies shared mode, allowing things to fall
  856. // through correctly.
  857. //
  858. if (pInfo->pArgs->fMultipleDevices)
  859. {
  860. pEntry->fSharedPhoneNumbers =
  861. Button_GetCheck( pInfo->hwndCbSharedPhoneNumbers );
  862. }
  863. else
  864. {
  865. pEntry->fSharedPhoneNumbers = TRUE;
  866. }
  867. // Set the phone number set for the first phone number of the
  868. // current link (shared or selected) to the contents of the phone
  869. // number controls.
  870. //
  871. GeGetPhoneFields( pInfo, pInfo->pCurLinkNode );
  872. // Swap lists, saving updates to caller's global list of area
  873. // codes. Caller's original list will be destroyed by PeTerm.
  874. //
  875. if (pInfo->pListAreaCodes)
  876. {
  877. DtlSwapLists(
  878. pInfo->pArgs->pUser->pdtllistAreaCodes,
  879. pInfo->pListAreaCodes );
  880. pInfo->pArgs->pUser->fDirty = TRUE;
  881. }
  882. }
  883. else if (pEntry->dwType == RASET_Vpn)
  884. {
  885. // For whistler 522872
  886. DTLNODE* pNodeTmp = NULL;
  887. PBLINK* pLink = NULL;
  888. PBPHONE* pPhone = NULL;
  889. // Save host name, i.e. the VPN phone number.
  890. //
  891. pNodeTmp = DtlGetFirstNode( pEntry->pdtllistLinks );
  892. ASSERT( pNodeTmp );
  893. pLink = (PBLINK* )DtlGetData( pNodeTmp );
  894. pNodeTmp = FirstPhoneNodeFromPhoneList( pLink->pdtllistPhones );
  895. if(NULL == pNodeTmp)
  896. {
  897. return FALSE;
  898. }
  899. pPhone = (PBPHONE* )DtlGetData( pNodeTmp );
  900. Free0( pPhone->pszPhoneNumber );
  901. pPhone->pszPhoneNumber = GetText( pInfo->hwndEbHostName );
  902. FirstPhoneNodeToPhoneList( pLink->pdtllistPhones, pNodeTmp );
  903. // Any prequisite entry selection change has been saved already.
  904. // Just need to toss it if disabled.
  905. //
  906. if (!Button_GetCheck( pInfo->hwndCbDialAnotherFirst ))
  907. {
  908. Free0( pEntry->pszPrerequisiteEntry );
  909. pEntry->pszPrerequisiteEntry = NULL;
  910. Free0( pEntry->pszPrerequisitePbk );
  911. pEntry->pszPrerequisitePbk = NULL;
  912. }
  913. }
  914. else if (pEntry->dwType == RASET_Broadband)
  915. {
  916. DTLNODE* pNodeTmp = NULL;
  917. PBLINK* pLink = NULL;
  918. PBPHONE* pPhone = NULL;
  919. // Save service name, i.e. the broadband phone number.
  920. //
  921. pNodeTmp = DtlGetFirstNode( pEntry->pdtllistLinks );
  922. ASSERT( pNodeTmp );
  923. pLink = (PBLINK* )DtlGetData( pNodeTmp );
  924. pNodeTmp = FirstPhoneNodeFromPhoneList( pLink->pdtllistPhones );
  925. if(NULL == pNodeTmp)
  926. {
  927. return FALSE;
  928. }
  929. pPhone = (PBPHONE* )DtlGetData( pNodeTmp );
  930. Free0( pPhone->pszPhoneNumber );
  931. pPhone->pszPhoneNumber = GetText( pInfo->hwndEbBroadbandService );
  932. FirstPhoneNodeToPhoneList( pLink->pdtllistPhones, pNodeTmp );
  933. }
  934. else if (pEntry->dwType == RASET_Direct)
  935. {
  936. DTLNODE* pNodeTmp = NULL;
  937. PBLINK* pLink = NULL;
  938. // The currently enabled device is the one
  939. // that should be used for the connection. Only
  940. // one device will be enabled (DnUpdateSelectedDevice).
  941. for (pNodeTmp = DtlGetFirstNode( pEntry->pdtllistLinks );
  942. pNodeTmp;
  943. pNodeTmp = DtlGetNextNode( pNodeTmp ))
  944. {
  945. pLink = (PBLINK* )DtlGetData( pNodeTmp );
  946. ASSERT(pLink);
  947. if ( pLink->fEnabled )
  948. break;
  949. }
  950. // If we found a link successfully, deal with it
  951. // now.
  952. if ( pLink && pLink->fEnabled ) {
  953. if (pLink->pbport.pbdevicetype == PBDT_ComPort)
  954. MdmInstallNullModem (pLink->pbport.pszPort);
  955. }
  956. }
  957. }
  958. // Save Options page fields.
  959. //
  960. if (pInfo->hwndOe)
  961. {
  962. UINT unValue;
  963. BOOL f;
  964. INT iSel;
  965. pEntry->fShowDialingProgress =
  966. Button_GetCheck( pInfo->hwndCbDisplayProgress );
  967. // Note: The'fPreviewUserPw', 'fPreviewDomain' fields are updated as
  968. // they are changed.
  969. pEntry->fPreviewPhoneNumber =
  970. Button_GetCheck( pInfo->hwndCbPreviewNumber );
  971. unValue = GetDlgItemInt(
  972. pInfo->hwndOe, CID_OE_EB_RedialAttempts, &f, FALSE );
  973. if (f && unValue <= RAS_MaxRedialCount)
  974. {
  975. pEntry->dwRedialAttempts = unValue;
  976. }
  977. iSel = ComboBox_GetCurSel( pInfo->hwndLbRedialTimes );
  978. pEntry->dwRedialSeconds =
  979. (DWORD )ComboBox_GetItemData( pInfo->hwndLbRedialTimes, iSel );
  980. iSel = ComboBox_GetCurSel( pInfo->hwndLbIdleTimes );
  981. pEntry->lIdleDisconnectSeconds =
  982. (LONG )ComboBox_GetItemData( pInfo->hwndLbIdleTimes, iSel );
  983. if (pInfo->pArgs->fRouter)
  984. {
  985. pEntry->fRedialOnLinkFailure =
  986. Button_GetCheck( pInfo->hwndRbPersistent );
  987. }
  988. else
  989. {
  990. pEntry->fRedialOnLinkFailure =
  991. Button_GetCheck( pInfo->hwndCbRedialOnDrop );
  992. }
  993. // Note: dwDialMode is saved as changed.
  994. // Note: X.25 settings are saved at OK on that dialog.
  995. }
  996. // Save Security page fields.
  997. //
  998. if (pInfo->hwndLo)
  999. {
  1000. if (Button_GetCheck( pInfo->hwndRbTypicalSecurity ))
  1001. {
  1002. LoSaveTypicalAuthSettings( pInfo );
  1003. if (pEntry->dwTypicalAuth == TA_CardOrCert)
  1004. {
  1005. /*
  1006. // Toss any existing advanced EAP configuration remnants when
  1007. // typical smartcard, per bug 262702 and VBaliga email.
  1008. //
  1009. Free0( pEntry->pCustomAuthData );
  1010. pEntry->pCustomAuthData = NULL;
  1011. pEntry->cbCustomAuthData = 0;
  1012. */
  1013. (void) DwSetCustomAuthData(
  1014. pEntry,
  1015. 0,
  1016. NULL);
  1017. TRACE( "RasSetEapUserData" );
  1018. ASSERT( g_pRasSetEapUserData );
  1019. g_pRasSetEapUserData(
  1020. INVALID_HANDLE_VALUE,
  1021. pInfo->pArgs->pFile->pszPath,
  1022. pEntry->pszEntryName,
  1023. NULL,
  1024. 0 );
  1025. TRACE( "RasSetEapUserData done" );
  1026. }
  1027. }
  1028. if (pEntry->dwType == RASET_Phone)
  1029. {
  1030. Free0( pEntry->pszScriptAfter );
  1031. SuGetInfo( &pInfo->suinfo,
  1032. &pEntry->fScriptAfter,
  1033. &pEntry->fScriptAfterTerminal,
  1034. &pEntry->pszScriptAfter );
  1035. }
  1036. }
  1037. // Save Network page fields.
  1038. // We won't have anything to do if we never initialized pNetCfg.
  1039. //
  1040. if (pInfo->pNetCfg)
  1041. {
  1042. HRESULT hr;
  1043. // Update the phone book entry with the enabled state of the components.
  1044. // Do this by enumerating the components from the list view item data
  1045. // and consulting the check state for each.
  1046. //
  1047. NeSaveBindingChanges(pInfo);
  1048. hr = INetCfg_Apply (pInfo->pNetCfg);
  1049. if (((NETCFG_S_REBOOT == hr) || (pInfo->fRebootAlreadyRequested)) &&
  1050. pInfo->pNetConUtilities)
  1051. {
  1052. DWORD dwFlags = QUFR_REBOOT;
  1053. if (!pInfo->fRebootAlreadyRequested)
  1054. dwFlags |= QUFR_PROMPT;
  1055. //$TODO NULL caption?
  1056. INetConnectionUiUtilities_QueryUserForReboot (
  1057. pInfo->pNetConUtilities, pInfo->hwndDlg, NULL, dwFlags);
  1058. }
  1059. }
  1060. #if 0 //!!!
  1061. if ((fLocalPad || iPadSelection != 0)
  1062. && (!pEntry->pszX25Address || IsAllWhite( pEntry->pszX25Address )))
  1063. {
  1064. // Address field is blank with X.25 dial-up or local PAD chosen.
  1065. //
  1066. MsgDlg( pInfo->hwndDlg, SID_NoX25Address, NULL );
  1067. PropSheet_SetCurSel( pInfo->hwndDlg, NULL, PE_XsPage );
  1068. SetFocus( pInfo->hwndEbX25Address );
  1069. Edit_SetSel( pInfo->hwndEbX25Address, 0, -1 );
  1070. return FALSE;
  1071. }
  1072. #endif
  1073. // Make sure proprietary ISDN options are disabled if more than one link
  1074. // is enabled. The proprietary ISDN option is only meaningful when
  1075. // calling a down-level server that needs Digiboard channel aggragation
  1076. // instead of PPP multi-link.
  1077. //
  1078. {
  1079. DTLNODE* pNode;
  1080. DWORD cIsdnLinks;
  1081. cIsdnLinks = 0;
  1082. for (pNode = DtlGetFirstNode( pEntry->pdtllistLinks );
  1083. pNode;
  1084. pNode = DtlGetNextNode( pNode ))
  1085. {
  1086. PBLINK* pLink = (PBLINK* )DtlGetData( pNode );
  1087. ASSERT(pLink);
  1088. if (pLink->fEnabled && pLink->pbport.pbdevicetype == PBDT_Isdn)
  1089. {
  1090. ++cIsdnLinks;
  1091. }
  1092. }
  1093. if (cIsdnLinks > 1)
  1094. {
  1095. for (pNode = DtlGetFirstNode( pEntry->pdtllistLinks );
  1096. pNode;
  1097. pNode = DtlGetNextNode( pNode ))
  1098. {
  1099. PBLINK* pLink = (PBLINK* )DtlGetData( pNode );
  1100. ASSERT(pLink);
  1101. if (pLink->fEnabled && pLink->fProprietaryIsdn)
  1102. {
  1103. pLink->fProprietaryIsdn = FALSE;
  1104. }
  1105. }
  1106. }
  1107. }
  1108. // Inform user that edits to the connected entry won't take affect until
  1109. // the entry is hung up and re-dialed, per PierreS's insistence.
  1110. //
  1111. if (HrasconnFromEntry( pInfo->pArgs->pFile->pszPath, pEntry->pszEntryName ))
  1112. {
  1113. MsgDlg( pInfo->hwndDlg, SID_EditConnected, NULL );
  1114. }
  1115. // It's a valid new/changed entry. Commit the changes to the phonebook
  1116. // and preferences. This occurs immediately in "ShellOwned" mode where
  1117. // the RasEntryDlg API has already returned, but is otherwise deferred
  1118. // until the API is ready to return.
  1119. //
  1120. if (pInfo->pArgs->pApiArgs->dwFlags & RASEDFLAG_ShellOwned)
  1121. {
  1122. EuCommit( pInfo->pArgs );
  1123. }
  1124. else
  1125. {
  1126. pInfo->pArgs->fCommit = TRUE;
  1127. }
  1128. return TRUE;
  1129. }
  1130. PEINFO*
  1131. PeContext(
  1132. IN HWND hwndPage )
  1133. // Retrieve the property sheet context from a property page handle.
  1134. //
  1135. {
  1136. return (PEINFO* )GetProp( GetParent( hwndPage ), g_contextId );
  1137. }
  1138. DWORD
  1139. PeCountEnabledLinks(
  1140. IN PEINFO* pInfo )
  1141. // Returns the number of enabled links in the entry.
  1142. //
  1143. {
  1144. DWORD c;
  1145. DTLNODE* pNode;
  1146. c = 0;
  1147. for (pNode = DtlGetFirstNode( pInfo->pArgs->pEntry->pdtllistLinks );
  1148. pNode;
  1149. pNode = DtlGetNextNode( pNode ))
  1150. {
  1151. PBLINK* pLink = (PBLINK* )DtlGetData( pNode );
  1152. if (pLink->fEnabled)
  1153. {
  1154. ++c;
  1155. }
  1156. }
  1157. TRACE1( "PeCountEnabledLinks=%d", c );
  1158. return c;
  1159. }
  1160. VOID
  1161. PeExit(
  1162. IN PEINFO* pInfo,
  1163. IN DWORD dwError )
  1164. // Forces an exit from the dialog, reporting 'dwError' to the caller.
  1165. // 'PInfo' is the dialog context.
  1166. //
  1167. // Note: This cannot be called during initialization of the first page.
  1168. // See PeExitInit.
  1169. //
  1170. {
  1171. TRACE( "PeExit" );
  1172. // In "ShellOwned" mode where the RasEntryDlg API has already returned,
  1173. // output arguments are not recorded.
  1174. //
  1175. if (!(pInfo->pArgs->pApiArgs->dwFlags & RASEDFLAG_ShellOwned))
  1176. {
  1177. pInfo->pArgs->pApiArgs->dwError = dwError;
  1178. }
  1179. PropSheet_PressButton( pInfo->hwndDlg, PSBTN_CANCEL );
  1180. }
  1181. VOID
  1182. PeExitInit(
  1183. IN HWND hwndDlg,
  1184. IN EINFO* pEinfo,
  1185. IN DWORD dwError )
  1186. // Utility to report errors within PeInit and other first page
  1187. // initialization. 'HwndDlg' is the dialog window. 'PEinfo' is the
  1188. // common context block, i.e. the PropertySheet argument. 'DwError' is
  1189. // the error that occurred.
  1190. //
  1191. {
  1192. // In "ShellOwned" mode where the RasEntryDlg API has already returned,
  1193. // output arguments are not recorded.
  1194. //
  1195. if (!(pEinfo->pApiArgs->dwFlags & RASEDFLAG_ShellOwned))
  1196. {
  1197. pEinfo->pApiArgs->dwError = dwError;
  1198. }
  1199. SetOffDesktop( hwndDlg, SOD_MoveOff, NULL );
  1200. SetOffDesktop( hwndDlg, SOD_Free, NULL );
  1201. PostMessage( hwndDlg, WM_COMMAND,
  1202. MAKEWPARAM( IDCANCEL , BN_CLICKED ),
  1203. (LPARAM )GetDlgItem( hwndDlg, IDCANCEL ) );
  1204. }
  1205. PEINFO*
  1206. PeInit(
  1207. IN HWND hwndFirstPage,
  1208. IN EINFO* pArgs )
  1209. // Property sheet level initialization. 'HwndPage' is the handle of the
  1210. // first page. 'PArgs' is the common entry input argument block.
  1211. //
  1212. // Returns address of the context block if successful, NULL otherwise. If
  1213. // NULL is returned, an appropriate message has been displayed, and the
  1214. // property sheet has been cancelled.
  1215. //
  1216. {
  1217. DWORD dwErr;
  1218. DWORD dwOp;
  1219. PEINFO* pInfo;
  1220. HWND hwndDlg;
  1221. TRACE( "PeInit" );
  1222. hwndDlg = GetParent( hwndFirstPage );
  1223. // Allocate the context information block. Initialize it enough so that
  1224. // it can be destroyed properly, and associate the context with the
  1225. // window.
  1226. //
  1227. {
  1228. pInfo = Malloc( sizeof(*pInfo) );
  1229. if (!pInfo)
  1230. {
  1231. TRACE( "Context NOT allocated" );
  1232. ErrorDlg( hwndDlg, SID_OP_LoadDlg, ERROR_NOT_ENOUGH_MEMORY, NULL );
  1233. PeExitInit( hwndDlg, pArgs, ERROR_NOT_ENOUGH_MEMORY );
  1234. return NULL;
  1235. }
  1236. ZeroMemory( pInfo, sizeof(PEINFO) );
  1237. pInfo->pArgs = pArgs;
  1238. pInfo->hwndDlg = hwndDlg;
  1239. pInfo->hwndFirstPage = hwndFirstPage;
  1240. if (!SetProp( hwndDlg, g_contextId, pInfo ))
  1241. {
  1242. TRACE(" Context NOT set" );
  1243. ErrorDlg( hwndDlg, SID_OP_LoadDlg, ERROR_UNKNOWN, NULL );
  1244. Free( pInfo );
  1245. PeExitInit( hwndDlg, pArgs, ERROR_UNKNOWN );
  1246. return NULL;
  1247. }
  1248. TRACE( "Context set" );
  1249. }
  1250. // Position the dialog per API caller's instructions.
  1251. //
  1252. //For whislter bug 238459, we center the Property dialog box on its
  1253. //parent window rather than shift it as before. gangz
  1254. //
  1255. PositionDlg( hwndDlg,
  1256. 0,
  1257. pArgs->pApiArgs->xDlg, pArgs->pApiArgs->yDlg );
  1258. // Mess with the title bar gadgets.
  1259. //
  1260. //TweakTitleBar( hwndDlg );
  1261. // Indicate no device has yet been selected.
  1262. //
  1263. pInfo->iDeviceSelected = -1;
  1264. // Indicate the "no security settings for SLIP" popup is appropriate for
  1265. // the entry and has not been viewed yet during this visit.
  1266. //
  1267. if (pArgs->pEntry->dwBaseProtocol == BP_Slip)
  1268. {
  1269. pInfo->fShowSlipPopup = TRUE;
  1270. }
  1271. // Initialize COM which may be needed by netshell calls.
  1272. //
  1273. {
  1274. HRESULT hr;
  1275. hr = CoInitializeEx( NULL, COINIT_APARTMENTTHREADED );
  1276. if (hr == RPC_E_CHANGED_MODE)
  1277. {
  1278. hr = CoInitializeEx( NULL, COINIT_MULTITHREADED );
  1279. }
  1280. if (hr == S_OK || hr == S_FALSE)
  1281. {
  1282. pInfo->fComInitialized = TRUE;
  1283. }
  1284. }
  1285. #if 0
  1286. // Set even fixed tab widths.
  1287. //
  1288. SetEvenTabWidths( hwndDlg, PE_PageCount );
  1289. #endif
  1290. return pInfo;
  1291. }
  1292. VOID
  1293. PeTerm(
  1294. IN HWND hwndPage )
  1295. // Property sheet level termination. Releases the context block.
  1296. // 'HwndPage' is the handle of a property page.
  1297. //
  1298. {
  1299. PEINFO* pInfo;
  1300. TRACE( "PeTerm" );
  1301. pInfo = PeContext( hwndPage );
  1302. if (pInfo)
  1303. {
  1304. if (pInfo->pArgs->pApiArgs->dwFlags & RASEDFLAG_ShellOwned)
  1305. {
  1306. EuFree(pInfo->pArgs);
  1307. pInfo->pArgs = NULL;
  1308. }
  1309. if (pInfo->hwndLbDialAnotherFirst)
  1310. {
  1311. GeClearLbDialAnotherFirst( pInfo->hwndLbDialAnotherFirst );
  1312. }
  1313. if (pInfo->pListAreaCodes)
  1314. {
  1315. DtlDestroyList( pInfo->pListAreaCodes, DestroyPszNode );
  1316. }
  1317. #if 0
  1318. if (pInfo->pListEapcfgs)
  1319. {
  1320. DtlDestroyList( pInfo->pListEapcfgs, DestroyEapcfgNode );
  1321. }
  1322. #endif
  1323. if (pInfo->fCuInfoInitialized)
  1324. {
  1325. CuFree( &pInfo->cuinfo );
  1326. }
  1327. if (pInfo->fSuInfoInitialized)
  1328. {
  1329. SuFree( &pInfo->suinfo );
  1330. }
  1331. // Cleanup networking page context.
  1332. //
  1333. {
  1334. // Release our UI info callback object after revoking its info.
  1335. //
  1336. if (pInfo->punkUiInfoCallback)
  1337. {
  1338. RevokePeinfoFromUiInfoCallbackObject (pInfo->punkUiInfoCallback);
  1339. ReleaseObj (pInfo->punkUiInfoCallback);
  1340. }
  1341. //!!! Major hack: Get the list view on the networking page
  1342. // to dump its items before the pInfo and pInfo->pNetCfg go away.
  1343. // We have to do this here when we dismiss the property sheet
  1344. // from the General tab. When this happens, the general page
  1345. // is destroyed first (causing us to wind up here in PeTerm)
  1346. // before the networking page is destroyed. When the networking
  1347. // page is destroyed, its listview will also get destroyed
  1348. // causing all of its items to be deleted. If those LVN_ITEMDELETED
  1349. // notifications show up after pInfo and pInfo->pNetCfg are long
  1350. // gone, badness ensues. We need to solve this by decoupling
  1351. // PeTerm from a WM_DESTROY message and hooking it up to some
  1352. // later notification (like a page callback).
  1353. //
  1354. ListView_DeleteAllItems (pInfo->hwndLvComponents);
  1355. if (pInfo->pNetConUtilities)
  1356. {
  1357. INetConnectionUiUtilities_Release(pInfo->pNetConUtilities);
  1358. }
  1359. if (pInfo->pNetCfg)
  1360. {
  1361. HrUninitializeAndReleaseINetCfg (pInfo->fInitCom,
  1362. pInfo->pNetCfg, pInfo->fNetCfgLock);
  1363. }
  1364. SetupDiDestroyClassImageList (&pInfo->cild);
  1365. }
  1366. if (pInfo->fComInitialized)
  1367. {
  1368. CoUninitialize();
  1369. }
  1370. Free( pInfo );
  1371. TRACE("Context freed");
  1372. }
  1373. RemoveProp( GetParent( hwndPage ), g_contextId );
  1374. }
  1375. //----------------------------------------------------------------------------
  1376. // General property page (non-VPN)
  1377. // Listed alphabetically following dialog proc
  1378. //----------------------------------------------------------------------------
  1379. INT_PTR CALLBACK
  1380. GeDlgProcSingle(
  1381. IN HWND hwnd,
  1382. IN UINT unMsg,
  1383. IN WPARAM wparam,
  1384. IN LPARAM lparam )
  1385. // DialogProc callback for the General page of the Entry Property sheet
  1386. // when in single device mode. Parameters and return value are as
  1387. // described for standard windows 'DialogProc's.
  1388. //
  1389. {
  1390. #if 0
  1391. TRACE4( "GeDlgProcS(h=$%x,m=$%x,w=$%x,l=$%x)",
  1392. (DWORD )hwnd, (DWORD )unMsg, (DWORD )wparam, (DWORD )lparam );
  1393. #endif
  1394. if (ListView_OwnerHandler(
  1395. hwnd, unMsg, wparam, lparam, GeLvDevicesCallbackSingle ))
  1396. {
  1397. return TRUE;
  1398. }
  1399. return GeDlgProc( hwnd, unMsg, wparam, lparam );
  1400. }
  1401. INT_PTR CALLBACK
  1402. GeDlgProcMultiple(
  1403. IN HWND hwnd,
  1404. IN UINT unMsg,
  1405. IN WPARAM wparam,
  1406. IN LPARAM lparam )
  1407. // DialogProc callback for the General page of the Entry Property sheet
  1408. // when in multiple device mode. Parameters and return value are as
  1409. // described for standard windows 'DialogProc's.
  1410. //
  1411. {
  1412. #if 0
  1413. TRACE4( "GeDlgProcS(h=$%x,m=$%x,w=$%x,l=$%x)",
  1414. (DWORD )hwnd, (DWORD )unMsg, (DWORD )wparam, (DWORD )lparam );
  1415. #endif
  1416. if (ListView_OwnerHandler(
  1417. hwnd, unMsg, wparam, lparam, GeLvDevicesCallbackMultiple ))
  1418. {
  1419. return TRUE;
  1420. }
  1421. return GeDlgProc( hwnd, unMsg, wparam, lparam );
  1422. }
  1423. INT_PTR CALLBACK
  1424. GeDlgProc(
  1425. IN HWND hwnd,
  1426. IN UINT unMsg,
  1427. IN WPARAM wparam,
  1428. IN LPARAM lparam )
  1429. // DialogProc callback for the General page of the Entry Property sheet.
  1430. // Called directly for VPNs or called by one of the two non-VPN stubs so
  1431. // 'pInfo' lookup is not required for every messages. Parameters and
  1432. // return value are as described for standard windows 'DialogProc's.
  1433. //
  1434. {
  1435. switch (unMsg)
  1436. {
  1437. case WM_INITDIALOG:
  1438. {
  1439. return
  1440. GeInit( hwnd, (EINFO* )(((PROPSHEETPAGE* )lparam)->lParam) );
  1441. }
  1442. case WM_HELP:
  1443. case WM_CONTEXTMENU:
  1444. {
  1445. ContextHelp( g_adwGeHelp, hwnd, unMsg, wparam, lparam );
  1446. break;
  1447. }
  1448. case WM_NOTIFY:
  1449. {
  1450. switch (((NMHDR* )lparam)->code)
  1451. {
  1452. case PSN_APPLY:
  1453. {
  1454. BOOL fValid;
  1455. TRACE( "GeAPPLY" );
  1456. fValid = PeApply( hwnd );
  1457. SetWindowLong(
  1458. hwnd, DWLP_MSGRESULT,
  1459. (fValid)
  1460. ? PSNRET_NOERROR
  1461. : PSNRET_INVALID_NOCHANGEPAGE );
  1462. return TRUE;
  1463. }
  1464. case PSN_RESET:
  1465. {
  1466. TRACE( "GeRESET" );
  1467. SetWindowLong( hwnd, DWLP_MSGRESULT, FALSE );
  1468. break;
  1469. }
  1470. case LVXN_SETCHECK:
  1471. {
  1472. PEINFO* pInfo;
  1473. // An item was just checked or unchecked.
  1474. //
  1475. pInfo = PeContext( hwnd );
  1476. ASSERT( pInfo );
  1477. if (pInfo == NULL)
  1478. {
  1479. break;
  1480. }
  1481. GeUpdatePhoneNumberFields( pInfo, FALSE );
  1482. // For whistler bug 29419 gangz
  1483. // We should grey out the "All device call the same number"
  1484. // if not all the modems are selected
  1485. //
  1486. do
  1487. {
  1488. int i, iCount = 0, iChecked = 0;
  1489. BOOL fEnable = TRUE;
  1490. iCount = ListView_GetItemCount(
  1491. pInfo->hwndLvDevices
  1492. );
  1493. if ( iCount <= 0 )
  1494. {
  1495. break;
  1496. }
  1497. for ( i = 0; i < iCount; i ++ )
  1498. {
  1499. if ( ListView_GetCheck(
  1500. pInfo->hwndLvDevices,
  1501. i)
  1502. )
  1503. {
  1504. iChecked ++;
  1505. }
  1506. if ( 2 <=iChecked )
  1507. {
  1508. break;
  1509. }
  1510. }
  1511. if ( iChecked < 2 )
  1512. {
  1513. fEnable = FALSE;
  1514. }
  1515. if ( pInfo->hwndCbSharedPhoneNumbers )
  1516. {
  1517. EnableWindow( pInfo->hwndCbSharedPhoneNumbers,
  1518. fEnable);
  1519. }
  1520. }while(FALSE);
  1521. break;
  1522. }
  1523. case LVN_ITEMCHANGED:
  1524. {
  1525. NM_LISTVIEW* p;
  1526. p = (NM_LISTVIEW* )lparam;
  1527. if ((p->uNewState & LVIS_SELECTED)
  1528. && !(p->uOldState & LVIS_SELECTED))
  1529. {
  1530. PEINFO* pInfo;
  1531. // This item was just selected.
  1532. //
  1533. pInfo = PeContext( hwnd );
  1534. ASSERT( pInfo );
  1535. if (pInfo == NULL)
  1536. {
  1537. break;
  1538. }
  1539. GeUpdatePhoneNumberFields( pInfo, FALSE );
  1540. GeUpdateUpDownButtons( pInfo );
  1541. }
  1542. break;
  1543. }
  1544. }
  1545. break;
  1546. }
  1547. case WM_COMMAND:
  1548. {
  1549. PEINFO* pInfo = PeContext( hwnd );
  1550. ASSERT(pInfo);
  1551. if (pInfo == NULL)
  1552. {
  1553. break;
  1554. }
  1555. return GeCommand(
  1556. pInfo, HIWORD( wparam ), LOWORD( wparam ), (HWND )lparam );
  1557. }
  1558. case WM_DESTROY:
  1559. {
  1560. PeTerm( hwnd );
  1561. break;
  1562. }
  1563. }
  1564. return FALSE;
  1565. }
  1566. VOID
  1567. GeAlternates(
  1568. IN PEINFO* pInfo )
  1569. // Called when the "Alternates" button is pressed to popup the alternate
  1570. // phone number dialog.
  1571. //
  1572. {
  1573. // Pick up any control window changes into the underlying link so the
  1574. // dialog will reflect them.
  1575. //
  1576. GeGetPhoneFields( pInfo, pInfo->pCurLinkNode );
  1577. if (pInfo->pArgs->fRouter)
  1578. {
  1579. PBLINK* pLink;
  1580. DTLLIST* pListPsz;
  1581. DTLNODE* pNode;
  1582. // TAPI modifiers are not offered in the demand dial connection case,
  1583. // where user enters only a simple string phone number. The old
  1584. // NT4-style Alternates dialog that allows simple string edits only is
  1585. // used here. First, must convert the NT5-style list of PBPHONE nodes
  1586. // to a list of PSZ nodes that the old dialog expects.
  1587. //
  1588. pListPsz = DtlCreateList( 0L );
  1589. if (!pListPsz)
  1590. {
  1591. return;
  1592. }
  1593. pLink = (PBLINK* )DtlGetData( pInfo->pCurLinkNode );
  1594. for (pNode = DtlGetFirstNode( pLink->pdtllistPhones );
  1595. pNode;
  1596. pNode = DtlGetNextNode( pNode ) )
  1597. {
  1598. PBPHONE* pPhone;
  1599. DTLNODE* pNodePsz;
  1600. pPhone = (PBPHONE* )DtlGetData( pNode );
  1601. ASSERT( pPhone );
  1602. if (pPhone->pszPhoneNumber && *(pPhone->pszPhoneNumber))
  1603. {
  1604. pNodePsz = CreatePszNode( pPhone->pszPhoneNumber );
  1605. if (pNodePsz)
  1606. {
  1607. DtlAddNodeLast( pListPsz, pNodePsz );
  1608. }
  1609. }
  1610. }
  1611. // Call the old-sytle Alternates dialog which is shared with the
  1612. // demand dial wizard.
  1613. //
  1614. if (PhoneNumberDlg(
  1615. pInfo->hwndGe, TRUE, pListPsz, &pLink->fPromoteAlternates ))
  1616. {
  1617. // User pressed OK. Convert back to a PBPHONE node list.
  1618. //
  1619. while (pNode = DtlGetFirstNode( pLink->pdtllistPhones ))
  1620. {
  1621. DtlRemoveNode( pLink->pdtllistPhones, pNode );
  1622. DestroyPhoneNode( pNode );
  1623. }
  1624. for (pNode = DtlGetFirstNode( pListPsz );
  1625. pNode;
  1626. pNode = DtlGetNextNode( pNode ) )
  1627. {
  1628. TCHAR* psz;
  1629. DTLNODE* pPhoneNode;
  1630. PBPHONE* pPhone;
  1631. psz = (TCHAR* )DtlGetData( pNode );
  1632. if (!psz)
  1633. {
  1634. continue;
  1635. }
  1636. pPhoneNode = CreatePhoneNode();
  1637. if (!pPhoneNode)
  1638. {
  1639. continue;
  1640. }
  1641. pPhone = (PBPHONE* )DtlGetData( pPhoneNode );
  1642. if (!pPhone)
  1643. {
  1644. continue;
  1645. }
  1646. pPhone->pszPhoneNumber = psz;
  1647. DtlPutData( pNode, NULL );
  1648. DtlAddNodeLast( pLink->pdtllistPhones, pPhoneNode );
  1649. }
  1650. // Refresh the displayed phone number information, since user's
  1651. // edits in the dialog may have changed them.
  1652. //
  1653. GeSetPhoneFields( pInfo, pInfo->pCurLinkNode, FALSE );
  1654. }
  1655. DtlDestroyList( pListPsz, DestroyPszNode );
  1656. }
  1657. else
  1658. {
  1659. // Popup the Alternate Phone Number dialog on the link.
  1660. //
  1661. if (AlternatePhoneNumbersDlg(
  1662. pInfo->hwndDlg, pInfo->pCurLinkNode, pInfo->pListAreaCodes ))
  1663. {
  1664. // User pressed OK. Refresh the displayed phone number
  1665. // information, since user's edits in the dialog may have changed
  1666. // them.
  1667. //
  1668. GeSetPhoneFields( pInfo, pInfo->pCurLinkNode, FALSE );
  1669. }
  1670. }
  1671. }
  1672. VOID
  1673. GeDialingRules(
  1674. IN PEINFO* pInfo )
  1675. // Called when the "Rules" button is pressed to popup the tapi
  1676. // dialing rules dialog.
  1677. //
  1678. {
  1679. TCHAR pszAreaCode[RAS_MaxPhoneNumber];
  1680. TCHAR pszPhoneNumber[RAS_MaxPhoneNumber];
  1681. DWORD dwErr, dwCountryCode, dwLineId;
  1682. COUNTRY* pCountry = NULL;
  1683. INT iSel;
  1684. TRACE( "GeDialingRules" );
  1685. // Get the current phone number
  1686. //
  1687. GetWindowText ( pInfo->hwndEbPhoneNumber,
  1688. pszPhoneNumber,
  1689. sizeof(pszPhoneNumber) / sizeof(TCHAR) );
  1690. // Get the current area code
  1691. //
  1692. GetWindowText ( pInfo->hwndClbAreaCodes,
  1693. pszAreaCode,
  1694. sizeof(pszAreaCode) / sizeof(TCHAR) );
  1695. // Get the current country code
  1696. //
  1697. iSel = ComboBox_GetCurSel ( pInfo->hwndLbCountryCodes );
  1698. if (iSel >= 0)
  1699. {
  1700. pCountry = (COUNTRY*) ComboBox_GetItemDataPtr (
  1701. pInfo->hwndLbCountryCodes, iSel );
  1702. }
  1703. dwCountryCode = (pCountry) ? pCountry->dwCode : 0;
  1704. // Popup TAPI dialing rules dialog.
  1705. //
  1706. dwErr = TapiLocationDlg(
  1707. g_hinstDll,
  1708. &(pInfo->cuinfo.hlineapp),
  1709. pInfo->hwndDlg,
  1710. dwCountryCode,
  1711. pszAreaCode,
  1712. pszPhoneNumber,
  1713. 0 );
  1714. if (dwErr != 0)
  1715. {
  1716. ErrorDlg( pInfo->hwndDlg, SID_OP_LoadTapiInfo, dwErr, NULL );
  1717. }
  1718. }
  1719. VOID
  1720. GeClearLbDialAnotherFirst(
  1721. IN HWND hwndLbDialAnotherFirst )
  1722. // Clear prerequisite entry list box. 'hwndLbDialAnotherFirst' is the
  1723. // window handle of the listbox control. context.
  1724. //
  1725. {
  1726. PREREQITEM* pItem;
  1727. while (pItem = ComboBox_GetItemDataPtr( hwndLbDialAnotherFirst, 0 ))
  1728. {
  1729. ComboBox_DeleteString( hwndLbDialAnotherFirst, 0 );
  1730. Free0( pItem->pszEntry );
  1731. Free0( pItem->pszPbk );
  1732. Free( pItem );
  1733. }
  1734. }
  1735. BOOL
  1736. GeCommand(
  1737. IN PEINFO* pInfo,
  1738. IN WORD wNotification,
  1739. IN WORD wId,
  1740. IN HWND hwndCtrl )
  1741. // Called on WM_COMMAND. 'PInfo' is the dialog context. 'WNotification'
  1742. // is the notification code of the command. 'wId' is the control/menu
  1743. // identifier of the command. 'HwndCtrl' is the control window handle of
  1744. // the command.
  1745. //
  1746. // Returns true if processed message, false otherwise.
  1747. //
  1748. {
  1749. TRACE3( "GeCommand(n=%d,i=%d,c=$%x)",
  1750. (DWORD )wNotification, (DWORD )wId, (ULONG_PTR )hwndCtrl );
  1751. switch (wId)
  1752. {
  1753. case CID_GE_PB_MoveUp:
  1754. {
  1755. GeMoveDevice( pInfo, TRUE );
  1756. return TRUE;
  1757. }
  1758. case CID_GE_PB_MoveDown:
  1759. {
  1760. GeMoveDevice( pInfo, FALSE );
  1761. return TRUE;
  1762. }
  1763. case CID_GE_PB_Configure:
  1764. {
  1765. GeConfigure( pInfo );
  1766. return TRUE;
  1767. }
  1768. case CID_GE_PB_Alternates:
  1769. {
  1770. GeAlternates( pInfo );
  1771. return TRUE;
  1772. }
  1773. case CID_GE_PB_DialingRules:
  1774. {
  1775. GeDialingRules( pInfo );
  1776. return TRUE;
  1777. }
  1778. case CID_GE_CB_SharedPhoneNumber:
  1779. {
  1780. GeUpdatePhoneNumberFields( pInfo, TRUE );
  1781. return TRUE;
  1782. }
  1783. case CID_GE_CB_UseDialingRules:
  1784. {
  1785. if (CuDialingRulesCbHandler( &pInfo->cuinfo, wNotification ))
  1786. {
  1787. return TRUE;
  1788. }
  1789. break;
  1790. }
  1791. case CID_GE_LB_CountryCodes:
  1792. {
  1793. if (CuCountryCodeLbHandler( &pInfo->cuinfo, wNotification ))
  1794. {
  1795. return TRUE;
  1796. }
  1797. break;
  1798. }
  1799. case CID_GE_CB_DialAnotherFirst:
  1800. {
  1801. GeUpdateDialAnotherFirstState( pInfo );
  1802. return TRUE;
  1803. }
  1804. case CID_GE_LB_DialAnotherFirst:
  1805. {
  1806. if (wNotification == CBN_SELCHANGE)
  1807. {
  1808. GeDialAnotherFirstSelChange( pInfo );
  1809. return TRUE;
  1810. }
  1811. break;
  1812. }
  1813. case CID_GE_LB_Devices:
  1814. {
  1815. if (wNotification == CBN_SELCHANGE)
  1816. {
  1817. DTLLIST* pList;
  1818. DTLNODE* pNode, *pNode2;
  1819. PBLINK * pLink;
  1820. pList = pInfo->pArgs->pEntry->pdtllistLinks;
  1821. // Get node from current selection
  1822. pNode = (DTLNODE* )ComboBox_GetItemDataPtr(
  1823. pInfo->hwndLbDevices,
  1824. ComboBox_GetCurSel( pInfo->hwndLbDevices ) );
  1825. if(NULL == pNode)
  1826. {
  1827. break;
  1828. }
  1829. // Remove selected item from list of links
  1830. // and disable all other links
  1831. DtlRemoveNode ( pList, pNode );
  1832. for (pNode2 = DtlGetFirstNode (pList);
  1833. pNode2;
  1834. pNode2 = DtlGetNextNode (pNode2))
  1835. {
  1836. pLink = (PBLINK* )DtlGetData( pNode2 );
  1837. pLink->fEnabled = FALSE;
  1838. }
  1839. // Enable selected device and Re-add
  1840. // in list of links at front
  1841. pLink = (PBLINK* )DtlGetData( pNode );
  1842. pLink->fEnabled = TRUE;
  1843. DtlAddNodeFirst( pList, pNode );
  1844. }
  1845. break;
  1846. }
  1847. }
  1848. return FALSE;
  1849. }
  1850. VOID
  1851. GeConfigure(
  1852. IN PEINFO* pInfo )
  1853. // Called when the "Configure" button is pressed to popup the appropriate
  1854. // device configuration dialog.
  1855. //
  1856. {
  1857. DTLNODE* pNode;
  1858. PBLINK* pLink;
  1859. PBENTRY* pEntry;
  1860. BOOL fMultilinking = FALSE;
  1861. pEntry = pInfo->pArgs->pEntry;
  1862. // pmay: 245860
  1863. //
  1864. // Need to allow config of null modem speed.
  1865. //
  1866. if ( pEntry->dwType == RASET_Direct )
  1867. {
  1868. INT iSel;
  1869. iSel = ComboBox_GetCurSel( pInfo->hwndLbDevices );
  1870. pNode = (DTLNODE*)
  1871. ComboBox_GetItemDataPtr ( pInfo->hwndLbDevices, iSel );
  1872. }
  1873. else
  1874. {
  1875. pNode = (DTLNODE* )ListView_GetSelectedParamPtr( pInfo->hwndLvDevices );
  1876. fMultilinking =
  1877. (ListView_GetCheckedCount( pInfo->hwndLvDevices ) > 1
  1878. && pEntry->dwDialMode == RASEDM_DialAll);
  1879. }
  1880. if (!pNode)
  1881. {
  1882. return;
  1883. }
  1884. pLink = (PBLINK* )DtlGetData( pNode );
  1885. DeviceConfigureDlg(
  1886. pInfo->hwndDlg,
  1887. pLink,
  1888. pEntry,
  1889. !fMultilinking,
  1890. pInfo->pArgs->fRouter);
  1891. }
  1892. VOID
  1893. GeDialAnotherFirstSelChange(
  1894. IN PEINFO* pInfo )
  1895. // Called when the prerequisite entry selection changes. 'PInfo' is the
  1896. // property sheet context.
  1897. //
  1898. {
  1899. PBENTRY* pEntry;
  1900. PREREQITEM* pItem;
  1901. INT iSel;
  1902. iSel = ComboBox_GetCurSel( pInfo->hwndLbDialAnotherFirst );
  1903. if (iSel < 0)
  1904. {
  1905. return;
  1906. }
  1907. pEntry = pInfo->pArgs->pEntry;
  1908. Free0( pEntry->pszPrerequisiteEntry );
  1909. Free0( pEntry->pszPrerequisitePbk );
  1910. pItem = (PREREQITEM* )
  1911. ComboBox_GetItemDataPtr( pInfo->hwndLbDialAnotherFirst, iSel );
  1912. if(NULL != pItem)
  1913. {
  1914. pEntry->pszPrerequisiteEntry = StrDup( pItem->pszEntry );
  1915. pEntry->pszPrerequisitePbk = StrDup( pItem->pszPbk );
  1916. }
  1917. pEntry->fDirty = TRUE;
  1918. }
  1919. BOOL
  1920. GeFillLbDialAnotherFirst(
  1921. IN PEINFO* pInfo,
  1922. IN BOOL fAbortIfPrereqNotFound )
  1923. // Fill prerequisite entry list box with all non-VPN entries in the
  1924. // phonebook, and select the prerequiste one. 'PInfo' is the property
  1925. // sheet context. 'FAbortIfPrereqNotFound' means the list should not be
  1926. // filled unless the entry's prerequisite entry is found and selected.
  1927. //
  1928. // Returns TRUE if a selection was made, FALSE otherwise.
  1929. //
  1930. {
  1931. DWORD i;
  1932. INT iThis;
  1933. INT iSel;
  1934. TCHAR* pszEntry;
  1935. TCHAR* pszPrerequisiteEntry = NULL;
  1936. RASENTRYNAME* pRens;
  1937. RASENTRYNAME* pRen;
  1938. DWORD dwRens;
  1939. GeClearLbDialAnotherFirst( pInfo->hwndLbDialAnotherFirst );
  1940. iSel = -1;
  1941. pszEntry = pInfo->pArgs->pEntry->pszEntryName;
  1942. //
  1943. // Make a dup of this prerequisite entry here. Otherwise
  1944. // this leads to accessing freed memory when _SetCurSelNotify
  1945. // frees pszPrerequisiteEntry - [raos].
  1946. //
  1947. if(NULL != pInfo->pArgs->pEntry->pszPrerequisiteEntry)
  1948. {
  1949. pszPrerequisiteEntry = StrDup(
  1950. pInfo->pArgs->pEntry->pszPrerequisiteEntry);
  1951. }
  1952. if (GetRasEntrynameTable( &pRens, &dwRens ) != 0)
  1953. {
  1954. return FALSE;
  1955. }
  1956. for (i = 0, pRen = pRens; i < dwRens; ++i, ++pRen )
  1957. {
  1958. PREREQITEM* pItem;
  1959. if (lstrcmp( pRen->szEntryName, pszEntry ) == 0)
  1960. {
  1961. continue;
  1962. }
  1963. pItem = Malloc( sizeof(PREREQITEM) );
  1964. if (!pItem)
  1965. {
  1966. continue;
  1967. }
  1968. pItem->pszEntry = StrDup( pRen->szEntryName );
  1969. pItem->pszPbk = StrDup( pRen->szPhonebookPath );
  1970. if (!pItem->pszEntry || !pItem->pszPbk)
  1971. {
  1972. Free0( pItem->pszEntry );
  1973. Free( pItem );
  1974. continue;
  1975. }
  1976. iThis = ComboBox_AddItem(
  1977. pInfo->hwndLbDialAnotherFirst, pItem->pszEntry, pItem );
  1978. if (pszPrerequisiteEntry && *(pszPrerequisiteEntry)
  1979. && lstrcmp( pItem->pszEntry, pszPrerequisiteEntry ) == 0)
  1980. {
  1981. iSel = iThis;
  1982. ComboBox_SetCurSelNotify( pInfo->hwndLbDialAnotherFirst, iSel );
  1983. }
  1984. }
  1985. Free( pRens );
  1986. if (iSel < 0)
  1987. {
  1988. if (fAbortIfPrereqNotFound)
  1989. {
  1990. GeClearLbDialAnotherFirst( pInfo->hwndLbDialAnotherFirst );
  1991. }
  1992. else
  1993. {
  1994. iSel = 0;
  1995. ComboBox_SetCurSelNotify( pInfo->hwndLbDialAnotherFirst, iSel );
  1996. }
  1997. }
  1998. Free0(pszPrerequisiteEntry);
  1999. return (iSel >= 0);
  2000. }
  2001. VOID
  2002. GeFillLbDevices(
  2003. IN PEINFO* pInfo )
  2004. // Populate the already initialized ListBox of devices, selecting the
  2005. // currently selected item or if none, the first item. 'PInfo' is the
  2006. // property sheet context.
  2007. //
  2008. {
  2009. DTLNODE* pNode;
  2010. DTLNODE* pSelNode;
  2011. DTLLIST* pListLinks;
  2012. INT iItem;
  2013. INT iSelItem;
  2014. TRACE( "GeFillLbDevices" );
  2015. pSelNode = NULL;
  2016. iSelItem = -1;
  2017. // (Re-)populate the list.
  2018. //
  2019. pListLinks = pInfo->pArgs->pEntry->pdtllistLinks;
  2020. for (pNode = DtlGetFirstNode( pListLinks ), iItem = 0;
  2021. pNode;
  2022. pNode = DtlGetNextNode( pNode ), ++iItem)
  2023. {
  2024. PBLINK* pLink;
  2025. DWORD dwImage;
  2026. TCHAR* pszText;
  2027. pLink = (PBLINK* )DtlGetData( pNode );
  2028. ASSERT( pLink );
  2029. pszText = DisplayPszFromPpbport( &pLink->pbport, &dwImage );
  2030. if (pszText)
  2031. {
  2032. iItem = ComboBox_AddString( pInfo->hwndLbDevices, pszText );
  2033. ComboBox_SetItemData ( pInfo->hwndLbDevices, iItem, pNode );
  2034. Free (pszText);
  2035. }
  2036. }
  2037. ComboBox_SetCurSelNotify( pInfo->hwndLbDevices, 0 );
  2038. }
  2039. VOID
  2040. GeFillLvDevices(
  2041. IN PEINFO* pInfo )
  2042. // Populate the already initialized ListView of devices, selecting the
  2043. // currently selected item or if none, the first item. 'PInfo' is the
  2044. // property sheet context.
  2045. //
  2046. {
  2047. DTLNODE* pNode;
  2048. DTLNODE* pSelNode;
  2049. DTLLIST* pListLinks;
  2050. INT iItem;
  2051. INT iSelItem;
  2052. BOOL bFirstTime = TRUE;
  2053. INT cItems;
  2054. TRACE( "GeFillLvDevices" );
  2055. pSelNode = NULL;
  2056. iSelItem = -1;
  2057. if (ListView_GetItemCount( pInfo->hwndLvDevices ) > 0)
  2058. {
  2059. // ListView has been filled. Lookup the selected link node, if any,
  2060. // then save the check state to the links, and delete all items from
  2061. // the list.
  2062. //
  2063. if (pInfo->iDeviceSelected >= 0)
  2064. {
  2065. pSelNode =
  2066. (DTLNODE* )ListView_GetParamPtr(
  2067. pInfo->hwndLvDevices, pInfo->iDeviceSelected );
  2068. }
  2069. GeSaveLvDeviceChecks( pInfo );
  2070. ListView_DeleteAllItems( pInfo->hwndLvDevices );
  2071. bFirstTime = FALSE;
  2072. }
  2073. // (Re-)populate the list.
  2074. //
  2075. pListLinks = pInfo->pArgs->pEntry->pdtllistLinks;
  2076. for (pNode = DtlGetFirstNode( pListLinks ), iItem = 0;
  2077. pNode;
  2078. pNode = DtlGetNextNode( pNode ), ++iItem)
  2079. {
  2080. PBLINK* pLink;
  2081. DWORD dwImage;
  2082. TCHAR* pszText;
  2083. pLink = (PBLINK* )DtlGetData( pNode );
  2084. ASSERT( pLink );
  2085. pszText = DisplayPszFromPpbport( &pLink->pbport, &dwImage );
  2086. if (pszText)
  2087. {
  2088. LV_ITEM item;
  2089. ZeroMemory( &item, sizeof(item) );
  2090. item.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM;
  2091. item.iItem = iItem;
  2092. item.lParam = (LPARAM )pNode;
  2093. item.pszText = pszText;
  2094. item.cchTextMax = wcslen(pszText) + 1;
  2095. item.iImage = dwImage;
  2096. iItem = ListView_InsertItem( pInfo->hwndLvDevices, &item );
  2097. Free( pszText );
  2098. if (pNode == pSelNode)
  2099. {
  2100. iSelItem = iItem;
  2101. pInfo->iDeviceSelected = iItem;
  2102. }
  2103. /*
  2104. if (pInfo->pArgs->fMultipleDevices)
  2105. {
  2106. ListView_SetCheck(
  2107. pInfo->hwndLvDevices, iItem, pLink->fEnabled );
  2108. }
  2109. */
  2110. }
  2111. }
  2112. if(pInfo->pArgs->fMultipleDevices)
  2113. {
  2114. INT i = -1;
  2115. while ((i = ListView_GetNextItem(
  2116. pInfo->hwndLvDevices, i, LVNI_ALL )) >= 0)
  2117. {
  2118. DTLNODE* pNodeTmp = NULL;
  2119. PBLINK* pLink = NULL;
  2120. pNodeTmp = (DTLNODE* )ListView_GetParamPtr( pInfo->hwndLvDevices, i );
  2121. ASSERT( pNodeTmp );
  2122. if(NULL == pNodeTmp)
  2123. {
  2124. continue;
  2125. }
  2126. pLink = (PBLINK* )DtlGetData( pNodeTmp );
  2127. ASSERT( pLink );
  2128. ListView_SetCheck(
  2129. pInfo->hwndLvDevices, i, pLink->fEnabled);
  2130. }
  2131. }
  2132. if (bFirstTime == TRUE)
  2133. {
  2134. // Add a single column exactly wide enough to fully display
  2135. // the widest member of the list.
  2136. //
  2137. LV_COLUMN col;
  2138. ZeroMemory( &col, sizeof(col) );
  2139. col.mask = LVCF_FMT;
  2140. col.fmt = LVCFMT_LEFT;
  2141. ListView_InsertColumn( pInfo->hwndLvDevices, 0, &col );
  2142. ListView_SetColumnWidth( pInfo->hwndLvDevices, 0, LVSCW_AUTOSIZE_USEHEADER );
  2143. }
  2144. // EuInit creates a bogus device if there are none guaranteeing that the
  2145. // device list is never empty.
  2146. //
  2147. ASSERT( iItem > 0 );
  2148. // Select the previously selected item, or the first item if none. This
  2149. // will trigger an update of the phone number related controls. The
  2150. // "previous selection" index is updated to the new index of the same
  2151. // item.
  2152. //
  2153. if (iSelItem >= 0)
  2154. {
  2155. pInfo->iDeviceSelected = iSelItem;
  2156. }
  2157. else
  2158. {
  2159. iSelItem = 0;
  2160. }
  2161. ListView_SetItemState(
  2162. pInfo->hwndLvDevices, iSelItem, LVIS_SELECTED, LVIS_SELECTED );
  2163. }
  2164. VOID
  2165. GeInitLvDevices(
  2166. IN PEINFO* pInfo )
  2167. // Initialize the ListView of devices.
  2168. //
  2169. {
  2170. BOOL fChecksInstalled;
  2171. // Install "listview of checkboxes" handling.
  2172. //
  2173. if (pInfo->pArgs->fMultipleDevices)
  2174. {
  2175. fChecksInstalled =
  2176. ListView_InstallChecks( pInfo->hwndLvDevices, g_hinstDll );
  2177. if (!fChecksInstalled)
  2178. return;
  2179. }
  2180. // Set the modem, adapter, and other device images.
  2181. //
  2182. ListView_SetDeviceImageList( pInfo->hwndLvDevices, g_hinstDll );
  2183. // Add a single column exactly wide enough to fully display the widest
  2184. // member of the list.
  2185. //
  2186. ListView_InsertSingleAutoWidthColumn( pInfo->hwndLvDevices );
  2187. }
  2188. VOID
  2189. GeGetPhoneFields(
  2190. IN PEINFO* pInfo,
  2191. OUT DTLNODE* pDstLinkNode )
  2192. // Load the phone number group box field settings into the phone number
  2193. // information of PBLINK node 'pDstLinkNode'. 'PInfo' is the property
  2194. // sheet context.
  2195. //
  2196. {
  2197. PBLINK* pLink;
  2198. PBPHONE* pPhone;
  2199. DTLNODE* pPhoneNode;
  2200. TRACE( "GeGetPhoneFields" );
  2201. pLink = (PBLINK* )DtlGetData( pDstLinkNode );
  2202. ASSERT( pLink );
  2203. pPhoneNode = FirstPhoneNodeFromPhoneList( pLink->pdtllistPhones );
  2204. if (pPhoneNode)
  2205. {
  2206. CuGetInfo( &pInfo->cuinfo, pPhoneNode );
  2207. FirstPhoneNodeToPhoneList( pLink->pdtllistPhones, pPhoneNode );
  2208. }
  2209. }
  2210. BOOL
  2211. GeInit(
  2212. IN HWND hwndPage,
  2213. IN OUT EINFO* pArgs )
  2214. // Called on WM_INITDIALOG. 'hwndPage' is the handle of the property
  2215. // page. 'PArgs' is the arguments from the PropertySheet caller.
  2216. //
  2217. // Return false if focus was set, true otherwise.
  2218. //
  2219. {
  2220. DWORD dwErr;
  2221. PEINFO* pInfo;
  2222. PBENTRY* pEntry;
  2223. TRACE( "GeInit" );
  2224. // We're first page, so initialize the property sheet.
  2225. //
  2226. pInfo = PeInit( hwndPage, pArgs );
  2227. if (!pInfo)
  2228. {
  2229. return TRUE;
  2230. }
  2231. pEntry = pInfo->pArgs->pEntry;
  2232. // Initialize page-specific context information.
  2233. //
  2234. pInfo->hwndGe = hwndPage;
  2235. // Initialize the "show icon in the taskbar" button, the lone piece of consistency among
  2236. // the various forms.
  2237. //
  2238. //for bug 154607 whistler, Enable/Disable Show Icon on taskbar
  2239. //check box according to Policy
  2240. //
  2241. //
  2242. {
  2243. BOOL fShowStatistics = TRUE;
  2244. NeEnsureNetshellLoaded (pInfo);
  2245. if ( NULL != pInfo->pNetConUtilities)
  2246. {
  2247. fShowStatistics =
  2248. INetConnectionUiUtilities_UserHasPermission(
  2249. pInfo->pNetConUtilities, NCPERM_Statistics);
  2250. }
  2251. pInfo->hwndCbShowIcon =
  2252. GetDlgItem( hwndPage, CID_GE_CB_ShowIcon );
  2253. ASSERT( pInfo->hwndCbShowIcon );
  2254. if ( pInfo->pArgs->fRouter )
  2255. {
  2256. Button_SetCheck( pInfo->hwndCbShowIcon, FALSE );
  2257. ShowWindow( pInfo->hwndCbShowIcon, SW_HIDE );
  2258. }
  2259. else
  2260. {
  2261. Button_SetCheck(
  2262. pInfo->hwndCbShowIcon, pEntry->fShowMonitorIconInTaskBar );
  2263. if ( !fShowStatistics )
  2264. {
  2265. EnableWindow( pInfo->hwndCbShowIcon, FALSE );
  2266. }
  2267. }
  2268. }
  2269. if (pEntry->dwType == RASET_Vpn)
  2270. {
  2271. pInfo->hwndEbHostName =
  2272. GetDlgItem( hwndPage, CID_GE_EB_HostName );
  2273. ASSERT( pInfo->hwndEbHostName );
  2274. pInfo->hwndCbDialAnotherFirst =
  2275. GetDlgItem( hwndPage, CID_GE_CB_DialAnotherFirst );
  2276. ASSERT( pInfo->hwndCbDialAnotherFirst );
  2277. pInfo->hwndLbDialAnotherFirst =
  2278. GetDlgItem( hwndPage, CID_GE_LB_DialAnotherFirst );
  2279. ASSERT( pInfo->hwndLbDialAnotherFirst );
  2280. // Initialize host name, i.e. the "phone number".
  2281. //
  2282. {
  2283. DTLNODE* pNode;
  2284. PBLINK* pLink;
  2285. PBPHONE* pPhone;
  2286. Edit_LimitText( pInfo->hwndEbHostName, RAS_MaxPhoneNumber );
  2287. pNode = DtlGetFirstNode( pEntry->pdtllistLinks );
  2288. ASSERT( pNode );
  2289. pLink = (PBLINK* )DtlGetData( pNode );
  2290. pNode = FirstPhoneNodeFromPhoneList( pLink->pdtllistPhones );
  2291. if(NULL == pNode)
  2292. {
  2293. return TRUE;
  2294. }
  2295. pPhone = (PBPHONE* )DtlGetData( pNode );
  2296. SetWindowText( pInfo->hwndEbHostName, pPhone->pszPhoneNumber );
  2297. DestroyPhoneNode( pNode );
  2298. }
  2299. // Initialize the "dial connected first" controls.
  2300. //
  2301. if (pInfo->pArgs->fRouter)
  2302. {
  2303. Button_SetCheck( pInfo->hwndCbDialAnotherFirst, FALSE );
  2304. EnableWindow( pInfo->hwndCbDialAnotherFirst, FALSE );
  2305. ShowWindow( pInfo->hwndCbDialAnotherFirst, SW_HIDE );
  2306. EnableWindow( pInfo->hwndLbDialAnotherFirst, FALSE );
  2307. ShowWindow(pInfo->hwndLbDialAnotherFirst, SW_HIDE );
  2308. ShowWindow(
  2309. GetDlgItem( hwndPage, CID_GE_GB_FirstConnect ),
  2310. SW_HIDE );
  2311. ShowWindow(
  2312. GetDlgItem( hwndPage, CID_GE_ST_Explain ),
  2313. SW_HIDE );
  2314. }
  2315. else
  2316. {
  2317. BOOL fEnableLb;
  2318. fEnableLb = FALSE;
  2319. if (pEntry->pszPrerequisiteEntry
  2320. && *(pEntry->pszPrerequisiteEntry))
  2321. {
  2322. if (GeFillLbDialAnotherFirst( pInfo, TRUE ))
  2323. {
  2324. fEnableLb = TRUE;
  2325. }
  2326. else
  2327. {
  2328. // Don't enable the listbox if the prerequisite entry
  2329. // defined no longer exists. See bug 220420.
  2330. //
  2331. Free0( pEntry->pszPrerequisiteEntry );
  2332. pEntry->pszPrerequisiteEntry = NULL;
  2333. Free0( pEntry->pszPrerequisitePbk );
  2334. pEntry->pszPrerequisitePbk = NULL;
  2335. }
  2336. }
  2337. Button_SetCheck( pInfo->hwndCbDialAnotherFirst, fEnableLb );
  2338. EnableWindow( pInfo->hwndLbDialAnotherFirst, fEnableLb );
  2339. if (pArgs->fDisableFirstConnect)
  2340. {
  2341. EnableWindow( pInfo->hwndCbDialAnotherFirst, FALSE );
  2342. EnableWindow( pInfo->hwndLbDialAnotherFirst, FALSE );
  2343. }
  2344. }
  2345. return TRUE;
  2346. }
  2347. else if (pEntry->dwType == RASET_Broadband)
  2348. {
  2349. pInfo->hwndEbBroadbandService =
  2350. GetDlgItem( hwndPage, CID_GE_EB_ServiceName );
  2351. ASSERT( pInfo->hwndEbBroadbandService );
  2352. // Initialize host name, i.e. the "phone number".
  2353. //
  2354. {
  2355. DTLNODE* pNode;
  2356. PBLINK* pLink;
  2357. PBPHONE* pPhone;
  2358. Edit_LimitText( pInfo->hwndEbBroadbandService, RAS_MaxPhoneNumber );
  2359. pNode = DtlGetFirstNode( pEntry->pdtllistLinks );
  2360. ASSERT( pNode );
  2361. pLink = (PBLINK* )DtlGetData( pNode );
  2362. pNode = FirstPhoneNodeFromPhoneList( pLink->pdtllistPhones );
  2363. if(NULL == pNode)
  2364. {
  2365. return TRUE;
  2366. }
  2367. pPhone = (PBPHONE* )DtlGetData( pNode );
  2368. SetWindowText( pInfo->hwndEbBroadbandService, pPhone->pszPhoneNumber );
  2369. DestroyPhoneNode( pNode );
  2370. }
  2371. return TRUE;
  2372. }
  2373. else if (pEntry->dwType == RASET_Phone)
  2374. {
  2375. if (pArgs->fMultipleDevices)
  2376. {
  2377. pInfo->hwndLvDevices =
  2378. GetDlgItem( hwndPage, CID_GE_LV_Devices );
  2379. ASSERT( pInfo->hwndLvDevices );
  2380. pInfo->hwndPbUp =
  2381. GetDlgItem( hwndPage, CID_GE_PB_MoveUp );
  2382. ASSERT( pInfo->hwndPbUp );
  2383. pInfo->hwndPbDown =
  2384. GetDlgItem( hwndPage, CID_GE_PB_MoveDown );
  2385. ASSERT( pInfo->hwndPbDown );
  2386. pInfo->hwndCbSharedPhoneNumbers =
  2387. GetDlgItem( hwndPage, CID_GE_CB_SharedPhoneNumber );
  2388. ASSERT( pInfo->hwndCbSharedPhoneNumbers );
  2389. }
  2390. else
  2391. {
  2392. // The listview has a different control-ID in single mode so that
  2393. // a different help context can be provided.
  2394. //
  2395. pInfo->hwndLvDevices =
  2396. GetDlgItem( hwndPage, CID_GE_LV_Device );
  2397. ASSERT( pInfo->hwndLvDevices );
  2398. }
  2399. pInfo->hwndPbConfigureDevice =
  2400. GetDlgItem( hwndPage, CID_GE_PB_Configure );
  2401. ASSERT( pInfo->hwndPbConfigureDevice );
  2402. if ( pEntry->fGlobalDeviceSettings )
  2403. {
  2404. // Whislter bug 281306. If the entry is set up to use
  2405. // control panel settings, then hide the option that
  2406. // allows users to configure the devices per-phonebook.
  2407. //
  2408. ShowWindow( pInfo->hwndPbConfigureDevice, SW_HIDE );
  2409. }
  2410. pInfo->hwndStPhoneNumber =
  2411. GetDlgItem( hwndPage, CID_GE_ST_PhoneNumber );
  2412. ASSERT( pInfo->hwndStPhoneNumber );
  2413. pInfo->hwndEbPhoneNumber =
  2414. GetDlgItem( hwndPage, CID_GE_EB_PhoneNumber );
  2415. ASSERT( pInfo->hwndEbPhoneNumber );
  2416. pInfo->hwndPbAlternates =
  2417. GetDlgItem( hwndPage, CID_GE_PB_Alternates );
  2418. ASSERT( pInfo->hwndPbAlternates );
  2419. if (!pInfo->pArgs->fRouter)
  2420. {
  2421. pInfo->hwndGbPhoneNumber =
  2422. GetDlgItem( hwndPage, CID_GE_GB_PhoneNumber );
  2423. ASSERT( pInfo->hwndGbPhoneNumber );
  2424. pInfo->hwndStAreaCodes =
  2425. GetDlgItem( hwndPage, CID_GE_ST_AreaCodes );
  2426. ASSERT( pInfo->hwndStAreaCodes );
  2427. pInfo->hwndClbAreaCodes =
  2428. GetDlgItem( hwndPage, CID_GE_CLB_AreaCodes );
  2429. ASSERT( pInfo->hwndClbAreaCodes );
  2430. pInfo->hwndStCountryCodes =
  2431. GetDlgItem( hwndPage, CID_GE_ST_CountryCodes );
  2432. ASSERT( pInfo->hwndStCountryCodes );
  2433. pInfo->hwndLbCountryCodes =
  2434. GetDlgItem( hwndPage, CID_GE_LB_CountryCodes );
  2435. ASSERT( pInfo->hwndLbCountryCodes );
  2436. pInfo->hwndCbUseDialingRules =
  2437. GetDlgItem( hwndPage, CID_GE_CB_UseDialingRules );
  2438. ASSERT( pInfo->hwndCbUseDialingRules );
  2439. pInfo->hwndPbDialingRules =
  2440. GetDlgItem( hwndPage, CID_GE_PB_DialingRules );
  2441. ASSERT( pInfo->hwndPbDialingRules );
  2442. }
  2443. if (pArgs->fMultipleDevices)
  2444. {
  2445. // Set the shared phone number checkbox.
  2446. //
  2447. Button_SetCheck(
  2448. pInfo->hwndCbSharedPhoneNumbers, pEntry->fSharedPhoneNumbers );
  2449. // Load the icons into the move up and move down buttons. From
  2450. // what I can tell tell in MSDN, you don't have to close or
  2451. // destroy the icon handle.
  2452. //
  2453. pInfo->hiconUpArr = LoadImage(
  2454. g_hinstDll, MAKEINTRESOURCE( IID_UpArr ), IMAGE_ICON, 0, 0, 0 );
  2455. pInfo->hiconDnArr = LoadImage(
  2456. g_hinstDll, MAKEINTRESOURCE( IID_DnArr ), IMAGE_ICON, 0, 0, 0 );
  2457. pInfo->hiconUpArrDis = LoadImage(
  2458. g_hinstDll, MAKEINTRESOURCE( IID_UpArrDis ), IMAGE_ICON, 0, 0, 0 );
  2459. pInfo->hiconDnArrDis = LoadImage(
  2460. g_hinstDll, MAKEINTRESOURCE( IID_DnArrDis ), IMAGE_ICON, 0, 0, 0 );
  2461. }
  2462. pInfo->pListAreaCodes = DtlDuplicateList(
  2463. pInfo->pArgs->pUser->pdtllistAreaCodes,
  2464. DuplicatePszNode, DestroyPszNode );
  2465. CuInit( &pInfo->cuinfo,
  2466. pInfo->hwndStAreaCodes, pInfo->hwndClbAreaCodes,
  2467. pInfo->hwndStPhoneNumber, pInfo->hwndEbPhoneNumber,
  2468. pInfo->hwndStCountryCodes, pInfo->hwndLbCountryCodes,
  2469. pInfo->hwndCbUseDialingRules, pInfo->hwndPbDialingRules,
  2470. pInfo->hwndPbAlternates,
  2471. NULL, NULL,
  2472. pInfo->pListAreaCodes );
  2473. pInfo->fCuInfoInitialized = TRUE;
  2474. // Configure and populate the device list, selecting the first item.
  2475. //
  2476. GeInitLvDevices( pInfo );
  2477. GeFillLvDevices( pInfo );
  2478. // Set initial focus.
  2479. //
  2480. if (pArgs->fMultipleDevices)
  2481. {
  2482. SetFocus( pInfo->hwndLvDevices );
  2483. }
  2484. else
  2485. {
  2486. ASSERT( IsWindowEnabled( pInfo->hwndEbPhoneNumber ) );
  2487. SetFocus( pInfo->hwndEbPhoneNumber );
  2488. Edit_SetSel( pInfo->hwndEbPhoneNumber, 0, -1 );
  2489. }
  2490. return FALSE;
  2491. }
  2492. else
  2493. {
  2494. ASSERT( pEntry->dwType == RASET_Direct );
  2495. // The listview has a different control-ID in single mode so that
  2496. // a different help context can be provided.
  2497. //
  2498. pInfo->hwndLbDevices =
  2499. GetDlgItem( hwndPage, CID_GE_LB_Devices );
  2500. ASSERT( pInfo->hwndLbDevices );
  2501. // Configure and populate the device list, selecting the first item.
  2502. //
  2503. GeFillLbDevices( pInfo );
  2504. }
  2505. return TRUE;
  2506. }
  2507. LVXDRAWINFO*
  2508. GeLvDevicesCallbackMultiple(
  2509. IN HWND hwndLv,
  2510. IN DWORD dwItem )
  2511. // Enhanced list view callback to report drawing information. 'HwndLv' is
  2512. // the handle of the list view control. 'DwItem' is the index of the item
  2513. // being drawn.
  2514. //
  2515. // Returns the address of the draw information.
  2516. //
  2517. {
  2518. // Use "full row select" and other recommended options.
  2519. //
  2520. // Fields are 'nCols', 'dxIndent', 'dwFlags', 'adwFlags[]'.
  2521. //
  2522. static LVXDRAWINFO info = { 1, 0, 0, { 0 } };
  2523. return &info;
  2524. }
  2525. LVXDRAWINFO*
  2526. GeLvDevicesCallbackSingle(
  2527. IN HWND hwndLv,
  2528. IN DWORD dwItem )
  2529. // Enhanced list view callback to report drawing information. 'HwndLv' is
  2530. // the handle of the list view control. 'DwItem' is the index of the item
  2531. // being drawn.
  2532. //
  2533. // Returns the address of the draw information.
  2534. //
  2535. {
  2536. // Set up to emulate a static text control but with icon on left.
  2537. //
  2538. // Fields are 'nCols', 'dxIndent', 'dwFlags', 'adwFlags[]'.
  2539. //
  2540. static LVXDRAWINFO info = { 1, 0, LVXDI_DxFill, { LVXDIA_Static } };
  2541. return &info;
  2542. }
  2543. VOID
  2544. GeMoveDevice(
  2545. IN PEINFO* pInfo,
  2546. IN BOOL fUp )
  2547. // Refill the ListView of devices with the selected item moved up or down
  2548. // one position. 'FUp' is set to move up, otherwise moves down. 'PInfo'
  2549. // is the property sheeet context.
  2550. //
  2551. {
  2552. DTLNODE* pNode;
  2553. DTLNODE* pPrevNode;
  2554. DTLNODE* pNextNode;
  2555. DTLLIST* pList;
  2556. if (pInfo->iDeviceSelected < 0)
  2557. {
  2558. return;
  2559. }
  2560. pNode =
  2561. (DTLNODE* )ListView_GetParamPtr(
  2562. pInfo->hwndLvDevices, pInfo->iDeviceSelected );
  2563. ASSERT( pNode );
  2564. if(NULL == pNode)
  2565. {
  2566. return;
  2567. }
  2568. pList = pInfo->pArgs->pEntry->pdtllistLinks;
  2569. if (fUp)
  2570. {
  2571. pPrevNode = DtlGetPrevNode( pNode );
  2572. if (!pPrevNode)
  2573. {
  2574. return;
  2575. }
  2576. DtlRemoveNode( pList, pNode );
  2577. DtlAddNodeBefore( pList, pPrevNode, pNode );
  2578. }
  2579. else
  2580. {
  2581. pNextNode = DtlGetNextNode( pNode );
  2582. if (!pNextNode)
  2583. {
  2584. return;
  2585. }
  2586. DtlRemoveNode( pList, pNode );
  2587. DtlAddNodeAfter( pList, pNextNode, pNode );
  2588. }
  2589. GeFillLvDevices( pInfo );
  2590. }
  2591. DWORD
  2592. GeSaveLvDeviceChecks(
  2593. IN PEINFO* pInfo )
  2594. // Mark links enabled/disabled based on it's check box in the ListView of
  2595. // devices. Returns the count of enabled devices.
  2596. //
  2597. {
  2598. DWORD dwCount = 0;
  2599. if (pInfo->pArgs->fMultipleDevices)
  2600. {
  2601. INT i;
  2602. i = -1;
  2603. while ((i = ListView_GetNextItem(
  2604. pInfo->hwndLvDevices, i, LVNI_ALL )) >= 0)
  2605. {
  2606. DTLNODE* pNode;
  2607. PBLINK* pLink;
  2608. pNode = (DTLNODE* )ListView_GetParamPtr( pInfo->hwndLvDevices, i );
  2609. ASSERT( pNode );
  2610. if(NULL == pNode)
  2611. {
  2612. return 0;
  2613. }
  2614. pLink = (PBLINK* )DtlGetData( pNode );
  2615. ASSERT( pLink );
  2616. pLink->fEnabled = ListView_GetCheck( pInfo->hwndLvDevices, i );
  2617. dwCount += (pLink->fEnabled) ? 1 : 0;
  2618. }
  2619. }
  2620. return dwCount;
  2621. }
  2622. VOID
  2623. GeSetPhoneFields(
  2624. IN PEINFO* pInfo,
  2625. IN DTLNODE* pSrcLinkNode,
  2626. IN BOOL fDisableAll )
  2627. // Set the phone number group box fields from the phone information in
  2628. // PBLINK node 'pSrcLinkNode'. 'PInfo' is the property sheet context.
  2629. //
  2630. {
  2631. PBLINK* pLink;
  2632. DTLNODE* pPhoneNode;
  2633. TRACE( "GeSetPhoneFields" );
  2634. pLink = (PBLINK* )DtlGetData( pSrcLinkNode );
  2635. ASSERT( pLink );
  2636. pPhoneNode = FirstPhoneNodeFromPhoneList( pLink->pdtllistPhones );
  2637. if (pPhoneNode)
  2638. {
  2639. CuSetInfo( &pInfo->cuinfo, pPhoneNode, fDisableAll );
  2640. DestroyPhoneNode( pPhoneNode );
  2641. }
  2642. }
  2643. VOID
  2644. GeUpdateDialAnotherFirstState(
  2645. IN PEINFO* pInfo )
  2646. // Update the prequisite entry controls. 'PInfo' is the property sheet
  2647. // context.
  2648. //
  2649. {
  2650. if (Button_GetCheck( pInfo->hwndCbDialAnotherFirst ))
  2651. {
  2652. GeFillLbDialAnotherFirst( pInfo, FALSE );
  2653. EnableWindow( pInfo->hwndLbDialAnotherFirst, TRUE );
  2654. }
  2655. else
  2656. {
  2657. GeClearLbDialAnotherFirst( pInfo->hwndLbDialAnotherFirst );
  2658. EnableWindow( pInfo->hwndLbDialAnotherFirst, FALSE );
  2659. }
  2660. }
  2661. VOID
  2662. GeUpdatePhoneNumberFields(
  2663. IN PEINFO* pInfo,
  2664. IN BOOL fSharedToggle )
  2665. // Called when anything affecting the Phone Number group of controls
  2666. // occurs. 'PInfo' is the property sheet context. 'FSharedToggle' is set
  2667. // when the update is due to the toggling of the shared phone number
  2668. // checkbox.
  2669. //
  2670. {
  2671. INT i;
  2672. BOOL fShared;
  2673. DTLNODE* pNode;
  2674. PBLINK* pLink;
  2675. TRACE( "GeUpdatePhoneNumberFields" );
  2676. if (pInfo->pArgs->fMultipleDevices)
  2677. {
  2678. fShared = Button_GetCheck( pInfo->hwndCbSharedPhoneNumbers );
  2679. }
  2680. else
  2681. {
  2682. fShared = TRUE;
  2683. ASSERT( !fSharedToggle );
  2684. }
  2685. if (pInfo->iDeviceSelected >= 0)
  2686. {
  2687. // A device was previously selected.
  2688. //
  2689. pNode = (DTLNODE* )ListView_GetParamPtr(
  2690. pInfo->hwndLvDevices, pInfo->iDeviceSelected );
  2691. ASSERT( pNode );
  2692. if(NULL == pNode)
  2693. {
  2694. return;
  2695. }
  2696. if (fShared)
  2697. {
  2698. if (fSharedToggle)
  2699. {
  2700. // Shared-mode just toggled on. Update the selected node from
  2701. // the controls, then copy it's phone settings to the shared
  2702. // node.
  2703. //
  2704. GeGetPhoneFields( pInfo, pNode );
  2705. CopyLinkPhoneNumberInfo( pInfo->pArgs->pSharedNode, pNode );
  2706. }
  2707. else
  2708. {
  2709. // Update the shared node from the controls.
  2710. //
  2711. GeGetPhoneFields( pInfo, pInfo->pArgs->pSharedNode );
  2712. }
  2713. }
  2714. else
  2715. {
  2716. if (fSharedToggle)
  2717. {
  2718. // Shared-mode just toggled off. Update the shared node from
  2719. // the controls, then copy it's phone settings to the selected
  2720. // node.
  2721. //
  2722. GeGetPhoneFields( pInfo, pInfo->pArgs->pSharedNode );
  2723. CopyLinkPhoneNumberInfo( pNode, pInfo->pArgs->pSharedNode );
  2724. }
  2725. else
  2726. {
  2727. // Update the previously selected node from the controls.
  2728. //
  2729. GeGetPhoneFields( pInfo, pNode );
  2730. }
  2731. }
  2732. }
  2733. // Load the phone number fields and title with the phone number for the
  2734. // selected link. Save the selected device index in the context block so
  2735. // we'll know where to swap out the phone number when the selection
  2736. // changes.
  2737. //
  2738. i = ListView_GetNextItem( pInfo->hwndLvDevices, -1, LVIS_SELECTED );
  2739. pInfo->iDeviceSelected = i;
  2740. if (i < 0)
  2741. {
  2742. // No device is currently selected. This occurs because a new
  2743. // selection generates first an "unselect" event, then a separate
  2744. // "select" event.
  2745. //
  2746. return;
  2747. }
  2748. // Set the phone number fields including group box title, all
  2749. // enabling/disabling, and "blanked" handling of area code and country
  2750. // code. The entire phone number group is disabled when in separate
  2751. // number mode with the selected device unchecked.
  2752. //
  2753. if (fShared)
  2754. {
  2755. pInfo->pCurLinkNode = pInfo->pArgs->pSharedNode;
  2756. GeUpdatePhoneNumberTitle( pInfo, NULL );
  2757. GeSetPhoneFields( pInfo, pInfo->pArgs->pSharedNode, FALSE );
  2758. }
  2759. else
  2760. {
  2761. pNode = (DTLNODE* )ListView_GetParamPtr( pInfo->hwndLvDevices, i );
  2762. ASSERT( pNode );
  2763. if(NULL == pNode)
  2764. {
  2765. return;
  2766. }
  2767. pLink = (PBLINK* )DtlGetData( pNode );
  2768. ASSERT( pLink );
  2769. if(NULL == pLink)
  2770. {
  2771. return;
  2772. }
  2773. pInfo->pCurLinkNode = pNode;
  2774. GeUpdatePhoneNumberTitle( pInfo, pLink->pbport.pszDevice );
  2775. GeSetPhoneFields( pInfo, pNode,
  2776. !(ListView_GetCheck( pInfo->hwndLvDevices, i )) );
  2777. }
  2778. // When the enabled device count falls below 2 the "Multiple Devices"
  2779. // group box and contained controls on the Options page are disabled. If
  2780. // 2 or above it is enabled.
  2781. //
  2782. if (pInfo->hwndOe && pInfo->pArgs->fMultipleDevices)
  2783. {
  2784. DWORD cChecked;
  2785. cChecked = ListView_GetCheckedCount( pInfo->hwndLvDevices );
  2786. OeEnableMultipleDeviceGroup( pInfo, (cChecked > 1) );
  2787. }
  2788. }
  2789. VOID
  2790. GeUpdatePhoneNumberTitle(
  2791. IN PEINFO* pInfo,
  2792. IN TCHAR* pszDevice )
  2793. // Update the Phone Number group box title based on the "share" mode.
  2794. // 'PInfo' is the property sheet context. 'PszDevice' is the device name
  2795. // string to display in non-shared mode or NULL in shared mode.
  2796. //
  2797. {
  2798. if (!pInfo->hwndGbPhoneNumber)
  2799. {
  2800. return;
  2801. }
  2802. if (pszDevice)
  2803. {
  2804. TCHAR* psz;
  2805. TCHAR* pszFormat;
  2806. // Set the individual title, e.g. "Phone number for K-Tel 28.8
  2807. // Fax/Plus".
  2808. //
  2809. pszFormat = PszFromId( g_hinstDll, SID_LinkPhoneNumber );
  2810. if (pszFormat)
  2811. {
  2812. psz = Malloc(
  2813. (lstrlen( pszFormat ) + lstrlen( pszDevice ))
  2814. * sizeof(TCHAR) );
  2815. if (psz)
  2816. {
  2817. wsprintf( psz, pszFormat, pszDevice );
  2818. SetWindowText( pInfo->hwndGbPhoneNumber, psz );
  2819. Free( psz );
  2820. }
  2821. Free( pszFormat );
  2822. }
  2823. }
  2824. else
  2825. {
  2826. TCHAR* psz;
  2827. // Set the shared title, e.g. "Phone number".
  2828. //
  2829. psz = PszFromId( g_hinstDll, SID_SharedPhoneNumber );
  2830. if (psz)
  2831. {
  2832. SetWindowText( pInfo->hwndGbPhoneNumber, psz );
  2833. Free( psz );
  2834. }
  2835. }
  2836. }
  2837. VOID
  2838. GeUpdateUpDownButtons(
  2839. IN PEINFO* pInfo )
  2840. // Update the enable/disable and corresponding icon for the
  2841. // move-up/move-down buttons. Moves focus and default button as
  2842. // necessary. 'PInfo' is the property sheet context.
  2843. //
  2844. {
  2845. INT iSel;
  2846. INT cItems;
  2847. BOOL fSel;
  2848. if (!pInfo->pArgs->fMultipleDevices)
  2849. {
  2850. return;
  2851. }
  2852. iSel = ListView_GetNextItem( pInfo->hwndLvDevices, -1, LVNI_SELECTED );
  2853. fSel = (iSel >= 0);
  2854. cItems = ListView_GetItemCount( pInfo->hwndLvDevices );
  2855. // "Up" button, enabled if there is an item above.
  2856. //
  2857. if (iSel > 0)
  2858. {
  2859. EnableWindow( pInfo->hwndPbUp, TRUE );
  2860. SendMessage( pInfo->hwndPbUp, BM_SETIMAGE, IMAGE_ICON,
  2861. (LPARAM )pInfo->hiconUpArr );
  2862. }
  2863. else
  2864. {
  2865. EnableWindow( pInfo->hwndPbUp, FALSE );
  2866. SendMessage( pInfo->hwndPbUp, BM_SETIMAGE, IMAGE_ICON,
  2867. (LPARAM )pInfo->hiconUpArrDis );
  2868. }
  2869. // "Down" button, enabled if there is an item below.
  2870. //
  2871. if (fSel && (iSel < cItems - 1))
  2872. {
  2873. EnableWindow( pInfo->hwndPbDown, TRUE );
  2874. SendMessage( pInfo->hwndPbDown, BM_SETIMAGE, IMAGE_ICON,
  2875. (LPARAM )pInfo->hiconDnArr );
  2876. }
  2877. else
  2878. {
  2879. EnableWindow( pInfo->hwndPbDown, FALSE );
  2880. SendMessage( pInfo->hwndPbDown, BM_SETIMAGE, IMAGE_ICON,
  2881. (LPARAM )pInfo->hiconDnArrDis );
  2882. }
  2883. // if the focus button is disabled, move focus to the ListView and make OK
  2884. // the default button.
  2885. //
  2886. if (!IsWindowEnabled( GetFocus() ))
  2887. {
  2888. SetFocus( pInfo->hwndLvDevices );
  2889. Button_MakeDefault( pInfo->hwndDlg,
  2890. GetDlgItem( pInfo->hwndDlg, IDOK ) );
  2891. }
  2892. }
  2893. //----------------------------------------------------------------------------
  2894. // Options property page
  2895. // Listed alphabetically following dialog proc
  2896. //----------------------------------------------------------------------------
  2897. INT_PTR CALLBACK
  2898. OeDlgProc(
  2899. IN HWND hwnd,
  2900. IN UINT unMsg,
  2901. IN WPARAM wparam,
  2902. IN LPARAM lparam )
  2903. // DialogProc callback for the Options page of the Entry property sheet.
  2904. // Parameters and return value are as described for standard windows
  2905. // 'DialogProc's.
  2906. //
  2907. {
  2908. #if 0
  2909. TRACE4( "OeDlgProc(h=$%x,m=$%x,w=$%x,l=$%x)",
  2910. (DWORD )hwnd, (DWORD )unMsg, (DWORD )wparam, (DWORD )lparam );
  2911. #endif
  2912. switch (unMsg)
  2913. {
  2914. case WM_INITDIALOG:
  2915. {
  2916. return OeInit( hwnd );
  2917. }
  2918. case WM_HELP:
  2919. case WM_CONTEXTMENU:
  2920. {
  2921. PEINFO* pInfo = PeContext( hwnd );
  2922. ASSERT(pInfo);
  2923. if (pInfo == NULL)
  2924. {
  2925. break;
  2926. }
  2927. if (pInfo->pArgs->fRouter)
  2928. {
  2929. ContextHelp( g_adwOeRouterHelp, hwnd, unMsg, wparam, lparam );
  2930. }
  2931. else
  2932. {
  2933. ContextHelp( g_adwOeHelp, hwnd, unMsg, wparam, lparam );
  2934. }
  2935. break;
  2936. }
  2937. case WM_COMMAND:
  2938. {
  2939. PEINFO* pInfo = PeContext( hwnd );
  2940. ASSERT(pInfo);
  2941. if (pInfo == NULL)
  2942. {
  2943. break;
  2944. }
  2945. return OeCommand(
  2946. pInfo, HIWORD( wparam ), LOWORD( wparam ),(HWND )lparam );
  2947. }
  2948. case WM_NOTIFY:
  2949. {
  2950. PEINFO* pInfo = PeContext( hwnd );
  2951. ASSERT(pInfo);
  2952. if (pInfo == NULL)
  2953. {
  2954. break;
  2955. }
  2956. switch (((NMHDR* )lparam)->code)
  2957. {
  2958. case PSN_SETACTIVE:
  2959. {
  2960. // Because of inter-page dependencies on the 'fAutoLogon'
  2961. // flag the User/password and subordinate checkbox states
  2962. // must be reinitialized at each activation.
  2963. //
  2964. OeUpdateUserPwState( pInfo );
  2965. break;
  2966. }
  2967. }
  2968. break;
  2969. }
  2970. }
  2971. return FALSE;
  2972. }
  2973. BOOL
  2974. OeCommand(
  2975. IN PEINFO* pInfo,
  2976. IN WORD wNotification,
  2977. IN WORD wId,
  2978. IN HWND hwndCtrl )
  2979. // Called on WM_COMMAND. 'PInfo' is the dialog context. 'WNotification'
  2980. // is the notification code of the command. 'wId' is the control/menu
  2981. // identifier of the command. 'HwndCtrl' is the control window handle of
  2982. // the command.
  2983. //
  2984. // Returns true if processed message, false otherwise.
  2985. //
  2986. {
  2987. TRACE3( "OeCommand(n=%d,i=%d,c=$%x)",
  2988. (DWORD )wNotification, (DWORD )wId, (ULONG_PTR )hwndCtrl );
  2989. switch (wId)
  2990. {
  2991. case CID_OE_CB_PreviewUserPw:
  2992. {
  2993. pInfo->pArgs->pEntry->fPreviewUserPw =
  2994. Button_GetCheck( pInfo->hwndCbPreviewUserPw );
  2995. OeUpdateUserPwState( pInfo );
  2996. return TRUE;
  2997. }
  2998. case CID_OE_CB_PreviewDomain:
  2999. {
  3000. pInfo->pArgs->pEntry->fPreviewDomain =
  3001. Button_GetCheck( pInfo->hwndCbPreviewDomain );
  3002. return TRUE;
  3003. }
  3004. case CID_OE_PB_Configure:
  3005. {
  3006. MultiLinkDialingDlg( pInfo->hwndDlg, pInfo->pArgs->pEntry );
  3007. return TRUE;
  3008. }
  3009. case CID_OE_PB_X25:
  3010. {
  3011. OeX25( pInfo );
  3012. return TRUE;
  3013. }
  3014. case CID_OE_PB_Tunnel:
  3015. {
  3016. OeTunnel( pInfo );
  3017. return TRUE;
  3018. }
  3019. case CID_OE_LB_MultipleDevices:
  3020. {
  3021. pInfo->pArgs->pEntry->dwDialMode =
  3022. (DWORD)ComboBox_GetItemData( pInfo->hwndLbMultipleDevices,
  3023. ComboBox_GetCurSel( pInfo->hwndLbMultipleDevices ) );
  3024. EnableWindow( pInfo->hwndPbConfigureDialing,
  3025. !!(pInfo->pArgs->pEntry->dwDialMode == RASEDM_DialAsNeeded) );
  3026. return TRUE;
  3027. }
  3028. case CID_OE_RB_Persistent:
  3029. {
  3030. switch (wNotification)
  3031. {
  3032. case BN_CLICKED:
  3033. {
  3034. ComboBox_SetCurSel( pInfo->hwndLbIdleTimes, 0 );
  3035. EnableWindow( pInfo->hwndLbIdleTimes, FALSE );
  3036. return TRUE;
  3037. }
  3038. }
  3039. break;
  3040. }
  3041. case CID_OE_RB_DemandDial:
  3042. {
  3043. switch (wNotification)
  3044. {
  3045. case BN_CLICKED:
  3046. {
  3047. EnableWindow( pInfo->hwndLbIdleTimes, TRUE );
  3048. return TRUE;
  3049. }
  3050. }
  3051. break;
  3052. }
  3053. case CID_OE_PB_Callback:
  3054. {
  3055. RouterCallbackDlg ( pInfo->hwndOe, pInfo->pArgs );
  3056. return TRUE;
  3057. }
  3058. }
  3059. return FALSE;
  3060. }
  3061. VOID
  3062. OeEnableMultipleDeviceGroup(
  3063. IN PEINFO* pInfo,
  3064. IN BOOL fEnable )
  3065. // Enable/disable the Multiple Devices groupbox and all controls it
  3066. // contains based on 'fEnable'. 'PInfo' is the property sheet context.
  3067. //
  3068. {
  3069. EnableWindow( pInfo->hwndGbMultipleDevices, fEnable );
  3070. EnableWindow( pInfo->hwndLbMultipleDevices, fEnable );
  3071. EnableWindow( pInfo->hwndPbConfigureDialing,
  3072. (fEnable
  3073. && !!(pInfo->pArgs->pEntry->dwDialMode == RASEDM_DialAsNeeded)) );
  3074. }
  3075. BOOL
  3076. OeInit(
  3077. IN HWND hwndPage )
  3078. // Called on WM_INITDIALOG. 'hwndPage' is the handle of the property
  3079. // page.
  3080. //
  3081. // Return false if focus was set, true otherwise.
  3082. //
  3083. {
  3084. PEINFO* pInfo;
  3085. PBENTRY* pEntry;
  3086. LBTABLEITEM* pItem;
  3087. HWND hwndLb;
  3088. INT i;
  3089. INT iSel;
  3090. HWND hwndUdRedialAttempts;
  3091. static LBTABLEITEM aRedialTimes[] =
  3092. {
  3093. SID_Time1s, 1,
  3094. SID_Time3s, 3,
  3095. SID_Time5s, 5,
  3096. SID_Time10s, 10,
  3097. SID_Time30s, 30,
  3098. SID_Time1m, 60,
  3099. SID_Time2m, 120,
  3100. SID_Time5m, 300,
  3101. SID_Time10m, RAS_RedialPause10m,
  3102. 0, 0
  3103. };
  3104. static LBTABLEITEM aIdleTimes[] =
  3105. {
  3106. SID_TimeNever, 0,
  3107. SID_Time1m, 60,
  3108. SID_Time5m, 300,
  3109. SID_Time10m, 600,
  3110. SID_Time20m, 1200, //Add for whistler bug 307969
  3111. SID_Time30m, 1800,
  3112. SID_Time1h, 3600,
  3113. SID_Time2h, 7200,
  3114. SID_Time4h, 14400,
  3115. SID_Time8h, 28800,
  3116. SID_Time24h, 86400,
  3117. 0, 0
  3118. };
  3119. static LBTABLEITEM aMultipleDeviceOptions[] =
  3120. {
  3121. SID_DialOnlyFirst, 0,
  3122. SID_DialAll, RASEDM_DialAll,
  3123. SID_DialNeeded, RASEDM_DialAsNeeded,
  3124. 0, 0
  3125. };
  3126. TRACE( "OeInit" );
  3127. pInfo = PeContext( hwndPage );
  3128. if (!pInfo)
  3129. {
  3130. return TRUE;
  3131. }
  3132. pEntry = pInfo->pArgs->pEntry;
  3133. // Initialize page-specific context information.
  3134. //
  3135. pInfo->hwndOe = hwndPage;
  3136. // Initialize 'Dialing options' group box.
  3137. //
  3138. if (!pInfo->pArgs->fRouter)
  3139. {
  3140. pInfo->hwndCbDisplayProgress =
  3141. GetDlgItem( hwndPage, CID_OE_CB_DisplayProgress );
  3142. ASSERT( pInfo->hwndCbDisplayProgress );
  3143. Button_SetCheck(
  3144. pInfo->hwndCbDisplayProgress, pEntry->fShowDialingProgress );
  3145. pInfo->hwndCbPreviewUserPw =
  3146. GetDlgItem( hwndPage, CID_OE_CB_PreviewUserPw );
  3147. ASSERT( pInfo->hwndCbPreviewUserPw );
  3148. pInfo->fPreviewUserPw = pEntry->fPreviewUserPw;
  3149. Button_SetCheck( pInfo->hwndCbPreviewUserPw, pInfo->fPreviewUserPw );
  3150. pInfo->hwndCbPreviewDomain =
  3151. GetDlgItem( hwndPage, CID_OE_CB_PreviewDomain );
  3152. ASSERT( pInfo->hwndCbPreviewDomain );
  3153. pInfo->fPreviewDomain = pEntry->fPreviewDomain;
  3154. Button_SetCheck( pInfo->hwndCbPreviewDomain, pInfo->fPreviewDomain );
  3155. if (pEntry->dwType == RASET_Phone)
  3156. {
  3157. pInfo->hwndCbPreviewNumber =
  3158. GetDlgItem( hwndPage, CID_OE_CB_PreviewNumber );
  3159. ASSERT( pInfo->hwndCbPreviewNumber );
  3160. Button_SetCheck(
  3161. pInfo->hwndCbPreviewNumber, pEntry->fPreviewPhoneNumber );
  3162. }
  3163. }
  3164. // Initialize 'Redialing options' group box. In the 'fRouter' case this
  3165. // includes both the 'Dialing policy' and 'Connection type' group boxes.
  3166. //
  3167. {
  3168. pInfo->hwndEbRedialAttempts =
  3169. GetDlgItem( hwndPage, CID_OE_EB_RedialAttempts );
  3170. ASSERT( pInfo->hwndEbRedialAttempts );
  3171. // Redial attempts. Note that the RAS API and phonebook allow redials
  3172. // up to RAS_MaxRedialCount (999999999). However, it was decided this
  3173. // many redials didn't make sense. Thus we have limited the UI to a max
  3174. // of MAX_UI_REDIAL_ATTEMPTS (99) redials even though through the API
  3175. // or an upgraded phonebook entry may have more.
  3176. //
  3177. hwndUdRedialAttempts = CreateUpDownControl(
  3178. WS_CHILD + WS_VISIBLE + WS_BORDER + UDS_SETBUDDYINT
  3179. + UDS_ALIGNRIGHT + UDS_NOTHOUSANDS + UDS_ARROWKEYS,
  3180. 0, 0, 0, 0, hwndPage, 100, g_hinstDll, pInfo->hwndEbRedialAttempts,
  3181. MAX_UI_REDIAL_ATTEMPTS, 0, 0 );
  3182. ASSERT( hwndUdRedialAttempts );
  3183. Edit_LimitText( pInfo->hwndEbRedialAttempts, MAX_UI_REDIAL_CHARS );
  3184. SetDlgItemInt( hwndPage, CID_OE_EB_RedialAttempts,
  3185. pEntry->dwRedialAttempts, FALSE );
  3186. // Redial times.
  3187. //
  3188. pInfo->hwndLbRedialTimes =
  3189. GetDlgItem( hwndPage, CID_OE_LB_RedialTimes );
  3190. ASSERT( pInfo->hwndLbRedialTimes );
  3191. {
  3192. iSel = -1;
  3193. for (pItem = aRedialTimes, i = 0;
  3194. pItem->sidItem;
  3195. ++pItem, ++i )
  3196. {
  3197. ComboBox_AddItemFromId( g_hinstDll, pInfo->hwndLbRedialTimes,
  3198. pItem->sidItem, (VOID* )UlongToPtr(pItem->dwData ));
  3199. if (iSel < 0
  3200. && pEntry->dwRedialSeconds <= pItem->dwData)
  3201. {
  3202. iSel = i;
  3203. ComboBox_SetCurSel( pInfo->hwndLbRedialTimes, iSel );
  3204. }
  3205. }
  3206. if (iSel < 0)
  3207. {
  3208. ComboBox_SetCurSel( pInfo->hwndLbRedialTimes, i - 1 );
  3209. }
  3210. }
  3211. // Idle times.
  3212. //
  3213. pInfo->hwndLbIdleTimes =
  3214. GetDlgItem( hwndPage, CID_OE_LB_IdleTimes );
  3215. ASSERT( pInfo->hwndLbIdleTimes );
  3216. {
  3217. if (pEntry->lIdleDisconnectSeconds < 0)
  3218. {
  3219. pEntry->lIdleDisconnectSeconds = 0;
  3220. }
  3221. iSel = -1;
  3222. for (pItem = aIdleTimes, i = 0;
  3223. pItem->sidItem;
  3224. ++pItem, ++i )
  3225. {
  3226. ComboBox_AddItemFromId( g_hinstDll, pInfo->hwndLbIdleTimes,
  3227. pItem->sidItem, (VOID* )UlongToPtr(pItem->dwData));
  3228. if (iSel < 0
  3229. && pEntry->lIdleDisconnectSeconds <= (LONG )pItem->dwData)
  3230. {
  3231. iSel = i;
  3232. ComboBox_SetCurSel( pInfo->hwndLbIdleTimes, iSel );
  3233. }
  3234. }
  3235. if (iSel < 0)
  3236. {
  3237. ComboBox_SetCurSel( pInfo->hwndLbIdleTimes, i - 1 );
  3238. }
  3239. }
  3240. if (pInfo->pArgs->fRouter)
  3241. {
  3242. HWND hwndRb;
  3243. //for whistler bug 294271, initialize the window handlers for
  3244. //multiple device group gangz
  3245. //
  3246. pInfo->hwndGbMultipleDevices =
  3247. GetDlgItem( hwndPage, CID_OE_GB_MultipleDevices );
  3248. ASSERT( pInfo->hwndGbMultipleDevices );
  3249. pInfo->hwndLbMultipleDevices =
  3250. GetDlgItem( hwndPage, CID_OE_LB_MultipleDevices );
  3251. ASSERT( pInfo->hwndLbMultipleDevices );
  3252. pInfo->hwndPbConfigureDialing =
  3253. GetDlgItem( hwndPage, CID_OE_PB_Configure );
  3254. ASSERT( pInfo->hwndPbConfigureDialing );
  3255. // Connection type radio buttons.
  3256. //
  3257. pInfo->hwndRbDemandDial =
  3258. GetDlgItem( hwndPage, CID_OE_RB_DemandDial );
  3259. ASSERT( pInfo->hwndRbDemandDial );
  3260. pInfo->hwndRbPersistent =
  3261. GetDlgItem( hwndPage, CID_OE_RB_Persistent );
  3262. ASSERT( pInfo->hwndRbPersistent );
  3263. hwndRb =
  3264. (pEntry->fRedialOnLinkFailure)
  3265. ? pInfo->hwndRbPersistent
  3266. : pInfo->hwndRbDemandDial;
  3267. SendMessage( hwndRb, BM_CLICK, 0, 0 );
  3268. }
  3269. else
  3270. {
  3271. // Redial on link failure
  3272. //
  3273. pInfo->hwndCbRedialOnDrop =
  3274. GetDlgItem( hwndPage, CID_OE_CB_RedialOnDrop );
  3275. ASSERT( pInfo->hwndCbRedialOnDrop );
  3276. Button_SetCheck(
  3277. pInfo->hwndCbRedialOnDrop, pEntry->fRedialOnLinkFailure );
  3278. }
  3279. }
  3280. // Initialize 'Multiple devices' group box.
  3281. //
  3282. if (pEntry->dwType == RASET_Phone)
  3283. {
  3284. pInfo->hwndGbMultipleDevices =
  3285. GetDlgItem( hwndPage, CID_OE_GB_MultipleDevices );
  3286. ASSERT( pInfo->hwndGbMultipleDevices );
  3287. pInfo->hwndLbMultipleDevices =
  3288. GetDlgItem( hwndPage, CID_OE_LB_MultipleDevices );
  3289. ASSERT( pInfo->hwndLbMultipleDevices );
  3290. pInfo->hwndPbConfigureDialing =
  3291. GetDlgItem( hwndPage, CID_OE_PB_Configure );
  3292. ASSERT( pInfo->hwndPbConfigureDialing );
  3293. {
  3294. iSel = -1;
  3295. for (pItem = aMultipleDeviceOptions, i = 0;
  3296. pItem->sidItem;
  3297. ++pItem, ++i )
  3298. {
  3299. ComboBox_AddItemFromId(
  3300. g_hinstDll, pInfo->hwndLbMultipleDevices,
  3301. pItem->sidItem, (VOID* )UlongToPtr(pItem->dwData));
  3302. if (pEntry->dwDialMode == pItem->dwData)
  3303. {
  3304. iSel = i;
  3305. ComboBox_SetCurSel( pInfo->hwndLbMultipleDevices, iSel );
  3306. }
  3307. }
  3308. if (iSel < 0)
  3309. {
  3310. ComboBox_SetCurSel( pInfo->hwndLbMultipleDevices, 0 );
  3311. }
  3312. }
  3313. if (pInfo->pArgs->fMultipleDevices)
  3314. {
  3315. DWORD cChecked;
  3316. // When the enabled device count falls below 2 the "Multiple
  3317. // Devices" group box and contained controls are disabled. If 2
  3318. // or above it is enabled.
  3319. //
  3320. if (pInfo->hwndLvDevices)
  3321. {
  3322. cChecked = ListView_GetCheckedCount( pInfo->hwndLvDevices );
  3323. OeEnableMultipleDeviceGroup( pInfo, (cChecked > 1) );
  3324. }
  3325. }
  3326. else
  3327. {
  3328. ShowWindow( pInfo->hwndGbMultipleDevices, SW_HIDE );
  3329. ShowWindow( pInfo->hwndLbMultipleDevices, SW_HIDE );
  3330. ShowWindow( pInfo->hwndPbConfigureDialing, SW_HIDE );
  3331. }
  3332. }
  3333. else if (pInfo->pArgs->fRouter && pEntry->dwType == RASET_Vpn)
  3334. {
  3335. // Make sure that a VPN demand dial interface can't be configured for
  3336. // multilink.
  3337. //
  3338. ComboBox_SetCurSel( pInfo->hwndLbMultipleDevices, 0 );
  3339. ShowWindow( pInfo->hwndGbMultipleDevices, SW_HIDE );
  3340. ShowWindow( pInfo->hwndLbMultipleDevices, SW_HIDE );
  3341. ShowWindow( pInfo->hwndPbConfigureDialing, SW_HIDE );
  3342. }
  3343. else if (pEntry->dwType == RASET_Broadband)
  3344. {
  3345. // Make sure that broadband connections can't be multilinked since
  3346. // it is not possible to select multiple ports.
  3347. //
  3348. ComboBox_SetCurSel( pInfo->hwndLbMultipleDevices, 0 );
  3349. ShowWindow( pInfo->hwndGbMultipleDevices, SW_HIDE );
  3350. ShowWindow( pInfo->hwndLbMultipleDevices, SW_HIDE );
  3351. ShowWindow( pInfo->hwndPbConfigureDialing, SW_HIDE );
  3352. }
  3353. else if ( pEntry->dwType == RASET_Direct )
  3354. {
  3355. //for whistler bug 294271, initialize the window handlers for
  3356. //multiple device group gangz
  3357. //
  3358. ShowWindow( pInfo->hwndGbMultipleDevices, SW_HIDE );
  3359. ShowWindow( pInfo->hwndLbMultipleDevices, SW_HIDE );
  3360. ShowWindow( pInfo->hwndPbConfigureDialing, SW_HIDE );
  3361. }
  3362. // Bug 261692: Don't show X.25 button unless "phone" type entry.
  3363. //
  3364. if (pInfo->pArgs->fRouter && pEntry->dwType != RASET_Phone)
  3365. {
  3366. pInfo->hwndPbX25 = GetDlgItem( hwndPage, CID_OE_PB_X25 );
  3367. ASSERT( pInfo->hwndPbX25 );
  3368. ShowWindow( pInfo->hwndPbX25, SW_HIDE );
  3369. EnableWindow( pInfo->hwndPbX25, FALSE );
  3370. }
  3371. return TRUE;
  3372. }
  3373. VOID
  3374. OeTunnel(
  3375. IN PEINFO* pInfo )
  3376. // Called when the "Virtual (tunnel) connection" button is pressed to
  3377. // chain the VPN add entry wizard.
  3378. //
  3379. {
  3380. //!!!
  3381. }
  3382. VOID
  3383. OeUpdateUserPwState(
  3384. IN PEINFO* pInfo )
  3385. // Called to update the enabled/disabled save/restore state of the
  3386. // User/password and Domain checkboxes.
  3387. //
  3388. {
  3389. PBENTRY* pEntry;
  3390. pEntry = pInfo->pArgs->pEntry;
  3391. EnableCbWithRestore(
  3392. pInfo->hwndCbPreviewUserPw,
  3393. !pEntry->fAutoLogon,
  3394. FALSE,
  3395. &pInfo->fPreviewUserPw );
  3396. EnableCbWithRestore(
  3397. pInfo->hwndCbPreviewDomain,
  3398. !pEntry->fAutoLogon,
  3399. FALSE,
  3400. &pInfo->fPreviewDomain );
  3401. }
  3402. VOID
  3403. OeX25(
  3404. IN PEINFO* pInfo )
  3405. // Called when the X.25 button is pressed to popup the X.25 settings
  3406. // dialog.
  3407. //
  3408. {
  3409. DTLNODE* pNode;
  3410. PBLINK* pLink;
  3411. BOOL fLocalPad;
  3412. INT iSel;
  3413. // Figure out if the selected device is a local PAD device.
  3414. //
  3415. fLocalPad = FALSE;
  3416. iSel = ListView_GetNextItem( pInfo->hwndLvDevices, -1, LVNI_SELECTED );
  3417. if (iSel >= 0)
  3418. {
  3419. pNode = (DTLNODE* )ListView_GetParamPtr( pInfo->hwndLvDevices, iSel );
  3420. ASSERT( pNode );
  3421. if(NULL == pNode)
  3422. {
  3423. return;
  3424. }
  3425. pLink = (PBLINK* )DtlGetData( pNode );
  3426. ASSERT( pLink );
  3427. if (pLink->pbport.pbdevicetype == PBDT_Pad)
  3428. {
  3429. fLocalPad = TRUE;
  3430. }
  3431. }
  3432. // Popup the X.25 dialog which saves directly to the common context
  3433. // 'pEntry' if user makes changes.
  3434. //
  3435. X25LogonSettingsDlg( pInfo->hwndDlg, fLocalPad, pInfo->pArgs->pEntry );
  3436. }
  3437. //----------------------------------------------------------------------------
  3438. // Security property page
  3439. // Listed alphabetically following dialog proc
  3440. //----------------------------------------------------------------------------
  3441. INT_PTR CALLBACK
  3442. LoDlgProc(
  3443. IN HWND hwnd,
  3444. IN UINT unMsg,
  3445. IN WPARAM wparam,
  3446. IN LPARAM lparam )
  3447. // DialogProc callback for the Security page of the Entry property sheet
  3448. // "Lo" is for Logon, the original name of this page. Parameters and
  3449. // return value are as described for standard windows 'DialogProc's.
  3450. //
  3451. {
  3452. #if 0
  3453. TRACE4( "LoDlgProc(h=$%x,m=$%x,w=$%x,l=$%x)",
  3454. (DWORD )hwnd, (DWORD )unMsg, (DWORD )wparam, (DWORD )lparam );
  3455. #endif
  3456. switch (unMsg)
  3457. {
  3458. case WM_INITDIALOG:
  3459. {
  3460. return LoInit( hwnd );
  3461. }
  3462. case WM_HELP:
  3463. case WM_CONTEXTMENU:
  3464. {
  3465. ContextHelp( g_adwLoHelp, hwnd, unMsg, wparam, lparam );
  3466. break;
  3467. }
  3468. case WM_COMMAND:
  3469. {
  3470. PEINFO* pInfo = PeContext( hwnd );
  3471. ASSERT(pInfo);
  3472. if (pInfo == NULL)
  3473. {
  3474. break;
  3475. }
  3476. return LoCommand(
  3477. pInfo, HIWORD( wparam ), LOWORD( wparam ),(HWND )lparam );
  3478. }
  3479. case WM_NOTIFY:
  3480. {
  3481. PEINFO* pInfo = PeContext( hwnd );
  3482. ASSERT(pInfo);
  3483. if (pInfo == NULL)
  3484. {
  3485. break;
  3486. }
  3487. switch (((NMHDR* )lparam)->code)
  3488. {
  3489. case PSN_SETACTIVE:
  3490. {
  3491. // Because of inter-page dependencies on the framing type,
  3492. // the typical and advanced sections must be reinitialized
  3493. // at each activation.
  3494. //
  3495. BOOL fEnabled;
  3496. //This is for pre-shared key bug
  3497. //
  3498. fEnabled = ( VS_PptpOnly != pInfo->pArgs->pEntry->dwVpnStrategy );
  3499. EnableWindow( pInfo->hwndPbIPSec, fEnabled );
  3500. pInfo->fAuthRbInitialized = FALSE;
  3501. LoRefreshSecuritySettings( pInfo );
  3502. break;
  3503. }
  3504. }
  3505. break;
  3506. }
  3507. }
  3508. return FALSE;
  3509. }
  3510. BOOL
  3511. LoCommand(
  3512. IN PEINFO* pInfo,
  3513. IN WORD wNotification,
  3514. IN WORD wId,
  3515. IN HWND hwndCtrl )
  3516. // Called on WM_COMMAND. 'PInfo' is the dialog context. 'WNotification'
  3517. // is the notification code of the command. 'wId' is the control/menu
  3518. // identifier of the command. 'HwndCtrl' is the control window handle of
  3519. // the command.
  3520. //
  3521. // Returns true if processed message, false otherwise.
  3522. //
  3523. {
  3524. TRACE3( "LoCommand(n=%d,i=%d,c=$%x)",
  3525. (DWORD )wNotification, (DWORD )wId, (ULONG_PTR )hwndCtrl );
  3526. switch (wId)
  3527. {
  3528. case CID_LO_LB_Auths:
  3529. {
  3530. switch (wNotification)
  3531. {
  3532. case CBN_SELCHANGE:
  3533. {
  3534. LoLbAuthsSelChange( pInfo );
  3535. return TRUE;
  3536. }
  3537. }
  3538. break;
  3539. }
  3540. case CID_LO_CB_UseWindowsPw:
  3541. {
  3542. switch (wNotification)
  3543. {
  3544. case BN_CLICKED:
  3545. {
  3546. // Necessary to save 'fAutoLogon' setting immediately as
  3547. // there is an inter-page dependency with the Option page
  3548. // 'fPreviewUserPw' and subordinate controls.
  3549. //
  3550. LoSaveTypicalAuthSettings( pInfo );
  3551. return TRUE;
  3552. }
  3553. }
  3554. break;
  3555. }
  3556. case CID_LO_RB_TypicalSecurity:
  3557. {
  3558. switch (wNotification)
  3559. {
  3560. case BN_CLICKED:
  3561. {
  3562. if (!pInfo->fAuthRbInitialized)
  3563. {
  3564. pInfo->fAuthRbInitialized = TRUE;
  3565. }
  3566. pInfo->pArgs->pEntry->dwAuthRestrictions
  3567. &= ~(AR_F_AuthCustom);
  3568. LoEnableSecuritySettings( pInfo, TRUE, FALSE );
  3569. return TRUE;
  3570. }
  3571. }
  3572. break;
  3573. }
  3574. case CID_LO_RB_AdvancedSecurity:
  3575. {
  3576. switch (wNotification)
  3577. {
  3578. case BN_CLICKED:
  3579. {
  3580. if (!pInfo->fAuthRbInitialized)
  3581. {
  3582. pInfo->fAuthRbInitialized = TRUE;
  3583. }
  3584. else
  3585. {
  3586. // Save the "typical" settings as they will be used as
  3587. // defaults should user decide to invoke the advanced
  3588. // security dialog.
  3589. //
  3590. LoSaveTypicalAuthSettings( pInfo );
  3591. }
  3592. pInfo->pArgs->pEntry->dwAuthRestrictions
  3593. |= AR_F_AuthCustom;
  3594. LoEnableSecuritySettings( pInfo, FALSE, TRUE );
  3595. return TRUE;
  3596. }
  3597. }
  3598. break;
  3599. }
  3600. case CID_LO_PB_Advanced:
  3601. {
  3602. switch (wNotification)
  3603. {
  3604. case BN_CLICKED:
  3605. {
  3606. // At this point, the 'pEntry' authentication settings
  3607. // match the current "typical" settings, which the
  3608. // advanced dialog uses as defaults.
  3609. //
  3610. AdvancedSecurityDlg( pInfo->hwndDlg, pInfo->pArgs );
  3611. return TRUE;
  3612. }
  3613. }
  3614. break;
  3615. }
  3616. case CID_LO_PB_IPSec:
  3617. {
  3618. switch (wNotification)
  3619. {
  3620. case BN_CLICKED:
  3621. {
  3622. IPSecPolicyDlg( pInfo->hwndDlg, pInfo->pArgs );
  3623. return TRUE;
  3624. }
  3625. }
  3626. break;
  3627. }
  3628. case CID_LO_CB_RunScript:
  3629. {
  3630. if (SuScriptsCbHandler( &pInfo->suinfo, wNotification ))
  3631. {
  3632. return TRUE;
  3633. }
  3634. break;
  3635. }
  3636. case CID_LO_PB_Edit:
  3637. {
  3638. if (SuEditPbHandler( &pInfo->suinfo, wNotification ))
  3639. {
  3640. return TRUE;
  3641. }
  3642. break;
  3643. }
  3644. case CID_LO_PB_Browse:
  3645. {
  3646. if (SuBrowsePbHandler( &pInfo->suinfo, wNotification ))
  3647. {
  3648. return TRUE;
  3649. }
  3650. break;
  3651. }
  3652. }
  3653. return FALSE;
  3654. }
  3655. VOID
  3656. LoEnableSecuritySettings(
  3657. IN PEINFO* pInfo,
  3658. IN BOOL fTypical,
  3659. IN BOOL fAdvanced )
  3660. // Enables/disables the typical or advanced security settings based on
  3661. // caller's 'fTypical' and 'fAdvanced' flags. If neither flag is set all
  3662. // controls including the frames and radio buttons are disabled. Both
  3663. // flags may not be set. 'PInfo' is the property sheet context.
  3664. //
  3665. {
  3666. BOOL fEither;
  3667. ASSERT( !(fTypical && fAdvanced) );
  3668. fEither = (fTypical || fAdvanced);
  3669. EnableWindow( pInfo->hwndGbSecurityOptions, fEither );
  3670. EnableWindow( pInfo->hwndRbTypicalSecurity, fEither );
  3671. EnableWindow( pInfo->hwndStAuths, fTypical );
  3672. EnableLbWithRestore( pInfo->hwndLbAuths, fTypical, &pInfo->iLbAuths );
  3673. // Note: "Use Windows password" and "require encryption" checkbox updates
  3674. // are triggered by the EnableLbWithRestore above.
  3675. EnableWindow( pInfo->hwndRbAdvancedSecurity, fEither );
  3676. EnableWindow( pInfo->hwndStAdvancedText, fAdvanced );
  3677. EnableWindow( pInfo->hwndPbAdvanced, fAdvanced );
  3678. }
  3679. VOID
  3680. LoFillLbAuths(
  3681. IN PEINFO* pInfo )
  3682. // Fill the authentication list box and set the selection based on the
  3683. // setting in the phonebook entry. 'PInfo' is the property sheet context.
  3684. // This routine should be called only once.
  3685. //
  3686. {
  3687. INT i;
  3688. LBTABLEITEM* pItem;
  3689. LBTABLEITEM* pItems;
  3690. PBENTRY* pEntry;
  3691. LBTABLEITEM aItemsPhone[] =
  3692. {
  3693. SID_AuthUnsecured, TA_Unsecure,
  3694. SID_AuthSecured, TA_Secure,
  3695. SID_AuthCardOrCert, TA_CardOrCert,
  3696. 0, 0
  3697. };
  3698. LBTABLEITEM aItemsVpn[] =
  3699. {
  3700. SID_AuthSecured, TA_Secure,
  3701. SID_AuthCardOrCert, TA_CardOrCert,
  3702. 0, 0
  3703. };
  3704. LBTABLEITEM aItemsPhoneRouter[] =
  3705. {
  3706. SID_AuthUnsecured, TA_Unsecure,
  3707. SID_AuthSecured, TA_Secure,
  3708. 0, 0
  3709. };
  3710. LBTABLEITEM aItemsVpnRouter[] =
  3711. {
  3712. SID_AuthSecured, TA_Secure,
  3713. 0, 0
  3714. };
  3715. pEntry = pInfo->pArgs->pEntry;
  3716. if (pEntry->dwType == RASET_Vpn)
  3717. {
  3718. pItems = (pInfo->pArgs->fRouter) ? aItemsVpnRouter : aItemsVpn;
  3719. }
  3720. else
  3721. {
  3722. pItems = (pInfo->pArgs->fRouter) ? aItemsPhoneRouter : aItemsPhone;
  3723. }
  3724. for (pItem = pItems; pItem->sidItem; ++pItem)
  3725. {
  3726. i = ComboBox_AddItemFromId(
  3727. g_hinstDll, pInfo->hwndLbAuths,
  3728. pItem->sidItem, (VOID* )UlongToPtr(pItem->dwData));
  3729. if (pEntry->dwTypicalAuth == pItem->dwData)
  3730. {
  3731. ComboBox_SetCurSelNotify( pInfo->hwndLbAuths, i );
  3732. }
  3733. }
  3734. if (ComboBox_GetCurSel( pInfo->hwndLbAuths ) < 0)
  3735. {
  3736. ComboBox_SetCurSelNotify( pInfo->hwndLbAuths, 0 );
  3737. }
  3738. }
  3739. BOOL
  3740. LoInit(
  3741. IN HWND hwndPage )
  3742. // Called on WM_INITDIALOG. 'hwndPage' is the handle of the property
  3743. // page.
  3744. //
  3745. // Return false if focus was set, true otherwise.
  3746. //
  3747. {
  3748. PEINFO* pInfo;
  3749. PBENTRY* pEntry;
  3750. TRACE( "LoInit" );
  3751. pInfo = PeContext( hwndPage );
  3752. if (!pInfo)
  3753. {
  3754. return TRUE;
  3755. }
  3756. pEntry = pInfo->pArgs->pEntry;
  3757. // Initialize page-specific context information.
  3758. //
  3759. pInfo->hwndLo = hwndPage;
  3760. pInfo->hwndGbSecurityOptions =
  3761. GetDlgItem( hwndPage, CID_LO_GB_SecurityOptions );
  3762. ASSERT( pInfo->hwndGbSecurityOptions );
  3763. pInfo->hwndRbTypicalSecurity =
  3764. GetDlgItem( hwndPage, CID_LO_RB_TypicalSecurity );
  3765. ASSERT( pInfo->hwndRbTypicalSecurity );
  3766. pInfo->hwndStAuths = GetDlgItem( hwndPage, CID_LO_ST_Auths );
  3767. ASSERT( pInfo->hwndStAuths );
  3768. pInfo->hwndLbAuths = GetDlgItem( hwndPage, CID_LO_LB_Auths );
  3769. ASSERT( pInfo->hwndLbAuths );
  3770. pInfo->hwndCbUseWindowsPw = GetDlgItem( hwndPage, CID_LO_CB_UseWindowsPw );
  3771. ASSERT( pInfo->hwndCbUseWindowsPw );
  3772. pInfo->hwndCbEncryption = GetDlgItem( hwndPage, CID_LO_CB_Encryption );
  3773. ASSERT( pInfo->hwndCbEncryption );
  3774. pInfo->hwndRbAdvancedSecurity =
  3775. GetDlgItem( hwndPage, CID_LO_RB_AdvancedSecurity );
  3776. ASSERT( pInfo->hwndRbAdvancedSecurity );
  3777. pInfo->hwndStAdvancedText = GetDlgItem( hwndPage, CID_LO_ST_AdvancedText );
  3778. ASSERT( pInfo->hwndStAdvancedText );
  3779. pInfo->hwndPbAdvanced = GetDlgItem( hwndPage, CID_LO_PB_Advanced );
  3780. ASSERT( pInfo->hwndPbAdvanced );
  3781. //
  3782. //for VPN's security page show IPSec Policy
  3783. // for whistler bug 193987
  3784. //
  3785. if ( pInfo->pArgs->pEntry->dwType == RASET_Vpn )
  3786. {
  3787. BOOL fEnabled;
  3788. pInfo->hwndPbIPSec = GetDlgItem( hwndPage, CID_LO_PB_IPSec );
  3789. ASSERT( pInfo->hwndPbIPSec );
  3790. // gangz
  3791. //If it is for a remote Win2k server's Demand Dialer
  3792. //dont show the IPSec Policy stuff, because W2k didnt
  3793. //implement this.
  3794. //
  3795. if ( pInfo->pArgs->fW2kRouter )
  3796. {
  3797. ShowWindow( pInfo->hwndPbIPSec, FALSE );
  3798. }
  3799. else
  3800. {
  3801. fEnabled = ( VS_PptpOnly != pInfo->pArgs->pEntry->dwVpnStrategy );
  3802. EnableWindow( pInfo->hwndPbIPSec, fEnabled );
  3803. }
  3804. //for the IPSec Policy dialog, fPSKCached = TRUE means the user already
  3805. //go to the IPSec Policy dialog and saved a PSK gangz
  3806. //
  3807. pInfo->pArgs->fPSKCached = FALSE;
  3808. //gangz: for bug# 276452
  3809. //On a Server OS, the help message for this IPSec pushbutton
  3810. //should be different from that for a Non-server OS,
  3811. //so change its help ID when neeeded.
  3812. //
  3813. if ( IsServerOS() )
  3814. {
  3815. DWORD * p = (DWORD *)g_adwLoHelp;
  3816. while( p )
  3817. {
  3818. if ( (p[0] == 0) && ( p[1] == 0 ) )
  3819. {
  3820. break;
  3821. }
  3822. if ( (p[0] == CID_LO_PB_IPSec) &&
  3823. (p[1] == HID_LO_PB_IPSec) )
  3824. {
  3825. p[1] = HID_LO_PB_IPSecServer;
  3826. break;
  3827. }
  3828. p+=2;
  3829. }
  3830. }
  3831. }
  3832. else
  3833. {
  3834. pInfo->hwndGbScripting = GetDlgItem( hwndPage, CID_LO_GB_Scripting );
  3835. ASSERT( pInfo->hwndGbScripting );
  3836. pInfo->hwndCbRunScript = GetDlgItem( hwndPage, CID_LO_CB_RunScript );
  3837. ASSERT( pInfo->hwndCbRunScript );
  3838. pInfo->hwndCbTerminal = GetDlgItem( hwndPage, CID_LO_CB_Terminal );
  3839. ASSERT( pInfo->hwndCbTerminal );
  3840. pInfo->hwndLbScripts = GetDlgItem( hwndPage, CID_LO_LB_Scripts );
  3841. ASSERT( pInfo->hwndLbScripts );
  3842. pInfo->hwndPbEdit = GetDlgItem( hwndPage, CID_LO_PB_Edit );
  3843. ASSERT( pInfo->hwndPbEdit );
  3844. pInfo->hwndPbBrowse = GetDlgItem( hwndPage, CID_LO_PB_Browse );
  3845. ASSERT( pInfo->hwndPbBrowse );
  3846. }
  3847. // Initialize the page controls. Note that the page activation event
  3848. // immediately after this initialization triggers the final security
  3849. // setting enabling/disabling and does any "restore caching". While this
  3850. // initialization sets the check values and list selection to bootstrap
  3851. // the "restore caching", these settings may be adjusted by the activation
  3852. // refresh.
  3853. //
  3854. if (pInfo->pArgs->fRouter)
  3855. {
  3856. // The "Use Windows credentials" option is removed in the demand-dial
  3857. // case.
  3858. //
  3859. pInfo->fUseWindowsPw = FALSE;
  3860. Button_SetCheck( pInfo->hwndCbUseWindowsPw, FALSE );
  3861. EnableWindow ( pInfo->hwndCbUseWindowsPw, FALSE );
  3862. ShowWindow (pInfo->hwndCbUseWindowsPw, SW_HIDE );
  3863. }
  3864. else
  3865. {
  3866. pInfo->fUseWindowsPw = pEntry->fAutoLogon;
  3867. Button_SetCheck( pInfo->hwndCbUseWindowsPw, pInfo->fUseWindowsPw );
  3868. }
  3869. pInfo->fEncryption =
  3870. (pEntry->dwDataEncryption != DE_None
  3871. && pEntry->dwDataEncryption != DE_IfPossible);
  3872. Button_SetCheck( pInfo->hwndCbEncryption, pInfo->fEncryption );
  3873. // Fill authentiction list and set selection, which triggers all
  3874. // appropriate enabling/disabling.
  3875. //
  3876. LoFillLbAuths( pInfo );
  3877. if ((pInfo->pArgs->pEntry->dwType != RASET_Vpn)
  3878. && (pInfo->pArgs->pEntry->dwType != RASET_Direct)
  3879. && (pInfo->pArgs->pEntry->dwType != RASET_Broadband))
  3880. //&& !pInfo->pArgs->fRouter)
  3881. {
  3882. // Set up the after-dial scripting controls.
  3883. //
  3884. SuInit( &pInfo->suinfo,
  3885. pInfo->hwndCbRunScript,
  3886. pInfo->hwndCbTerminal,
  3887. pInfo->hwndLbScripts,
  3888. pInfo->hwndPbEdit,
  3889. pInfo->hwndPbBrowse,
  3890. pInfo->pArgs->fRouter ? SU_F_DisableTerminal : 0);
  3891. pInfo->fSuInfoInitialized = TRUE;
  3892. SuSetInfo( &pInfo->suinfo,
  3893. pEntry->fScriptAfter,
  3894. pEntry->fScriptAfterTerminal,
  3895. pEntry->pszScriptAfter );
  3896. }
  3897. else
  3898. {
  3899. // Disable/hide the after-dial scripting controls.
  3900. // for VPN there is no need to do this Disable/hide operation
  3901. //
  3902. if (pInfo->pArgs->pEntry->dwType != RASET_Vpn)
  3903. {
  3904. EnableWindow( pInfo->hwndGbScripting, FALSE );
  3905. ShowWindow( pInfo->hwndGbScripting, SW_HIDE );
  3906. EnableWindow( pInfo->hwndCbRunScript, FALSE );
  3907. ShowWindow( pInfo->hwndCbRunScript, SW_HIDE );
  3908. EnableWindow( pInfo->hwndCbTerminal, FALSE );
  3909. ShowWindow( pInfo->hwndCbTerminal, SW_HIDE );
  3910. EnableWindow( pInfo->hwndLbScripts, FALSE );
  3911. ShowWindow( pInfo->hwndLbScripts, SW_HIDE );
  3912. EnableWindow( pInfo->hwndPbEdit, FALSE );
  3913. ShowWindow( pInfo->hwndPbEdit, SW_HIDE );
  3914. EnableWindow( pInfo->hwndPbBrowse, FALSE );
  3915. ShowWindow( pInfo->hwndPbBrowse, SW_HIDE );
  3916. }
  3917. }
  3918. if (pInfo->pArgs->fRouter)
  3919. {
  3920. EnableWindow( pInfo->hwndCbTerminal, FALSE );
  3921. ShowWindow( pInfo->hwndCbTerminal, SW_HIDE );
  3922. }
  3923. return TRUE;
  3924. }
  3925. VOID
  3926. LoLbAuthsSelChange(
  3927. IN PEINFO* pInfo )
  3928. // Called when the selection in the authentication drop list is changed.
  3929. //
  3930. {
  3931. INT iSel;
  3932. DWORD dwTaCode;
  3933. // Retrieve the bitmask of authentication protocols associated with the
  3934. // selected authentication level.
  3935. //
  3936. iSel = ComboBox_GetCurSel( pInfo->hwndLbAuths );
  3937. if (iSel < 0)
  3938. {
  3939. dwTaCode = 0;
  3940. }
  3941. else
  3942. {
  3943. dwTaCode = (DWORD )ComboBox_GetItemData( pInfo->hwndLbAuths, iSel );
  3944. }
  3945. if (!pInfo->pArgs->fRouter)
  3946. {
  3947. // Update the "Use Windows NT credentials" checkbox. Per the spec, it
  3948. // is enabled only for "require secure password", though the real
  3949. // requirement is that MSCHAP (provides NT-style credentials) gets
  3950. // negotiated.
  3951. //
  3952. EnableCbWithRestore(
  3953. pInfo->hwndCbUseWindowsPw,
  3954. (dwTaCode == TA_Secure),
  3955. FALSE,
  3956. &pInfo->fUseWindowsPw );
  3957. }
  3958. // Update the "Require data encryption" checkbox. Per the spec, it is
  3959. // enabled unless "allow unsecured password" is selected, though the real
  3960. // requirement is that all authentication protocols in the set provide
  3961. // MPPE encryption keys.
  3962. //
  3963. EnableCbWithRestore(
  3964. pInfo->hwndCbEncryption,
  3965. (dwTaCode != 0 && dwTaCode != TA_Unsecure),
  3966. FALSE,
  3967. &pInfo->fEncryption );
  3968. }
  3969. VOID
  3970. LoRefreshSecuritySettings(
  3971. IN PEINFO* pInfo )
  3972. // Sets the contents and state of all typical and advanced security
  3973. // setting fields.
  3974. //
  3975. {
  3976. if (pInfo->pArgs->pEntry->dwBaseProtocol & BP_Slip)
  3977. {
  3978. // For SLIP framing, all the typical and advanced controls are
  3979. // disabled and the radio buttons show no selection.
  3980. //
  3981. Button_SetCheck( pInfo->hwndRbTypicalSecurity, FALSE );
  3982. Button_SetCheck( pInfo->hwndRbAdvancedSecurity, FALSE );
  3983. LoEnableSecuritySettings( pInfo, FALSE, FALSE );
  3984. if (pInfo->fShowSlipPopup)
  3985. {
  3986. // Time to show the one-shot informational about SLIP not doing
  3987. // any in-protocol authentication or encryption.
  3988. //
  3989. MsgDlg( pInfo->hwndDlg, SID_NoAuthForSlip, NULL );
  3990. pInfo->fShowSlipPopup = FALSE;
  3991. }
  3992. }
  3993. else
  3994. {
  3995. HWND hwndRb;
  3996. // For PPP framing, select the appropriate security setting radio
  3997. // button which triggers additional enabling/disabling of the framed
  3998. // controls.
  3999. //
  4000. if (pInfo->pArgs->pEntry->dwAuthRestrictions & AR_F_AuthCustom)
  4001. {
  4002. hwndRb = pInfo->hwndRbAdvancedSecurity;
  4003. }
  4004. else
  4005. {
  4006. hwndRb = pInfo->hwndRbTypicalSecurity;
  4007. }
  4008. SendMessage( hwndRb, BM_CLICK, 0, 0 );
  4009. }
  4010. }
  4011. VOID
  4012. LoSaveTypicalAuthSettings(
  4013. IN PEINFO* pInfo )
  4014. // Save the values in the "typical" authentication controls to the
  4015. // phonebook entry. 'PInfo' is the property sheet context.
  4016. //
  4017. {
  4018. PBENTRY* pEntry;
  4019. INT iSel;
  4020. pEntry = pInfo->pArgs->pEntry;
  4021. iSel = ComboBox_GetCurSel( pInfo->hwndLbAuths );
  4022. if (iSel >= 0)
  4023. {
  4024. pEntry->dwTypicalAuth =
  4025. (DWORD) ComboBox_GetItemData( pInfo->hwndLbAuths, iSel );
  4026. pEntry->dwAuthRestrictions =
  4027. AuthRestrictionsFromTypicalAuth( pEntry->dwTypicalAuth );
  4028. // Set the default custom authentication key value for smart
  4029. // cards. RasDial API should assume this default anyway, but we
  4030. // need it before then in DialerDlgEap.
  4031. //
  4032. if (pEntry->dwTypicalAuth == TA_CardOrCert)
  4033. {
  4034. pEntry->dwCustomAuthKey = EAPCFG_DefaultKey;
  4035. }
  4036. else
  4037. {
  4038. pEntry->dwCustomAuthKey = (DWORD )-1;
  4039. }
  4040. }
  4041. if (IsWindowEnabled( pInfo->hwndCbUseWindowsPw ))
  4042. {
  4043. pEntry->fAutoLogon =
  4044. Button_GetCheck( pInfo->hwndCbUseWindowsPw );
  4045. }
  4046. else
  4047. {
  4048. pEntry->fAutoLogon = FALSE;
  4049. }
  4050. if (IsWindowEnabled( pInfo->hwndCbEncryption ))
  4051. {
  4052. pEntry->dwDataEncryption =
  4053. (Button_GetCheck( pInfo->hwndCbEncryption ))
  4054. ? DE_Require : DE_IfPossible;
  4055. }
  4056. else
  4057. {
  4058. pEntry->dwDataEncryption = DE_IfPossible;
  4059. }
  4060. if (pEntry->dwDataEncryption == DE_Require
  4061. && !(pEntry->dwType == RASET_Vpn
  4062. && pEntry->dwVpnStrategy == VS_L2tpOnly))
  4063. {
  4064. // Encryption is required and MPPE will be the encryption method
  4065. // so eliminate authentication protocols that don't support it.
  4066. //
  4067. pEntry->dwAuthRestrictions &= ~(AR_F_AuthNoMPPE);
  4068. }
  4069. }
  4070. //----------------------------------------------------------------------------
  4071. // Networking property page
  4072. // Listed alphabetically following dialog proc
  4073. //----------------------------------------------------------------------------
  4074. LVXDRAWINFO*
  4075. NeLvComponentsCallback(
  4076. IN HWND hwndLv,
  4077. IN DWORD dwItem )
  4078. // Enhanced list view callback to report drawing information. 'HwndLv' is
  4079. // the handle of the list view control. 'DwItem' is the index of the item
  4080. // being drawn.
  4081. //
  4082. // Returns the address of the draw information.
  4083. //
  4084. {
  4085. // Use "full row select" and other recommended options.
  4086. //
  4087. // Fields are 'nCols', 'dxIndent', 'dwFlags', 'adwFlags[]'.
  4088. //
  4089. static LVXDRAWINFO info = { 1, 0, LVXDI_DxFill, { 0 } };
  4090. return &info;
  4091. }
  4092. INT_PTR CALLBACK
  4093. NeDlgProc(
  4094. IN HWND hwnd,
  4095. IN UINT unMsg,
  4096. IN WPARAM wparam,
  4097. IN LPARAM lparam )
  4098. // DialogProc callback for the Network page of the Entry property sheet.
  4099. // Parameters and return value are as described for standard windows
  4100. // 'DialogProc's.
  4101. //
  4102. {
  4103. // Filter the customized list view messages
  4104. if (ListView_OwnerHandler(hwnd, unMsg, wparam, lparam, NeLvComponentsCallback))
  4105. return TRUE;
  4106. switch (unMsg)
  4107. {
  4108. case WM_INITDIALOG:
  4109. {
  4110. return NeInit( hwnd );
  4111. }
  4112. case WM_HELP:
  4113. case WM_CONTEXTMENU:
  4114. {
  4115. ContextHelp( g_adwNeHelp, hwnd, unMsg, wparam, lparam );
  4116. break;
  4117. }
  4118. case WM_COMMAND:
  4119. {
  4120. PEINFO* pInfo = PeContext (hwnd);
  4121. ASSERT (pInfo);
  4122. switch (LOWORD(wparam))
  4123. {
  4124. case CID_NE_LB_ServerType:
  4125. if (CBN_SELCHANGE == HIWORD(wparam))
  4126. {
  4127. NeServerTypeSelChange (pInfo);
  4128. }
  4129. break;
  4130. case CID_NE_PB_Settings:
  4131. DialogBoxParam (g_hinstDll,
  4132. MAKEINTRESOURCE(DID_NE_PppSettings),
  4133. hwnd, PpDlgProc, (LPARAM)pInfo);
  4134. break;
  4135. case CID_NE_PB_Add:
  4136. NeAddComponent (pInfo);
  4137. break;
  4138. case CID_NE_PB_Properties:
  4139. NeShowComponentProperties (pInfo);
  4140. break;
  4141. case CID_NE_PB_Remove:
  4142. NeRemoveComponent (pInfo);
  4143. break;
  4144. }
  4145. break;
  4146. }
  4147. case WM_NOTIFY:
  4148. {
  4149. PEINFO* pInfo = PeContext(hwnd);
  4150. //!!! Hack related to PeTerm in WM_DESTROY. We still get
  4151. // WM_NOTIFYs after PeTerm is called. So we commented out the
  4152. // following assert and moved it into each message handler below.
  4153. //ASSERT (pInfo);
  4154. switch (((NMHDR*)lparam)->code)
  4155. {
  4156. // !!! See if base lvx.c code can handle inversion of check state on double
  4157. // click.
  4158. #if 0
  4159. case NM_CLICK:
  4160. ASSERT (pInfo);
  4161. if (CID_NE_LV_Components == ((NMHDR*)lparam)->idFrom)
  4162. {
  4163. NeLvClick (pInfo, FALSE);
  4164. }
  4165. break;
  4166. #endif
  4167. case NM_DBLCLK:
  4168. ASSERT (pInfo);
  4169. if (CID_NE_LV_Components == ((NMHDR*)lparam)->idFrom)
  4170. {
  4171. NeLvClick (pInfo, TRUE);
  4172. }
  4173. break;
  4174. case LVN_ITEMCHANGED:
  4175. ASSERT (pInfo);
  4176. NeLvItemChanged (pInfo);
  4177. break;
  4178. case LVN_DELETEITEM:
  4179. ASSERT (pInfo);
  4180. NeLvDeleteItem (pInfo, (NM_LISTVIEW*)lparam);
  4181. break;
  4182. case PSN_SETACTIVE:
  4183. ASSERT (pInfo);
  4184. // If we couldn't get INetCfg, we can't show this page.
  4185. //
  4186. if (!pInfo->pNetCfg)
  4187. {
  4188. MsgDlg( pInfo->hwndDlg, ERR_CANT_SHOW_NETTAB_INETCFG, NULL );
  4189. SetWindowLong( hwnd, DWLP_MSGRESULT, -1 );
  4190. return TRUE;
  4191. }
  4192. break;
  4193. }
  4194. break;
  4195. }
  4196. }
  4197. return FALSE;
  4198. }
  4199. void
  4200. NeEnsureNetshellLoaded (
  4201. IN PEINFO* pInfo)
  4202. {
  4203. // Load the netshell utilities interface. The interface is freed in PeTerm.
  4204. //
  4205. if (!pInfo->pNetConUtilities)
  4206. {
  4207. // Initialize the NetConnectionsUiUtilities
  4208. //
  4209. HRESULT hr = HrCreateNetConnectionUtilities(&pInfo->pNetConUtilities);
  4210. }
  4211. }
  4212. BOOL
  4213. NeInit(
  4214. IN HWND hwndPage )
  4215. // Called on WM_INITDIALOG. 'hwndPage' is the handle of the property
  4216. // page.
  4217. //
  4218. // Return false if focus was set, true otherwise.
  4219. //
  4220. {
  4221. PEINFO* pInfo;
  4222. PBENTRY* pEntry;
  4223. pInfo = PeContext( hwndPage );
  4224. if (!pInfo)
  4225. {
  4226. return TRUE;
  4227. }
  4228. // Initialize page-specific context information.
  4229. //
  4230. pInfo->hwndLbServerType =
  4231. GetDlgItem( hwndPage, CID_NE_LB_ServerType );
  4232. ASSERT( pInfo->hwndLbServerType );
  4233. pInfo->hwndPbSettings =
  4234. GetDlgItem( hwndPage, CID_NE_PB_Settings );
  4235. ASSERT( pInfo->hwndPbSettings );
  4236. pInfo->hwndLvComponents =
  4237. GetDlgItem( hwndPage, CID_NE_LV_Components );
  4238. ASSERT( pInfo->hwndLvComponents );
  4239. pInfo->hwndPbAdd =
  4240. GetDlgItem( hwndPage, CID_NE_PB_Add );
  4241. ASSERT( pInfo->hwndPbAdd );
  4242. pInfo->hwndPbRemove =
  4243. GetDlgItem( hwndPage, CID_NE_PB_Remove );
  4244. ASSERT( pInfo->hwndPbRemove );
  4245. pInfo->hwndPbProperties =
  4246. GetDlgItem( hwndPage, CID_NE_PB_Properties );
  4247. ASSERT( pInfo->hwndPbProperties );
  4248. pInfo->hwndDescription =
  4249. GetDlgItem( hwndPage, CID_NE_LB_ComponentDesc );
  4250. ASSERT( pInfo->hwndDescription );
  4251. // Initialize page.
  4252. //
  4253. pEntry = pInfo->pArgs->pEntry;
  4254. // Initialize the server type combo box with the strings and the selection.
  4255. //
  4256. if (pEntry->dwType == RASET_Vpn)
  4257. {
  4258. INT i;
  4259. LBTABLEITEM* pItem;
  4260. // Whistler bug 312921 CM/RAS should default to PPTP instead of L2TP
  4261. //
  4262. LBTABLEITEM aItems[] =
  4263. {
  4264. SID_ST_VpnAuto, VS_PptpFirst,
  4265. SID_ST_VpnPptp, VS_PptpOnly,
  4266. SID_ST_VpnL2tp, VS_L2tpOnly,
  4267. 0, 0
  4268. };
  4269. for (pItem = aItems; pItem->sidItem != 0; ++pItem)
  4270. {
  4271. i = ComboBox_AddItemFromId(
  4272. g_hinstDll, pInfo->hwndLbServerType,
  4273. pItem->sidItem, (VOID* )UlongToPtr(pItem->dwData));
  4274. if (pItem->dwData == pEntry->dwVpnStrategy)
  4275. {
  4276. ComboBox_SetCurSel( pInfo->hwndLbServerType, i );
  4277. }
  4278. }
  4279. // If nothing was selected, then the strategy must have been one of the
  4280. // VS_xxxxFirst values. Set the current selection to automatic.
  4281. if ( ComboBox_GetCurSel ( pInfo->hwndLbServerType ) < 0 )
  4282. ComboBox_SetCurSel( pInfo->hwndLbServerType, 0 );
  4283. // Change the label to be VPN-specific per bug 307526.
  4284. //
  4285. {
  4286. TCHAR* psz;
  4287. psz = PszFromId( g_hinstDll, SID_NE_VpnServerLabel );
  4288. if (psz)
  4289. {
  4290. SetWindowText(
  4291. GetDlgItem( hwndPage, CID_NE_ST_ServerType ), psz );
  4292. Free( psz );
  4293. }
  4294. }
  4295. }
  4296. else if (pEntry->dwType == RASET_Broadband)
  4297. {
  4298. INT i;
  4299. LBTABLEITEM* pItem;
  4300. LBTABLEITEM aItems[] =
  4301. {
  4302. SID_ST_BbPppoe, BP_Ppp,
  4303. 0, 0
  4304. };
  4305. for (pItem = aItems; pItem->sidItem != 0; ++pItem)
  4306. {
  4307. i = ComboBox_AddItemFromId(
  4308. g_hinstDll, pInfo->hwndLbServerType,
  4309. pItem->sidItem, (VOID* )UlongToPtr(pItem->dwData));
  4310. }
  4311. ComboBox_SetCurSel( pInfo->hwndLbServerType, 0 );
  4312. // Change the label to be broadband-specific
  4313. //
  4314. {
  4315. TCHAR* psz;
  4316. psz = PszFromId( g_hinstDll, SID_NE_BbServerLabel );
  4317. if (psz)
  4318. {
  4319. SetWindowText(
  4320. GetDlgItem( hwndPage, CID_NE_ST_ServerType ), psz );
  4321. Free( psz );
  4322. }
  4323. }
  4324. }
  4325. else
  4326. {
  4327. ComboBox_AddItemFromId (g_hinstDll, pInfo->hwndLbServerType,
  4328. SID_ST_Ppp, (VOID*)BP_Ppp );
  4329. if (!pInfo->pArgs->fRouter)
  4330. {
  4331. ComboBox_AddItemFromId (g_hinstDll, pInfo->hwndLbServerType,
  4332. SID_ST_Slip, (VOID*)BP_Slip );
  4333. }
  4334. if (pEntry->dwBaseProtocol == BP_Ppp)
  4335. {
  4336. ComboBox_SetCurSel(pInfo->hwndLbServerType, 0 );
  4337. }
  4338. else
  4339. {
  4340. ComboBox_SetCurSel( pInfo->hwndLbServerType, 1 );
  4341. EnableWindow( pInfo->hwndPbSettings, FALSE );
  4342. }
  4343. }
  4344. // Set the image list for the state of the check boxes.
  4345. //
  4346. ListView_InstallChecks( pInfo->hwndLvComponents, g_hinstDll );
  4347. ListView_InsertSingleAutoWidthColumn( pInfo->hwndLvComponents );
  4348. // Set the image list for the component bitmaps. Unfortunately we have to
  4349. // duplicate it (as opposed to share) because the image list for the state
  4350. // icons is not shared. (If we set the shared style, all image lists would
  4351. // have to be deleted manually.
  4352. //
  4353. {
  4354. ZeroMemory (&pInfo->cild, sizeof(pInfo->cild));
  4355. pInfo->cild.cbSize = sizeof(pInfo->cild);
  4356. if (SetupDiGetClassImageList (&pInfo->cild))
  4357. {
  4358. HIMAGELIST himlSmall = ImageList_Duplicate (pInfo->cild.ImageList);
  4359. ListView_SetImageList (pInfo->hwndLvComponents, himlSmall, LVSIL_SMALL);
  4360. }
  4361. }
  4362. // Get the interface used to change network configuration and lock it.
  4363. // The description of who has the lock (us) comes from the title of our
  4364. // parent dialog. This is done so that when other applications try to obtain
  4365. // the lock (and fail) they get an indication of who has it locked. They
  4366. // can then direct the user to close our window to release the lock.
  4367. //
  4368. {
  4369. BOOL fEnableAdd = TRUE;
  4370. HRESULT hr;
  4371. TCHAR pszParentCaption [MAX_PATH] = {0};
  4372. GetWindowText (GetParent(hwndPage), pszParentCaption, MAX_PATH);
  4373. pInfo->fInitCom = TRUE;
  4374. hr = HrCreateAndInitializeINetCfg (&pInfo->fInitCom, &pInfo->pNetCfg,
  4375. TRUE, 0, pszParentCaption, NULL);
  4376. if (S_OK == hr)
  4377. {
  4378. // Refresh the list view.
  4379. //
  4380. hr = HrNeRefreshListView (pInfo);
  4381. // Reset the state of the buttons as if something changed.
  4382. //
  4383. NeLvItemChanged (pInfo);
  4384. pInfo->fNetCfgLock = TRUE;
  4385. }
  4386. else
  4387. {
  4388. DWORD dwMsg = SID_NE_ReadOnly;
  4389. //For whistler bug 311566
  4390. //
  4391. if (NETCFG_E_NO_WRITE_LOCK == hr)
  4392. {
  4393. pInfo->fReadOnly = TRUE;
  4394. }
  4395. if (NETCFG_E_NEED_REBOOT == hr)
  4396. {
  4397. dwMsg = SID_NE_Reboot;
  4398. }
  4399. else if (E_ACCESSDENIED == hr)
  4400. {
  4401. pInfo->fNonAdmin = TRUE;
  4402. dwMsg = SID_NE_AccessDenied;
  4403. }
  4404. // Uh.. ok let's try that again in read-only mode
  4405. hr = HrCreateAndInitializeINetCfg (&pInfo->fInitCom,
  4406. &pInfo->pNetCfg,FALSE, 0,
  4407. pszParentCaption, NULL);
  4408. if (S_OK == hr)
  4409. {
  4410. // Refresh the list view.
  4411. //
  4412. hr = HrNeRefreshListView (pInfo);
  4413. // Reset the state of the buttons as if something changed.
  4414. //
  4415. NeLvItemChanged (pInfo);
  4416. MsgDlg( pInfo->hwndDlg, dwMsg, NULL );
  4417. }
  4418. }
  4419. // Get the interface so we can check our access rights to the UI
  4420. //
  4421. NeEnsureNetshellLoaded (pInfo);
  4422. if (NULL != pInfo->pNetConUtilities)
  4423. {
  4424. fEnableAdd = INetConnectionUiUtilities_UserHasPermission(
  4425. pInfo->pNetConUtilities,
  4426. NCPERM_AddRemoveComponents);
  4427. }
  4428. // Disable some buttons if user does not have privilege
  4429. //
  4430. if (pInfo->fReadOnly || (NULL == pInfo->pNetConUtilities))
  4431. {
  4432. EnableWindow(pInfo->hwndPbAdd, FALSE);
  4433. EnableWindow(pInfo->hwndPbRemove, FALSE);
  4434. EnableWindow(pInfo->hwndPbProperties, FALSE);
  4435. }
  4436. // Disable some buttons if running in non-admin mode
  4437. else if (pInfo->fNonAdmin)
  4438. {
  4439. EnableWindow(pInfo->hwndPbAdd, FALSE);
  4440. EnableWindow(pInfo->hwndPbRemove, FALSE);
  4441. }
  4442. else
  4443. {
  4444. EnableWindow(pInfo->hwndPbAdd, fEnableAdd);
  4445. // Other buttons enabled via NeLvItemChanged
  4446. }
  4447. // pmay: 348623
  4448. //
  4449. // Hide some buttons if we're remote admining
  4450. //
  4451. if (pInfo->pArgs->fRemote)
  4452. {
  4453. ShowWindow(pInfo->hwndPbAdd, SW_HIDE);
  4454. ShowWindow(pInfo->hwndPbRemove, SW_HIDE);
  4455. }
  4456. }
  4457. return TRUE;
  4458. }
  4459. void
  4460. NeServerTypeSelChange (
  4461. IN PEINFO* pInfo)
  4462. {
  4463. PBENTRY* pEntry;
  4464. int iSel;
  4465. DWORD dwValue;
  4466. pEntry = pInfo->pArgs->pEntry;
  4467. iSel = ComboBox_GetCurSel (pInfo->hwndLbServerType);
  4468. ASSERT (CB_ERR != iSel);
  4469. dwValue = (DWORD) ComboBox_GetItemData (pInfo->hwndLbServerType, iSel);
  4470. // Regular connections choose between slip and ppp
  4471. //
  4472. if (pEntry->dwType != RASET_Vpn)
  4473. {
  4474. pEntry->dwBaseProtocol = dwValue;
  4475. // When SLIP is selected, turn off all protocols but IP and indicate
  4476. // the SLIP security page informational popup should appear.
  4477. //
  4478. if (BP_Slip == dwValue)
  4479. {
  4480. // No need to exclude the protocols. We lose this config state if
  4481. // we remove this and its of no use anyway. PPP won't be done
  4482. // if slip is selected -- [raos].
  4483. //
  4484. // pEntry->dwfExcludedProtocols = ~NP_Ip;
  4485. pInfo->fShowSlipPopup = TRUE;
  4486. }
  4487. HrNeRefreshListView (pInfo);
  4488. }
  4489. // Vpn connections select a strategy. When automatic is selected,
  4490. // we need to make sure the authentication and encryption is
  4491. // compatible
  4492. //
  4493. else
  4494. {
  4495. pEntry->dwVpnStrategy = dwValue;
  4496. // Whistler bug 312921 CM/RAS should default to PPTP instead of L2TP
  4497. //
  4498. if (dwValue == VS_PptpFirst)
  4499. {
  4500. pEntry->dwDataEncryption = DE_Require;
  4501. if( !(pEntry->dwAuthRestrictions & AR_F_AuthEAP ) )
  4502. {
  4503. pEntry->dwAuthRestrictions = AR_F_TypicalSecure;
  4504. }
  4505. pEntry->dwTypicalAuth = TA_Secure;
  4506. }
  4507. }
  4508. EnableWindow (pInfo->hwndPbSettings, !!(BP_Ppp == pEntry->dwBaseProtocol));
  4509. }
  4510. BOOL
  4511. NeRequestReboot (
  4512. IN PEINFO* pInfo)
  4513. {
  4514. NeEnsureNetshellLoaded (pInfo);
  4515. if (pInfo->pNetConUtilities)
  4516. {
  4517. HRESULT hr;
  4518. // A reboot is required. Ask the user if it is ok to reboot now
  4519. //
  4520. //$TODO NULL caption?
  4521. hr = INetConnectionUiUtilities_QueryUserForReboot(
  4522. pInfo->pNetConUtilities, pInfo->hwndDlg,
  4523. NULL, QUFR_PROMPT);
  4524. if (S_OK == hr)
  4525. {
  4526. // User requested a reboot, note this for processing in OnApply
  4527. // which is triggered by the message posted below
  4528. //
  4529. pInfo->fRebootAlreadyRequested = TRUE;
  4530. // Press the cancel button (changes have already been applied)
  4531. // so the appropriate cleanup occurs.
  4532. //
  4533. PostMessage(pInfo->hwndDlg, PSM_PRESSBUTTON,
  4534. (WPARAM)PSBTN_OK, 0);
  4535. }
  4536. else if (S_FALSE == hr)
  4537. {
  4538. // User denied to request to reboot
  4539. //
  4540. return FALSE;
  4541. }
  4542. }
  4543. return TRUE;
  4544. }
  4545. void
  4546. NeSaveBindingChanges(IN PEINFO* pInfo)
  4547. {
  4548. // Won't have changes to keep unless we have a writable INetCfg
  4549. if (pInfo->pNetCfg)
  4550. {
  4551. int iItem;
  4552. INetCfgComponent* pComponent;
  4553. BOOL fEnabled;
  4554. HRESULT hr;
  4555. // Update the phone book entry with the enabled state of the components.
  4556. // Do this by enumerating the components from the list view item data
  4557. // and consulting the check state for each.
  4558. //
  4559. iItem = -1;
  4560. while (-1 != (iItem = ListView_GetNextItem (pInfo->hwndLvComponents,
  4561. iItem, LVNI_ALL)))
  4562. {
  4563. pComponent = PComponentFromItemIndex (pInfo->hwndLvComponents, iItem);
  4564. ASSERT (pComponent);
  4565. fEnabled = ListView_GetCheck (pInfo->hwndLvComponents, iItem);
  4566. if(pComponent)
  4567. {
  4568. NeEnableComponent (pInfo, pComponent, fEnabled);
  4569. }
  4570. }
  4571. }
  4572. }
  4573. void
  4574. NeAddComponent (
  4575. IN PEINFO* pInfo)
  4576. {
  4577. NeEnsureNetshellLoaded (pInfo);
  4578. // If we have our pointer to the interface used to bring up the add
  4579. // component dialog (obtained above only once), call it.
  4580. //
  4581. if (pInfo->pNetConUtilities)
  4582. {
  4583. HRESULT hr;
  4584. // We want to filter out protocols that RAS does not care about
  4585. // We do this by sending in a CI_FILTER_INFO structure indicating
  4586. // we want non-RAS protocols filtered out
  4587. //
  4588. CI_FILTER_INFO cfi = {0};
  4589. cfi.eFilter = FC_RASCLI;
  4590. ASSERT (pInfo->pNetCfg);
  4591. hr = INetConnectionUiUtilities_DisplayAddComponentDialog(
  4592. pInfo->pNetConUtilities, pInfo->hwndDlg,
  4593. pInfo->pNetCfg, &cfi);
  4594. // If the user didn't cancel, refresh the list view.
  4595. //
  4596. if (S_FALSE != hr)
  4597. {
  4598. if (SUCCEEDED(hr))
  4599. {
  4600. // Change the Cancel Button to CLOSE (because we committed changes)
  4601. //
  4602. PropSheet_CancelToClose(pInfo->hwndDlg);
  4603. }
  4604. // commit binding changes made (Raid #297216)
  4605. NeSaveBindingChanges(pInfo);
  4606. HrNeRefreshListView (pInfo);
  4607. // Reset the state of the buttons as if something changed.
  4608. //
  4609. NeLvItemChanged (pInfo);
  4610. // If reboot is needed request approval for this from the user
  4611. //
  4612. if (NETCFG_S_REBOOT == hr)
  4613. {
  4614. NeRequestReboot (pInfo);
  4615. }
  4616. }
  4617. }
  4618. }
  4619. void
  4620. NeRemoveComponent (
  4621. IN PEINFO* pInfo)
  4622. {
  4623. NeEnsureNetshellLoaded (pInfo);
  4624. // If we have our pointer to the function used to bring up the remove
  4625. // component dialog (obtained above only once), call it.
  4626. //
  4627. if (pInfo->pNetConUtilities)
  4628. {
  4629. HRESULT hr;
  4630. INetCfgComponent* pComponent;
  4631. pComponent = PComponentFromCurSel (pInfo->hwndLvComponents, NULL);
  4632. ASSERT (pComponent);
  4633. ASSERT (pInfo->pNetCfg);
  4634. hr = INetConnectionUiUtilities_QueryUserAndRemoveComponent(
  4635. pInfo->pNetConUtilities, pInfo->hwndDlg,
  4636. pInfo->pNetCfg, pComponent);
  4637. // If the user didn't cancel, refresh the list view.
  4638. //
  4639. if (S_FALSE != hr)
  4640. {
  4641. if (SUCCEEDED(hr))
  4642. {
  4643. // Change the Cancel Button to CLOSE (because we committed changes)
  4644. //
  4645. PropSheet_CancelToClose(pInfo->hwndDlg);
  4646. }
  4647. NeSaveBindingChanges(pInfo);
  4648. HrNeRefreshListView(pInfo);
  4649. // Reset the state of the buttons as if something changed.
  4650. //
  4651. NeLvItemChanged (pInfo);
  4652. // If reboot is needed request approval for this from the user
  4653. //
  4654. if (NETCFG_S_REBOOT == hr)
  4655. {
  4656. NeRequestReboot (pInfo);
  4657. }
  4658. }
  4659. }
  4660. }
  4661. void
  4662. NeLvClick (
  4663. IN PEINFO* pInfo,
  4664. IN BOOL fDoubleClick)
  4665. {
  4666. //Add the IsWindowEnabled for whistler bug #204976
  4667. //Not to pop up the property dialog box if it is a router
  4668. //and the selected List View item is IPX
  4669. //
  4670. if (fDoubleClick && IsWindowEnabled(pInfo->hwndPbProperties))
  4671. {
  4672. INetCfgComponent* pComponent;
  4673. int iItem;
  4674. pComponent = PComponentFromCurSel (pInfo->hwndLvComponents, &iItem);
  4675. if (pComponent)
  4676. {
  4677. HRESULT hr;
  4678. if ( ListView_GetCheck (pInfo->hwndLvComponents, iItem))
  4679. {
  4680. // Check if the component has property UI
  4681. //
  4682. // Create the UI info callback object if we haven't done so yet.
  4683. // If this fails, we can still show properties. TCP/IP just might
  4684. // not know which UI-variant to show.
  4685. //
  4686. if (!pInfo->punkUiInfoCallback)
  4687. {
  4688. HrCreateUiInfoCallbackObject (pInfo, &pInfo->punkUiInfoCallback);
  4689. }
  4690. // Check if the component has property UI
  4691. hr = INetCfgComponent_RaisePropertyUi ( pComponent,
  4692. pInfo->hwndDlg,
  4693. NCRP_QUERY_PROPERTY_UI,
  4694. pInfo->punkUiInfoCallback);
  4695. if (S_OK == hr)
  4696. {
  4697. NeEnsureNetshellLoaded (pInfo);
  4698. if ((NULL != pInfo->pNetConUtilities) &&
  4699. INetConnectionUiUtilities_UserHasPermission(
  4700. pInfo->pNetConUtilities,
  4701. NCPERM_RasChangeProperties))
  4702. {
  4703. NeShowComponentProperties (pInfo);
  4704. }
  4705. }
  4706. }
  4707. }
  4708. }
  4709. }
  4710. void
  4711. NeLvItemChanged (
  4712. IN PEINFO* pInfo)
  4713. {
  4714. LPWSTR pszwDescription = NULL;
  4715. BOOL fEnableRemove = FALSE;
  4716. BOOL fEnableProperties = FALSE;
  4717. INetCfgComponent* pComponent;
  4718. int iItem;
  4719. // Get the current selection if it exists.
  4720. //
  4721. pComponent = PComponentFromCurSel (pInfo->hwndLvComponents, &iItem);
  4722. if (pComponent)
  4723. {
  4724. NeEnsureNetshellLoaded (pInfo);
  4725. // Determine if removal is allowed
  4726. //
  4727. if (NULL != pInfo->pNetConUtilities)
  4728. {
  4729. DWORD dwFlags = 0;
  4730. HRESULT hr;
  4731. fEnableRemove = INetConnectionUiUtilities_UserHasPermission(
  4732. pInfo->pNetConUtilities,
  4733. NCPERM_AddRemoveComponents);
  4734. //Now disable the user ability to uninstall TCP stack
  4735. //for whistler bug 322846 gangz
  4736. //
  4737. hr = INetCfgComponent_GetCharacteristics(pComponent, &dwFlags );
  4738. if( SUCCEEDED(hr) && (NCF_NOT_USER_REMOVABLE & dwFlags) )
  4739. {
  4740. fEnableRemove = FALSE;
  4741. }
  4742. }
  4743. // See if the properties UI should be allowed. Only allow it for
  4744. // enabled items that have UI to display.
  4745. //
  4746. {
  4747. HRESULT hr = S_OK;
  4748. if (ListView_GetCheck (pInfo->hwndLvComponents, iItem))
  4749. {
  4750. // Check if the component has property UI
  4751. //
  4752. INetCfgComponent* pComponentTmp = PComponentFromCurSel (pInfo->hwndLvComponents, NULL);
  4753. ASSERT (pComponentTmp);
  4754. // Create the UI info callback object if we haven't done so yet.
  4755. // If this fails, we can still show properties. TCP/IP just might
  4756. // not know which UI-variant to show.
  4757. //
  4758. if (!pInfo->punkUiInfoCallback)
  4759. {
  4760. HrCreateUiInfoCallbackObject (pInfo, &pInfo->punkUiInfoCallback);
  4761. }
  4762. if(pComponentTmp)
  4763. {
  4764. // Check if the component has property UI
  4765. hr = INetCfgComponent_RaisePropertyUi ( pComponentTmp,
  4766. pInfo->hwndDlg,
  4767. NCRP_QUERY_PROPERTY_UI,
  4768. pInfo->punkUiInfoCallback);
  4769. if ((S_OK == hr) && (NULL != pInfo->pNetConUtilities))
  4770. {
  4771. fEnableProperties = INetConnectionUiUtilities_UserHasPermission(
  4772. pInfo->pNetConUtilities,
  4773. NCPERM_RasChangeProperties);
  4774. }
  4775. }
  4776. }
  4777. }
  4778. // Bug #221837 (danielwe): Set member vars based on whether they
  4779. // are checked in the UI
  4780. //
  4781. {
  4782. PBENTRY * pEntry;
  4783. BOOL fIsChecked;
  4784. LPWSTR pszwId = NULL;
  4785. pEntry = pInfo->pArgs->pEntry;
  4786. fIsChecked = ListView_GetCheck(pInfo->hwndLvComponents, iItem);
  4787. if (SUCCEEDED(INetCfgComponent_GetId(pComponent, &pszwId)))
  4788. {
  4789. // For whistler 522872
  4790. //
  4791. if( CSTR_EQUAL == CompareStringW(
  4792. LOCALE_INVARIANT,
  4793. NORM_IGNORECASE,
  4794. NETCFG_CLIENT_CID_MS_MSClient,
  4795. -1,
  4796. pszwId,
  4797. -1
  4798. )
  4799. )
  4800. {
  4801. pEntry->fBindMsNetClient = fIsChecked;
  4802. }
  4803. else if( CSTR_EQUAL == CompareStringW(
  4804. LOCALE_INVARIANT,
  4805. NORM_IGNORECASE,
  4806. NETCFG_SERVICE_CID_MS_SERVER,
  4807. -1,
  4808. pszwId,
  4809. -1
  4810. )
  4811. )
  4812. {
  4813. pEntry->fShareMsFilePrint = fIsChecked;
  4814. }
  4815. // pmay 406630
  4816. //
  4817. // Disable the properties of all components but tcpip if we
  4818. // are running in non-admin mode
  4819. //
  4820. else if ( CSTR_EQUAL == CompareStringW(
  4821. LOCALE_INVARIANT,
  4822. NORM_IGNORECASE,
  4823. NETCFG_TRANS_CID_MS_TCPIP,
  4824. -1,
  4825. pszwId,
  4826. -1)
  4827. )
  4828. {
  4829. if (pInfo->fNonAdmin)
  4830. {
  4831. fEnableProperties = FALSE;
  4832. }
  4833. }
  4834. CoTaskMemFree(pszwId);
  4835. }
  4836. }
  4837. // Bug #348623 (pmay):
  4838. //
  4839. // Ipx is hardcoded to disable properties when remote admining
  4840. // a router.
  4841. //
  4842. if (pInfo->pArgs->fRouter ) //commented for bug #204976 //&& pInfo->pArgs->fRemote)
  4843. {
  4844. LPWSTR pszwId = NULL;
  4845. if (SUCCEEDED(INetCfgComponent_GetId(pComponent, &pszwId)))
  4846. {
  4847. if ( CSTR_EQUAL== CompareStringW(
  4848. LOCALE_INVARIANT,
  4849. NORM_IGNORECASE,
  4850. NETCFG_TRANS_CID_MS_NWIPX,
  4851. -1,
  4852. pszwId,
  4853. -1)
  4854. )
  4855. {
  4856. fEnableProperties = FALSE;
  4857. }
  4858. CoTaskMemFree(pszwId);
  4859. }
  4860. }
  4861. // Get the description text. Failure is okay here. It just means
  4862. // we'll display nothing.
  4863. //
  4864. INetCfgComponent_GetHelpText (pComponent, &pszwDescription);
  4865. }
  4866. // Update the UI with its new state.
  4867. //
  4868. if (!pInfo->fReadOnly)
  4869. {
  4870. EnableWindow (pInfo->hwndPbRemove, fEnableRemove);
  4871. EnableWindow (pInfo->hwndPbProperties, fEnableProperties);
  4872. }
  4873. if(NULL != pszwDescription)
  4874. {
  4875. SetWindowText (pInfo->hwndDescription, pszwDescription);
  4876. CoTaskMemFree (pszwDescription);
  4877. }
  4878. }
  4879. void
  4880. NeLvDeleteItem (
  4881. IN PEINFO* pInfo,
  4882. IN NM_LISTVIEW* pnmlv)
  4883. {
  4884. // Release our component object stored as the lParam of the list view
  4885. // item.
  4886. //
  4887. INetCfgComponent* pComponent;
  4888. pComponent = PComponentFromItemIndex (pInfo->hwndLvComponents,
  4889. pnmlv->iItem);
  4890. ReleaseObj (pComponent);
  4891. }
  4892. //----------------------------------------------------------------------------
  4893. // Networking property page PPP Settings dialog
  4894. //----------------------------------------------------------------------------
  4895. INT_PTR CALLBACK
  4896. PpDlgProc(
  4897. IN HWND hwnd,
  4898. IN UINT unMsg,
  4899. IN WPARAM wparam,
  4900. IN LPARAM lparam )
  4901. {
  4902. PEINFO* pInfo;
  4903. PBENTRY* pEntry;
  4904. switch (unMsg)
  4905. {
  4906. case WM_INITDIALOG:
  4907. {
  4908. pInfo = (PEINFO*)lparam;
  4909. ASSERT (pInfo);
  4910. pEntry = pInfo->pArgs->pEntry;
  4911. CheckDlgButton (hwnd, CID_NE_EnableLcp,
  4912. (pEntry->fLcpExtensions)
  4913. ? BST_CHECKED : BST_UNCHECKED);
  4914. CheckDlgButton (hwnd, CID_NE_EnableCompression,
  4915. (pEntry->fSwCompression)
  4916. ? BST_CHECKED : BST_UNCHECKED);
  4917. //Cut Negotiate multi-link for whistler bug 385842
  4918. //
  4919. CheckDlgButton (hwnd, CID_NE_NegotiateMultilinkAlways,
  4920. (pEntry->fNegotiateMultilinkAlways)
  4921. ? BST_CHECKED : BST_UNCHECKED);
  4922. SetWindowLongPtr (hwnd, DWLP_USER, (ULONG_PTR )lparam);
  4923. // Center dialog on the owner window.
  4924. //
  4925. CenterWindow(hwnd, GetParent(hwnd));
  4926. // Add context help button to title bar.
  4927. //
  4928. AddContextHelpButton(hwnd);
  4929. return TRUE;
  4930. }
  4931. case WM_HELP:
  4932. case WM_CONTEXTMENU:
  4933. {
  4934. ContextHelp( g_adwPpHelp, hwnd, unMsg, wparam, lparam );
  4935. break;
  4936. }
  4937. case WM_COMMAND:
  4938. {
  4939. if ((IDOK == LOWORD(wparam)) &&
  4940. (BN_CLICKED == HIWORD(wparam)))
  4941. {
  4942. pInfo = (PEINFO*)GetWindowLongPtr (hwnd, DWLP_USER);
  4943. ASSERT (pInfo);
  4944. pEntry = pInfo->pArgs->pEntry;
  4945. pEntry->fLcpExtensions = (BST_CHECKED ==
  4946. IsDlgButtonChecked (hwnd, CID_NE_EnableLcp));
  4947. pEntry->fSwCompression = (BST_CHECKED ==
  4948. IsDlgButtonChecked (hwnd, CID_NE_EnableCompression));
  4949. //Cut Negotiate multi-link for whistler bug 385842
  4950. //
  4951. pEntry->fNegotiateMultilinkAlways = (BST_CHECKED ==
  4952. IsDlgButtonChecked (hwnd, CID_NE_NegotiateMultilinkAlways));
  4953. /*
  4954. pEntry->fNegotiateMultilinkAlways = FALSE;
  4955. */
  4956. EndDialog (hwnd, TRUE);
  4957. return TRUE;
  4958. }
  4959. else if ((IDCANCEL == LOWORD(wparam)) &&
  4960. (BN_CLICKED == HIWORD(wparam)))
  4961. {
  4962. EndDialog (hwnd, FALSE);
  4963. return TRUE;
  4964. }
  4965. break;
  4966. }
  4967. }
  4968. return FALSE;
  4969. }
  4970. INT_PTR CALLBACK
  4971. SaUnavailDlgProc(
  4972. IN HWND hwnd,
  4973. IN UINT unMsg,
  4974. IN WPARAM wparam,
  4975. IN LPARAM lparam )
  4976. // DialogProc callback for the Shared Access Unavailable page of the Entry property
  4977. // sheet.
  4978. // Parameters and return value are as described for standard windows
  4979. // 'DialogProc's.
  4980. //
  4981. {
  4982. #if 0
  4983. TRACE4( "SaUnavailDlgProc(h=$%x,m=$%x,w=$%x,l=$%x)",
  4984. (DWORD )hwnd, (DWORD )unMsg, (DWORD )wparam, (DWORD )lparam );
  4985. #endif
  4986. switch (unMsg)
  4987. {
  4988. case WM_INITDIALOG:
  4989. {
  4990. LPWSTR pszError;
  4991. PEINFO* pInfo = PeContext( hwnd );
  4992. ASSERT(pInfo);
  4993. if (pInfo == NULL)
  4994. {
  4995. break;
  4996. }
  4997. pszError = PszFromId(g_hinstDll, pInfo->pArgs->hShowHNetPagesResult == HRESULT_FROM_WIN32(ERROR_SERVICE_DISABLED) ? SID_SA_NoWMIError : SID_SA_StoreError);
  4998. if(NULL != pszError)
  4999. {
  5000. SetDlgItemText(hwnd, CID_SA_ST_ErrorText, pszError);
  5001. Free(pszError);
  5002. }
  5003. }
  5004. case WM_HELP:
  5005. case WM_CONTEXTMENU:
  5006. {
  5007. // ContextHelp( g_adwSaHelp, hwnd, unMsg, wparam, lparam );
  5008. break;
  5009. }
  5010. }
  5011. return FALSE;
  5012. }
  5013. //----------------------------------------------------------------------------
  5014. // Routing property page (PLACEHOLDER only)
  5015. // Listed alphabetically following dialog proc
  5016. //----------------------------------------------------------------------------
  5017. INT_PTR CALLBACK
  5018. RdDlgProc(
  5019. IN HWND hwnd,
  5020. IN UINT unMsg,
  5021. IN WPARAM wparam,
  5022. IN LPARAM lparam )
  5023. // DialogProc callback for the Routing page of the Entry property sheet.
  5024. // Parameters and return value are as described for standard windows
  5025. // 'DialogProc's.
  5026. //
  5027. {
  5028. return FALSE;
  5029. }
  5030. /*----------------------------------------------------------------------------
  5031. ** (Router) Callback dialog
  5032. ** Listed alphabetically following dialog proc
  5033. **----------------------------------------------------------------------------
  5034. */
  5035. BOOL
  5036. RouterCallbackDlg(
  5037. IN HWND hwndOwner,
  5038. IN OUT EINFO* pEinfo )
  5039. /* Pops-up the (Router) Callback dialog. Initial settings are read from
  5040. ** the working entry (no/yes choice) and router user preferences (number
  5041. ** list) in common entry context 'pEinfo' and the result of user's edits
  5042. ** written there on "OK" exit. 'HwndOwner' is the window owning the
  5043. ** dialog.
  5044. **
  5045. ** Returns true if user pressed OK and succeeded, false if he pressed
  5046. ** Cancel or encountered an error.
  5047. */
  5048. {
  5049. INT_PTR nStatus;
  5050. TRACE("RouterCallbackDlg");
  5051. nStatus =
  5052. DialogBoxParam(
  5053. g_hinstDll,
  5054. MAKEINTRESOURCE( DID_CR_CallbackRouter ),
  5055. hwndOwner,
  5056. CrDlgProc,
  5057. (LPARAM )pEinfo );
  5058. if (nStatus == -1)
  5059. {
  5060. ErrorDlg( hwndOwner, SID_OP_LoadDlg, ERROR_UNKNOWN, NULL );
  5061. nStatus = FALSE;
  5062. }
  5063. return (nStatus) ? TRUE : FALSE;
  5064. }
  5065. INT_PTR CALLBACK
  5066. CrDlgProc(
  5067. IN HWND hwnd,
  5068. IN UINT unMsg,
  5069. IN WPARAM wparam,
  5070. IN LPARAM lparam )
  5071. /* DialogProc callback for the (Router) Callback dialog. Parameters and
  5072. ** return value are as described for standard windows 'DialogProc's.
  5073. */
  5074. {
  5075. #if 0
  5076. TRACE4("CrDlgProc(h=$%x,m=$%x,w=$%x,l=$%x)",
  5077. (DWORD)hwnd,(DWORD)unMsg,(DWORD)wparam,(DWORD)lparam);
  5078. #endif
  5079. if (ListView_OwnerHandler(
  5080. hwnd, unMsg, wparam, lparam, CbutilLvNumbersCallback ))
  5081. {
  5082. return TRUE;
  5083. }
  5084. switch (unMsg)
  5085. {
  5086. case WM_INITDIALOG:
  5087. return CrInit( hwnd, (EINFO* )lparam );
  5088. case WM_HELP:
  5089. case WM_CONTEXTMENU:
  5090. ContextHelp( g_adwCrHelp, hwnd, unMsg, wparam, lparam );
  5091. break;
  5092. case WM_NOTIFY:
  5093. {
  5094. switch (((NMHDR* )lparam)->code)
  5095. {
  5096. case NM_DBLCLK:
  5097. {
  5098. CRINFO* pInfo = (CRINFO* )GetWindowLongPtr( hwnd, DWLP_USER );
  5099. ASSERT(pInfo);
  5100. SendMessage( pInfo->hwndPbEdit, BM_CLICK, 0, 0 );
  5101. return TRUE;
  5102. }
  5103. case LVN_ITEMCHANGED:
  5104. {
  5105. CRINFO* pInfo = (CRINFO* )GetWindowLongPtr( hwnd, DWLP_USER );
  5106. ASSERT(pInfo);
  5107. CrUpdateLvAndPbState( pInfo );
  5108. return TRUE;
  5109. }
  5110. }
  5111. break;
  5112. }
  5113. case WM_COMMAND:
  5114. {
  5115. CRINFO* pInfo = (CRINFO* )GetWindowLongPtr( hwnd, DWLP_USER );
  5116. ASSERT(pInfo);
  5117. return CrCommand(
  5118. pInfo, HIWORD( wparam ), LOWORD( wparam ), (HWND )lparam );
  5119. }
  5120. case WM_DESTROY:
  5121. {
  5122. CrTerm( hwnd );
  5123. break;
  5124. }
  5125. }
  5126. return FALSE;
  5127. }
  5128. BOOL
  5129. CrCommand(
  5130. IN CRINFO* pInfo,
  5131. IN WORD wNotification,
  5132. IN WORD wId,
  5133. IN HWND hwndCtrl )
  5134. /* Called on WM_COMMAND. 'PInfo' is the dialog context. 'WNotification'
  5135. ** is the notification code of the command. 'wId' is the control/menu
  5136. ** identifier of the command. 'HwndCtrl' is the control window handle of
  5137. ** the command.
  5138. **
  5139. ** Returns true if processed message, false otherwise.
  5140. */
  5141. {
  5142. TRACE3("CrCommand(n=%d,i=%d,c=$%x)",
  5143. (DWORD)wNotification,(DWORD)wId,(ULONG_PTR )hwndCtrl);
  5144. switch (wId)
  5145. {
  5146. case CID_CR_RB_No:
  5147. case CID_CR_RB_Yes:
  5148. {
  5149. if (wNotification == BN_CLICKED)
  5150. {
  5151. CrUpdateLvAndPbState( pInfo );
  5152. if (wId == CID_CR_RB_Yes
  5153. && ListView_GetSelectedCount( pInfo->hwndLvNumbers ) == 0)
  5154. {
  5155. /* Nothing's selected, so select the first item, if any.
  5156. */
  5157. ListView_SetItemState( pInfo->hwndLvNumbers, 0,
  5158. LVIS_SELECTED, LVIS_SELECTED );
  5159. }
  5160. }
  5161. break;
  5162. }
  5163. case CID_CR_PB_Edit:
  5164. {
  5165. if (wNotification == BN_CLICKED)
  5166. CbutilEdit( pInfo->hwndDlg, pInfo->hwndLvNumbers );
  5167. break;
  5168. }
  5169. case CID_CR_PB_Delete:
  5170. {
  5171. if (wNotification == BN_CLICKED)
  5172. CbutilDelete( pInfo->hwndDlg, pInfo->hwndLvNumbers );
  5173. break;
  5174. }
  5175. case IDOK:
  5176. {
  5177. TRACE("OK pressed");
  5178. CrSave( pInfo );
  5179. EndDialog( pInfo->hwndDlg, TRUE );
  5180. return TRUE;
  5181. }
  5182. case IDCANCEL:
  5183. {
  5184. TRACE("Cancel pressed");
  5185. EndDialog( pInfo->hwndDlg, FALSE );
  5186. return TRUE;
  5187. }
  5188. }
  5189. return FALSE;
  5190. }
  5191. BOOL
  5192. CrInit(
  5193. IN HWND hwndDlg,
  5194. IN EINFO* pArgs )
  5195. /* Called on WM_INITDIALOG. 'hwndDlg' is the handle of the phonebook
  5196. ** dialog window. 'pArgs' is caller's argument to the stub API.
  5197. **
  5198. ** Return false if focus was set, true otherwise, i.e. as defined for
  5199. ** WM_INITDIALOG.
  5200. */
  5201. {
  5202. DWORD dwErr;
  5203. CRINFO* pInfo;
  5204. TRACE("CrInit");
  5205. /* Allocate the dialog context block. Initialize minimally for proper
  5206. ** cleanup, then attach to the dialog window.
  5207. */
  5208. {
  5209. pInfo = Malloc( sizeof(*pInfo) );
  5210. if (!pInfo)
  5211. {
  5212. ErrorDlg( hwndDlg, SID_OP_LoadDlg, ERROR_NOT_ENOUGH_MEMORY, NULL );
  5213. EndDialog( hwndDlg, FALSE );
  5214. return TRUE;
  5215. }
  5216. ZeroMemory( pInfo, sizeof(*pInfo) );
  5217. pInfo->pArgs = pArgs;
  5218. pInfo->hwndDlg = hwndDlg;
  5219. SetWindowLongPtr( hwndDlg, DWLP_USER, (ULONG_PTR )pInfo );
  5220. TRACE("Context set");
  5221. }
  5222. /* Initialize page-specific context information.
  5223. */
  5224. pInfo->hwndRbNo = GetDlgItem( hwndDlg, CID_CR_RB_No );
  5225. ASSERT(pInfo->hwndRbNo);
  5226. pInfo->hwndRbYes = GetDlgItem( hwndDlg, CID_CR_RB_Yes );
  5227. ASSERT(pInfo->hwndRbYes);
  5228. pInfo->hwndLvNumbers = GetDlgItem( hwndDlg, CID_CR_LV_Numbers );
  5229. ASSERT(pInfo->hwndLvNumbers);
  5230. pInfo->hwndPbEdit = GetDlgItem( hwndDlg, CID_CR_PB_Edit );
  5231. ASSERT(pInfo->hwndPbEdit);
  5232. pInfo->hwndPbDelete = GetDlgItem( hwndDlg, CID_CR_PB_Delete );
  5233. ASSERT(pInfo->hwndPbDelete);
  5234. /* Initialize the listview.
  5235. */
  5236. CbutilFillLvNumbers(
  5237. pInfo->hwndDlg, pInfo->hwndLvNumbers,
  5238. pArgs->pUser->pdtllistCallback, pArgs->fRouter );
  5239. /* Set the radio button selection, which triggers appropriate
  5240. ** enabling/disabling.
  5241. */
  5242. {
  5243. HWND hwndRb;
  5244. if (pArgs->pEntry->dwCallbackMode == CBM_No)
  5245. hwndRb = pInfo->hwndRbNo;
  5246. else
  5247. {
  5248. ASSERT(pArgs->pEntry->dwCallbackMode==CBM_Yes);
  5249. hwndRb = pInfo->hwndRbYes;
  5250. }
  5251. SendMessage( hwndRb, BM_CLICK, 0, 0 );
  5252. }
  5253. /* Center dialog on the owner window.
  5254. */
  5255. CenterWindow( hwndDlg, GetParent( hwndDlg ) );
  5256. // Add context help button to title bar.
  5257. //
  5258. AddContextHelpButton( hwndDlg );
  5259. return TRUE;
  5260. }
  5261. VOID
  5262. CrSave(
  5263. IN CRINFO* pInfo )
  5264. /* Saves dialog settings in the entry. 'PInfo' is the dialog context.
  5265. */
  5266. {
  5267. PBENTRY* pEntry;
  5268. TRACE("CrSave");
  5269. pEntry = pInfo->pArgs->pEntry;
  5270. ASSERT(pEntry);
  5271. if (IsDlgButtonChecked( pInfo->hwndDlg, CID_CR_RB_No ))
  5272. pEntry->dwCallbackMode = CBM_No;
  5273. else
  5274. pEntry->dwCallbackMode = CBM_Yes;
  5275. pEntry->dwfOverridePref |= RASOR_CallbackMode;
  5276. pEntry->fDirty = TRUE;
  5277. pInfo->pArgs->pUser->fDirty = TRUE;
  5278. CbutilSaveLv(
  5279. pInfo->hwndLvNumbers, pInfo->pArgs->pUser->pdtllistCallback );
  5280. }
  5281. VOID
  5282. CrTerm(
  5283. IN HWND hwndDlg )
  5284. /* Called on WM_DESTROY. 'HwndDlg' is that handle of the dialog window.
  5285. */
  5286. {
  5287. CRINFO* pInfo = (CRINFO* )GetWindowLongPtr( hwndDlg, DWLP_USER );
  5288. TRACE("CrTerm");
  5289. // pmay: 213060
  5290. //
  5291. // Cleanup the numbers
  5292. //
  5293. if ( pInfo->hwndLvNumbers )
  5294. {
  5295. CbutilLvNumbersCleanup( pInfo->hwndLvNumbers );
  5296. }
  5297. if (pInfo)
  5298. {
  5299. Free( pInfo );
  5300. }
  5301. }
  5302. VOID
  5303. CrUpdateLvAndPbState(
  5304. IN CRINFO* pInfo )
  5305. /* Enables/disables the list view and associated buttons. ListView is
  5306. ** gray unless auto-callback is selected. Buttons gray unless
  5307. ** auto-callback selected and there is an item selected.
  5308. */
  5309. {
  5310. BOOL fEnableList;
  5311. BOOL fEnableButton;
  5312. fEnableList = Button_GetCheck( pInfo->hwndRbYes );
  5313. if (fEnableList)
  5314. {
  5315. fEnableButton =
  5316. ListView_GetSelectedCount( pInfo->hwndLvNumbers );
  5317. }
  5318. else
  5319. fEnableButton = FALSE;
  5320. EnableWindow( pInfo->hwndLvNumbers, fEnableList );
  5321. EnableWindow( pInfo->hwndPbEdit, fEnableButton );
  5322. EnableWindow( pInfo->hwndPbDelete, fEnableButton );
  5323. }
  5324. INT_PTR CALLBACK
  5325. SaDisableFirewallWarningDlgProc(
  5326. IN HWND hwnd,
  5327. IN UINT unMsg,
  5328. IN WPARAM wparam,
  5329. IN LPARAM lparam )
  5330. {
  5331. switch(unMsg)
  5332. {
  5333. case WM_COMMAND:
  5334. {
  5335. switch(LOWORD(wparam))
  5336. {
  5337. case IDYES:
  5338. case IDNO:
  5339. if(BST_CHECKED == IsDlgButtonChecked(hwnd, CID_SA_PB_DisableFirewallWarning))
  5340. {
  5341. HKEY hFirewallKey;
  5342. if(ERROR_SUCCESS == RegCreateKeyEx(HKEY_CURRENT_USER, g_pszFirewallRegKey, 0, NULL, 0, KEY_SET_VALUE, NULL, &hFirewallKey, NULL))
  5343. {
  5344. DWORD dwValue = TRUE;
  5345. RegSetValueEx(hFirewallKey, g_pszDisableFirewallWarningValue, 0, REG_DWORD, (CONST BYTE*)&dwValue, sizeof(dwValue));
  5346. RegCloseKey(hFirewallKey);
  5347. }
  5348. }
  5349. // fallthru
  5350. case IDCANCEL:
  5351. EndDialog(hwnd, LOWORD(wparam));
  5352. break;
  5353. }
  5354. break;
  5355. }
  5356. }
  5357. return FALSE;
  5358. }
  5359. BOOL SaIsAdapterDHCPEnabled(IHNetConnection* pConnection)
  5360. {
  5361. HRESULT hr;
  5362. BOOL fDHCP = FALSE;
  5363. GUID* pAdapterGuid;
  5364. hr = IHNetConnection_GetGuid(pConnection, &pAdapterGuid);
  5365. if(SUCCEEDED(hr))
  5366. {
  5367. LPOLESTR pAdapterName;
  5368. hr = StringFromCLSID(pAdapterGuid, &pAdapterName);
  5369. if(SUCCEEDED(hr))
  5370. {
  5371. SIZE_T Length = wcslen(pAdapterName);
  5372. LPSTR pszAnsiAdapterName = Malloc(Length + 1);
  5373. if(NULL != pszAnsiAdapterName)
  5374. {
  5375. if(0 != WideCharToMultiByte(CP_ACP, 0, pAdapterName, (int)(Length + 1), pszAnsiAdapterName, (int)(Length + 1), NULL, NULL))
  5376. {
  5377. HMODULE hIpHelper;
  5378. hIpHelper = LoadLibrary(L"iphlpapi");
  5379. if(NULL != hIpHelper)
  5380. {
  5381. DWORD (WINAPI *pGetAdaptersInfo)(PIP_ADAPTER_INFO, PULONG);
  5382. pGetAdaptersInfo = (DWORD (WINAPI*)(PIP_ADAPTER_INFO, PULONG)) GetProcAddress(hIpHelper, "GetAdaptersInfo");
  5383. if(NULL != pGetAdaptersInfo)
  5384. {
  5385. ULONG ulSize = 0;
  5386. if(ERROR_BUFFER_OVERFLOW == pGetAdaptersInfo(NULL, &ulSize))
  5387. {
  5388. PIP_ADAPTER_INFO pInfo = Malloc(ulSize);
  5389. if(NULL != pInfo)
  5390. {
  5391. if(ERROR_SUCCESS == pGetAdaptersInfo(pInfo, &ulSize))
  5392. {
  5393. PIP_ADAPTER_INFO pAdapterInfo = pInfo;
  5394. do
  5395. {
  5396. if(0 == lstrcmpA(pszAnsiAdapterName, pAdapterInfo->AdapterName))
  5397. {
  5398. fDHCP = !!pAdapterInfo->DhcpEnabled;
  5399. break;
  5400. }
  5401. } while(NULL != (pAdapterInfo = pAdapterInfo->Next));
  5402. }
  5403. Free(pInfo);
  5404. }
  5405. }
  5406. }
  5407. FreeLibrary(hIpHelper);
  5408. }
  5409. }
  5410. Free(pszAnsiAdapterName);
  5411. }
  5412. CoTaskMemFree(pAdapterName);
  5413. }
  5414. CoTaskMemFree(pAdapterGuid);
  5415. }
  5416. return fDHCP;
  5417. }