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.

238 lines
5.9 KiB

  1. /*++
  2. Copyright (c) 1999 Microsoft Corporation
  3. Abstract:
  4. @doc
  5. @module snapdlg.cpp | Implementation of the snapshot dialog
  6. @end
  7. Author:
  8. Adi Oltean [aoltean] 01/25/2000
  9. Revision History:
  10. Name Date Comments
  11. aoltean 01/25/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 "SnapDlg.h"
  21. #ifdef _DEBUG
  22. #define new DEBUG_NEW
  23. #undef THIS_FILE
  24. static char THIS_FILE[] = __FILE__;
  25. #endif
  26. #define STR2W(str) ((LPTSTR)((LPCTSTR)(str)))
  27. /////////////////////////////////////////////////////////////////////////////
  28. // CSnapDlg dialog
  29. CSnapDlg::CSnapDlg(
  30. IVssCoordinator *pICoord,
  31. CWnd* pParent /*=NULL*/
  32. )
  33. : CVssTestGenericDlg(CSnapDlg::IDD, pParent), m_pICoord(pICoord)
  34. {
  35. //{{AFX_DATA_INIT(CSnapDlg)
  36. m_ID = GUID_NULL;
  37. m_SnapshotSetID = GUID_NULL;
  38. m_strSnapshotDeviceObject.Empty();
  39. m_strOriginalVolumeName.Empty();
  40. m_ProviderID = GUID_NULL;
  41. m_lSnapshotAttributes = 0;
  42. m_strCreationTimestamp.Empty();
  43. m_eStatus = 0;
  44. //}}AFX_DATA_INIT
  45. }
  46. CSnapDlg::~CSnapDlg()
  47. {
  48. }
  49. void CSnapDlg::DoDataExchange(CDataExchange* pDX)
  50. {
  51. CVssTestGenericDlg::DoDataExchange(pDX);
  52. //{{AFX_DATA_MAP(CSnapDlg)
  53. DDX_Text(pDX, IDC_SNAP_ID, m_ID);
  54. DDX_Text(pDX, IDC_SNAP_SSID, m_SnapshotSetID);
  55. DDX_Text(pDX, IDC_SNAP_DEVICE, m_strSnapshotDeviceObject);
  56. DDX_Text(pDX, IDC_SNAP_ORIGINAL_VOL_NAME, m_strOriginalVolumeName);
  57. DDX_Text(pDX, IDC_SNAP_STATUS, m_eStatus);
  58. //}}AFX_DATA_MAP
  59. }
  60. BEGIN_MESSAGE_MAP(CSnapDlg, CVssTestGenericDlg)
  61. //{{AFX_MSG_MAP(CSnapDlg)
  62. ON_BN_CLICKED(IDC_NEXT, OnNext)
  63. ON_BN_CLICKED(IDC_NEXT_OBJECT, OnNextSnapshot)
  64. //}}AFX_MSG_MAP
  65. END_MESSAGE_MAP()
  66. /////////////////////////////////////////////////////////////////////////////
  67. // CSnapDlg message handlers
  68. BOOL CSnapDlg::OnInitDialog()
  69. {
  70. CVssFunctionTracer ft( VSSDBG_VSSTEST, L"CSnapDlg::OnInitDialog" );
  71. try
  72. {
  73. CVssTestGenericDlg::OnInitDialog();
  74. m_eMethodType = VSST_S_GET_SNAPSHOT;
  75. BOOL bRes = ::CheckRadioButton( m_hWnd,
  76. IDC_SNAP_GET_PROPERTIES,
  77. IDC_SNAP_GET_PROPERTIES,
  78. IDC_SNAP_GET_PROPERTIES );
  79. _ASSERTE( bRes );
  80. UpdateData( FALSE );
  81. }
  82. VSS_STANDARD_CATCH(ft)
  83. return TRUE; // return TRUE unless you set the focus to a control
  84. }
  85. void CSnapDlg::OnNext()
  86. {
  87. CVssFunctionTracer ft( VSSDBG_VSSTEST, L"CSnapDlg::OnNext" );
  88. USES_CONVERSION;
  89. try
  90. {
  91. UpdateData();
  92. // Try to allocate the diff area object, if needed
  93. if (m_pISnap == NULL)
  94. {
  95. // Get the diff area interface
  96. ft.hr = m_pICoord->GetSnapshot(
  97. m_ID,
  98. IID_IVssSnapshot,
  99. reinterpret_cast<IUnknown**>(&m_pISnap)
  100. );
  101. if (ft.HrFailed())
  102. ft.ErrBox( VSSDBG_VSSTEST, E_UNEXPECTED,
  103. L"Error getting the snapshot interface 0x%08lx", ft.hr);
  104. }
  105. switch(m_eMethodType)
  106. {
  107. case VSST_S_GET_SNAPSHOT:
  108. {
  109. // Empty the fields
  110. m_ID = GUID_NULL;
  111. m_SnapshotSetID = GUID_NULL;
  112. m_strSnapshotDeviceObject.Empty();
  113. m_strOriginalVolumeName.Empty();
  114. m_ProviderID = GUID_NULL;
  115. m_lSnapshotAttributes = 0;
  116. m_strCreationTimestamp.Empty();
  117. m_eStatus = 0;
  118. // Get the properties
  119. VSS_OBJECT_PROP_Ptr ptrObjProp;
  120. ptrObjProp.InitializeAsEmpty(ft);
  121. VSS_OBJECT_PROP* pProp = ptrObjProp.GetStruct();
  122. BS_ASSERT(pProp);
  123. VSS_SNAPSHOT_PROP* pSnapProp = &(pProp->Obj.Snap);
  124. // Get the properties
  125. BS_ASSERT(m_pISnap);
  126. ft.hr = m_pISnap->GetProperties(pSnapProp);
  127. if (ft.HrFailed())
  128. ft.ErrBox( VSSDBG_VSSTEST, E_UNEXPECTED,
  129. L"Error getting the properties 0x%08lx", ft.hr);
  130. // Fill the dialog fields
  131. m_ID = pSnapProp->m_SnapshotId;
  132. m_SnapshotSetID = pSnapProp->m_SnapshotSetId;
  133. m_strSnapshotDeviceObject = pSnapProp->m_pwszSnapshotDeviceObject;
  134. m_strOriginalVolumeName = pSnapProp->m_pwszOriginalVolumeName;
  135. m_ProviderID = pSnapProp->m_ProviderId;
  136. m_lSnapshotAttributes = pSnapProp->m_lSnapshotAttributes;
  137. m_strCreationTimestamp.Format( L"0x%08lx%08lx", pSnapProp->m_tsCreationTimestamp);
  138. m_eStatus = pSnapProp->m_eStatus;
  139. UpdateData( FALSE );
  140. }
  141. break;
  142. default:
  143. BS_ASSERT(false);
  144. ft.ErrBox( VSSDBG_VSSTEST, E_UNEXPECTED, L"Invalid method type");
  145. }
  146. }
  147. VSS_STANDARD_CATCH(ft)
  148. }
  149. void CSnapDlg::OnGetSnapshot()
  150. {
  151. m_eMethodType = VSST_S_GET_SNAPSHOT;
  152. }
  153. void CSnapDlg::OnNextSnapshot()
  154. {
  155. CVssFunctionTracer ft( VSSDBG_VSSTEST, L"CSnapDlg::OnNextSnapshot");
  156. if (m_pEnum == NULL)
  157. return;
  158. // Empty the fields
  159. m_ID = GUID_NULL;
  160. m_SnapshotSetID = GUID_NULL;
  161. m_strSnapshotDeviceObject.Empty();
  162. m_strOriginalVolumeName.Empty();
  163. m_ProviderID = GUID_NULL;
  164. m_lSnapshotAttributes = 0;
  165. m_strCreationTimestamp.Empty();
  166. m_eStatus = 0;
  167. // Get the properties
  168. VSS_OBJECT_PROP_Ptr ptrObjProp;
  169. ptrObjProp.InitializeAsEmpty(ft);
  170. VSS_OBJECT_PROP* pProp = ptrObjProp.GetStruct();
  171. BS_ASSERT(pProp);
  172. ULONG ulFetched;
  173. ft.hr = m_pEnum->Next(1, pProp, &ulFetched);
  174. if (ft.HrFailed())
  175. ft.ErrBox( VSSDBG_VSSTEST, E_UNEXPECTED,
  176. L"Error querying the next volume 0x%08lx", ft.hr);
  177. VSS_SNAPSHOT_PROP* pSnapProp = &(pProp->Obj.Snap);
  178. m_ID = pSnapProp->m_SnapshotId;
  179. m_SnapshotSetID = pSnapProp->m_SnapshotSetId;
  180. m_strSnapshotDeviceObject = pSnapProp->m_pwszSnapshotDeviceObject;
  181. m_ProviderID = pSnapProp->m_ProviderId;
  182. m_lSnapshotAttributes = pSnapProp->m_lSnapshotAttributes;
  183. m_strCreationTimestamp.Format( L"0x%08lx%08lx", pSnapProp->m_tsCreationTimestamp);
  184. m_eStatus = pSnapProp->m_eStatus;
  185. UpdateData( FALSE );
  186. }