@@ -35,11 +35,12 @@
|
||||
#include <QJsonValue>
|
||||
|
||||
#include "core/logging.h"
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/networkaccessmanager.h"
|
||||
#include "tidalservice.h"
|
||||
#include "tidalbaserequest.h"
|
||||
|
||||
TidalBaseRequest::TidalBaseRequest(TidalService *service, NetworkAccessManager *network, QObject *parent)
|
||||
TidalBaseRequest::TidalBaseRequest(TidalService *service, SharedPtr<NetworkAccessManager> network, QObject *parent)
|
||||
: QObject(parent),
|
||||
service_(service),
|
||||
network_(network) {}
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
#include <QJsonObject>
|
||||
#include <QJsonValue>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "tidalservice.h"
|
||||
|
||||
class QNetworkReply;
|
||||
@@ -45,7 +46,7 @@ class TidalBaseRequest : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit TidalBaseRequest(TidalService *service, NetworkAccessManager *network, QObject *parent = nullptr);
|
||||
explicit TidalBaseRequest(TidalService *service, SharedPtr<NetworkAccessManager> network, QObject *parent = nullptr);
|
||||
|
||||
enum class QueryType {
|
||||
None,
|
||||
@@ -101,8 +102,7 @@ class TidalBaseRequest : public QObject {
|
||||
|
||||
private:
|
||||
TidalService *service_;
|
||||
NetworkAccessManager *network_;
|
||||
|
||||
SharedPtr<NetworkAccessManager> network_;
|
||||
};
|
||||
|
||||
#endif // TIDALBASEREQUEST_H
|
||||
|
||||
@@ -32,13 +32,14 @@
|
||||
#include <QNetworkReply>
|
||||
|
||||
#include "core/logging.h"
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/networkaccessmanager.h"
|
||||
#include "core/song.h"
|
||||
#include "tidalservice.h"
|
||||
#include "tidalbaserequest.h"
|
||||
#include "tidalfavoriterequest.h"
|
||||
|
||||
TidalFavoriteRequest::TidalFavoriteRequest(TidalService *service, NetworkAccessManager *network, QObject *parent)
|
||||
TidalFavoriteRequest::TidalFavoriteRequest(TidalService *service, SharedPtr<NetworkAccessManager> network, QObject *parent)
|
||||
: TidalBaseRequest(service, network, parent),
|
||||
service_(service),
|
||||
network_(network),
|
||||
|
||||
@@ -27,9 +27,11 @@
|
||||
#include <QVariant>
|
||||
#include <QString>
|
||||
|
||||
#include "tidalbaserequest.h"
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/song.h"
|
||||
|
||||
#include "tidalbaserequest.h"
|
||||
|
||||
class QNetworkReply;
|
||||
class TidalService;
|
||||
class NetworkAccessManager;
|
||||
@@ -38,7 +40,7 @@ class TidalFavoriteRequest : public TidalBaseRequest {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit TidalFavoriteRequest(TidalService *service, NetworkAccessManager *network, QObject *parent = nullptr);
|
||||
explicit TidalFavoriteRequest(TidalService *service, SharedPtr<NetworkAccessManager> network, QObject *parent = nullptr);
|
||||
~TidalFavoriteRequest() override;
|
||||
|
||||
bool need_login() { return need_login_; }
|
||||
@@ -85,10 +87,9 @@ class TidalFavoriteRequest : public TidalBaseRequest {
|
||||
void RemoveFavoritesRequest(const FavoriteType type, const QString &id, const SongList &songs);
|
||||
|
||||
TidalService *service_;
|
||||
NetworkAccessManager *network_;
|
||||
SharedPtr<NetworkAccessManager> network_;
|
||||
QList <QNetworkReply*> replies_;
|
||||
bool need_login_;
|
||||
|
||||
};
|
||||
|
||||
#endif // TIDALFAVORITEREQUEST_H
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
#include <QTimer>
|
||||
|
||||
#include "core/logging.h"
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/networkaccessmanager.h"
|
||||
#include "core/song.h"
|
||||
#include "core/application.h"
|
||||
@@ -55,7 +56,7 @@ constexpr int TidalRequest::kMaxConcurrentAlbumSongsRequests = 3;
|
||||
constexpr int TidalRequest::kMaxConcurrentAlbumCoverRequests = 1;
|
||||
constexpr int TidalRequest::kFlushRequestsDelay = 200;
|
||||
|
||||
TidalRequest::TidalRequest(TidalService *service, TidalUrlHandler *url_handler, Application *app, NetworkAccessManager *network, QueryType query_type, QObject *parent)
|
||||
TidalRequest::TidalRequest(TidalService *service, TidalUrlHandler *url_handler, Application *app, SharedPtr<NetworkAccessManager> network, QueryType query_type, QObject *parent)
|
||||
: TidalBaseRequest(service, network, parent),
|
||||
service_(service),
|
||||
url_handler_(url_handler),
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
#include <QUrl>
|
||||
#include <QJsonObject>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/song.h"
|
||||
|
||||
#include "tidalbaserequest.h"
|
||||
@@ -52,7 +53,7 @@ class TidalRequest : public TidalBaseRequest {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit TidalRequest(TidalService *service, TidalUrlHandler *url_handler, Application *app, NetworkAccessManager *network, QueryType query_type, QObject *parent);
|
||||
explicit TidalRequest(TidalService *service, TidalUrlHandler *url_handler, Application *app, SharedPtr<NetworkAccessManager> network, QueryType query_type, QObject *parent);
|
||||
~TidalRequest() override;
|
||||
|
||||
void ReloadSettings();
|
||||
@@ -183,7 +184,7 @@ class TidalRequest : public TidalBaseRequest {
|
||||
TidalService *service_;
|
||||
TidalUrlHandler *url_handler_;
|
||||
Application *app_;
|
||||
NetworkAccessManager *network_;
|
||||
SharedPtr<NetworkAccessManager> network_;
|
||||
QTimer *timer_flush_requests_;
|
||||
|
||||
const QueryType query_type_;
|
||||
@@ -246,7 +247,6 @@ class TidalRequest : public TidalBaseRequest {
|
||||
bool need_login_;
|
||||
QList<QNetworkReply*> replies_;
|
||||
QList<QNetworkReply*> album_cover_replies_;
|
||||
|
||||
};
|
||||
|
||||
#endif // TIDALREQUEST_H
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <memory>
|
||||
#include <chrono>
|
||||
#include <memory>
|
||||
|
||||
#include <QObject>
|
||||
#include <QDesktopServices>
|
||||
@@ -42,6 +42,7 @@
|
||||
#include <QSortFilterProxyModel>
|
||||
|
||||
#include "core/logging.h"
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/application.h"
|
||||
#include "core/player.h"
|
||||
#include "core/networkaccessmanager.h"
|
||||
@@ -61,6 +62,9 @@
|
||||
#include "settings/settingsdialog.h"
|
||||
#include "settings/tidalsettingspage.h"
|
||||
|
||||
using std::make_shared;
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
const Song::Source TidalService::kSource = Song::Source::Tidal;
|
||||
|
||||
const char TidalService::kApiUrl[] = "https://api.tidalhifi.com/v1";
|
||||
@@ -82,8 +86,6 @@ constexpr char TidalService::kArtistsSongsFtsTable[] = "tidal_artists_songs_fts"
|
||||
constexpr char TidalService::kAlbumsSongsFtsTable[] = "tidal_albums_songs_fts";
|
||||
constexpr char TidalService::kSongsFtsTable[] = "tidal_songs_fts";
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
TidalService::TidalService(Application *app, QObject *parent)
|
||||
: InternetService(Song::Source::Tidal, "Tidal", "tidal", TidalSettingsPage::kSettingsGroup, SettingsDialog::Page::Tidal, app, parent),
|
||||
app_(app),
|
||||
@@ -126,15 +128,15 @@ TidalService::TidalService(Application *app, QObject *parent)
|
||||
|
||||
// Backends
|
||||
|
||||
artists_collection_backend_ = new CollectionBackend();
|
||||
artists_collection_backend_ = make_shared<CollectionBackend>();
|
||||
artists_collection_backend_->moveToThread(app_->database()->thread());
|
||||
artists_collection_backend_->Init(app_->database(), app->task_manager(), Song::Source::Tidal, kArtistsSongsTable, kArtistsSongsFtsTable);
|
||||
|
||||
albums_collection_backend_ = new CollectionBackend();
|
||||
albums_collection_backend_ = make_shared<CollectionBackend>();
|
||||
albums_collection_backend_->moveToThread(app_->database()->thread());
|
||||
albums_collection_backend_->Init(app_->database(), app->task_manager(), Song::Source::Tidal, kAlbumsSongsTable, kAlbumsSongsFtsTable);
|
||||
|
||||
songs_collection_backend_ = new CollectionBackend();
|
||||
songs_collection_backend_ = make_shared<CollectionBackend>();
|
||||
songs_collection_backend_->moveToThread(app_->database()->thread());
|
||||
songs_collection_backend_->Init(app_->database(), app->task_manager(), Song::Source::Tidal, kSongsTable, kSongsFtsTable);
|
||||
|
||||
@@ -186,13 +188,13 @@ TidalService::TidalService(Application *app, QObject *parent)
|
||||
|
||||
QObject::connect(favorite_request_, &TidalFavoriteRequest::RequestLogin, this, &TidalService::SendLogin);
|
||||
|
||||
QObject::connect(favorite_request_, &TidalFavoriteRequest::ArtistsAdded, artists_collection_backend_, &CollectionBackend::AddOrUpdateSongs);
|
||||
QObject::connect(favorite_request_, &TidalFavoriteRequest::AlbumsAdded, albums_collection_backend_, &CollectionBackend::AddOrUpdateSongs);
|
||||
QObject::connect(favorite_request_, &TidalFavoriteRequest::SongsAdded, songs_collection_backend_, &CollectionBackend::AddOrUpdateSongs);
|
||||
QObject::connect(favorite_request_, &TidalFavoriteRequest::ArtistsAdded, &*artists_collection_backend_, &CollectionBackend::AddOrUpdateSongs);
|
||||
QObject::connect(favorite_request_, &TidalFavoriteRequest::AlbumsAdded, &*albums_collection_backend_, &CollectionBackend::AddOrUpdateSongs);
|
||||
QObject::connect(favorite_request_, &TidalFavoriteRequest::SongsAdded, &*songs_collection_backend_, &CollectionBackend::AddOrUpdateSongs);
|
||||
|
||||
QObject::connect(favorite_request_, &TidalFavoriteRequest::ArtistsRemoved, artists_collection_backend_, &CollectionBackend::DeleteSongs);
|
||||
QObject::connect(favorite_request_, &TidalFavoriteRequest::AlbumsRemoved, albums_collection_backend_, &CollectionBackend::DeleteSongs);
|
||||
QObject::connect(favorite_request_, &TidalFavoriteRequest::SongsRemoved, songs_collection_backend_, &CollectionBackend::DeleteSongs);
|
||||
QObject::connect(favorite_request_, &TidalFavoriteRequest::ArtistsRemoved, &*artists_collection_backend_, &CollectionBackend::DeleteSongs);
|
||||
QObject::connect(favorite_request_, &TidalFavoriteRequest::AlbumsRemoved, &*albums_collection_backend_, &CollectionBackend::DeleteSongs);
|
||||
QObject::connect(favorite_request_, &TidalFavoriteRequest::SongsRemoved, &*songs_collection_backend_, &CollectionBackend::DeleteSongs);
|
||||
|
||||
TidalService::ReloadSettings();
|
||||
LoadSession();
|
||||
@@ -209,23 +211,19 @@ TidalService::~TidalService() {
|
||||
}
|
||||
|
||||
while (!stream_url_requests_.isEmpty()) {
|
||||
std::shared_ptr<TidalStreamURLRequest> stream_url_req = stream_url_requests_.take(stream_url_requests_.firstKey());
|
||||
QObject::disconnect(stream_url_req.get(), nullptr, this, nullptr);
|
||||
SharedPtr<TidalStreamURLRequest> stream_url_req = stream_url_requests_.take(stream_url_requests_.firstKey());
|
||||
QObject::disconnect(&*stream_url_req, nullptr, this, nullptr);
|
||||
}
|
||||
|
||||
artists_collection_backend_->deleteLater();
|
||||
albums_collection_backend_->deleteLater();
|
||||
songs_collection_backend_->deleteLater();
|
||||
|
||||
}
|
||||
|
||||
void TidalService::Exit() {
|
||||
|
||||
wait_for_exit_ << artists_collection_backend_ << albums_collection_backend_ << songs_collection_backend_;
|
||||
wait_for_exit_ << &*artists_collection_backend_ << &*albums_collection_backend_ << &*songs_collection_backend_;
|
||||
|
||||
QObject::connect(artists_collection_backend_, &CollectionBackend::ExitFinished, this, &TidalService::ExitReceived);
|
||||
QObject::connect(albums_collection_backend_, &CollectionBackend::ExitFinished, this, &TidalService::ExitReceived);
|
||||
QObject::connect(songs_collection_backend_, &CollectionBackend::ExitFinished, this, &TidalService::ExitReceived);
|
||||
QObject::connect(&*artists_collection_backend_, &CollectionBackend::ExitFinished, this, &TidalService::ExitReceived);
|
||||
QObject::connect(&*albums_collection_backend_, &CollectionBackend::ExitFinished, this, &TidalService::ExitReceived);
|
||||
QObject::connect(&*songs_collection_backend_, &CollectionBackend::ExitFinished, this, &TidalService::ExitReceived);
|
||||
|
||||
artists_collection_backend_->ExitAsync();
|
||||
albums_collection_backend_->ExitAsync();
|
||||
@@ -729,8 +727,8 @@ void TidalService::TryLogin() {
|
||||
void TidalService::ResetArtistsRequest() {
|
||||
|
||||
if (artists_request_) {
|
||||
QObject::disconnect(artists_request_.get(), nullptr, this, nullptr);
|
||||
QObject::disconnect(this, nullptr, artists_request_.get(), nullptr);
|
||||
QObject::disconnect(&*artists_request_, nullptr, this, nullptr);
|
||||
QObject::disconnect(this, nullptr, &*artists_request_, nullptr);
|
||||
artists_request_.reset();
|
||||
}
|
||||
|
||||
@@ -753,11 +751,11 @@ void TidalService::GetArtists() {
|
||||
|
||||
ResetArtistsRequest();
|
||||
artists_request_.reset(new TidalRequest(this, url_handler_, app_, network_, TidalBaseRequest::QueryType::Artists, this), [](TidalRequest *request) { request->deleteLater(); });
|
||||
QObject::connect(artists_request_.get(), &TidalRequest::RequestLogin, this, &TidalService::SendLogin);
|
||||
QObject::connect(artists_request_.get(), &TidalRequest::Results, this, &TidalService::ArtistsResultsReceived);
|
||||
QObject::connect(artists_request_.get(), &TidalRequest::UpdateStatus, this, &TidalService::ArtistsUpdateStatusReceived);
|
||||
QObject::connect(artists_request_.get(), &TidalRequest::UpdateProgress, this, &TidalService::ArtistsUpdateProgressReceived);
|
||||
QObject::connect(this, &TidalService::LoginComplete, artists_request_.get(), &TidalRequest::LoginComplete);
|
||||
QObject::connect(&*artists_request_, &TidalRequest::RequestLogin, this, &TidalService::SendLogin);
|
||||
QObject::connect(&*artists_request_, &TidalRequest::Results, this, &TidalService::ArtistsResultsReceived);
|
||||
QObject::connect(&*artists_request_, &TidalRequest::UpdateStatus, this, &TidalService::ArtistsUpdateStatusReceived);
|
||||
QObject::connect(&*artists_request_, &TidalRequest::UpdateProgress, this, &TidalService::ArtistsUpdateProgressReceived);
|
||||
QObject::connect(this, &TidalService::LoginComplete, &*artists_request_, &TidalRequest::LoginComplete);
|
||||
|
||||
artists_request_->Process();
|
||||
|
||||
@@ -784,8 +782,8 @@ void TidalService::ArtistsUpdateProgressReceived(const int id, const int progres
|
||||
void TidalService::ResetAlbumsRequest() {
|
||||
|
||||
if (albums_request_) {
|
||||
QObject::disconnect(albums_request_.get(), nullptr, this, nullptr);
|
||||
QObject::disconnect(this, nullptr, albums_request_.get(), nullptr);
|
||||
QObject::disconnect(&*albums_request_, nullptr, this, nullptr);
|
||||
QObject::disconnect(this, nullptr, &*albums_request_, nullptr);
|
||||
albums_request_.reset();
|
||||
}
|
||||
|
||||
@@ -808,11 +806,11 @@ void TidalService::GetAlbums() {
|
||||
|
||||
ResetAlbumsRequest();
|
||||
albums_request_.reset(new TidalRequest(this, url_handler_, app_, network_, TidalBaseRequest::QueryType::Albums, this), [](TidalRequest *request) { request->deleteLater(); });
|
||||
QObject::connect(albums_request_.get(), &TidalRequest::RequestLogin, this, &TidalService::SendLogin);
|
||||
QObject::connect(albums_request_.get(), &TidalRequest::Results, this, &TidalService::AlbumsResultsReceived);
|
||||
QObject::connect(albums_request_.get(), &TidalRequest::UpdateStatus, this, &TidalService::AlbumsUpdateStatusReceived);
|
||||
QObject::connect(albums_request_.get(), &TidalRequest::UpdateProgress, this, &TidalService::AlbumsUpdateProgressReceived);
|
||||
QObject::connect(this, &TidalService::LoginComplete, albums_request_.get(), &TidalRequest::LoginComplete);
|
||||
QObject::connect(&*albums_request_, &TidalRequest::RequestLogin, this, &TidalService::SendLogin);
|
||||
QObject::connect(&*albums_request_, &TidalRequest::Results, this, &TidalService::AlbumsResultsReceived);
|
||||
QObject::connect(&*albums_request_, &TidalRequest::UpdateStatus, this, &TidalService::AlbumsUpdateStatusReceived);
|
||||
QObject::connect(&*albums_request_, &TidalRequest::UpdateProgress, this, &TidalService::AlbumsUpdateProgressReceived);
|
||||
QObject::connect(this, &TidalService::LoginComplete, &*albums_request_, &TidalRequest::LoginComplete);
|
||||
|
||||
albums_request_->Process();
|
||||
|
||||
@@ -839,8 +837,8 @@ void TidalService::AlbumsUpdateProgressReceived(const int id, const int progress
|
||||
void TidalService::ResetSongsRequest() {
|
||||
|
||||
if (songs_request_) {
|
||||
QObject::disconnect(songs_request_.get(), nullptr, this, nullptr);
|
||||
QObject::disconnect(this, nullptr, songs_request_.get(), nullptr);
|
||||
QObject::disconnect(&*songs_request_, nullptr, this, nullptr);
|
||||
QObject::disconnect(this, nullptr, &*songs_request_, nullptr);
|
||||
songs_request_.reset();
|
||||
}
|
||||
|
||||
@@ -863,11 +861,11 @@ void TidalService::GetSongs() {
|
||||
|
||||
ResetSongsRequest();
|
||||
songs_request_.reset(new TidalRequest(this, url_handler_, app_, network_, TidalBaseRequest::QueryType::Songs, this), [](TidalRequest *request) { request->deleteLater(); });
|
||||
QObject::connect(songs_request_.get(), &TidalRequest::RequestLogin, this, &TidalService::SendLogin);
|
||||
QObject::connect(songs_request_.get(), &TidalRequest::Results, this, &TidalService::SongsResultsReceived);
|
||||
QObject::connect(songs_request_.get(), &TidalRequest::UpdateStatus, this, &TidalService::SongsUpdateStatusReceived);
|
||||
QObject::connect(songs_request_.get(), &TidalRequest::UpdateProgress, this, &TidalService::SongsUpdateProgressReceived);
|
||||
QObject::connect(this, &TidalService::LoginComplete, songs_request_.get(), &TidalRequest::LoginComplete);
|
||||
QObject::connect(&*songs_request_, &TidalRequest::RequestLogin, this, &TidalService::SendLogin);
|
||||
QObject::connect(&*songs_request_, &TidalRequest::Results, this, &TidalService::SongsResultsReceived);
|
||||
QObject::connect(&*songs_request_, &TidalRequest::UpdateStatus, this, &TidalService::SongsUpdateStatusReceived);
|
||||
QObject::connect(&*songs_request_, &TidalRequest::UpdateProgress, this, &TidalService::SongsUpdateProgressReceived);
|
||||
QObject::connect(this, &TidalService::LoginComplete, &*songs_request_, &TidalRequest::LoginComplete);
|
||||
|
||||
songs_request_->Process();
|
||||
|
||||
@@ -955,11 +953,11 @@ void TidalService::SendSearch() {
|
||||
|
||||
search_request_.reset(new TidalRequest(this, url_handler_, app_, network_, query_type, this), [](TidalRequest *request) { request->deleteLater(); });
|
||||
|
||||
QObject::connect(search_request_.get(), &TidalRequest::RequestLogin, this, &TidalService::SendLogin);
|
||||
QObject::connect(search_request_.get(), &TidalRequest::Results, this, &TidalService::SearchResultsReceived);
|
||||
QObject::connect(search_request_.get(), &TidalRequest::UpdateStatus, this, &TidalService::SearchUpdateStatus);
|
||||
QObject::connect(search_request_.get(), &TidalRequest::UpdateProgress, this, &TidalService::SearchUpdateProgress);
|
||||
QObject::connect(this, &TidalService::LoginComplete, search_request_.get(), &TidalRequest::LoginComplete);
|
||||
QObject::connect(&*search_request_, &TidalRequest::RequestLogin, this, &TidalService::SendLogin);
|
||||
QObject::connect(&*search_request_, &TidalRequest::Results, this, &TidalService::SearchResultsReceived);
|
||||
QObject::connect(&*search_request_, &TidalRequest::UpdateStatus, this, &TidalService::SearchUpdateStatus);
|
||||
QObject::connect(&*search_request_, &TidalRequest::UpdateProgress, this, &TidalService::SearchUpdateProgress);
|
||||
QObject::connect(this, &TidalService::LoginComplete, &*search_request_, &TidalRequest::LoginComplete);
|
||||
|
||||
search_request_->Search(search_id_, search_text_);
|
||||
search_request_->Process();
|
||||
@@ -988,14 +986,14 @@ uint TidalService::GetStreamURL(const QUrl &url, QString &error) {
|
||||
|
||||
uint id = 0;
|
||||
while (id == 0) id = ++next_stream_url_request_id_;
|
||||
std::shared_ptr<TidalStreamURLRequest> stream_url_req;
|
||||
SharedPtr<TidalStreamURLRequest> stream_url_req;
|
||||
stream_url_req.reset(new TidalStreamURLRequest(this, network_, url, id), [](TidalStreamURLRequest *request) { request->deleteLater(); });
|
||||
stream_url_requests_.insert(id, stream_url_req);
|
||||
|
||||
QObject::connect(stream_url_req.get(), &TidalStreamURLRequest::TryLogin, this, &TidalService::TryLogin);
|
||||
QObject::connect(stream_url_req.get(), &TidalStreamURLRequest::StreamURLFailure, this, &TidalService::HandleStreamURLFailure);
|
||||
QObject::connect(stream_url_req.get(), &TidalStreamURLRequest::StreamURLSuccess, this, &TidalService::HandleStreamURLSuccess);
|
||||
QObject::connect(this, &TidalService::LoginComplete, stream_url_req.get(), &TidalStreamURLRequest::LoginComplete);
|
||||
QObject::connect(&*stream_url_req, &TidalStreamURLRequest::TryLogin, this, &TidalService::TryLogin);
|
||||
QObject::connect(&*stream_url_req, &TidalStreamURLRequest::StreamURLFailure, this, &TidalService::HandleStreamURLFailure);
|
||||
QObject::connect(&*stream_url_req, &TidalStreamURLRequest::StreamURLSuccess, this, &TidalService::HandleStreamURLSuccess);
|
||||
QObject::connect(this, &TidalService::LoginComplete, &*stream_url_req, &TidalStreamURLRequest::LoginComplete);
|
||||
|
||||
stream_url_req->Process();
|
||||
|
||||
|
||||
@@ -22,8 +22,6 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <QtGlobal>
|
||||
#include <QObject>
|
||||
#include <QPair>
|
||||
@@ -38,6 +36,7 @@
|
||||
#include <QDateTime>
|
||||
#include <QSslError>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/song.h"
|
||||
#include "internet/internetservice.h"
|
||||
#include "internet/internetsearchview.h"
|
||||
@@ -60,7 +59,7 @@ class TidalService : public InternetService {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit TidalService(Application *app, QObject *parent);
|
||||
explicit TidalService(Application *app, QObject *parent = nullptr);
|
||||
~TidalService() override;
|
||||
|
||||
static const Song::Source kSource;
|
||||
@@ -104,9 +103,9 @@ class TidalService : public InternetService {
|
||||
|
||||
uint GetStreamURL(const QUrl &url, QString &error);
|
||||
|
||||
CollectionBackend *artists_collection_backend() override { return artists_collection_backend_; }
|
||||
CollectionBackend *albums_collection_backend() override { return albums_collection_backend_; }
|
||||
CollectionBackend *songs_collection_backend() override { return songs_collection_backend_; }
|
||||
SharedPtr<CollectionBackend> artists_collection_backend() override { return artists_collection_backend_; }
|
||||
SharedPtr<CollectionBackend> albums_collection_backend() override { return albums_collection_backend_; }
|
||||
SharedPtr<CollectionBackend> songs_collection_backend() override { return songs_collection_backend_; }
|
||||
|
||||
CollectionModel *artists_collection_model() override { return artists_collection_model_; }
|
||||
CollectionModel *albums_collection_model() override { return albums_collection_model_; }
|
||||
@@ -177,12 +176,12 @@ class TidalService : public InternetService {
|
||||
static const char kSongsFtsTable[];
|
||||
|
||||
Application *app_;
|
||||
NetworkAccessManager *network_;
|
||||
SharedPtr<NetworkAccessManager> network_;
|
||||
TidalUrlHandler *url_handler_;
|
||||
|
||||
CollectionBackend *artists_collection_backend_;
|
||||
CollectionBackend *albums_collection_backend_;
|
||||
CollectionBackend *songs_collection_backend_;
|
||||
SharedPtr<CollectionBackend> artists_collection_backend_;
|
||||
SharedPtr<CollectionBackend> albums_collection_backend_;
|
||||
SharedPtr<CollectionBackend> songs_collection_backend_;
|
||||
|
||||
CollectionModel *artists_collection_model_;
|
||||
CollectionModel *albums_collection_model_;
|
||||
@@ -196,10 +195,10 @@ class TidalService : public InternetService {
|
||||
QTimer *timer_login_attempt_;
|
||||
QTimer *timer_refresh_login_;
|
||||
|
||||
std::shared_ptr<TidalRequest> artists_request_;
|
||||
std::shared_ptr<TidalRequest> albums_request_;
|
||||
std::shared_ptr<TidalRequest> songs_request_;
|
||||
std::shared_ptr<TidalRequest> search_request_;
|
||||
SharedPtr<TidalRequest> artists_request_;
|
||||
SharedPtr<TidalRequest> albums_request_;
|
||||
SharedPtr<TidalRequest> songs_request_;
|
||||
SharedPtr<TidalRequest> search_request_;
|
||||
TidalFavoriteRequest *favorite_request_;
|
||||
|
||||
bool enabled_;
|
||||
@@ -240,13 +239,14 @@ class TidalService : public InternetService {
|
||||
QString code_challenge_;
|
||||
|
||||
uint next_stream_url_request_id_;
|
||||
QMap<uint, std::shared_ptr<TidalStreamURLRequest>> stream_url_requests_;
|
||||
QMap<uint, SharedPtr<TidalStreamURLRequest>> stream_url_requests_;
|
||||
|
||||
QStringList login_errors_;
|
||||
|
||||
QList<QObject*> wait_for_exit_;
|
||||
QList<QNetworkReply*> replies_;
|
||||
|
||||
};
|
||||
|
||||
using TidalServicePtr = SharedPtr<TidalService>;
|
||||
|
||||
#endif // TIDALSERVICE_H
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
#include <QXmlStreamReader>
|
||||
|
||||
#include "core/logging.h"
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/networkaccessmanager.h"
|
||||
#include "core/song.h"
|
||||
#include "settings/tidalsettingspage.h"
|
||||
@@ -41,7 +42,7 @@
|
||||
#include "tidalbaserequest.h"
|
||||
#include "tidalstreamurlrequest.h"
|
||||
|
||||
TidalStreamURLRequest::TidalStreamURLRequest(TidalService *service, NetworkAccessManager *network, const QUrl &media_url, const uint id, QObject *parent)
|
||||
TidalStreamURLRequest::TidalStreamURLRequest(TidalService *service, SharedPtr<NetworkAccessManager> network, const QUrl &media_url, const uint id, QObject *parent)
|
||||
: TidalBaseRequest(service, network, parent),
|
||||
service_(service),
|
||||
reply_(nullptr),
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include <QStringList>
|
||||
#include <QUrl>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/song.h"
|
||||
#include "tidalservice.h"
|
||||
#include "tidalbaserequest.h"
|
||||
@@ -41,7 +42,7 @@ class TidalStreamURLRequest : public TidalBaseRequest {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit TidalStreamURLRequest(TidalService *service, NetworkAccessManager *network, const QUrl &media_url, const uint id, QObject *parent = nullptr);
|
||||
explicit TidalStreamURLRequest(TidalService *service, SharedPtr<NetworkAccessManager> network, const QUrl &media_url, const uint id, QObject *parent = nullptr);
|
||||
~TidalStreamURLRequest() override;
|
||||
|
||||
void GetStreamURL();
|
||||
@@ -78,7 +79,6 @@ class TidalStreamURLRequest : public TidalBaseRequest {
|
||||
int tries_;
|
||||
bool need_login_;
|
||||
QStringList errors_;
|
||||
|
||||
};
|
||||
|
||||
#endif // TIDALSTREAMURLREQUEST_H
|
||||
|
||||
@@ -34,8 +34,8 @@ TidalUrlHandler::TidalUrlHandler(Application *app, TidalService *service)
|
||||
app_(app),
|
||||
service_(service) {
|
||||
|
||||
QObject::connect(service, &TidalService::StreamURLFailure, this, &TidalUrlHandler::GetStreamURLFailure);
|
||||
QObject::connect(service, &TidalService::StreamURLSuccess, this, &TidalUrlHandler::GetStreamURLSuccess);
|
||||
QObject::connect(&*service, &TidalService::StreamURLFailure, this, &TidalUrlHandler::GetStreamURLFailure);
|
||||
QObject::connect(&*service, &TidalService::StreamURLSuccess, this, &TidalUrlHandler::GetStreamURLSuccess);
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user