Source code of Windows XP (NT5)
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.

123 lines
3.7 KiB

  1. /////////////////////////////////////////////////////////////////////////////////////
  2. // MPEG2TuneRequest.h : Declaration of the CMPEG2TuneRequest
  3. // Copyright (c) Microsoft Corporation 2000.
  4. #ifndef __MPEG2TUNEREQUEST_H_
  5. #define __MPEG2TUNEREQUEST_H_
  6. #pragma once
  7. #include <objectwithsiteimplsec.h>
  8. #include "MPEG2tunerequestimpl.h"
  9. /////////////////////////////////////////////////////////////////////////////
  10. // CMPEG2TuneRequest
  11. class ATL_NO_VTABLE CMPEG2TuneRequest :
  12. public CComObjectRootEx<CComMultiThreadModel>,
  13. public IMPEG2TuneRequestImpl<CMPEG2TuneRequest>,
  14. public CComCoClass<CMPEG2TuneRequest, &CLSID_MPEG2TuneRequest>,
  15. public IObjectWithSiteImplSec<CMPEG2TuneRequest>,
  16. public ISupportErrorInfo
  17. {
  18. public:
  19. REGISTER_AUTOMATION_OBJECT_WITH_TM(IDS_REG_TUNEROBJ,
  20. IDS_REG_MPEG2TUNEREQUEST_PROGID,
  21. IDS_REG_MPEG2TUNEREQUEST_DESC,
  22. LIBID_TunerLib,
  23. CLSID_MPEG2TuneRequest, tvBoth);
  24. BEGIN_COM_MAP(CMPEG2TuneRequest)
  25. COM_INTERFACE_ENTRY(IMPEG2TuneRequest)
  26. COM_INTERFACE_ENTRY(ITuneRequest)
  27. COM_INTERFACE_ENTRY(IDispatch)
  28. COM_INTERFACE_ENTRY(ISupportErrorInfo)
  29. COM_INTERFACE_ENTRY(IPersistPropertyBag)
  30. COM_INTERFACE_ENTRY(IPersist)
  31. COM_INTERFACE_ENTRY(IObjectWithSite)
  32. END_COM_MAP_WITH_FTM()
  33. BEGIN_CATEGORY_MAP(CMPEG2TuneRequest)
  34. IMPLEMENTED_CATEGORY(CATID_SafeForScripting)
  35. IMPLEMENTED_CATEGORY(CATID_SafeForInitializing)
  36. IMPLEMENTED_CATEGORY(CATID_PersistsToPropertyBag)
  37. END_CATEGORY_MAP()
  38. // ISupportsErrorInfo
  39. STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid);
  40. typedef IMPEG2TuneRequestImpl<CMPEG2TuneRequest> basetype;
  41. BEGIN_PROP_MAP(CMPEG2TuneRequest)
  42. CHAIN_PROP_MAP(basetype)
  43. END_PROP_MAP()
  44. };
  45. typedef CComQIPtr<IMPEG2TuneRequestSupport> PQMPEG2TuneRequestSupport;
  46. /////////////////////////////////////////////////////////////////////////////
  47. // CMPEG2TuneRequest
  48. class ATL_NO_VTABLE CMPEG2TuneRequestFactory :
  49. public CComObjectRootEx<CComSingleThreadModel>,
  50. public IDispatchImpl<IMPEG2TuneRequestFactory,
  51. &__uuidof(IMPEG2TuneRequestFactory),
  52. &LIBID_TunerLib>,
  53. public CComCoClass<CMPEG2TuneRequestFactory, &CLSID_MPEG2TuneRequestFactory>,
  54. public IObjectWithSiteImplSec<CMPEG2TuneRequestFactory>,
  55. public ISupportErrorInfo
  56. {
  57. public:
  58. REGISTER_AUTOMATION_OBJECT(IDS_REG_TUNEROBJ,
  59. IDS_REG_MPEG2TUNEREQUESTFACTORY_PROGID,
  60. IDS_REG_MPEG2TUNEREQUESTFACTORY_DESC,
  61. LIBID_TunerLib,
  62. CLSID_MPEG2TuneRequestFactory);
  63. BEGIN_COM_MAP(CMPEG2TuneRequestFactory)
  64. COM_INTERFACE_ENTRY(IMPEG2TuneRequestFactory)
  65. COM_INTERFACE_ENTRY(IDispatch)
  66. COM_INTERFACE_ENTRY(IObjectWithSite)
  67. COM_INTERFACE_ENTRY(ISupportErrorInfo)
  68. END_COM_MAP_WITH_FTM()
  69. BEGIN_CATEGORY_MAP(CMPEG2TuneRequestFactory)
  70. IMPLEMENTED_CATEGORY(CATID_SafeForScripting)
  71. IMPLEMENTED_CATEGORY(CATID_SafeForInitializing)
  72. END_CATEGORY_MAP()
  73. // ISupportsErrorInfo
  74. STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid);
  75. STDMETHOD(CreateTuneRequest)(ITuningSpace* pTS, IMPEG2TuneRequest** pTR) {
  76. if (!pTR) {
  77. return E_POINTER;
  78. }
  79. try {
  80. PQMPEG2TuneRequestSupport pt(pTS);
  81. if (!pt) {
  82. return Error(IDS_INVALID_TS, __uuidof(IMPEG2TuneRequestFactory), E_INVALIDARG);
  83. }
  84. CMPEG2TuneRequest* pNewTR = new CComObject<CMPEG2TuneRequest>;
  85. ATL_LOCK();
  86. ASSERT(!pNewTR->m_TS);
  87. HRESULT hr = pTS->Clone(&pNewTR->m_TS);
  88. if (FAILED(hr)) {
  89. pNewTR->Release();
  90. return hr;
  91. }
  92. pNewTR->AddRef();
  93. *pTR = pNewTR;
  94. return NOERROR;
  95. } catch(...) {
  96. return E_POINTER;
  97. }
  98. }
  99. };
  100. #endif //__MPEG2TUNEREQUESTFACTORY_H_