1
0

XSPFHandler.cpp 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #include "XSPFHandler.h"
  2. #include "XSPFLoader.h"
  3. #include "api__xspf.h"
  4. #include "resource.h"
  5. const wchar_t *XSPFHandler::EnumerateExtensions(size_t n)
  6. {
  7. switch(n)
  8. {
  9. case 0:
  10. return L"xspf";
  11. default:
  12. return 0;
  13. }
  14. }
  15. const char *XSPFHandler::EnumerateMIMETypes(size_t n)
  16. {
  17. switch(n)
  18. {
  19. case 0:
  20. return "application/xspf+xml";
  21. default:
  22. return 0;
  23. }
  24. }
  25. const wchar_t *XSPFHandler::GetName()
  26. {
  27. static wchar_t xspfpl[64];
  28. // no point re-loading this all of the time since it won't change once we've been loaded
  29. return (!xspfpl[0]?WASABI_API_LNGSTRINGW_BUF(IDS_XSPF_PLAYLIST,xspfpl,64):xspfpl);
  30. }
  31. // returns SUCCESS and FAILED, so be careful ...
  32. int XSPFHandler::SupportedFilename(const wchar_t *filename)
  33. {
  34. size_t filenameLength = wcslen(filename);
  35. size_t extensionLength = wcslen(L".xspf");
  36. if (filenameLength < extensionLength) return SVC_PLAYLISTHANDLER_FAILED; // too short
  37. if (!_wcsicmp(filename + filenameLength - extensionLength, L".xspf"))
  38. return SVC_PLAYLISTHANDLER_SUCCESS;
  39. else
  40. return SVC_PLAYLISTHANDLER_FAILED;
  41. }
  42. int XSPFHandler::SupportedMIMEType(const char *type)
  43. {
  44. if (!strcmp(type, "application/xspf+xml"))
  45. return SVC_PLAYLISTHANDLER_SUCCESS;
  46. else
  47. return SVC_PLAYLISTHANDLER_FAILED;
  48. }
  49. ifc_playlistloader *XSPFHandler::CreateLoader(const wchar_t *filename)
  50. {
  51. return new XSPFLoader;
  52. }
  53. void XSPFHandler::ReleaseLoader(ifc_playlistloader *loader)
  54. {
  55. delete static_cast<XSPFLoader *>(loader);
  56. }
  57. // Define the dispatch table
  58. #define CBCLASS XSPFHandler
  59. START_DISPATCH;
  60. CB(SVC_PLAYLISTHANDLER_ENUMEXTENSIONS, EnumerateExtensions)
  61. CB(SVC_PLAYLISTHANDLER_ENUMMIMETYPES, EnumerateMIMETypes)
  62. CB(SVC_PLAYLISTHANDLER_SUPPORTFILENAME, SupportedFilename)
  63. CB(SVC_PLAYLISTHANDLER_CREATELOADER, CreateLoader)
  64. VCB(SVC_PLAYLISTHANDLER_RELEASELOADER, ReleaseLoader)
  65. CB(SVC_PLAYLISTHANDLER_GETNAME, GetName)
  66. END_DISPATCH;