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.

223 lines
5.6 KiB

  1. /*++
  2. Copyright (c) 1999 Microsoft Corporation
  3. Abstract:
  4. @doc
  5. @module VolDlg.cpp | Implementation of the IsVolumeXXX dialog
  6. @end
  7. Author:
  8. Adi Oltean [aoltean] 10/22/2000
  9. Revision History:
  10. Name Date Comments
  11. aoltean 10/22/2000 Created
  12. --*/
  13. /////////////////////////////////////////////////////////////////////////////
  14. // Includes
  15. #include "stdafx.hxx"
  16. #include "resource.h"
  17. #include "vsswprv.h"
  18. #include "GenDlg.h"
  19. #include "VssTest.h"
  20. #include "VolDlg.h"
  21. #include "vswriter.h"
  22. #include "vsbackup.h"
  23. #ifdef _DEBUG
  24. #define new DEBUG_NEW
  25. #undef THIS_FILE
  26. static char THIS_FILE[] = __FILE__;
  27. #endif
  28. #define STR2W(str) ((LPTSTR)((LPCTSTR)(str)))
  29. /////////////////////////////////////////////////////////////////////////////
  30. // CVolDlg dialog
  31. CVolDlg::CVolDlg(
  32. IVssCoordinator *pICoord,
  33. CWnd* pParent /*=NULL*/
  34. )
  35. : CVssTestGenericDlg(CVolDlg::IDD, pParent), m_pICoord(pICoord)
  36. {
  37. //{{AFX_DATA_INIT(CVolDlg)
  38. m_strObjectId.Empty();
  39. m_strVolumeName.Empty();
  40. //}}AFX_DATA_INIT
  41. }
  42. CVolDlg::~CVolDlg()
  43. {
  44. }
  45. void CVolDlg::DoDataExchange(CDataExchange* pDX)
  46. {
  47. CVssTestGenericDlg::DoDataExchange(pDX);
  48. //{{AFX_DATA_MAP(CVolDlg)
  49. DDX_Text(pDX, IDC_VOLUME_OBJECT_ID, m_strObjectId);
  50. DDX_Text(pDX, IDC_VOLUME_NAME, m_strVolumeName);
  51. //}}AFX_DATA_MAP
  52. }
  53. BEGIN_MESSAGE_MAP(CVolDlg, CVssTestGenericDlg)
  54. //{{AFX_MSG_MAP(CVolDlg)
  55. ON_BN_CLICKED(IDC_NEXT, OnNext)
  56. ON_BN_CLICKED(IDC_VOLUME_IS_VOL_SUPPORTED, OnIsVolumeSupported)
  57. ON_BN_CLICKED(IDC_VOLUME_IS_VOL_SNAPSHOTTED,OnIsVolumeSnapshotted)
  58. ON_BN_CLICKED(IDC_VOLUME_IS_VOL_SUPPORTED2, OnIsVolumeSupported2)
  59. ON_BN_CLICKED(IDC_VOLUME_IS_VOL_SNAPSHOTTED2,OnIsVolumeSnapshotted2)
  60. //}}AFX_MSG_MAP
  61. END_MESSAGE_MAP()
  62. /////////////////////////////////////////////////////////////////////////////
  63. // CVolDlg message handlers
  64. BOOL CVolDlg::OnInitDialog()
  65. {
  66. CVssFunctionTracer ft( VSSDBG_VSSTEST, L"CVolDlg::OnInitDialog" );
  67. try
  68. {
  69. CVssTestGenericDlg::OnInitDialog();
  70. m_eCallType = VSS_IS_VOL_SUPPORTED;
  71. BOOL bRes = ::CheckRadioButton( m_hWnd, IDC_VOLUME_IS_VOL_SUPPORTED, IDC_VOLUME_IS_VOL_SUPPORTED, IDC_VOLUME_IS_VOL_SUPPORTED );
  72. _ASSERTE( bRes );
  73. // Initializing Snapshot Set ID
  74. VSS_ID ObjectId = VSS_SWPRV_ProviderId;
  75. LPOLESTR strGUID;
  76. ft.hr = ::StringFromCLSID( ObjectId, &strGUID );
  77. if ( ft.HrFailed() )
  78. ft.ErrBox( VSSDBG_VSSTEST, E_UNEXPECTED, L"Error on calling StringFromCLSID. hr = 0x%08lx", ft.hr);
  79. m_strObjectId = OLE2T(strGUID);
  80. ::CoTaskMemFree(strGUID);
  81. UpdateData( FALSE );
  82. }
  83. VSS_STANDARD_CATCH(ft)
  84. return TRUE; // return TRUE unless you set the focus to a control
  85. }
  86. void CVolDlg::OnNext()
  87. {
  88. CVssFunctionTracer ft( VSSDBG_VSSTEST, L"CVolDlg::OnNext" );
  89. USES_CONVERSION;
  90. const nBuffLen = 2048; // including the zero character.
  91. WCHAR wszBuffer[nBuffLen];
  92. try
  93. {
  94. UpdateData();
  95. // Get the provider Id.
  96. LPTSTR ptszObjectId = const_cast<LPTSTR>(LPCTSTR(m_strObjectId));
  97. VSS_ID ProviderId;
  98. ft.hr = ::CLSIDFromString(T2OLE(ptszObjectId), &ProviderId);
  99. if (ft.HrFailed())
  100. ft.Throw( VSSDBG_COORD, E_UNEXPECTED,
  101. L"Error on converting the object Id %s to a GUID. lRes == 0x%08lx",
  102. T2W(ptszObjectId), ft.hr );
  103. // Get the enumerator
  104. BS_ASSERT(m_pICoord);
  105. BOOL bResult = FALSE;
  106. LPWSTR pwszFunctionName = L"<unknown function>";
  107. switch (m_eCallType) {
  108. case VSS_IS_VOL_SUPPORTED:
  109. ft.hr = m_pICoord->IsVolumeSupported(
  110. ProviderId,
  111. T2W(LPTSTR((LPCTSTR)m_strVolumeName)),
  112. &bResult
  113. );
  114. pwszFunctionName = L"IsVolumeSupported";
  115. break;
  116. case VSS_IS_VOL_SNAPSHOTTED:
  117. ft.hr = m_pICoord->IsVolumeSnapshotted(
  118. ProviderId,
  119. T2W(LPTSTR((LPCTSTR)m_strVolumeName)),
  120. &bResult
  121. );
  122. pwszFunctionName = L"IsVolumeSnapshotted";
  123. break;
  124. case VSS_IS_VOL_SUPPORTED2:
  125. {
  126. CComPtr<IVssBackupComponents> pComp;
  127. ft.hr = CreateVssBackupComponents(&pComp);
  128. ft.hr = pComp->IsVolumeSupported(
  129. ProviderId,
  130. T2W(LPTSTR((LPCTSTR)m_strVolumeName)),
  131. &bResult
  132. );
  133. pwszFunctionName = L"IsVolumeSupported2";
  134. }
  135. break;
  136. case VSS_IS_VOL_SNAPSHOTTED2:
  137. ft.hr = IsVolumeSnapshotted(
  138. T2W(LPTSTR((LPCTSTR)m_strVolumeName)),
  139. &bResult
  140. );
  141. pwszFunctionName = L"IsVolumeSnapshotted2";
  142. break;
  143. default:
  144. ft.ErrBox( VSSDBG_VSSTEST, E_UNEXPECTED,
  145. L"Invalid call type %s().", pwszFunctionName);
  146. }
  147. if (ft.HrFailed())
  148. ft.ErrBox( VSSDBG_VSSTEST, ft.hr,
  149. L"Error on calling %s(). [0x%08lx]", pwszFunctionName, ft.hr);
  150. ft.MsgBox(L"Function result", L"Function %s("WSTR_GUID_FMT L", %s, ...) returned %s",
  151. pwszFunctionName,
  152. GUID_PRINTF_ARG(ProviderId),
  153. T2W(LPTSTR((LPCTSTR)m_strVolumeName)),
  154. bResult? L"TRUE":L"FALSE");
  155. }
  156. VSS_STANDARD_CATCH(ft)
  157. }
  158. void CVolDlg::OnIsVolumeSupported()
  159. {
  160. m_eCallType = VSS_IS_VOL_SUPPORTED;
  161. }
  162. void CVolDlg::OnIsVolumeSnapshotted()
  163. {
  164. m_eCallType = VSS_IS_VOL_SNAPSHOTTED;
  165. }
  166. void CVolDlg::OnIsVolumeSupported2()
  167. {
  168. m_eCallType = VSS_IS_VOL_SUPPORTED;
  169. }
  170. void CVolDlg::OnIsVolumeSnapshotted2()
  171. {
  172. m_eCallType = VSS_IS_VOL_SNAPSHOTTED;
  173. }