@@ -40,17 +40,19 @@
|
||||
#include <QJsonObject>
|
||||
#include <QJsonValue>
|
||||
|
||||
#include "acoustidclient.h"
|
||||
#include "core/logging.h"
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/networkaccessmanager.h"
|
||||
#include "core/networktimeouts.h"
|
||||
#include "core/logging.h"
|
||||
#include "utilities/timeconstants.h"
|
||||
|
||||
#include "acoustidclient.h"
|
||||
|
||||
const char *AcoustidClient::kClientId = "0qjUoxbowg";
|
||||
const char *AcoustidClient::kUrl = "https://api.acoustid.org/v2/lookup";
|
||||
const int AcoustidClient::kDefaultTimeout = 5000; // msec
|
||||
|
||||
AcoustidClient::AcoustidClient(NetworkAccessManager *network, QObject *parent)
|
||||
AcoustidClient::AcoustidClient(SharedPtr<NetworkAccessManager> network, QObject *parent)
|
||||
: QObject(parent),
|
||||
network_(network),
|
||||
timeouts_(new NetworkTimeouts(kDefaultTimeout, this)) {}
|
||||
|
||||
@@ -29,6 +29,8 @@
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
|
||||
class QNetworkReply;
|
||||
class NetworkAccessManager;
|
||||
class NetworkTimeouts;
|
||||
@@ -43,7 +45,7 @@ class AcoustidClient : public QObject {
|
||||
// IDs are provided by the caller when a request is started and included in the Finished signal - they have no meaning to AcoustidClient.
|
||||
|
||||
public:
|
||||
explicit AcoustidClient(NetworkAccessManager *network, QObject *parent = nullptr);
|
||||
explicit AcoustidClient(SharedPtr<NetworkAccessManager> network, QObject *parent = nullptr);
|
||||
~AcoustidClient() override;
|
||||
|
||||
// Network requests will be aborted after this interval.
|
||||
@@ -69,7 +71,7 @@ class AcoustidClient : public QObject {
|
||||
static const char *kUrl;
|
||||
static const int kDefaultTimeout;
|
||||
|
||||
NetworkAccessManager *network_;
|
||||
SharedPtr<NetworkAccessManager> network_;
|
||||
NetworkTimeouts *timeouts_;
|
||||
QMap<int, QNetworkReply*> requests_;
|
||||
};
|
||||
|
||||
@@ -43,6 +43,7 @@
|
||||
#include <QTimer>
|
||||
|
||||
#include "core/logging.h"
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/networkaccessmanager.h"
|
||||
#include "core/networktimeouts.h"
|
||||
#include "utilities/xmlutils.h"
|
||||
@@ -55,7 +56,7 @@ const int MusicBrainzClient::kRequestsDelay = 1200;
|
||||
const int MusicBrainzClient::kDefaultTimeout = 8000;
|
||||
const int MusicBrainzClient::kMaxRequestPerTrack = 3;
|
||||
|
||||
MusicBrainzClient::MusicBrainzClient(QNetworkAccessManager *network, QObject *parent)
|
||||
MusicBrainzClient::MusicBrainzClient(SharedPtr<NetworkAccessManager> network, QObject *parent)
|
||||
: QObject(parent),
|
||||
network_(network),
|
||||
timeouts_(new NetworkTimeouts(kDefaultTimeout, this)),
|
||||
|
||||
@@ -33,10 +33,12 @@
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
|
||||
class QNetworkAccessManager;
|
||||
#include "core/shared_ptr.h"
|
||||
|
||||
class QNetworkReply;
|
||||
class QTimer;
|
||||
class QXmlStreamReader;
|
||||
class NetworkAccessManager;
|
||||
class NetworkTimeouts;
|
||||
|
||||
class MusicBrainzClient : public QObject {
|
||||
@@ -50,7 +52,7 @@ class MusicBrainzClient : public QObject {
|
||||
public:
|
||||
// The second argument allows for specifying a custom network access manager.
|
||||
// It is used in tests. The ownership of network is not transferred.
|
||||
explicit MusicBrainzClient(QNetworkAccessManager *network, QObject *parent = nullptr);
|
||||
explicit MusicBrainzClient(SharedPtr<NetworkAccessManager> network, QObject *parent = nullptr);
|
||||
~MusicBrainzClient() override;
|
||||
|
||||
struct Result {
|
||||
@@ -208,7 +210,7 @@ class MusicBrainzClient : public QObject {
|
||||
static const int kDefaultTimeout;
|
||||
static const int kMaxRequestPerTrack;
|
||||
|
||||
QNetworkAccessManager *network_;
|
||||
SharedPtr<NetworkAccessManager> network_;
|
||||
NetworkTimeouts *timeouts_;
|
||||
QMultiMap<int, Request> requests_pending_;
|
||||
QMultiMap<int, QNetworkReply*> requests_;
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include <QFutureWatcher>
|
||||
#include <QString>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/networkaccessmanager.h"
|
||||
#include "utilities/timeconstants.h"
|
||||
#include "engine/chromaprinter.h"
|
||||
@@ -36,7 +37,7 @@
|
||||
#include "musicbrainzclient.h"
|
||||
#include "tagfetcher.h"
|
||||
|
||||
TagFetcher::TagFetcher(NetworkAccessManager *network, QObject *parent)
|
||||
TagFetcher::TagFetcher(SharedPtr<NetworkAccessManager> network, QObject *parent)
|
||||
: QObject(parent),
|
||||
fingerprint_watcher_(nullptr),
|
||||
acoustid_client_(new AcoustidClient(network, this)),
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/song.h"
|
||||
#include "musicbrainzclient.h"
|
||||
|
||||
@@ -41,7 +42,7 @@ class TagFetcher : public QObject {
|
||||
// High level interface to Fingerprinter, AcoustidClient and MusicBrainzClient.
|
||||
|
||||
public:
|
||||
explicit TagFetcher(NetworkAccessManager *network, QObject *parent = nullptr);
|
||||
explicit TagFetcher(SharedPtr<NetworkAccessManager> network, QObject *parent = nullptr);
|
||||
|
||||
void StartFetch(const SongList &songs);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user