Clementine-audio-player-Mac.../src/lastfmservice.h

75 lines
1.8 KiB
C
Raw Normal View History

#ifndef LASTFMSERVICE_H
#define LASTFMSERVICE_H
#include "radioservice.h"
2009-12-29 20:22:02 +01:00
#include "song.h"
2009-12-26 22:35:45 +01:00
#include <lastfm/RadioTuner>
2009-12-26 18:19:14 +01:00
class LastFMConfig;
class LastFMService : public RadioService {
2009-12-26 18:19:14 +01:00
Q_OBJECT
public:
LastFMService(QObject* parent = 0);
2009-12-26 18:19:14 +01:00
~LastFMService();
2009-12-29 20:22:02 +01:00
static const char* kServiceName;
2009-12-26 18:19:14 +01:00
static const char* kSettingsGroup;
2009-12-29 20:22:02 +01:00
static const char* kAudioscrobblerClientId;
static const char* kApiKey;
static const char* kSecret;
enum ItemType {
Type_MyRecommendations = 1000,
Type_MyRadio,
Type_MyLoved,
Type_MyNeighbourhood,
};
2009-12-26 22:35:45 +01:00
// RadioService
RadioItem* CreateRootItem(RadioItem* parent);
void LazyPopulate(RadioItem *item);
2009-12-26 23:15:57 +01:00
QList<RadioItem::PlaylistData> DataForItem(RadioItem* item);
2009-12-26 22:35:45 +01:00
void StartLoading(const QUrl& url);
void LoadNext(const QUrl& url);
2009-12-29 17:12:08 +01:00
bool IsPauseAllowed() const { return false; }
bool ShowLastFmControls() const { return true; }
2009-12-29 20:22:02 +01:00
bool IsAuthenticated() const;
2009-12-26 18:19:14 +01:00
void Authenticate(const QString& username, const QString& password);
2009-12-29 20:22:02 +01:00
void NowPlaying(const Song& song);
void Scrobble(const Song& song);
void Love(const Song& song);
void Ban(const Song& song);
2009-12-26 18:19:14 +01:00
signals:
void AuthenticationComplete(bool success);
private slots:
void AuthenticateReplyFinished();
2009-12-26 22:35:45 +01:00
void TunerTrackAvailable();
void TunerError(lastfm::ws::Error error);
private:
RadioItem* CreateStationItem(ItemType type, const QString& name,
const QString& icon, RadioItem* parent);
2009-12-26 22:35:45 +01:00
QString ErrorString(lastfm::ws::Error error) const;
2009-12-29 20:22:02 +01:00
bool InitScrobbler();
lastfm::Track TrackFromSong(const Song& song) const;
2009-12-26 18:19:14 +01:00
private:
2009-12-26 22:35:45 +01:00
lastfm::RadioTuner* tuner_;
2009-12-29 20:22:02 +01:00
lastfm::Audioscrobbler* scrobbler_;
lastfm::Track last_track_;
LastFMConfig* config_;
2009-12-26 22:35:45 +01:00
QUrl last_url_;
bool initial_tune_;
};
#endif // LASTFMSERVICE_H