Change connect message handling.

This commit is contained in:
Andreas 2013-03-27 16:54:02 +01:00
parent 7258cd2c17
commit a79834755b
6 changed files with 25 additions and 10 deletions

View File

@ -152,6 +152,7 @@ message ResponseUpdateTrackPosition {
// The connect message containing the authentication code
message RequestConnect {
optional int32 auth_code = 1;
optional bool send_playlist_songs = 2;
}
// Respone, why the connection was closed
@ -176,7 +177,7 @@ message RequestSetTrackPosition {
// The message itself
message Message {
optional int32 version = 1 [default=4];
optional int32 version = 1 [default=5];
optional MsgType type = 2 [default=UNKNOWN]; // What data is in the message?
optional RequestConnect request_connect = 21;

View File

@ -69,8 +69,7 @@ void IncomingDataParser::Parse(const pb::remote::Message& msg) {
// Now check what's to do
switch (msg.type()) {
case pb::remote::CONNECT: emit SendClementineInfo();
emit SendFirstData();
case pb::remote::CONNECT: ClientConnect(msg);
break;
case pb::remote::DISCONNECT: close_connection_ = true;
break;
@ -159,3 +158,16 @@ void IncomingDataParser::SetShuffleMode(const pb::remote::Shuffle& shuffle) {
default: break;
}
}
void IncomingDataParser::ClientConnect(const pb::remote::Message& msg) {
// Always sned the Clementine infos
emit SendClementineInfo();
// Check if we should send the first data
if (!msg.request_connect().has_send_playlist_songs() // legacy
|| msg.request_connect().send_playlist_songs()) {
emit SendFirstData(true);
} else {
emit SendFirstData(false);
}
}

View File

@ -18,7 +18,7 @@ public slots:
signals:
void SendClementineInfo();
void SendFirstData();
void SendFirstData(bool send_playlist_songs);
void SendAllPlaylists();
void SendPlaylistSongs(int id);
@ -36,7 +36,6 @@ signals:
void SetShuffleMode(PlaylistSequence::ShuffleMode mode);
void SeekTo(int seconds);
private:
Application* app_;
bool close_connection_;
@ -45,6 +44,7 @@ private:
void ChangeSong(const pb::remote::Message& msg);
void SetRepeatMode(const pb::remote::Repeat& repeat);
void SetShuffleMode(const pb::remote::Shuffle& shuffle);
void ClientConnect(const pb::remote::Message& msg);
};
#endif // INCOMINGDATAPARSER_H

View File

@ -120,8 +120,8 @@ void NetworkRemote::AcceptConnection() {
// Setting up the signals, but only once
connect(incoming_data_parser_.get(), SIGNAL(SendClementineInfo()),
outgoing_data_creator_.get(), SLOT(SendClementineInfo()));
connect(incoming_data_parser_.get(), SIGNAL(SendFirstData()),
outgoing_data_creator_.get(), SLOT(SendFirstData()));
connect(incoming_data_parser_.get(), SIGNAL(SendFirstData(bool)),
outgoing_data_creator_.get(), SLOT(SendFirstData(bool)));
connect(incoming_data_parser_.get(), SIGNAL(SendAllPlaylists()),
outgoing_data_creator_.get(), SLOT(SendAllPlaylists()));
connect(incoming_data_parser_.get(), SIGNAL(SendPlaylistSongs(int)),

View File

@ -151,7 +151,7 @@ void OutgoingDataCreator::PlaylistRenamed(int id, const QString& new_name) {
SendAllPlaylists();
}
void OutgoingDataCreator::SendFirstData() {
void OutgoingDataCreator::SendFirstData(bool send_playlist_songs) {
// First Send the current song
PlaylistItemPtr item = app_->player()->GetCurrentItem();
if (!item) {
@ -170,7 +170,9 @@ void OutgoingDataCreator::SendFirstData() {
SendAllPlaylists();
// Send the tracks of the active playlist
SendPlaylistSongs(app_->playlist_manager()->active_id());
if (send_playlist_songs) {
SendPlaylistSongs(app_->playlist_manager()->active_id());
}
// Send the current random and repeat mode
SendShuffleMode(app_->playlist_manager()->sequence()->shuffle_mode());

View File

@ -26,7 +26,7 @@ public:
public slots:
void SendClementineInfo();
void SendAllPlaylists();
void SendFirstData();
void SendFirstData(bool send_playlist_songs);
void SendPlaylistSongs(int id);
void PlaylistChanged(Playlist*);
void VolumeChanged(int volume);