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.

566 lines
12 KiB

  1. // Channel.h : Declaration of the CChannel
  2. #ifndef __CHANNEL_H_
  3. #define __CHANNEL_H_
  4. #include "resource.h" // main symbols
  5. #include "guidedb.h"
  6. #include "object.h"
  7. #include "GuideStoreCP.h"
  8. /////////////////////////////////////////////////////////////////////////////
  9. // CChannel
  10. class ATL_NO_VTABLE CChannel :
  11. public CComObjectRootEx<CComObjectThreadModel>,
  12. public CComCoClass<CChannel, &CLSID_Channel>,
  13. public IConnectionPointContainerImpl<CChannel>,
  14. public CObjectGlue,
  15. public IDispatchImpl<IChannel, &IID_IChannel, &LIBID_GUIDESTORELib>
  16. {
  17. public:
  18. CChannel()
  19. {
  20. #if defined(_ATL_FREE_THREADED)
  21. m_pUnkMarshaler = NULL;
  22. #endif
  23. }
  24. DECLARE_REGISTRY_RESOURCEID(IDR_CHANNEL)
  25. DECLARE_GET_CONTROLLING_UNKNOWN()
  26. #if defined(_ATL_FREE_THREADED)
  27. DECLARE_PROTECT_FINAL_CONSTRUCT()
  28. #endif
  29. BEGIN_COM_MAP(CChannel)
  30. COM_INTERFACE_ENTRY(IChannel)
  31. COM_INTERFACE_ENTRY(IDispatch)
  32. COM_INTERFACE_ENTRY(IConnectionPointContainer)
  33. #if defined(_ATL_FREE_THREADED)
  34. COM_INTERFACE_ENTRY_AGGREGATE(IID_IMarshal, m_pUnkMarshaler.p)
  35. #endif
  36. END_COM_MAP()
  37. BEGIN_CONNECTION_POINT_MAP(CChannel)
  38. END_CONNECTION_POINT_MAP()
  39. #if defined(_ATL_FREE_THREADED)
  40. HRESULT FinalConstruct()
  41. {
  42. HRESULT hr;
  43. hr = CoCreateFreeThreadedMarshaler(
  44. GetControllingUnknown(), &m_pUnkMarshaler.p);
  45. return hr;
  46. }
  47. void FinalRelease()
  48. {
  49. m_pUnkMarshaler.Release();
  50. }
  51. CComPtr<IUnknown> m_pUnkMarshaler;
  52. #endif
  53. void Init(IService *pservice, BSTR bstrName)
  54. {
  55. m_pservice = pservice;
  56. m_bstrName = bstrName;
  57. }
  58. // IChannel
  59. public:
  60. STDMETHOD(get_MetaProperties)(/*[out, retval]*/ IMetaProperties * *ppprops)
  61. {
  62. return CObjectGlue::get_MetaProperties(ppprops);
  63. }
  64. STDMETHOD(get_ID)(/*[out, retval]*/ long *pid)
  65. {
  66. return CObjectGlue::get_ID(pid);
  67. }
  68. STDMETHOD(get_ChannelLineups)(/*[out, retval]*/ IChannelLineups * *pVal);
  69. STDMETHOD(putref_Service)(IService * pservice);
  70. STDMETHOD(get_Service)(/*[out, retval]*/ IService * *ppservice);
  71. STDMETHOD(get_Name)(/*[out, retval]*/ BSTR *pVal);
  72. STDMETHOD(put_Name)(/*[in]*/ BSTR newVal);
  73. protected:
  74. _bstr_t m_bstrName;
  75. CComPtr<IService> m_pservice;
  76. };
  77. // Channel.h : Declaration of the CChannels
  78. /////////////////////////////////////////////////////////////////////////////
  79. // CChannels
  80. class ATL_NO_VTABLE CChannels :
  81. public CComObjectRootEx<CComObjectThreadModel>,
  82. public CComCoClass<CChannels, &CLSID_Channels>,
  83. public IConnectionPointContainerImpl<CChannels>,
  84. public CObjectsGlue<IChannels, IChannel>,
  85. public IDispatchImpl<IChannels, &IID_IChannels, &LIBID_GUIDESTORELib>,
  86. public CProxyIChannelsEvents< CChannels >
  87. {
  88. public:
  89. CChannels()
  90. {
  91. #if defined(_ATL_FREE_THREADED)
  92. m_pUnkMarshaler = NULL;
  93. #endif
  94. }
  95. DECLARE_REGISTRY_RESOURCEID(IDR_CHANNELS)
  96. DECLARE_GET_CONTROLLING_UNKNOWN()
  97. #if defined(_ATL_FREE_THREADED)
  98. DECLARE_PROTECT_FINAL_CONSTRUCT()
  99. #endif
  100. BEGIN_COM_MAP(CChannels)
  101. COM_INTERFACE_ENTRY(IChannels)
  102. COM_INTERFACE_ENTRY(IDispatch)
  103. COM_INTERFACE_ENTRY(IConnectionPointContainer)
  104. #if defined(_ATL_FREE_THREADED)
  105. COM_INTERFACE_ENTRY_AGGREGATE(IID_IMarshal, m_pUnkMarshaler.p)
  106. #endif
  107. COM_INTERFACE_ENTRY_IMPL(IConnectionPointContainer)
  108. COM_INTERFACE_ENTRY(IObjectsNotifications)
  109. END_COM_MAP()
  110. BEGIN_CONNECTION_POINT_MAP(CChannels)
  111. CONNECTION_POINT_ENTRY(DIID_IChannelsEvents)
  112. END_CONNECTION_POINT_MAP()
  113. #if defined(_ATL_FREE_THREADED)
  114. HRESULT FinalConstruct()
  115. {
  116. HRESULT hr;
  117. hr = CoCreateFreeThreadedMarshaler(
  118. GetControllingUnknown(), &m_pUnkMarshaler.p);
  119. return hr;
  120. }
  121. void FinalRelease()
  122. {
  123. m_pUnkMarshaler.Release();
  124. }
  125. CComPtr<IUnknown> m_pUnkMarshaler;
  126. #endif
  127. // IObjectsNotifications
  128. STDMETHOD(Notify_ItemAdded)(IUnknown *punk)
  129. {
  130. CComQIPtr<IChannel> pchan(punk);
  131. return Fire_ItemAdded(pchan);
  132. }
  133. STDMETHOD(Notify_ItemRemoved)(long idObj)
  134. {
  135. return Fire_ItemRemoved(idObj);
  136. }
  137. STDMETHOD(Notify_ItemChanged)(IUnknown *punk)
  138. {
  139. CComQIPtr<IChannel> pchan(punk);
  140. return Fire_ItemChanged(pchan);
  141. }
  142. STDMETHOD(Notify_ItemsChanged)()
  143. {
  144. return Fire_ItemsChanged();
  145. }
  146. // IChannels
  147. public:
  148. STDMETHOD(get_ItemWithName)(BSTR bstrName, /*[out, retval]*/ IChannel **ppchan);
  149. STDMETHOD(get_ItemsWithMetaPropertyCond)(IMetaPropertyCondition *pcond, /*[out, retval]*/ IChannels * *ppchans)
  150. {
  151. ENTER_API
  152. {
  153. ValidateInPtr<IMetaPropertyCondition>(pcond);
  154. ValidateOutPtr<IChannels>(ppchans, NULL);
  155. return _get_ItemsWithMetaPropertyCond(pcond, ppchans);
  156. }
  157. LEAVE_API
  158. }
  159. STDMETHOD(get_AddNewAt)(IService *pservice, BSTR bstrName, long index,
  160. /*[out, retval]*/ IChannel * *pVal);
  161. STDMETHOD(AddAt)(IChannel *pchan, long index);
  162. STDMETHOD(Remove)(VARIANT varIndex)
  163. {
  164. ENTER_API
  165. {
  166. return _Remove(varIndex);
  167. }
  168. LEAVE_API
  169. }
  170. STDMETHOD(RemoveAll)()
  171. {
  172. ENTER_API
  173. {
  174. return _RemoveAll();
  175. }
  176. LEAVE_API
  177. }
  178. STDMETHOD(Resync)()
  179. {
  180. ENTER_API
  181. {
  182. return _Resync();
  183. }
  184. LEAVE_API
  185. }
  186. STDMETHOD(UnreferencedItems)(/*[out, retval]*/ IChannels * *ppchans)
  187. {
  188. ENTER_API
  189. {
  190. ValidateOutPtr<IChannels>(ppchans, NULL);
  191. return _UnreferencedItems(ppchans);
  192. }
  193. LEAVE_API
  194. }
  195. STDMETHOD(get_ItemsByKey)(IMetaPropertyType *pproptype, IGuideDataProvider *pprovider, long idLang, long vt, IChannels **ppchans)
  196. {
  197. ENTER_API
  198. {
  199. ValidateInPtr<IMetaPropertyType>(pproptype);
  200. ValidateInPtr_NULL_OK<IGuideDataProvider>(pprovider);
  201. ValidateOutPtr<IChannels>(ppchans, NULL);
  202. return _get_ItemsByKey(pproptype, pprovider, idLang, vt, ppchans);
  203. }
  204. LEAVE_API
  205. }
  206. STDMETHOD(get_ItemWithKey)(VARIANT varKey, /*[out, retval]*/ IChannel * *ppchan)
  207. {
  208. ENTER_API
  209. {
  210. ValidateOutPtr<IChannel>(ppchan, NULL);
  211. return _get_ItemWithKey(varKey, ppchan);
  212. }
  213. LEAVE_API
  214. }
  215. STDMETHOD(get_Item)(VARIANT varIndex, /*[out, retval]*/ IChannel * *ppchan)
  216. {
  217. ENTER_API
  218. {
  219. ValidateOutPtr<IChannel>(ppchan, NULL);
  220. return _get_Item(varIndex, ppchan);
  221. }
  222. LEAVE_API
  223. }
  224. STDMETHOD(get_Count)(/*[out, retval]*/ long *plCount)
  225. {
  226. ENTER_API
  227. {
  228. ValidateOut<long>(plCount, 0);
  229. return _get_Count(plCount);
  230. }
  231. LEAVE_API
  232. }
  233. #ifdef IMPLEMENT_NewEnum
  234. STDMETHOD(get__NewEnum)(IUnknown **ppunk)
  235. {
  236. ENTER_API
  237. {
  238. ValidateOutPtr<IUnknown>(ppunk, NULL);
  239. return _get__NewEnum(ppunk);
  240. }
  241. LEAVE_API
  242. }
  243. #endif
  244. protected:
  245. };
  246. // Channel.h : Declaration of the CChannelLineup
  247. /////////////////////////////////////////////////////////////////////////////
  248. // CChannelLineup
  249. class ATL_NO_VTABLE CChannelLineup :
  250. public CComObjectRootEx<CComObjectThreadModel>,
  251. public CComCoClass<CChannelLineup, &CLSID_ChannelLineup>,
  252. public IConnectionPointContainerImpl<CChannelLineup>,
  253. public CObjectGlue,
  254. public IDispatchImpl<IChannelLineup, &IID_IChannelLineup, &LIBID_GUIDESTORELib>
  255. {
  256. public:
  257. CChannelLineup()
  258. {
  259. #if defined(_ATL_FREE_THREADED)
  260. m_pUnkMarshaler = NULL;
  261. #endif
  262. m_pchans = NULL;
  263. }
  264. DECLARE_REGISTRY_RESOURCEID(IDR_CHANNELLINEUP)
  265. DECLARE_GET_CONTROLLING_UNKNOWN()
  266. #if defined(_ATL_FREE_THREADED)
  267. DECLARE_PROTECT_FINAL_CONSTRUCT()
  268. #endif
  269. BEGIN_COM_MAP(CChannelLineup)
  270. COM_INTERFACE_ENTRY(IChannelLineup)
  271. COM_INTERFACE_ENTRY(IDispatch)
  272. COM_INTERFACE_ENTRY(IConnectionPointContainer)
  273. #if defined(_ATL_FREE_THREADED)
  274. COM_INTERFACE_ENTRY_AGGREGATE(IID_IMarshal, m_pUnkMarshaler.p)
  275. #endif
  276. END_COM_MAP()
  277. BEGIN_CONNECTION_POINT_MAP(CChannelLineup)
  278. END_CONNECTION_POINT_MAP()
  279. #if defined(_ATL_FREE_THREADED)
  280. HRESULT FinalConstruct()
  281. {
  282. HRESULT hr;
  283. hr = CoCreateFreeThreadedMarshaler(
  284. GetControllingUnknown(), &m_pUnkMarshaler.p);
  285. return hr;
  286. }
  287. void FinalRelease()
  288. {
  289. m_pUnkMarshaler.Release();
  290. }
  291. CComPtr<IUnknown> m_pUnkMarshaler;
  292. #endif
  293. // IChannelLineup
  294. public:
  295. STDMETHOD(get_MetaProperties)(/*[out, retval]*/ IMetaProperties * *ppprops)
  296. {
  297. return CObjectGlue::get_MetaProperties(ppprops);
  298. }
  299. STDMETHOD(get_ID)(/*[out, retval]*/ long *pid)
  300. {
  301. return CObjectGlue::get_ID(pid);
  302. }
  303. STDMETHOD(get_Channels)(/*[out, retval]*/ IChannels * *pVal);
  304. STDMETHOD(get_Name)(/*[out, retval]*/ BSTR *pVal);
  305. STDMETHOD(put_Name)(/*[in]*/ BSTR newVal);
  306. protected:
  307. CComPtr<IChannels> m_pchans;
  308. };
  309. // Channel.h : Declaration of the CChannelLineups
  310. /////////////////////////////////////////////////////////////////////////////
  311. // CChannelLineups
  312. class ATL_NO_VTABLE CChannelLineups :
  313. public CComObjectRootEx<CComObjectThreadModel>,
  314. public CComCoClass<CChannelLineups, &CLSID_ChannelLineups>,
  315. public CObjectsGlue<IChannelLineups, IChannelLineup>,
  316. public IConnectionPointContainerImpl<CChannelLineups>,
  317. public IDispatchImpl<IChannelLineups, &IID_IChannelLineups, &LIBID_GUIDESTORELib>,
  318. public CProxyIChannelLineupsEvents< CChannelLineups >
  319. {
  320. public:
  321. CChannelLineups()
  322. {
  323. #if defined(_ATL_FREE_THREADED)
  324. m_pUnkMarshaler = NULL;
  325. #endif
  326. }
  327. DECLARE_REGISTRY_RESOURCEID(IDR_CHANNELLINEUPS)
  328. DECLARE_GET_CONTROLLING_UNKNOWN()
  329. #if defined(_ATL_FREE_THREADED)
  330. DECLARE_PROTECT_FINAL_CONSTRUCT()
  331. #endif
  332. BEGIN_COM_MAP(CChannelLineups)
  333. COM_INTERFACE_ENTRY(IChannelLineups)
  334. COM_INTERFACE_ENTRY(IDispatch)
  335. COM_INTERFACE_ENTRY(IConnectionPointContainer)
  336. #if defined(_ATL_FREE_THREADED)
  337. COM_INTERFACE_ENTRY_AGGREGATE(IID_IMarshal, m_pUnkMarshaler.p)
  338. #endif
  339. COM_INTERFACE_ENTRY_IMPL(IConnectionPointContainer)
  340. COM_INTERFACE_ENTRY(IObjectsNotifications)
  341. END_COM_MAP()
  342. BEGIN_CONNECTION_POINT_MAP(CChannelLineups)
  343. CONNECTION_POINT_ENTRY(DIID_IChannelLineupsEvents)
  344. END_CONNECTION_POINT_MAP()
  345. #if defined(_ATL_FREE_THREADED)
  346. HRESULT FinalConstruct()
  347. {
  348. HRESULT hr;
  349. hr = CoCreateFreeThreadedMarshaler(
  350. GetControllingUnknown(), &m_pUnkMarshaler.p);
  351. return hr;
  352. }
  353. void FinalRelease()
  354. {
  355. m_pUnkMarshaler.Release();
  356. }
  357. CComPtr<IUnknown> m_pUnkMarshaler;
  358. #endif
  359. // IObjectsNotifications
  360. STDMETHOD(Notify_ItemAdded)(IUnknown *punk)
  361. {
  362. CComQIPtr<IChannelLineup> pchanlineup(punk);
  363. return Fire_ItemAdded(pchanlineup);
  364. }
  365. STDMETHOD(Notify_ItemRemoved)(long idObj)
  366. {
  367. return Fire_ItemRemoved(idObj);
  368. }
  369. STDMETHOD(Notify_ItemChanged)(IUnknown *punk)
  370. {
  371. CComQIPtr<IChannelLineup> pchanlineup(punk);
  372. return Fire_ItemChanged(pchanlineup);
  373. }
  374. STDMETHOD(Notify_ItemsChanged)()
  375. {
  376. return Fire_ItemsChanged();
  377. }
  378. // IChannelLineups
  379. STDMETHOD(Remove)(VARIANT varIndex)
  380. {
  381. ENTER_API
  382. {
  383. return _Remove(varIndex);
  384. }
  385. LEAVE_API
  386. }
  387. STDMETHOD(RemoveAll)()
  388. {
  389. ENTER_API
  390. {
  391. return _RemoveAll();
  392. }
  393. LEAVE_API
  394. }
  395. STDMETHOD(Resync)()
  396. {
  397. ENTER_API
  398. {
  399. return _Resync();
  400. }
  401. LEAVE_API
  402. }
  403. STDMETHOD(UnreferencedItems)(/*[out, retval]*/ IChannelLineups * *ppchanlineups)
  404. {
  405. ENTER_API
  406. {
  407. ValidateOutPtr<IChannelLineups>(ppchanlineups, NULL);
  408. return _UnreferencedItems(ppchanlineups);
  409. }
  410. LEAVE_API
  411. }
  412. STDMETHOD(get_ItemsByKey)(IMetaPropertyType *pproptype, IGuideDataProvider *pprovider, long idLang, long vt, IChannelLineups **ppchanlineups)
  413. {
  414. ENTER_API
  415. {
  416. ValidateInPtr<IMetaPropertyType>(pproptype);
  417. ValidateInPtr_NULL_OK<IGuideDataProvider>(pprovider);
  418. ValidateOutPtr<IChannelLineups>(ppchanlineups, NULL);
  419. return _get_ItemsByKey(pproptype, pprovider, idLang, vt, ppchanlineups);
  420. }
  421. LEAVE_API
  422. }
  423. STDMETHOD(get_ItemWithKey)(VARIANT varKey, /*[out, retval]*/ IChannelLineup * *ppchanlineup)
  424. {
  425. ENTER_API
  426. {
  427. ValidateOutPtr<IChannelLineup>(ppchanlineup, NULL);
  428. return _get_ItemWithKey(varKey, ppchanlineup);
  429. }
  430. LEAVE_API
  431. }
  432. STDMETHOD(get_Item)(VARIANT varIndex, /*[out, retval]*/ IChannelLineup **ppchanlineup)
  433. {
  434. ENTER_API
  435. {
  436. ValidateOutPtr<IChannelLineup>(ppchanlineup, NULL);
  437. return _get_Item(varIndex, ppchanlineup);
  438. }
  439. LEAVE_API
  440. }
  441. STDMETHOD(get_Count)(/*[out, retval]*/ long *plCount)
  442. {
  443. ENTER_API
  444. {
  445. ValidateOut<long>(plCount, 0);
  446. return _get_Count(plCount);
  447. }
  448. LEAVE_API
  449. }
  450. #ifdef IMPLEMENT_NewEnum
  451. STDMETHOD(get__NewEnum)(IUnknown **ppunk)
  452. {
  453. ENTER_API
  454. {
  455. ValidateOutPtr<IUnknown>(ppunk, NULL);
  456. return _get__NewEnum(ppunk);
  457. }
  458. LEAVE_API
  459. }
  460. #endif
  461. public:
  462. STDMETHOD(get_AddNew)(BSTR bstrName, /*[out, retval]*/ IChannelLineup * *ppchanlineup)
  463. {
  464. ENTER_API
  465. {
  466. ValidateIn(bstrName);
  467. ValidateOutPtr<IChannelLineup>(ppchanlineup, NULL);
  468. HRESULT hr = _get_AddNew(ppchanlineup);
  469. if (FAILED(hr))
  470. return hr;
  471. return (*ppchanlineup)->put_Name(bstrName);
  472. }
  473. LEAVE_API
  474. }
  475. protected:
  476. };
  477. #endif //__CHANNEL_H_