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.

127 lines
2.9 KiB

  1. //******************************************************************************
  2. //
  3. // Copyright (c) 1999-2000, Microsoft Corporation, All rights reserved
  4. //
  5. //*****************************************************************************
  6. #include "precomp.h"
  7. #include <wbemint.h>
  8. #include "delivrec.h"
  9. #include "qsink.h"
  10. #include "nsrep.h"
  11. /*************************************************************************
  12. CDeliveryRecord
  13. **************************************************************************/
  14. CDeliveryRecord::~CDeliveryRecord()
  15. {
  16. if ( m_pNamespace )
  17. {
  18. m_pNamespace->RemoveFromCache( m_dwSize );
  19. }
  20. Clear();
  21. }
  22. void CDeliveryRecord::AddToCache( CEssNamespace * pNamespace, DWORD dwTotalSize, DWORD * pdwSleep )
  23. {
  24. _DBG_ASSERT( pNamespace );
  25. if ( NULL == m_pNamespace )
  26. {
  27. m_pNamespace = pNamespace;
  28. }
  29. m_pNamespace->AddToCache( m_dwSize, dwTotalSize, pdwSleep );
  30. }
  31. HRESULT CDeliveryRecord::Initialize( IWbemClassObject** apEvents,
  32. ULONG cEvents,
  33. IWbemCallSecurity* pCallSec )
  34. {
  35. HRESULT hr;
  36. Clear();
  37. m_pCallSec = pCallSec;
  38. for( ULONG i=0; i < cEvents; i++ )
  39. {
  40. //
  41. // TODO : should clone the object here later.
  42. //
  43. if ( m_Events.Add( apEvents[i] ) < 0 )
  44. {
  45. return WBEM_E_OUT_OF_MEMORY;
  46. }
  47. hr = AdjustTotalSize( apEvents[i] );
  48. if ( FAILED(hr) )
  49. {
  50. return WBEM_E_CRITICAL_ERROR;
  51. }
  52. }
  53. return WBEM_S_NO_ERROR;
  54. }
  55. HRESULT CDeliveryRecord::AdjustTotalSize( IWbemClassObject* pObj )
  56. {
  57. HRESULT hr;
  58. CWbemPtr<_IWmiObject> pEventInt;
  59. hr = pObj->QueryInterface( IID__IWmiObject, (void**)&pEventInt );
  60. if ( FAILED(hr) )
  61. {
  62. return hr;
  63. }
  64. DWORD dwSize;
  65. hr = pEventInt->GetObjectMemory( NULL, 0, &dwSize );
  66. if ( FAILED(hr) && hr != WBEM_E_BUFFER_TOO_SMALL )
  67. {
  68. return hr;
  69. }
  70. m_dwSize += dwSize;
  71. return WBEM_S_NO_ERROR;
  72. }
  73. /*************************************************************************
  74. CExpressDeliveryRecord
  75. **************************************************************************/
  76. HRESULT CExpressDeliveryRecord::PreDeliverAction( ITransaction* pTxn )
  77. {
  78. return WBEM_S_NO_ERROR;
  79. }
  80. HRESULT CExpressDeliveryRecord::PostDeliverAction( ITransaction* pTxn,
  81. HRESULT hres )
  82. {
  83. return WBEM_S_NO_ERROR;
  84. }
  85. CReuseMemoryManager CExpressDeliveryRecord::mstatic_Manager(sizeof CExpressDeliveryRecord);
  86. void *CExpressDeliveryRecord::operator new(size_t nBlock)
  87. {
  88. return mstatic_Manager.Allocate();
  89. }
  90. void CExpressDeliveryRecord::operator delete(void* p)
  91. {
  92. mstatic_Manager.Free(p);
  93. }