File indexing completed on 2024-05-05 04:49:17

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 AMAROK_SERVICEPLUGINMANAGER_H
0018 #define AMAROK_SERVICEPLUGINMANAGER_H
0019 
0020 #include <QObject>
0021 #include <QStringList>
0022 #include <QSet>
0023 
0024 class ServiceBase;
0025 namespace Plugins {
0026     class PluginFactory;
0027 }
0028 
0029 /** A class to keep track of available service plugins and load them as needed
0030  *
0031  *  @author
0032  */
0033 class ServicePluginManager : public QObject
0034 {
0035     Q_OBJECT
0036 
0037 public:
0038 
0039     static ServicePluginManager *instance();
0040     static void destroy();
0041 
0042     /**
0043      * Load any services that are configured to be loaded.
0044      * Unload any services that have been switched off.
0045      */
0046     void setFactories( const QList<QSharedPointer<Plugins::PluginFactory> > &factories );
0047 
0048 public Q_SLOTS:
0049     QStringList loadedServices() const;
0050     QStringList loadedServiceNames() const;
0051     QString serviceDescription( const QString &service );
0052     QString serviceMessages( const QString &service );
0053     QString sendMessage( const QString &service, const QString &message );
0054 
0055 private:
0056     static ServicePluginManager* s_instance;
0057     ServicePluginManager();
0058     ~ServicePluginManager() override;
0059 
0060     Q_DISABLE_COPY( ServicePluginManager )
0061 
0062     /** The list of currently set factories.
0063      *  Note: the PluginManager owns the pointers.
0064      */
0065     QList<QSharedPointer<Plugins::PluginFactory> > m_factories;
0066 
0067 private Q_SLOTS:
0068     void slotNewService( ServiceBase *newService);
0069     void slotRemoveService( ServiceBase *removedService );
0070 };
0071 
0072 
0073 #endif //AMAROK_SERVICEPLUGINMANAGER_H
0074