Sayonara Player
AbstractStreamHandler.h
1 /* AbstractStreamHandler.h */
2 
3 /* Copyright (C) 2011-2016 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 
22 #ifndef AbstractStreamHandler_H
23 #define AbstractStreamHandler_H
24 
25 #include <QMap>
26 #include <QString>
27 #include "Helper/MetaData/MetaDataList.h"
28 
29 
31 
32 
33 class PlaylistHandler;
34 class AsyncWebAccess;
35 class DatabaseConnector;
36 
44 class AbstractStreamHandler : public QObject
45 {
46  Q_OBJECT
47  public:
48  explicit AbstractStreamHandler(QObject *parent=nullptr);
49 
50 signals:
51  void sig_error();
52  void sig_data_available();
53 
54  public:
61  bool parse_station(const QString& url, const QString& station_name);
62 
68  MetaDataList get_tracks(const QString& station_name);
69 
75  void save(const QString& station_name, const QString& url);
76 
82  virtual bool get_all_streams(StreamMap& streams)=0;
83 
91  virtual bool add_stream(const QString& station_name, const QString& url)=0;
92 
98  virtual bool delete_stream(const QString& station_name)=0;
99 
106  virtual bool update_url(const QString& station_name, const QString& url)=0;
107 
114  virtual bool rename_stream(const QString& station_name, const QString& url)=0;
115 
119  void clear();
120 
121 
122  protected:
123  DatabaseConnector* _db=nullptr;
124  PlaylistHandler* _playlist=nullptr;
125 
126 
127  QMap<QString, MetaDataList> _station_contents;
128  QString _station_name;
129  bool _blocked;
130 
131 
132  private slots:
133  void stream_parser_finished(bool success);
134 
135 };
136 
137 #endif // AbstractStreamHandler_H
void clear()
Clears all station content.
virtual bool rename_stream(const QString &station_name, const QString &url)=0
Rename the station.
virtual bool get_all_streams(StreamMap &streams)=0
This method should return all stations in database.
void save(const QString &station_name, const QString &url)
Saves the station. Calls the add_stream() method.
Definition: DatabaseConnector.h:40
Definition: MetaDataList.h:44
MetaDataList get_tracks(const QString &station_name)
get_tracks
virtual bool update_url(const QString &station_name, const QString &url)=0
Update the url of a station.
virtual bool delete_stream(const QString &station_name)=0
Delete a station from the database.
Asynchgronous web access class.
Definition: AsyncWebAccess.h:37
Global handler for playlists.
Definition: PlaylistHandler.h:47
virtual bool add_stream(const QString &station_name, const QString &url)=0
This method should add a new station to database. If the station already exists, there should be a co...
Used to interprete website data as streams. Some methods have to be overridden, to map their function...
Definition: AbstractStreamHandler.h:44
bool parse_station(const QString &url, const QString &station_name)
Retrieves data from the station and tries to interprete it via the parse_content() method...