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 LASTFMSERVICE_H
19
#define LASTFMSERVICE_H
27
uint qHash(const lastfm::Track& track);
29
#include "fixlastfm.h"
30
#include <lastfm/Track>
31
#include <lastfm/ws.h>
33
#include "radiomodel.h"
34
#include "radioservice.h"
35
#include "lastfmstationdialog.h"
36
#include "core/song.h"
37
#include "playlist/playlistitem.h"
43
#include <boost/scoped_ptr.hpp>
47
class QNetworkAccessManager;
49
class LastFMService : public RadioService {
53
LastFMService(RadioModel* parent);
56
static const char* kServiceName;
57
static const char* kSettingsGroup;
58
static const char* kAudioscrobblerClientId;
59
static const char* kApiKey;
60
static const char* kSecret;
62
static const char* kUrlArtist;
63
static const char* kUrlTag;
64
static const char* kUrlCustom;
66
static const char* kTitleArtist;
67
static const char* kTitleTag;
68
static const char* kTitleCustom;
71
Type_Root = RadioModel::TypeCount,
81
QStandardItem* CreateRootItem();
82
void LazyPopulate(QStandardItem* parent);
84
void ShowContextMenu(const QModelIndex& index, const QPoint &global_pos);
86
PlaylistItem::SpecialLoadResult StartLoading(const QUrl& url);
87
PlaylistItem::SpecialLoadResult LoadNext(const QUrl& url);
89
PlaylistItem::Options playlistitem_options() const;
91
void ReloadSettings();
93
virtual QString Icon() { return ":last.fm/lastfm.png"; }
95
// Last.fm specific stuff
96
bool IsAuthenticated() const;
97
bool IsScrobblingEnabled() const { return scrobbling_enabled_; }
98
bool AreButtonsVisible() const { return buttons_visible_; }
100
void Authenticate(const QString& username, const QString& password);
103
void FetchMoreTracks();
105
PlaylistItemPtr PlaylistItemForUrl(const QUrl& url);
108
void NowPlaying(const Song& song);
115
void AuthenticationComplete(bool success);
116
void ScrobblingEnabledChanged(bool value);
117
void ButtonVisibilityChanged(bool value);
120
QModelIndex GetCurrentIndex();
123
void AuthenticateReplyFinished();
124
void RefreshFriendsFinished();
125
void RefreshNeighboursFinished();
127
void TunerTrackAvailable();
128
void TunerError(lastfm::ws::Error error);
130
void AddArtistRadio();
132
void AddCustomRadio();
136
void FetchMoreTracksFinished();
139
void StreamMetadataReady();
142
QStandardItem* CreateStationItem(QStandardItem* parent,
143
const QString& name, const QString& icon, const QString& url,
144
const QString& title);
145
QString ErrorString(lastfm::ws::Error error) const;
146
bool InitScrobbler();
147
lastfm::Track TrackFromSong(const Song& song) const;
148
void RefreshFriends();
149
void RefreshNeighbours();
150
void AddArtistOrTag(const QString& name,
151
LastFMStationDialog::Type dialog_type,
152
const QString& url_pattern,
153
const QString& title_pattern,
154
const QString& icon, QStandardItem* list);
155
void SaveList(const QString& name, QStandardItem* list) const;
156
void RestoreList(const QString& name,
157
const QString& url_pattern,
158
const QString& title_pattern,
159
const QIcon& icon, QStandardItem* parent);
161
static QUrl FixupUrl(const QUrl& url);
162
void Tune(const lastfm::RadioStation& station);
164
void AddSelectedToPlaylist(bool clear_first);
167
lastfm::Audioscrobbler* scrobbler_;
168
lastfm::Track last_track_;
169
lastfm::Track next_metadata_;
170
QQueue<lastfm::Track> playlist_;
172
boost::scoped_ptr<LastFMStationDialog> station_dialog_;
174
boost::scoped_ptr<QMenu> context_menu_;
175
QAction* remove_action_;
176
QAction* add_artist_action_;
177
QAction* add_tag_action_;
178
QAction* add_custom_action_;
179
QStandardItem* context_item_;
185
bool scrobbling_enabled_;
186
bool buttons_visible_;
188
QStandardItem* artist_list_;
189
QStandardItem* tag_list_;
190
QStandardItem* custom_list_;
191
QStandardItem* friends_list_;
192
QStandardItem* neighbours_list_;
194
QHash<lastfm::Track, QString> art_urls_;
197
#endif // LASTFMSERVICE_H