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 #ifndef JAMENDOSERVICE_H 0018 #define JAMENDOSERVICE_H 0019 0020 #include "ServiceBase.h" 0021 #include "JamendoDatabaseHandler.h" 0022 #include "JamendoXmlParser.h" 0023 #include "ServiceSqlCollection.h" 0024 0025 #include "core/support/Amarok.h" 0026 #include <kio/job.h> 0027 #include <kio/jobclasses.h> 0028 0029 class JamendoServiceFactory : public ServiceFactory 0030 { 0031 Q_PLUGIN_METADATA(IID AmarokPluginFactory_iid FILE "amarok_service_jamendo.json") 0032 Q_INTERFACES(Plugins::PluginFactory) 0033 Q_OBJECT 0034 0035 public: 0036 JamendoServiceFactory(); 0037 virtual ~JamendoServiceFactory() {} 0038 0039 virtual void init(); 0040 virtual QString name(); 0041 virtual KConfigGroup config(); 0042 0043 virtual bool possiblyContainsTrack( const QUrl &url ) const { return url.url().contains( "jamendo.com", Qt::CaseInsensitive ); } 0044 }; 0045 0046 class JamendoService : public ServiceBase 0047 { 0048 Q_OBJECT 0049 public: 0050 JamendoService( JamendoServiceFactory* parent, const QString &name ); 0051 0052 ~JamendoService(); 0053 0054 void polish(); 0055 virtual Collections::Collection * collection() { return m_collection; } 0056 0057 private Q_SLOTS: 0058 void updateButtonClicked(); 0059 void download(); 0060 void listDownloadComplete( KJob* downloadJob); 0061 void listDownloadCancelled(); 0062 void doneParsing(); 0063 0064 /** 0065 * Checks if download button should be enabled 0066 * @param selection the new selection 0067 */ 0068 void itemSelected( CollectionTreeItem * selectedItem ); 0069 0070 0071 private: 0072 //DatabaseDrivenContentModel * m_model; 0073 QPushButton *m_updateListButton; 0074 QPushButton *m_downloadButton; 0075 KIO::FileCopyJob * m_listDownloadJob; 0076 QString m_tempFileName; 0077 Collections::ServiceSqlCollection * m_collection; 0078 Meta::JamendoAlbum * m_currentAlbum; 0079 0080 JamendoXmlParser * m_xmlParser; 0081 }; 0082 0083 #endif