mirror of
https://github.com/clementine-player/Clementine
synced 2025-02-03 04:37:33 +01:00
- Send songrating to client.
- Receive songrating as float (like saved in Song). - On RemoteClient destructor check if socket is still connected before calling waitForDisconnect() (cherry picked from commit 9237356e3310080af350db55bdb74f7437766783)
This commit is contained in:
parent
d7d7df7646
commit
fc78a78afc
@ -81,6 +81,7 @@ message SongMetadata {
|
|||||||
optional bool is_local = 15;
|
optional bool is_local = 15;
|
||||||
optional string filename = 16;
|
optional string filename = 16;
|
||||||
optional int32 file_size = 17;
|
optional int32 file_size = 17;
|
||||||
|
optional float rating = 18; // 0 (0 stars) to 1 (5 stars)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Playlist informations
|
// Playlist informations
|
||||||
@ -270,12 +271,12 @@ message ResponseSongOffer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
message RequestRateSong {
|
message RequestRateSong {
|
||||||
optional int32 rating = 1; // 0 to 5
|
optional float rating = 1; // 0 to 1
|
||||||
}
|
}
|
||||||
|
|
||||||
// The message itself
|
// The message itself
|
||||||
message Message {
|
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 MsgType type = 2 [default=UNKNOWN]; // What data is in the message?
|
||||||
|
|
||||||
optional RequestConnect request_connect = 21;
|
optional RequestConnect request_connect = 21;
|
||||||
|
@ -77,8 +77,8 @@ IncomingDataParser::IncomingDataParser(Application* app)
|
|||||||
connect(this, SIGNAL(Close(int)),
|
connect(this, SIGNAL(Close(int)),
|
||||||
app_->playlist_manager(), SLOT(Close(int)));
|
app_->playlist_manager(), SLOT(Close(int)));
|
||||||
|
|
||||||
connect(this, SIGNAL(RateCurrentSong(int)),
|
connect(this, SIGNAL(RateCurrentSong(double)),
|
||||||
app_->playlist_manager(), SLOT(RateCurrentSong(int)));
|
app_->playlist_manager(), SLOT(RateCurrentSong(double)));
|
||||||
|
|
||||||
#ifdef HAVE_LIBLASTFM
|
#ifdef HAVE_LIBLASTFM
|
||||||
connect(this, SIGNAL(Love()),
|
connect(this, SIGNAL(Love()),
|
||||||
@ -300,7 +300,6 @@ void IncomingDataParser::ClosePlaylist(const pb::remote::Message &msg) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void IncomingDataParser::RateSong(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);
|
emit RateCurrentSong(rating);
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,7 @@ signals:
|
|||||||
void SendSongs(const pb::remote::RequestDownloadSongs& request, RemoteClient* client);
|
void SendSongs(const pb::remote::RequestDownloadSongs& request, RemoteClient* client);
|
||||||
void ResponseSongOffer(RemoteClient* client, bool accepted);
|
void ResponseSongOffer(RemoteClient* client, bool accepted);
|
||||||
void SendLibrary(RemoteClient* client);
|
void SendLibrary(RemoteClient* client);
|
||||||
void RateCurrentSong(int);
|
void RateCurrentSong(double);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Application* app_;
|
Application* app_;
|
||||||
|
@ -353,6 +353,7 @@ void OutgoingDataCreator::CreateSong(
|
|||||||
song_metadata->set_is_local(song.url().scheme() == "file");
|
song_metadata->set_is_local(song.url().scheme() == "file");
|
||||||
song_metadata->set_filename(DataCommaSizeFromQString(song.basefilename()));
|
song_metadata->set_filename(DataCommaSizeFromQString(song.basefilename()));
|
||||||
song_metadata->set_file_size(song.filesize());
|
song_metadata->set_file_size(song.filesize());
|
||||||
|
song_metadata->set_rating(song.rating());
|
||||||
|
|
||||||
// Append coverart
|
// Append coverart
|
||||||
if (!art.isNull()) {
|
if (!art.isNull()) {
|
||||||
|
@ -53,7 +53,8 @@ RemoteClient::RemoteClient(Application* app, QTcpSocket* client)
|
|||||||
|
|
||||||
RemoteClient::~RemoteClient() {
|
RemoteClient::~RemoteClient() {
|
||||||
client_->close();
|
client_->close();
|
||||||
client_->waitForDisconnected(2000);
|
if (client_->state() == QAbstractSocket::ConnectedState)
|
||||||
|
client_->waitForDisconnected(2000);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RemoteClient::setDownloader(bool downloader) {
|
void RemoteClient::setDownloader(bool downloader) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user