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.

975 lines
31 KiB

  1. /*++
  2. 1998 Seagate Software, Inc. All rights reserved.
  3. Module Name:
  4. PrCar.cpp
  5. Abstract:
  6. Cartridge Property Pages.
  7. Author:
  8. Rohde Wakefield [rohde] 15-Sep-1997
  9. Revision History:
  10. --*/
  11. #include "stdafx.h"
  12. #include "metalib.h"
  13. #include "PrCar.h"
  14. #include "ca.h"
  15. static void RsAddDisabledText( CString & StatusString, BOOL Disabled )
  16. {
  17. if( Disabled ) {
  18. CString disabledText;
  19. CString tempText;
  20. disabledText.LoadString( IDS_RECREATE_LOCATION_DISABLED );
  21. AfxFormatString2( tempText, IDS_RECREATE_STATUS_FORMAT, StatusString, disabledText );
  22. StatusString = tempText;
  23. }
  24. }
  25. static DWORD pStatusHelpIds[] =
  26. {
  27. IDC_NAME, idh_media_master_name,
  28. IDC_NAME_LABEL, idh_media_master_name,
  29. IDC_STATUS, idh_media_master_status,
  30. IDC_STATUS_LABEL, idh_media_master_status,
  31. IDC_CAPACITY, idh_media_master_capacity,
  32. IDC_CAPACITY_LABEL, idh_media_master_capacity,
  33. IDC_FREESPACE, idh_media_master_free_space,
  34. IDC_FREESPACE_LABEL, idh_media_master_free_space,
  35. IDC_MODIFIED, idh_media_master_last_modified,
  36. IDC_MODIFIED_LABEL, idh_media_master_last_modified,
  37. IDC_STATUS_1, idh_media_copy1_status,
  38. IDC_COPY_1, idh_media_copy1_status,
  39. IDC_STATUS_2, idh_media_copy2_status,
  40. IDC_COPY_2, idh_media_copy2_status,
  41. IDC_STATUS_3, idh_media_copy3_status,
  42. IDC_COPY_3, idh_media_copy3_status,
  43. 0, 0
  44. };
  45. static DWORD pCopiesHelpIds[] =
  46. {
  47. IDC_MODIFIED, idh_media_master_last_modified,
  48. IDC_MODIFIED_LABEL, idh_media_master_last_modified,
  49. IDC_NAME_1_LABEL, idh_media_copy1_name,
  50. IDC_NAME_1, idh_media_copy1_name,
  51. IDC_NAME_2_LABEL, idh_media_copy2_name,
  52. IDC_NAME_2, idh_media_copy2_name,
  53. IDC_NAME_3_LABEL, idh_media_copy3_name,
  54. IDC_NAME_3, idh_media_copy3_name,
  55. IDC_STATUS_1, idh_media_copy1_status,
  56. IDC_STATUS_1_LABEL, idh_media_copy1_status,
  57. IDC_STATUS_2, idh_media_copy2_status,
  58. IDC_STATUS_2_LABEL, idh_media_copy2_status,
  59. IDC_STATUS_3, idh_media_copy3_status,
  60. IDC_STATUS_3_LABEL, idh_media_copy3_status,
  61. IDC_DELETE_1, idh_media_copy1_delete_button,
  62. IDC_DELETE_2, idh_media_copy2_delete_button,
  63. IDC_DELETE_3, idh_media_copy3_delete_button,
  64. IDC_MODIFIED_1, idh_media_copy1_last_modified,
  65. IDC_MODIFIED_1_LABEL, idh_media_copy1_last_modified,
  66. IDC_MODIFIED_2, idh_media_copy2_last_modified,
  67. IDC_MODIFIED_2_LABEL, idh_media_copy2_last_modified,
  68. IDC_MODIFIED_3, idh_media_copy3_last_modified,
  69. IDC_MODIFIED_3_LABEL, idh_media_copy3_last_modified,
  70. 0, 0
  71. };
  72. static DWORD pRecoverHelpIds[] =
  73. {
  74. IDC_RECREATE_MASTER, idh_media_recreate_master_button,
  75. 0, 0
  76. };
  77. /////////////////////////////////////////////////////////////////////////////
  78. // CPropCartStatus property page
  79. CPropCartStatus::CPropCartStatus( long resourceId ) : CSakPropertyPage( resourceId )
  80. {
  81. //{{AFX_DATA_INIT(CPropCartStatus)
  82. //}}AFX_DATA_INIT
  83. m_pHelpIds = pStatusHelpIds;
  84. m_DlgID = resourceId;
  85. }
  86. CPropCartStatus::~CPropCartStatus()
  87. {
  88. }
  89. void CPropCartStatus::DoDataExchange(CDataExchange* pDX)
  90. {
  91. CSakPropertyPage::DoDataExchange(pDX );
  92. //{{AFX_DATA_MAP(CPropCartStatus)
  93. //}}AFX_DATA_MAP
  94. if( IDD_PROP_CAR_STATUS == m_DlgID ) {
  95. DDX_Control(pDX, IDC_DESCRIPTION, m_Description);
  96. DDX_Control(pDX, IDC_NAME, m_Name);
  97. }
  98. }
  99. BEGIN_MESSAGE_MAP(CPropCartStatus, CSakPropertyPage)
  100. //{{AFX_MSG_MAP(CPropCartStatus)
  101. //}}AFX_MSG_MAP
  102. END_MESSAGE_MAP()
  103. /////////////////////////////////////////////////////////////////////////////
  104. // CPropCartStatus message handlers
  105. typedef struct {
  106. int label, status;
  107. } CONTROL_SET_GENERAL;
  108. CONTROL_SET_GENERAL copyGeneral[] = {
  109. { IDC_COPY_1, IDC_STATUS_1 },
  110. { IDC_COPY_2, IDC_STATUS_2 },
  111. { IDC_COPY_3, IDC_STATUS_3 }
  112. };
  113. BOOL CPropCartStatus::OnInitDialog( )
  114. {
  115. WsbTraceIn( L"CPropCartStatus::OnInitDialog", L"" );
  116. HRESULT hr = S_OK;
  117. CSakPropertyPage::OnInitDialog( );
  118. try {
  119. //
  120. // Get the Hsm Server
  121. //
  122. WsbAffirmHr( m_pParent->GetHsmServer( &m_pHsmServer ) );
  123. //
  124. // Get the Rms Server
  125. //
  126. WsbAffirmHr( ( (CUiCarSheet *)m_pParent )->GetRmsServer( &m_pRmsServer ) );
  127. //
  128. // Set multi-select boolean
  129. //
  130. m_bMultiSelect = ( m_pParent->IsMultiSelect() == S_OK );
  131. Refresh();
  132. } WsbCatch( hr );
  133. WsbTraceOut( L"CPropCartStatus::OnInitDialog", L"hr = <%ls>", WsbHrAsString( hr ) );
  134. return( TRUE );
  135. }
  136. HRESULT CPropCartStatus::Refresh ()
  137. {
  138. WsbTraceIn( L"CPropCartStatus::Refresh", L"" );
  139. GUID mediaId;
  140. USHORT status;
  141. CString statusString;
  142. CMediaInfoObject mio;
  143. CString sText;
  144. HRESULT hr = S_OK;
  145. AFX_MANAGE_STATE( AfxGetStaticModuleState() );
  146. try {
  147. //
  148. // If refresh is called and the node is not initialized, do nothing
  149. //
  150. if( m_pHsmServer ) {
  151. //
  152. // Get the number of media copies from the sheet object
  153. //
  154. WsbAffirmHr( ( (CUiCarSheet *)m_pParent )->GetNumMediaCopies( &m_NumMediaCopies ) );
  155. if( !m_bMultiSelect ) {
  156. //
  157. // SINGLE SELECT
  158. //
  159. //
  160. // Get media info
  161. //
  162. ( (CUiCarSheet *)m_pParent )->GetMediaId( &mediaId );
  163. mio.Initialize( mediaId, m_pHsmServer, m_pRmsServer );
  164. //
  165. // Get info and set controls
  166. //
  167. SetDlgItemText( IDC_DESCRIPTION, mio.m_MasterDescription );
  168. SetDlgItemText( IDC_NAME, mio.m_MasterName );
  169. status = RsGetCartStatus( mio.m_LastHr, mio.m_ReadOnly, mio.m_Recreating, mio.m_NextDataSet, mio.m_LastGoodNextDataSet );
  170. WsbAffirmHr( RsGetCartStatusString( status, statusString ) );
  171. RsAddDisabledText( statusString, mio.m_Disabled );
  172. SetDlgItemText( IDC_STATUS, statusString );
  173. //
  174. // Show capacity statistics
  175. //
  176. WsbAffirmHr( RsGuiFormatLongLong4Char( mio.m_Capacity, sText ) );
  177. SetDlgItemText( IDC_CAPACITY, sText );
  178. WsbAffirmHr( RsGuiFormatLongLong4Char( mio.m_FreeSpace, sText ) );
  179. SetDlgItemText( IDC_FREESPACE, sText );
  180. CTime time( mio.m_Modify );
  181. SetDlgItemText( IDC_MODIFIED, time.Format( L"%#c" ) );
  182. for( int index = 0; index < HSMADMIN_MAX_COPY_SETS; index++ ) {
  183. GetDlgItem( copyGeneral[index].label )->EnableWindow( index < m_NumMediaCopies );
  184. GetDlgItem( copyGeneral[index].status )->EnableWindow( index < m_NumMediaCopies );
  185. status = RsGetCopyStatus( mio.m_CopyInfo[index].m_RmsId, mio.m_CopyInfo[index].m_Hr, mio.m_CopyInfo[index].m_NextDataSet, mio.m_LastGoodNextDataSet );
  186. WsbAffirmHr( RsGetCopyStatusString( status, statusString ) );
  187. RsAddDisabledText( statusString, mio.m_CopyInfo[index].m_Disabled );
  188. SetDlgItemText( copyGeneral[index].status, statusString );
  189. }
  190. } else {
  191. //
  192. // Multi-Select
  193. //
  194. GUID mediaId;
  195. LONGLONG totalCapacity = 0;
  196. LONGLONG totalFreeSpace = 0;
  197. USHORT statusCartRecreate = 0;
  198. USHORT statusCartReadOnly = 0;
  199. USHORT statusCartNormal = 0;
  200. USHORT statusCartRO = 0;
  201. USHORT statusCartRW = 0;
  202. USHORT statusCartMissing = 0;
  203. USHORT statusCopyNone[ HSMADMIN_MAX_COPY_SETS ];
  204. USHORT statusCopyError[ HSMADMIN_MAX_COPY_SETS ];
  205. USHORT statusCopyMissing[ HSMADMIN_MAX_COPY_SETS ];
  206. USHORT statusCopyOutSync[ HSMADMIN_MAX_COPY_SETS ];
  207. USHORT statusCopyInSync[ HSMADMIN_MAX_COPY_SETS ];
  208. //
  209. // initialize copy totals
  210. //
  211. for( int i = 0; i < HSMADMIN_MAX_COPY_SETS; i++ ) {
  212. statusCopyNone[i] = 0;
  213. statusCopyError[i] = 0;
  214. statusCopyOutSync[i] = 0;
  215. statusCopyInSync[i] = 0;
  216. }
  217. int bookMark = 0;
  218. int numMedia = 0;
  219. while( m_pParent->GetNextObjectId( &bookMark, &mediaId ) == S_OK ) {
  220. numMedia++;
  221. mio.Initialize( mediaId, m_pHsmServer, m_pRmsServer );
  222. //
  223. // total up statuses
  224. //
  225. status = RsGetCartStatus( mio.m_LastHr, mio.m_ReadOnly, mio.m_Recreating, mio.m_NextDataSet, mio.m_LastGoodNextDataSet );
  226. switch( status ) {
  227. case RS_MEDIA_STATUS_RECREATE:
  228. statusCartRecreate++;
  229. break;
  230. case RS_MEDIA_STATUS_READONLY:
  231. statusCartReadOnly++;
  232. break;
  233. case RS_MEDIA_STATUS_NORMAL:
  234. statusCartNormal++;
  235. break;
  236. case RS_MEDIA_STATUS_ERROR_RO:
  237. statusCartRO++;
  238. break;
  239. case RS_MEDIA_STATUS_ERROR_RW:
  240. statusCartRW++;
  241. break;
  242. case RS_MEDIA_STATUS_ERROR_MISSING:
  243. statusCartMissing++;
  244. break;
  245. }
  246. for( int index = 0; index < HSMADMIN_MAX_COPY_SETS; index++ ) {
  247. int status = RsGetCopyStatus( mio.m_CopyInfo[index].m_RmsId, mio.m_CopyInfo[index].m_Hr, mio.m_CopyInfo[index].m_NextDataSet, mio.m_LastGoodNextDataSet );
  248. //
  249. // Total up the statuses
  250. //
  251. switch( status ) {
  252. case RS_MEDIA_COPY_STATUS_NONE:
  253. statusCopyNone[index]++;
  254. break;
  255. case RS_MEDIA_COPY_STATUS_ERROR:
  256. statusCopyError[index]++;
  257. break;
  258. case RS_MEDIA_COPY_STATUS_MISSING:
  259. statusCopyMissing[index]++;
  260. break;
  261. case RS_MEDIA_COPY_STATUS_OUTSYNC:
  262. statusCopyOutSync[index]++;
  263. break;
  264. case RS_MEDIA_COPY_STATUS_INSYNC:
  265. statusCopyInSync[index]++;
  266. break;
  267. }
  268. }
  269. totalCapacity += mio.m_Capacity;
  270. totalFreeSpace += mio.m_FreeSpace;
  271. } // While
  272. //
  273. // Display number of media selected
  274. //
  275. sText.Format( IDS_MEDIA, numMedia );
  276. SetDlgItemText( IDC_DESCRIPTION_MULTI, sText );
  277. //
  278. // Show the accumulated statistics
  279. //
  280. CString sText;
  281. WsbAffirmHr( RsGuiFormatLongLong4Char( totalCapacity, sText ) );
  282. SetDlgItemText( IDC_CAPACITY, sText );
  283. WsbAffirmHr( RsGuiFormatLongLong4Char( totalFreeSpace, sText ) );
  284. SetDlgItemText( IDC_FREESPACE, sText );
  285. //
  286. // Show the accumulated cart statuses
  287. //
  288. RsGetCartMultiStatusString( statusCartRecreate, statusCartReadOnly,
  289. statusCartNormal, statusCartRO, statusCartRW, statusCartMissing,
  290. statusString );
  291. SetDlgItemText( IDC_STATUS, statusString );
  292. for( i = 0; i < HSMADMIN_MAX_COPY_SETS; i++ ) {
  293. WsbAffirmHr( RsGetCopyMultiStatusString( statusCopyNone[i],
  294. statusCopyError[i], statusCopyOutSync[i], statusCopyInSync[i], statusString ) );
  295. SetDlgItemText( copyGeneral[i].status, statusString );
  296. GetDlgItem( copyGeneral[i].label )->EnableWindow( i < m_NumMediaCopies );
  297. GetDlgItem( copyGeneral[i].status )->EnableWindow( i < m_NumMediaCopies );
  298. } // for
  299. }
  300. }
  301. } WsbCatch( hr );
  302. WsbTraceOut( L"CPropCartStatus::Refresh", L"hr = <%ls>", WsbHrAsString( hr ) );
  303. return( hr );
  304. }
  305. BOOL CPropCartStatus::OnApply( )
  306. {
  307. WsbTraceIn( L"CPropCartStatus::OnApply", L"" );
  308. BOOL retVal = CSakPropertyPage::OnApply( );
  309. WsbTraceOut( L"CPropCartStatus::OnApply", L"" );
  310. return( retVal );
  311. }
  312. /////////////////////////////////////////////////////////////////////////////
  313. // CPropCartCopies property page
  314. CPropCartCopies::CPropCartCopies( long resourceId ) : CSakPropertyPage( resourceId )
  315. {
  316. //{{AFX_DATA_INIT(CPropCartCopies)
  317. // NOTE: the ClassWizard will add member initialization here
  318. //}}AFX_DATA_INIT
  319. m_pHelpIds = pCopiesHelpIds;
  320. m_DlgID = resourceId;
  321. }
  322. CPropCartCopies::~CPropCartCopies()
  323. {
  324. }
  325. void CPropCartCopies::DoDataExchange(CDataExchange* pDX)
  326. {
  327. CSakPropertyPage::DoDataExchange(pDX);
  328. //{{AFX_DATA_MAP(CPropCartCopies)
  329. //}}AFX_DATA_MAP
  330. if( IDD_PROP_CAR_COPIES == m_DlgID ) {
  331. DDX_Control(pDX, IDC_NAME_3, m_Name3);
  332. DDX_Control(pDX, IDC_NAME_2, m_Name2);
  333. DDX_Control(pDX, IDC_NAME_1, m_Name1);
  334. DDX_Control(pDX, IDC_STATUS_3, m_Status3);
  335. DDX_Control(pDX, IDC_STATUS_2, m_Status2);
  336. DDX_Control(pDX, IDC_STATUS_1, m_Status1);
  337. }
  338. }
  339. BEGIN_MESSAGE_MAP(CPropCartCopies, CSakPropertyPage)
  340. //{{AFX_MSG_MAP(CPropCartCopies)
  341. ON_BN_CLICKED(IDC_DELETE_1, OnDelete1)
  342. ON_BN_CLICKED(IDC_DELETE_2, OnDelete2)
  343. ON_BN_CLICKED(IDC_DELETE_3, OnDelete3)
  344. //}}AFX_MSG_MAP
  345. END_MESSAGE_MAP()
  346. /////////////////////////////////////////////////////////////////////////////
  347. // CPropCartCopies message handlers
  348. typedef struct {
  349. int group,
  350. nameLabel,
  351. name,
  352. statusLabel,
  353. status,
  354. modifyLabel,
  355. modify,
  356. deleteCopy;
  357. } CONTROL_SET_COPIES;
  358. CONTROL_SET_COPIES copyCopies[] = {
  359. { IDC_COPY_1, IDC_NAME_1_LABEL, IDC_NAME_1, IDC_STATUS_1_LABEL, IDC_STATUS_1, IDC_MODIFIED_1_LABEL, IDC_MODIFIED_1, IDC_DELETE_1 },
  360. { IDC_COPY_2, IDC_NAME_2_LABEL, IDC_NAME_2, IDC_STATUS_2_LABEL, IDC_STATUS_2, IDC_MODIFIED_2_LABEL, IDC_MODIFIED_2, IDC_DELETE_2 },
  361. { IDC_COPY_3, IDC_NAME_3_LABEL, IDC_NAME_3, IDC_STATUS_3_LABEL, IDC_STATUS_3, IDC_MODIFIED_3_LABEL, IDC_MODIFIED_3, IDC_DELETE_3 }
  362. };
  363. BOOL CPropCartCopies::OnInitDialog()
  364. {
  365. WsbTraceIn( L"CPropCartCopies::OnInitDialog", L"" );
  366. HRESULT hr = S_OK;
  367. CSakPropertyPage::OnInitDialog( );
  368. AFX_MANAGE_STATE( AfxGetStaticModuleState() );
  369. try {
  370. //
  371. // Get the Hsm Server
  372. //
  373. WsbAffirmHr( m_pParent->GetHsmServer( &m_pHsmServer ) );
  374. //
  375. // Get the Rms Server
  376. //
  377. WsbAffirmHr( ( (CUiCarSheet* ) m_pParent )->GetRmsServer( &m_pRmsServer ) );
  378. //
  379. // Set multi-select boolean
  380. //
  381. m_bMultiSelect = ( m_pParent->IsMultiSelect() == S_OK );
  382. Refresh();
  383. } WsbCatch( hr );
  384. WsbTraceOut( L"CPropCartCopies::OnInitDialog", L"hr = <%ls>", WsbHrAsString( hr ) );
  385. return( TRUE );
  386. }
  387. HRESULT CPropCartCopies::Refresh( )
  388. {
  389. WsbTraceIn( L"CPropCartCopies::Refresh", L"" );
  390. HRESULT hr = S_OK;
  391. GUID mediaId;
  392. CMediaInfoObject mio;
  393. try {
  394. //
  395. // Only refresh if we've been intialized
  396. //
  397. if( m_pHsmServer ) {
  398. //
  399. // Get the number of media copies from the sheet object
  400. //
  401. WsbAffirmHr( ( (CUiCarSheet *)m_pParent )->GetNumMediaCopies( &m_NumMediaCopies ) );
  402. if( !m_bMultiSelect ) {
  403. //
  404. // SINGLE SELECT
  405. //
  406. //
  407. // Get the media Id and initialize the info object
  408. //
  409. ( (CUiCarSheet *)m_pParent )->GetMediaId( &mediaId );
  410. mio.Initialize( mediaId, m_pHsmServer, m_pRmsServer );
  411. //
  412. // Get info and set controls
  413. //
  414. CTime time( mio.m_Modify );
  415. SetDlgItemText( IDC_MODIFIED, time.Format( L"%#c" ) );
  416. //
  417. // Disable the controls for displaying info on non-existant
  418. // Copies. Fill in the info for copies that exist.
  419. //
  420. for( int index = 0; index < HSMADMIN_MAX_COPY_SETS; index++ ) {
  421. BOOL mediaMissing = IsEqualGUID( mio.m_CopyInfo[index].m_RmsId, GUID_NULL );
  422. GetDlgItem( copyCopies[index].group )->EnableWindow( index < m_NumMediaCopies );
  423. GetDlgItem( copyCopies[index].nameLabel )->EnableWindow( index < m_NumMediaCopies );
  424. GetDlgItem( copyCopies[index].name )->EnableWindow( index < m_NumMediaCopies );
  425. GetDlgItem( copyCopies[index].statusLabel )->EnableWindow( index < m_NumMediaCopies );
  426. GetDlgItem( copyCopies[index].status )->EnableWindow( index < m_NumMediaCopies );
  427. GetDlgItem( copyCopies[index].modifyLabel )->EnableWindow( index < m_NumMediaCopies );
  428. GetDlgItem( copyCopies[index].modify )->EnableWindow( index < m_NumMediaCopies );
  429. GetDlgItem( copyCopies[index].deleteCopy )->EnableWindow( ! mediaMissing );
  430. SetDlgItemText( copyCopies[index].name, L"" );
  431. SetDlgItemText( copyCopies[index].status, L"" );
  432. SetDlgItemText( copyCopies[index].modify, L"" );
  433. USHORT status;
  434. CString statusString;
  435. status = RsGetCopyStatus( mio.m_CopyInfo[index].m_RmsId, mio.m_CopyInfo[index].m_Hr, mio.m_CopyInfo[index].m_NextDataSet, mio.m_LastGoodNextDataSet );
  436. WsbAffirmHr( RsGetCopyStatusString( status, statusString ) );
  437. RsAddDisabledText( statusString, mio.m_CopyInfo[index].m_Disabled );
  438. SetDlgItemText( copyCopies[index].status, statusString );
  439. if( !mediaMissing ) {
  440. time = mio.m_CopyInfo[index].m_ModifyTime;
  441. SetDlgItemText( copyCopies[index].modify, time.Format( L"%#c" ) );
  442. CComPtr<IRmsCartridge> pCart;
  443. CWsbBstrPtr name;
  444. if( SUCCEEDED( m_pRmsServer->FindCartridgeById( mio.m_CopyInfo[index].m_RmsId, &pCart ) ) ) {
  445. WsbAffirmHr( pCart->GetName( &name ) );
  446. }
  447. SetDlgItemText( copyCopies[index].name, name );
  448. }
  449. }
  450. } else {
  451. //
  452. // MULTI-SELECT
  453. //
  454. BOOL bGotOne [HSMADMIN_MAX_COPY_SETS];
  455. int bookMark = 0;
  456. USHORT statusCopyNone [HSMADMIN_MAX_COPY_SETS];
  457. USHORT statusCopyError [HSMADMIN_MAX_COPY_SETS];
  458. USHORT statusCopyMissing [HSMADMIN_MAX_COPY_SETS];
  459. USHORT statusCopyOutSync [HSMADMIN_MAX_COPY_SETS];
  460. USHORT statusCopyInSync [HSMADMIN_MAX_COPY_SETS];
  461. //
  462. // initialize copy totals
  463. //
  464. for( int i = 0; i < HSMADMIN_MAX_COPY_SETS; i++ ) {
  465. statusCopyNone[i] = 0;
  466. statusCopyError[i] = 0;
  467. statusCopyOutSync[i] = 0;
  468. statusCopyInSync[i] = 0;
  469. bGotOne[i] = FALSE;
  470. }
  471. //
  472. // For each selected medium...
  473. //
  474. while( m_pParent->GetNextObjectId( &bookMark, &mediaId ) == S_OK ) {
  475. mio.Initialize( mediaId, m_pHsmServer, m_pRmsServer );
  476. //
  477. // Tally up the statuses for all valid copy sets
  478. //
  479. for( int index = 0; index < HSMADMIN_MAX_COPY_SETS; index++ ) {
  480. //
  481. // Is there is at least one valid copy in this copyset
  482. // for any of the selected media?
  483. //
  484. if( ! IsEqualGUID( mio.m_CopyInfo[index].m_RmsId, GUID_NULL ) ) {
  485. bGotOne[index] = TRUE;
  486. }
  487. USHORT status;
  488. CString statusString;
  489. status = RsGetCopyStatus( mio.m_CopyInfo[index].m_RmsId, mio.m_CopyInfo[index].m_Hr, mio.m_CopyInfo[index].m_NextDataSet, mio.m_LastGoodNextDataSet );
  490. // Total up the statuses
  491. switch( status ) {
  492. case RS_MEDIA_COPY_STATUS_NONE:
  493. statusCopyNone[index]++;
  494. break;
  495. case RS_MEDIA_COPY_STATUS_ERROR:
  496. statusCopyError[index]++;
  497. break;
  498. case RS_MEDIA_COPY_STATUS_MISSING:
  499. statusCopyMissing[index]++;
  500. break;
  501. case RS_MEDIA_COPY_STATUS_OUTSYNC:
  502. statusCopyOutSync[index]++;
  503. break;
  504. case RS_MEDIA_COPY_STATUS_INSYNC:
  505. statusCopyInSync[index]++;
  506. break;
  507. }
  508. }
  509. } // while
  510. //
  511. // Show accumlated statuses for each valid copy set
  512. //
  513. CString statusString;
  514. for( i = 0; i < HSMADMIN_MAX_COPY_SETS; i++ ) {
  515. WsbAffirmHr( RsGetCopyMultiStatusString( statusCopyNone[i],
  516. statusCopyError[i], statusCopyOutSync[i], statusCopyInSync[i], statusString ) );
  517. SetDlgItemText( copyCopies[i].status, statusString );
  518. }
  519. //
  520. // Set control states
  521. //
  522. for( i = 0; i < HSMADMIN_MAX_COPY_SETS; i++ ) {
  523. GetDlgItem( copyCopies[i].group )->EnableWindow( i < m_NumMediaCopies );
  524. GetDlgItem( copyCopies[i].statusLabel )->EnableWindow( i < m_NumMediaCopies );
  525. GetDlgItem( copyCopies[i].status )->EnableWindow( i < m_NumMediaCopies );
  526. GetDlgItem( copyCopies[i].deleteCopy )->EnableWindow( bGotOne[i] );
  527. }
  528. }
  529. }
  530. } WsbCatch( hr );
  531. WsbTraceOut( L"CPropCartCopies::Refresh", L"hr = <%ls>", WsbHrAsString( hr ) );
  532. return( hr );
  533. }
  534. void CPropCartCopies::OnDelete1()
  535. {
  536. OnDelete( 1 );
  537. }
  538. void CPropCartCopies::OnDelete2()
  539. {
  540. OnDelete( 2 );
  541. }
  542. void CPropCartCopies::OnDelete3()
  543. {
  544. OnDelete( 3 );
  545. }
  546. void CPropCartCopies::OnDelete( int Copy )
  547. {
  548. WsbTraceIn( L"CPropCartCopies::OnDelete", L"Copy = <%d>", Copy );
  549. HRESULT hr = S_OK;
  550. CMediaInfoObject mio;
  551. GUID mediaId;
  552. try {
  553. if( !m_bMultiSelect ) {
  554. //
  555. // Single Select
  556. //
  557. CString confirm;
  558. //
  559. // Get the media Id and initialize the info object
  560. //
  561. ( (CUiCarSheet *)m_pParent )->GetMediaId( &mediaId );
  562. mio.Initialize( mediaId, m_pHsmServer, m_pRmsServer );
  563. confirm.Format( IDS_CONFIRM_MEDIA_COPY_DELETE, Copy, mio.m_Description );
  564. if( IDYES == AfxMessageBox( confirm, MB_ICONEXCLAMATION | MB_YESNO | MB_DEFBUTTON2 ) ) {
  565. WsbAffirmHr( mio.DeleteCopy( Copy ) );
  566. }
  567. } else {
  568. //
  569. // Multi-Select
  570. // tally up the names of the selected media
  571. //
  572. int bookMark = 0;
  573. GUID mediaId;
  574. CString szMediaList = L"";
  575. BOOL bFirst = TRUE;
  576. while( m_pParent->GetNextObjectId( &bookMark, &mediaId ) == S_OK ) {
  577. mio.Initialize( mediaId, m_pHsmServer, m_pRmsServer );
  578. //
  579. // Does the copy exist?
  580. //
  581. if( !IsEqualGUID( mio.m_CopyInfo[Copy - 1].m_RmsId, GUID_NULL ) ) {
  582. //
  583. // Put in commas after the first Id
  584. //
  585. if( !bFirst ) {
  586. szMediaList += L", ";
  587. } else {
  588. bFirst = FALSE;
  589. }
  590. szMediaList += mio.m_Description;
  591. }
  592. }
  593. CString confirm;
  594. confirm.Format( IDS_CONFIRM_MEDIA_COPY_DELETE_MULTI, Copy, szMediaList );
  595. if( IDYES == AfxMessageBox( confirm, MB_ICONEXCLAMATION | MB_YESNO | MB_DEFBUTTON2 ) ) {
  596. bookMark = 0;
  597. while( m_pParent->GetNextObjectId( &bookMark, &mediaId ) == S_OK ) {
  598. WsbAffirmHr( mio.Initialize( mediaId, m_pHsmServer, m_pRmsServer ) );
  599. //
  600. // Does the copy exist?
  601. //
  602. if( !IsEqualGUID( mio.m_CopyInfo[Copy - 1].m_RmsId, GUID_NULL ) ) {
  603. WsbAffirmHr( mio.DeleteCopy( Copy ) );
  604. }
  605. }
  606. }
  607. }
  608. //
  609. // Now notify all the nodes
  610. //
  611. ( (CUiCarSheet *) m_pParent )-> OnPropertyChange( m_hConsoleHandle );
  612. } WsbCatch( hr );
  613. WsbTraceOut( L"CPropCartCopies::OnDelete", L"hr = <%ls>", WsbHrAsString( hr ) );
  614. }
  615. /////////////////////////////////////////////////////////////////////////////
  616. // CPropCartRecover property page
  617. CPropCartRecover::CPropCartRecover() : CSakPropertyPage(CPropCartRecover::IDD)
  618. {
  619. //{{AFX_DATA_INIT(CPropCartRecover)
  620. // NOTE: the ClassWizard will add member initialization here
  621. //}}AFX_DATA_INIT
  622. m_pHelpIds = pRecoverHelpIds;
  623. }
  624. CPropCartRecover::~CPropCartRecover()
  625. {
  626. }
  627. void CPropCartRecover::DoDataExchange(CDataExchange* pDX)
  628. {
  629. CSakPropertyPage::DoDataExchange(pDX);
  630. //{{AFX_DATA_MAP(CPropCartRecover)
  631. // NOTE: the ClassWizard will add DDX and DDV calls here
  632. //}}AFX_DATA_MAP
  633. }
  634. BEGIN_MESSAGE_MAP(CPropCartRecover, CSakPropertyPage)
  635. //{{AFX_MSG_MAP(CPropCartRecover)
  636. ON_BN_CLICKED(IDC_RECREATE_MASTER, OnRecreateMaster)
  637. //}}AFX_MSG_MAP
  638. END_MESSAGE_MAP()
  639. void CPropCartRecover::OnRecreateMaster()
  640. {
  641. WsbTraceIn( L"CPropCartRecover::OnRecreateMaster", L"" );
  642. HRESULT hr = S_OK;
  643. CMediaInfoObject mio;
  644. GUID mediaId;
  645. try {
  646. //
  647. // For single select only!
  648. //
  649. WsbAssert( !m_bMultiSelect, E_FAIL );
  650. //
  651. // Get the media Id and initialize the info object
  652. //
  653. ( (CUiCarSheet *)m_pParent )->GetMediaId( &mediaId );
  654. mio.Initialize( mediaId, m_pHsmServer, m_pRmsServer );
  655. WsbAffirmHr( mio.RecreateMaster() );
  656. //
  657. // Now notify all the nodes
  658. //
  659. ( (CUiCarSheet *) m_pParent )->OnPropertyChange( m_hConsoleHandle );
  660. } WsbCatch( hr );
  661. WsbTraceOut( L"CPropCartRecover::OnRecreateMaster", L"hr = <%ls>", WsbHrAsString( hr ) );
  662. }
  663. /////////////////////////////////////////////////////////////////////////////
  664. // CPropCartRecover message handlers
  665. BOOL CPropCartRecover::OnInitDialog()
  666. {
  667. WsbTraceIn( L"CPropCartRecover::OnInitDialog", L"" );
  668. HRESULT hr = S_OK;
  669. CSakPropertyPage::OnInitDialog();
  670. try {
  671. //
  672. // Set multi-select boolean
  673. //
  674. m_bMultiSelect = ( m_pParent->IsMultiSelect() == S_OK );
  675. //
  676. // Get the Hsm Server
  677. //
  678. WsbAffirmHr( m_pParent->GetHsmServer( &m_pHsmServer ) );
  679. //
  680. // Get the Rms Server
  681. //
  682. WsbAffirmHr( ( (CUiCarSheet *) m_pParent )->GetRmsServer( &m_pRmsServer ) );
  683. Refresh( );
  684. } WsbCatch( hr );
  685. WsbTraceOut( L"CPropCartRecover::OnInitDialog", L"hr = <%ls>", WsbHrAsString( hr ) );
  686. return( TRUE );
  687. }
  688. HRESULT CPropCartRecover::Refresh()
  689. {
  690. WsbTraceIn( L"CPropCartRecover::Refresh", L"" );
  691. HRESULT hr = S_OK;
  692. GUID mediaId;
  693. CMediaInfoObject mio;
  694. try {
  695. //
  696. // Only refresh if we've been initialized
  697. //
  698. if( m_pHsmServer ) {
  699. if( ! m_bMultiSelect ) {
  700. //
  701. // Get the number of media copies from the sheet object
  702. //
  703. WsbAffirmHr( ( (CUiCarSheet *) m_pParent )->GetNumMediaCopies( &m_NumMediaCopies ) );
  704. //
  705. // Get the media Id and initialize the info object
  706. //
  707. ( (CUiCarSheet *)m_pParent )->GetMediaId( &mediaId );
  708. mio.Initialize( mediaId, m_pHsmServer, m_pRmsServer );
  709. //
  710. // SINGLE SELECT (this page is implemented for single-select only
  711. //
  712. BOOL enableRecreate = FALSE;
  713. for( int index = 0; index < HSMADMIN_MAX_COPY_SETS; index++ ) {
  714. if( index < m_NumMediaCopies ) {
  715. if( !IsEqualGUID( mio.m_CopyInfo[index].m_RmsId, GUID_NULL ) ) {
  716. enableRecreate = TRUE;
  717. }
  718. } else {
  719. SetDlgItemText( copyGeneral[index].status, L"" );
  720. }
  721. }
  722. GetDlgItem( IDC_RECREATE_MASTER )->EnableWindow( enableRecreate );
  723. }
  724. }
  725. } WsbCatch( hr );
  726. WsbTraceOut( L"CPropCartRecover::Refresh", L"hr = <%ls>", WsbHrAsString( hr ) );
  727. return( hr );
  728. }