svc_albumArtProvider.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #ifndef NULLSOFT_AGAVE_SVC_ALBUMARTPROVIDER_H
  2. #define NULLSOFT_AGAVE_SVC_ALBUMARTPROVIDER_H
  3. #include "../../bfc/dispatch.h"
  4. #include "../../bfc/std_mkncc.h" // for MKnCC()
  5. enum
  6. {
  7. ALBUMARTPROVIDER_SUCCESS = 0,
  8. ALBUMARTPROVIDER_FAILURE = 1,
  9. ALBUMARTPROVIDER_READONLY = 2,
  10. ALBUMARTPROVIDER_TYPE_EMBEDDED = 0, // contained within another file (e.g. inside id3v2 tag)
  11. ALBUMARTPROVIDER_TYPE_DATABASE = 1, // cached in a database somewhere (e.g. ipod artwork DB)
  12. ALBUMARTPROVIDER_TYPE_FOLDER = 2, // sitting on a folder somewhere (e.g. folder.jpg)
  13. };
  14. class svc_albumArtProvider : public Dispatchable
  15. {
  16. protected:
  17. svc_albumArtProvider() {}
  18. ~svc_albumArtProvider() {}
  19. public:
  20. static FOURCC getServiceType() { return svc_albumArtProvider::SERVICETYPE; }
  21. bool IsMine(const wchar_t *filename);
  22. int ProviderType();
  23. // implementation note: use WASABI_API_MEMMGR to alloc bits and mimetype, so that the recipient can free through that
  24. int GetAlbumArtData(const wchar_t *filename, const wchar_t *type, void **bits, size_t *len, wchar_t **mimeType);
  25. int SetAlbumArtData(const wchar_t *filename, const wchar_t *type, void *bits, size_t len, const wchar_t *mimeType);
  26. int DeleteAlbumArt(const wchar_t *filename, const wchar_t *type);
  27. DISPATCH_CODES
  28. {
  29. SVC_ALBUMARTPROVIDER_PROVIDERTYPE = 0,
  30. SVC_ALBUMARTPROVIDER_GETALBUMARTDATA = 10,
  31. SVC_ALBUMARTPROVIDER_ISMINE = 20,
  32. SVC_ALBUMARTPROVIDER_SETALBUMARTDATA = 30,
  33. SVC_ALBUMARTPROVIDER_DELETEALBUMART = 40,
  34. };
  35. enum
  36. {
  37. SERVICETYPE = MK3CC('a','a','p')
  38. };
  39. };
  40. inline bool svc_albumArtProvider::IsMine(const wchar_t *filename)
  41. {
  42. return _call(SVC_ALBUMARTPROVIDER_ISMINE, false, filename);
  43. }
  44. inline int svc_albumArtProvider::ProviderType()
  45. {
  46. return _call(SVC_ALBUMARTPROVIDER_PROVIDERTYPE, (int)ALBUMARTPROVIDER_TYPE_EMBEDDED);
  47. }
  48. inline int svc_albumArtProvider::GetAlbumArtData(const wchar_t *filename, const wchar_t *type, void **bits, size_t *len, wchar_t **mimeType)
  49. {
  50. return _call(SVC_ALBUMARTPROVIDER_GETALBUMARTDATA, (int)ALBUMARTPROVIDER_FAILURE, filename, type, bits, len, mimeType);
  51. }
  52. inline int svc_albumArtProvider::SetAlbumArtData(const wchar_t *filename, const wchar_t *type, void *bits, size_t len, const wchar_t *mimeType)
  53. {
  54. return _call(SVC_ALBUMARTPROVIDER_SETALBUMARTDATA, (int)ALBUMARTPROVIDER_FAILURE, filename, type, bits, len, mimeType);
  55. }
  56. inline int svc_albumArtProvider::DeleteAlbumArt(const wchar_t *filename, const wchar_t *type)
  57. {
  58. return _call(SVC_ALBUMARTPROVIDER_DELETEALBUMART, (int)ALBUMARTPROVIDER_FAILURE, filename, type);
  59. }
  60. #endif