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.

157 lines
3.3 KiB

  1. /*****************************************************************************\
  2. * MODULE: reqcont.cpp
  3. *
  4. * PURPOSE: Implementation of COM interface for BidiSpooler
  5. *
  6. * Copyright (C) 2000 Microsoft Corporation
  7. *
  8. * History:
  9. *
  10. * 03/09/00 Weihai Chen (weihaic) Created
  11. *
  12. \*****************************************************************************/
  13. #include "precomp.h"
  14. #include "priv.h"
  15. TBidiRequestContainer::TBidiRequestContainer():
  16. m_cRef(1)
  17. {
  18. InterlockedIncrement(&g_cComponents) ;
  19. m_bValid = m_ReqInterfaceList.bValid ();
  20. DBGMSG(DBG_TRACE,("TBidiRequestContainer Created\n"));
  21. }
  22. TBidiRequestContainer::~TBidiRequestContainer()
  23. {
  24. InterlockedDecrement(&g_cComponents) ;
  25. DBGMSG(DBG_TRACE,("TBidiRequestContainer Dstroy self\n"));
  26. }
  27. STDMETHODIMP
  28. TBidiRequestContainer::QueryInterface (
  29. REFIID iid,
  30. void** ppv)
  31. {
  32. HRESULT hr = S_OK;
  33. DBGMSG(DBG_TRACE,("Enter TBidiRequestContainer QI\n"));
  34. if (iid == IID_IUnknown) {
  35. *ppv = static_cast<IBidiRequestContainer*>(this) ;
  36. }
  37. else if (iid == IID_IBidiRequestContainer) {
  38. *ppv = static_cast<IBidiRequestContainer*>(this) ;
  39. }
  40. else {
  41. *ppv = NULL ;
  42. hr = E_NOINTERFACE ;
  43. }
  44. if (*ppv) {
  45. reinterpret_cast<IUnknown*>(*ppv)->AddRef() ;
  46. }
  47. DBGMSG(DBG_TRACE,("Leave TBidiRequestContainer QI hr=%x\n", hr));
  48. return hr ;
  49. }
  50. STDMETHODIMP_ (ULONG)
  51. TBidiRequestContainer::AddRef ()
  52. {
  53. DBGMSG(DBG_TRACE,("Enter TBidiRequestContainer::AddRef ref= %d\n", m_cRef));
  54. return InterlockedIncrement(&m_cRef) ;
  55. }
  56. STDMETHODIMP_ (ULONG)
  57. TBidiRequestContainer::Release ()
  58. {
  59. DBGMSG(DBG_TRACE,("Enter TBidiRequestContainer::Release ref= %d\n", m_cRef));
  60. if (InterlockedDecrement(&m_cRef) == 0)
  61. {
  62. delete this ;
  63. return 0 ;
  64. }
  65. return m_cRef ;
  66. }
  67. STDMETHODIMP
  68. TBidiRequestContainer::AddRequest (
  69. IN IBidiRequest *pRequest)
  70. {
  71. HRESULT hr (E_FAIL);
  72. DBGMSG(DBG_TRACE,("Enter TBidiRequestContainer::AddRequest\n"));
  73. if (m_bValid) {
  74. TBidiRequestInterfaceData * pData = NULL;
  75. pData = new TBidiRequestInterfaceData (pRequest);
  76. if (pData) {
  77. if (m_ReqInterfaceList.AppendItem (pData)) {
  78. hr = S_OK;
  79. }
  80. else
  81. delete pData;
  82. }
  83. if (hr != S_OK) {
  84. hr = LastError2HRESULT ();
  85. }
  86. }
  87. else
  88. hr = E_HANDLE;
  89. return hr;
  90. }
  91. STDMETHODIMP
  92. TBidiRequestContainer::GetEnumObject (
  93. OUT IEnumUnknown **ppenum)
  94. {
  95. HRESULT hr;
  96. if (m_bValid) {
  97. hr = PrivCreateComponent <TBidiRequestContainerEnum> (
  98. new TBidiRequestContainerEnum (*this, m_ReqInterfaceList),
  99. IID_IEnumUnknown, (void **)ppenum);
  100. }
  101. else
  102. hr = E_HANDLE;
  103. return hr;
  104. }
  105. STDMETHODIMP
  106. TBidiRequestContainer::GetRequestCount(
  107. OUT ULONG *puCount)
  108. {
  109. HRESULT hr;
  110. if (m_bValid) {
  111. if (m_ReqInterfaceList.GetTotalNode (puCount)) {
  112. hr = S_OK;
  113. }
  114. else
  115. hr = LastError2HRESULT ();
  116. }
  117. else
  118. hr = E_HANDLE;
  119. return hr;
  120. }