Refactor Tidal, Spotify, Qobuz, Subsonic and cover providers
Use common HTTP, Json and OAuthenticator class
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2024, Jonas Kvinge <jonas@jkvinge.net>
|
||||
* Copyright 2024-2025, 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
|
||||
@@ -22,15 +22,10 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QList>
|
||||
#include <QQueue>
|
||||
#include <QVariant>
|
||||
#include <QByteArray>
|
||||
#include <QString>
|
||||
#include <QDateTime>
|
||||
#include <QSslError>
|
||||
#include <QJsonObject>
|
||||
|
||||
#include "includes/shared_ptr.h"
|
||||
#include "jsoncoverprovider.h"
|
||||
@@ -38,13 +33,13 @@
|
||||
class QNetworkReply;
|
||||
class NetworkAccessManager;
|
||||
class QTimer;
|
||||
class OAuthenticator;
|
||||
|
||||
class OpenTidalCoverProvider : public JsonCoverProvider {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit OpenTidalCoverProvider(const SharedPtr<NetworkAccessManager> network, QObject *parent = nullptr);
|
||||
~OpenTidalCoverProvider() override;
|
||||
|
||||
bool StartSearch(const QString &artist, const QString &album, const QString &title, const int id) override;
|
||||
void CancelSearch(const int id) override;
|
||||
@@ -60,33 +55,24 @@ class OpenTidalCoverProvider : public JsonCoverProvider {
|
||||
using SearchRequestPtr = SharedPtr<SearchRequest>;
|
||||
|
||||
private:
|
||||
void LoadSession();
|
||||
void LoginCheck();
|
||||
void Login();
|
||||
QJsonObject GetJsonObject(QNetworkReply *reply);
|
||||
QJsonObject ExtractJsonObj(const QByteArray &data);
|
||||
void SendSearchRequest(SearchRequestPtr request);
|
||||
JsonObjectResult ParseJsonObject(QNetworkReply *reply);
|
||||
void FinishAllSearches();
|
||||
void Error(const QString &error, const QVariant &debug = QVariant()) override;
|
||||
|
||||
private Q_SLOTS:
|
||||
void OAuthFinished(const bool success, const QString &error = QString());
|
||||
void FlushRequests();
|
||||
void LoginFinished(QNetworkReply *reply);
|
||||
void HandleLoginSSLErrors(const QList<QSslError> &ssl_errors);
|
||||
void HandleSearchReply(QNetworkReply *reply, OpenTidalCoverProvider::SearchRequestPtr search_request);
|
||||
|
||||
private:
|
||||
QTimer *login_timer_;
|
||||
OAuthenticator *oauth_;
|
||||
QTimer *timer_flush_requests_;
|
||||
bool login_in_progress_;
|
||||
QDateTime last_login_attempt_;
|
||||
bool have_login_;
|
||||
QString token_type_;
|
||||
QString access_token_;
|
||||
qint64 login_time_;
|
||||
qint64 expires_in_;
|
||||
QQueue<SearchRequestPtr> search_requests_queue_;
|
||||
QList<QNetworkReply*> replies_;
|
||||
};
|
||||
|
||||
#endif // OPENTIDALCOVERPROVIDER_H
|
||||
|
||||
Reference in New Issue
Block a user