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.

106 lines
3.1 KiB

  1. //*************************************************************
  2. //
  3. // Resultant set of policy, Progressor Indicator class
  4. //
  5. // Microsoft Confidential
  6. // Copyright (c) Microsoft Corporation 1995
  7. // All rights reserved
  8. //
  9. // History: 7-Jun-99 NishadM Created
  10. //
  11. //*************************************************************
  12. #include "Indicate.h"
  13. //*************************************************************
  14. //
  15. // CProgressIndicator::CProgressIndicator(()
  16. //
  17. // Purpose: Constructor
  18. //
  19. // Parameters:
  20. // pObjectSink - response handler
  21. // pOutParams - out parameters
  22. // bstrNumer - numerator string
  23. // bstrDenom - denominator string
  24. // ulNumer - numerator
  25. // ulDenom - denominator
  26. // fIntermediateStatus - intermediate status reqd.
  27. //
  28. //
  29. //*************************************************************
  30. CProgressIndicator::CProgressIndicator( IWbemObjectSink* pObjectSink,
  31. bool fIntermediateStatus,
  32. unsigned long ulNumer,
  33. unsigned long ulDenom ) :
  34. m_ulNumerator( ulNumer ),
  35. m_ulDenominator( ulDenom ),
  36. m_xObjectSink( pObjectSink ),
  37. m_fIntermediateStatus( fIntermediateStatus ),
  38. m_fIsValid( pObjectSink != 0 )
  39. {
  40. }
  41. //*************************************************************
  42. //
  43. // CProgressIndicator::~CProgressIndicator(()
  44. //
  45. // Purpose: Destructor
  46. //
  47. //
  48. //*************************************************************
  49. CProgressIndicator::~CProgressIndicator()
  50. {
  51. m_xObjectSink.Acquire();
  52. }
  53. //*************************************************************
  54. //
  55. // CProgressIndicator::IncrementBy(()
  56. //
  57. // Purpose: Increments the progress by x%
  58. //
  59. // Parameters:
  60. // ulPercent - percent to increment by
  61. //
  62. //
  63. //*************************************************************
  64. HRESULT
  65. CProgressIndicator::IncrementBy( unsigned long ulPercent )
  66. {
  67. if ( !IsValid() )
  68. {
  69. return E_FAIL;
  70. }
  71. //
  72. // numerator cannot be greater than denominator
  73. //
  74. m_ulNumerator += ulPercent;
  75. if ( m_ulNumerator > m_ulDenominator )
  76. {
  77. m_ulNumerator = m_ulDenominator;
  78. }
  79. if ( m_fIntermediateStatus )
  80. {
  81. return m_xObjectSink->SetStatus(WBEM_STATUS_PROGRESS, MAKELONG( m_ulNumerator, m_ulDenominator ), 0, 0 );
  82. }
  83. return S_OK;
  84. }
  85. //*************************************************************
  86. //
  87. // CProgressIndicator::SetComplete()
  88. //
  89. // Purpose: Increments progress to 100% and forces Indicate
  90. //
  91. //
  92. //*************************************************************
  93. HRESULT
  94. CProgressIndicator::SetComplete()
  95. {
  96. return IncrementBy( MaxProgress() - CurrentProgress() );
  97. }