2018-12-23 18:54:27 +01:00
|
|
|
/*
|
|
|
|
* Strawberry Music Player
|
2021-03-20 21:14:47 +01:00
|
|
|
* Copyright 2018-2021, 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 AUDIOSCROBBLER_H
|
|
|
|
#define AUDIOSCROBBLER_H
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2023-07-21 05:55:24 +02:00
|
|
|
#include <memory>
|
|
|
|
|
2023-04-21 20:20:53 +02:00
|
|
|
#include <QtGlobal>
|
2018-12-23 18:54:27 +01:00
|
|
|
#include <QObject>
|
2020-08-25 23:44:27 +02:00
|
|
|
#include <QList>
|
2023-04-21 20:20:53 +02:00
|
|
|
#include <QMap>
|
2018-12-23 18:54:27 +01:00
|
|
|
#include <QString>
|
|
|
|
|
2023-07-21 05:55:24 +02:00
|
|
|
#include "core/shared_ptr.h"
|
2020-08-25 23:44:27 +02:00
|
|
|
#include "core/song.h"
|
2023-07-21 05:55:24 +02:00
|
|
|
#include "scrobblersettings.h"
|
2018-12-23 18:54:27 +01:00
|
|
|
|
|
|
|
class Application;
|
|
|
|
class ScrobblerService;
|
2023-04-21 20:20:53 +02:00
|
|
|
class Song;
|
2018-12-23 18:54:27 +01:00
|
|
|
|
|
|
|
class AudioScrobbler : public QObject {
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
explicit AudioScrobbler(Application *app, QObject *parent = nullptr);
|
2023-04-21 20:20:53 +02:00
|
|
|
~AudioScrobbler();
|
|
|
|
|
2023-07-21 05:55:24 +02:00
|
|
|
void AddService(SharedPtr<ScrobblerService> service);
|
|
|
|
void RemoveService(SharedPtr<ScrobblerService> service);
|
|
|
|
QList<SharedPtr<ScrobblerService>> List() const { return services_.values(); }
|
2023-04-21 20:20:53 +02:00
|
|
|
bool HasAnyServices() const { return !services_.isEmpty(); }
|
|
|
|
int NextId();
|
|
|
|
|
2023-07-21 05:55:24 +02:00
|
|
|
QList<SharedPtr<ScrobblerService>> GetAll();
|
|
|
|
SharedPtr<ScrobblerService> ServiceByName(const QString &name);
|
2023-04-21 20:20:53 +02:00
|
|
|
template<typename T>
|
2023-07-21 05:55:24 +02:00
|
|
|
SharedPtr<T> Service() {
|
2024-04-11 02:56:01 +02:00
|
|
|
return std::static_pointer_cast<T>(ServiceByName(QLatin1String(T::kName)));
|
2023-04-21 20:20:53 +02:00
|
|
|
}
|
2018-12-23 18:54:27 +01:00
|
|
|
|
|
|
|
void ReloadSettings();
|
2023-07-21 05:55:24 +02:00
|
|
|
SharedPtr<ScrobblerSettings> settings() { return settings_; }
|
2018-12-23 18:54:27 +01:00
|
|
|
|
2023-07-21 05:55:24 +02:00
|
|
|
bool enabled() const { return settings_->enabled(); }
|
|
|
|
bool offline() const { return settings_->offline(); }
|
|
|
|
bool scrobble_button() const { return settings_->scrobble_button(); }
|
|
|
|
bool love_button() const { return settings_->love_button(); }
|
|
|
|
int submit_delay() const { return settings_->submit_delay(); }
|
|
|
|
bool prefer_albumartist() const { return settings_->prefer_albumartist(); }
|
|
|
|
bool ShowErrorDialog() const { return settings_->show_error_dialog(); }
|
2024-04-04 21:17:07 +02:00
|
|
|
bool strip_remastered() const { return settings_->strip_remastered(); }
|
2023-07-21 05:55:24 +02:00
|
|
|
QList<Song::Source> sources() const { return settings_->sources(); }
|
2018-12-23 18:54:27 +01:00
|
|
|
|
2023-04-21 20:20:53 +02:00
|
|
|
void ShowConfig();
|
|
|
|
|
2018-12-23 18:54:27 +01:00
|
|
|
void UpdateNowPlaying(const Song &song);
|
2019-06-12 00:38:52 +02:00
|
|
|
void ClearPlaying();
|
2021-10-30 02:21:29 +02:00
|
|
|
void Scrobble(const Song &song, const qint64 scrobble_point);
|
2018-12-23 18:54:27 +01:00
|
|
|
|
|
|
|
public slots:
|
|
|
|
void ToggleScrobbling();
|
|
|
|
void ToggleOffline();
|
2023-04-21 20:20:53 +02:00
|
|
|
void ErrorReceived(const QString &error);
|
2018-12-23 18:54:27 +01:00
|
|
|
void Submit();
|
2019-06-12 00:38:52 +02:00
|
|
|
void Love();
|
2018-12-23 18:54:27 +01:00
|
|
|
void WriteCache();
|
|
|
|
|
|
|
|
signals:
|
2023-04-09 20:23:42 +02:00
|
|
|
void ErrorMessage(const QString &error);
|
2018-12-23 18:54:27 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
Application *app_;
|
2023-07-21 05:55:24 +02:00
|
|
|
SharedPtr<ScrobblerSettings> settings_;
|
|
|
|
QMap<QString, SharedPtr<ScrobblerService>> services_;
|
2018-12-23 18:54:27 +01:00
|
|
|
|
2023-04-21 20:20:53 +02:00
|
|
|
Q_DISABLE_COPY(AudioScrobbler)
|
2018-12-23 18:54:27 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // AUDIOSCROBBLER_H
|