2010-11-23 18:38:39 +01: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 JAMENDOSERVICE_H
|
|
|
|
#define JAMENDOSERVICE_H
|
|
|
|
|
|
|
|
#include "radioservice.h"
|
|
|
|
|
|
|
|
#include <QXmlStreamReader>
|
|
|
|
|
|
|
|
#include "core/song.h"
|
|
|
|
|
|
|
|
class LibraryBackend;
|
|
|
|
class LibraryFilterWidget;
|
|
|
|
class LibraryModel;
|
|
|
|
class NetworkAccessManager;
|
|
|
|
class QIODevice;
|
|
|
|
class QMenu;
|
|
|
|
class QSortFilterProxyModel;
|
|
|
|
|
|
|
|
class JamendoService : public RadioService {
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
JamendoService(RadioModel* parent);
|
|
|
|
~JamendoService();
|
|
|
|
|
|
|
|
RadioItem* CreateRootItem(RadioItem* parent);
|
|
|
|
void LazyPopulate(RadioItem* item);
|
|
|
|
|
2010-11-25 23:04:23 +01:00
|
|
|
void ShowContextMenu(RadioItem* item, const QModelIndex& index,
|
|
|
|
const QPoint& global_pos);
|
|
|
|
|
2010-11-23 18:38:39 +01:00
|
|
|
QWidget* HeaderWidget() const;
|
|
|
|
|
2010-11-27 20:11:36 +01:00
|
|
|
LibraryBackend* library_backend() const { return library_backend_; }
|
|
|
|
|
2010-11-23 18:38:39 +01:00
|
|
|
static const char* kServiceName;
|
|
|
|
static const char* kDirectoryUrl;
|
|
|
|
static const char* kMp3StreamUrl;
|
|
|
|
static const char* kOggStreamUrl;
|
|
|
|
static const char* kAlbumCoverUrl;
|
2010-11-25 23:16:29 +01:00
|
|
|
static const char* kAlbumInfoUrl;
|
|
|
|
static const char* kDownloadAlbumUrl;
|
2010-11-25 23:04:23 +01:00
|
|
|
static const char* kHomepage;
|
2010-11-23 18:38:39 +01:00
|
|
|
|
|
|
|
static const char* kSongsTable;
|
|
|
|
static const char* kFtsTable;
|
2010-11-27 17:14:09 +01:00
|
|
|
static const char* kTrackIdsTable;
|
|
|
|
static const char* kTrackIdsColumn;
|
2010-11-23 18:38:39 +01:00
|
|
|
|
|
|
|
static const char* kSettingsGroup;
|
|
|
|
|
2010-11-23 19:53:08 +01:00
|
|
|
static const int kBatchSize;
|
|
|
|
static const int kApproxDatabaseSize;
|
|
|
|
|
2010-11-23 18:38:39 +01:00
|
|
|
private:
|
2010-11-23 19:53:08 +01:00
|
|
|
void ParseDirectory(QIODevice* device) const;
|
2010-11-23 18:38:39 +01:00
|
|
|
|
2010-11-27 17:14:09 +01:00
|
|
|
typedef QList<int> TrackIdList;
|
|
|
|
|
|
|
|
SongList ReadArtist(QXmlStreamReader* reader, TrackIdList* track_ids) const;
|
|
|
|
SongList ReadAlbum(const QString& artist, QXmlStreamReader* reader,
|
|
|
|
TrackIdList* track_ids) const;
|
2010-11-23 18:38:39 +01:00
|
|
|
Song ReadTrack(const QString& artist,
|
|
|
|
const QString& album,
|
|
|
|
const QString& album_cover,
|
2010-11-25 23:16:29 +01:00
|
|
|
int album_id,
|
2010-11-27 17:14:09 +01:00
|
|
|
QXmlStreamReader* reader,
|
|
|
|
TrackIdList* track_ids) const;
|
|
|
|
void InsertTrackIds(const TrackIdList& ids) const;
|
2010-11-23 18:38:39 +01:00
|
|
|
|
|
|
|
void EnsureMenuCreated();
|
|
|
|
|
2010-12-04 16:49:43 +01:00
|
|
|
void AddSelectedToPlaylist(bool clear_first);
|
|
|
|
|
2010-11-23 18:38:39 +01:00
|
|
|
private slots:
|
2010-11-26 00:05:37 +01:00
|
|
|
void DownloadDirectory();
|
2010-11-23 19:53:08 +01:00
|
|
|
void DownloadDirectoryProgress(qint64 received, qint64 total);
|
2010-11-23 18:38:39 +01:00
|
|
|
void DownloadDirectoryFinished();
|
|
|
|
void ParseDirectoryFinished();
|
|
|
|
void UpdateTotalSongCount(int count);
|
|
|
|
|
2010-11-25 23:04:23 +01:00
|
|
|
void AddToPlaylist();
|
2010-12-04 16:49:43 +01:00
|
|
|
void LoadToPlaylist();
|
2010-11-25 23:04:23 +01:00
|
|
|
void AlbumInfo();
|
|
|
|
void DownloadAlbum();
|
|
|
|
void Homepage();
|
|
|
|
|
2010-11-23 18:38:39 +01:00
|
|
|
private:
|
|
|
|
NetworkAccessManager* network_;
|
|
|
|
RadioItem* root_;
|
|
|
|
|
2010-11-25 23:04:23 +01:00
|
|
|
QMenu* context_menu_;
|
|
|
|
QModelIndex context_item_;
|
|
|
|
|
|
|
|
QAction* add_to_playlist_;
|
2010-12-04 16:49:43 +01:00
|
|
|
QAction* load_to_playlist_;
|
2010-11-25 23:04:23 +01:00
|
|
|
QAction* album_info_;
|
|
|
|
QAction* download_album_;
|
|
|
|
|
2010-11-23 18:38:39 +01:00
|
|
|
LibraryBackend* library_backend_;
|
|
|
|
LibraryFilterWidget* library_filter_;
|
|
|
|
LibraryModel* library_model_;
|
|
|
|
QSortFilterProxyModel* library_sort_model_;
|
|
|
|
|
2010-11-23 19:53:08 +01:00
|
|
|
int load_database_task_id_;
|
|
|
|
|
2010-11-23 18:38:39 +01:00
|
|
|
int total_song_count_;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|