@@ -19,8 +19,6 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <QtGlobal>
|
||||
#include <QObject>
|
||||
#include <QByteArray>
|
||||
|
||||
@@ -22,8 +22,6 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <QObject>
|
||||
#include <QList>
|
||||
#include <QSet>
|
||||
@@ -36,6 +34,7 @@
|
||||
#include <QSslError>
|
||||
#include <QJsonObject>
|
||||
|
||||
#include "core/scoped_ptr.h"
|
||||
#include "subsonicservice.h"
|
||||
#include "settings/subsonicsettingspage.h"
|
||||
|
||||
@@ -76,8 +75,7 @@ class SubsonicBaseRequest : public QObject {
|
||||
|
||||
private:
|
||||
SubsonicService *service_;
|
||||
std::unique_ptr<QNetworkAccessManager> network_;
|
||||
|
||||
ScopedPtr<QNetworkAccessManager> network_;
|
||||
};
|
||||
|
||||
#endif // SUBSONICBASEREQUEST_H
|
||||
|
||||
@@ -42,13 +42,13 @@
|
||||
#include <QSettings>
|
||||
#include <QSortFilterProxyModel>
|
||||
|
||||
#include "utilities/randutils.h"
|
||||
#include "core/logging.h"
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/application.h"
|
||||
#include "core/player.h"
|
||||
#include "core/logging.h"
|
||||
#include "core/networkaccessmanager.h"
|
||||
#include "core/database.h"
|
||||
#include "core/song.h"
|
||||
#include "utilities/randutils.h"
|
||||
#include "collection/collectionbackend.h"
|
||||
#include "collection/collectionmodel.h"
|
||||
#include "subsonicservice.h"
|
||||
@@ -57,8 +57,9 @@
|
||||
#include "subsonicscrobblerequest.h"
|
||||
#include "settings/settingsdialog.h"
|
||||
#include "settings/subsonicsettingspage.h"
|
||||
#include "scrobbler/audioscrobbler.h"
|
||||
#include "scrobbler/subsonicscrobbler.h"
|
||||
|
||||
using std::make_unique;
|
||||
using std::make_shared;
|
||||
|
||||
const Song::Source SubsonicService::kSource = Song::Source::Subsonic;
|
||||
const char *SubsonicService::kClientName = "Strawberry";
|
||||
@@ -84,7 +85,7 @@ SubsonicService::SubsonicService(Application *app, QObject *parent)
|
||||
|
||||
// Backend
|
||||
|
||||
collection_backend_ = new CollectionBackend();
|
||||
collection_backend_ = make_shared<CollectionBackend>();
|
||||
collection_backend_->moveToThread(app_->database()->thread());
|
||||
collection_backend_->Init(app_->database(), app->task_manager(), Song::Source::Subsonic, kSongsTable, kSongsFtsTable);
|
||||
|
||||
@@ -99,8 +100,6 @@ SubsonicService::SubsonicService(Application *app, QObject *parent)
|
||||
|
||||
SubsonicService::ReloadSettings();
|
||||
|
||||
app->scrobbler()->AddService(new SubsonicScrobbler(app->scrobbler(), this, this));
|
||||
|
||||
}
|
||||
|
||||
SubsonicService::~SubsonicService() {
|
||||
@@ -112,13 +111,11 @@ SubsonicService::~SubsonicService() {
|
||||
reply->deleteLater();
|
||||
}
|
||||
|
||||
collection_backend_->deleteLater();
|
||||
|
||||
}
|
||||
|
||||
void SubsonicService::Exit() {
|
||||
|
||||
QObject::connect(collection_backend_, &CollectionBackend::ExitFinished, this, &SubsonicService::ExitFinished);
|
||||
QObject::connect(&*collection_backend_, &CollectionBackend::ExitFinished, this, &SubsonicService::ExitFinished);
|
||||
collection_backend_->ExitAsync();
|
||||
|
||||
}
|
||||
@@ -154,7 +151,7 @@ void SubsonicService::SendPing() {
|
||||
void SubsonicService::SendPingWithCredentials(QUrl url, const QString &username, const QString &password, const SubsonicSettingsPage::AuthMethod auth_method, const bool redirect) {
|
||||
|
||||
if (!network_ || !redirect) {
|
||||
network_ = std::make_unique<QNetworkAccessManager>();
|
||||
network_ = make_unique<QNetworkAccessManager>();
|
||||
network_->setRedirectPolicy(QNetworkRequest::NoLessSafeRedirectPolicy);
|
||||
ping_redirects_ = 0;
|
||||
}
|
||||
@@ -413,8 +410,8 @@ void SubsonicService::Scrobble(const QString &song_id, const bool submission, co
|
||||
void SubsonicService::ResetSongsRequest() {
|
||||
|
||||
if (songs_request_) {
|
||||
QObject::disconnect(songs_request_.get(), nullptr, this, nullptr);
|
||||
QObject::disconnect(this, nullptr, songs_request_.get(), nullptr);
|
||||
QObject::disconnect(&*songs_request_, nullptr, this, nullptr);
|
||||
QObject::disconnect(this, nullptr, &*songs_request_, nullptr);
|
||||
songs_request_.reset();
|
||||
}
|
||||
|
||||
@@ -434,10 +431,10 @@ void SubsonicService::GetSongs() {
|
||||
|
||||
ResetSongsRequest();
|
||||
songs_request_.reset(new SubsonicRequest(this, url_handler_, app_), [](SubsonicRequest *request) { request->deleteLater(); });
|
||||
QObject::connect(songs_request_.get(), &SubsonicRequest::Results, this, &SubsonicService::SongsResultsReceived);
|
||||
QObject::connect(songs_request_.get(), &SubsonicRequest::UpdateStatus, this, &SubsonicService::SongsUpdateStatus);
|
||||
QObject::connect(songs_request_.get(), &SubsonicRequest::ProgressSetMaximum, this, &SubsonicService::SongsProgressSetMaximum);
|
||||
QObject::connect(songs_request_.get(), &SubsonicRequest::UpdateProgress, this, &SubsonicService::SongsUpdateProgress);
|
||||
QObject::connect(&*songs_request_, &SubsonicRequest::Results, this, &SubsonicService::SongsResultsReceived);
|
||||
QObject::connect(&*songs_request_, &SubsonicRequest::UpdateStatus, this, &SubsonicService::SongsUpdateStatus);
|
||||
QObject::connect(&*songs_request_, &SubsonicRequest::ProgressSetMaximum, this, &SubsonicService::SongsProgressSetMaximum);
|
||||
QObject::connect(&*songs_request_, &SubsonicRequest::UpdateProgress, this, &SubsonicService::SongsUpdateProgress);
|
||||
|
||||
songs_request_->GetAlbums();
|
||||
|
||||
|
||||
@@ -22,8 +22,6 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <QObject>
|
||||
#include <QPair>
|
||||
#include <QSet>
|
||||
@@ -38,6 +36,8 @@
|
||||
#include <QSslError>
|
||||
#include <QDateTime>
|
||||
|
||||
#include "core/scoped_ptr.h"
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/song.h"
|
||||
#include "internet/internetservice.h"
|
||||
#include "settings/subsonicsettingspage.h"
|
||||
@@ -56,7 +56,7 @@ class SubsonicService : public InternetService {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit SubsonicService(Application *app, QObject *parent);
|
||||
explicit SubsonicService(Application *app, QObject *parent = nullptr);
|
||||
~SubsonicService() override;
|
||||
|
||||
static const Song::Source kSource;
|
||||
@@ -76,11 +76,11 @@ class SubsonicService : public InternetService {
|
||||
bool download_album_covers() const { return download_album_covers_; }
|
||||
SubsonicSettingsPage::AuthMethod auth_method() const { return auth_method_; }
|
||||
|
||||
CollectionBackend *collection_backend() const { return collection_backend_; }
|
||||
SharedPtr<CollectionBackend> collection_backend() const { return collection_backend_; }
|
||||
CollectionModel *collection_model() const { return collection_model_; }
|
||||
QSortFilterProxyModel *collection_sort_model() const { return collection_sort_model_; }
|
||||
|
||||
CollectionBackend *songs_collection_backend() override { return collection_backend_; }
|
||||
SharedPtr<CollectionBackend> songs_collection_backend() override { return collection_backend_; }
|
||||
CollectionModel *songs_collection_model() override { return collection_model_; }
|
||||
QSortFilterProxyModel *songs_collection_sort_model() override { return collection_sort_model_; }
|
||||
|
||||
@@ -108,15 +108,15 @@ class SubsonicService : public InternetService {
|
||||
static const int kMaxRedirects;
|
||||
|
||||
Application *app_;
|
||||
std::unique_ptr<QNetworkAccessManager> network_;
|
||||
ScopedPtr<QNetworkAccessManager> network_;
|
||||
SubsonicUrlHandler *url_handler_;
|
||||
|
||||
CollectionBackend *collection_backend_;
|
||||
SharedPtr<CollectionBackend> collection_backend_;
|
||||
CollectionModel *collection_model_;
|
||||
QSortFilterProxyModel *collection_sort_model_;
|
||||
|
||||
std::shared_ptr<SubsonicRequest> songs_request_;
|
||||
std::shared_ptr<SubsonicScrobbleRequest> scrobble_request_;
|
||||
SharedPtr<SubsonicRequest> songs_request_;
|
||||
SharedPtr<SubsonicScrobbleRequest> scrobble_request_;
|
||||
|
||||
QUrl server_url_;
|
||||
QString username_;
|
||||
@@ -130,7 +130,8 @@ class SubsonicService : public InternetService {
|
||||
int ping_redirects_;
|
||||
|
||||
QList<QNetworkReply*> replies_;
|
||||
|
||||
};
|
||||
|
||||
using SubsonicServicePtr = SharedPtr<SubsonicService>;
|
||||
|
||||
#endif // SUBSONICSERVICE_H
|
||||
|
||||
Reference in New Issue
Block a user