File indexing completed on 2024-05-19 04:50:13

0001 /****************************************************************************************
0002  * Copyright (c) 2007 Nikolaj Hald Nielsen <nhn@kde.org>                                *
0003  *                                                                                      *
0004  * This program is free software; you can redistribute it and/or modify it under        *
0005  * the terms of the GNU General Public License as published by the Free Software        *
0006  * Foundation; either version 2 of the License, or (at your option) any later           *
0007  * version.                                                                             *
0008  *                                                                                      *
0009  * This program is distributed in the hope that it will be useful, but WITHOUT ANY      *
0010  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A      *
0011  * PARTICULAR PURPOSE. See the GNU General Public License for more details.             *
0012  *                                                                                      *
0013  * You should have received a copy of the GNU General Public License along with         *
0014  * this program.  If not, see <http://www.gnu.org/licenses/>.                           *
0015  ****************************************************************************************/
0016 
0017 #include "JamendoMeta.h"
0018 
0019 #include "JamendoService.h"
0020 #include "SvgHandler.h"
0021 
0022 #include "core/support/Debug.h"
0023 #include <QStandardPaths>
0024 
0025 #include <QAction>
0026 
0027 using namespace Meta;
0028 
0029 JamendoMetaFactory::JamendoMetaFactory( const QString & dbPrefix, JamendoService * service )
0030     : ServiceMetaFactory( dbPrefix )
0031     , m_service( service )
0032 {
0033 }
0034 
0035 TrackPtr JamendoMetaFactory::createTrack( const QStringList & rows )
0036 {
0037     JamendoTrack * track = new JamendoTrack( rows );
0038     track->setService( m_service );
0039     return TrackPtr( track );
0040 }
0041 
0042 int
0043 JamendoMetaFactory::getAlbumSqlRowCount()
0044 {
0045     return ServiceMetaFactory::getAlbumSqlRowCount() + 6;
0046 }
0047 
0048 QString
0049 JamendoMetaFactory::getAlbumSqlRows()
0050 {
0051     QString sqlRows = ServiceMetaFactory::getAlbumSqlRows();
0052 
0053     sqlRows += ", ";
0054     sqlRows += tablePrefix() + "_albums.popularity, ";
0055     sqlRows += tablePrefix() + "_albums.cover_url, ";
0056     sqlRows += tablePrefix() + "_albums.launch_year, ";
0057     sqlRows += tablePrefix() + "_albums.genre, ";
0058     sqlRows += tablePrefix() + "_albums.mp3_torrent_url, "; // Deprecated
0059     sqlRows += tablePrefix() + "_albums.ogg_torrent_url "; // Deprecated
0060 
0061     return sqlRows;
0062 }
0063 
0064 AlbumPtr
0065 JamendoMetaFactory::createAlbum( const QStringList & rows )
0066 {
0067     JamendoAlbum * album = new JamendoAlbum( rows );
0068     album->setService( m_service );
0069     album->setSourceName( "Jamendo.com" );
0070     return AlbumPtr( album );
0071 }
0072 
0073 int
0074 JamendoMetaFactory::getArtistSqlRowCount()
0075 {
0076     return ServiceMetaFactory::getArtistSqlRowCount() + 4;
0077 }
0078 
0079 QString
0080 JamendoMetaFactory::getArtistSqlRows()
0081 {
0082     QString sqlRows = ServiceMetaFactory::getArtistSqlRows();
0083 
0084     sqlRows += ", ";
0085     sqlRows += tablePrefix() + "_artists.country, ";
0086     sqlRows += tablePrefix() + "_artists.photo_url, ";
0087     sqlRows += tablePrefix() + "_artists.jamendo_url, ";
0088     sqlRows += tablePrefix() + "_artists.home_url ";
0089 
0090     return sqlRows;
0091 }
0092 
0093 ArtistPtr
0094 JamendoMetaFactory::createArtist( const QStringList & rows )
0095 {
0096     JamendoArtist * artist = new JamendoArtist( rows );
0097     artist->setSourceName( "Jamendo.com" );
0098     return ArtistPtr( artist );
0099 }
0100 
0101 GenrePtr
0102 JamendoMetaFactory::createGenre( const QStringList & rows )
0103 {
0104     JamendoGenre * genre = new JamendoGenre( rows );
0105     genre->setSourceName( "Jamendo.com" );
0106     return GenrePtr( genre );
0107 }
0108 
0109 //// JamendoTrack ////
0110 
0111 JamendoTrack::JamendoTrack( const QString &name )
0112     : ServiceTrack( name )
0113     , m_service ( 0 )
0114 {
0115 }
0116 
0117 JamendoTrack::JamendoTrack( const QStringList & resultRow )
0118     : ServiceTrack( resultRow )
0119     , m_service ( 0 )
0120 {
0121 }
0122 
0123 QString
0124 Meta::JamendoTrack::sourceName()
0125 {
0126     return "Jamendo.com";
0127 }
0128 
0129 QString
0130 Meta::JamendoTrack::sourceDescription()
0131 {
0132     return i18n( "A site where artists can freely share their music" );
0133 }
0134 
0135 QPixmap
0136 Meta::JamendoTrack::emblem()
0137 {
0138     return QPixmap( QStandardPaths::locate( QStandardPaths::GenericDataLocation, "amarok/images/emblem-jamendo.png" ) );
0139 }
0140 
0141 
0142 QString JamendoTrack::scalableEmblem()
0143 {
0144     return QStandardPaths::locate( QStandardPaths::GenericDataLocation, "amarok/images/emblem-jamendo-scalable.svgz" );
0145 }
0146 
0147 void
0148 Meta::JamendoTrack::setService(JamendoService * service)
0149 {
0150     m_service = service;
0151 }
0152 
0153 QString JamendoTrack::type() const
0154 {
0155     return "mp3";
0156 }
0157 
0158 //// JamendoArtist ////
0159 
0160 JamendoArtist::JamendoArtist( const QString &name )
0161     : ServiceArtist( name )
0162 {
0163 }
0164 
0165 JamendoArtist::JamendoArtist( const QStringList & resultRow )
0166     : ServiceArtist( resultRow )
0167 {
0168     m_country = resultRow[3];
0169     m_photoURL = resultRow[4];
0170     m_jamendoURL = resultRow[5];
0171     m_homeURL = resultRow[6];
0172 }
0173 
0174 void
0175 JamendoArtist::setCountry( const QString & country )
0176 {
0177     m_country = country;
0178 }
0179 
0180 QString
0181 JamendoArtist::country() const
0182 {
0183     return m_country;
0184 }
0185 
0186 
0187 void
0188 JamendoArtist::setPhotoURL( const QString &photoURL )
0189 {
0190     m_photoURL = photoURL;
0191 }
0192 
0193 QString
0194 JamendoArtist::photoURL( ) const
0195 {
0196     return m_photoURL;
0197 }
0198 
0199 void
0200 JamendoArtist::setHomeURL( const QString &homeURL )
0201 {
0202     m_homeURL = homeURL;
0203 }
0204 
0205 QString
0206 JamendoArtist::homeURL( ) const
0207 {
0208     return m_homeURL;
0209 }
0210 
0211 void
0212 JamendoArtist::setJamendoURL( const QString & jamendoURL )
0213 {
0214     m_jamendoURL = jamendoURL;
0215 }
0216 
0217 QString
0218 JamendoArtist::jamendoURL() const
0219 {
0220     return m_jamendoURL;
0221 }
0222 
0223 
0224 //// JamendoAlbum ////
0225 
0226 JamendoAlbum::JamendoAlbum( const QString &name )
0227     : ServiceAlbumWithCover( name )
0228 {
0229 }
0230 
0231 JamendoAlbum::JamendoAlbum( const QStringList & resultRow )
0232     : ServiceAlbumWithCover( resultRow )
0233 {
0234     m_popularity = resultRow[4].toFloat();
0235     m_coverURL = resultRow[5];
0236     m_launchYear = resultRow[6].toInt();
0237     m_genre = resultRow[7];
0238 }
0239 
0240 void
0241 JamendoAlbum::setCoverUrl( const QString &coverURL )
0242 {
0243     m_coverURL = coverURL;
0244 }
0245 
0246 QString
0247 JamendoAlbum::coverUrl( ) const
0248 {
0249     return m_coverURL;
0250 }
0251 
0252 void
0253 JamendoAlbum::setLaunchYear( int launchYear )
0254 {
0255     m_launchYear = launchYear;
0256 }
0257 
0258 int
0259 JamendoAlbum::launchYear( ) const
0260 {
0261     return m_launchYear;
0262 }
0263 
0264 void
0265 JamendoAlbum::setGenre( const QString&genre )
0266 {
0267     m_genre = genre;
0268 }
0269 
0270 QString
0271 JamendoAlbum::genre( ) const
0272 {
0273     return m_genre;
0274 }
0275 
0276 void
0277 JamendoAlbum::setPopularity( float popularity )
0278 {
0279     m_popularity = popularity;
0280 }
0281 
0282 float
0283 JamendoAlbum::popularity() const
0284 {
0285     return m_popularity;
0286 }
0287 
0288 void
0289 Meta::JamendoAlbum::setService( JamendoService * service )
0290 {
0291     m_service = service;
0292 }
0293 
0294 JamendoService *
0295 Meta::JamendoAlbum::service()
0296 {
0297     return m_service;
0298 }
0299 
0300 
0301 JamendoGenre::JamendoGenre( const QString & name )
0302     : ServiceGenre( name )
0303 {
0304 }
0305 
0306 JamendoGenre::JamendoGenre( const QStringList & resultRow )
0307     : ServiceGenre( resultRow )
0308 {
0309 }
0310