2011-02-19 19:24:11 +01: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 REMOTE_H
|
|
|
|
#define REMOTE_H
|
|
|
|
|
|
|
|
#include "core/song.h"
|
|
|
|
|
|
|
|
#include <QObject>
|
2011-03-08 22:16:09 +01:00
|
|
|
#include <QTcpSocket>
|
2011-02-19 19:24:11 +01:00
|
|
|
|
|
|
|
#include <xrme/connection.h>
|
|
|
|
#include <xrme/mediaplayerinterface.h>
|
2011-03-13 19:20:37 +01:00
|
|
|
#include <xrme/mediastorageinterface.h>
|
2011-02-19 19:24:11 +01:00
|
|
|
|
|
|
|
class ArtLoader;
|
|
|
|
class Player;
|
|
|
|
|
|
|
|
class Remote : public QObject,
|
2011-03-13 19:20:37 +01:00
|
|
|
protected xrme::MediaPlayerInterface,
|
|
|
|
protected xrme::MediaStorageInterface {
|
2011-02-19 19:24:11 +01:00
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
Remote(Player* player, QObject* parent = 0);
|
|
|
|
|
|
|
|
static const int kMaxRetries = 3;
|
|
|
|
|
|
|
|
public slots:
|
|
|
|
void ReloadSettings();
|
|
|
|
void ArtLoaded(const Song&, const QString&, const QImage& image);
|
|
|
|
|
|
|
|
signals:
|
|
|
|
void Error(const QString& message);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
// xrme::MediaPlayerInterface
|
|
|
|
void PlayPause();
|
|
|
|
void Stop();
|
|
|
|
void Next();
|
|
|
|
void Previous();
|
|
|
|
xrme::State state() const;
|
|
|
|
QImage album_art() const;
|
|
|
|
|
2011-03-13 19:20:37 +01:00
|
|
|
// xrme::MediaStorageInterface
|
|
|
|
QStringList GetArtists() const;
|
|
|
|
|
2011-02-19 19:24:11 +01:00
|
|
|
private slots:
|
|
|
|
void Connected();
|
|
|
|
void Disconnected(const QString& error);
|
|
|
|
|
|
|
|
void SetStateChanged();
|
|
|
|
|
2011-03-08 22:16:09 +01:00
|
|
|
void TomahawkSIPReceived(const QVariant& json);
|
|
|
|
void TomahawkConnected();
|
|
|
|
void TomahawkDisconnected();
|
|
|
|
void TomahawkReadyRead();
|
|
|
|
void TomahawkError(QAbstractSocket::SocketError);
|
|
|
|
|
|
|
|
void TomahawkDBConnected();
|
|
|
|
void TomahawkDBDisconnected();
|
|
|
|
void TomahawkDBReadyRead();
|
|
|
|
|
2011-03-13 19:20:37 +01:00
|
|
|
void TomahawkTransferConnected();
|
|
|
|
void TomahawkTransferDisconnected();
|
|
|
|
void TomahawkTransferReadyRead();
|
|
|
|
|
2011-02-19 19:24:11 +01:00
|
|
|
private:
|
|
|
|
bool is_configured() const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
Player* player_;
|
|
|
|
xrme::Connection* connection_;
|
|
|
|
|
2011-03-08 22:16:09 +01:00
|
|
|
struct TomahawkConnection {
|
|
|
|
QString key;
|
|
|
|
QString unique_name;
|
|
|
|
bool visible;
|
|
|
|
QTcpSocket* socket;
|
|
|
|
int num_bytes;
|
|
|
|
quint8 flags;
|
2011-03-13 19:20:37 +01:00
|
|
|
QString offer;
|
|
|
|
QString controlid;
|
2011-03-08 22:16:09 +01:00
|
|
|
};
|
|
|
|
QMap<QTcpSocket*, TomahawkConnection*> tomahawk_connections_;
|
|
|
|
|
2011-02-19 19:24:11 +01:00
|
|
|
QImage last_image_;
|
|
|
|
int retry_count_;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // REMOTE_H
|