mirror of
https://github.com/clementine-player/Clementine
synced 2025-01-30 11:04:57 +01:00
Merge branch 'master' of https://code.google.com/r/asfa194-clementineremote into remotecontrol
This commit is contained in:
commit
5ba67850fb
@ -22,7 +22,7 @@ enum MsgType {
|
||||
// Messages that contain the repeat or random mode
|
||||
// Either set by client or clementine
|
||||
REPEAT = 27;
|
||||
RANDOM = 28;
|
||||
SHUFFLE = 28;
|
||||
|
||||
// Messages send from server to client
|
||||
INFO = 40;
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "core/logging.h"
|
||||
#include "engines/enginebase.h"
|
||||
#include "playlist/playlistmanager.h"
|
||||
#include "playlist/playlistsequence.h"
|
||||
|
||||
IncomingDataParser::IncomingDataParser(Application* app)
|
||||
:app_(app)
|
||||
@ -45,6 +46,12 @@ IncomingDataParser::IncomingDataParser(Application* app)
|
||||
app_->playlist_manager(), SLOT(SetActivePlaylist(int)));
|
||||
connect(this, SIGNAL(ShuffleCurrent()),
|
||||
app_->playlist_manager(), SLOT(ShuffleCurrent()));
|
||||
connect(this, SIGNAL(SetRepeatMode(PlaylistSequence::RepeatMode)),
|
||||
app_->playlist_manager()->sequence(),
|
||||
SLOT(SetRepeatMode(PlaylistSequence::RepeatMode)));
|
||||
connect(this, SIGNAL(SetShuffleMode(PlaylistSequence::ShuffleMode)),
|
||||
app_->playlist_manager()->sequence(),
|
||||
SLOT(SetShuffleMode(PlaylistSequence::ShuffleMode)));
|
||||
}
|
||||
|
||||
IncomingDataParser::~IncomingDataParser() {
|
||||
@ -93,6 +100,10 @@ void IncomingDataParser::Parse(const QByteArray& data) {
|
||||
break;
|
||||
case pb::remote::SHUFFLE_PLAYLIST: emit ShuffleCurrent();
|
||||
break;
|
||||
case pb::remote::REPEAT: SetRepeatMode(msg.repeat());
|
||||
break;
|
||||
case pb::remote::SHUFFLE: SetShuffleMode(msg.shuffle());
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
@ -113,3 +124,39 @@ void IncomingDataParser::ChangeSong(const pb::remote::Message& msg) {
|
||||
// Play the selected song
|
||||
emit PlayAt(request.song_index(), Engine::Manual, false);
|
||||
}
|
||||
|
||||
void IncomingDataParser::SetRepeatMode(const pb::remote::Repeat& repeat) {
|
||||
switch (repeat.repeat_mode()) {
|
||||
case pb::remote::Repeat_Off:
|
||||
emit SetRepeatMode(PlaylistSequence::Repeat_Off);
|
||||
break;
|
||||
case pb::remote::Repeat_Track:
|
||||
emit SetRepeatMode(PlaylistSequence::Repeat_Track);
|
||||
break;
|
||||
case pb::remote::Repeat_Album:
|
||||
emit SetRepeatMode(PlaylistSequence::Repeat_Album);
|
||||
break;
|
||||
case pb::remote::Repeat_Playlist:
|
||||
emit SetRepeatMode(PlaylistSequence::Repeat_Playlist);
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
void IncomingDataParser::SetShuffleMode(const pb::remote::Shuffle& shuffle) {
|
||||
switch (shuffle.shuffle_mode()) {
|
||||
case pb::remote::Shuffle_Off:
|
||||
emit SetShuffleMode(PlaylistSequence::Shuffle_Off);
|
||||
break;
|
||||
case pb::remote::Shuffle_All:
|
||||
emit SetShuffleMode(PlaylistSequence::Shuffle_All);
|
||||
break;
|
||||
case pb::remote::Shuffle_InsideAlbum:
|
||||
emit SetShuffleMode(PlaylistSequence::Shuffle_InsideAlbum);
|
||||
break;
|
||||
case pb::remote::Shuffle_Albums:
|
||||
emit SetShuffleMode(PlaylistSequence::Shuffle_Albums);
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
@ -32,6 +32,8 @@ signals:
|
||||
void PlayAt(int i, Engine::TrackChangeFlags change, bool reshuffle);
|
||||
void SetActivePlaylist(int id);
|
||||
void ShuffleCurrent();
|
||||
void SetRepeatMode(PlaylistSequence::RepeatMode mode);
|
||||
void SetShuffleMode(PlaylistSequence::ShuffleMode mode);
|
||||
|
||||
private:
|
||||
Application* app_;
|
||||
@ -39,6 +41,8 @@ private:
|
||||
|
||||
void GetPlaylistSongs(const pb::remote::Message& msg);
|
||||
void ChangeSong(const pb::remote::Message& msg);
|
||||
void SetRepeatMode(const pb::remote::Repeat& repeat);
|
||||
void SetShuffleMode(const pb::remote::Shuffle& shuffle);
|
||||
};
|
||||
|
||||
#endif // INCOMINGDATAPARSER_H
|
||||
|
@ -125,6 +125,15 @@ void NetworkRemote::AcceptConnection() {
|
||||
SLOT(VolumeChanged(int)));
|
||||
connect(app_->player()->engine(), SIGNAL(StateChanged(Engine::State)),
|
||||
outgoing_data_creator_.get(), SLOT(StateChanged(Engine::State)));
|
||||
|
||||
connect(app_->playlist_manager()->sequence(),
|
||||
SIGNAL(RepeatModeChanged(PlaylistSequence::RepeatMode)),
|
||||
outgoing_data_creator_.get(),
|
||||
SLOT(SendRepeatMode(PlaylistSequence::RepeatMode)));
|
||||
connect(app_->playlist_manager()->sequence(),
|
||||
SIGNAL(ShuffleModeChanged(PlaylistSequence::ShuffleMode)),
|
||||
outgoing_data_creator_.get(),
|
||||
SLOT(SendShuffleMode(PlaylistSequence::ShuffleMode)));
|
||||
}
|
||||
|
||||
QTcpServer* server = qobject_cast<QTcpServer*>(sender());
|
||||
@ -133,6 +142,7 @@ void NetworkRemote::AcceptConnection() {
|
||||
if (only_non_public_ip_ && !IpIsPrivate(client_socket->peerAddress())) {
|
||||
qLog(Info) << "Got a connection from public ip" <<
|
||||
client_socket->peerAddress().toString();
|
||||
client_socket->close();
|
||||
} else {
|
||||
CreateRemoteClient(client_socket);
|
||||
}
|
||||
@ -144,7 +154,7 @@ bool NetworkRemote::IpIsPrivate(const QHostAddress& address) {
|
||||
address.isInSubnet(QHostAddress::parseSubnet("127.0.0.1/8")) ||
|
||||
// Link Local v6
|
||||
address.isInSubnet(QHostAddress::parseSubnet("::1/128")) ||
|
||||
address.isInSubnet(QHostAddress::parseSubnet("fe80::/10"));
|
||||
address.isInSubnet(QHostAddress::parseSubnet("fe80::/10")) ||
|
||||
// Private v4 range
|
||||
address.isInSubnet(QHostAddress::parseSubnet("192.168.0.0/16")) ||
|
||||
address.isInSubnet(QHostAddress::parseSubnet("172.16.0.0/12")) ||
|
||||
|
@ -270,6 +270,50 @@ void OutgoingDataCreator::StateChanged(Engine::State state) {
|
||||
SendDataToClients(&msg);
|
||||
}
|
||||
|
||||
void OutgoingDataCreator::SendRepeatMode(PlaylistSequence::RepeatMode mode) {
|
||||
pb::remote::Message msg;
|
||||
msg.set_type(pb::remote::REPEAT);
|
||||
|
||||
switch (mode) {
|
||||
case PlaylistSequence::Repeat_Off:
|
||||
msg.mutable_repeat()->set_repeat_mode(pb::remote::Repeat_Off);
|
||||
break;
|
||||
case PlaylistSequence::Repeat_Track:
|
||||
msg.mutable_repeat()->set_repeat_mode(pb::remote::Repeat_Track);
|
||||
break;
|
||||
case PlaylistSequence::Repeat_Album:
|
||||
msg.mutable_repeat()->set_repeat_mode(pb::remote::Repeat_Album);
|
||||
break;
|
||||
case PlaylistSequence::Repeat_Playlist:
|
||||
msg.mutable_repeat()->set_repeat_mode(pb::remote::Repeat_Playlist);
|
||||
break;
|
||||
}
|
||||
|
||||
SendDataToClients(&msg);
|
||||
}
|
||||
|
||||
void OutgoingDataCreator::SendShuffleMode(PlaylistSequence::ShuffleMode mode) {
|
||||
pb::remote::Message msg;
|
||||
msg.set_type(pb::remote::SHUFFLE);
|
||||
|
||||
switch (mode) {
|
||||
case PlaylistSequence::Shuffle_Off:
|
||||
msg.mutable_shuffle()->set_shuffle_mode(pb::remote::Shuffle_Off);
|
||||
break;
|
||||
case PlaylistSequence::Shuffle_All:
|
||||
msg.mutable_shuffle()->set_shuffle_mode(pb::remote::Shuffle_All);
|
||||
break;
|
||||
case PlaylistSequence::Shuffle_InsideAlbum:
|
||||
msg.mutable_shuffle()->set_shuffle_mode(pb::remote::Shuffle_InsideAlbum);
|
||||
break;
|
||||
case PlaylistSequence::Shuffle_Albums:
|
||||
msg.mutable_shuffle()->set_shuffle_mode(pb::remote::Shuffle_Albums);
|
||||
break;
|
||||
}
|
||||
|
||||
SendDataToClients(&msg);
|
||||
}
|
||||
|
||||
void OutgoingDataCreator::SendKeepAlive() {
|
||||
pb::remote::Message msg;
|
||||
msg.set_type(pb::remote::KEEP_ALIVE);
|
||||
|
@ -34,6 +34,8 @@ public slots:
|
||||
void CurrentSongChanged(const Song& song, const QString& uri, const QImage& img);
|
||||
void StateChanged(Engine::State);
|
||||
void SendKeepAlive();
|
||||
void SendRepeatMode(PlaylistSequence::RepeatMode mode);
|
||||
void SendShuffleMode(PlaylistSequence::ShuffleMode mode);
|
||||
|
||||
private:
|
||||
Application* app_;
|
||||
|
Loading…
x
Reference in New Issue
Block a user