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.

304 lines
7.2 KiB

  1. // ScheduleEntry.h : Declaration of the CScheduleEntry
  2. #ifndef __SCHEDULEENTRY_H_
  3. #define __SCHEDULEENTRY_H_
  4. #include "resource.h" // main symbols
  5. #include "object.h"
  6. #include "GuideStoreCP.h"
  7. class CScheduleEntry;
  8. class CScheduleEntries;
  9. /////////////////////////////////////////////////////////////////////////////
  10. // CScheduleEntry
  11. class ATL_NO_VTABLE CScheduleEntry :
  12. public CComObjectRootEx<CComObjectThreadModel>,
  13. public CComCoClass<CScheduleEntry, &CLSID_ScheduleEntry>,
  14. public CObjectGlue,
  15. public IDispatchImpl<IScheduleEntry, &IID_IScheduleEntry, &LIBID_GUIDESTORELib>
  16. {
  17. public:
  18. CScheduleEntry()
  19. {
  20. #if defined(_ATL_FREE_THREADED)
  21. m_pUnkMarshaler = NULL;
  22. #endif
  23. }
  24. DECLARE_REGISTRY_RESOURCEID(IDR_SCHEDULEENTRY)
  25. DECLARE_GET_CONTROLLING_UNKNOWN()
  26. #if defined(_ATL_FREE_THREADED)
  27. DECLARE_PROTECT_FINAL_CONSTRUCT()
  28. #endif
  29. BEGIN_COM_MAP(CScheduleEntry)
  30. COM_INTERFACE_ENTRY(IScheduleEntry)
  31. COM_INTERFACE_ENTRY(IDispatch)
  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. CComPtr<IUnknown> m_pUnkMarshaler;
  46. #endif
  47. // IScheduleEntry
  48. public:
  49. STDMETHOD(get_MetaProperties)(/*[out, retval]*/ IMetaProperties * *ppprops)
  50. {
  51. return CObjectGlue::get_MetaProperties(ppprops);
  52. }
  53. STDMETHOD(get_ID)(/*[out, retval]*/ long *pid)
  54. {
  55. return CObjectGlue::get_ID(pid);
  56. }
  57. STDMETHOD(get_Length)(/*[out, retval]*/ long *pVal);
  58. STDMETHOD(get_EndTime)(/*[out, retval]*/ DATE *pdt);
  59. STDMETHOD(put_EndTime)(/*[in]*/ DATE dt);
  60. STDMETHOD(get_StartTime)(/*[out, retval]*/ DATE *pdt);
  61. STDMETHOD(put_StartTime)(/*[in]*/ DATE dt);
  62. STDMETHOD(get_Program)(/*[out, retval]*/ IProgram * *ppprog);
  63. STDMETHOD(putref_Program)(/*[in]*/ IProgram * pprog);
  64. STDMETHOD(get_Service)(/*[out, retval]*/ IService * *ppservice);
  65. STDMETHOD(putref_Service)(/*[in]*/ IService * pservice);
  66. protected:
  67. CComPtr<IService> m_pservice;
  68. CComPtr<IProgram> m_pprog;
  69. };
  70. /////////////////////////////////////////////////////////////////////////////
  71. // CScheduleEntries
  72. class ATL_NO_VTABLE CScheduleEntries :
  73. public CComObjectRootEx<CComObjectThreadModel>,
  74. public CComCoClass<CScheduleEntries, &CLSID_ScheduleEntries>,
  75. public IConnectionPointContainerImpl<CScheduleEntries>,
  76. public CObjectsGlue<IScheduleEntries, IScheduleEntry>,
  77. public IDispatchImpl<IScheduleEntries, &IID_IScheduleEntries, &LIBID_GUIDESTORELib>,
  78. public CProxyIScheduleEntriesEvents< CScheduleEntries >
  79. {
  80. public:
  81. CScheduleEntries()
  82. {
  83. #if defined(_ATL_FREE_THREADED)
  84. m_pUnkMarshaler = NULL;
  85. #endif
  86. }
  87. DECLARE_REGISTRY_RESOURCEID(IDR_SCHEDULEENTRIES)
  88. DECLARE_GET_CONTROLLING_UNKNOWN()
  89. DECLARE_PROTECT_FINAL_CONSTRUCT()
  90. BEGIN_COM_MAP(CScheduleEntries)
  91. COM_INTERFACE_ENTRY(IScheduleEntries)
  92. COM_INTERFACE_ENTRY(IDispatch)
  93. COM_INTERFACE_ENTRY(IConnectionPointContainer)
  94. #if defined(_ATL_FREE_THREADED)
  95. COM_INTERFACE_ENTRY_AGGREGATE(IID_IMarshal, m_pUnkMarshaler.p)
  96. #endif
  97. COM_INTERFACE_ENTRY_IMPL(IConnectionPointContainer)
  98. COM_INTERFACE_ENTRY(IObjectsNotifications)
  99. END_COM_MAP()
  100. BEGIN_CONNECTION_POINT_MAP(CScheduleEntries)
  101. CONNECTION_POINT_ENTRY(DIID_IScheduleEntriesEvents)
  102. END_CONNECTION_POINT_MAP()
  103. #if defined(_ATL_FREE_THREADED)
  104. HRESULT FinalConstruct()
  105. {
  106. HRESULT hr;
  107. hr = CoCreateFreeThreadedMarshaler(
  108. GetControllingUnknown(), &m_pUnkMarshaler.p);
  109. return hr;
  110. }
  111. void FinalRelease()
  112. {
  113. m_pUnkMarshaler.Release();
  114. }
  115. CComPtr<IUnknown> m_pUnkMarshaler;
  116. #endif
  117. // IObjectsNotifications
  118. STDMETHOD(Notify_ItemAdded)(IUnknown *punk)
  119. {
  120. CComQIPtr<IScheduleEntry> pschedentry(punk);
  121. return Fire_ItemAdded(pschedentry);
  122. }
  123. STDMETHOD(Notify_ItemRemoved)(long idObj)
  124. {
  125. return Fire_ItemRemoved(idObj);
  126. }
  127. STDMETHOD(Notify_ItemChanged)(IUnknown *punk)
  128. {
  129. CComQIPtr<IScheduleEntry> pschedentry(punk);
  130. return Fire_ItemChanged(pschedentry);
  131. }
  132. STDMETHOD(Notify_ItemsChanged)()
  133. {
  134. return Fire_ItemsChanged();
  135. }
  136. // IScheduleEntries
  137. public:
  138. STDMETHOD(Remove)(VARIANT var)
  139. {
  140. ENTER_API
  141. {
  142. return _Remove(var);
  143. }
  144. LEAVE_API
  145. }
  146. STDMETHOD(RemoveAll)()
  147. {
  148. ENTER_API
  149. {
  150. return _RemoveAll();
  151. }
  152. LEAVE_API
  153. }
  154. STDMETHOD(Resync)()
  155. {
  156. ENTER_API
  157. {
  158. return _Resync();
  159. }
  160. LEAVE_API
  161. }
  162. STDMETHOD(UnreferencedItems)(/*[out, retval]*/ IScheduleEntries * *ppschedentries)
  163. {
  164. ENTER_API
  165. {
  166. ValidateOutPtr<IScheduleEntries>(ppschedentries, NULL);
  167. return _UnreferencedItems(ppschedentries);
  168. }
  169. LEAVE_API
  170. }
  171. STDMETHOD(get_ItemsInTimeRange)(DATE dtStart, DATE dtEnd, /*[out, retval]*/ IScheduleEntries * *ppschedentries)
  172. {
  173. ENTER_API
  174. {
  175. ValidateOutPtr<IScheduleEntries>(ppschedentries, NULL);
  176. return _get_ItemsInTimeRange(dtStart, dtEnd, ppschedentries);
  177. }
  178. LEAVE_API
  179. }
  180. STDMETHOD(get_AddNew)(DATE dtStart, DATE dtEnd, IService *pservice, IProgram *pprog, /*[out, retval]*/ IScheduleEntry * *pVal);
  181. STDMETHOD(get_ItemsWithMetaPropertyCond)(IMetaPropertyCondition *pcond, /*[out, retval]*/ IScheduleEntries * *ppschedentries)
  182. {
  183. ENTER_API
  184. {
  185. ValidateInPtr<IMetaPropertyCondition>(pcond);
  186. ValidateOutPtr<IScheduleEntries>(ppschedentries, NULL);
  187. return _get_ItemsWithMetaPropertyCond(pcond, ppschedentries);
  188. }
  189. LEAVE_API
  190. }
  191. STDMETHOD(get_ItemsWithMetaProperty)(IMetaProperty *pprop, /*[out, retval]*/ IScheduleEntries * *ppschedentries)
  192. {
  193. ENTER_API
  194. {
  195. ValidateInPtr<IMetaProperty>(pprop);
  196. ValidateOutPtr<IScheduleEntries>(ppschedentries, NULL);
  197. return _get_ItemsWithMetaProperty(pprop, ppschedentries);
  198. }
  199. LEAVE_API
  200. }
  201. STDMETHOD(get_ItemsWithService)(IService *pservice, /*[out, retval]*/ IScheduleEntries **ppschedentries);
  202. STDMETHOD(get_ItemWithServiceAtTime)(IService *pservice, DATE dt, /*[out, retval]*/ IScheduleEntry * *pVal);
  203. STDMETHOD(get_ItemsByKey)(IMetaPropertyType *pproptype, IGuideDataProvider *pprovider, long idLang, long vt, IScheduleEntries **ppschedentries)
  204. {
  205. ENTER_API
  206. {
  207. ValidateInPtr<IMetaPropertyType>(pproptype);
  208. ValidateInPtr_NULL_OK<IGuideDataProvider>(pprovider);
  209. ValidateOutPtr<IScheduleEntries>(ppschedentries, NULL);
  210. return _get_ItemsByKey(pproptype, pprovider, idLang, vt, ppschedentries);
  211. }
  212. LEAVE_API
  213. }
  214. STDMETHOD(get_ItemWithKey)(VARIANT varKey, /*[out, retval]*/ IScheduleEntry * *ppschedentry)
  215. {
  216. ENTER_API
  217. {
  218. ValidateOutPtr<IScheduleEntry>(ppschedentry, NULL);
  219. return _get_ItemWithKey(varKey, ppschedentry);
  220. }
  221. LEAVE_API
  222. }
  223. STDMETHOD(get_Item)(VARIANT varIndex, /*[out, retval]*/ IScheduleEntry * *ppschedentry)
  224. {
  225. ENTER_API
  226. {
  227. ValidateOutPtr<IScheduleEntry>(ppschedentry, NULL);
  228. return _get_Item(varIndex, ppschedentry);
  229. }
  230. LEAVE_API
  231. }
  232. STDMETHOD(get_Count)(/*[out, retval]*/ long *plCount)
  233. {
  234. ENTER_API
  235. {
  236. ValidateOut<long>(plCount, 0);
  237. return _get_Count(plCount);
  238. }
  239. LEAVE_API
  240. }
  241. #ifdef IMPLEMENT_NewEnum
  242. STDMETHOD(get__NewEnum)(IUnknown **ppunk)
  243. {
  244. ENTER_API
  245. {
  246. ValidateOutPtr<IUnknown>(ppunk, NULL);
  247. return _get__NewEnum(ppunk);
  248. }
  249. LEAVE_API
  250. }
  251. #endif
  252. protected:
  253. };
  254. #if defined(_ATL_FREE_THREADED)
  255. inline void CScheduleEntry::FinalRelease()
  256. {
  257. m_pUnkMarshaler.Release();
  258. }
  259. #endif
  260. #endif //__SCHEDULEENTRY_H_