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.

260 lines
6.6 KiB

  1. /*++
  2. Copyright (c) 1999 Microsoft Corporation
  3. Abstract:
  4. @doc
  5. @module DelDlg.cpp | Implementation of the delete dialog
  6. @end
  7. Author:
  8. Adi Oltean [aoltean] 10/10/1999
  9. Revision History:
  10. Name Date Comments
  11. aoltean 10/10/1999 Created
  12. --*/
  13. /////////////////////////////////////////////////////////////////////////////
  14. // Includes
  15. #include "stdafx.hxx"
  16. #include "resource.h"
  17. #include "GenDlg.h"
  18. #include "VssTest.h"
  19. #include "DelDlg.h"
  20. #ifdef _DEBUG
  21. #define new DEBUG_NEW
  22. #undef THIS_FILE
  23. static char THIS_FILE[] = __FILE__;
  24. #endif
  25. #define STR2W(str) ((LPTSTR)((LPCTSTR)(str)))
  26. /////////////////////////////////////////////////////////////////////////////
  27. // CDeleteDlg dialog
  28. CDeleteDlg::CDeleteDlg(
  29. IVssCoordinator *pICoord,
  30. CWnd* pParent /*=NULL*/
  31. )
  32. : CVssTestGenericDlg(CDeleteDlg::IDD, pParent), m_pICoord(pICoord)
  33. {
  34. //{{AFX_DATA_INIT(CDeleteDlg)
  35. m_strObjectId.Empty();
  36. m_bForceDelete = FALSE;
  37. //}}AFX_DATA_INIT
  38. }
  39. CDeleteDlg::~CDeleteDlg()
  40. {
  41. }
  42. void CDeleteDlg::DoDataExchange(CDataExchange* pDX)
  43. {
  44. CVssTestGenericDlg::DoDataExchange(pDX);
  45. //{{AFX_DATA_MAP(CDeleteDlg)
  46. DDX_Text(pDX, IDC_QUERY_OBJECT_ID, m_strObjectId);
  47. DDX_Check(pDX,IDC_DELETE_FORCE_DELETE, m_bForceDelete );
  48. //}}AFX_DATA_MAP
  49. }
  50. BEGIN_MESSAGE_MAP(CDeleteDlg, CVssTestGenericDlg)
  51. //{{AFX_MSG_MAP(CDeleteDlg)
  52. ON_BN_CLICKED(IDC_NEXT, OnNext)
  53. ON_BN_CLICKED(IDC_QUERY_SRC_SNAP, OnSrcSnap)
  54. ON_BN_CLICKED(IDC_QUERY_SRC_SET, OnSrcSet)
  55. ON_BN_CLICKED(IDC_QUERY_SRC_PROV, OnSrcProv)
  56. ON_BN_CLICKED(IDC_QUERY_SRC_VOL, OnSrcVol)
  57. //}}AFX_MSG_MAP
  58. END_MESSAGE_MAP()
  59. /////////////////////////////////////////////////////////////////////////////
  60. // CDeleteDlg message handlers
  61. BOOL CDeleteDlg::OnInitDialog()
  62. {
  63. CVssFunctionTracer ft( VSSDBG_VSSTEST, L"CDeleteDlg::OnInitDialog" );
  64. try
  65. {
  66. CVssTestGenericDlg::OnInitDialog();
  67. m_eSrcType = VSS_OBJECT_SNAPSHOT_SET;
  68. BOOL bRes = ::CheckRadioButton( m_hWnd, IDC_QUERY_SRC_SET, IDC_QUERY_SRC_SET, IDC_QUERY_SRC_SET );
  69. _ASSERTE( bRes );
  70. VSS_ID ObjectId;
  71. ft.hr = ::CoCreateGuid(&ObjectId);
  72. if (ft.HrFailed())
  73. ft.ErrBox( VSSDBG_VSSTEST, E_UNEXPECTED,
  74. L"Cannot create object guid. [0x%08lx]", ft.hr);
  75. // Initializing Snapshot Set ID
  76. LPOLESTR strGUID;
  77. ft.hr = ::StringFromCLSID( ObjectId, &strGUID );
  78. if ( ft.HrFailed() )
  79. ft.ErrBox( VSSDBG_VSSTEST, E_UNEXPECTED, L"Error on calling StringFromCLSID. hr = 0x%08lx", ft.hr);
  80. m_strObjectId = OLE2T(strGUID);
  81. ::CoTaskMemFree(strGUID);
  82. UpdateData( FALSE );
  83. }
  84. VSS_STANDARD_CATCH(ft)
  85. return TRUE; // return TRUE unless you set the focus to a control
  86. }
  87. void CDeleteDlg::OnNext()
  88. {
  89. CVssFunctionTracer ft( VSSDBG_VSSTEST, L"CDeleteDlg::OnNext" );
  90. USES_CONVERSION;
  91. try
  92. {
  93. UpdateData();
  94. // Get the queried object Id.
  95. LPTSTR ptszObjectId = const_cast<LPTSTR>(LPCTSTR(m_strObjectId));
  96. VSS_ID ObjectId;
  97. ft.hr = ::CLSIDFromString(T2OLE(ptszObjectId), &ObjectId);
  98. if (ft.HrFailed())
  99. ft.Throw( VSSDBG_COORD, E_UNEXPECTED,
  100. L"Error on converting the object Id %s to a GUID. lRes == 0x%08lx",
  101. T2W(ptszObjectId), ft.hr );
  102. // Get the enumerator
  103. BS_ASSERT(m_pICoord);
  104. CComPtr<IVssEnumObject> pEnum;
  105. LONG lDeletedSnapshots;
  106. VSS_ID NondeletedSnapshotID;
  107. ft.hr = m_pICoord->DeleteSnapshots(
  108. ObjectId,
  109. m_eSrcType,
  110. m_bForceDelete,
  111. &lDeletedSnapshots,
  112. &NondeletedSnapshotID
  113. );
  114. if (ft.HrFailed())
  115. ft.ErrBox( VSSDBG_VSSTEST, E_UNEXPECTED,
  116. L"Cannot delete (all) snapshots. [0x%08lx]\n"
  117. L"%ld snapshot(s) succeeded to be deleted.\n"
  118. L"The snapshot that cannot be deleted: " WSTR_GUID_FMT,
  119. ft.hr, lDeletedSnapshots,
  120. GUID_PRINTF_ARG(NondeletedSnapshotID));
  121. ft.MsgBox( L"Succeeded", L"%ld Snapshot(s) deleted!", lDeletedSnapshots );
  122. }
  123. VSS_STANDARD_CATCH(ft)
  124. }
  125. void CDeleteDlg::OnSrcSnap()
  126. {
  127. m_eSrcType = VSS_OBJECT_SNAPSHOT;
  128. /*
  129. m_eDestType = VSS_OBJECT_SNAPSHOT_SET;
  130. BOOL bRes = ::CheckRadioButton( m_hWnd, IDC_QUERY_DEST_SNAP, IDC_QUERY_DEST_VOL, IDC_QUERY_DEST_SET );
  131. _ASSERTE( bRes );
  132. CWnd* pWnd = GetDlgItem(IDC_QUERY_DEST_SNAP);
  133. if (pWnd)
  134. pWnd->EnableWindow(FALSE);
  135. pWnd = GetDlgItem(IDC_QUERY_DEST_SET);
  136. if (pWnd)
  137. pWnd->EnableWindow(TRUE);
  138. pWnd = GetDlgItem(IDC_QUERY_DEST_PROV);
  139. if (pWnd)
  140. pWnd->EnableWindow(TRUE);
  141. pWnd = GetDlgItem(IDC_QUERY_DEST_VOL);
  142. if (pWnd)
  143. pWnd->EnableWindow(TRUE);
  144. */
  145. }
  146. void CDeleteDlg::OnSrcSet()
  147. {
  148. m_eSrcType = VSS_OBJECT_SNAPSHOT_SET;
  149. /*
  150. m_eDestType = VSS_OBJECT_SNAPSHOT;
  151. BOOL bRes = ::CheckRadioButton( m_hWnd, IDC_QUERY_DEST_SNAP, IDC_QUERY_DEST_VOL, IDC_QUERY_DEST_SNAP );
  152. _ASSERTE( bRes );
  153. CWnd* pWnd = GetDlgItem(IDC_QUERY_DEST_SNAP);
  154. if (pWnd)
  155. pWnd->EnableWindow(TRUE);
  156. pWnd = GetDlgItem(IDC_QUERY_DEST_SET);
  157. if (pWnd)
  158. pWnd->EnableWindow(FALSE);
  159. pWnd = GetDlgItem(IDC_QUERY_DEST_PROV);
  160. if (pWnd)
  161. pWnd->EnableWindow(TRUE);
  162. pWnd = GetDlgItem(IDC_QUERY_DEST_VOL);
  163. if (pWnd)
  164. pWnd->EnableWindow(TRUE);
  165. */
  166. }
  167. void CDeleteDlg::OnSrcProv()
  168. {
  169. m_eSrcType = VSS_OBJECT_PROVIDER;
  170. /*
  171. m_eDestType = VSS_OBJECT_SNAPSHOT_SET;
  172. BOOL bRes = ::CheckRadioButton( m_hWnd, IDC_QUERY_DEST_SNAP, IDC_QUERY_DEST_VOL, IDC_QUERY_DEST_SNAP );
  173. _ASSERTE( bRes );
  174. CWnd* pWnd = GetDlgItem(IDC_QUERY_DEST_SNAP);
  175. if (pWnd)
  176. pWnd->EnableWindow(TRUE);
  177. pWnd = GetDlgItem(IDC_QUERY_DEST_SET);
  178. if (pWnd)
  179. pWnd->EnableWindow(TRUE);
  180. pWnd = GetDlgItem(IDC_QUERY_DEST_PROV);
  181. if (pWnd)
  182. pWnd->EnableWindow(FALSE);
  183. pWnd = GetDlgItem(IDC_QUERY_DEST_VOL);
  184. if (pWnd)
  185. pWnd->EnableWindow(TRUE);
  186. */
  187. }
  188. void CDeleteDlg::OnSrcVol()
  189. {
  190. // m_eSrcType = VSS_OBJECT_VOLUME;
  191. /*
  192. m_eDestType = VSS_OBJECT_SNAPSHOT_SET;
  193. BOOL bRes = ::CheckRadioButton( m_hWnd, IDC_QUERY_DEST_SNAP, IDC_QUERY_DEST_VOL, IDC_QUERY_DEST_SNAP );
  194. _ASSERTE( bRes );
  195. CWnd* pWnd = GetDlgItem(IDC_QUERY_DEST_SNAP);
  196. if (pWnd)
  197. pWnd->EnableWindow(TRUE);
  198. pWnd = GetDlgItem(IDC_QUERY_DEST_SET);
  199. if (pWnd)
  200. pWnd->EnableWindow(TRUE);
  201. pWnd = GetDlgItem(IDC_QUERY_DEST_PROV);
  202. if (pWnd)
  203. pWnd->EnableWindow(TRUE);
  204. pWnd = GetDlgItem(IDC_QUERY_DEST_VOL);
  205. if (pWnd)
  206. pWnd->EnableWindow(FALSE);
  207. */
  208. }