PageRenderTime 83ms CodeModel.GetById 40ms app.highlight 11ms RepoModel.GetById 30ms app.codeStats 0ms

/thirdparty/liblastfm2/src/radio/RadioStation.h

http://github.com/tomahawk-player/tomahawk
C++ Header | 123 lines | 71 code | 24 blank | 28 comment | 0 complexity | 09a04b3b4e08b7b4a8d306b7a508f925 MD5 | raw file
  1/*
  2   Copyright 2009 Last.fm Ltd. 
  3      - Primarily authored by Max Howell, Jono Cole and Doug Mansell
  4
  5   This file is part of liblastfm.
  6
  7   liblastfm is free software: you can redistribute it and/or modify
  8   it under the terms of the GNU General Public License as published by
  9   the Free Software Foundation, either version 3 of the License, or
 10   (at your option) any later version.
 11
 12   liblastfm is distributed in the hope that it will be useful,
 13   but WITHOUT ANY WARRANTY; without even the implied warranty of
 14   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 15   GNU General Public License for more details.
 16
 17   You should have received a copy of the GNU General Public License
 18   along with liblastfm.  If not, see <http://www.gnu.org/licenses/>.
 19*/
 20#ifndef LASTFM_RADIO_STATION_H
 21#define LASTFM_RADIO_STATION_H
 22
 23#include <lastfm/User>
 24#include <lastfm/Tag>
 25#include <lastfm/Artist>
 26
 27namespace lastfm
 28{
 29    /** @author <jono@last.fm> 
 30      */
 31    class LASTFM_DLLEXPORT RadioStation
 32    {
 33    public:
 34        RadioStation()
 35        {}
 36        RadioStation( const QString& s )
 37        {
 38        setString( s );
 39        }
 40    
 41        static RadioStation library( const lastfm::User& user );
 42        static RadioStation library( QList<lastfm::User>& users );
 43
 44        static RadioStation similar( const lastfm::Artist& artist );
 45        static RadioStation similar( QList<lastfm::Artist>& artist );
 46
 47        static RadioStation tag( const lastfm::Tag& tag );
 48        static RadioStation tag( QList<lastfm::Tag>& tag );
 49
 50        static RadioStation recommendations( const lastfm::User& user );
 51        static RadioStation friends( const lastfm::User& user );
 52        static RadioStation neighbourhood( const lastfm::User& user );
 53
 54        static RadioStation mix( const lastfm::User& user );
 55
 56        QNetworkReply* getSampleArtists( int limit = 50 ) const;
 57        QNetworkReply* getTagSuggestions( int limit = 50 ) const;
 58
 59        /** eg. "mxcl's Loved Tracks"
 60          * It is worth noting that the Radio doesn't set the title of RadioStation 
 61          * object until we have tuned to it, and then we only set the one we give 
 62          * you back.
 63          */    
 64        QString title() const;
 65        /** the Last.fm url, eg. lastfm://user/mxcl/loved */
 66        QString url() const;
 67
 68        void setTitle( const QString& title );
 69
 70        void setTagFilter( const QString& tag );
 71
 72        void setRep(float rep);
 73        void setMainstr(float mainstr);
 74        void setDisco(bool disco);
 75
 76        float rep() const;
 77        float mainstr() const;
 78        bool disco() const;
 79
 80        bool isLegacyPlaylist() const
 81        {
 82            return m_url.toString().startsWith( "lastfm://play/" ) ||
 83                   m_url.toString().startsWith( "lastfm://preview/" ) ||
 84                   m_url.toString().startsWith( "lastfm://track/" ) ||
 85                   m_url.toString().startsWith( "lastfm://playlist/" );
 86        }
 87
 88        // good for getRecentStations:
 89        static QList<RadioStation> list( QNetworkReply* );
 90
 91        bool operator==( const RadioStation& that ) const;
 92
 93    private:
 94        void setString( const QString& s );
 95
 96        static QString libraryStr( QList<lastfm::User>& user );
 97        static QString recommendationsStr( const lastfm::User& user ) { return "lastfm://user/" + user + "/recommended"; }
 98        static QString friendsStr( const lastfm::User& user )         { return "lastfm://user/" + user + "/friends"; }
 99        static QString neighbourhoodStr( const lastfm::User& user )   { return "lastfm://user/" + user + "/neighbours"; }
100        static QString tagStr( QList<lastfm::Tag>& tag );
101        static QString similarStr( QList<lastfm::Artist>& artist );
102        static QString mixStr( const lastfm::User& user )             { return "lastfm://user/" + user + "/mix"; }
103    private:
104        QUrl m_url;
105        QString m_title;
106        QString m_tagFilter;
107
108        float m_rep;
109        float m_mainstr;
110        bool m_disco;
111    };
112}
113
114
115Q_DECLARE_METATYPE( lastfm::RadioStation )
116
117
118inline QDebug operator<<( QDebug d, const lastfm::RadioStation& station )
119{
120    return d << station.url();
121}
122
123#endif