2021-07-11 01:02:53 +02:00
|
|
|
/*
|
|
|
|
* Strawberry Music Player
|
|
|
|
* Copyright 2021, Jonas Kvinge <jonas@jkvinge.net>
|
|
|
|
*
|
|
|
|
* Strawberry is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* Strawberry is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef RADIOSERVICE_H
|
|
|
|
#define RADIOSERVICE_H
|
|
|
|
|
|
|
|
#include <QObject>
|
2023-07-12 18:13:02 +02:00
|
|
|
#include <QMetaType>
|
2021-07-11 01:02:53 +02:00
|
|
|
#include <QList>
|
2021-07-11 01:20:42 +02:00
|
|
|
#include <QVariant>
|
2021-07-11 02:31:15 +02:00
|
|
|
#include <QByteArray>
|
2021-07-11 01:02:53 +02:00
|
|
|
#include <QString>
|
|
|
|
#include <QUrl>
|
|
|
|
#include <QIcon>
|
|
|
|
#include <QJsonObject>
|
|
|
|
|
2023-07-21 05:55:24 +02:00
|
|
|
#include "core/shared_ptr.h"
|
2021-07-11 01:02:53 +02:00
|
|
|
#include "core/song.h"
|
|
|
|
#include "radiochannel.h"
|
|
|
|
|
|
|
|
class QNetworkReply;
|
|
|
|
|
|
|
|
class Application;
|
|
|
|
class NetworkAccessManager;
|
|
|
|
|
|
|
|
class RadioService : public QObject {
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2023-07-21 05:55:24 +02:00
|
|
|
explicit RadioService(const Song::Source source, const QString &name, const QIcon &icon, Application *app, SharedPtr<NetworkAccessManager> network, QObject *parent = nullptr);
|
2021-07-11 01:02:53 +02:00
|
|
|
|
|
|
|
Song::Source source() const { return source_; }
|
|
|
|
QString name() const { return name_; }
|
|
|
|
|
|
|
|
virtual void ReloadSettings() {}
|
|
|
|
|
|
|
|
virtual QUrl Homepage() = 0;
|
|
|
|
virtual QUrl Donate() = 0;
|
|
|
|
|
|
|
|
signals:
|
2023-04-09 20:23:42 +02:00
|
|
|
void NewChannels(const RadioChannelList &channels = RadioChannelList());
|
2021-07-11 01:02:53 +02:00
|
|
|
|
|
|
|
public slots:
|
|
|
|
virtual void GetChannels() = 0;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
QByteArray ExtractData(QNetworkReply *reply);
|
|
|
|
QJsonObject ExtractJsonObj(const QByteArray &data);
|
|
|
|
QJsonObject ExtractJsonObj(QNetworkReply *reply);
|
|
|
|
void Error(const QString &error, const QVariant &debug = QVariant());
|
|
|
|
|
|
|
|
protected:
|
|
|
|
Application *app_;
|
2023-07-21 05:55:24 +02:00
|
|
|
SharedPtr<NetworkAccessManager> network_;
|
2021-07-11 01:02:53 +02:00
|
|
|
Song::Source source_;
|
|
|
|
QString name_;
|
|
|
|
QIcon icon_;
|
|
|
|
};
|
|
|
|
|
|
|
|
Q_DECLARE_METATYPE(RadioService*)
|
|
|
|
|
|
|
|
#endif // RADIOSERVICE_H
|