1
0
mirror of https://github.com/clementine-player/Clementine synced 2024-12-15 02:46:57 +01:00

Include rate song feature in network remote.

This commit is contained in:
Andreas 2013-08-15 20:52:12 +02:00
parent 9987b3f9a9
commit 1254d025ab
3 changed files with 25 additions and 1 deletions

View File

@ -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;

View File

@ -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<LastFMService>(), 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);
}

View File

@ -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