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

1733 lines
59 KiB

  1. //*********************************************************************
  2. //* Microsoft Windows **
  3. //* Copyright(c) Microsoft Corp., 1994 **
  4. //*********************************************************************
  5. //
  6. // ISPUPGUI.C - Functions for Wizard pages to use existing Internet Service Provider
  7. // (ISP) -- e.g. upgrade
  8. //
  9. // HISTORY:
  10. //
  11. // 1/6/95 jeremys Created.
  12. // 96/03/09 markdu Moved all references to 'need terminal window after
  13. // dial' into RASENTRY.dwfOptions.
  14. // 96/03/10 markdu Moved all references to modem name into RASENTRY.
  15. // 96/03/10 markdu Moved all references to phone number into RASENTRY.
  16. // 96/03/23 markdu Replaced CLIENTINFO references with CLIENTCONFIG.
  17. // 96/03/24 markdu Replaced memset with ZeroMemory for consistency.
  18. // 96/03/25 markdu If a fatal error occurs, set gfQuitWizard.
  19. // 96/03/26 markdu Store values from UI even when back is pressed.
  20. // 96/04/04 markdu Added phonebook name param to ValidateConnectoidName.
  21. // 96/04/07 markdu NASH BUG 15645 Enable phone number controls based on
  22. // user's selection for dial-as-is checkbox. Don't require an
  23. // area code when dial-as-is selected.
  24. // 96/05/06 markdu NASH BUG 15637 Removed unused code.
  25. //
  26. #include "wizard.h"
  27. #include "icwextsn.h"
  28. #include "icwaprtc.h"
  29. #include "imnext.h"
  30. #include "pagefcns.h"
  31. #define TAB_PAGES 2
  32. INT_PTR CALLBACK TabConnDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
  33. INT_PTR CALLBACK TabAddrDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
  34. VOID EnableWizard(HWND hDlg,BOOL fEnable);
  35. VOID EnableConnectionControls(HWND hDlg);
  36. VOID EnablePhoneNumberControls(HWND hDlg);
  37. VOID EnableScriptControls(HWND hDlg);
  38. DWORD BrowseScriptFile(HWND hDlg);
  39. BOOL CALLBACK AdvancedDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam,
  40. LPARAM lParam);
  41. // This flag is used to indicate that gpRasEntry has been filled with
  42. // data from a connectoid at some point.
  43. BOOL fEntryHasBeenLoaded = FALSE;
  44. DWORD gdwDefCountryID = 0;
  45. /*******************************************************************
  46. NAME: ConnectionInitProc
  47. SYNOPSIS: Called when page is displayed
  48. ENTRY: hDlg - dialog window
  49. fFirstInit - TRUE if this is the first time the dialog
  50. is initialized, FALSE if this InitProc has been called
  51. before (e.g. went past this page and backed up)
  52. Note that code in HowToConnectOKProc ensures that if we make it
  53. here, there is at least one connectoid on the system
  54. ********************************************************************/
  55. BOOL CALLBACK ConnectionInitProc(HWND hDlg,BOOL fFirstInit)
  56. {
  57. if (fFirstInit)
  58. {
  59. // populate the connectoid list box with list of connectoids
  60. InitConnectoidList(GetDlgItem(hDlg,IDC_ISPNAME),gpUserInfo->szISPName);
  61. ProcessDBCS(hDlg, IDC_ISPNAME);
  62. // // Set fields
  63. // CheckDlgButton(hDlg,IDC_NEWCONNECTION,gpUserInfo->fNewConnection);
  64. // CheckDlgButton(hDlg,IDC_EXISTINGCONNECTION,!gpUserInfo->fNewConnection);
  65. // store a default selection in the listbox if there isn't
  66. // currently a default
  67. if( LB_ERR == ListBox_GetCurSel(GetDlgItem(hDlg,IDC_ISPNAME)) )
  68. {
  69. ListBox_SetCurSel(GetDlgItem(hDlg,IDC_ISPNAME), 0);
  70. //
  71. // ChrisK Olympus 7509 6/25/97
  72. // If the default was not set, then don't select Existing connection
  73. //
  74. // Set fields
  75. CheckDlgButton(hDlg,IDC_NEWCONNECTION,TRUE);
  76. CheckDlgButton(hDlg,IDC_EXISTINGCONNECTION,FALSE);
  77. }
  78. else
  79. {
  80. //
  81. // If there is a default already selected, then select "Use an
  82. // existing connection".
  83. //
  84. CheckDlgButton(hDlg,IDC_NEWCONNECTION,FALSE);
  85. CheckDlgButton(hDlg,IDC_EXISTINGCONNECTION,TRUE);
  86. }
  87. EnableConnectionControls(hDlg);
  88. // load in strings for the description paragraph
  89. TCHAR szWhole[ (2 * MAX_RES_LEN) + 1] = TEXT("\0");
  90. TCHAR szTemp[ MAX_RES_LEN + 1] = TEXT("nothing\0");
  91. LoadSz(IDS_CONNECTION_DESC1,szTemp,sizeof(szTemp));
  92. lstrcat( szWhole, szTemp );
  93. LoadSz(IDS_CONNECTION_DESC2,szTemp,sizeof(szTemp));
  94. lstrcat( szWhole, szTemp );
  95. SetWindowText (GetDlgItem(hDlg,IDC_DESC), szWhole);
  96. }
  97. // if we've travelled through external apprentice pages,
  98. // it's easy for our current page pointer to get munged,
  99. // so reset it here for sanity's sake.
  100. gpWizardState->uCurrentPage = ORD_PAGE_CONNECTION;
  101. return FALSE;
  102. }
  103. /*******************************************************************
  104. NAME: ConnectionOKProc
  105. SYNOPSIS: Called when Next or Back btns pressed from page
  106. ENTRY: hDlg - dialog window
  107. fForward - TRUE if 'Next' was pressed, FALSE if 'Back'
  108. puNextPage - if 'Next' was pressed,
  109. proc can fill this in with next page to go to. This
  110. parameter is ingored if 'Back' was pressed.
  111. pfKeepHistory - page will not be kept in history if
  112. proc fills this in with FALSE.
  113. EXIT: returns TRUE to allow page to be turned, FALSE
  114. to keep the same page.
  115. ********************************************************************/
  116. BOOL CALLBACK ConnectionOKProc(HWND hDlg,BOOL fForward,UINT * puNextPage,
  117. BOOL * pfKeepHistory)
  118. {
  119. ASSERT(puNextPage);
  120. if (fForward)
  121. {
  122. gpUserInfo->fNewConnection = IsDlgButtonChecked(hDlg, IDC_NEWCONNECTION);
  123. if (gpUserInfo->fNewConnection)
  124. {
  125. if (gfFirstNewConnection)
  126. {
  127. // The first time through we want to set everything to default
  128. // for the novice user. If the user backs up and returns to
  129. // create new connection, we want to leave whatever was there
  130. // from before.
  131. gfFirstNewConnection = FALSE;
  132. // set the connectoid entries to their defaults
  133. InitRasEntry(gpRasEntry);
  134. gpUserInfo->fModifyConnection = FALSE;
  135. gpUserInfo->fModifyAdvanced = FALSE;
  136. gpUserInfo->fAutoDNS = TRUE;
  137. gpUserInfo->szISPName[0] = '\0';
  138. }
  139. // 5/8/97 jmazner Olympus #4108
  140. // move connectionName to the end
  141. //*puNextPage = ORD_PAGE_CONNECTIONNAME;
  142. *puNextPage = ORD_PAGE_PHONENUMBER;
  143. }
  144. else
  145. {
  146. // Copy the current name into a temp for comparison purposes
  147. TCHAR szISPNameTmp[MAX_ISP_NAME + 1];
  148. lstrcpy(szISPNameTmp, gpUserInfo->szISPName);
  149. // get ISP name from UI
  150. ListBox_GetText(GetDlgItem(hDlg,IDC_ISPNAME),
  151. ListBox_GetCurSel(GetDlgItem(hDlg,IDC_ISPNAME)),
  152. gpUserInfo->szISPName);
  153. // If the entry we pulled from the UI does NOT match our
  154. // string, we want to process this entry name
  155. // since we have not seen this entry yet.
  156. // If we have already loaded the data for this entry, though,
  157. // we don't want to mess with it since the user may have gone ahead.
  158. // changed something, and then come back.
  159. // Note: The first time through, the entry will match even
  160. // though we haven't yet loaded the data, so we have to check the flag.
  161. if ((FALSE == fEntryHasBeenLoaded) ||
  162. lstrcmp(gpUserInfo->szISPName, szISPNameTmp))
  163. {
  164. // Since we are going to either reinit the RASENTRY struct
  165. // or load an existing one over top, we need to store
  166. // all info we have collected so far
  167. TCHAR szDeviceNameTmp[RAS_MaxDeviceName + 1];
  168. TCHAR szDeviceTypeTmp[RAS_MaxDeviceType + 1];
  169. lstrcpy(szDeviceNameTmp, gpRasEntry->szDeviceName);
  170. lstrcpy(szDeviceTypeTmp, gpRasEntry->szDeviceType);
  171. // Get dialing params for this connectoid
  172. DWORD dwRet = GetEntry(&gpRasEntry, &gdwRasEntrySize, gpUserInfo->szISPName);
  173. if (ERROR_SUCCESS != dwRet)
  174. {
  175. // For some reason we failed, initialize back to defaults and
  176. // ask user to select a different one
  177. InitRasEntry(gpRasEntry);
  178. DisplayFieldErrorMsg(hDlg,IDC_ISPNAME,IDS_ERRCorruptConnection);
  179. return FALSE;
  180. }
  181. GetConnectoidUsername(gpUserInfo->szISPName,gpUserInfo->szAccountName,
  182. ARRAYSIZE(gpUserInfo->szAccountName),gpUserInfo->szPassword,
  183. ARRAYSIZE(gpUserInfo->szPassword));
  184. // Restore the data from temporary variables.
  185. lstrcpy(gpRasEntry->szDeviceName, szDeviceNameTmp);
  186. lstrcpy(gpRasEntry->szDeviceType, szDeviceTypeTmp);
  187. // Set the flag to indicate that we have done this once
  188. fEntryHasBeenLoaded = TRUE;
  189. }
  190. // set next page to go to
  191. if( gpWizardState->dwRunFlags & RSW_APPRENTICE )
  192. {
  193. // we're about to jump back to the external wizard, and we don't want
  194. // this page to show up in our history list
  195. *pfKeepHistory = FALSE;
  196. *puNextPage = g_uExternUINext;
  197. //Notify the main Wizard that this was the last page
  198. ASSERT( g_pExternalIICWExtension )
  199. if (g_fIsExternalWizard97)
  200. g_pExternalIICWExtension->SetFirstLastPage(0, IDD_PAGE_CONNECTION97);
  201. else
  202. g_pExternalIICWExtension->SetFirstLastPage(0, IDD_PAGE_CONNECTION);
  203. g_fConnectionInfoValid = TRUE;
  204. }
  205. else
  206. *puNextPage = ORD_PAGE_MODIFYCONNECTION;
  207. }
  208. }
  209. return TRUE;
  210. }
  211. /*******************************************************************
  212. NAME: ConnectionCmdProc
  213. SYNOPSIS: Called when dlg control pressed on page
  214. ENTRY: hDlg - dialog window
  215. uCtrlID - control ID of control that was touched
  216. ********************************************************************/
  217. BOOL CALLBACK ConnectionCmdProc(HWND hDlg,WPARAM wParam,LPARAM lParam)
  218. {
  219. switch (GET_WM_COMMAND_ID(wParam, lParam))
  220. {
  221. case IDC_NEWCONNECTION:
  222. case IDC_EXISTINGCONNECTION:
  223. // if check box selected, enable controls appropriately
  224. EnableConnectionControls(hDlg);
  225. break;
  226. }
  227. return TRUE;
  228. }
  229. /*******************************************************************
  230. NAME: EnableConnectionControls
  231. SYNOPSIS: If "Use existing connection" is checked, enable controls
  232. existing connections. If not, disable them.
  233. ********************************************************************/
  234. VOID EnableConnectionControls(HWND hDlg)
  235. {
  236. static int iSelection = -1;
  237. static BOOL bCurStateNew = FALSE;
  238. BOOL fNew = IsDlgButtonChecked(hDlg,IDC_NEWCONNECTION);
  239. // jmazner 11/9/96 Normandy #8469 and #8293
  240. if (fNew)
  241. {
  242. // if user uses the keybd arrows to go from "new" to "existing",
  243. // we get called _twice_ here; once when "new" is still checked,
  244. // and then again when we're expecting it. This screws us up,
  245. // because in the first call, the list box is disabled and cur
  246. // sel is set to -1, and that gets written into iSelection,
  247. // obliterating the value we were saving. So use the bCurStateNew
  248. // flag to prevent this.
  249. if( bCurStateNew )
  250. return;
  251. bCurStateNew = TRUE;
  252. // save, and then clear out current selection before disabling
  253. // note that if there's no selection, GetCurSel returns LB_ERR,
  254. // but we want to save -1, since that's what we use in SetCurSel
  255. // to remove all selections.
  256. iSelection = ListBox_GetCurSel(GetDlgItem(hDlg,IDC_ISPNAME));
  257. if( LB_ERR == iSelection )
  258. iSelection = -1;
  259. ListBox_SetCurSel(GetDlgItem(hDlg,IDC_ISPNAME), -1);
  260. EnableDlgItem(hDlg,IDC_ISPNAME,FALSE);
  261. }
  262. else
  263. {
  264. bCurStateNew = FALSE;
  265. EnableDlgItem(hDlg,IDC_ISPNAME,TRUE);
  266. ListBox_SetCurSel(GetDlgItem(hDlg,IDC_ISPNAME), iSelection);
  267. }
  268. }
  269. /*******************************************************************
  270. NAME: ModifyConnectionInitProc
  271. SYNOPSIS: Called when page is displayed
  272. ENTRY: hDlg - dialog window
  273. fFirstInit - TRUE if this is the first time the dialog
  274. is initialized, FALSE if this InitProc has been called
  275. before (e.g. went past this page and backed up)
  276. ********************************************************************/
  277. BOOL CALLBACK ModifyConnectionInitProc(HWND hDlg,BOOL fFirstInit)
  278. {
  279. static TCHAR szCurConnectoid[MAX_ISP_NAME + 1] = TEXT("");
  280. if (fFirstInit)
  281. {
  282. TCHAR szMsg[MAX_RES_LEN + MAX_ISP_NAME + 1];
  283. TCHAR szFmt[MAX_RES_LEN+1];
  284. LoadSz(IDS_MODIFYCONNECTION,szFmt,sizeof(szFmt));
  285. wsprintf(szMsg,szFmt,gpUserInfo->szISPName);
  286. ProcessDBCS(hDlg, IDC_LBLMODIFYCONNECTION);
  287. SetDlgItemText(hDlg,IDC_LBLMODIFYCONNECTION,szMsg);
  288. // keep track of current connectoid name for future compares
  289. lstrcpyn( szCurConnectoid, gpUserInfo->szISPName, MAX_ISP_NAME );
  290. CheckDlgButton(hDlg,IDC_MODIFYCONNECTION,gpUserInfo->fModifyConnection);
  291. CheckDlgButton(hDlg,IDC_NOMODIFYCONNECTION,!(gpUserInfo->fModifyConnection));
  292. }
  293. else
  294. {
  295. // jmazner 11/9/96 Normandy #10605
  296. // if the user changed connectoids, update the dialog text
  297. if( lstrcmp(szCurConnectoid, gpUserInfo->szISPName) )
  298. {
  299. TCHAR szMsg[MAX_RES_LEN + MAX_ISP_NAME + 1];
  300. TCHAR szFmt[MAX_RES_LEN+1];
  301. LoadSz(IDS_MODIFYCONNECTION,szFmt,sizeof(szFmt));
  302. wsprintf(szMsg,szFmt,gpUserInfo->szISPName);
  303. SetDlgItemText(hDlg,IDC_LBLMODIFYCONNECTION,szMsg);
  304. // store new connectoid name for future compares
  305. lstrcpyn( szCurConnectoid, gpUserInfo->szISPName, MAX_ISP_NAME );
  306. }
  307. }
  308. // if we've travelled through external apprentice pages,
  309. // it's easy for our current page pointer to get munged,
  310. // so reset it here for sanity's sake.
  311. gpWizardState->uCurrentPage = ORD_PAGE_MODIFYCONNECTION;
  312. return TRUE;
  313. }
  314. /*******************************************************************
  315. NAME: ModifyConnectionOKProc
  316. SYNOPSIS: Called when Next or Back btns pressed from page
  317. ENTRY: hDlg - dialog window
  318. fForward - TRUE if 'Next' was pressed, FALSE if 'Back'
  319. puNextPage - if 'Next' was pressed,
  320. proc can fill this in with next page to go to. This
  321. parameter is ingored if 'Back' was pressed.
  322. pfKeepHistory - page will not be kept in history if
  323. proc fills this in with FALSE.
  324. EXIT: returns TRUE to allow page to be turned, FALSE
  325. to keep the same page.
  326. ********************************************************************/
  327. BOOL CALLBACK ModifyConnectionOKProc(HWND hDlg,BOOL fForward,UINT * puNextPage,
  328. BOOL * pfKeepHistory)
  329. {
  330. ASSERT(puNextPage);
  331. OSVERSIONINFO osver;
  332. if (fForward)
  333. {
  334. // we can not programatically alter a CSLIP connection. So if they picked
  335. // one, do not allow them to continue down the "modify" path.
  336. if ( (RASFP_Slip == gpRasEntry->dwFramingProtocol)
  337. && (RASEO_IpHeaderCompression & gpRasEntry->dwfOptions) &&
  338. IsDlgButtonChecked(hDlg, IDC_MODIFYCONNECTION))
  339. {
  340. ZeroMemory(&osver,sizeof(osver));
  341. osver.dwOSVersionInfoSize = sizeof(osver);
  342. GetVersionEx(&osver);
  343. if (VER_PLATFORM_WIN32_WINDOWS == osver.dwPlatformId)
  344. {
  345. MsgBox(hDlg,IDS_ERRModifyCSLIP,MB_ICONEXCLAMATION,MB_OK);
  346. return FALSE;
  347. }
  348. }
  349. gpUserInfo->fModifyConnection = IsDlgButtonChecked(hDlg, IDC_MODIFYCONNECTION);
  350. if (gpUserInfo->fModifyConnection)
  351. {
  352. *puNextPage = ORD_PAGE_PHONENUMBER;
  353. }
  354. else
  355. {
  356. if( gpWizardState->dwRunFlags & RSW_APPRENTICE )
  357. {
  358. // we're about to jump back to the external wizard, and we don't want
  359. // this page to show up in our history list
  360. *pfKeepHistory = FALSE;
  361. *puNextPage = g_uExternUINext;
  362. //Notify the main Wizard that this was the last page
  363. ASSERT( g_pExternalIICWExtension )
  364. if (g_fIsExternalWizard97)
  365. g_pExternalIICWExtension->SetFirstLastPage(0, IDD_PAGE_MODIFYCONNECTION97);
  366. else
  367. g_pExternalIICWExtension->SetFirstLastPage(0, IDD_PAGE_MODIFYCONNECTION);
  368. g_fConnectionInfoValid = TRUE;
  369. }
  370. else if( LoadAcctMgrUI(GetParent(hDlg),
  371. g_fIsWizard97 ? IDD_PAGE_MODIFYCONNECTION97 : IDD_PAGE_MODIFYCONNECTION,
  372. g_fIsWizard97 ? IDD_PAGE_CONNECTEDOK97FIRSTLAST : IDD_PAGE_CONNECTEDOK,
  373. g_fIsWizard97 ? WIZ_USE_WIZARD97 : 0) )
  374. {
  375. if( DialogIDAlreadyInUse( g_uAcctMgrUIFirst) )
  376. {
  377. // we're about to jump into the external apprentice, and we don't want
  378. // this page to show up in our history list
  379. *pfKeepHistory = FALSE;
  380. *puNextPage = g_uAcctMgrUIFirst;
  381. }
  382. else
  383. {
  384. DEBUGMSG("hmm, the first acctMgr dlg id is supposedly %d, but it's not marked as in use!",
  385. g_uAcctMgrUIFirst);
  386. *puNextPage = (g_fIsICW ? g_uExternUINext : ORD_PAGE_CONNECTEDOK);
  387. }
  388. }
  389. else
  390. {
  391. DEBUGMSG("LoadAcctMgrUI returned false, guess we'd better skip over it!");
  392. *puNextPage = (g_fIsICW ? g_uExternUINext : ORD_PAGE_CONNECTEDOK);
  393. }
  394. }
  395. }
  396. return TRUE;
  397. }
  398. /*******************************************************************
  399. NAME: ConnectionNameInitProc
  400. SYNOPSIS: Called when page is displayed
  401. ENTRY: hDlg - dialog window
  402. fFirstInit - TRUE if this is the first time the dialog
  403. is initialized, FALSE if this InitProc has been called
  404. before (e.g. went past this page and backed up)
  405. ********************************************************************/
  406. BOOL CALLBACK ConnectionNameInitProc(HWND hDlg,BOOL fFirstInit)
  407. {
  408. if (fFirstInit)
  409. {
  410. // limit text fields appropriately
  411. SendDlgItemMessage(hDlg,IDC_CONNECTIONNAME,EM_LIMITTEXT,
  412. MAX_ISP_NAME,0L);
  413. ProcessDBCS(hDlg, IDC_CONNECTIONNAME);
  414. }
  415. // fill text fields
  416. //
  417. // 5/17/97 jmazner Olympus #4608 and 4108
  418. // do this in all cases to pick up any changes from the
  419. // PhoneNumber pae.
  420. //
  421. SetDlgItemText(hDlg,IDC_CONNECTIONNAME,gpUserInfo->szISPName);
  422. return TRUE;
  423. }
  424. /*******************************************************************
  425. NAME: ConnectionNameOKProc
  426. SYNOPSIS: Called when Next or Back btns pressed from page
  427. ENTRY: hDlg - dialog window
  428. fForward - TRUE if 'Next' was pressed, FALSE if 'Back'
  429. puNextPage - if 'Next' was pressed,
  430. proc can fill this in with next page to go to. This
  431. parameter is ingored if 'Back' was pressed.
  432. pfKeepHistory - page will not be kept in history if
  433. proc fills this in with FALSE.
  434. EXIT: returns TRUE to allow page to be turned, FALSE
  435. to keep the same page.
  436. ********************************************************************/
  437. BOOL CALLBACK ConnectionNameOKProc(HWND hDlg,BOOL fForward,UINT * puNextPage,
  438. BOOL * pfKeepHistory)
  439. {
  440. ASSERT(puNextPage);
  441. // 5/8/97 jmazner Olympus #4108
  442. // reworked this function to take into acct that this page is now
  443. // at the _end_ of the series of dialogs, so it shouln't try to
  444. // fill in defaults.
  445. //
  446. // get ISP name from UI
  447. //
  448. // 5/17/97 jmazner Olympus #4108 update (see also #4608)
  449. // Do this even if we're going backwards so that the default name code in
  450. // PhoneNumberOKProc will know if the user has changed the connectoid name.
  451. //
  452. GetDlgItemText(hDlg,IDC_CONNECTIONNAME,gpUserInfo->szISPName,
  453. ARRAYSIZE(gpUserInfo->szISPName));
  454. if (fForward)
  455. {
  456. // Copy the current name into a temp for comparison purposes
  457. //CHAR szISPNameTmp[MAX_ISP_NAME + 1];
  458. //lstrcpy(szISPNameTmp, gpUserInfo->szISPName);
  459. // make sure user typed a service provider name
  460. if (!lstrlen(gpUserInfo->szISPName))
  461. {
  462. DisplayFieldErrorMsg(hDlg,IDC_CONNECTIONNAME,IDS_NEED_ISPNAME);
  463. return FALSE;
  464. }
  465. // validate the ISP name, which will be used later as the
  466. // name of an RNA connectoid
  467. DWORD dwRet = ValidateConnectoidName(NULL, gpUserInfo->szISPName);
  468. if (dwRet == ERROR_ALREADY_EXISTS)
  469. {
  470. DisplayFieldErrorMsg(hDlg,IDC_CONNECTIONNAME,IDS_ERRDuplicateConnectoidName);
  471. return FALSE;
  472. }
  473. else if (dwRet != ERROR_SUCCESS)
  474. {
  475. // 12/19/96 jmazner Normandy #12890
  476. // Legal connectoid names are different under w95 and NT
  477. if( IsNT() )
  478. {
  479. MsgBoxParam(hDlg,IDS_ERRConnectoidNameNT,MB_ICONEXCLAMATION,MB_OK,
  480. gpUserInfo->szISPName);
  481. }
  482. else
  483. {
  484. MsgBoxParam(hDlg,IDS_ERRConnectoidName95,MB_ICONEXCLAMATION,MB_OK,
  485. gpUserInfo->szISPName);
  486. }
  487. // 12/17/96 jmazner Normandy #12851
  488. // if the validate failed, remove the name from the UserInfo struct
  489. gpUserInfo->szISPName[0] = '\0';
  490. // select ISP name in dialog and fail the OK command
  491. SetFocus(GetDlgItem(hDlg,IDC_CONNECTIONNAME));
  492. SendDlgItemMessage(hDlg,IDC_CONNECTIONNAME,EM_SETSEL,0,-1);
  493. return FALSE;
  494. }
  495. /**
  496. if ((FALSE == fEntryHasBeenLoaded) ||
  497. lstrcmp(gpUserInfo->szISPName, szISPNameTmp))
  498. {
  499. // Since we are going to either reinit the RASENTRY struct
  500. // or load an existing one over top, we need to store
  501. // all info we have collected so far
  502. TCHAR szDeviceNameTmp[RAS_MaxDeviceName + 1];
  503. TCHAR szDeviceTypeTmp[RAS_MaxDeviceType + 1];
  504. lstrcpy(szDeviceNameTmp, gpRasEntry->szDeviceName);
  505. lstrcpy(szDeviceTypeTmp, gpRasEntry->szDeviceType);
  506. // validate the ISP name, which will be used later as the
  507. // name of an RNA connectoid
  508. DWORD dwRet = ValidateConnectoidName(NULL, gpUserInfo->szISPName);
  509. if (dwRet == ERROR_ALREADY_EXISTS)
  510. {
  511. // this connectoid already exists. Re-use it, and get
  512. // dialing params for this connectoid
  513. dwRet = GetEntry(&gpRasEntry, &gdwRasEntrySize, gpUserInfo->szISPName);
  514. if (ERROR_SUCCESS != dwRet)
  515. {
  516. // For some reason we failed, so just re-init to default
  517. InitRasEntry(gpRasEntry);
  518. }
  519. GetConnectoidUsername(gpUserInfo->szISPName,gpUserInfo->szAccountName,
  520. sizeof(gpUserInfo->szAccountName),gpUserInfo->szPassword,
  521. sizeof(gpUserInfo->szPassword));
  522. }
  523. else if (dwRet != ERROR_SUCCESS)
  524. {
  525. // 12/19/96 jmazner Normandy #12890
  526. // Legal connectoid names are different under w95 and NT
  527. if( IsNT() )
  528. {
  529. MsgBoxParam(hDlg,IDS_ERRConnectoidNameNT,MB_ICONEXCLAMATION,MB_OK,
  530. gpUserInfo->szISPName);
  531. }
  532. else
  533. {
  534. MsgBoxParam(hDlg,IDS_ERRConnectoidName95,MB_ICONEXCLAMATION,MB_OK,
  535. gpUserInfo->szISPName);
  536. }
  537. // 12/17/96 jmazner Normandy #12851
  538. // if the validate failed, remove the name from the UserInfo struct
  539. gpUserInfo->szISPName[0] = '\0';
  540. // select ISP name in dialog and fail the OK command
  541. SetFocus(GetDlgItem(hDlg,IDC_CONNECTIONNAME));
  542. SendDlgItemMessage(hDlg,IDC_CONNECTIONNAME,EM_SETSEL,0,-1);
  543. return FALSE;
  544. }
  545. else
  546. {
  547. // Normandy 13018 - ChrisK 1-9-97
  548. // Default username has been set to <blank>
  549. //// this connectoid doesn't exist yet. Clear out connectoid-specifc
  550. //// information from user struct, because we might have
  551. //// info from other connectoids in struct if user chose a connectoid,
  552. //// then backed up and typed a different name
  553. //GetDefaultUserName(gpUserInfo->szAccountName,sizeof(gpUserInfo->szAccountName));
  554. gpUserInfo->szAccountName[0] = '\0';
  555. gpUserInfo->szPassword[0] = '\0';
  556. // initialize the rasentry structure
  557. InitRasEntry(gpRasEntry);
  558. }
  559. // Restore the data from temporary variables.
  560. lstrcpy(gpRasEntry->szDeviceName, szDeviceNameTmp);
  561. lstrcpy(gpRasEntry->szDeviceType, szDeviceTypeTmp);
  562. // Set the flag to indicate that we have done this once
  563. fEntryHasBeenLoaded = TRUE;
  564. }
  565. **/
  566. // set next page to go to
  567. //*puNextPage = ORD_PAGE_PHONENUMBER;
  568. if( gpWizardState->dwRunFlags & RSW_APPRENTICE )
  569. {
  570. // we're about to jump back to the external wizard, and we don't want
  571. // this page to show up in our history list
  572. *pfKeepHistory = FALSE;
  573. *puNextPage = g_uExternUINext;
  574. //Notify the main Wizard that this was the last page
  575. ASSERT( g_pExternalIICWExtension )
  576. if (g_fIsExternalWizard97)
  577. g_pExternalIICWExtension->SetFirstLastPage(0, IDD_PAGE_CONNECTIONNAME97);
  578. else
  579. g_pExternalIICWExtension->SetFirstLastPage(0, IDD_PAGE_CONNECTIONNAME);
  580. g_fConnectionInfoValid = TRUE;
  581. }
  582. else if( LoadAcctMgrUI(GetParent(hDlg),
  583. g_fIsWizard97 ? IDD_PAGE_CONNECTIONNAME97 : IDD_PAGE_CONNECTIONNAME,
  584. g_fIsWizard97 ? IDD_PAGE_CONNECTEDOK97FIRSTLAST : IDD_PAGE_CONNECTEDOK,
  585. g_fIsWizard97 ? WIZ_USE_WIZARD97 : 0) )
  586. {
  587. if( DialogIDAlreadyInUse( g_uAcctMgrUIFirst) )
  588. {
  589. // we're about to jump into the external apprentice, and we don't want
  590. // this page to show up in our history list
  591. *pfKeepHistory = FALSE;
  592. *puNextPage = g_uAcctMgrUIFirst;
  593. }
  594. else
  595. {
  596. DEBUGMSG("hmm, the first acctMgr dlg id is supposedly %d, but it's not marked as in use!",
  597. g_uAcctMgrUIFirst);
  598. *puNextPage = (g_fIsICW ? g_uExternUINext : ORD_PAGE_CONNECTEDOK);
  599. }
  600. }
  601. else
  602. {
  603. DEBUGMSG("LoadAcctMgrUI returned false, guess we'd better skip over it!");
  604. *puNextPage = (g_fIsICW ? g_uExternUINext : ORD_PAGE_CONNECTEDOK);
  605. }
  606. }
  607. return TRUE;
  608. }
  609. /*******************************************************************
  610. NAME: PhoneNumberInitProc
  611. SYNOPSIS: Called when page is displayed
  612. ENTRY: hDlg - dialog window
  613. fFirstInit - TRUE if this is the first time the dialog
  614. is initialized, FALSE if this InitProc has been called
  615. before (e.g. went past this page and backed up)
  616. ********************************************************************/
  617. BOOL CALLBACK PhoneNumberInitProc(HWND hDlg,BOOL fFirstInit)
  618. {
  619. if (IsNT5())
  620. {
  621. TCHAR szTemp[ MAX_RES_LEN + 1] = TEXT("\0");
  622. LoadSz(IDS_USEDIALRULES, szTemp, sizeof(szTemp));
  623. SetWindowText(GetDlgItem(hDlg, IDC_USEDIALRULES), szTemp);
  624. }
  625. if (fFirstInit)
  626. {
  627. // limit text fields appropriately
  628. SendDlgItemMessage(hDlg,IDC_AREACODE,EM_LIMITTEXT,
  629. MAX_UI_AREA_CODE,0L);
  630. SendDlgItemMessage(hDlg,IDC_PHONENUMBER,EM_LIMITTEXT,
  631. MAX_UI_PHONENUM,0L);
  632. // initialize text fields
  633. SetDlgItemText(hDlg,IDC_AREACODE,gpRasEntry->szAreaCode);
  634. SetDlgItemText(hDlg,IDC_PHONENUMBER,gpRasEntry->szLocalPhoneNumber);
  635. // initialize dial-as-is checkbox
  636. CheckDlgButton(hDlg,IDC_USEDIALRULES,
  637. gpRasEntry->dwfOptions & RASEO_UseCountryAndAreaCodes);
  638. }
  639. else
  640. {
  641. ProcessDBCS(hDlg, IDC_COUNTRYCODE);
  642. //
  643. // 5/17/97 jmazner Olympus #4608
  644. // if user didn't have a modem when they started down the manual path,
  645. // then InitRasEntry couldn't fill in an area code. If it looks
  646. // like that happened, try calling InitRasEntry again.
  647. //
  648. // 6/3/97 jmazner Olympus #5657
  649. // Ah, but if Dial-as-is is selected, there probably won't be an area
  650. // code. So don't re-init in that case.
  651. //
  652. // 7/16/97 jmazner Olympus #9571
  653. // the saga continues -- there are some cases (eg: Kuwait) where it's
  654. // perfectly valid to have an empty area code but still use TAPI
  655. // dialing rules. To make life easier, move this code into HowToConnectOKProc
  656. // so that we call it _before_ any user information has been entered into the
  657. // gpRasEntry struct.
  658. //
  659. //if( (NULL == gpRasEntry->szAreaCode[0]) &&
  660. // (gpRasEntry->dwfOptions & RASEO_UseCountryAndAreaCodes) )
  661. //{
  662. // InitRasEntry( gpRasEntry );
  663. //}
  664. HWND hwndCB = GetDlgItem(hDlg,IDC_COUNTRYCODE);
  665. // put default RNA country code in combo box
  666. InitCountryCodeList(hwndCB);
  667. // Normandy 13097 - ChrisK 1/8/97
  668. // The default selection should be based on the Country ID not the code
  669. // select country ID if we already have a default
  670. if (gdwDefCountryID)
  671. {
  672. gpRasEntry->dwCountryID = gdwDefCountryID;
  673. if (!SetCountryIDSelection(hwndCB, gdwDefCountryID))
  674. {
  675. // country code for default connectoid is not the same
  676. // as default RNA country code, fill in the listbox with
  677. // all country codes and then try selection again
  678. FillCountryCodeList(hwndCB);
  679. // if this one fails, then just give up
  680. BOOL fRet=SetCountryIDSelection(hwndCB, gdwDefCountryID);
  681. ASSERT(fRet);
  682. }
  683. }
  684. // enable controls appropriately
  685. EnablePhoneNumberControls(hDlg);
  686. }
  687. gpWizardState->uCurrentPage = ORD_PAGE_PHONENUMBER;
  688. return TRUE;
  689. }
  690. /*******************************************************************
  691. NAME: PhoneNumberOKProc
  692. SYNOPSIS: Called when Next or Back btns pressed from page
  693. ENTRY: hDlg - dialog window
  694. fForward - TRUE if 'Next' was pressed, FALSE if 'Back'
  695. puNextPage - if 'Next' was pressed,
  696. proc can fill this in with next page to go to. This
  697. parameter is ingored if 'Back' was pressed.
  698. pfKeepHistory - page will not be kept in history if
  699. proc fills this in with FALSE.
  700. EXIT: returns TRUE to allow page to be turned, FALSE
  701. to keep the same page.
  702. ********************************************************************/
  703. BOOL CALLBACK PhoneNumberOKProc(HWND hDlg,BOOL fForward,UINT * puNextPage,
  704. BOOL * pfKeepHistory)
  705. {
  706. static TCHAR s_szPreviousDefaultName[MAX_ISP_NAME+1] = TEXT("\0uninitialized");
  707. TCHAR szNewDefaultName[MAX_ISP_NAME + 1] = TEXT("\0");
  708. ASSERT(puNextPage);
  709. // get area code and phone number out of dialog
  710. GetDlgItemText(hDlg,IDC_AREACODE,gpRasEntry->szAreaCode,
  711. ARRAYSIZE(gpRasEntry->szAreaCode));
  712. GetDlgItemText(hDlg,IDC_PHONENUMBER,gpRasEntry->szLocalPhoneNumber,
  713. ARRAYSIZE(gpRasEntry->szLocalPhoneNumber));
  714. // get selected country code from combo box
  715. LPCOUNTRYCODE lpCountryCode;
  716. GetCountryCodeSelection(GetDlgItem(hDlg,IDC_COUNTRYCODE),&lpCountryCode);
  717. // Store country code info in our struct
  718. gpRasEntry->dwCountryCode = lpCountryCode->dwCountryCode;
  719. gpRasEntry->dwCountryID = lpCountryCode->dwCountryID;
  720. gdwDefCountryID = gpRasEntry->dwCountryID;
  721. // set the dial-as-is flag appropriately;
  722. if (IsDlgButtonChecked(hDlg,IDC_USEDIALRULES))
  723. {
  724. gpRasEntry->dwfOptions |= RASEO_UseCountryAndAreaCodes;
  725. }
  726. else
  727. {
  728. gpRasEntry->dwfOptions &= ~RASEO_UseCountryAndAreaCodes;
  729. }
  730. if (fForward)
  731. {
  732. // make sure user typed in a phone number
  733. if (!lstrlen(gpRasEntry->szLocalPhoneNumber))
  734. {
  735. DisplayFieldErrorMsg(hDlg,IDC_PHONENUMBER,IDS_NEED_PHONENUMBER);
  736. return FALSE;
  737. }
  738. // 11/11/96 jmazner Normandy #7623
  739. // make sure phone number has only valid chars
  740. //
  741. // 5/17/97 jmazner Olympus #137
  742. // that includes checking for DBCS chars.
  743. #if !defined(WIN16)
  744. if (!IsSBCSString(gpRasEntry->szLocalPhoneNumber))
  745. {
  746. DisplayFieldErrorMsg(hDlg,IDC_PHONENUMBER,IDS_SBCSONLY);
  747. return FALSE;
  748. }
  749. #endif
  750. if( !IsDialableString(gpRasEntry->szLocalPhoneNumber) )
  751. {
  752. DisplayFieldErrorMsg(hDlg,IDC_PHONENUMBER,IDS_INVALIDPHONE);
  753. return FALSE;
  754. }
  755. // 11/11/96 jmazner Normandy #7623
  756. // make sure area code has only valid chars
  757. #if !defined(WIN16)
  758. if( gpRasEntry->szAreaCode[0] && !IsSBCSString(gpRasEntry->szAreaCode))
  759. {
  760. DisplayFieldErrorMsg(hDlg,IDC_AREACODE,IDS_SBCSONLY);
  761. return FALSE;
  762. }
  763. #endif
  764. if( gpRasEntry->szAreaCode[0] && !IsDialableString(gpRasEntry->szAreaCode) )
  765. {
  766. DisplayFieldErrorMsg(hDlg,IDC_AREACODE,IDS_INVALIDPHONE);
  767. return FALSE;
  768. }
  769. // make sure user typed in an area code unless dial-as-is was chosen
  770. /* if ((!lstrlen(gpRasEntry->szAreaCode)) &&
  771. (!IsDlgButtonChecked(hDlg,IDC_DIALASIS)))
  772. {
  773. DisplayFieldErrorMsg(hDlg,IDC_AREACODE,IDS_NEED_AREACODE);
  774. return FALSE;
  775. }
  776. */
  777. // 5/8/97 jmazner Olympus #4108
  778. // prepopulate connectoid name with "Connection to xxx-xxxx"
  779. if( gpUserInfo->szISPName )
  780. {
  781. TCHAR szFmt[MAX_ISP_NAME + 1];
  782. ZeroMemory(&szFmt, MAX_ISP_NAME + 1);
  783. LoadSz(IDS_CONNECTIONTO,szFmt, MAX_ISP_NAME + 1);
  784. wsprintf(szNewDefaultName, szFmt, gpRasEntry->szLocalPhoneNumber );
  785. if( (NULL == gpUserInfo->szISPName[0]) ||
  786. (0 == lstrcmp(s_szPreviousDefaultName, gpUserInfo->szISPName)) )
  787. {
  788. lstrcpy( gpUserInfo->szISPName, szNewDefaultName );
  789. lstrcpy( s_szPreviousDefaultName, szNewDefaultName );
  790. }
  791. }
  792. *puNextPage = ORD_PAGE_NAMEANDPASSWORD;
  793. }
  794. // free country code list buffer
  795. DeInitCountryCodeList();
  796. return TRUE;
  797. }
  798. BOOL RunAdvDlg(HWND hDlg)
  799. {
  800. HPROPSHEETPAGE hWizPage[TAB_PAGES]; // array to hold handles to pages
  801. PROPSHEETPAGE psPage; // struct used to create prop sheet pages
  802. PROPSHEETHEADER psHeader; // struct used to run wizard property sheet
  803. INT_PTR iRet;
  804. TCHAR szTemp[MAX_RES_LEN + 1];
  805. // zero out structures
  806. ZeroMemory(&hWizPage,sizeof(hWizPage)); // hWizPage is an array
  807. ZeroMemory(&psPage,sizeof(PROPSHEETPAGE));
  808. ZeroMemory(&psHeader,sizeof(PROPSHEETHEADER));
  809. // fill out common data property sheet page struct
  810. psPage.dwSize = sizeof(PROPSHEETPAGE);
  811. psPage.hInstance = ghInstance;
  812. psPage.dwFlags = PSP_DEFAULT | PSP_USETITLE;
  813. // create a property sheet page for each page in the wizard
  814. // create a property sheet page for the connection tab
  815. psPage.pszTemplate = MAKEINTRESOURCE(IDD_ADVANCE_TAB_CONN);
  816. LoadSz(IDS_CONNECTION, szTemp, MAX_RES_LEN);
  817. psPage.pszTitle = szTemp;
  818. psPage.pfnDlgProc = TabConnDlgProc;
  819. hWizPage[0] = CreatePropertySheetPage(&psPage);
  820. // create a property sheet page for the address tab
  821. psPage.pszTemplate = MAKEINTRESOURCE(IDD_ADVANCE_TAB_ADDR);
  822. LoadSz(IDS_ADDRESS, szTemp, MAX_RES_LEN);
  823. psPage.pszTitle = szTemp;
  824. psPage.pfnDlgProc = TabAddrDlgProc;
  825. hWizPage[1] = CreatePropertySheetPage(&psPage);
  826. if (!hWizPage[1])
  827. DestroyPropertySheetPage(hWizPage[0]);
  828. // fill out property sheet header struct
  829. psHeader.dwSize = sizeof(psHeader);
  830. psHeader.dwFlags = PSH_NOAPPLYNOW;
  831. psHeader.hwndParent = hDlg;
  832. psHeader.hInstance = ghInstance;
  833. psHeader.nPages = TAB_PAGES;
  834. psHeader.phpage = hWizPage;
  835. LoadSz(IDS_ADVANCE_PROPERTIES, szTemp, MAX_RES_LEN);
  836. psHeader.pszCaption = szTemp;
  837. psHeader.nStartPage = 0;
  838. HINSTANCE hComCtl = LoadLibrary(TEXT("comctl32.dll"));
  839. if (hComCtl)
  840. {
  841. PFNInitCommonControlsEx pfnInitCommonControlsEx = NULL;
  842. if (pfnInitCommonControlsEx = (PFNInitCommonControlsEx)GetProcAddress(hComCtl,"InitCommonControlsEx"))
  843. {
  844. //register the Native font control so the dialog won't fail
  845. INITCOMMONCONTROLSEX iccex;
  846. iccex.dwSize = sizeof(INITCOMMONCONTROLSEX);
  847. iccex.dwICC = ICC_NATIVEFNTCTL_CLASS;
  848. if (!pfnInitCommonControlsEx(&iccex))
  849. return FALSE;
  850. }
  851. FreeLibrary(hComCtl);
  852. }
  853. // run the Wizard
  854. iRet = PropertySheet(&psHeader);
  855. return (iRet > 0);
  856. }
  857. /*******************************************************************
  858. NAME: PhoneNumberCmdProc
  859. SYNOPSIS: Called when dlg control pressed on page
  860. ENTRY: hDlg - dialog window
  861. uCtrlID - control ID of control that was touched
  862. ********************************************************************/
  863. BOOL CALLBACK PhoneNumberCmdProc(HWND hDlg,WPARAM wParam,LPARAM lParam)
  864. {
  865. switch (GET_WM_COMMAND_ID(wParam, lParam)) {
  866. case IDC_USEDIALRULES:
  867. // if check box selected, enable controls appropriately
  868. EnablePhoneNumberControls(hDlg);
  869. break;
  870. case IDC_COUNTRYCODE:
  871. FillCountryCodeList(GetDlgItem(hDlg,IDC_COUNTRYCODE));
  872. break;
  873. case IDC_MODIFYADVANCED:
  874. // if check box selected, enable controls appropriately
  875. RASENTRY pRasEntry;
  876. // Store the current setting now. If later user canceled we can reset them all back
  877. // We are doing this because at this moment we don't want to break up the
  878. // the verifying and saving code into 2 big steps because the verifcation and the saving
  879. // are self contained in 4 individual ok procs. ( originally in 4 different advance pages )
  880. // It is too much work to regroup them into
  881. // two separate operations.
  882. memcpy(&pRasEntry, gpRasEntry, sizeof(RASENTRY));
  883. if (!RunAdvDlg(hDlg))
  884. {
  885. memcpy(gpRasEntry, &pRasEntry, sizeof(RASENTRY));
  886. }
  887. break;
  888. }
  889. return TRUE;
  890. }
  891. /*******************************************************************
  892. NAME: EnablePhoneNumberControls
  893. SYNOPSIS: If "Don't use country code..." is checked, disable controls for
  894. area code and country code. If not, enable them.
  895. ********************************************************************/
  896. VOID EnablePhoneNumberControls(HWND hDlg)
  897. {
  898. BOOL fUseDialRules = IsDlgButtonChecked(hDlg,IDC_USEDIALRULES);
  899. EnableDlgItem(hDlg,IDC_AREACODE,fUseDialRules);
  900. EnableDlgItem(hDlg,IDC_TX_AREACODE,fUseDialRules);
  901. EnableDlgItem(hDlg,IDC_TX_SEPARATOR,fUseDialRules);
  902. EnableDlgItem(hDlg,IDC_COUNTRYCODE,fUseDialRules);
  903. EnableDlgItem(hDlg,IDC_TX_COUNTRYCODE,fUseDialRules);
  904. }
  905. /*******************************************************************
  906. NAME: NameAndPasswordInitProc
  907. SYNOPSIS: Called when page is displayed
  908. ENTRY: hDlg - dialog window
  909. fFirstInit - TRUE if this is the first time the dialog
  910. is initialized, FALSE if this InitProc has been called
  911. before (e.g. went past this page and backed up)
  912. ********************************************************************/
  913. BOOL CALLBACK NameAndPasswordInitProc(HWND hDlg,BOOL fFirstInit)
  914. {
  915. if (fFirstInit)
  916. {
  917. //
  918. // 7/30/97 jmazner Olympus 1111
  919. //
  920. ProcessDBCS( hDlg, IDC_USERNAME );
  921. // limit text fields appropriately
  922. SendDlgItemMessage(hDlg,IDC_USERNAME,EM_LIMITTEXT,
  923. MAX_ISP_USERNAME,0L);
  924. SendDlgItemMessage(hDlg,IDC_PASSWORD,EM_LIMITTEXT,
  925. MAX_ISP_PASSWORD,0L);
  926. SetDlgItemText(hDlg,IDC_USERNAME,gpUserInfo->szAccountName);
  927. SetDlgItemText(hDlg,IDC_PASSWORD,gpUserInfo->szPassword);
  928. }
  929. return TRUE;
  930. }
  931. /*******************************************************************
  932. NAME: NameAndPasswordOKProc
  933. SYNOPSIS: Called when Next or Back btns pressed from page
  934. ENTRY: hDlg - dialog window
  935. fForward - TRUE if 'Next' was pressed, FALSE if 'Back'
  936. puNextPage - if 'Next' was pressed,
  937. proc can fill this in with next page to go to. This
  938. parameter is ingored if 'Back' was pressed.
  939. pfKeepHistory - page will not be kept in history if
  940. proc fills this in with FALSE.
  941. EXIT: returns TRUE to allow page to be turned, FALSE
  942. to keep the same page.
  943. ********************************************************************/
  944. BOOL CALLBACK NameAndPasswordOKProc(HWND hDlg,BOOL fForward,UINT * puNextPage,
  945. BOOL * pfKeepHistory)
  946. {
  947. ASSERT(puNextPage);
  948. // get user name and password from UI
  949. GetDlgItemText(hDlg,IDC_USERNAME,gpUserInfo->szAccountName,
  950. ARRAYSIZE(gpUserInfo->szAccountName));
  951. GetDlgItemText(hDlg,IDC_PASSWORD,gpUserInfo->szPassword,
  952. ARRAYSIZE(gpUserInfo->szPassword));
  953. if (fForward)
  954. {
  955. // warn (but allow user to proceed) if username is blank
  956. if (!lstrlen(gpUserInfo->szAccountName))
  957. {
  958. if (!WarnFieldIsEmpty(hDlg,IDC_USERNAME,IDS_WARN_EMPTY_USERNAME))
  959. return FALSE; // stay on this page if user heeds warning
  960. }
  961. //
  962. // 5/17/97 jmazner Olympus #248
  963. // warn if password is empty
  964. //
  965. if (!lstrlen(gpUserInfo->szPassword))
  966. {
  967. if (!WarnFieldIsEmpty(hDlg,IDC_PASSWORD,IDS_WARN_EMPTY_PASSWORD))
  968. return FALSE; // stay on this page if user heeds warning
  969. }
  970. // set next page to go to
  971. if (gpUserInfo->fNewConnection)
  972. {
  973. *puNextPage = ORD_PAGE_CONNECTIONNAME;
  974. }
  975. else if( gpWizardState->dwRunFlags & RSW_APPRENTICE )
  976. {
  977. // we're about to jump back to the external wizard, and we don't want
  978. // this page to show up in our history list
  979. *pfKeepHistory = FALSE;
  980. *puNextPage = g_uExternUINext;
  981. //Notify the main Wizard that this was the last page
  982. ASSERT( g_pExternalIICWExtension )
  983. if (g_fIsExternalWizard97)
  984. g_pExternalIICWExtension->SetFirstLastPage(0, IDD_PAGE_NAMEANDPASSWORD97);
  985. else
  986. g_pExternalIICWExtension->SetFirstLastPage(0, IDD_PAGE_NAMEANDPASSWORD);
  987. g_fConnectionInfoValid = TRUE;
  988. }
  989. else if( LoadAcctMgrUI(GetParent(hDlg),
  990. g_fIsWizard97 ? IDD_PAGE_NAMEANDPASSWORD97 : IDD_PAGE_NAMEANDPASSWORD,
  991. g_fIsWizard97 ? IDD_PAGE_CONNECTEDOK97FIRSTLAST : IDD_PAGE_CONNECTEDOK,
  992. g_fIsWizard97 ? WIZ_USE_WIZARD97 : 0) )
  993. {
  994. if( DialogIDAlreadyInUse( g_uAcctMgrUIFirst) )
  995. {
  996. // we're about to jump into the external apprentice, and we don't want
  997. // this page to show up in our history list
  998. *pfKeepHistory = FALSE;
  999. *puNextPage = g_uAcctMgrUIFirst;
  1000. }
  1001. else
  1002. {
  1003. DEBUGMSG("hmm, the first acctMgr dlg id is supposedly %d, but it's not marked as in use!",
  1004. g_uAcctMgrUIFirst);
  1005. *puNextPage = (g_fIsICW ? g_uExternUINext : ORD_PAGE_CONNECTEDOK);
  1006. }
  1007. }
  1008. else
  1009. {
  1010. DEBUGMSG("LoadAcctMgrUI returned false, guess we'd better skip over it!");
  1011. *puNextPage = (g_fIsICW ? g_uExternUINext : ORD_PAGE_CONNECTEDOK);
  1012. }
  1013. }
  1014. return TRUE;
  1015. }
  1016. /*******************************************************************
  1017. NAME: TabConnDlgProc
  1018. SYNOPSIS: Dialog proc for Connection advanced button
  1019. ********************************************************************/
  1020. INT_PTR CALLBACK TabConnDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam,
  1021. LPARAM lParam)
  1022. {
  1023. switch (uMsg)
  1024. {
  1025. case WM_INITDIALOG:
  1026. {
  1027. //Remove the system menu from the window's style
  1028. LONG window_style = GetWindowLong(GetParent(hDlg), GWL_EXSTYLE);
  1029. window_style &= ~WS_EX_CONTEXTHELP;
  1030. //set the style attribute of the main frame window
  1031. SetWindowLong(GetParent(hDlg), GWL_EXSTYLE, window_style);
  1032. ConnectionProtocolInitProc(hDlg, TRUE);
  1033. LoginScriptInitProc(hDlg, TRUE);
  1034. break;
  1035. }
  1036. case WM_COMMAND:
  1037. {
  1038. switch (LOWORD(wParam))
  1039. {
  1040. case IDC_BROWSE:
  1041. BrowseScriptFile(hDlg);
  1042. break;
  1043. case IDC_PROTOCOLPPP:
  1044. case IDC_PROTOCOLSLIP:
  1045. case IDC_PROTOCOLCSLIP:
  1046. // set next page to go to
  1047. EnableWindow(GetDlgItem(hDlg,IDC_DISABLELCP), FALSE);
  1048. if (IsDlgButtonChecked(hDlg, IDC_PROTOCOLPPP))
  1049. {
  1050. OSVERSIONINFO osver;
  1051. ZeroMemory(&osver,sizeof(osver));
  1052. osver.dwOSVersionInfoSize = sizeof(osver);
  1053. GetVersionEx(&osver);
  1054. // LCP extensions only effect PPP connections in NT
  1055. if (VER_PLATFORM_WIN32_NT == osver.dwPlatformId)
  1056. EnableWindow(GetDlgItem(hDlg,IDC_DISABLELCP), TRUE);
  1057. }
  1058. break;
  1059. default:
  1060. LoginScriptCmdProc(hDlg, LOWORD(wParam));
  1061. break;
  1062. }
  1063. break;
  1064. }
  1065. case WM_NOTIFY:
  1066. {
  1067. NMHDR * lpnm = (NMHDR *) lParam;
  1068. switch (lpnm->code)
  1069. {
  1070. case PSN_KILLACTIVE:
  1071. {
  1072. if (!ConnectionProtocolOKProc(hDlg))
  1073. {
  1074. SetWindowLongPtr(hDlg, DWLP_MSGRESULT, TRUE);
  1075. return TRUE;
  1076. }
  1077. if (!LoginScriptOKProc(hDlg))
  1078. {
  1079. SetWindowLongPtr(hDlg, DWLP_MSGRESULT, TRUE);
  1080. return TRUE;
  1081. }
  1082. }
  1083. }
  1084. break;
  1085. }
  1086. }
  1087. return FALSE;
  1088. }
  1089. /*******************************************************************
  1090. NAME: TabConnDlgProc
  1091. SYNOPSIS: Dialog proc for Connection advanced button
  1092. ********************************************************************/
  1093. INT_PTR CALLBACK TabAddrDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam,
  1094. LPARAM lParam)
  1095. {
  1096. switch (uMsg)
  1097. {
  1098. case WM_INITDIALOG:
  1099. {
  1100. IPAddressInitProc(hDlg, TRUE);
  1101. DNSAddressInitProc(hDlg, TRUE);
  1102. break;
  1103. }
  1104. case WM_COMMAND:
  1105. {
  1106. IPAddressCmdProc(hDlg, LOWORD(wParam));
  1107. DNSAddressCmdProc(hDlg, LOWORD(wParam));
  1108. break;
  1109. }
  1110. case WM_NOTIFY:
  1111. {
  1112. NMHDR * lpnm = (NMHDR *) lParam;
  1113. switch (lpnm->code)
  1114. {
  1115. case PSN_KILLACTIVE:
  1116. {
  1117. if (!IPAddressOKProc(hDlg))
  1118. {
  1119. SetWindowLongPtr(hDlg, DWLP_MSGRESULT, TRUE);
  1120. return TRUE;
  1121. }
  1122. if (!DNSAddressOKProc(hDlg))
  1123. {
  1124. SetWindowLongPtr(hDlg, DWLP_MSGRESULT, TRUE);
  1125. return TRUE;
  1126. }
  1127. }
  1128. }
  1129. break;
  1130. }
  1131. }
  1132. return FALSE;
  1133. }
  1134. /*******************************************************************
  1135. NAME: ConnectionProtocolInitProc
  1136. SYNOPSIS: Called when page is displayed
  1137. ENTRY: hDlg - dialog window
  1138. fFirstInit - TRUE if this is the first time the dialog
  1139. is initialized, FALSE if this InitProc has been called
  1140. before (e.g. went past this page and backed up)
  1141. ********************************************************************/
  1142. BOOL CALLBACK ConnectionProtocolInitProc(HWND hDlg,BOOL fFirstInit)
  1143. {
  1144. if (fFirstInit)
  1145. {
  1146. OSVERSIONINFO osver;
  1147. ZeroMemory(&osver,sizeof(osver));
  1148. osver.dwOSVersionInfoSize = sizeof(osver);
  1149. GetVersionEx(&osver);
  1150. if (VER_PLATFORM_WIN32_WINDOWS == osver.dwPlatformId)
  1151. {
  1152. RECT Rect;
  1153. RECT OriginalRect;
  1154. ShowWindow(GetDlgItem(hDlg,IDC_PROTOCOLCSLIP),SW_HIDE);
  1155. EnableWindow(GetDlgItem(hDlg,IDC_PROTOCOLCSLIP), FALSE);
  1156. ShowWindow(GetDlgItem(hDlg,IDC_DISABLELCP),SW_HIDE);
  1157. EnableWindow(GetDlgItem(hDlg,IDC_DISABLELCP), FALSE);
  1158. GetWindowRect(GetDlgItem(hDlg,IDC_PROTOCOLSLIP), &Rect);
  1159. GetWindowRect(GetDlgItem(hDlg,IDC_PROTOCOLCSLIP), &OriginalRect);
  1160. // assume that if it's Japanese, and it's not NT, it must be win95J!
  1161. RECT itemRect;
  1162. POINT thePoint;
  1163. HWND hwndItem = GetDlgItem(hDlg,IDC_PROTOCOLSLIP);
  1164. GetWindowRect(hwndItem, &itemRect);
  1165. // need to convert the coords from global to local client,
  1166. // since MoveWindow below will expext client coords.
  1167. thePoint.x = itemRect.left;
  1168. thePoint.y = itemRect.top;
  1169. ScreenToClient(hDlg, &thePoint );
  1170. itemRect.left = thePoint.x;
  1171. itemRect.top = thePoint.y;
  1172. thePoint.x = itemRect.right;
  1173. thePoint.y = itemRect.bottom;
  1174. ScreenToClient(hDlg, &thePoint );
  1175. itemRect.right = thePoint.x;
  1176. itemRect.bottom = thePoint.y;
  1177. MoveWindow(hwndItem,
  1178. itemRect.left,
  1179. itemRect.top - (OriginalRect.top - Rect.top),
  1180. (itemRect.right - itemRect.left),
  1181. (itemRect.bottom - itemRect.top), TRUE);
  1182. }
  1183. // initialize radio buttons, default to PPP
  1184. CheckDlgButton(hDlg,IDC_PROTOCOLPPP,RASFP_Ppp == gpRasEntry->dwFramingProtocol);
  1185. EnableWindow(GetDlgItem(hDlg,IDC_DISABLELCP), FALSE);
  1186. if (IsDlgButtonChecked(hDlg, IDC_PROTOCOLPPP))
  1187. {
  1188. OSVERSIONINFO osver;
  1189. ZeroMemory(&osver,sizeof(osver));
  1190. osver.dwOSVersionInfoSize = sizeof(osver);
  1191. GetVersionEx(&osver);
  1192. if ((RASFP_Ppp == gpRasEntry->dwFramingProtocol) &&
  1193. (VER_PLATFORM_WIN32_NT == osver.dwPlatformId))
  1194. {
  1195. // LCP extensions only effect PPP connections
  1196. EnableWindow(GetDlgItem(hDlg,IDC_DISABLELCP), TRUE);
  1197. }
  1198. }
  1199. CheckDlgButton(hDlg,IDC_DISABLELCP,(RASEO_DisableLcpExtensions & gpRasEntry->dwfOptions));
  1200. CheckDlgButton(hDlg,IDC_PROTOCOLSLIP,(RASFP_Slip == gpRasEntry->dwFramingProtocol)
  1201. && !(gpRasEntry->dwfOptions & RASEO_IpHeaderCompression));
  1202. CheckDlgButton(hDlg,IDC_PROTOCOLCSLIP,(RASFP_Slip == gpRasEntry->dwFramingProtocol)
  1203. && (gpRasEntry->dwfOptions & RASEO_IpHeaderCompression));
  1204. }
  1205. return TRUE;
  1206. }
  1207. /*******************************************************************
  1208. NAME: ConnectionProtocolOKProc
  1209. SYNOPSIS: Called when Next or Back btns pressed from page
  1210. ENTRY: hDlg - dialog window
  1211. fForward - TRUE if 'Next' was pressed, FALSE if 'Back'
  1212. puNextPage - if 'Next' was pressed,
  1213. proc can fill this in with next page to go to. This
  1214. parameter is ingored if 'Back' was pressed.
  1215. pfKeepHistory - page will not be kept in history if
  1216. proc fills this in with FALSE.
  1217. EXIT: returns TRUE to allow page to be turned, FALSE
  1218. to keep the same page.
  1219. ********************************************************************/
  1220. BOOL CALLBACK ConnectionProtocolOKProc(HWND hDlg)
  1221. {
  1222. ASSERT(puNextPage);
  1223. // read radio button state
  1224. if (IsDlgButtonChecked(hDlg, IDC_PROTOCOLPPP))
  1225. {
  1226. // Set entry for PPP
  1227. gpRasEntry->dwfOptions |= RASEO_IpHeaderCompression;
  1228. gpRasEntry->dwFramingProtocol = RASFP_Ppp;
  1229. if (IsDlgButtonChecked(hDlg, IDC_DISABLELCP))
  1230. {
  1231. gpRasEntry->dwfOptions |= RASEO_DisableLcpExtensions;
  1232. }
  1233. else
  1234. {
  1235. gpRasEntry->dwfOptions &= ~(RASEO_DisableLcpExtensions);
  1236. }
  1237. }
  1238. else if (IsDlgButtonChecked(hDlg, IDC_PROTOCOLSLIP))
  1239. {
  1240. // Set entry for SLIP
  1241. gpRasEntry->dwfOptions &= ~RASEO_IpHeaderCompression;
  1242. gpRasEntry->dwFramingProtocol = RASFP_Slip;
  1243. }
  1244. else if (IsDlgButtonChecked(hDlg, IDC_PROTOCOLCSLIP))
  1245. {
  1246. // Set entry for C-SLIP
  1247. gpRasEntry->dwfOptions |= RASEO_IpHeaderCompression;
  1248. gpRasEntry->dwFramingProtocol = RASFP_Slip;
  1249. }
  1250. return TRUE;
  1251. }
  1252. /*******************************************************************
  1253. NAME: LoginScriptInitProc
  1254. SYNOPSIS: Called when page is displayed
  1255. ENTRY: hDlg - dialog window
  1256. fFirstInit - TRUE if this is the first time the dialog
  1257. is initialized, FALSE if this InitProc has been called
  1258. before (e.g. went past this page and backed up)
  1259. ********************************************************************/
  1260. BOOL CALLBACK LoginScriptInitProc(HWND hDlg,BOOL fFirstInit)
  1261. {
  1262. if (fFirstInit)
  1263. {
  1264. // Set limit on edit box
  1265. SendDlgItemMessage(hDlg,IDC_SCRIPTFILE,EM_LIMITTEXT,
  1266. MAX_PATH,0L);
  1267. ProcessDBCS(hDlg, IDC_SCRIPTFILE);
  1268. // If there is a script file, default to use script
  1269. // If no script file, base selection on whether or not
  1270. // a post-dial terminal window is desired.
  1271. if (lstrlen(gpRasEntry->szScript))
  1272. {
  1273. CheckDlgButton(hDlg,IDC_NOTERMINALAFTERDIAL,FALSE);
  1274. CheckDlgButton(hDlg,IDC_TERMINALAFTERDIAL,FALSE);
  1275. CheckDlgButton(hDlg,IDC_SCRIPT,TRUE);
  1276. SetDlgItemText(hDlg,IDC_SCRIPTFILE,gpRasEntry->szScript);
  1277. // set focus to the script text field
  1278. SetFocus(GetDlgItem(hDlg,IDC_SCRIPTFILE));
  1279. }
  1280. else
  1281. {
  1282. BOOL fTerminalWindow = (gpRasEntry->dwfOptions & RASEO_TerminalAfterDial);
  1283. CheckDlgButton(hDlg,IDC_NOTERMINALAFTERDIAL,!fTerminalWindow);
  1284. CheckDlgButton(hDlg,IDC_TERMINALAFTERDIAL,fTerminalWindow);
  1285. CheckDlgButton(hDlg,IDC_SCRIPT,FALSE);
  1286. }
  1287. }
  1288. // enable script controls appropriately
  1289. EnableScriptControls(hDlg);
  1290. return TRUE;
  1291. }
  1292. /*******************************************************************
  1293. NAME: LoginScriptOKProc
  1294. SYNOPSIS: Called when Next or Back btns pressed from page
  1295. ENTRY: hDlg - dialog window
  1296. fForward - TRUE if 'Next' was pressed, FALSE if 'Back'
  1297. puNextPage - if 'Next' was pressed,
  1298. proc can fill this in with next page to go to. This
  1299. parameter is ingored if 'Back' was pressed.
  1300. pfKeepHistory - page will not be kept in history if
  1301. proc fills this in with FALSE.
  1302. EXIT: returns TRUE to allow page to be turned, FALSE
  1303. to keep the same page.
  1304. ********************************************************************/
  1305. BOOL CALLBACK LoginScriptOKProc(HWND hDlg)
  1306. {
  1307. ASSERT(puNextPage);
  1308. // read radio button state
  1309. if (IsDlgButtonChecked(hDlg, IDC_NOTERMINALAFTERDIAL))
  1310. {
  1311. // Set entry for no terminal window or script
  1312. gpRasEntry->dwfOptions &= ~RASEO_TerminalAfterDial;
  1313. lstrcpy(gpRasEntry->szScript, szNull);
  1314. }
  1315. else if (IsDlgButtonChecked(hDlg, IDC_TERMINALAFTERDIAL))
  1316. {
  1317. // Set entry for terminal window and no script
  1318. gpRasEntry->dwfOptions |= RASEO_TerminalAfterDial;
  1319. lstrcpy(gpRasEntry->szScript, szNull);
  1320. }
  1321. else if (IsDlgButtonChecked(hDlg, IDC_SCRIPT))
  1322. {
  1323. // Set entry for script, but no terminal window
  1324. gpRasEntry->dwfOptions &= ~RASEO_TerminalAfterDial;
  1325. GetDlgItemText(hDlg,IDC_SCRIPTFILE,gpRasEntry->szScript,
  1326. ARRAYSIZE(gpRasEntry->szScript));
  1327. }
  1328. if(IsDlgButtonChecked(hDlg, IDC_SCRIPT))
  1329. {
  1330. if( 0xFFFFFFFF == GetFileAttributes(gpRasEntry->szScript))
  1331. {
  1332. DisplayFieldErrorMsg(hDlg,IDC_SCRIPTFILE,IDS_LOGINSCRIPTINVALID);
  1333. return FALSE;
  1334. }
  1335. }
  1336. return TRUE;
  1337. }
  1338. /*******************************************************************
  1339. NAME: LoginScriptCmdProc
  1340. SYNOPSIS: Called when dlg control pressed on page
  1341. ENTRY: hDlg - dialog window
  1342. uCtrlID - control ID of control that was touched
  1343. ********************************************************************/
  1344. BOOL CALLBACK LoginScriptCmdProc(HWND hDlg,UINT uCtrlID)
  1345. {
  1346. switch (uCtrlID)
  1347. {
  1348. case IDC_NOTERMINALAFTERDIAL:
  1349. case IDC_TERMINALAFTERDIAL:
  1350. case IDC_SCRIPT:
  1351. // if radio buttons pushed, enable script controls appropriately
  1352. EnableScriptControls(hDlg);
  1353. break;
  1354. case IDC_BROWSE:
  1355. BrowseScriptFile(hDlg);
  1356. break;
  1357. }
  1358. return TRUE;
  1359. }
  1360. /*******************************************************************
  1361. NAME: EnableScriptControls
  1362. SYNOPSIS: If "Use this script" is checked, enable controls for
  1363. browsing. If not, disable them.
  1364. ********************************************************************/
  1365. VOID EnableScriptControls(HWND hDlg)
  1366. {
  1367. BOOL fUseScript = IsDlgButtonChecked(hDlg,IDC_SCRIPT);
  1368. EnableDlgItem(hDlg,IDC_SCRIPT_LABEL,fUseScript);
  1369. EnableDlgItem(hDlg,IDC_SCRIPTFILE,fUseScript);
  1370. EnableDlgItem(hDlg,IDC_BROWSE,fUseScript);
  1371. }
  1372. //****************************************************************************
  1373. // DWORD BrowseScriptFile (HWND)
  1374. //
  1375. // This function taken from RNA
  1376. //
  1377. // History:
  1378. // Tue 08-Nov-1994 09:14:13 -by- Viroon Touranachun [viroont]
  1379. // Created.
  1380. //****************************************************************************
  1381. DWORD BrowseScriptFile(HWND hDlg)
  1382. {
  1383. OPENFILENAME ofn;
  1384. LPTSTR pszFiles, szFileName, szFilter;
  1385. DWORD dwRet;
  1386. // Allocate filename buffer
  1387. //
  1388. if ((pszFiles = (LPTSTR)LocalAlloc(LPTR, 2*MAX_PATH*sizeof(TCHAR))) == NULL)
  1389. return ERROR_OUTOFMEMORY;
  1390. szFileName = pszFiles;
  1391. szFilter = szFileName+MAX_PATH;
  1392. // Start file browser dialog
  1393. //
  1394. LoadString(ghInstance, IDS_SCRIPT_FILE_FILTER, szFilter, MAX_PATH);
  1395. *szFileName = '\0';
  1396. ofn.lStructSize = sizeof(ofn);
  1397. ofn.hwndOwner = hDlg;
  1398. ofn.hInstance = ghInstance;
  1399. ofn.lpstrFilter = szFilter;
  1400. ofn.lpstrCustomFilter = NULL;
  1401. ofn.nMaxCustFilter = 0;
  1402. ofn.nFilterIndex = 2;
  1403. ofn.lpstrFile = szFileName;
  1404. ofn.nMaxFile = MAX_PATH;
  1405. ofn.lpstrFileTitle = NULL;
  1406. ofn.nMaxFileTitle = 0;
  1407. ofn.lpstrInitialDir = NULL;
  1408. ofn.lpstrTitle = NULL;
  1409. ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
  1410. ofn.nFileOffset = 0;
  1411. ofn.nFileExtension = 0;
  1412. ofn.lpstrDefExt = NULL;
  1413. ofn.lCustData = 0;
  1414. ofn.lpfnHook = NULL;
  1415. ofn.lpTemplateName = NULL;
  1416. if (GetOpenFileName(&ofn))
  1417. {
  1418. // Set the filename to a new name
  1419. //
  1420. SetDlgItemText(hDlg,IDC_SCRIPTFILE,szFileName);
  1421. dwRet = ERROR_SUCCESS;
  1422. }
  1423. else
  1424. {
  1425. dwRet = ERROR_OPEN_FAILED;
  1426. };
  1427. LocalFree(pszFiles);
  1428. return dwRet;
  1429. }