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

1312 lines
25 KiB

  1. /*++
  2. Copyright (c) 1994-1998 Microsoft Corporation
  3. Module Name :
  4. mmmdlg.cpp
  5. Abstract:
  6. Multi-multi-multi dialog editor
  7. Author:
  8. Ronald Meijer (ronaldm)
  9. Project:
  10. Internet Services Manager
  11. Revision History:
  12. --*/
  13. //
  14. // Include Files
  15. //
  16. #include "stdafx.h"
  17. #include "common.h"
  18. #include "inetmgrapp.h"
  19. #include "mmmdlg.h"
  20. #include "inetprop.h"
  21. #include "w3sht.h"
  22. #ifdef _DEBUG
  23. #define new DEBUG_NEW
  24. #undef THIS_FILE
  25. static char THIS_FILE[] = __FILE__;
  26. #endif
  27. //
  28. // Registry key name for this dialog
  29. //
  30. const TCHAR g_szRegKeyIP[] = _T("MMMIpBindings");
  31. const TCHAR g_szRegKeySSL[] = _T("MMMSSLBindings");
  32. //
  33. // IP Bindings Listbox Column Definitions
  34. //
  35. static const ODL_COLUMN_DEF g_aIPColumns[] =
  36. {
  37. // ===============================================
  38. // Weight Label
  39. // ===============================================
  40. { 6, IDS_MMM_IP_ADDRESS, },
  41. { 3, IDS_MMM_TCP_PORT, },
  42. { 10, IDS_MMM_DOMAIN_NAME, },
  43. };
  44. //
  45. // SSL Bindings Listbox Column Definitions
  46. //
  47. static const ODL_COLUMN_DEF g_aSSLColumns[] =
  48. {
  49. // ===============================================
  50. // Weight Label
  51. // ===============================================
  52. { 2, IDS_MMM_IP_ADDRESS, },
  53. { 1, IDS_MMM_SSL_PORT, },
  54. };
  55. #define NUM_COLUMNS(cols) (sizeof(cols) / sizeof(cols[0]))
  56. IMPLEMENT_DYNAMIC(CMMMListBox, CRMCListBox);
  57. //
  58. // Bitmap indices
  59. //
  60. enum
  61. {
  62. BMPID_BINDING,
  63. //
  64. // Don't move this one
  65. //
  66. BMPID_TOTAL
  67. };
  68. const int CMMMListBox::nBitmaps = BMPID_TOTAL;
  69. CMMMListBox::CMMMListBox(
  70. IN LPCTSTR lpszRegKey,
  71. IN int cColumns,
  72. IN const ODL_COLUMN_DEF * pColumns
  73. )
  74. /*++
  75. Routine Description:
  76. Constructor
  77. Arguments:
  78. None
  79. Return Value:
  80. N/A
  81. --*/
  82. : CHeaderListBox(HLS_STRETCH, lpszRegKey),
  83. m_cColumns(cColumns),
  84. m_pColumns(pColumns)
  85. {
  86. VERIFY(m_strDefaultIP.LoadString(IDS_DEFAULT));
  87. VERIFY(m_strNoPort.LoadString(IDS_MMM_NA));
  88. }
  89. void
  90. CMMMListBox::DrawItemEx(
  91. IN CRMCListBoxDrawStruct & ds
  92. )
  93. /*++
  94. Routine Description:
  95. Draw item in the listbox
  96. Arguments:
  97. CRMCListBoxDrawStruct & ds : Draw item structure
  98. Return Value:
  99. None
  100. --*/
  101. {
  102. CString & strBinding = *(CString *)ds.m_ItemData;
  103. TRACEEOLID(strBinding);
  104. UINT nPort;
  105. LPCTSTR lp;
  106. CString strHostHeader;
  107. CString strPort;
  108. CString strIP;
  109. CIPAddress iaIpAddress;
  110. CInstanceProps::CrackBinding(
  111. strBinding,
  112. iaIpAddress,
  113. nPort,
  114. strHostHeader
  115. );
  116. //
  117. // Display Granted/Denied with appropriate bitmap
  118. //
  119. DrawBitmap(ds, 0, BMPID_BINDING);
  120. if (iaIpAddress.IsZeroValue())
  121. {
  122. lp = m_strDefaultIP;
  123. }
  124. else
  125. {
  126. lp = iaIpAddress.QueryIPAddress(strIP);
  127. }
  128. ColumnText(ds, 0, TRUE, lp);
  129. if (nPort > 0)
  130. {
  131. strPort.Format(_T("%u"), nPort);
  132. lp = strPort;
  133. }
  134. else
  135. {
  136. lp = m_strNoPort;
  137. }
  138. ColumnText(ds, 1, FALSE, lp);
  139. ColumnText(ds, 2, FALSE, strHostHeader);
  140. }
  141. /* virtual */
  142. BOOL
  143. CMMMListBox::Initialize()
  144. /*++
  145. Routine Description:
  146. Initialize the listbox. Insert the columns as requested, and lay
  147. them out appropriately
  148. Arguments:
  149. None
  150. Return Value:
  151. TRUE for succesful initialisation, FALSE otherwise
  152. --*/
  153. {
  154. if (!CHeaderListBox::Initialize())
  155. {
  156. return FALSE;
  157. }
  158. //
  159. // Build all columns
  160. //
  161. HINSTANCE hInst = AfxGetResourceHandle();
  162. for (int nCol = 0; nCol < m_cColumns; ++nCol)
  163. {
  164. InsertColumn(nCol, m_pColumns[nCol].nWeight, m_pColumns[nCol].nLabelID, hInst);
  165. }
  166. //
  167. // Try to set the widths from the stored registry value,
  168. // otherwise distribute according to column weights specified
  169. //
  170. // if (!SetWidthsFromReg())
  171. // {
  172. DistributeColumns();
  173. // }
  174. return TRUE;
  175. }
  176. void AFXAPI
  177. DDXV_UINT(
  178. IN CDataExchange * pDX,
  179. IN UINT nID,
  180. IN OUT UINT & uValue,
  181. IN UINT uMin,
  182. IN UINT uMax,
  183. IN UINT nEmptyErrorMsg OPTIONAL
  184. )
  185. /*++
  186. Routine Description:
  187. DDX/DDV Function that uses a space to denote a 0 value
  188. Arguments:
  189. CDataExchange * pDX : Data exchange object
  190. UINT nID : Resource ID
  191. OUT UINT & uValue : Value
  192. UINT uMin : Minimum value
  193. UINT uMax : Maximum value
  194. UINT nEmptyErrorMsg : Error message ID for empty unit, or 0 if empty OK
  195. Return Value:
  196. None.
  197. --*/
  198. {
  199. ASSERT(uMin <= uMax);
  200. CWnd * pWnd = CWnd::FromHandle(pDX->PrepareEditCtrl(nID));
  201. ASSERT(pWnd != NULL);
  202. if (pDX->m_bSaveAndValidate)
  203. {
  204. if (pWnd->GetWindowTextLength() > 0)
  205. {
  206. // This Needs to come before DDX_Text which will try to put text big number into small number
  207. DDV_MinMaxBalloon(pDX, nID, uMin, uMax);
  208. DDX_TextBalloon(pDX, nID, uValue);
  209. }
  210. else
  211. {
  212. uValue = 0;
  213. if (nEmptyErrorMsg)
  214. {
  215. DDV_ShowBalloonAndFail(pDX, nEmptyErrorMsg);
  216. }
  217. }
  218. }
  219. else
  220. {
  221. if (uValue != 0)
  222. {
  223. DDX_TextBalloon(pDX, nID, uValue);
  224. }
  225. else
  226. {
  227. pWnd->SetWindowText(_T(""));
  228. }
  229. }
  230. }
  231. BOOL
  232. IsBindingUnique(
  233. IN CString & strBinding,
  234. IN CStringList & strlBindings,
  235. IN int iCurrent OPTIONAL
  236. )
  237. /*++
  238. Routine Description:
  239. Helper function to determine if a binding is unique.
  240. Arguments:
  241. CString & strBinding : Binding string
  242. CStringList & strlBindings : List of bindings
  243. int iCurrent : Index of "current" item.
  244. Not used for uniqueness checking.
  245. Return Value:
  246. TRUE if the binding is unique, FALSE otherwise.
  247. --*/
  248. {
  249. int iItem = 0;
  250. for(POSITION pos = strlBindings.GetHeadPosition(); pos != NULL; /**/ )
  251. {
  252. CString & str = strlBindings.GetNext(pos);
  253. if (iItem != iCurrent && &str != &strBinding && str == strBinding)
  254. {
  255. //
  256. // Not unique!
  257. //
  258. return FALSE;
  259. }
  260. ++iItem;
  261. }
  262. //
  263. // Unique
  264. //
  265. return TRUE;
  266. }
  267. //
  268. // Multi-multi-multi editing dialog
  269. //
  270. // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  271. CMMMEditDlg::CMMMEditDlg(
  272. IN CString & strServerName,
  273. IN CStringList & strlBindings,
  274. IN CStringList & strlOtherBindings,
  275. IN OUT CString & entry,
  276. IN BOOL fIPBinding,
  277. IN CWnd * pParent OPTIONAL
  278. )
  279. /*++
  280. Routine Description:
  281. Constructor
  282. Arguments:
  283. CString & strServerName : Server name
  284. CStringList & strlBindings : bindings
  285. CStringList & strlOtherBindings : "other" bindings list
  286. CString & entry : Entry being edited
  287. BOOL fIPBinding : TRUE for IP, FALSE for SSL
  288. CWnd * pParent : Optional parent window
  289. Return Value:
  290. N/A
  291. --*/
  292. : CDialog(CMMMEditDlg::IDD, pParent),
  293. m_strServerName(strServerName),
  294. m_strlBindings(strlBindings),
  295. m_strlOtherBindings(strlOtherBindings),
  296. m_entry(entry),
  297. m_fIPBinding(fIPBinding),
  298. m_nIpAddressSel(-1),
  299. m_nHelpContext(CMMMEditDlg::IDD + 0x20000)
  300. {
  301. #if 0 // Keep class wizard happy
  302. //{{AFX_DATA_INIT(CMMMEditDlg)
  303. m_nIpAddressSel = -1;
  304. //}}AFX_DATA_INIT
  305. #endif // 0
  306. CInstanceProps::CrackBinding(
  307. m_entry,
  308. m_iaIpAddress,
  309. m_nPort,
  310. m_strDomainName
  311. );
  312. }
  313. void
  314. CMMMEditDlg::DoDataExchange(
  315. IN CDataExchange * pDX
  316. )
  317. /*++
  318. Routine Description:
  319. Initialise/Store control data
  320. Arguments:
  321. CDataExchange * pDX - DDX/DDV control structure
  322. Return Value:
  323. None
  324. --*/
  325. {
  326. CDialog::DoDataExchange(pDX);
  327. //{{AFX_DATA_MAP(CMMMEditDlg)
  328. DDX_Text(pDX, IDC_EDIT_DOMAIN_NAME, m_strDomainName);
  329. DDV_MaxCharsBalloon(pDX, m_strDomainName, MAX_PATH);
  330. DDX_Control(pDX, IDC_COMBO_IP_ADDRESSES, m_combo_IpAddresses);
  331. DDX_Control(pDX, IDC_STATIC_PORT, m_static_Port);
  332. //}}AFX_DATA_MAP
  333. DDXV_UINT(pDX, IDC_EDIT_PORT, m_nPort, 1, 65535, IDS_NO_PORT);
  334. DDX_CBIndex(pDX, IDC_COMBO_IP_ADDRESSES, m_nIpAddressSel);
  335. if (pDX->m_bSaveAndValidate && !FetchIpAddressFromCombo(
  336. m_combo_IpAddresses, m_oblIpAddresses, m_iaIpAddress))
  337. {
  338. pDX->Fail();
  339. }
  340. // Currently IIS support in domain names only A-Z,a-z,0-9,.-
  341. if (pDX->m_bSaveAndValidate)
  342. {
  343. LPCTSTR p = m_strDomainName;
  344. while (p != NULL && *p != 0)
  345. {
  346. TCHAR c = towupper(*p);
  347. if ( (c >= _T('A') && c <= _T('Z'))
  348. || (c >= _T('0') && c <= _T('9'))
  349. || (c == _T('.') || c == _T('-'))
  350. )
  351. {
  352. p++;
  353. continue;
  354. }
  355. else
  356. {
  357. pDX->PrepareEditCtrl(IDC_EDIT_DOMAIN_NAME);
  358. DDV_ShowBalloonAndFail(pDX, IDS_WARNING_DOMAIN_NAME);
  359. }
  360. }
  361. // Check if the host header is valid
  362. if (!m_strDomainName.IsEmpty())
  363. {
  364. if (FAILED(IsValidHostHeader(m_strDomainName)))
  365. {
  366. pDX->PrepareEditCtrl(IDC_EDIT_DOMAIN_NAME);
  367. if (FAILED(IsAllNumHostHeader(m_strDomainName)))
  368. {
  369. DDV_ShowBalloonAndFail(pDX, IDS_ERR_DOMAIN_NAME_INVALID);
  370. }
  371. else
  372. {
  373. // it's all numeric, show error msg, saying that it is now
  374. // an invalid entry (in iis5,iis51) it used to be valid.
  375. DDV_ShowBalloonAndFail(pDX, IDS_ERR_DOMAIN_NAME_ALL_NUMERIC);
  376. }
  377. }
  378. }
  379. }
  380. }
  381. void
  382. CMMMEditDlg::OnHelp()
  383. {
  384. WinHelpDebug(m_nHelpContext);
  385. WinHelp(m_nHelpContext);
  386. }
  387. //
  388. // Message Map
  389. //
  390. BEGIN_MESSAGE_MAP(CMMMEditDlg, CDialog)
  391. //{{AFX_MSG_MAP(CMMMEditDlg)
  392. ON_COMMAND(ID_HELP, OnHelp)
  393. //}}AFX_MSG_MAP
  394. END_MESSAGE_MAP()
  395. //
  396. // Message Handlers
  397. //
  398. // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  399. BOOL
  400. CMMMEditDlg::OnInitDialog()
  401. /*++
  402. Routine Description:
  403. WM_INITDIALOG handler. Initialize the dialog.
  404. Arguments:
  405. None.
  406. Return Value:
  407. TRUE if focus is to be set automatically, FALSE if the focus
  408. is already set.
  409. --*/
  410. {
  411. CDialog::OnInitDialog();
  412. BeginWaitCursor();
  413. PopulateComboWithKnownIpAddresses(
  414. m_strServerName,
  415. m_combo_IpAddresses,
  416. m_iaIpAddress,
  417. m_oblIpAddresses,
  418. m_nIpAddressSel
  419. );
  420. EndWaitCursor();
  421. //
  422. // Configure dialog for either SSL or IP binding editing
  423. //
  424. CString str;
  425. VERIFY(str.LoadString(m_fIPBinding
  426. ? IDS_EDIT_MMM_TITLE
  427. : IDS_EDIT_SSL_MMM_TITLE));
  428. SetWindowText(str);
  429. VERIFY(str.LoadString(m_fIPBinding
  430. ? IDS_TCP_PORT
  431. : IDS_SSL_PORT));
  432. m_static_Port.SetWindowText(str);
  433. ActivateControl(*GetDlgItem(IDC_STATIC_HEADER_NAME), m_fIPBinding);
  434. ActivateControl(*GetDlgItem(IDC_EDIT_DOMAIN_NAME), m_fIPBinding);
  435. #if 0
  436. CHARFORMAT cf;
  437. ZeroMemory(&cf, sizeof(cf));
  438. cf.cbSize = sizeof(cf);
  439. cf.dwMask = CFM_FACE;
  440. cf.bPitchAndFamily = FIXED_PITCH | FF_DONTCARE;
  441. lstrcpyn((LPTSTR)cf.szFaceName, _T("Courier"), LF_FACESIZE);
  442. SendDlgItemMessage(IDC_EDIT_DOMAIN_NAME, EM_SETCHARFORMAT, SCF_ALL, (LPARAM)&cf);
  443. #endif
  444. DWORD event = (DWORD)SendDlgItemMessage(IDC_EDIT_DOMAIN_NAME, EM_GETEVENTMASK, 0, 0);
  445. event |= ENM_CHANGE;
  446. SendDlgItemMessage(IDC_EDIT_DOMAIN_NAME, EM_SETEVENTMASK, 0, (LPARAM)event);
  447. if (m_fIPBinding)
  448. {
  449. m_nHelpContext = (CMMMEditDlg::IDD + 0x20000);
  450. }
  451. else
  452. {
  453. m_nHelpContext = (CMMMEditDlg::IDD + 0x40000);
  454. }
  455. return TRUE;
  456. }
  457. void
  458. CMMMEditDlg::OnOK()
  459. /*++
  460. Routine Description:
  461. OK button handler. Verify values are acceptable, and change
  462. Arguments:
  463. None
  464. Return Value:
  465. None
  466. --*/
  467. {
  468. if (!UpdateData(TRUE))
  469. {
  470. return;
  471. }
  472. if (m_nPort == 0)
  473. {
  474. EditShowBalloon(GetDlgItem(IDC_EDIT_PORT)->m_hWnd, IDS_NO_PORT);
  475. return;
  476. }
  477. CString strOldBinding(m_entry);
  478. CInstanceProps::BuildBinding(m_entry, m_iaIpAddress, m_nPort, m_strDomainName);
  479. //
  480. // Ensure the ip/address doesn't exist in the "other" binding list
  481. //
  482. if (CInstanceProps::IsPortInUse(m_strlOtherBindings, m_iaIpAddress, m_nPort))
  483. {
  484. //
  485. // Restore the old binding
  486. //
  487. m_entry = strOldBinding;
  488. EditShowBalloon(GetDlgItem(IDC_EDIT_PORT)->m_hWnd, m_fIPBinding
  489. ? IDS_ERR_PORT_IN_USE_SSL : IDS_ERR_PORT_IN_USE_TCP);
  490. return;
  491. }
  492. if (!IsBindingUnique(m_entry, m_strlBindings))
  493. {
  494. //
  495. // Restore the old binding
  496. //
  497. m_entry = strOldBinding;
  498. EditShowBalloon(GetDlgItem(IDC_EDIT_PORT)->m_hWnd, IDS_ERR_BINDING);
  499. return;
  500. }
  501. CDialog::OnOK();
  502. }
  503. //
  504. // Multi-multi-multi list dialog
  505. //
  506. // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  507. CMMMDlg::CMMMDlg(
  508. IN LPCTSTR lpServerName,
  509. IN DWORD dwInstance,
  510. IN CComAuthInfo * pAuthInfo,
  511. IN LPCTSTR lpMetaPath,
  512. IN OUT CStringList & strlBindings,
  513. IN OUT CStringList & strlSecureBindings,
  514. IN CWnd * pParent OPTIONAL
  515. )
  516. /*++
  517. Routine Description:
  518. Constructor
  519. Arguments:
  520. CStringList & strlBindings : Service bindings
  521. CStringList & strlSecureBindings : SSL port bindings
  522. CWnd * pParent : Optional parent window
  523. Return Value:
  524. N/A
  525. --*/
  526. : CDialog(CMMMDlg::IDD, pParent),
  527. m_ListBoxRes(
  528. IDB_BINDINGS,
  529. CMMMListBox::nBitmaps
  530. ),
  531. m_list_Bindings(g_szRegKeyIP, NUM_COLUMNS(g_aIPColumns), g_aIPColumns),
  532. m_list_SSLBindings(g_szRegKeySSL, NUM_COLUMNS(g_aSSLColumns), g_aSSLColumns),
  533. m_strlBindings(),
  534. m_strlSecureBindings(),
  535. m_strServerName(lpServerName),
  536. m_strMetaPath(lpMetaPath),
  537. m_pAuthInfo(pAuthInfo),
  538. m_fDirty(FALSE),
  539. m_nHelpContext(CMMMDlg::IDD + 0x20000)
  540. {
  541. //{{AFX_DATA_INIT(CMMMDlg)
  542. //}}AFX_DATA_INIT
  543. m_fCertInstalled = ::IsCertInstalledOnServer(m_pAuthInfo, lpMetaPath),
  544. m_strlBindings.AddTail(&strlBindings);
  545. m_strlSecureBindings.AddTail(&strlSecureBindings);
  546. m_list_Bindings.AttachResources(&m_ListBoxRes);
  547. m_list_SSLBindings.AttachResources(&m_ListBoxRes);
  548. }
  549. void
  550. CMMMDlg::DoDataExchange(
  551. IN CDataExchange * pDX
  552. )
  553. /*++
  554. Routine Description:
  555. Initialise/Store control data
  556. Arguments:
  557. CDataExchange * pDX - DDX/DDV control structure
  558. Return Value:
  559. None
  560. --*/
  561. {
  562. CDialog::DoDataExchange(pDX);
  563. //{{AFX_DATA_MAP(CMMMDlg)
  564. DDX_Control(pDX, IDC_BUTTON_ADD, m_button_Add);
  565. DDX_Control(pDX, IDC_BUTTON_REMOVE, m_button_Remove);
  566. DDX_Control(pDX, IDC_BUTTON_EDIT, m_button_Edit);
  567. DDX_Control(pDX, IDC_BUTTON_ADD_SSL, m_button_AddSSL);
  568. DDX_Control(pDX, IDC_BUTTON_REMOVE_SSL, m_button_RemoveSSL);
  569. DDX_Control(pDX, IDC_BUTTON_EDIT_SSL, m_button_EditSSL);
  570. DDX_Control(pDX, IDOK, m_button_OK);
  571. //}}AFX_DATA_MAP
  572. DDX_Control(pDX, IDC_LIST_MMM, m_list_Bindings);
  573. DDX_Control(pDX, IDC_LIST_SSL_MMM, m_list_SSLBindings);
  574. }
  575. BOOL
  576. CMMMDlg::OnItemChanged()
  577. /*++
  578. Routine Description:
  579. Mark that the dialog as dirty
  580. Arguments:
  581. None
  582. Return Value:
  583. TRUE if the remove button is enabled
  584. --*/
  585. {
  586. m_fDirty = TRUE;
  587. return SetControlStates();
  588. }
  589. BOOL
  590. CMMMDlg::SetControlStates()
  591. /*++
  592. Routine Description:
  593. Set the enabled state of the controls depending on the current
  594. values in the dialog
  595. Arguments:
  596. None
  597. Return Value:
  598. TRUE if the remove button is enabled
  599. --*/
  600. {
  601. BOOL fSel = m_list_Bindings.GetSelCount() > 0;
  602. m_button_Remove.EnableWindow(fSel);
  603. m_button_Edit.EnableWindow(m_list_Bindings.GetSelCount() == 1);
  604. m_button_RemoveSSL.EnableWindow(m_list_SSLBindings.GetSelCount() > 0);
  605. m_button_EditSSL.EnableWindow(m_list_SSLBindings.GetSelCount() == 1);
  606. m_button_OK.EnableWindow(m_fDirty && m_list_Bindings.GetCount() > 0);
  607. return fSel;
  608. }
  609. void
  610. CMMMDlg::AddBindings(
  611. IN CMMMListBox & list,
  612. IN CStringList & strlBindings
  613. )
  614. /*++
  615. Routine Description:
  616. Add bindings information to the specified listbox
  617. Arguments:
  618. CMMMListBox & list : MMM Listbox (SSL or IP)
  619. CStringList & strlBindings : SSL or IP bindings
  620. Return Value:
  621. None
  622. --*/
  623. {
  624. for (POSITION pos = strlBindings.GetHeadPosition(); pos != NULL; /**/)
  625. {
  626. CString & strBinding = strlBindings.GetNext(pos);
  627. list.AddItem(strBinding);
  628. }
  629. }
  630. void
  631. CMMMDlg::OnHelp()
  632. {
  633. WinHelpDebug(m_nHelpContext);
  634. WinHelp(m_nHelpContext);
  635. }
  636. //
  637. // Message Map
  638. //
  639. BEGIN_MESSAGE_MAP(CMMMDlg, CDialog)
  640. //{{AFX_MSG_MAP(CMMMDlg)
  641. ON_BN_CLICKED(IDC_BUTTON_ADD, OnButtonAdd)
  642. ON_BN_CLICKED(IDC_BUTTON_EDIT, OnButtonEdit)
  643. ON_BN_CLICKED(IDC_BUTTON_REMOVE, OnButtonRemove)
  644. ON_BN_CLICKED(IDC_BUTTON_ADD_SSL, OnButtonAddSsl)
  645. ON_BN_CLICKED(IDC_BUTTON_EDIT_SSL, OnButtonEditSsl)
  646. ON_BN_CLICKED(IDC_BUTTON_REMOVE_SSL, OnButtonRemoveSsl)
  647. ON_LBN_DBLCLK(IDC_LIST_MMM, OnDblclkListMmm)
  648. ON_LBN_DBLCLK(IDC_LIST_SSL_MMM, OnDblclkListSslMmm)
  649. ON_LBN_SELCHANGE(IDC_LIST_MMM, OnSelchangeListMmm)
  650. ON_LBN_SELCHANGE(IDC_LIST_SSL_MMM, OnSelchangeListSslMmm)
  651. ON_COMMAND(ID_HELP, OnHelp)
  652. //}}AFX_MSG_MAP
  653. END_MESSAGE_MAP()
  654. //
  655. // Message Handlers
  656. //
  657. // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  658. void
  659. CMMMDlg::OnButtonAdd()
  660. /*++
  661. Routine Description:
  662. Add button handler
  663. Arguments:
  664. None
  665. Return Value:
  666. None
  667. --*/
  668. {
  669. //
  670. // Add entry
  671. //
  672. CString strEntry;
  673. CMMMEditDlg dlg(
  674. m_strServerName,
  675. m_strlBindings,
  676. m_strlSecureBindings,
  677. strEntry,
  678. TRUE, /* IP binding */
  679. this
  680. );
  681. if (dlg.DoModal() == IDOK)
  682. {
  683. POSITION pos = m_strlBindings.AddTail(strEntry);
  684. int nSel = m_list_Bindings.AddItem(m_strlBindings.GetAt(pos));
  685. m_list_Bindings.SetCurSel(nSel);
  686. OnItemChanged();
  687. }
  688. }
  689. void
  690. CMMMDlg::OnButtonEdit()
  691. /*++
  692. Routine Description:
  693. Edit button handler
  694. Arguments:
  695. None
  696. Return Value:
  697. None
  698. --*/
  699. {
  700. //
  701. // Edit entry
  702. //
  703. int nCurSel = m_list_Bindings.GetCurSel();
  704. if (nCurSel != LB_ERR)
  705. {
  706. CString & strEntry = m_list_Bindings.GetItem(nCurSel);
  707. CMMMEditDlg dlg(
  708. m_strServerName,
  709. m_strlBindings,
  710. m_strlSecureBindings,
  711. strEntry,
  712. TRUE, /* IP binding */
  713. this
  714. );
  715. if (dlg.DoModal() == IDOK)
  716. {
  717. m_list_Bindings.InvalidateSelection(nCurSel);
  718. OnItemChanged();
  719. }
  720. }
  721. }
  722. void
  723. CMMMDlg::OnButtonRemove()
  724. /*++
  725. Routine Description:
  726. Remove button handler
  727. Arguments:
  728. None
  729. Return Value:
  730. None
  731. --*/
  732. {
  733. int nCurSel = m_list_Bindings.GetCurSel();
  734. int nSel = 0;
  735. int cChanges = 0;
  736. while (nSel < m_list_Bindings.GetCount())
  737. {
  738. //
  739. // Remove Selected entry
  740. //
  741. if (m_list_Bindings.GetSel(nSel))
  742. {
  743. m_strlBindings.RemoveAt(m_strlBindings.FindIndex(nSel));
  744. m_list_Bindings.DeleteString(nSel);
  745. ++cChanges;
  746. continue;
  747. }
  748. ++nSel;
  749. }
  750. if (cChanges)
  751. {
  752. m_list_Bindings.SetCurSel(nCurSel);
  753. if (!OnItemChanged())
  754. {
  755. m_button_Add.SetFocus();
  756. }
  757. }
  758. /*
  759. //
  760. // Remove Selected entry
  761. //
  762. int nCurSel = m_list_Bindings.GetCurSel();
  763. if (nCurSel != LB_ERR)
  764. {
  765. m_strlBindings.RemoveAt(m_strlBindings.FindIndex(nCurSel));
  766. m_list_Bindings.DeleteString(nCurSel);
  767. if (nCurSel >= m_list_Bindings.GetCount())
  768. {
  769. --nCurSel;
  770. }
  771. m_list_Bindings.SetCurSel(nCurSel);
  772. if (!OnItemChanged())
  773. {
  774. m_button_Add.SetFocus();
  775. }
  776. }
  777. */
  778. }
  779. void
  780. CMMMDlg::OnDblclkListMmm()
  781. /*++
  782. Routine Description:
  783. Double click notification handler
  784. Arguments:
  785. None
  786. Return Value:
  787. None
  788. --*/
  789. {
  790. OnButtonEdit();
  791. }
  792. void
  793. CMMMDlg::OnSelchangeListMmm()
  794. /*++
  795. Routine Description:
  796. selection change notification handler
  797. Arguments:
  798. None
  799. Return Value:
  800. None
  801. --*/
  802. {
  803. SetControlStates();
  804. }
  805. void
  806. CMMMDlg::OnButtonAddSsl()
  807. /*++
  808. Routine Description:
  809. 'Add SSL' button handler
  810. Arguments:
  811. None
  812. Return Value:
  813. None
  814. --*/
  815. {
  816. //
  817. // Add entry
  818. //
  819. CString strEntry;
  820. CMMMEditDlg dlg(
  821. m_strServerName,
  822. m_strlSecureBindings,
  823. m_strlBindings,
  824. strEntry,
  825. FALSE, /* SSL binding */
  826. this
  827. );
  828. if (dlg.DoModal() == IDOK)
  829. {
  830. POSITION pos = m_strlSecureBindings.AddTail(strEntry);
  831. int nSel = m_list_SSLBindings.AddItem(m_strlSecureBindings.GetAt(pos));
  832. m_list_SSLBindings.SetCurSel(nSel);
  833. OnItemChanged();
  834. }
  835. }
  836. void
  837. CMMMDlg::OnButtonEditSsl()
  838. /*++
  839. Routine Description:
  840. 'Edit SSL' button handler
  841. Arguments:
  842. None
  843. Return Value:
  844. None
  845. --*/
  846. {
  847. //
  848. // Edit entry
  849. //
  850. int nCurSel = m_list_SSLBindings.GetCurSel();
  851. if (nCurSel != LB_ERR)
  852. {
  853. CString & strEntry = m_list_SSLBindings.GetItem(nCurSel);
  854. CMMMEditDlg dlg(
  855. m_strServerName,
  856. m_strlSecureBindings,
  857. m_strlBindings,
  858. strEntry,
  859. FALSE, /* SSL binding */
  860. this
  861. );
  862. if (dlg.DoModal() == IDOK)
  863. {
  864. m_list_SSLBindings.InvalidateSelection(nCurSel);
  865. OnItemChanged();
  866. }
  867. }
  868. }
  869. void
  870. CMMMDlg::OnButtonRemoveSsl()
  871. /*++
  872. Routine Description:
  873. 'Remove SSL' button handler
  874. Arguments:
  875. None
  876. Return Value:
  877. None
  878. --*/
  879. {
  880. int nCurSel = m_list_SSLBindings.GetCurSel();
  881. int nSel = 0;
  882. int cChanges = 0;
  883. while (nSel < m_list_SSLBindings.GetCount())
  884. {
  885. //
  886. // Remove Selected entry
  887. //
  888. if (m_list_SSLBindings.GetSel(nSel))
  889. {
  890. m_strlSecureBindings.RemoveAt(m_strlSecureBindings.FindIndex(nSel));
  891. m_list_SSLBindings.DeleteString(nSel);
  892. ++cChanges;
  893. continue;
  894. }
  895. ++nSel;
  896. }
  897. if (cChanges)
  898. {
  899. m_list_SSLBindings.SetCurSel(nCurSel);
  900. OnItemChanged();
  901. if (m_list_SSLBindings.GetSelCount() == 0)
  902. {
  903. //
  904. // Remove will be disabled
  905. //
  906. m_button_AddSSL.SetFocus();
  907. }
  908. }
  909. /*
  910. //
  911. // Remove Selected entry
  912. //
  913. int nCurSel = m_list_SSLBindings.GetCurSel();
  914. if (nCurSel != LB_ERR)
  915. {
  916. m_strlSecureBindings.RemoveAt(m_strlSecureBindings.FindIndex(nCurSel));
  917. m_list_SSLBindings.DeleteString(nCurSel);
  918. if (nCurSel >= m_list_SSLBindings.GetCount())
  919. {
  920. --nCurSel;
  921. }
  922. m_list_SSLBindings.SetCurSel(nCurSel);
  923. OnItemChanged();
  924. if (m_list_SSLBindings.GetCurSel() == LB_ERR)
  925. {
  926. //
  927. // Remove will be disabled
  928. //
  929. m_button_AddSSL.SetFocus();
  930. }
  931. }
  932. */
  933. }
  934. void
  935. CMMMDlg::OnDblclkListSslMmm()
  936. /*++
  937. Routine Description:
  938. SSL List 'double click' handler
  939. Arguments:
  940. None
  941. Return Value:
  942. None
  943. --*/
  944. {
  945. OnButtonEditSsl();
  946. }
  947. void
  948. CMMMDlg::OnSelchangeListSslMmm()
  949. /*++
  950. Routine Description:
  951. SSL List 'selection change' handler
  952. Arguments:
  953. None
  954. Return Value:
  955. None
  956. --*/
  957. {
  958. SetControlStates();
  959. }
  960. BOOL
  961. CMMMDlg::OnInitDialog()
  962. /*++
  963. Routine Description:
  964. WM_INITDIALOG handler. Initialize the dialog.
  965. Arguments:
  966. None.
  967. Return Value:
  968. TRUE if focus is to be set automatically, FALSE if the focus
  969. is already set.
  970. --*/
  971. {
  972. CDialog::OnInitDialog();
  973. m_list_Bindings.Initialize();
  974. m_list_SSLBindings.Initialize();
  975. AddBindings(m_list_Bindings, m_strlBindings);
  976. AddBindings(m_list_SSLBindings, m_strlSecureBindings);
  977. //
  978. // No certificates, no SSL
  979. //
  980. GetDlgItem(IDC_GROUP_SSL)->EnableWindow(m_fCertInstalled);
  981. m_list_SSLBindings.EnableWindow(m_fCertInstalled);
  982. m_button_AddSSL.EnableWindow(m_fCertInstalled);
  983. m_button_RemoveSSL.EnableWindow(m_fCertInstalled);
  984. m_button_EditSSL.EnableWindow(m_fCertInstalled);
  985. SetControlStates();
  986. return TRUE;
  987. }