diff --git a/ext/libclementine-remote/remotecontrolmessages.proto b/ext/libclementine-remote/remotecontrolmessages.proto index 067ca72e7..01dd57942 100644 --- a/ext/libclementine-remote/remotecontrolmessages.proto +++ b/ext/libclementine-remote/remotecontrolmessages.proto @@ -52,6 +52,7 @@ enum MsgType { SONG_FILE_CHUNK = 50; DOWNLOAD_QUEUE_EMPTY = 51; LIBRARY_CHUNK = 52; + DOWNLOAD_TOTAL_SIZE = 53; } // Valid Engine states @@ -278,9 +279,14 @@ message RequestRateSong { optional float rating = 1; // 0 to 1 } +message ResponseDownloadTotalSize { + optional int32 total_size = 1; + optional int32 file_count = 2; +} + // The message itself message Message { - optional int32 version = 1 [default=15]; + optional int32 version = 1 [default=16]; optional MsgType type = 2 [default=UNKNOWN]; // What data is in the message? optional RequestConnect request_connect = 21; @@ -311,4 +317,5 @@ message Message { optional ResponseSongFileChunk response_song_file_chunk = 32; optional ResponseSongOffer response_song_offer = 33; optional ResponseLibraryChunk response_library_chunk = 34; + optional ResponseDownloadTotalSize response_download_total_size = 36; } diff --git a/src/core/song.cpp b/src/core/song.cpp index 693bbe735..fba36f8c5 100644 --- a/src/core/song.cpp +++ b/src/core/song.cpp @@ -885,7 +885,7 @@ void Song::BindToQuery(QSqlQuery* query) const { if (Application::kIsPortable && Utilities::UrlOnSameDriveAsClementine(d->url_)) { query->bindValue(":filename", - Utilities::GetRelativePathToClementineBin(d->url_)); + Utilities::GetRelativePathToClementineBin(d->url_).toEncoded()); } else { query->bindValue(":filename", d->url_.toEncoded()); } diff --git a/src/networkremote/outgoingdatacreator.cpp b/src/networkremote/outgoingdatacreator.cpp index 58bb9f46e..3dac89eaf 100644 --- a/src/networkremote/outgoingdatacreator.cpp +++ b/src/networkremote/outgoingdatacreator.cpp @@ -595,10 +595,34 @@ void OutgoingDataCreator::SendSongs( break; } + // Send total file size & file count + SendTotalFileSize(client); + // Send first file OfferNextSong(client); } +void OutgoingDataCreator::SendTotalFileSize(RemoteClient *client) { + if (!download_queue_.contains(client)) return; + + pb::remote::Message msg; + msg.set_type(pb::remote::DOWNLOAD_TOTAL_SIZE); + + pb::remote::ResponseDownloadTotalSize* response = + msg.mutable_response_download_total_size(); + + response->set_file_count(download_queue_[client].size()); + + int total = 0; + for (DownloadItem item : download_queue_[client]) { + total += item.song_.filesize(); + } + + response->set_total_size(total); + + client->SendData(&msg); +} + void OutgoingDataCreator::OfferNextSong(RemoteClient* client) { if (!download_queue_.contains(client)) return; diff --git a/src/networkremote/outgoingdatacreator.h b/src/networkremote/outgoingdatacreator.h index 1afbf6ca6..05f89b292 100644 --- a/src/networkremote/outgoingdatacreator.h +++ b/src/networkremote/outgoingdatacreator.h @@ -109,6 +109,7 @@ class OutgoingDataCreator : public QObject { void SendPlaylist(RemoteClient* client, int playlist_id); void SendUrls(RemoteClient* client, const pb::remote::RequestDownloadSongs& request); void OfferNextSong(RemoteClient* client); + void SendTotalFileSize(RemoteClient* client); }; #endif // OUTGOINGDATACREATOR_H