2011-04-25 21:16:26 +02:00
|
|
|
/* This file is part of Clementine.
|
|
|
|
Copyright 2010, David Sansome <me@davidsansome.com>
|
|
|
|
|
|
|
|
Clementine is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
Clementine is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef SPOTIFYSERVER_H
|
|
|
|
#define SPOTIFYSERVER_H
|
|
|
|
|
2012-01-08 00:26:27 +01:00
|
|
|
#include "spotifymessages.pb.h"
|
2012-01-08 00:30:33 +01:00
|
|
|
#include "core/messagehandler.h"
|
2011-04-25 21:16:26 +02:00
|
|
|
|
2011-04-29 15:41:42 +02:00
|
|
|
#include <QImage>
|
2011-04-26 15:42:58 +02:00
|
|
|
#include <QObject>
|
2011-04-25 21:16:26 +02:00
|
|
|
|
2011-04-27 18:38:28 +02:00
|
|
|
|
2011-04-25 21:16:26 +02:00
|
|
|
class QTcpServer;
|
|
|
|
class QTcpSocket;
|
|
|
|
|
2012-01-08 00:30:33 +01:00
|
|
|
class SpotifyServer : public AbstractMessageHandler<pb::spotify::Message> {
|
2011-04-25 21:16:26 +02:00
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
SpotifyServer(QObject* parent = 0);
|
|
|
|
|
|
|
|
void Init();
|
2011-11-27 18:29:33 +01:00
|
|
|
void Login(const QString& username, const QString& password,
|
2012-01-08 00:26:27 +01:00
|
|
|
pb::spotify::Bitrate bitrate, bool volume_normalisation);
|
2011-04-25 21:16:26 +02:00
|
|
|
|
2011-04-26 19:06:36 +02:00
|
|
|
void LoadStarred();
|
2011-05-25 16:22:49 +02:00
|
|
|
void SyncStarred();
|
2011-04-26 19:06:36 +02:00
|
|
|
void LoadInbox();
|
2011-05-25 16:22:49 +02:00
|
|
|
void SyncInbox();
|
2011-04-26 19:06:36 +02:00
|
|
|
void LoadUserPlaylist(int index);
|
2011-05-25 16:22:49 +02:00
|
|
|
void SyncUserPlaylist(int index);
|
2011-11-28 19:11:09 +01:00
|
|
|
void StartPlaybackLater(const QString& uri, quint16 port);
|
2011-08-29 03:00:59 +02:00
|
|
|
void Search(const QString& text, int limit, int limit_album = 0);
|
2011-04-29 15:41:42 +02:00
|
|
|
void LoadImage(const QString& id);
|
2011-08-29 04:26:59 +02:00
|
|
|
void AlbumBrowse(const QString& uri);
|
2012-01-08 00:26:27 +01:00
|
|
|
void SetPlaybackSettings(pb::spotify::Bitrate bitrate, bool volume_normalisation);
|
2012-06-12 15:53:23 +02:00
|
|
|
void LoadToplist();
|
2011-04-27 18:38:28 +02:00
|
|
|
|
2011-04-25 21:16:26 +02:00
|
|
|
int server_port() const;
|
|
|
|
|
2011-09-25 20:24:44 +02:00
|
|
|
public slots:
|
2011-11-28 19:11:09 +01:00
|
|
|
void StartPlayback(const QString& uri, quint16 port);
|
2011-09-25 20:24:44 +02:00
|
|
|
void Seek(qint64 offset_bytes);
|
|
|
|
|
2011-04-25 21:16:26 +02:00
|
|
|
signals:
|
2011-08-27 23:01:28 +02:00
|
|
|
void LoginCompleted(bool success, const QString& error,
|
2012-01-08 00:26:27 +01:00
|
|
|
pb::spotify::LoginResponse_Error error_code);
|
|
|
|
void PlaylistsUpdated(const pb::spotify::Playlists& playlists);
|
2011-04-25 21:16:26 +02:00
|
|
|
|
2012-01-08 00:26:27 +01:00
|
|
|
void StarredLoaded(const pb::spotify::LoadPlaylistResponse& response);
|
|
|
|
void InboxLoaded(const pb::spotify::LoadPlaylistResponse& response);
|
|
|
|
void UserPlaylistLoaded(const pb::spotify::LoadPlaylistResponse& response);
|
2011-04-27 18:38:28 +02:00
|
|
|
void PlaybackError(const QString& message);
|
2012-01-08 00:26:27 +01:00
|
|
|
void SearchResults(const pb::spotify::SearchResponse& response);
|
2011-04-29 15:41:42 +02:00
|
|
|
void ImageLoaded(const QString& id, const QImage& image);
|
2012-01-08 00:26:27 +01:00
|
|
|
void SyncPlaylistProgress(const pb::spotify::SyncPlaylistProgress& progress);
|
|
|
|
void AlbumBrowseResults(const pb::spotify::BrowseAlbumResponse& response);
|
2012-06-12 15:53:23 +02:00
|
|
|
void ToplistBrowseResults(const pb::spotify::BrowseToplistResponse& response);
|
2011-04-27 18:38:28 +02:00
|
|
|
|
2012-01-08 00:30:33 +01:00
|
|
|
protected:
|
|
|
|
void MessageArrived(const pb::spotify::Message& message);
|
|
|
|
|
2011-04-25 21:16:26 +02:00
|
|
|
private slots:
|
|
|
|
void NewConnection();
|
|
|
|
|
|
|
|
private:
|
2012-01-08 00:26:27 +01:00
|
|
|
void LoadPlaylist(pb::spotify::PlaylistType type, int index = -1);
|
|
|
|
void SyncPlaylist(pb::spotify::PlaylistType type, int index, bool offline);
|
2012-01-08 00:30:33 +01:00
|
|
|
void SendOrQueueMessage(const pb::spotify::Message& message);
|
2011-04-25 21:16:26 +02:00
|
|
|
|
|
|
|
QTcpServer* server_;
|
2011-04-26 15:42:58 +02:00
|
|
|
bool logged_in_;
|
|
|
|
|
2012-01-08 00:31:20 +01:00
|
|
|
QList<pb::spotify::Message> queued_login_messages_;
|
|
|
|
QList<pb::spotify::Message> queued_messages_;
|
2011-04-25 21:16:26 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // SPOTIFYSERVER_H
|