3031 lines
117 KiB
Diff
3031 lines
117 KiB
Diff
diff -ur ext/clementine-spotifyblob/spotifyclient.cpp ext/clementine-spotifyblob/spotifyclient.cpp
|
|
--- a/ext/clementine-spotifyblob/spotifyclient.cpp 2020-09-23 22:34:08.000000000 -0400
|
|
+++ b/ext/clementine-spotifyblob/spotifyclient.cpp 2021-02-19 12:03:48.233473023 -0500
|
|
@@ -40,7 +40,7 @@
|
|
const int SpotifyClient::kWaveHeaderSize = 44;
|
|
|
|
SpotifyClient::SpotifyClient(QObject* parent)
|
|
- : AbstractMessageHandler<pb::spotify::Message>(nullptr, parent),
|
|
+ : AbstractMessageHandler<cpb::spotify::Message>(nullptr, parent),
|
|
api_key_(QByteArray::fromBase64(kSpotifyApiKey)),
|
|
protocol_socket_(new QTcpSocket(this)),
|
|
session_(nullptr),
|
|
@@ -119,8 +119,8 @@
|
|
SpotifyClient* me =
|
|
reinterpret_cast<SpotifyClient*>(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 @@
|
|
|
|
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 @@
|
|
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::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 @@
|
|
QList<sp_albumbrowse*> 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 @@
|
|
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::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 @@
|
|
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 @@
|
|
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::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::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 @@
|
|
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 @@
|
|
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 @@
|
|
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 @@
|
|
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 @@
|
|
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 @@
|
|
}
|
|
|
|
// 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::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::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 @@
|
|
|
|
// 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::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 @@
|
|
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::ConvertAlbumBrowse(sp_albumbrowse* browse,
|
|
- pb::spotify::Track* pb) {
|
|
+ cpb::spotify::Track* pb) {
|
|
pb->set_track(sp_albumbrowse_num_tracks(browse));
|
|
}
|
|
|
|
@@ -853,7 +853,7 @@
|
|
|
|
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 @@
|
|
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 @@
|
|
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 @@
|
|
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::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 @@
|
|
<< 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 @@
|
|
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 @@
|
|
|
|
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::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 @@
|
|
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 @@
|
|
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::DeviceClosed() {
|
|
- AbstractMessageHandler<pb::spotify::Message>::DeviceClosed();
|
|
+ AbstractMessageHandler<cpb::spotify::Message>::DeviceClosed();
|
|
|
|
qApp->exit();
|
|
}
|
|
diff -ur ext/clementine-spotifyblob/spotifyclient.h ext/clementine-spotifyblob/spotifyclient.h
|
|
--- a/ext/clementine-spotifyblob/spotifyclient.h 2020-09-23 22:34:08.000000000 -0400
|
|
+++ b/ext/clementine-spotifyblob/spotifyclient.h 2021-02-19 12:03:48.233473023 -0500
|
|
@@ -35,7 +35,7 @@
|
|
class MediaPipeline;
|
|
class ResponseMessage;
|
|
|
|
-class SpotifyClient : public AbstractMessageHandler<pb::spotify::Message> {
|
|
+class SpotifyClient : public AbstractMessageHandler<cpb::spotify::Message> {
|
|
Q_OBJECT
|
|
|
|
public:
|
|
@@ -48,7 +48,7 @@
|
|
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 @@
|
|
|
|
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 @@
|
|
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<sp_track*> tracks_;
|
|
bool offline_sync;
|
|
};
|
|
|
|
struct PendingPlaybackRequest {
|
|
- pb::spotify::PlaybackRequest request_;
|
|
+ cpb::spotify::PlaybackRequest request_;
|
|
sp_link* link_;
|
|
sp_track* track_;
|
|
|
|
@@ -170,7 +170,7 @@
|
|
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 @@
|
|
QList<PendingPlaybackRequest> pending_playback_requests_;
|
|
QList<PendingImageRequest> pending_image_requests_;
|
|
QMap<sp_image*, int> image_callbacks_registered_;
|
|
- QMap<sp_search*, pb::spotify::SearchRequest> pending_searches_;
|
|
+ QMap<sp_search*, cpb::spotify::SearchRequest> pending_searches_;
|
|
QMap<sp_albumbrowse*, QString> pending_album_browses_;
|
|
- QMap<sp_toplistbrowse*, pb::spotify::BrowseToplistRequest>
|
|
+ QMap<sp_toplistbrowse*, cpb::spotify::BrowseToplistRequest>
|
|
pending_toplist_browses_;
|
|
|
|
QMap<sp_search*, QList<sp_albumbrowse*>> pending_search_album_browses_;
|
|
diff -ur ext/clementine-tagreader/tagreaderworker.cpp ext/clementine-tagreader/tagreaderworker.cpp
|
|
--- a/ext/clementine-tagreader/tagreaderworker.cpp 2020-09-23 22:34:08.000000000 -0400
|
|
+++ b/ext/clementine-tagreader/tagreaderworker.cpp 2021-02-19 12:03:48.234473027 -0500
|
|
@@ -25,10 +25,10 @@
|
|
#include <QUrl>
|
|
|
|
TagReaderWorker::TagReaderWorker(QIODevice* socket, QObject* parent)
|
|
- : AbstractMessageHandler<pb::tagreader::Message>(socket, parent) {}
|
|
+ : AbstractMessageHandler<cpb::tagreader::Message>(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 @@
|
|
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::DeviceClosed() {
|
|
- AbstractMessageHandler<pb::tagreader::Message>::DeviceClosed();
|
|
+ AbstractMessageHandler<cpb::tagreader::Message>::DeviceClosed();
|
|
|
|
qApp->exit();
|
|
}
|
|
diff -ur ext/clementine-tagreader/tagreaderworker.h ext/clementine-tagreader/tagreaderworker.h
|
|
--- a/ext/clementine-tagreader/tagreaderworker.h 2020-09-23 22:34:08.000000000 -0400
|
|
+++ b/ext/clementine-tagreader/tagreaderworker.h 2021-02-19 12:03:48.234473027 -0500
|
|
@@ -23,12 +23,12 @@
|
|
#include "tagreadermessages.pb.h"
|
|
#include "core/messagehandler.h"
|
|
|
|
-class TagReaderWorker : public AbstractMessageHandler<pb::tagreader::Message> {
|
|
+class TagReaderWorker : public AbstractMessageHandler<cpb::tagreader::Message> {
|
|
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 -ur ext/libclementine-remote/remotecontrolmessages.proto ext/libclementine-remote/remotecontrolmessages.proto
|
|
--- a/ext/libclementine-remote/remotecontrolmessages.proto 2020-09-23 22:34:08.000000000 -0400
|
|
+++ b/ext/libclementine-remote/remotecontrolmessages.proto 2021-02-19 12:03:48.234473027 -0500
|
|
@@ -20,7 +20,7 @@
|
|
|
|
syntax = "proto2";
|
|
|
|
-package pb.remote;
|
|
+package cpb.remote;
|
|
|
|
// The supported message types
|
|
enum MsgType {
|
|
diff -ur ext/libclementine-spotifyblob/spotifymessages.proto ext/libclementine-spotifyblob/spotifymessages.proto
|
|
--- a/ext/libclementine-spotifyblob/spotifymessages.proto 2020-09-23 22:34:08.000000000 -0400
|
|
+++ b/ext/libclementine-spotifyblob/spotifymessages.proto 2021-02-19 12:03:48.234473027 -0500
|
|
@@ -20,7 +20,7 @@
|
|
|
|
syntax = "proto2";
|
|
|
|
-package pb.spotify;
|
|
+package cpb.spotify;
|
|
|
|
message LoginRequest {
|
|
required string username = 1;
|
|
diff -ur ext/libclementine-tagreader/gmereader.cpp ext/libclementine-tagreader/gmereader.cpp
|
|
--- a/ext/libclementine-tagreader/gmereader.cpp 2020-09-23 22:34:08.000000000 -0400
|
|
+++ b/ext/libclementine-tagreader/gmereader.cpp 2021-02-19 12:03:48.234473027 -0500
|
|
@@ -20,7 +20,7 @@
|
|
}
|
|
|
|
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::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 @@
|
|
}
|
|
|
|
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 @@
|
|
}
|
|
|
|
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 @@
|
|
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 -ur ext/libclementine-tagreader/gmereader.h ext/libclementine-tagreader/gmereader.h
|
|
--- a/ext/libclementine-tagreader/gmereader.h 2020-09-23 22:34:08.000000000 -0400
|
|
+++ b/ext/libclementine-tagreader/gmereader.h 2021-02-19 12:03:48.235473030 -0500
|
|
@@ -10,7 +10,7 @@
|
|
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_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 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 -ur ext/libclementine-tagreader/tagreader.cpp ext/libclementine-tagreader/tagreader.cpp
|
|
--- a/ext/libclementine-tagreader/tagreader.cpp 2020-09-23 22:34:08.000000000 -0400
|
|
+++ b/ext/libclementine-tagreader/tagreader.cpp 2021-02-19 12:03:48.235473030 -0500
|
|
@@ -143,7 +143,7 @@
|
|
|
|
} // 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::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 @@
|
|
: 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::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::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::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::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::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<TagLib::ASF::File*>(fileref->file()))
|
|
- return pb::tagreader::SongMetadata_Type_ASF;
|
|
+ return cpb::tagreader::SongMetadata_Type_ASF;
|
|
#endif
|
|
if (dynamic_cast<TagLib::FLAC::File*>(fileref->file()))
|
|
- return pb::tagreader::SongMetadata_Type_FLAC;
|
|
+ return cpb::tagreader::SongMetadata_Type_FLAC;
|
|
#ifdef TAGLIB_WITH_MP4
|
|
if (dynamic_cast<TagLib::MP4::File*>(fileref->file()))
|
|
- return pb::tagreader::SongMetadata_Type_MP4;
|
|
+ return cpb::tagreader::SongMetadata_Type_MP4;
|
|
#endif
|
|
if (dynamic_cast<TagLib::MPC::File*>(fileref->file()))
|
|
- return pb::tagreader::SongMetadata_Type_MPC;
|
|
+ return cpb::tagreader::SongMetadata_Type_MPC;
|
|
if (dynamic_cast<TagLib::MPEG::File*>(fileref->file()))
|
|
- return pb::tagreader::SongMetadata_Type_MPEG;
|
|
+ return cpb::tagreader::SongMetadata_Type_MPEG;
|
|
if (dynamic_cast<TagLib::Ogg::FLAC::File*>(fileref->file()))
|
|
- return pb::tagreader::SongMetadata_Type_OGGFLAC;
|
|
+ return cpb::tagreader::SongMetadata_Type_OGGFLAC;
|
|
if (dynamic_cast<TagLib::Ogg::Speex::File*>(fileref->file()))
|
|
- return pb::tagreader::SongMetadata_Type_OGGSPEEX;
|
|
+ return cpb::tagreader::SongMetadata_Type_OGGSPEEX;
|
|
if (dynamic_cast<TagLib::Ogg::Vorbis::File*>(fileref->file()))
|
|
- return pb::tagreader::SongMetadata_Type_OGGVORBIS;
|
|
+ return cpb::tagreader::SongMetadata_Type_OGGVORBIS;
|
|
#ifdef TAGLIB_HAS_OPUS
|
|
if (dynamic_cast<TagLib::Ogg::Opus::File*>(fileref->file()))
|
|
- return pb::tagreader::SongMetadata_Type_OGGOPUS;
|
|
+ return cpb::tagreader::SongMetadata_Type_OGGOPUS;
|
|
#endif
|
|
if (dynamic_cast<TagLib::RIFF::AIFF::File*>(fileref->file()))
|
|
- return pb::tagreader::SongMetadata_Type_AIFF;
|
|
+ return cpb::tagreader::SongMetadata_Type_AIFF;
|
|
if (dynamic_cast<TagLib::RIFF::WAV::File*>(fileref->file()))
|
|
- return pb::tagreader::SongMetadata_Type_WAV;
|
|
+ return cpb::tagreader::SongMetadata_Type_WAV;
|
|
if (dynamic_cast<TagLib::TrueAudio::File*>(fileref->file()))
|
|
- return pb::tagreader::SongMetadata_Type_TRUEAUDIO;
|
|
+ return cpb::tagreader::SongMetadata_Type_TRUEAUDIO;
|
|
if (dynamic_cast<TagLib::WavPack::File*>(fileref->file()))
|
|
- return pb::tagreader::SongMetadata_Type_WAVPACK;
|
|
+ return cpb::tagreader::SongMetadata_Type_WAVPACK;
|
|
if (dynamic_cast<TagLib::APE::File*>(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::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::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 @@
|
|
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<CloudStream> stream(
|
|
@@ -1488,7 +1488,7 @@
|
|
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 -ur ext/libclementine-tagreader/tagreader.h ext/libclementine-tagreader/tagreader.h
|
|
--- a/ext/libclementine-tagreader/tagreader.h 2020-09-23 22:34:08.000000000 -0400
|
|
+++ b/ext/libclementine-tagreader/tagreader.h 2021-02-19 12:03:48.235473030 -0500
|
|
@@ -57,16 +57,16 @@
|
|
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 @@
|
|
#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 @@
|
|
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 -ur ext/libclementine-tagreader/tagreadermessages.proto ext/libclementine-tagreader/tagreadermessages.proto
|
|
--- a/ext/libclementine-tagreader/tagreadermessages.proto 2020-09-23 22:34:08.000000000 -0400
|
|
+++ b/ext/libclementine-tagreader/tagreadermessages.proto 2021-02-19 12:03:48.235473030 -0500
|
|
@@ -1,6 +1,6 @@
|
|
syntax = "proto2";
|
|
|
|
-package pb.tagreader;
|
|
+package cpb.tagreader;
|
|
|
|
message SongMetadata {
|
|
enum Type {
|
|
diff -ur src/core/song.cpp src/core/song.cpp
|
|
--- a/src/core/song.cpp 2020-09-23 22:34:08.000000000 -0400
|
|
+++ b/src/core/song.cpp 2021-02-19 12:03:48.236473033 -0500
|
|
@@ -526,7 +526,7 @@
|
|
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 @@
|
|
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 @@
|
|
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<pb::tagreader::SongMetadata_Type>(d->filetype_));
|
|
+ pb->set_type(static_cast<cpb::tagreader::SongMetadata_Type>(d->filetype_));
|
|
}
|
|
|
|
void Song::InitFromQuery(const SqlRow& q, bool reliable_metadata, int col) {
|
|
diff -ur src/core/song.h src/core/song.h
|
|
--- a/src/core/song.h 2020-09-23 22:34:08.000000000 -0400
|
|
+++ b/src/core/song.h 2021-02-19 12:04:03.092521906 -0500
|
|
@@ -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 @@
|
|
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 @@
|
|
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 -ur src/core/tagreaderclient.cpp src/core/tagreaderclient.cpp
|
|
--- a/src/core/tagreaderclient.cpp 2020-09-23 22:34:08.000000000 -0400
|
|
+++ b/src/core/tagreaderclient.cpp 2021-02-19 12:03:48.236473033 -0500
|
|
@@ -58,8 +58,8 @@
|
|
}
|
|
|
|
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::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::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 @@
|
|
}
|
|
|
|
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 @@
|
|
}
|
|
|
|
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::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::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 -ur src/core/tagreaderclient.h src/core/tagreaderclient.h
|
|
--- a/src/core/tagreaderclient.h 2020-09-23 22:34:08.000000000 -0400
|
|
+++ b/src/core/tagreaderclient.h 2021-02-19 12:03:48.236473033 -0500
|
|
@@ -37,7 +37,7 @@
|
|
public:
|
|
explicit TagReaderClient(QObject* parent = nullptr);
|
|
|
|
- typedef AbstractMessageHandler<pb::tagreader::Message> HandlerType;
|
|
+ typedef AbstractMessageHandler<cpb::tagreader::Message> HandlerType;
|
|
typedef HandlerType::ReplyType ReplyType;
|
|
|
|
static const char* kWorkerExecutableName;
|
|
@@ -78,7 +78,7 @@
|
|
static TagReaderClient* sInstance;
|
|
|
|
WorkerPool<HandlerType>* worker_pool_;
|
|
- QList<pb::tagreader::Message> message_queue_;
|
|
+ QList<cpb::tagreader::Message> message_queue_;
|
|
};
|
|
|
|
typedef TagReaderClient::ReplyType TagReaderReply;
|
|
diff -ur src/globalsearch/spotifysearchprovider.cpp src/globalsearch/spotifysearchprovider.cpp
|
|
--- a/src/globalsearch/spotifysearchprovider.cpp 2020-09-23 22:34:08.000000000 -0400
|
|
+++ b/src/globalsearch/spotifysearchprovider.cpp 2021-02-19 12:03:48.236473033 -0500
|
|
@@ -49,16 +49,16 @@
|
|
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::SearchFinishedSlot(
|
|
- const pb::spotify::SearchResponse& response) {
|
|
+ const cpb::spotify::SearchResponse& response) {
|
|
QString query_string = QString::fromUtf8(response.request().query().c_str());
|
|
QMap<QString, PendingState>::iterator it = queries_.find(query_string);
|
|
if (it == queries_.end()) return;
|
|
@@ -107,7 +107,7 @@
|
|
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<QString, int> artist_count;
|
|
QString majority_artist;
|
|
@@ -153,7 +153,7 @@
|
|
}
|
|
|
|
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::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::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::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 -ur src/globalsearch/spotifysearchprovider.h src/globalsearch/spotifysearchprovider.h
|
|
--- a/src/globalsearch/spotifysearchprovider.h 2020-09-23 22:34:08.000000000 -0400
|
|
+++ b/src/globalsearch/spotifysearchprovider.h 2021-02-19 12:03:48.237473037 -0500
|
|
@@ -41,17 +41,17 @@
|
|
|
|
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 -ur src/internet/core/cloudfileservice.cpp src/internet/core/cloudfileservice.cpp
|
|
--- a/src/internet/core/cloudfileservice.cpp 2020-09-23 22:34:08.000000000 -0400
|
|
+++ b/src/internet/core/cloudfileservice.cpp 2021-02-19 12:03:48.237473037 -0500
|
|
@@ -192,14 +192,14 @@
|
|
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 -ur src/internet/spotify/spotifyserver.cpp src/internet/spotify/spotifyserver.cpp
|
|
--- a/src/internet/spotify/spotifyserver.cpp 2020-09-23 22:34:08.000000000 -0400
|
|
+++ b/src/internet/spotify/spotifyserver.cpp 2021-02-19 12:03:48.237473037 -0500
|
|
@@ -31,7 +31,7 @@
|
|
#include "spotifymessages.pb.h"
|
|
|
|
SpotifyServer::SpotifyServer(QObject* parent)
|
|
- : AbstractMessageHandler<pb::spotify::Message>(nullptr, parent),
|
|
+ : AbstractMessageHandler<cpb::spotify::Message>(nullptr, parent),
|
|
server_(new QTcpServer(this)),
|
|
logged_in_(false) {
|
|
connect(server_, SIGNAL(newConnection()), SLOT(NewConnection()));
|
|
@@ -52,7 +52,7 @@
|
|
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 @@
|
|
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<pb::spotify::Message>* queue =
|
|
+ QList<cpb::spotify::Message>* queue =
|
|
is_login_message ? &queued_login_messages_ : &queued_messages_;
|
|
|
|
if (!device_ || (!is_login_message && !logged_in_)) {
|
|
@@ -75,11 +75,11 @@
|
|
}
|
|
|
|
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 @@
|
|
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 @@
|
|
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 @@
|
|
} 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 @@
|
|
} 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::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 @@
|
|
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 @@
|
|
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<QUrl>& songs_urls) {
|
|
- AddSongsToPlaylist(pb::spotify::Starred, songs_urls);
|
|
+ AddSongsToPlaylist(cpb::spotify::Starred, songs_urls);
|
|
}
|
|
|
|
void SpotifyServer::AddSongsToUserPlaylist(int playlist_index,
|
|
const QList<QUrl>& 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<QUrl>& 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::RemoveSongsFromStarred(
|
|
const QList<int>& 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<int>& 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<int>& 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::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::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,34 @@
|
|
}
|
|
|
|
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 -ur src/internet/spotify/spotifyserver.h src/internet/spotify/spotifyserver.h
|
|
--- a/src/internet/spotify/spotifyserver.h 2020-09-23 22:34:08.000000000 -0400
|
|
+++ b/src/internet/spotify/spotifyserver.h 2021-02-19 12:03:48.237473037 -0500
|
|
@@ -31,7 +31,7 @@
|
|
class QTcpServer;
|
|
class QTcpSocket;
|
|
|
|
-class SpotifyServer : public AbstractMessageHandler<pb::spotify::Message> {
|
|
+class SpotifyServer : public AbstractMessageHandler<cpb::spotify::Message> {
|
|
Q_OBJECT
|
|
|
|
public:
|
|
@@ -39,7 +39,7 @@
|
|
|
|
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 @@
|
|
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,43 @@
|
|
|
|
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<QUrl>& 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<int>& 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<pb::spotify::Message> queued_login_messages_;
|
|
- QList<pb::spotify::Message> queued_messages_;
|
|
+ QList<cpb::spotify::Message> queued_login_messages_;
|
|
+ QList<cpb::spotify::Message> queued_messages_;
|
|
};
|
|
|
|
#endif // INTERNET_SPOTIFY_SPOTIFYSERVER_H_
|
|
diff -ur src/internet/spotify/spotifyservice.cpp src/internet/spotify/spotifyservice.cpp
|
|
--- a/src/internet/spotify/spotifyservice.cpp 2020-09-23 22:34:08.000000000 -0400
|
|
+++ b/src/internet/spotify/spotifyservice.cpp 2021-02-19 12:03:48.238473040 -0500
|
|
@@ -85,7 +85,7 @@
|
|
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::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 @@
|
|
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 @@
|
|
|
|
login_state_ =
|
|
LoginState(s.value("login_state", LoginState_OtherError).toInt());
|
|
- bitrate_ = static_cast<pb::spotify::Bitrate>(
|
|
- s.value("bitrate", pb::spotify::Bitrate320k).toInt());
|
|
+ bitrate_ = static_cast<cpb::spotify::Bitrate>(
|
|
+ s.value("bitrate", cpb::spotify::Bitrate320k).toInt());
|
|
volume_normalisation_ = s.value("volume_normalisation", false).toBool();
|
|
|
|
if (server_ && blob_process_) {
|
|
@@ -267,29 +267,29 @@
|
|
|
|
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 @@
|
|
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 @@
|
|
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 @@
|
|
}
|
|
|
|
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 @@
|
|
}
|
|
|
|
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 @@
|
|
}
|
|
|
|
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::FillPlaylist(
|
|
QStandardItem* item,
|
|
- const google::protobuf::RepeatedPtrField<pb::spotify::Track>& tracks) {
|
|
+ const google::protobuf::RepeatedPtrField<cpb::spotify::Track>& tracks) {
|
|
if (item->hasChildren()) item->removeRows(0, item->rowCount());
|
|
|
|
for (int i = 0; i < tracks.size(); ++i) {
|
|
@@ -571,12 +571,12 @@
|
|
}
|
|
|
|
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::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::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<int, int>::const_iterator it = playlist_sync_ids_.constFind(
|
|
progress.request().user_playlist_index());
|
|
if (it != playlist_sync_ids_.constEnd()) {
|
|
@@ -916,7 +916,7 @@
|
|
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 -ur src/internet/spotify/spotifyservice.h src/internet/spotify/spotifyservice.h
|
|
--- a/src/internet/spotify/spotifyservice.h 2020-09-23 22:34:08.000000000 -0400
|
|
+++ b/src/internet/spotify/spotifyservice.h 2021-02-19 12:03:48.238473040 -0500
|
|
@@ -93,7 +93,7 @@
|
|
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 @@
|
|
void StartBlobProcess();
|
|
void FillPlaylist(
|
|
QStandardItem* item,
|
|
- const google::protobuf::RepeatedPtrField<pb::spotify::Track>& tracks);
|
|
+ const google::protobuf::RepeatedPtrField<cpb::spotify::Track>& tracks);
|
|
void FillPlaylist(QStandardItem* item,
|
|
- const pb::spotify::LoadPlaylistResponse& response);
|
|
+ const cpb::spotify::LoadPlaylistResponse& response);
|
|
void AddSongsToUserPlaylist(int playlist_index,
|
|
const QList<QUrl>& songs_urls);
|
|
void AddSongsToStarred(const QList<QUrl>& songs_urls);
|
|
@@ -123,26 +123,26 @@
|
|
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<int>& songs_indices_to_remove);
|
|
void RemoveSongsFromStarred(const QList<int>& 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 @@
|
|
QMap<int, int> playlist_sync_ids_;
|
|
|
|
LoginState login_state_;
|
|
- pb::spotify::Bitrate bitrate_;
|
|
+ cpb::spotify::Bitrate bitrate_;
|
|
bool volume_normalisation_;
|
|
};
|
|
|
|
diff -ur src/internet/spotify/spotifysettingspage.cpp src/internet/spotify/spotifysettingspage.cpp
|
|
--- a/src/internet/spotify/spotifysettingspage.cpp 2020-09-23 22:34:08.000000000 -0400
|
|
+++ b/src/internet/spotify/spotifysettingspage.cpp 2021-02-19 12:03:48.238473040 -0500
|
|
@@ -59,9 +59,9 @@
|
|
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 @@
|
|
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 -ur src/main.cpp src/main.cpp
|
|
--- a/src/main.cpp 2020-09-23 22:34:08.000000000 -0400
|
|
+++ b/src/main.cpp 2021-02-19 12:03:48.238473040 -0500
|
|
@@ -191,7 +191,7 @@
|
|
"304c6f756e67652e6d786dba012a28414c42554d2920476f74616e2050726f6a65637"
|
|
"4202d20416d6269656e74204c6f756e67652e6d786dc001c7a7efd104c801bad685e4"
|
|
"04d001eeca32");
|
|
- pb::tagreader::Message message;
|
|
+ cpb::tagreader::Message message;
|
|
message.ParseFromArray(data.constData(), data.size());
|
|
}
|
|
|
|
diff -ur src/networkremote/incomingdataparser.cpp src/networkremote/incomingdataparser.cpp
|
|
--- a/src/networkremote/incomingdataparser.cpp 2020-09-23 22:34:08.000000000 -0400
|
|
+++ b/src/networkremote/incomingdataparser.cpp 2021-02-19 12:03:48.239473043 -0500
|
|
@@ -97,99 +97,99 @@
|
|
|
|
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<RemoteClient*>(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::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;
|
|
default:
|
|
@@ -197,13 +197,13 @@
|
|
}
|
|
}
|
|
|
|
-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()) {
|
|
@@ -227,18 +227,18 @@
|
|
}
|
|
}
|
|
|
|
-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:
|
|
@@ -246,18 +246,18 @@
|
|
}
|
|
}
|
|
|
|
-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:
|
|
@@ -265,8 +265,8 @@
|
|
}
|
|
}
|
|
|
|
-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();
|
|
|
|
// Insert plain urls without metadata
|
|
if (!request.urls().empty()) {
|
|
@@ -292,8 +292,8 @@
|
|
}
|
|
}
|
|
|
|
-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<int> songs;
|
|
@@ -305,7 +305,7 @@
|
|
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();
|
|
@@ -321,7 +321,7 @@
|
|
}
|
|
}
|
|
|
|
-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();
|
|
@@ -330,27 +330,27 @@
|
|
}
|
|
}
|
|
|
|
-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::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);
|
|
diff -ur src/networkremote/incomingdataparser.h src/networkremote/incomingdataparser.h
|
|
--- a/src/networkremote/incomingdataparser.h 2020-09-23 22:34:08.000000000 -0400
|
|
+++ b/src/networkremote/incomingdataparser.h 2021-02-19 12:03:48.239473043 -0500
|
|
@@ -16,7 +16,7 @@
|
|
bool close_connection();
|
|
|
|
public slots:
|
|
- void Parse(const pb::remote::Message& msg);
|
|
+ void Parse(const cpb::remote::Message& msg);
|
|
void ReloadSettings();
|
|
|
|
signals:
|
|
@@ -61,20 +61,20 @@
|
|
bool close_connection_;
|
|
MainWindow::PlaylistAddBehaviour doubleclick_playlist_addmode_;
|
|
|
|
- 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 RateSong(const pb::remote::Message& msg);
|
|
- void GlobalSearch(RemoteClient* client, 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 RateSong(const cpb::remote::Message& msg);
|
|
+ void GlobalSearch(RemoteClient* client, const cpb::remote::Message& msg);
|
|
|
|
- Song CreateSongFromProtobuf(const pb::remote::SongMetadata& pb);
|
|
+ Song CreateSongFromProtobuf(const cpb::remote::SongMetadata& pb);
|
|
};
|
|
|
|
#endif // INCOMINGDATAPARSER_H
|
|
diff -ur src/networkremote/networkremote.cpp src/networkremote/networkremote.cpp
|
|
--- a/src/networkremote/networkremote.cpp 2020-09-23 22:34:08.000000000 -0400
|
|
+++ b/src/networkremote/networkremote.cpp 2021-02-19 12:03:48.239473043 -0500
|
|
@@ -214,8 +214,8 @@
|
|
clients_.push_back(client);
|
|
|
|
// 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 -ur src/networkremote/outgoingdatacreator.cpp src/networkremote/outgoingdatacreator.cpp
|
|
--- a/src/networkremote/outgoingdatacreator.cpp 2020-09-23 22:34:08.000000000 -0400
|
|
+++ b/src/networkremote/outgoingdatacreator.cpp 2021-02-19 12:03:48.239473043 -0500
|
|
@@ -144,7 +144,7 @@
|
|
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;
|
|
@@ -172,11 +172,11 @@
|
|
|
|
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);
|
|
|
|
@@ -188,20 +188,20 @@
|
|
}
|
|
|
|
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;
|
|
}
|
|
}
|
|
@@ -212,10 +212,10 @@
|
|
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();
|
|
|
|
// Get all playlists, even ones that are hidden in the UI.
|
|
for (const PlaylistBackend::Playlist& p :
|
|
@@ -224,7 +224,7 @@
|
|
int item_count = playlist_open ? app_playlists.at(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));
|
|
@@ -241,10 +241,10 @@
|
|
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<Playlist*> it(app_playlists);
|
|
while (it.hasNext()) {
|
|
@@ -253,7 +253,7 @@
|
|
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));
|
|
@@ -269,8 +269,8 @@
|
|
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);
|
|
}
|
|
@@ -322,8 +322,8 @@
|
|
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);
|
|
}
|
|
|
|
@@ -342,8 +342,8 @@
|
|
|
|
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();
|
|
@@ -355,7 +355,7 @@
|
|
|
|
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);
|
|
@@ -381,7 +381,7 @@
|
|
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()) {
|
|
@@ -407,8 +407,8 @@
|
|
|
|
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);
|
|
}
|
|
@@ -422,15 +422,15 @@
|
|
}
|
|
|
|
// 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);
|
|
|
|
@@ -441,7 +441,7 @@
|
|
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;
|
|
}
|
|
@@ -462,23 +462,23 @@
|
|
}
|
|
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;
|
|
};
|
|
@@ -487,27 +487,27 @@
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
@@ -515,21 +515,21 @@
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
@@ -537,14 +537,14 @@
|
|
}
|
|
|
|
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);
|
|
|
|
int position = std::floor(
|
|
float(app_->player()->engine()->position_nanosec()) / kNsecPerSec + 0.5);
|
|
@@ -561,10 +561,10 @@
|
|
}
|
|
|
|
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);
|
|
}
|
|
|
|
@@ -572,9 +572,9 @@
|
|
|
|
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
|
|
@@ -582,7 +582,7 @@
|
|
qobject_cast<UltimateLyricsLyric*>(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_));
|
|
@@ -623,10 +623,10 @@
|
|
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);
|
|
@@ -674,14 +674,14 @@
|
|
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);
|
|
|
|
@@ -696,11 +696,11 @@
|
|
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(
|
|
@@ -715,7 +715,7 @@
|
|
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);
|
|
}
|
|
|
|
@@ -731,14 +731,14 @@
|
|
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);
|
|
|
|
diff -ur src/networkremote/outgoingdatacreator.h src/networkremote/outgoingdatacreator.h
|
|
--- a/src/networkremote/outgoingdatacreator.h 2020-09-23 22:34:08.000000000 -0400
|
|
+++ b/src/networkremote/outgoingdatacreator.h 2021-02-19 12:03:48.239473043 -0500
|
|
@@ -49,7 +49,7 @@
|
|
void SetClients(QList<RemoteClient*>* clients);
|
|
|
|
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();
|
|
@@ -102,8 +102,8 @@
|
|
|
|
QMap<int, GlobalSearchRequest> 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 -ur src/networkremote/remoteclient.cpp src/networkremote/remoteclient.cpp
|
|
--- a/src/networkremote/remoteclient.cpp 2020-09-23 22:34:08.000000000 -0400
|
|
+++ b/src/networkremote/remoteclient.cpp 2021-02-19 12:03:48.240473046 -0500
|
|
@@ -103,33 +103,33 @@
|
|
}
|
|
|
|
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 @@
|
|
|
|
// 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 @@
|
|
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 @@
|
|
}
|
|
|
|
// 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::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 -ur src/networkremote/remoteclient.h src/networkremote/remoteclient.h
|
|
--- a/src/networkremote/remoteclient.h 2020-09-23 22:34:08.000000000 -0400
|
|
+++ b/src/networkremote/remoteclient.h 2021-02-19 12:03:48.240473046 -0500
|
|
@@ -16,11 +16,11 @@
|
|
~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_; }
|
|
|
|
@@ -28,13 +28,13 @@
|
|
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 -ur src/networkremote/songsender.cpp src/networkremote/songsender.cpp
|
|
--- a/src/networkremote/songsender.cpp 2020-09-23 22:34:08.000000000 -0400
|
|
+++ b/src/networkremote/songsender.cpp 2021-02-19 12:03:48.240473046 -0500
|
|
@@ -67,29 +67,29 @@
|
|
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.playlist_id());
|
|
break;
|
|
- case pb::remote::Urls:
|
|
+ case cpb::remote::Urls:
|
|
SendUrls(request);
|
|
break;
|
|
default:
|
|
@@ -139,10 +139,10 @@
|
|
|
|
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_);
|
|
@@ -161,10 +161,10 @@
|
|
}
|
|
|
|
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());
|
|
@@ -186,16 +186,16 @@
|
|
}
|
|
|
|
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
|
|
@@ -247,10 +247,10 @@
|
|
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;
|
|
|
|
@@ -275,7 +275,7 @@
|
|
// 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);
|
|
@@ -346,7 +346,7 @@
|
|
}
|
|
}
|
|
|
|
-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 -ur src/networkremote/songsender.h src/networkremote/songsender.h
|
|
--- a/src/networkremote/songsender.h 2020-09-23 22:34:08.000000000 -0400
|
|
+++ b/src/networkremote/songsender.h 2021-02-19 12:03:48.240473046 -0500
|
|
@@ -30,7 +30,7 @@
|
|
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:
|
|
@@ -53,7 +53,7 @@
|
|
void SendSingleSong(DownloadItem download_item);
|
|
void SendAlbum(const Song& song);
|
|
void SendPlaylist(int playlist_id);
|
|
- void SendUrls(const pb::remote::RequestDownloadSongs& request);
|
|
+ void SendUrls(const cpb::remote::RequestDownloadSongs& request);
|
|
void OfferNextSong();
|
|
void SendTotalFileSize();
|
|
void TranscodeLosslessFiles();
|
|
diff -ur tests/song_test.cpp tests/song_test.cpp
|
|
--- a/tests/song_test.cpp 2020-09-23 22:34:08.000000000 -0400
|
|
+++ b/tests/song_test.cpp 2021-02-19 12:03:48.240473046 -0500
|
|
@@ -45,7 +45,7 @@
|
|
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 @@
|
|
|
|
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 @@
|
|
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);
|
|
}
|