From 9237356e3310080af350db55bdb74f7437766783 Mon Sep 17 00:00:00 2001 From: Andreas Date: Sun, 22 Sep 2013 12:06:19 +0200 Subject: [PATCH] - Send songrating to client. - Receive songrating as float (like saved in Song). - On RemoteClient destructor check if socket is still connected before calling waitForDisconnect() --- ext/libclementine-remote/remotecontrolmessages.proto | 5 +++-- src/networkremote/incomingdataparser.cpp | 7 +++---- src/networkremote/incomingdataparser.h | 2 +- src/networkremote/outgoingdatacreator.cpp | 1 + src/networkremote/remoteclient.cpp | 3 ++- 5 files changed, 10 insertions(+), 8 deletions(-) diff --git a/ext/libclementine-remote/remotecontrolmessages.proto b/ext/libclementine-remote/remotecontrolmessages.proto index fe67a4e0f..3079305ca 100644 --- a/ext/libclementine-remote/remotecontrolmessages.proto +++ b/ext/libclementine-remote/remotecontrolmessages.proto @@ -81,6 +81,7 @@ message SongMetadata { optional bool is_local = 15; optional string filename = 16; optional int32 file_size = 17; + optional float rating = 18; // 0 (0 stars) to 1 (5 stars) } // Playlist informations @@ -270,12 +271,12 @@ message ResponseSongOffer { } message RequestRateSong { - optional int32 rating = 1; // 0 to 5 + optional float rating = 1; // 0 to 1 } // The message itself message Message { - optional int32 version = 1 [default=10]; + optional int32 version = 1 [default=11]; optional MsgType type = 2 [default=UNKNOWN]; // What data is in the message? optional RequestConnect request_connect = 21; diff --git a/src/networkremote/incomingdataparser.cpp b/src/networkremote/incomingdataparser.cpp index cd17f3281..4cac08ab4 100644 --- a/src/networkremote/incomingdataparser.cpp +++ b/src/networkremote/incomingdataparser.cpp @@ -77,8 +77,8 @@ 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))); + connect(this, SIGNAL(RateCurrentSong(double)), + app_->playlist_manager(), SLOT(RateCurrentSong(double))); #ifdef HAVE_LIBLASTFM connect(this, SIGNAL(Love()), @@ -300,7 +300,6 @@ void IncomingDataParser::ClosePlaylist(const pb::remote::Message &msg) { } void IncomingDataParser::RateSong(const pb::remote::Message &msg) { - int rating = qBound(0, msg.request_rate_song().rating(), 5); - + double rating = (double) msg.request_rate_song().rating(); emit RateCurrentSong(rating); } diff --git a/src/networkremote/incomingdataparser.h b/src/networkremote/incomingdataparser.h index 98a8f6e42..285c97e6a 100644 --- a/src/networkremote/incomingdataparser.h +++ b/src/networkremote/incomingdataparser.h @@ -48,7 +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); + void RateCurrentSong(double); private: Application* app_; diff --git a/src/networkremote/outgoingdatacreator.cpp b/src/networkremote/outgoingdatacreator.cpp index a973c0993..97924c450 100644 --- a/src/networkremote/outgoingdatacreator.cpp +++ b/src/networkremote/outgoingdatacreator.cpp @@ -353,6 +353,7 @@ void OutgoingDataCreator::CreateSong( song_metadata->set_is_local(song.url().scheme() == "file"); song_metadata->set_filename(DataCommaSizeFromQString(song.basefilename())); song_metadata->set_file_size(song.filesize()); + song_metadata->set_rating(song.rating()); // Append coverart if (!art.isNull()) { diff --git a/src/networkremote/remoteclient.cpp b/src/networkremote/remoteclient.cpp index 492644000..4e2a84c85 100644 --- a/src/networkremote/remoteclient.cpp +++ b/src/networkremote/remoteclient.cpp @@ -53,7 +53,8 @@ RemoteClient::RemoteClient(Application* app, QTcpSocket* client) RemoteClient::~RemoteClient() { client_->close(); - client_->waitForDisconnected(2000); + if (client_->state() == QAbstractSocket::ConnectedState) + client_->waitForDisconnected(2000); } void RemoteClient::setDownloader(bool downloader) {