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 MAGNATUNESERVICE_H
19
#define MAGNATUNESERVICE_H
21
#include <QXmlStreamReader>
23
#include "internetservice.h"
25
class QNetworkAccessManager;
26
class QSortFilterProxyModel;
31
class MagnatuneUrlHandler;
33
class MagnatuneService : public InternetService {
37
MagnatuneService(InternetModel* parent);
40
// Values are saved in QSettings and are indices into the combo box in
44
Membership_Streaming = 1,
45
Membership_Download = 2,
48
// Values are saved in QSettings and are indices into the combo box in
50
enum PreferredFormat {
58
static const char* kServiceName;
59
static const char* kSettingsGroup;
60
static const char* kDatabaseUrl;
61
static const char* kSongsTable;
62
static const char* kFtsTable;
63
static const char* kHomepage;
64
static const char* kStreamingHostname;
65
static const char* kDownloadHostname;
66
static const char* kPartnerId;
67
static const char* kDownloadUrl;
69
static QString ReadElementText(QXmlStreamReader& reader);
71
QStandardItem* CreateRootItem();
72
void LazyPopulate(QStandardItem* item);
74
void ShowContextMenu(const QModelIndex& index, const QPoint& global_pos);
76
QWidget* HeaderWidget() const;
78
void ReloadSettings();
80
// Magnatune specific stuff
81
MembershipType membership_type() const { return membership_; }
82
PreferredFormat preferred_format() const { return format_; }
83
QString username() const { return username_; }
84
QString password() const { return password_; }
85
LibraryBackend* library_backend() const { return library_backend_; }
87
QUrl ModifyUrl(const QUrl& url) const;
90
void DownloadFinished(const QStringList& albums);
93
QModelIndex GetCurrentIndex();
96
void UpdateTotalSongCount(int count);
97
void ReloadDatabase();
98
void ReloadDatabaseFinished();
105
void EnsureMenuCreated();
107
Song ReadTrack(QXmlStreamReader& reader);
110
MagnatuneUrlHandler* url_handler_;
112
QMenu* context_menu_;
113
QModelIndex context_item_;
114
QStandardItem* root_;
118
LibraryBackend* library_backend_;
119
LibraryModel* library_model_;
120
LibraryFilterWidget* library_filter_;
121
QSortFilterProxyModel* library_sort_model_;
122
int load_database_task_id_;
124
MembershipType membership_;
127
PreferredFormat format_;
129
int total_song_count_;
131
QNetworkAccessManager* network_;
134
#endif // MAGNATUNESERVICE_H