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.

248 lines
6.3 KiB

  1. #ifndef __STDPROP_H_
  2. #define __STDPROP_H_
  3. IMetaProperty *GetMetaProperty(IUnknown *pobj, IMetaPropertyType *pproptype, long lang = 0);
  4. HRESULT GetMetaPropertyValue(IUnknown *pobj, IMetaPropertyType *pproptype,
  5. VARIANT *pvarValue);
  6. HRESULT PutMetaPropertyValue(IUnknown *pobj, IMetaPropertyType *pproptype,
  7. VARIANT varValue);
  8. class CGuideDB;
  9. class CStdPropSet
  10. {
  11. public:
  12. CStdPropSet(const char *szName)
  13. {
  14. m_bstrName = szName;
  15. m_ppropset = NULL;
  16. }
  17. virtual HRESULT GetDB(CGuideDB **ppdb) = 0;
  18. IMetaPropertyType *GetMetaPropertyType(long id, const char *szName);
  19. void Init(IMetaPropertySets *ppropsets)
  20. {
  21. m_ppropsets = ppropsets;
  22. }
  23. IMetaProperty *GetMetaProperty(IUnknown *pobj, IMetaPropertyType *pproptype, long lang = 0);
  24. HRESULT GetMetaPropertyValue(IUnknown *pobj, IMetaPropertyType *pproptype,
  25. VARIANT *pvarValue);
  26. HRESULT PutMetaPropertyValue(IUnknown *pobj, IMetaPropertyType *pproptype,
  27. VARIANT varValue);
  28. protected:
  29. CComPtr<IMetaPropertySet> m_ppropset;
  30. CComPtr<IMetaPropertySets> m_ppropsets;
  31. _bstr_t m_bstrName;
  32. };
  33. #define BEGIN_PROPERTYSET_(n, s) \
  34. class n ## PropSet : public CStdPropSet \
  35. { \
  36. public: \
  37. n ## PropSet() : CStdPropSet(s) \
  38. { \
  39. }
  40. #define BEGIN_PROPERTYSET(n) BEGIN_PROPERTYSET_(n, #n)
  41. #define PROPSET_ENTRY_(id, n, s) \
  42. CComPtr<IMetaPropertyType> m_p##n; \
  43. IMetaPropertyType * n##MetaPropertyType() \
  44. { \
  45. if (m_p##n == NULL) \
  46. m_p##n = GetMetaPropertyType(id, s); \
  47. return m_p##n; \
  48. } \
  49. template <class T> \
  50. HRESULT _get_##n(T *pT, VARIANT *pvarValue) \
  51. { \
  52. CComQIPtr<IMetaPropertyType> pproptype = n##MetaPropertyType(); \
  53. if (pproptype == NULL) \
  54. return E_FAIL; \
  55. return GetMetaPropertyValue(pT, pproptype, pvarValue); \
  56. } \
  57. template <class T> \
  58. HRESULT _get_##n(T *pT, BSTR *pbstr) \
  59. { \
  60. HRESULT hr; \
  61. _variant_t varValue; \
  62. CComQIPtr<IMetaPropertyType> pproptype = n##MetaPropertyType(); \
  63. if (pproptype == NULL) \
  64. return E_FAIL; \
  65. hr = GetMetaPropertyValue(pT, pproptype, &varValue); \
  66. if (FAILED(hr)) \
  67. return hr; \
  68. *pbstr = _bstr_t(varValue).copy(); \
  69. return S_OK; \
  70. } \
  71. template <class T> \
  72. HRESULT _get_##n(T *pT, DATE *pdate) \
  73. { \
  74. HRESULT hr; \
  75. _variant_t varValue; \
  76. hr = GetMetaPropertyValue(pT, n##MetaPropertyType(), &varValue); \
  77. if (FAILED(hr)) \
  78. return hr; \
  79. try \
  80. { \
  81. varValue.ChangeType(VT_DATE); \
  82. } \
  83. catch (_com_error & e) \
  84. { \
  85. return e.Error(); \
  86. } \
  87. *pdate = varValue.date; \
  88. return S_OK; \
  89. } \
  90. HRESULT _get_##n(IUnknown *punk, VARIANT *pvarValue) \
  91. { \
  92. return GetMetaPropertyValue(punk, n##MetaPropertyType(), pvarValue); \
  93. } \
  94. template <class T> \
  95. HRESULT _put_##n(T *pT, VARIANT varValue) \
  96. { \
  97. return PutMetaPropertyValue(pT, n##MetaPropertyType(), varValue); \
  98. } \
  99. template <class T> \
  100. HRESULT _put_##n(T *pT, BSTR bstr) \
  101. { \
  102. _variant_t varValue(bstr); \
  103. return PutMetaPropertyValue(pT, n##MetaPropertyType(), varValue); \
  104. } \
  105. template <class T> \
  106. HRESULT _put_##n(T *pT, DATE date) \
  107. { \
  108. _variant_t varValue(date); \
  109. return PutMetaPropertyValue(pT, n##MetaPropertyType(), varValue); \
  110. } \
  111. HRESULT _put_##n(IUnknown *punk, VARIANT varValue) \
  112. { \
  113. return PutMetaPropertyValue(punk, n##MetaPropertyType(), varValue); \
  114. } \
  115. #define PROPSET_ENTRY(id, n) PROPSET_ENTRY_(id, n, #n)
  116. #define END_PROPERTYSET(n) \
  117. }; \
  118. BEGIN_PROPERTYSET(Description)
  119. PROPSET_ENTRY(0, ID)
  120. PROPSET_ENTRY(1, Name)
  121. PROPSET_ENTRY(2, Title)
  122. PROPSET_ENTRY(3, Subtitle)
  123. PROPSET_ENTRY_(4, OneSentence, "One Sentence")
  124. PROPSET_ENTRY_(5, OneParagraph, "One Paragraph")
  125. PROPSET_ENTRY(6, Version)
  126. END_PROPERTYSET(Description)
  127. BEGIN_PROPERTYSET(Time)
  128. PROPSET_ENTRY(1, Start)
  129. PROPSET_ENTRY(2, End)
  130. END_PROPERTYSET(Time)
  131. BEGIN_PROPERTYSET(Copyright)
  132. PROPSET_ENTRY(1, Text)
  133. PROPSET_ENTRY(2, Date)
  134. END_PROPERTYSET(Copyright)
  135. BEGIN_PROPERTYSET(Service)
  136. PROPSET_ENTRY(1, TuneRequest)
  137. END_PROPERTYSET(Service)
  138. BEGIN_PROPERTYSET(ScheduleEntry)
  139. PROPSET_ENTRY(1, Service)
  140. PROPSET_ENTRY(2, Program)
  141. END_PROPERTYSET(Service)
  142. BEGIN_PROPERTYSET(Channels)
  143. PROPSET_ENTRY(1, Channel)
  144. END_PROPERTYSET(Channels)
  145. BEGIN_PROPERTYSET(Channel)
  146. PROPSET_ENTRY(1, Service)
  147. END_PROPERTYSET(Channel)
  148. BEGIN_PROPERTYSET(Ratings)
  149. PROPSET_ENTRY(1, MinimumAge)
  150. PROPSET_ENTRY(2, Sex)
  151. PROPSET_ENTRY(3, Violence)
  152. PROPSET_ENTRY(4, Language)
  153. END_PROPERTYSET(Ratings)
  154. BEGIN_PROPERTYSET_(MPAARatings, "MPAA Ratings")
  155. PROPSET_ENTRY(1, Rating)
  156. END_PROPERTYSET(MPAARatings)
  157. BEGIN_PROPERTYSET(Categories)
  158. PROPSET_ENTRY( 0x00, Reserved_00)
  159. PROPSET_ENTRY( 0x01, Movie)
  160. PROPSET_ENTRY( 0x02, Sports)
  161. PROPSET_ENTRY( 0x03, Special)
  162. PROPSET_ENTRY( 0x04, Series)
  163. PROPSET_ENTRY( 0x05, News)
  164. PROPSET_ENTRY( 0x06, Shopping)
  165. PROPSET_ENTRY( 0x07, Reserved_07)
  166. PROPSET_ENTRY( 0x08, Reserved_08)
  167. PROPSET_ENTRY( 0x09, Reserved_09)
  168. PROPSET_ENTRY( 0x0A, Reserved_0A)
  169. PROPSET_ENTRY( 0x0B, Reserved_0B)
  170. PROPSET_ENTRY( 0x0C, Reserved_0C)
  171. PROPSET_ENTRY( 0x0D, Reserved_0D)
  172. PROPSET_ENTRY( 0x0E, Reserved_0E)
  173. PROPSET_ENTRY( 0x0F, Reserved_0F)
  174. PROPSET_ENTRY( 0x10, Action)
  175. PROPSET_ENTRY( 0x11, Adventure)
  176. PROPSET_ENTRY( 0x12, Children)
  177. PROPSET_ENTRY( 0x13, Comedy)
  178. PROPSET_ENTRY( 0x14, Drama)
  179. PROPSET_ENTRY( 0x15, Fantasy)
  180. PROPSET_ENTRY( 0x16, Horror)
  181. PROPSET_ENTRY( 0x17, Musical)
  182. PROPSET_ENTRY( 0x18, Romance)
  183. PROPSET_ENTRY_(0x19, SciFi, "Sci-Fi")
  184. PROPSET_ENTRY( 0x1A, Western)
  185. PROPSET_ENTRY( 0x20, Baseball)
  186. PROPSET_ENTRY( 0x21, Basketball)
  187. PROPSET_ENTRY( 0x22, Boxing)
  188. PROPSET_ENTRY( 0x23, Football)
  189. PROPSET_ENTRY( 0x24, Golf)
  190. PROPSET_ENTRY( 0x25, Hockey)
  191. PROPSET_ENTRY( 0x26, Racing)
  192. PROPSET_ENTRY( 0x27, Skiing)
  193. PROPSET_ENTRY( 0x28, Soccer)
  194. PROPSET_ENTRY( 0x29, Tennis)
  195. PROPSET_ENTRY( 0x2A, Wrestling)
  196. PROPSET_ENTRY_(0x32, CulturalArts, "Cultural Arts")
  197. PROPSET_ENTRY( 0x34, Educational)
  198. PROPSET_ENTRY_(0x35, GeneralInterest, "General Interest")
  199. PROPSET_ENTRY_(0x36, HowTo, "How-to")
  200. PROPSET_ENTRY( 0x37, Mature)
  201. PROPSET_ENTRY( 0x38, Music)
  202. PROPSET_ENTRY( 0x39, Religious)
  203. PROPSET_ENTRY_(0x3A, SoapOpera, "Soap Opera")
  204. PROPSET_ENTRY( 0x3B, Talk)
  205. PROPSET_ENTRY( 0x50, Business)
  206. PROPSET_ENTRY( 0x51, Current)
  207. PROPSET_ENTRY( 0x53, Weather)
  208. PROPSET_ENTRY_(0x60, HomeShopping, "Home Shopping")
  209. PROPSET_ENTRY_(0x61, ProductInfo, "Product Information")
  210. END_PROPERTYSET(Categories)
  211. BEGIN_PROPERTYSET(Provider)
  212. PROPSET_ENTRY(1, Name)
  213. PROPSET_ENTRY(2, NetworkName)
  214. PROPSET_ENTRY(3, Description)
  215. END_PROPERTYSET(Provider)
  216. #endif //__STDPROP_H_