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.

172 lines
4.4 KiB

  1. #include "stdafx.h"
  2. #include "WizardSheet.h"
  3. #include "WaitDlg.h"
  4. CSelectSite::CSelectSite( CWizardSheet* pTheSheet ) :
  5. m_pTheSheet( pTheSheet )
  6. {
  7. m_strTitle.LoadString( IDS_TITLE_SELECTSITE );
  8. m_strSubTitle.LoadString( IDS_SUBTITLE_SELECTSITE );
  9. SetHeaderTitle( m_strTitle );
  10. SetHeaderSubTitle( m_strSubTitle );
  11. }
  12. BOOL CSelectSite::OnSetActive()
  13. {
  14. bool bHaveSel = ListBox_GetCurSel( GetDlgItem( IDC_SITELIST ) ) != LB_ERR;
  15. SetWizardButtons( PSWIZB_BACK | ( bHaveSel ? PSWIZB_NEXT : 0 ) );
  16. return TRUE;
  17. }
  18. void CSelectSite::AddSite( const IMSAdminBasePtr& spABO, LPCWSTR wszPath, LPCWSTR wszSiteID )
  19. {
  20. WCHAR wszBuffer[ METADATA_MAX_NAME_LEN ];
  21. METADATA_HANDLE hWeb = NULL;
  22. METADATA_RECORD md = { 0 };
  23. DWORD dwNotUsed = 0;
  24. md.dwMDIdentifier = MD_KEY_TYPE;
  25. md.dwMDDataType = STRING_METADATA;
  26. md.dwMDUserType = ALL_METADATA;
  27. md.dwMDDataLen = METADATA_MAX_NAME_LEN * sizeof( WCHAR );
  28. md.pbMDData = reinterpret_cast<BYTE*>( wszBuffer );
  29. HRESULT hr = spABO->OpenKey( METADATA_MASTER_ROOT_HANDLE,
  30. wszPath,
  31. METADATA_PERMISSION_READ,
  32. 3000,
  33. &hWeb );
  34. if ( SUCCEEDED( hr ) )
  35. {
  36. hr = spABO->GetData( hWeb, NULL, &md, &dwNotUsed );
  37. }
  38. if ( SUCCEEDED( hr ) )
  39. {
  40. hr = ::_wcsicmp( wszBuffer, L"IISWebServer" ) == 0 ? S_OK : E_FAIL;
  41. }
  42. if ( SUCCEEDED( hr ) )
  43. {
  44. md.dwMDIdentifier = MD_SERVER_COMMENT;
  45. md.dwMDDataLen = METADATA_MAX_NAME_LEN * sizeof( WCHAR );
  46. hr = spABO->GetData( hWeb, NULL, &md, &dwNotUsed );
  47. }
  48. if ( SUCCEEDED( hr ) )
  49. {
  50. int iItem = ListBox_AddString( GetDlgItem( IDC_SITELIST ), wszBuffer );
  51. if ( iItem != LB_ERR )
  52. {
  53. DWORD dwSiteID = 0;
  54. VERIFY( ::swscanf( wszSiteID, L"%u", &dwSiteID ) );
  55. ListBox_SetItemData( GetDlgItem( IDC_SITELIST ), iItem, dwSiteID );
  56. }
  57. }
  58. }
  59. void CSelectSite::LoadWebSites()
  60. {
  61. IMSAdminBasePtr spABO;
  62. WCHAR wszBuffer[ METADATA_MAX_NAME_LEN ];
  63. WCHAR wszWebPath[ 2 * METADATA_MAX_NAME_LEN ];
  64. HRESULT hr = spABO.CreateInstance( CLSID_MSAdminBase );
  65. if ( SUCCEEDED( hr ) )
  66. {
  67. for ( int i = 0; SUCCEEDED( hr ); ++i )
  68. {
  69. hr = spABO->EnumKeys( METADATA_MASTER_ROOT_HANDLE, L"LM/W3SVC", wszBuffer, i );
  70. if ( SUCCEEDED( hr ) )
  71. {
  72. ::swprintf( wszWebPath, L"LM/W3SVC/%s", wszBuffer );
  73. AddSite( spABO, wszWebPath, wszBuffer );
  74. }
  75. }
  76. }
  77. }
  78. LRESULT CSelectSite::OnInitDialog( UINT, WPARAM, LPARAM, BOOL& )
  79. {
  80. CWaitDlg dlg( m_hWnd, IDS_WAIT_LOADSITES );
  81. LoadWebSites();
  82. return 0;
  83. }
  84. LRESULT CSelectSite::OnSelChange( WORD /*wNotifyCode*/, WORD /*wID*/, HWND hWndCtl, BOOL& /*bHandled*/ )
  85. {
  86. if ( ListBox_GetCurSel( hWndCtl ) != LB_ERR )
  87. {
  88. SetWizardButtons( PSWIZB_BACK | PSWIZB_NEXT );
  89. ::EnableWindow( GetDlgItem( IDC_ACLS ), TRUE );
  90. ::EnableWindow( GetDlgItem( IDC_CONTENT ), TRUE );
  91. ::EnableWindow( GetDlgItem( IDC_CERTIFICATE ), TRUE );
  92. }
  93. return 0;
  94. }
  95. int CSelectSite::OnWizardNext()
  96. {
  97. CListBox LB( GetDlgItem( IDC_SITELIST ) );
  98. LB.GetText( LB.GetCurSel(), /*r*/m_strSiteName );
  99. m_dwSiteID = LB.GetItemData( LB.GetCurSel() );
  100. m_bExportContent = Button_GetCheck( GetDlgItem( IDC_CONTENT ) ) != FALSE;
  101. m_bExportCert = Button_GetCheck( GetDlgItem( IDC_CERTIFICATE ) ) != FALSE;
  102. m_bExportACLs = Button_GetCheck( GetDlgItem( IDC_ACLS ) ) != FALSE;
  103. return 0;
  104. }
  105. LRESULT CSelectSite::OnAclChange( WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/ )
  106. {
  107. if ( IDC_CONTENT == wID )
  108. {
  109. if ( !Button_GetCheck( GetDlgItem( IDC_CONTENT ) ) )
  110. {
  111. Button_SetCheck( GetDlgItem( IDC_ACLS ), FALSE );
  112. }
  113. }
  114. else if ( IDC_ACLS == wID )
  115. {
  116. if ( Button_GetCheck( GetDlgItem( IDC_ACLS ) ) )
  117. {
  118. Button_SetCheck( GetDlgItem( IDC_CONTENT ), TRUE );
  119. }
  120. }
  121. return 0;
  122. }