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.

112 lines
3.4 KiB

  1. #include "stdafx.h"
  2. #include "WizardSheet.h"
  3. #include "UIUtils.h"
  4. CPackageConfig::CPackageConfig( CWizardSheet* pTheSheet ) :
  5. m_pTheSheet( pTheSheet )
  6. {
  7. m_strTitle.LoadString( IDS_TITLE_PKG );
  8. m_strSubTitle.LoadString( IDS_SUBTITLE_PKG );
  9. SetHeaderTitle( m_strTitle );
  10. SetHeaderSubTitle( m_strSubTitle );
  11. }
  12. LRESULT CPackageConfig::OnInitDialog( UINT, WPARAM, LPARAM, BOOL& )
  13. {
  14. Edit_LimitText( GetDlgItem( IDC_PWD ), MAX_PWD_LEN );
  15. Edit_LimitText( GetDlgItem( IDC_CONFIRM ), MAX_PWD_LEN );
  16. Edit_LimitText( GetDlgItem( IDC_PKGNAME ), MAX_PATH );
  17. // Enable auto complete for the filename control
  18. m_pTheSheet->SetAutocomplete( GetDlgItem( IDC_PKGNAME ), SHACF_FILESYSTEM );
  19. return 0;
  20. }
  21. LRESULT CPackageConfig::OnBrowse( WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/ )
  22. {
  23. CString strFilter;
  24. UIUtils::LoadOFNFilterFromRes( IDS_FILTER_PACKAGE, /*r*/strFilter );
  25. CFileDialog dlg( FALSE,
  26. L"*.pkg",
  27. NULL,
  28. OFN_ENABLESIZING | OFN_EXPLORER,
  29. strFilter,
  30. m_hWnd );
  31. if ( dlg.DoModal() == IDCANCEL ) return 0;
  32. VERIFY( SetDlgItemText( IDC_PKGNAME, dlg.m_szFileName ) );
  33. return 0;
  34. }
  35. int CPackageConfig::OnWizardNext()
  36. {
  37. UINT nErrorID = 0;
  38. GetDlgItemText( IDC_PKGNAME, m_strFilename.GetBuffer( MAX_PATH + 1 ), MAX_PATH );
  39. m_strFilename.ReleaseBuffer();
  40. // Check the package filename is valid
  41. TFileHandle shFile( ::CreateFile( m_strFilename,
  42. GENERIC_WRITE,
  43. 0,
  44. NULL,
  45. OPEN_ALWAYS,
  46. FILE_ATTRIBUTE_NORMAL,
  47. NULL ) );
  48. CString strPwd;
  49. CString strPwdConfirm;
  50. // Check the password is confirmed properly
  51. GetDlgItemText( IDC_PWD, strPwd.GetBuffer( MAX_PWD_LEN + 1 ), MAX_PWD_LEN );
  52. GetDlgItemText( IDC_CONFIRM, strPwdConfirm.GetBuffer( MAX_PWD_LEN + 1 ), MAX_PWD_LEN );
  53. strPwd.ReleaseBuffer();
  54. strPwdConfirm.ReleaseBuffer();
  55. if ( !shFile.IsValid() )
  56. {
  57. nErrorID = IDS_E_WRONGPKGNAME;
  58. ::SetFocus( GetDlgItem( IDC_PKGNAME ) );
  59. }
  60. else if ( strPwd.IsEmpty() )
  61. {
  62. nErrorID = IDS_E_PASSWORD_EMPTY;
  63. ::SetFocus( GetDlgItem( IDC_PWD ) );
  64. }
  65. else if ( strPwd != strPwdConfirm )
  66. {
  67. nErrorID = IDS_E_PWDS_DIFFER;
  68. ::SetFocus( GetDlgItem( IDC_CONFIRM ) );
  69. }
  70. if ( nErrorID != 0 )
  71. {
  72. UIUtils::MessageBox( m_hWnd, nErrorID, IDS_APPTITLE, MB_OK | MB_ICONSTOP );
  73. return -1;
  74. }
  75. // Get the data
  76. GetDlgItemText( IDC_COMMENT, m_strComment.GetBuffer( 1024 + 1 ), 1024 );
  77. m_strComment.ReleaseBuffer();
  78. m_strPassword = strPwd;
  79. m_bCompress = Button_GetCheck( GetDlgItem( IDC_COMPRESS ) ) != FALSE;
  80. m_bEncrypt = Button_GetCheck( GetDlgItem( IDC_ENCRYPT ) ) != FALSE;
  81. m_bPostProcess = Button_GetCheck( GetDlgItem( IDC_ADDPOSTPROCESS ) ) != FALSE;
  82. // We will display either the post-import dlg or the summary page
  83. return Button_GetCheck( GetDlgItem( IDC_ADDPOSTPROCESS ) ) ? IDD_WPEXP_POSTPROCESS : IDD_WPEXP_SUMMARY;
  84. }