From 1254d025ab6640d5173c9feee8782526654bc8c4 Mon Sep 17 00:00:00 2001 From: Andreas Date: Thu, 15 Aug 2013 20:52:12 +0200 Subject: [PATCH] Include rate song feature in network remote. --- .../remotecontrolmessages.proto | 8 +++++++- src/networkremote/incomingdataparser.cpp | 16 ++++++++++++++++ src/networkremote/incomingdataparser.h | 2 ++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/ext/libclementine-remote/remotecontrolmessages.proto b/ext/libclementine-remote/remotecontrolmessages.proto index be75b9ddd..fe67a4e0f 100644 --- a/ext/libclementine-remote/remotecontrolmessages.proto +++ b/ext/libclementine-remote/remotecontrolmessages.proto @@ -22,6 +22,7 @@ enum MsgType { BAN = 13; STOP_AFTER = 17; GET_LIBRARY = 18; + RATE_SONG = 19; // Messages send by both DISCONNECT = 2; @@ -268,9 +269,13 @@ message ResponseSongOffer { optional bool accepted = 1; // true = client wants to download item } +message RequestRateSong { + optional int32 rating = 1; // 0 to 5 +} + // The message itself message Message { - optional int32 version = 1 [default=9]; + optional int32 version = 1 [default=10]; optional MsgType type = 2 [default=UNKNOWN]; // What data is in the message? optional RequestConnect request_connect = 21; @@ -284,6 +289,7 @@ message Message { optional RequestOpenPlaylist request_open_playlist = 28; optional RequestClosePlaylist request_close_playlist = 29; optional RequestDownloadSongs request_download_songs = 31; + optional RequestRateSong request_rate_song = 35; optional Repeat repeat = 13; optional Shuffle shuffle = 14; diff --git a/src/networkremote/incomingdataparser.cpp b/src/networkremote/incomingdataparser.cpp index 1cbfc9f08..8df26bd21 100644 --- a/src/networkremote/incomingdataparser.cpp +++ b/src/networkremote/incomingdataparser.cpp @@ -77,6 +77,9 @@ IncomingDataParser::IncomingDataParser(Application* app) connect(this, SIGNAL(Close(int)), app_->playlist_manager(), SLOT(Close(int))); + connect(this, SIGNAL(RateCurrentSong(int)), + app_->playlist_manager(), SLOT(RateCurrentSong(int))); + #ifdef HAVE_LIBLASTFM connect(this, SIGNAL(Love()), InternetModel::Service(), SLOT(Love())); @@ -180,6 +183,9 @@ void IncomingDataParser::Parse(const pb::remote::Message& msg) { case pb::remote::GET_LIBRARY: emit SendLibrary(client); break; + case pb::remote::RATE_SONG: + RateSong(msg); + break; default: break; } } @@ -292,3 +298,13 @@ void IncomingDataParser::OpenPlaylist(const pb::remote::Message &msg) { void IncomingDataParser::ClosePlaylist(const pb::remote::Message &msg) { emit Close(msg.request_close_playlist().playlist_id()); } + +void IncomingDataParser::RateSong(const pb::remote::Message &msg) { + int rating = msg.request_rate_song().rating(); + + // Rating is from 0 to 5 + if (rating > 5) rating = 5; + if (rating < 0) rating = 0; + + emit RateCurrentSong(rating); +} diff --git a/src/networkremote/incomingdataparser.h b/src/networkremote/incomingdataparser.h index 9b064f77f..98a8f6e42 100644 --- a/src/networkremote/incomingdataparser.h +++ b/src/networkremote/incomingdataparser.h @@ -48,6 +48,7 @@ signals: void SendSongs(const pb::remote::RequestDownloadSongs& request, RemoteClient* client); void ResponseSongOffer(RemoteClient* client, bool accepted); void SendLibrary(RemoteClient* client); + void RateCurrentSong(int); private: Application* app_; @@ -63,6 +64,7 @@ private: 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); }; #endif // INCOMINGDATAPARSER_H