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

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 AMPACHESERVICE_H
0018 #define AMPACHESERVICE_H
0019 
0020 #include "AmpacheServiceCollection.h"
0021 #include "ServiceBase.h"
0022 
0023 #include <QPointer>
0024 
0025 class AmpacheAccountLogin;
0026 
0027 class AmpacheServiceFactory: public ServiceFactory
0028 {
0029     Q_PLUGIN_METADATA(IID AmarokPluginFactory_iid FILE "amarok_service_ampache.json")
0030     Q_INTERFACES(Plugins::PluginFactory)
0031     Q_OBJECT
0032 
0033     public:
0034         AmpacheServiceFactory();
0035         ~AmpacheServiceFactory() override {}
0036 
0037         bool possiblyContainsTrack( const QUrl &url ) const override;
0038 
0039         void init() override;
0040         QString name() override;
0041         KConfigGroup config() override;
0042 };
0043 
0044 
0045 /**
0046 A service for displaying, previewing and downloading music from Ampache music servers
0047 
0048     @author
0049 */
0050 class AmpacheService : public ServiceBase
0051 {
0052 
0053 Q_OBJECT
0054     
0055 public:
0056     explicit AmpacheService( AmpacheServiceFactory* parent, const QString &name,
0057                              const QUrl &url = QUrl(), const QString &username = QString(),
0058                              const QString &password = QString() );
0059 
0060     ~AmpacheService() override;
0061 
0062     void polish() override;
0063     void reauthenticate();
0064 
0065     Collections::Collection * collection() override { return m_collection; }
0066 
0067 private Q_SLOTS:
0068     void onLoginSuccessful();
0069 
0070 private:
0071     InfoParserBase *m_infoParser;
0072     Collections::AmpacheServiceCollection *  m_collection;
0073     QPointer<AmpacheAccountLogin> m_ampacheLogin;
0074 
0075     // Disable copy constructor and assignment
0076     AmpacheService( const AmpacheService& );
0077     AmpacheService& operator=( const AmpacheService& );
0078 };
0079 
0080 #endif