File indexing completed on 2024-05-19 04:50:10
0001 /**************************************************************************************** 0002 * Copyright (c) 2007 Casey Link <unnamedrambler@gmail.com> * 0003 * Copyright (c) 2007 Nikolaj Hald Nielsen <nhn@kde.org> * 0004 * (c) 2013 Ralf Engels <ralf-engels@gmx.de> * 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 AMPACHEMETA_H 0020 #define AMPACHEMETA_H 0021 0022 #include "ServiceBase.h" 0023 #include "ServiceMetaBase.h" 0024 #include "ServiceAlbumCoverDownloader.h" 0025 0026 #include <QDateTime> 0027 #include <QList> 0028 #include <QSet> 0029 #include <QStandardPaths> 0030 #include <QString> 0031 #include <QStringList> 0032 0033 0034 namespace Meta 0035 { 0036 0037 class AmpacheTrack : public ServiceTrack 0038 { 0039 0040 public: 0041 explicit AmpacheTrack( const QString& title, ServiceBase * service = nullptr ) 0042 : ServiceTrack( title ) 0043 , m_service( service ) 0044 , m_discNumber( 0 ) 0045 { 0046 Q_UNUSED(m_service); // might be used again later 0047 } 0048 0049 QString sourceName() override { return "Ampache"; } 0050 QString sourceDescription() override { return "The Ampache music server project: http://Ampache.org"; } 0051 QPixmap emblem() override { return QPixmap( QStandardPaths::locate( QStandardPaths::GenericDataLocation, "amarok/images/emblem-ampache.png" ) ); } 0052 QString scalableEmblem() override { return QStandardPaths::locate( QStandardPaths::GenericDataLocation, "amarok/images/emblem-ampache-scalable.svgz" ); } 0053 QString notPlayableReason() const override; 0054 0055 int discNumber() const override { return m_discNumber; } 0056 void setDiscNumber( int newDiscNumber ) override { m_discNumber = newDiscNumber; } 0057 0058 private: 0059 ServiceBase * m_service; 0060 0061 int m_discNumber; 0062 }; 0063 0064 0065 class AmpacheAlbum : public ServiceAlbumWithCover 0066 { 0067 private: 0068 QString m_coverURL; 0069 0070 public: 0071 explicit AmpacheAlbum( const QString &name ); 0072 explicit AmpacheAlbum( const QStringList &resultRow ); 0073 0074 ~AmpacheAlbum() override; 0075 0076 QString downloadPrefix() const override { return "ampache"; } 0077 0078 void setCoverUrl( const QString &coverURL ) override; 0079 QString coverUrl() const override; 0080 0081 bool operator==( const Meta::Album &other ) const override 0082 { 0083 return name() == other.name(); 0084 } 0085 0086 QList<int> ids() const { return m_ampacheAlbums.keys(); } 0087 0088 struct AmpacheAlbumInfo { 0089 int id; 0090 int discNumber; 0091 int year; 0092 }; 0093 0094 /** Add an ampache album to this Amarok album. 0095 Warning: The album will not be automatically 0096 registered with the new id, same as with setId 0097 */ 0098 void addInfo( const AmpacheAlbumInfo &info ); 0099 0100 /** Get's an album info for a specific ID */ 0101 AmpacheAlbumInfo getInfo( int id ) const; 0102 0103 private: 0104 0105 // the unique album key of ampache contains discNumber and year 0106 // the Amarok key only name and artist 0107 // so this AmpacheAlbum object represents a number of ampache albums. 0108 QHash<int, AmpacheAlbumInfo> m_ampacheAlbums; 0109 }; 0110 0111 class AmpacheArtist : public ServiceArtist 0112 { 0113 private: 0114 QString m_coverURL; 0115 0116 public: 0117 AmpacheArtist( const QString &name, ServiceBase * service ) 0118 : ServiceArtist( name ) 0119 , m_service( service ) 0120 {} 0121 0122 bool isBookmarkable() const override { return true; } 0123 QString collectionName() const override { return m_service->name(); } 0124 bool simpleFiltering() const override { return true; } 0125 0126 bool operator==( const Meta::Artist &other ) const override 0127 { 0128 return name() == other.name(); 0129 } 0130 0131 private: 0132 ServiceBase * m_service; 0133 }; 0134 0135 } 0136 0137 #endif // End include guard