Sayonara Player
AbstractStreamHandler.h
1 /* AbstractStreamHandler.h */
2 
3 /* Copyright (C) 2011-2017 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 <QMap>
25 #include <QObject>
26 
27 #include "Utils/Pimpl.h"
28 
30 
38 class AbstractStreamHandler : public QObject
39 {
40  Q_OBJECT
42 
43  public:
44  explicit AbstractStreamHandler(QObject *parent=nullptr);
45  virtual ~AbstractStreamHandler();
46 
47  signals:
48  void sig_stopped();
49  void sig_error();
50  void sig_data_available();
51  void sig_too_many_urls_found(int n_urls, int max_n_urls);
52 
53  public:
60  bool parse_station(const QString& url, const QString& station_name);
61 
67  void save(const QString& station_name, const QString& url);
68 
74  virtual bool get_all_streams(StreamMap& streams)=0;
75 
83  virtual bool add_stream(const QString& station_name, const QString& url)=0;
84 
90  virtual bool delete_stream(const QString& station_name)=0;
91 
98  virtual bool update_url(const QString& station_name, const QString& url)=0;
99 
103  void clear();
104 
105  void stop();
106 
107  private slots:
108  void stream_parser_finished(bool success);
109  void stopped();
110 };
111 
112 #endif // AbstractStreamHandler_H
void clear()
Clears all station content.
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.
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.
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:38
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...