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.

107 lines
2.7 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. RTCConnect.h
  5. Abstract:
  6. Definition of the CRTCConnectionPoint class
  7. --*/
  8. #ifndef __RTCCONNECT__
  9. #define __RTCCONNECT__
  10. #if _MSC_VER > 1000
  11. #pragma once
  12. #endif // _MSC_VER > 1000
  13. /////////////////////////////////////////////////////////////////////////////
  14. // CRTCConnectionPoint
  15. template <class T>
  16. class CRTCConnectionPoint :
  17. public IConnectionPointImpl<T, &IID_IRTCEventNotification, CComDynamicUnkArray>
  18. {
  19. public:
  20. VOID _FireEvent(RTC_EVENT rtce, IDispatch * pEvent)
  21. {
  22. T* pT = static_cast<T*>(this);
  23. int nConnectionIndex;
  24. int nConnections = m_vec.GetSize();
  25. for (nConnectionIndex = 0;
  26. nConnectionIndex < nConnections; nConnectionIndex++)
  27. {
  28. pT->Lock();
  29. CComPtr<IUnknown> sp = m_vec.GetAt(nConnectionIndex);
  30. pT->Unlock();
  31. if ( sp != NULL )
  32. {
  33. IRTCEventNotification * pCallback;
  34. HRESULT hr;
  35. hr = sp->QueryInterface(IID_IRTCEventNotification,
  36. (void **)&pCallback
  37. );
  38. if (SUCCEEDED(hr))
  39. {
  40. pCallback->Event( rtce, pEvent );
  41. pCallback->Release();
  42. }
  43. }
  44. }
  45. }
  46. };
  47. /////////////////////////////////////////////////////////////////////////////
  48. // CRTCDispatchConnectionPoint
  49. template <class T>
  50. class CRTCDispatchConnectionPoint :
  51. public IConnectionPointImpl<T, &DIID_IRTCDispatchEventNotification, CComDynamicUnkArray>
  52. {
  53. public:
  54. VOID _FireDispatchEvent(RTC_EVENT rtce, IDispatch * pEvent)
  55. {
  56. T* pT = static_cast<T*>(this);
  57. int nConnectionIndex;
  58. int nConnections = m_vec.GetSize();
  59. CComVariant* pvars = new CComVariant[2];
  60. for (nConnectionIndex = 0;
  61. nConnectionIndex < nConnections; nConnectionIndex++)
  62. {
  63. pT->Lock();
  64. CComPtr<IUnknown> sp = m_vec.GetAt(nConnectionIndex);
  65. pT->Unlock();
  66. if ( sp != NULL )
  67. {
  68. IDispatch * pDispatch;
  69. pDispatch = reinterpret_cast<IDispatch*>(sp.p);
  70. if (pDispatch != NULL)
  71. {
  72. pvars[1] = rtce;
  73. pvars[0] = pEvent;
  74. DISPPARAMS disp = { pvars, NULL, 2, 0 };
  75. pDispatch->Invoke(0x1, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, NULL, NULL, NULL);
  76. }
  77. }
  78. }
  79. delete[] pvars;
  80. }
  81. };
  82. #endif //__RTCCONNECT__