strawberry-audio-player-win.../src/tidal/tidalstreamurlrequest.h

84 lines
2.3 KiB
C
Raw Normal View History

2020-04-13 19:04:06 +02:00
/*
* Strawberry Music Player
2021-03-20 21:14:47 +01:00
* Copyright 2018-2021, Jonas Kvinge <jonas@jkvinge.net>
2020-04-13 19:04:06 +02:00
*
* 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 TIDALSTREAMURLREQUEST_H
#define TIDALSTREAMURLREQUEST_H
#include "config.h"
#include <QtGlobal>
#include <QObject>
#include <QVariant>
#include <QString>
#include <QStringList>
#include <QUrl>
#include "core/song.h"
#include "tidalservice.h"
#include "tidalbaserequest.h"
#include "settings/tidalsettingspage.h"
class QNetworkReply;
class NetworkAccessManager;
class TidalStreamURLRequest : public TidalBaseRequest {
Q_OBJECT
public:
2021-07-02 01:11:59 +02:00
explicit TidalStreamURLRequest(TidalService *service, NetworkAccessManager *network, const QUrl &original_url, const int id, QObject *parent = nullptr);
2020-06-15 21:55:05 +02:00
~TidalStreamURLRequest() override;
2020-04-13 19:04:06 +02:00
void GetStreamURL();
void Process();
void Cancel();
bool oauth() { return service_->oauth(); }
TidalSettingsPage::StreamUrlMethod stream_url_method() { return service_->stream_url_method(); }
QUrl original_url() { return original_url_; }
int song_id() { return song_id_; }
2021-06-28 00:21:14 +02:00
void set_need_login() override { need_login_ = true; }
2020-04-13 19:04:06 +02:00
bool need_login() { return need_login_; }
signals:
void TryLogin();
void StreamURLFinished(int id, QUrl original_url, QUrl stream_url, Song::FileType filetype, int samplerate, int bit_depth, qint64 duration, QString error = QString());
2020-04-13 19:04:06 +02:00
private slots:
void StreamURLReceived();
2021-01-26 16:48:04 +01:00
public slots:
2021-06-20 19:04:08 +02:00
void LoginComplete(const bool success, const QString &error = QString());
2021-01-26 16:48:04 +01:00
2020-04-13 19:04:06 +02:00
private:
2020-06-15 21:55:05 +02:00
void Error(const QString &error, const QVariant &debug = QVariant()) override;
2020-04-13 19:04:06 +02:00
TidalService *service_;
QNetworkReply *reply_;
QUrl original_url_;
int id_;
2020-04-13 19:04:06 +02:00
int song_id_;
int tries_;
bool need_login_;
QStringList errors_;
};
#endif // TIDALSTREAMURLREQUEST_H