Source code of Windows XP (NT5)
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.

165 lines
3.4 KiB

  1. #include "headers.hxx"
  2. #include "AnalisysPage.hpp"
  3. #include "resource.h"
  4. #include "common.hpp"
  5. #include "AnalisysResults.hpp"
  6. #include "CSVDSReader.hpp"
  7. #include "Analisys.hpp"
  8. #include "global.hpp"
  9. #include "constants.hpp"
  10. AnalisysPage::AnalisysPage
  11. (
  12. const CSVDSReader& csvReader409_,
  13. const CSVDSReader& csvReaderIntl_,
  14. const String& ldapPrefix_,
  15. const String& rootContainerDn_,
  16. AnalisysResults& res,
  17. const String& reportName_
  18. )
  19. :
  20. csvReader409(csvReader409_),
  21. csvReaderIntl(csvReaderIntl_),
  22. ldapPrefix(ldapPrefix_),
  23. rootContainerDn(rootContainerDn_),
  24. results(res),
  25. reportName(reportName_),
  26. WizardPage
  27. (
  28. IDD_ANALISYS,
  29. IDS_ANALISYS_PAGE_TITLE,
  30. IDS_ANALISYS_PAGE_SUBTITLE,
  31. true
  32. )
  33. {
  34. LOG_CTOR(AnalisysPage);
  35. }
  36. AnalisysPage::~AnalisysPage()
  37. {
  38. LOG_DTOR(AnalisysPage);
  39. }
  40. long WINAPI startAnalisys(long arg)
  41. {
  42. LOG_FUNCTION(startAnalisys);
  43. AnalisysPage *page=(AnalisysPage *)arg;
  44. Analisys analisys(
  45. page->csvReader409,
  46. page->csvReaderIntl,
  47. page->ldapPrefix,
  48. page->rootContainerDn,
  49. page->results,
  50. &page->reportName,
  51. page
  52. );
  53. // CoInitialize must be called per thread
  54. HRESULT hr = ::CoInitialize(0);
  55. ASSERT(SUCCEEDED(hr));
  56. hrError=analisys.run();
  57. CoUninitialize();
  58. page->FinishProgress();
  59. return 0;
  60. }
  61. // WizardPage overrides
  62. bool
  63. AnalisysPage::OnSetActive()
  64. {
  65. LOG_FUNCTION(AnalisysPage::OnSetActive);
  66. Win::PropSheet_SetWizButtons(Win::GetParent(hwnd), 0);
  67. pos=0;
  68. HANDLE hA=CreateThread(
  69. NULL,0,
  70. (LPTHREAD_START_ROUTINE) startAnalisys,
  71. this,
  72. 0, 0
  73. );
  74. CloseHandle(hA);
  75. return true;
  76. }
  77. void
  78. AnalisysPage::OnInit()
  79. {
  80. LOG_FUNCTION(AnalisysPage::OnInit);
  81. HWND prog=GetDlgItem(hwnd,IDC_PROGRESS_ANALISYS);
  82. // calculate the # of locales
  83. for(long t=0;LOCALEIDS[t]!=0;t++)
  84. {
  85. //empty
  86. }
  87. SendMessage(prog,PBM_SETRANGE,0,MAKELPARAM(0,t));
  88. };
  89. bool
  90. AnalisysPage::OnWizBack()
  91. {
  92. LOG_FUNCTION(AnalisysPage::OnWizBack);
  93. GetWizard().SetNextPageID(hwnd,IDD_WELCOME);
  94. return true;
  95. }
  96. bool
  97. AnalisysPage::OnWizNext()
  98. {
  99. LOG_FUNCTION(AnalisysPage::OnWizNext);
  100. if (FAILED(hrError))
  101. {
  102. GetWizard().SetNextPageID(hwnd,IDD_FINISH);
  103. }
  104. else
  105. {
  106. GetWizard().SetNextPageID(hwnd,IDD_UPDATES_REQUIRED);
  107. }
  108. return true;
  109. }
  110. void AnalisysPage::StepProgress()
  111. {
  112. LOG_FUNCTION(AnalisysPage::StepProgress);
  113. HWND prog=GetDlgItem(hwnd,IDC_PROGRESS_ANALISYS);
  114. SendMessage(prog,PBM_SETPOS,pos++,0);
  115. }
  116. void AnalisysPage::FinishProgress()
  117. {
  118. LOG_FUNCTION(AnalisysPage::FinishProgress);
  119. Win::PropSheet_SetWizButtons(Win::GetParent(hwnd),PSWIZB_NEXT);
  120. String result;
  121. if (FAILED(hrError))
  122. {
  123. result=String::format(IDS_IDC_ANALISYS_RESULT_INCOMPLETE);
  124. error=String::format(IDS_ANALISYS_ERROR,error.c_str());
  125. }
  126. else
  127. {
  128. result=String::format(IDS_IDC_ANALISYS_RESULT_COMPLETE);
  129. }
  130. Win::SetDlgItemText(hwnd,IDC_ANALISYS_RESULT,result);
  131. HWND text=GetDlgItem(hwnd,IDC_ANALISYS_RESULT);
  132. Win::ShowWindow(text,SW_SHOW);
  133. }