mirror of
https://github.com/clementine-player/Clementine
synced 2024-12-18 20:34:39 +01:00
Rename SpotifyMessage to Message
This commit is contained in:
parent
68a379ef26
commit
67c6dead5a
@ -91,8 +91,8 @@ SpotifyClient::SpotifyClient(QObject* parent)
|
||||
events_timer_->setSingleShot(true);
|
||||
connect(events_timer_, SIGNAL(timeout()), SLOT(ProcessEvents()));
|
||||
|
||||
connect(handler_, SIGNAL(MessageArrived(pb::spotify::SpotifyMessage)),
|
||||
SLOT(HandleMessage(pb::spotify::SpotifyMessage)));
|
||||
connect(handler_, SIGNAL(MessageArrived(pb::spotify::Message)),
|
||||
SLOT(HandleMessage(pb::spotify::Message)));
|
||||
connect(protocol_socket_, SIGNAL(disconnected()),
|
||||
QCoreApplication::instance(), SLOT(quit()));
|
||||
}
|
||||
@ -217,7 +217,7 @@ void SpotifyClient::SendSearchResponse(sp_search* result) {
|
||||
pb::spotify::SearchRequest req = pending_searches_.take(result);
|
||||
|
||||
// Prepare the response
|
||||
pb::spotify::SpotifyMessage message;
|
||||
pb::spotify::Message message;
|
||||
pb::spotify::SearchResponse* response = message.mutable_search_response();
|
||||
|
||||
*response->mutable_request() = req;
|
||||
@ -265,7 +265,7 @@ void SpotifyClient::SendSearchResponse(sp_search* result) {
|
||||
sp_search_release(result);
|
||||
}
|
||||
|
||||
void SpotifyClient::HandleMessage(const pb::spotify::SpotifyMessage& message) {
|
||||
void SpotifyClient::HandleMessage(const pb::spotify::Message& message) {
|
||||
if (message.has_login_request()) {
|
||||
Login(message.login_request());
|
||||
} else if (message.has_load_playlist_request()) {
|
||||
@ -330,7 +330,7 @@ void SpotifyClient::Login(const pb::spotify::LoginRequest& req) {
|
||||
|
||||
void SpotifyClient::SendLoginCompleted(bool success, const QString& error,
|
||||
pb::spotify::LoginResponse_Error error_code) {
|
||||
pb::spotify::SpotifyMessage message;
|
||||
pb::spotify::Message message;
|
||||
|
||||
pb::spotify::LoginResponse* response = message.mutable_login_response();
|
||||
response->set_success(success);
|
||||
@ -380,7 +380,7 @@ void SpotifyClient::PlaylistRemovedCallback(sp_playlistcontainer* pc, sp_playlis
|
||||
}
|
||||
|
||||
void SpotifyClient::SendPlaylistList() {
|
||||
pb::spotify::SpotifyMessage message;
|
||||
pb::spotify::Message message;
|
||||
pb::spotify::Playlists* response = message.mutable_playlists_updated();
|
||||
|
||||
sp_playlistcontainer* container = sp_session_playlistcontainer(session_);
|
||||
@ -464,7 +464,7 @@ void SpotifyClient::LoadPlaylist(const pb::spotify::LoadPlaylistRequest& req) {
|
||||
if (!pending_load.playlist_) {
|
||||
qLog(Warning) << "Invalid playlist requested or not logged in";
|
||||
|
||||
pb::spotify::SpotifyMessage message;
|
||||
pb::spotify::Message message;
|
||||
pb::spotify::LoadPlaylistResponse* response = message.mutable_load_playlist_response();
|
||||
*response->mutable_request() = req;
|
||||
handler_->SendMessage(message);
|
||||
@ -528,7 +528,7 @@ void SpotifyClient::PlaylistStateChangedForLoadPlaylist(sp_playlist* pl, void* u
|
||||
}
|
||||
|
||||
// Everything is loaded so send the response protobuf and unref everything.
|
||||
pb::spotify::SpotifyMessage message;
|
||||
pb::spotify::Message message;
|
||||
pb::spotify::LoadPlaylistResponse* response = message.mutable_load_playlist_response();
|
||||
|
||||
// For some reason, we receive the starred tracks in reverse order but not
|
||||
@ -745,7 +745,7 @@ void SpotifyClient::OfflineStatusUpdatedCallback(sp_session* session) {
|
||||
|
||||
void SpotifyClient::SendDownloadProgress(
|
||||
pb::spotify::PlaylistType type, int index, int download_progress) {
|
||||
pb::spotify::SpotifyMessage message;
|
||||
pb::spotify::Message message;
|
||||
pb::spotify::SyncPlaylistProgress* progress = message.mutable_sync_playlist_progress();
|
||||
progress->mutable_request()->set_type(type);
|
||||
if (index != -1) {
|
||||
@ -835,7 +835,7 @@ void SpotifyClient::TryPlaybackAgain(const PendingPlaybackRequest& req) {
|
||||
}
|
||||
|
||||
void SpotifyClient::SendPlaybackError(const QString& error) {
|
||||
pb::spotify::SpotifyMessage message;
|
||||
pb::spotify::Message message;
|
||||
pb::spotify::PlaybackError* msg = message.mutable_playback_error();
|
||||
|
||||
msg->set_error(DataCommaSizeFromQString(error));
|
||||
@ -849,7 +849,7 @@ void SpotifyClient::LoadImage(const QString& id_b64) {
|
||||
<< kSpotifyImageIDSize << "bytes):" << id_b64;
|
||||
|
||||
// Send an error response straight away
|
||||
pb::spotify::SpotifyMessage message;
|
||||
pb::spotify::Message message;
|
||||
pb::spotify::ImageResponse* msg = message.mutable_image_response();
|
||||
msg->set_id(DataCommaSizeFromQString(id_b64));
|
||||
handler_->SendMessage(message);
|
||||
@ -898,7 +898,7 @@ void SpotifyClient::TryImageAgain(sp_image* image) {
|
||||
const void* data = sp_image_data(image, &size);
|
||||
|
||||
// Send the response
|
||||
pb::spotify::SpotifyMessage message;
|
||||
pb::spotify::Message message;
|
||||
pb::spotify::ImageResponse* msg = message.mutable_image_response();
|
||||
msg->set_id(DataCommaSizeFromQString(req->id_b64_));
|
||||
if (data && size) {
|
||||
@ -951,7 +951,7 @@ void SpotifyClient::AlbumBrowseComplete(sp_albumbrowse* result, void* userdata)
|
||||
|
||||
QString uri = me->pending_album_browses_.take(result);
|
||||
|
||||
pb::spotify::SpotifyMessage message;
|
||||
pb::spotify::Message message;
|
||||
pb::spotify::BrowseAlbumResponse* msg = message.mutable_browse_album_response();
|
||||
|
||||
msg->set_uri(DataCommaSizeFromQString(uri));
|
||||
|
@ -49,7 +49,7 @@ public:
|
||||
void Init(quint16 port);
|
||||
|
||||
private slots:
|
||||
void HandleMessage(const pb::spotify::SpotifyMessage& message);
|
||||
void HandleMessage(const pb::spotify::Message& message);
|
||||
void ProcessEvents();
|
||||
|
||||
private:
|
||||
|
@ -162,7 +162,7 @@ message PlaybackSettings {
|
||||
optional bool volume_normalisation = 2 [default = false];
|
||||
}
|
||||
|
||||
message SpotifyMessage {
|
||||
message Message {
|
||||
optional LoginRequest login_request = 1;
|
||||
optional LoginResponse login_response = 2;
|
||||
optional Playlists playlists_updated = 3;
|
||||
|
@ -52,22 +52,22 @@ void SpotifyServer::NewConnection() {
|
||||
|
||||
protocol_socket_ = server_->nextPendingConnection();
|
||||
handler_ = new SpotifyMessageHandler(protocol_socket_, this);
|
||||
connect(handler_, SIGNAL(MessageArrived(pb::spotify::SpotifyMessage)),
|
||||
SLOT(HandleMessage(pb::spotify::SpotifyMessage)));
|
||||
connect(handler_, SIGNAL(MessageArrived(pb::spotify::Message)),
|
||||
SLOT(HandleMessage(pb::spotify::Message)));
|
||||
|
||||
qLog(Info) << "Connection from port" << protocol_socket_->peerPort();
|
||||
|
||||
// Send any login messages that were queued before the client connected
|
||||
foreach (const pb::spotify::SpotifyMessage& message, queued_login_messages_) {
|
||||
foreach (const pb::spotify::Message& message, queued_login_messages_) {
|
||||
SendMessage(message);
|
||||
}
|
||||
queued_login_messages_.clear();
|
||||
}
|
||||
|
||||
void SpotifyServer::SendMessage(const pb::spotify::SpotifyMessage& message) {
|
||||
void SpotifyServer::SendMessage(const pb::spotify::Message& message) {
|
||||
const bool is_login_message = message.has_login_request();
|
||||
|
||||
QList<pb::spotify::SpotifyMessage>* queue =
|
||||
QList<pb::spotify::Message>* queue =
|
||||
is_login_message ? &queued_login_messages_ : &queued_messages_;
|
||||
|
||||
if (!protocol_socket_ || (!is_login_message && !logged_in_)) {
|
||||
@ -79,7 +79,7 @@ void SpotifyServer::SendMessage(const pb::spotify::SpotifyMessage& message) {
|
||||
|
||||
void SpotifyServer::Login(const QString& username, const QString& password,
|
||||
pb::spotify::Bitrate bitrate, bool volume_normalisation) {
|
||||
pb::spotify::SpotifyMessage message;
|
||||
pb::spotify::Message message;
|
||||
|
||||
pb::spotify::LoginRequest* request = message.mutable_login_request();
|
||||
request->set_username(DataCommaSizeFromQString(username));
|
||||
@ -93,7 +93,7 @@ void SpotifyServer::Login(const QString& username, const QString& password,
|
||||
}
|
||||
|
||||
void SpotifyServer::SetPlaybackSettings(pb::spotify::Bitrate bitrate, bool volume_normalisation) {
|
||||
pb::spotify::SpotifyMessage message;
|
||||
pb::spotify::Message message;
|
||||
|
||||
pb::spotify::PlaybackSettings* request = message.mutable_set_playback_settings_request();
|
||||
request->set_bitrate(bitrate);
|
||||
@ -102,14 +102,14 @@ void SpotifyServer::SetPlaybackSettings(pb::spotify::Bitrate bitrate, bool volum
|
||||
SendMessage(message);
|
||||
}
|
||||
|
||||
void SpotifyServer::HandleMessage(const pb::spotify::SpotifyMessage& message) {
|
||||
void SpotifyServer::HandleMessage(const pb::spotify::Message& message) {
|
||||
if (message.has_login_response()) {
|
||||
const pb::spotify::LoginResponse& response = message.login_response();
|
||||
logged_in_ = response.success();
|
||||
|
||||
if (response.success()) {
|
||||
// Send any messages that were queued before the client logged in
|
||||
foreach (const pb::spotify::SpotifyMessage& message, queued_messages_) {
|
||||
foreach (const pb::spotify::Message& message, queued_messages_) {
|
||||
SendMessage(message);
|
||||
}
|
||||
queued_messages_.clear();
|
||||
@ -157,7 +157,7 @@ void SpotifyServer::HandleMessage(const pb::spotify::SpotifyMessage& message) {
|
||||
}
|
||||
|
||||
void SpotifyServer::LoadPlaylist(pb::spotify::PlaylistType type, int index) {
|
||||
pb::spotify::SpotifyMessage message;
|
||||
pb::spotify::Message message;
|
||||
pb::spotify::LoadPlaylistRequest* req = message.mutable_load_playlist_request();
|
||||
|
||||
req->set_type(type);
|
||||
@ -170,7 +170,7 @@ void SpotifyServer::LoadPlaylist(pb::spotify::PlaylistType type, int index) {
|
||||
|
||||
void SpotifyServer::SyncPlaylist(
|
||||
pb::spotify::PlaylistType type, int index, bool offline) {
|
||||
pb::spotify::SpotifyMessage message;
|
||||
pb::spotify::Message message;
|
||||
pb::spotify::SyncPlaylistRequest* req = message.mutable_sync_playlist_request();
|
||||
req->mutable_request()->set_type(type);
|
||||
if (index != -1) {
|
||||
@ -218,7 +218,7 @@ void SpotifyServer::StartPlaybackLater(const QString& uri, quint16 port) {
|
||||
}
|
||||
|
||||
void SpotifyServer::StartPlayback(const QString& uri, quint16 port) {
|
||||
pb::spotify::SpotifyMessage message;
|
||||
pb::spotify::Message message;
|
||||
pb::spotify::PlaybackRequest* req = message.mutable_playback_request();
|
||||
|
||||
req->set_track_uri(DataCommaSizeFromQString(uri));
|
||||
@ -227,7 +227,7 @@ void SpotifyServer::StartPlayback(const QString& uri, quint16 port) {
|
||||
}
|
||||
|
||||
void SpotifyServer::Seek(qint64 offset_bytes) {
|
||||
pb::spotify::SpotifyMessage message;
|
||||
pb::spotify::Message message;
|
||||
pb::spotify::SeekRequest* req = message.mutable_seek_request();
|
||||
|
||||
req->set_offset_bytes(offset_bytes);
|
||||
@ -235,7 +235,7 @@ void SpotifyServer::Seek(qint64 offset_bytes) {
|
||||
}
|
||||
|
||||
void SpotifyServer::Search(const QString& text, int limit, int limit_album) {
|
||||
pb::spotify::SpotifyMessage message;
|
||||
pb::spotify::Message message;
|
||||
pb::spotify::SearchRequest* req = message.mutable_search_request();
|
||||
|
||||
req->set_query(DataCommaSizeFromQString(text));
|
||||
@ -245,7 +245,7 @@ void SpotifyServer::Search(const QString& text, int limit, int limit_album) {
|
||||
}
|
||||
|
||||
void SpotifyServer::LoadImage(const QString& id) {
|
||||
pb::spotify::SpotifyMessage message;
|
||||
pb::spotify::Message message;
|
||||
pb::spotify::ImageRequest* req = message.mutable_image_request();
|
||||
|
||||
req->set_id(DataCommaSizeFromQString(id));
|
||||
@ -253,7 +253,7 @@ void SpotifyServer::LoadImage(const QString& id) {
|
||||
}
|
||||
|
||||
void SpotifyServer::AlbumBrowse(const QString& uri) {
|
||||
pb::spotify::SpotifyMessage message;
|
||||
pb::spotify::Message message;
|
||||
pb::spotify::BrowseAlbumRequest* req = message.mutable_browse_album_request();
|
||||
|
||||
req->set_uri(DataCommaSizeFromQString(uri));
|
||||
|
@ -72,20 +72,20 @@ signals:
|
||||
|
||||
private slots:
|
||||
void NewConnection();
|
||||
void HandleMessage(const pb::spotify::SpotifyMessage& message);
|
||||
void HandleMessage(const pb::spotify::Message& message);
|
||||
|
||||
private:
|
||||
void LoadPlaylist(pb::spotify::PlaylistType type, int index = -1);
|
||||
void SyncPlaylist(pb::spotify::PlaylistType type, int index, bool offline);
|
||||
void SendMessage(const pb::spotify::SpotifyMessage& message);
|
||||
void SendMessage(const pb::spotify::Message& message);
|
||||
|
||||
QTcpServer* server_;
|
||||
QTcpSocket* protocol_socket_;
|
||||
SpotifyMessageHandler* handler_;
|
||||
bool logged_in_;
|
||||
|
||||
QList<pb::spotify::SpotifyMessage> queued_login_messages_;
|
||||
QList<pb::spotify::SpotifyMessage> queued_messages_;
|
||||
QList<pb::spotify::Message> queued_login_messages_;
|
||||
QList<pb::spotify::Message> queued_messages_;
|
||||
};
|
||||
|
||||
#endif // SPOTIFYSERVER_H
|
||||
|
Loading…
Reference in New Issue
Block a user