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.

164 lines
4.8 KiB

  1. //---------------------------------------------------------------------------
  2. // NotifyConnPtCn.cpp : CVDNotifyDBEventsConnPtCont implementation file
  3. //
  4. // Copyright (c) 1996 Microsoft Corporation, All Rights Reserved
  5. // Developed by Sheridan Software Systems, Inc.
  6. //---------------------------------------------------------------------------
  7. #include "stdafx.h"
  8. #include "NConnPt.h"
  9. #include "NConnPtC.h"
  10. #include "enumcnpt.h"
  11. #include "Notifier.h"
  12. #include "RSSource.h"
  13. // needed for ASSERTs and FAIL
  14. //
  15. SZTHISFILE
  16. //=--------------------------------------------------------------------------=
  17. // CVDNotifyDBEventsConnPtCont constructor
  18. //
  19. CVDNotifyDBEventsConnPtCont::CVDNotifyDBEventsConnPtCont()
  20. {
  21. m_pNotifier = NULL;
  22. #ifdef _DEBUG
  23. g_cVDNotifyDBEventsConnPtContCreated++;
  24. #endif
  25. }
  26. //=--------------------------------------------------------------------------=
  27. // CVDNotifyDBEventsConnPtCont destructor
  28. //
  29. CVDNotifyDBEventsConnPtCont::~CVDNotifyDBEventsConnPtCont()
  30. {
  31. RELEASE_OBJECT(m_pNotifyDBEventsConnPt)
  32. #ifdef _DEBUG
  33. g_cVDNotifyDBEventsConnPtContDestroyed++;
  34. #endif
  35. }
  36. //=--------------------------------------------------------------------------=
  37. // Create - Create connection point container object
  38. //=--------------------------------------------------------------------------=
  39. // This function creates a new connection point container object
  40. //
  41. // Parameters:
  42. // pConnPtContainer - [in] a pointer to rowset object
  43. // ppNotifyDBEventsConnPt - [out] a pointer in which to return pointer to
  44. // connection point container object
  45. //
  46. // Output:
  47. // HRESULT - S_OK if successful
  48. // E_OUTOFMEMORY not enough memory to create object
  49. //
  50. // Notes:
  51. //
  52. HRESULT CVDNotifyDBEventsConnPtCont::Create(CVDNotifier * pNotifier, CVDNotifyDBEventsConnPtCont ** ppConnPtContainer)
  53. {
  54. *ppConnPtContainer = NULL;
  55. CVDNotifyDBEventsConnPtCont * pConnPtContainer = new CVDNotifyDBEventsConnPtCont();
  56. if (!pConnPtContainer)
  57. return E_OUTOFMEMORY;
  58. pConnPtContainer->m_pNotifier = pNotifier;
  59. CVDNotifyDBEventsConnPt::Create(pConnPtContainer, &pConnPtContainer->m_pNotifyDBEventsConnPt);
  60. if (!pConnPtContainer->m_pNotifyDBEventsConnPt)
  61. {
  62. delete pConnPtContainer;
  63. return E_OUTOFMEMORY;
  64. }
  65. *ppConnPtContainer = pConnPtContainer;
  66. return S_OK;
  67. }
  68. //=--------------------------------------------------------------------------=
  69. // Destroy - Destroy this connection point container object
  70. //
  71. void CVDNotifyDBEventsConnPtCont::Destroy()
  72. {
  73. delete this;
  74. }
  75. //=--------------------------------------------------------------------------=
  76. // IUnknown QueryInterface
  77. //
  78. HRESULT CVDNotifyDBEventsConnPtCont::QueryInterface(REFIID riid, void **ppvObjOut)
  79. {
  80. return ((CVDNotifier*)m_pNotifier)->QueryInterface(riid, ppvObjOut); // logically part of CVDNotifier derived object;
  81. }
  82. //=--------------------------------------------------------------------------=
  83. // IUnknown AddRef
  84. //
  85. ULONG CVDNotifyDBEventsConnPtCont::AddRef(void)
  86. {
  87. return ((CVDNotifier*)m_pNotifier)->AddRef(); // logically part of CVDNotifier derived object
  88. }
  89. //=--------------------------------------------------------------------------=
  90. // IUnknown Release
  91. //
  92. ULONG CVDNotifyDBEventsConnPtCont::Release(void)
  93. {
  94. return ((CVDNotifier*)m_pNotifier)->Release(); // logically part of CVDNotifier derived object
  95. }
  96. //=--------------------------------------------------------------------------=
  97. // IConnectionPointContainer Methods
  98. //=--------------------------------------------------------------------------=
  99. //=--------------------------------------------------------------------------=
  100. // IConnectionPointContainer EnumConnectionPoints
  101. //
  102. HRESULT CVDNotifyDBEventsConnPtCont::EnumConnectionPoints(LPENUMCONNECTIONPOINTS FAR* ppEnum)
  103. {
  104. ASSERT_POINTER(ppEnum, LPENUMCONNECTIONPOINTS)
  105. CVDEnumConnPoints* pEnum = NULL;
  106. if (m_pNotifyDBEventsConnPt)
  107. {
  108. pEnum = new CVDEnumConnPoints(m_pNotifyDBEventsConnPt);
  109. if (!pEnum)
  110. {
  111. *ppEnum = NULL;
  112. return E_OUTOFMEMORY;
  113. }
  114. }
  115. *ppEnum = pEnum;
  116. return (pEnum != NULL) ? S_OK : CONNECT_E_NOCONNECTION;
  117. }
  118. //=--------------------------------------------------------------------------=
  119. // IConnectionPointContainer FindConnectionPoint
  120. //
  121. HRESULT CVDNotifyDBEventsConnPtCont::FindConnectionPoint(REFIID iid, LPCONNECTIONPOINT FAR* ppCP)
  122. {
  123. ASSERT_POINTER(ppCP, LPCONNECTIONPOINT)
  124. if (m_pNotifyDBEventsConnPt)
  125. {
  126. // there is only one connection point supported - IID_INotifyDBEvents
  127. if (DO_GUIDS_MATCH(iid, IID_INotifyDBEvents))
  128. {
  129. m_pNotifyDBEventsConnPt->AddRef();
  130. *ppCP = m_pNotifyDBEventsConnPt;
  131. return S_OK;
  132. }
  133. }
  134. return E_NOINTERFACE;
  135. }