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.

163 lines
4.3 KiB

  1. /*++
  2. 1998 Seagate Software, Inc. All rights reserved.
  3. Module Name:
  4. PrMedSet.cpp
  5. Abstract:
  6. Media Set Property Page.
  7. Author:
  8. Art Bragg [abragg] 08-Aug-1997
  9. Revision History:
  10. --*/
  11. #include "stdafx.h"
  12. #include "PrMedSet.h"
  13. #include "WzMedSet.h"
  14. static DWORD pHelpIds[] =
  15. {
  16. IDC_EDIT_MEDIA_COPIES, idh_media_number_of_copy_sets,
  17. IDC_SPIN_MEDIA_COPIES, idh_media_number_of_copy_sets,
  18. IDC_TEXT_MEDIA_COPIES, idh_media_number_of_copy_sets,
  19. 0, 0
  20. };
  21. /////////////////////////////////////////////////////////////////////////////
  22. // CPrMedSet property page
  23. CPrMedSet::CPrMedSet() : CSakPropertyPage(CPrMedSet::IDD)
  24. {
  25. //{{AFX_DATA_INIT(CPrMedSet)
  26. m_numMediaCopies = 0;
  27. //}}AFX_DATA_INIT
  28. m_pHelpIds = pHelpIds;
  29. }
  30. CPrMedSet::~CPrMedSet()
  31. {
  32. }
  33. void CPrMedSet::DoDataExchange(CDataExchange* pDX)
  34. {
  35. CSakPropertyPage::DoDataExchange(pDX);
  36. //{{AFX_DATA_MAP(CPrMedSet)
  37. DDX_Control(pDX, IDC_SPIN_MEDIA_COPIES, m_spinMediaCopies);
  38. DDX_Text(pDX, IDC_EDIT_MEDIA_COPIES, m_numMediaCopies);
  39. DDV_MinMaxUInt(pDX, m_numMediaCopies, 0, 3);
  40. //}}AFX_DATA_MAP
  41. }
  42. BEGIN_MESSAGE_MAP(CPrMedSet, CSakPropertyPage)
  43. //{{AFX_MSG_MAP(CPrMedSet)
  44. ON_WM_DESTROY()
  45. ON_EN_CHANGE(IDC_EDIT_MEDIA_COPIES, OnChangeEditMediaCopies)
  46. //}}AFX_MSG_MAP
  47. END_MESSAGE_MAP()
  48. /////////////////////////////////////////////////////////////////////////////
  49. // CPrMedSet message handlers
  50. BOOL CPrMedSet::OnInitDialog()
  51. {
  52. HRESULT hr = S_OK;
  53. HRESULT hrSupported = S_OK;
  54. CSakPropertyPage::OnInitDialog();
  55. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  56. try {
  57. //
  58. // Set the limit on the spinner
  59. //
  60. m_spinMediaCopies.SetRange( 0, 3 );
  61. //
  62. // Get the single storage pool pointer
  63. //
  64. CComPtr<IHsmServer> pEngine;
  65. WsbAffirmHr( m_pParent->GetHsmServer( &pEngine ) );
  66. WsbAffirmHr( RsGetStoragePool( pEngine, &m_pStoragePool ) );
  67. WsbAffirmHr( m_pParent->GetRmsServer( &m_pRmsServer ) );
  68. GUID mediaSetId;
  69. CWsbBstrPtr mediaName;
  70. WsbAffirmHr( m_pStoragePool->GetMediaSet( &mediaSetId, &mediaName ) );
  71. CComPtr<IRmsMediaSet> pMediaSet;
  72. WsbAffirmHr( m_pRmsServer->CreateObject( mediaSetId, CLSID_CRmsMediaSet, IID_IRmsMediaSet, RmsOpenExisting, (void**)&pMediaSet ) );
  73. //
  74. // Set up control states
  75. // If we support media copies, enable controls
  76. // If we don't support media copies, disable and show reason text
  77. // If error, disable and don't show reason text
  78. //
  79. hrSupported = pMediaSet->IsMediaCopySupported( );
  80. GetDlgItem( IDC_TEXT_MEDIA_COPIES )->EnableWindow( S_OK == hrSupported );
  81. GetDlgItem( IDC_EDIT_MEDIA_COPIES )->EnableWindow( S_OK == hrSupported );
  82. GetDlgItem( IDC_SPIN_MEDIA_COPIES )->EnableWindow( S_OK == hrSupported );
  83. //
  84. // And initialize control
  85. //
  86. USHORT numMediaCopies;
  87. WsbAffirmHr( m_pStoragePool->GetNumMediaCopies( &numMediaCopies ) );
  88. m_numMediaCopies = numMediaCopies;
  89. UpdateData( FALSE );
  90. } WsbCatch( hr );
  91. GetDlgItem( IDC_TEXT_DISABLED )->ShowWindow( S_FALSE == hrSupported ? SW_SHOW : SW_HIDE );
  92. return TRUE;
  93. }
  94. void CPrMedSet::OnChangeEditMediaCopies()
  95. {
  96. SetModified( TRUE );
  97. }
  98. BOOL CPrMedSet::OnApply()
  99. {
  100. HRESULT hr = 0;
  101. UpdateData( TRUE );
  102. try {
  103. WsbAffirmHr( m_pStoragePool->SetNumMediaCopies( (USHORT)m_numMediaCopies ) );
  104. //
  105. // Tell it to save
  106. //
  107. CComPtr<IHsmServer> pServer;
  108. WsbAffirmHr( m_pParent->GetHsmServer( &pServer ) );
  109. WsbAffirmHr( pServer->SavePersistData( ) );
  110. //
  111. // Find the media node - updating the root node is useless
  112. // since we need to change the media node contents.
  113. //
  114. CComPtr<ISakSnapAsk> pAsk;
  115. CComPtr<ISakNode> pNode;
  116. WsbAffirmHr( m_pParent->GetSakSnapAsk( &pAsk ) );
  117. WsbAffirmHr( pAsk->GetNodeOfType( cGuidMedSet, &pNode ) );
  118. //
  119. // Now notify the nodes
  120. //
  121. m_pParent->OnPropertyChange( m_hConsoleHandle, pNode );
  122. } WsbCatch( hr );
  123. return CSakPropertyPage::OnApply();
  124. }