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

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