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.

1999 lines
55 KiB

  1. /*++
  2. 1998 Seagate Software, Inc. All rights reserved.
  3. Module Name:
  4. WzQStart.cpp
  5. Abstract:
  6. Setup Wizard implementation.
  7. Author:
  8. Rohde Wakefield [rohde] 12-Aug-1997
  9. Revision History:
  10. --*/
  11. #include "stdafx.h"
  12. #include "HsmConn.h"
  13. #include "RpFilt.h"
  14. #include "rsstrdef.h"
  15. #include "WzQStart.h"
  16. #include "SchedSht.h"
  17. #define CHECK_SYSTEM_TIMER_ID 9284
  18. #define CHECK_SYSTEM_TIMER_MS 1000
  19. #define QSHEET ((CQuickStartWizard*)m_pSheet)
  20. const HRESULT E_INVALID_DOMAINNAME = HRESULT_FROM_WIN32( ERROR_INVALID_DOMAINNAME );
  21. const HRESULT E_ACCESS_DENIED = HRESULT_FROM_WIN32( ERROR_ACCESS_DENIED );
  22. /////////////////////////////////////////////////////////////////////////////
  23. // CQuickStartWizard
  24. CQuickStartWizard::CQuickStartWizard( )
  25. {
  26. WsbTraceIn( L"CQuickStartWizard::CQuickStartWizard", L"" );
  27. m_TitleId = IDS_WIZ_QSTART_TITLE;
  28. m_HeaderId = IDB_QSTART_HEADER;
  29. m_WatermarkId = IDB_QSTART_WATERMARK;
  30. //
  31. // Init So that we know what checks we have done
  32. //
  33. m_CheckSysState = CST_NOT_STARTED;
  34. m_hrCheckSysResult = S_OK;
  35. WsbTraceOut( L"CQuickStartWizard::CQuickStartWizard", L"" );
  36. }
  37. CQuickStartWizard::~CQuickStartWizard( )
  38. {
  39. WsbTraceIn( L"CQuickStartWizard::~CQuickStartWizard", L"" );
  40. WsbTraceOut( L"CQuickStartWizard::~CQuickStartWizard", L"" );
  41. }
  42. STDMETHODIMP
  43. CQuickStartWizard::AddWizardPages(
  44. IN RS_PCREATE_HANDLE Handle,
  45. IN IUnknown* pCallback,
  46. IN ISakSnapAsk* pSakSnapAsk
  47. )
  48. {
  49. WsbTraceIn( L"CQuickStartWizard::AddWizardPages", L"" );
  50. HRESULT hr = S_OK;
  51. try {
  52. //
  53. // Initialize the Sheet
  54. //
  55. WsbAffirmHr( InitSheet( Handle, pCallback, 0, pSakSnapAsk, 0, 0 ) );
  56. //
  57. // Load pages
  58. //
  59. WsbAffirmHr( AddPage( &m_IntroPage ) );
  60. WsbAffirmHr( AddPage( &m_CheckPage ) );
  61. WsbAffirmHr( AddPage( &m_ManageRes ) );
  62. WsbAffirmHr( AddPage( &m_ManageResX ) );
  63. WsbAffirmHr( AddPage( &m_InitialValues ) );
  64. WsbAffirmHr( AddPage( &m_MediaSel ) );
  65. WsbAffirmHr( AddPage( &m_SchedulePage ) );
  66. WsbAffirmHr( AddPage( &m_FinishPage ) );
  67. } WsbCatch( hr );
  68. WsbTraceOut( L"CQuickStartWizard::AddWizardPages", L"hr = <%ls>", WsbHrAsString( hr ) );
  69. return( hr );
  70. }
  71. HRESULT CQuickStartWizard::InitTask( )
  72. {
  73. WsbTraceIn( L"CQuickStartWizard::InitTask", L"" );
  74. HRESULT hr = S_OK;
  75. try {
  76. //
  77. // Need to connect to the scheduling agent to get a page
  78. // to show. Do that up front
  79. //
  80. WsbAffirmHr( m_pSchedAgent.CoCreateInstance( CLSID_CSchedulingAgent ) );
  81. CString jobTitle;
  82. jobTitle.LoadString( IDS_SCHED_TASK_TEMP_TITLE );
  83. //
  84. // If it exists already, blow it away (assume doing fresh install)
  85. // Ignore error in case not exist.
  86. //
  87. m_pSchedAgent->Delete( jobTitle );
  88. WsbAffirmHr( m_pSchedAgent->NewWorkItem( jobTitle, CLSID_CTask, IID_ITask, (IUnknown**)&m_pTask ) );
  89. TASK_TRIGGER taskTrigger;
  90. SYSTEMTIME sysTime;
  91. WORD triggerNumber;
  92. WsbAffirmHr( m_pTask->CreateTrigger( &triggerNumber, &m_pTrigger ) );
  93. memset( &taskTrigger, 0, sizeof( taskTrigger ) );
  94. taskTrigger.cbTriggerSize = sizeof( taskTrigger );
  95. GetSystemTime( &sysTime );
  96. taskTrigger.wBeginYear = sysTime.wYear;
  97. taskTrigger.wBeginMonth = sysTime.wMonth;
  98. taskTrigger.wBeginDay = sysTime.wDay;
  99. taskTrigger.wStartHour = 2;
  100. taskTrigger.TriggerType = TASK_TIME_TRIGGER_DAILY;
  101. taskTrigger.Type.Daily.DaysInterval = 1;
  102. WsbAffirmHr( m_pTrigger->SetTrigger( &taskTrigger ) );
  103. } WsbCatchAndDo( hr,
  104. CString errString;
  105. AfxFormatString1( errString, IDS_ERR_CREATE_TASK, WsbHrAsString( hr ) );
  106. AfxMessageBox( errString, RS_MB_ERROR );
  107. PressButton( PSBTN_FINISH );
  108. );
  109. WsbTraceOut( L"CQuickStartWizard::InitTask", L"hr = <%ls>", WsbHrAsString( hr ) );
  110. return( hr );
  111. }
  112. HRESULT CQuickStartWizard::OnCancel( )
  113. {
  114. WsbTraceIn( L"CQuickStartWizard::OnCancel", L"" );
  115. //
  116. // Need to delete the task
  117. //
  118. if( m_pSchedAgent ) {
  119. if( m_pTrigger ) m_pTrigger.Release( );
  120. if( m_pTask ) m_pTask.Release( );
  121. CWsbStringPtr jobTitle;
  122. WsbAffirmHr(WsbGetResourceString(IDS_HSM_SCHED_TASK_TITLE, &jobTitle));
  123. m_pSchedAgent->Delete( jobTitle );
  124. //
  125. // Delete the temporary tesk
  126. //
  127. CString tempTitle;
  128. tempTitle.LoadString( IDS_SCHED_TASK_TEMP_TITLE );
  129. m_pSchedAgent->Delete( tempTitle );
  130. }
  131. WsbTraceOut( L"CQuickStartWizard::OnCancel", L"" );
  132. return( S_OK );
  133. }
  134. HRESULT
  135. CQuickStartWizard::OnFinish(
  136. )
  137. {
  138. WsbTraceIn( L"CQuickStartWizard::OnFinish", L"" );
  139. BOOL doAll = FALSE;
  140. //
  141. // The sheet really owns the process as a whole,
  142. // so it will do the final assembly
  143. //
  144. HRESULT hr = S_OK;
  145. HRESULT hrLoop = S_OK;
  146. BOOL completedAll = FALSE;
  147. try {
  148. //
  149. // Show the Wait cursor so that they know we are busy
  150. //
  151. CWaitCursor wait;
  152. //
  153. // Get the HSM service interface for creating local objects
  154. //
  155. CComPtr<IWsbCreateLocalObject> pCreateLocal;
  156. CComPtr<IHsmServer> pServer;
  157. CComPtr<IFsaServer> pFsa;
  158. CComPtr<IRmsServer> pRms;
  159. CComPtr<IWsbIndexedCollection> pResCollection;
  160. CComPtr<IHsmManagedResource> pHsmResource;
  161. CComPtr <IWsbIndexedCollection> pStoPoCollection;
  162. CComPtr <IHsmStoragePool> pStoragePool;
  163. WsbAffirmHr( GetHsmServer( pServer ) );
  164. WsbAffirmHr( GetFsaServer( pFsa ) );
  165. WsbAffirmHr( GetRmsServer( pRms ) );
  166. WsbAffirmHr( pServer->QueryInterface( IID_IWsbCreateLocalObject, (void **) &pCreateLocal ) );
  167. WsbAffirmHr( pServer->GetManagedResources( &pResCollection ) );
  168. WsbAffirmHr( pResCollection->RemoveAllAndRelease( ) );
  169. //
  170. // Pull out the default levels for all resources to be managed
  171. //
  172. ULONG defaultFreeSpace = CONVERT_TO_HSMNUM( m_InitialValues.m_FreeSpaceSpinner.GetPos( ) );
  173. LONGLONG defaultMinSize = ( (LONGLONG)m_InitialValues.m_MinSizeSpinner.GetPos( ) ) * ((LONGLONG)1024);
  174. FILETIME defaultAccess = WsbLLtoFT( ( (LONGLONG)m_InitialValues.m_AccessSpinner.GetPos( ) ) * (LONGLONG)WSB_FT_TICKS_PER_DAY );
  175. // Is the "all" radio button selected?
  176. if( !m_ManageRes.m_RadioSelect.GetCheck() ) {
  177. doAll = TRUE;
  178. }
  179. //
  180. // Go through the listbox and pull out the checked resources.
  181. // Create HSM managed volumes for them
  182. //
  183. CSakVolList &listBox = m_ManageRes.m_ListBox;
  184. INT index;
  185. for( index = 0; index < listBox.GetItemCount( ); index++ ) {
  186. if( ( doAll ) || ( listBox.GetCheck( index ) ) ) {
  187. CResourceInfo* pResInfo = (CResourceInfo*)listBox.GetItemData( index );
  188. WsbAffirmPointer( pResInfo );
  189. try {
  190. //
  191. // Create Local to server since it will eventually own it.
  192. //
  193. pHsmResource.Release( );
  194. WsbAffirmHr( pCreateLocal->CreateInstance(
  195. CLSID_CHsmManagedResource,
  196. IID_IHsmManagedResource,
  197. (void**)&pHsmResource ) );
  198. //
  199. // Initialize Fsa object to its initial values.
  200. //
  201. WsbAffirmHr( (pResInfo->m_pResource)->SetHsmLevel( defaultFreeSpace ) );
  202. WsbAffirmHr( (pResInfo->m_pResource)->SetManageableItemLogicalSize( defaultMinSize ) );
  203. WsbAffirmHr( (pResInfo->m_pResource)->SetManageableItemAccessTime( TRUE, defaultAccess ) );
  204. //
  205. // Associate HSM Managed Resource with the FSA resource
  206. // (also adds to HSM collection)
  207. //
  208. WsbAffirmHr( pHsmResource->InitFromFsaResource( pResInfo->m_pResource ) );
  209. WsbAffirmHr( pResCollection->Add( pHsmResource ) );
  210. } WsbCatch( hrLoop );
  211. }
  212. }
  213. //
  214. // And now that all configuration of services is done,
  215. // save it all
  216. //
  217. WsbAffirmHr( RsServerSaveAll( pServer ) );
  218. WsbAffirmHr( RsServerSaveAll( pFsa ) );
  219. //
  220. // Set up the schedule. We have created a temporary object that
  221. // will never be saved to disk. Instead, we need the service to
  222. // create the task so that it has the correct account. We then
  223. // grab it and copy over the triggers from the temp job.
  224. //
  225. CWsbStringPtr taskTitle, commentString;
  226. WsbAffirmHr(WsbGetResourceString(IDS_HSM_SCHED_TASK_TITLE, &taskTitle));
  227. WsbAffirmHr(WsbGetResourceString(IDS_HSM_SCHED_COMMENT, &commentString));
  228. CComPtr<ITask> pTask;
  229. WsbAffirmHr( pServer->CreateTask( taskTitle, L"", commentString, TASK_TIME_TRIGGER_DAILY, 0, 0, TRUE ) );
  230. WsbAffirmHr( m_pSchedAgent->Activate( taskTitle, IID_ITask, (IUnknown**)&pTask ) );
  231. // Nuke the temporary one created for us.
  232. WsbAffirmHr( pTask->DeleteTrigger( 0 ) );
  233. CComPtr<ITaskTrigger> pTrigger1, pTrigger2;
  234. WORD triggerCount, triggerIndex, newTriggerIndex;
  235. TASK_TRIGGER taskTrigger;
  236. WsbAffirmHr( m_pTask->GetTriggerCount( &triggerCount ) );
  237. for( triggerIndex = 0; triggerIndex < triggerCount; triggerIndex++ ) {
  238. WsbAffirmHr( m_pTask->GetTrigger( triggerIndex, &pTrigger1 ) );
  239. WsbAffirmHr( pTrigger1->GetTrigger( &taskTrigger ) );
  240. WsbAffirmHr( pTask->CreateTrigger( &newTriggerIndex, &pTrigger2 ) );
  241. // Just to note - WsbAffirm( newTriggerIndex == triggerIndex, E_UNEXPECTED );
  242. WsbAffirmHr( pTrigger2->SetTrigger( &taskTrigger ) );
  243. pTrigger1.Release( );
  244. pTrigger2.Release( );
  245. }
  246. // Set real parameters since we have a real schedule now.
  247. CString parameters;
  248. parameters = RS_STR_KICKOFF_PARAMS;
  249. WsbAffirmHr( pTask->SetParameters( parameters ) );
  250. CComPtr<IPersistFile> pPersist;
  251. WsbAffirmHr( pTask->QueryInterface( IID_IPersistFile, (void**)&pPersist ) );
  252. WsbAffirmHr( pPersist->Save( 0, 0 ) );
  253. //
  254. // Do last since it is what we key off of for being "Set up"
  255. //
  256. // Configure the selected media set
  257. //
  258. INT curSel = m_MediaSel.m_ListMediaSel.GetCurSel ();
  259. WsbAffirm( (curSel != LB_ERR), E_FAIL );
  260. IRmsMediaSet* pMediaSet = (IRmsMediaSet *) m_MediaSel.m_ListMediaSel.GetItemDataPtr( curSel );
  261. //
  262. // Get the storage pool.
  263. //
  264. WsbAffirmHr( RsGetStoragePool( pServer, &pStoragePool ) );
  265. //
  266. // Set the media set info in the storage pool
  267. //
  268. WsbAffirmHr( pStoragePool->InitFromRmsMediaSet( pMediaSet ) );
  269. WsbAffirmHr( RsServerSaveAll( pServer ) );
  270. //
  271. // Delete the temporary tesk
  272. //
  273. CString tempTitle;
  274. tempTitle.LoadString( IDS_SCHED_TASK_TEMP_TITLE );
  275. m_pSchedAgent->Delete( tempTitle );
  276. //
  277. // Show any error that occurred while managing volumes
  278. //
  279. completedAll = TRUE;
  280. WsbAffirmHr( hrLoop );
  281. } WsbCatchAndDo( hr,
  282. CString errString;
  283. AfxFormatString1( errString, IDS_ERROR_QSTART_ONFINISH, WsbHrAsString( hr ) );
  284. AfxMessageBox( errString, RS_MB_ERROR );
  285. );
  286. //
  287. // Set result so invoking code knows what our result is.
  288. // The constructor set this to RS_E_CANCELED, so an S_FALSE would
  289. // indicate a canceled wizard.
  290. //
  291. m_HrFinish = ( completedAll ) ? S_OK : hr;
  292. WsbTraceOut( L"CQuickStartWizard::OnFinish", L"hr = <%ls>", WsbHrAsString( hr ) );
  293. return( hr );
  294. }
  295. HRESULT
  296. CQuickStartWizard::GetHsmServer(
  297. CComPtr<IHsmServer> &pServ
  298. )
  299. {
  300. WsbTraceIn( L"CQuickStartWizard::GetHsmServer", L"" );
  301. HRESULT hr = S_OK;
  302. try {
  303. if( !m_pHsmServer ) {
  304. CWsbStringPtr computerName;
  305. WsbAffirmHr( WsbGetComputerName( computerName ) );
  306. WsbAffirmHr( HsmConnectFromName( HSMCONN_TYPE_HSM, computerName, IID_IHsmServer, (void**)&m_pHsmServer ) );
  307. }
  308. pServ = m_pHsmServer;
  309. } WsbCatch( hr );
  310. WsbTraceOut( L"CQuickStartWizard::GetHsmServer", L"hr = <%ls>, pServ = <0x%p>", WsbHrAsString( hr ), pServ.p );
  311. return( hr );
  312. }
  313. HRESULT
  314. CQuickStartWizard::GetFsaServer(
  315. CComPtr<IFsaServer> &pServ
  316. )
  317. {
  318. WsbTraceIn( L"CQuickStartWizard::GetFsaServer", L"" );
  319. HRESULT hr = S_OK;
  320. try {
  321. if( !m_pFsaServer ) {
  322. CWsbStringPtr computerName;
  323. WsbAffirmHr( WsbGetComputerName( computerName ) );
  324. WsbAffirmHr(computerName.Append("\\NTFS"));
  325. WsbAffirmHr( HsmConnectFromName( HSMCONN_TYPE_FSA, computerName, IID_IFsaServer, (void**)&m_pFsaServer ) );
  326. }
  327. pServ = m_pFsaServer;
  328. } WsbCatch( hr );
  329. WsbTraceOut( L"CQuickStartWizard::GetFsaServer", L"hr = <%ls>, pServ = <0x%p>", WsbHrAsString( hr ), pServ.p );
  330. return( hr );
  331. }
  332. HRESULT
  333. CQuickStartWizard::GetRmsServer(
  334. CComPtr<IRmsServer> &pServ
  335. )
  336. {
  337. WsbTraceIn( L"CQuickStartWizard::GetRmsServer", L"" );
  338. HRESULT hr = S_OK;
  339. try {
  340. if( !m_pRmsServer ) {
  341. CWsbStringPtr computerName;
  342. WsbAffirmHr( WsbGetComputerName( computerName ) );
  343. CComPtr<IHsmServer> pHsmServer;
  344. WsbAffirmHr( HsmConnectFromName( HSMCONN_TYPE_HSM, computerName, IID_IHsmServer, (void**)&pHsmServer ) );
  345. WsbAffirmPointer(pHsmServer);
  346. WsbAffirmHr(pHsmServer->GetHsmMediaMgr(&m_pRmsServer));
  347. }
  348. pServ = m_pRmsServer;
  349. } WsbCatch( hr );
  350. WsbTraceOut( L"CQuickStartWizard::GetRmsServer", L"hr = <%ls>, pServ = <0x%p>", WsbHrAsString( hr ), pServ.p );
  351. return( hr );
  352. }
  353. HRESULT
  354. CQuickStartWizard::ReleaseServers(
  355. void
  356. )
  357. {
  358. WsbTraceIn( L"CQuickStartWizard::ReleaseServers", L"" );
  359. HRESULT hr = S_OK;
  360. m_pHsmServer.Release( );
  361. m_pFsaServer.Release( );
  362. m_pRmsServer.Release( );
  363. WsbTraceOut( L"CQuickStartWizard::ReleaseServers", L"hr = <%ls>", WsbHrAsString( hr ) );
  364. return( S_OK );
  365. }
  366. DWORD WINAPI
  367. CQuickStartWizard::CheckSysThreadStart(
  368. LPVOID pv
  369. )
  370. {
  371. WsbTraceIn( L"CQuickStartWizard::CheckSysThreadStart", L"" );
  372. AFX_MANAGE_STATE(AfxGetStaticModuleState( ));
  373. HRESULT hr = S_OK;
  374. HRESULT hrInternal = S_OK;
  375. HRESULT hrCom = S_OK;
  376. CQuickStartWizard * pWiz = (CQuickStartWizard*)pv;
  377. try {
  378. hrCom = CoInitialize( 0 );
  379. WsbAffirmHr( hrCom );
  380. WsbAffirmPointer( pv );
  381. pWiz->m_hrCheckSysResult = S_OK;
  382. do {
  383. WsbTrace( L"Checking Account Security\n" );
  384. pWiz->m_CheckSysState = CST_ACCOUNT;
  385. //
  386. // Do they have admin privs?
  387. //
  388. WsbAffirmHr( hrInternal = WsbCheckAccess( WSB_ACCESS_TYPE_ADMINISTRATOR ) );
  389. if( hrInternal == E_ACCESSDENIED ) {
  390. hr = S_FALSE;
  391. continue;
  392. }
  393. // Is media suppported?
  394. WsbTrace( L"Account Security OK\n" );
  395. WsbTrace( L"Checking for Supported Media\n" );
  396. pWiz->m_CheckSysState = CST_SUPP_MEDIA;
  397. WsbAffirmHr(hrInternal = RsIsSupportedMediaAvailable( ) );
  398. if( hrInternal == S_FALSE ) {
  399. hr = S_FALSE;
  400. continue;
  401. }
  402. WsbTrace( L"Supported Media Found\n" );
  403. pWiz->m_CheckSysState = CST_DONE;
  404. } while( 0 );
  405. } WsbCatch( hr );
  406. //
  407. // And report back what our results are
  408. //
  409. pWiz->m_hrCheckSysResult = hr;
  410. //
  411. // We'll exit and end thread, so hide the main threads handle of us.
  412. //
  413. pWiz->m_hCheckSysThread = 0;
  414. if (SUCCEEDED(hrCom)) {
  415. CoUninitialize( );
  416. }
  417. WsbTraceOut( L"CQuickStartWizard::CheckSysThreadStart", L"hr = <%ls>", WsbHrAsString( hr ) );
  418. return( hr );
  419. }
  420. /////////////////////////////////////////////////////////////////////////////
  421. // CQuickStartIntro property page
  422. BEGIN_MESSAGE_MAP(CQuickStartIntro, CSakWizardPage)
  423. //{{AFX_MSG_MAP(CQuickStartIntro)
  424. //}}AFX_MSG_MAP
  425. END_MESSAGE_MAP( )
  426. CQuickStartIntro::CQuickStartIntro() :
  427. CSakWizardPage_InitBaseExt( WIZ_QSTART_INTRO )
  428. {
  429. WsbTraceIn( L"CQuickStartIntro::CQuickStartIntro", L"" );
  430. //{{AFX_DATA_INIT(CQuickStartIntro)
  431. // NOTE: the ClassWizard will add member initialization here
  432. //}}AFX_DATA_INIT
  433. WsbTraceOut( L"CQuickStartIntro::CQuickStartIntro", L"" );
  434. }
  435. HRESULT
  436. CQuickStartIntro::IsDriverRunning()
  437. {
  438. HRESULT hr = S_FALSE;
  439. //
  440. // Ensure the filter is installed and running.
  441. //
  442. SC_HANDLE hSCM = 0;
  443. SC_HANDLE hDriver = 0;
  444. SERVICE_STATUS serviceStatus;
  445. try {
  446. hSCM = OpenSCManager( 0, 0, GENERIC_READ );
  447. WsbAffirmPointer( hSCM );
  448. hDriver = OpenService( hSCM, TEXT( RSFILTER_SERVICENAME ), SERVICE_QUERY_STATUS );
  449. WsbAffirmStatus( 0 != hDriver );
  450. WsbAffirmStatus( QueryServiceStatus( hDriver, &serviceStatus ) );
  451. if( SERVICE_RUNNING == serviceStatus.dwCurrentState ) {
  452. //
  453. // Things look good, set flag so Wizard will allow conitue.
  454. //
  455. hr = S_OK;
  456. }
  457. } WsbCatch( hr );
  458. if( hSCM ) CloseServiceHandle( hSCM );
  459. if( hDriver ) CloseServiceHandle( hDriver );
  460. return( hr );
  461. }
  462. HRESULT
  463. CQuickStartIntro::CheckLastAccessDateState(
  464. LAD_STATE* ladState
  465. )
  466. {
  467. WsbTraceIn( L"CQuickStartIntro::CheckLastAccessDateState", L"" );
  468. const OLECHAR* localMachine = 0;
  469. const OLECHAR* regPath = L"System\\CurrentControlSet\\Control\\FileSystem";
  470. const OLECHAR* regValue = L"NtfsDisableLastAccessUpdate";
  471. HRESULT hr = S_OK;
  472. DWORD pVal = 0;
  473. try {
  474. // Install might have changed this registry value from 1 to 0. If the value
  475. // is not 1, we assume that the registry was 1 at one time and install
  476. // changed it to 0. This is a one time check, so the value is removed from
  477. // the registry if not 1.
  478. // If the following fails we assume that the value is not in the registry,
  479. // the normal case.
  480. if( S_OK == WsbGetRegistryValueDWORD( localMachine,
  481. regPath,
  482. regValue,
  483. &pVal ) ) {
  484. if( pVal == (DWORD)1 ) {
  485. *ladState = LAD_DISABLED;
  486. } else {
  487. *ladState = LAD_ENABLED;
  488. WsbAffirmHr( WsbRemoveRegistryValue ( localMachine,
  489. regPath,
  490. regValue ) );
  491. }
  492. } else {
  493. *ladState = LAD_UNSET;
  494. }
  495. } WsbCatch( hr );
  496. WsbTraceOut( L"CQuickStartIntro::CheckLastAccessDateState",
  497. L"HRESULT = %ls, *ladState = %d",
  498. WsbHrAsString( hr ),
  499. *ladState );
  500. return( hr );
  501. }
  502. LRESULT
  503. CQuickStartIntro::OnWizardNext()
  504. {
  505. LAD_STATE ladState = LAD_UNSET;
  506. HRESULT hr = IsDriverRunning( );
  507. if( S_FALSE == hr ) {
  508. //
  509. // And the final restart dialog so the filter can load
  510. // In order to shut down we must enable a privilege.
  511. //
  512. if( IDYES == AfxMessageBox( IDS_QSTART_RESTART_NT, MB_YESNO | MB_ICONEXCLAMATION ) ) {
  513. HANDLE hToken;
  514. if( OpenProcessToken( GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken ) ) {
  515. TOKEN_PRIVILEGES privs;
  516. LookupPrivilegeValue( 0, SE_SHUTDOWN_NAME, &privs.Privileges[0].Luid );
  517. privs.PrivilegeCount = 1;
  518. privs.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
  519. AdjustTokenPrivileges( hToken, FALSE, &privs, 0, 0, 0 );
  520. ExitWindowsEx( EWX_REBOOT, 0 );
  521. }
  522. }
  523. return( -1 );
  524. } else if( HRESULT_FROM_WIN32( ERROR_SERVICE_DOES_NOT_EXIST ) == hr ) {
  525. AfxMessageBox( IDS_ERR_QSTART_NO_FILTER, RS_MB_ERROR );
  526. return( -1 );
  527. } else if( FAILED( hr ) ) {
  528. CString message;
  529. AfxFormatString1( message, IDS_ERR_QSTART_FILTER_ERROR, WsbHrAsString( hr ) );
  530. AfxMessageBox( message, RS_MB_ERROR );
  531. return( -1 );
  532. } else {
  533. WsbAffirmHr( CheckLastAccessDateState( &ladState ) );
  534. if( ladState == LAD_DISABLED ) {
  535. AfxMessageBox( IDS_WIZ_LAST_ACCESS_DATE_DISABLED, MB_OK | MB_ICONEXCLAMATION );
  536. } else if( ladState == LAD_ENABLED ) {
  537. AfxMessageBox( IDS_WIZ_LAST_ACCESS_DATE_ENABLED, MB_OK | MB_ICONEXCLAMATION );
  538. }
  539. }
  540. //
  541. // Last check is if we can create temp task
  542. //
  543. if( FAILED( QSHEET->InitTask( ) ) ) {
  544. return( -1 );
  545. }
  546. //
  547. // If we got through it, must be OK to continue
  548. //
  549. return( 0 );
  550. }
  551. CQuickStartIntro::~CQuickStartIntro( )
  552. {
  553. WsbTraceIn( L"CQuickStartIntro::~CQuickStartIntro", L"" );
  554. WsbTraceOut( L"CQuickStartIntro::~CQuickStartIntro", L"" );
  555. }
  556. void CQuickStartIntro::DoDataExchange(CDataExchange* pDX)
  557. {
  558. WsbTraceIn( L"CQuickStartIntro::DoDataExchange", L"" );
  559. CSakWizardPage::DoDataExchange(pDX);
  560. //{{AFX_DATA_MAP(CQuickStartIntro)
  561. // NOTE: the ClassWizard will add DDX and DDV calls here
  562. //}}AFX_DATA_MAP
  563. WsbTraceOut( L"CQuickStartIntro::DoDataExchange", L"" );
  564. }
  565. BOOL CQuickStartIntro::OnInitDialog( )
  566. {
  567. WsbTraceIn( L"CQuickStartIntro::OnInitDialog", L"" );
  568. CSakWizardPage::OnInitDialog( );
  569. WsbTraceOut( L"CQuickStartIntro::OnInitDialog", L"" );
  570. return TRUE;
  571. }
  572. BOOL CQuickStartIntro::OnSetActive( )
  573. {
  574. WsbTraceIn( L"CQuickStartIntro::OnSetActive", L"" );
  575. BOOL retval = CSakWizardPage::OnSetActive( );
  576. m_pSheet->SetWizardButtons( PSWIZB_NEXT );
  577. WsbTraceOut( L"CQuickStartIntro::OnSetActive", L"retval = <%ls>", WsbBoolAsString( retval ) );
  578. return( retval );
  579. }
  580. /////////////////////////////////////////////////////////////////////////////
  581. // CQuickStartInitialValues property page
  582. CQuickStartInitialValues::CQuickStartInitialValues() :
  583. CSakWizardPage_InitBaseInt( WIZ_QSTART_INITIAL_VAL )
  584. {
  585. WsbTraceIn( L"CQuickStartInitialValues::CQuickStartInitialValues", L"" );
  586. //{{AFX_DATA_INIT(CQuickStartInitialValues)
  587. //}}AFX_DATA_INIT
  588. WsbTraceOut( L"CQuickStartInitialValues::CQuickStartInitialValues", L"" );
  589. }
  590. CQuickStartInitialValues::~CQuickStartInitialValues( )
  591. {
  592. WsbTraceIn( L"CQuickStartInitialValues::~CQuickStartInitialValues", L"" );
  593. WsbTraceOut( L"CQuickStartInitialValues::~CQuickStartInitialValues", L"" );
  594. }
  595. void CQuickStartInitialValues::DoDataExchange(CDataExchange* pDX)
  596. {
  597. WsbTraceIn( L"CQuickStartInitialValues::DoDataExchange", L"" );
  598. CSakWizardPage::DoDataExchange(pDX);
  599. //{{AFX_DATA_MAP(CQuickStartInitialValues)
  600. DDX_Control(pDX, IDC_MINSIZE_BUDDY, m_MinSizeEdit);
  601. DDX_Control(pDX, IDC_FREESPACE_BUDDY, m_FreeSpaceEdit);
  602. DDX_Control(pDX, IDC_ACCESS_BUDDY, m_AccessEdit);
  603. DDX_Control(pDX, IDC_MINSIZE_SPIN, m_MinSizeSpinner);
  604. DDX_Control(pDX, IDC_FREESPACE_SPIN, m_FreeSpaceSpinner);
  605. DDX_Control(pDX, IDC_ACCESS_SPIN, m_AccessSpinner);
  606. //}}AFX_DATA_MAP
  607. WsbTraceOut( L"CQuickStartInitialValues::DoDataExchange", L"" );
  608. }
  609. BEGIN_MESSAGE_MAP(CQuickStartInitialValues, CSakWizardPage)
  610. //{{AFX_MSG_MAP(CQuickStartInitialValues)
  611. //}}AFX_MSG_MAP
  612. END_MESSAGE_MAP( )
  613. /////////////////////////////////////////////////////////////////////////////
  614. // CQuickStartInitialValues message handlers
  615. BOOL CQuickStartInitialValues::OnInitDialog( )
  616. {
  617. WsbTraceIn( L"CQuickStartInitialValues::OnInitDialog", L"" );
  618. CSakWizardPage::OnInitDialog( );
  619. HRESULT hr = S_OK;
  620. try {
  621. //
  622. // Set up the spinners
  623. //
  624. m_FreeSpaceSpinner.SetRange( HSMADMIN_MIN_FREESPACE, HSMADMIN_MAX_FREESPACE );
  625. m_MinSizeSpinner.SetRange( HSMADMIN_MIN_MINSIZE, HSMADMIN_MAX_MINSIZE );
  626. m_AccessSpinner.SetRange( HSMADMIN_MIN_INACTIVITY, HSMADMIN_MAX_INACTIVITY );
  627. m_FreeSpaceSpinner.SetPos( HSMADMIN_DEFAULT_FREESPACE );
  628. m_MinSizeSpinner.SetPos( HSMADMIN_DEFAULT_MINSIZE );
  629. m_AccessSpinner.SetPos( HSMADMIN_DEFAULT_INACTIVITY );
  630. m_FreeSpaceEdit.SetLimitText( 2 );
  631. m_MinSizeEdit.SetLimitText( 5 );
  632. m_AccessEdit.SetLimitText( 3 );
  633. } WsbCatch( hr );
  634. WsbTraceOut( L"CQuickStartInitialValues::OnInitDialog", L"" );
  635. return TRUE;
  636. }
  637. BOOL CQuickStartInitialValues::OnSetActive( )
  638. {
  639. WsbTraceIn( L"CQuickStartInitialValues::OnSetActive", L"" );
  640. BOOL retval = FALSE;
  641. //
  642. // Make sure at least one item is checked before allowing active
  643. //
  644. BOOL check = FALSE;
  645. CSakVolList &listBox = QSHEET->m_ManageRes.m_ListBox;
  646. for( INT i = 0; ( i < listBox.GetItemCount( ) ) && !check; i++ ) {
  647. if( listBox.GetCheck( i ) ) check = TRUE;
  648. }
  649. if( check ) {
  650. retval = CSakWizardPage::OnSetActive( );
  651. m_pSheet->SetWizardButtons( PSWIZB_BACK | PSWIZB_NEXT );
  652. }
  653. WsbTraceOut( L"CQuickStartInitialValues::OnSetActive", L"retval = <%ls>", WsbBoolAsString( retval ) );
  654. return( retval );
  655. }
  656. BOOL CQuickStartInitialValues::OnKillActive( )
  657. {
  658. WsbTraceIn( L"CQuickStartInitialValues::OnKillActive", L"" );
  659. BOOL retval = FALSE;
  660. //
  661. // Need to handle strange case where a user can enter a value within
  662. // the parameters of the number of digits allowed, but the value can
  663. // be out of range. This is detected by the spin box which will
  664. // return an error if its buddy control is out of range.
  665. //
  666. if( HIWORD( m_MinSizeSpinner.GetPos( ) ) > 0 ) {
  667. // Control reports on error...
  668. retval = FALSE;
  669. CString message;
  670. AfxFormatString2( message, IDS_ERR_MINSIZE_RANGE,
  671. CString( WsbLongAsString( (LONG)HSMADMIN_MIN_MINSIZE ) ),
  672. CString( WsbLongAsString( (LONG)HSMADMIN_MAX_MINSIZE ) ) );
  673. AfxMessageBox( message, MB_OK | MB_ICONWARNING );
  674. } else {
  675. retval = CSakWizardPage::OnKillActive();
  676. }
  677. WsbTraceOut( L"CQuickStartInitialValues::OnKillActive", L"retval = <%ls>", WsbBoolAsString( retval ) );
  678. return( retval );
  679. }
  680. /////////////////////////////////////////////////////////////////////////////
  681. // CQuickStartManageRes property page
  682. CQuickStartManageRes::CQuickStartManageRes() :
  683. CSakWizardPage_InitBaseInt( WIZ_QSTART_MANRES_SEL )
  684. {
  685. WsbTraceIn( L"CQuickStartManageRes::CQuickStartManageRes", L"" );
  686. //{{AFX_DATA_INIT(CQuickStartManageRes)
  687. //}}AFX_DATA_INIT
  688. WsbTraceOut( L"CQuickStartManageRes::CQuickStartManageRes", L"" );
  689. }
  690. CQuickStartManageRes::~CQuickStartManageRes( )
  691. {
  692. WsbTraceIn( L"CQuickStartManageRes::~CQuickStartManageRes", L"" );
  693. WsbTraceOut( L"CQuickStartManageRes::~CQuickStartManageRes", L"" );
  694. }
  695. void CQuickStartManageRes::DoDataExchange(CDataExchange* pDX)
  696. {
  697. WsbTraceIn( L"CQuickStartManageRes::DoDataExchange", L"" );
  698. CSakWizardPage::DoDataExchange(pDX);
  699. //{{AFX_DATA_MAP(CQuickStartManageRes)
  700. DDX_Control(pDX, IDC_MANRES_SELECT, m_ListBox);
  701. DDX_Control(pDX, IDC_RADIO_SELECT, m_RadioSelect);
  702. //}}AFX_DATA_MAP
  703. WsbTraceOut( L"CQuickStartManageRes::DoDataExchange", L"" );
  704. }
  705. BEGIN_MESSAGE_MAP(CQuickStartManageRes, CSakWizardPage)
  706. //{{AFX_MSG_MAP(CQuickStartManageRes)
  707. ON_WM_DESTROY( )
  708. ON_LBN_DBLCLK(IDC_MANRES_SELECT, OnDblclkSelect)
  709. ON_BN_CLICKED(IDC_RADIO_MANAGE_ALL, OnRadioQsManageAll)
  710. ON_BN_CLICKED(IDC_RADIO_SELECT, OnQsRadioSelect)
  711. ON_NOTIFY(LVN_ITEMCHANGED, IDC_MANRES_SELECT, OnItemchanged)
  712. //}}AFX_MSG_MAP
  713. END_MESSAGE_MAP( )
  714. /////////////////////////////////////////////////////////////////////////////
  715. // CQuickStartManageRes message handlers
  716. BOOL CQuickStartManageRes::OnInitDialog( )
  717. {
  718. WsbTraceIn( L"CQuickStartManageRes::OnInitDialog", L"" );
  719. CSakWizardPage::OnInitDialog( );
  720. BOOL gotOne = FALSE;
  721. HRESULT hr = S_OK;
  722. CResourceInfo* pResInfo = 0;
  723. try {
  724. //
  725. // Connect to the FSA for this machine
  726. //
  727. CWsbStringPtr computerName;
  728. WsbAffirmHr( WsbGetComputerName( computerName ) );
  729. CComPtr<IFsaServer> pFsaServer;
  730. WsbAffirmHr( QSHEET->GetFsaServer( pFsaServer ) );
  731. CComPtr<IWsbEnum> pEnum;
  732. WsbAffirmHr( pFsaServer->EnumResources( &pEnum ) );
  733. HRESULT hrEnum;
  734. CComPtr<IFsaResource> pResource;
  735. hrEnum = pEnum->First( IID_IFsaResource, (void**)&pResource );
  736. WsbAffirm( SUCCEEDED( hrEnum ) || ( WSB_E_NOTFOUND == hrEnum ), hrEnum );
  737. INT index = 0;
  738. while( SUCCEEDED( hrEnum ) ) {
  739. //
  740. // If path is blank, do not show this volume
  741. //
  742. if( S_OK == RsIsVolumeAvailable( pResource ) ) {
  743. gotOne = TRUE;
  744. pResInfo = new CResourceInfo( pResource );
  745. WsbAffirmAlloc( pResInfo );
  746. WsbAffirmHr( pResInfo->m_HrConstruct );
  747. //
  748. // Set Name, Capacity and Free Space columns.
  749. //
  750. WsbAffirm( LB_ERR != index, E_FAIL );
  751. LONGLONG totalSpace = 0;
  752. LONGLONG freeSpace = 0;
  753. LONGLONG premigrated = 0;
  754. LONGLONG truncated = 0;
  755. WsbAffirmHr( pResource->GetSizes( &totalSpace, &freeSpace, &premigrated, &truncated ) );
  756. CString totalString, freeString;
  757. RsGuiFormatLongLong4Char( totalSpace, totalString );
  758. RsGuiFormatLongLong4Char( freeSpace, freeString );
  759. WsbAffirm( m_ListBox.AppendItem( pResInfo->m_DisplayName, totalString, freeString, &index ), E_FAIL );
  760. WsbAffirm( -1 != index, E_FAIL );
  761. //
  762. // Store struct pointer in listbox
  763. //
  764. WsbAffirm( m_ListBox.SetItemData( index, (DWORD_PTR)pResInfo ), E_FAIL );
  765. pResInfo = 0;
  766. //
  767. // Initialize selected array
  768. //
  769. m_ListBoxSelected[ index ] = FALSE;
  770. }
  771. //
  772. // Prepare for next iteration
  773. //
  774. pResource.Release( );
  775. hrEnum = pEnum->Next( IID_IFsaResource, (void**)&pResource );
  776. }
  777. m_ListBox.SortItems( CResourceInfo::Compare, 0 );
  778. //
  779. // Set the button AFTER we fill the box
  780. //
  781. CheckRadioButton( IDC_RADIO_MANAGE_ALL, IDC_RADIO_SELECT, IDC_RADIO_SELECT );
  782. OnQsRadioSelect( );
  783. } WsbCatch( hr );
  784. if( pResInfo ) delete pResInfo;
  785. WsbTraceOut( L"CQuickStartManageRes::OnInitDialog", L"" );
  786. return TRUE;
  787. }
  788. BOOL CQuickStartManageRes::OnSetActive( )
  789. {
  790. WsbTraceIn( L"CQuickStartManageRes::OnSetActive", L"" );
  791. BOOL retval = CSakWizardPage::OnSetActive( );
  792. if( m_ListBox.GetItemCount( ) <= 0 ) {
  793. retval = FALSE;
  794. }
  795. SetButtons( );
  796. WsbTraceOut( L"CQuickStartManageRes::OnSetActive", L"retval = <%ls>", WsbBoolAsString( retval ) );
  797. return( retval );
  798. }
  799. void CQuickStartManageRes::OnItemchanged(NMHDR* pNMHDR, LRESULT* pResult)
  800. {
  801. WsbTraceIn( L"CQuickStartManageRes::OnItemchanged", L"" );
  802. NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
  803. SetButtons();
  804. *pResult = 0;
  805. WsbTraceOut( L"CQuickStartManageRes::OnItemchanged", L"" );
  806. }
  807. void CQuickStartManageRes::OnDblclkSelect( )
  808. {
  809. WsbTraceIn( L"CQuickStartManageRes::OnDblclkSelect", L"" );
  810. SetButtons( );
  811. WsbTraceOut( L"CQuickStartManageRes::OnDblclkSelect", L"" );
  812. }
  813. void CQuickStartManageRes::SetButtons( )
  814. {
  815. WsbTraceIn( L"CQuickStartManageRes::SetButtons", L"" );
  816. BOOL fChecked = FALSE;
  817. INT count;
  818. // Is the "all" radio checked?
  819. if( !m_RadioSelect.GetCheck() ) {
  820. fChecked = TRUE;
  821. } else {
  822. // If one or more selected in the list box, set next button
  823. count = m_ListBox.GetItemCount();
  824. for( INT index = 0; index < count; index++ ) {
  825. if( m_ListBox.GetCheck( index ) ) {
  826. fChecked = TRUE;
  827. }
  828. }
  829. }
  830. m_pSheet->SetWizardButtons( PSWIZB_NEXT );
  831. WsbTraceOut( L"CQuickStartManageRes::SetButtons", L"" );
  832. }
  833. void CQuickStartManageRes::OnDestroy( )
  834. {
  835. WsbTraceIn( L"CQuickStartManageRes::OnDestroy", L"" );
  836. CSakWizardPage::OnDestroy( );
  837. //
  838. // Cleanup the listbox's interface pointers
  839. // happens when the CResourceInfo is destructed
  840. //
  841. INT index;
  842. for( index = 0; index < m_ListBox.GetItemCount( ); index++ ) {
  843. CResourceInfo* pResInfo = (CResourceInfo*)m_ListBox.GetItemData( index );
  844. delete pResInfo;
  845. }
  846. WsbTraceOut( L"CQuickStartManageRes::OnDestroy", L"" );
  847. }
  848. void CQuickStartManageRes::OnRadioQsManageAll()
  849. {
  850. INT i;
  851. //
  852. // Save the current selection in the itemData array
  853. // Check all the boxes for display purposes only
  854. //
  855. for( i = 0; i < m_ListBox.GetItemCount(); i++ ) {
  856. m_ListBoxSelected[ i ] = m_ListBox.GetCheck( i );
  857. m_ListBox.SetCheck( i, TRUE );
  858. }
  859. m_ListBox.EnableWindow( FALSE );
  860. SetButtons();
  861. }
  862. void CQuickStartManageRes::OnQsRadioSelect()
  863. {
  864. INT i;
  865. // Get saved selection from itemdata array
  866. for( i = 0; i < m_ListBox.GetItemCount(); i++ ) {
  867. m_ListBox.SetCheck( i, m_ListBoxSelected[ i ] );
  868. }
  869. m_ListBox.EnableWindow( TRUE );
  870. SetButtons();
  871. }
  872. /////////////////////////////////////////////////////////////////////////////
  873. // CQuickStartManageResX property page
  874. CQuickStartManageResX::CQuickStartManageResX() :
  875. CSakWizardPage_InitBaseInt( WIZ_QSTART_MANRES_SELX )
  876. {
  877. WsbTraceIn( L"CQuickStartManageResX::CQuickStartManageResX", L"" );
  878. //{{AFX_DATA_INIT(CQuickStartManageResX)
  879. //}}AFX_DATA_INIT
  880. WsbTraceOut( L"CQuickStartManageResX::CQuickStartManageResX", L"" );
  881. }
  882. CQuickStartManageResX::~CQuickStartManageResX( )
  883. {
  884. WsbTraceIn( L"CQuickStartManageResX::~CQuickStartManageResX", L"" );
  885. WsbTraceOut( L"CQuickStartManageResX::~CQuickStartManageResX", L"" );
  886. }
  887. void CQuickStartManageResX::DoDataExchange(CDataExchange* pDX)
  888. {
  889. WsbTraceIn( L"CQuickStartManageResX::DoDataExchange", L"" );
  890. CSakWizardPage::DoDataExchange(pDX);
  891. //{{AFX_DATA_MAP(CQuickStartManageResX)
  892. //}}AFX_DATA_MAP
  893. WsbTraceOut( L"CQuickStartManageResX::DoDataExchange", L"" );
  894. }
  895. BEGIN_MESSAGE_MAP(CQuickStartManageResX, CSakWizardPage)
  896. //{{AFX_MSG_MAP(CQuickStartManageResX)
  897. //}}AFX_MSG_MAP
  898. END_MESSAGE_MAP( )
  899. /////////////////////////////////////////////////////////////////////////////
  900. // CQuickStartManageResX message handlers
  901. BOOL CQuickStartManageResX::OnSetActive( )
  902. {
  903. WsbTraceIn( L"CQuickStartManageResX::OnSetActive", L"" );
  904. BOOL retval = CSakWizardPage::OnSetActive( );
  905. if( QSHEET->m_ManageRes.m_ListBox.GetItemCount( ) > 0 ) {
  906. retval = FALSE;
  907. }
  908. m_pSheet->SetWizardButtons( PSWIZB_NEXT );
  909. WsbTraceOut( L"CQuickStartManageResX::OnSetActive", L"retval = <%ls>", WsbBoolAsString( retval ) );
  910. return( retval );
  911. }
  912. /////////////////////////////////////////////////////////////////////////////
  913. // CQuickStartMediaSel property page
  914. CQuickStartMediaSel::CQuickStartMediaSel() :
  915. CSakWizardPage_InitBaseInt( WIZ_QSTART_MEDIA_SEL )
  916. {
  917. WsbTraceIn( L"CQuickStartMediaSel::CQuickStartMediaSel", L"" );
  918. //{{AFX_DATA_INIT(CQuickStartMediaSel)
  919. // NOTE: the ClassWizard will add member initialization here
  920. //}}AFX_DATA_INIT
  921. WsbTraceOut( L"CQuickStartMediaSel::CQuickStartMediaSel", L"" );
  922. }
  923. CQuickStartMediaSel::~CQuickStartMediaSel( )
  924. {
  925. WsbTraceIn( L"CQuickStartMediaSel::~CQuickStartMediaSel", L"" );
  926. WsbTraceOut( L"CQuickStartMediaSel::~CQuickStartMediaSel", L"" );
  927. }
  928. void CQuickStartMediaSel::DoDataExchange(CDataExchange* pDX)
  929. {
  930. WsbTraceIn( L"CQuickStartMediaSel::DoDataExchange", L"" );
  931. CSakWizardPage::DoDataExchange(pDX);
  932. //{{AFX_DATA_MAP(CQuickStartMediaSel)
  933. DDX_Control(pDX, IDC_MEDIA_SEL, m_ListMediaSel);
  934. //}}AFX_DATA_MAP
  935. WsbTraceOut( L"CQuickStartMediaSel::DoDataExchange", L"" );
  936. }
  937. BEGIN_MESSAGE_MAP(CQuickStartMediaSel, CSakWizardPage)
  938. //{{AFX_MSG_MAP(CQuickStartMediaSel)
  939. ON_WM_DESTROY()
  940. ON_LBN_SELCHANGE(IDC_MEDIA_SEL, OnSelchangeMediaSel)
  941. //}}AFX_MSG_MAP
  942. END_MESSAGE_MAP( )
  943. BOOL CQuickStartMediaSel::OnInitDialog()
  944. {
  945. WsbTraceIn( L"CQuickStartMediaSel::OnInitDialog", L"" );
  946. HRESULT hr = 0;
  947. ULONG numEntries;
  948. CSakWizardPage::OnInitDialog();
  949. try {
  950. //
  951. // Get IRmsServer
  952. //
  953. CComPtr<IRmsServer> pRmsServer;
  954. WsbAffirmHr( QSHEET->GetRmsServer( pRmsServer ) );
  955. //
  956. // Get collection of Rms media sets
  957. //
  958. CComPtr<IRmsMediaSet> pMediaSet;
  959. CComPtr<IWsbIndexedCollection> pMediaSets;
  960. pRmsServer->GetMediaSets (&pMediaSets);
  961. WsbAffirmHr( pMediaSets->GetEntries( &numEntries ) );
  962. for( ULONG i = 0; i < numEntries; i++ ) {
  963. CWsbBstrPtr szMediaType;
  964. pMediaSet.Release();
  965. WsbAffirmHr( pMediaSets->At( i, IID_IRmsMediaSet, (void**) &pMediaSet ) );
  966. WsbAffirmHr( pMediaSet->GetName ( &szMediaType ) );
  967. //
  968. // Add the string to the listbox
  969. //
  970. INT index = m_ListMediaSel.AddString (szMediaType);
  971. //
  972. // Add the interface pointer to the list box
  973. //
  974. m_ListMediaSel.SetItemDataPtr( index, pMediaSet.Detach( ) );
  975. }
  976. //
  977. // And automatically select the first entry
  978. //
  979. m_ListMediaSel.SetCurSel( 0 );
  980. } WsbCatch (hr);
  981. WsbTraceOut( L"CQuickStartMediaSel::OnInitDialog", L"" );
  982. return TRUE;
  983. }
  984. /////////////////////////////////////////////////////////////////////////////
  985. // CQuickStartMediaSel message handlers
  986. void CQuickStartMediaSel::OnDestroy()
  987. {
  988. WsbTraceIn( L"CQuickStartMediaSel::OnDestroy", L"" );
  989. CSakWizardPage::OnDestroy();
  990. //
  991. // Cleanup the listbox's interface pointers
  992. //
  993. INT index;
  994. for( index = 0; index < m_ListMediaSel.GetCount( ); index++ ) {
  995. IRmsMediaSet* pMediaSet = (IRmsMediaSet*) (m_ListMediaSel.GetItemDataPtr( index ));
  996. pMediaSet->Release( );
  997. }
  998. WsbTraceOut( L"CQuickStartMediaSel::OnDestroy", L"" );
  999. }
  1000. void CQuickStartMediaSel::SetButtons( )
  1001. {
  1002. WsbTraceIn( L"CQuickStartMediaSel::SetButtons", L"" );
  1003. //
  1004. // Make sure at least one item is checked before allowing "next"
  1005. //
  1006. if( m_ListMediaSel.GetCurSel() != LB_ERR ) {
  1007. //
  1008. // Something is selected
  1009. //
  1010. m_pSheet->SetWizardButtons( PSWIZB_BACK | PSWIZB_NEXT );
  1011. } else {
  1012. //
  1013. // Nothing selected - don't allow to pass
  1014. //
  1015. m_pSheet->SetWizardButtons( PSWIZB_BACK );
  1016. }
  1017. WsbTraceOut( L"CQuickStartMediaSel::SetButtons", L"" );
  1018. }
  1019. BOOL CQuickStartMediaSel::OnSetActive( )
  1020. {
  1021. WsbTraceIn( L"CQuickStartMediaSel::OnSetActive", L"" );
  1022. SetButtons( );
  1023. BOOL retval = CSakWizardPage::OnSetActive( );
  1024. WsbTraceOut( L"CQuickStartMediaSel::OnSetActive", L"retval = <%ls>", WsbBoolAsString( retval ) );
  1025. return( retval );
  1026. }
  1027. void CQuickStartMediaSel::OnSelchangeMediaSel()
  1028. {
  1029. WsbTraceIn( L"CQuickStartMediaSel::OnSelchangeMediaSel", L"" );
  1030. SetButtons( );
  1031. WsbTraceOut( L"CQuickStartMediaSel::OnSelchangeMediaSel", L"" );
  1032. }
  1033. /////////////////////////////////////////////////////////////////////////////
  1034. // CQuickStartSchedule property page
  1035. CQuickStartSchedule::CQuickStartSchedule() :
  1036. CSakWizardPage_InitBaseInt( WIZ_QSTART_SCHEDULE )
  1037. {
  1038. WsbTraceIn( L"CQuickStartSchedule::CQuickStartSchedule", L"" );
  1039. //{{AFX_DATA_INIT(CQuickStartSchedule)
  1040. // NOTE: the ClassWizard will add member initialization here
  1041. //}}AFX_DATA_INIT
  1042. WsbTraceOut( L"CQuickStartSchedule::CQuickStartSchedule", L"" );
  1043. }
  1044. CQuickStartSchedule::~CQuickStartSchedule()
  1045. {
  1046. WsbTraceIn( L"CQuickStartSchedule::~CQuickStartSchedule", L"" );
  1047. WsbTraceOut( L"CQuickStartSchedule::~CQuickStartSchedule", L"" );
  1048. }
  1049. void CQuickStartSchedule::DoDataExchange(CDataExchange* pDX)
  1050. {
  1051. WsbTraceIn( L"CQuickStartSchedule::DoDataExchange", L"" );
  1052. CSakWizardPage::DoDataExchange(pDX);
  1053. //{{AFX_DATA_MAP(CQuickStartSchedule)
  1054. // NOTE: the ClassWizard will add DDX and DDV calls here
  1055. //}}AFX_DATA_MAP
  1056. WsbTraceOut( L"CQuickStartSchedule::DoDataExchange", L"" );
  1057. }
  1058. BEGIN_MESSAGE_MAP(CQuickStartSchedule, CSakWizardPage)
  1059. //{{AFX_MSG_MAP(CQuickStartSchedule)
  1060. ON_BN_CLICKED(IDC_CHANGE_SCHED, OnChangeSchedule)
  1061. //}}AFX_MSG_MAP
  1062. END_MESSAGE_MAP()
  1063. /////////////////////////////////////////////////////////////////////////////
  1064. // CQuickStartSchedule message handlers
  1065. void CQuickStartSchedule::OnChangeSchedule()
  1066. {
  1067. WsbTraceIn( L"CQuickStartSchedule::OnChangeSchedule", L"" );
  1068. CScheduleSheet scheduleSheet( IDS_SCHED_MANAGE_TITLE, QSHEET->m_pTask, 0, 0 );
  1069. scheduleSheet.DoModal( );
  1070. UpdateDescription( );
  1071. WsbTraceOut( L"CQuickStartSchedule::OnChangeSchedule", L"" );
  1072. }
  1073. BOOL CQuickStartSchedule::OnSetActive()
  1074. {
  1075. WsbTraceIn( L"CQuickStartSchedule::OnSetActive", L"" );
  1076. CSakWizardPage::OnSetActive();
  1077. //
  1078. // Enable buttons
  1079. //
  1080. m_pSheet->SetWizardButtons( PSWIZB_BACK | PSWIZB_NEXT );
  1081. //
  1082. // Update the text box which has the description
  1083. //
  1084. UpdateDescription( );
  1085. WsbTraceOut( L"CQuickStartSchedule::OnSetActive", L"" );
  1086. return TRUE;
  1087. }
  1088. HRESULT
  1089. CQuickStartSchedule::UpdateDescription
  1090. (
  1091. void
  1092. )
  1093. {
  1094. WsbTraceIn( L"CQuickStartSchedule::UpdateDescription", L"" );
  1095. HRESULT hr = S_OK;
  1096. try {
  1097. //
  1098. // And set schedule text into the text box.
  1099. //
  1100. CString buildString;
  1101. WORD triggerCount, triggerIndex;
  1102. WsbAffirmHr( QSHEET->m_pTask->GetTriggerCount( &triggerCount ) );
  1103. CWsbStringPtr scheduleString;
  1104. for( triggerIndex = 0; triggerIndex < triggerCount; triggerIndex++ ) {
  1105. WsbAffirmHr( QSHEET->m_pTask->GetTriggerString( triggerIndex, &scheduleString ) );
  1106. buildString += scheduleString;
  1107. buildString += L"\r\n";
  1108. scheduleString.Free( );
  1109. }
  1110. CEdit *pEdit = (CEdit *) GetDlgItem( IDC_SCHED_TEXT );
  1111. pEdit->SetWindowText( buildString );
  1112. //
  1113. // Now check to see if we should add a scroll bar
  1114. //
  1115. //
  1116. // It seems the only way to know that an edit control needs a scrollbar
  1117. // is to force it to scroll to the bottom and see if the first
  1118. // visible line is the first actual line
  1119. //
  1120. pEdit->LineScroll( MAXSHORT );
  1121. if( pEdit->GetFirstVisibleLine( ) > 0 ) {
  1122. //
  1123. // Add the scroll styles
  1124. //
  1125. pEdit->ModifyStyle( 0, WS_VSCROLL | ES_AUTOVSCROLL, SWP_DRAWFRAME );
  1126. } else {
  1127. //
  1128. // Remove the scrollbar (set range to 0)
  1129. //
  1130. pEdit->SetScrollRange( SB_VERT, 0, 0, TRUE );
  1131. }
  1132. //
  1133. // Remove selection
  1134. //
  1135. pEdit->PostMessage( EM_SETSEL, -1, 0 );
  1136. } WsbCatch( hr );
  1137. WsbTraceOut( L"CQuickStartSchedule::UpdateDescription", L"hr = <%ls>", WsbHrAsString( hr ) );
  1138. return( hr );
  1139. }
  1140. /////////////////////////////////////////////////////////////////////////////
  1141. // CQuickStartFinish property page
  1142. CQuickStartFinish::CQuickStartFinish() :
  1143. CSakWizardPage_InitBaseExt( WIZ_QSTART_FINISH )
  1144. {
  1145. WsbTraceIn( L"CQuickStartFinish::CQuickStartFinish", L"" );
  1146. //{{AFX_DATA_INIT(CQuickStartFinish)
  1147. // NOTE: the ClassWizard will add member initialization here
  1148. //}}AFX_DATA_INIT
  1149. WsbTraceOut( L"CQuickStartFinish::CQuickStartFinish", L"" );
  1150. }
  1151. CQuickStartFinish::~CQuickStartFinish( )
  1152. {
  1153. WsbTraceIn( L"CQuickStartFinish::~CQuickStartFinish", L"" );
  1154. WsbTraceOut( L"CQuickStartFinish::~CQuickStartFinish", L"" );
  1155. }
  1156. void CQuickStartFinish::DoDataExchange(CDataExchange* pDX)
  1157. {
  1158. WsbTraceIn( L"CQuickStartFinish::DoDataExchange", L"" );
  1159. CSakWizardPage::DoDataExchange(pDX);
  1160. //{{AFX_DATA_MAP(CQuickStartFinish)
  1161. // NOTE: the ClassWizard will add DDX and DDV calls here
  1162. //}}AFX_DATA_MAP
  1163. WsbTraceOut( L"CQuickStartFinish::DoDataExchange", L"" );
  1164. }
  1165. BEGIN_MESSAGE_MAP(CQuickStartFinish, CSakWizardPage)
  1166. //{{AFX_MSG_MAP(CQuickStartFinish)
  1167. ON_EN_SETFOCUS(IDC_WIZ_FINAL_TEXT, OnSetFocusFinalText)
  1168. //}}AFX_MSG_MAP
  1169. END_MESSAGE_MAP( )
  1170. /////////////////////////////////////////////////////////////////////////////
  1171. // CQuickStartFinish message handlers
  1172. BOOL CQuickStartFinish::OnInitDialog( )
  1173. {
  1174. WsbTraceIn( L"CQuickStartFinish::OnInitDialog", L"" );
  1175. //
  1176. // Set up the fonts that we use for this page
  1177. //
  1178. CSakWizardPage::OnInitDialog( );
  1179. WsbTraceOut( L"CQuickStartFinish::OnInitDialog", L"" );
  1180. return TRUE;
  1181. }
  1182. BOOL CQuickStartFinish::OnSetActive( )
  1183. {
  1184. WsbTraceIn( L"CQuickStartFinish::OnSetActive", L"" );
  1185. CSakWizardPage::OnSetActive( );
  1186. m_pSheet->SetWizardButtons( PSWIZB_BACK | PSWIZB_FINISH );
  1187. //
  1188. // Fill in text of configuration
  1189. //
  1190. CString formatString, formattedString, buildString, tempString, indentString;
  1191. indentString.LoadString( IDS_QSTART_FINISH_INDENT );
  1192. #define FORMAT_TEXT( cid, arg ) \
  1193. AfxFormatString1( formattedString, cid, arg ); \
  1194. buildString += formattedString;
  1195. FORMAT_TEXT( IDS_QSTART_MANRES_TEXT, 0 );
  1196. buildString += L"\r\n";
  1197. //
  1198. // Add Resources
  1199. //
  1200. CSakVolList *pListBox = &(QSHEET->m_ManageRes.m_ListBox);
  1201. INT index, managedCount = 0;
  1202. for( index = 0; index < pListBox->GetItemCount( ); index++ ) {
  1203. if( pListBox->GetCheck( index ) ) {
  1204. buildString += indentString;
  1205. tempString = pListBox->GetItemText( index, 0 );
  1206. buildString += tempString;
  1207. buildString += L"\r\n";
  1208. managedCount++;
  1209. }
  1210. }
  1211. if( 0 == managedCount ) {
  1212. FORMAT_TEXT( IDS_QSTART_MANAGE_NO_VOLUMES, 0 );
  1213. buildString += L"\r\n\r\n";
  1214. } else {
  1215. buildString += L"\r\n";
  1216. //
  1217. // The levels
  1218. //
  1219. FORMAT_TEXT( IDS_QSTART_FREESPACE_TEXT, WsbLongAsString( QSHEET->m_InitialValues.m_FreeSpaceSpinner.GetPos( ) ) );
  1220. buildString += L"\r\n\r\n";
  1221. AfxFormatString2( formattedString, IDS_QSTART_CRITERIA_TEXT,
  1222. CString( WsbLongAsString( QSHEET->m_InitialValues.m_MinSizeSpinner.GetPos( ) ) ),
  1223. CString( WsbLongAsString( QSHEET->m_InitialValues.m_AccessSpinner.GetPos( ) ) ) );
  1224. buildString += formattedString;
  1225. buildString += L"\r\n\r\n";
  1226. }
  1227. //
  1228. // Media Type
  1229. //
  1230. QSHEET->m_MediaSel.m_ListMediaSel.GetWindowText( tempString );
  1231. FORMAT_TEXT( IDS_QSTART_MEDIA_TEXT, tempString );
  1232. buildString += L"\r\n\r\n";
  1233. //
  1234. // And Schedule
  1235. //
  1236. FORMAT_TEXT( IDS_QSTART_SCHED_TEXT, 0 );
  1237. buildString += L"\r\n";
  1238. WORD triggerCount, triggerIndex;
  1239. QSHEET->m_pTask->GetTriggerCount( &triggerCount );
  1240. CWsbStringPtr scheduleString;
  1241. for( triggerIndex = 0; triggerIndex < triggerCount; triggerIndex++ ) {
  1242. QSHEET->m_pTask->GetTriggerString( triggerIndex, &scheduleString );
  1243. buildString += indentString;
  1244. buildString += scheduleString;
  1245. if( triggerIndex < triggerCount - 1 ) {
  1246. buildString += L"\r\n";
  1247. }
  1248. scheduleString.Free( );
  1249. }
  1250. CEdit * pEdit = (CEdit*)GetDlgItem( IDC_WIZ_FINAL_TEXT );
  1251. pEdit->SetWindowText( buildString );
  1252. // Set the margins
  1253. pEdit->SetMargins( 4, 4 );
  1254. pEdit->PostMessage( EM_SETSEL, 0, 0 );
  1255. pEdit->PostMessage( EM_SCROLLCARET, 0, 0 );
  1256. pEdit->PostMessage( EM_SETSEL, -1, 0 );
  1257. WsbTraceOut( L"CQuickStartFinish::OnSetActive", L"" );
  1258. return TRUE;
  1259. }
  1260. void CQuickStartFinish::OnSetFocusFinalText()
  1261. {
  1262. WsbTraceIn( L"CQuickStartFinish::OnSetFocusFinalText", L"" );
  1263. //
  1264. // Deselect the text
  1265. //
  1266. CEdit *pEdit = (CEdit *) GetDlgItem( IDC_WIZ_FINAL_TEXT );
  1267. pEdit->SetSel( -1, 0, FALSE );
  1268. WsbTraceOut( L"CQuickStartFinish::OnSetFocusFinalText", L"" );
  1269. }
  1270. /////////////////////////////////////////////////////////////////////////////
  1271. // CQuickStartCheck property page
  1272. CQuickStartCheck::CQuickStartCheck() :
  1273. CSakWizardPage_InitBaseInt( WIZ_QSTART_CHECK )
  1274. {
  1275. WsbTraceIn( L"CQuickStartCheck::CQuickStartCheck", L"" );
  1276. m_TimerStarted = FALSE;
  1277. //{{AFX_DATA_INIT(CQuickStartCheck)
  1278. // NOTE: the ClassWizard will add member initialization here
  1279. //}}AFX_DATA_INIT
  1280. WsbTraceOut( L"CQuickStartCheck::CQuickStartCheck", L"" );
  1281. }
  1282. CQuickStartCheck::~CQuickStartCheck()
  1283. {
  1284. WsbTraceIn( L"CQuickStartCheck::~CQuickStartCheck", L"" );
  1285. WsbTraceOut( L"CQuickStartCheck::~CQuickStartCheck", L"" );
  1286. }
  1287. void CQuickStartCheck::DoDataExchange(CDataExchange* pDX)
  1288. {
  1289. WsbTraceIn( L"CQuickStartCheck::DoDataExchange", L"" );
  1290. CSakWizardPage::DoDataExchange(pDX);
  1291. //{{AFX_DATA_MAP(CQuickStartCheck)
  1292. //}}AFX_DATA_MAP
  1293. WsbTraceOut( L"CQuickStartCheck::DoDataExchange", L"" );
  1294. }
  1295. BEGIN_MESSAGE_MAP(CQuickStartCheck, CSakWizardPage)
  1296. //{{AFX_MSG_MAP(CQuickStartCheck)
  1297. ON_WM_TIMER()
  1298. //}}AFX_MSG_MAP
  1299. END_MESSAGE_MAP()
  1300. /////////////////////////////////////////////////////////////////////////////
  1301. // CQuickStartCheck message handlers
  1302. BOOL CQuickStartCheck::OnSetActive()
  1303. {
  1304. WsbTraceIn( L"CQuickStartCheck::OnSetActive", L"" );
  1305. BOOL retval = CSakWizardPage::OnSetActive();
  1306. m_pSheet->SetWizardButtons( PSWIZB_BACK );
  1307. //
  1308. // Kick off the thread which will check the system
  1309. //
  1310. DWORD threadId;
  1311. QSHEET->m_CheckSysState = CST_NOT_STARTED;
  1312. QSHEET->m_hCheckSysThread =
  1313. CreateThread( 0, 1024, CQuickStartWizard::CheckSysThreadStart, QSHEET, 0, &threadId );
  1314. StartTimer( );
  1315. WsbTraceOut( L"CQuickStartCheck::OnSetActive", L"" );
  1316. return( retval );
  1317. }
  1318. BOOL CQuickStartCheck::OnKillActive()
  1319. {
  1320. WsbTraceIn( L"CQuickStartCheck::OnKillActive", L"" );
  1321. StopTimer( );
  1322. BOOL retval = CSakWizardPage::OnKillActive();
  1323. WsbTraceOut( L"CQuickStartCheck::OnKillActive", L"" );
  1324. return( retval );}
  1325. BOOL CQuickStartCheck::OnInitDialog()
  1326. {
  1327. WsbTraceIn( L"CQuickStartCheck::OnInitDialog", L"" );
  1328. CSakWizardPage::OnInitDialog();
  1329. GetDlgItem( IDC_CHECK_LOGON_BOX )->SetFont( GetWingDingFont( ) );
  1330. GetDlgItem( IDC_CHECK_SUPP_MEDIA_BOX )->SetFont( GetWingDingFont( ) );
  1331. m_CheckString = GetWingDingCheckChar( );
  1332. m_ExString = GetWingDingExChar( );
  1333. WsbTraceOut( L"CQuickStartCheck::OnInitDialog", L"" );
  1334. return TRUE;
  1335. }
  1336. void CQuickStartCheck::StartTimer( )
  1337. {
  1338. WsbTraceIn( L"CQuickStartCheck::StartTimer", L"" );
  1339. if( !m_TimerStarted ) {
  1340. m_TimerStarted = TRUE;
  1341. SetTimer( CHECK_SYSTEM_TIMER_ID, CHECK_SYSTEM_TIMER_MS, 0 );
  1342. }
  1343. WsbTraceOut( L"CQuickStartCheck::StartTimer", L"" );
  1344. }
  1345. void CQuickStartCheck::StopTimer( )
  1346. {
  1347. WsbTraceIn( L"CQuickStartCheck::StopTimer", L"" );
  1348. if( m_TimerStarted ) {
  1349. m_TimerStarted = FALSE;
  1350. KillTimer( CHECK_SYSTEM_TIMER_ID );
  1351. if( CST_DONE != QSHEET->m_CheckSysState ) {
  1352. TerminateThread( QSHEET->m_hCheckSysThread, 0 );
  1353. }
  1354. }
  1355. WsbTraceOut( L"CQuickStartCheck::StopTimer", L"" );
  1356. }
  1357. void CQuickStartCheck::OnTimer(UINT nIDEvent)
  1358. {
  1359. WsbTraceIn( L"CQuickStartCheck::OnTimer", L"" );
  1360. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  1361. if( CHECK_SYSTEM_TIMER_ID == nIDEvent ) {
  1362. HRESULT hr = S_OK;
  1363. try {
  1364. //
  1365. // First update the checkmarks
  1366. //
  1367. HRESULT hrThread = QSHEET->m_hrCheckSysResult;
  1368. CST_STATE state = QSHEET->m_CheckSysState;
  1369. SetDlgItemText( IDC_CHECK_LOGON_BOX, state > CST_ACCOUNT ? m_CheckString : L"" );
  1370. SetDlgItemText( IDC_CHECK_SUPP_MEDIA_BOX, state > CST_SUPP_MEDIA ? m_CheckString : L"" );
  1371. GetDlgItem( IDC_CHECK_LOGON_TEXT )->SetFont( CST_ACCOUNT == state ? GetBoldShellFont( ) : GetShellFont( ) );
  1372. GetDlgItem( IDC_CHECK_SUPP_MEDIA_TEXT )->SetFont( CST_SUPP_MEDIA == state ? GetBoldShellFont( ) : GetShellFont( ) );
  1373. switch( QSHEET->m_CheckSysState ) {
  1374. case CST_ACCOUNT:
  1375. if( hrThread == S_FALSE ) {
  1376. StopTimer( );
  1377. AfxMessageBox( IDS_ERR_NO_ADMIN_PRIV, RS_MB_ERROR );
  1378. m_pSheet->PressButton( PSBTN_CANCEL );
  1379. // m_pSheet->SetWizardButtons( PSWIZB_BACK );
  1380. }
  1381. break;
  1382. case CST_SUPP_MEDIA:
  1383. if( hrThread == S_FALSE ) {
  1384. StopTimer( );
  1385. AfxMessageBox( IDS_ERR_NO_SUPP_MEDIA, RS_MB_ERROR );
  1386. m_pSheet->PressButton( PSBTN_CANCEL );
  1387. // m_pSheet->SetWizardButtons( PSWIZB_BACK );
  1388. }
  1389. break;
  1390. case CST_DONE:
  1391. StopTimer( );
  1392. m_pSheet->PressButton( PSBTN_NEXT );
  1393. break;
  1394. }
  1395. if( FAILED( hrThread ) ) {
  1396. StopTimer( );
  1397. // Report any errors
  1398. RsReportError( hrThread, IDS_ERROR_SYSTEM_CHECK );
  1399. m_pSheet->PressButton( PSBTN_CANCEL );
  1400. // m_pSheet->SetWizardButtons( PSWIZB_BACK );
  1401. }
  1402. } WsbCatch( hr );
  1403. }
  1404. CSakWizardPage::OnTimer(nIDEvent);
  1405. WsbTraceOut( L"CQuickStartCheck::OnTimer", L"" );
  1406. }