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.

322 lines
6.7 KiB

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