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.

349 lines
9.0 KiB

  1. /*++
  2. Copyright (c) 1999 Microsoft Corporation
  3. Abstract:
  4. @doc
  5. @module CoordDlg.cpp | Implementation of the query dialog
  6. @end
  7. Author:
  8. Adi Oltean [aoltean] 09/22/1999
  9. Revision History:
  10. Name Date Comments
  11. aoltean 09/22/1999 Created
  12. aoltean 09/27/1999 Adding Query mask flags
  13. --*/
  14. /////////////////////////////////////////////////////////////////////////////
  15. // Includes
  16. #include "stdafx.hxx"
  17. #include "resource.h"
  18. #include "vsswprv.h"
  19. #include "GenDlg.h"
  20. #include "VssTest.h"
  21. #include "QueryDlg.h"
  22. #ifdef _DEBUG
  23. #define new DEBUG_NEW
  24. #undef THIS_FILE
  25. static char THIS_FILE[] = __FILE__;
  26. #endif
  27. #define STR2W(str) ((LPTSTR)((LPCTSTR)(str)))
  28. /////////////////////////////////////////////////////////////////////////////
  29. // CQueryDlg dialog
  30. CQueryDlg::CQueryDlg(
  31. IVssCoordinator *pICoord,
  32. CWnd* pParent /*=NULL*/
  33. )
  34. : CVssTestGenericDlg(CQueryDlg::IDD, pParent), m_pICoord(pICoord)
  35. {
  36. //{{AFX_DATA_INIT(CQueryDlg)
  37. m_strObjectId.Empty();
  38. m_bCkQueriedObject = FALSE;
  39. m_bCkName = TRUE;
  40. m_bCkVersion = TRUE;
  41. m_bCkDevice = TRUE;
  42. m_bCkOriginal = TRUE;
  43. //}}AFX_DATA_INIT
  44. }
  45. CQueryDlg::~CQueryDlg()
  46. {
  47. }
  48. void CQueryDlg::DoDataExchange(CDataExchange* pDX)
  49. {
  50. CVssTestGenericDlg::DoDataExchange(pDX);
  51. //{{AFX_DATA_MAP(CQueryDlg)
  52. DDX_Text(pDX, IDC_QUERY_OBJECT_ID, m_strObjectId);
  53. DDX_Check(pDX,IDC_QUERY_CK_OBJECT, m_bCkQueriedObject );
  54. DDX_Check(pDX,IDC_QUERY_CK_DEVICE ,m_bCkDevice );
  55. DDX_Check(pDX,IDC_QUERY_CK_ORIGINAL,m_bCkOriginal );
  56. DDX_Check(pDX,IDC_QUERY_CK_NAME ,m_bCkName );
  57. DDX_Check(pDX,IDC_QUERY_CK_VERSION,m_bCkVersion );
  58. //}}AFX_DATA_MAP
  59. }
  60. BEGIN_MESSAGE_MAP(CQueryDlg, CVssTestGenericDlg)
  61. //{{AFX_MSG_MAP(CQueryDlg)
  62. ON_BN_CLICKED(IDC_NEXT, OnNext)
  63. ON_BN_CLICKED(IDC_QUERY_CK_OBJECT, OnQueriedChk)
  64. ON_BN_CLICKED(IDC_QUERY_SRC_SNAP, OnSrcSnap)
  65. ON_BN_CLICKED(IDC_QUERY_SRC_SET, OnSrcSet)
  66. ON_BN_CLICKED(IDC_QUERY_SRC_PROV, OnSrcProv)
  67. ON_BN_CLICKED(IDC_QUERY_SRC_VOL, OnSrcVol)
  68. ON_BN_CLICKED(IDC_QUERY_DEST_SNAP, OnDestSnap)
  69. ON_BN_CLICKED(IDC_QUERY_DEST_SET, OnDestSet)
  70. ON_BN_CLICKED(IDC_QUERY_DEST_PROV, OnDestProv)
  71. ON_BN_CLICKED(IDC_QUERY_DEST_VOL, OnDestVol)
  72. ON_BN_CLICKED(IDC_QUERY_DEST_WRITER,OnDestWriter)
  73. //}}AFX_MSG_MAP
  74. END_MESSAGE_MAP()
  75. /////////////////////////////////////////////////////////////////////////////
  76. // CQueryDlg message handlers
  77. BOOL CQueryDlg::OnInitDialog()
  78. {
  79. CVssFunctionTracer ft( VSSDBG_VSSTEST, L"CQueryDlg::OnInitDialog" );
  80. try
  81. {
  82. CVssTestGenericDlg::OnInitDialog();
  83. /*
  84. m_eSrcType = VSS_OBJECT_PROVIDER;
  85. BOOL bRes = ::CheckRadioButton( m_hWnd, IDC_QUERY_SRC_PROV, IDC_QUERY_SRC_PROV, IDC_QUERY_SRC_PROV );
  86. _ASSERTE( bRes );
  87. */
  88. m_eDestType = VSS_OBJECT_SNAPSHOT;
  89. BOOL bRes = ::CheckRadioButton( m_hWnd, IDC_QUERY_DEST_SNAP, IDC_QUERY_DEST_VOL, IDC_QUERY_DEST_SNAP );
  90. _ASSERTE( bRes );
  91. /*
  92. // Set destination button
  93. OnSrcSet();
  94. */
  95. // Initializing Snapshot Set ID
  96. VSS_ID ObjectId = VSS_SWPRV_ProviderId;
  97. LPOLESTR strGUID;
  98. ft.hr = ::StringFromCLSID( ObjectId, &strGUID );
  99. if ( ft.HrFailed() )
  100. ft.ErrBox( VSSDBG_VSSTEST, E_UNEXPECTED, L"Error on calling StringFromCLSID. hr = 0x%08lx", ft.hr);
  101. m_strObjectId = OLE2T(strGUID);
  102. ::CoTaskMemFree(strGUID);
  103. UpdateData( FALSE );
  104. }
  105. VSS_STANDARD_CATCH(ft)
  106. return TRUE; // return TRUE unless you set the focus to a control
  107. }
  108. void CQueryDlg::OnNext()
  109. {
  110. CVssFunctionTracer ft( VSSDBG_VSSTEST, L"CQueryDlg::OnNext" );
  111. USES_CONVERSION;
  112. const nBuffLen = 2048; // including the zero character.
  113. WCHAR wszBuffer[nBuffLen];
  114. try
  115. {
  116. UpdateData();
  117. // Get the queried object Id.
  118. LPTSTR ptszObjectId = const_cast<LPTSTR>(LPCTSTR(m_strObjectId));
  119. VSS_ID ObjectId;
  120. ft.hr = ::CLSIDFromString(T2OLE(ptszObjectId), &ObjectId);
  121. if (ft.HrFailed())
  122. ft.Throw( VSSDBG_COORD, E_UNEXPECTED,
  123. L"Error on converting the object Id %s to a GUID. lRes == 0x%08lx",
  124. T2W(ptszObjectId), ft.hr );
  125. // Get the enumerator
  126. BS_ASSERT(m_pICoord);
  127. CComPtr<IVssEnumObject> pEnum;
  128. ft.hr = m_pICoord->Query(
  129. m_bCkQueriedObject? ObjectId: GUID_NULL,
  130. m_bCkQueriedObject? m_eSrcType: VSS_OBJECT_NONE,
  131. m_eDestType,
  132. &pEnum
  133. );
  134. if (ft.HrFailed())
  135. ft.ErrBox( VSSDBG_VSSTEST, E_OUTOFMEMORY,
  136. L"Cannot interogate enumerator instance. [0x%08lx]", ft.hr);
  137. if (ft.hr == S_FALSE)
  138. ft.MsgBox( L"Results", L"Empty result...");
  139. // Allocate the new structure object, but with zero contents.
  140. // The internal pointer must not be NULL.
  141. VSS_OBJECT_PROP_Ptr ptrObjProp;
  142. ptrObjProp.InitializeAsEmpty(ft);
  143. while(true)
  144. {
  145. // Get the Next object in the newly allocated structure object.
  146. VSS_OBJECT_PROP* pProp = ptrObjProp.GetStruct();
  147. BS_ASSERT(pProp);
  148. ULONG ulFetched;
  149. ft.hr = pEnum->Next(1, pProp, &ulFetched);
  150. if (ft.hr == S_FALSE) // end of enumeration
  151. break;
  152. if (ft.HrFailed())
  153. ft.ErrBox( VSSDBG_VSSTEST, E_UNEXPECTED, L"Error calling Next");
  154. // Print the contents
  155. ptrObjProp.Print( ft, wszBuffer, nBuffLen - 1 );
  156. ft.Trace( VSSDBG_SWPRV, L"Results %s", wszBuffer);
  157. ft.MsgBox( L"Results", wszBuffer);
  158. // release COM allocated pointers at unmarshalling time
  159. // Warning: do not release the union pointer! It is needed for the next cicle.
  160. VSS_OBJECT_PROP_Copy::destroy(pProp);
  161. }
  162. }
  163. VSS_STANDARD_CATCH(ft)
  164. }
  165. void CQueryDlg::OnSrcSnap()
  166. {
  167. m_eSrcType = VSS_OBJECT_SNAPSHOT;
  168. /*
  169. m_eDestType = VSS_OBJECT_SNAPSHOT_SET;
  170. BOOL bRes = ::CheckRadioButton( m_hWnd, IDC_QUERY_DEST_SNAP, IDC_QUERY_DEST_VOL, IDC_QUERY_DEST_SET );
  171. _ASSERTE( bRes );
  172. CWnd* pWnd = GetDlgItem(IDC_QUERY_DEST_SNAP);
  173. if (pWnd)
  174. pWnd->EnableWindow(FALSE);
  175. pWnd = GetDlgItem(IDC_QUERY_DEST_SET);
  176. if (pWnd)
  177. pWnd->EnableWindow(TRUE);
  178. pWnd = GetDlgItem(IDC_QUERY_DEST_PROV);
  179. if (pWnd)
  180. pWnd->EnableWindow(TRUE);
  181. pWnd = GetDlgItem(IDC_QUERY_DEST_VOL);
  182. if (pWnd)
  183. pWnd->EnableWindow(TRUE);
  184. */
  185. }
  186. void CQueryDlg::OnSrcSet()
  187. {
  188. m_eSrcType = VSS_OBJECT_SNAPSHOT_SET;
  189. /*
  190. m_eDestType = VSS_OBJECT_SNAPSHOT;
  191. BOOL bRes = ::CheckRadioButton( m_hWnd, IDC_QUERY_DEST_SNAP, IDC_QUERY_DEST_VOL, IDC_QUERY_DEST_SNAP );
  192. _ASSERTE( bRes );
  193. CWnd* pWnd = GetDlgItem(IDC_QUERY_DEST_SNAP);
  194. if (pWnd)
  195. pWnd->EnableWindow(TRUE);
  196. pWnd = GetDlgItem(IDC_QUERY_DEST_SET);
  197. if (pWnd)
  198. pWnd->EnableWindow(FALSE);
  199. pWnd = GetDlgItem(IDC_QUERY_DEST_PROV);
  200. if (pWnd)
  201. pWnd->EnableWindow(TRUE);
  202. pWnd = GetDlgItem(IDC_QUERY_DEST_VOL);
  203. if (pWnd)
  204. pWnd->EnableWindow(TRUE);
  205. */
  206. }
  207. void CQueryDlg::OnSrcProv()
  208. {
  209. m_eSrcType = VSS_OBJECT_PROVIDER;
  210. /*
  211. m_eDestType = VSS_OBJECT_SNAPSHOT_SET;
  212. BOOL bRes = ::CheckRadioButton( m_hWnd, IDC_QUERY_DEST_SNAP, IDC_QUERY_DEST_VOL, IDC_QUERY_DEST_SNAP );
  213. _ASSERTE( bRes );
  214. CWnd* pWnd = GetDlgItem(IDC_QUERY_DEST_SNAP);
  215. if (pWnd)
  216. pWnd->EnableWindow(TRUE);
  217. pWnd = GetDlgItem(IDC_QUERY_DEST_SET);
  218. if (pWnd)
  219. pWnd->EnableWindow(TRUE);
  220. pWnd = GetDlgItem(IDC_QUERY_DEST_PROV);
  221. if (pWnd)
  222. pWnd->EnableWindow(FALSE);
  223. pWnd = GetDlgItem(IDC_QUERY_DEST_VOL);
  224. if (pWnd)
  225. pWnd->EnableWindow(TRUE);
  226. */
  227. }
  228. void CQueryDlg::OnSrcVol()
  229. {
  230. // m_eSrcType = VSS_OBJECT_VOLUME;
  231. /*
  232. m_eDestType = VSS_OBJECT_SNAPSHOT_SET;
  233. BOOL bRes = ::CheckRadioButton( m_hWnd, IDC_QUERY_DEST_SNAP, IDC_QUERY_DEST_VOL, IDC_QUERY_DEST_SNAP );
  234. _ASSERTE( bRes );
  235. CWnd* pWnd = GetDlgItem(IDC_QUERY_DEST_SNAP);
  236. if (pWnd)
  237. pWnd->EnableWindow(TRUE);
  238. pWnd = GetDlgItem(IDC_QUERY_DEST_SET);
  239. if (pWnd)
  240. pWnd->EnableWindow(TRUE);
  241. pWnd = GetDlgItem(IDC_QUERY_DEST_PROV);
  242. if (pWnd)
  243. pWnd->EnableWindow(TRUE);
  244. pWnd = GetDlgItem(IDC_QUERY_DEST_VOL);
  245. if (pWnd)
  246. pWnd->EnableWindow(FALSE);
  247. */
  248. }
  249. void CQueryDlg::OnDestSnap()
  250. {
  251. m_eDestType = VSS_OBJECT_SNAPSHOT;
  252. }
  253. void CQueryDlg::OnDestSet()
  254. {
  255. // m_eDestType = VSS_OBJECT_SNAPSHOT_SET;
  256. }
  257. void CQueryDlg::OnDestProv()
  258. {
  259. m_eDestType = VSS_OBJECT_PROVIDER;
  260. }
  261. void CQueryDlg::OnDestVol()
  262. {
  263. // m_eDestType = VSS_OBJECT_VOLUME;
  264. }
  265. void CQueryDlg::OnDestWriter()
  266. {
  267. }
  268. void CQueryDlg::OnQueriedChk()
  269. {
  270. UpdateData();
  271. if (CWnd* pWnd = GetDlgItem(IDC_QUERY_OBJECT_ID))
  272. pWnd->EnableWindow(m_bCkQueriedObject);
  273. if (CWnd* pWnd = GetDlgItem(IDC_QUERY_SRC_SNAP))
  274. pWnd->EnableWindow(m_bCkQueriedObject);
  275. if (CWnd* pWnd = GetDlgItem(IDC_QUERY_SRC_SET))
  276. pWnd->EnableWindow(m_bCkQueriedObject);
  277. if (CWnd* pWnd = GetDlgItem(IDC_QUERY_SRC_VOL))
  278. pWnd->EnableWindow(m_bCkQueriedObject);
  279. if (CWnd* pWnd = GetDlgItem(IDC_QUERY_SRC_PROV))
  280. pWnd->EnableWindow(m_bCkQueriedObject);
  281. }