JSAPI2_PodcastsAPI.cpp 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. #include "JSAPI2_PodcastsAPI.h"
  2. #include "../Winamp/JSAPI.h"
  3. #include "api__ml_wire.h"
  4. #include "./rssCOM.h"
  5. JSAPI2::PodcastsAPI::PodcastsAPI( const wchar_t *_key, JSAPI::ifc_info *_info )
  6. {
  7. info = _info;
  8. key = _key;
  9. }
  10. enum
  11. {
  12. DISP_PODCASTS_SUBSCRIBE,
  13. };
  14. #define DISP_TABLE \
  15. CHECK_ID(Subscribe, DISP_PODCASTS_SUBSCRIBE)\
  16. #define CHECK_ID(str, id) if (wcscmp(rgszNames[i], L## #str) == 0) { rgdispid[i] = id; continue; }
  17. HRESULT JSAPI2::PodcastsAPI::GetIDsOfNames(REFIID riid, OLECHAR FAR* FAR* rgszNames, unsigned int cNames, LCID lcid, DISPID FAR* rgdispid)
  18. {
  19. bool unknowns = false;
  20. for (unsigned int i = 0;i != cNames;i++)
  21. {
  22. DISP_TABLE
  23. rgdispid[i] = DISPID_UNKNOWN;
  24. unknowns = true;
  25. }
  26. if (unknowns)
  27. return DISP_E_UNKNOWNNAME;
  28. else
  29. return S_OK;
  30. }
  31. HRESULT JSAPI2::PodcastsAPI::GetTypeInfo(unsigned int itinfo, LCID lcid, ITypeInfo FAR* FAR* pptinfo)
  32. {
  33. return E_NOTIMPL;
  34. }
  35. HRESULT JSAPI2::PodcastsAPI::GetTypeInfoCount(unsigned int FAR * pctinfo)
  36. {
  37. return E_NOTIMPL;
  38. }
  39. HRESULT JSAPI2::PodcastsAPI::Subscribe(WORD wFlags, DISPPARAMS FAR *pdispparams, VARIANT FAR *pvarResult, unsigned int FAR *puArgErr)
  40. {
  41. JSAPI_VERIFY_METHOD(wFlags);
  42. JSAPI_VERIFY_PARAMCOUNT(pdispparams, 1);
  43. if (AGAVE_API_JSAPI2_SECURITY->GetActionAuthorization(L"podcasts", L"subscribe", key, info, JSAPI2::api_security::ACTION_PROMPT) == JSAPI2::api_security::ACTION_ALLOWED)
  44. {
  45. RssCOM::SubscribeUrl(JSAPI_PARAM(pdispparams, 1).bstrVal, pvarResult);
  46. }
  47. else
  48. {
  49. JSAPI_INIT_RESULT(pvarResult, VT_BOOL);
  50. JSAPI_SET_RESULT(pvarResult, boolVal, VARIANT_FALSE);
  51. }
  52. return S_OK;
  53. }
  54. #undef CHECK_ID
  55. #define CHECK_ID(str, id) case id: return str(wFlags, pdispparams, pvarResult, puArgErr);
  56. HRESULT JSAPI2::PodcastsAPI::Invoke(DISPID dispid, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS FAR *pdispparams, VARIANT FAR *pvarResult, EXCEPINFO FAR * pexecinfo, unsigned int FAR *puArgErr)
  57. {
  58. switch (dispid)
  59. {
  60. DISP_TABLE
  61. }
  62. return DISP_E_MEMBERNOTFOUND;
  63. }
  64. STDMETHODIMP JSAPI2::PodcastsAPI::QueryInterface(REFIID riid, PVOID *ppvObject)
  65. {
  66. if (!ppvObject)
  67. return E_POINTER;
  68. else if (IsEqualIID(riid, IID_IDispatch))
  69. *ppvObject = (IDispatch *)this;
  70. else if (IsEqualIID(riid, IID_IUnknown))
  71. *ppvObject = this;
  72. else
  73. {
  74. *ppvObject = NULL;
  75. return E_NOINTERFACE;
  76. }
  77. AddRef();
  78. return S_OK;
  79. }
  80. ULONG JSAPI2::PodcastsAPI::AddRef(void)
  81. {
  82. return _refCount.fetch_add( 1 );
  83. }
  84. ULONG JSAPI2::PodcastsAPI::Release( void )
  85. {
  86. LONG lRef = _refCount.fetch_sub( 1 );
  87. if ( lRef == 0 )
  88. delete this;
  89. return lRef;
  90. }