From 07852149492512ed684a459c52336a49e82fff7d Mon Sep 17 00:00:00 2001 From: Andreas Date: Sat, 27 Jul 2013 14:13:02 +0200 Subject: [PATCH] - Do not offer streams to download clients. - Move Google Play logo and qr code to the middle of the settings screen. --- .../remotecontrolmessages.proto | 1 + src/networkremote/outgoingdatacreator.cpp | 52 +++++++++++------ src/ui/networkremotesettingspage.ui | 56 +++++++++++++++++-- 3 files changed, 87 insertions(+), 22 deletions(-) diff --git a/ext/libclementine-remote/remotecontrolmessages.proto b/ext/libclementine-remote/remotecontrolmessages.proto index 48378794e..993ec629a 100644 --- a/ext/libclementine-remote/remotecontrolmessages.proto +++ b/ext/libclementine-remote/remotecontrolmessages.proto @@ -48,6 +48,7 @@ enum MsgType { FIRST_DATA_SENT_COMPLETE = 48; LYRICS = 49; SONG_FILE_CHUNK = 50; + DOWNLOAD_QUEUE_EMPTY = 51; } // Valid Engine states diff --git a/src/networkremote/outgoingdatacreator.cpp b/src/networkremote/outgoingdatacreator.cpp index 9e82c7408..d63232d3d 100644 --- a/src/networkremote/outgoingdatacreator.cpp +++ b/src/networkremote/outgoingdatacreator.cpp @@ -577,24 +577,27 @@ void OutgoingDataCreator::OfferNextSong(RemoteClient *client) { if (!download_queue_.contains(client)) return; - if (download_queue_.value(client).isEmpty()) - return; - - // Get the item and send the single song - DownloadItem item = download_queue_[client].head(); - pb::remote::Message msg; - msg.set_type(pb::remote::SONG_FILE_CHUNK); - pb::remote::ResponseSongFileChunk* chunk = msg.mutable_response_song_file_chunk(); - // Song offer is chunk no 0 - chunk->set_chunk_count(0); - chunk->set_chunk_number(0); - chunk->set_file_count(item.song_count_); - chunk->set_file_number(item.song_no_); + if (download_queue_.value(client).isEmpty()) { + // We sent all songs, tell the client the queue is empty + msg.set_type(pb::remote::DOWNLOAD_QUEUE_EMPTY); + } else { + // Get the item and send the single song + DownloadItem item = download_queue_[client].head(); - CreateSong(item.song_, item.song_.image(), -1, - chunk->mutable_song_metadata()); + msg.set_type(pb::remote::SONG_FILE_CHUNK); + pb::remote::ResponseSongFileChunk* chunk = msg.mutable_response_song_file_chunk(); + + // Song offer is chunk no 0 + chunk->set_chunk_count(0); + chunk->set_chunk_number(0); + chunk->set_file_count(item.song_count_); + chunk->set_file_number(item.song_no_); + + CreateSong(item.song_, item.song_.image(), -1, + chunk->mutable_song_metadata()); + } msg.set_version(msg.default_instance().version()); client->SendData(&msg); @@ -671,6 +674,10 @@ void OutgoingDataCreator::SendSingleSong(RemoteClient* client, const Song &song, } void OutgoingDataCreator::SendAlbum(RemoteClient *client, const Song &song) { + // No streams! + if (song.url().scheme() != "file") + return; + SongList album = app_->library_backend()->GetSongsByAlbum(song.album()); foreach (Song s, album) { @@ -687,8 +694,19 @@ void OutgoingDataCreator::SendPlaylist(RemoteClient *client, int playlist_id) { } SongList song_list = playlist->GetAllSongs(); + // Count the local songs + int count = 0; foreach (Song s, song_list) { - DownloadItem item(s, song_list.indexOf(s)+1, song_list.size()); - download_queue_[client].append(item); + if (s.url().scheme() == "file") { + count++; + } + } + + foreach (Song s, song_list) { + // Only local files! + if (s.url().scheme() == "file") { + DownloadItem item(s, song_list.indexOf(s)+1, count); + download_queue_[client].append(item); + } } } diff --git a/src/ui/networkremotesettingspage.ui b/src/ui/networkremotesettingspage.ui index 7033d06b9..23120536b 100644 --- a/src/ui/networkremotesettingspage.ui +++ b/src/ui/networkremotesettingspage.ui @@ -6,8 +6,8 @@ 0 0 - 884 - 587 + 385 + 528 @@ -135,9 +135,52 @@ - - - PointingHandCursor + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + PointingHandCursor + + + Qt::AlignCenter + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + or scan the QR code! + + + Qt::AlignCenter @@ -146,6 +189,9 @@ :/clementine_remote_qr.png + + Qt::AlignCenter +