2009-12-26 16:13:38 +01:00
|
|
|
#ifndef LASTFMSERVICE_H
|
|
|
|
#define LASTFMSERVICE_H
|
|
|
|
|
|
|
|
#include "radioservice.h"
|
2009-12-29 20:22:02 +01:00
|
|
|
#include "song.h"
|
2009-12-26 16:13:38 +01:00
|
|
|
|
2009-12-26 22:35:45 +01:00
|
|
|
#include <lastfm/RadioTuner>
|
|
|
|
|
2009-12-30 00:01:07 +01:00
|
|
|
class QMenu;
|
|
|
|
|
2009-12-26 18:19:14 +01:00
|
|
|
class LastFMConfig;
|
|
|
|
|
2009-12-26 16:13:38 +01:00
|
|
|
class LastFMService : public RadioService {
|
2009-12-26 18:19:14 +01:00
|
|
|
Q_OBJECT
|
|
|
|
|
2009-12-26 16:13:38 +01:00
|
|
|
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;
|
2009-12-26 16:13:38 +01:00
|
|
|
|
|
|
|
enum ItemType {
|
|
|
|
Type_MyRecommendations = 1000,
|
|
|
|
Type_MyRadio,
|
|
|
|
Type_MyLoved,
|
|
|
|
Type_MyNeighbourhood,
|
2009-12-30 01:31:00 +01:00
|
|
|
Type_ArtistRadio,
|
|
|
|
Type_TagRadio,
|
|
|
|
Type_MyFriends,
|
|
|
|
Type_MyNeighbours,
|
2009-12-30 02:29:47 +01:00
|
|
|
Type_OtherUser,
|
|
|
|
Type_OtherUserRadio,
|
|
|
|
Type_OtherUserLoved,
|
|
|
|
Type_OtherUserNeighbourhood,
|
2009-12-26 16:13:38 +01:00
|
|
|
};
|
|
|
|
|
2009-12-26 22:35:45 +01:00
|
|
|
// RadioService
|
2009-12-26 16:13:38 +01:00
|
|
|
RadioItem* CreateRootItem(RadioItem* parent);
|
|
|
|
void LazyPopulate(RadioItem *item);
|
2009-12-30 00:17:54 +01:00
|
|
|
|
|
|
|
QUrl UrlForItem(const RadioItem* item) const;
|
|
|
|
QString TitleForItem(const RadioItem* item) const;
|
|
|
|
|
2009-12-30 00:01:07 +01:00
|
|
|
void ShowContextMenu(RadioItem *item, const QPoint &global_pos);
|
2009-12-30 00:17:54 +01:00
|
|
|
|
2009-12-26 22:35:45 +01:00
|
|
|
void StartLoading(const QUrl& url);
|
2009-12-26 23:59:11 +01:00
|
|
|
void LoadNext(const QUrl& url);
|
2009-12-30 00:17:54 +01:00
|
|
|
|
2009-12-29 17:12:08 +01:00
|
|
|
bool IsPauseAllowed() const { return false; }
|
|
|
|
bool ShowLastFmControls() const { return true; }
|
|
|
|
|
2009-12-30 00:17:54 +01:00
|
|
|
// Last.fm specific stuff
|
2009-12-29 20:22:02 +01:00
|
|
|
bool IsAuthenticated() const;
|
2009-12-29 21:48:50 +01:00
|
|
|
bool IsScrobblingEnabled() const { return scrobbling_enabled_; }
|
2009-12-26 18:19:14 +01:00
|
|
|
|
2009-12-30 01:31:00 +01:00
|
|
|
void Authenticate(const QString& username, const QString& password);
|
2009-12-29 21:48:50 +01:00
|
|
|
|
|
|
|
public slots:
|
2009-12-30 01:31:00 +01:00
|
|
|
void NowPlaying(const Song& song);
|
2009-12-29 21:11:03 +01:00
|
|
|
void Scrobble();
|
|
|
|
void Love();
|
|
|
|
void Ban();
|
2009-12-29 20:22:02 +01:00
|
|
|
|
2009-12-26 18:19:14 +01:00
|
|
|
signals:
|
|
|
|
void AuthenticationComplete(bool success);
|
2009-12-29 21:48:50 +01:00
|
|
|
void ScrobblingEnabledChanged(bool value);
|
2009-12-26 18:19:14 +01:00
|
|
|
|
|
|
|
private slots:
|
|
|
|
void AuthenticateReplyFinished();
|
2009-12-29 21:48:50 +01:00
|
|
|
void ScrobblingEnabledChangedSlot(bool value);
|
2009-12-30 01:31:00 +01:00
|
|
|
void RefreshFriendsFinished();
|
|
|
|
void RefreshNeighboursFinished();
|
2009-12-26 18:19:14 +01:00
|
|
|
|
2009-12-26 22:35:45 +01:00
|
|
|
void TunerTrackAvailable();
|
|
|
|
void TunerError(lastfm::ws::Error error);
|
|
|
|
|
2009-12-26 16:13:38 +01:00
|
|
|
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-30 01:31:00 +01:00
|
|
|
void RefreshFriends();
|
|
|
|
void RefreshNeighbours();
|
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-30 00:01:07 +01:00
|
|
|
QMenu* context_menu_;
|
|
|
|
|
2009-12-26 22:35:45 +01:00
|
|
|
QUrl last_url_;
|
2009-12-26 23:59:11 +01:00
|
|
|
bool initial_tune_;
|
2009-12-29 21:48:50 +01:00
|
|
|
|
|
|
|
bool scrobbling_enabled_;
|
2009-12-30 01:31:00 +01:00
|
|
|
|
|
|
|
RadioItem* friends_list_;
|
|
|
|
RadioItem* neighbours_list_;
|
2009-12-26 16:13:38 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // LASTFMSERVICE_H
|