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
|
|
|
|
|
2011-04-26 15:42:58 +02:00
|
|
|
#include "spotifyblob/spotifymessages.pb.h"
|
|
|
|
#include "spotifyblob/spotifymessageutils.h"
|
2011-04-25 21:16:26 +02:00
|
|
|
|
2011-04-26 15:42:58 +02:00
|
|
|
#include <QObject>
|
2011-04-25 21:16:26 +02:00
|
|
|
|
|
|
|
class QTcpServer;
|
|
|
|
class QTcpSocket;
|
|
|
|
|
2011-04-26 15:42:58 +02:00
|
|
|
class SpotifyServer : public QObject, protected SpotifyMessageUtils {
|
2011-04-25 21:16:26 +02:00
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
SpotifyServer(QObject* parent = 0);
|
|
|
|
|
|
|
|
void Init();
|
|
|
|
void Login(const QString& username, const QString& password);
|
|
|
|
|
|
|
|
int server_port() const;
|
|
|
|
|
|
|
|
signals:
|
|
|
|
void LoginCompleted(bool success);
|
2011-04-26 15:42:58 +02:00
|
|
|
void PlaylistsUpdated(const protobuf::Playlists& playlists);
|
2011-04-25 21:16:26 +02:00
|
|
|
|
|
|
|
private slots:
|
|
|
|
void NewConnection();
|
|
|
|
void ProtocolSocketReadyRead();
|
|
|
|
|
|
|
|
private:
|
2011-04-26 15:42:58 +02:00
|
|
|
void SendMessage(const protobuf::SpotifyMessage& message);
|
2011-04-25 21:16:26 +02:00
|
|
|
|
|
|
|
QTcpServer* server_;
|
|
|
|
QTcpSocket* protocol_socket_;
|
2011-04-26 15:42:58 +02:00
|
|
|
bool logged_in_;
|
|
|
|
|
|
|
|
QList<protobuf::SpotifyMessage> queued_login_messages_;
|
|
|
|
QList<protobuf::SpotifyMessage> queued_messages_;
|
2011-04-25 21:16:26 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // SPOTIFYSERVER_H
|