Clementine-audio-player-Mac.../src/globalsearch/spotifysearchprovider.h

68 lines
2.1 KiB
C
Raw Normal View History

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"
#include "spotifymessages.pb.h"
2011-08-29 00:59:18 +02:00
class SpotifyServer;
class SpotifySearchProvider : public SearchProvider {
Q_OBJECT
public:
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
// SearchProvider
bool IsLoggedIn() override;
void ShowConfig() override;
InternetService* internet_service() override { return service_; }
private slots:
2011-08-29 00:59:18 +02:00
void ServerDestroyed();
void SearchFinishedSlot(const cpb::spotify::SearchResponse& response);
2011-08-29 00:59:18 +02:00
void ArtLoadedSlot(const QString& id, const QImage& image);
void SuggestionsLoaded(const cpb::spotify::LoadPlaylistResponse& response);
void SuggestionsLoaded(const cpb::spotify::BrowseToplistResponse& response);
2011-08-29 00:59:18 +02:00
private:
2011-08-29 00:59:18 +02:00
SpotifyServer* server();
void LoadSuggestions();
void AddSuggestionFromTrack(const cpb::spotify::Track& track);
void AddSuggestionFromAlbum(const cpb::spotify::Album& album);
private:
2011-08-29 00:59:18 +02:00
SpotifyServer* server_;
SpotifyService* service_;
QMap<QString, PendingState> queries_;
QMap<QString, int> pending_art_;
QMap<QString, int> pending_tracks_;
QSet<QString> suggestions_;
2011-08-29 00:59:18 +02:00
};
#endif // SPOTIFYSEARCHPROVIDER_H