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.

160 lines
4.4 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1995.
  5. //
  6. // File: callback.cxx
  7. //
  8. // Contents: Callback mechanism and thread switching code
  9. //
  10. // Classes:
  11. //
  12. // Functions:
  13. //
  14. // History: 11-11-95 JohannP (Johann Posch) Created
  15. //
  16. //----------------------------------------------------------------------------
  17. #include <trans.h>
  18. #include "callback.hxx"
  19. HRESULT CreateINetCallback(CBinding *pCBdg, DWORD *pdwContext, PFNCINETCALLBACK *pCB)
  20. {
  21. DEBUG_ENTER((DBG_TRANS,
  22. Hresult,
  23. "CreateINetCallback",
  24. "%#x, %#x, %#x, %#x",
  25. pCBdg, pdwContext, pCB
  26. ));
  27. DEBUG_LEAVE(NOERROR);
  28. return NOERROR;
  29. }
  30. PFNCINETCALLBACK CreateCallback(DWORD dwId, LPVOID pv)
  31. {
  32. DEBUG_ENTER((DBG_TRANS,
  33. Pointer,
  34. "CreateCallback",
  35. "%#x, %#x",
  36. dwId, pv
  37. ));
  38. DEBUG_LEAVE(NULL);
  39. return NULL;
  40. }
  41. #ifdef OLD_UNUSED
  42. void Update(CInternetTransaction *pThis,DLD *pdld, char *pszStatusText)
  43. {
  44. DEBUG_ENTER((DBG_TRANS,
  45. None,
  46. "Update",
  47. "%#x, %#x, %#x, %#x",
  48. pThis, pdld, pszStatusText
  49. ));
  50. Assert(pThis != NULL);
  51. Assert(!pThis->m_fComplete);
  52. if (pdld == NULL)
  53. {
  54. DEBUG_LEAVE(0);
  55. return;
  56. }
  57. AssertDo(pThis->HrPostNotifications(s_WM_UPDATECALLBACK, pdld,
  58. pszStatusText, INLERR_OK) == NOERROR);
  59. DEBUG_LEAVE(0);
  60. }
  61. void Inetdone(CInternetTransaction *pThis, BOOL fInStartTransaction, DLD *pdld, int errCode)
  62. {
  63. DEBUG_ENTER((DBG_TRANS,
  64. None,
  65. "Inetdone",
  66. "%#x, %B, %#x, %d",
  67. pThis, fInStartTransaction, pdld, errCode
  68. ));
  69. Assert(pThis != NULL);
  70. Assert(!pThis->m_fComplete);
  71. if (!fInStartTransaction)
  72. {
  73. Assert(pThis->m_hInet != NULL);
  74. if (pThis->m_hInet == NULL)
  75. {
  76. DEBUG_LEAVE(0);
  77. return;
  78. }
  79. }
  80. pThis->m_fComplete = TRUE;
  81. pThis->m_hInet = NULL;
  82. AssertDo(pThis->HrPostNotifications(s_WM_INETDONECALLBACK, pdld, "",
  83. errCode) == NOERROR);
  84. // Release the reference we had added in HrStartDataRetrieval.
  85. // Note: after this call, the object may no longer exist
  86. pThis->Release();
  87. DEBUG_LEAVE(0);
  88. }
  89. /*---------------------------------------------------------------------------
  90. CInternetTransaction::HrPostNotification
  91. Post a notification message to all the client requests that are
  92. connected to this internet transaction.
  93. ----------------------------------------------------------------- DavidEbb -*/
  94. HRESULT CInternetTransaction::HrPostNotifications(UINT uiMsg,
  95. DLD *pdld, char *pszStatusText, int errCode)
  96. {
  97. DEBUG_ENTER((DBG_TRANS,
  98. Hresult,
  99. "CInternetTransaction::HrPostNotifications",
  100. "this=%#x, %#x, %#x, %.80q, %d",
  101. this, uiMsg, pdld, pszStatusText, errCode
  102. ));
  103. CALLBACKDATA *pcbd;
  104. CClientRequest *pcrqTmp = m_pcrqFirst;
  105. Assert(pdld != NULL);
  106. Assert(m_pcrqFirst != NULL);
  107. {
  108. // Save the file name if we don't already have it.
  109. if (m_wzFileName[0] == '\0')
  110. A2W(pdld->szTargetFile, m_wzFileName, MAX_PATH);
  111. }
  112. // Traverse the whole linked list
  113. while (pcrqTmp != NULL)
  114. {
  115. // Note: we need to allocate a new CALLBACKDATA structure for each
  116. // client request in the list, because we are giving up
  117. // ownership of it when we call PostMessage().
  118. pcbd = CreateCallBackData(pdld, pszStatusText, errCode);
  119. if (pcbd == NULL)
  120. {
  121. DEBUG_LEAVE(E_OUTOFMEMORY);
  122. return E_OUTOFMEMORY;
  123. }
  124. Assert(pcrqTmp->HwndGetStatusWindow() != NULL);
  125. // Post a message to the hidden window in the main thread.
  126. PostMessage(pcrqTmp->HwndGetStatusWindow(), uiMsg,(WPARAM)pcrqTmp, (LPARAM)pcbd);
  127. pcrqTmp = pcrqTmp->GetNextRequest();
  128. }
  129. DEBUG_LEAVE(NOERROR);
  130. return NOERROR;
  131. }
  132. #endif //OLD_UNUSED