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.

857 lines
24 KiB

  1. /*++
  2. 1998 Seagate Software, Inc. All rights reserved.
  3. Module Name:
  4. WzMedSet.cpp
  5. Abstract:
  6. Wizard for Media Set - Copy Set Wizard.
  7. Author:
  8. Rohde Wakefield [rohde] 23-09-1997
  9. Revision History:
  10. --*/
  11. #include "stdafx.h"
  12. #include "MeSe.h"
  13. #include "WzMedSet.h"
  14. /////////////////////////////////////////////////////////////////////////////
  15. // CMediaCopyWizard
  16. CMediaCopyWizard::CMediaCopyWizard()
  17. {
  18. WsbTraceIn( L"CMediaCopyWizard::CMediaCopyWizard", L"" );
  19. m_TitleId = IDS_WIZ_CAR_COPY_TITLE;
  20. m_HeaderId = IDB_MEDIA_SYNC_HEADER;
  21. m_WatermarkId = IDB_MEDIA_SYNC_WATERMARK;
  22. WsbTraceOut( L"CMediaCopyWizard::CMediaCopyWizard", L"" );
  23. }
  24. CMediaCopyWizard::~CMediaCopyWizard()
  25. {
  26. WsbTraceIn( L"CMediaCopyWizard::~CMediaCopyWizard", L"" );
  27. WsbTraceOut( L"CMediaCopyWizard::~CMediaCopyWizard", L"" );
  28. }
  29. STDMETHODIMP
  30. CMediaCopyWizard::AddWizardPages(
  31. IN RS_PCREATE_HANDLE Handle,
  32. IN IUnknown* pCallback,
  33. IN ISakSnapAsk* pSakSnapAsk
  34. )
  35. {
  36. WsbTraceIn( L"CMediaCopyWizard::AddWizardPages", L"" );
  37. HRESULT hr = S_OK;
  38. try {
  39. //
  40. // Initialize the Sheet
  41. //
  42. WsbAffirmHr( InitSheet( Handle, pCallback, 0, pSakSnapAsk, 0, 0 ) );
  43. //
  44. // Get the number of media copies. If 0, we put up the media copies
  45. // page.
  46. //
  47. CComPtr<IHsmServer> pHsmServer;
  48. CComPtr<IHsmStoragePool> pStoragePool;
  49. WsbAffirmHrOk( pSakSnapAsk->GetHsmServer( &pHsmServer ) );
  50. WsbAffirmHr( RsGetStoragePool( pHsmServer, &pStoragePool ) );
  51. WsbAffirmHr( pStoragePool->GetNumMediaCopies( &m_numMediaCopiesOrig ) );
  52. //
  53. // Load pages
  54. //
  55. WsbAffirmHr( AddPage( &m_pageIntro ) );
  56. if ( m_numMediaCopiesOrig == 0 ) {
  57. WsbAffirmHr( AddPage( &m_pageNumCopies ) );
  58. }
  59. WsbAffirmHr( AddPage( &m_pageSelect ) );
  60. WsbAffirmHr( AddPage( &m_pageFinish ) );
  61. } WsbCatch( hr );
  62. WsbTraceOut( L"CMediaCopyWizard::AddWizardPages", L"" );
  63. return( hr );
  64. }
  65. HRESULT CMediaCopyWizard::OnFinish( )
  66. {
  67. WsbTraceIn( L"CMediaCopyWizard::OnFinish", L"" );
  68. //
  69. // The sheet really owns the process as a whole,
  70. // so it will do the final assembly
  71. //
  72. HRESULT hr = S_OK;
  73. HRESULT hrInternal = S_OK;
  74. try {
  75. USHORT numMediaCopies;
  76. CComPtr<IHsmServer> pHsmServer;
  77. CComPtr<IHsmStoragePool> pStoragePool;
  78. WsbAffirmHrOk( GetHsmServer( &pHsmServer ) );
  79. WsbAffirmHr( RsGetStoragePool( pHsmServer, &pStoragePool ) );
  80. //
  81. // If we changed the number of media copies (i.e. it was orignally 0),
  82. // reset it in Engine
  83. //
  84. if( m_numMediaCopiesOrig == 0 ) {
  85. hrInternal = m_pageNumCopies.GetNumMediaCopies( &numMediaCopies );
  86. if( S_OK == hrInternal ) {
  87. WsbAffirmHr( pStoragePool->SetNumMediaCopies( numMediaCopies ) );
  88. WsbAffirmHr( pHsmServer->SavePersistData( ) );
  89. HRESULT hrUpdate = S_OK;
  90. try {
  91. //
  92. // Find the media node - updating the root node is useless
  93. // since we need to change the media node contents.
  94. //
  95. CComPtr<ISakSnapAsk> pAsk;
  96. CComPtr<ISakNode> pNode;
  97. WsbAffirmHr( GetSakSnapAsk( &pAsk ) );
  98. WsbAffirmHr( pAsk->GetNodeOfType( cGuidMedSet, &pNode ) );
  99. //
  100. // Now notify the node
  101. //
  102. OnPropertyChange( m_Handle, pNode );
  103. } WsbCatch( hrUpdate );
  104. }
  105. }
  106. //
  107. // And run the job for the selected copy set
  108. //
  109. INT copyNum = m_pageSelect.m_List.GetSelectedSet( );
  110. WsbAffirmHr( RsCreateAndRunMediaCopyJob( pHsmServer, copyNum, FALSE ) );
  111. } WsbCatch( hr );
  112. m_HrFinish = hr;
  113. WsbTraceOut( L"CMediaCopyWizard::OnFinish", L"hr = <%ls>", WsbHrAsString( hr ) );
  114. return( hr );
  115. }
  116. /////////////////////////////////////////////////////////////////////////////
  117. // CMediaCopyWizardIntro property page
  118. CMediaCopyWizardIntro::CMediaCopyWizardIntro() :
  119. CSakWizardPage_InitBaseExt( WIZ_CAR_COPY_INTRO )
  120. {
  121. WsbTraceIn( L"CMediaCopyWizardIntro::CMediaCopyWizardIntro", L"" );
  122. //{{AFX_DATA_INIT(CMediaCopyWizardIntro)
  123. // NOTE: the ClassWizard will add member initialization here
  124. //}}AFX_DATA_INIT
  125. WsbTraceOut( L"CMediaCopyWizardIntro::CMediaCopyWizardIntro", L"" );
  126. }
  127. CMediaCopyWizardIntro::~CMediaCopyWizardIntro()
  128. {
  129. WsbTraceIn( L"CMediaCopyWizardIntro::~CMediaCopyWizardIntro", L"" );
  130. WsbTraceOut( L"CMediaCopyWizardIntro::~CMediaCopyWizardIntro", L"" );
  131. }
  132. void CMediaCopyWizardIntro::DoDataExchange(CDataExchange* pDX)
  133. {
  134. WsbTraceIn( L"CMediaCopyWizardIntro::DoDataExchange", L"" );
  135. CSakWizardPage::DoDataExchange(pDX );
  136. //{{AFX_DATA_MAP(CMediaCopyWizardIntro)
  137. // NOTE: the ClassWizard will add DDX and DDV calls here
  138. //}}AFX_DATA_MAP
  139. WsbTraceOut( L"CMediaCopyWizardIntro::DoDataExchange", L"" );
  140. }
  141. BEGIN_MESSAGE_MAP(CMediaCopyWizardIntro, CSakWizardPage)
  142. //{{AFX_MSG_MAP(CMediaCopyWizardIntro)
  143. //}}AFX_MSG_MAP
  144. END_MESSAGE_MAP()
  145. /////////////////////////////////////////////////////////////////////////////
  146. // CMediaCopyWizardIntro message handlers
  147. BOOL CMediaCopyWizardIntro::OnInitDialog( )
  148. {
  149. WsbTraceIn( L"CMediaCopyWizardIntro::OnInitDialog", L"" );
  150. CSakWizardPage::OnInitDialog( );
  151. WsbTraceOut( L"CMediaCopyWizardIntro::OnInitDialog", L"" );
  152. return TRUE;
  153. }
  154. BOOL CMediaCopyWizardIntro::OnSetActive( )
  155. {
  156. WsbTraceIn( L"CMediaCopyWizardIntro::OnSetActive", L"" );
  157. m_pSheet->SetWizardButtons( PSWIZB_NEXT );
  158. BOOL retval = CSakWizardPage::OnSetActive( );
  159. WsbTraceOut( L"CMediaCopyWizardIntro::OnSetActive", L"" );
  160. return( retval );
  161. }
  162. /////////////////////////////////////////////////////////////////////////////
  163. // CMediaCopyWizardSelect property page
  164. CMediaCopyWizardSelect::CMediaCopyWizardSelect():
  165. CSakWizardPage_InitBaseInt( WIZ_CAR_COPY_SELECT ),
  166. m_List( this )
  167. {
  168. WsbTraceIn( L"CMediaCopyWizardSelect::CMediaCopyWizardSelect", L"" );
  169. //{{AFX_DATA_INIT(CMediaCopyWizardSelect)
  170. // NOTE: the ClassWizard will add member initialization here
  171. //}}AFX_DATA_INIT
  172. WsbTraceOut( L"CMediaCopyWizardSelect::CMediaCopyWizardSelect", L"" );
  173. }
  174. CMediaCopyWizardSelect::~CMediaCopyWizardSelect()
  175. {
  176. WsbTraceIn( L"CMediaCopyWizardSelect::~CMediaCopyWizardSelect", L"" );
  177. WsbTraceOut( L"CMediaCopyWizardSelect::~CMediaCopyWizardSelect", L"" );
  178. }
  179. void CMediaCopyWizardSelect::DoDataExchange(CDataExchange* pDX)
  180. {
  181. WsbTraceIn( L"CMediaCopyWizardSelect::DoDataExchange", L"" );
  182. CSakWizardPage::DoDataExchange(pDX );
  183. //{{AFX_DATA_MAP(CMediaCopyWizardSelect)
  184. DDX_Control(pDX, IDC_COPY_LIST, m_List);
  185. //}}AFX_DATA_MAP
  186. WsbTraceOut( L"CMediaCopyWizardSelect::DoDataExchange", L"" );
  187. }
  188. BEGIN_MESSAGE_MAP(CMediaCopyWizardSelect, CSakWizardPage)
  189. //{{AFX_MSG_MAP(CMediaCopyWizardSelect)
  190. ON_CBN_SELCHANGE(IDC_COPY_LIST, OnSelchangeCopyList)
  191. //}}AFX_MSG_MAP
  192. END_MESSAGE_MAP()
  193. /////////////////////////////////////////////////////////////////////////////
  194. // CMediaCopyWizardSelect message handlers
  195. BOOL CMediaCopyWizardSelect::OnInitDialog( )
  196. {
  197. WsbTraceIn( L"CMediaCopyWizardSelect::OnInitDialog", L"" );
  198. CSakWizardPage::OnInitDialog( );
  199. WsbTraceOut( L"CMediaCopyWizardSelect::OnInitDialog", L"" );
  200. return TRUE;
  201. }
  202. BOOL CMediaCopyWizardSelect::OnSetActive( )
  203. {
  204. WsbTraceIn( L"CMediaCopyWizardSelect::OnSetActive", L"" );
  205. m_List.UpdateView( );
  206. SetButtons( );
  207. BOOL retval = CSakWizardPage::OnSetActive( );
  208. WsbTraceOut( L"CMediaCopyWizardSelect::OnSetActive", L"" );
  209. return( retval );
  210. }
  211. void
  212. CMediaCopyWizardSelect::SetButtons()
  213. {
  214. WsbTraceIn( L"CMediaCopyWizardSelect::SetButtons", L"" );
  215. INT curSel = m_List.GetSelectedSet( );
  216. if( curSel > 0 ) {
  217. m_pSheet->SetWizardButtons( PSWIZB_BACK | PSWIZB_NEXT );
  218. } else {
  219. m_pSheet->SetWizardButtons( PSWIZB_BACK );
  220. }
  221. WsbTraceOut( L"CMediaCopyWizardSelect::SetButtons", L"" );
  222. }
  223. void CMediaCopyWizardSelect::OnSelchangeCopyList()
  224. {
  225. WsbTraceIn( L"CMediaCopyWizardSelect::OnSelchangeCopyList", L"" );
  226. SetButtons();
  227. WsbTraceOut( L"CMediaCopyWizardSelect::OnSelchangeCopyList", L"" );
  228. }
  229. /////////////////////////////////////////////////////////////////////////////
  230. // CMediaCopyWizardFinish property page
  231. CMediaCopyWizardFinish::CMediaCopyWizardFinish() :
  232. CSakWizardPage_InitBaseExt( WIZ_CAR_COPY_FINISH )
  233. {
  234. WsbTraceIn( L"CMediaCopyWizardFinish::CMediaCopyWizardFinish", L"" );
  235. //{{AFX_DATA_INIT(CMediaCopyWizardFinish)
  236. // NOTE: the ClassWizard will add member initialization here
  237. //}}AFX_DATA_INIT
  238. WsbTraceOut( L"CMediaCopyWizardFinish::CMediaCopyWizardFinish", L"" );
  239. }
  240. CMediaCopyWizardFinish::~CMediaCopyWizardFinish()
  241. {
  242. WsbTraceIn( L"CMediaCopyWizardFinish::~CMediaCopyWizardFinish", L"" );
  243. WsbTraceOut( L"CMediaCopyWizardFinish::~CMediaCopyWizardFinish", L"" );
  244. }
  245. void CMediaCopyWizardFinish::DoDataExchange(CDataExchange* pDX)
  246. {
  247. WsbTraceIn( L"CMediaCopyWizardFinish::DoDataExchange", L"" );
  248. CSakWizardPage::DoDataExchange(pDX );
  249. //{{AFX_DATA_MAP(CMediaCopyWizardFinish)
  250. // NOTE: the ClassWizard will add DDX and DDV calls here
  251. //}}AFX_DATA_MAP
  252. WsbTraceOut( L"CMediaCopyWizardFinish::DoDataExchange", L"" );
  253. }
  254. BEGIN_MESSAGE_MAP(CMediaCopyWizardFinish, CSakWizardPage)
  255. //{{AFX_MSG_MAP(CMediaCopyWizardFinish)
  256. //}}AFX_MSG_MAP
  257. END_MESSAGE_MAP()
  258. /////////////////////////////////////////////////////////////////////////////
  259. // CMediaCopyWizardFinish message handlers
  260. BOOL CMediaCopyWizardFinish::OnInitDialog( )
  261. {
  262. WsbTraceIn( L"CMediaCopyWizardFinish::OnInitDialog", L"" );
  263. CSakWizardPage::OnInitDialog( );
  264. // GetDlgItem( IDC_REQUESTS_IN_NTMS )->SetFont( GetBoldShellFont( ) );
  265. WsbTraceOut( L"CMediaCopyWizardFinish::OnInitDialog", L"" );
  266. return TRUE;
  267. }
  268. BOOL CMediaCopyWizardFinish::OnSetActive( )
  269. {
  270. HRESULT hrInternal = S_OK;
  271. WsbTraceIn( L"CMediaCopyWizardFinish::OnSetActive", L"" );
  272. BOOL fRet = CSakWizardPage::OnSetActive( );
  273. //
  274. // Update the text on the page according to what is selected.
  275. //
  276. CString tmpString, tmpString2, newText;
  277. USHORT numMediaCopies = 0, oldMediaCopies = 0;
  278. CMediaCopyWizard* pSheet = (CMediaCopyWizard*)m_pSheet;
  279. oldMediaCopies = pSheet->m_numMediaCopiesOrig;
  280. // If we were originally set to 0, then we must have a new setting
  281. // in the media copies page
  282. if( oldMediaCopies == 0 ) {
  283. hrInternal = pSheet->m_pageNumCopies.GetNumMediaCopies( &numMediaCopies );
  284. } else {
  285. numMediaCopies = oldMediaCopies;
  286. }
  287. //
  288. // If we are changing the number of media copies, show it here
  289. //
  290. if( ( S_OK == hrInternal ) && ( numMediaCopies != oldMediaCopies ) ) {
  291. tmpString.LoadString( IDS_WIZ_CAR_COPY_NEW_NUM );
  292. tmpString2.Format( tmpString, (INT)numMediaCopies, (INT)oldMediaCopies );
  293. }
  294. //
  295. // Grab the copy set description - make so that it fits within a sentence.
  296. //
  297. INT setNum = pSheet->m_pageSelect.m_List.GetSelectedSet( );
  298. tmpString.Format( L"%d", setNum );
  299. AfxFormatString2( newText, IDS_WIZ_CAR_COPY_SELECT, tmpString, tmpString2 );
  300. SetDlgItemText( IDC_SELECT_TEXT, newText );
  301. //
  302. // And fill in the task notification from the resource strings used
  303. // to present the dialog normally.
  304. //
  305. newText.LoadString( IDS_JOB_MEDIA_COPY_TITLE );
  306. tmpString.Format( newText, pSheet->m_pageSelect.m_List.GetSelectedSet( ) );
  307. CWsbStringPtr computerName;
  308. HRESULT hr = S_OK;
  309. try {
  310. CComPtr<IHsmServer> pHsmServer;
  311. WsbAffirmHrOk( m_pSheet->GetHsmServer( &pHsmServer ) );
  312. WsbAffirmHr( pHsmServer->GetName( &computerName ) );
  313. } WsbCatch( hr );
  314. AfxFormatString2( newText, IDS_WIZ_FINISH_RUN_JOB, tmpString, computerName );
  315. SetDlgItemText( IDC_TASK_TEXT, newText );
  316. m_pSheet->SetWizardButtons( PSWIZB_BACK | PSWIZB_FINISH );
  317. WsbTraceOut( L"CMediaCopyWizardFinish::OnSetActive", L"" );
  318. return( fRet );
  319. }
  320. /////////////////////////////////////////////////////////////////////////////
  321. // CMediaCopyWizardNumCopies property page
  322. CMediaCopyWizardNumCopies::CMediaCopyWizardNumCopies() :
  323. CSakWizardPage_InitBaseInt( WIZ_CAR_COPY_NUM_COPIES )
  324. {
  325. //{{AFX_DATA_INIT(CMediaCopyWizardNumCopies)
  326. // NOTE: the ClassWizard will add member initialization here
  327. //}}AFX_DATA_INIT
  328. }
  329. CMediaCopyWizardNumCopies::~CMediaCopyWizardNumCopies()
  330. {
  331. }
  332. void CMediaCopyWizardNumCopies::DoDataExchange(CDataExchange* pDX)
  333. {
  334. CSakWizardPage::DoDataExchange(pDX);
  335. //{{AFX_DATA_MAP(CMediaCopyWizardNumCopies)
  336. DDX_Control(pDX, IDC_SPIN_MEDIA_COPIES, m_SpinMediaCopies);
  337. DDX_Control(pDX, IDC_EDIT_MEDIA_COPIES, m_EditMediaCopies);
  338. //}}AFX_DATA_MAP
  339. }
  340. BEGIN_MESSAGE_MAP(CMediaCopyWizardNumCopies, CSakWizardPage)
  341. //{{AFX_MSG_MAP(CMediaCopyWizardNumCopies)
  342. ON_EN_CHANGE(IDC_EDIT_MEDIA_COPIES, OnChangeEditMediaCopies)
  343. //}}AFX_MSG_MAP
  344. END_MESSAGE_MAP()
  345. /////////////////////////////////////////////////////////////////////////////
  346. // CMediaCopyWizardNumCopies message handlers
  347. BOOL CMediaCopyWizardNumCopies::OnInitDialog()
  348. {
  349. CSakWizardPage::OnInitDialog();
  350. //
  351. // Set the limit on the spinner, and initial value.
  352. //
  353. CMediaCopyWizard* pSheet = (CMediaCopyWizard*)m_pSheet;
  354. m_SpinMediaCopies.SetRange (0, 3);
  355. m_SpinMediaCopies.SetPos( pSheet->m_numMediaCopiesOrig );
  356. m_EditMediaCopies.LimitText( 1 );
  357. return TRUE;
  358. }
  359. HRESULT CMediaCopyWizardNumCopies::GetNumMediaCopies( USHORT* pNumMediaCopies, USHORT* pEditMediaCopies )
  360. {
  361. WsbTraceIn( L"CMediaCopyWizardSelect::GetNumMediaCopies", L"" );
  362. HRESULT hr = S_OK;
  363. BOOL translated = TRUE;
  364. UINT editVal = GetDlgItemInt( IDC_EDIT_MEDIA_COPIES, &translated );
  365. //
  366. // Need to be careful since we get called here before dialog object
  367. // is constructed
  368. //
  369. if( translated && m_SpinMediaCopies.m_hWnd ) {
  370. //
  371. // If Ok, always return what the spin says.
  372. //
  373. *pNumMediaCopies = (USHORT)m_SpinMediaCopies.GetPos( );
  374. if( pEditMediaCopies ) {
  375. *pEditMediaCopies = (USHORT)editVal;
  376. }
  377. }
  378. WsbTraceOut( L"CMediaCopyWizardNumCopies::GetNumMediaCopies", L"hr = <%ls>, *pNumMediaCopies = <%hd>", WsbHrAsString( hr ), *pNumMediaCopies );
  379. return( hr );
  380. }
  381. void
  382. CMediaCopyWizardNumCopies::SetButtons()
  383. {
  384. WsbTraceIn( L"CMediaCopyWizardSelect::SetButtons", L"" );
  385. USHORT numMediaCopies = 0;
  386. GetNumMediaCopies( &numMediaCopies );
  387. if( numMediaCopies > 0 ) {
  388. m_pSheet->SetWizardButtons( PSWIZB_BACK | PSWIZB_NEXT );
  389. } else {
  390. m_pSheet->SetWizardButtons( PSWIZB_BACK );
  391. }
  392. WsbTraceOut( L"CMediaCopyWizardNumCopies::SetButtons", L"" );
  393. }
  394. BOOL CMediaCopyWizardNumCopies::OnSetActive()
  395. {
  396. WsbTraceIn( L"CMediaCopyWizardSelect::OnSetActive", L"" );
  397. BOOL retval = CSakWizardPage::OnSetActive();
  398. SetButtons();
  399. WsbTraceOut( L"CMediaCopyWizardNumCopies::OnSetActive", L"" );
  400. return( retval );
  401. }
  402. BOOL CMediaCopyWizardNumCopies::OnKillActive()
  403. {
  404. WsbTraceIn( L"CMediaCopyWizardSelect::OnKillActive", L"" );
  405. BOOL retval = FALSE;
  406. //
  407. // Need to handle case where a user can enter a value within
  408. // the parameters of the number of digits allowed, but the value can
  409. // be out of range. This is detected by the spin box which will
  410. // return an error if its buddy control is out of range.
  411. //
  412. if( HIWORD( m_SpinMediaCopies.GetPos( ) ) > 0 ) {
  413. // Control reports on error...
  414. retval = FALSE;
  415. CString message;
  416. AfxFormatString2( message, IDS_ERR_COPYSET_RANGE,
  417. CString( WsbLongAsString( (LONG)(HSMADMIN_MIN_COPY_SETS+1) ) ),
  418. CString( WsbLongAsString( (LONG)HSMADMIN_MAX_COPY_SETS ) ) );
  419. AfxMessageBox( message, MB_OK | MB_ICONWARNING );
  420. } else {
  421. retval = CSakWizardPage::OnKillActive();
  422. }
  423. WsbTraceOut( L"CMediaCopyWizardNumCopies::OnKillActive", L"" );
  424. return( retval );
  425. }
  426. void CMediaCopyWizardNumCopies::OnChangeEditMediaCopies()
  427. {
  428. WsbTraceIn( L"CMediaCopyWizardSelect::OnChangeEditMediaCopies", L"" );
  429. SetButtons();
  430. WsbTraceOut( L"CMediaCopyWizardNumCopies::OnChangeEditMediaCopies", L"" );
  431. }
  432. /////////////////////////////////////////////////////////////////////////////
  433. // CCopySetList
  434. CCopySetList::CCopySetList( CMediaCopyWizardSelect * pPage )
  435. {
  436. WsbTraceIn( L"CCopySetList::CCopySetList", L"" );
  437. for( INT index = 0; index < HSMADMIN_MAX_COPY_SETS; index++ ) {
  438. m_CopySetInfo[index].m_Updated = WsbLLtoFT( 0 );
  439. m_CopySetInfo[index].m_NumOutOfDate = 0;
  440. m_CopySetInfo[index].m_NumMissing = 0;
  441. }
  442. m_pPage = pPage;
  443. WsbTraceOut( L"CCopySetList::CCopySetList", L"" );
  444. }
  445. CCopySetList::~CCopySetList()
  446. {
  447. WsbTraceIn( L"CCopySetList::~CCopySetList", L"" );
  448. WsbTraceOut( L"CCopySetList::~CCopySetList", L"" );
  449. }
  450. BEGIN_MESSAGE_MAP(CCopySetList, CListCtrl)
  451. //{{AFX_MSG_MAP(CCopySetList)
  452. //}}AFX_MSG_MAP
  453. END_MESSAGE_MAP()
  454. /////////////////////////////////////////////////////////////////////////////
  455. // CCopySetList message handlers
  456. void
  457. CCopySetList::UpdateView(
  458. )
  459. {
  460. WsbTraceIn( L"CCopySetList::UpdateView", L"" );
  461. HRESULT hr = S_OK;
  462. try {
  463. USHORT numMediaCopies;
  464. CMediaCopyWizard* pSheet = (CMediaCopyWizard*)(m_pPage->m_pSheet);
  465. //
  466. // Get the number of media copies from either the media copies
  467. // page or RMS.
  468. //
  469. if( pSheet->m_numMediaCopiesOrig == 0 ) {
  470. pSheet->m_pageNumCopies.GetNumMediaCopies( &numMediaCopies );
  471. } else {
  472. numMediaCopies = pSheet->m_numMediaCopiesOrig;
  473. }
  474. CString tmpString;
  475. INT oldCurSel = GetSelectedSet( );
  476. INT newCurSel = oldCurSel;
  477. LockWindowUpdate( );
  478. DeleteAllItems( );
  479. for( INT index = 0; index < numMediaCopies; index++ ) {
  480. //
  481. // Add the entries to each column
  482. //
  483. tmpString.Format( IDS_WIZ_CAR_COPY_SEL_TEXT, index + 1 );
  484. this->InsertItem( index, tmpString, 0 );
  485. tmpString.Format( L"%d", m_CopySetInfo[index].m_NumOutOfDate );
  486. this->SetItemText( index, m_UpdateCol, tmpString );
  487. tmpString.Format( L"%d", m_CopySetInfo[index].m_NumMissing );
  488. this->SetItemText( index, m_CreateCol, tmpString );
  489. }
  490. if( CB_ERR == oldCurSel ) {
  491. //
  492. // No selection before, find the most likely to need updating - most out of date
  493. //
  494. newCurSel = 1;
  495. FILETIME latestTime = WsbLLtoFT( (LONGLONG)-1 );
  496. for( INT index = 0; index < numMediaCopies; index++ ) {
  497. if( CompareFileTime( &latestTime, &(m_CopySetInfo[index].m_Updated) ) > 0 ) {
  498. latestTime = m_CopySetInfo[index].m_Updated;
  499. newCurSel = index + 1;
  500. }
  501. }
  502. } else if( oldCurSel > numMediaCopies ) {
  503. newCurSel = numMediaCopies;
  504. }
  505. SelectSet( newCurSel );
  506. UnlockWindowUpdate( );
  507. } WsbCatch( hr );
  508. WsbTraceOut( L"CCopySetList::UpdateView", L"" );
  509. }
  510. INT
  511. CCopySetList::GetSelectedSet(
  512. )
  513. {
  514. INT retval = GetNextItem( -1, LVIS_SELECTED );
  515. if( CB_ERR != retval ) {
  516. retval++;
  517. }
  518. return( retval );
  519. }
  520. void
  521. CCopySetList::SelectSet(
  522. INT SetNum
  523. )
  524. {
  525. if( SetNum > 0 ) {
  526. SetItemState( SetNum - 1, LVIS_SELECTED, LVIS_SELECTED );
  527. }
  528. }
  529. void CCopySetList::PreSubclassWindow()
  530. {
  531. WsbTraceIn( L"CCopySetList::PreSubclassWindow", L"" );
  532. HRESULT hr = S_OK;
  533. CComPtr<IWsbDb> pDb;
  534. CComPtr<IWsbDbSession> pDbSession;
  535. CComPtr<IMediaInfo> pMediaInfo;
  536. try {
  537. //
  538. // Set the style appropriately
  539. //
  540. ListView_SetExtendedListViewStyle( GetSafeHwnd( ), LVS_EX_FULLROWSELECT );
  541. //
  542. // Also need to calculate some buffer space
  543. // Use 4 dialog units (for numeral)
  544. //
  545. CRect padRect( 0, 0, 8, 8 );
  546. m_pPage->MapDialogRect( padRect );
  547. //
  548. // Set up columns
  549. //
  550. INT column = 0;
  551. CString titleString;
  552. LVCOLUMN lvc;
  553. memset( &lvc, 0, sizeof( lvc ) );
  554. lvc.mask = LVCF_FMT | LVCF_TEXT | LVCF_WIDTH;
  555. lvc.fmt = LVCFMT_CENTER;
  556. m_CopySetCol = column;
  557. titleString.LoadString( IDS_COPYSET_COPYSET );
  558. lvc.cx = GetStringWidth( titleString ) + padRect.Width( ) * 2;
  559. lvc.pszText = (LPTSTR)(LPCTSTR)titleString;
  560. InsertColumn( m_CopySetCol, &lvc );
  561. column++;
  562. m_UpdateCol = column;
  563. titleString.LoadString( IDS_COPYSET_OUT_OF_DATE );
  564. lvc.cx = GetStringWidth( titleString ) + padRect.Width( );
  565. lvc.pszText = (LPTSTR)(LPCTSTR)titleString;
  566. InsertColumn( m_UpdateCol, &lvc );
  567. column++;
  568. m_CreateCol = column;
  569. titleString.LoadString( IDS_COPYSET_DO_NOT_EXIST );
  570. lvc.cx = GetStringWidth( titleString ) + padRect.Width( );
  571. lvc.pszText = (LPTSTR)(LPCTSTR)titleString;
  572. InsertColumn( m_CreateCol, &lvc );
  573. column++;
  574. //
  575. // Hook up to DB and get info
  576. //
  577. CComPtr<IHsmServer> pHsmServer;
  578. CComPtr<IRmsServer> pRmsServer;
  579. WsbAffirmHrOk( m_pPage->m_pSheet->GetHsmServer( &pHsmServer ) );
  580. WsbAffirmHrOk( m_pPage->m_pSheet->GetRmsServer( &pRmsServer ) );
  581. CMediaInfoObject mio;
  582. mio.Initialize( GUID_NULL, pHsmServer, pRmsServer );
  583. HRESULT hrEnum = mio.First( );
  584. WsbAffirm( SUCCEEDED( hrEnum ) || ( WSB_E_NOTFOUND == hrEnum ), hrEnum );
  585. while( SUCCEEDED( hrEnum ) ) {
  586. if( S_OK == mio.IsViewable( FALSE ) ) {
  587. for( INT index = 0; index < HSMADMIN_MAX_COPY_SETS; index++ ) {
  588. if( S_OK != mio.DoesCopyExist( index ) ) {
  589. m_CopySetInfo[index].m_NumMissing++;
  590. } else {
  591. //
  592. // And check to see if out of date
  593. //
  594. if( S_OK != mio.IsCopyInSync( index ) ) {
  595. m_CopySetInfo[index].m_NumOutOfDate++;
  596. }
  597. //
  598. // Look for latest date of update per set
  599. //
  600. if( CompareFileTime( &(m_CopySetInfo[index].m_Updated), &(mio.m_CopyInfo[index].m_ModifyTime) ) < 0 ) {
  601. m_CopySetInfo[index].m_Updated = (mio.m_CopyInfo[index].m_ModifyTime);
  602. }
  603. }
  604. }
  605. }
  606. hrEnum = mio.Next( );
  607. }
  608. } WsbCatch( hr );
  609. CListCtrl::PreSubclassWindow();
  610. WsbTraceOut( L"CCopySetList::PreSubclassWindow", L"" );
  611. }