PageRenderTime 49ms CodeModel.GetById 14ms RepoModel.GetById 1ms app.codeStats 0ms

/libtunepimp-0.5.3/lib/track.cpp

#
C++ | 99 lines | 61 code | 12 blank | 26 comment | 12 complexity | 72d0fa48373ce1640dc7a1de17c80c43 MD5 | raw file
Possible License(s): LGPL-2.1, LGPL-3.0, GPL-2.0, LGPL-2.0
  1. /*----------------------------------------------------------------------------
  2. libtunepimp -- The MusicBrainz tagging library.
  3. Let a thousand taggers bloom!
  4. Copyright (C) Robert Kaye 2003
  5. This file is part of libtunepimp.
  6. libtunepimp is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 2 of the License, or
  9. (at your option) any later version.
  10. libtunepimp is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with libtunepimp; if not, write to the Free Software
  16. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  17. $Id: track.cpp 7216 2006-04-14 23:10:49Z robert $
  18. ----------------------------------------------------------------------------*/
  19. #include "../config.h"
  20. #include "track.h"
  21. #include "tunepimp.h"
  22. #include "write.h"
  23. void Track::setStatus(const TPFileStatus status)
  24. {
  25. this->status = status;
  26. context->getTunePimp()->trackChangedStatus(this);
  27. }
  28. void Track::setLocalMetadata(const Metadata &data)
  29. {
  30. MetadataCompare comp;
  31. local = data;
  32. sim = comp.compare(server, local);
  33. changed = !(server == local);
  34. if (!changed && (context->getRenameFiles() || context->getMoveFiles()))
  35. {
  36. FileNameMaker maker(context);
  37. string newName;
  38. newName = fileName;
  39. maker.makeNewFileName(local, newName, 0);
  40. #ifdef WIN32
  41. if (stricmp(newName.c_str(), fileName.c_str()))
  42. #else
  43. if (strcmp(newName.c_str(), fileName.c_str()))
  44. #endif
  45. changed = true;
  46. }
  47. }
  48. void Track::setServerMetadata(const Metadata &data)
  49. {
  50. MetadataCompare comp;
  51. server = data;
  52. sim = comp.compare(server, local);
  53. changed = !(server == local);
  54. if (!changed && (context->getRenameFiles() || context->getMoveFiles()))
  55. {
  56. FileNameMaker maker(context);
  57. string newName;
  58. newName = fileName;
  59. maker.makeNewFileName(server, newName, 0);
  60. #ifdef WIN32
  61. if (stricmp(newName.c_str(), fileName.c_str()))
  62. #else
  63. if (strcmp(newName.c_str(), fileName.c_str()))
  64. #endif
  65. changed = true;
  66. }
  67. }
  68. void Track::setPUID(const string &puid)
  69. {
  70. this->puid = puid;
  71. }
  72. void Track::lock(void)
  73. {
  74. mutex.acquire();
  75. }
  76. void Track::unlock(void)
  77. {
  78. mutex.release();
  79. }