1 /*
2  * Strawberry Music Player
3  * This file was part of Clementine.
4  * Copyright 2010, David Sansome <me@davidsansome.com>
5  * Copyright 2018-2021, Jonas Kvinge <jonas@jkvinge.net>
6  *
7  * Strawberry is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * Strawberry is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with Strawberry.  If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef INTERNETSERVICES_H
23 #define INTERNETSERVICES_H
24 
25 #include "config.h"
26 
27 #include <QObject>
28 #include <QList>
29 #include <QMap>
30 #include <QString>
31 
32 #include "core/song.h"
33 
34 class InternetService;
35 
36 class InternetServices : public QObject {
37   Q_OBJECT
38 
39  public:
40   explicit InternetServices(QObject *parent = nullptr);
41   ~InternetServices() override;
42 
43   InternetService *ServiceBySource(const Song::Source source) const;
44   template <typename T>
45   T *Service() {
46     return static_cast<T*>(ServiceBySource(T::kSource));
47   }
48 
49   void AddService(InternetService *service);
50   void RemoveService(InternetService *service);
51   void ReloadSettings();
52   void Exit();
53 
54  signals:
55   void ExitFinished();
56 
57  private slots:
58   void ExitReceived();
59 
60  private:
61   QMap<Song::Source, InternetService*> services_;
62   QList<InternetService*> wait_for_exit_;
63 
64 };
65 
66 #endif  // INTERNETSERVICES_H
67