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.

150 lines
3.2 KiB

  1. #include "headers.hxx"
  2. #include "UpdatesPage.hpp"
  3. #include "resource.h"
  4. #include "common.hpp"
  5. #include "repair.hpp"
  6. #include "AnalisysResults.hpp"
  7. #include "CSVDSReader.hpp"
  8. UpdatesPage::UpdatesPage
  9. (
  10. const CSVDSReader& csvReader409_,
  11. const CSVDSReader& csvReaderIntl_,
  12. const String& domain_,
  13. const String& rootContainerDn_,
  14. const String& ldiffName_,
  15. const String& csvName_,
  16. const String& saveName_,
  17. const String& logPath_,
  18. AnalisysResults& res,
  19. bool *someRepairWasRun_
  20. )
  21. :
  22. csvReader409(csvReader409_),
  23. csvReaderIntl(csvReaderIntl_),
  24. domain(domain_),
  25. rootContainerDn(rootContainerDn_),
  26. ldiffName(ldiffName_),
  27. csvName(csvName_),
  28. saveName(saveName_),
  29. logPath(logPath_),
  30. results(res),
  31. someRepairWasRun(someRepairWasRun_),
  32. WizardPage
  33. (
  34. IDD_UPDATES,
  35. IDS_UPDATES_PAGE_TITLE,
  36. IDS_UPDATES_PAGE_SUBTITLE,
  37. true
  38. )
  39. {
  40. LOG_CTOR(UpdatesPage);
  41. }
  42. UpdatesPage::~UpdatesPage()
  43. {
  44. LOG_DTOR(UpdatesPage);
  45. }
  46. long WINAPI startRepair(long arg)
  47. {
  48. LOG_FUNCTION(startRepair);
  49. UpdatesPage *page=(UpdatesPage *)arg;
  50. HRESULT hr=S_OK;
  51. do
  52. {
  53. // CoInitialize must be called per thread
  54. hr = ::CoInitialize(0);
  55. ASSERT(SUCCEEDED(hr));
  56. Repair repair
  57. (
  58. page->csvReader409,
  59. page->csvReaderIntl,
  60. page->domain,
  61. page->rootContainerDn,
  62. page->results,
  63. page->ldiffName,
  64. page->csvName,
  65. page->saveName,
  66. page->logPath,
  67. page,
  68. page->someRepairWasRun
  69. );
  70. HWND prog=GetDlgItem(page->hwnd,IDC_PROGRESS_REPAIR);
  71. long nProgress=repair.getTotalProgress();
  72. SendMessage(prog,PBM_SETRANGE,0,MAKELPARAM(0, nProgress));
  73. hr=repair.run();
  74. CoUninitialize();
  75. BREAK_ON_FAILED_HRESULT(hr);
  76. } while(0);
  77. hrError=hr;
  78. page->FinishProgress();
  79. return 0;
  80. }
  81. bool
  82. UpdatesPage::OnSetActive()
  83. {
  84. LOG_FUNCTION(UpdatesPage::OnSetActive);
  85. EnableWindow(GetDlgItem(Win::GetParent(hwnd),IDCANCEL),false);
  86. Win::PropSheet_SetWizButtons(
  87. Win::GetParent(hwnd),
  88. 0
  89. );
  90. pos=0;
  91. HANDLE hA=CreateThread(
  92. NULL,0,
  93. (LPTHREAD_START_ROUTINE) startRepair,
  94. this,
  95. 0, 0
  96. );
  97. CloseHandle(hA);
  98. return true;
  99. }
  100. void UpdatesPage::StepProgress(long steps)
  101. {
  102. LOG_FUNCTION(UpdatesPage::StepProgress);
  103. HWND prog=GetDlgItem(hwnd,IDC_PROGRESS_REPAIR);
  104. pos+=steps;
  105. SendMessage(prog,PBM_SETPOS,pos,0);
  106. }
  107. void UpdatesPage::FinishProgress()
  108. {
  109. LOG_FUNCTION(UpdatesPage::FinishProgress);
  110. Win::PropSheet_SetWizButtons(Win::GetParent(hwnd),PSWIZB_NEXT);
  111. if (FAILED(hrError))
  112. {
  113. error=String::format(IDS_REPAIR_ERROR,error.c_str());
  114. }
  115. HWND text=GetDlgItem(hwnd,IDC_UPDATE_COMPLETE);
  116. Win::ShowWindow(text,SW_SHOW);
  117. Win::PropSheet_SetWizButtons(
  118. Win::GetParent(hwnd),
  119. PSWIZB_NEXT
  120. );
  121. }