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.

280 lines
6.7 KiB

  1. // GuideDataProvider.h : Declaration of the CGuideDataProvider
  2. #ifndef __GUIDEDATAPROVIDER_H_
  3. #define __GUIDEDATAPROVIDER_H_
  4. #include "resource.h" // main symbols
  5. #include "object.h"
  6. #include "GuideStoreCP.h"
  7. class CGuideDataProvider;
  8. class CGuideDataProviders;
  9. class DECLSPEC_UUID("e78e3f11-3c6f-4b32-834a-753a1909588e") ATL_NO_VTABLE CGuideDataProvider :
  10. public CComObjectRootEx<CComObjectThreadModel>,
  11. public CComCoClass<CGuideDataProvider, &CLSID_GuideDataProvider>,
  12. public CObjectGlue,
  13. public IDispatchImpl<IGuideDataProvider, &IID_IGuideDataProvider, &LIBID_GUIDESTORELib>
  14. {
  15. public:
  16. CGuideDataProvider()
  17. {
  18. #if defined(_ATL_FREE_THREADED)
  19. m_pUnkMarshaler = NULL;
  20. #endif
  21. }
  22. DECLARE_REGISTRY_RESOURCEID(IDR_GUIDEDATAPROVIDER)
  23. DECLARE_GET_CONTROLLING_UNKNOWN()
  24. #if defined(_ATL_FREE_THREADED)
  25. DECLARE_PROTECT_FINAL_CONSTRUCT()
  26. #endif
  27. BEGIN_COM_MAP(CGuideDataProvider)
  28. COM_INTERFACE_ENTRY(IGuideDataProvider)
  29. COM_INTERFACE_ENTRY(CGuideDataProvider)
  30. COM_INTERFACE_ENTRY(IDispatch)
  31. #if defined(_ATL_FREE_THREADED)
  32. COM_INTERFACE_ENTRY_AGGREGATE(IID_IMarshal, m_pUnkMarshaler.p)
  33. #endif
  34. END_COM_MAP()
  35. #if defined(_ATL_FREE_THREADED)
  36. HRESULT FinalConstruct()
  37. {
  38. HRESULT hr;
  39. hr = CoCreateFreeThreadedMarshaler(
  40. GetControllingUnknown(), &m_pUnkMarshaler.p);
  41. return hr;
  42. }
  43. void FinalRelease()
  44. {
  45. m_pUnkMarshaler.Release();
  46. }
  47. CComPtr<IUnknown> m_pUnkMarshaler;
  48. #endif
  49. // IGuideDataProvider
  50. public:
  51. STDMETHOD(get_MetaProperties)(/*[out, retval]*/ IMetaProperties * *ppprops)
  52. {
  53. return CObjectGlue::get_MetaProperties(ppprops);
  54. }
  55. STDMETHOD(get_ID)(/*[out, retval]*/ long *pid)
  56. {
  57. return CObjectGlue::get_ID(pid);
  58. }
  59. STDMETHOD(get_Description)(/*[out, retval]*/ BSTR *pbstrDesc);
  60. STDMETHOD(put_Description)(/*[in]*/ BSTR bstrDesc);
  61. STDMETHOD(get_Name)(/*[out, retval]*/ BSTR *pbstrName);
  62. };
  63. // GuideDataProvider.h : Declaration of the CGuideDataProviders
  64. /////////////////////////////////////////////////////////////////////////////
  65. // CGuideDataProviders
  66. class ATL_NO_VTABLE CGuideDataProviders :
  67. public CComObjectRootEx<CComObjectThreadModel>,
  68. public CComCoClass<CGuideDataProviders, &CLSID_GuideDataProviders>,
  69. public IConnectionPointContainerImpl<CGuideDataProviders>,
  70. public CObjectsGlue<IGuideDataProviders, IGuideDataProvider>,
  71. public CProxyIGuideDataProvidersEvents< CGuideDataProviders >,
  72. public IDispatchImpl<IGuideDataProviders, &IID_IGuideDataProviders, &LIBID_GUIDESTORELib>
  73. {
  74. public:
  75. CGuideDataProviders()
  76. {
  77. #if defined(_ATL_FREE_THREADED)
  78. m_pUnkMarshaler = NULL;
  79. #endif
  80. }
  81. DECLARE_REGISTRY_RESOURCEID(IDR_GUIDEDATAPROVIDERS)
  82. DECLARE_GET_CONTROLLING_UNKNOWN()
  83. #if defined(_ATL_FREE_THREADED)
  84. DECLARE_PROTECT_FINAL_CONSTRUCT()
  85. #endif
  86. BEGIN_COM_MAP(CGuideDataProviders)
  87. COM_INTERFACE_ENTRY(IGuideDataProviders)
  88. COM_INTERFACE_ENTRY(IDispatch)
  89. COM_INTERFACE_ENTRY(IConnectionPointContainer)
  90. #if defined(_ATL_FREE_THREADED)
  91. COM_INTERFACE_ENTRY_AGGREGATE(IID_IMarshal, m_pUnkMarshaler.p)
  92. #endif
  93. END_COM_MAP()
  94. BEGIN_CONNECTION_POINT_MAP(CGuideDataProviders)
  95. CONNECTION_POINT_ENTRY(DIID_IGuideDataProvidersEvents)
  96. END_CONNECTION_POINT_MAP()
  97. // Reflect Notifications from CObjectsGlue<>
  98. STDMETHOD(Notify_ItemAdded)(IUnknown *punk)
  99. {
  100. CComQIPtr<IGuideDataProvider> pprovider(punk);
  101. return Fire_ItemAdded(pprovider);
  102. }
  103. STDMETHOD(Notify_ItemRemoved)(long idObj)
  104. {
  105. return Fire_ItemRemoved(idObj);
  106. }
  107. STDMETHOD(Notify_ItemChanged)(IUnknown *punk)
  108. {
  109. CComQIPtr<IGuideDataProvider> pprovider(punk);
  110. return Fire_ItemChanged(pprovider);
  111. }
  112. STDMETHOD(Notify_ItemsChanged)()
  113. {
  114. return Fire_ItemsChanged();
  115. }
  116. #if defined(_ATL_FREE_THREADED)
  117. HRESULT FinalConstruct()
  118. {
  119. HRESULT hr;
  120. hr = CoCreateFreeThreadedMarshaler(
  121. GetControllingUnknown(), &m_pUnkMarshaler.p);
  122. return hr;
  123. }
  124. void FinalRelease()
  125. {
  126. m_pUnkMarshaler.Release();
  127. }
  128. CComPtr<IUnknown> m_pUnkMarshaler;
  129. #endif
  130. // IGuideDataProviders
  131. STDMETHOD(get_ItemWithName)(BSTR bstrName, /*[out, retval]*/ IGuideDataProvider **ppdataprovider);
  132. STDMETHOD(get_AddNew)(/* [in] */ BSTR bstrName, /*[out, retval]*/ IGuideDataProvider * *ppdataprovider)
  133. {
  134. ENTER_API
  135. {
  136. HRESULT hr;
  137. ValidateOutPtr<IGuideDataProvider>(ppdataprovider, NULL);
  138. hr = get_ItemWithName(bstrName, ppdataprovider);
  139. if (SUCCEEDED(hr))
  140. return hr;
  141. hr = _get_AddNew(ppdataprovider);
  142. if (FAILED(hr))
  143. return hr;
  144. return m_pdb->DescriptionPropSet::_put_Name(*ppdataprovider, bstrName);
  145. }
  146. LEAVE_API
  147. }
  148. STDMETHOD(get_ItemsWithMetaPropertyCond)(IMetaPropertyCondition *pcond, /*[out, retval]*/ IGuideDataProviders * *ppdataproviders)
  149. {
  150. ENTER_API
  151. {
  152. ValidateInPtr<IMetaPropertyCondition>(pcond);
  153. ValidateOutPtr<IGuideDataProviders>(ppdataproviders, NULL);
  154. return _get_ItemsWithMetaPropertyCond(pcond, ppdataproviders);
  155. }
  156. LEAVE_API
  157. }
  158. STDMETHOD(get_ItemsWithMetaProperty)(IMetaProperty *pprop, /*[out, retval]*/ IGuideDataProviders * *ppdataproviders)
  159. {
  160. ENTER_API
  161. {
  162. ValidateInPtr<IMetaProperty>(pprop);
  163. ValidateOutPtr<IGuideDataProviders>(ppdataproviders, NULL);
  164. return _get_ItemsWithMetaProperty(pprop, ppdataproviders);
  165. }
  166. LEAVE_API
  167. }
  168. STDMETHOD(get_ItemWithID)(long id, /*[out, retval]*/ IGuideDataProvider * *ppdataprovider)
  169. {
  170. ENTER_API
  171. {
  172. ValidateOutPtr<IGuideDataProvider>(ppdataprovider, NULL);
  173. return _get_ItemWithID(id, ppdataprovider);
  174. }
  175. LEAVE_API
  176. }
  177. STDMETHOD(get_ItemsByKey)(IMetaPropertyType *pproptype, IGuideDataProvider *pprovider, long idLang, long vt, IGuideDataProviders **ppdataproviders)
  178. {
  179. ENTER_API
  180. {
  181. ValidateInPtr<IMetaPropertyType>(pproptype);
  182. ValidateInPtr_NULL_OK<IGuideDataProvider>(pprovider);
  183. ValidateOutPtr<IGuideDataProviders>(ppdataproviders, NULL);
  184. return _get_ItemsByKey(pproptype, pprovider, idLang, vt, ppdataproviders);
  185. }
  186. LEAVE_API
  187. }
  188. STDMETHOD(get_ItemWithKey)(VARIANT varKey, /*[out, retval]*/ IGuideDataProvider * *ppdataprovider)
  189. {
  190. ENTER_API
  191. {
  192. ValidateOutPtr<IGuideDataProvider>(ppdataprovider, NULL);
  193. return _get_ItemWithKey(varKey, ppdataprovider);
  194. }
  195. LEAVE_API
  196. }
  197. STDMETHOD(get_Item)(VARIANT varIndex, /*[out, retval]*/ IGuideDataProvider * *ppdataprovider)
  198. {
  199. ENTER_API
  200. {
  201. ValidateOutPtr<IGuideDataProvider>(ppdataprovider, NULL);
  202. return _get_Item(varIndex, ppdataprovider);
  203. }
  204. LEAVE_API
  205. }
  206. STDMETHOD(get_Count)(/*[out, retval]*/ long *plCount)
  207. {
  208. ENTER_API
  209. {
  210. ValidateOut<long>(plCount, 0);
  211. return _get_Count(plCount);
  212. }
  213. LEAVE_API
  214. }
  215. #ifdef IMPLEMENT_NewEnum
  216. STDMETHOD(get__NewEnum)(IUnknown **ppunk)
  217. {
  218. ENTER_API
  219. {
  220. ValidateOutPtr<IUnknown>(ppunk, NULL);
  221. return _get__NewEnum(ppunk);
  222. }
  223. LEAVE_API
  224. }
  225. #endif
  226. STDMETHOD(Resync)()
  227. {
  228. ENTER_API
  229. {
  230. return _Resync();
  231. }
  232. LEAVE_API
  233. }
  234. public:
  235. };
  236. #endif //__GUIDEDATAPROVIDER_H_