From 1a3828e2c19b2369d0bcf1b6bd0623b735962f1b Mon Sep 17 00:00:00 2001 From: Jim Broadus Date: Sat, 20 Feb 2021 13:20:04 -0800 Subject: [PATCH] protobuf: Fix namespace conflict Protobuf 3.15 adds a namespace alias for "pb" that conflicts with Clementine's. Modify Clementine to use "cpb". Patch provided by @ahesford Reference: https://github.com/protocolbuffers/protobuf/blob/5c028d6cf42e426d47f5baa6ea3f0f5c86b97beb/src/google/protobuf/port.h#L44 --- ext/clementine-spotifyblob/spotifyclient.cpp | 128 ++++++------ ext/clementine-spotifyblob/spotifyclient.h | 44 ++--- ext/clementine-tagreader/tagreaderworker.cpp | 10 +- ext/clementine-tagreader/tagreaderworker.h | 4 +- .../remotecontrolmessages.proto | 2 +- .../spotifymessages.proto | 2 +- ext/libclementine-tagreader/gmereader.cpp | 10 +- ext/libclementine-tagreader/gmereader.h | 6 +- ext/libclementine-tagreader/tagreader.cpp | 58 +++--- ext/libclementine-tagreader/tagreader.h | 26 +-- .../tagreadermessages.proto | 2 +- src/core/song.cpp | 6 +- src/core/song.h | 8 +- src/core/tagreaderclient.cpp | 28 +-- src/core/tagreaderclient.h | 4 +- src/globalsearch/spotifysearchprovider.cpp | 26 +-- src/globalsearch/spotifysearchprovider.h | 10 +- src/internet/core/cloudfileservice.cpp | 4 +- src/internet/spotify/spotifyserver.cpp | 115 +++++------ src/internet/spotify/spotifyserver.h | 41 ++-- src/internet/spotify/spotifyservice.cpp | 82 ++++---- src/internet/spotify/spotifyservice.h | 26 +-- src/internet/spotify/spotifysettingspage.cpp | 8 +- src/main.cpp | 2 +- src/networkremote/incomingdataparser.cpp | 126 ++++++------ src/networkremote/incomingdataparser.h | 32 +-- src/networkremote/networkremote.cpp | 4 +- src/networkremote/outgoingdatacreator.cpp | 183 +++++++++--------- src/networkremote/outgoingdatacreator.h | 6 +- src/networkremote/remoteclient.cpp | 26 +-- src/networkremote/remoteclient.h | 8 +- src/networkremote/songsender.cpp | 43 ++-- src/networkremote/songsender.h | 6 +- tests/song_test.cpp | 8 +- 34 files changed, 550 insertions(+), 544 deletions(-) diff --git a/ext/clementine-spotifyblob/spotifyclient.cpp b/ext/clementine-spotifyblob/spotifyclient.cpp index 367ec9319..b8470a6b7 100644 --- a/ext/clementine-spotifyblob/spotifyclient.cpp +++ b/ext/clementine-spotifyblob/spotifyclient.cpp @@ -40,7 +40,7 @@ const int SpotifyClient::kSpotifyImageIDSize = 20; const int SpotifyClient::kWaveHeaderSize = 44; SpotifyClient::SpotifyClient(QObject* parent) - : AbstractMessageHandler(nullptr, parent), + : AbstractMessageHandler(nullptr, parent), api_key_(QByteArray::fromBase64(kSpotifyApiKey)), protocol_socket_(new QTcpSocket(this)), session_(nullptr), @@ -119,8 +119,8 @@ void SpotifyClient::LoggedInCallback(sp_session* session, sp_error error) { SpotifyClient* me = reinterpret_cast(sp_session_userdata(session)); const bool success = error == SP_ERROR_OK; - pb::spotify::LoginResponse_Error error_code = - pb::spotify::LoginResponse_Error_Other; + cpb::spotify::LoginResponse_Error error_code = + cpb::spotify::LoginResponse_Error_Other; if (!success) { qLog(Warning) << "Failed to login" << sp_error_message(error); @@ -128,16 +128,16 @@ void SpotifyClient::LoggedInCallback(sp_session* session, sp_error error) { switch (error) { case SP_ERROR_BAD_USERNAME_OR_PASSWORD: - error_code = pb::spotify::LoginResponse_Error_BadUsernameOrPassword; + error_code = cpb::spotify::LoginResponse_Error_BadUsernameOrPassword; break; case SP_ERROR_USER_BANNED: - error_code = pb::spotify::LoginResponse_Error_UserBanned; + error_code = cpb::spotify::LoginResponse_Error_UserBanned; break; case SP_ERROR_USER_NEEDS_PREMIUM: - error_code = pb::spotify::LoginResponse_Error_UserNeedsPremium; + error_code = cpb::spotify::LoginResponse_Error_UserNeedsPremium; break; default: - error_code = pb::spotify::LoginResponse_Error_Other; + error_code = cpb::spotify::LoginResponse_Error_Other; break; } @@ -166,7 +166,7 @@ void SpotifyClient::LogMessageCallback(sp_session* session, const char* data) { qLog(Debug) << "libspotify:" << QString::fromUtf8(data).trimmed(); } -void SpotifyClient::Search(const pb::spotify::SearchRequest& req) { +void SpotifyClient::Search(const cpb::spotify::SearchRequest& req) { sp_search* search = sp_search_create(session_, req.query().c_str(), 0, req.limit(), 0, req.limit_album(), 0, 0, // artists @@ -221,11 +221,11 @@ void SpotifyClient::SearchAlbumBrowseComplete(sp_albumbrowse* result, void SpotifyClient::SendSearchResponse(sp_search* result) { // Take the request out of the queue - pb::spotify::SearchRequest req = pending_searches_.take(result); + cpb::spotify::SearchRequest req = pending_searches_.take(result); // Prepare the response - pb::spotify::Message message; - pb::spotify::SearchResponse* response = message.mutable_search_response(); + cpb::spotify::Message message; + cpb::spotify::SearchResponse* response = message.mutable_search_response(); *response->mutable_request() = req; @@ -250,7 +250,7 @@ void SpotifyClient::SendSearchResponse(sp_search* result) { QList browses = pending_search_album_browses_.take(result); for (sp_albumbrowse* browse : browses) { sp_album* album = sp_albumbrowse_album(browse); - pb::spotify::Album* msg = response->add_album(); + cpb::spotify::Album* msg = response->add_album(); ConvertAlbum(album, msg->mutable_metadata()); ConvertAlbumBrowse(browse, msg->mutable_metadata()); @@ -272,7 +272,7 @@ void SpotifyClient::SendSearchResponse(sp_search* result) { sp_search_release(result); } -void SpotifyClient::MessageArrived(const pb::spotify::Message& message) { +void SpotifyClient::MessageArrived(const cpb::spotify::Message& message) { if (message.has_login_request()) { Login(message.login_request()); } else if (message.has_load_playlist_request()) { @@ -303,16 +303,16 @@ void SpotifyClient::MessageArrived(const pb::spotify::Message& message) { } void SpotifyClient::SetPlaybackSettings( - const pb::spotify::PlaybackSettings& req) { + const cpb::spotify::PlaybackSettings& req) { sp_bitrate bitrate = SP_BITRATE_320k; switch (req.bitrate()) { - case pb::spotify::Bitrate96k: + case cpb::spotify::Bitrate96k: bitrate = SP_BITRATE_96k; break; - case pb::spotify::Bitrate160k: + case cpb::spotify::Bitrate160k: bitrate = SP_BITRATE_160k; break; - case pb::spotify::Bitrate320k: + case cpb::spotify::Bitrate320k: bitrate = SP_BITRATE_320k; break; } @@ -325,12 +325,12 @@ void SpotifyClient::SetPlaybackSettings( sp_session_set_volume_normalization(session_, req.volume_normalisation()); } -void SpotifyClient::Login(const pb::spotify::LoginRequest& req) { +void SpotifyClient::Login(const cpb::spotify::LoginRequest& req) { sp_error error = sp_session_create(&spotify_config_, &session_); if (error != SP_ERROR_OK) { qLog(Warning) << "Failed to create session" << sp_error_message(error); SendLoginCompleted(false, sp_error_message(error), - pb::spotify::LoginResponse_Error_Other); + cpb::spotify::LoginResponse_Error_Other); return; } @@ -341,7 +341,7 @@ void SpotifyClient::Login(const pb::spotify::LoginRequest& req) { if (error != SP_ERROR_OK) { qLog(Warning) << "Tried to relogin but no stored credentials"; SendLoginCompleted(false, sp_error_message(error), - pb::spotify::LoginResponse_Error_ReloginFailed); + cpb::spotify::LoginResponse_Error_ReloginFailed); } } else { sp_session_login(session_, req.username().c_str(), req.password().c_str(), @@ -352,10 +352,10 @@ void SpotifyClient::Login(const pb::spotify::LoginRequest& req) { void SpotifyClient::SendLoginCompleted( bool success, const QString& error, - pb::spotify::LoginResponse_Error error_code) { - pb::spotify::Message message; + cpb::spotify::LoginResponse_Error error_code) { + cpb::spotify::Message message; - pb::spotify::LoginResponse* response = message.mutable_login_response(); + cpb::spotify::LoginResponse* response = message.mutable_login_response(); response->set_success(success); response->set_error(DataCommaSizeFromQString(error)); @@ -412,8 +412,8 @@ void SpotifyClient::PlaylistRemovedCallback(sp_playlistcontainer* pc, } void SpotifyClient::SendPlaylistList() { - pb::spotify::Message message; - pb::spotify::Playlists* response = message.mutable_playlists_updated(); + cpb::spotify::Message message; + cpb::spotify::Playlists* response = message.mutable_playlists_updated(); sp_playlistcontainer* container = sp_session_playlistcontainer(session_); if (!container) { @@ -441,7 +441,7 @@ void SpotifyClient::SendPlaylistList() { continue; } - pb::spotify::Playlists::Playlist* msg = response->add_playlist(); + cpb::spotify::Playlists::Playlist* msg = response->add_playlist(); msg->set_index(i); msg->set_name(sp_playlist_name(playlist)); sp_user* playlist_owner = sp_playlist_owner(playlist); @@ -470,19 +470,19 @@ void SpotifyClient::SendPlaylistList() { SendMessage(message); } -sp_playlist* SpotifyClient::GetPlaylist(pb::spotify::PlaylistType type, +sp_playlist* SpotifyClient::GetPlaylist(cpb::spotify::PlaylistType type, int user_index) { sp_playlist* playlist = nullptr; switch (type) { - case pb::spotify::Inbox: + case cpb::spotify::Inbox: playlist = sp_session_inbox_create(session_); break; - case pb::spotify::Starred: + case cpb::spotify::Starred: playlist = sp_session_starred_create(session_); break; - case pb::spotify::UserPlaylist: { + case cpb::spotify::UserPlaylist: { sp_playlistcontainer* pc = sp_session_playlistcontainer(session_); if (pc && user_index <= sp_playlistcontainer_num_playlists(pc)) { @@ -499,7 +499,7 @@ sp_playlist* SpotifyClient::GetPlaylist(pb::spotify::PlaylistType type, return playlist; } -void SpotifyClient::LoadPlaylist(const pb::spotify::LoadPlaylistRequest& req) { +void SpotifyClient::LoadPlaylist(const cpb::spotify::LoadPlaylistRequest& req) { PendingLoadPlaylist pending_load; pending_load.request_ = req; pending_load.playlist_ = GetPlaylist(req.type(), req.user_playlist_index()); @@ -509,8 +509,8 @@ void SpotifyClient::LoadPlaylist(const pb::spotify::LoadPlaylistRequest& req) { if (!pending_load.playlist_) { qLog(Warning) << "Invalid playlist requested or not logged in"; - pb::spotify::Message message; - pb::spotify::LoadPlaylistResponse* response = + cpb::spotify::Message message; + cpb::spotify::LoadPlaylistResponse* response = message.mutable_load_playlist_response(); *response->mutable_request() = req; SendMessage(message); @@ -524,7 +524,7 @@ void SpotifyClient::LoadPlaylist(const pb::spotify::LoadPlaylistRequest& req) { PlaylistStateChangedForLoadPlaylist(pending_load.playlist_, this); } -void SpotifyClient::SyncPlaylist(const pb::spotify::SyncPlaylistRequest& req) { +void SpotifyClient::SyncPlaylist(const cpb::spotify::SyncPlaylistRequest& req) { sp_playlist* playlist = GetPlaylist(req.request().type(), req.request().user_playlist_index()); @@ -577,13 +577,13 @@ void SpotifyClient::PlaylistStateChangedForLoadPlaylist(sp_playlist* pl, } // Everything is loaded so send the response protobuf and unref everything. - pb::spotify::Message message; - pb::spotify::LoadPlaylistResponse* response = + cpb::spotify::Message message; + cpb::spotify::LoadPlaylistResponse* response = message.mutable_load_playlist_response(); // For some reason, we receive the starred tracks in reverse order but not // other playlists. - if (pending_load->request_.type() == pb::spotify::Starred) { + if (pending_load->request_.type() == cpb::spotify::Starred) { std::reverse(pending_load->tracks_.begin(), pending_load->tracks_.end()); } @@ -610,7 +610,7 @@ void SpotifyClient::PlaylistStateChangedForGetPlaylists(sp_playlist* pl, } void SpotifyClient::AddTracksToPlaylist( - const pb::spotify::AddTracksToPlaylistRequest& req) { + const cpb::spotify::AddTracksToPlaylistRequest& req) { // Get the playlist we want to update sp_playlist* playlist = GetPlaylist(req.playlist_type(), req.playlist_index()); @@ -649,7 +649,7 @@ void SpotifyClient::AddTracksToPlaylist( } void SpotifyClient::RemoveTracksFromPlaylist( - const pb::spotify::RemoveTracksFromPlaylistRequest& req) { + const cpb::spotify::RemoveTracksFromPlaylistRequest& req) { // Get the playlist we want to update sp_playlist* playlist = GetPlaylist(req.playlist_type(), req.playlist_index()); @@ -667,7 +667,7 @@ void SpotifyClient::RemoveTracksFromPlaylist( // WTF: sp_playlist_remove_tracks indexes start from the end for starred // playlist, not from the beginning like other playlists: reverse them - if (req.playlist_type() == pb::spotify::Starred) { + if (req.playlist_type() == cpb::spotify::Starred) { int num_tracks = sp_playlist_num_tracks(playlist); for (int i = 0; i < req.track_index_size(); i++) { tracks_indices_array[i] = num_tracks - tracks_indices_array[i] - 1; @@ -680,7 +680,7 @@ void SpotifyClient::RemoveTracksFromPlaylist( } } -void SpotifyClient::ConvertTrack(sp_track* track, pb::spotify::Track* pb) { +void SpotifyClient::ConvertTrack(sp_track* track, cpb::spotify::Track* pb) { sp_album* album = sp_track_album(track); pb->set_starred(sp_track_is_starred(session_, track)); @@ -713,7 +713,7 @@ void SpotifyClient::ConvertTrack(sp_track* track, pb::spotify::Track* pb) { pb->set_uri(uri); } -void SpotifyClient::ConvertAlbum(sp_album* album, pb::spotify::Track* pb) { +void SpotifyClient::ConvertAlbum(sp_album* album, cpb::spotify::Track* pb) { pb->set_album(sp_album_name(album)); pb->set_year(sp_album_year(album)); pb->add_artist(sp_artist_name(sp_album_artist(album))); @@ -744,7 +744,7 @@ void SpotifyClient::ConvertAlbum(sp_album* album, pb::spotify::Track* pb) { } void SpotifyClient::ConvertAlbumBrowse(sp_albumbrowse* browse, - pb::spotify::Track* pb) { + cpb::spotify::Track* pb) { pb->set_track(sp_albumbrowse_num_tracks(browse)); } @@ -853,7 +853,7 @@ void SpotifyClient::OfflineStatusUpdatedCallback(sp_session* session) { int download_progress = me->GetDownloadProgress(playlist); if (download_progress != -1) { - me->SendDownloadProgress(pb::spotify::UserPlaylist, i, download_progress); + me->SendDownloadProgress(cpb::spotify::UserPlaylist, i, download_progress); } } @@ -862,7 +862,7 @@ void SpotifyClient::OfflineStatusUpdatedCallback(sp_session* session) { sp_playlist_release(inbox); if (download_progress != -1) { - me->SendDownloadProgress(pb::spotify::Inbox, -1, download_progress); + me->SendDownloadProgress(cpb::spotify::Inbox, -1, download_progress); } sp_playlist* starred = sp_session_starred_create(session); @@ -870,14 +870,14 @@ void SpotifyClient::OfflineStatusUpdatedCallback(sp_session* session) { sp_playlist_release(starred); if (download_progress != -1) { - me->SendDownloadProgress(pb::spotify::Starred, -1, download_progress); + me->SendDownloadProgress(cpb::spotify::Starred, -1, download_progress); } } -void SpotifyClient::SendDownloadProgress(pb::spotify::PlaylistType type, +void SpotifyClient::SendDownloadProgress(cpb::spotify::PlaylistType type, int index, int download_progress) { - pb::spotify::Message message; - pb::spotify::SyncPlaylistProgress* progress = + cpb::spotify::Message message; + cpb::spotify::SyncPlaylistProgress* progress = message.mutable_sync_playlist_progress(); progress->mutable_request()->set_type(type); if (index != -1) { @@ -903,7 +903,7 @@ int SpotifyClient::GetDownloadProgress(sp_playlist* playlist) { return -1; } -void SpotifyClient::StartPlayback(const pb::spotify::PlaybackRequest& req) { +void SpotifyClient::StartPlayback(const cpb::spotify::PlaybackRequest& req) { // Get a link object from the URI sp_link* link = sp_link_create_from_string(req.track_uri().c_str()); if (!link) { @@ -970,8 +970,8 @@ void SpotifyClient::TryPlaybackAgain(const PendingPlaybackRequest& req) { } void SpotifyClient::SendPlaybackError(const QString& error) { - pb::spotify::Message message; - pb::spotify::PlaybackError* msg = message.mutable_playback_error(); + cpb::spotify::Message message; + cpb::spotify::PlaybackError* msg = message.mutable_playback_error(); msg->set_error(DataCommaSizeFromQString(error)); SendMessage(message); @@ -984,8 +984,8 @@ void SpotifyClient::LoadImage(const QString& id_b64) { << kSpotifyImageIDSize << "bytes):" << id_b64; // Send an error response straight away - pb::spotify::Message message; - pb::spotify::ImageResponse* msg = message.mutable_image_response(); + cpb::spotify::Message message; + cpb::spotify::ImageResponse* msg = message.mutable_image_response(); msg->set_id(DataCommaSizeFromQString(id_b64)); SendMessage(message); return; @@ -1033,8 +1033,8 @@ void SpotifyClient::TryImageAgain(sp_image* image) { const void* data = sp_image_data(image, &size); // Send the response - pb::spotify::Message message; - pb::spotify::ImageResponse* msg = message.mutable_image_response(); + cpb::spotify::Message message; + cpb::spotify::ImageResponse* msg = message.mutable_image_response(); msg->set_id(DataCommaSizeFromQString(req->id_b64_)); if (data && size) { msg->set_data(data, size); @@ -1086,8 +1086,8 @@ void SpotifyClient::AlbumBrowseComplete(sp_albumbrowse* result, QString uri = me->pending_album_browses_.take(result); - pb::spotify::Message message; - pb::spotify::BrowseAlbumResponse* msg = + cpb::spotify::Message message; + cpb::spotify::BrowseAlbumResponse* msg = message.mutable_browse_album_response(); msg->set_uri(DataCommaSizeFromQString(uri)); @@ -1102,7 +1102,7 @@ void SpotifyClient::AlbumBrowseComplete(sp_albumbrowse* result, } void SpotifyClient::BrowseToplist( - const pb::spotify::BrowseToplistRequest& req) { + const cpb::spotify::BrowseToplistRequest& req) { sp_toplistbrowse* browse = sp_toplistbrowse_create( session_, SP_TOPLIST_TYPE_TRACKS, // TODO: Support albums and artists. SP_TOPLIST_REGION_EVERYWHERE, // TODO: Support other regions. @@ -1110,7 +1110,7 @@ void SpotifyClient::BrowseToplist( pending_toplist_browses_[browse] = req; } -void SpotifyClient::SetPaused(const pb::spotify::PauseRequest& req) { +void SpotifyClient::SetPaused(const cpb::spotify::PauseRequest& req) { sp_session_player_play(session_, !req.paused()); } @@ -1125,11 +1125,11 @@ void SpotifyClient::ToplistBrowseComplete(sp_toplistbrowse* result, return; } - const pb::spotify::BrowseToplistRequest& request = + const cpb::spotify::BrowseToplistRequest& request = me->pending_toplist_browses_.take(result); - pb::spotify::Message message; - pb::spotify::BrowseToplistResponse* msg = + cpb::spotify::Message message; + cpb::spotify::BrowseToplistResponse* msg = message.mutable_browse_toplist_response(); msg->mutable_request()->CopyFrom(request); @@ -1143,7 +1143,7 @@ void SpotifyClient::ToplistBrowseComplete(sp_toplistbrowse* result, } void SpotifyClient::DeviceClosed() { - AbstractMessageHandler::DeviceClosed(); + AbstractMessageHandler::DeviceClosed(); qApp->exit(); } diff --git a/ext/clementine-spotifyblob/spotifyclient.h b/ext/clementine-spotifyblob/spotifyclient.h index 7f60b0e51..a496c2864 100644 --- a/ext/clementine-spotifyblob/spotifyclient.h +++ b/ext/clementine-spotifyblob/spotifyclient.h @@ -35,7 +35,7 @@ class QTimer; class MediaPipeline; class ResponseMessage; -class SpotifyClient : public AbstractMessageHandler { +class SpotifyClient : public AbstractMessageHandler { Q_OBJECT public: @@ -48,7 +48,7 @@ class SpotifyClient : public AbstractMessageHandler { void Init(quint16 port); protected: - void MessageArrived(const pb::spotify::Message& message); + void MessageArrived(const cpb::spotify::Message& message); void DeviceClosed(); private slots: @@ -56,7 +56,7 @@ class SpotifyClient : public AbstractMessageHandler { private: void SendLoginCompleted(bool success, const QString& error, - pb::spotify::LoginResponse_Error error_code); + cpb::spotify::LoginResponse_Error error_code); void SendPlaybackError(const QString& error); void SendSearchResponse(sp_search* result); @@ -118,40 +118,40 @@ class SpotifyClient : public AbstractMessageHandler { ToplistBrowseComplete(sp_toplistbrowse* result, void* userdata); // Request handlers. - void Login(const pb::spotify::LoginRequest& req); - void Search(const pb::spotify::SearchRequest& req); - void LoadPlaylist(const pb::spotify::LoadPlaylistRequest& req); - void SyncPlaylist(const pb::spotify::SyncPlaylistRequest& req); - void AddTracksToPlaylist(const pb::spotify::AddTracksToPlaylistRequest& req); + void Login(const cpb::spotify::LoginRequest& req); + void Search(const cpb::spotify::SearchRequest& req); + void LoadPlaylist(const cpb::spotify::LoadPlaylistRequest& req); + void SyncPlaylist(const cpb::spotify::SyncPlaylistRequest& req); + void AddTracksToPlaylist(const cpb::spotify::AddTracksToPlaylistRequest& req); void RemoveTracksFromPlaylist( - const pb::spotify::RemoveTracksFromPlaylistRequest& req); - void StartPlayback(const pb::spotify::PlaybackRequest& req); + const cpb::spotify::RemoveTracksFromPlaylistRequest& req); + void StartPlayback(const cpb::spotify::PlaybackRequest& req); void Seek(qint64 offset_nsec); void LoadImage(const QString& id_b64); void BrowseAlbum(const QString& uri); - void BrowseToplist(const pb::spotify::BrowseToplistRequest& req); - void SetPlaybackSettings(const pb::spotify::PlaybackSettings& req); - void SetPaused(const pb::spotify::PauseRequest& req); + void BrowseToplist(const cpb::spotify::BrowseToplistRequest& req); + void SetPlaybackSettings(const cpb::spotify::PlaybackSettings& req); + void SetPaused(const cpb::spotify::PauseRequest& req); void SendPlaylistList(); - void ConvertTrack(sp_track* track, pb::spotify::Track* pb); - void ConvertAlbum(sp_album* album, pb::spotify::Track* pb); - void ConvertAlbumBrowse(sp_albumbrowse* browse, pb::spotify::Track* pb); + void ConvertTrack(sp_track* track, cpb::spotify::Track* pb); + void ConvertAlbum(sp_album* album, cpb::spotify::Track* pb); + void ConvertAlbumBrowse(sp_albumbrowse* browse, cpb::spotify::Track* pb); // Gets the appropriate sp_playlist* but does not load it. - sp_playlist* GetPlaylist(pb::spotify::PlaylistType type, int user_index); + sp_playlist* GetPlaylist(cpb::spotify::PlaylistType type, int user_index); private: struct PendingLoadPlaylist { - pb::spotify::LoadPlaylistRequest request_; + cpb::spotify::LoadPlaylistRequest request_; sp_playlist* playlist_; QList tracks_; bool offline_sync; }; struct PendingPlaybackRequest { - pb::spotify::PlaybackRequest request_; + cpb::spotify::PlaybackRequest request_; sp_link* link_; sp_track* track_; @@ -170,7 +170,7 @@ class SpotifyClient : public AbstractMessageHandler { void TryPlaybackAgain(const PendingPlaybackRequest& req); void TryImageAgain(sp_image* image); int GetDownloadProgress(sp_playlist* playlist); - void SendDownloadProgress(pb::spotify::PlaylistType type, int index, + void SendDownloadProgress(cpb::spotify::PlaylistType type, int index, int download_progress); QByteArray api_key_; @@ -190,9 +190,9 @@ class SpotifyClient : public AbstractMessageHandler { QList pending_playback_requests_; QList pending_image_requests_; QMap image_callbacks_registered_; - QMap pending_searches_; + QMap pending_searches_; QMap pending_album_browses_; - QMap + QMap pending_toplist_browses_; QMap> pending_search_album_browses_; diff --git a/ext/clementine-tagreader/tagreaderworker.cpp b/ext/clementine-tagreader/tagreaderworker.cpp index 235aa3f11..fe171a56b 100644 --- a/ext/clementine-tagreader/tagreaderworker.cpp +++ b/ext/clementine-tagreader/tagreaderworker.cpp @@ -25,10 +25,10 @@ #include TagReaderWorker::TagReaderWorker(QIODevice* socket, QObject* parent) - : AbstractMessageHandler(socket, parent) {} + : AbstractMessageHandler(socket, parent) {} -void TagReaderWorker::MessageArrived(const pb::tagreader::Message& message) { - pb::tagreader::Message reply; +void TagReaderWorker::MessageArrived(const cpb::tagreader::Message& message) { + cpb::tagreader::Message reply; #if 0 // Crash every few requests @@ -68,7 +68,7 @@ void TagReaderWorker::MessageArrived(const pb::tagreader::Message& message) { data.size()); } else if (message.has_read_cloud_file_request()) { #ifdef HAVE_GOOGLE_DRIVE - const pb::tagreader::ReadCloudFileRequest& req = + const cpb::tagreader::ReadCloudFileRequest& req = message.read_cloud_file_request(); if (!tag_reader_.ReadCloudFile( QUrl::fromEncoded(QByteArray(req.download_url().data(), @@ -86,7 +86,7 @@ void TagReaderWorker::MessageArrived(const pb::tagreader::Message& message) { } void TagReaderWorker::DeviceClosed() { - AbstractMessageHandler::DeviceClosed(); + AbstractMessageHandler::DeviceClosed(); qApp->exit(); } diff --git a/ext/clementine-tagreader/tagreaderworker.h b/ext/clementine-tagreader/tagreaderworker.h index 796671d24..859096527 100644 --- a/ext/clementine-tagreader/tagreaderworker.h +++ b/ext/clementine-tagreader/tagreaderworker.h @@ -23,12 +23,12 @@ #include "tagreadermessages.pb.h" #include "core/messagehandler.h" -class TagReaderWorker : public AbstractMessageHandler { +class TagReaderWorker : public AbstractMessageHandler { public: TagReaderWorker(QIODevice* socket, QObject* parent = NULL); protected: - void MessageArrived(const pb::tagreader::Message& message); + void MessageArrived(const cpb::tagreader::Message& message); void DeviceClosed(); private: diff --git a/ext/libclementine-remote/remotecontrolmessages.proto b/ext/libclementine-remote/remotecontrolmessages.proto index 4cb1e6524..483af1fcc 100644 --- a/ext/libclementine-remote/remotecontrolmessages.proto +++ b/ext/libclementine-remote/remotecontrolmessages.proto @@ -20,7 +20,7 @@ syntax = "proto2"; -package pb.remote; +package cpb.remote; // The supported message types enum MsgType { diff --git a/ext/libclementine-spotifyblob/spotifymessages.proto b/ext/libclementine-spotifyblob/spotifymessages.proto index e56af1aa7..d89b1eb0c 100644 --- a/ext/libclementine-spotifyblob/spotifymessages.proto +++ b/ext/libclementine-spotifyblob/spotifymessages.proto @@ -20,7 +20,7 @@ syntax = "proto2"; -package pb.spotify; +package cpb.spotify; message LoginRequest { required string username = 1; diff --git a/ext/libclementine-tagreader/gmereader.cpp b/ext/libclementine-tagreader/gmereader.cpp index 382add16d..fd45926ab 100644 --- a/ext/libclementine-tagreader/gmereader.cpp +++ b/ext/libclementine-tagreader/gmereader.cpp @@ -20,7 +20,7 @@ bool GME::IsSupportedFormat(const QFileInfo& file_info) { } void GME::ReadFile(const QFileInfo& file_info, - pb::tagreader::SongMetadata* song_info) { + cpb::tagreader::SongMetadata* song_info) { if (file_info.completeSuffix().endsWith("spc")) SPC::Read(file_info, song_info); if (file_info.completeSuffix().endsWith("vgm")) @@ -28,7 +28,7 @@ void GME::ReadFile(const QFileInfo& file_info, } void GME::SPC::Read(const QFileInfo& file_info, - pb::tagreader::SongMetadata* song_info) { + cpb::tagreader::SongMetadata* song_info) { QFile file(file_info.filePath()); if (!file.open(QIODevice::ReadOnly)) return; @@ -137,7 +137,7 @@ void GME::SPC::Read(const QFileInfo& file_info, } song_info->set_valid(true); - song_info->set_type(pb::tagreader::SongMetadata_Type_SPC); + song_info->set_type(cpb::tagreader::SongMetadata_Type_SPC); } qint16 GME::SPC::GetNextMemAddressAlign32bit(qint16 input) { @@ -157,7 +157,7 @@ quint64 GME::SPC::ConvertSPCStringToNum(const QByteArray& arr) { } void GME::VGM::Read(const QFileInfo& file_info, - pb::tagreader::SongMetadata* song_info) { + cpb::tagreader::SongMetadata* song_info) { QFile file(file_info.filePath()); if (!file.open(QIODevice::ReadOnly)) return; @@ -206,7 +206,7 @@ void GME::VGM::Read(const QFileInfo& file_info, song_info->set_year(strings[8].left(4).toInt()); song_info->set_length_nanosec(length * kNsecPerMsec); song_info->set_valid(true); - song_info->set_type(pb::tagreader::SongMetadata_Type_VGM); + song_info->set_type(cpb::tagreader::SongMetadata_Type_VGM); } bool GME::VGM::GetPlaybackLength(const QByteArray& sample_count_bytes, diff --git a/ext/libclementine-tagreader/gmereader.h b/ext/libclementine-tagreader/gmereader.h index e3959be15..20bb00cda 100644 --- a/ext/libclementine-tagreader/gmereader.h +++ b/ext/libclementine-tagreader/gmereader.h @@ -10,7 +10,7 @@ class QByteArray; namespace GME { bool IsSupportedFormat(const QFileInfo& file_info); void ReadFile(const QFileInfo& file_info, - pb::tagreader::SongMetadata* song_info); + cpb::tagreader::SongMetadata* song_info); namespace SPC { /* SPC SPEC: @@ -42,7 +42,7 @@ enum xID6_ID { SongName = 0x01, GameName = 0x02, ArtistName = 0x03 }; enum xID6_TYPE { Length = 0x0, String = 0x1, Integer = 0x4 }; -void Read(const QFileInfo& file_info, pb::tagreader::SongMetadata* song_info); +void Read(const QFileInfo& file_info, cpb::tagreader::SongMetadata* song_info); qint16 GetNextMemAddressAlign32bit(qint16 input); quint64 ConvertSPCStringToNum(const QByteArray& arr); } // namespace SPC @@ -58,7 +58,7 @@ const int LOOP_SAMPLE_COUNT = 0x20; const int SAMPLE_TIMEBASE = 44100; const int GST_GME_LOOP_TIME_MS = 8000; -void Read(const QFileInfo& file_info, pb::tagreader::SongMetadata* song_info); +void Read(const QFileInfo& file_info, cpb::tagreader::SongMetadata* song_info); /* Takes in two QByteArrays, expected to be 4 bytes long. Desired length * is returned via output parameter out_length. Returns false on error. */ bool GetPlaybackLength(const QByteArray& sample_count_bytes, diff --git a/ext/libclementine-tagreader/tagreader.cpp b/ext/libclementine-tagreader/tagreader.cpp index 45704408c..42c9ce996 100644 --- a/ext/libclementine-tagreader/tagreader.cpp +++ b/ext/libclementine-tagreader/tagreader.cpp @@ -143,7 +143,7 @@ QString ReplaceUnderscoresWithSpaces(const QString& s) { } // namespace -void TagReader::GuessArtistAndTitle(pb::tagreader::SongMetadata* song) const { +void TagReader::GuessArtistAndTitle(cpb::tagreader::SongMetadata* song) const { QString artist = QString::fromStdString(song->artist()); QString title = QString::fromStdString(song->title()); const QString bn = QString::fromStdString(song->basefilename()); @@ -171,7 +171,7 @@ void TagReader::GuessArtistAndTitle(pb::tagreader::SongMetadata* song) const { } void TagReader::GuessAlbum(const QFileInfo& info, - pb::tagreader::SongMetadata* song) const { + cpb::tagreader::SongMetadata* song) const { QString album = QString::fromStdString(song->album()); if (!album.isEmpty()) return; const QString str_dir = info.absoluteDir().absolutePath(); @@ -191,7 +191,7 @@ TagReader::TagReader() : factory_(new TagLibFileRefFactory), kEmbeddedCover("(embedded)") {} void TagReader::ReadFile(const QString& filename, - pb::tagreader::SongMetadata* song) const { + cpb::tagreader::SongMetadata* song) const { const QByteArray url(QUrl::fromLocalFile(filename).toEncoded()); const QFileInfo info(filename); @@ -674,7 +674,7 @@ void TagReader::Decode(const QString& tag, const QTextCodec* codec, } void TagReader::ParseFMPSFrame(const QString& name, const QString& value, - pb::tagreader::SongMetadata* song) const { + cpb::tagreader::SongMetadata* song) const { qLog(Debug) << "Parsing FMPSFrame" << name << ", " << value; FMPSParser parser; if (!parser.Parse(value) || parser.is_empty()) return; @@ -717,7 +717,7 @@ void TagReader::ParseFMPSFrame(const QString& name, const QString& value, void TagReader::ParseOggTag(const TagLib::Ogg::FieldListMap& map, const QTextCodec* codec, QString* disc, QString* compilation, - pb::tagreader::SongMetadata* song) const { + cpb::tagreader::SongMetadata* song) const { if (!map["COMPOSER"].isEmpty()) Decode(map["COMPOSER"].front(), codec, song->mutable_composer()); if (!map["PERFORMER"].isEmpty()) @@ -774,7 +774,7 @@ void TagReader::ParseOggTag(const TagLib::Ogg::FieldListMap& map, void TagReader::SetVorbisComments( TagLib::Ogg::XiphComment* vorbis_comments, - const pb::tagreader::SongMetadata& song) const { + const cpb::tagreader::SongMetadata& song) const { vorbis_comments->addField("COMPOSER", StdStringToTaglibString(song.composer()), true); vorbis_comments->addField("PERFORMER", @@ -810,7 +810,7 @@ void TagReader::SetVorbisComments( void TagReader::SetFMPSStatisticsVorbisComments( TagLib::Ogg::XiphComment* vorbis_comments, - const pb::tagreader::SongMetadata& song) const { + const cpb::tagreader::SongMetadata& song) const { if (song.playcount()) vorbis_comments->addField("FMPS_PLAYCOUNT", TagLib::String::number(song.playcount()), true); @@ -822,54 +822,54 @@ void TagReader::SetFMPSStatisticsVorbisComments( void TagReader::SetFMPSRatingVorbisComments( TagLib::Ogg::XiphComment* vorbis_comments, - const pb::tagreader::SongMetadata& song) const { + const cpb::tagreader::SongMetadata& song) const { vorbis_comments->addField( "FMPS_RATING", QStringToTaglibString(QString::number(song.rating())), true); } -pb::tagreader::SongMetadata_Type TagReader::GuessFileType( +cpb::tagreader::SongMetadata_Type TagReader::GuessFileType( TagLib::FileRef* fileref) const { #ifdef TAGLIB_WITH_ASF if (dynamic_cast(fileref->file())) - return pb::tagreader::SongMetadata_Type_ASF; + return cpb::tagreader::SongMetadata_Type_ASF; #endif if (dynamic_cast(fileref->file())) - return pb::tagreader::SongMetadata_Type_FLAC; + return cpb::tagreader::SongMetadata_Type_FLAC; #ifdef TAGLIB_WITH_MP4 if (dynamic_cast(fileref->file())) - return pb::tagreader::SongMetadata_Type_MP4; + return cpb::tagreader::SongMetadata_Type_MP4; #endif if (dynamic_cast(fileref->file())) - return pb::tagreader::SongMetadata_Type_MPC; + return cpb::tagreader::SongMetadata_Type_MPC; if (dynamic_cast(fileref->file())) - return pb::tagreader::SongMetadata_Type_MPEG; + return cpb::tagreader::SongMetadata_Type_MPEG; if (dynamic_cast(fileref->file())) - return pb::tagreader::SongMetadata_Type_OGGFLAC; + return cpb::tagreader::SongMetadata_Type_OGGFLAC; if (dynamic_cast(fileref->file())) - return pb::tagreader::SongMetadata_Type_OGGSPEEX; + return cpb::tagreader::SongMetadata_Type_OGGSPEEX; if (dynamic_cast(fileref->file())) - return pb::tagreader::SongMetadata_Type_OGGVORBIS; + return cpb::tagreader::SongMetadata_Type_OGGVORBIS; #ifdef TAGLIB_HAS_OPUS if (dynamic_cast(fileref->file())) - return pb::tagreader::SongMetadata_Type_OGGOPUS; + return cpb::tagreader::SongMetadata_Type_OGGOPUS; #endif if (dynamic_cast(fileref->file())) - return pb::tagreader::SongMetadata_Type_AIFF; + return cpb::tagreader::SongMetadata_Type_AIFF; if (dynamic_cast(fileref->file())) - return pb::tagreader::SongMetadata_Type_WAV; + return cpb::tagreader::SongMetadata_Type_WAV; if (dynamic_cast(fileref->file())) - return pb::tagreader::SongMetadata_Type_TRUEAUDIO; + return cpb::tagreader::SongMetadata_Type_TRUEAUDIO; if (dynamic_cast(fileref->file())) - return pb::tagreader::SongMetadata_Type_WAVPACK; + return cpb::tagreader::SongMetadata_Type_WAVPACK; if (dynamic_cast(fileref->file())) - return pb::tagreader::SongMetadata_Type_APE; + return cpb::tagreader::SongMetadata_Type_APE; - return pb::tagreader::SongMetadata_Type_UNKNOWN; + return cpb::tagreader::SongMetadata_Type_UNKNOWN; } bool TagReader::SaveFile(const QString& filename, - const pb::tagreader::SongMetadata& song) const { + const cpb::tagreader::SongMetadata& song) const { if (filename.isNull()) return false; qLog(Debug) << "Saving tags to" << filename; @@ -986,7 +986,7 @@ bool TagReader::SaveFile(const QString& filename, } bool TagReader::SaveSongStatisticsToFile( - const QString& filename, const pb::tagreader::SongMetadata& song) const { + const QString& filename, const cpb::tagreader::SongMetadata& song) const { if (filename.isNull()) return false; qLog(Debug) << "Saving song statistics tags to" << filename; @@ -1083,7 +1083,7 @@ bool TagReader::SaveSongStatisticsToFile( } bool TagReader::SaveSongRatingToFile( - const QString& filename, const pb::tagreader::SongMetadata& song) const { + const QString& filename, const cpb::tagreader::SongMetadata& song) const { if (filename.isNull()) return false; qLog(Debug) << "Saving song rating tags to" << filename; @@ -1427,7 +1427,7 @@ QByteArray TagReader::LoadEmbeddedArt(const QString& filename) const { bool TagReader::ReadCloudFile(const QUrl& download_url, const QString& title, int size, const QString& mime_type, const QString& authorisation_header, - pb::tagreader::SongMetadata* song) const { + cpb::tagreader::SongMetadata* song) const { qLog(Debug) << "Loading tags from" << title; std::unique_ptr stream( @@ -1488,7 +1488,7 @@ bool TagReader::ReadCloudFile(const QUrl& download_url, const QString& title, song->set_year(tag->tag()->year()); } - song->set_type(pb::tagreader::SongMetadata_Type_STREAM); + song->set_type(cpb::tagreader::SongMetadata_Type_STREAM); if (tag->audioProperties()) { song->set_length_nanosec(tag->audioProperties()->length() * kNsecPerSec); diff --git a/ext/libclementine-tagreader/tagreader.h b/ext/libclementine-tagreader/tagreader.h index 84a4302d9..c8e5e7fee 100644 --- a/ext/libclementine-tagreader/tagreader.h +++ b/ext/libclementine-tagreader/tagreader.h @@ -57,16 +57,16 @@ class TagReader { TagReader(); void ReadFile(const QString& filename, - pb::tagreader::SongMetadata* song) const; + cpb::tagreader::SongMetadata* song) const; bool SaveFile(const QString& filename, - const pb::tagreader::SongMetadata& song) const; + const cpb::tagreader::SongMetadata& song) const; // Returns false if something went wrong; returns true otherwise (might // returns true if the file exists but nothing has been written inside because // statistics tag format is not supported for this kind of file) bool SaveSongStatisticsToFile(const QString& filename, - const pb::tagreader::SongMetadata& song) const; + const cpb::tagreader::SongMetadata& song) const; bool SaveSongRatingToFile(const QString& filename, - const pb::tagreader::SongMetadata& song) const; + const cpb::tagreader::SongMetadata& song) const; bool IsMediaFile(const QString& filename) const; QByteArray LoadEmbeddedArt(const QString& filename) const; @@ -74,7 +74,7 @@ class TagReader { #ifdef HAVE_GOOGLE_DRIVE bool ReadCloudFile(const QUrl& download_url, const QString& title, int size, const QString& mime_type, const QString& access_token, - pb::tagreader::SongMetadata* song) const; + cpb::tagreader::SongMetadata* song) const; #endif // HAVE_GOOGLE_DRIVE static void Decode(const TagLib::String& tag, const QTextCodec* codec, @@ -83,23 +83,23 @@ class TagReader { std::string* output); void ParseFMPSFrame(const QString& name, const QString& value, - pb::tagreader::SongMetadata* song) const; + cpb::tagreader::SongMetadata* song) const; void ParseOggTag(const TagLib::Ogg::FieldListMap& map, const QTextCodec* codec, QString* disc, QString* compilation, - pb::tagreader::SongMetadata* song) const; + cpb::tagreader::SongMetadata* song) const; void SetVorbisComments(TagLib::Ogg::XiphComment* vorbis_comments, - const pb::tagreader::SongMetadata& song) const; + const cpb::tagreader::SongMetadata& song) const; void SetFMPSStatisticsVorbisComments( TagLib::Ogg::XiphComment* vorbis_comments, - const pb::tagreader::SongMetadata& song) const; + const cpb::tagreader::SongMetadata& song) const; void SetFMPSRatingVorbisComments( TagLib::Ogg::XiphComment* vorbis_comments, - const pb::tagreader::SongMetadata& song) const; + const cpb::tagreader::SongMetadata& song) const; - void GuessArtistAndTitle(pb::tagreader::SongMetadata* song) const; - void GuessAlbum(const QFileInfo &info, pb::tagreader::SongMetadata* song) const; + void GuessArtistAndTitle(cpb::tagreader::SongMetadata* song) const; + void GuessAlbum(const QFileInfo &info, cpb::tagreader::SongMetadata* song) const; - pb::tagreader::SongMetadata_Type GuessFileType( + cpb::tagreader::SongMetadata_Type GuessFileType( TagLib::FileRef* fileref) const; void SetUserTextFrame(const QString& description, const QString& value, diff --git a/ext/libclementine-tagreader/tagreadermessages.proto b/ext/libclementine-tagreader/tagreadermessages.proto index 531efb717..2089ea76a 100644 --- a/ext/libclementine-tagreader/tagreadermessages.proto +++ b/ext/libclementine-tagreader/tagreadermessages.proto @@ -1,6 +1,6 @@ syntax = "proto2"; -package pb.tagreader; +package cpb.tagreader; message SongMetadata { enum Type { diff --git a/src/core/song.cpp b/src/core/song.cpp index f5037afc3..0fdf6a0cd 100644 --- a/src/core/song.cpp +++ b/src/core/song.cpp @@ -526,7 +526,7 @@ QString Song::Decode(const QString& tag, const QTextCodec* codec) { return codec->toUnicode(tag.toUtf8()); } -void Song::InitFromProtobuf(const pb::tagreader::SongMetadata& pb) { +void Song::InitFromProtobuf(const cpb::tagreader::SongMetadata& pb) { d->init_from_file_ = true; d->valid_ = pb.valid(); d->title_ = QStringFromStdString(pb.title()); @@ -575,7 +575,7 @@ void Song::InitFromProtobuf(const pb::tagreader::SongMetadata& pb) { InitArtManual(); } -void Song::ToProtobuf(pb::tagreader::SongMetadata* pb) const { +void Song::ToProtobuf(cpb::tagreader::SongMetadata* pb) const { const QByteArray url(d->url_.toEncoded()); pb->set_valid(d->valid_); @@ -610,7 +610,7 @@ void Song::ToProtobuf(pb::tagreader::SongMetadata* pb) const { pb->set_filesize(d->filesize_); pb->set_suspicious_tags(d->suspicious_tags_); pb->set_art_automatic(DataCommaSizeFromQString(d->art_automatic_)); - pb->set_type(static_cast(d->filetype_)); + pb->set_type(static_cast(d->filetype_)); } void Song::InitFromQuery(const SqlRow& q, bool reliable_metadata, int col) { diff --git a/src/core/song.h b/src/core/song.h index 9d93ae5c2..aed522ce2 100644 --- a/src/core/song.h +++ b/src/core/song.h @@ -37,11 +37,11 @@ #include "config.h" #include "engines/engine_fwd.h" -namespace pb { +namespace cpb { namespace tagreader { class SongMetadata; } // namespace tagreader -} // namespace pb +} // namespace cpb class QSqlQuery; class QUrl; @@ -123,7 +123,7 @@ class Song { qint64 length_nanosec); void Init(const QString& title, const QString& artist, const QString& album, qint64 beginning, qint64 end); - void InitFromProtobuf(const pb::tagreader::SongMetadata& pb); + void InitFromProtobuf(const cpb::tagreader::SongMetadata& pb); void InitFromQuery(const SqlRow& query, bool reliable_metadata, int col = 0); void InitFromFilePartial( const QString& filename); // Just store the filename: incomplete but fast @@ -159,7 +159,7 @@ class Song { void ToLastFM(lastfm::Track* track, bool prefer_album_artist) const; #endif void ToXesam(QVariantMap* map) const; - void ToProtobuf(pb::tagreader::SongMetadata* pb) const; + void ToProtobuf(cpb::tagreader::SongMetadata* pb) const; // Simple accessors bool is_valid() const; diff --git a/src/core/tagreaderclient.cpp b/src/core/tagreaderclient.cpp index 521ce1824..db2a21929 100644 --- a/src/core/tagreaderclient.cpp +++ b/src/core/tagreaderclient.cpp @@ -58,8 +58,8 @@ void TagReaderClient::WorkerFailedToStart() { } TagReaderReply* TagReaderClient::ReadFile(const QString& filename) { - pb::tagreader::Message message; - pb::tagreader::ReadFileRequest* req = message.mutable_read_file_request(); + cpb::tagreader::Message message; + cpb::tagreader::ReadFileRequest* req = message.mutable_read_file_request(); req->set_filename(DataCommaSizeFromQString(filename)); @@ -68,8 +68,8 @@ TagReaderReply* TagReaderClient::ReadFile(const QString& filename) { TagReaderReply* TagReaderClient::SaveFile(const QString& filename, const Song& metadata) { - pb::tagreader::Message message; - pb::tagreader::SaveFileRequest* req = message.mutable_save_file_request(); + cpb::tagreader::Message message; + cpb::tagreader::SaveFileRequest* req = message.mutable_save_file_request(); req->set_filename(DataCommaSizeFromQString(filename)); metadata.ToProtobuf(req->mutable_metadata()); @@ -78,8 +78,8 @@ TagReaderReply* TagReaderClient::SaveFile(const QString& filename, } TagReaderReply* TagReaderClient::UpdateSongStatistics(const Song& metadata) { - pb::tagreader::Message message; - pb::tagreader::SaveSongStatisticsToFileRequest* req = + cpb::tagreader::Message message; + cpb::tagreader::SaveSongStatisticsToFileRequest* req = message.mutable_save_song_statistics_to_file_request(); req->set_filename(DataCommaSizeFromQString(metadata.url().toLocalFile())); @@ -96,8 +96,8 @@ void TagReaderClient::UpdateSongsStatistics(const SongList& songs) { } TagReaderReply* TagReaderClient::UpdateSongRating(const Song& metadata) { - pb::tagreader::Message message; - pb::tagreader::SaveSongRatingToFileRequest* req = + cpb::tagreader::Message message; + cpb::tagreader::SaveSongRatingToFileRequest* req = message.mutable_save_song_rating_to_file_request(); req->set_filename(DataCommaSizeFromQString(metadata.url().toLocalFile())); @@ -114,8 +114,8 @@ void TagReaderClient::UpdateSongsRating(const SongList& songs) { } TagReaderReply* TagReaderClient::IsMediaFile(const QString& filename) { - pb::tagreader::Message message; - pb::tagreader::IsMediaFileRequest* req = + cpb::tagreader::Message message; + cpb::tagreader::IsMediaFileRequest* req = message.mutable_is_media_file_request(); req->set_filename(DataCommaSizeFromQString(filename)); @@ -124,8 +124,8 @@ TagReaderReply* TagReaderClient::IsMediaFile(const QString& filename) { } TagReaderReply* TagReaderClient::LoadEmbeddedArt(const QString& filename) { - pb::tagreader::Message message; - pb::tagreader::LoadEmbeddedArtRequest* req = + cpb::tagreader::Message message; + cpb::tagreader::LoadEmbeddedArtRequest* req = message.mutable_load_embedded_art_request(); req->set_filename(DataCommaSizeFromQString(filename)); @@ -136,8 +136,8 @@ TagReaderReply* TagReaderClient::LoadEmbeddedArt(const QString& filename) { TagReaderReply* TagReaderClient::ReadCloudFile( const QUrl& download_url, const QString& title, int size, const QString& mime_type, const QString& authorisation_header) { - pb::tagreader::Message message; - pb::tagreader::ReadCloudFileRequest* req = + cpb::tagreader::Message message; + cpb::tagreader::ReadCloudFileRequest* req = message.mutable_read_cloud_file_request(); const QString url_string = download_url.toEncoded(); diff --git a/src/core/tagreaderclient.h b/src/core/tagreaderclient.h index 5571f5d56..018b06774 100644 --- a/src/core/tagreaderclient.h +++ b/src/core/tagreaderclient.h @@ -37,7 +37,7 @@ class TagReaderClient : public QObject { public: explicit TagReaderClient(QObject* parent = nullptr); - typedef AbstractMessageHandler HandlerType; + typedef AbstractMessageHandler HandlerType; typedef HandlerType::ReplyType ReplyType; static const char* kWorkerExecutableName; @@ -78,7 +78,7 @@ class TagReaderClient : public QObject { static TagReaderClient* sInstance; WorkerPool* worker_pool_; - QList message_queue_; + QList message_queue_; }; typedef TagReaderClient::ReplyType TagReaderReply; diff --git a/src/globalsearch/spotifysearchprovider.cpp b/src/globalsearch/spotifysearchprovider.cpp index 4a6f4df2c..d61816d57 100644 --- a/src/globalsearch/spotifysearchprovider.cpp +++ b/src/globalsearch/spotifysearchprovider.cpp @@ -49,16 +49,16 @@ SpotifyServer* SpotifySearchProvider::server() { if (!service_->IsBlobInstalled()) return nullptr; server_ = service_->server(); - connect(server_, SIGNAL(SearchResults(pb::spotify::SearchResponse)), - SLOT(SearchFinishedSlot(pb::spotify::SearchResponse))); + connect(server_, SIGNAL(SearchResults(cpb::spotify::SearchResponse)), + SLOT(SearchFinishedSlot(cpb::spotify::SearchResponse))); connect(server_, SIGNAL(ImageLoaded(QString, QImage)), SLOT(ArtLoadedSlot(QString, QImage))); connect(server_, SIGNAL(destroyed()), SLOT(ServerDestroyed())); - connect(server_, SIGNAL(StarredLoaded(pb::spotify::LoadPlaylistResponse)), - SLOT(SuggestionsLoaded(pb::spotify::LoadPlaylistResponse))); + connect(server_, SIGNAL(StarredLoaded(cpb::spotify::LoadPlaylistResponse)), + SLOT(SuggestionsLoaded(cpb::spotify::LoadPlaylistResponse))); connect(server_, - SIGNAL(ToplistBrowseResults(pb::spotify::BrowseToplistResponse)), - SLOT(SuggestionsLoaded(pb::spotify::BrowseToplistResponse))); + SIGNAL(ToplistBrowseResults(cpb::spotify::BrowseToplistResponse)), + SLOT(SuggestionsLoaded(cpb::spotify::BrowseToplistResponse))); return server_; } @@ -82,7 +82,7 @@ void SpotifySearchProvider::SearchAsync(int id, const QString& query) { } void SpotifySearchProvider::SearchFinishedSlot( - const pb::spotify::SearchResponse& response) { + const cpb::spotify::SearchResponse& response) { QString query_string = QString::fromUtf8(response.request().query().c_str()); QMap::iterator it = queries_.find(query_string); if (it == queries_.end()) return; @@ -107,7 +107,7 @@ void SpotifySearchProvider::SearchFinishedSlot( ResultList ret; for (int i = 0; i < response.album_size(); ++i) { - const pb::spotify::Album& album = response.album(i); + const cpb::spotify::Album& album = response.album(i); QHash artist_count; QString majority_artist; @@ -153,7 +153,7 @@ void SpotifySearchProvider::SearchFinishedSlot( } for (int i = 0; i < response.result_size(); ++i) { - const pb::spotify::Track& track = response.result(i); + const cpb::spotify::Track& track = response.result(i); // Check this track/album against tracks we've already seen // in the album results, and skip if it's a duplicate @@ -211,7 +211,7 @@ void SpotifySearchProvider::ShowConfig() { } void SpotifySearchProvider::AddSuggestionFromTrack( - const pb::spotify::Track& track) { + const cpb::spotify::Track& track) { if (!track.title().empty()) { suggestions_.insert(QString::fromUtf8(track.title().c_str())); } @@ -226,7 +226,7 @@ void SpotifySearchProvider::AddSuggestionFromTrack( } void SpotifySearchProvider::AddSuggestionFromAlbum( - const pb::spotify::Album& album) { + const cpb::spotify::Album& album) { AddSuggestionFromTrack(album.metadata()); for (int i = 0; i < album.track_size(); ++i) { AddSuggestionFromTrack(album.track(i)); @@ -234,14 +234,14 @@ void SpotifySearchProvider::AddSuggestionFromAlbum( } void SpotifySearchProvider::SuggestionsLoaded( - const pb::spotify::LoadPlaylistResponse& playlist) { + const cpb::spotify::LoadPlaylistResponse& playlist) { for (int i = 0; i < playlist.track_size(); ++i) { AddSuggestionFromTrack(playlist.track(i)); } } void SpotifySearchProvider::SuggestionsLoaded( - const pb::spotify::BrowseToplistResponse& response) { + const cpb::spotify::BrowseToplistResponse& response) { for (int i = 0; i < response.track_size(); ++i) { AddSuggestionFromTrack(response.track(i)); } diff --git a/src/globalsearch/spotifysearchprovider.h b/src/globalsearch/spotifysearchprovider.h index 6419962cf..41169194a 100644 --- a/src/globalsearch/spotifysearchprovider.h +++ b/src/globalsearch/spotifysearchprovider.h @@ -41,17 +41,17 @@ class SpotifySearchProvider : public SearchProvider { private slots: void ServerDestroyed(); - void SearchFinishedSlot(const pb::spotify::SearchResponse& response); + void SearchFinishedSlot(const cpb::spotify::SearchResponse& response); void ArtLoadedSlot(const QString& id, const QImage& image); - void SuggestionsLoaded(const pb::spotify::LoadPlaylistResponse& response); - void SuggestionsLoaded(const pb::spotify::BrowseToplistResponse& response); + void SuggestionsLoaded(const cpb::spotify::LoadPlaylistResponse& response); + void SuggestionsLoaded(const cpb::spotify::BrowseToplistResponse& response); private: SpotifyServer* server(); void LoadSuggestions(); - void AddSuggestionFromTrack(const pb::spotify::Track& track); - void AddSuggestionFromAlbum(const pb::spotify::Album& album); + void AddSuggestionFromTrack(const cpb::spotify::Track& track); + void AddSuggestionFromAlbum(const cpb::spotify::Album& album); private: SpotifyServer* server_; diff --git a/src/internet/core/cloudfileservice.cpp b/src/internet/core/cloudfileservice.cpp index fcb411b3c..2a3ad7518 100644 --- a/src/internet/core/cloudfileservice.cpp +++ b/src/internet/core/cloudfileservice.cpp @@ -192,14 +192,14 @@ void CloudFileService::ReadTagsFinished(TagReaderClient::ReplyType* reply, indexing_task_max_); } - const pb::tagreader::ReadCloudFileResponse& message = + const cpb::tagreader::ReadCloudFileResponse& message = reply->message().read_cloud_file_response(); if (!message.has_metadata() || !message.metadata().filesize()) { qLog(Debug) << "Failed to tag:" << metadata.url(); return; } - pb::tagreader::SongMetadata metadata_pb; + cpb::tagreader::SongMetadata metadata_pb; metadata.ToProtobuf(&metadata_pb); metadata_pb.MergeFrom(message.metadata()); diff --git a/src/internet/spotify/spotifyserver.cpp b/src/internet/spotify/spotifyserver.cpp index 126163bb0..bc600f4d9 100644 --- a/src/internet/spotify/spotifyserver.cpp +++ b/src/internet/spotify/spotifyserver.cpp @@ -31,7 +31,7 @@ #include "spotifymessages.pb.h" SpotifyServer::SpotifyServer(QObject* parent) - : AbstractMessageHandler(nullptr, parent), + : AbstractMessageHandler(nullptr, parent), server_(new QTcpServer(this)), logged_in_(false) { connect(server_, SIGNAL(newConnection()), SLOT(NewConnection())); @@ -52,7 +52,7 @@ void SpotifyServer::NewConnection() { qLog(Info) << "Connection from port" << socket->peerPort(); // Send any login messages that were queued before the client connected - for (const pb::spotify::Message& message : queued_login_messages_) { + for (const cpb::spotify::Message& message : queued_login_messages_) { SendOrQueueMessage(message); } queued_login_messages_.clear(); @@ -61,10 +61,10 @@ void SpotifyServer::NewConnection() { disconnect(server_, SIGNAL(newConnection()), this, 0); } -void SpotifyServer::SendOrQueueMessage(const pb::spotify::Message& message) { +void SpotifyServer::SendOrQueueMessage(const cpb::spotify::Message& message) { const bool is_login_message = message.has_login_request(); - QList* queue = + QList* queue = is_login_message ? &queued_login_messages_ : &queued_messages_; if (!device_ || (!is_login_message && !logged_in_)) { @@ -75,11 +75,11 @@ void SpotifyServer::SendOrQueueMessage(const pb::spotify::Message& message) { } void SpotifyServer::Login(const QString& username, const QString& password, - pb::spotify::Bitrate bitrate, + cpb::spotify::Bitrate bitrate, bool volume_normalisation) { - pb::spotify::Message message; + cpb::spotify::Message message; - pb::spotify::LoginRequest* request = message.mutable_login_request(); + cpb::spotify::LoginRequest* request = message.mutable_login_request(); request->set_username(DataCommaSizeFromQString(username)); if (!password.isEmpty()) { request->set_password(DataCommaSizeFromQString(password)); @@ -91,11 +91,11 @@ void SpotifyServer::Login(const QString& username, const QString& password, SendOrQueueMessage(message); } -void SpotifyServer::SetPlaybackSettings(pb::spotify::Bitrate bitrate, +void SpotifyServer::SetPlaybackSettings(cpb::spotify::Bitrate bitrate, bool volume_normalisation) { - pb::spotify::Message message; + cpb::spotify::Message message; - pb::spotify::PlaybackSettings* request = + cpb::spotify::PlaybackSettings* request = message.mutable_set_playback_settings_request(); request->set_bitrate(bitrate); request->set_volume_normalisation(volume_normalisation); @@ -103,14 +103,14 @@ void SpotifyServer::SetPlaybackSettings(pb::spotify::Bitrate bitrate, SendOrQueueMessage(message); } -void SpotifyServer::MessageArrived(const pb::spotify::Message& message) { +void SpotifyServer::MessageArrived(const cpb::spotify::Message& message) { if (message.has_login_response()) { - const pb::spotify::LoginResponse& response = message.login_response(); + const cpb::spotify::LoginResponse& response = message.login_response(); logged_in_ = response.success(); if (response.success()) { // Send any messages that were queued before the client logged in - for (const pb::spotify::Message& message : queued_messages_) { + for (const cpb::spotify::Message& message : queued_messages_) { SendOrQueueMessage(message); } queued_messages_.clear(); @@ -122,19 +122,19 @@ void SpotifyServer::MessageArrived(const pb::spotify::Message& message) { } else if (message.has_playlists_updated()) { emit PlaylistsUpdated(message.playlists_updated()); } else if (message.has_load_playlist_response()) { - const pb::spotify::LoadPlaylistResponse& response = + const cpb::spotify::LoadPlaylistResponse& response = message.load_playlist_response(); switch (response.request().type()) { - case pb::spotify::Inbox: + case cpb::spotify::Inbox: emit InboxLoaded(response); break; - case pb::spotify::Starred: + case cpb::spotify::Starred: emit StarredLoaded(response); break; - case pb::spotify::UserPlaylist: + case cpb::spotify::UserPlaylist: emit UserPlaylistLoaded(response); break; } @@ -143,7 +143,7 @@ void SpotifyServer::MessageArrived(const pb::spotify::Message& message) { } else if (message.has_search_response()) { emit SearchResults(message.search_response()); } else if (message.has_image_response()) { - const pb::spotify::ImageResponse& response = message.image_response(); + const cpb::spotify::ImageResponse& response = message.image_response(); const QString id = QStringFromStdString(response.id()); if (response.has_data()) { @@ -162,9 +162,9 @@ void SpotifyServer::MessageArrived(const pb::spotify::Message& message) { } } -void SpotifyServer::LoadPlaylist(pb::spotify::PlaylistType type, int index) { - pb::spotify::Message message; - pb::spotify::LoadPlaylistRequest* req = +void SpotifyServer::LoadPlaylist(cpb::spotify::PlaylistType type, int index) { + cpb::spotify::Message message; + cpb::spotify::LoadPlaylistRequest* req = message.mutable_load_playlist_request(); req->set_type(type); @@ -175,10 +175,10 @@ void SpotifyServer::LoadPlaylist(pb::spotify::PlaylistType type, int index) { SendOrQueueMessage(message); } -void SpotifyServer::SyncPlaylist(pb::spotify::PlaylistType type, int index, +void SpotifyServer::SyncPlaylist(cpb::spotify::PlaylistType type, int index, bool offline) { - pb::spotify::Message message; - pb::spotify::SyncPlaylistRequest* req = + cpb::spotify::Message message; + cpb::spotify::SyncPlaylistRequest* req = message.mutable_sync_playlist_request(); req->mutable_request()->set_type(type); if (index != -1) { @@ -189,40 +189,40 @@ void SpotifyServer::SyncPlaylist(pb::spotify::PlaylistType type, int index, SendOrQueueMessage(message); } -void SpotifyServer::SyncInbox() { SyncPlaylist(pb::spotify::Inbox, -1, true); } +void SpotifyServer::SyncInbox() { SyncPlaylist(cpb::spotify::Inbox, -1, true); } void SpotifyServer::SyncStarred() { - SyncPlaylist(pb::spotify::Starred, -1, true); + SyncPlaylist(cpb::spotify::Starred, -1, true); } void SpotifyServer::SyncUserPlaylist(int index) { Q_ASSERT(index >= 0); - SyncPlaylist(pb::spotify::UserPlaylist, index, true); + SyncPlaylist(cpb::spotify::UserPlaylist, index, true); } -void SpotifyServer::LoadInbox() { LoadPlaylist(pb::spotify::Inbox); } +void SpotifyServer::LoadInbox() { LoadPlaylist(cpb::spotify::Inbox); } -void SpotifyServer::LoadStarred() { LoadPlaylist(pb::spotify::Starred); } +void SpotifyServer::LoadStarred() { LoadPlaylist(cpb::spotify::Starred); } void SpotifyServer::LoadUserPlaylist(int index) { Q_ASSERT(index >= 0); - LoadPlaylist(pb::spotify::UserPlaylist, index); + LoadPlaylist(cpb::spotify::UserPlaylist, index); } void SpotifyServer::AddSongsToStarred(const QList& songs_urls) { - AddSongsToPlaylist(pb::spotify::Starred, songs_urls); + AddSongsToPlaylist(cpb::spotify::Starred, songs_urls); } void SpotifyServer::AddSongsToUserPlaylist(int playlist_index, const QList& songs_urls) { - AddSongsToPlaylist(pb::spotify::UserPlaylist, songs_urls, playlist_index); + AddSongsToPlaylist(cpb::spotify::UserPlaylist, songs_urls, playlist_index); } void SpotifyServer::AddSongsToPlaylist( - const pb::spotify::PlaylistType playlist_type, + const cpb::spotify::PlaylistType playlist_type, const QList& songs_urls, int playlist_index) { - pb::spotify::Message message; - pb::spotify::AddTracksToPlaylistRequest* req = + cpb::spotify::Message message; + cpb::spotify::AddTracksToPlaylistRequest* req = message.mutable_add_tracks_to_playlist(); req->set_playlist_type(playlist_type); req->set_playlist_index(playlist_index); @@ -234,23 +234,23 @@ void SpotifyServer::AddSongsToPlaylist( void SpotifyServer::RemoveSongsFromStarred( const QList& songs_indices_to_remove) { - RemoveSongsFromPlaylist(pb::spotify::Starred, songs_indices_to_remove); + RemoveSongsFromPlaylist(cpb::spotify::Starred, songs_indices_to_remove); } void SpotifyServer::RemoveSongsFromUserPlaylist( int playlist_index, const QList& songs_indices_to_remove) { - RemoveSongsFromPlaylist(pb::spotify::UserPlaylist, songs_indices_to_remove, + RemoveSongsFromPlaylist(cpb::spotify::UserPlaylist, songs_indices_to_remove, playlist_index); } void SpotifyServer::RemoveSongsFromPlaylist( - const pb::spotify::PlaylistType playlist_type, + const cpb::spotify::PlaylistType playlist_type, const QList& songs_indices_to_remove, int playlist_index) { - pb::spotify::Message message; - pb::spotify::RemoveTracksFromPlaylistRequest* req = + cpb::spotify::Message message; + cpb::spotify::RemoveTracksFromPlaylistRequest* req = message.mutable_remove_tracks_from_playlist(); req->set_playlist_type(playlist_type); - if (playlist_type == pb::spotify::UserPlaylist) { + if (playlist_type == cpb::spotify::UserPlaylist) { req->set_playlist_index(playlist_index); } for (int song_index : songs_indices_to_remove) { @@ -260,8 +260,8 @@ void SpotifyServer::RemoveSongsFromPlaylist( } void SpotifyServer::StartPlayback(const QString& uri, quint16 port) { - pb::spotify::Message message; - pb::spotify::PlaybackRequest* req = message.mutable_playback_request(); + cpb::spotify::Message message; + cpb::spotify::PlaybackRequest* req = message.mutable_playback_request(); req->set_track_uri(DataCommaSizeFromQString(uri)); req->set_media_port(port); @@ -269,16 +269,16 @@ void SpotifyServer::StartPlayback(const QString& uri, quint16 port) { } void SpotifyServer::Seek(qint64 offset_nsec) { - pb::spotify::Message message; - pb::spotify::SeekRequest* req = message.mutable_seek_request(); + cpb::spotify::Message message; + cpb::spotify::SeekRequest* req = message.mutable_seek_request(); req->set_offset_nsec(offset_nsec); SendOrQueueMessage(message); } void SpotifyServer::Search(const QString& text, int limit, int limit_album) { - pb::spotify::Message message; - pb::spotify::SearchRequest* req = message.mutable_search_request(); + cpb::spotify::Message message; + cpb::spotify::SearchRequest* req = message.mutable_search_request(); req->set_query(DataCommaSizeFromQString(text)); req->set_limit(limit); @@ -287,34 +287,35 @@ void SpotifyServer::Search(const QString& text, int limit, int limit_album) { } void SpotifyServer::LoadImage(const QString& id) { - pb::spotify::Message message; - pb::spotify::ImageRequest* req = message.mutable_image_request(); + cpb::spotify::Message message; + cpb::spotify::ImageRequest* req = message.mutable_image_request(); req->set_id(DataCommaSizeFromQString(id)); SendOrQueueMessage(message); } void SpotifyServer::AlbumBrowse(const QString& uri) { - pb::spotify::Message message; - pb::spotify::BrowseAlbumRequest* req = message.mutable_browse_album_request(); + cpb::spotify::Message message; + cpb::spotify::BrowseAlbumRequest* req = + message.mutable_browse_album_request(); req->set_uri(DataCommaSizeFromQString(uri)); SendOrQueueMessage(message); } void SpotifyServer::LoadToplist() { - pb::spotify::Message message; - pb::spotify::BrowseToplistRequest* req = + cpb::spotify::Message message; + cpb::spotify::BrowseToplistRequest* req = message.mutable_browse_toplist_request(); - req->set_type(pb::spotify::BrowseToplistRequest::Tracks); - req->set_region(pb::spotify::BrowseToplistRequest::Everywhere); + req->set_type(cpb::spotify::BrowseToplistRequest::Tracks); + req->set_region(cpb::spotify::BrowseToplistRequest::Everywhere); SendOrQueueMessage(message); } void SpotifyServer::SetPaused(const bool paused) { - pb::spotify::Message message; - pb::spotify::PauseRequest* req = message.mutable_pause_request(); + cpb::spotify::Message message; + cpb::spotify::PauseRequest* req = message.mutable_pause_request(); req->set_paused(paused); SendOrQueueMessage(message); } diff --git a/src/internet/spotify/spotifyserver.h b/src/internet/spotify/spotifyserver.h index 168cb9bad..6609d4d78 100644 --- a/src/internet/spotify/spotifyserver.h +++ b/src/internet/spotify/spotifyserver.h @@ -31,7 +31,7 @@ class QTcpServer; class QTcpSocket; -class SpotifyServer : public AbstractMessageHandler { +class SpotifyServer : public AbstractMessageHandler { Q_OBJECT public: @@ -39,7 +39,7 @@ class SpotifyServer : public AbstractMessageHandler { void Init(); void Login(const QString& username, const QString& password, - pb::spotify::Bitrate bitrate, bool volume_normalisation); + cpb::spotify::Bitrate bitrate, bool volume_normalisation); void LoadStarred(); void SyncStarred(); @@ -56,7 +56,7 @@ class SpotifyServer : public AbstractMessageHandler { void Search(const QString& text, int limit, int limit_album = 0); void LoadImage(const QString& id); void AlbumBrowse(const QString& uri); - void SetPlaybackSettings(pb::spotify::Bitrate bitrate, + void SetPlaybackSettings(cpb::spotify::Bitrate bitrate, bool volume_normalisation); void LoadToplist(); void SetPaused(const bool paused); @@ -69,43 +69,44 @@ class SpotifyServer : public AbstractMessageHandler { signals: void LoginCompleted(bool success, const QString& error, - pb::spotify::LoginResponse_Error error_code); - void PlaylistsUpdated(const pb::spotify::Playlists& playlists); + cpb::spotify::LoginResponse_Error error_code); + void PlaylistsUpdated(const cpb::spotify::Playlists& playlists); - void StarredLoaded(const pb::spotify::LoadPlaylistResponse& response); - void InboxLoaded(const pb::spotify::LoadPlaylistResponse& response); - void UserPlaylistLoaded(const pb::spotify::LoadPlaylistResponse& response); + void StarredLoaded(const cpb::spotify::LoadPlaylistResponse& response); + void InboxLoaded(const cpb::spotify::LoadPlaylistResponse& response); + void UserPlaylistLoaded(const cpb::spotify::LoadPlaylistResponse& response); void PlaybackError(const QString& message); - void SearchResults(const pb::spotify::SearchResponse& response); + void SearchResults(const cpb::spotify::SearchResponse& response); void ImageLoaded(const QString& id, const QImage& image); - void SyncPlaylistProgress(const pb::spotify::SyncPlaylistProgress& progress); - void AlbumBrowseResults(const pb::spotify::BrowseAlbumResponse& response); - void ToplistBrowseResults(const pb::spotify::BrowseToplistResponse& response); + void SyncPlaylistProgress(const cpb::spotify::SyncPlaylistProgress& progress); + void AlbumBrowseResults(const cpb::spotify::BrowseAlbumResponse& response); + void ToplistBrowseResults( + const cpb::spotify::BrowseToplistResponse& response); protected: - void MessageArrived(const pb::spotify::Message& message); + void MessageArrived(const cpb::spotify::Message& message); private slots: void NewConnection(); private: - void LoadPlaylist(pb::spotify::PlaylistType type, int index = -1); - void SyncPlaylist(pb::spotify::PlaylistType type, int index, bool offline); - void AddSongsToPlaylist(const pb::spotify::PlaylistType playlist_type, + void LoadPlaylist(cpb::spotify::PlaylistType type, int index = -1); + void SyncPlaylist(cpb::spotify::PlaylistType type, int index, bool offline); + void AddSongsToPlaylist(const cpb::spotify::PlaylistType playlist_type, const QList& songs_urls, // Used iff type is user_playlist int playlist_index = -1); - void RemoveSongsFromPlaylist(const pb::spotify::PlaylistType playlist_type, + void RemoveSongsFromPlaylist(const cpb::spotify::PlaylistType playlist_type, const QList& songs_indices_to_remove, // Used iff type is user_playlist int playlist_index = -1); - void SendOrQueueMessage(const pb::spotify::Message& message); + void SendOrQueueMessage(const cpb::spotify::Message& message); QTcpServer* server_; bool logged_in_; - QList queued_login_messages_; - QList queued_messages_; + QList queued_login_messages_; + QList queued_messages_; }; #endif // INTERNET_SPOTIFY_SPOTIFYSERVER_H_ diff --git a/src/internet/spotify/spotifyservice.cpp b/src/internet/spotify/spotifyservice.cpp index 365a747dc..99d3a6fed 100644 --- a/src/internet/spotify/spotifyservice.cpp +++ b/src/internet/spotify/spotifyservice.cpp @@ -85,7 +85,7 @@ SpotifyService::SpotifyService(Application* app, InternetModel* parent) search_box_(new SearchBoxWidget(this)), search_delay_(new QTimer(this)), login_state_(LoginState_OtherError), - bitrate_(pb::spotify::Bitrate320k), + bitrate_(cpb::spotify::Bitrate320k), volume_normalisation_(false) { // Build the search path for the binary blob. // Look for one distributed alongside clementine first, then check in the @@ -174,7 +174,7 @@ void SpotifyService::Login(const QString& username, const QString& password) { void SpotifyService::LoginCompleted( bool success, const QString& error, - pb::spotify::LoginResponse_Error error_code) { + cpb::spotify::LoginResponse_Error error_code) { if (login_task_id_) { app_->task_manager()->SetTaskFinished(login_task_id_); login_task_id_ = 0; @@ -185,19 +185,19 @@ void SpotifyService::LoginCompleted( QString error_copy(error); switch (error_code) { - case pb::spotify::LoginResponse_Error_BadUsernameOrPassword: + case cpb::spotify::LoginResponse_Error_BadUsernameOrPassword: login_state_ = LoginState_BadCredentials; break; - case pb::spotify::LoginResponse_Error_UserBanned: + case cpb::spotify::LoginResponse_Error_UserBanned: login_state_ = LoginState_Banned; break; - case pb::spotify::LoginResponse_Error_UserNeedsPremium: + case cpb::spotify::LoginResponse_Error_UserNeedsPremium: login_state_ = LoginState_NoPremium; break; - case pb::spotify::LoginResponse_Error_ReloginFailed: + case cpb::spotify::LoginResponse_Error_ReloginFailed: if (login_state_ == LoginState_LoggedIn) { // This is the first time the relogin has failed - show a message this // time only. @@ -247,8 +247,8 @@ void SpotifyService::ReloadSettings() { login_state_ = LoginState(s.value("login_state", LoginState_OtherError).toInt()); - bitrate_ = static_cast( - s.value("bitrate", pb::spotify::Bitrate320k).toInt()); + bitrate_ = static_cast( + s.value("bitrate", cpb::spotify::Bitrate320k).toInt()); volume_normalisation_ = s.value("volume_normalisation", false).toBool(); if (server_ && blob_process_) { @@ -267,29 +267,29 @@ void SpotifyService::EnsureServerCreated(const QString& username, connect( server_, - SIGNAL(LoginCompleted(bool, QString, pb::spotify::LoginResponse_Error)), - SLOT(LoginCompleted(bool, QString, pb::spotify::LoginResponse_Error))); - connect(server_, SIGNAL(PlaylistsUpdated(pb::spotify::Playlists)), - SLOT(PlaylistsUpdated(pb::spotify::Playlists))); - connect(server_, SIGNAL(InboxLoaded(pb::spotify::LoadPlaylistResponse)), - SLOT(InboxLoaded(pb::spotify::LoadPlaylistResponse))); - connect(server_, SIGNAL(StarredLoaded(pb::spotify::LoadPlaylistResponse)), - SLOT(StarredLoaded(pb::spotify::LoadPlaylistResponse))); + SIGNAL(LoginCompleted(bool, QString, cpb::spotify::LoginResponse_Error)), + SLOT(LoginCompleted(bool, QString, cpb::spotify::LoginResponse_Error))); + connect(server_, SIGNAL(PlaylistsUpdated(cpb::spotify::Playlists)), + SLOT(PlaylistsUpdated(cpb::spotify::Playlists))); + connect(server_, SIGNAL(InboxLoaded(cpb::spotify::LoadPlaylistResponse)), + SLOT(InboxLoaded(cpb::spotify::LoadPlaylistResponse))); + connect(server_, SIGNAL(StarredLoaded(cpb::spotify::LoadPlaylistResponse)), + SLOT(StarredLoaded(cpb::spotify::LoadPlaylistResponse))); connect(server_, - SIGNAL(UserPlaylistLoaded(pb::spotify::LoadPlaylistResponse)), - SLOT(UserPlaylistLoaded(pb::spotify::LoadPlaylistResponse))); + SIGNAL(UserPlaylistLoaded(cpb::spotify::LoadPlaylistResponse)), + SLOT(UserPlaylistLoaded(cpb::spotify::LoadPlaylistResponse))); connect(server_, SIGNAL(PlaybackError(QString)), SIGNAL(StreamError(QString))); - connect(server_, SIGNAL(SearchResults(pb::spotify::SearchResponse)), - SLOT(SearchResults(pb::spotify::SearchResponse))); + connect(server_, SIGNAL(SearchResults(cpb::spotify::SearchResponse)), + SLOT(SearchResults(cpb::spotify::SearchResponse))); connect(server_, SIGNAL(ImageLoaded(QString, QImage)), SIGNAL(ImageLoaded(QString, QImage))); connect(server_, - SIGNAL(SyncPlaylistProgress(pb::spotify::SyncPlaylistProgress)), - SLOT(SyncPlaylistProgress(pb::spotify::SyncPlaylistProgress))); + SIGNAL(SyncPlaylistProgress(cpb::spotify::SyncPlaylistProgress)), + SLOT(SyncPlaylistProgress(cpb::spotify::SyncPlaylistProgress))); connect(server_, - SIGNAL(ToplistBrowseResults(pb::spotify::BrowseToplistResponse)), - SLOT(ToplistLoaded(pb::spotify::BrowseToplistResponse))); + SIGNAL(ToplistBrowseResults(cpb::spotify::BrowseToplistResponse)), + SLOT(ToplistLoaded(cpb::spotify::BrowseToplistResponse))); server_->Init(); @@ -432,7 +432,7 @@ void SpotifyService::InitSearch() { root_->appendRow(inbox_); } -void SpotifyService::PlaylistsUpdated(const pb::spotify::Playlists& response) { +void SpotifyService::PlaylistsUpdated(const cpb::spotify::Playlists& response) { if (login_task_id_) { app_->task_manager()->SetTaskFinished(login_task_id_); login_task_id_ = 0; @@ -463,7 +463,7 @@ void SpotifyService::PlaylistsUpdated(const pb::spotify::Playlists& response) { playlists_.clear(); for (int i = 0; i < response.playlist_size(); ++i) { - const pb::spotify::Playlists::Playlist& msg = response.playlist(i); + const cpb::spotify::Playlists::Playlist& msg = response.playlist(i); QString playlist_title = QStringFromStdString(msg.name()); if (!msg.is_mine()) { @@ -490,13 +490,13 @@ void SpotifyService::PlaylistsUpdated(const pb::spotify::Playlists& response) { } bool SpotifyService::DoPlaylistsDiffer( - const pb::spotify::Playlists& response) const { + const cpb::spotify::Playlists& response) const { if (playlists_.count() != response.playlist_size()) { return true; } for (int i = 0; i < response.playlist_size(); ++i) { - const pb::spotify::Playlists::Playlist& msg = response.playlist(i); + const cpb::spotify::Playlists::Playlist& msg = response.playlist(i); const QStandardItem* item = PlaylistBySpotifyIndex(msg.index()); if (!item) { @@ -516,21 +516,21 @@ bool SpotifyService::DoPlaylistsDiffer( } void SpotifyService::InboxLoaded( - const pb::spotify::LoadPlaylistResponse& response) { + const cpb::spotify::LoadPlaylistResponse& response) { if (inbox_) { FillPlaylist(inbox_, response); } } void SpotifyService::StarredLoaded( - const pb::spotify::LoadPlaylistResponse& response) { + const cpb::spotify::LoadPlaylistResponse& response) { if (starred_) { FillPlaylist(starred_, response); } } void SpotifyService::ToplistLoaded( - const pb::spotify::BrowseToplistResponse& response) { + const cpb::spotify::BrowseToplistResponse& response) { if (toplist_) { FillPlaylist(toplist_, response.track()); } @@ -546,7 +546,7 @@ QStandardItem* SpotifyService::PlaylistBySpotifyIndex(int index) const { } void SpotifyService::UserPlaylistLoaded( - const pb::spotify::LoadPlaylistResponse& response) { + const cpb::spotify::LoadPlaylistResponse& response) { // Find a playlist with this index QStandardItem* item = PlaylistBySpotifyIndex(response.request().user_playlist_index()); @@ -557,7 +557,7 @@ void SpotifyService::UserPlaylistLoaded( void SpotifyService::FillPlaylist( QStandardItem* item, - const google::protobuf::RepeatedPtrField& tracks) { + const google::protobuf::RepeatedPtrField& tracks) { if (item->hasChildren()) item->removeRows(0, item->rowCount()); for (int i = 0; i < tracks.size(); ++i) { @@ -571,12 +571,12 @@ void SpotifyService::FillPlaylist( } void SpotifyService::FillPlaylist( - QStandardItem* item, const pb::spotify::LoadPlaylistResponse& response) { + QStandardItem* item, const cpb::spotify::LoadPlaylistResponse& response) { qLog(Debug) << "Filling playlist:" << item->text(); FillPlaylist(item, response.track()); } -void SpotifyService::SongFromProtobuf(const pb::spotify::Track& track, +void SpotifyService::SongFromProtobuf(const cpb::spotify::Track& track, Song* song) { song->set_rating(track.starred() ? 1.0 : 0.0); song->set_title(QStringFromStdString(track.title())); @@ -747,7 +747,7 @@ void SpotifyService::DoSearch() { } void SpotifyService::SearchResults( - const pb::spotify::SearchResponse& response) { + const cpb::spotify::SearchResponse& response) { if (QStringFromStdString(response.request().query()) != pending_search_) { qLog(Debug) << "Old search result for" << QStringFromStdString(response.request().query()) @@ -888,17 +888,17 @@ void SpotifyService::SetPaused(bool paused) { } void SpotifyService::SyncPlaylistProgress( - const pb::spotify::SyncPlaylistProgress& progress) { + const cpb::spotify::SyncPlaylistProgress& progress) { qLog(Debug) << "Sync progress:" << progress.sync_progress(); int task_id = -1; switch (progress.request().type()) { - case pb::spotify::Inbox: + case cpb::spotify::Inbox: task_id = inbox_sync_id_; break; - case pb::spotify::Starred: + case cpb::spotify::Starred: task_id = starred_sync_id_; break; - case pb::spotify::UserPlaylist: { + case cpb::spotify::UserPlaylist: { QMap::const_iterator it = playlist_sync_ids_.constFind( progress.request().user_playlist_index()); if (it != playlist_sync_ids_.constEnd()) { @@ -916,7 +916,7 @@ void SpotifyService::SyncPlaylistProgress( app_->task_manager()->SetTaskProgress(task_id, progress.sync_progress(), 100); if (progress.sync_progress() == 100) { app_->task_manager()->SetTaskFinished(task_id); - if (progress.request().type() == pb::spotify::UserPlaylist) { + if (progress.request().type() == cpb::spotify::UserPlaylist) { playlist_sync_ids_.remove(task_id); } } diff --git a/src/internet/spotify/spotifyservice.h b/src/internet/spotify/spotifyservice.h index cd372d69e..1b162dc3c 100644 --- a/src/internet/spotify/spotifyservice.h +++ b/src/internet/spotify/spotifyservice.h @@ -93,7 +93,7 @@ class SpotifyService : public InternetService { LoginState login_state() const { return login_state_; } bool IsLoggedIn() const { return login_state_ == LoginState_LoggedIn; } - static void SongFromProtobuf(const pb::spotify::Track& track, Song* song); + static void SongFromProtobuf(const cpb::spotify::Track& track, Song* song); signals: void BlobStateChanged(); @@ -109,9 +109,9 @@ class SpotifyService : public InternetService { void StartBlobProcess(); void FillPlaylist( QStandardItem* item, - const google::protobuf::RepeatedPtrField& tracks); + const google::protobuf::RepeatedPtrField& tracks); void FillPlaylist(QStandardItem* item, - const pb::spotify::LoadPlaylistResponse& response); + const cpb::spotify::LoadPlaylistResponse& response); void AddSongsToUserPlaylist(int playlist_index, const QList& songs_urls); void AddSongsToStarred(const QList& songs_urls); @@ -123,26 +123,26 @@ class SpotifyService : public InternetService { void InitSearch(); void ClearSearchResults(); QStandardItem* PlaylistBySpotifyIndex(int index) const; - bool DoPlaylistsDiffer(const pb::spotify::Playlists& response) const; + bool DoPlaylistsDiffer(const cpb::spotify::Playlists& response) const; private slots: void EnsureServerCreated(const QString& username = QString(), const QString& password = QString()); void BlobProcessError(QProcess::ProcessError error); void LoginCompleted(bool success, const QString& error, - pb::spotify::LoginResponse_Error error_code); + cpb::spotify::LoginResponse_Error error_code); void AddCurrentSongToUserPlaylist(QAction* action); void AddCurrentSongToStarredPlaylist(); void RemoveSongsFromUserPlaylist(int playlist_index, const QList& songs_indices_to_remove); void RemoveSongsFromStarred(const QList& songs_indices_to_remove); - void PlaylistsUpdated(const pb::spotify::Playlists& response); - void InboxLoaded(const pb::spotify::LoadPlaylistResponse& response); - void StarredLoaded(const pb::spotify::LoadPlaylistResponse& response); - void UserPlaylistLoaded(const pb::spotify::LoadPlaylistResponse& response); - void SearchResults(const pb::spotify::SearchResponse& response); - void SyncPlaylistProgress(const pb::spotify::SyncPlaylistProgress& progress); - void ToplistLoaded(const pb::spotify::BrowseToplistResponse& response); + void PlaylistsUpdated(const cpb::spotify::Playlists& response); + void InboxLoaded(const cpb::spotify::LoadPlaylistResponse& response); + void StarredLoaded(const cpb::spotify::LoadPlaylistResponse& response); + void UserPlaylistLoaded(const cpb::spotify::LoadPlaylistResponse& response); + void SearchResults(const cpb::spotify::SearchResponse& response); + void SyncPlaylistProgress(const cpb::spotify::SyncPlaylistProgress& progress); + void ToplistLoaded(const cpb::spotify::BrowseToplistResponse& response); void GetCurrentSongUrlToShare() const; void GetCurrentPlaylistUrlToShare() const; @@ -188,7 +188,7 @@ class SpotifyService : public InternetService { QMap playlist_sync_ids_; LoginState login_state_; - pb::spotify::Bitrate bitrate_; + cpb::spotify::Bitrate bitrate_; bool volume_normalisation_; }; diff --git a/src/internet/spotify/spotifysettingspage.cpp b/src/internet/spotify/spotifysettingspage.cpp index 5bd566736..4d3505fb4 100644 --- a/src/internet/spotify/spotifysettingspage.cpp +++ b/src/internet/spotify/spotifysettingspage.cpp @@ -59,9 +59,9 @@ SpotifySettingsPage::SpotifySettingsPage(SettingsDialog* dialog) ui_->login_state->AddCredentialField(ui_->password); ui_->login_state->AddCredentialGroup(ui_->account_group); - ui_->bitrate->addItem("96 " + tr("kbps"), pb::spotify::Bitrate96k); - ui_->bitrate->addItem("160 " + tr("kbps"), pb::spotify::Bitrate160k); - ui_->bitrate->addItem("320 " + tr("kbps"), pb::spotify::Bitrate320k); + ui_->bitrate->addItem("96 " + tr("kbps"), cpb::spotify::Bitrate96k); + ui_->bitrate->addItem("160 " + tr("kbps"), cpb::spotify::Bitrate160k); + ui_->bitrate->addItem("320 " + tr("kbps"), cpb::spotify::Bitrate320k); BlobStateChanged(); } @@ -108,7 +108,7 @@ void SpotifySettingsPage::Load() { validated_ = false; ui_->bitrate->setCurrentIndex(ui_->bitrate->findData( - s.value("bitrate", pb::spotify::Bitrate320k).toInt())); + s.value("bitrate", cpb::spotify::Bitrate320k).toInt())); ui_->volume_normalisation->setChecked( s.value("volume_normalisation", false).toBool()); diff --git a/src/main.cpp b/src/main.cpp index ec1e1f03f..7737d112c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -191,7 +191,7 @@ void ParseAProto() { "304c6f756e67652e6d786dba012a28414c42554d2920476f74616e2050726f6a65637" "4202d20416d6269656e74204c6f756e67652e6d786dc001c7a7efd104c801bad685e4" "04d001eeca32"); - pb::tagreader::Message message; + cpb::tagreader::Message message; message.ParseFromArray(data.constData(), data.size()); } diff --git a/src/networkremote/incomingdataparser.cpp b/src/networkremote/incomingdataparser.cpp index 8d483fa8c..9d9f59f8b 100644 --- a/src/networkremote/incomingdataparser.cpp +++ b/src/networkremote/incomingdataparser.cpp @@ -107,112 +107,112 @@ void IncomingDataParser::ReloadSettings() { bool IncomingDataParser::close_connection() { return close_connection_; } -void IncomingDataParser::Parse(const pb::remote::Message& msg) { +void IncomingDataParser::Parse(const cpb::remote::Message& msg) { close_connection_ = false; RemoteClient* client = qobject_cast(sender()); // Now check what's to do switch (msg.type()) { - case pb::remote::CONNECT: + case cpb::remote::CONNECT: ClientConnect(msg, client); break; - case pb::remote::DISCONNECT: + case cpb::remote::DISCONNECT: close_connection_ = true; break; - case pb::remote::REQUEST_PLAYLISTS: + case cpb::remote::REQUEST_PLAYLISTS: SendPlaylists(msg); break; - case pb::remote::REQUEST_PLAYLIST_SONGS: + case cpb::remote::REQUEST_PLAYLIST_SONGS: GetPlaylistSongs(msg); break; - case pb::remote::SET_VOLUME: + case cpb::remote::SET_VOLUME: emit SetVolume(msg.request_set_volume().volume()); break; - case pb::remote::PLAY: + case cpb::remote::PLAY: emit Play(); break; - case pb::remote::PLAYPAUSE: + case cpb::remote::PLAYPAUSE: emit PlayPause(); break; - case pb::remote::PAUSE: + case cpb::remote::PAUSE: emit Pause(); break; - case pb::remote::STOP: + case cpb::remote::STOP: emit Stop(); break; - case pb::remote::STOP_AFTER: + case cpb::remote::STOP_AFTER: emit StopAfterCurrent(); break; - case pb::remote::NEXT: + case cpb::remote::NEXT: emit Next(); break; - case pb::remote::PREVIOUS: + case cpb::remote::PREVIOUS: emit Previous(); break; - case pb::remote::CHANGE_SONG: + case cpb::remote::CHANGE_SONG: ChangeSong(msg); break; - case pb::remote::SHUFFLE_PLAYLIST: + case cpb::remote::SHUFFLE_PLAYLIST: emit ShuffleCurrent(); break; - case pb::remote::REPEAT: + case cpb::remote::REPEAT: SetRepeatMode(msg.repeat()); break; - case pb::remote::SHUFFLE: + case cpb::remote::SHUFFLE: SetShuffleMode(msg.shuffle()); break; - case pb::remote::SET_TRACK_POSITION: + case cpb::remote::SET_TRACK_POSITION: emit SeekTo(msg.request_set_track_position().position()); break; - case pb::remote::INSERT_URLS: + case cpb::remote::INSERT_URLS: InsertUrls(msg); break; - case pb::remote::REMOVE_SONGS: + case cpb::remote::REMOVE_SONGS: RemoveSongs(msg); break; - case pb::remote::OPEN_PLAYLIST: + case cpb::remote::OPEN_PLAYLIST: OpenPlaylist(msg); break; - case pb::remote::CLOSE_PLAYLIST: + case cpb::remote::CLOSE_PLAYLIST: ClosePlaylist(msg); break; - case pb::remote::UPDATE_PLAYLIST: + case cpb::remote::UPDATE_PLAYLIST: UpdatePlaylist(msg); break; - case pb::remote::LOVE: + case cpb::remote::LOVE: emit Love(); break; - case pb::remote::BAN: + case cpb::remote::BAN: emit Ban(); break; - case pb::remote::GET_LYRICS: + case cpb::remote::GET_LYRICS: emit GetLyrics(); break; - case pb::remote::DOWNLOAD_SONGS: + case cpb::remote::DOWNLOAD_SONGS: client->song_sender()->SendSongs(msg.request_download_songs()); break; - case pb::remote::SONG_OFFER_RESPONSE: + case cpb::remote::SONG_OFFER_RESPONSE: client->song_sender()->ResponseSongOffer( msg.response_song_offer().accepted()); break; - case pb::remote::GET_LIBRARY: + case cpb::remote::GET_LIBRARY: emit SendLibrary(client); break; - case pb::remote::RATE_SONG: + case cpb::remote::RATE_SONG: RateSong(msg); break; - case pb::remote::GLOBAL_SEARCH: + case cpb::remote::GLOBAL_SEARCH: GlobalSearch(client, msg); break; - case pb::remote::REQUEST_FILES: + case cpb::remote::REQUEST_FILES: emit SendListFiles( QString::fromStdString(msg.request_list_files().relative_path()), client); break; - case pb::remote::APPEND_FILES: + case cpb::remote::APPEND_FILES: AppendFilesToPlaylist(msg); break; - case pb::remote::REQUEST_SAVED_RADIOS: + case cpb::remote::REQUEST_SAVED_RADIOS: emit SendSavedRadios(client); break; @@ -221,13 +221,13 @@ void IncomingDataParser::Parse(const pb::remote::Message& msg) { } } -void IncomingDataParser::GetPlaylistSongs(const pb::remote::Message& msg) { +void IncomingDataParser::GetPlaylistSongs(const cpb::remote::Message& msg) { emit SendPlaylistSongs(msg.request_playlist_songs().id()); } -void IncomingDataParser::ChangeSong(const pb::remote::Message& msg) { +void IncomingDataParser::ChangeSong(const cpb::remote::Message& msg) { // Get the first entry and check if there is a song - const pb::remote::RequestChangeSong& request = msg.request_change_song(); + const cpb::remote::RequestChangeSong& request = msg.request_change_song(); // Check if we need to change the playlist if (request.playlist_id() != app_->playlist_manager()->active_id()) { @@ -251,18 +251,18 @@ void IncomingDataParser::ChangeSong(const pb::remote::Message& msg) { } } -void IncomingDataParser::SetRepeatMode(const pb::remote::Repeat& repeat) { +void IncomingDataParser::SetRepeatMode(const cpb::remote::Repeat& repeat) { switch (repeat.repeat_mode()) { - case pb::remote::Repeat_Off: + case cpb::remote::Repeat_Off: emit SetRepeatMode(PlaylistSequence::Repeat_Off); break; - case pb::remote::Repeat_Track: + case cpb::remote::Repeat_Track: emit SetRepeatMode(PlaylistSequence::Repeat_Track); break; - case pb::remote::Repeat_Album: + case cpb::remote::Repeat_Album: emit SetRepeatMode(PlaylistSequence::Repeat_Album); break; - case pb::remote::Repeat_Playlist: + case cpb::remote::Repeat_Playlist: emit SetRepeatMode(PlaylistSequence::Repeat_Playlist); break; default: @@ -270,18 +270,18 @@ void IncomingDataParser::SetRepeatMode(const pb::remote::Repeat& repeat) { } } -void IncomingDataParser::SetShuffleMode(const pb::remote::Shuffle& shuffle) { +void IncomingDataParser::SetShuffleMode(const cpb::remote::Shuffle& shuffle) { switch (shuffle.shuffle_mode()) { - case pb::remote::Shuffle_Off: + case cpb::remote::Shuffle_Off: emit SetShuffleMode(PlaylistSequence::Shuffle_Off); break; - case pb::remote::Shuffle_All: + case cpb::remote::Shuffle_All: emit SetShuffleMode(PlaylistSequence::Shuffle_All); break; - case pb::remote::Shuffle_InsideAlbum: + case cpb::remote::Shuffle_InsideAlbum: emit SetShuffleMode(PlaylistSequence::Shuffle_InsideAlbum); break; - case pb::remote::Shuffle_Albums: + case cpb::remote::Shuffle_Albums: emit SetShuffleMode(PlaylistSequence::Shuffle_Albums); break; default: @@ -289,8 +289,8 @@ void IncomingDataParser::SetShuffleMode(const pb::remote::Shuffle& shuffle) { } } -void IncomingDataParser::InsertUrls(const pb::remote::Message& msg) { - const pb::remote::RequestInsertUrls& request = msg.request_insert_urls(); +void IncomingDataParser::InsertUrls(const cpb::remote::Message& msg) { + const cpb::remote::RequestInsertUrls& request = msg.request_insert_urls(); int playlist_id = request.playlist_id(); // Insert plain urls without metadata @@ -328,8 +328,8 @@ void IncomingDataParser::InsertUrls(const pb::remote::Message& msg) { } } -void IncomingDataParser::RemoveSongs(const pb::remote::Message& msg) { - const pb::remote::RequestRemoveSongs& request = msg.request_remove_songs(); +void IncomingDataParser::RemoveSongs(const cpb::remote::Message& msg) { + const cpb::remote::RequestRemoveSongs& request = msg.request_remove_songs(); // Extract urls QList songs; @@ -341,7 +341,7 @@ void IncomingDataParser::RemoveSongs(const pb::remote::Message& msg) { emit RemoveSongs(request.playlist_id(), songs); } -void IncomingDataParser::ClientConnect(const pb::remote::Message& msg, +void IncomingDataParser::ClientConnect(const cpb::remote::Message& msg, RemoteClient* client) { // Always sned the Clementine infos emit SendClementineInfo(); @@ -357,7 +357,7 @@ void IncomingDataParser::ClientConnect(const pb::remote::Message& msg, } } -void IncomingDataParser::SendPlaylists(const pb::remote::Message& msg) { +void IncomingDataParser::SendPlaylists(const cpb::remote::Message& msg) { if (!msg.has_request_playlists() || !msg.request_playlists().include_closed()) { emit SendAllActivePlaylists(); @@ -366,16 +366,16 @@ void IncomingDataParser::SendPlaylists(const pb::remote::Message& msg) { } } -void IncomingDataParser::OpenPlaylist(const pb::remote::Message& msg) { +void IncomingDataParser::OpenPlaylist(const cpb::remote::Message& msg) { emit Open(msg.request_open_playlist().playlist_id()); } -void IncomingDataParser::ClosePlaylist(const pb::remote::Message& msg) { +void IncomingDataParser::ClosePlaylist(const cpb::remote::Message& msg) { emit Close(msg.request_close_playlist().playlist_id()); } -void IncomingDataParser::UpdatePlaylist(const pb::remote::Message& msg) { - const pb::remote::RequestUpdatePlaylist& req_update = +void IncomingDataParser::UpdatePlaylist(const cpb::remote::Message& msg) { + const cpb::remote::RequestUpdatePlaylist& req_update = msg.request_update_playlist(); if (req_update.has_create_new_playlist() && req_update.create_new_playlist()) { @@ -396,19 +396,19 @@ void IncomingDataParser::UpdatePlaylist(const pb::remote::Message& msg) { emit Favorite(req_update.playlist_id(), req_update.favorite()); } -void IncomingDataParser::RateSong(const pb::remote::Message& msg) { +void IncomingDataParser::RateSong(const cpb::remote::Message& msg) { double rating = (double)msg.request_rate_song().rating(); emit RateCurrentSong(rating); } void IncomingDataParser::GlobalSearch(RemoteClient* client, - const pb::remote::Message& msg) { + const cpb::remote::Message& msg) { emit DoGlobalSearch(QStringFromStdString(msg.request_global_search().query()), client); } Song IncomingDataParser::CreateSongFromProtobuf( - const pb::remote::SongMetadata& pb) { + const cpb::remote::SongMetadata& pb) { Song song; song.Init(QStringFromStdString(pb.title()), QStringFromStdString(pb.artist()), QStringFromStdString(pb.album()), pb.length() * kNsecPerSec); @@ -429,7 +429,8 @@ Song IncomingDataParser::CreateSongFromProtobuf( return song; } -void IncomingDataParser::AppendFilesToPlaylist(const pb::remote::Message& msg) { +void IncomingDataParser::AppendFilesToPlaylist( + const cpb::remote::Message& msg) { if (files_root_folder_.isEmpty()) { // should never happen... qLog(Warning) << "Remote root dir is not set although receiving " "APPEND_FILES request..."; @@ -441,7 +442,8 @@ void IncomingDataParser::AppendFilesToPlaylist(const pb::remote::Message& msg) { return; } - const pb::remote::RequestAppendFiles& req_append = msg.request_append_files(); + const cpb::remote::RequestAppendFiles& req_append = + msg.request_append_files(); QString relative_path = QString::fromStdString(req_append.relative_path()); if (relative_path.startsWith("/")) relative_path.remove(0, 1); diff --git a/src/networkremote/incomingdataparser.h b/src/networkremote/incomingdataparser.h index 9c46dcf72..57d3cf8f0 100644 --- a/src/networkremote/incomingdataparser.h +++ b/src/networkremote/incomingdataparser.h @@ -20,7 +20,7 @@ class IncomingDataParser : public QObject { } public slots: - void Parse(const pb::remote::Message& msg); + void Parse(const cpb::remote::Message& msg); void ReloadSettings(); signals: @@ -75,22 +75,22 @@ class IncomingDataParser : public QObject { MainWindow::PlaylistAddBehaviour doubleclick_playlist_addmode_; QString files_root_folder_; - void GetPlaylistSongs(const pb::remote::Message& msg); - void ChangeSong(const pb::remote::Message& msg); - void SetRepeatMode(const pb::remote::Repeat& repeat); - void SetShuffleMode(const pb::remote::Shuffle& shuffle); - void InsertUrls(const pb::remote::Message& msg); - void RemoveSongs(const pb::remote::Message& msg); - void ClientConnect(const pb::remote::Message& msg, RemoteClient* client); - void SendPlaylists(const pb::remote::Message& msg); - void OpenPlaylist(const pb::remote::Message& msg); - void ClosePlaylist(const pb::remote::Message& msg); - void UpdatePlaylist(const pb::remote::Message& msg); - void RateSong(const pb::remote::Message& msg); - void GlobalSearch(RemoteClient* client, const pb::remote::Message& msg); - void AppendFilesToPlaylist(const pb::remote::Message& msg); + void GetPlaylistSongs(const cpb::remote::Message& msg); + void ChangeSong(const cpb::remote::Message& msg); + void SetRepeatMode(const cpb::remote::Repeat& repeat); + void SetShuffleMode(const cpb::remote::Shuffle& shuffle); + void InsertUrls(const cpb::remote::Message& msg); + void RemoveSongs(const cpb::remote::Message& msg); + void ClientConnect(const cpb::remote::Message& msg, RemoteClient* client); + void SendPlaylists(const cpb::remote::Message& msg); + void OpenPlaylist(const cpb::remote::Message& msg); + void ClosePlaylist(const cpb::remote::Message& msg); + void UpdatePlaylist(const cpb::remote::Message& msg); + void RateSong(const cpb::remote::Message& msg); + void GlobalSearch(RemoteClient* client, const cpb::remote::Message& msg); + void AppendFilesToPlaylist(const cpb::remote::Message& msg); - Song CreateSongFromProtobuf(const pb::remote::SongMetadata& pb); + Song CreateSongFromProtobuf(const cpb::remote::SongMetadata& pb); }; #endif // INCOMINGDATAPARSER_H diff --git a/src/networkremote/networkremote.cpp b/src/networkremote/networkremote.cpp index e376404a2..4e3eb4d85 100644 --- a/src/networkremote/networkremote.cpp +++ b/src/networkremote/networkremote.cpp @@ -234,8 +234,8 @@ void NetworkRemote::CreateRemoteClient(QTcpSocket* client_socket) { outgoing_data_creator_->SetAllowDownloads(client->allow_downloads()); // Connect the signal to parse data - connect(client, SIGNAL(Parse(pb::remote::Message)), - incoming_data_parser_.get(), SLOT(Parse(pb::remote::Message))); + connect(client, SIGNAL(Parse(cpb::remote::Message)), + incoming_data_parser_.get(), SLOT(Parse(cpb::remote::Message))); } } diff --git a/src/networkremote/outgoingdatacreator.cpp b/src/networkremote/outgoingdatacreator.cpp index b122e9786..39d500691 100644 --- a/src/networkremote/outgoingdatacreator.cpp +++ b/src/networkremote/outgoingdatacreator.cpp @@ -147,7 +147,7 @@ SongInfoProvider* OutgoingDataCreator::ProviderByName( return nullptr; } -void OutgoingDataCreator::SendDataToClients(pb::remote::Message* msg) { +void OutgoingDataCreator::SendDataToClients(cpb::remote::Message* msg) { // Check if we have clients to send data to if (clients_->empty()) { return; @@ -175,11 +175,11 @@ void OutgoingDataCreator::SendDataToClients(pb::remote::Message* msg) { void OutgoingDataCreator::SendClementineInfo() { // Create the general message and set the message type - pb::remote::Message msg; - msg.set_type(pb::remote::INFO); + cpb::remote::Message msg; + msg.set_type(cpb::remote::INFO); // Now add the message specific data - pb::remote::ResponseClementineInfo* info = + cpb::remote::ResponseClementineInfo* info = msg.mutable_response_clementine_info(); SetEngineState(info); @@ -196,20 +196,20 @@ void OutgoingDataCreator::SendClementineInfo() { } void OutgoingDataCreator::SetEngineState( - pb::remote::ResponseClementineInfo* msg) { + cpb::remote::ResponseClementineInfo* msg) { switch (app_->player()->GetState()) { case Engine::Idle: - msg->set_state(pb::remote::Idle); + msg->set_state(cpb::remote::Idle); break; case Engine::Error: case Engine::Empty: - msg->set_state(pb::remote::Empty); + msg->set_state(cpb::remote::Empty); break; case Engine::Playing: - msg->set_state(pb::remote::Playing); + msg->set_state(cpb::remote::Playing); break; case Engine::Paused: - msg->set_state(pb::remote::Paused); + msg->set_state(cpb::remote::Paused); break; } } @@ -220,10 +220,10 @@ void OutgoingDataCreator::SendAllPlaylists() { int active_playlist = playlist_manager->active_id(); // Create message - pb::remote::Message msg; - msg.set_type(pb::remote::PLAYLISTS); + cpb::remote::Message msg; + msg.set_type(cpb::remote::PLAYLISTS); - pb::remote::ResponsePlaylists* playlists = msg.mutable_response_playlists(); + cpb::remote::ResponsePlaylists* playlists = msg.mutable_response_playlists(); playlists->set_include_closed(true); // Get all playlists, even ones that are hidden in the UI. @@ -234,7 +234,7 @@ void OutgoingDataCreator::SendAllPlaylists() { playlist_open ? playlist_manager->playlist(p.id)->rowCount() : 0; // Create a new playlist - pb::remote::Playlist* playlist = playlists->add_playlist(); + cpb::remote::Playlist* playlist = playlists->add_playlist(); playlist->set_name(DataCommaSizeFromQString(p.name)); playlist->set_id(p.id); playlist->set_active((p.id == active_playlist)); @@ -252,10 +252,10 @@ void OutgoingDataCreator::SendAllActivePlaylists() { int active_playlist = app_->playlist_manager()->active_id(); // Create message - pb::remote::Message msg; - msg.set_type(pb::remote::PLAYLISTS); + cpb::remote::Message msg; + msg.set_type(cpb::remote::PLAYLISTS); - pb::remote::ResponsePlaylists* playlists = msg.mutable_response_playlists(); + cpb::remote::ResponsePlaylists* playlists = msg.mutable_response_playlists(); QListIterator it(app_playlists); while (it.hasNext()) { @@ -264,7 +264,7 @@ void OutgoingDataCreator::SendAllActivePlaylists() { QString playlist_name = app_->playlist_manager()->GetPlaylistName(p->id()); // Create a new playlist - pb::remote::Playlist* playlist = playlists->add_playlist(); + cpb::remote::Playlist* playlist = playlists->add_playlist(); playlist->set_name(DataCommaSizeFromQString(playlist_name)); playlist->set_id(p->id()); playlist->set_active((p->id() == active_playlist)); @@ -281,8 +281,8 @@ void OutgoingDataCreator::ActiveChanged(Playlist* playlist) { SendPlaylistSongs(playlist->id()); // Send the changed message after sending the playlist songs - pb::remote::Message msg; - msg.set_type(pb::remote::ACTIVE_PLAYLIST_CHANGED); + cpb::remote::Message msg; + msg.set_type(cpb::remote::ACTIVE_PLAYLIST_CHANGED); msg.mutable_response_active_changed()->set_id(playlist->id()); SendDataToClients(&msg); } @@ -335,8 +335,8 @@ void OutgoingDataCreator::SendFirstData(bool send_playlist_songs) { SendRepeatMode(app_->playlist_manager()->sequence()->repeat_mode()); // We send all first data - pb::remote::Message msg; - msg.set_type(pb::remote::FIRST_DATA_SENT_COMPLETE); + cpb::remote::Message msg; + msg.set_type(cpb::remote::FIRST_DATA_SENT_COMPLETE); SendDataToClients(&msg); } @@ -355,8 +355,8 @@ void OutgoingDataCreator::CurrentSongChanged(const Song& song, void OutgoingDataCreator::SendSongMetadata() { // Create the message - pb::remote::Message msg; - msg.set_type(pb::remote::CURRENT_METAINFO); + cpb::remote::Message msg; + msg.set_type(cpb::remote::CURRENT_METAINFO); // If there is no song, create an empty node, otherwise fill it with data int i = app_->playlist_manager()->active()->current_row(); @@ -368,7 +368,7 @@ void OutgoingDataCreator::SendSongMetadata() { void OutgoingDataCreator::CreateSong(const Song& song, const QImage& art, const int index, - pb::remote::SongMetadata* song_metadata) { + cpb::remote::SongMetadata* song_metadata) { if (song.is_valid()) { song_metadata->set_id(song.id()); song_metadata->set_index(index); @@ -394,7 +394,7 @@ void OutgoingDataCreator::CreateSong(const Song& song, const QImage& art, DataCommaSizeFromQString(song.art_automatic())); song_metadata->set_art_manual(DataCommaSizeFromQString(song.art_manual())); song_metadata->set_type( - static_cast<::pb::remote::SongMetadata_Type>(song.filetype())); + static_cast<::cpb::remote::SongMetadata_Type>(song.filetype())); // Append coverart if (!art.isNull()) { @@ -420,8 +420,8 @@ void OutgoingDataCreator::CreateSong(const Song& song, const QImage& art, void OutgoingDataCreator::VolumeChanged(int volume) { // Create the message - pb::remote::Message msg; - msg.set_type(pb::remote::SET_VOLUME); + cpb::remote::Message msg; + msg.set_type(cpb::remote::SET_VOLUME); msg.mutable_request_set_volume()->set_volume(volume); SendDataToClients(&msg); } @@ -435,15 +435,15 @@ void OutgoingDataCreator::SendPlaylistSongs(int id) { } // Create the message and the playlist - pb::remote::Message msg; - msg.set_type(pb::remote::PLAYLIST_SONGS); + cpb::remote::Message msg; + msg.set_type(cpb::remote::PLAYLIST_SONGS); // Create the Response message - pb::remote::ResponsePlaylistSongs* pb_response_playlist_songs = + cpb::remote::ResponsePlaylistSongs* pb_response_playlist_songs = msg.mutable_response_playlist_songs(); // Create a new playlist - pb::remote::Playlist* pb_playlist = + cpb::remote::Playlist* pb_playlist = pb_response_playlist_songs->mutable_requested_playlist(); pb_playlist->set_id(id); @@ -454,7 +454,8 @@ void OutgoingDataCreator::SendPlaylistSongs(int id) { QImage null_img; while (it.hasNext()) { Song song = it.next(); - pb::remote::SongMetadata* pb_song = pb_response_playlist_songs->add_songs(); + cpb::remote::SongMetadata* pb_song = + pb_response_playlist_songs->add_songs(); CreateSong(song, null_img, index, pb_song); ++index; } @@ -475,23 +476,23 @@ void OutgoingDataCreator::StateChanged(Engine::State state) { } last_state_ = state; - pb::remote::Message msg; + cpb::remote::Message msg; switch (state) { case Engine::Playing: - msg.set_type(pb::remote::PLAY); + msg.set_type(cpb::remote::PLAY); track_position_timer_->start(1000); break; case Engine::Paused: - msg.set_type(pb::remote::PAUSE); + msg.set_type(cpb::remote::PAUSE); track_position_timer_->stop(); break; case Engine::Empty: - msg.set_type(pb::remote::STOP); // Empty is called when player stopped + msg.set_type(cpb::remote::STOP); // Empty is called when player stopped track_position_timer_->stop(); break; default: - msg.set_type(pb::remote::STOP); + msg.set_type(cpb::remote::STOP); track_position_timer_->stop(); break; }; @@ -500,27 +501,27 @@ void OutgoingDataCreator::StateChanged(Engine::State state) { } void OutgoingDataCreator::SendRepeatMode(PlaylistSequence::RepeatMode mode) { - pb::remote::Message msg; - msg.set_type(pb::remote::REPEAT); + cpb::remote::Message msg; + msg.set_type(cpb::remote::REPEAT); switch (mode) { case PlaylistSequence::Repeat_Off: - msg.mutable_repeat()->set_repeat_mode(pb::remote::Repeat_Off); + msg.mutable_repeat()->set_repeat_mode(cpb::remote::Repeat_Off); break; case PlaylistSequence::Repeat_Track: - msg.mutable_repeat()->set_repeat_mode(pb::remote::Repeat_Track); + msg.mutable_repeat()->set_repeat_mode(cpb::remote::Repeat_Track); break; case PlaylistSequence::Repeat_Album: - msg.mutable_repeat()->set_repeat_mode(pb::remote::Repeat_Album); + msg.mutable_repeat()->set_repeat_mode(cpb::remote::Repeat_Album); break; case PlaylistSequence::Repeat_Playlist: - msg.mutable_repeat()->set_repeat_mode(pb::remote::Repeat_Playlist); + msg.mutable_repeat()->set_repeat_mode(cpb::remote::Repeat_Playlist); break; case PlaylistSequence::Repeat_OneByOne: - msg.mutable_repeat()->set_repeat_mode(pb::remote::Repeat_OneByOne); + msg.mutable_repeat()->set_repeat_mode(cpb::remote::Repeat_OneByOne); break; case PlaylistSequence::Repeat_Intro: - msg.mutable_repeat()->set_repeat_mode(pb::remote::Repeat_Intro); + msg.mutable_repeat()->set_repeat_mode(cpb::remote::Repeat_Intro); break; } @@ -528,21 +529,21 @@ void OutgoingDataCreator::SendRepeatMode(PlaylistSequence::RepeatMode mode) { } void OutgoingDataCreator::SendShuffleMode(PlaylistSequence::ShuffleMode mode) { - pb::remote::Message msg; - msg.set_type(pb::remote::SHUFFLE); + cpb::remote::Message msg; + msg.set_type(cpb::remote::SHUFFLE); switch (mode) { case PlaylistSequence::Shuffle_Off: - msg.mutable_shuffle()->set_shuffle_mode(pb::remote::Shuffle_Off); + msg.mutable_shuffle()->set_shuffle_mode(cpb::remote::Shuffle_Off); break; case PlaylistSequence::Shuffle_All: - msg.mutable_shuffle()->set_shuffle_mode(pb::remote::Shuffle_All); + msg.mutable_shuffle()->set_shuffle_mode(cpb::remote::Shuffle_All); break; case PlaylistSequence::Shuffle_InsideAlbum: - msg.mutable_shuffle()->set_shuffle_mode(pb::remote::Shuffle_InsideAlbum); + msg.mutable_shuffle()->set_shuffle_mode(cpb::remote::Shuffle_InsideAlbum); break; case PlaylistSequence::Shuffle_Albums: - msg.mutable_shuffle()->set_shuffle_mode(pb::remote::Shuffle_Albums); + msg.mutable_shuffle()->set_shuffle_mode(cpb::remote::Shuffle_Albums); break; } @@ -550,14 +551,14 @@ void OutgoingDataCreator::SendShuffleMode(PlaylistSequence::ShuffleMode mode) { } void OutgoingDataCreator::SendKeepAlive() { - pb::remote::Message msg; - msg.set_type(pb::remote::KEEP_ALIVE); + cpb::remote::Message msg; + msg.set_type(cpb::remote::KEEP_ALIVE); SendDataToClients(&msg); } void OutgoingDataCreator::UpdateTrackPosition() { - pb::remote::Message msg; - msg.set_type(pb::remote::UPDATE_TRACK_POSITION); + cpb::remote::Message msg; + msg.set_type(cpb::remote::UPDATE_TRACK_POSITION); qint64 position_nanosec = app_->player()->engine()->position_nanosec(); int position = static_cast( @@ -574,10 +575,10 @@ void OutgoingDataCreator::UpdateTrackPosition() { } void OutgoingDataCreator::DisconnectAllClients() { - pb::remote::Message msg; - msg.set_type(pb::remote::DISCONNECT); + cpb::remote::Message msg; + msg.set_type(cpb::remote::DISCONNECT); msg.mutable_response_disconnect()->set_reason_disconnect( - pb::remote::Server_Shutdown); + cpb::remote::Server_Shutdown); SendDataToClients(&msg); } @@ -585,9 +586,9 @@ void OutgoingDataCreator::GetLyrics() { fetcher_->FetchInfo(current_song_); } void OutgoingDataCreator::SendLyrics(int id, const SongInfoFetcher::Result& result) { - pb::remote::Message msg; - msg.set_type(pb::remote::LYRICS); - pb::remote::ResponseLyrics* response = msg.mutable_response_lyrics(); + cpb::remote::Message msg; + msg.set_type(cpb::remote::LYRICS); + cpb::remote::ResponseLyrics* response = msg.mutable_response_lyrics(); for (const CollapsibleInfoPane::Data& data : result.info_) { // If the size is zero, do not send the provider @@ -595,7 +596,7 @@ void OutgoingDataCreator::SendLyrics(int id, qobject_cast(data.content_object_); if (editor->toPlainText().length() == 0) continue; - pb::remote::Lyric* lyric = response->mutable_lyrics()->Add(); + cpb::remote::Lyric* lyric = response->mutable_lyrics()->Add(); lyric->set_id(DataCommaSizeFromQString(data.id_)); lyric->set_title(DataCommaSizeFromQString(data.title_)); @@ -636,10 +637,10 @@ void OutgoingDataCreator::SendLibrary(RemoteClient* client) { file.open(QIODevice::ReadOnly); QByteArray data; - pb::remote::Message msg; - pb::remote::ResponseLibraryChunk* chunk = + cpb::remote::Message msg; + cpb::remote::ResponseLibraryChunk* chunk = msg.mutable_response_library_chunk(); - msg.set_type(pb::remote::LIBRARY_CHUNK); + msg.set_type(cpb::remote::LIBRARY_CHUNK); // Calculate the number of chunks int chunk_count = qRound((file.size() / kFileChunkSize) + 0.5); @@ -687,14 +688,14 @@ void OutgoingDataCreator::DoGlobalSearch(const QString& query, global_search_result_map_.insert(id, request); // Send status message - pb::remote::Message msg; - pb::remote::ResponseGlobalSearchStatus* status = + cpb::remote::Message msg; + cpb::remote::ResponseGlobalSearchStatus* status = msg.mutable_response_global_search_status(); - msg.set_type(pb::remote::GLOBAL_SEARCH_STATUS); + msg.set_type(cpb::remote::GLOBAL_SEARCH_STATUS); status->set_id(id); status->set_query(DataCommaSizeFromQString(query)); - status->set_status(pb::remote::GlobalSearchStarted); + status->set_status(cpb::remote::GlobalSearchStarted); client->SendData(&msg); @@ -709,11 +710,11 @@ void OutgoingDataCreator::ResultsAvailable( RemoteClient* client = search_request.client_; QImage null_img; - pb::remote::Message msg; - pb::remote::ResponseGlobalSearch* response = + cpb::remote::Message msg; + cpb::remote::ResponseGlobalSearch* response = msg.mutable_response_global_search(); - msg.set_type(pb::remote::GLOBAL_SEARCH_RESULT); + msg.set_type(cpb::remote::GLOBAL_SEARCH_RESULT); response->set_id(search_request.id_); response->set_query(DataCommaSizeFromQString(search_request.query_)); response->set_search_provider( @@ -728,7 +729,7 @@ void OutgoingDataCreator::ResultsAvailable( response->set_search_provider_icon(byte_array.constData(), byte_array.size()); for (const SearchProvider::Result& result : results) { - pb::remote::SongMetadata* pb_song = response->add_song_metadata(); + cpb::remote::SongMetadata* pb_song = response->add_song_metadata(); CreateSong(result.metadata_, null_img, 0, pb_song); } @@ -744,14 +745,14 @@ void OutgoingDataCreator::SearchFinished(int id) { GlobalSearchRequest req = global_search_result_map_.take(id); // Send status message - pb::remote::Message msg; - pb::remote::ResponseGlobalSearchStatus* status = + cpb::remote::Message msg; + cpb::remote::ResponseGlobalSearchStatus* status = msg.mutable_response_global_search_status(); - msg.set_type(pb::remote::GLOBAL_SEARCH_STATUS); + msg.set_type(cpb::remote::GLOBAL_SEARCH_STATUS); status->set_id(req.id_); status->set_query(DataCommaSizeFromQString(req.query_)); - status->set_status(pb::remote::GlobalSearchFinished); + status->set_status(cpb::remote::GlobalSearchFinished); req.client_->SendData(&msg); @@ -760,32 +761,32 @@ void OutgoingDataCreator::SearchFinished(int id) { void OutgoingDataCreator::SendListFiles(QString relative_path, RemoteClient* client) { - pb::remote::Message msg; - msg.set_type(pb::remote::LIST_FILES); - pb::remote::ResponseListFiles* files = msg.mutable_response_list_files(); + cpb::remote::Message msg; + msg.set_type(cpb::remote::LIST_FILES); + cpb::remote::ResponseListFiles* files = msg.mutable_response_list_files(); // Security checks if (files_root_folder_.isEmpty()) { - files->set_error(pb::remote::ResponseListFiles::ROOT_DIR_NOT_SET); + files->set_error(cpb::remote::ResponseListFiles::ROOT_DIR_NOT_SET); SendDataToClients(&msg); return; } QDir root_dir(files_root_folder_); if (!root_dir.exists()) - files->set_error(pb::remote::ResponseListFiles::ROOT_DIR_NOT_SET); + files->set_error(cpb::remote::ResponseListFiles::ROOT_DIR_NOT_SET); else if (relative_path.startsWith("..") || relative_path.startsWith("./..")) - files->set_error(pb::remote::ResponseListFiles::DIR_NOT_ACCESSIBLE); + files->set_error(cpb::remote::ResponseListFiles::DIR_NOT_ACCESSIBLE); else { if (relative_path.startsWith("/")) relative_path.remove(0, 1); QFileInfo fi_folder(root_dir, relative_path); if (!fi_folder.exists()) - files->set_error(pb::remote::ResponseListFiles::DIR_NOT_EXIST); + files->set_error(cpb::remote::ResponseListFiles::DIR_NOT_EXIST); else if (!fi_folder.isDir()) - files->set_error(pb::remote::ResponseListFiles::DIR_NOT_EXIST); + files->set_error(cpb::remote::ResponseListFiles::DIR_NOT_EXIST); else if (root_dir.relativeFilePath(fi_folder.absoluteFilePath()) .startsWith("../")) - files->set_error(pb::remote::ResponseListFiles::DIR_NOT_ACCESSIBLE); + files->set_error(cpb::remote::ResponseListFiles::DIR_NOT_ACCESSIBLE); else { files->set_relative_path( root_dir.relativeFilePath(fi_folder.absoluteFilePath()) @@ -796,7 +797,7 @@ void OutgoingDataCreator::SendListFiles(QString relative_path, for (const QFileInfo& fi : dir.entryInfoList()) { if (fi.isDir() || files_music_extensions_.contains(fi.suffix())) { - pb::remote::FileMetadata* pb_file = files->add_files(); + cpb::remote::FileMetadata* pb_file = files->add_files(); pb_file->set_is_dir(fi.isDir()); pb_file->set_filename(fi.fileName().toStdString()); } @@ -807,16 +808,16 @@ void OutgoingDataCreator::SendListFiles(QString relative_path, } void OutgoingDataCreator::SendSavedRadios(RemoteClient* client) { - pb::remote::Message msg; - msg.set_type(pb::remote::REQUEST_SAVED_RADIOS); + cpb::remote::Message msg; + msg.set_type(cpb::remote::REQUEST_SAVED_RADIOS); SavedRadio* radio_service = static_cast( InternetModel::ServiceByName(SavedRadio::kServiceName)); if (radio_service) { - pb::remote::ResponseSavedRadios* radios = + cpb::remote::ResponseSavedRadios* radios = msg.mutable_response_saved_radios(); for (const auto& stream : radio_service->Streams()) { - pb::remote::Stream* pb_stream = radios->add_streams(); + cpb::remote::Stream* pb_stream = radios->add_streams(); pb_stream->set_name(stream.name_.toStdString()); pb_stream->set_url(stream.url_.toString().toStdString()); if (!stream.url_logo_.isEmpty()) diff --git a/src/networkremote/outgoingdatacreator.h b/src/networkremote/outgoingdatacreator.h index c50d95c5f..8d4bbdbc6 100644 --- a/src/networkremote/outgoingdatacreator.h +++ b/src/networkremote/outgoingdatacreator.h @@ -57,7 +57,7 @@ class OutgoingDataCreator : public QObject { allow_downloads_ = allow_downloads; } static void CreateSong(const Song& song, const QImage& art, const int index, - pb::remote::SongMetadata* song_metadata); + cpb::remote::SongMetadata* song_metadata); public slots: void SendClementineInfo(); @@ -116,8 +116,8 @@ class OutgoingDataCreator : public QObject { QMap global_search_result_map_; - void SendDataToClients(pb::remote::Message* msg); - void SetEngineState(pb::remote::ResponseClementineInfo* msg); + void SendDataToClients(cpb::remote::Message* msg); + void SetEngineState(cpb::remote::ResponseClementineInfo* msg); void CheckEnabledProviders(); SongInfoProvider* ProviderByName(const QString& name) const; }; diff --git a/src/networkremote/remoteclient.cpp b/src/networkremote/remoteclient.cpp index e9bf6298f..232d183b5 100644 --- a/src/networkremote/remoteclient.cpp +++ b/src/networkremote/remoteclient.cpp @@ -103,33 +103,33 @@ void RemoteClient::IncomingData() { } void RemoteClient::ParseMessage(const QByteArray& data) { - pb::remote::Message msg; + cpb::remote::Message msg; if (!msg.ParseFromArray(data.constData(), data.size())) { qLog(Info) << "Couldn't parse data"; return; } - if (msg.type() == pb::remote::CONNECT && use_auth_code_) { + if (msg.type() == cpb::remote::CONNECT && use_auth_code_) { if (msg.request_connect().auth_code() != auth_code_) { - DisconnectClient(pb::remote::Wrong_Auth_Code); + DisconnectClient(cpb::remote::Wrong_Auth_Code); return; } else { authenticated_ = true; } } - if (msg.type() == pb::remote::CONNECT) { + if (msg.type() == cpb::remote::CONNECT) { setDownloader(msg.request_connect().downloader()); qDebug() << "Downloader" << downloader_; } // Check if downloads are allowed - if (msg.type() == pb::remote::DOWNLOAD_SONGS && !allow_downloads_) { - DisconnectClient(pb::remote::Download_Forbidden); + if (msg.type() == cpb::remote::DOWNLOAD_SONGS && !allow_downloads_) { + DisconnectClient(cpb::remote::Download_Forbidden); return; } - if (msg.type() == pb::remote::DISCONNECT) { + if (msg.type() == cpb::remote::DISCONNECT) { client_->abort(); qDebug() << "Client disconnected"; return; @@ -137,7 +137,7 @@ void RemoteClient::ParseMessage(const QByteArray& data) { // Check if the client has sent the correct auth code if (!authenticated_) { - DisconnectClient(pb::remote::Not_Authenticated); + DisconnectClient(cpb::remote::Not_Authenticated); return; } @@ -145,9 +145,9 @@ void RemoteClient::ParseMessage(const QByteArray& data) { emit Parse(msg); } -void RemoteClient::DisconnectClient(pb::remote::ReasonDisconnect reason) { - pb::remote::Message msg; - msg.set_type(pb::remote::DISCONNECT); +void RemoteClient::DisconnectClient(cpb::remote::ReasonDisconnect reason) { + cpb::remote::Message msg; + msg.set_type(cpb::remote::DISCONNECT); msg.mutable_response_disconnect()->set_reason_disconnect(reason); SendDataToClient(&msg); @@ -158,7 +158,7 @@ void RemoteClient::DisconnectClient(pb::remote::ReasonDisconnect reason) { } // Sends data to client without check if authenticated -void RemoteClient::SendDataToClient(pb::remote::Message* msg) { +void RemoteClient::SendDataToClient(cpb::remote::Message* msg) { // Set the default version msg->set_version(msg->default_instance().version()); @@ -185,7 +185,7 @@ void RemoteClient::SendDataToClient(pb::remote::Message* msg) { } } -void RemoteClient::SendData(pb::remote::Message* msg) { +void RemoteClient::SendData(cpb::remote::Message* msg) { // Check if client is authenticated before sending the data if (authenticated_) { SendDataToClient(msg); diff --git a/src/networkremote/remoteclient.h b/src/networkremote/remoteclient.h index 11a878842..66294513d 100644 --- a/src/networkremote/remoteclient.h +++ b/src/networkremote/remoteclient.h @@ -14,11 +14,11 @@ class RemoteClient : public QObject { ~RemoteClient(); // This method checks if client is authenticated before sending the data - void SendData(pb::remote::Message* msg); + void SendData(cpb::remote::Message* msg); QAbstractSocket::SocketState State(); void setDownloader(bool downloader); bool isDownloader() { return downloader_; } - void DisconnectClient(pb::remote::ReasonDisconnect reason); + void DisconnectClient(cpb::remote::ReasonDisconnect reason); SongSender* song_sender() { return song_sender_; } const QString& files_root_folder() const { return files_root_folder_; } @@ -31,13 +31,13 @@ class RemoteClient : public QObject { void IncomingData(); signals: - void Parse(const pb::remote::Message& msg); + void Parse(const cpb::remote::Message& msg); private: void ParseMessage(const QByteArray& data); // Sends data to client without check if authenticated - void SendDataToClient(pb::remote::Message* msg); + void SendDataToClient(cpb::remote::Message* msg); Application* app_; diff --git a/src/networkremote/songsender.cpp b/src/networkremote/songsender.cpp index 3e78e2ca3..682a11b09 100644 --- a/src/networkremote/songsender.cpp +++ b/src/networkremote/songsender.cpp @@ -68,29 +68,29 @@ SongSender::~SongSender() { transcoder_->Cancel(); } -void SongSender::SendSongs(const pb::remote::RequestDownloadSongs& request) { +void SongSender::SendSongs(const cpb::remote::RequestDownloadSongs& request) { Song current_song; if (app_->player()->GetCurrentItem()) { current_song = app_->player()->GetCurrentItem()->Metadata(); } switch (request.download_item()) { - case pb::remote::CurrentItem: { + case cpb::remote::CurrentItem: { if (current_song.is_valid()) { DownloadItem item(current_song, 1, 1); download_queue_.append(item); } break; } - case pb::remote::ItemAlbum: + case cpb::remote::ItemAlbum: if (current_song.is_valid()) { SendAlbum(current_song); } break; - case pb::remote::APlaylist: + case cpb::remote::APlaylist: SendPlaylist(request); break; - case pb::remote::Urls: + case cpb::remote::Urls: SendUrls(request); break; default: @@ -140,10 +140,10 @@ void SongSender::TranscodeJobComplete(const QString& input, void SongSender::SendTranscoderStatus() { // Send a message to the remote that we are converting files - pb::remote::Message msg; - msg.set_type(pb::remote::TRANSCODING_FILES); + cpb::remote::Message msg; + msg.set_type(cpb::remote::TRANSCODING_FILES); - pb::remote::ResponseTranscoderStatus* status = + cpb::remote::ResponseTranscoderStatus* status = msg.mutable_response_transcoder_status(); status->set_processed(transcoder_map_.count()); status->set_total(total_transcode_); @@ -162,10 +162,10 @@ void SongSender::StartTransfer() { } void SongSender::SendTotalFileSize() { - pb::remote::Message msg; - msg.set_type(pb::remote::DOWNLOAD_TOTAL_SIZE); + cpb::remote::Message msg; + msg.set_type(cpb::remote::DOWNLOAD_TOTAL_SIZE); - pb::remote::ResponseDownloadTotalSize* response = + cpb::remote::ResponseDownloadTotalSize* response = msg.mutable_response_download_total_size(); response->set_file_count(download_queue_.size()); @@ -187,16 +187,16 @@ void SongSender::SendTotalFileSize() { } void SongSender::OfferNextSong() { - pb::remote::Message msg; + cpb::remote::Message msg; if (download_queue_.isEmpty()) { - msg.set_type(pb::remote::DOWNLOAD_QUEUE_EMPTY); + msg.set_type(cpb::remote::DOWNLOAD_QUEUE_EMPTY); } else { // Get the item and send the single song DownloadItem item = download_queue_.head(); - msg.set_type(pb::remote::SONG_FILE_CHUNK); - pb::remote::ResponseSongFileChunk* chunk = + msg.set_type(cpb::remote::SONG_FILE_CHUNK); + cpb::remote::ResponseSongFileChunk* chunk = msg.mutable_response_song_file_chunk(); // Open the file @@ -248,10 +248,10 @@ void SongSender::SendSingleSong(DownloadItem download_item) { file.open(QIODevice::ReadOnly); QByteArray data; - pb::remote::Message msg; - pb::remote::ResponseSongFileChunk* chunk = + cpb::remote::Message msg; + cpb::remote::ResponseSongFileChunk* chunk = msg.mutable_response_song_file_chunk(); - msg.set_type(pb::remote::SONG_FILE_CHUNK); + msg.set_type(cpb::remote::SONG_FILE_CHUNK); QImage null_image; @@ -276,7 +276,7 @@ void SongSender::SendSingleSong(DownloadItem download_item) { // what file it receives. if (chunk_number == 1) { int i = app_->playlist_manager()->active()->current_row(); - pb::remote::SongMetadata* song_metadata = + cpb::remote::SongMetadata* song_metadata = msg.mutable_response_song_file_chunk()->mutable_song_metadata(); OutgoingDataCreator::CreateSong(download_item.song_, null_image, i, song_metadata); @@ -322,7 +322,8 @@ void SongSender::SendAlbum(const Song& song) { } } -void SongSender::SendPlaylist(const pb::remote::RequestDownloadSongs& request) { +void SongSender::SendPlaylist( + const cpb::remote::RequestDownloadSongs& request) { int playlist_id = request.playlist_id(); Playlist* playlist = app_->playlist_manager()->playlist(playlist_id); if (!playlist) { @@ -353,7 +354,7 @@ void SongSender::SendPlaylist(const pb::remote::RequestDownloadSongs& request) { } } -void SongSender::SendUrls(const pb::remote::RequestDownloadSongs& request) { +void SongSender::SendUrls(const cpb::remote::RequestDownloadSongs& request) { SongList song_list; // First gather all valid songs diff --git a/src/networkremote/songsender.h b/src/networkremote/songsender.h index a48261340..115ca94fe 100644 --- a/src/networkremote/songsender.h +++ b/src/networkremote/songsender.h @@ -30,7 +30,7 @@ class SongSender : public QObject { static const quint32 kFileChunkSize; public slots: - void SendSongs(const pb::remote::RequestDownloadSongs& request); + void SendSongs(const cpb::remote::RequestDownloadSongs& request); void ResponseSongOffer(bool accepted); private slots: @@ -52,8 +52,8 @@ class SongSender : public QObject { void SendSingleSong(DownloadItem download_item); void SendAlbum(const Song& song); - void SendPlaylist(const pb::remote::RequestDownloadSongs& request); - void SendUrls(const pb::remote::RequestDownloadSongs& request); + void SendPlaylist(const cpb::remote::RequestDownloadSongs& request); + void SendUrls(const cpb::remote::RequestDownloadSongs& request); void OfferNextSong(); void SendTotalFileSize(); void TranscodeLosslessFiles(); diff --git a/tests/song_test.cpp b/tests/song_test.cpp index c8453989e..1fde4ccf9 100644 --- a/tests/song_test.cpp +++ b/tests/song_test.cpp @@ -45,7 +45,7 @@ class SongTest : public ::testing::Test { static Song ReadSongFromFile(const QString& filename) { TagReader tag_reader; Song song; - ::pb::tagreader::SongMetadata pb_song; + ::cpb::tagreader::SongMetadata pb_song; // We need to init protobuf object from a Song object, to have default // values initialized correctly. For example, Song's rating is -1 by @@ -59,7 +59,7 @@ class SongTest : public ::testing::Test { static void WriteSongToFile(const Song& song, const QString& filename) { TagReader tag_reader; - ::pb::tagreader::SongMetadata pb_song; + ::cpb::tagreader::SongMetadata pb_song; song.ToProtobuf(&pb_song); tag_reader.SaveFile(filename, pb_song); } @@ -67,14 +67,14 @@ class SongTest : public ::testing::Test { static void WriteSongStatisticsToFile(const Song& song, const QString& filename) { TagReader tag_reader; - ::pb::tagreader::SongMetadata pb_song; + ::cpb::tagreader::SongMetadata pb_song; song.ToProtobuf(&pb_song); tag_reader.SaveSongStatisticsToFile(filename, pb_song); } static void WriteSongRatingToFile(const Song& song, const QString& filename) { TagReader tag_reader; - ::pb::tagreader::SongMetadata pb_song; + ::cpb::tagreader::SongMetadata pb_song; song.ToProtobuf(&pb_song); tag_reader.SaveSongRatingToFile(filename, pb_song); }