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.

160 lines
2.8 KiB

  1. //=======================================================================
  2. //
  3. // Copyright (c) 1999 Microsoft Corporation. All Rights Reserved.
  4. //
  5. // File: callback.cpp
  6. //
  7. // Purpose: INSENG callback implementation
  8. //
  9. // History: 19-jan-99 YAsmi Created
  10. //
  11. //=======================================================================
  12. #include "callback.h"
  13. CInstallEngineCallback::CInstallEngineCallback()
  14. {
  15. m_cRef = 0;
  16. m_pProgress = NULL;
  17. m_pEngine = NULL;
  18. Reset();
  19. }
  20. void CInstallEngineCallback::Reset()
  21. {
  22. m_dwInstallStatus = 0;
  23. m_dwPhase = INSTALLSTATUS_INITIALIZING;
  24. m_hResult = NOERROR;
  25. m_bAborted = FALSE;
  26. }
  27. //
  28. //IUnknown
  29. //
  30. STDMETHODIMP_(ULONG) CInstallEngineCallback::AddRef()
  31. {
  32. return ++m_cRef;
  33. }
  34. STDMETHODIMP_(ULONG) CInstallEngineCallback::Release()
  35. {
  36. if (--m_cRef != 0)
  37. return m_cRef;
  38. //we don't delete the object here because we want the client of the object to explicitly delete it
  39. return 0;
  40. }
  41. STDMETHODIMP CInstallEngineCallback::QueryInterface(REFIID riid, void** ppv)
  42. {
  43. *ppv = NULL;
  44. if((riid == IID_IUnknown) || (riid == IID_IInstallEngineCallback))
  45. *ppv = this;
  46. if(*ppv == NULL)
  47. return E_NOINTERFACE;
  48. ((LPUNKNOWN)*ppv)->AddRef();
  49. return NOERROR;
  50. }
  51. //
  52. //IInstallEngineCallback
  53. //
  54. STDMETHODIMP CInstallEngineCallback::OnComponentProgress(LPCSTR pszID, DWORD dwPhase, LPCSTR pszString, LPCSTR pszMsgString, ULONG ulSofar, ULONG ulMax)
  55. {
  56. /*
  57. if(dwPhase == INSTALLSTATUS_RUNNING)
  58. _pProgDlg->SetInsProgress(ulSofar);
  59. */
  60. m_dwPhase = dwPhase;
  61. if (m_pProgress != NULL)
  62. {
  63. //
  64. // check for cancel
  65. //
  66. if (m_pEngine != NULL)
  67. {
  68. if (!m_bAborted)
  69. {
  70. if (WaitForSingleObject(m_pProgress->GetCancelEvent(), 0) == WAIT_OBJECT_0)
  71. m_bAborted = TRUE;
  72. }
  73. if (m_bAborted)
  74. {
  75. //
  76. // keep telling the engine to abort
  77. //
  78. m_pEngine->Abort(0);
  79. }
  80. }
  81. }
  82. return NOERROR;
  83. }
  84. STDMETHODIMP CInstallEngineCallback::OnStopComponent(LPCSTR pszID, HRESULT hrError, DWORD dwPhase, LPCSTR pszString, DWORD dwStatus)
  85. {
  86. return NOERROR;
  87. }
  88. STDMETHODIMP CInstallEngineCallback::OnEngineStatusChange(DWORD dwEngineStatus, DWORD sub)
  89. {
  90. return NOERROR;
  91. }
  92. STDMETHODIMP CInstallEngineCallback::OnStartInstall(DWORD dwDLSize, DWORD dwTotalSize)
  93. {
  94. /*
  95. if(_pProgDlg)
  96. _pProgDlg->SetInsProgGoal(dwTotalSize);
  97. */
  98. return NOERROR;
  99. }
  100. STDMETHODIMP CInstallEngineCallback::OnStartComponent(LPCSTR pszID, DWORD dwDLSize,
  101. DWORD dwInstallSize, LPCSTR pszName)
  102. {
  103. /*
  104. _strCurrentName = BSTRFROMANSI(pszName);
  105. */
  106. return NOERROR;
  107. }
  108. STDMETHODIMP CInstallEngineCallback::OnEngineProblem(DWORD dwProblem, LPDWORD pdwAction)
  109. {
  110. return S_OK;
  111. }
  112. STDMETHODIMP CInstallEngineCallback::OnStopInstall(HRESULT hrError, LPCSTR szError, DWORD dwStatus)
  113. {
  114. m_hResult = hrError;
  115. m_dwInstallStatus = dwStatus;
  116. return NOERROR;
  117. }