Formatting

This commit is contained in:
Jonas Kvinge
2021-07-11 07:40:57 +02:00
parent 87b9a8c4c8
commit a6742d401c
149 changed files with 595 additions and 565 deletions

View File

@@ -41,18 +41,17 @@
# include "subsonicscrobbler.h"
#endif
AudioScrobbler::AudioScrobbler(Application *app, QObject *parent) :
QObject(parent),
app_(app),
scrobbler_services_(new ScrobblerServices(this)),
enabled_(false),
offline_(false),
scrobble_button_(false),
love_button_(false),
submit_delay_(0),
prefer_albumartist_(false),
show_error_dialog_(false)
{
AudioScrobbler::AudioScrobbler(Application *app, QObject *parent)
: QObject(parent),
app_(app),
scrobbler_services_(new ScrobblerServices(this)),
enabled_(false),
offline_(false),
scrobble_button_(false),
love_button_(false),
submit_delay_(0),
prefer_albumartist_(false),
show_error_dialog_(false) {
scrobbler_services_->AddService(new LastFMScrobbler(app_, scrobbler_services_));
scrobbler_services_->AddService(new LibreFMScrobbler(app_, scrobbler_services_));

View File

@@ -50,16 +50,16 @@
const int LastFMImport::kRequestsDelay = 2000;
LastFMImport::LastFMImport(QObject *parent) :
QObject(parent),
network_(new NetworkAccessManager(this)),
timer_flush_requests_(new QTimer(this)),
lastplayed_(false),
playcount_(false),
playcount_total_(0),
lastplayed_total_(0),
playcount_received_(0),
lastplayed_received_(0) {
LastFMImport::LastFMImport(QObject *parent)
: QObject(parent),
network_(new NetworkAccessManager(this)),
timer_flush_requests_(new QTimer(this)),
lastplayed_(false),
playcount_(false),
playcount_total_(0),
lastplayed_total_(0),
playcount_received_(0),
lastplayed_received_(0) {
timer_flush_requests_->setInterval(kRequestsDelay);
timer_flush_requests_->setSingleShot(false);

View File

@@ -34,16 +34,17 @@ const char *LastFMScrobbler::kAuthUrl = "https://www.last.fm/api/auth/";
const char *LastFMScrobbler::kApiUrl = "https://ws.audioscrobbler.com/2.0/";
const char *LastFMScrobbler::kCacheFile = "lastfmscrobbler.cache";
LastFMScrobbler::LastFMScrobbler(Application *app, QObject *parent) : ScrobblingAPI20(kName, kSettingsGroup, kAuthUrl, kApiUrl, true, app, parent),
auth_url_(kAuthUrl),
api_url_(kApiUrl),
app_(app),
network_(new NetworkAccessManager(this)),
cache_(new ScrobblerCache(kCacheFile, this)),
enabled_(false),
subscriber_(false),
submitted_(false),
timestamp_(0) {
LastFMScrobbler::LastFMScrobbler(Application *app, QObject *parent)
: ScrobblingAPI20(kName, kSettingsGroup, kAuthUrl, kApiUrl, true, app, parent),
auth_url_(kAuthUrl),
api_url_(kApiUrl),
app_(app),
network_(new NetworkAccessManager(this)),
cache_(new ScrobblerCache(kCacheFile, this)),
enabled_(false),
subscriber_(false),
submitted_(false),
timestamp_(0) {
ReloadSettings();
LoadSession();

View File

@@ -34,16 +34,17 @@ const char *LibreFMScrobbler::kAuthUrl = "https://www.libre.fm/api/auth/";
const char *LibreFMScrobbler::kApiUrl = "https://libre.fm/2.0/";
const char *LibreFMScrobbler::kCacheFile = "librefmscrobbler.cache";
LibreFMScrobbler::LibreFMScrobbler(Application *app, QObject *parent) : ScrobblingAPI20(kName, kSettingsGroup, kAuthUrl, kApiUrl, false, app, parent),
auth_url_(kAuthUrl),
api_url_(kApiUrl),
app_(app),
network_(new NetworkAccessManager(this)),
cache_(new ScrobblerCache(kCacheFile, this)),
enabled_(false),
subscriber_(false),
submitted_(false),
timestamp_(0) {
LibreFMScrobbler::LibreFMScrobbler(Application *app, QObject *parent)
: ScrobblingAPI20(kName, kSettingsGroup, kAuthUrl, kApiUrl, false, app, parent),
auth_url_(kAuthUrl),
api_url_(kApiUrl),
app_(app),
network_(new NetworkAccessManager(this)),
cache_(new ScrobblerCache(kCacheFile, this)),
enabled_(false),
subscriber_(false),
submitted_(false),
timestamp_(0) {
ReloadSettings();
LoadSession();

View File

@@ -62,17 +62,18 @@ const char *ListenBrainzScrobbler::kClientSecretB64 = "Uk9GZ2hrZVEzRjNvUHlFaHFpe
const char *ListenBrainzScrobbler::kCacheFile = "listenbrainzscrobbler.cache";
const int ListenBrainzScrobbler::kScrobblesPerRequest = 10;
ListenBrainzScrobbler::ListenBrainzScrobbler(Application *app, QObject *parent) : ScrobblerService(kName, app, parent),
app_(app),
network_(new NetworkAccessManager(this)),
cache_(new ScrobblerCache(kCacheFile, this)),
server_(nullptr),
enabled_(false),
expires_in_(-1),
login_time_(0),
submitted_(false),
scrobbled_(false),
timestamp_(0) {
ListenBrainzScrobbler::ListenBrainzScrobbler(Application *app, QObject *parent)
: ScrobblerService(kName, app, parent),
app_(app),
network_(new NetworkAccessManager(this)),
cache_(new ScrobblerCache(kCacheFile, this)),
server_(nullptr),
enabled_(false),
expires_in_(-1),
login_time_(0),
submitted_(false),
scrobbled_(false),
timestamp_(0) {
refresh_login_timer_.setSingleShot(true);
QObject::connect(&refresh_login_timer_, &QTimer::timeout, this, &ListenBrainzScrobbler::RequestNewAccessToken);
@@ -304,7 +305,7 @@ void ListenBrainzScrobbler::AuthenticateReplyFinished(QNetworkReply *reply) {
AuthError("Json document from server was empty.");
return;
}
if (json_obj.contains("error") && json_obj.contains("error_description")) {
QString failure_reason = json_obj["error_description"].toString();
AuthError(failure_reason);
@@ -412,7 +413,7 @@ QByteArray ListenBrainzScrobbler::GetReplyData(QNetworkReply *reply) {
}
return data;
}
void ListenBrainzScrobbler::UpdateNowPlaying(const Song &song) {

View File

@@ -46,11 +46,11 @@
using namespace std::chrono_literals;
ScrobblerCache::ScrobblerCache(const QString &filename, QObject *parent) :
QObject(parent),
timer_flush_(new QTimer(this)),
filename_(QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + "/" + filename),
loaded_(false) {
ScrobblerCache::ScrobblerCache(const QString &filename, QObject *parent)
: QObject(parent),
timer_flush_(new QTimer(this)),
filename_(QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + "/" + filename),
loaded_(false) {
ReadCache();
loaded_ = true;

View File

@@ -24,13 +24,13 @@
#include "scrobblercacheitem.h"
ScrobblerCacheItem::ScrobblerCacheItem(const QString &artist, const QString &album, const QString &song, const QString &albumartist, const int track, const qint64 duration, const quint64 timestamp, QObject *parent) :
QObject(parent),
artist_(artist),
album_(album),
song_(song),
albumartist_(albumartist),
track_(track),
duration_(duration),
timestamp_(timestamp),
sent_(false) {}
ScrobblerCacheItem::ScrobblerCacheItem(const QString &artist, const QString &album, const QString &song, const QString &albumartist, const int track, const qint64 duration, const quint64 timestamp, QObject *parent)
: QObject(parent),
artist_(artist),
album_(album),
song_(song),
albumartist_(albumartist),
track_(track),
duration_(duration),
timestamp_(timestamp),
sent_(false) {}

View File

@@ -64,22 +64,22 @@ const char *ScrobblingAPI20::kApiKey = "211990b4c96782c05d1536e7219eb56e";
const char *ScrobblingAPI20::kSecret = "80fd738f49596e9709b1bf9319c444a8";
const int ScrobblingAPI20::kScrobblesPerRequest = 50;
ScrobblingAPI20::ScrobblingAPI20(const QString &name, const QString &settings_group, const QString &auth_url, const QString &api_url, const bool batch, Application *app, QObject *parent) :
ScrobblerService(name, app, parent),
name_(name),
settings_group_(settings_group),
auth_url_(auth_url),
api_url_(api_url),
batch_(batch),
app_(app),
server_(nullptr),
enabled_(false),
https_(false),
prefer_albumartist_(false),
subscriber_(false),
submitted_(false),
scrobbled_(false),
timestamp_(0) {
ScrobblingAPI20::ScrobblingAPI20(const QString &name, const QString &settings_group, const QString &auth_url, const QString &api_url, const bool batch, Application *app, QObject *parent)
: ScrobblerService(name, app, parent),
name_(name),
settings_group_(settings_group),
auth_url_(auth_url),
api_url_(api_url),
batch_(batch),
app_(app),
server_(nullptr),
enabled_(false),
https_(false),
prefer_albumartist_(false),
subscriber_(false),
submitted_(false),
scrobbled_(false),
timestamp_(0) {
timer_submit_.setSingleShot(true);
QObject::connect(&timer_submit_, &QTimer::timeout, this, &ScrobblingAPI20::Submit);
@@ -301,13 +301,13 @@ void ScrobblingAPI20::AuthenticateReplyFinished(QNetworkReply *reply) {
}
return;
}
QJsonObject json_obj = ExtractJsonObj(data);
if (json_obj.isEmpty()) {
AuthError("Json document from server was empty.");
return;
}
if (json_obj.contains("error") && json_obj.contains("message")) {
int error = json_obj["error"].toInt();
QString message = json_obj["message"].toString();
@@ -339,7 +339,7 @@ void ScrobblingAPI20::AuthenticateReplyFinished(QNetworkReply *reply) {
subscriber_ = json_obj["subscriber"].toBool();
username_ = json_obj["name"].toString();
session_key_ = json_obj["key"].toString();
QSettings s;
s.beginGroup(settings_group_);
s.setValue("subscriber", subscriber_);

View File

@@ -52,7 +52,7 @@ class ScrobblingAPI20 : public ScrobblerService {
void ReloadSettings() override;
void LoadSession();
virtual NetworkAccessManager *network() const = 0;
virtual ScrobblerCache *cache() const = 0;

View File

@@ -41,11 +41,12 @@
const char *SubsonicScrobbler::kName = "Subsonic";
SubsonicScrobbler::SubsonicScrobbler(Application *app, QObject *parent) : ScrobblerService(kName, app, parent),
app_(app),
service_(app->internet_services()->Service<SubsonicService>()),
enabled_(false),
submitted_(false) {
SubsonicScrobbler::SubsonicScrobbler(Application *app, QObject *parent)
: ScrobblerService(kName, app, parent),
app_(app),
service_(app->internet_services()->Service<SubsonicService>()),
enabled_(false),
submitted_(false) {
timer_submit_.setSingleShot(true);
QObject::connect(&timer_submit_, &QTimer::timeout, this, &SubsonicScrobbler::Submit);