2011-08-29 00:59:18 +02:00
|
|
|
/* This file is part of Clementine.
|
|
|
|
Copyright 2010, David Sansome <me@davidsansome.com>
|
|
|
|
|
|
|
|
Clementine 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.
|
|
|
|
|
|
|
|
Clementine 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 Clementine. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef SPOTIFYSEARCHPROVIDER_H
|
|
|
|
#define SPOTIFYSEARCHPROVIDER_H
|
|
|
|
|
2016-12-20 15:16:42 +01:00
|
|
|
#include "internet/spotify/spotifyservice.h"
|
2011-08-29 00:59:18 +02:00
|
|
|
#include "searchprovider.h"
|
2012-01-08 00:26:27 +01:00
|
|
|
#include "spotifymessages.pb.h"
|
2011-08-29 00:59:18 +02:00
|
|
|
|
|
|
|
class SpotifyServer;
|
|
|
|
|
|
|
|
class SpotifySearchProvider : public SearchProvider {
|
|
|
|
Q_OBJECT
|
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
public:
|
2014-02-10 16:03:54 +01:00
|
|
|
SpotifySearchProvider(Application* app, QObject* parent = nullptr);
|
2011-08-29 00:59:18 +02:00
|
|
|
|
2016-12-20 15:16:42 +01:00
|
|
|
void SearchAsync(int id, const QString& query) override;
|
|
|
|
void LoadArtAsync(int id, const Result& result) override;
|
|
|
|
QStringList GetSuggestions(int count) override;
|
2011-08-29 00:59:18 +02:00
|
|
|
|
2014-12-03 22:27:43 +01:00
|
|
|
// SearchProvider
|
|
|
|
bool IsLoggedIn() override;
|
|
|
|
void ShowConfig() override;
|
|
|
|
InternetService* internet_service() override { return service_; }
|
2011-10-20 15:03:47 +02:00
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
private slots:
|
2011-08-29 00:59:18 +02:00
|
|
|
void ServerDestroyed();
|
2021-02-20 22:20:04 +01:00
|
|
|
void SearchFinishedSlot(const cpb::spotify::SearchResponse& response);
|
2011-08-29 00:59:18 +02:00
|
|
|
void ArtLoadedSlot(const QString& id, const QImage& image);
|
2021-02-20 22:20:04 +01:00
|
|
|
void SuggestionsLoaded(const cpb::spotify::LoadPlaylistResponse& response);
|
|
|
|
void SuggestionsLoaded(const cpb::spotify::BrowseToplistResponse& response);
|
2011-08-29 00:59:18 +02:00
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
private:
|
2011-08-29 00:59:18 +02:00
|
|
|
SpotifyServer* server();
|
|
|
|
|
2012-07-12 16:35:09 +02:00
|
|
|
void LoadSuggestions();
|
2021-02-20 22:20:04 +01:00
|
|
|
void AddSuggestionFromTrack(const cpb::spotify::Track& track);
|
|
|
|
void AddSuggestionFromAlbum(const cpb::spotify::Album& album);
|
2012-07-12 16:35:09 +02:00
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
private:
|
2011-08-29 00:59:18 +02:00
|
|
|
SpotifyServer* server_;
|
|
|
|
SpotifyService* service_;
|
|
|
|
|
|
|
|
QMap<QString, PendingState> queries_;
|
|
|
|
QMap<QString, int> pending_art_;
|
2011-08-29 04:26:59 +02:00
|
|
|
QMap<QString, int> pending_tracks_;
|
2012-07-12 16:35:09 +02:00
|
|
|
|
|
|
|
QSet<QString> suggestions_;
|
2011-08-29 00:59:18 +02:00
|
|
|
};
|
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
#endif // SPOTIFYSEARCHPROVIDER_H
|