2010-05-08 22:56:39 +02:00
|
|
|
/* This file is part of Clementine.
|
2010-11-20 14:27:10 +01:00
|
|
|
Copyright 2010, David Sansome <me@davidsansome.com>
|
2010-05-08 22:56:39 +02:00
|
|
|
|
|
|
|
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 MAGNATUNESERVICE_H
|
|
|
|
#define MAGNATUNESERVICE_H
|
|
|
|
|
|
|
|
#include <QXmlStreamReader>
|
|
|
|
|
2011-07-15 15:27:50 +02:00
|
|
|
#include "internetservice.h"
|
2010-05-08 22:56:39 +02:00
|
|
|
|
|
|
|
class QNetworkAccessManager;
|
2010-05-09 18:53:35 +02:00
|
|
|
class QSortFilterProxyModel;
|
2010-05-10 23:50:31 +02:00
|
|
|
class QMenu;
|
2010-05-08 22:56:39 +02:00
|
|
|
|
2010-05-09 17:51:04 +02:00
|
|
|
class LibraryBackend;
|
|
|
|
class LibraryModel;
|
2011-04-28 17:10:28 +02:00
|
|
|
class MagnatuneUrlHandler;
|
2010-05-09 17:51:04 +02:00
|
|
|
|
2011-07-15 15:27:50 +02:00
|
|
|
class MagnatuneService : public InternetService {
|
2010-05-08 22:56:39 +02:00
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2012-02-12 14:41:50 +01:00
|
|
|
MagnatuneService(Application* app, InternetModel* parent);
|
2010-05-09 20:36:10 +02:00
|
|
|
~MagnatuneService();
|
2010-05-08 22:56:39 +02:00
|
|
|
|
2010-06-09 01:18:20 +02:00
|
|
|
// Values are saved in QSettings and are indices into the combo box in
|
|
|
|
// MagnatuneConfig
|
2010-06-09 00:56:31 +02:00
|
|
|
enum MembershipType {
|
|
|
|
Membership_None = 0,
|
|
|
|
Membership_Streaming = 1,
|
|
|
|
Membership_Download = 2,
|
|
|
|
};
|
|
|
|
|
2010-06-09 01:18:20 +02:00
|
|
|
// Values are saved in QSettings and are indices into the combo box in
|
|
|
|
// MagnatuneConfig
|
|
|
|
enum PreferredFormat {
|
|
|
|
Format_Ogg = 0,
|
|
|
|
Format_Flac = 1,
|
|
|
|
Format_Wav = 2,
|
|
|
|
Format_MP3_VBR = 3,
|
|
|
|
Format_MP3_128 = 4,
|
|
|
|
};
|
|
|
|
|
2010-05-08 22:56:39 +02:00
|
|
|
static const char* kServiceName;
|
2010-05-09 22:18:05 +02:00
|
|
|
static const char* kSettingsGroup;
|
2010-05-08 22:56:39 +02:00
|
|
|
static const char* kDatabaseUrl;
|
2010-05-09 19:19:48 +02:00
|
|
|
static const char* kSongsTable;
|
2010-06-20 18:30:10 +02:00
|
|
|
static const char* kFtsTable;
|
2010-05-09 20:36:10 +02:00
|
|
|
static const char* kHomepage;
|
2010-06-09 00:56:31 +02:00
|
|
|
static const char* kStreamingHostname;
|
|
|
|
static const char* kDownloadHostname;
|
2010-06-09 16:02:26 +02:00
|
|
|
static const char* kPartnerId;
|
|
|
|
static const char* kDownloadUrl;
|
|
|
|
|
|
|
|
static QString ReadElementText(QXmlStreamReader& reader);
|
2010-05-08 22:56:39 +02:00
|
|
|
|
2011-01-09 19:27:41 +01:00
|
|
|
QStandardItem* CreateRootItem();
|
|
|
|
void LazyPopulate(QStandardItem* item);
|
2010-05-08 22:56:39 +02:00
|
|
|
|
2012-03-11 15:44:43 +01:00
|
|
|
void ShowContextMenu(const QPoint& global_pos);
|
2010-05-09 19:53:27 +02:00
|
|
|
|
2010-06-09 17:38:00 +02:00
|
|
|
QWidget* HeaderWidget() const;
|
2010-05-09 22:18:05 +02:00
|
|
|
|
2010-06-09 00:56:31 +02:00
|
|
|
void ReloadSettings();
|
|
|
|
|
|
|
|
// Magnatune specific stuff
|
|
|
|
MembershipType membership_type() const { return membership_; }
|
2010-06-09 16:02:26 +02:00
|
|
|
PreferredFormat preferred_format() const { return format_; }
|
|
|
|
QString username() const { return username_; }
|
|
|
|
QString password() const { return password_; }
|
2010-11-27 20:11:36 +01:00
|
|
|
LibraryBackend* library_backend() const { return library_backend_; }
|
2010-06-09 16:02:26 +02:00
|
|
|
|
2010-06-09 00:56:31 +02:00
|
|
|
QUrl ModifyUrl(const QUrl& url) const;
|
|
|
|
|
2010-06-12 22:43:07 +02:00
|
|
|
signals:
|
|
|
|
void DownloadFinished(const QStringList& albums);
|
|
|
|
|
2010-05-08 22:56:39 +02:00
|
|
|
private slots:
|
2010-12-11 16:07:39 +01:00
|
|
|
void UpdateTotalSongCount(int count);
|
2010-05-08 22:56:39 +02:00
|
|
|
void ReloadDatabase();
|
|
|
|
void ReloadDatabaseFinished();
|
|
|
|
|
2010-06-09 16:02:26 +02:00
|
|
|
void Download();
|
2010-05-09 20:36:10 +02:00
|
|
|
void Homepage();
|
2010-06-09 16:02:26 +02:00
|
|
|
void ShowConfig();
|
2010-05-09 20:36:10 +02:00
|
|
|
|
2010-05-08 22:56:39 +02:00
|
|
|
private:
|
2010-08-27 17:20:52 +02:00
|
|
|
void EnsureMenuCreated();
|
|
|
|
|
2010-05-09 18:53:35 +02:00
|
|
|
Song ReadTrack(QXmlStreamReader& reader);
|
2010-05-08 22:56:39 +02:00
|
|
|
|
|
|
|
private:
|
2011-04-28 17:10:28 +02:00
|
|
|
MagnatuneUrlHandler* url_handler_;
|
|
|
|
|
2010-05-09 20:36:10 +02:00
|
|
|
QMenu* context_menu_;
|
2011-01-09 19:27:41 +01:00
|
|
|
QStandardItem* root_;
|
2010-05-09 20:36:10 +02:00
|
|
|
|
2010-06-09 16:02:26 +02:00
|
|
|
QAction* download_;
|
2010-05-09 20:36:10 +02:00
|
|
|
|
2010-05-09 17:51:04 +02:00
|
|
|
LibraryBackend* library_backend_;
|
|
|
|
LibraryModel* library_model_;
|
2010-06-09 17:38:00 +02:00
|
|
|
LibraryFilterWidget* library_filter_;
|
2010-05-09 18:53:35 +02:00
|
|
|
QSortFilterProxyModel* library_sort_model_;
|
2010-06-23 15:21:30 +02:00
|
|
|
int load_database_task_id_;
|
2010-05-09 18:53:35 +02:00
|
|
|
|
2010-06-09 00:56:31 +02:00
|
|
|
MembershipType membership_;
|
|
|
|
QString username_;
|
|
|
|
QString password_;
|
2010-06-09 01:18:20 +02:00
|
|
|
PreferredFormat format_;
|
2010-06-09 00:56:31 +02:00
|
|
|
|
2010-05-09 18:53:35 +02:00
|
|
|
int total_song_count_;
|
2010-05-08 22:56:39 +02:00
|
|
|
|
|
|
|
QNetworkAccessManager* network_;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // MAGNATUNESERVICE_H
|