1
/* This file is part of Clementine.
2
Copyright 2010, David Sansome <me@davidsansome.com>
4
Clementine is free software: you can redistribute it and/or modify
5
it under the terms of the GNU General Public License as published by
6
the Free Software Foundation, either version 3 of the License, or
7
(at your option) any later version.
9
Clementine is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
GNU General Public License for more details.
14
You should have received a copy of the GNU General Public License
15
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
18
#ifndef ALBUMCOVERFETCHER_H
19
#define ALBUMCOVERFETCHER_H
23
#include <QNetworkAccessManager>
27
#include <lastfm/Album>
29
#include <boost/scoped_ptr.hpp>
34
// This class searches for album covers for a given query or artist/album and
36
class AlbumCoverFetcher : public QObject {
40
AlbumCoverFetcher(QObject* parent = 0, QNetworkAccessManager* network = 0);
41
virtual ~AlbumCoverFetcher() {}
48
typedef QList<SearchResult> SearchResults;
50
static const int kMaxConcurrentRequests;
52
quint64 SearchForCovers(const QString& query);
53
quint64 FetchAlbumCover(const QString& artist, const QString& album);
58
void AlbumCoverFetched(quint64, const QImage& cover);
59
void SearchFinished(quint64, const AlbumCoverFetcher::SearchResults& results);
62
void AlbumSearchFinished();
63
void AlbumCoverFetchFinished();
67
struct QueuedRequest {
73
void AddRequest(const QueuedRequest req);
75
QNetworkAccessManager* network_;
78
QQueue<QueuedRequest> queued_requests_;
79
QMap<QNetworkReply*, QueuedRequest> active_requests_;
81
QTimer* request_starter_;
84
#endif // ALBUMCOVERFETCHER_H