1 /****************************************************************************************
2  * Copyright (c) 2007 Nikolaj Hald Nielsen <nhn@kde.org>                                *
3  *                                                                                      *
4  * This program is free software; you can redistribute it and/or modify it under        *
5  * the terms of the GNU General Public License as published by the Free Software        *
6  * Foundation; either version 2 of the License, or (at your option) any later           *
7  * version.                                                                             *
8  *                                                                                      *
9  * This program is distributed in the hope that it will be useful, but WITHOUT ANY      *
10  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A      *
11  * PARTICULAR PURPOSE. See the GNU General Public License for more details.             *
12  *                                                                                      *
13  * You should have received a copy of the GNU General Public License along with         *
14  * this program.  If not, see <http://www.gnu.org/licenses/>.                           *
15  ****************************************************************************************/
16 
17 #ifndef AMAROK_SERVICEPLUGINMANAGER_H
18 #define AMAROK_SERVICEPLUGINMANAGER_H
19 
20 #include <QObject>
21 #include <QStringList>
22 #include <QSet>
23 
24 class ServiceBase;
25 namespace Plugins {
26     class PluginFactory;
27 }
28 
29 /** A class to keep track of available service plugins and load them as needed
30  *
31  *  @author
32  */
33 class ServicePluginManager : public QObject
34 {
35     Q_OBJECT
36 
37 public:
38 
39     static ServicePluginManager *instance();
40     static void destroy();
41 
42     /**
43      * Load any services that are configured to be loaded.
44      * Unload any services that have been switched off.
45      */
46     void setFactories( const QList<QSharedPointer<Plugins::PluginFactory> > &factories );
47 
48 public Q_SLOTS:
49     QStringList loadedServices() const;
50     QStringList loadedServiceNames() const;
51     QString serviceDescription( const QString &service );
52     QString serviceMessages( const QString &service );
53     QString sendMessage( const QString &service, const QString &message );
54 
55 private:
56     static ServicePluginManager* s_instance;
57     ServicePluginManager();
58     ~ServicePluginManager() override;
59 
60     Q_DISABLE_COPY( ServicePluginManager )
61 
62     /** The list of currently set factories.
63      *  Note: the PluginManager owns the pointers.
64      */
65     QList<QSharedPointer<Plugins::PluginFactory> > m_factories;
66 
67 private Q_SLOTS:
68     void slotNewService( ServiceBase *newService);
69     void slotRemoveService( ServiceBase *removedService );
70 };
71 
72 
73 #endif //AMAROK_SERVICEPLUGINMANAGER_H
74 
75