Use C++11 enum class
This commit is contained in:
@@ -47,15 +47,15 @@ class TidalBaseRequest : public QObject {
|
||||
public:
|
||||
explicit TidalBaseRequest(TidalService *service, NetworkAccessManager *network, QObject *parent = nullptr);
|
||||
|
||||
enum QueryType {
|
||||
QueryType_None,
|
||||
QueryType_Artists,
|
||||
QueryType_Albums,
|
||||
QueryType_Songs,
|
||||
QueryType_SearchArtists,
|
||||
QueryType_SearchAlbums,
|
||||
QueryType_SearchSongs,
|
||||
QueryType_StreamURL,
|
||||
enum class QueryType {
|
||||
None,
|
||||
Artists,
|
||||
Albums,
|
||||
Songs,
|
||||
SearchArtists,
|
||||
SearchAlbums,
|
||||
SearchSongs,
|
||||
StreamURL
|
||||
};
|
||||
|
||||
protected:
|
||||
|
||||
@@ -58,11 +58,11 @@ TidalFavoriteRequest::~TidalFavoriteRequest() {
|
||||
QString TidalFavoriteRequest::FavoriteText(const FavoriteType type) {
|
||||
|
||||
switch (type) {
|
||||
case FavoriteType_Artists:
|
||||
case FavoriteType::Artists:
|
||||
return "artists";
|
||||
case FavoriteType_Albums:
|
||||
case FavoriteType::Albums:
|
||||
return "albums";
|
||||
case FavoriteType_Songs:
|
||||
case FavoriteType::Songs:
|
||||
return "tracks";
|
||||
}
|
||||
|
||||
@@ -73,11 +73,11 @@ QString TidalFavoriteRequest::FavoriteText(const FavoriteType type) {
|
||||
QString TidalFavoriteRequest::FavoriteMethod(const FavoriteType type) {
|
||||
|
||||
switch (type) {
|
||||
case FavoriteType_Artists:
|
||||
case FavoriteType::Artists:
|
||||
return "artistIds";
|
||||
case FavoriteType_Albums:
|
||||
case FavoriteType::Albums:
|
||||
return "albumIds";
|
||||
case FavoriteType_Songs:
|
||||
case FavoriteType::Songs:
|
||||
return "trackIds";
|
||||
}
|
||||
|
||||
@@ -86,19 +86,19 @@ QString TidalFavoriteRequest::FavoriteMethod(const FavoriteType type) {
|
||||
}
|
||||
|
||||
void TidalFavoriteRequest::AddArtists(const SongList &songs) {
|
||||
AddFavorites(FavoriteType_Artists, songs);
|
||||
AddFavorites(FavoriteType::Artists, songs);
|
||||
}
|
||||
|
||||
void TidalFavoriteRequest::AddAlbums(const SongList &songs) {
|
||||
AddFavorites(FavoriteType_Albums, songs);
|
||||
AddFavorites(FavoriteType::Albums, songs);
|
||||
}
|
||||
|
||||
void TidalFavoriteRequest::AddSongs(const SongList &songs) {
|
||||
AddFavorites(FavoriteType_Songs, songs);
|
||||
AddFavorites(FavoriteType::Songs, songs);
|
||||
}
|
||||
|
||||
void TidalFavoriteRequest::AddSongs(const SongMap &songs) {
|
||||
AddFavoritesRequest(FavoriteType_Songs, songs.keys(), songs.values());
|
||||
AddFavoritesRequest(FavoriteType::Songs, songs.keys(), songs.values());
|
||||
}
|
||||
|
||||
void TidalFavoriteRequest::AddFavorites(const FavoriteType type, const SongList &songs) {
|
||||
@@ -107,15 +107,15 @@ void TidalFavoriteRequest::AddFavorites(const FavoriteType type, const SongList
|
||||
for (const Song &song : songs) {
|
||||
QString id;
|
||||
switch (type) {
|
||||
case FavoriteType_Artists:
|
||||
case FavoriteType::Artists:
|
||||
if (song.artist_id().isEmpty()) continue;
|
||||
id = song.artist_id();
|
||||
break;
|
||||
case FavoriteType_Albums:
|
||||
case FavoriteType::Albums:
|
||||
if (song.album_id().isEmpty()) continue;
|
||||
id = song.album_id();
|
||||
break;
|
||||
case FavoriteType_Songs:
|
||||
case FavoriteType::Songs:
|
||||
if (song.song_id().isEmpty()) continue;
|
||||
id = song.song_id();
|
||||
break;
|
||||
@@ -176,13 +176,13 @@ void TidalFavoriteRequest::AddFavoritesReply(QNetworkReply *reply, const Favorit
|
||||
qLog(Debug) << "Tidal:" << songs.count() << "songs added to" << FavoriteText(type) << "favorites.";
|
||||
|
||||
switch (type) {
|
||||
case FavoriteType_Artists:
|
||||
case FavoriteType::Artists:
|
||||
emit ArtistsAdded(songs);
|
||||
break;
|
||||
case FavoriteType_Albums:
|
||||
case FavoriteType::Albums:
|
||||
emit AlbumsAdded(songs);
|
||||
break;
|
||||
case FavoriteType_Songs:
|
||||
case FavoriteType::Songs:
|
||||
emit SongsAdded(songs);
|
||||
break;
|
||||
}
|
||||
@@ -190,22 +190,22 @@ void TidalFavoriteRequest::AddFavoritesReply(QNetworkReply *reply, const Favorit
|
||||
}
|
||||
|
||||
void TidalFavoriteRequest::RemoveArtists(const SongList &songs) {
|
||||
RemoveFavorites(FavoriteType_Artists, songs);
|
||||
RemoveFavorites(FavoriteType::Artists, songs);
|
||||
}
|
||||
|
||||
void TidalFavoriteRequest::RemoveAlbums(const SongList &songs) {
|
||||
RemoveFavorites(FavoriteType_Albums, songs);
|
||||
RemoveFavorites(FavoriteType::Albums, songs);
|
||||
}
|
||||
|
||||
void TidalFavoriteRequest::RemoveSongs(const SongList &songs) {
|
||||
RemoveFavorites(FavoriteType_Songs, songs);
|
||||
RemoveFavorites(FavoriteType::Songs, songs);
|
||||
}
|
||||
|
||||
void TidalFavoriteRequest::RemoveSongs(const SongMap &songs) {
|
||||
|
||||
SongList songs_list = songs.values();
|
||||
for (const Song &song : songs_list) {
|
||||
RemoveFavoritesRequest(FavoriteType_Songs, song.song_id(), SongList() << song);
|
||||
RemoveFavoritesRequest(FavoriteType::Songs, song.song_id(), SongList() << song);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -216,15 +216,15 @@ void TidalFavoriteRequest::RemoveFavorites(const FavoriteType type, const SongLi
|
||||
for (const Song &song : songs) {
|
||||
QString id;
|
||||
switch (type) {
|
||||
case FavoriteType_Artists:
|
||||
case FavoriteType::Artists:
|
||||
if (song.artist_id().isEmpty()) continue;
|
||||
id = song.artist_id();
|
||||
break;
|
||||
case FavoriteType_Albums:
|
||||
case FavoriteType::Albums:
|
||||
if (song.album_id().isEmpty()) continue;
|
||||
id = song.album_id();
|
||||
break;
|
||||
case FavoriteType_Songs:
|
||||
case FavoriteType::Songs:
|
||||
if (song.song_id().isEmpty()) continue;
|
||||
id = song.song_id();
|
||||
break;
|
||||
@@ -288,13 +288,13 @@ void TidalFavoriteRequest::RemoveFavoritesReply(QNetworkReply *reply, const Favo
|
||||
qLog(Debug) << "Tidal:" << songs.count() << "songs removed from" << FavoriteText(type) << "favorites.";
|
||||
|
||||
switch (type) {
|
||||
case FavoriteType_Artists:
|
||||
case FavoriteType::Artists:
|
||||
emit ArtistsRemoved(songs);
|
||||
break;
|
||||
case FavoriteType_Albums:
|
||||
case FavoriteType::Albums:
|
||||
emit AlbumsRemoved(songs);
|
||||
break;
|
||||
case FavoriteType_Songs:
|
||||
case FavoriteType::Songs:
|
||||
emit SongsRemoved(songs);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -41,15 +41,16 @@ class TidalFavoriteRequest : public TidalBaseRequest {
|
||||
explicit TidalFavoriteRequest(TidalService *service, NetworkAccessManager *network, QObject *parent = nullptr);
|
||||
~TidalFavoriteRequest() override;
|
||||
|
||||
enum FavoriteType {
|
||||
FavoriteType_Artists,
|
||||
FavoriteType_Albums,
|
||||
FavoriteType_Songs
|
||||
};
|
||||
|
||||
bool need_login() { return need_login_; }
|
||||
void set_need_login() override { need_login_ = true; }
|
||||
|
||||
private:
|
||||
enum class FavoriteType {
|
||||
Artists,
|
||||
Albums,
|
||||
Songs
|
||||
};
|
||||
|
||||
signals:
|
||||
void ArtistsAdded(SongList);
|
||||
void AlbumsAdded(SongList);
|
||||
|
||||
@@ -52,14 +52,14 @@ 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 type, QObject *parent)
|
||||
TidalRequest::TidalRequest(TidalService *service, TidalUrlHandler *url_handler, Application *app, NetworkAccessManager *network, QueryType query_type, QObject *parent)
|
||||
: TidalBaseRequest(service, network, parent),
|
||||
service_(service),
|
||||
url_handler_(url_handler),
|
||||
app_(app),
|
||||
network_(network),
|
||||
timer_flush_requests_(new QTimer(this)),
|
||||
type_(type),
|
||||
query_type_(query_type),
|
||||
fetchalbums_(service->fetchalbums()),
|
||||
coversize_(service->coversize()),
|
||||
query_id_(-1),
|
||||
@@ -141,23 +141,23 @@ void TidalRequest::Process() {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (type_) {
|
||||
case QueryType::QueryType_Artists:
|
||||
switch (query_type_) {
|
||||
case QueryType::Artists:
|
||||
GetArtists();
|
||||
break;
|
||||
case QueryType::QueryType_Albums:
|
||||
case QueryType::Albums:
|
||||
GetAlbums();
|
||||
break;
|
||||
case QueryType::QueryType_Songs:
|
||||
case QueryType::Songs:
|
||||
GetSongs();
|
||||
break;
|
||||
case QueryType::QueryType_SearchArtists:
|
||||
case QueryType::SearchArtists:
|
||||
ArtistsSearch();
|
||||
break;
|
||||
case QueryType::QueryType_SearchAlbums:
|
||||
case QueryType::SearchAlbums:
|
||||
AlbumsSearch();
|
||||
break;
|
||||
case QueryType::QueryType_SearchSongs:
|
||||
case QueryType::SearchSongs:
|
||||
SongsSearch();
|
||||
break;
|
||||
default:
|
||||
@@ -244,14 +244,14 @@ void TidalRequest::FlushArtistsRequests() {
|
||||
Request request = artists_requests_queue_.dequeue();
|
||||
|
||||
ParamList parameters;
|
||||
if (type_ == QueryType_SearchArtists) parameters << Param("query", search_text_);
|
||||
if (query_type_ == QueryType::SearchArtists) parameters << Param("query", search_text_);
|
||||
if (request.limit > 0) parameters << Param("limit", QString::number(request.limit));
|
||||
if (request.offset > 0) parameters << Param("offset", QString::number(request.offset));
|
||||
QNetworkReply *reply = nullptr;
|
||||
if (type_ == QueryType_Artists) {
|
||||
if (query_type_ == QueryType::Artists) {
|
||||
reply = CreateRequest(QString("users/%1/favorites/artists").arg(service_->user_id()), parameters);
|
||||
}
|
||||
if (type_ == QueryType_SearchArtists) {
|
||||
if (query_type_ == QueryType::SearchArtists) {
|
||||
reply = CreateRequest("search/artists", parameters);
|
||||
}
|
||||
if (!reply) continue;
|
||||
@@ -292,14 +292,14 @@ void TidalRequest::FlushAlbumsRequests() {
|
||||
Request request = albums_requests_queue_.dequeue();
|
||||
|
||||
ParamList parameters;
|
||||
if (type_ == QueryType_SearchAlbums) parameters << Param("query", search_text_);
|
||||
if (query_type_ == QueryType::SearchAlbums) parameters << Param("query", search_text_);
|
||||
if (request.limit > 0) parameters << Param("limit", QString::number(request.limit));
|
||||
if (request.offset > 0) parameters << Param("offset", QString::number(request.offset));
|
||||
QNetworkReply *reply = nullptr;
|
||||
if (type_ == QueryType_Albums) {
|
||||
if (query_type_ == QueryType::Albums) {
|
||||
reply = CreateRequest(QString("users/%1/favorites/albums").arg(service_->user_id()), parameters);
|
||||
}
|
||||
if (type_ == QueryType_SearchAlbums) {
|
||||
if (query_type_ == QueryType::SearchAlbums) {
|
||||
reply = CreateRequest("search/albums", parameters);
|
||||
}
|
||||
if (!reply) continue;
|
||||
@@ -340,14 +340,14 @@ void TidalRequest::FlushSongsRequests() {
|
||||
Request request = songs_requests_queue_.dequeue();
|
||||
|
||||
ParamList parameters;
|
||||
if (type_ == QueryType_SearchSongs) parameters << Param("query", search_text_);
|
||||
if (query_type_ == QueryType::SearchSongs) parameters << Param("query", search_text_);
|
||||
if (request.limit > 0) parameters << Param("limit", QString::number(request.limit));
|
||||
if (request.offset > 0) parameters << Param("offset", QString::number(request.offset));
|
||||
QNetworkReply *reply = nullptr;
|
||||
if (type_ == QueryType_Songs) {
|
||||
if (query_type_ == QueryType::Songs) {
|
||||
reply = CreateRequest(QString("users/%1/favorites/tracks").arg(service_->user_id()), parameters);
|
||||
}
|
||||
if (type_ == QueryType_SearchSongs) {
|
||||
if (query_type_ == QueryType::SearchSongs) {
|
||||
reply = CreateRequest("search/tracks", parameters);
|
||||
}
|
||||
if (!reply) continue;
|
||||
@@ -526,8 +526,8 @@ void TidalRequest::ArtistsFinishCheck(const int limit, const int offset, const i
|
||||
if ((limit == 0 || limit > artists_received) && artists_received_ < artists_total_) {
|
||||
int offset_next = offset + artists_received;
|
||||
if (offset_next > 0 && offset_next < artists_total_) {
|
||||
if (type_ == QueryType_Artists) AddArtistsRequest(offset_next);
|
||||
else if (type_ == QueryType_SearchArtists) AddArtistsSearchRequest(offset_next);
|
||||
if (query_type_ == QueryType::Artists) AddArtistsRequest(offset_next);
|
||||
else if (query_type_ == QueryType::SearchArtists) AddArtistsSearchRequest(offset_next);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -760,7 +760,7 @@ void TidalRequest::AlbumsReceived(QNetworkReply *reply, const Artist &artist_req
|
||||
|
||||
}
|
||||
|
||||
if (type_ == QueryType_Albums || type_ == QueryType_SearchAlbums) {
|
||||
if (query_type_ == QueryType::Albums || query_type_ == QueryType::SearchAlbums) {
|
||||
albums_received_ += albums_received;
|
||||
emit UpdateProgress(query_id_, GetProgress(albums_received_, albums_total_));
|
||||
}
|
||||
@@ -776,15 +776,15 @@ void TidalRequest::AlbumsFinishCheck(const Artist &artist, const int limit, cons
|
||||
if (limit == 0 || limit > albums_received) {
|
||||
int offset_next = offset + albums_received;
|
||||
if (offset_next > 0 && offset_next < albums_total) {
|
||||
switch (type_) {
|
||||
case QueryType_Albums:
|
||||
switch (query_type_) {
|
||||
case QueryType::Albums:
|
||||
AddAlbumsRequest(offset_next);
|
||||
break;
|
||||
case QueryType_SearchAlbums:
|
||||
case QueryType::SearchAlbums:
|
||||
AddAlbumsSearchRequest(offset_next);
|
||||
break;
|
||||
case QueryType_Artists:
|
||||
case QueryType_SearchArtists:
|
||||
case QueryType::Artists:
|
||||
case QueryType::SearchArtists:
|
||||
AddArtistAlbumsRequest(artist, offset_next);
|
||||
break;
|
||||
default:
|
||||
@@ -826,7 +826,7 @@ void TidalRequest::SongsReplyReceived(QNetworkReply *reply, const int limit_requ
|
||||
|
||||
--songs_requests_active_;
|
||||
++songs_requests_received_;
|
||||
if (type_ == QueryType_SearchSongs && fetchalbums_) {
|
||||
if (query_type_ == QueryType::SearchSongs && fetchalbums_) {
|
||||
AlbumsReceived(reply, Artist(), limit_requested, offset_requested, offset_requested == 0);
|
||||
}
|
||||
else {
|
||||
@@ -952,7 +952,7 @@ void TidalRequest::SongsReceived(QNetworkReply *reply, const Artist &artist, con
|
||||
}
|
||||
|
||||
++songs_received;
|
||||
Song song(Song::Source_Tidal);
|
||||
Song song(Song::Source::Tidal);
|
||||
ParseSong(song, obj_item, artist, album);
|
||||
if (!song.is_valid()) continue;
|
||||
if (song.disc() >= 2) multidisc = true;
|
||||
@@ -966,7 +966,7 @@ void TidalRequest::SongsReceived(QNetworkReply *reply, const Artist &artist, con
|
||||
songs_.insert(song.song_id(), song);
|
||||
}
|
||||
|
||||
if (type_ == QueryType_Songs || type_ == QueryType_SearchSongs) {
|
||||
if (query_type_ == QueryType::Songs || query_type_ == QueryType::SearchSongs) {
|
||||
songs_received_ += songs_received;
|
||||
emit UpdateProgress(query_id_, GetProgress(songs_received_, songs_total_));
|
||||
}
|
||||
@@ -982,21 +982,21 @@ void TidalRequest::SongsFinishCheck(const Artist &artist, const Album &album, co
|
||||
if (limit == 0 || limit > songs_received) {
|
||||
int offset_next = offset + songs_received;
|
||||
if (offset_next > 0 && offset_next < songs_total) {
|
||||
switch (type_) {
|
||||
case QueryType_Songs:
|
||||
switch (query_type_) {
|
||||
case QueryType::Songs:
|
||||
AddSongsRequest(offset_next);
|
||||
break;
|
||||
case QueryType_SearchSongs:
|
||||
case QueryType::SearchSongs:
|
||||
// If artist_id and album_id isn't zero it means that it's a songs search where we fetch all albums too. So fallthrough.
|
||||
if (artist.artist_id.isEmpty() && album.album_id.isEmpty()) {
|
||||
AddSongsSearchRequest(offset_next);
|
||||
break;
|
||||
}
|
||||
[[fallthrough]];
|
||||
case QueryType_Artists:
|
||||
case QueryType_SearchArtists:
|
||||
case QueryType_Albums:
|
||||
case QueryType_SearchAlbums:
|
||||
case QueryType::Artists:
|
||||
case QueryType::SearchArtists:
|
||||
case QueryType::Albums:
|
||||
case QueryType::SearchAlbums:
|
||||
AddAlbumSongsRequest(artist, album, offset_next);
|
||||
break;
|
||||
default:
|
||||
@@ -1129,7 +1129,7 @@ void TidalRequest::ParseSong(Song &song, const QJsonObject &json_obj, const Arti
|
||||
|
||||
//qLog(Debug) << "id" << song_id << "track" << track << "disc" << disc << "title" << title << "album" << album << "album artist" << album_artist << "artist" << artist << cover << allow_streaming << url;
|
||||
|
||||
song.set_source(Song::Source_Tidal);
|
||||
song.set_source(Song::Source::Tidal);
|
||||
song.set_song_id(song_id);
|
||||
song.set_album_id(album_id);
|
||||
song.set_artist_id(artist_id);
|
||||
@@ -1146,7 +1146,7 @@ void TidalRequest::ParseSong(Song &song, const QJsonObject &json_obj, const Arti
|
||||
}
|
||||
song.set_comment(copyright);
|
||||
song.set_directory_id(0);
|
||||
song.set_filetype(Song::FileType_Stream);
|
||||
song.set_filetype(Song::FileType::Stream);
|
||||
song.set_filesize(0);
|
||||
song.set_mtime(0);
|
||||
song.set_ctime(0);
|
||||
|
||||
@@ -51,7 +51,7 @@ class TidalRequest : public TidalBaseRequest {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit TidalRequest(TidalService *service, TidalUrlHandler *url_handler, Application *app, NetworkAccessManager *network, QueryType type, QObject *parent);
|
||||
explicit TidalRequest(TidalService *service, TidalUrlHandler *url_handler, Application *app, NetworkAccessManager *network, QueryType query_type, QObject *parent);
|
||||
~TidalRequest() override;
|
||||
|
||||
void ReloadSettings();
|
||||
@@ -122,8 +122,8 @@ class TidalRequest : public TidalBaseRequest {
|
||||
void LoginComplete(const bool success, const QString &error = QString());
|
||||
|
||||
private:
|
||||
bool IsQuery() { return (type_ == QueryType_Artists || type_ == QueryType_Albums || type_ == QueryType_Songs); }
|
||||
bool IsSearch() { return (type_ == QueryType_SearchArtists || type_ == QueryType_SearchAlbums || type_ == QueryType_SearchSongs); }
|
||||
bool IsQuery() { return (query_type_ == QueryType::Artists || query_type_ == QueryType::Albums || query_type_ == QueryType::Songs); }
|
||||
bool IsSearch() { return (query_type_ == QueryType::SearchArtists || query_type_ == QueryType::SearchAlbums || query_type_ == QueryType::SearchSongs); }
|
||||
|
||||
void StartRequests();
|
||||
void FlushRequests();
|
||||
@@ -185,7 +185,7 @@ class TidalRequest : public TidalBaseRequest {
|
||||
NetworkAccessManager *network_;
|
||||
QTimer *timer_flush_requests_;
|
||||
|
||||
const QueryType type_;
|
||||
const QueryType query_type_;
|
||||
const bool fetchalbums_;
|
||||
const QString coversize_;
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@
|
||||
#include "settings/settingsdialog.h"
|
||||
#include "settings/tidalsettingspage.h"
|
||||
|
||||
const Song::Source TidalService::kSource = Song::Source_Tidal;
|
||||
const Song::Source TidalService::kSource = Song::Source::Tidal;
|
||||
|
||||
const char TidalService::kApiUrl[] = "https://api.tidalhifi.com/v1";
|
||||
const char TidalService::kResourcesUrl[] = "https://resources.tidal.com";
|
||||
@@ -85,7 +85,7 @@ 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),
|
||||
: InternetService(Song::Source::Tidal, "Tidal", "tidal", TidalSettingsPage::kSettingsGroup, SettingsDialog::Page::Tidal, app, parent),
|
||||
app_(app),
|
||||
network_(new NetworkAccessManager(this)),
|
||||
url_handler_(new TidalUrlHandler(app, this)),
|
||||
@@ -110,13 +110,13 @@ TidalService::TidalService(Application *app, QObject *parent)
|
||||
songssearchlimit_(1),
|
||||
fetchalbums_(true),
|
||||
download_album_covers_(true),
|
||||
stream_url_method_(TidalSettingsPage::StreamUrlMethod_StreamUrl),
|
||||
stream_url_method_(TidalSettingsPage::StreamUrlMethod::StreamUrl),
|
||||
album_explicit_(false),
|
||||
expires_in_(0),
|
||||
login_time_(0),
|
||||
pending_search_id_(0),
|
||||
next_pending_search_id_(1),
|
||||
pending_search_type_(InternetSearchView::SearchType_Artists),
|
||||
pending_search_type_(InternetSearchView::SearchType::Artists),
|
||||
search_id_(0),
|
||||
login_sent_(false),
|
||||
login_attempts_(0),
|
||||
@@ -128,15 +128,15 @@ TidalService::TidalService(Application *app, QObject *parent)
|
||||
|
||||
artists_collection_backend_ = new CollectionBackend();
|
||||
artists_collection_backend_->moveToThread(app_->database()->thread());
|
||||
artists_collection_backend_->Init(app_->database(), app->task_manager(), Song::Source_Tidal, kArtistsSongsTable, kArtistsSongsFtsTable);
|
||||
artists_collection_backend_->Init(app_->database(), app->task_manager(), Song::Source::Tidal, kArtistsSongsTable, kArtistsSongsFtsTable);
|
||||
|
||||
albums_collection_backend_ = new CollectionBackend();
|
||||
albums_collection_backend_->moveToThread(app_->database()->thread());
|
||||
albums_collection_backend_->Init(app_->database(), app->task_manager(), Song::Source_Tidal, kAlbumsSongsTable, kAlbumsSongsFtsTable);
|
||||
albums_collection_backend_->Init(app_->database(), app->task_manager(), Song::Source::Tidal, kAlbumsSongsTable, kAlbumsSongsFtsTable);
|
||||
|
||||
songs_collection_backend_ = new CollectionBackend();
|
||||
songs_collection_backend_->moveToThread(app_->database()->thread());
|
||||
songs_collection_backend_->Init(app_->database(), app->task_manager(), Song::Source_Tidal, kSongsTable, kSongsFtsTable);
|
||||
songs_collection_backend_->Init(app_->database(), app->task_manager(), Song::Source::Tidal, kSongsTable, kSongsFtsTable);
|
||||
|
||||
artists_collection_model_ = new CollectionModel(artists_collection_backend_, app_, this);
|
||||
albums_collection_model_ = new CollectionModel(albums_collection_backend_, app_, this);
|
||||
@@ -244,7 +244,7 @@ void TidalService::ExitReceived() {
|
||||
}
|
||||
|
||||
void TidalService::ShowConfig() {
|
||||
app_->OpenSettingsDialogAtPage(SettingsDialog::Page_Tidal);
|
||||
app_->OpenSettingsDialogAtPage(SettingsDialog::Page::Tidal);
|
||||
}
|
||||
|
||||
void TidalService::LoadSession() {
|
||||
@@ -296,7 +296,7 @@ void TidalService::ReloadSettings() {
|
||||
fetchalbums_ = s.value("fetchalbums", false).toBool();
|
||||
coversize_ = s.value("coversize", "640x640").toString();
|
||||
download_album_covers_ = s.value("downloadalbumcovers", true).toBool();
|
||||
stream_url_method_ = static_cast<TidalSettingsPage::StreamUrlMethod>(s.value("streamurl").toInt());
|
||||
stream_url_method_ = static_cast<TidalSettingsPage::StreamUrlMethod>(s.value("streamurl", static_cast<int>(TidalSettingsPage::StreamUrlMethod::StreamUrl)).toInt());
|
||||
album_explicit_ = s.value("album_explicit").toBool();
|
||||
|
||||
s.endGroup();
|
||||
@@ -752,7 +752,7 @@ void TidalService::GetArtists() {
|
||||
}
|
||||
|
||||
ResetArtistsRequest();
|
||||
artists_request_.reset(new TidalRequest(this, url_handler_, app_, network_, TidalBaseRequest::QueryType_Artists, this), [](TidalRequest *request) { request->deleteLater(); });
|
||||
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);
|
||||
@@ -807,7 +807,7 @@ void TidalService::GetAlbums() {
|
||||
}
|
||||
|
||||
ResetAlbumsRequest();
|
||||
albums_request_.reset(new TidalRequest(this, url_handler_, app_, network_, TidalBaseRequest::QueryType_Albums, this), [](TidalRequest *request) { request->deleteLater(); });
|
||||
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);
|
||||
@@ -862,7 +862,7 @@ void TidalService::GetSongs() {
|
||||
}
|
||||
|
||||
ResetSongsRequest();
|
||||
songs_request_.reset(new TidalRequest(this, url_handler_, app_, network_, TidalBaseRequest::QueryType_Songs, this), [](TidalRequest *request) { request->deleteLater(); });
|
||||
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);
|
||||
@@ -936,24 +936,24 @@ void TidalService::CancelSearch() {
|
||||
|
||||
void TidalService::SendSearch() {
|
||||
|
||||
TidalBaseRequest::QueryType type = TidalBaseRequest::QueryType_None;
|
||||
TidalBaseRequest::QueryType query_type = TidalBaseRequest::QueryType::None;
|
||||
|
||||
switch (pending_search_type_) {
|
||||
case InternetSearchView::SearchType_Artists:
|
||||
type = TidalBaseRequest::QueryType_SearchArtists;
|
||||
case InternetSearchView::SearchType::Artists:
|
||||
query_type = TidalBaseRequest::QueryType::SearchArtists;
|
||||
break;
|
||||
case InternetSearchView::SearchType_Albums:
|
||||
type = TidalBaseRequest::QueryType_SearchAlbums;
|
||||
case InternetSearchView::SearchType::Albums:
|
||||
query_type = TidalBaseRequest::QueryType::SearchAlbums;
|
||||
break;
|
||||
case InternetSearchView::SearchType_Songs:
|
||||
type = TidalBaseRequest::QueryType_SearchSongs;
|
||||
case InternetSearchView::SearchType::Songs:
|
||||
query_type = TidalBaseRequest::QueryType::SearchSongs;
|
||||
break;
|
||||
default:
|
||||
//Error("Invalid search type.");
|
||||
return;
|
||||
}
|
||||
|
||||
search_request_.reset(new TidalRequest(this, url_handler_, app_, network_, type, this), [](TidalRequest *request) { request->deleteLater(); });
|
||||
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);
|
||||
|
||||
@@ -119,12 +119,12 @@ void TidalStreamURLRequest::GetStreamURL() {
|
||||
ParamList params;
|
||||
|
||||
switch (stream_url_method()) {
|
||||
case TidalSettingsPage::StreamUrlMethod_StreamUrl:
|
||||
case TidalSettingsPage::StreamUrlMethod::StreamUrl:
|
||||
params << Param("soundQuality", quality());
|
||||
reply_ = CreateRequest(QString("tracks/%1/streamUrl").arg(song_id_), params);
|
||||
QObject::connect(reply_, &QNetworkReply::finished, this, &TidalStreamURLRequest::StreamURLReceived);
|
||||
break;
|
||||
case TidalSettingsPage::StreamUrlMethod_UrlPostPaywall:
|
||||
case TidalSettingsPage::StreamUrlMethod::UrlPostPaywall:
|
||||
params << Param("audioquality", quality());
|
||||
params << Param("playbackmode", "STREAM");
|
||||
params << Param("assetpresentation", "FULL");
|
||||
@@ -132,7 +132,7 @@ void TidalStreamURLRequest::GetStreamURL() {
|
||||
reply_ = CreateRequest(QString("tracks/%1/urlpostpaywall").arg(song_id_), params);
|
||||
QObject::connect(reply_, &QNetworkReply::finished, this, &TidalStreamURLRequest::StreamURLReceived);
|
||||
break;
|
||||
case TidalSettingsPage::StreamUrlMethod_PlaybackInfoPostPaywall:
|
||||
case TidalSettingsPage::StreamUrlMethod::PlaybackInfoPostPaywall:
|
||||
params << Param("audioquality", quality());
|
||||
params << Param("playbackmode", "STREAM");
|
||||
params << Param("assetpresentation", "FULL");
|
||||
@@ -180,16 +180,16 @@ void TidalStreamURLRequest::StreamURLReceived() {
|
||||
return;
|
||||
}
|
||||
|
||||
Song::FileType filetype(Song::FileType_Stream);
|
||||
Song::FileType filetype(Song::FileType::Stream);
|
||||
|
||||
if (json_obj.contains("codec") || json_obj.contains("codecs")) {
|
||||
QString codec;
|
||||
if (json_obj.contains("codec")) codec = json_obj["codec"].toString().toLower();
|
||||
if (json_obj.contains("codecs")) codec = json_obj["codecs"].toString().toLower();
|
||||
filetype = Song::FiletypeByExtension(codec);
|
||||
if (filetype == Song::FileType_Unknown) {
|
||||
if (filetype == Song::FileType::Unknown) {
|
||||
qLog(Debug) << "Tidal: Unknown codec" << codec;
|
||||
filetype = Song::FileType_Stream;
|
||||
filetype = Song::FileType::Stream;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -237,11 +237,11 @@ void TidalStreamURLRequest::StreamURLReceived() {
|
||||
QStringList suffixes = mimedb.mimeTypeForName(mimetype.toUtf8()).suffixes();
|
||||
for (const QString &suffix : suffixes) {
|
||||
filetype = Song::FiletypeByExtension(suffix);
|
||||
if (filetype != Song::FileType_Unknown) break;
|
||||
if (filetype != Song::FileType::Unknown) break;
|
||||
}
|
||||
if (filetype == Song::FileType_Unknown) {
|
||||
if (filetype == Song::FileType::Unknown) {
|
||||
qLog(Debug) << "Tidal: Unknown mimetype" << mimetype;
|
||||
filetype = Song::FileType_Stream;
|
||||
filetype = Song::FileType::Stream;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -263,10 +263,10 @@ void TidalStreamURLRequest::StreamURLReceived() {
|
||||
else if (json_obj.contains("url")) {
|
||||
QUrl new_url(json_obj["url"].toString());
|
||||
urls << new_url;
|
||||
if (filetype == Song::FileType_Stream) {
|
||||
if (filetype == Song::FileType::Stream) {
|
||||
// Guess filetype by filename extension in URL.
|
||||
filetype = Song::FiletypeByExtension(QFileInfo(new_url.path()).suffix());
|
||||
if (filetype == Song::FileType_Unknown) filetype = Song::FileType_Stream;
|
||||
if (filetype == Song::FileType::Unknown) filetype = Song::FileType::Stream;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -47,13 +47,13 @@ UrlHandler::LoadResult TidalUrlHandler::StartLoading(const QUrl &url) {
|
||||
req.id = service_->GetStreamURL(url, error);
|
||||
if (req.id == 0) {
|
||||
CancelTask(req.task_id);
|
||||
return LoadResult(url, LoadResult::Error, error);
|
||||
return LoadResult(url, LoadResult::Type::Error, error);
|
||||
}
|
||||
|
||||
requests_.insert(req.id, req);
|
||||
|
||||
LoadResult ret(url);
|
||||
ret.type_ = LoadResult::WillLoadAsynchronously;
|
||||
ret.type_ = LoadResult::Type::WillLoadAsynchronously;
|
||||
|
||||
return ret;
|
||||
|
||||
@@ -65,7 +65,7 @@ void TidalUrlHandler::GetStreamURLFailure(const uint id, const QUrl &original_ur
|
||||
Request req = requests_.take(id);
|
||||
CancelTask(req.task_id);
|
||||
|
||||
emit AsyncLoadComplete(LoadResult(original_url, LoadResult::Error, error));
|
||||
emit AsyncLoadComplete(LoadResult(original_url, LoadResult::Type::Error, error));
|
||||
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ void TidalUrlHandler::GetStreamURLSuccess(const uint id, const QUrl &original_ur
|
||||
Request req = requests_.take(id);
|
||||
CancelTask(req.task_id);
|
||||
|
||||
emit AsyncLoadComplete(LoadResult(original_url, LoadResult::TrackAvailable, stream_url, filetype, samplerate, bit_depth, duration));
|
||||
emit AsyncLoadComplete(LoadResult(original_url, LoadResult::Type::TrackAvailable, stream_url, filetype, samplerate, bit_depth, duration));
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user