WifiPlaylist.cpp 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. #include "WifiPlaylist.h"
  2. #include "api.h"
  3. #include "nu/AutoWide.h"
  4. /* ---- WifiTrack ---- */
  5. WifiTrack::WifiTrack()
  6. {
  7. last_updated=0;
  8. id=0;
  9. artist=0;
  10. album=0;
  11. composer=0;
  12. duration=0;
  13. track=0;
  14. year=0;
  15. size=0;
  16. title=0;
  17. mime_type=0;
  18. }
  19. WifiTrack::WifiTrack(const char *id, const itemRecordW *record, const wchar_t *filename)
  20. {
  21. this->id=AutoWideDup(id);
  22. artist=_wcsdup(record->artist);
  23. album=_wcsdup(record->album);
  24. composer=_wcsdup(record->composer);
  25. duration=record->length;
  26. track=record->track;
  27. year=record->year;
  28. size=record->filesize;
  29. title=_wcsdup(record->title);
  30. wchar_t mime[128] = {0};
  31. if (AGAVE_API_METADATA->GetExtendedFileInfo(filename, L"mime", mime, 128) && mime[0])
  32. {
  33. mime_type=_wcsdup(mime);
  34. }
  35. else
  36. {
  37. mime_type=0;
  38. }
  39. last_updated=record->lastupd;
  40. }
  41. WifiTrack::WifiTrack(const WifiTrack &copy)
  42. {
  43. id=_wcsdup(copy.id);
  44. artist=_wcsdup(copy.artist);
  45. album=_wcsdup(copy.album);
  46. composer=_wcsdup(copy.composer);
  47. duration=copy.duration;
  48. track=copy.track;
  49. year=copy.year;
  50. size=copy.size;
  51. title=_wcsdup(copy.title);
  52. mime_type=_wcsdup(copy.mime_type);
  53. last_updated=copy.last_updated;
  54. }
  55. WifiTrack::~WifiTrack()
  56. {
  57. free(id);
  58. free(artist);
  59. free(album);
  60. free(composer);
  61. free(title);
  62. free(mime_type);
  63. }
  64. /* ---- WifiPlaylist ---- */
  65. WifiPlaylist::WifiPlaylist()
  66. {
  67. id=0;
  68. name=0;
  69. }
  70. WifiPlaylist::WifiPlaylist(const char *id, const wchar_t *name)
  71. {
  72. this->id = AutoWideDup(id);
  73. this->name = _wcsdup(name);
  74. }
  75. WifiPlaylist::~WifiPlaylist()
  76. {
  77. free(id);
  78. free(name);
  79. //tracks.deleteAll();
  80. for (auto obj : tracks)
  81. {
  82. delete obj;
  83. }
  84. tracks.clear();
  85. }
  86. void WifiPlaylist::SetName(const wchar_t *new_name)
  87. {
  88. if (name != new_name)
  89. {
  90. free(name);
  91. name = _wcsdup(new_name);
  92. }
  93. }