Change connect message handling.
This commit is contained in:
parent
7258cd2c17
commit
a79834755b
@ -152,6 +152,7 @@ message ResponseUpdateTrackPosition {
|
|||||||
// The connect message containing the authentication code
|
// The connect message containing the authentication code
|
||||||
message RequestConnect {
|
message RequestConnect {
|
||||||
optional int32 auth_code = 1;
|
optional int32 auth_code = 1;
|
||||||
|
optional bool send_playlist_songs = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Respone, why the connection was closed
|
// Respone, why the connection was closed
|
||||||
@ -176,7 +177,7 @@ message RequestSetTrackPosition {
|
|||||||
|
|
||||||
// The message itself
|
// The message itself
|
||||||
message Message {
|
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 MsgType type = 2 [default=UNKNOWN]; // What data is in the message?
|
||||||
|
|
||||||
optional RequestConnect request_connect = 21;
|
optional RequestConnect request_connect = 21;
|
||||||
|
@ -69,8 +69,7 @@ void IncomingDataParser::Parse(const pb::remote::Message& msg) {
|
|||||||
|
|
||||||
// Now check what's to do
|
// Now check what's to do
|
||||||
switch (msg.type()) {
|
switch (msg.type()) {
|
||||||
case pb::remote::CONNECT: emit SendClementineInfo();
|
case pb::remote::CONNECT: ClientConnect(msg);
|
||||||
emit SendFirstData();
|
|
||||||
break;
|
break;
|
||||||
case pb::remote::DISCONNECT: close_connection_ = true;
|
case pb::remote::DISCONNECT: close_connection_ = true;
|
||||||
break;
|
break;
|
||||||
@ -159,3 +158,16 @@ void IncomingDataParser::SetShuffleMode(const pb::remote::Shuffle& shuffle) {
|
|||||||
default: break;
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -18,7 +18,7 @@ public slots:
|
|||||||
|
|
||||||
signals:
|
signals:
|
||||||
void SendClementineInfo();
|
void SendClementineInfo();
|
||||||
void SendFirstData();
|
void SendFirstData(bool send_playlist_songs);
|
||||||
void SendAllPlaylists();
|
void SendAllPlaylists();
|
||||||
void SendPlaylistSongs(int id);
|
void SendPlaylistSongs(int id);
|
||||||
|
|
||||||
@ -36,7 +36,6 @@ signals:
|
|||||||
void SetShuffleMode(PlaylistSequence::ShuffleMode mode);
|
void SetShuffleMode(PlaylistSequence::ShuffleMode mode);
|
||||||
void SeekTo(int seconds);
|
void SeekTo(int seconds);
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Application* app_;
|
Application* app_;
|
||||||
bool close_connection_;
|
bool close_connection_;
|
||||||
@ -45,6 +44,7 @@ private:
|
|||||||
void ChangeSong(const pb::remote::Message& msg);
|
void ChangeSong(const pb::remote::Message& msg);
|
||||||
void SetRepeatMode(const pb::remote::Repeat& repeat);
|
void SetRepeatMode(const pb::remote::Repeat& repeat);
|
||||||
void SetShuffleMode(const pb::remote::Shuffle& shuffle);
|
void SetShuffleMode(const pb::remote::Shuffle& shuffle);
|
||||||
|
void ClientConnect(const pb::remote::Message& msg);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // INCOMINGDATAPARSER_H
|
#endif // INCOMINGDATAPARSER_H
|
||||||
|
@ -120,8 +120,8 @@ void NetworkRemote::AcceptConnection() {
|
|||||||
// Setting up the signals, but only once
|
// Setting up the signals, but only once
|
||||||
connect(incoming_data_parser_.get(), SIGNAL(SendClementineInfo()),
|
connect(incoming_data_parser_.get(), SIGNAL(SendClementineInfo()),
|
||||||
outgoing_data_creator_.get(), SLOT(SendClementineInfo()));
|
outgoing_data_creator_.get(), SLOT(SendClementineInfo()));
|
||||||
connect(incoming_data_parser_.get(), SIGNAL(SendFirstData()),
|
connect(incoming_data_parser_.get(), SIGNAL(SendFirstData(bool)),
|
||||||
outgoing_data_creator_.get(), SLOT(SendFirstData()));
|
outgoing_data_creator_.get(), SLOT(SendFirstData(bool)));
|
||||||
connect(incoming_data_parser_.get(), SIGNAL(SendAllPlaylists()),
|
connect(incoming_data_parser_.get(), SIGNAL(SendAllPlaylists()),
|
||||||
outgoing_data_creator_.get(), SLOT(SendAllPlaylists()));
|
outgoing_data_creator_.get(), SLOT(SendAllPlaylists()));
|
||||||
connect(incoming_data_parser_.get(), SIGNAL(SendPlaylistSongs(int)),
|
connect(incoming_data_parser_.get(), SIGNAL(SendPlaylistSongs(int)),
|
||||||
|
@ -151,7 +151,7 @@ void OutgoingDataCreator::PlaylistRenamed(int id, const QString& new_name) {
|
|||||||
SendAllPlaylists();
|
SendAllPlaylists();
|
||||||
}
|
}
|
||||||
|
|
||||||
void OutgoingDataCreator::SendFirstData() {
|
void OutgoingDataCreator::SendFirstData(bool send_playlist_songs) {
|
||||||
// First Send the current song
|
// First Send the current song
|
||||||
PlaylistItemPtr item = app_->player()->GetCurrentItem();
|
PlaylistItemPtr item = app_->player()->GetCurrentItem();
|
||||||
if (!item) {
|
if (!item) {
|
||||||
@ -170,7 +170,9 @@ void OutgoingDataCreator::SendFirstData() {
|
|||||||
SendAllPlaylists();
|
SendAllPlaylists();
|
||||||
|
|
||||||
// Send the tracks of the active playlist
|
// Send the tracks of the active playlist
|
||||||
|
if (send_playlist_songs) {
|
||||||
SendPlaylistSongs(app_->playlist_manager()->active_id());
|
SendPlaylistSongs(app_->playlist_manager()->active_id());
|
||||||
|
}
|
||||||
|
|
||||||
// Send the current random and repeat mode
|
// Send the current random and repeat mode
|
||||||
SendShuffleMode(app_->playlist_manager()->sequence()->shuffle_mode());
|
SendShuffleMode(app_->playlist_manager()->sequence()->shuffle_mode());
|
||||||
|
@ -26,7 +26,7 @@ public:
|
|||||||
public slots:
|
public slots:
|
||||||
void SendClementineInfo();
|
void SendClementineInfo();
|
||||||
void SendAllPlaylists();
|
void SendAllPlaylists();
|
||||||
void SendFirstData();
|
void SendFirstData(bool send_playlist_songs);
|
||||||
void SendPlaylistSongs(int id);
|
void SendPlaylistSongs(int id);
|
||||||
void PlaylistChanged(Playlist*);
|
void PlaylistChanged(Playlist*);
|
||||||
void VolumeChanged(int volume);
|
void VolumeChanged(int volume);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user