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.

116 lines
2.6 KiB

  1. #include "precomp.h"
  2. #include "AsyncObjectSink.h"
  3. #include <stdio.h>
  4. CAsyncObjectSink::CAsyncObjectSink(HWND hTreeWnd, HTREEITEM hItem,struct NSNODE *parent,DataSource *dataSrc, ENUMTYPE eType)
  5. {
  6. m_lRef = 0;
  7. m_pParent = parent;
  8. m_hTreeWnd = hTreeWnd;
  9. m_hItem = hItem;
  10. m_pDataSrc = dataSrc;
  11. m_enumType = eType;
  12. m_bChildren = false;
  13. m_pStub = NULL;
  14. }
  15. CAsyncObjectSink::~CAsyncObjectSink()
  16. {
  17. }
  18. ULONG CAsyncObjectSink::AddRef()
  19. {
  20. return InterlockedIncrement(&m_lRef);
  21. }
  22. ULONG CAsyncObjectSink::Release()
  23. {
  24. long lRef = InterlockedDecrement(&m_lRef);
  25. if(lRef == 0)
  26. delete this;
  27. return lRef;
  28. }
  29. HRESULT CAsyncObjectSink::QueryInterface(REFIID riid, void** ppv)
  30. {
  31. if (riid == IID_IUnknown || riid == IID_IWbemObjectSink)
  32. {
  33. *ppv = (IWbemObjectSink *) this;
  34. AddRef();
  35. return S_OK;
  36. }
  37. else return E_NOINTERFACE;
  38. }
  39. HRESULT CAsyncObjectSink::Indicate(long lObjCount, IWbemClassObject **pArray)
  40. {
  41. // OutputDebugString(_T("Indicate Received"));
  42. // Loop through the array, examining the objects.
  43. for (long i = 0; i < lObjCount; i++)
  44. {
  45. IWbemClassObject *pTemp = pArray[i];
  46. // Use the object
  47. switch(m_enumType)
  48. {
  49. case ENUM_NAMESPACE:
  50. m_pDataSrc->InsertNamespaceNode(m_hTreeWnd,m_hItem,m_pParent,pTemp);
  51. break;
  52. case ENUM_CLASS :
  53. m_pDataSrc->InsertClassNode(m_hTreeWnd,m_hItem,m_pParent,pTemp);
  54. break;
  55. case ENUM_INSTANCE:
  56. m_pDataSrc->InsertInstanceNode(m_hTreeWnd,m_hItem,m_pParent,pTemp);
  57. break;
  58. case ENUM_SCOPE_INSTANCE:
  59. m_pDataSrc->InsertScopeInstanceNode(m_hTreeWnd,m_hItem,m_pParent,pTemp);
  60. break;
  61. default:
  62. break;
  63. }
  64. if(m_bChildren == false)
  65. {
  66. m_bChildren = true;
  67. TreeView_Expand(m_hTreeWnd,m_hItem,TVE_EXPAND);
  68. }
  69. }
  70. return WBEM_S_NO_ERROR;
  71. }
  72. HRESULT CAsyncObjectSink::SetStatus(
  73. /* [in] */ long lFlags,
  74. /* [in] */ HRESULT hResult,
  75. /* [in] */ BSTR strParam,
  76. /* [in] */ IWbemClassObject __RPC_FAR *pObjParam
  77. )
  78. {
  79. // printf("CAsyncObjectSink::SetStatus hResult = 0x%X\n", hResult);
  80. if(lFlags == WBEM_STATUS_COMPLETE)
  81. {
  82. if(m_bChildren == false)
  83. {
  84. m_pDataSrc->RemovePlus(m_hTreeWnd,m_hItem);
  85. }
  86. m_pDataSrc->ProcessEndEnumAsync((IWbemObjectSink *) this);
  87. }
  88. return WBEM_S_NO_ERROR;
  89. }
  90. HRESULT CAsyncObjectSink::SetSinkStub(IWbemObjectSink *pStub)
  91. {
  92. if (m_pStub != NULL)
  93. m_pStub->Release();
  94. m_pStub = pStub;
  95. if (m_pStub != NULL)
  96. m_pStub->AddRef();
  97. return S_OK;
  98. }
  99. IWbemObjectSink* CAsyncObjectSink::GetSinkStub()
  100. {
  101. return m_pStub;
  102. }