Change to const references, make search progress and status pass search id

This commit is contained in:
Jonas Kvinge
2019-06-20 16:33:28 +02:00
parent 9d222e2c57
commit bf4001968e
22 changed files with 499 additions and 482 deletions

View File

@@ -452,8 +452,6 @@ void TidalService::SendLogin() {
void TidalService::SendLogin(const QString &username, const QString &password, const QString &token) {
emit UpdateStatus(tr("Authenticating..."));
login_sent_ = true;
++login_attempts_;
if (timer_login_attempt_->isActive()) timer_login_attempt_->stop();
@@ -639,27 +637,30 @@ void TidalService::GetArtists() {
artists_request_.reset(new TidalRequest(this, url_handler_, network_, TidalBaseRequest::QueryType_Artists, this));
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(ProgressSetMaximum(int)), SIGNAL(ArtistsProgressSetMaximum(int)));
connect(artists_request_.get(), SIGNAL(UpdateProgress(int)), SIGNAL(ArtistsUpdateProgress(int)));
connect(artists_request_.get(), SIGNAL(Results(const int, const SongList&, const QString&)), SLOT(ArtistsResultsReceived(const int, const SongList&, const QString&)));
connect(artists_request_.get(), SIGNAL(UpdateStatus(const int, const QString&)), SLOT(ArtistsUpdateStatusReceived(const int, const QString&)));
connect(artists_request_.get(), SIGNAL(ProgressSetMaximum(const int, const int)), SLOT(ArtistsProgressSetMaximumReceived(const int, const int)));
connect(artists_request_.get(), SIGNAL(UpdateProgress(const int, const int)), SLOT(ArtistsUpdateProgressReceived(const int, const int)));
connect(this, SIGNAL(LoginComplete(bool, QString)), artists_request_.get(), SLOT(LoginComplete(bool, QString)));
artists_request_->Process();
}
void TidalService::ArtistsResultsReceived(SongList songs) {
emit ArtistsResults(songs);
void TidalService::ArtistsResultsReceived(const int id, const SongList &songs, const QString &error) {
emit ArtistsResults(songs, error);
}
void TidalService::ArtistsErrorReceived(QString error) {
void TidalService::ArtistsUpdateStatusReceived(const int id, const QString &text) {
emit ArtistsUpdateStatus(text);
}
emit ArtistsError(error);
void TidalService::ArtistsProgressSetMaximumReceived(const int id, const int max) {
emit ArtistsProgressSetMaximum(max);
}
void TidalService::ArtistsUpdateProgressReceived(const int id, const int progress) {
emit ArtistsUpdateProgress(progress);
}
void TidalService::ResetAlbumsRequest() {
@@ -676,27 +677,30 @@ void TidalService::GetAlbums() {
ResetAlbumsRequest();
albums_request_.reset(new TidalRequest(this, url_handler_, network_, TidalBaseRequest::QueryType_Albums, this));
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(ProgressSetMaximum(int)), SIGNAL(AlbumsProgressSetMaximum(int)));
connect(albums_request_.get(), SIGNAL(UpdateProgress(int)), SIGNAL(AlbumsUpdateProgress(int)));
connect(albums_request_.get(), SIGNAL(Results(const int, const SongList&, const QString&)), SLOT(AlbumsResultsReceived(const int, const SongList&, const QString&)));
connect(albums_request_.get(), SIGNAL(UpdateStatus(const int, const QString&)), SLOT(AlbumsUpdateStatusReceived(const int, const QString&)));
connect(albums_request_.get(), SIGNAL(ProgressSetMaximum(const int, const int)), SLOT(AlbumsProgressSetMaximumReceived(const int, const int)));
connect(albums_request_.get(), SIGNAL(UpdateProgress(const int, const int)), SLOT(AlbumsUpdateProgressReceived(const int, const int)));
connect(this, SIGNAL(LoginComplete(bool, QString)), albums_request_.get(), SLOT(LoginComplete(bool, QString)));
albums_request_->Process();
}
void TidalService::AlbumsResultsReceived(SongList songs) {
emit AlbumsResults(songs);
void TidalService::AlbumsResultsReceived(const int id, const SongList &songs, const QString &error) {
emit AlbumsResults(songs, error);
}
void TidalService::AlbumsErrorReceived(QString error) {
void TidalService::AlbumsUpdateStatusReceived(const int id, const QString &text) {
emit AlbumsUpdateStatus(text);
}
emit AlbumsError(error);
void TidalService::AlbumsProgressSetMaximumReceived(const int id, const int max) {
emit AlbumsProgressSetMaximum(max);
}
void TidalService::AlbumsUpdateProgressReceived(const int id, const int progress) {
emit AlbumsUpdateProgress(progress);
}
void TidalService::ResetSongsRequest() {
@@ -713,27 +717,30 @@ void TidalService::GetSongs() {
ResetSongsRequest();
songs_request_.reset(new TidalRequest(this, url_handler_, network_, TidalBaseRequest::QueryType_Songs, this));
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(ProgressSetMaximum(int)), SIGNAL(SongsProgressSetMaximum(int)));
connect(songs_request_.get(), SIGNAL(UpdateProgress(int)), SIGNAL(SongsUpdateProgress(int)));
connect(songs_request_.get(), SIGNAL(Results(const int, const SongList&, const QString&)), SLOT(SongsResultsReceived(const int, const SongList&, const QString&)));
connect(songs_request_.get(), SIGNAL(UpdateStatus(const int, const QString&)), SLOT(SongsUpdateStatusReceived(const int, const QString&)));
connect(songs_request_.get(), SIGNAL(ProgressSetMaximum(const int, const int)), SLOT(SongsProgressSetMaximumReceived(const int, const int)));
connect(songs_request_.get(), SIGNAL(UpdateProgress(const int, const int)), SLOT(SongsUpdateProgressReceived(const int, const int)));
connect(this, SIGNAL(LoginComplete(bool, QString)), songs_request_.get(), SLOT(LoginComplete(bool, QString)));
songs_request_->Process();
}
void TidalService::SongsResultsReceived(SongList songs) {
emit SongsResults(songs);
void TidalService::SongsResultsReceived(const int id, const SongList &songs, const QString &error) {
emit SongsResults(songs, error);
}
void TidalService::SongsErrorReceived(QString error) {
void TidalService::SongsUpdateStatusReceived(const int id, const QString &text) {
emit SongsUpdateStatus(text);
}
emit SongsError(error);
void TidalService::SongsProgressSetMaximumReceived(const int id, const int max) {
emit SongsProgressSetMaximum(max);
}
void TidalService::SongsUpdateProgressReceived(const int id, const int progress) {
emit SongsUpdateProgress(progress);
}
int TidalService::Search(const QString &text, InternetSearch::SearchType type) {
@@ -758,7 +765,7 @@ int TidalService::Search(const QString &text, InternetSearch::SearchType type) {
void TidalService::StartSearch() {
if ((oauth_ && !authenticated()) || api_token_.isEmpty() || username_.isEmpty() || password_.isEmpty()) {
emit SearchError(pending_search_id_, tr("Not authenticated."));
emit SearchResults(pending_search_id_, SongList(), tr("Not authenticated."));
next_pending_search_id_ = 1;
ShowConfig();
return;
@@ -795,11 +802,10 @@ void TidalService::SendSearch() {
search_request_.reset(new TidalRequest(this, url_handler_, network_, type, this));
connect(search_request_.get(), SIGNAL(SearchResults(int, SongList)), SIGNAL(SearchResults(int, SongList)));
connect(search_request_.get(), SIGNAL(ErrorSignal(int, QString)), SIGNAL(SearchError(int, QString)));
connect(search_request_.get(), SIGNAL(UpdateStatus(QString)), SIGNAL(SearchUpdateStatus(QString)));
connect(search_request_.get(), SIGNAL(ProgressSetMaximum(int)), SIGNAL(SearchProgressSetMaximum(int)));
connect(search_request_.get(), SIGNAL(UpdateProgress(int)), SIGNAL(SearchUpdateProgress(int)));
connect(search_request_.get(), SIGNAL(Results(const int, const SongList&, const QString&)), SLOT(SearchResultsReceived(const int, const SongList&, const QString&)));
connect(search_request_.get(), SIGNAL(UpdateStatus(const int, const QString&)), SIGNAL(SearchUpdateStatus(const int, const QString&)));
connect(search_request_.get(), SIGNAL(ProgressSetMaximum(const int, const int)), SIGNAL(SearchProgressSetMaximum(const int, const int)));
connect(search_request_.get(), SIGNAL(UpdateProgress(const int, const int)), SIGNAL(SearchUpdateProgress(const int, const int)));
connect(this, SIGNAL(LoginComplete(bool, QString)), search_request_.get(), SLOT(LoginComplete(bool, QString)));
search_request_->Search(search_id_, search_text_);
@@ -807,6 +813,10 @@ void TidalService::SendSearch() {
}
void TidalService::SearchResultsReceived(const int id, const SongList &songs, const QString &error) {
emit SearchResults(id, songs, error);
}
void TidalService::GetStreamURL(const QUrl &url) {
TidalStreamURLRequest *stream_url_req = new TidalStreamURLRequest(this, network_, url, this);