2018-12-23 18:54:27 +01:00
|
|
|
/*
|
|
|
|
* Strawberry Music Player
|
2023-03-25 14:25:21 +01:00
|
|
|
* Copyright 2018-2023, Jonas Kvinge <jonas@jkvinge.net>
|
2018-12-23 18:54:27 +01:00
|
|
|
*
|
|
|
|
* Strawberry 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.
|
|
|
|
*
|
|
|
|
* Strawberry 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 Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef SCROBBLERSERVICE_H
|
|
|
|
#define SCROBBLERSERVICE_H
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <QObject>
|
2018-12-26 15:05:32 +01:00
|
|
|
#include <QPair>
|
|
|
|
#include <QList>
|
2018-12-23 18:54:27 +01:00
|
|
|
#include <QVariant>
|
|
|
|
#include <QByteArray>
|
2018-12-26 15:05:32 +01:00
|
|
|
#include <QString>
|
2018-12-23 18:54:27 +01:00
|
|
|
#include <QJsonObject>
|
|
|
|
|
2023-03-25 14:25:21 +01:00
|
|
|
#include "core/song.h"
|
|
|
|
|
2018-12-23 18:54:27 +01:00
|
|
|
class Application;
|
|
|
|
|
|
|
|
class ScrobblerService : public QObject {
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
explicit ScrobblerService(const QString &name, Application *app, QObject *parent);
|
|
|
|
|
|
|
|
QString name() const { return name_; }
|
|
|
|
|
|
|
|
virtual void ReloadSettings() = 0;
|
|
|
|
|
|
|
|
virtual bool IsEnabled() const { return false; }
|
|
|
|
virtual bool IsAuthenticated() const { return false; }
|
|
|
|
|
|
|
|
virtual void UpdateNowPlaying(const Song &song) = 0;
|
2019-06-12 00:38:52 +02:00
|
|
|
virtual void ClearPlaying() = 0;
|
2018-12-23 18:54:27 +01:00
|
|
|
virtual void Scrobble(const Song &song) = 0;
|
2019-06-12 00:38:52 +02:00
|
|
|
virtual void Love() {}
|
2018-12-23 18:54:27 +01:00
|
|
|
|
2022-02-16 17:46:40 +01:00
|
|
|
virtual void StartSubmit(const bool initial = false) = 0;
|
2018-12-23 18:54:27 +01:00
|
|
|
virtual void Submitted() = 0;
|
|
|
|
virtual bool IsSubmitted() const { return false; }
|
|
|
|
|
2023-03-25 14:25:21 +01:00
|
|
|
protected:
|
2022-10-13 22:39:31 +02:00
|
|
|
using Param = QPair<QString, QString>;
|
|
|
|
using ParamList = QList<Param>;
|
2023-03-25 14:25:21 +01:00
|
|
|
using EncodedParam = QPair<QByteArray, QByteArray>;
|
2018-12-23 18:54:27 +01:00
|
|
|
|
2023-04-21 02:11:23 +02:00
|
|
|
bool ExtractJsonObj(const QByteArray &data, QJsonObject &json_obj, QString &error_description);
|
2023-03-25 14:25:21 +01:00
|
|
|
|
|
|
|
QString StripAlbum(QString album) const;
|
|
|
|
QString StripTitle(QString title) const;
|
2018-12-23 18:54:27 +01:00
|
|
|
|
|
|
|
public slots:
|
|
|
|
virtual void Submit() = 0;
|
|
|
|
virtual void WriteCache() = 0;
|
|
|
|
|
|
|
|
signals:
|
2023-04-09 20:23:42 +02:00
|
|
|
void ErrorMessage(const QString &error);
|
2018-12-23 18:54:27 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
QString name_;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // SCROBBLERSERVICE_H
|