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.

328 lines
7.4 KiB

  1. // Service.h : Declaration of the CService
  2. #ifndef __SERVICE_H_
  3. #define __SERVICE_H_
  4. #include "resource.h" // main symbols
  5. #include "object.h"
  6. #include "GuideStoreCP.h"
  7. class CService;
  8. class CServices;
  9. /////////////////////////////////////////////////////////////////////////////
  10. // CService
  11. class ATL_NO_VTABLE CService :
  12. public CComObjectRootEx<CComObjectThreadModel>,
  13. public CComCoClass<CService, &CLSID_Service>,
  14. public CObjectGlue,
  15. public IDispatchImpl<IService, &IID_IService, &LIBID_GUIDESTORELib>
  16. {
  17. public:
  18. CService()
  19. {
  20. #if defined(_ATL_FREE_THREADED)
  21. m_pUnkMarshaler = NULL;
  22. #endif
  23. m_punkTuneRequest = NULL;
  24. }
  25. DECLARE_REGISTRY_RESOURCEID(IDR_SERVICE)
  26. DECLARE_GET_CONTROLLING_UNKNOWN()
  27. #if defined(_ATL_FREE_THREADED)
  28. DECLARE_PROTECT_FINAL_CONSTRUCT()
  29. #endif
  30. BEGIN_COM_MAP(CService)
  31. COM_INTERFACE_ENTRY(IService)
  32. COM_INTERFACE_ENTRY(IDispatch)
  33. #if defined(_ATL_FREE_THREADED)
  34. COM_INTERFACE_ENTRY_AGGREGATE(IID_IMarshal, m_pUnkMarshaler.p)
  35. #endif
  36. END_COM_MAP()
  37. #if defined(_ATL_FREE_THREADED)
  38. HRESULT FinalConstruct()
  39. {
  40. HRESULT hr;
  41. hr = CoCreateFreeThreadedMarshaler(
  42. GetControllingUnknown(), &m_pUnkMarshaler.p);
  43. return hr;
  44. }
  45. void FinalRelease();
  46. CComPtr<IUnknown> m_pUnkMarshaler;
  47. #endif
  48. // IService
  49. public:
  50. STDMETHOD(get_MetaProperties)(/*[out, retval]*/ IMetaProperties * *ppprops)
  51. {
  52. return CObjectGlue::get_MetaProperties(ppprops);
  53. }
  54. STDMETHOD(get_ID)(/*[out, retval]*/ long *pid)
  55. {
  56. return CObjectGlue::get_ID(pid);
  57. }
  58. STDMETHOD(get_ScheduleEntries)(/*[out, retval]*/ IScheduleEntries * *pVal);
  59. STDMETHOD(get_ProviderDescription)(/*[out, retval]*/ BSTR *pbstrDesc);
  60. STDMETHOD(put_ProviderDescription)(/*[in]*/ BSTR pbstrDesc);
  61. STDMETHOD(get_ProviderNetworkName)(/*[out, retval]*/ BSTR *pbstrName);
  62. STDMETHOD(put_ProviderNetworkName)(/*[in]*/ BSTR bstrName);
  63. STDMETHOD(get_ProviderName)(/*[out, retval]*/ BSTR *pbstrName);
  64. STDMETHOD(put_ProviderName)(/*[in]*/ BSTR pbstrName);
  65. STDMETHOD(get_EndTime)(/*[out, retval]*/ DATE *pdt);
  66. STDMETHOD(put_EndTime)(/*[in]*/ DATE dt);
  67. STDMETHOD(get_StartTime)(/*[out, retval]*/ DATE *pdt);
  68. STDMETHOD(put_StartTime)(/*[in]*/ DATE dt);
  69. STDMETHOD(get_TuneRequest)(/*[out, retval]*/ IUnknown * *ppunk);
  70. STDMETHOD(putref_TuneRequest)(/*[in]*/ IUnknown *punk);
  71. protected:
  72. CComPtr<IUnknown> m_punkTuneRequest;
  73. };
  74. // Service.h : Declaration of the CServices
  75. /////////////////////////////////////////////////////////////////////////////
  76. // CServices
  77. class ATL_NO_VTABLE CServices :
  78. public CComObjectRootEx<CComObjectThreadModel>,
  79. public CComCoClass<CServices, &CLSID_Services>,
  80. public IConnectionPointContainerImpl<CServices>,
  81. public CObjectsGlue<IServices, IService>,
  82. public IDispatchImpl<IServices, &IID_IServices, &LIBID_GUIDESTORELib>,
  83. public CProxyIServicesEvents< CServices >
  84. {
  85. public:
  86. CServices()
  87. {
  88. #if defined(_ATL_FREE_THREADED)
  89. m_pUnkMarshaler = NULL;
  90. #endif
  91. m_pchanlineups = NULL;
  92. }
  93. DECLARE_REGISTRY_RESOURCEID(IDR_SERVICES)
  94. DECLARE_GET_CONTROLLING_UNKNOWN()
  95. #if defined(_ATL_FREE_THREADED)
  96. DECLARE_PROTECT_FINAL_CONSTRUCT()
  97. #endif
  98. BEGIN_COM_MAP(CServices)
  99. COM_INTERFACE_ENTRY(IServices)
  100. COM_INTERFACE_ENTRY(IDispatch)
  101. COM_INTERFACE_ENTRY(IConnectionPointContainer)
  102. #if defined(_ATL_FREE_THREADED)
  103. COM_INTERFACE_ENTRY_AGGREGATE(IID_IMarshal, m_pUnkMarshaler.p)
  104. #endif
  105. COM_INTERFACE_ENTRY_IMPL(IConnectionPointContainer)
  106. COM_INTERFACE_ENTRY(IObjectsNotifications)
  107. END_COM_MAP()
  108. BEGIN_CONNECTION_POINT_MAP(CServices)
  109. CONNECTION_POINT_ENTRY(DIID_IServicesEvents)
  110. END_CONNECTION_POINT_MAP()
  111. // IObjectsNotifications
  112. STDMETHOD(Notify_ItemAdded)(IUnknown *punk)
  113. {
  114. CComQIPtr<IService> pservice(punk);
  115. return Fire_ItemAdded(pservice);
  116. }
  117. STDMETHOD(Notify_ItemRemoved)(long idObj)
  118. {
  119. return Fire_ItemRemoved(idObj);
  120. }
  121. STDMETHOD(Notify_ItemChanged)(IUnknown *punk)
  122. {
  123. CComQIPtr<IService> pservice(punk);
  124. return Fire_ItemChanged(pservice);
  125. }
  126. STDMETHOD(Notify_ItemsChanged)()
  127. {
  128. return Fire_ItemsChanged();
  129. }
  130. #if defined(_ATL_FREE_THREADED)
  131. HRESULT FinalConstruct()
  132. {
  133. HRESULT hr;
  134. hr = CoCreateFreeThreadedMarshaler(
  135. GetControllingUnknown(), &m_pUnkMarshaler.p);
  136. return hr;
  137. }
  138. void FinalRelease()
  139. {
  140. m_pUnkMarshaler.Release();
  141. m_pchanlineups.Release();
  142. }
  143. CComPtr<IUnknown> m_pUnkMarshaler;
  144. #endif
  145. // IServices
  146. public:
  147. STDMETHOD(get_ItemsInTimeRange)(DATE dtStart, DATE dtEnd, /*[out, retval]*/ IServices * *ppservices)
  148. {
  149. ENTER_API
  150. {
  151. ValidateOutPtr<IServices>(ppservices, NULL);
  152. return _get_ItemsInTimeRange(dtStart, dtEnd, ppservices);
  153. }
  154. LEAVE_API
  155. }
  156. STDMETHOD(get_AddNew)(IUnknown *punkTuneRequest, BSTR bstrProviderName, BSTR bstrProviderDescription, BSTR bstrProviderNetworkName, DATE dtStart, DATE dtEnd, /*[out, retval]*/ IService * *pVal);
  157. STDMETHOD(get_ItemsWithMetaPropertyCond)(IMetaPropertyCondition *pcond, /*[out, retval]*/ IServices * *ppservices)
  158. {
  159. ENTER_API
  160. {
  161. ValidateInPtr<IMetaPropertyCondition>(pcond);
  162. ValidateOutPtr<IServices>(ppservices, NULL);
  163. return _get_ItemsWithMetaPropertyCond(pcond, ppservices);
  164. }
  165. LEAVE_API
  166. }
  167. STDMETHOD(get_ItemsWithMetaProperty)(IMetaProperty *pprop, /*[out, retval]*/ IServices * *ppservices)
  168. {
  169. ENTER_API
  170. {
  171. ValidateInPtr<IMetaProperty>(pprop);
  172. ValidateOutPtr<IServices>(ppservices, NULL);
  173. return _get_ItemsWithMetaProperty(pprop, ppservices);
  174. }
  175. LEAVE_API
  176. }
  177. STDMETHOD(get_ItemWithProviderName)(BSTR bstrProviderName, /*[out, retval]*/ IService * *pVal);
  178. STDMETHOD(get_ItemsByKey)(IMetaPropertyType *pproptype, IGuideDataProvider *pprovider, long idLang, long vt, IServices **ppservices)
  179. {
  180. ENTER_API
  181. {
  182. ValidateInPtr<IMetaPropertyType>(pproptype);
  183. ValidateInPtr_NULL_OK<IGuideDataProvider>(pprovider);
  184. ValidateOutPtr<IServices>(ppservices, NULL);
  185. return _get_ItemsByKey(pproptype, pprovider, idLang, vt, ppservices);
  186. }
  187. LEAVE_API
  188. }
  189. STDMETHOD(get_ItemWithKey)(VARIANT varKey, /*[out, retval]*/ IService * *ppservice)
  190. {
  191. ENTER_API
  192. {
  193. ValidateOutPtr<IService>(ppservice, NULL);
  194. return _get_ItemWithKey(varKey, ppservice);
  195. }
  196. LEAVE_API
  197. }
  198. STDMETHOD(get_ItemWithID)(long id, /*[out, retval]*/ IService * *ppservice)
  199. {
  200. ENTER_API
  201. {
  202. ValidateOutPtr<IService>(ppservice, NULL);
  203. return _get_ItemWithID(id, ppservice);
  204. }
  205. LEAVE_API
  206. }
  207. STDMETHOD(Remove)(VARIANT varIndex)
  208. {
  209. ENTER_API
  210. {
  211. return _Remove(varIndex);
  212. }
  213. LEAVE_API
  214. }
  215. STDMETHOD(RemoveAll)()
  216. {
  217. ENTER_API
  218. {
  219. return _RemoveAll();
  220. }
  221. LEAVE_API
  222. }
  223. STDMETHOD(Resync)()
  224. {
  225. ENTER_API
  226. {
  227. return _Resync();
  228. }
  229. LEAVE_API
  230. }
  231. STDMETHOD(UnreferencedItems)(/*[out, retval]*/ IServices * *ppservices)
  232. {
  233. ENTER_API
  234. {
  235. ValidateOutPtr<IServices>(ppservices, NULL);
  236. return _UnreferencedItems(ppservices);
  237. }
  238. LEAVE_API
  239. }
  240. STDMETHOD(get_ChannelLineups)(/*[out, retval]*/ IChannelLineups * *pVal);
  241. STDMETHOD(get_Item)(VARIANT varIndex, /*[out, retval]*/ IService * *ppservice)
  242. {
  243. ENTER_API
  244. {
  245. ValidateOutPtr<IService>(ppservice, NULL);
  246. return _get_Item(varIndex, ppservice);
  247. }
  248. LEAVE_API
  249. }
  250. STDMETHOD(get_Count)(/*[out, retval]*/ long *plCount)
  251. {
  252. ENTER_API
  253. {
  254. ValidateOut<long>(plCount, 0);
  255. return _get_Count(plCount);
  256. }
  257. LEAVE_API
  258. }
  259. #ifdef IMPLEMENT_NewEnum
  260. STDMETHOD(get__NewEnum)(IUnknown **ppunk)
  261. {
  262. ENTER_API
  263. {
  264. ValidateOutPtr<IUnknown>(ppunk, NULL);
  265. return _get__NewEnum(ppunk);
  266. }
  267. LEAVE_API
  268. }
  269. #endif
  270. protected:
  271. CComPtr<IChannelLineups> m_pchanlineups;
  272. };
  273. #if defined(_ATL_FREE_THREADED)
  274. inline void CService::FinalRelease()
  275. {
  276. m_pUnkMarshaler.Release();
  277. }
  278. #endif
  279. #endif //__SERVICE_H_