1
0

MediaLibraryCOM.cpp 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. #include "main.h"
  2. #include "MediaLibraryCOM.h"
  3. #include "OnlineMediaCOM.h"
  4. extern "C" extern winampGeneralPurposePlugin plugin;
  5. extern prefsDlgRecW myPrefsItem;
  6. OnlineMediaCOM onlineMediaCOM;
  7. enum
  8. {
  9. DISP_ONLINEMEDIA = 312,
  10. DISP_PREFERENCES,
  11. DISP_HIDDEN,
  12. };
  13. #define CHECK_ID(str, id) if (wcscmp(rgszNames[i], L##str) == 0) { rgdispid[i] = id; continue; }
  14. HRESULT MediaLibraryCOM::GetIDsOfNames(REFIID riid, OLECHAR FAR* FAR* rgszNames, unsigned int cNames, LCID lcid, DISPID FAR* rgdispid)
  15. {
  16. bool unknowns = false;
  17. for (unsigned int i = 0;i != cNames;i++)
  18. {
  19. CHECK_ID("OnlineMedia", DISP_ONLINEMEDIA)
  20. CHECK_ID("ShowPreferences", DISP_PREFERENCES);
  21. CHECK_ID("hidden", DISP_HIDDEN);
  22. rgdispid[i] = DISPID_UNKNOWN;
  23. unknowns = true;
  24. }
  25. if (unknowns)
  26. return DISP_E_UNKNOWNNAME;
  27. else
  28. return S_OK;
  29. }
  30. HRESULT MediaLibraryCOM::GetTypeInfo(unsigned int itinfo, LCID lcid, ITypeInfo FAR* FAR* pptinfo)
  31. {
  32. return E_NOTIMPL;
  33. }
  34. HRESULT MediaLibraryCOM::GetTypeInfoCount(unsigned int FAR * pctinfo)
  35. {
  36. return E_NOTIMPL;
  37. }
  38. HRESULT MediaLibraryCOM::Invoke(DISPID dispid, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS FAR *pdispparams, VARIANT FAR *pvarResult, EXCEPINFO FAR * pexecinfo, unsigned int FAR *puArgErr)
  39. {
  40. switch (dispid)
  41. {
  42. case DISP_HIDDEN:
  43. VariantInit(pvarResult);
  44. V_VT(pvarResult) = VT_BOOL;
  45. V_BOOL(pvarResult) = !IsVisible();
  46. return S_OK;
  47. case DISP_ONLINEMEDIA:
  48. VariantInit(pvarResult);
  49. V_VT(pvarResult) = VT_DISPATCH;
  50. V_DISPATCH(pvarResult) = &onlineMediaCOM;
  51. return S_OK;
  52. case DISP_PREFERENCES:
  53. SendMessage(plugin.hwndParent, WM_WA_IPC, (WPARAM)&myPrefsItem, IPC_OPENPREFSTOPAGE);
  54. return S_OK;
  55. }
  56. return DISP_E_MEMBERNOTFOUND;
  57. }
  58. STDMETHODIMP MediaLibraryCOM::QueryInterface(REFIID riid, PVOID *ppvObject)
  59. {
  60. if (!ppvObject)
  61. return E_POINTER;
  62. else if (IsEqualIID(riid, IID_IDispatch))
  63. *ppvObject = (IDispatch *)this;
  64. else if (IsEqualIID(riid, IID_IUnknown))
  65. *ppvObject = this;
  66. else
  67. {
  68. *ppvObject = NULL;
  69. return E_NOINTERFACE;
  70. }
  71. AddRef();
  72. return S_OK;
  73. }
  74. ULONG MediaLibraryCOM::AddRef(void)
  75. {
  76. return 0;
  77. }
  78. ULONG MediaLibraryCOM::Release(void)
  79. {
  80. return 0;
  81. }