Use C++11 enum class
This commit is contained in:
@@ -47,15 +47,15 @@ class QobuzBaseRequest : public QObject {
|
||||
explicit QobuzBaseRequest(QobuzService *service, NetworkAccessManager *network, QObject *parent = nullptr);
|
||||
~QobuzBaseRequest();
|
||||
|
||||
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:
|
||||
|
||||
@@ -54,11 +54,11 @@ QobuzFavoriteRequest::~QobuzFavoriteRequest() {
|
||||
QString QobuzFavoriteRequest::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:
|
||||
default:
|
||||
return "tracks";
|
||||
}
|
||||
@@ -68,13 +68,13 @@ QString QobuzFavoriteRequest::FavoriteText(const FavoriteType type) {
|
||||
QString QobuzFavoriteRequest::FavoriteMethod(const FavoriteType type) {
|
||||
|
||||
switch (type) {
|
||||
case FavoriteType_Artists:
|
||||
case FavoriteType::Artists:
|
||||
return "artist_ids";
|
||||
break;
|
||||
case FavoriteType_Albums:
|
||||
case FavoriteType::Albums:
|
||||
return "album_ids";
|
||||
break;
|
||||
case FavoriteType_Songs:
|
||||
case FavoriteType::Songs:
|
||||
return "track_ids";
|
||||
break;
|
||||
}
|
||||
@@ -84,19 +84,19 @@ QString QobuzFavoriteRequest::FavoriteMethod(const FavoriteType type) {
|
||||
}
|
||||
|
||||
void QobuzFavoriteRequest::AddArtists(const SongList &songs) {
|
||||
AddFavorites(FavoriteType_Artists, songs);
|
||||
AddFavorites(FavoriteType::Artists, songs);
|
||||
}
|
||||
|
||||
void QobuzFavoriteRequest::AddAlbums(const SongList &songs) {
|
||||
AddFavorites(FavoriteType_Albums, songs);
|
||||
AddFavorites(FavoriteType::Albums, songs);
|
||||
}
|
||||
|
||||
void QobuzFavoriteRequest::AddSongs(const SongList &songs) {
|
||||
AddFavorites(FavoriteType_Songs, songs);
|
||||
AddFavorites(FavoriteType::Songs, songs);
|
||||
}
|
||||
|
||||
void QobuzFavoriteRequest::AddSongs(const SongMap &songs) {
|
||||
AddFavoritesRequest(FavoriteType_Songs, songs.keys(), songs.values());
|
||||
AddFavoritesRequest(FavoriteType::Songs, songs.keys(), songs.values());
|
||||
}
|
||||
|
||||
void QobuzFavoriteRequest::AddFavorites(const FavoriteType type, const SongList &songs) {
|
||||
@@ -105,15 +105,15 @@ void QobuzFavoriteRequest::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;
|
||||
@@ -165,13 +165,13 @@ void QobuzFavoriteRequest::AddFavoritesReply(QNetworkReply *reply, const Favorit
|
||||
qLog(Debug) << "Qobuz:" << 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;
|
||||
}
|
||||
@@ -179,19 +179,19 @@ void QobuzFavoriteRequest::AddFavoritesReply(QNetworkReply *reply, const Favorit
|
||||
}
|
||||
|
||||
void QobuzFavoriteRequest::RemoveArtists(const SongList &songs) {
|
||||
RemoveFavorites(FavoriteType_Artists, songs);
|
||||
RemoveFavorites(FavoriteType::Artists, songs);
|
||||
}
|
||||
|
||||
void QobuzFavoriteRequest::RemoveAlbums(const SongList &songs) {
|
||||
RemoveFavorites(FavoriteType_Albums, songs);
|
||||
RemoveFavorites(FavoriteType::Albums, songs);
|
||||
}
|
||||
|
||||
void QobuzFavoriteRequest::RemoveSongs(const SongList &songs) {
|
||||
RemoveFavorites(FavoriteType_Songs, songs);
|
||||
RemoveFavorites(FavoriteType::Songs, songs);
|
||||
}
|
||||
|
||||
void QobuzFavoriteRequest::RemoveSongs(const SongMap &songs) {
|
||||
RemoveFavoritesRequest(FavoriteType_Songs, songs.keys(), songs.values());
|
||||
RemoveFavoritesRequest(FavoriteType::Songs, songs.keys(), songs.values());
|
||||
}
|
||||
|
||||
void QobuzFavoriteRequest::RemoveFavorites(const FavoriteType type, const SongList &songs) {
|
||||
@@ -200,15 +200,15 @@ void QobuzFavoriteRequest::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;
|
||||
@@ -259,13 +259,13 @@ void QobuzFavoriteRequest::RemoveFavoritesReply(QNetworkReply *reply, const Favo
|
||||
qLog(Debug) << "Qobuz:" << 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,10 +41,11 @@ class QobuzFavoriteRequest : public QobuzBaseRequest {
|
||||
explicit QobuzFavoriteRequest(QobuzService *service, NetworkAccessManager *network, QObject *parent = nullptr);
|
||||
~QobuzFavoriteRequest();
|
||||
|
||||
enum FavoriteType {
|
||||
FavoriteType_Artists,
|
||||
FavoriteType_Albums,
|
||||
FavoriteType_Songs
|
||||
private:
|
||||
enum class FavoriteType {
|
||||
Artists,
|
||||
Albums,
|
||||
Songs
|
||||
};
|
||||
|
||||
signals:
|
||||
|
||||
@@ -51,14 +51,14 @@ constexpr int QobuzRequest::kMaxConcurrentAlbumSongsRequests = 3;
|
||||
constexpr int QobuzRequest::kMaxConcurrentAlbumCoverRequests = 1;
|
||||
constexpr int QobuzRequest::kFlushRequestsDelay = 200;
|
||||
|
||||
QobuzRequest::QobuzRequest(QobuzService *service, QobuzUrlHandler *url_handler, Application *app, NetworkAccessManager *network, QueryType type, QObject *parent)
|
||||
QobuzRequest::QobuzRequest(QobuzService *service, QobuzUrlHandler *url_handler, Application *app, NetworkAccessManager *network, const QueryType query_type, QObject *parent)
|
||||
: QobuzBaseRequest(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),
|
||||
query_id_(-1),
|
||||
finished_(false),
|
||||
artists_requests_total_(0),
|
||||
@@ -117,23 +117,23 @@ QobuzRequest::~QobuzRequest() {
|
||||
|
||||
void QobuzRequest::Process() {
|
||||
|
||||
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:
|
||||
@@ -220,18 +220,18 @@ void QobuzRequest::FlushArtistsRequests() {
|
||||
Request request = artists_requests_queue_.dequeue();
|
||||
|
||||
ParamList params;
|
||||
if (type_ == QueryType_Artists) {
|
||||
if (query_type_ == QueryType::Artists) {
|
||||
params << Param("type", "artists");
|
||||
params << Param("user_auth_token", user_auth_token());
|
||||
}
|
||||
else if (type_ == QueryType_SearchArtists) params << Param("query", search_text_);
|
||||
else if (query_type_ == QueryType::SearchArtists) params << Param("query", search_text_);
|
||||
if (request.limit > 0) params << Param("limit", QString::number(request.limit));
|
||||
if (request.offset > 0) params << Param("offset", QString::number(request.offset));
|
||||
QNetworkReply *reply = nullptr;
|
||||
if (type_ == QueryType_Artists) {
|
||||
if (query_type_ == QueryType::Artists) {
|
||||
reply = CreateRequest(QString("favorite/getUserFavorites"), params);
|
||||
}
|
||||
else if (type_ == QueryType_SearchArtists) {
|
||||
else if (query_type_ == QueryType::SearchArtists) {
|
||||
reply = CreateRequest("artist/search", params);
|
||||
}
|
||||
if (!reply) continue;
|
||||
@@ -272,18 +272,18 @@ void QobuzRequest::FlushAlbumsRequests() {
|
||||
Request request = albums_requests_queue_.dequeue();
|
||||
|
||||
ParamList params;
|
||||
if (type_ == QueryType_Albums) {
|
||||
if (query_type_ == QueryType::Albums) {
|
||||
params << Param("type", "albums");
|
||||
params << Param("user_auth_token", user_auth_token());
|
||||
}
|
||||
else if (type_ == QueryType_SearchAlbums) params << Param("query", search_text_);
|
||||
else if (query_type_ == QueryType::SearchAlbums) params << Param("query", search_text_);
|
||||
if (request.limit > 0) params << Param("limit", QString::number(request.limit));
|
||||
if (request.offset > 0) params << Param("offset", QString::number(request.offset));
|
||||
QNetworkReply *reply = nullptr;
|
||||
if (type_ == QueryType_Albums) {
|
||||
if (query_type_ == QueryType::Albums) {
|
||||
reply = CreateRequest(QString("favorite/getUserFavorites"), params);
|
||||
}
|
||||
else if (type_ == QueryType_SearchAlbums) {
|
||||
else if (query_type_ == QueryType::SearchAlbums) {
|
||||
reply = CreateRequest("album/search", params);
|
||||
}
|
||||
if (!reply) continue;
|
||||
@@ -324,18 +324,18 @@ void QobuzRequest::FlushSongsRequests() {
|
||||
Request request = songs_requests_queue_.dequeue();
|
||||
|
||||
ParamList params;
|
||||
if (type_ == QueryType_Songs) {
|
||||
if (query_type_ == QueryType::Songs) {
|
||||
params << Param("type", "tracks");
|
||||
params << Param("user_auth_token", user_auth_token());
|
||||
}
|
||||
else if (type_ == QueryType_SearchSongs) params << Param("query", search_text_);
|
||||
else if (query_type_ == QueryType::SearchSongs) params << Param("query", search_text_);
|
||||
if (request.limit > 0) params << Param("limit", QString::number(request.limit));
|
||||
if (request.offset > 0) params << Param("offset", QString::number(request.offset));
|
||||
QNetworkReply *reply = nullptr;
|
||||
if (type_ == QueryType_Songs) {
|
||||
if (query_type_ == QueryType::Songs) {
|
||||
reply = CreateRequest(QString("favorite/getUserFavorites"), params);
|
||||
}
|
||||
else if (type_ == QueryType_SearchSongs) {
|
||||
else if (query_type_ == QueryType::SearchSongs) {
|
||||
reply = CreateRequest("track/search", params);
|
||||
}
|
||||
if (!reply) continue;
|
||||
@@ -528,8 +528,8 @@ void QobuzRequest::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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -683,7 +683,7 @@ void QobuzRequest::AlbumsReceived(QNetworkReply *reply, const Artist &artist_req
|
||||
}
|
||||
QJsonArray array_items = value_items.toArray();
|
||||
if (array_items.isEmpty()) {
|
||||
if ((type_ == QueryType_Albums || type_ == QueryType_SearchAlbums) && offset_requested == 0) {
|
||||
if ((query_type_ == QueryType::Albums || query_type_ == QueryType::SearchAlbums) && offset_requested == 0) {
|
||||
no_results_ = true;
|
||||
}
|
||||
AlbumsFinishCheck(artist_requested);
|
||||
@@ -749,7 +749,7 @@ void QobuzRequest::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_));
|
||||
}
|
||||
@@ -765,15 +765,15 @@ void QobuzRequest::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:
|
||||
@@ -978,7 +978,7 @@ void QobuzRequest::SongsReceived(QNetworkReply *reply, const Artist &artist_requ
|
||||
|
||||
QJsonArray array_items = value_items.toArray();
|
||||
if (array_items.isEmpty()) {
|
||||
if ((type_ == QueryType_Songs || type_ == QueryType_SearchSongs) && offset_requested == 0) {
|
||||
if ((query_type_ == QueryType::Songs || query_type_ == QueryType::SearchSongs) && offset_requested == 0) {
|
||||
no_results_ = true;
|
||||
}
|
||||
SongsFinishCheck(album_artist, album, limit_requested, offset_requested, songs_total);
|
||||
@@ -998,7 +998,7 @@ void QobuzRequest::SongsReceived(QNetworkReply *reply, const Artist &artist_requ
|
||||
QJsonObject obj_item = value_item.toObject();
|
||||
|
||||
++songs_received;
|
||||
Song song(Song::Source_Qobuz);
|
||||
Song song(Song::Source::Qobuz);
|
||||
ParseSong(song, obj_item, album_artist, album);
|
||||
if (!song.is_valid()) continue;
|
||||
if (song.disc() >= 2) multidisc = true;
|
||||
@@ -1012,7 +1012,7 @@ void QobuzRequest::SongsReceived(QNetworkReply *reply, const Artist &artist_requ
|
||||
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_));
|
||||
}
|
||||
@@ -1028,17 +1028,17 @@ void QobuzRequest::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:
|
||||
AddSongsSearchRequest(offset_next);
|
||||
break;
|
||||
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:
|
||||
@@ -1184,7 +1184,7 @@ void QobuzRequest::ParseSong(Song &song, const QJsonObject &json_obj, const Arti
|
||||
|
||||
//qLog(Debug) << "id" << song_id << "track" << track << "title" << title << "album" << album << "album artist" << album_artist << cover_url << streamable << url;
|
||||
|
||||
song.set_source(Song::Source_Qobuz);
|
||||
song.set_source(Song::Source::Qobuz);
|
||||
song.set_song_id(song_id);
|
||||
song.set_album_id(song_album.album_id);
|
||||
song.set_artist_id(song_artist.artist_id);
|
||||
@@ -1202,7 +1202,7 @@ void QobuzRequest::ParseSong(Song &song, const QJsonObject &json_obj, const Arti
|
||||
song.set_composer(composer);
|
||||
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);
|
||||
|
||||
@@ -52,7 +52,7 @@ class QobuzRequest : public QobuzBaseRequest {
|
||||
|
||||
public:
|
||||
|
||||
explicit QobuzRequest(QobuzService *service, QobuzUrlHandler *url_handler, Application *app, NetworkAccessManager *network, QueryType type, QObject *parent = nullptr);
|
||||
explicit QobuzRequest(QobuzService *service, QobuzUrlHandler *url_handler, Application *app, NetworkAccessManager *network, const QueryType query_type, QObject *parent = nullptr);
|
||||
~QobuzRequest() override;
|
||||
|
||||
void ReloadSettings();
|
||||
@@ -120,8 +120,8 @@ class QobuzRequest : public QobuzBaseRequest {
|
||||
|
||||
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();
|
||||
@@ -184,7 +184,7 @@ class QobuzRequest : public QobuzBaseRequest {
|
||||
NetworkAccessManager *network_;
|
||||
QTimer *timer_flush_requests_;
|
||||
|
||||
const QueryType type_;
|
||||
const QueryType query_type_;
|
||||
int query_id_;
|
||||
QString search_text_;
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@
|
||||
#include "settings/settingsdialog.h"
|
||||
#include "settings/qobuzsettingspage.h"
|
||||
|
||||
const Song::Source QobuzService::kSource = Song::Source_Qobuz;
|
||||
const Song::Source QobuzService::kSource = Song::Source::Qobuz;
|
||||
const char QobuzService::kApiUrl[] = "https://www.qobuz.com/api.json/0.2";
|
||||
|
||||
constexpr char QobuzService::kAuthUrl[] = "https://www.qobuz.com/api.json/0.2/user/login";
|
||||
@@ -74,7 +74,7 @@ constexpr char QobuzService::kAlbumsSongsFtsTable[] = "qobuz_albums_songs_fts";
|
||||
constexpr char QobuzService::kSongsFtsTable[] = "qobuz_songs_fts";
|
||||
|
||||
QobuzService::QobuzService(Application *app, QObject *parent)
|
||||
: InternetService(Song::Source_Qobuz, "Qobuz", "qobuz", QobuzSettingsPage::kSettingsGroup, SettingsDialog::Page_Qobuz, app, parent),
|
||||
: InternetService(Song::Source::Qobuz, "Qobuz", "qobuz", QobuzSettingsPage::kSettingsGroup, SettingsDialog::Page::Qobuz, app, parent),
|
||||
app_(app),
|
||||
network_(new NetworkAccessManager(this)),
|
||||
url_handler_(new QobuzUrlHandler(app, this)),
|
||||
@@ -100,7 +100,7 @@ QobuzService::QobuzService(Application *app, QObject *parent)
|
||||
credential_id_(-1),
|
||||
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),
|
||||
@@ -112,15 +112,15 @@ QobuzService::QobuzService(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_Qobuz, kArtistsSongsTable, kArtistsSongsFtsTable);
|
||||
artists_collection_backend_->Init(app_->database(), app->task_manager(), Song::Source::Qobuz, 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_Qobuz, kAlbumsSongsTable, kAlbumsSongsFtsTable);
|
||||
albums_collection_backend_->Init(app_->database(), app->task_manager(), Song::Source::Qobuz, 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_Qobuz, kSongsTable, kSongsFtsTable);
|
||||
songs_collection_backend_->Init(app_->database(), app->task_manager(), Song::Source::Qobuz, kSongsTable, kSongsFtsTable);
|
||||
|
||||
artists_collection_model_ = new CollectionModel(artists_collection_backend_, app_, this);
|
||||
albums_collection_model_ = new CollectionModel(albums_collection_backend_, app_, this);
|
||||
@@ -221,7 +221,7 @@ void QobuzService::ExitReceived() {
|
||||
}
|
||||
|
||||
void QobuzService::ShowConfig() {
|
||||
app_->OpenSettingsDialogAtPage(SettingsDialog::Page_Qobuz);
|
||||
app_->OpenSettingsDialogAtPage(SettingsDialog::Page::Qobuz);
|
||||
}
|
||||
|
||||
void QobuzService::ReloadSettings() {
|
||||
@@ -535,7 +535,7 @@ void QobuzService::GetArtists() {
|
||||
}
|
||||
|
||||
ResetArtistsRequest();
|
||||
artists_request_.reset(new QobuzRequest(this, url_handler_, app_, network_, QobuzBaseRequest::QueryType_Artists), [](QobuzRequest *request) { request->deleteLater(); });
|
||||
artists_request_.reset(new QobuzRequest(this, url_handler_, app_, network_, QobuzBaseRequest::QueryType::Artists), [](QobuzRequest *request) { request->deleteLater(); });
|
||||
QObject::connect(artists_request_.get(), &QobuzRequest::Results, this, &QobuzService::ArtistsResultsReceived);
|
||||
QObject::connect(artists_request_.get(), &QobuzRequest::UpdateStatus, this, &QobuzService::ArtistsUpdateStatusReceived);
|
||||
QObject::connect(artists_request_.get(), &QobuzRequest::UpdateProgress, this, &QobuzService::ArtistsUpdateProgressReceived);
|
||||
@@ -585,7 +585,7 @@ void QobuzService::GetAlbums() {
|
||||
}
|
||||
|
||||
ResetAlbumsRequest();
|
||||
albums_request_.reset(new QobuzRequest(this, url_handler_, app_, network_, QobuzBaseRequest::QueryType_Albums), [](QobuzRequest *request) { request->deleteLater(); });
|
||||
albums_request_.reset(new QobuzRequest(this, url_handler_, app_, network_, QobuzBaseRequest::QueryType::Albums), [](QobuzRequest *request) { request->deleteLater(); });
|
||||
QObject::connect(albums_request_.get(), &QobuzRequest::Results, this, &QobuzService::AlbumsResultsReceived);
|
||||
QObject::connect(albums_request_.get(), &QobuzRequest::UpdateStatus, this, &QobuzService::AlbumsUpdateStatusReceived);
|
||||
QObject::connect(albums_request_.get(), &QobuzRequest::UpdateProgress, this, &QobuzService::AlbumsUpdateProgressReceived);
|
||||
@@ -635,7 +635,7 @@ void QobuzService::GetSongs() {
|
||||
}
|
||||
|
||||
ResetSongsRequest();
|
||||
songs_request_.reset(new QobuzRequest(this, url_handler_, app_, network_, QobuzBaseRequest::QueryType_Songs), [](QobuzRequest *request) { request->deleteLater(); });
|
||||
songs_request_.reset(new QobuzRequest(this, url_handler_, app_, network_, QobuzBaseRequest::QueryType::Songs), [](QobuzRequest *request) { request->deleteLater(); });
|
||||
QObject::connect(songs_request_.get(), &QobuzRequest::Results, this, &QobuzService::SongsResultsReceived);
|
||||
QObject::connect(songs_request_.get(), &QobuzRequest::UpdateStatus, this, &QobuzService::SongsUpdateStatusReceived);
|
||||
QObject::connect(songs_request_.get(), &QobuzRequest::UpdateProgress, this, &QobuzService::SongsUpdateProgressReceived);
|
||||
@@ -700,21 +700,21 @@ void QobuzService::CancelSearch() {
|
||||
|
||||
void QobuzService::SendSearch() {
|
||||
|
||||
QobuzBaseRequest::QueryType type = QobuzBaseRequest::QueryType_None;
|
||||
QobuzBaseRequest::QueryType query_type = QobuzBaseRequest::QueryType::None;
|
||||
|
||||
switch (pending_search_type_) {
|
||||
case InternetSearchView::SearchType_Artists:
|
||||
type = QobuzBaseRequest::QueryType_SearchArtists;
|
||||
case InternetSearchView::SearchType::Artists:
|
||||
query_type = QobuzBaseRequest::QueryType::SearchArtists;
|
||||
break;
|
||||
case InternetSearchView::SearchType_Albums:
|
||||
type = QobuzBaseRequest::QueryType_SearchAlbums;
|
||||
case InternetSearchView::SearchType::Albums:
|
||||
query_type = QobuzBaseRequest::QueryType::SearchAlbums;
|
||||
break;
|
||||
case InternetSearchView::SearchType_Songs:
|
||||
type = QobuzBaseRequest::QueryType_SearchSongs;
|
||||
case InternetSearchView::SearchType::Songs:
|
||||
query_type = QobuzBaseRequest::QueryType::SearchSongs;
|
||||
break;
|
||||
}
|
||||
|
||||
search_request_.reset(new QobuzRequest(this, url_handler_, app_, network_, type), [](QobuzRequest *request) { request->deleteLater(); } );
|
||||
search_request_.reset(new QobuzRequest(this, url_handler_, app_, network_, query_type), [](QobuzRequest *request) { request->deleteLater(); } );
|
||||
|
||||
QObject::connect(search_request_.get(), &QobuzRequest::Results, this, &QobuzService::SearchResultsReceived);
|
||||
QObject::connect(search_request_.get(), &QobuzRequest::UpdateStatus, this, &QobuzService::SearchUpdateStatus);
|
||||
|
||||
@@ -189,16 +189,16 @@ void QobuzStreamURLRequest::StreamURLReceived() {
|
||||
QUrl url(json_obj["url"].toString());
|
||||
QString mimetype = json_obj["mime_type"].toString();
|
||||
|
||||
Song::FileType filetype(Song::FileType_Unknown);
|
||||
Song::FileType filetype(Song::FileType::Unknown);
|
||||
QMimeDatabase mimedb;
|
||||
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) << "Qobuz: Unknown mimetype" << mimetype;
|
||||
filetype = Song::FileType_Stream;
|
||||
filetype = Song::FileType::Stream;
|
||||
}
|
||||
|
||||
if (!url.isValid()) {
|
||||
|
||||
@@ -47,13 +47,13 @@ UrlHandler::LoadResult QobuzUrlHandler::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 QobuzUrlHandler::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 QobuzUrlHandler::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