Sayonara Player
Loading...
Searching...
No Matches
AbstractStationHandler.h
1/* AbstractStationHandler.h */
2
3/* Copyright (C) 2011-2024 Michael Lugmair (Lucio Carreras)
4 *
5 * This file is part of sayonara player
6 *
7 * This program 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 * This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21#ifndef SAYONARA_ABSTRACT_STATION_HANDLER_H
22#define SAYONARA_ABSTRACT_STATION_HANDLER_H
23
24#include "Utils/Pimpl.h"
25#include "Utils/Streams/Station.h"
26
27#include <QObject>
28#include <QList>
29
30namespace Playlist
31{
32 class Creator;
33}
34
36
37class AbstractStationHandler :
38 public QObject
39{
40 Q_OBJECT
41 PIMPL(AbstractStationHandler)
42
43 signals:
44 void sigStopped();
45 void sigError();
46 void sigDataAvailable();
47 void sigUrlCountExceeded(int urlCount, int maxUrlCount);
48
49 public:
50 AbstractStationHandler(Playlist::Creator* playlistCreator,
51 const std::shared_ptr<StationParserFactory>& stationParserFactory,
52 QObject* parent = nullptr);
53 ~AbstractStationHandler() override;
54
55 bool parseStation(const StationPtr& station);
56
57 void addTemporaryStation(const StationPtr& station);
58 [[nodiscard]] bool isTemporary(const QString& stationName) const;
59
60 [[nodiscard]] StationPtr station(const QString& name);
61 bool addNewStation(const StationPtr& station);
62 bool removeStation(const QString& name);
63 [[nodiscard]] virtual QList<StationPtr> getAllStations() const;
64
65 virtual bool updateStation(const QString& name, const StationPtr& station) = 0;
66
67 void stop();
68
69 protected:
70 virtual MetaDataList preprocessPlaylist(const StationPtr& station, MetaDataList tracks) = 0;
71 virtual bool saveStation(const StationPtr& station) = 0;
72 virtual bool deleteStation(const QString& name) = 0;
73 [[nodiscard]] virtual StationPtr fetchStation(const QString& name) = 0;
74 [[nodiscard]] virtual QList<StationPtr> fetchAllStations() const = 0;
75
76 private:
77 void createPlaylist(const StationPtr& station, MetaDataList tracks);
78
79 private slots: // NOLINT(readability-redundant-access-specifiers)
80 void parserFinished(bool success);
81 void parserStopped();
82};
83
84#endif // SAYONARA_ABSTRACT_STATION_HANDLER_H
Definition MetaDataList.h:34
Definition PlaylistInterface.h:59
Definition EngineUtils.h:33
Definition StreamParser.h:53