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.

4059 lines
124 KiB

  1. //Copyright (c) 1998 - 1999 Microsoft Corporation
  2. /*******************************************************************************
  3. *
  4. * ewsdlg.cpp
  5. *
  6. * implementation of CEditWinStationDlg dialog class
  7. *
  8. * copyright notice: Copyright 1995, Citrix Systems Inc.
  9. *
  10. * $Author: thanhl $ Butch Davis
  11. *
  12. * $Log: N:\NT\PRIVATE\UTILS\CITRIX\WINUTILS\TSCFG\VCS\EWSDLG.CPP $
  13. *
  14. * Rev 1.51 04 May 1998 13:14:50 thanhl
  15. * MS bug#2090 fix
  16. *
  17. * Rev 1.50 18 Apr 1998 15:31:18 donm
  18. * Added capability bits
  19. *
  20. * Rev 1.49 Feb 21 1998 12:58:56 grega
  21. *
  22. *
  23. * Rev 1.47 28 Jan 1998 14:08:36 donm
  24. * sets default encryption and grays out control properly
  25. *
  26. * Rev 1.46 13 Jan 1998 14:08:26 donm
  27. * gets encryption levels from extension DLL
  28. *
  29. * Rev 1.45 10 Dec 1997 15:59:20 donm
  30. * added ability to have extension DLLs
  31. *
  32. * Rev 1.44 16 Sep 1997 09:16:30 butchd
  33. * delayed network transport error till OnOK
  34. *
  35. * Rev 1.43 29 Jul 1997 11:10:54 butchd
  36. * Don't allow editing of Max WinStation Count during rename
  37. *
  38. * Rev 1.42 15 Jul 1997 17:08:34 thanhl
  39. * Add support for Required PDs
  40. *
  41. * Rev 1.41 27 Jun 1997 15:58:26 butchd
  42. * Registry changes for Wds/Tds/Pds/Cds
  43. *
  44. * Rev 1.40 19 Jun 1997 19:22:14 kurtp
  45. * update
  46. *
  47. * Rev 1.39 18 Jun 1997 15:13:32 butchd
  48. * Hydrix split
  49. *
  50. * Rev 1.38 19 May 1997 14:34:42 butchd
  51. * ifdef out NASICALL dependancies
  52. *
  53. * Rev 1.37 03 May 1997 19:06:28 butchd
  54. * look out for RAS-configured modems
  55. *
  56. * Rev 1.36 25 Apr 1997 11:07:18 butchd
  57. * update
  58. *
  59. * Rev 1.35 25 Mar 1997 09:00:04 butchd
  60. * update
  61. *
  62. * Rev 1.34 21 Mar 1997 16:26:10 butchd
  63. * update
  64. *
  65. * Rev 1.33 11 Mar 1997 15:37:18 donm
  66. * update
  67. *
  68. * Rev 1.32 03 Mar 1997 17:14:24 butchd
  69. * update
  70. *
  71. * Rev 1.31 28 Feb 1997 17:59:32 butchd
  72. * update
  73. *
  74. * Rev 1.30 18 Dec 1996 16:02:04 butchd
  75. * update
  76. *
  77. * Rev 1.29 15 Oct 1996 09:11:12 butchd
  78. * update
  79. *
  80. *******************************************************************************/
  81. /*
  82. * include files
  83. */
  84. #include "stdafx.h"
  85. #include "wincfg.h"
  86. //#include <citrix\nasicall.h>// for InitializeNASIPortNames() NASI enum call
  87. #include <hydra\oemtdapi.h>// for OemTdxxx APIs
  88. #include "appsvdoc.h"
  89. #include "ewsdlg.h"
  90. #include "atdlg.h"
  91. #include "anasidlg.h"
  92. #define INITGUID
  93. #include "objbase.h"
  94. #include "initguid.h"
  95. #include <netcfgx.h>
  96. #include "devguid.h"
  97. #ifdef _DEBUG
  98. #undef THIS_FILE
  99. static char BASED_CODE THIS_FILE[] = __FILE__;
  100. #endif
  101. extern CWincfgApp *pApp;
  102. extern "C" LPCTSTR WinUtilsAppName;
  103. extern "C" HWND WinUtilsAppWindow;
  104. extern "C" HINSTANCE WinUtilsAppInstance;
  105. /*
  106. * Global command line variables.
  107. */
  108. extern USHORT g_Install;
  109. extern USHORT g_Add;
  110. extern WDNAME g_szType;
  111. extern PDNAME g_szTransport;
  112. extern ULONG g_ulCount;
  113. #define RELEASEPTR(iPointer) if(iPointer) \
  114. { \
  115. iPointer->Release(); \
  116. iPointer = NULL; \
  117. }
  118. ////////////////////////////////////////////////////////////////////////////////
  119. // CEditWinStationDlg class construction / destruction, implementation
  120. /*******************************************************************************
  121. *
  122. * CEditWinStationDlg - CEditWinStationDlg constructor
  123. *
  124. * ENTRY:
  125. * pDoc (input)
  126. * Points to CAppServerDoc; current document.
  127. * EXIT:
  128. * (Refer to MFC CDialog::CDialog documentation)
  129. *
  130. ******************************************************************************/
  131. CEditWinStationDlg::CEditWinStationDlg( CAppServerDoc *pDoc )
  132. : CBaseDialog(CEditWinStationDlg::IDD),
  133. m_pDoc(pDoc),
  134. m_bAsyncListsInitialized(FALSE),
  135. m_nPreviousMaxTAPILineNumber(-1),
  136. m_nCurrentMaxTAPILineNumber(-1),
  137. m_nComboBoxIndexOfLatestTAPIDevice(-1),
  138. m_pCurrentTdList(NULL),
  139. m_pCurrentPdList(NULL)
  140. {
  141. //{{AFX_DATA_INIT(CEditWinStationDlg)
  142. //}}AFX_DATA_INIT
  143. /*
  144. * Zero-initialize the NASICONFIG member structure.
  145. */
  146. memset(&m_NASIConfig, 0, sizeof(m_NASIConfig));
  147. } // end CEditWinStationDlg::CEditWinStationDlg
  148. ////////////////////////////////////////////////////////////////////////////////
  149. // CEditWinStationDlg operations
  150. /*******************************************************************************
  151. *
  152. * RefrenceAssociatedLists -
  153. * CEditWinStationDlg member function: protected operation
  154. *
  155. * Set the m_pCurrentTdList and m_pCurrentPdList members to point to the
  156. * lists associated with the currently selected Wd (Type).
  157. *
  158. * ENTRY:
  159. * EXIT:
  160. *
  161. ******************************************************************************/
  162. void
  163. CEditWinStationDlg::RefrenceAssociatedLists()
  164. {
  165. int index, count, currentcount;
  166. POSITION pos;
  167. CComboBox *pWdNameBox = (CComboBox *)GetDlgItem(IDC_WDNAME);
  168. if ( (index = pWdNameBox->GetCurSel()) != CB_ERR ) {
  169. if ( (count = pWdNameBox->GetItemData( index )) != CB_ERR ) {
  170. for ( currentcount = 0, pos = pApp->m_TdListList.GetHeadPosition();
  171. pos != NULL;
  172. currentcount++ ) {
  173. m_pCurrentTdList = (CObList *)pApp->m_TdListList.GetNext( pos );
  174. if ( currentcount == count )
  175. break;
  176. }
  177. for ( currentcount = 0, pos = pApp->m_PdListList.GetHeadPosition();
  178. pos != NULL;
  179. currentcount++ ) {
  180. m_pCurrentPdList = (CObList *)pApp->m_PdListList.GetNext( pos );
  181. if ( currentcount == count )
  182. break;
  183. }
  184. }
  185. }
  186. } // end RefrenceAssociatedLists
  187. /*******************************************************************************
  188. *
  189. * InitializeTransportComboBox -
  190. * CEditWinStationDlg member function: protected operation
  191. *
  192. * Initialize the Transport combo box with Tds available for the
  193. * currently selected Wd (Type).
  194. *
  195. * ENTRY:
  196. * EXIT:
  197. *
  198. ******************************************************************************/
  199. void
  200. CEditWinStationDlg::InitializeTransportComboBox()
  201. {
  202. CComboBox *pTdNameBox = (CComboBox *)GetDlgItem(IDC_TDNAME);
  203. POSITION pos;
  204. /*
  205. * (re)initialize the Transport combo-box.
  206. */
  207. pTdNameBox->ResetContent();
  208. for ( pos = m_pCurrentTdList->GetHeadPosition(); pos != NULL; ) {
  209. PPDLOBJECT pObject = (PPDLOBJECT)m_pCurrentTdList->GetNext( pos );
  210. pTdNameBox->AddString( pObject->m_PdConfig.Data.PdName );
  211. }
  212. /*
  213. * Select the currently specified PD in the combo-box. If that fails,
  214. * select the first in the list.
  215. */
  216. if ( pTdNameBox->SelectString(-1, m_WSConfig.Pd[0].Create.PdName) == CB_ERR )
  217. pTdNameBox->SetCurSel(0);
  218. } // end InitializeTransportComboBox
  219. /*******************************************************************************
  220. *
  221. * InitializeLists - CEditWinStationDlg member function: protected operation
  222. *
  223. * Initialize the list box(es) to be used with the specified Pd.
  224. *
  225. * ENTRY:
  226. * pPdConfig (input)
  227. * Pointer to PDCONFIG3 structure specifying the Pd.
  228. *
  229. * EXIT:
  230. * (BOOL) TRUE if the Pd list box(es) were initialized. FALSE if error.
  231. *
  232. * FUTURE: For now, FALSE will indicate that there was an error
  233. * initializing the device list for the PD, the cause of which is
  234. * saved for GetLastError(). Additional status codes and/or
  235. * a queue of error conditions will need to be returned as the
  236. * additional FUTURE actions defined below are implemented.
  237. *
  238. ******************************************************************************/
  239. BOOL
  240. CEditWinStationDlg::InitializeLists( PPDCONFIG3 pPdConfig )
  241. {
  242. switch( pPdConfig->Data.SdClass ) {
  243. case SdAsync:
  244. /*
  245. * Initialize the Device combo-box.
  246. */
  247. if ( !InitializeAsyncLists(pPdConfig) )
  248. return(FALSE);
  249. break;
  250. case SdNetwork:
  251. /*
  252. * Initialize the LANADAPTER combo-box.
  253. */
  254. if ( !InitializeNetworkLists(pPdConfig) )
  255. return(FALSE);
  256. break;
  257. case SdNasi:
  258. /*
  259. * NOTE: we don't initalize the NASI Port Name list at this
  260. * time, since it will be initialized at various times during
  261. * the dialog activity (like when SetDefaults() is processed).
  262. */
  263. break;
  264. case SdOemTransport:
  265. /*
  266. * Initialize the DEVICE combo-box.
  267. */
  268. if ( !InitializeOemTdLists(pPdConfig) )
  269. return(FALSE);
  270. break;
  271. default:
  272. break;
  273. }
  274. return(TRUE);
  275. } // end CEditWinStationDlg::InitializeLists
  276. /*******************************************************************************
  277. *
  278. * HandleListInitError -
  279. * CEditWinStationDlg member function: protected operation
  280. *
  281. * Output a nice explaination as to why the list initialization failed.
  282. *
  283. * ENTRY:
  284. * pPdConfig (input)
  285. * Pointer to PDCONFIG3 structure specifying the current Pd.
  286. * ListInitError (input)
  287. * Error resource id from InitializeLists
  288. *
  289. * EXIT:
  290. *
  291. ******************************************************************************/
  292. void
  293. CEditWinStationDlg::HandleListInitError( PPDCONFIG3 pPdConfig, DWORD ListInitError )
  294. {
  295. /*
  296. * Output a specific message for error conditions.
  297. */
  298. switch( pPdConfig->Data.SdClass ) {
  299. case SdAsync:
  300. case SdNetwork:
  301. case SdNasi:
  302. ERROR_MESSAGE((ListInitError))
  303. break;
  304. case SdOemTransport:
  305. switch ( ListInitError ) {
  306. case IDP_ERROR_OEMTDINIT_NOCONFIGDLL:
  307. case IDP_ERROR_OEMTDINIT_CONFIGDLLENUMERATIONFAILURE:
  308. case IDP_ERROR_PDINIT:
  309. ERROR_MESSAGE((ListInitError))
  310. break;
  311. case IDP_ERROR_OEMTDINIT_MISSINGCONFIGDLLENTRYPOINT:
  312. case IDP_ERROR_OEMTDINIT_CANTOPENCONFIGDLL:
  313. ERROR_MESSAGE((ListInitError, pPdConfig->ConfigDLL))
  314. break;
  315. }
  316. break;
  317. }
  318. } // end CEditWinStationDlg::HandleListInitError
  319. /*******************************************************************************
  320. *
  321. * HandleSetFieldsError -
  322. * CEditWinStationDlg member function: protected operation
  323. *
  324. * Output a nice explaination as to why the setting the Pd fields failed.
  325. *
  326. * ENTRY:
  327. * pPdConfig (input)
  328. * Pointer to PDCONFIG3 structure specifying the current Pd.
  329. * nId (input)
  330. * Specifies control Id of field in error.
  331. *
  332. * EXIT:
  333. *
  334. ******************************************************************************/
  335. void
  336. CEditWinStationDlg::HandleSetFieldsError( PPDCONFIG3 pPdConfig,
  337. int nId )
  338. {
  339. /*
  340. * Output protocol-specific error message.
  341. */
  342. switch( pPdConfig->Data.SdClass ) {
  343. case SdAsync:
  344. switch ( nId ) {
  345. case IDC_ASYNC_DEVICENAME:
  346. {
  347. TCHAR szDecoratedName[DEVICENAME_LENGTH + MODEMNAME_LENGTH + 1];
  348. FormDecoratedAsyncDeviceName(
  349. szDecoratedName,
  350. &(m_WSConfig.Pd[0].Params.Async) );
  351. ERROR_MESSAGE(( IDP_ERROR_INVALIDDEVICE,
  352. szDecoratedName ))
  353. }
  354. break;
  355. default:
  356. break;
  357. }
  358. break;
  359. case SdNetwork:
  360. switch ( nId ) {
  361. case IDC_NETWORK_LANADAPTER:
  362. ERROR_MESSAGE(( (pPdConfig->Data.PdFlag & PD_LANA) ?
  363. IDP_ERROR_INVALIDNETBIOSLANA :
  364. IDP_ERROR_INVALIDNETWORKADAPTER,
  365. m_WSConfig.Pd[0].Params.Network.LanAdapter ))
  366. break;
  367. default:
  368. break;
  369. }
  370. break;
  371. case SdOemTransport:
  372. switch ( nId ) {
  373. case IDC_OEMTD_DEVICENAME:
  374. ERROR_MESSAGE(( IDP_ERROR_INVALIDDEVICE,
  375. m_WSConfig.Pd[0].Params.OemTd.DeviceName ))
  376. break;
  377. default:
  378. break;
  379. }
  380. break;
  381. }
  382. } // end CEditWinStationDlg::HandleSetFieldsError
  383. /*******************************************************************************
  384. *
  385. * InitializeAsyncLists - CEditWinStationDlg member function: protected operation
  386. *
  387. * Initialize the Async Device combo-box with the device strings
  388. * associated with the specified Async PD DLL.
  389. *
  390. * ENTRY:
  391. * pPdConfig (input)
  392. * Pointer to PDCONFIG3 structure specifying the Pd.
  393. * EXIT:
  394. * (BOOL) TRUE if the Device combo-box was initialized.
  395. * FALSE if error (code set for GetLastError).
  396. *
  397. * If the highest-numbered TAPI line device has been added to the combo
  398. * box, the m_nComboBoxIndexOfLatestTAPIDevice member will be set to the
  399. * combo-box index of that item. It will be -1 if the combo-box does
  400. * not contain the highest numbered TAPI line device.
  401. *
  402. * This routine also saves the current max TAPI line number
  403. * (m_nCurrentMaxTAPILineNumber) to the previous max TAPI line number
  404. * (m_nPreviousMaxTAPILineNumber) and will recalculate the current max
  405. * number so the caller can determine if the enumeration found a new TAPI
  406. * line device by checking for m_nCurrentMaxTAPILineNumber >
  407. * m_nPreviousMaxTAPILineNumber.
  408. *
  409. ******************************************************************************/
  410. BOOL
  411. CEditWinStationDlg::InitializeAsyncLists( PPDCONFIG3 pPdConfig )
  412. {
  413. PPDPARAMS pPdParams;
  414. char *pBuffer = NULL;
  415. ULONG i, Entries;
  416. CComboBox *pDevice = (CComboBox *)GetDlgItem(IDC_ASYNC_DEVICENAME);
  417. int index, nLoopIndexOfLatestTAPIDevice = -1;
  418. TCHAR szDecoratedName[DEVICENAME_LENGTH + MODEMNAME_LENGTH + 1];
  419. /*
  420. * If the Async lists have already been initialized, we don't need to
  421. * do it again, since there is only one Async Transport for WinStations.
  422. * This is not the case for Network WinStations, as there are different
  423. * network transport types.
  424. */
  425. if ( m_bAsyncListsInitialized )
  426. return(TRUE);
  427. /*
  428. * Clear the Device combo-box.
  429. */
  430. pDevice->ResetContent();
  431. /*
  432. * Perform the device enumeration.
  433. */
  434. if ( (pBuffer = (char *)WinEnumerateDevices(
  435. this->GetSafeHwnd(),
  436. pPdConfig,
  437. &Entries,
  438. g_Install ? TRUE : FALSE )) == NULL ) {
  439. SetLastError(IDP_ERROR_ASYNCDEVICEINIT);
  440. goto BadEnumerate;
  441. }
  442. /*
  443. * Set previous max TAPI line number to current max TAPI line number,
  444. * initialize current max TAPI line number and latest TAPI device combo-box
  445. * index, and loop to initialize the combo-box.
  446. */
  447. m_nPreviousMaxTAPILineNumber = m_nCurrentMaxTAPILineNumber;
  448. m_nCurrentMaxTAPILineNumber = m_nComboBoxIndexOfLatestTAPIDevice = -1;
  449. for ( i = 0, pPdParams = (PPDPARAMS)pBuffer; i < Entries; i++, pPdParams++ ) {
  450. /*
  451. * Form decorated name.
  452. */
  453. FormDecoratedAsyncDeviceName( szDecoratedName, &(pPdParams->Async) );
  454. /*
  455. * If this device is a TAPI modem and it's line number (in BaudRate field)
  456. * is greater than the current max line number, set it's line number as max and
  457. * save this loop index.
  458. */
  459. if ( *(pPdParams->Async.ModemName) &&
  460. (int(pPdParams->Async.BaudRate) > m_nCurrentMaxTAPILineNumber) ) {
  461. m_nCurrentMaxTAPILineNumber = int(pPdParams->Async.BaudRate);
  462. nLoopIndexOfLatestTAPIDevice = i;
  463. }
  464. /*
  465. * Don't add this device to the list if it is already in use by a
  466. * WinStation other than the current one.
  467. */
  468. if ( !((CAppServerDoc *)m_pDoc)->
  469. IsAsyncDeviceAvailable( pPdParams->Async.DeviceName,
  470. (m_DlgMode == EWSDlgCopy) ?
  471. TEXT("") : m_pWSName) )
  472. continue;
  473. /*
  474. * Insert the name into the combo-box if it's not a TAPI modem
  475. * or it is a TAPI modem that's not being used by RAS and it's
  476. * port is currently available.
  477. */
  478. if ( !*(pPdParams->Async.ModemName) ||
  479. (!pPdParams->Async.Parity &&
  480. (pDevice->FindStringExact(-1, pPdParams->Async.DeviceName)
  481. != CB_ERR)) ) {
  482. index = CBInsertInstancedName( szDecoratedName,
  483. pDevice );
  484. if ( (index == CB_ERR) || (index == CB_ERRSPACE) )
  485. goto BadAdd;
  486. }
  487. /*
  488. * If this device is a modem, make sure that the raw port this
  489. * device is configured on is not present in the list. This will
  490. * also take care of removing the raw port for TAPI modems that are
  491. * configured for use by RAS, in which case neither the configured.
  492. * TAPI modem(s) or raw port will be present in the list.
  493. */
  494. if ( *(pPdParams->Async.ModemName) &&
  495. ((index = pDevice->FindStringExact(
  496. -1, pPdParams->Async.DeviceName ))
  497. != CB_ERR) )
  498. pDevice->DeleteString(index);
  499. }
  500. /*
  501. * Always make sure that the currently configured device is in
  502. * the list.
  503. */
  504. if ( *(m_WSConfig.Pd[0].Params.Async.DeviceName) ) {
  505. FormDecoratedAsyncDeviceName( szDecoratedName,
  506. &(m_WSConfig.Pd[0].Params.Async) );
  507. if ( (index = pDevice->FindStringExact(
  508. -1, szDecoratedName )) == CB_ERR ) {
  509. index = CBInsertInstancedName(
  510. szDecoratedName,
  511. pDevice );
  512. if ( (index == CB_ERR) || (index == CB_ERRSPACE) )
  513. goto BadAdd;
  514. }
  515. }
  516. /*
  517. * If the highest line-numbered TAPI device that was added to
  518. * the combo-box, find and save it's index in
  519. * m_nComboBoxIndexOfLatestTAPIDevice.
  520. */
  521. if ( nLoopIndexOfLatestTAPIDevice > -1 ) {
  522. pPdParams = &((PPDPARAMS)pBuffer)[nLoopIndexOfLatestTAPIDevice];
  523. FormDecoratedAsyncDeviceName( szDecoratedName, &(pPdParams->Async) );
  524. if ( (index = pDevice->FindStringExact(-1, szDecoratedName)) != CB_ERR )
  525. m_nComboBoxIndexOfLatestTAPIDevice = index;
  526. }
  527. /*
  528. * Free the enumeration buffer and return success.
  529. */
  530. VERIFY( LocalFree(pBuffer) == NULL );
  531. m_bAsyncListsInitialized = TRUE;
  532. return(TRUE);
  533. /*==============================================================================
  534. * Error returns
  535. *============================================================================*/
  536. BadAdd:
  537. LocalFree(pBuffer);
  538. SetLastError(IDP_ERROR_PDINIT);
  539. BadEnumerate:
  540. return(FALSE);
  541. } // end CEditWinStationDlg::InitializeAsyncLists
  542. /*******************************************************************************
  543. *
  544. * InitializeNetworkLists -
  545. * CEditWinStationDlg member function: protected operation
  546. *
  547. * Initialize the Network Lan Adapter combo-box with the network adapter
  548. * strings and ordinal values associated with the specified Network PD DLL.
  549. *
  550. * ENTRY:
  551. * pPdConfig (input)
  552. * Pointer to PDCONFIG3 structure specifying the Pd.
  553. *
  554. * EXIT:
  555. * (BOOL) TRUE if the Lan Adapter combo-box was initialized.
  556. * FALSE if error (code set for GetLastError)
  557. *
  558. ******************************************************************************/
  559. BOOL
  560. CEditWinStationDlg::InitializeNetworkLists( PPDCONFIG3 pPdConfig )
  561. {
  562. BOOL bResult = 0;
  563. CComboBox *pLanAdapter = (CComboBox *)GetDlgItem(IDC_NETWORK_LANADAPTER);
  564. /*
  565. * Clear the Lan Adapter combo-box.
  566. */
  567. pLanAdapter->ResetContent();
  568. bResult = AddNetworkDeviceNameToList(pPdConfig,pLanAdapter);
  569. return(TRUE); //We are returning TRUE always as we atleast return "All Lan Adapters"
  570. } // end CEditWinStationDlg::InitializeNetworkLists
  571. /*******************************************************************************
  572. *
  573. * InitializeNASIPortNames -
  574. * CEditWinStationDlg member function: protected operation
  575. *
  576. * Initialize the NASI Port Name combo-box with the NASI Port strings,
  577. * based on the current NASICONFIG UserName, Password, FileServer,
  578. * and GlobalSession settings.
  579. *
  580. * NOTE: we only perform this initialization if any of the above settings
  581. * have changed since the last time this function was called.
  582. *
  583. * ENTRY:
  584. * pNASIConfig (input)
  585. * Pointer to NASICONFIG structure for the current NASI WinStation Set.
  586. *
  587. * EXIT:
  588. * (BOOL) TRUE if the Port Name combo-box was initialized (or not needed);
  589. * FALSE if error (code set for GetLastError)
  590. *
  591. ******************************************************************************/
  592. // local helper function StripUndies(): strips trailing underscores from
  593. // names returned by NCS enumeration calls.
  594. void
  595. StripUndies( PBYTE String, ULONG Length )
  596. {
  597. LONG i;
  598. for ( i = Length-2; i > 0; i-- ) {
  599. if ( String[i] == '_' )
  600. String[i] = '\0';
  601. else
  602. break;
  603. }
  604. }
  605. BOOL
  606. CEditWinStationDlg::InitializeNASIPortNames( PNASICONFIG pNASIConfig )
  607. {
  608. #ifdef NASI
  609. PORTQUERY PortQuery;
  610. NCS_ENUMERATE_HANDLE hEnum;
  611. int index;
  612. ULONG Status;
  613. #endif // NASI
  614. BOOL bReturn = TRUE;
  615. CComboBox *pPortName = (CComboBox *)GetDlgItem(IDC_NASI_PORTNAME);
  616. /*
  617. * Only do this if any of the 'input' settings have changed.
  618. */
  619. if ( !lstrcmp(m_NASIConfig.UserName, pNASIConfig->UserName) &&
  620. !lstrcmp(m_NASIConfig.PassWord, pNASIConfig->PassWord) &&
  621. !lstrcmp(m_NASIConfig.FileServer, pNASIConfig->FileServer) &&
  622. m_NASIConfig.GlobalSession == pNASIConfig->GlobalSession ) {
  623. return(TRUE);
  624. }
  625. /*
  626. * Update the saved input settings.
  627. */
  628. lstrcpy(m_NASIConfig.UserName, pNASIConfig->UserName);
  629. lstrcpy(m_NASIConfig.PassWord, pNASIConfig->PassWord);
  630. lstrcpy(m_NASIConfig.FileServer, pNASIConfig->FileServer);
  631. m_NASIConfig.GlobalSession = pNASIConfig->GlobalSession;
  632. /*
  633. * Clear the Port Name combo-box.
  634. */
  635. pPortName->ResetContent();
  636. #ifdef NASI
  637. /*
  638. * Perform NASI port enumeration
  639. */
  640. if ( !(Status = NCSOpenEnumerate(
  641. &hEnum,
  642. (PBYTE)pNASIConfig->UserName,
  643. (PBYTE)pNASIConfig->PassWord,
  644. (PBYTE)pNASIConfig->FileServer,
  645. pNASIConfig->GlobalSession ? TRUE : FALSE )) ) {
  646. while ( !Status ) {
  647. Status = NCSEnumerate(hEnum, &PortQuery);
  648. if ( !Status ) {
  649. StripUndies(PortQuery.abSpecific, sizeof(PortQuery.abSpecific));
  650. index = pPortName->AddString((LPTSTR)PortQuery.abSpecific);
  651. if ( (index == CB_ERR) || (index == CB_ERRSPACE) ) {
  652. SetLastError(IDP_ERROR_PDINIT);
  653. bReturn = FALSE;
  654. break;
  655. }
  656. }
  657. }
  658. NCSCloseEnumerate(hEnum);
  659. }
  660. #endif // NASI
  661. /*
  662. * Set the Port Name combo-box selection. Default to the
  663. * first item in the list (if any) if no SpecificName (Port Name)
  664. * is defined.
  665. */
  666. if ( !*(pNASIConfig->SpecificName) ) {
  667. pPortName->SetCurSel(0);
  668. } else {
  669. pPortName->SetWindowText(pNASIConfig->SpecificName);
  670. }
  671. return(bReturn);
  672. } // end CEditWinStationDlg::InitializeNASIPortNames
  673. /*******************************************************************************
  674. *
  675. * InitializeOemTdLists -
  676. * CEditWinStationDlg member function: protected operation
  677. *
  678. * Initialize the Oem Transport Device combo-box with the device strings
  679. * returned by the Oem configuration helper DLL
  680. *
  681. * ENTRY:
  682. * pPdConfig (input)
  683. * Pointer to PDCONFIG3 structure specifying the Pd.
  684. *
  685. * EXIT:
  686. * (BOOL) TRUE if the device combo-box was initialized.
  687. * FALSE if error (code set for GetLastError)
  688. *
  689. ******************************************************************************/
  690. BOOL
  691. CEditWinStationDlg::InitializeOemTdLists( PPDCONFIG3 pPdConfig )
  692. {
  693. BOOL bStatus = FALSE;
  694. CComboBox *pDevice = (CComboBox *)GetDlgItem(IDC_OEMTD_DEVICENAME);
  695. HMODULE hMod;
  696. PFNOEMTDENUMERATEDEVICESW pfnOemTdEnumerateDevicesW;
  697. PFNOEMTDFREEBUFFERW pfnOemTdFreeBufferW;
  698. /*
  699. * Clear the Device combo-box.
  700. */
  701. pDevice->ResetContent();
  702. if ( *pPdConfig->ConfigDLL ) {
  703. if ( hMod = ::LoadLibrary(pPdConfig->ConfigDLL) ) {
  704. if ( (pfnOemTdEnumerateDevicesW =
  705. (PFNOEMTDENUMERATEDEVICESW)::GetProcAddress(hMod, OEMTDENUMERATEDEVICESW)) &&
  706. (pfnOemTdFreeBufferW =
  707. (PFNOEMTDFREEBUFFERW)::GetProcAddress(hMod, OEMTDFREEBUFFERW)) ) {
  708. LPWSTR pBuffer, pDeviceName;
  709. int index;
  710. if ( (*pfnOemTdEnumerateDevicesW)( &pBuffer ) == ERROR_SUCCESS ) {
  711. for ( pDeviceName = pBuffer;
  712. *pDeviceName;
  713. pDeviceName += (wcslen(pDeviceName) + 1) ) {
  714. /*
  715. * Don't add this device to the list if it is already in use by a
  716. * WinStation other than the current one.
  717. */
  718. if ( !((CAppServerDoc *)m_pDoc)->
  719. IsOemTdDeviceAvailable( pDeviceName,
  720. pPdConfig->Data.PdName,
  721. (m_DlgMode == EWSDlgCopy) ?
  722. TEXT("") : m_pWSName ) )
  723. continue;
  724. index = pDevice->AddString(pDeviceName);
  725. if ( (index == CB_ERR) || (index == CB_ERRSPACE) ) {
  726. SetLastError(IDP_ERROR_PDINIT);
  727. break;
  728. }
  729. }
  730. (*pfnOemTdFreeBufferW)( pBuffer );
  731. } else {
  732. SetLastError(IDP_ERROR_OEMTDINIT_CONFIGDLLENUMERATIONFAILURE);
  733. }
  734. } else {
  735. SetLastError(IDP_ERROR_OEMTDINIT_MISSINGCONFIGDLLENTRYPOINT);
  736. }
  737. ::FreeLibrary(hMod);
  738. } else {
  739. SetLastError(IDP_ERROR_OEMTDINIT_CANTOPENCONFIGDLL);
  740. }
  741. } else {
  742. SetLastError(IDP_ERROR_OEMTDINIT_NOCONFIGDLL);
  743. }
  744. return(bStatus);
  745. } // end CEditWinStationDlg::InitializeOemTdLists
  746. /*******************************************************************************
  747. *
  748. * GetSelectedPdConfig - CEditWinStationDlg member function: protected operation
  749. *
  750. * Read the PD config structure associated with the currently selected
  751. * TD in the Transport combo-box.
  752. *
  753. * ENTRY:
  754. * pPdConfig (output)
  755. * Pointer to PDCONFIG3 structure to fill.
  756. * EXIT:
  757. * nothing
  758. *
  759. ******************************************************************************/
  760. void
  761. CEditWinStationDlg::GetSelectedPdConfig( PPDCONFIG3 pPdConfig )
  762. {
  763. POSITION pos;
  764. CComboBox *pPd = (CComboBox *)GetDlgItem(IDC_TDNAME);
  765. PDNAME PdName;
  766. PPDLOBJECT pObject;
  767. /*
  768. * Fetch the currently selected TD string from the combo-box.
  769. */
  770. pPd->GetLBText( pPd->GetCurSel(), PdName );
  771. /*
  772. * Traverse the PD list and obtain the PdConfig of matching PdName element.
  773. */
  774. for ( pos = m_pCurrentTdList->GetHeadPosition(); pos != NULL; ) {
  775. pObject = (PPDLOBJECT)m_pCurrentTdList->GetNext( pos );
  776. if ( !lstrcmp( pObject->m_PdConfig.Data.PdName, PdName ) ) {
  777. *pPdConfig = pObject->m_PdConfig;
  778. break;
  779. }
  780. }
  781. } // end CEditWinStation::GetSelectedPdConfig
  782. /*******************************************************************************
  783. *
  784. * GetSelectedWdConfig - CEditWinStationDlg member function: protected operation
  785. *
  786. * Read the Wd config structure associated with the current
  787. * selection in the Wd combo-box.
  788. *
  789. * ENTRY:
  790. * pWdConfig (output)
  791. * Pointer to WDCONFIG2 structure to fill.
  792. *
  793. * EXIT:
  794. * nothing
  795. *
  796. ******************************************************************************/
  797. void
  798. CEditWinStationDlg::GetSelectedWdConfig( PWDCONFIG2 pWdConfig )
  799. {
  800. POSITION pos;
  801. CComboBox *pWd = (CComboBox *)GetDlgItem(IDC_WDNAME);
  802. WDNAME WdName;
  803. PTERMLOBJECT pObject;
  804. /*
  805. * Fetch the currently selected WD string from the combo-box.
  806. */
  807. pWd->GetLBText( pWd->GetCurSel(), WdName );
  808. /*
  809. * Traverse the WD list and obtain the WdConfig of matching WdName element.
  810. */
  811. for ( pos = pApp->m_WdList.GetHeadPosition(); pos != NULL; ) {
  812. pObject = (PTERMLOBJECT)pApp->m_WdList.GetNext( pos );
  813. if ( !lstrcmp( pObject->m_WdConfig.Wd.WdName, WdName ) ) {
  814. *pWdConfig = pObject->m_WdConfig;
  815. break;
  816. }
  817. }
  818. } // end CEditWinStation::GetSelectedWdConfig
  819. PTERMLOBJECT
  820. CEditWinStationDlg::GetSelectedWdListObject()
  821. {
  822. POSITION pos;
  823. CComboBox *pWd = (CComboBox *)GetDlgItem(IDC_WDNAME);
  824. WDNAME WdName;
  825. PTERMLOBJECT pObject;
  826. /*
  827. * Fetch the currently selected WD string from the combo-box.
  828. */
  829. pWd->GetLBText( pWd->GetCurSel(), WdName );
  830. /*
  831. * Traverse the WD list and obtain the WdConfig of matching WdName element.
  832. */
  833. for ( pos = pApp->m_WdList.GetHeadPosition(); pos != NULL; ) {
  834. pObject = (PTERMLOBJECT)pApp->m_WdList.GetNext( pos );
  835. if ( !lstrcmp( pObject->m_WdConfig.Wd.WdName, WdName ) ) {
  836. return(pObject);
  837. }
  838. }
  839. return(NULL);
  840. } // end CEditWinStation::GetSelectedWdListObject
  841. /*******************************************************************************
  842. *
  843. * SetConfigurationFields -
  844. * CEditWinStationDlg member function: protected operation
  845. *
  846. * Main control function for the hiding / showing / setting of the proper
  847. * Pd-specific configuration fields.
  848. *
  849. *
  850. * ENTRY:
  851. * EXIT:
  852. * TRUE if the SetxxxFields was sucessful; FALSE otherwise.
  853. *
  854. ******************************************************************************/
  855. BOOL
  856. CEditWinStationDlg::SetConfigurationFields()
  857. {
  858. BOOL bSetFields;
  859. /*
  860. * If the previous PdConfig is not the same as the current, disable and
  861. * hide all controls in the previous (currently displayed) Pd and
  862. * then enable (if not 'View' mode) and show the controls in the new
  863. * Pd.
  864. */
  865. if ( memcmp(&m_PreviousPdConfig, &(m_WSConfig.Pd[0].Create), sizeof(m_PreviousPdConfig)) ) {
  866. /*
  867. * If this is not the first time that the function is called (at
  868. * dialog init time), disable/hide the current configuration fields.
  869. * These fields will already be disabled/hidden otherwise.
  870. */
  871. if ( m_PreviousPdConfig.SdClass != SdNone ) {
  872. /*
  873. * Set the style of the parent dialog window to 'hidden' to suppress
  874. * the 'disable/hide' repainting of the child windows that is about
  875. * to take place.
  876. */
  877. SetWindowLong( m_hWnd, GWL_STYLE,
  878. GetWindowLong( m_hWnd, GWL_STYLE ) & (~WS_VISIBLE) );
  879. switch ( m_PreviousPdConfig.SdClass ) {
  880. case SdAsync:
  881. EnableAsyncFields(FALSE);
  882. break;
  883. case SdNetwork:
  884. EnableNetworkFields(FALSE);
  885. break;
  886. case SdNasi:
  887. EnableNASIFields(FALSE);
  888. break;
  889. case SdOemTransport:
  890. EnableOemTdFields(FALSE);
  891. break;
  892. }
  893. /*
  894. * Make the parent dialog window visible again to allow the child
  895. * window 'enable/show' painting to take place.
  896. */
  897. SetWindowLong( m_hWnd, GWL_STYLE,
  898. GetWindowLong( m_hWnd, GWL_STYLE ) | WS_VISIBLE );
  899. }
  900. switch ( m_WSConfig.Pd[0].Create.SdClass ) {
  901. case SdNone:
  902. break;
  903. case SdAsync:
  904. EnableAsyncFields(TRUE);
  905. break;
  906. case SdNetwork:
  907. EnableNetworkFields(TRUE);
  908. break;
  909. case SdNasi:
  910. EnableNASIFields(TRUE);
  911. break;
  912. case SdOemTransport:
  913. EnableOemTdFields(TRUE);
  914. break;
  915. }
  916. }
  917. /*
  918. * Set the previous PdConfig to the current one.
  919. */
  920. memcpy(&m_PreviousPdConfig, &(m_WSConfig.Pd[0].Create), sizeof(m_PreviousPdConfig));
  921. // If the WD doesn't support any of the capabilities presented in the
  922. // "Client Settings" dialogs, disable it's button
  923. PTERMLOBJECT pTermObject = GetSelectedWdListObject();
  924. if(pTermObject && !(pTermObject->m_Capabilities & WDC_CLIENT_DIALOG_MASK)) {
  925. GetDlgItem(IDC_CLIENT_SETTINGS)->EnableWindow(FALSE);
  926. }
  927. /*
  928. * Set the data in the configuration fields.
  929. */
  930. switch ( m_WSConfig.Pd[0].Create.SdClass ) {
  931. case SdNone:
  932. bSetFields = TRUE;
  933. break;
  934. case SdAsync:
  935. bSetFields = SetAsyncFields();
  936. break;
  937. case SdNetwork:
  938. bSetFields = SetNetworkFields();
  939. break;
  940. case SdNasi:
  941. bSetFields = SetNASIFields();
  942. break;
  943. case SdOemTransport:
  944. bSetFields = SetOemTdFields();
  945. break;
  946. }
  947. /*
  948. * Return the status of the SetxxxFields call.
  949. */
  950. return(bSetFields);
  951. } // end CEditWinStationDlg::SetConfigurationFields
  952. /*******************************************************************************
  953. *
  954. * EnableAsyncFields - CEditWinStationDlg member function: protected operation
  955. *
  956. * Enable and show or disable and hide the Async Pd configuration field's
  957. * control windows.
  958. *
  959. * ENTRY:
  960. * bEnableAndShow (input)
  961. * TRUE to enable and show the controls; FALSE to disable and hide.
  962. * EXIT:
  963. *
  964. ******************************************************************************/
  965. void
  966. CEditWinStationDlg::EnableAsyncFields( BOOL bEnableAndShow )
  967. {
  968. BOOL bEnableFlag = (bEnableAndShow && ((m_DlgMode != EWSDlgView) &&
  969. (m_DlgMode != EWSDlgRename))) ?
  970. TRUE : FALSE;
  971. int nCmdShow = bEnableAndShow ? SW_SHOW : SW_HIDE;
  972. int id;
  973. /*
  974. * NOTE: must keep the Async label and control IDs consecutive for this
  975. * iteration to function properly.
  976. */
  977. for ( id=IDL_ASYNC; id <= IDC_ASYNC_TEST; id++ ) {
  978. GetDlgItem(id)->EnableWindow(bEnableFlag);
  979. GetDlgItem(id)->ShowWindow(nCmdShow);
  980. }
  981. /*
  982. * The Advanced WinStation and Client Settings buttons are always
  983. * SHOWN and ENABLED for Async.
  984. */
  985. if(bEnableAndShow) {
  986. GetDlgItem(IDC_ADVANCED_WINSTATION)->ShowWindow(SW_SHOW);
  987. GetDlgItem(IDC_ADVANCED_WINSTATION)->EnableWindow(TRUE);
  988. GetDlgItem(IDC_CLIENT_SETTINGS)->ShowWindow(SW_SHOW);
  989. GetDlgItem(IDC_CLIENT_SETTINGS)->EnableWindow(TRUE);
  990. }
  991. } // end CEditWinStationDlg::EnableAsyncFields
  992. /*******************************************************************************
  993. *
  994. * EnableNetworkFields - CEditWinStationDlg member function: protected operation
  995. *
  996. * Enable and show or disable and hide the Network Pd configuration
  997. * field's control windows.
  998. *
  999. * ENTRY:
  1000. * bEnableAndShow (input)
  1001. * TRUE to enable and show the controls; FALSE to disable and hide.
  1002. * EXIT:
  1003. *
  1004. ******************************************************************************/
  1005. void
  1006. CEditWinStationDlg::EnableNetworkFields( BOOL bEnableAndShow )
  1007. {
  1008. BOOL bEnableFlag = (bEnableAndShow && ((m_DlgMode != EWSDlgView) &&
  1009. (m_DlgMode != EWSDlgRename))) ?
  1010. TRUE : FALSE;
  1011. int nCmdShow = bEnableAndShow ? SW_SHOW : SW_HIDE;
  1012. int id;
  1013. /*
  1014. * NOTE: must keep the Network label and control IDs consecutive for this
  1015. * iteration to function properly.
  1016. */
  1017. for ( id=IDL_NETWORK; id <= IDC_NETWORK_INSTANCECOUNT_UNLIMITED; id++ ) {
  1018. GetDlgItem(id)->EnableWindow(bEnableFlag);
  1019. GetDlgItem(id)->ShowWindow(nCmdShow);
  1020. }
  1021. /*
  1022. * The Advanced WinStation and Client Settings buttons are
  1023. * always SHOWN and ENABLED for Network.
  1024. */
  1025. if(bEnableAndShow) {
  1026. GetDlgItem(IDC_ADVANCED_WINSTATION)->ShowWindow(SW_SHOW);
  1027. GetDlgItem(IDC_ADVANCED_WINSTATION)->EnableWindow(TRUE);
  1028. GetDlgItem(IDC_CLIENT_SETTINGS)->ShowWindow(SW_SHOW);
  1029. GetDlgItem(IDC_CLIENT_SETTINGS)->EnableWindow(TRUE);
  1030. }
  1031. } // end CEditWinStationDlg::EnableNetworkFields
  1032. /*******************************************************************************
  1033. *
  1034. * EnableNASIFields - CEditWinStationDlg member function: protected operation
  1035. *
  1036. * Enable and show or disable and hide the NASI Pd configuration
  1037. * field's control windows.
  1038. *
  1039. * ENTRY:
  1040. * bEnableAndShow (input)
  1041. * TRUE to enable and show the controls; FALSE to disable and hide.
  1042. * EXIT:
  1043. *
  1044. ******************************************************************************/
  1045. void
  1046. CEditWinStationDlg::EnableNASIFields( BOOL bEnableAndShow )
  1047. {
  1048. BOOL bEnableFlag = (bEnableAndShow && ((m_DlgMode != EWSDlgView) &&
  1049. (m_DlgMode != EWSDlgRename))) ?
  1050. TRUE : FALSE;
  1051. int nCmdShow = bEnableAndShow ? SW_SHOW : SW_HIDE;
  1052. int id;
  1053. /*
  1054. * NOTE: must keep the NASI label and control IDs consecutive for this
  1055. * iteration to function properly.
  1056. */
  1057. for ( id=IDL_NASI; id <= IDC_NASI_ADVANCED; id++ ) {
  1058. GetDlgItem(id)->EnableWindow(bEnableFlag);
  1059. GetDlgItem(id)->ShowWindow(nCmdShow);
  1060. }
  1061. /*
  1062. * The Advanced WinStation and Client Settings buttons are
  1063. * always SHOWN and ENABLED for Nasi.
  1064. */
  1065. if(bEnableAndShow) {
  1066. GetDlgItem(IDC_ADVANCED_WINSTATION)->ShowWindow(SW_SHOW);
  1067. GetDlgItem(IDC_ADVANCED_WINSTATION)->EnableWindow(TRUE);
  1068. GetDlgItem(IDC_CLIENT_SETTINGS)->ShowWindow(SW_SHOW);
  1069. GetDlgItem(IDC_CLIENT_SETTINGS)->EnableWindow(TRUE);
  1070. }
  1071. } // end CEditWinStationDlg::EnableNASIFields
  1072. /*******************************************************************************
  1073. *
  1074. * EnableOemTdFields - CEditWinStationDlg member function: protected operation
  1075. *
  1076. * Enable and show or disable and hide the Oem Transport Pd configuration
  1077. * field's control windows.
  1078. *
  1079. * ENTRY:
  1080. * bEnableAndShow (input)
  1081. * TRUE to enable and show the controls; FALSE to disable and hide.
  1082. * EXIT:
  1083. *
  1084. ******************************************************************************/
  1085. void
  1086. CEditWinStationDlg::EnableOemTdFields( BOOL bEnableAndShow )
  1087. {
  1088. BOOL bEnableFlag = (bEnableAndShow && ((m_DlgMode != EWSDlgView) &&
  1089. (m_DlgMode != EWSDlgRename))) ?
  1090. TRUE : FALSE;
  1091. int nCmdShow = bEnableAndShow ? SW_SHOW : SW_HIDE;
  1092. int id;
  1093. /*
  1094. * NOTE: must keep the Oem label and control IDs consecutive for this
  1095. * iteration to function properly.
  1096. */
  1097. for ( id=IDL_OEMTD; id <= IDC_OEMTD_INSTANCECOUNT_UNLIMITED; id++ ) {
  1098. GetDlgItem(id)->EnableWindow(bEnableFlag);
  1099. GetDlgItem(id)->ShowWindow(nCmdShow);
  1100. }
  1101. /*
  1102. * If we're enabling and this is a single-instance Oem Transport,
  1103. * hide the multi-instance fields.
  1104. */
  1105. if ( bEnableAndShow && (m_WSConfig.Pd[0].Create.PdFlag & PD_SINGLE_INST) ) {
  1106. for ( id=IDL_OEMTD_INSTANCECOUNT;
  1107. id <= IDC_OEMTD_INSTANCECOUNT_UNLIMITED; id++ ) {
  1108. GetDlgItem(id)->EnableWindow(FALSE);
  1109. GetDlgItem(id)->ShowWindow(SW_HIDE);
  1110. }
  1111. }
  1112. /*
  1113. * The Advanced WinStation and Client Settings buttons are
  1114. * always SHOWN and ENABLED for Oem.
  1115. */
  1116. if(bEnableAndShow) {
  1117. GetDlgItem(IDC_ADVANCED_WINSTATION)->ShowWindow(SW_SHOW);
  1118. GetDlgItem(IDC_ADVANCED_WINSTATION)->EnableWindow(TRUE);
  1119. GetDlgItem(IDC_CLIENT_SETTINGS)->ShowWindow(SW_SHOW);
  1120. GetDlgItem(IDC_CLIENT_SETTINGS)->EnableWindow(TRUE);
  1121. }
  1122. } // end CEditWinStationDlg::EnableOemTdFields
  1123. /*******************************************************************************
  1124. *
  1125. * SetAsyncFields - CEditWinStationDlg member function: protected operation
  1126. *
  1127. * Set the contents of the Async Pd configuration fields.
  1128. *
  1129. * ENTRY:
  1130. * EXIT:
  1131. * TRUE if no errors on field setting; FALSE otherwise.
  1132. * WM_EDITSETFIELDSERROR message(s) will have been posted on error.
  1133. *
  1134. ******************************************************************************/
  1135. BOOL
  1136. CEditWinStationDlg::SetAsyncFields()
  1137. {
  1138. BOOL bStatus = TRUE;
  1139. BOOL bSelectDefault = (m_DlgMode == EWSDlgAdd) ||
  1140. (m_DlgMode == EWSDlgCopy) ||
  1141. !(*m_WSConfig.Pd[0].Params.Async.DeviceName);
  1142. CComboBox *pDevice = (CComboBox *)GetDlgItem(IDC_ASYNC_DEVICENAME);
  1143. CComboBox *pCallback = (CComboBox *)GetDlgItem(IDC_ASYNC_MODEMCALLBACK);
  1144. TCHAR szDeviceName[DEVICENAME_LENGTH+MODEMNAME_LENGTH+1];
  1145. /*
  1146. * Set the DEVICE combo-box selection from the current selection.
  1147. */
  1148. FormDecoratedAsyncDeviceName( szDeviceName, &(m_WSConfig.Pd[0].Params.Async) );
  1149. if ( pDevice->SelectString(-1, szDeviceName) == CB_ERR ) {
  1150. /*
  1151. * Can't select current async DeviceName in combo-box. If this is
  1152. * because we're supposed to select a default device name, select
  1153. * the first device in the list.
  1154. */
  1155. if ( bSelectDefault ) {
  1156. pDevice->SetCurSel(0);
  1157. } else {
  1158. PostMessage(WM_EDITSETFIELDSERROR, IDC_ASYNC_DEVICENAME, 0);
  1159. bStatus = FALSE;
  1160. }
  1161. }
  1162. /*
  1163. * If the DEVICENAME list is empty, disable the Install Modems button,
  1164. * since the user can't install a modem to a COM port that's unavailable
  1165. * (maybe could, but would be very frustrating when it couldn't be used).
  1166. */
  1167. if ( pDevice->GetCount() == 0 )
  1168. GetDlgItem(IDC_ASYNC_MODEMINSTALL)->EnableWindow(FALSE);
  1169. /*
  1170. * Set the MODEMCALLBACK combo-box selection, phone number, and 'inherit'
  1171. * checkboxes, based on the current UserConfig settings.
  1172. */
  1173. pCallback->SetCurSel(m_WSConfig.Config.User.Callback);
  1174. SetDlgItemText( IDC_ASYNC_MODEMCALLBACK_PHONENUMBER,
  1175. m_WSConfig.Config.User.CallbackNumber );
  1176. CheckDlgButton( IDC_ASYNC_MODEMCALLBACK_INHERIT,
  1177. m_WSConfig.Config.User.fInheritCallback );
  1178. CheckDlgButton( IDC_ASYNC_MODEMCALLBACK_PHONENUMBER_INHERIT,
  1179. m_WSConfig.Config.User.fInheritCallbackNumber );
  1180. /*
  1181. * Set the BAUDRATE combo-box selection (in it's edit field) and limit the
  1182. * edit field text.
  1183. */
  1184. {
  1185. TCHAR string[ULONG_DIGIT_MAX];
  1186. wsprintf( string, TEXT("%lu"), m_WSConfig.Pd[0].Params.Async.BaudRate );
  1187. SetDlgItemText( IDC_ASYNC_BAUDRATE, string );
  1188. ((CEdit *)GetDlgItem(IDC_ASYNC_BAUDRATE))
  1189. ->LimitText( ULONG_DIGIT_MAX-1 );
  1190. }
  1191. /*
  1192. * Set the CONNECT combo-box selection.
  1193. */
  1194. ((CComboBox *)GetDlgItem(IDC_ASYNC_CONNECT))->SetCurSel(
  1195. m_WSConfig.Pd[0].Params.Async.Connect.Type);
  1196. /*
  1197. * Perform OnSelchangeAsyncDevicename() to properly
  1198. * set up control states.
  1199. */
  1200. OnSelchangeAsyncDevicename();
  1201. /*
  1202. * Return the set fields status.
  1203. */
  1204. return(bStatus);
  1205. } // end CEditWinStationDlg::SetAsyncFields
  1206. /*******************************************************************************
  1207. *
  1208. * SetNetworkFields - CEditWinStationDlg member function: protected operation
  1209. *
  1210. * Set the contents of the Network Pd configuration fields.
  1211. *
  1212. * ENTRY:
  1213. * EXIT:
  1214. * TRUE if no errors on field setting; FALSE otherwise.
  1215. * WM_EDITSETFIELDSERROR message(s) will have been posted on error.
  1216. *
  1217. ******************************************************************************/
  1218. BOOL
  1219. CEditWinStationDlg::SetNetworkFields()
  1220. {
  1221. int i;
  1222. BOOL bSelectDefault = (m_DlgMode == EWSDlgAdd) ||
  1223. (m_DlgMode == EWSDlgCopy) ||
  1224. (m_WSConfig.Pd[0].Params.Network.LanAdapter == -1);
  1225. CComboBox *pLanAdapter = (CComboBox *)GetDlgItem(IDC_NETWORK_LANADAPTER);
  1226. /*
  1227. * Set InstanceCount field and limit text.
  1228. */
  1229. SetupInstanceCount(IDC_NETWORK_INSTANCECOUNT);
  1230. ((CEdit *)GetDlgItem(IDC_NETWORK_INSTANCECOUNT))
  1231. ->LimitText( INSTANCE_COUNT_DIGIT_MAX );
  1232. /*
  1233. * Set the LANADAPTER combo-box selection.
  1234. */
  1235. for ( i = pLanAdapter->GetCount(); i > 0; i-- ) {
  1236. /*
  1237. * If the current list item has the saved Lan Adapter's number, break
  1238. * from loop to select this list item.
  1239. */
  1240. if ( m_WSConfig.Pd[0].Params.Network.LanAdapter ==
  1241. (LONG)pLanAdapter->GetItemData(i-1) )
  1242. break;
  1243. }
  1244. /*
  1245. * Select a list item only if we found a match or are to
  1246. * set the 'default'.
  1247. */
  1248. if ( (i > 0) || bSelectDefault ) {
  1249. pLanAdapter->SetCurSel(bSelectDefault ? 0 : i-1);
  1250. if ( bSelectDefault )
  1251. m_WSConfig.Pd[0].Params.Network.LanAdapter =
  1252. (LONG)pLanAdapter->GetItemData(0);
  1253. return(TRUE);
  1254. } else {
  1255. PostMessage(WM_EDITSETFIELDSERROR, IDC_NETWORK_LANADAPTER, 0);
  1256. return(FALSE);
  1257. }
  1258. } // end CEditWinStationDlg::SetNetworkFields
  1259. /*******************************************************************************
  1260. *
  1261. * SetNASIFields - CEditWinStationDlg member function: protected operation
  1262. *
  1263. * Set the contents of the NASI Pd configuration fields.
  1264. *
  1265. * ENTRY:
  1266. * EXIT:
  1267. * TRUE if no errors on field setting; FALSE otherwise.
  1268. * WM_EDITSETFIELDSERROR message(s) will have been posted on error.
  1269. *
  1270. ******************************************************************************/
  1271. BOOL
  1272. CEditWinStationDlg::SetNASIFields()
  1273. {
  1274. CComboBox *pPortName = (CComboBox *)GetDlgItem(IDC_NASI_PORTNAME);
  1275. /*
  1276. * Set edit fields.
  1277. */
  1278. SetDlgItemText(IDC_NASI_USERNAME, m_WSConfig.Pd[0].Params.Nasi.UserName);
  1279. SetDlgItemText(IDC_NASI_PASSWORD, m_WSConfig.Pd[0].Params.Nasi.PassWord);
  1280. SetupInstanceCount(IDC_NASI_INSTANCECOUNT);
  1281. /*
  1282. * Limit edit field lengths.
  1283. */
  1284. ((CEdit *)GetDlgItem(IDC_NASI_USERNAME))->LimitText(NASIUSERNAME_LENGTH);
  1285. ((CEdit *)GetDlgItem(IDC_NASI_PASSWORD))->LimitText(NASIPASSWORD_LENGTH);
  1286. pPortName->LimitText(NASISPECIFICNAME_LENGTH);
  1287. ((CEdit *)GetDlgItem(IDC_NASI_INSTANCECOUNT))->
  1288. LimitText(INSTANCE_COUNT_DIGIT_MAX);
  1289. /*
  1290. * Set the Port Name combo-box selection. Default to the
  1291. * first item in the list (if any) if no SpecificName (Port Name)
  1292. * is defined.
  1293. */
  1294. if ( !*(m_WSConfig.Pd[0].Params.Nasi.SpecificName) ) {
  1295. pPortName->SetCurSel(0);
  1296. } else {
  1297. pPortName->SetWindowText(m_WSConfig.Pd[0].Params.Nasi.SpecificName);
  1298. }
  1299. return(TRUE);
  1300. } // end CEditWinStationDlg::SetNASIFields
  1301. /*******************************************************************************
  1302. *
  1303. * SetOemTdFields - CEditWinStationDlg member function: protected operation
  1304. *
  1305. * Set the contents of the Oem Transport Pd configuration fields.
  1306. *
  1307. * ENTRY:
  1308. * EXIT:
  1309. * TRUE if no errors on field setting; FALSE otherwise.
  1310. * WM_EDITSETFIELDSERROR message(s) will have been posted on error.
  1311. *
  1312. ******************************************************************************/
  1313. BOOL
  1314. CEditWinStationDlg::SetOemTdFields()
  1315. {
  1316. BOOL bStatus = TRUE;
  1317. BOOL bSelectDefault = (m_DlgMode == EWSDlgAdd) ||
  1318. (m_DlgMode == EWSDlgCopy) ||
  1319. !(*m_WSConfig.Pd[0].Params.OemTd.DeviceName);
  1320. CComboBox *pDevice = (CComboBox *)GetDlgItem(IDC_OEMTD_DEVICENAME);
  1321. /*
  1322. * Set InstanceCount field and limit text.
  1323. */
  1324. SetupInstanceCount(IDC_OEMTD_INSTANCECOUNT);
  1325. ((CEdit *)GetDlgItem(IDC_OEMTD_INSTANCECOUNT))
  1326. ->LimitText( INSTANCE_COUNT_DIGIT_MAX );
  1327. /*
  1328. * Set the DEVICE combo-box selection.
  1329. */
  1330. if ( pDevice->SelectString(-1, m_WSConfig.Pd[0].Params.OemTd.DeviceName) == CB_ERR ) {
  1331. /*
  1332. * Can't select current DeviceName in combo-box. If this is
  1333. * because we're supposed to select a default device name, select
  1334. * the first device in the list.
  1335. */
  1336. if ( bSelectDefault ) {
  1337. pDevice->SetCurSel(0);
  1338. } else {
  1339. PostMessage(WM_EDITSETFIELDSERROR, IDC_OEMTD_DEVICENAME, 0);
  1340. bStatus = FALSE;
  1341. }
  1342. }
  1343. return(bStatus);
  1344. } // end CEditWinStationDlg::SetOemTdFields
  1345. /*******************************************************************************
  1346. *
  1347. * SetDefaults - CEditWinStationDlg member function: protected operation
  1348. *
  1349. * Set defaults for current Protocol Configuration.
  1350. *
  1351. * ENTRY:
  1352. * EXIT:
  1353. *
  1354. ******************************************************************************/
  1355. void
  1356. CEditWinStationDlg::SetDefaults()
  1357. {
  1358. int i;
  1359. WDCONFIG2 WdConfig;
  1360. CString szText;
  1361. /*
  1362. * Clear out all non-base WinStation Pd structures, and default
  1363. * the instance count if we're not in an auto-add mode.
  1364. */
  1365. for ( i=1; i < MAX_PDCONFIG; i++ )
  1366. memset(&m_WSConfig.Pd[i], 0, sizeof(PDCONFIG));
  1367. if ( !g_Add )
  1368. m_WSConfig.Create.MaxInstanceCount =
  1369. (m_WSConfig.Pd[0].Create.PdFlag & PD_SINGLE_INST) ?
  1370. 1 : INSTANCE_COUNT_UNLIMITED;
  1371. /*
  1372. * Fetch the currently selected Wd's config structure.
  1373. */
  1374. GetSelectedWdConfig(&WdConfig);
  1375. /*
  1376. * Copy the Wd information into the WinStation config structure.
  1377. */
  1378. m_WSConfig.Wd = WdConfig.Wd;
  1379. m_WSConfig.Config.User = WdConfig.User;
  1380. // m_WSConfig.Config.Hotkeys = WdConfig.Hotkeys;
  1381. /*
  1382. * Establish default settings for the Pd[0]'s PdParams structure.
  1383. */
  1384. switch ( m_WSConfig.Pd[0].Create.SdClass ) {
  1385. case SdNetwork:
  1386. /*
  1387. * Zeroing the Pd[0].Params.Network structure and setting the
  1388. * LanAdapter field to -1 will set proper defaults.
  1389. */
  1390. memset(&m_WSConfig.Pd[0].Params.Network, 0,
  1391. sizeof(m_WSConfig.Pd[0].Params.Network));
  1392. m_WSConfig.Pd[0].Params.Network.LanAdapter = -1;
  1393. break;
  1394. case SdNasi:
  1395. /*
  1396. * Zero the Pd[0].Params.Nasi structure, set GlobalSession TRUE,
  1397. * UserName to default, and SessionName to the AppServer name
  1398. * (less the beginning slashes).
  1399. */
  1400. memset(&m_WSConfig.Pd[0].Params.Nasi, 0,
  1401. sizeof(m_WSConfig.Pd[0].Params.Nasi));
  1402. m_WSConfig.Pd[0].Params.Nasi.GlobalSession = TRUE;
  1403. szText.LoadString(IDS_NASI_DEFAULT_USERNAME);
  1404. lstrcpy(m_WSConfig.Pd[0].Params.Nasi.UserName, szText);
  1405. lstrncpy( m_WSConfig.Pd[0].Params.Nasi.SessionName,
  1406. &(pApp->m_szCurrentAppServer[2]),
  1407. NASISESSIONNAME_LENGTH );
  1408. m_WSConfig.Pd[0].Params.Nasi.SessionName[NASISESSIONNAME_LENGTH] =
  1409. TCHAR('\0');
  1410. /*
  1411. * We also establish the PortName list box at this time.
  1412. */
  1413. InitializeNASIPortNames(&(m_WSConfig.Pd[0].Params.Nasi));
  1414. break;
  1415. case SdAsync:
  1416. /*
  1417. * Copy the Async WD configuration information into
  1418. * Pd[0]'s Async structure to establish defaults.
  1419. */
  1420. m_WSConfig.Pd[0].Params.Async = WdConfig.Async;
  1421. break;
  1422. case SdOemTransport:
  1423. /*
  1424. * Zero the Pd[0].Params.OemTd structure to set proper defaults.
  1425. */
  1426. memset(&m_WSConfig.Pd[0].Params.OemTd, 0,
  1427. sizeof(m_WSConfig.Pd[0].Params.OemTd));
  1428. break;
  1429. }
  1430. /*
  1431. * Set the encryption level to the default for the WD
  1432. */
  1433. EncryptionLevel *pEncryptionLevels = NULL;
  1434. LONG NumEncryptionLevels = 0L;
  1435. BOOL bSet = FALSE;
  1436. // Get the array of encryption levels from the extension DLL
  1437. PTERMLOBJECT pTermObject = GetSelectedWdListObject();
  1438. if(pTermObject && pTermObject->m_hExtensionDLL && pTermObject->m_lpfnExtEncryptionLevels)
  1439. NumEncryptionLevels = (*pTermObject->m_lpfnExtEncryptionLevels)(&WdConfig.Wd.WdName, &pEncryptionLevels);
  1440. if(pEncryptionLevels) {
  1441. // Loop through the encryption levels and look for the default
  1442. for(int i = 0; i < NumEncryptionLevels; i++) {
  1443. // If this is the default encryption level, set the user's
  1444. // encryption level to this one
  1445. if(pEncryptionLevels[i].Flags & ELF_DEFAULT) {
  1446. m_WSConfig.Config.User.MinEncryptionLevel = (UCHAR)pEncryptionLevels[i].RegistryValue;
  1447. bSet = TRUE;
  1448. }
  1449. }
  1450. // If none of the encryption levels was flagged as the default,
  1451. // use the first encryption level as the default.
  1452. if(!bSet) {
  1453. m_WSConfig.Config.User.MinEncryptionLevel = (UCHAR)pEncryptionLevels[0].RegistryValue;
  1454. }
  1455. } else {
  1456. // There aren't any encryption levels
  1457. m_WSConfig.Config.User.MinEncryptionLevel = 0;
  1458. }
  1459. /*
  1460. * Update the Protocol Configuration fields.
  1461. */
  1462. SetConfigurationFields();
  1463. } // end CEditWinStationDlg::SetDefaults
  1464. /*******************************************************************************
  1465. *
  1466. * GetConfigurationFields -
  1467. * CEditWinStationDlg member function: protected operation
  1468. *
  1469. * Fetch the configuration field contents and validate.
  1470. *
  1471. * ENTRY:
  1472. * EXIT:
  1473. * (BOOL) TRUE if the configuration fields were all OK; FALSE otherwise.
  1474. *
  1475. ******************************************************************************/
  1476. BOOL
  1477. CEditWinStationDlg::GetConfigurationFields()
  1478. {
  1479. /*
  1480. * Fetch the data in the configuration fields.
  1481. */
  1482. switch ( m_WSConfig.Pd[0].Create.SdClass ) {
  1483. case SdNone:
  1484. break;
  1485. case SdAsync:
  1486. return(GetAsyncFields());
  1487. case SdNetwork:
  1488. return(GetNetworkFields());
  1489. case SdNasi:
  1490. return(GetNASIFields());
  1491. case SdOemTransport:
  1492. return(GetOemTdFields());
  1493. }
  1494. return(TRUE);
  1495. } // end CEditWinStationDlg::GetConfigurationFields
  1496. /*******************************************************************************
  1497. *
  1498. * GetAsyncFields - CEditWinStationDlg member function: protected operation
  1499. *
  1500. * Fetch and validate the Async configuration field contents.
  1501. *
  1502. * ENTRY:
  1503. * EXIT:
  1504. * (BOOL) TRUE if all of the Async configuration fields were OK;
  1505. * FALSE otherwise.
  1506. *
  1507. ******************************************************************************/
  1508. BOOL
  1509. CEditWinStationDlg::GetAsyncFields()
  1510. {
  1511. /*
  1512. * Fetch the currently selected DEVICENAME string.
  1513. */
  1514. {
  1515. CComboBox *pDeviceName = (CComboBox *)GetDlgItem(IDC_ASYNC_DEVICENAME);
  1516. int index;
  1517. if ( !pDeviceName->GetCount() ||
  1518. ((index = pDeviceName->GetCurSel()) == CB_ERR) ) {
  1519. /*
  1520. * No device is selected.
  1521. */
  1522. ERROR_MESSAGE((IDP_INVALID_DEVICE))
  1523. GotoDlgCtrl(GetDlgItem(IDC_ASYNC_DEVICENAME));
  1524. return(FALSE);
  1525. } else
  1526. OnSelchangeAsyncDevicename();
  1527. }
  1528. /*
  1529. * Get the MODEMCALLBACK phone number (callback state and 'user specified'
  1530. * flags are already gotten).
  1531. */
  1532. GetDlgItemText( IDC_ASYNC_MODEMCALLBACK_PHONENUMBER,
  1533. m_WSConfig.Config.User.CallbackNumber,
  1534. lengthof(m_WSConfig.Config.User.CallbackNumber) );
  1535. /*
  1536. * Fetch and convert the BAUDRATE combo-box selection (in it's edit field).
  1537. */
  1538. {
  1539. TCHAR string[ULONG_DIGIT_MAX], *endptr;
  1540. ULONG ul;
  1541. GetDlgItemText(IDC_ASYNC_BAUDRATE, string, lengthof(string));
  1542. ul = lstrtoul( string, &endptr, 10 );
  1543. if ( *endptr != TEXT('\0') ) {
  1544. /*
  1545. * Invalid character in Baud Rate field.
  1546. */
  1547. ERROR_MESSAGE((IDP_INVALID_BAUDRATE))
  1548. GotoDlgCtrl(GetDlgItem(IDC_ASYNC_BAUDRATE));
  1549. return(FALSE);
  1550. } else
  1551. m_WSConfig.Pd[0].Params.Async.BaudRate = ul;
  1552. }
  1553. /*
  1554. * Fetch the CONNECT combo-box selection and set/reset the break
  1555. * disconnect flag.
  1556. */
  1557. if ( (m_WSConfig.Pd[0].Params.Async.Connect.Type = (ASYNCCONNECTCLASS)
  1558. ((CComboBox *)GetDlgItem(IDC_ASYNC_CONNECT))->GetCurSel()) ==
  1559. Connect_FirstChar )
  1560. m_WSConfig.Pd[0].Params.Async.Connect.fEnableBreakDisconnect = 1;
  1561. else
  1562. m_WSConfig.Pd[0].Params.Async.Connect.fEnableBreakDisconnect = 0;
  1563. return(TRUE);
  1564. } // end CEditWinStationDlg::GetAsyncFields
  1565. /*******************************************************************************
  1566. *
  1567. * GetNetworkFields - CEditWinStationDlg member function: protected operation
  1568. *
  1569. * Fetch and validate the Network configuration field contents.
  1570. *
  1571. * ENTRY:
  1572. *
  1573. * EXIT:
  1574. * (BOOL) TRUE if all of the Network configuration fields were OK;
  1575. * FALSE otherwise.
  1576. *
  1577. ******************************************************************************/
  1578. BOOL
  1579. CEditWinStationDlg::GetNetworkFields()
  1580. {
  1581. CComboBox *pLanAdapter = (CComboBox *)GetDlgItem(IDC_NETWORK_LANADAPTER);
  1582. int index;
  1583. /*
  1584. * Fetch & validate instance count field.
  1585. */
  1586. if ( !ValidateInstanceCount(IDC_NETWORK_INSTANCECOUNT) )
  1587. return(FALSE);
  1588. /*
  1589. * Fetch the currently selected LANADAPTER string's associated value
  1590. * (ordinal network card #) and save.
  1591. */
  1592. if ( !pLanAdapter->GetCount() ||
  1593. ((index = pLanAdapter->GetCurSel()) == CB_ERR) ) {
  1594. /*
  1595. * No Lan Adapter is selected.
  1596. */
  1597. if ( !pLanAdapter->GetCount() )
  1598. ERROR_MESSAGE((IDP_ERROR_NETWORKDEVICEINIT))
  1599. else
  1600. ERROR_MESSAGE((IDP_INVALID_LANADAPTER))
  1601. GotoDlgCtrl(GetDlgItem(IDC_NETWORK_LANADAPTER));
  1602. return(FALSE);
  1603. } else {
  1604. m_WSConfig.Pd[0].Params.Network.LanAdapter =
  1605. pLanAdapter->GetItemData(index);
  1606. }
  1607. return(TRUE);
  1608. } // end CEditWinStationDlg::GetNetworkFields
  1609. /*******************************************************************************
  1610. *
  1611. * GetNASIFields - CEditWinStationDlg member function: protected operation
  1612. *
  1613. * Fetch and validate the NASI configuration field contents.
  1614. *
  1615. * ENTRY:
  1616. *
  1617. * EXIT:
  1618. * (BOOL) TRUE if all of the NASI configuration fields were OK;
  1619. * FALSE otherwise.
  1620. *
  1621. ******************************************************************************/
  1622. BOOL
  1623. CEditWinStationDlg::GetNASIFields()
  1624. {
  1625. /*
  1626. * Fetch & validate UserName field.
  1627. */
  1628. GetDlgItemText( IDC_NASI_USERNAME,
  1629. m_WSConfig.Pd[0].Params.Nasi.UserName,
  1630. lengthof(m_WSConfig.Pd[0].Params.Nasi.UserName) );
  1631. if ( !*(m_WSConfig.Pd[0].Params.Nasi.UserName) ) {
  1632. ERROR_MESSAGE((IDP_INVALID_NASI_USERNAME_EMPTY))
  1633. GotoDlgCtrl(GetDlgItem(IDC_NASI_USERNAME));
  1634. return(FALSE);
  1635. }
  1636. /*
  1637. * Fetch & validate Port Name field.
  1638. */
  1639. GetDlgItemText( IDC_NASI_PORTNAME,
  1640. m_WSConfig.Pd[0].Params.Nasi.SpecificName,
  1641. lengthof(m_WSConfig.Pd[0].Params.Nasi.SpecificName) );
  1642. if ( !*(m_WSConfig.Pd[0].Params.Nasi.SpecificName) ) {
  1643. ERROR_MESSAGE((IDP_INVALID_NASI_PORTNAME_EMPTY))
  1644. GotoDlgCtrl(GetDlgItem(IDC_NASI_PORTNAME));
  1645. return(FALSE);
  1646. }
  1647. /*
  1648. * Fetch & validate instance count field.
  1649. */
  1650. if ( !ValidateInstanceCount(IDC_NASI_INSTANCECOUNT) )
  1651. return(FALSE);
  1652. /*
  1653. * Fetch Password field.
  1654. */
  1655. GetDlgItemText( IDC_NASI_PASSWORD,
  1656. m_WSConfig.Pd[0].Params.Nasi.PassWord,
  1657. lengthof(m_WSConfig.Pd[0].Params.Nasi.PassWord) );
  1658. return(TRUE);
  1659. } // end CEditWinStationDlg::GetNASIFields
  1660. /*******************************************************************************
  1661. *
  1662. * GetOemTdFields - CEditWinStationDlg member function: protected operation
  1663. *
  1664. * Fetch and validate the Oem Transport configuration field contents.
  1665. *
  1666. * ENTRY:
  1667. *
  1668. * EXIT:
  1669. * (BOOL) TRUE if all of the Oem Transport configuration fields were OK;
  1670. * FALSE otherwise.
  1671. *
  1672. ******************************************************************************/
  1673. BOOL
  1674. CEditWinStationDlg::GetOemTdFields()
  1675. {
  1676. CComboBox *pDevice = (CComboBox *)GetDlgItem(IDC_OEMTD_DEVICENAME);
  1677. int index;
  1678. /*
  1679. * Fetch & validate instance count field.
  1680. */
  1681. if ( !ValidateInstanceCount(IDC_OEMTD_INSTANCECOUNT) )
  1682. return(FALSE);
  1683. /*
  1684. * Fetch the currently selected DEVICE string.
  1685. */
  1686. if ( !pDevice->GetCount() ||
  1687. ((index = pDevice->GetCurSel()) == CB_ERR) ) {
  1688. /*
  1689. * No Device is selected.
  1690. */
  1691. ERROR_MESSAGE((IDP_INVALID_DEVICE))
  1692. GotoDlgCtrl(GetDlgItem(IDC_OEMTD_DEVICENAME));
  1693. return(FALSE);
  1694. } else {
  1695. pDevice->GetLBText(
  1696. index,
  1697. m_WSConfig.Pd[0].Params.OemTd.DeviceName);
  1698. }
  1699. return(TRUE);
  1700. } // end CEditWinStationDlg::GetOemTdFields
  1701. /*******************************************************************************
  1702. *
  1703. * SetupInstanceCount -
  1704. * CEditWinStationDlg member function: protected operation
  1705. *
  1706. * Setup the specified instance count controls based on the current
  1707. * contents of m_WSConfig.Create.MaxInstanceCount.
  1708. *
  1709. * ENTRY:
  1710. * nControlId (input)
  1711. * Control ID of the instance count edit field. nControlId+1 must
  1712. * be the control ID of the 'unlimited' checkbox.
  1713. * EXIT:
  1714. *
  1715. ******************************************************************************/
  1716. void
  1717. CEditWinStationDlg::SetupInstanceCount(int nControlId)
  1718. {
  1719. if ( m_WSConfig.Create.MaxInstanceCount == INSTANCE_COUNT_UNLIMITED ) {
  1720. CheckDlgButton( nControlId+1, TRUE );
  1721. SetDlgItemText( nControlId, TEXT("") );
  1722. GetDlgItem(nControlId)->EnableWindow(FALSE);
  1723. } else {
  1724. SetDlgItemInt( nControlId, m_WSConfig.Create.MaxInstanceCount );
  1725. GetDlgItem(nControlId)->EnableWindow( ((m_DlgMode == EWSDlgRename) ||
  1726. (m_DlgMode == EWSDlgView)) ?
  1727. FALSE : TRUE );
  1728. }
  1729. } // end CEditWinStationDlg::SetupInstanceCount
  1730. /*******************************************************************************
  1731. *
  1732. * ValidateInstanceCount -
  1733. * CEditWinStationDlg member function: protected operation
  1734. *
  1735. * Fetch and validate the specified InstanceCount control contents
  1736. * and save to m_WSConfig.Create.MaxInstanceCount member variable if valid.
  1737. *
  1738. * ENTRY:
  1739. * nControlId (input)
  1740. * Control ID of the instance count edit field. nControlId+1 must
  1741. * be the control ID of the 'unlimited' checkbox.
  1742. * EXIT:
  1743. * (BOOL) TRUE if instance count is OK; FALSE otherwise (an error message
  1744. * will have been output).
  1745. *
  1746. ******************************************************************************/
  1747. BOOL
  1748. CEditWinStationDlg::ValidateInstanceCount(int nControlId)
  1749. {
  1750. BOOL bTrans, bStatus = TRUE;
  1751. int i;
  1752. /*
  1753. * Fetch & validate instance count field if 'unlimited' checkbox
  1754. * is not checked.
  1755. */
  1756. if ( !((CButton *)GetDlgItem(nControlId+1))->GetCheck() ) {
  1757. i = GetDlgItemInt(nControlId, &bTrans);
  1758. if ( !bTrans ||
  1759. (i < INSTANCE_COUNT_MIN) || (i > INSTANCE_COUNT_MAX) ) {
  1760. /*
  1761. * Invalid instance count. Display message and return to fix.
  1762. */
  1763. ERROR_MESSAGE((IDP_INVALID_INSTANCECOUNT, INSTANCE_COUNT_MIN, INSTANCE_COUNT_MAX))
  1764. GotoDlgCtrl(GetDlgItem(nControlId));
  1765. bStatus = FALSE;
  1766. } else {
  1767. m_WSConfig.Create.MaxInstanceCount = i;
  1768. }
  1769. }
  1770. return(bStatus);
  1771. } // end CEditWinStationDlg::ValidateInstanceCount
  1772. ////////////////////////////////////////////////////////////////////////////////
  1773. // CEditWinStationDlg message map
  1774. BEGIN_MESSAGE_MAP(CEditWinStationDlg, CBaseDialog)
  1775. //{{AFX_MSG_MAP(CEditWinStationDlg)
  1776. ON_BN_CLICKED(IDC_ASYNC_MODEMINSTALL, OnClickedAsyncModeminstall)
  1777. ON_BN_CLICKED(IDC_ASYNC_MODEMCONFIG, OnClickedAsyncModemconfig)
  1778. ON_BN_CLICKED(IDC_ASYNC_MODEMCALLBACK_INHERIT, OnClickedAsyncModemcallbackInherit)
  1779. ON_BN_CLICKED(IDC_ASYNC_MODEMCALLBACK_PHONENUMBER_INHERIT, OnClickedAsyncModemcallbackPhonenumberInherit)
  1780. ON_BN_CLICKED(IDC_ASYNC_DEFAULTS, OnClickedAsyncDefaults)
  1781. ON_BN_CLICKED(IDC_ASYNC_ADVANCED, OnClickedAsyncAdvanced)
  1782. ON_BN_CLICKED(IDC_ASYNC_TEST, OnClickedAsyncTest)
  1783. ON_BN_CLICKED(IDC_NASI_INSTANCECOUNT_UNLIMITED, OnClickedNasiInstancecountUnlimited)
  1784. ON_BN_CLICKED(IDC_NASI_ADVANCED, OnClickedNasiAdvanced)
  1785. ON_BN_CLICKED(IDC_NETWORK_INSTANCECOUNT_UNLIMITED, OnClickedNetworkInstancecountUnlimited)
  1786. ON_BN_CLICKED(IDC_OEMTD_INSTANCECOUNT_UNLIMITED, OnClickedOemInstancecountUnlimited)
  1787. ON_BN_CLICKED(IDC_ADVANCED_WINSTATION, OnClickedAdvancedWinStation)
  1788. ON_CBN_CLOSEUP(IDC_TDNAME, OnCloseupPdname)
  1789. ON_CBN_SELCHANGE(IDC_TDNAME, OnSelchangePdname)
  1790. ON_CBN_CLOSEUP(IDC_WDNAME, OnCloseupWdname)
  1791. ON_CBN_SELCHANGE(IDC_WDNAME, OnSelchangeWdname)
  1792. ON_CBN_CLOSEUP(IDC_ASYNC_DEVICENAME, OnCloseupAsyncDevicename)
  1793. ON_CBN_SELCHANGE(IDC_ASYNC_DEVICENAME, OnSelchangeAsyncDevicename)
  1794. ON_CBN_CLOSEUP(IDC_ASYNC_MODEMCALLBACK, OnCloseupAsyncModemcallback)
  1795. ON_CBN_SELCHANGE(IDC_ASYNC_MODEMCALLBACK, OnSelchangeAsyncModemcallback)
  1796. ON_CBN_CLOSEUP(IDC_ASYNC_BAUDRATE, OnCloseupAsyncBaudrate)
  1797. ON_CBN_SELCHANGE(IDC_ASYNC_BAUDRATE, OnSelchangeAsyncBaudrate)
  1798. ON_CBN_CLOSEUP(IDC_ASYNC_CONNECT, OnCloseupAsyncConnect)
  1799. ON_CBN_SELCHANGE(IDC_ASYNC_CONNECT, OnSelchangeAsyncConnect)
  1800. ON_CBN_DROPDOWN(IDC_NASI_PORTNAME, OnDropdownNasiPortname)
  1801. ON_MESSAGE(WM_LISTINITERROR, OnListInitError)
  1802. ON_MESSAGE(WM_EDITSETFIELDSERROR, OnSetFieldsError)
  1803. ON_BN_CLICKED(IDC_CLIENT_SETTINGS, OnClickedClientSettings)
  1804. ON_BN_CLICKED(IDC_EXTENSION_BUTTON, OnClickedExtensionButton)
  1805. //}}AFX_MSG_MAP
  1806. END_MESSAGE_MAP()
  1807. ////////////////////////////////////////////////////////////////////////////////
  1808. // CEditWinStationDlg commands
  1809. /*******************************************************************************
  1810. *
  1811. * OnInitDialog - CEditWinStationDlg member function: command (override)
  1812. *
  1813. * Performs the dialog intialization.
  1814. *
  1815. * ENTRY:
  1816. * EXIT:
  1817. * (Refer to CDialog::OnInitDialog documentation)
  1818. *
  1819. ******************************************************************************/
  1820. BOOL
  1821. CEditWinStationDlg::OnInitDialog()
  1822. {
  1823. int index, count;
  1824. CString string;
  1825. CComboBox *pComboBox;
  1826. POSITION pos;
  1827. /*
  1828. * Call the parent classes' OnInitDialog to perform default dialog
  1829. * initialization.
  1830. */
  1831. CBaseDialog::OnInitDialog();
  1832. /*
  1833. * Load up the fixed string combo boxes.
  1834. */
  1835. pComboBox = (CComboBox *)GetDlgItem(IDC_ASYNC_CONNECT);
  1836. string.LoadString(IDS_CONNECT_CTS);
  1837. pComboBox->AddString(string);
  1838. string.LoadString(IDS_CONNECT_DSR);
  1839. pComboBox->AddString(string);
  1840. string.LoadString(IDS_CONNECT_RI);
  1841. pComboBox->AddString(string);
  1842. string.LoadString(IDS_CONNECT_DCD);
  1843. pComboBox->AddString(string);
  1844. string.LoadString(IDS_CONNECT_FIRST_CHARACTER);
  1845. pComboBox->AddString(string);
  1846. string.LoadString(IDS_CONNECT_ALWAYS);
  1847. pComboBox->AddString(string);
  1848. pComboBox = (CComboBox *)GetDlgItem(IDC_ASYNC_MODEMCALLBACK);
  1849. string.LoadString(IDS_MODEM_CALLBACK_DISABLED);
  1850. pComboBox->AddString(string);
  1851. string.LoadString(IDS_MODEM_CALLBACK_ROVING);
  1852. pComboBox->AddString(string);
  1853. string.LoadString(IDS_MODEM_CALLBACK_FIXED);
  1854. pComboBox->AddString(string);
  1855. /*
  1856. * Initialize the WinStation name field if we're not in 'rename' mode.
  1857. */
  1858. if ( m_DlgMode != EWSDlgRename )
  1859. SetDlgItemText( IDC_WINSTATIONNAME, m_pWSName );
  1860. /*
  1861. * Initialize the Wd list box.
  1862. */
  1863. pComboBox = ((CComboBox *)GetDlgItem(IDC_WDNAME));
  1864. pComboBox->ResetContent();
  1865. for ( count = 0, pos = pApp->m_WdList.GetHeadPosition(); pos != NULL; count++ ) {
  1866. PTERMLOBJECT pObject = (PTERMLOBJECT)pApp->m_WdList.GetNext( pos );
  1867. index = pComboBox->AddString( pObject->m_WdConfig.Wd.WdName );
  1868. pComboBox->SetItemData(index, count);
  1869. }
  1870. /*
  1871. * Set the currently-selected WD.
  1872. */
  1873. if ( pComboBox->SelectString( -1, m_WSConfig.Wd.WdName ) == CB_ERR )
  1874. pComboBox->SetCurSel(0);
  1875. /*
  1876. * Disable the Wd list box and label if only one element is in the list.
  1877. */
  1878. pComboBox->EnableWindow(pComboBox->GetCount() > 1 ? TRUE : FALSE);
  1879. GetDlgItem(IDL_WDNAME)->EnableWindow(pComboBox->GetCount() > 1 ? TRUE : FALSE);
  1880. /*
  1881. * Set all combo boxes to use the 'extended' UI.
  1882. */
  1883. ((CComboBox *)GetDlgItem(IDC_TDNAME))->SetExtendedUI(TRUE);
  1884. ((CComboBox *)GetDlgItem(IDC_WDNAME))->SetExtendedUI(TRUE);
  1885. ((CComboBox *)GetDlgItem(IDC_ASYNC_DEVICENAME))->SetExtendedUI(TRUE);
  1886. ((CComboBox *)GetDlgItem(IDC_ASYNC_BAUDRATE))->SetExtendedUI(TRUE);
  1887. ((CComboBox *)GetDlgItem(IDC_ASYNC_CONNECT))->SetExtendedUI(TRUE);
  1888. ((CComboBox *)GetDlgItem(IDC_NETWORK_LANADAPTER))->SetExtendedUI(TRUE);
  1889. ((CComboBox *)GetDlgItem(IDC_NASI_PORTNAME))->SetExtendedUI(TRUE);
  1890. /*
  1891. * Initialize all other common control contents.
  1892. */
  1893. SetDlgItemText( IDC_WSCOMMENT, m_WSConfig.Config.Comment );
  1894. /*
  1895. * Set the maximum length for the edit controls.
  1896. */
  1897. ((CEdit *)GetDlgItem(IDC_WINSTATIONNAME))
  1898. ->LimitText(WINSTATIONNAME_LENGTH);
  1899. ((CEdit *)GetDlgItem(IDC_WSCOMMENT))
  1900. ->LimitText(WINSTATIONCOMMENT_LENGTH);
  1901. /*
  1902. * Process for current dialog mode.
  1903. */
  1904. if ( m_DlgMode == EWSDlgView ) {
  1905. /*
  1906. * View mode: set the dialog's title to "View WinStation Configuration".
  1907. */
  1908. {
  1909. CString szTitle;
  1910. szTitle.LoadString(IDS_VIEW_WINSTATION);
  1911. SetWindowText(szTitle);
  1912. }
  1913. /*
  1914. * Disable all common dialog controls (and their labels), except for
  1915. * navigation, CANCEL, & HELP buttons.
  1916. */
  1917. GetDlgItem(IDC_WINSTATIONNAME)->EnableWindow(FALSE);
  1918. GetDlgItem(IDL_WINSTATIONNAME)->EnableWindow(FALSE);
  1919. GetDlgItem(IDC_TDNAME)->EnableWindow(FALSE);
  1920. GetDlgItem(IDL_TDNAME)->EnableWindow(FALSE);
  1921. GetDlgItem(IDC_WDNAME)->EnableWindow(FALSE);
  1922. GetDlgItem(IDL_WDNAME)->EnableWindow(FALSE);
  1923. GetDlgItem(IDC_WSCOMMENT)->EnableWindow(FALSE);
  1924. GetDlgItem(IDL_WSCOMMENT)->EnableWindow(FALSE);
  1925. GetDlgItem(IDOK)->EnableWindow(FALSE);
  1926. } else if ( m_DlgMode == EWSDlgEdit ) {
  1927. /*
  1928. * Edit mode: set the dialog's title to "Edit WinStation Configuration".
  1929. */
  1930. {
  1931. CString szTitle;
  1932. szTitle.LoadString(IDS_EDIT_WINSTATION);
  1933. SetWindowText(szTitle);
  1934. }
  1935. /*
  1936. * Disable the WinStationName box and PD & WD combo boxes.
  1937. */
  1938. GetDlgItem(IDC_WINSTATIONNAME)->EnableWindow(FALSE);
  1939. GetDlgItem(IDL_WINSTATIONNAME)->EnableWindow(FALSE);
  1940. GetDlgItem(IDC_TDNAME)->EnableWindow(FALSE);
  1941. GetDlgItem(IDL_TDNAME)->EnableWindow(FALSE);
  1942. GetDlgItem(IDC_WDNAME)->EnableWindow(FALSE);
  1943. GetDlgItem(IDL_WDNAME)->EnableWindow(FALSE);
  1944. } else if ( m_DlgMode == EWSDlgAdd ) {
  1945. /*
  1946. * Add mode: set the dialog's title to "New WinStation".
  1947. */
  1948. {
  1949. CString szTitle;
  1950. szTitle.LoadString(IDS_NEW_WINSTATION);
  1951. SetWindowText(szTitle);
  1952. }
  1953. } else if ( m_DlgMode == EWSDlgCopy ){
  1954. /*
  1955. * Copy mode: set the dialog's title to "Copy of " plus the
  1956. * current WinStation name.
  1957. */
  1958. {
  1959. CString szTitle;
  1960. szTitle.LoadString(IDS_COPY_WINSTATION);
  1961. SetWindowText( szTitle + m_pWSName );
  1962. }
  1963. /*
  1964. * Disable the PD and WD combo boxes.
  1965. */
  1966. GetDlgItem(IDC_TDNAME)->EnableWindow(FALSE);
  1967. GetDlgItem(IDL_TDNAME)->EnableWindow(FALSE);
  1968. GetDlgItem(IDC_WDNAME)->EnableWindow(FALSE);
  1969. GetDlgItem(IDL_WDNAME)->EnableWindow(FALSE);
  1970. } else {
  1971. /*
  1972. * Rename mode: set the dialog's title to "Rename " plus the
  1973. * current WinStation name.
  1974. */
  1975. {
  1976. CString szTitle;
  1977. szTitle.LoadString(IDS_RENAME_WINSTATION);
  1978. SetWindowText( szTitle + m_pWSName );
  1979. }
  1980. /*
  1981. * Disable all common dialog controls (and their labels), except for
  1982. * WinStationName field and navigation, OK, CANCEL, & HELP buttons.
  1983. */
  1984. GetDlgItem(IDC_TDNAME)->EnableWindow(FALSE);
  1985. GetDlgItem(IDL_TDNAME)->EnableWindow(FALSE);
  1986. GetDlgItem(IDC_WDNAME)->EnableWindow(FALSE);
  1987. GetDlgItem(IDL_WDNAME)->EnableWindow(FALSE);
  1988. GetDlgItem(IDC_WSCOMMENT)->EnableWindow(FALSE);
  1989. GetDlgItem(IDL_WSCOMMENT)->EnableWindow(FALSE);
  1990. }
  1991. /*
  1992. * Zero init previous PdConfig and initialize fields.
  1993. */
  1994. memset(&m_PreviousPdConfig, 0, sizeof(m_PreviousPdConfig));
  1995. if ( m_DlgMode != EWSDlgAdd ) {
  1996. PDCONFIG3 PdConfig;
  1997. /*
  1998. * We're not in Add mode, so initialize list boxes for this WinStation's
  1999. * WD and TD and call SetConfigurationFields() to enable/show the proper
  2000. * configuration field controls and initialize them. We don't call
  2001. * OnSelchangeWdname() as for Add mode, because that will set Pd, Wd,
  2002. * and field defaults, loosing the current settings.
  2003. */
  2004. RefrenceAssociatedLists();
  2005. InitializeTransportComboBox();
  2006. GetSelectedPdConfig(&PdConfig);
  2007. if ( !InitializeLists(&PdConfig) )
  2008. PostMessage(WM_LISTINITERROR, 0, (LPARAM)GetLastError());
  2009. SetConfigurationFields();
  2010. /*
  2011. * Update the extension DLL button based on the selected Wd
  2012. */
  2013. PTERMLOBJECT pObject = GetSelectedWdListObject();
  2014. BOOL bShowButton = FALSE;
  2015. if(pObject && pObject->m_hExtensionDLL) {
  2016. TCHAR string[128];
  2017. if(::LoadString(pObject->m_hExtensionDLL, 100, string, 127)) {
  2018. /*
  2019. * The button is specified as hidden in the dialog template so
  2020. * we need to set the text and then show the window.
  2021. */
  2022. ((CButton*)GetDlgItem(IDC_EXTENSION_BUTTON))->SetWindowText(string);
  2023. bShowButton = TRUE;
  2024. }
  2025. }
  2026. ((CButton*)GetDlgItem(IDC_EXTENSION_BUTTON))->ShowWindow(bShowButton);
  2027. } else {
  2028. /*
  2029. * We're in auto-add mode.
  2030. */
  2031. if ( g_Add ) {
  2032. /*
  2033. * Set instance count from command line.
  2034. */
  2035. m_WSConfig.Create.MaxInstanceCount = (int)g_ulCount;
  2036. /*
  2037. * Initialize WdName and PdName to specified wd and transport.
  2038. */
  2039. lstrcpy(m_WSConfig.Wd.WdName, g_szType);
  2040. lstrcpy(m_WSConfig.Pd[0].Create.PdName, g_szTransport);
  2041. OnSelchangeWdname();
  2042. /*
  2043. * Post an IDOK message to cause automatic addition.
  2044. */
  2045. PostMessage(WM_COMMAND, IDOK);
  2046. } else { // normal add
  2047. /*
  2048. * NULL the PdName to establish the default WD / TD for
  2049. * the new WinStation.
  2050. */
  2051. memset( m_WSConfig.Pd[0].Create.PdName, 0,
  2052. sizeof(m_WSConfig.Pd[0].Create.PdName) );
  2053. OnSelchangeWdname();
  2054. }
  2055. }
  2056. /*
  2057. * If we're not in batch mode, make our window visible.
  2058. */
  2059. if ( !g_Batch )
  2060. ShowWindow(SW_SHOW);
  2061. /*
  2062. * If we're in Edit mode, set focus to the comment field.
  2063. * Otherwise, let dialog set focus/select first available control.
  2064. */
  2065. if ( m_DlgMode == EWSDlgEdit ) {
  2066. CEdit *pEdit = (CEdit *)GetDlgItem(IDC_WSCOMMENT);
  2067. GotoDlgCtrl(pEdit);
  2068. return(FALSE);
  2069. } else
  2070. return(TRUE);
  2071. } // end CEditWinStationDlg::OnInitDialog
  2072. /*******************************************************************************
  2073. *
  2074. * OnClickedAsyncModeminstall - CEditWinStationDlg member function: command
  2075. *
  2076. * Invoke the UNIMODEM installation dialog.
  2077. *
  2078. * ENTRY:
  2079. * EXIT:
  2080. *
  2081. ******************************************************************************/
  2082. #define MODEMINSTALL_ENUM_RETRY_COUNT 5
  2083. void CEditWinStationDlg::OnClickedAsyncModeminstall()
  2084. {
  2085. pApp->m_bAllowHelp = FALSE;
  2086. CComboBox *pDevice = (CComboBox *)GetDlgItem(IDC_ASYNC_DEVICENAME);
  2087. if ( InstallModem( GetSafeHwnd() ) ) {
  2088. PDCONFIG3 PdConfig;
  2089. int i;
  2090. CWaitCursor wait;
  2091. if ( ((m_DlgMode == EWSDlgAdd) || (m_DlgMode == EWSDlgCopy)) &&
  2092. !*(m_WSConfig.Pd[0].Params.Async.ModemName) ) {
  2093. /*
  2094. * If we're in Add or Copy mode and the currently selected device
  2095. * is not a modem device, zero out the device field before
  2096. * re-initializing the device list so that if the user added a
  2097. * modem to the device it will no longer show up in the list.
  2098. */
  2099. *(m_WSConfig.Pd[0].Params.Async.DeviceName) = TEXT('\0');
  2100. }
  2101. /*
  2102. * Loop up to MODEMINSTALL_ENUM_RETRY_COUNT times till we notice
  2103. * the new TAPI device.
  2104. */
  2105. for ( i = 0; i < MODEMINSTALL_ENUM_RETRY_COUNT; i++ ) {
  2106. m_bAsyncListsInitialized = FALSE;
  2107. GetSelectedPdConfig(&PdConfig);
  2108. InitializeAsyncLists(&PdConfig);
  2109. if ( m_nCurrentMaxTAPILineNumber > m_nPreviousMaxTAPILineNumber ) {
  2110. pDevice->SetCurSel(m_nComboBoxIndexOfLatestTAPIDevice);
  2111. break;
  2112. } else {
  2113. Sleep(1000L);
  2114. }
  2115. }
  2116. pDevice->ShowDropDown(TRUE);
  2117. }
  2118. pApp->m_bAllowHelp = TRUE;
  2119. } // end CEditWinStationDlg::OnClickedAsyncModeminstall
  2120. /*******************************************************************************
  2121. *
  2122. * OnClickedAsyncModemconfig - CEditWinStationDlg member function: command
  2123. *
  2124. * Invoke the UNIMODEM Config dialog.
  2125. *
  2126. * ENTRY:
  2127. * EXIT:
  2128. *
  2129. ******************************************************************************/
  2130. void
  2131. CEditWinStationDlg::OnClickedAsyncModemconfig()
  2132. {
  2133. pApp->m_bAllowHelp = FALSE;
  2134. if ( !ConfigureModem( m_WSConfig.Pd[0].Params.Async.ModemName,
  2135. GetSafeHwnd() ) ) {
  2136. ERROR_MESSAGE(( IDP_ERROR_MODEM_PROPERTIES_NOT_AVAILABLE,
  2137. m_WSConfig.Pd[0].Params.Async.ModemName ));
  2138. }
  2139. pApp->m_bAllowHelp = TRUE;
  2140. } // end CEditWinStationDlg::OnClickedAsyncModemconfig
  2141. /*******************************************************************************
  2142. *
  2143. * OnClickedAsyncModemcallbackInherit -
  2144. * CEditWinStationDlg member function: command
  2145. *
  2146. * Handle the 'inherit user config' for modem callback.
  2147. *
  2148. * ENTRY:
  2149. * EXIT:
  2150. *
  2151. ******************************************************************************/
  2152. void
  2153. CEditWinStationDlg::OnClickedAsyncModemcallbackInherit()
  2154. {
  2155. BOOL bChecked = ((CButton *)GetDlgItem(IDC_ASYNC_MODEMCALLBACK_INHERIT))->GetCheck();
  2156. BOOL bEnable = !bChecked &&
  2157. (m_DlgMode != EWSDlgView) &&
  2158. (m_DlgMode != EWSDlgRename);
  2159. m_WSConfig.Config.User.fInheritCallback = bChecked;
  2160. GetDlgItem(IDL_ASYNC_MODEMCALLBACK1)->EnableWindow(bEnable);
  2161. GetDlgItem(IDC_ASYNC_MODEMCALLBACK)->EnableWindow(bEnable);
  2162. } // end CEditWinStationDlg::OnClickedAsyncModemcallbackInherit
  2163. /*******************************************************************************
  2164. *
  2165. * OnClickedAsyncModemcallbackPhonenumberInherit -
  2166. * CEditWinStationDlg member function: command
  2167. *
  2168. * Handle the 'inherit user config' for modem callback phone number.
  2169. *
  2170. * ENTRY:
  2171. * EXIT:
  2172. *
  2173. ******************************************************************************/
  2174. void
  2175. CEditWinStationDlg::OnClickedAsyncModemcallbackPhonenumberInherit()
  2176. {
  2177. BOOL bChecked = ((CButton *)GetDlgItem(IDC_ASYNC_MODEMCALLBACK_PHONENUMBER_INHERIT))->GetCheck();
  2178. BOOL bEnable = !bChecked &&
  2179. (m_DlgMode != EWSDlgView) &&
  2180. (m_DlgMode != EWSDlgRename);
  2181. m_WSConfig.Config.User.fInheritCallbackNumber = bChecked;
  2182. GetDlgItem(IDL_ASYNC_MODEMCALLBACK_PHONENUMBER)->EnableWindow(bEnable);
  2183. GetDlgItem(IDC_ASYNC_MODEMCALLBACK_PHONENUMBER)->EnableWindow(bEnable);
  2184. } // end CEditWinStationDlg::OnClickedAsyncModemcallbackPhonenumberInherit
  2185. /*******************************************************************************
  2186. *
  2187. * OnClickedAsyncDefaults - CEditWinStationDlg member function: command
  2188. *
  2189. * Invoke the SetDefaults() member in response to Defaults button click.
  2190. *
  2191. * ENTRY:
  2192. * EXIT:
  2193. *
  2194. ******************************************************************************/
  2195. void CEditWinStationDlg::OnClickedAsyncDefaults()
  2196. {
  2197. SetDefaults();
  2198. } // end CEditWinStationDlg::OnClickedAsyncDefaults
  2199. /*******************************************************************************
  2200. *
  2201. * OnClickedAsyncAdvanced - CEditWinStationDlg member function: command
  2202. *
  2203. * Invoke the Advanced Async dialog.
  2204. *
  2205. * ENTRY:
  2206. * EXIT:
  2207. *
  2208. ******************************************************************************/
  2209. void CEditWinStationDlg::OnClickedAsyncAdvanced()
  2210. {
  2211. CAdvancedAsyncDlg AADlg;
  2212. /*
  2213. * Initialize the dialog's member variables.
  2214. */
  2215. AADlg.m_Async = m_WSConfig.Pd[0].Params.Async;
  2216. AADlg.m_bReadOnly = (m_DlgMode == EWSDlgView) ||
  2217. (m_DlgMode == EWSDlgRename) ? TRUE : FALSE;
  2218. AADlg.m_bModem = FALSE;
  2219. AADlg.m_nHexBase = pApp->m_nHexBase;
  2220. AADlg.m_nWdFlag = m_WSConfig.Wd.WdFlag;
  2221. /*
  2222. * Invoke the dialog.
  2223. */
  2224. if ( (AADlg.DoModal() == IDOK) &&
  2225. !AADlg.m_bReadOnly ) {
  2226. /*
  2227. * Fetch the dialog's member variables.
  2228. */
  2229. m_WSConfig.Pd[0].Params.Async = AADlg.m_Async;
  2230. pApp->m_nHexBase = AADlg.m_nHexBase;
  2231. }
  2232. } // end CEditWinStationDlg::OnClickedAsyncAdvanced
  2233. /*******************************************************************************
  2234. *
  2235. * OnClickedAsyncTest - CEditWinStationDlg member function: command
  2236. *
  2237. * Invoke the Async Test dialog.
  2238. *
  2239. * ENTRY:
  2240. * EXIT:
  2241. *
  2242. ******************************************************************************/
  2243. void
  2244. CEditWinStationDlg::OnClickedAsyncTest()
  2245. {
  2246. CAsyncTestDlg ATDlg;
  2247. WINSTATIONNAME WSName;
  2248. /*
  2249. * Get the current Configuration field data. Return if invalid data
  2250. * entered (stay in edit dialog to fix the data).
  2251. */
  2252. if ( !GetConfigurationFields() )
  2253. return;
  2254. ATDlg.m_PdConfig0 = m_WSConfig.Pd[0];
  2255. ATDlg.m_PdConfig1 = m_WSConfig.Pd[1];
  2256. if ( m_DlgMode == EWSDlgEdit ) {
  2257. GetDlgItemText(IDC_WINSTATIONNAME, WSName, lengthof(WSName));
  2258. ATDlg.m_pWSName = WSName;
  2259. } else {
  2260. ATDlg.m_pWSName = NULL;
  2261. }
  2262. /*
  2263. * Invoke the dialog.
  2264. */
  2265. ATDlg.DoModal();
  2266. } // end CEditWinStationDlg::OnClickedAsyncTest
  2267. /*******************************************************************************
  2268. *
  2269. * OnClickedNasiInstancecountUnlimited -
  2270. * CEditWinStationDlg member function: command
  2271. *
  2272. * Process NASI 'unlimited' checkbox.
  2273. *
  2274. * ENTRY:
  2275. * EXIT:
  2276. *
  2277. ******************************************************************************/
  2278. void
  2279. CEditWinStationDlg::OnClickedNasiInstancecountUnlimited()
  2280. {
  2281. if ( ((CButton *)GetDlgItem(IDC_NASI_INSTANCECOUNT_UNLIMITED))->GetCheck() ) {
  2282. m_WSConfig.Create.MaxInstanceCount = INSTANCE_COUNT_UNLIMITED;
  2283. SetupInstanceCount(IDC_NASI_INSTANCECOUNT);
  2284. } else {
  2285. m_WSConfig.Create.MaxInstanceCount = INSTANCE_COUNT_MIN;
  2286. SetupInstanceCount(IDC_NASI_INSTANCECOUNT);
  2287. GotoDlgCtrl( GetDlgItem(IDC_NASI_INSTANCECOUNT) );
  2288. }
  2289. } // end CEditWinStationDlg::OnClickedNasiInstancecountUnlimited
  2290. /*******************************************************************************
  2291. *
  2292. * OnClickedNetworkInstancecountUnlimited -
  2293. * CEditWinStationDlg member function: command
  2294. *
  2295. * Process Network 'unlimited' checkbox.
  2296. *
  2297. * ENTRY:
  2298. * EXIT:
  2299. *
  2300. ******************************************************************************/
  2301. void
  2302. CEditWinStationDlg::OnClickedNetworkInstancecountUnlimited()
  2303. {
  2304. if ( ((CButton *)GetDlgItem(IDC_NETWORK_INSTANCECOUNT_UNLIMITED))->GetCheck() ) {
  2305. m_WSConfig.Create.MaxInstanceCount = INSTANCE_COUNT_UNLIMITED;
  2306. SetupInstanceCount(IDC_NETWORK_INSTANCECOUNT);
  2307. } else {
  2308. m_WSConfig.Create.MaxInstanceCount = INSTANCE_COUNT_MIN;
  2309. SetupInstanceCount(IDC_NETWORK_INSTANCECOUNT);
  2310. GotoDlgCtrl( GetDlgItem(IDC_NETWORK_INSTANCECOUNT) );
  2311. }
  2312. } // end CEditWinStationDlg::OnClickedNetworkInstancecountUnlimited
  2313. /*******************************************************************************
  2314. *
  2315. * OnClickedOemInstancecountUnlimited -
  2316. * CEditWinStationDlg member function: command
  2317. *
  2318. * Process Oem Transport 'unlimited' checkbox.
  2319. *
  2320. * ENTRY:
  2321. * EXIT:
  2322. *
  2323. ******************************************************************************/
  2324. void
  2325. CEditWinStationDlg::OnClickedOemInstancecountUnlimited()
  2326. {
  2327. if ( ((CButton *)GetDlgItem(IDC_OEMTD_INSTANCECOUNT_UNLIMITED))->GetCheck() ) {
  2328. m_WSConfig.Create.MaxInstanceCount = INSTANCE_COUNT_UNLIMITED;
  2329. SetupInstanceCount(IDC_OEMTD_INSTANCECOUNT);
  2330. } else {
  2331. m_WSConfig.Create.MaxInstanceCount = INSTANCE_COUNT_MIN;
  2332. SetupInstanceCount(IDC_OEMTD_INSTANCECOUNT);
  2333. GotoDlgCtrl( GetDlgItem(IDC_OEMTD_INSTANCECOUNT) );
  2334. }
  2335. } // end CEditWinStationDlg::OnClickedOemInstancecountUnlimited
  2336. /*******************************************************************************
  2337. *
  2338. * OnClickedNasiAdvanced - CEditWinStationDlg member function: command
  2339. *
  2340. * Invoke the Advanced NASI dialog.
  2341. *
  2342. * ENTRY:
  2343. * EXIT:
  2344. *
  2345. ******************************************************************************/
  2346. void
  2347. CEditWinStationDlg::OnClickedNasiAdvanced()
  2348. {
  2349. CAdvancedNASIDlg ANDlg;
  2350. /*
  2351. * Initialize the dialog's member variables.
  2352. */
  2353. ANDlg.m_NASIConfig = m_WSConfig.Pd[0].Params.Nasi;
  2354. ANDlg.m_bReadOnly = (m_DlgMode == EWSDlgView) ||
  2355. (m_DlgMode == EWSDlgRename) ? TRUE : FALSE;
  2356. /*
  2357. * Invoke the dialog.
  2358. */
  2359. if ( (ANDlg.DoModal() == IDOK) &&
  2360. !ANDlg.m_bReadOnly ) {
  2361. /*
  2362. * Fetch the dialog's member variables.
  2363. */
  2364. m_WSConfig.Pd[0].Params.Nasi = ANDlg.m_NASIConfig;
  2365. }
  2366. } // end CEditWinStationDlg::OnClickedNasiAdvanced
  2367. /*******************************************************************************
  2368. *
  2369. * OnClickedAdvancedWinStation - CEditWinStationDlg member function: command
  2370. *
  2371. * Invoke the AdvancedWinStation dialog.
  2372. *
  2373. * ENTRY:
  2374. * EXIT:
  2375. *
  2376. ******************************************************************************/
  2377. void
  2378. CEditWinStationDlg::OnClickedAdvancedWinStation()
  2379. {
  2380. CAdvancedWinStationDlg AWSDlg;
  2381. /*
  2382. * Initialize the dialog's member variables.
  2383. */
  2384. AWSDlg.m_fEnableWinStation = m_WSConfig.Create.fEnableWinStation;
  2385. AWSDlg.m_UserConfig = m_WSConfig.Config.User;
  2386. // AWSDlg.m_Hotkeys = m_WSConfig.Config.Hotkeys;
  2387. AWSDlg.m_bReadOnly = (m_DlgMode == EWSDlgView) ||
  2388. (m_DlgMode == EWSDlgRename) ? TRUE : FALSE;
  2389. AWSDlg.m_bSystemConsole = !lstrcmpi( m_pWSName, pApp->m_szSystemConsole ) ?
  2390. TRUE : FALSE;
  2391. AWSDlg.m_pTermObject = GetSelectedWdListObject();
  2392. /*
  2393. * Invoke the dialog.
  2394. */
  2395. if ( (AWSDlg.DoModal() == IDOK) &&
  2396. !AWSDlg.m_bReadOnly ) {
  2397. /*
  2398. * Copy dialog's member variables back to our local member variables.
  2399. */
  2400. m_WSConfig.Create.fEnableWinStation = AWSDlg.m_fEnableWinStation;
  2401. m_WSConfig.Config.User = AWSDlg.m_UserConfig;
  2402. // m_WSConfig.Config.Hotkeys = AWSDlg.m_Hotkeys;
  2403. }
  2404. } // end CEditWinStationDlg::OnClickedAdvancedWinStation
  2405. /*******************************************************************************
  2406. *
  2407. * OnClickedClientSettings - CEditWinStationDlg member function: command
  2408. *
  2409. * Invoke the ClientSettings dialog.
  2410. *
  2411. * ENTRY:
  2412. * EXIT:
  2413. *
  2414. ******************************************************************************/
  2415. void
  2416. CEditWinStationDlg::OnClickedClientSettings()
  2417. {
  2418. CClientSettingsDlg CSDlg;
  2419. /*
  2420. * Initialize the dialog's member variables.
  2421. */
  2422. CSDlg.m_UserConfig = m_WSConfig.Config.User;
  2423. CSDlg.m_bReadOnly = (m_DlgMode == EWSDlgView) ||
  2424. (m_DlgMode == EWSDlgRename) ? TRUE : FALSE;
  2425. PTERMLOBJECT pTermObject = GetSelectedWdListObject();
  2426. CSDlg.m_Capabilities = pTermObject ? pTermObject->m_Capabilities : 0;
  2427. /*
  2428. * Invoke the dialog.
  2429. */
  2430. if ( (CSDlg.DoModal() == IDOK) &&
  2431. !CSDlg.m_bReadOnly ) {
  2432. /*
  2433. * Copy dialog's member variables back to our local member variables.
  2434. */
  2435. m_WSConfig.Config.User = CSDlg.m_UserConfig;
  2436. }
  2437. } // end CEditWinStationDlg::OnClickedClientSettings
  2438. /*******************************************************************************
  2439. *
  2440. * OnClickedExtensionButton - CEditWinStationDlg member function: command
  2441. *
  2442. * Invoke the Extension dialog.
  2443. *
  2444. * ENTRY:
  2445. * EXIT:
  2446. *
  2447. ******************************************************************************/
  2448. void
  2449. CEditWinStationDlg::OnClickedExtensionButton()
  2450. {
  2451. PTERMLOBJECT pObject = GetSelectedWdListObject();
  2452. if(pObject && pObject->m_hExtensionDLL && pObject->m_lpfnExtDialog) {
  2453. (*pObject->m_lpfnExtDialog)(m_hWnd, m_pExtObject);
  2454. }
  2455. } // end CEditWinStationDlg::OnClickedExtensionButton
  2456. /*******************************************************************************
  2457. *
  2458. * OnCloseupPdname - CEditWinStationDlg member function: command
  2459. *
  2460. * Invoke OnSelchangePdname() when Transport combo box closes up.
  2461. *
  2462. * ENTRY:
  2463. * EXIT:
  2464. *
  2465. ******************************************************************************/
  2466. void
  2467. CEditWinStationDlg::OnCloseupPdname()
  2468. {
  2469. OnSelchangePdname();
  2470. } // end CEditWinStationDlg::OnCloseupPdname
  2471. /*******************************************************************************
  2472. *
  2473. * OnSelcahngePdname - CEditWinStationDlg member function: command
  2474. *
  2475. * Process new PD (Transport) selection.
  2476. *
  2477. * ENTRY:
  2478. * EXIT:
  2479. *
  2480. ******************************************************************************/
  2481. void
  2482. CEditWinStationDlg::OnSelchangePdname()
  2483. {
  2484. int i;
  2485. WINSTATIONNAME WSName;
  2486. PDCONFIG3 PdConfig;
  2487. PDNAME PdName;
  2488. CComboBox *pTdNameBox = (CComboBox *)GetDlgItem(IDC_TDNAME);
  2489. CWaitCursor Wait;
  2490. /*
  2491. * Ignore this notification if the combo box is in a dropped-down
  2492. * state.
  2493. */
  2494. if ( pTdNameBox->GetDroppedState() )
  2495. return;
  2496. if ( (i = pTdNameBox->GetCurSel()) != CB_ERR ) {
  2497. /*
  2498. * If the newly selected Pd is the same as the one that is currently
  2499. * selected, ignore this notification.
  2500. */
  2501. pTdNameBox->GetLBText( i, PdName );
  2502. if ( !lstrcmp(PdName, m_WSConfig.Pd[0].Create.PdName) )
  2503. return;
  2504. } else {
  2505. /*
  2506. * No current selection (we're called from OnSelchangeWdname).
  2507. * Select the currently specified PD in the combo-box. If that fails,
  2508. * select the first in the list.
  2509. */
  2510. if ( pTdNameBox->SelectString(-1, m_WSConfig.Pd[0].Create.PdName) == CB_ERR )
  2511. pTdNameBox->SetCurSel(0);
  2512. }
  2513. /*
  2514. * Fetch the currently selected Protocol's config structure.
  2515. */
  2516. GetSelectedPdConfig(&PdConfig);
  2517. /*
  2518. * Clear out all WinStation Pd structures, then copy the selected PD
  2519. * information into the WinStation config's Pd[0] structure and default
  2520. * the instance count if we're not in auto-add mode.
  2521. */
  2522. for ( i=0; i < MAX_PDCONFIG; i++ )
  2523. memset(&m_WSConfig.Pd[i], 0, sizeof(PDCONFIG));
  2524. m_WSConfig.Pd[0].Create = PdConfig.Data;
  2525. m_WSConfig.Pd[0].Params.SdClass = PdConfig.Data.SdClass;
  2526. if ( !g_Add )
  2527. m_WSConfig.Create.MaxInstanceCount =
  2528. (m_WSConfig.Pd[0].Create.PdFlag & PD_SINGLE_INST) ?
  2529. 1 : INSTANCE_COUNT_UNLIMITED;
  2530. /*
  2531. * Initialize the list box(es) that will be used with the selected PD.
  2532. */
  2533. if ( !InitializeLists(&PdConfig) )
  2534. PostMessage(WM_LISTINITERROR, 0, (LPARAM)GetLastError());
  2535. /*
  2536. * Set the default Wd settings for this WinStation.
  2537. */
  2538. SetDefaults();
  2539. /*
  2540. * Process if no name has been entered yet (edit control not 'modified'):
  2541. * If we're a SdNetwork or PdNasi type, default the WinStation name to the
  2542. * WdPrefix plus the PD name. Otherwise, clear the WinStation name field.
  2543. * Set focus to the name and clear the 'modified' flag before leaving.
  2544. */
  2545. if ( !((CEdit *)GetDlgItem(IDC_WINSTATIONNAME))->GetModify() ) {
  2546. if ( (m_WSConfig.Pd[0].Create.SdClass == SdNetwork) ||
  2547. (m_WSConfig.Pd[0].Create.SdClass == SdNasi) ) {
  2548. PTERMLOBJECT pObject = GetSelectedWdListObject();
  2549. if(pObject) {
  2550. lstrcpy(WSName, pObject->m_WdConfig.Wd.WdPrefix);
  2551. if(WSName[0]) lstrcat(WSName, TEXT("-"));
  2552. lstrcat(WSName, m_WSConfig.Pd[0].Create.PdName);
  2553. }
  2554. else
  2555. lstrcpy(WSName, m_WSConfig.Pd[0].Create.PdName);
  2556. }
  2557. else
  2558. WSName[0] = TCHAR('\0');
  2559. SetDlgItemText(IDC_WINSTATIONNAME, WSName);
  2560. ((CEdit *)GetDlgItem(IDC_WINSTATIONNAME))->SetModify(FALSE);
  2561. GotoDlgCtrl(GetDlgItem(IDC_WINSTATIONNAME));
  2562. }
  2563. } // end CEditWinStationDlg::OnSelchangePdname
  2564. /*******************************************************************************
  2565. *
  2566. * OnCloseupWdname - CEditWinStationDlg member function: command
  2567. *
  2568. * Invoke OnSelchangeWdname() when Type combo box closes up.
  2569. *
  2570. * ENTRY:
  2571. * EXIT:
  2572. *
  2573. ******************************************************************************/
  2574. void
  2575. CEditWinStationDlg::OnCloseupWdname()
  2576. {
  2577. OnSelchangeWdname();
  2578. } // end CEditWinStationDlg::OnCloseupWdname
  2579. /*******************************************************************************
  2580. *
  2581. * OnSelchangeWdname - CEditWinStationDlg member function: command
  2582. *
  2583. * Process new Wd selection.
  2584. *
  2585. * ENTRY:
  2586. * EXIT:
  2587. *
  2588. ******************************************************************************/
  2589. void
  2590. CEditWinStationDlg::OnSelchangeWdname()
  2591. {
  2592. WDNAME WdName;
  2593. CComboBox *pWdNameBox = (CComboBox *)GetDlgItem(IDC_WDNAME);
  2594. CWaitCursor Wait;
  2595. /*
  2596. * Ignore this notification if the combo box is in a dropped-down
  2597. * state.
  2598. */
  2599. if ( pWdNameBox->GetDroppedState() )
  2600. return;
  2601. pWdNameBox->GetLBText( pWdNameBox->GetCurSel(), WdName );
  2602. /*
  2603. * Update the extension DLL button based on the selected Wd
  2604. */
  2605. PTERMLOBJECT pObject = GetSelectedWdListObject();
  2606. BOOL bShowButton = FALSE;
  2607. if(pObject && pObject->m_hExtensionDLL) {
  2608. TCHAR string[128];
  2609. if(::LoadString(pObject->m_hExtensionDLL, 100, string, 127)) {
  2610. ((CButton*)GetDlgItem(IDC_EXTENSION_BUTTON))->SetWindowText(string);
  2611. bShowButton = TRUE;
  2612. }
  2613. }
  2614. ((CButton*)GetDlgItem(IDC_EXTENSION_BUTTON))->ShowWindow(bShowButton);
  2615. /*
  2616. * If the newly selected Wd is the same as the one that is currently
  2617. * selected, ignore this notification.
  2618. */
  2619. if ( !lstrcmp(WdName, m_WSConfig.Wd.WdName) )
  2620. return;
  2621. #if 0
  2622. /*
  2623. * We need to set the Wd that is associated with this WinStation
  2624. *
  2625. */
  2626. if(pObject && pObject->m_hExtensionDLL && pObject->m_lpfnExtRegQuery) {
  2627. m_pExtObject = (*pObject->m_lpfnExtRegQuery)(m_pWSName);
  2628. } else m_pExtObject = NULL;
  2629. #endif
  2630. /*
  2631. * Point to the Td and Pd lists associated with this Wd and
  2632. * (re)initialize the Transport combo-box.
  2633. */
  2634. RefrenceAssociatedLists();
  2635. InitializeTransportComboBox();
  2636. /*
  2637. * Cause no current transport selection so that OnSelchangePdname will
  2638. * not ignore the call (the user may want to configure same transport
  2639. * but different type).
  2640. */
  2641. ((CComboBox *)GetDlgItem(IDC_TDNAME))->SetCurSel(-1);
  2642. /*
  2643. * Set default field contents for the currently configured Pd.
  2644. */
  2645. OnSelchangePdname();
  2646. /*
  2647. * We need to set the Wd that is associated with this WinStation
  2648. *
  2649. */
  2650. if(pObject && pObject->m_hExtensionDLL && pObject->m_lpfnExtRegQuery) {
  2651. PDCONFIG3 PdConfig;
  2652. GetSelectedPdConfig( &PdConfig );
  2653. m_pExtObject = (*pObject->m_lpfnExtRegQuery)(m_pWSName, &m_WSConfig.Pd[0]);
  2654. } else m_pExtObject = NULL;
  2655. } // end CEditWinStationDlg::OnSelchangeWdname
  2656. /*******************************************************************************
  2657. *
  2658. * OnCloseupAsyncDevicename - CEditWinStationDlg member function: command
  2659. *
  2660. * Invoke OnSelchangeAsyncDevicename() when Device combo box closes up.
  2661. *
  2662. * ENTRY:
  2663. * EXIT:
  2664. *
  2665. ******************************************************************************/
  2666. void
  2667. CEditWinStationDlg::OnCloseupAsyncDevicename()
  2668. {
  2669. OnSelchangeAsyncDevicename();
  2670. } // end CEditWinStationDlg::OnCloseupAsyncDevicename
  2671. /*******************************************************************************
  2672. *
  2673. * OnSelchangeAsyncDevicename - CEditWinStationDlg member function: command
  2674. *
  2675. * Process new Async Device selection.
  2676. *
  2677. * ENTRY:
  2678. * EXIT:
  2679. *
  2680. ******************************************************************************/
  2681. void
  2682. CEditWinStationDlg::OnSelchangeAsyncDevicename()
  2683. {
  2684. CComboBox *pDevice = (CComboBox *)GetDlgItem(IDC_ASYNC_DEVICENAME);
  2685. BOOL bModemEnableFlag, bDirectEnableFlag;
  2686. int index, nModemCmdShow, nDirectCmdShow;
  2687. /*
  2688. * Ignore this notification if the combo box is in a dropped-down
  2689. * state.
  2690. */
  2691. if ( pDevice->GetDroppedState() )
  2692. return;
  2693. if ( (index = pDevice->GetCurSel()) != CB_ERR ) {
  2694. TCHAR szDeviceName[DEVICENAME_LENGTH+MODEMNAME_LENGTH+1];
  2695. /*
  2696. * Fetch current selection and parse into device and modem names.
  2697. */
  2698. pDevice->GetLBText(index, szDeviceName);
  2699. ParseDecoratedAsyncDeviceName( szDeviceName,
  2700. &(m_WSConfig.Pd[0].Params.Async) );
  2701. }
  2702. /*
  2703. * The SetDefaults, Advanced, and Test buttons and Device Connect
  2704. * and Baud fields are enabled if the configuration is non-modem.
  2705. * Otherwise, the Configure Modem button and modem callback fields
  2706. * are enabled. (The Install Modems buttons is always enabled).
  2707. */
  2708. if ( (*m_WSConfig.Pd[0].Params.Async.ModemName) ) {
  2709. bModemEnableFlag = ( (m_DlgMode != EWSDlgRename) &&
  2710. (m_DlgMode != EWSDlgView) ) ?
  2711. TRUE : FALSE;
  2712. nModemCmdShow = SW_SHOW;
  2713. bDirectEnableFlag = FALSE;
  2714. nDirectCmdShow = SW_HIDE;
  2715. } else {
  2716. bModemEnableFlag = FALSE;
  2717. nModemCmdShow = SW_HIDE;
  2718. bDirectEnableFlag = ( (m_DlgMode != EWSDlgRename) &&
  2719. (m_DlgMode != EWSDlgView) ) ?
  2720. TRUE : FALSE;
  2721. nDirectCmdShow = SW_SHOW;
  2722. }
  2723. GetDlgItem(IDC_ASYNC_MODEMCONFIG)->ShowWindow(nModemCmdShow);
  2724. GetDlgItem(IDC_ASYNC_MODEMCONFIG)->EnableWindow(bModemEnableFlag);
  2725. GetDlgItem(IDL_ASYNC_MODEMCALLBACK)->ShowWindow(nModemCmdShow);
  2726. GetDlgItem(IDL_ASYNC_MODEMCALLBACK)->EnableWindow(bModemEnableFlag);
  2727. GetDlgItem(IDL_ASYNC_MODEMCALLBACK1)->ShowWindow(nModemCmdShow);
  2728. GetDlgItem(IDL_ASYNC_MODEMCALLBACK1)->EnableWindow(bModemEnableFlag);
  2729. GetDlgItem(IDC_ASYNC_MODEMCALLBACK)->ShowWindow(nModemCmdShow);
  2730. GetDlgItem(IDC_ASYNC_MODEMCALLBACK)->EnableWindow(bModemEnableFlag);
  2731. GetDlgItem(IDC_ASYNC_MODEMCALLBACK_INHERIT)->ShowWindow(nModemCmdShow);
  2732. GetDlgItem(IDC_ASYNC_MODEMCALLBACK_INHERIT)->EnableWindow(bModemEnableFlag);
  2733. GetDlgItem(IDL_ASYNC_MODEMCALLBACK_PHONENUMBER)->ShowWindow(nModemCmdShow);
  2734. GetDlgItem(IDL_ASYNC_MODEMCALLBACK_PHONENUMBER)->EnableWindow(bModemEnableFlag);
  2735. GetDlgItem(IDC_ASYNC_MODEMCALLBACK_PHONENUMBER)->ShowWindow(nModemCmdShow);
  2736. GetDlgItem(IDC_ASYNC_MODEMCALLBACK_PHONENUMBER)->EnableWindow(bModemEnableFlag);
  2737. GetDlgItem(IDC_ASYNC_MODEMCALLBACK_PHONENUMBER_INHERIT)->ShowWindow(nModemCmdShow);
  2738. GetDlgItem(IDC_ASYNC_MODEMCALLBACK_PHONENUMBER_INHERIT)->EnableWindow(bModemEnableFlag);
  2739. GetDlgItem(IDL_ASYNC_CONNECT)->ShowWindow(nDirectCmdShow);
  2740. GetDlgItem(IDL_ASYNC_CONNECT)->EnableWindow(bDirectEnableFlag);
  2741. GetDlgItem(IDC_ASYNC_CONNECT)->ShowWindow(nDirectCmdShow);
  2742. GetDlgItem(IDC_ASYNC_CONNECT)->EnableWindow(bDirectEnableFlag);
  2743. GetDlgItem(IDL_ASYNC_BAUDRATE)->ShowWindow(nDirectCmdShow);
  2744. GetDlgItem(IDL_ASYNC_BAUDRATE)->EnableWindow(bDirectEnableFlag);
  2745. GetDlgItem(IDC_ASYNC_BAUDRATE)->ShowWindow(nDirectCmdShow);
  2746. GetDlgItem(IDC_ASYNC_BAUDRATE)->EnableWindow(bDirectEnableFlag);
  2747. GetDlgItem(IDC_ASYNC_DEFAULTS)->ShowWindow(nDirectCmdShow);
  2748. GetDlgItem(IDC_ASYNC_DEFAULTS)->EnableWindow(bDirectEnableFlag);
  2749. GetDlgItem(IDC_ASYNC_ADVANCED)->ShowWindow(nDirectCmdShow);
  2750. GetDlgItem(IDC_ASYNC_ADVANCED)->EnableWindow(bDirectEnableFlag);
  2751. GetDlgItem(IDC_ASYNC_TEST)->ShowWindow(nDirectCmdShow);
  2752. GetDlgItem(IDC_ASYNC_TEST)->EnableWindow(bDirectEnableFlag);
  2753. /*
  2754. * If this is a modem device, properly set the callback fields.
  2755. */
  2756. if ( (*m_WSConfig.Pd[0].Params.Async.ModemName) ) {
  2757. OnClickedAsyncModemcallbackInherit();
  2758. OnClickedAsyncModemcallbackPhonenumberInherit();
  2759. }
  2760. } // end CEditWinStationDlg::OnSelchangeAsyncDevicename
  2761. /*******************************************************************************
  2762. *
  2763. * OnCloseupAsyncModemcallback - CModemConfigDlg member function: command
  2764. *
  2765. * Invoke OnSelchangeAsyncModemcallback() when Modem Callback combo box
  2766. * closes up.
  2767. *
  2768. * ENTRY:
  2769. * EXIT:
  2770. *
  2771. ******************************************************************************/
  2772. void
  2773. CEditWinStationDlg::OnCloseupAsyncModemcallback()
  2774. {
  2775. OnSelchangeAsyncModemcallback();
  2776. } // end CEditWinStationDlg::OnCloseupAsyncModemcallback
  2777. /*******************************************************************************
  2778. *
  2779. * OnSelchangeAsyncModemcallback - CModemConfigDlg member function: command
  2780. *
  2781. * Process new Modem Callback selection.
  2782. *
  2783. * ENTRY:
  2784. * EXIT:
  2785. *
  2786. ******************************************************************************/
  2787. void
  2788. CEditWinStationDlg::OnSelchangeAsyncModemcallback()
  2789. {
  2790. CComboBox *pCallback = (CComboBox *)GetDlgItem(IDC_ASYNC_MODEMCALLBACK);
  2791. /*
  2792. * Ignore this notification if the combo box is in a dropped-down
  2793. * state.
  2794. */
  2795. if ( pCallback->GetDroppedState() )
  2796. return;
  2797. /*
  2798. * Fetch current callback selection.
  2799. */
  2800. m_WSConfig.Config.User.Callback = (CALLBACKCLASS)(pCallback->GetCurSel());
  2801. } // end CEditWinStationDlg::OnSelchangeAsyncModemcallback
  2802. /*******************************************************************************
  2803. *
  2804. * OnCloseupAsyncBaudrate - CEditWinStationDlg member function: command
  2805. *
  2806. * Invoke OnSelchangeAsyncBaudrate() when Baud combo box closes up.
  2807. *
  2808. * ENTRY:
  2809. * EXIT:
  2810. *
  2811. ******************************************************************************/
  2812. void
  2813. CEditWinStationDlg::OnCloseupAsyncBaudrate()
  2814. {
  2815. OnSelchangeAsyncBaudrate();
  2816. } // end CEditWinStationDlg::OnCloseupAsyncBaudrate
  2817. /*******************************************************************************
  2818. *
  2819. * OnSelchangeAsyncBaudrate - CEditWinStationDlg member function: command
  2820. *
  2821. * Process new Async Baud combo-box selection.
  2822. *
  2823. * ENTRY:
  2824. * EXIT:
  2825. *
  2826. ******************************************************************************/
  2827. void
  2828. CEditWinStationDlg::OnSelchangeAsyncBaudrate()
  2829. {
  2830. CComboBox *pBaud = (CComboBox *)GetDlgItem(IDC_ASYNC_BAUDRATE);
  2831. TCHAR string[ULONG_DIGIT_MAX], *endptr;
  2832. /*
  2833. * Ignore this notification if the combo box is in a dropped-down
  2834. * state.
  2835. */
  2836. if ( pBaud->GetDroppedState() )
  2837. return;
  2838. GetDlgItemText(IDC_ASYNC_BAUDRATE, string, lengthof(string));
  2839. m_WSConfig.Pd[0].Params.Async.BaudRate = lstrtoul(string, &endptr, 10);
  2840. } // end CEditWinStationDlg::OnSelchangeAsyncBaudrate
  2841. /*******************************************************************************
  2842. *
  2843. * OnCloseupAsyncConnect - CEditWinStationDlg member function: command
  2844. *
  2845. * Invoke OnSelchangeAsyncConnect() when Connect combo box closes up.
  2846. *
  2847. * ENTRY:
  2848. * EXIT:
  2849. *
  2850. ******************************************************************************/
  2851. void
  2852. CEditWinStationDlg::OnCloseupAsyncConnect()
  2853. {
  2854. OnSelchangeAsyncConnect();
  2855. } // end CEditWinStationDlg::OnCloseupAsyncConnect
  2856. /*******************************************************************************
  2857. *
  2858. * OnSelchangeAsyncConnect - CEditWinStationDlg member function: command
  2859. *
  2860. * Process new Async Connect combo-box selection.
  2861. *
  2862. * ENTRY:
  2863. * EXIT:
  2864. *
  2865. ******************************************************************************/
  2866. void
  2867. CEditWinStationDlg::OnSelchangeAsyncConnect()
  2868. {
  2869. CComboBox *pConnect = (CComboBox *)GetDlgItem(IDC_ASYNC_CONNECT);
  2870. /*
  2871. * Ignore this notification if the combo box is in a dropped-down
  2872. * state.
  2873. */
  2874. if ( pConnect->GetDroppedState() )
  2875. return;
  2876. m_WSConfig.Pd[0].Params.Async.Connect.Type =
  2877. (ASYNCCONNECTCLASS)pConnect->GetCurSel();
  2878. } // end CEditWinStationDlg::OnSelchangeAsyncConnect
  2879. /*******************************************************************************
  2880. *
  2881. * OnDropdownNasiPortname - CEditWinStationDlg member function: command
  2882. *
  2883. * Update the Port Name combo box (if necessary) when it is opened up.
  2884. *
  2885. * ENTRY:
  2886. * EXIT:
  2887. *
  2888. ******************************************************************************/
  2889. void CEditWinStationDlg::OnDropdownNasiPortname()
  2890. {
  2891. CWaitCursor Wait;
  2892. /*
  2893. * We need to retrieve the current UserName, PassWord, and PortName contents
  2894. * (with no validation) in order for InitializeNASIPortNames() to be able
  2895. * to properly determine whether or not the 'input' fields have changed
  2896. * since the last time the function was called.
  2897. *
  2898. * NOTE: be careful if you decide to validate at this point in time, because
  2899. * any error message output to complain about invalid (like empty) fields may
  2900. * mess up the behavior of the dialog (a strange side effect ButchD has
  2901. * noticed in MFC).
  2902. */
  2903. GetDlgItemText( IDC_NASI_USERNAME,
  2904. m_WSConfig.Pd[0].Params.Nasi.UserName,
  2905. lengthof(m_WSConfig.Pd[0].Params.Nasi.UserName) );
  2906. GetDlgItemText( IDC_NASI_PASSWORD,
  2907. m_WSConfig.Pd[0].Params.Nasi.PassWord,
  2908. lengthof(m_WSConfig.Pd[0].Params.Nasi.PassWord) );
  2909. GetDlgItemText( IDC_NASI_PORTNAME,
  2910. m_WSConfig.Pd[0].Params.Nasi.SpecificName,
  2911. lengthof(m_WSConfig.Pd[0].Params.Nasi.SpecificName) );
  2912. /*
  2913. * Now we get to initialize the Port Names (if needed).
  2914. */
  2915. InitializeNASIPortNames(&(m_WSConfig.Pd[0].Params.Nasi));
  2916. } // end CEditWinStationDlg::OnDropdownNasiPortname
  2917. /*******************************************************************************
  2918. *
  2919. * OnOK - CEditWinStationDlg member function: command (override)
  2920. *
  2921. * Read all control contents back into the WinStation config structure
  2922. * before closing the dialog.
  2923. *
  2924. * ENTRY:
  2925. * EXIT:
  2926. *
  2927. ******************************************************************************/
  2928. void
  2929. CEditWinStationDlg::OnOK()
  2930. {
  2931. BOOL bOk = FALSE;
  2932. /*
  2933. * Get the current Configuration field data. Return if invalid data
  2934. * entered (stay in dialog to fix the data).
  2935. */
  2936. if ( !GetConfigurationFields() )
  2937. goto done;
  2938. /*
  2939. * Read common control contents back into the WinStation config structure.
  2940. */
  2941. GetDlgItemText( IDC_WSCOMMENT, m_WSConfig.Config.Comment,
  2942. lengthof(m_WSConfig.Config.Comment) );
  2943. /*
  2944. * If we're in Add, Copy, or Rename mode, fetch WinStation name from
  2945. * control and validate.
  2946. */
  2947. if ( (m_DlgMode == EWSDlgAdd) ||
  2948. (m_DlgMode == EWSDlgCopy) ||
  2949. (m_DlgMode == EWSDlgRename) ) {
  2950. GetDlgItemText(IDC_WINSTATIONNAME, m_pWSName, lengthof(WINSTATIONNAME));
  2951. /*
  2952. * If no WinStation name has been entered, output error message and
  2953. * reset focus to WinStation name field for correction.
  2954. */
  2955. if ( !*m_pWSName ) {
  2956. ERROR_MESSAGE((IDP_INVALID_WINSTATIONNAME_EMPTY))
  2957. GotoDlgCtrl(GetDlgItem(IDC_WINSTATIONNAME));
  2958. goto done;
  2959. }
  2960. /*
  2961. * The WinStation name cannot begin with a digit.
  2962. */
  2963. if ( _istdigit(*m_pWSName) ) {
  2964. ERROR_MESSAGE((IDP_INVALID_WINSTATIONNAME_DIGIT1))
  2965. GotoDlgCtrl(GetDlgItem(IDC_WINSTATIONNAME));
  2966. goto done;
  2967. }
  2968. /*
  2969. * Validate the WinStation name for invalid characters.
  2970. */
  2971. if ( lstrpbrk(m_pWSName, TEXT(":#.\\/ ")) ) {
  2972. ERROR_MESSAGE((IDP_INVALID_WINSTATIONNAME))
  2973. GotoDlgCtrl(GetDlgItem(IDC_WINSTATIONNAME));
  2974. goto done;
  2975. }
  2976. /*
  2977. * The WinStation cannot be called 'console', which is a reserved name.
  2978. */
  2979. if ( !lstrcmpi(m_pWSName, pApp->m_szSystemConsole) ) {
  2980. ERROR_MESSAGE((IDP_INVALID_WINSTATIONNAME_CONSOLE, pApp->m_szSystemConsole))
  2981. GotoDlgCtrl(GetDlgItem(IDC_WINSTATIONNAME));
  2982. goto done;
  2983. }
  2984. /*
  2985. * Make sure that the specified WinStation name is unique.
  2986. */
  2987. if ( !((CAppServerDoc *)m_pDoc)->IsWSNameUnique(m_pWSName) ) {
  2988. ERROR_MESSAGE((IDP_INVALID_WINSTATIONNAME_NOT_UNIQUE))
  2989. /*
  2990. * Set focus back to the WinStation name field and return
  2991. * (don't allow exit).
  2992. */
  2993. GotoDlgCtrl(GetDlgItem(IDC_WINSTATIONNAME));
  2994. goto done;
  2995. }
  2996. } // end 'Add, Copy, or Rename name validation' if.
  2997. /*
  2998. * Perform special validation for SdNetwork and SdNasi types.
  2999. */
  3000. if ( (m_WSConfig.Pd[0].Create.SdClass == SdNetwork) ||
  3001. (m_WSConfig.Pd[0].Create.SdClass == SdNasi) ) {
  3002. PWSLOBJECT pWSLObject;
  3003. /*
  3004. * Special SdNetwork check:
  3005. * If this is not a 'rename', make sure that no WinStation(s)
  3006. * already exist with the selected PdName, WdName, and LanAdapter.
  3007. * We don't need to make this check for rename, since the user
  3008. * can't change anything but the name, which has already been
  3009. * validated for uniqueness above.
  3010. */
  3011. if ( (m_WSConfig.Pd[0].Create.SdClass == SdNetwork) &&
  3012. (m_DlgMode != EWSDlgRename) &&
  3013. (pWSLObject =
  3014. ((CAppServerDoc *)m_pDoc)->GetWSLObjectNetworkMatch(
  3015. m_WSConfig.Pd[0].Create.PdName,
  3016. m_WSConfig.Wd.WdName,
  3017. m_WSConfig.Pd[0].Params.Network.LanAdapter )) ) {
  3018. CString sz1;
  3019. /*
  3020. * A WinStation already exists with specified Pd, Wd, and LanAdapter.
  3021. * If we're in Edit mode and the WinStation is actually 'us', then
  3022. * this is no problem. Otherwise, tell the user of the problem.
  3023. */
  3024. if ( (m_DlgMode != EWSDlgEdit) ||
  3025. lstrcmpi(m_pWSName, pWSLObject->m_WinStationName) ) {
  3026. /*
  3027. * Output a message indicating that existing WinStation(s)
  3028. * are already defined with the current Protocol, Wd,
  3029. * and LanAdapter; at least one of these must be changed for
  3030. * new WinStation(s).
  3031. */
  3032. ERROR_MESSAGE(( IDP_INVALID_NETWORK_WINSTATIONS_ALREADY_EXIST,
  3033. pWSLObject->m_WinStationName ))
  3034. GotoDlgCtrl(GetDlgItem(IDC_WINSTATIONNAME));
  3035. goto done;
  3036. }
  3037. }
  3038. } // end 'special validation for SdNetwork and SdNasi types' if
  3039. /*
  3040. * If we're in Add, Copy, or Edit mode, make sure that the non-base PD
  3041. * configuration fields are reset and then fill them with additional
  3042. * PDs if necessary.
  3043. */
  3044. if ( (m_DlgMode == EWSDlgAdd) || (m_DlgMode == EWSDlgCopy) ||
  3045. (m_DlgMode == EWSDlgEdit) ) {
  3046. int PdNext;
  3047. UINT i;
  3048. PDCONFIG3 PdConfig, SelectedPdConfig;
  3049. PdNext = 1;
  3050. for ( i=PdNext; i < MAX_PDCONFIG; i++ )
  3051. memset(&m_WSConfig.Pd[i], 0, sizeof(PDCONFIG));
  3052. /*
  3053. * If the selected Wd is an ICA type, process for additional Pds.
  3054. */
  3055. if ( m_WSConfig.Wd.WdFlag & WDF_ICA ) {
  3056. GetSelectedPdConfig(&SelectedPdConfig);
  3057. /*
  3058. * add additonal required PDs
  3059. */
  3060. for ( i=PdNext; i < SelectedPdConfig.RequiredPdCount; i++ ) {
  3061. GetPdConfig( m_pCurrentPdList, SelectedPdConfig.RequiredPds[i], &m_WSConfig, &PdConfig );
  3062. m_WSConfig.Pd[PdNext].Create = PdConfig.Data;
  3063. m_WSConfig.Pd[PdNext].Params.SdClass = PdConfig.Data.SdClass;
  3064. PdNext++;
  3065. }
  3066. }
  3067. /*
  3068. * Special Async handling.
  3069. */
  3070. if ( m_WSConfig.Pd[0].Create.SdClass == SdAsync ) {
  3071. /*
  3072. * Properly set connection driver flag and Cd config
  3073. * structure.
  3074. */
  3075. m_WSConfig.Pd[0].Params.Async.fConnectionDriver =
  3076. *(m_WSConfig.Pd[0].Params.Async.ModemName) ?
  3077. TRUE : FALSE;
  3078. SetupAsyncCdConfig( &(m_WSConfig.Pd[0].Params.Async),
  3079. &(m_WSConfig.Cd) );
  3080. }
  3081. } // end 'Add, Copy, or Edit' Pd configuration set' if
  3082. bOk = TRUE; // all's well
  3083. done:
  3084. /*
  3085. * If we're in batch mode and not all's well, post
  3086. * IDCANCEL to cancel this batch operation.
  3087. */
  3088. if ( g_Batch && !bOk )
  3089. PostMessage(WM_COMMAND, IDCANCEL);
  3090. /*
  3091. * If all's well, Call the parent classes' OnOk to complete dialog closing
  3092. * and destruction.
  3093. */
  3094. if ( bOk )
  3095. CBaseDialog::OnOK();
  3096. } // end CEditWinStationDlg::OnOk
  3097. /*******************************************************************************
  3098. *
  3099. * OnCancel - CEditWinStationDlg member function: command (override)
  3100. *
  3101. * Cancel the dialog.
  3102. *
  3103. * ENTRY:
  3104. * EXIT:
  3105. * (Refer to CDialog::OnCancel documentation)
  3106. *
  3107. ******************************************************************************/
  3108. void CEditWinStationDlg::OnCancel()
  3109. {
  3110. /*
  3111. * Call the parent classes' OnCancel to complete dialog closing
  3112. * and destruction.
  3113. */
  3114. CBaseDialog::OnCancel();
  3115. } // end CEditWinStationDlg::OnCancel
  3116. /*******************************************************************************
  3117. *
  3118. * OnListInitError - CEditWinStationDlg member function: command
  3119. *
  3120. * Handle the list initialization error condition.
  3121. *
  3122. * ENTRY:
  3123. * wParam (input)
  3124. * (not used)
  3125. * wLparam (input)
  3126. * contains the DWORD error code from the list initialization attempt
  3127. * EXIT:
  3128. * (LRESULT) always returns 0 to indicate error handling complete.
  3129. *
  3130. ******************************************************************************/
  3131. LRESULT
  3132. CEditWinStationDlg::OnListInitError( WPARAM wParam, LPARAM lParam )
  3133. {
  3134. PDCONFIG3 PdConfig;
  3135. GetSelectedPdConfig(&PdConfig);
  3136. HandleListInitError(&PdConfig, (DWORD)lParam);
  3137. return(0);
  3138. } // end CEditWinStationDlg::OnListInitError
  3139. /*******************************************************************************
  3140. *
  3141. * OnSetFieldsError - CEditWinStationDlg member function: command
  3142. *
  3143. * Handle the Protocol Configuration field set error condition.
  3144. *
  3145. * ENTRY:
  3146. * wParam (input)
  3147. * Contains the control ID that was in error during field setting.
  3148. * wLparam (input)
  3149. * (not used)
  3150. * EXIT:
  3151. * (LRESULT) always returns 0 to indicate error handling complete.
  3152. *
  3153. ******************************************************************************/
  3154. LRESULT
  3155. CEditWinStationDlg::OnSetFieldsError( WPARAM wParam, LPARAM lParam )
  3156. {
  3157. PDCONFIG3 PdConfig;
  3158. GetSelectedPdConfig(&PdConfig);
  3159. HandleSetFieldsError(&PdConfig, wParam);
  3160. return(0);
  3161. } // end CEditWinStationDlg::OnSetFieldsError
  3162. ////////////////////////////////////////////////////////////////////////////////
  3163. #define ERROR_PDINIT \
  3164. { \
  3165. bError = TRUE; \
  3166. goto cleanup; \
  3167. }
  3168. BOOL CEditWinStationDlg::AddNetworkDeviceNameToList(PPDCONFIG3 pPdConfig, CComboBox * pLanAdapter)
  3169. {
  3170. TCHAR szDevice[DEVICENAME_LENGTH];
  3171. int length = 0, index = 0,Entry = 0;
  3172. BOOL bError = FALSE;
  3173. //Interface pointer declarations
  3174. TCHAR szProtocol[256];
  3175. INetCfg * pnetCfg = NULL;
  3176. INetCfgClass * pNetCfgClass = NULL;
  3177. INetCfgClass * pNetCfgClassAdapter = NULL;
  3178. INetCfgComponent * pNetCfgComponent = NULL;
  3179. INetCfgComponent * pNetCfgComponentprot = NULL;
  3180. INetCfgComponent * pOwner = NULL;
  3181. IEnumNetCfgComponent * pEnumComponent = NULL;
  3182. INetCfgComponentBindings * pBinding = NULL;
  3183. LPWSTR pDisplayName = NULL;
  3184. DWORD dwCharacteristics;
  3185. ULONG count = 0;
  3186. HRESULT hResult = S_OK;
  3187. /*
  3188. * Check for NetBIOS (PD_LANA) mapping or other mapping.
  3189. */
  3190. if ( !(pPdConfig->Data.PdFlag & PD_LANA) )
  3191. {
  3192. //The First entry will be "All Lan Adapters"
  3193. length = LoadString( AfxGetInstanceHandle( ),
  3194. IDS_ALL_LAN_ADAPTERS, szDevice, DEVICENAME_LENGTH );
  3195. ASSERT(length);
  3196. index = pLanAdapter->AddString(szDevice);
  3197. if ( (index != CB_ERR) && (index != CB_ERRSPACE) )
  3198. {
  3199. pLanAdapter->SetItemData( index, Entry);
  3200. Entry++;
  3201. }
  3202. else
  3203. ERROR_PDINIT;
  3204. //include other possibilities
  3205. if(0 == lstrcmpi(pPdConfig->Data.PdName,L"tcp"))
  3206. lstrcpy(szProtocol,NETCFG_TRANS_CID_MS_TCPIP);
  3207. else
  3208. if(0 == lstrcmpi(pPdConfig->Data.PdName,L"netbios"))
  3209. lstrcpy(szProtocol,NETCFG_SERVICE_CID_MS_NETBIOS);
  3210. else
  3211. if(0 == lstrcmpi(pPdConfig->Data.PdName,L"ipx"))
  3212. lstrcpy(szProtocol,NETCFG_TRANS_CID_MS_NWIPX);
  3213. else
  3214. if(0 == lstrcmpi(pPdConfig->Data.PdName,L"spx"))
  3215. lstrcpy(szProtocol,NETCFG_TRANS_CID_MS_NWSPX);
  3216. else
  3217. return E_INVALIDARG;
  3218. if(S_OK != CoCreateInstance(CLSID_CNetCfg,NULL,CLSCTX_SERVER,IID_INetCfg,(LPVOID *)&pnetCfg))
  3219. ERROR_PDINIT;
  3220. if(pnetCfg)
  3221. {
  3222. hResult = pnetCfg->Initialize(NULL);
  3223. if(FAILED(hResult))
  3224. ERROR_PDINIT;
  3225. hResult = pnetCfg->QueryNetCfgClass(&GUID_DEVCLASS_NETTRANS ,IID_INetCfgClass,(void **)&pNetCfgClass);
  3226. if(FAILED(hResult))
  3227. ERROR_PDINIT;
  3228. hResult = pnetCfg->QueryNetCfgClass(&GUID_DEVCLASS_NET ,IID_INetCfgClass,(void **)&pNetCfgClassAdapter);
  3229. if(FAILED(hResult))
  3230. ERROR_PDINIT;
  3231. hResult = pNetCfgClass->FindComponent(szProtocol,&pNetCfgComponentprot);
  3232. if(FAILED(hResult))
  3233. ERROR_PDINIT;
  3234. hResult = pNetCfgComponentprot->QueryInterface(IID_INetCfgComponentBindings,(void **)&pBinding);
  3235. if(FAILED(hResult))
  3236. ERROR_PDINIT;
  3237. hResult = pNetCfgClassAdapter->EnumComponents(&pEnumComponent);
  3238. RELEASEPTR(pNetCfgClassAdapter);
  3239. if(FAILED(hResult))
  3240. ERROR_PDINIT;
  3241. hResult = S_OK;
  3242. while(TRUE)
  3243. {
  3244. hResult = pEnumComponent->Next(1,&pNetCfgComponent,&count);
  3245. if(count == 0 || NULL == pNetCfgComponent)
  3246. break;
  3247. hResult = pNetCfgComponent->GetCharacteristics(&dwCharacteristics);
  3248. if(FAILED(hResult))
  3249. {
  3250. RELEASEPTR(pNetCfgComponent);
  3251. continue;
  3252. }
  3253. if(dwCharacteristics & NCF_PHYSICAL)
  3254. {
  3255. if(S_OK == pBinding->IsBoundTo(pNetCfgComponent))
  3256. {
  3257. hResult = pNetCfgComponent->GetDisplayName(&pDisplayName);
  3258. if(FAILED(hResult))
  3259. ERROR_PDINIT;
  3260. index = pLanAdapter->AddString(pDisplayName);
  3261. CoTaskMemFree(pDisplayName);
  3262. if ( (index != CB_ERR) && (index != CB_ERRSPACE) )
  3263. {
  3264. pLanAdapter->SetItemData( index, Entry);
  3265. Entry++;
  3266. }
  3267. else
  3268. ERROR_PDINIT;
  3269. }
  3270. }
  3271. RELEASEPTR(pNetCfgComponent);
  3272. }
  3273. }
  3274. cleanup:
  3275. if(pnetCfg)
  3276. pnetCfg->Uninitialize();
  3277. RELEASEPTR(pBinding);
  3278. RELEASEPTR(pEnumComponent);
  3279. RELEASEPTR(pNetCfgComponentprot);
  3280. RELEASEPTR(pNetCfgComponent);
  3281. RELEASEPTR(pNetCfgClass);
  3282. RELEASEPTR(pnetCfg);
  3283. if(bError)
  3284. {
  3285. SetLastError(IDP_ERROR_PDINIT);
  3286. return(FALSE);
  3287. }
  3288. else
  3289. return TRUE;
  3290. }
  3291. else
  3292. {
  3293. /*
  3294. * NetBIOS LANA #: see which LanaMap entry corresponds to the specified
  3295. * Lan Adapter.
  3296. */
  3297. //Just use the functionality in Utildll. This seems to remain same on NT5.0 also
  3298. PPDPARAMS pPdParams, pBuffer;
  3299. DEVICENAME szDevice;
  3300. ULONG i, Entries;
  3301. BOOL bResult = 0;
  3302. int index;
  3303. /*
  3304. * Perform the device enumeration.
  3305. */
  3306. if ( (pBuffer = WinEnumerateDevices(
  3307. this->GetSafeHwnd(),
  3308. pPdConfig,
  3309. &Entries,
  3310. g_Install ? TRUE : FALSE )) == NULL )
  3311. {
  3312. // Don't report error here - let OnOK handle empty lan adapter selection
  3313. // SetLastError(IDP_ERROR_NETWORKDEVICEINIT);
  3314. // return(FALSE);
  3315. Entries = 0;
  3316. }
  3317. /*
  3318. * Loop to initialize the combo-box.
  3319. */
  3320. for ( i = 0, pPdParams = pBuffer; i < Entries; i++, pPdParams++ ) {
  3321. /*
  3322. * Fetch the Description for this device.
  3323. */
  3324. if(!RegGetNetworkDeviceName(NULL, pPdConfig, pPdParams,
  3325. szDevice, DEVICENAME_LENGTH))
  3326. {
  3327. SetLastError(IDP_ERROR_PDINIT);
  3328. LocalFree(pBuffer);
  3329. return(FALSE);
  3330. }
  3331. /*
  3332. * If the device description is not empty ('hidden' device), add the
  3333. * device description and the ordinal value to the Lan Adapter
  3334. * combo-box.
  3335. */
  3336. if ( *szDevice )
  3337. {
  3338. index = pLanAdapter->AddString(szDevice);
  3339. if ( (index != CB_ERR) && (index != CB_ERRSPACE) )
  3340. pLanAdapter->SetItemData( index, pPdParams->Network.LanAdapter );
  3341. else
  3342. {
  3343. SetLastError(IDP_ERROR_PDINIT);
  3344. LocalFree(pBuffer);
  3345. return(FALSE);
  3346. }
  3347. }
  3348. /*
  3349. * Free the enumeration buffer and return success.
  3350. */
  3351. if ( pBuffer )
  3352. LocalFree(pBuffer);
  3353. }
  3354. return TRUE;
  3355. }
  3356. }