mirror of
https://github.com/clementine-player/Clementine
synced 2024-12-13 09:56:31 +01:00
Send filesize and file count in advance when client wants to download songs.
This commit is contained in:
parent
f7f1fcd1e5
commit
f52e48c956
@ -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;
|
||||
}
|
||||
|
@ -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());
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user