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.

162 lines
4.2 KiB

  1. //=======================================================================
  2. //
  3. // Copyright (c) 2000 Microsoft Corporation. All Rights Reserved.
  4. //
  5. // File: EvtMsgWnd.cpp: implementation of the CEventMsgWindow class.
  6. //
  7. // Created by: Charles Ma
  8. // 6/18/1999
  9. //
  10. //=======================================================================
  11. #include "stdafx.h"
  12. #include "EvtMsgWnd.h"
  13. #include "Update.h"
  14. #include <logging.h>
  15. #include <atlwin.cpp>
  16. /////////////////////////////////////////////////////////////////////////////
  17. // CEventMsgWindow
  18. /////////////////////////////////////////////////////////////////////////////
  19. // override method
  20. //
  21. // we need to create a popup window - a control can not create
  22. // a top-level child window
  23. //
  24. /////////////////////////////////////////////////////////////////////////////
  25. void CEventMsgWindow::Create()
  26. {
  27. if (NULL == m_pControl)
  28. return;
  29. //
  30. // make the window size 1 pixel
  31. //
  32. RECT rcPos;
  33. rcPos.left = 0;
  34. rcPos.top = 0;
  35. rcPos.bottom = 1;
  36. rcPos.right = 1;
  37. //
  38. // call base class method, with WS_POPUP style
  39. //
  40. m_hWnd = CWindowImpl<CEventMsgWindow>::Create(NULL, rcPos, _T("EventWindow"), WS_POPUP);
  41. }
  42. /////////////////////////////////////////////////////////////////////////////
  43. // destroy the window
  44. /////////////////////////////////////////////////////////////////////////////
  45. void CEventMsgWindow::Destroy()
  46. {
  47. if (NULL != m_hWnd)
  48. {
  49. m_hWnd = NULL;
  50. CWindowImpl<CEventMsgWindow>::DestroyWindow();
  51. }
  52. }
  53. /////////////////////////////////////////////////////////////////////////////
  54. // message handlers
  55. /////////////////////////////////////////////////////////////////////////////
  56. LRESULT CEventMsgWindow::OnFireEvent(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  57. {
  58. #if defined(DBG)
  59. USES_CONVERSION;
  60. LOG_Block("OnFireEvent()");
  61. LOG_Out(_T("Msg=%d"), uMsg);
  62. #endif
  63. //
  64. // if control is not passed in, we can not fire the event. return E_FAIL
  65. //
  66. pEventData pEvtData = NULL;
  67. if (NULL == m_pControl)
  68. {
  69. return E_FAIL;
  70. }
  71. switch (uMsg)
  72. {
  73. case UM_EVENT_ITEMSTART:
  74. //
  75. // this item is about to get downloaded
  76. //
  77. pEvtData = (pEventData)lParam;
  78. if (pEvtData)
  79. {
  80. //
  81. // about to start an item download/install
  82. //
  83. #if defined(DBG)
  84. LOG_Out(_T("About to fire event OnItemStart(%s, <item>, %ld)"),
  85. OLE2T(pEvtData->bstrUuidOperation),
  86. pEvtData->lCommandRequest);
  87. LOG_XmlBSTR(pEvtData->bstrXmlData);
  88. #endif
  89. m_pControl->Fire_OnItemStart(pEvtData->bstrUuidOperation,
  90. pEvtData->bstrXmlData, // this is actually BSTR of an item
  91. &pEvtData->lCommandRequest);
  92. if (pEvtData->hevDoneWithMessage != NULL)
  93. SetEvent(pEvtData->hevDoneWithMessage);
  94. }
  95. break;
  96. case UM_EVENT_PROGRESS:
  97. //
  98. // dopwnlaod or install progress
  99. //
  100. pEvtData = (pEventData)lParam;
  101. #if defined(DBG)
  102. LOG_Out(_T("About to fire event OnProgress(%s, %d, %s, %ld)"),
  103. OLE2T(pEvtData->bstrUuidOperation),
  104. pEvtData->fItemCompleted,
  105. OLE2T(pEvtData->bstrProgress),
  106. pEvtData->lCommandRequest);
  107. #endif
  108. if (pEvtData)
  109. {
  110. m_pControl->Fire_OnProgress(pEvtData->bstrUuidOperation,
  111. pEvtData->fItemCompleted,
  112. pEvtData->bstrProgress,
  113. &pEvtData->lCommandRequest);
  114. if (pEvtData->hevDoneWithMessage != NULL)
  115. SetEvent(pEvtData->hevDoneWithMessage);
  116. }
  117. break;
  118. case UM_EVENT_COMPLETE:
  119. //
  120. // download or install operation complete
  121. //
  122. pEvtData = (pEventData)lParam;
  123. #if defined(DBG)
  124. LOG_Out(_T("About to fire event OnOperationComplete(%s, result)"),
  125. OLE2T(pEvtData->bstrUuidOperation));
  126. LOG_XmlBSTR(pEvtData->bstrXmlData);
  127. #endif
  128. if (pEvtData)
  129. {
  130. m_pControl->Fire_OnOperationComplete(pEvtData->bstrUuidOperation, pEvtData->bstrXmlData);
  131. if (pEvtData->hevDoneWithMessage != NULL)
  132. SetEvent(pEvtData->hevDoneWithMessage);
  133. }
  134. break;
  135. case UM_EVENT_SELFUPDATE_COMPLETE:
  136. //
  137. // the lParam should be the error code
  138. //
  139. #if defined(DBG)
  140. LOG_Out(_T("About to fire event OnSelfUpdateComplete(%ld)"), (LONG)lParam);
  141. #endif
  142. m_pControl->Fire_OnSelfUpdateComplete((LONG)lParam);
  143. break;
  144. }
  145. return S_OK;
  146. }