mirror of
https://github.com/strawberrymusicplayer/strawberry
synced 2025-01-30 00:55:33 +01:00
Queue tidal requests
This commit is contained in:
parent
2b7d48ce77
commit
f26f932fd7
@ -48,7 +48,9 @@ class InternetCollectionViewContainer : public QWidget {
|
|||||||
QWidget *internetcollection_page() const { return ui_->internetcollection_page; }
|
QWidget *internetcollection_page() const { return ui_->internetcollection_page; }
|
||||||
InternetCollectionView *view() const { return ui_->view; }
|
InternetCollectionView *view() const { return ui_->view; }
|
||||||
CollectionFilterWidget *filter() const { return ui_->filter; }
|
CollectionFilterWidget *filter() const { return ui_->filter; }
|
||||||
QPushButton *refresh() const { return ui_->refresh; }
|
QPushButton *button_refresh() const { return ui_->refresh; }
|
||||||
|
QPushButton *button_close() const { return ui_->close; }
|
||||||
|
QPushButton *button_abort() const { return ui_->abort; }
|
||||||
QLabel *status() const { return ui_->status; }
|
QLabel *status() const { return ui_->status; }
|
||||||
QProgressBar *progressbar() const { return ui_->progressbar; }
|
QProgressBar *progressbar() const { return ui_->progressbar; }
|
||||||
void ReloadSettings() { view()->ReloadSettings(); }
|
void ReloadSettings() { view()->ReloadSettings(); }
|
||||||
|
@ -69,6 +69,37 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="layout_buttons">
|
||||||
|
<item>
|
||||||
|
<spacer name="spacer_buttons">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="close">
|
||||||
|
<property name="text">
|
||||||
|
<string>Close</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="abort">
|
||||||
|
<property name="text">
|
||||||
|
<string>Abort</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<spacer name="verticalSpacer">
|
<spacer name="verticalSpacer">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
|
@ -67,6 +67,9 @@ class InternetService : public QObject {
|
|||||||
virtual void GetArtists() = 0;
|
virtual void GetArtists() = 0;
|
||||||
virtual void GetAlbums() = 0;
|
virtual void GetAlbums() = 0;
|
||||||
virtual void GetSongs() = 0;
|
virtual void GetSongs() = 0;
|
||||||
|
virtual void ResetArtistsRequest() = 0;
|
||||||
|
virtual void ResetAlbumsRequest() = 0;
|
||||||
|
virtual void ResetSongsRequest() = 0;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void Login();
|
void Login();
|
||||||
|
@ -55,9 +55,11 @@ InternetTabsView::InternetTabsView(Application *app, InternetService *service, I
|
|||||||
ui_->artists_collection->filter()->SetCollectionModel(service_->artists_collection_model());
|
ui_->artists_collection->filter()->SetCollectionModel(service_->artists_collection_model());
|
||||||
|
|
||||||
connect(ui_->artists_collection->view(), SIGNAL(GetSongs()), SLOT(GetArtists()));
|
connect(ui_->artists_collection->view(), SIGNAL(GetSongs()), SLOT(GetArtists()));
|
||||||
connect(ui_->artists_collection->refresh(), SIGNAL(clicked()), SLOT(GetArtists()));
|
connect(ui_->artists_collection->button_refresh(), SIGNAL(clicked()), SLOT(GetArtists()));
|
||||||
|
connect(ui_->artists_collection->button_close(), SIGNAL(clicked()), SLOT(AbortGetArtists()));
|
||||||
|
connect(ui_->artists_collection->button_abort(), SIGNAL(clicked()), SLOT(AbortGetArtists()));
|
||||||
connect(service_, SIGNAL(ArtistsResults(SongList)), SLOT(ArtistsFinished(SongList)));
|
connect(service_, SIGNAL(ArtistsResults(SongList)), SLOT(ArtistsFinished(SongList)));
|
||||||
connect(service_, SIGNAL(ArtistsError(QString)), ui_->artists_collection->status(), SLOT(setText(QString)));
|
connect(service_, SIGNAL(ArtistsError(QString)), SLOT(ArtistsError(QString)));
|
||||||
connect(service_, SIGNAL(ArtistsUpdateStatus(QString)), ui_->artists_collection->status(), SLOT(setText(QString)));
|
connect(service_, SIGNAL(ArtistsUpdateStatus(QString)), ui_->artists_collection->status(), SLOT(setText(QString)));
|
||||||
connect(service_, SIGNAL(ArtistsProgressSetMaximum(int)), ui_->artists_collection->progressbar(), SLOT(setMaximum(int)));
|
connect(service_, SIGNAL(ArtistsProgressSetMaximum(int)), ui_->artists_collection->progressbar(), SLOT(setMaximum(int)));
|
||||||
connect(service_, SIGNAL(ArtistsUpdateProgress(int)), ui_->artists_collection->progressbar(), SLOT(setValue(int)));
|
connect(service_, SIGNAL(ArtistsUpdateProgress(int)), ui_->artists_collection->progressbar(), SLOT(setValue(int)));
|
||||||
@ -81,9 +83,11 @@ InternetTabsView::InternetTabsView(Application *app, InternetService *service, I
|
|||||||
ui_->albums_collection->filter()->SetCollectionModel(service_->albums_collection_model());
|
ui_->albums_collection->filter()->SetCollectionModel(service_->albums_collection_model());
|
||||||
|
|
||||||
connect(ui_->albums_collection->view(), SIGNAL(GetSongs()), SLOT(GetAlbums()));
|
connect(ui_->albums_collection->view(), SIGNAL(GetSongs()), SLOT(GetAlbums()));
|
||||||
connect(ui_->albums_collection->refresh(), SIGNAL(clicked()), SLOT(GetAlbums()));
|
connect(ui_->albums_collection->button_refresh(), SIGNAL(clicked()), SLOT(GetAlbums()));
|
||||||
|
connect(ui_->albums_collection->button_close(), SIGNAL(clicked()), SLOT(AbortGetAlbums()));
|
||||||
|
connect(ui_->albums_collection->button_abort(), SIGNAL(clicked()), SLOT(AbortGetAlbums()));
|
||||||
connect(service_, SIGNAL(AlbumsResults(SongList)), SLOT(AlbumsFinished(SongList)));
|
connect(service_, SIGNAL(AlbumsResults(SongList)), SLOT(AlbumsFinished(SongList)));
|
||||||
connect(service_, SIGNAL(AlbumsError(QString)), ui_->albums_collection->status(), SLOT(setText(QString)));
|
connect(service_, SIGNAL(AlbumsError(QString)), SLOT(AlbumsError(QString)));
|
||||||
connect(service_, SIGNAL(AlbumsUpdateStatus(QString)), ui_->albums_collection->status(), SLOT(setText(QString)));
|
connect(service_, SIGNAL(AlbumsUpdateStatus(QString)), ui_->albums_collection->status(), SLOT(setText(QString)));
|
||||||
connect(service_, SIGNAL(AlbumsProgressSetMaximum(int)), ui_->albums_collection->progressbar(), SLOT(setMaximum(int)));
|
connect(service_, SIGNAL(AlbumsProgressSetMaximum(int)), ui_->albums_collection->progressbar(), SLOT(setMaximum(int)));
|
||||||
connect(service_, SIGNAL(AlbumsUpdateProgress(int)), ui_->albums_collection->progressbar(), SLOT(setValue(int)));
|
connect(service_, SIGNAL(AlbumsUpdateProgress(int)), ui_->albums_collection->progressbar(), SLOT(setValue(int)));
|
||||||
@ -107,9 +111,11 @@ InternetTabsView::InternetTabsView(Application *app, InternetService *service, I
|
|||||||
ui_->songs_collection->filter()->SetCollectionModel(service_->songs_collection_model());
|
ui_->songs_collection->filter()->SetCollectionModel(service_->songs_collection_model());
|
||||||
|
|
||||||
connect(ui_->songs_collection->view(), SIGNAL(GetSongs()), SLOT(GetSongs()));
|
connect(ui_->songs_collection->view(), SIGNAL(GetSongs()), SLOT(GetSongs()));
|
||||||
connect(ui_->songs_collection->refresh(), SIGNAL(clicked()), SLOT(GetSongs()));
|
connect(ui_->songs_collection->button_refresh(), SIGNAL(clicked()), SLOT(GetSongs()));
|
||||||
|
connect(ui_->songs_collection->button_close(), SIGNAL(clicked()), SLOT(AbortGetSongs()));
|
||||||
|
connect(ui_->songs_collection->button_abort(), SIGNAL(clicked()), SLOT(AbortGetSongs()));
|
||||||
connect(service_, SIGNAL(SongsResults(SongList)), SLOT(SongsFinished(SongList)));
|
connect(service_, SIGNAL(SongsResults(SongList)), SLOT(SongsFinished(SongList)));
|
||||||
connect(service_, SIGNAL(SongsError(QString)), ui_->songs_collection->status(), SLOT(setText(QString)));
|
connect(service_, SIGNAL(SongsError(QString)), SLOT(SongsError(QString)));
|
||||||
connect(service_, SIGNAL(SongsUpdateStatus(QString)), ui_->songs_collection->status(), SLOT(setText(QString)));
|
connect(service_, SIGNAL(SongsUpdateStatus(QString)), ui_->songs_collection->status(), SLOT(setText(QString)));
|
||||||
connect(service_, SIGNAL(SongsProgressSetMaximum(int)), ui_->songs_collection->progressbar(), SLOT(setMaximum(int)));
|
connect(service_, SIGNAL(SongsProgressSetMaximum(int)), ui_->songs_collection->progressbar(), SLOT(setMaximum(int)));
|
||||||
connect(service_, SIGNAL(SongsUpdateProgress(int)), ui_->songs_collection->progressbar(), SLOT(setValue(int)));
|
connect(service_, SIGNAL(SongsUpdateProgress(int)), ui_->songs_collection->progressbar(), SLOT(setValue(int)));
|
||||||
@ -129,7 +135,6 @@ InternetTabsView::InternetTabsView(Application *app, InternetService *service, I
|
|||||||
s.beginGroup(settings_group_);
|
s.beginGroup(settings_group_);
|
||||||
QString tab = s.value("tab", "artists").toString().toLower();
|
QString tab = s.value("tab", "artists").toString().toLower();
|
||||||
s.endGroup();
|
s.endGroup();
|
||||||
qLog(Debug) << tab;
|
|
||||||
|
|
||||||
if (tab == "artists") {
|
if (tab == "artists") {
|
||||||
ui_->tabs->setCurrentWidget(ui_->artists);
|
ui_->tabs->setCurrentWidget(ui_->artists);
|
||||||
@ -165,12 +170,34 @@ void InternetTabsView::contextMenuEvent(QContextMenuEvent *e) {
|
|||||||
|
|
||||||
void InternetTabsView::GetArtists() {
|
void InternetTabsView::GetArtists() {
|
||||||
|
|
||||||
ui_->artists_collection->stacked()->setCurrentWidget(ui_->artists_collection->help_page());
|
ui_->artists_collection->status()->clear();
|
||||||
ui_->artists_collection->progressbar()->show();
|
ui_->artists_collection->progressbar()->show();
|
||||||
|
ui_->artists_collection->button_abort()->show();
|
||||||
|
ui_->artists_collection->button_close()->hide();
|
||||||
|
ui_->artists_collection->stacked()->setCurrentWidget(ui_->artists_collection->help_page());
|
||||||
service_->GetArtists();
|
service_->GetArtists();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void InternetTabsView::AbortGetArtists() {
|
||||||
|
|
||||||
|
service_->ResetArtistsRequest();
|
||||||
|
ui_->artists_collection->progressbar()->setValue(0);
|
||||||
|
ui_->artists_collection->status()->clear();
|
||||||
|
ui_->artists_collection->stacked()->setCurrentWidget(ui_->artists_collection->internetcollection_page());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void InternetTabsView::ArtistsError(QString error) {
|
||||||
|
|
||||||
|
ui_->artists_collection->status()->setText(error);
|
||||||
|
ui_->artists_collection->progressbar()->setValue(0);
|
||||||
|
ui_->artists_collection->progressbar()->hide();
|
||||||
|
ui_->artists_collection->button_abort()->hide();
|
||||||
|
ui_->artists_collection->button_close()->show();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void InternetTabsView::ArtistsFinished(SongList songs) {
|
void InternetTabsView::ArtistsFinished(SongList songs) {
|
||||||
|
|
||||||
service_->artists_collection_backend()->DeleteAll();
|
service_->artists_collection_backend()->DeleteAll();
|
||||||
@ -182,11 +209,34 @@ void InternetTabsView::ArtistsFinished(SongList songs) {
|
|||||||
|
|
||||||
void InternetTabsView::GetAlbums() {
|
void InternetTabsView::GetAlbums() {
|
||||||
|
|
||||||
|
ui_->albums_collection->status()->clear();
|
||||||
|
ui_->albums_collection->progressbar()->show();
|
||||||
|
ui_->albums_collection->button_abort()->show();
|
||||||
|
ui_->albums_collection->button_close()->hide();
|
||||||
ui_->albums_collection->stacked()->setCurrentWidget(ui_->albums_collection->help_page());
|
ui_->albums_collection->stacked()->setCurrentWidget(ui_->albums_collection->help_page());
|
||||||
service_->GetAlbums();
|
service_->GetAlbums();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void InternetTabsView::AbortGetAlbums() {
|
||||||
|
|
||||||
|
service_->ResetAlbumsRequest();
|
||||||
|
ui_->albums_collection->progressbar()->setValue(0);
|
||||||
|
ui_->albums_collection->status()->clear();
|
||||||
|
ui_->albums_collection->stacked()->setCurrentWidget(ui_->albums_collection->internetcollection_page());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void InternetTabsView::AlbumsError(QString error) {
|
||||||
|
|
||||||
|
ui_->albums_collection->status()->setText(error);
|
||||||
|
ui_->albums_collection->progressbar()->setValue(0);
|
||||||
|
ui_->albums_collection->progressbar()->hide();
|
||||||
|
ui_->albums_collection->button_abort()->hide();
|
||||||
|
ui_->albums_collection->button_close()->show();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void InternetTabsView::AlbumsFinished(SongList songs) {
|
void InternetTabsView::AlbumsFinished(SongList songs) {
|
||||||
|
|
||||||
service_->albums_collection_backend()->DeleteAll();
|
service_->albums_collection_backend()->DeleteAll();
|
||||||
@ -198,11 +248,34 @@ void InternetTabsView::AlbumsFinished(SongList songs) {
|
|||||||
|
|
||||||
void InternetTabsView::GetSongs() {
|
void InternetTabsView::GetSongs() {
|
||||||
|
|
||||||
|
ui_->songs_collection->status()->clear();
|
||||||
|
ui_->songs_collection->progressbar()->show();
|
||||||
|
ui_->songs_collection->button_abort()->show();
|
||||||
|
ui_->songs_collection->button_close()->hide();
|
||||||
ui_->songs_collection->stacked()->setCurrentWidget(ui_->songs_collection->help_page());
|
ui_->songs_collection->stacked()->setCurrentWidget(ui_->songs_collection->help_page());
|
||||||
service_->GetSongs();
|
service_->GetSongs();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void InternetTabsView::AbortGetSongs() {
|
||||||
|
|
||||||
|
service_->ResetSongsRequest();
|
||||||
|
ui_->songs_collection->progressbar()->setValue(0);
|
||||||
|
ui_->songs_collection->status()->clear();
|
||||||
|
ui_->songs_collection->stacked()->setCurrentWidget(ui_->songs_collection->internetcollection_page());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void InternetTabsView::SongsError(QString error) {
|
||||||
|
|
||||||
|
ui_->songs_collection->status()->setText(error);
|
||||||
|
ui_->songs_collection->progressbar()->setValue(0);
|
||||||
|
ui_->songs_collection->progressbar()->hide();
|
||||||
|
ui_->songs_collection->button_abort()->hide();
|
||||||
|
ui_->songs_collection->button_close()->show();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void InternetTabsView::SongsFinished(SongList songs) {
|
void InternetTabsView::SongsFinished(SongList songs) {
|
||||||
|
|
||||||
service_->songs_collection_backend()->DeleteAll();
|
service_->songs_collection_backend()->DeleteAll();
|
||||||
|
@ -59,6 +59,12 @@ class InternetTabsView : public QWidget {
|
|||||||
void GetArtists();
|
void GetArtists();
|
||||||
void GetAlbums();
|
void GetAlbums();
|
||||||
void GetSongs();
|
void GetSongs();
|
||||||
|
void AbortGetArtists();
|
||||||
|
void AbortGetAlbums();
|
||||||
|
void AbortGetSongs();
|
||||||
|
void ArtistsError(QString error);
|
||||||
|
void AlbumsError(QString error);
|
||||||
|
void SongsError(QString error);
|
||||||
void ArtistsFinished(SongList songs);
|
void ArtistsFinished(SongList songs);
|
||||||
void AlbumsFinished(SongList songs);
|
void AlbumsFinished(SongList songs);
|
||||||
void SongsFinished(SongList songs);
|
void SongsFinished(SongList songs);
|
||||||
|
@ -11,25 +11,10 @@
|
|||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<property name="spacing">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="leftMargin">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="topMargin">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="rightMargin">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="bottomMargin">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<item>
|
<item>
|
||||||
<widget class="QTabWidget" name="tabs">
|
<widget class="QTabWidget" name="tabs">
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>3</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="artists">
|
<widget class="QWidget" name="artists">
|
||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
@ -102,6 +87,18 @@
|
|||||||
<string>Search</string>
|
<string>Search</string>
|
||||||
</attribute>
|
</attribute>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<widget class="InternetSearchView" name="search_view" native="true"/>
|
<widget class="InternetSearchView" name="search_view" native="true"/>
|
||||||
</item>
|
</item>
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -29,6 +29,7 @@
|
|||||||
#include <QHash>
|
#include <QHash>
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
#include <QMultiMap>
|
#include <QMultiMap>
|
||||||
|
#include <QQueue>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
#include <QNetworkReply>
|
#include <QNetworkReply>
|
||||||
@ -71,41 +72,100 @@ class TidalRequest : public TidalBaseRequest {
|
|||||||
void UpdateProgress(int max);
|
void UpdateProgress(int max);
|
||||||
void StreamURLFinished(const QUrl original_url, const QUrl url, const Song::FileType, QString error = QString());
|
void StreamURLFinished(const QUrl original_url, const QUrl url, const Song::FileType, QString error = QString());
|
||||||
|
|
||||||
public slots:
|
|
||||||
void GetArtists(const int offset = 0);
|
|
||||||
void GetAlbums(const int offset = 0);
|
|
||||||
void GetSongs(const int offset = 0);
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void LoginComplete(bool success, QString error = QString());
|
void LoginComplete(bool success, QString error = QString());
|
||||||
void ArtistsReceived(QNetworkReply *reply, const int limit_requested = 0, const int offset_requested = 0);
|
|
||||||
void AlbumsReceived(QNetworkReply *reply, const int artist_id = 0, const int limit_requested = 0, const int offset_requested = 0);
|
void ArtistsReplyReceived(QNetworkReply *reply, const int limit_requested, const int offset_requested);
|
||||||
void SongsReceived(QNetworkReply *reply, const int album_id);
|
|
||||||
|
void AlbumsReplyReceived(QNetworkReply *reply, const int limit_requested, const int offset_requested);
|
||||||
|
void AlbumsReceived(QNetworkReply *reply, const int artist_id, const int limit_requested, const int offset_requested);
|
||||||
|
|
||||||
|
void SongsReplyReceived(QNetworkReply *reply, const int limit_requested, const int offset_requested);
|
||||||
|
void SongsReceived(QNetworkReply *reply, const int artist_id, const int album_id, const int limit_requested, const int offset_requested, const QString album_artist = QString());
|
||||||
|
|
||||||
|
void ArtistAlbumsReplyReceived(QNetworkReply *reply, const int artist_id, const int offset_requested);
|
||||||
|
void AlbumSongsReplyReceived(QNetworkReply *reply, const int artist_id, const int album_id, const int offset_requested, const QString album_artist);
|
||||||
void AlbumCoverReceived(QNetworkReply *reply, const int album_id, const QUrl url);
|
void AlbumCoverReceived(QNetworkReply *reply, const int album_id, const QUrl url);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef QPair<QString, QString> Param;
|
typedef QPair<QString, QString> Param;
|
||||||
typedef QList<Param> ParamList;
|
typedef QList<Param> ParamList;
|
||||||
|
|
||||||
|
struct Request {
|
||||||
|
//Request(const int artist_id = 0, const int limit = 0, const int offset = 0) :
|
||||||
|
//artist_id_(artist_id), limit_(limit), offset_(offset) {}
|
||||||
|
int artist_id = 0;
|
||||||
|
int album_id = 0;
|
||||||
|
int song_id = 0;
|
||||||
|
int offset = 0;
|
||||||
|
int limit = 0;
|
||||||
|
QString album_artist;
|
||||||
|
};
|
||||||
|
struct AlbumCoverRequest {
|
||||||
|
int artist_id = 0;
|
||||||
|
int album_id = 0;
|
||||||
|
QUrl url;
|
||||||
|
};
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
struct AlbumSongsRequest {
|
||||||
|
AlbumSongsRequest(const int artist_id = 0, const int album_id = 0, const QString &album_artist = QString()) :
|
||||||
|
artist_id_(artist_id), album_id_(album_id), album_artist_(album_artist) {}
|
||||||
|
int artist_id_;
|
||||||
|
int album_id_;
|
||||||
|
QString album_artist_;
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
const bool IsQuery() { return (type_ == QueryType_Artists || type_ == QueryType_Albums || type_ == QueryType_Songs); }
|
const bool IsQuery() { return (type_ == QueryType_Artists || type_ == QueryType_Albums || type_ == QueryType_Songs); }
|
||||||
const bool IsSearch() { return (type_ == QueryType_SearchArtists || type_ == QueryType_SearchAlbums || type_ == QueryType_SearchSongs); }
|
const bool IsSearch() { return (type_ == QueryType_SearchArtists || type_ == QueryType_SearchAlbums || type_ == QueryType_SearchSongs); }
|
||||||
|
|
||||||
void SendSearch();
|
void GetArtists();
|
||||||
void ArtistsSearch(const int offset = 0);
|
void GetAlbums();
|
||||||
void AlbumsSearch(const int offset = 0);
|
void GetSongs();
|
||||||
void SongsSearch(const int offset = 0);
|
|
||||||
|
void ArtistsSearch();
|
||||||
|
void AlbumsSearch();
|
||||||
|
void SongsSearch();
|
||||||
|
|
||||||
|
void AddArtistsRequest(const int offset = 0, const int limit = 0);
|
||||||
|
void AddArtistsSearchRequest(const int offset = 0);
|
||||||
|
void FlushArtistsRequests();
|
||||||
|
void AddAlbumsRequest(const int offset = 0, const int limit = 0);
|
||||||
|
void AddAlbumsSearchRequest(const int offset = 0);
|
||||||
|
void FlushAlbumsRequests();
|
||||||
|
void AddSongsRequest(const int offset = 0, const int limit = 0);
|
||||||
|
void AddSongsSearchRequest(const int offset = 0);
|
||||||
|
void FlushSongsRequests();
|
||||||
|
|
||||||
void ArtistsFinishCheck(const int limit = 0, const int offset = 0, const int artists_received = 0);
|
void ArtistsFinishCheck(const int limit = 0, const int offset = 0, const int artists_received = 0);
|
||||||
void AlbumsFinishCheck(const int artist_id, const int limit = 0, const int offset = 0, const int albums_total = 0, const int albums_received = 0);
|
void AlbumsFinishCheck(const int artist_id, const int limit = 0, const int offset = 0, const int albums_total = 0, const int albums_received = 0);
|
||||||
void GetArtistAlbums(const int artist_id, const int offset = 0);
|
void SongsFinishCheck(const int artist_id, const int album_id, const int limit, const int offset, const int songs_total, const int songs_received, const QString &album_artist);
|
||||||
void GetAlbumSongs(const int album_id);
|
|
||||||
int ParseSong(Song &song, const int album_id_requested, const QJsonValue &value, QString album_artist = QString());
|
void AddArtistAlbumsRequest(const int artist_id, const int offset = 0);
|
||||||
|
void FlushArtistAlbumsRequests();
|
||||||
|
|
||||||
|
void AddAlbumSongsRequest(const int artist_id, const int album_id, const QString &album_artist, const int offset = 0);
|
||||||
|
void FlushAlbumSongsRequests();
|
||||||
|
|
||||||
|
int ParseSong(Song &song, const QJsonObject &json_obj, const int artist_id_requested = 0, const int album_id_requested = 0, const QString &album_artist = QString());
|
||||||
|
|
||||||
void GetAlbumCovers();
|
void GetAlbumCovers();
|
||||||
void GetAlbumCover(Song &song);
|
void AddAlbumCoverRequest(Song &song);
|
||||||
|
void FlushAlbumCoverRequests();
|
||||||
|
void AlbumCoverFinishCheck();
|
||||||
|
|
||||||
void FinishCheck();
|
void FinishCheck();
|
||||||
QString LoginError(QString error, QVariant debug = QVariant());
|
void Warn(QString error, QVariant debug = QVariant());
|
||||||
QString Error(QString error, QVariant debug = QVariant());
|
QString Error(QString error, QVariant debug = QVariant());
|
||||||
|
|
||||||
static const char *kResourcesUrl;
|
static const char *kResourcesUrl;
|
||||||
|
static const int kMaxConcurrentArtistsRequests;
|
||||||
|
static const int kMaxConcurrentAlbumsRequests;
|
||||||
|
static const int kMaxConcurrentSongsRequests;
|
||||||
|
static const int kMaxConcurrentArtistAlbumsRequests;
|
||||||
|
static const int kMaxConcurrentAlbumSongsRequests;
|
||||||
|
static const int kMaxConcurrentAlbumCoverRequests;
|
||||||
|
|
||||||
TidalService *service_;
|
TidalService *service_;
|
||||||
TidalUrlHandler *url_handler_;
|
TidalUrlHandler *url_handler_;
|
||||||
@ -115,20 +175,38 @@ class TidalRequest : public TidalBaseRequest {
|
|||||||
|
|
||||||
int search_id_;
|
int search_id_;
|
||||||
QString search_text_;
|
QString search_text_;
|
||||||
QList<int> artist_albums_queue_;
|
|
||||||
QList<int> artist_albums_requests_;
|
QQueue<Request> artists_requests_queue_;
|
||||||
QHash<int, QString> album_songs_requests_;
|
QQueue<Request> albums_requests_queue_;
|
||||||
QMultiMap<int, Song*> album_covers_requests_;
|
QQueue<Request> songs_requests_queue_;
|
||||||
|
|
||||||
|
QQueue<Request> artist_albums_requests_queue_;
|
||||||
|
QQueue<Request> album_songs_requests_queue_;
|
||||||
|
QQueue<AlbumCoverRequest> album_cover_requests_queue_;
|
||||||
|
|
||||||
|
QList<int> artist_albums_requests_pending_;
|
||||||
|
QHash<int, Request> album_songs_requests_pending_;
|
||||||
|
QMultiMap<int, Song*> album_covers_requests_sent_;
|
||||||
|
|
||||||
|
int artists_requests_active_;
|
||||||
int artists_total_;
|
int artists_total_;
|
||||||
int artists_chunk_requested_;
|
|
||||||
int artists_chunk_received_;
|
|
||||||
int artists_received_;
|
int artists_received_;
|
||||||
int artist_albums_chunk_requested_;
|
|
||||||
int artist_albums_chunk_received_;
|
int albums_requests_active_;
|
||||||
|
int songs_requests_active_;
|
||||||
|
|
||||||
|
int artist_albums_requests_active_;
|
||||||
|
int artist_albums_requested_;
|
||||||
int artist_albums_received_;
|
int artist_albums_received_;
|
||||||
|
|
||||||
|
int album_songs_requests_active_;
|
||||||
|
int album_songs_requested_;
|
||||||
int album_songs_received_;
|
int album_songs_received_;
|
||||||
|
|
||||||
|
int album_covers_requests_active_;
|
||||||
int album_covers_requested_;
|
int album_covers_requested_;
|
||||||
int album_covers_received_;
|
int album_covers_received_;
|
||||||
|
|
||||||
SongList songs_;
|
SongList songs_;
|
||||||
QString errors_;
|
QString errors_;
|
||||||
bool need_login_;
|
bool need_login_;
|
||||||
|
@ -365,65 +365,125 @@ void TidalService::TryLogin() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TidalService::ResetArtistsRequest() {
|
||||||
|
|
||||||
|
if (artists_request_.get()) {
|
||||||
|
disconnect(artists_request_.get(), 0, nullptr, 0);
|
||||||
|
disconnect(this, 0, artists_request_.get(), 0);
|
||||||
|
artists_request_.reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void TidalService::GetArtists() {
|
void TidalService::GetArtists() {
|
||||||
|
|
||||||
|
ResetArtistsRequest();
|
||||||
|
|
||||||
artists_request_.reset(new TidalRequest(this, url_handler_, network_, TidalBaseRequest::QueryType_Artists, this));
|
artists_request_.reset(new TidalRequest(this, url_handler_, network_, TidalBaseRequest::QueryType_Artists, this));
|
||||||
|
|
||||||
connect(artists_request_.get(), SIGNAL(ErrorSignal(QString)), SIGNAL(ArtistsError(QString)));
|
connect(artists_request_.get(), SIGNAL(ErrorSignal(QString)), SLOT(ArtistsErrorReceived(QString)));
|
||||||
|
connect(artists_request_.get(), SIGNAL(Results(SongList)), SLOT(ArtistsResultsReceived(SongList)));
|
||||||
connect(artists_request_.get(), SIGNAL(UpdateStatus(QString)), SIGNAL(ArtistsUpdateStatus(QString)));
|
connect(artists_request_.get(), SIGNAL(UpdateStatus(QString)), SIGNAL(ArtistsUpdateStatus(QString)));
|
||||||
connect(artists_request_.get(), SIGNAL(ProgressSetMaximum(int)), SIGNAL(ArtistsProgressSetMaximum(int)));
|
connect(artists_request_.get(), SIGNAL(ProgressSetMaximum(int)), SIGNAL(ArtistsProgressSetMaximum(int)));
|
||||||
connect(artists_request_.get(), SIGNAL(UpdateProgress(int)), SIGNAL(ArtistsUpdateProgress(int)));
|
connect(artists_request_.get(), SIGNAL(UpdateProgress(int)), SIGNAL(ArtistsUpdateProgress(int)));
|
||||||
connect(artists_request_.get(), SIGNAL(Results(SongList)), SIGNAL(ArtistsResults(SongList)));
|
|
||||||
connect(this, SIGNAL(LoginComplete(bool, QString)), artists_request_.get(), SLOT(LoginComplete(bool, QString)));
|
connect(this, SIGNAL(LoginComplete(bool, QString)), artists_request_.get(), SLOT(LoginComplete(bool, QString)));
|
||||||
|
|
||||||
artists_request_->Process();
|
artists_request_->Process();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TidalService::UpdateArtists(SongList songs) {
|
void TidalService::ArtistsResultsReceived(SongList songs) {
|
||||||
|
|
||||||
artists_collection_backend_->DeleteAll();
|
emit ArtistsResults(songs);
|
||||||
artists_collection_backend_->AddOrUpdateSongs(songs);
|
ResetArtistsRequest();
|
||||||
artists_collection_model_->Reset();
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void TidalService::ArtistsErrorReceived(QString error) {
|
||||||
|
|
||||||
|
emit ArtistsError(error);
|
||||||
|
ResetArtistsRequest();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void TidalService::ResetAlbumsRequest() {
|
||||||
|
|
||||||
|
if (albums_request_.get()) {
|
||||||
|
disconnect(albums_request_.get(), 0, nullptr, 0);
|
||||||
|
disconnect(this, 0, albums_request_.get(), 0);
|
||||||
|
albums_request_.reset();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TidalService::GetAlbums() {
|
void TidalService::GetAlbums() {
|
||||||
|
|
||||||
|
ResetAlbumsRequest();
|
||||||
albums_request_.reset(new TidalRequest(this, url_handler_, network_, TidalBaseRequest::QueryType_Albums, this));
|
albums_request_.reset(new TidalRequest(this, url_handler_, network_, TidalBaseRequest::QueryType_Albums, this));
|
||||||
connect(albums_request_.get(), SIGNAL(ErrorSignal(QString)), SIGNAL(AlbumsError(QString)));
|
connect(albums_request_.get(), SIGNAL(ErrorSignal(QString)), SLOT(AlbumsErrorReceived(QString)));
|
||||||
|
connect(albums_request_.get(), SIGNAL(Results(SongList)), SLOT(AlbumsResultsReceived(SongList)));
|
||||||
connect(albums_request_.get(), SIGNAL(UpdateStatus(QString)), SIGNAL(AlbumsUpdateStatus(QString)));
|
connect(albums_request_.get(), SIGNAL(UpdateStatus(QString)), SIGNAL(AlbumsUpdateStatus(QString)));
|
||||||
connect(albums_request_.get(), SIGNAL(ProgressSetMaximum(int)), SIGNAL(AlbumsProgressSetMaximum(int)));
|
connect(albums_request_.get(), SIGNAL(ProgressSetMaximum(int)), SIGNAL(AlbumsProgressSetMaximum(int)));
|
||||||
connect(albums_request_.get(), SIGNAL(UpdateProgress(int)), SIGNAL(AlbumsUpdateProgress(int)));
|
connect(albums_request_.get(), SIGNAL(UpdateProgress(int)), SIGNAL(AlbumsUpdateProgress(int)));
|
||||||
connect(albums_request_.get(), SIGNAL(Results(SongList)), SIGNAL(AlbumsResults(SongList)));
|
|
||||||
connect(this, SIGNAL(LoginComplete(bool, QString)), albums_request_.get(), SLOT(LoginComplete(bool, QString)));
|
connect(this, SIGNAL(LoginComplete(bool, QString)), albums_request_.get(), SLOT(LoginComplete(bool, QString)));
|
||||||
|
|
||||||
albums_request_->Process();
|
albums_request_->Process();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TidalService::UpdateAlbums(SongList songs) {
|
void TidalService::AlbumsResultsReceived(SongList songs) {
|
||||||
|
|
||||||
albums_collection_backend_->DeleteAll();
|
emit AlbumsResults(songs);
|
||||||
albums_collection_backend_->AddOrUpdateSongs(songs);
|
ResetAlbumsRequest();
|
||||||
albums_collection_model_->Reset();
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void TidalService::AlbumsErrorReceived(QString error) {
|
||||||
|
|
||||||
|
emit AlbumsError(error);
|
||||||
|
ResetAlbumsRequest();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void TidalService::ResetSongsRequest() {
|
||||||
|
|
||||||
|
if (songs_request_.get()) {
|
||||||
|
disconnect(songs_request_.get(), 0, nullptr, 0);
|
||||||
|
disconnect(this, 0, songs_request_.get(), 0);
|
||||||
|
songs_request_.reset();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TidalService::GetSongs() {
|
void TidalService::GetSongs() {
|
||||||
|
|
||||||
|
ResetSongsRequest();
|
||||||
songs_request_.reset(new TidalRequest(this, url_handler_, network_, TidalBaseRequest::QueryType_Songs, this));
|
songs_request_.reset(new TidalRequest(this, url_handler_, network_, TidalBaseRequest::QueryType_Songs, this));
|
||||||
connect(songs_request_.get(), SIGNAL(ErrorSignal(QString)), SIGNAL(SongsError(QString)));
|
connect(songs_request_.get(), SIGNAL(ErrorSignal(QString)), SLOT(SongsErrorReceived(QString)));
|
||||||
|
connect(songs_request_.get(), SIGNAL(Results(SongList)), SLOT(SongsResultsReceived(SongList)));
|
||||||
connect(songs_request_.get(), SIGNAL(UpdateStatus(QString)), SIGNAL(SongsUpdateStatus(QString)));
|
connect(songs_request_.get(), SIGNAL(UpdateStatus(QString)), SIGNAL(SongsUpdateStatus(QString)));
|
||||||
connect(songs_request_.get(), SIGNAL(ProgressSetMaximum(int)), SIGNAL(SongsProgressSetMaximum(int)));
|
connect(songs_request_.get(), SIGNAL(ProgressSetMaximum(int)), SIGNAL(SongsProgressSetMaximum(int)));
|
||||||
connect(songs_request_.get(), SIGNAL(UpdateProgress(int)), SIGNAL(SongsUpdateProgress(int)));
|
connect(songs_request_.get(), SIGNAL(UpdateProgress(int)), SIGNAL(SongsUpdateProgress(int)));
|
||||||
connect(songs_request_.get(), SIGNAL(Results(SongList)), SIGNAL(SongsResults(SongList)));
|
|
||||||
connect(this, SIGNAL(LoginComplete(bool, QString)), songs_request_.get(), SLOT(LoginComplete(bool, QString)));
|
connect(this, SIGNAL(LoginComplete(bool, QString)), songs_request_.get(), SLOT(LoginComplete(bool, QString)));
|
||||||
|
|
||||||
songs_request_->Process();
|
songs_request_->Process();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TidalService::SongsResultsReceived(SongList songs) {
|
||||||
|
|
||||||
|
emit SongsResults(songs);
|
||||||
|
ResetSongsRequest();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void TidalService::SongsErrorReceived(QString error) {
|
||||||
|
|
||||||
|
emit SongsError(error);
|
||||||
|
ResetSongsRequest();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
int TidalService::Search(const QString &text, InternetSearch::SearchType type) {
|
int TidalService::Search(const QString &text, InternetSearch::SearchType type) {
|
||||||
|
|
||||||
pending_search_id_ = next_pending_search_id_;
|
pending_search_id_ = next_pending_search_id_;
|
||||||
|
@ -118,14 +118,21 @@ class TidalService : public InternetService {
|
|||||||
void GetArtists();
|
void GetArtists();
|
||||||
void GetAlbums();
|
void GetAlbums();
|
||||||
void GetSongs();
|
void GetSongs();
|
||||||
|
void ResetArtistsRequest();
|
||||||
|
void ResetAlbumsRequest();
|
||||||
|
void ResetSongsRequest();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void SendLogin();
|
void SendLogin();
|
||||||
void HandleAuthReply(QNetworkReply *reply);
|
void HandleAuthReply(QNetworkReply *reply);
|
||||||
void ResetLoginAttempts();
|
void ResetLoginAttempts();
|
||||||
void StartSearch();
|
void StartSearch();
|
||||||
void UpdateArtists(SongList songs);
|
void ArtistsResultsReceived(SongList songs);
|
||||||
void UpdateAlbums(SongList songs);
|
void ArtistsErrorReceived(QString error);
|
||||||
|
void AlbumsResultsReceived(SongList songs);
|
||||||
|
void AlbumsErrorReceived(QString error);
|
||||||
|
void SongsResultsReceived(SongList songs);
|
||||||
|
void SongsErrorReceived(QString error);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef QPair<QString, QString> Param;
|
typedef QPair<QString, QString> Param;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user