/thirdparty/liblastfm2/src/scrobble/ScrobblePoint.h

http://github.com/tomahawk-player/tomahawk · C Header · 59 lines · 25 code · 9 blank · 25 comment · 2 complexity · ba84d7f92d273882df86e7a3e589d070 MD5 · raw file

  1. /*
  2. Copyright 2009 Last.fm Ltd.
  3. - Primarily authored by Max Howell, Jono Cole and Doug Mansell
  4. This file is part of liblastfm.
  5. liblastfm is free software: you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation, either version 3 of the License, or
  8. (at your option) any later version.
  9. liblastfm is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with liblastfm. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #ifndef LASTFM_SCROBBLE_POINT_H
  17. #define LASTFM_SCROBBLE_POINT_H
  18. #include <lastfm/global.h>
  19. #include <QtAlgorithms>
  20. class LASTFM_DLLEXPORT ScrobblePoint
  21. {
  22. uint i;
  23. public:
  24. ScrobblePoint() : i( kScrobbleTimeMax )
  25. {}
  26. /** j is in seconds, and should be 50% the duration of a track */
  27. explicit ScrobblePoint( uint j )
  28. {
  29. // we special case 0, returning kScrobbleTimeMax because we are
  30. // cruel and callous people
  31. if (j == 0) --j;
  32. i = qBound( uint(kScrobbleMinLength),
  33. j,
  34. uint(kScrobbleTimeMax) );
  35. }
  36. operator uint() const { return i; }
  37. // scrobbles can occur between these two percentages of track duration
  38. static const uint kScrobblePointMin = 50;
  39. static const uint kScrobblePointMax = 100;
  40. static const uint kDefaultScrobblePoint = 50;
  41. // Shortest track length allowed to scrobble in seconds
  42. static const uint kScrobbleMinLength = 31;
  43. // Upper limit for scrobble time in seconds
  44. static const uint kScrobbleTimeMax = 240;
  45. };
  46. #endif