Sayonara Player
Loading...
Searching...
No Matches
AbstractStationHandler.h
1/* AbstractStreamHandler.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 AbstractStreamHandler_H
22#define AbstractStreamHandler_H
23
24#include "Utils/Pimpl.h"
25#include "Utils/Streams/Station.h"
26
27#include <QObject>
28#include <QList>
29
30class PlaylistCreator;
32
34 public QObject
35{
36 Q_OBJECT
38
39 signals:
40 void sigStopped();
41 void sigError();
42 void sigDataAvailable();
43 void sigUrlCountExceeded(int urlCount, int maxUrlCount);
44
45 public:
47 const std::shared_ptr<StationParserFactory>& stationParserFactory,
48 QObject* parent = nullptr);
49 ~AbstractStationHandler() override;
50
51 bool parseStation(const StationPtr& station);
52
53 void addTemporaryStation(const StationPtr& station);
54 [[nodiscard]] bool isTemporary(const QString& stationName) const;
55
56 [[nodiscard]] StationPtr station(const QString& name);
57 bool addNewStream(const StationPtr& station);
58 bool removeStream(const QString& name);
59
60 virtual bool getAllStreams(QList<StationPtr>& streams) = 0;
61 virtual bool updateStream(const QString& name, const StationPtr& station) = 0;
62
63 void stop();
64
65 protected:
66 virtual MetaDataList preprocessPlaylist(const StationPtr& station, MetaDataList tracks) = 0;
67 virtual bool saveStream(const StationPtr& station) = 0;
68 virtual bool deleteStream(const QString& name) = 0;
69 [[nodiscard]] virtual StationPtr fetchStation(const QString& name) = 0;
70
71 private:
72 void createPlaylist(const StationPtr& station, const MetaDataList& tracks);
73
74 private slots: // NOLINT(readability-redundant-access-specifiers)
75 void parserFinished(bool success);
76 void parserStopped();
77};
78
79#endif // AbstractStreamHandler_H
Definition: AbstractStationHandler.h:35
Definition: MetaDataList.h:34
Definition: PlaylistInterface.h:57
Definition: EngineUtils.h:33
Definition: StreamParser.h:53