File indexing completed on 2025-01-05 04:26:56

0001 /****************************************************************************************
0002  * Copyright (c) 2007 Maximilian Kossick <maximilian.kossick@googlemail.com>            *
0003  * Copyright (c) 2008 Shane King <kde@dontletsstart.com>                                *
0004  * Copyright (c) 2008 Leo Franchi <lfranchi@kde.org>                                    *
0005  *                                                                                      *
0006  * This program is free software; you can redistribute it and/or modify it under        *
0007  * the terms of the GNU General Public License as published by the Free Software        *
0008  * Foundation; either version 2 of the License, or (at your option) any later           *
0009  * version.                                                                             *
0010  *                                                                                      *
0011  * This program is distributed in the hope that it will be useful, but WITHOUT ANY      *
0012  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A      *
0013  * PARTICULAR PURPOSE. See the GNU General Public License for more details.             *
0014  *                                                                                      *
0015  * You should have received a copy of the GNU General Public License along with         *
0016  * this program.  If not, see <http://www.gnu.org/licenses/>.                           *
0017  ****************************************************************************************/
0018 
0019 #ifndef AMAROK_LASTFMMETA_H
0020 #define AMAROK_LASTFMMETA_H
0021 
0022 #include "core/meta/Meta.h"
0023 #include "core/capabilities/Capability.h"
0024 #include "services/ServiceMetaBase.h" // for the SourceInfoProvider
0025 
0026 namespace lastfm {
0027     class Track;
0028 }
0029 
0030 namespace LastFm
0031 {
0032     class Track : public QObject, public Meta::Track, public SourceInfoProvider
0033     {
0034         Q_OBJECT
0035         public:
0036             class Private;
0037 
0038             explicit Track( const QString &lastFmUri );
0039             explicit Track( lastfm::Track track ); //Convenience Constructor to allow constructing a Meta::LastFmTrack from a LastFmTrack (confusing?)
0040             ~Track() override;
0041 
0042         // methods inherited from Meta::Base
0043             QString name() const override;
0044             QString sortableName() const override;
0045 
0046         // methods inherited from Meta::Track
0047             QUrl playableUrl() const override;
0048             QString prettyUrl() const override;
0049             QString uidUrl() const override;
0050             QString notPlayableReason() const override;
0051 
0052             Meta::AlbumPtr album() const override;
0053             Meta::ArtistPtr artist() const override;
0054             Meta::GenrePtr genre() const override;
0055             Meta::ComposerPtr composer() const override;
0056             Meta::YearPtr year() const override;
0057 
0058             qreal bpm() const override;
0059 
0060             QString comment() const override;
0061 
0062             int trackNumber() const override;
0063 
0064             int discNumber() const override;
0065 
0066             qint64 length() const override;
0067             int filesize() const override;
0068             int sampleRate() const override;
0069             int bitrate() const override;
0070 
0071             QString type() const override;
0072 
0073             bool inCollection() const override;
0074             Collections::Collection *collection() const override;
0075 
0076             bool hasCapabilityInterface( Capabilities::Capability::Type type ) const override;
0077             Capabilities::Capability* createCapabilityInterface( Capabilities::Capability::Type type ) override;
0078 
0079             Meta::StatisticsPtr statistics() override;
0080 
0081         // own methods:
0082             void setTrackInfo( const lastfm::Track &trackInfo );
0083 
0084             QString sourceName() override;
0085             QString sourceDescription() override;
0086             QPixmap emblem() override;
0087             QString scalableEmblem() override;
0088 
0089             //LastFm specific methods, cast the object to LastFm::Track to use them
0090             //you can cast the Track when type() returns "stream/lastfm" (or use a dynamic cast:)
0091             QUrl internalUrl() const; // this returns the private temporary url to the .mp3, DO NOT USE,
0092                                    // if you are asking, it has already expired
0093             QString streamName() const; // A nice name for the stream..
0094 
0095         public Q_SLOTS:
0096             void ban();
0097 
0098         private Q_SLOTS:
0099             void slotResultReady();
0100             void slotWsReply();
0101 
0102         Q_SIGNALS:
0103             void skipTrack(); // needed for communication with multiplayablecapability
0104 
0105         private:
0106             void init( int id = -1 );
0107             //use a d-pointer because some code is going to work directly with LastFm::Track
0108             Private * const d;
0109             QList< QAction * > m_trackActions;
0110     };
0111 
0112     class LastFmProviderCapability : public Capabilities::Capability
0113     {
0114         public:
0115             LastFmProviderCapability();
0116             ~LastFmProviderCapability() override;
0117     };
0118 
0119     typedef AmarokSharedPointer<Track> TrackPtr;
0120 }
0121 
0122 #endif