1
0

uvox_3901.cpp 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #include "uvox_3901.h"
  2. #include "api__in_mp3.h"
  3. #include "api/service/waservicefactory.h"
  4. #include <strsafe.h>
  5. #include "in2.h"
  6. extern In_Module mod;
  7. #include "FactoryHelper.h"
  8. Ultravox3901::Ultravox3901() : parser(0)
  9. {
  10. title[0]=album[0]=artist[0]=album_art_url[0]=0;
  11. ServiceBuild(parser, obj_xmlGUID);
  12. if (parser)
  13. {
  14. parser->xmlreader_registerCallback(L"metadata\fsong\f*", this);
  15. parser->xmlreader_open();
  16. }
  17. }
  18. Ultravox3901::~Ultravox3901()
  19. {
  20. ServiceRelease(parser, obj_xmlGUID);
  21. }
  22. int Ultravox3901::Parse(const char *xml_data)
  23. {
  24. if (parser)
  25. {
  26. int ret = parser->xmlreader_feed((void *)xml_data, strlen(xml_data));
  27. if (ret != API_XML_SUCCESS)
  28. return ret;
  29. return parser->xmlreader_feed(0, 0);
  30. }
  31. return API_XML_FAILURE;
  32. }
  33. void Ultravox3901::TextHandler(const wchar_t *xmlpath, const wchar_t *xmltag, const wchar_t *str)
  34. {
  35. if (!_wcsicmp(xmltag, L"name"))
  36. {
  37. StringCbCatW(title, sizeof(title), str);
  38. }
  39. else if (!_wcsicmp(xmltag, L"album"))
  40. {
  41. StringCbCatW(album, sizeof(album), str);
  42. }
  43. else if (!_wcsicmp(xmltag, L"artist"))
  44. {
  45. StringCbCatW(artist, sizeof(artist), str);
  46. }
  47. else if (!_wcsicmp(xmltag, L"album_art"))
  48. {
  49. StringCbCatW(album_art_url, sizeof(album_art_url), str);
  50. }
  51. }
  52. int Ultravox3901::GetExtendedData(const char *tag, wchar_t *data, int dataLen)
  53. {
  54. if (!_stricmp(tag, "uvox/title"))
  55. StringCchCopy(data, dataLen, title);
  56. else if (!_stricmp(tag, "uvox/album"))
  57. StringCchCopy(data, dataLen, album);
  58. else if (!_stricmp(tag, "uvox/artist"))
  59. StringCchCopy(data, dataLen, artist);
  60. else if (!_stricmp(tag, "uvox/albumart"))
  61. StringCchCopy(data, dataLen, album_art_url);
  62. else
  63. return 0;
  64. return 1;
  65. }
  66. #define CBCLASS Ultravox3901
  67. START_DISPATCH;
  68. VCB(ONCHARDATA, TextHandler)
  69. END_DISPATCH;
  70. #undef CBCLASS