File indexing completed on 2024-05-05 04:48:33
0001 /**************************************************************************************** 0002 * Copyright (c) 2007 Leo Franchi <lfranchi@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 #ifndef LYRICS_MANAGER_H 0018 #define LYRICS_MANAGER_H 0019 0020 #include "amarok_export.h" 0021 #include "core/meta/Meta.h" 0022 #include "network/NetworkAccessManagerProxy.h" 0023 0024 #include <QMap> 0025 #include <QStringList> 0026 #include <QUrl> 0027 #include <QVariant> 0028 0029 0030 class AMAROK_EXPORT LyricsManager : public QObject 0031 { 0032 Q_OBJECT 0033 0034 public: 0035 static LyricsManager* instance() 0036 { 0037 if( !s_self ) 0038 s_self = new LyricsManager(); 0039 0040 return s_self; 0041 } 0042 0043 /** 0044 * Tests if the given lyrics are empty. 0045 * 0046 * @param lyrics The lyrics which will be tested. 0047 * 0048 * @return true if the given lyrics are empty, otherwise false. 0049 */ 0050 bool isEmpty( const QString &lyrics ) const; 0051 0052 void newTrack( const Meta::TrackPtr &track ); 0053 void lyricsResult( const QByteArray& lyrics, Meta::TrackPtr track ); 0054 void lyricsLoaded( const QUrl &url, const QByteArray &data, const NetworkAccessManagerProxy::Error &err ); 0055 void loadLyrics( Meta::TrackPtr track, bool overwrite = false ); 0056 0057 Q_SIGNALS: 0058 void newLyrics( Meta::TrackPtr ); 0059 void newSuggestions( const QVariantList& ); 0060 void error( const QString &); 0061 0062 private: 0063 LyricsManager(); 0064 0065 void sanitizeTitle( QString &title ); 0066 void sanitizeArtist( QString &artist ); 0067 0068 static LyricsManager* s_self; 0069 0070 QMap<QUrl, Meta::TrackPtr> m_trackMap; 0071 0072 private Q_SLOTS: 0073 void updateRedirectedUrl( const QUrl& oldUrl, const QUrl& newUrl ); 0074 }; 0075 0076 #endif