diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d50a6bbe6..e8b8f6e24 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -133,7 +133,6 @@ set(SOURCES globalsearch/tooltipresultwidget.cpp internet/digitallyimportedclient.cpp - internet/digitallyimportedservice.cpp internet/digitallyimportedservicebase.cpp internet/digitallyimportedsettingspage.cpp internet/digitallyimportedurlhandler.cpp @@ -159,7 +158,6 @@ set(SOURCES internet/magnatuneservice.cpp internet/magnatuneurlhandler.cpp internet/savedradio.cpp - internet/skyfmservice.cpp internet/somafmservice.cpp internet/somafmurlhandler.cpp @@ -403,7 +401,6 @@ set(HEADERS internet/magnatunesettingspage.h internet/magnatuneservice.h internet/savedradio.h - internet/skyfmservice.h internet/somafmservice.h internet/somafmurlhandler.h diff --git a/src/globalsearch/digitallyimportedsearchprovider.cpp b/src/globalsearch/digitallyimportedsearchprovider.cpp index c78cfe812..3c51567f8 100644 --- a/src/globalsearch/digitallyimportedsearchprovider.cpp +++ b/src/globalsearch/digitallyimportedsearchprovider.cpp @@ -24,7 +24,7 @@ DigitallyImportedSearchProvider::DigitallyImportedSearchProvider( : SimpleSearchProvider(parent), service_(service) { - Init(service_->name(), service->url_scheme(), service_->icon(), + Init(service_->name(), service->api_service_name(), service_->icon(), ArtIsInSongMetadata); set_safe_words(QStringList() << "sky.fm" << "skyfm" << "di.fm" << "difm" diff --git a/src/internet/digitallyimportedservice.cpp b/src/internet/digitallyimportedservice.cpp deleted file mode 100644 index 5b25fe892..000000000 --- a/src/internet/digitallyimportedservice.cpp +++ /dev/null @@ -1,32 +0,0 @@ -/* This file is part of Clementine. - Copyright 2010, David Sansome - - 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 . -*/ - -#include "digitallyimportedservice.h" -#include "core/logging.h" - -#include -#include -#include - -DigitallyImportedService::DigitallyImportedService(InternetModel* model, QObject* parent) - : DigitallyImportedServiceBase("DigitallyImported", model, parent) -{ - Init("Digitally Imported", QUrl("http://www.di.fm"), - "di.fm", QUrl("http://listen.di.fm"), "digitallyimported", - ":/providers/digitallyimported.png", "di"); -} - diff --git a/src/internet/digitallyimportedservice.h b/src/internet/digitallyimportedservice.h deleted file mode 100644 index b87e289e8..000000000 --- a/src/internet/digitallyimportedservice.h +++ /dev/null @@ -1,28 +0,0 @@ -/* This file is part of Clementine. - Copyright 2010, David Sansome - - 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 . -*/ - -#ifndef DIGITALLYIMPORTEDSERVICE_H -#define DIGITALLYIMPORTEDSERVICE_H - -#include "digitallyimportedservicebase.h" - -class DigitallyImportedService : public DigitallyImportedServiceBase { -public: - DigitallyImportedService(InternetModel* model, QObject* parent = NULL); -}; - -#endif // DIGITALLYIMPORTEDSERVICE_H diff --git a/src/internet/digitallyimportedservicebase.cpp b/src/internet/digitallyimportedservicebase.cpp index b91a75eec..95db1484f 100644 --- a/src/internet/digitallyimportedservicebase.cpp +++ b/src/internet/digitallyimportedservicebase.cpp @@ -39,47 +39,39 @@ const int DigitallyImportedServiceBase::kStreamsCacheDurationSecs = DigitallyImportedServiceBase::DigitallyImportedServiceBase( - const QString& name, InternetModel* model, QObject* parent) + const QString& name, + const QString& description, + const QUrl& homepage_url, + const QIcon& icon, + const QString& api_service_name, + InternetModel* model, QObject* parent) : InternetService(name, model, parent), + homepage_url_(homepage_url), + icon_(icon), + service_description_(description), + api_service_name_(api_service_name), network_(new NetworkAccessManager(this)), url_handler_(new DigitallyImportedUrlHandler(this)), basic_audio_type_(1), premium_audio_type_(2), root_(NULL), context_item_(NULL), - api_client_(NULL) + api_client_(new DigitallyImportedClient(api_service_name, this)) { + model->player()->RegisterUrlHandler(url_handler_); + model->global_search()->AddProvider(new DigitallyImportedSearchProvider(this, this)); + basic_playlists_ - << "http://listen.%1/public3/%2.pls" - << "http://listen.%1/public1/%2.pls" - << "http://listen.%1/public5/%2.asx"; + << "http://%1/public3/%2.pls" + << "http://%1/public1/%2.pls" + << "http://%1/public5/%2.asx"; premium_playlists_ - << "http://listen.%1/premium_high/%2.pls?hash=%3" - << "http://listen.%1/premium_medium/%2.pls?hash=%3" - << "http://listen.%1/premium/%2.pls?hash=%3" - << "http://listen.%1/premium_wma_low/%2.asx?hash=%3" - << "http://listen.%1/premium_wma/%2.asx?hash=%3"; -} - -void DigitallyImportedServiceBase::Init( - const QString& description, const QUrl& homepage_url, - const QString& homepage_name, const QUrl& stream_list_url, - const QString& url_scheme, const QString& icon_path, - const QString& api_service_name) { - service_description_ = description; - homepage_url_ = homepage_url; - homepage_name_ = homepage_name; - stream_list_url_ = stream_list_url; - url_scheme_ = url_scheme; - icon_path_ = icon_path; - api_service_name_ = api_service_name; - icon_ = QIcon(icon_path_); - - model()->player()->RegisterUrlHandler(url_handler_); - model()->global_search()->AddProvider(new DigitallyImportedSearchProvider(this, this)); - - api_client_ = new DigitallyImportedClient(api_service_name, this); + << "http://%1/premium_high/%2.pls?hash=%3" + << "http://%1/premium_medium/%2.pls?hash=%3" + << "http://%1/premium/%2.pls?hash=%3" + << "http://%1/premium_wma_low/%2.asx?hash=%3" + << "http://%1/premium_wma/%2.asx?hash=%3"; } DigitallyImportedServiceBase::~DigitallyImportedServiceBase() { @@ -153,7 +145,7 @@ void DigitallyImportedServiceBase::SongFromChannel( const DigitallyImportedClient::Channel& channel, Song* song) const { song->set_title(channel.name_); song->set_artist(service_description_ + " - " + channel.director_); - song->set_url(QUrl(url_scheme_ + "://" + channel.key_)); + song->set_url(QUrl(api_service_name_ + "://" + channel.key_)); song->set_art_automatic(channel.art_url_.toString()); } @@ -169,7 +161,7 @@ void DigitallyImportedServiceBase::ReloadSettings() { premium_audio_type_ = s.value("premium_audio_type", 2).toInt(); username_ = s.value("username").toString(); listen_hash_ = s.value("listen_hash").toString(); - last_refreshed_channels_ = s.value("last_refreshed_v2_" + url_scheme_).toDateTime(); + last_refreshed_channels_ = s.value("last_refreshed_" + api_service_name_).toDateTime(); saved_channels_ = LoadChannels(); } @@ -179,7 +171,7 @@ void DigitallyImportedServiceBase::ShowContextMenu( context_menu_.reset(new QMenu); context_menu_->addActions(GetPlaylistActions()); context_menu_->addAction(IconLoader::Load("download"), - tr("Open %1 in browser").arg(homepage_name_), + tr("Open %1 in browser").arg(homepage_url_.host()), this, SLOT(Homepage())); context_menu_->addAction(IconLoader::Load("view-refresh"), tr("Refresh streams"), @@ -224,7 +216,7 @@ DigitallyImportedClient::ChannelList DigitallyImportedServiceBase::LoadChannels( QSettings s; s.beginGroup(kSettingsGroup); - int count = s.beginReadArray(url_scheme_); + int count = s.beginReadArray(api_service_name_); for (int i=0 ; iindex(); } + + +DigitallyImportedService::DigitallyImportedService(InternetModel* model, QObject* parent) + : DigitallyImportedServiceBase("DigitallyImported", + "Digitally Imported", + QUrl("http://www.di.fm"), + QIcon(":/providers/digitallyimported.png"), + "di", + model, parent) +{ +} + +SkyFmService::SkyFmService(InternetModel* model, QObject* parent) + : DigitallyImportedServiceBase("SKY.fm", + "SKY.fm", + QUrl("http://www.sky.fm"), + QIcon(":/providers/skyfm.png"), + "sky", + model, parent) +{ +} diff --git a/src/internet/digitallyimportedservicebase.h b/src/internet/digitallyimportedservicebase.h index eac9be9fa..0a8a4d33e 100644 --- a/src/internet/digitallyimportedservicebase.h +++ b/src/internet/digitallyimportedservicebase.h @@ -34,7 +34,12 @@ class DigitallyImportedServiceBase : public InternetService { friend class DigitallyImportedUrlHandler; public: - DigitallyImportedServiceBase(const QString& name, InternetModel* model, + DigitallyImportedServiceBase(const QString& name, + const QString& description, + const QUrl& homepage_url, + const QIcon& icon, + const QString& api_service_name, + InternetModel* model, QObject* parent = NULL); ~DigitallyImportedServiceBase(); @@ -50,12 +55,8 @@ public: bool is_premium_account() const; const QUrl& homepage_url() const { return homepage_url_; } - const QString& homepage_name() const { return homepage_name_; } - const QUrl& stream_list_url() const { return stream_list_url_; } - const QString& icon_path() const { return icon_path_; } const QIcon& icon() const { return icon_; } const QString& service_description() const { return service_description_; } - const QString& url_scheme() const { return url_scheme_; } const QString& api_service_name() const { return api_service_name_; } bool IsChannelListStale() const; @@ -67,18 +68,10 @@ signals: void StreamsChanged(); protected: - // Subclasses must call this from their constructor - void Init(const QString& description, const QUrl& homepage_url, - const QString& homepage_name, const QUrl& stream_list_url, - const QString& url_scheme, const QString& icon_path, - const QString& api_service_name); - QModelIndex GetCurrentIndex(); -protected slots: - void LoadPlaylistFinished(); - private slots: + void LoadPlaylistFinished(); void Homepage(); void ForceRefreshStreams(); void RefreshStreams(); @@ -95,12 +88,8 @@ private: private: // Set by subclasses through the constructor QUrl homepage_url_; - QString homepage_name_; - QUrl stream_list_url_; - QString icon_path_; QIcon icon_; QString service_description_; - QString url_scheme_; QString api_service_name_; QStringList basic_playlists_; @@ -125,4 +114,14 @@ private: DigitallyImportedClient* api_client_; }; +class DigitallyImportedService : public DigitallyImportedServiceBase { +public: + DigitallyImportedService(InternetModel* model, QObject* parent = NULL); +}; + +class SkyFmService : public DigitallyImportedServiceBase { +public: + SkyFmService(InternetModel* model, QObject* parent = NULL); +}; + #endif // DIGITALLYIMPORTEDSERVICEBASE_H diff --git a/src/internet/digitallyimportedurlhandler.cpp b/src/internet/digitallyimportedurlhandler.cpp index e5e55ba39..ff16e60e2 100644 --- a/src/internet/digitallyimportedurlhandler.cpp +++ b/src/internet/digitallyimportedurlhandler.cpp @@ -30,7 +30,7 @@ DigitallyImportedUrlHandler::DigitallyImportedUrlHandler(DigitallyImportedServic } QString DigitallyImportedUrlHandler::scheme() const { - return service_->url_scheme_; + return service_->api_service_name(); } UrlHandler::LoadResult DigitallyImportedUrlHandler::StartLoading(const QUrl& url) { diff --git a/src/internet/internetmodel.cpp b/src/internet/internetmodel.cpp index c75921c43..2f48befd6 100644 --- a/src/internet/internetmodel.cpp +++ b/src/internet/internetmodel.cpp @@ -15,7 +15,7 @@ along with Clementine. If not, see . */ -#include "digitallyimportedservice.h" +#include "digitallyimportedservicebase.h" #include "icecastservice.h" #include "jamendoservice.h" #include "magnatuneservice.h" @@ -23,7 +23,6 @@ #include "internetmodel.h" #include "internetservice.h" #include "savedradio.h" -#include "skyfmservice.h" #include "somafmservice.h" #include "groovesharkservice.h" #include "core/logging.h" @@ -66,6 +65,7 @@ InternetModel::InternetModel(BackgroundThread* db_thread, #ifdef HAVE_LIBLASTFM AddService(new LastFMService(this)); #endif + AddService(new GroovesharkService(this)); AddService(new MagnatuneService(this)); AddService(new SavedRadio(this)); AddService(new SkyFmService(this)); @@ -73,7 +73,6 @@ InternetModel::InternetModel(BackgroundThread* db_thread, #ifdef HAVE_SPOTIFY AddService(new SpotifyService(this)); #endif - AddService(new GroovesharkService(this)); } void InternetModel::AddService(InternetService *service) { diff --git a/src/internet/skyfmservice.cpp b/src/internet/skyfmservice.cpp deleted file mode 100644 index 6f05734cb..000000000 --- a/src/internet/skyfmservice.cpp +++ /dev/null @@ -1,33 +0,0 @@ -/* This file is part of Clementine. - Copyright 2010, David Sansome - - 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 . -*/ - -#include "digitallyimportedurlhandler.h" -#include "internetmodel.h" -#include "skyfmservice.h" -#include "core/logging.h" -#include "core/taskmanager.h" - -#include -#include - -SkyFmService::SkyFmService(InternetModel* model, QObject* parent) - : DigitallyImportedServiceBase( - "SKY.fm", model, parent) -{ - Init("SKY.fm", QUrl("http://www.sky.fm"), "sky.fm", - QUrl("http://listen.sky.fm"), "skyfm", ":/providers/skyfm.png", "sky"); -} diff --git a/src/internet/skyfmservice.h b/src/internet/skyfmservice.h deleted file mode 100644 index 573f8b9d3..000000000 --- a/src/internet/skyfmservice.h +++ /dev/null @@ -1,28 +0,0 @@ -/* This file is part of Clementine. - Copyright 2010, David Sansome - - 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 . -*/ - -#ifndef SKYFMSERVICE_H -#define SKYFMSERVICE_H - -#include "digitallyimportedservicebase.h" - -class SkyFmService : public DigitallyImportedServiceBase { -public: - SkyFmService(InternetModel* model, QObject* parent = NULL); -}; - -#endif // SKYFMSERVICE_H diff --git a/src/translations/translations.pot b/src/translations/translations.pot index 776001564..1009594ee 100644 --- a/src/translations/translations.pot +++ b/src/translations/translations.pot @@ -1003,7 +1003,7 @@ msgstr "" msgid "Configure library..." msgstr "" -#: internet/digitallyimportedservicebase.cpp:189 +#: internet/digitallyimportedservicebase.cpp:181 #: ../bin/src/ui_globalsearchsettingspage.h:167 msgid "Configure..." msgstr "" @@ -1593,7 +1593,7 @@ msgstr "" msgid "Error loading %1" msgstr "" -#: internet/digitallyimportedservicebase.cpp:211 +#: internet/digitallyimportedservicebase.cpp:203 #: internet/digitallyimportedurlhandler.cpp:73 msgid "Error loading di.fm playlist" msgstr "" @@ -1854,7 +1854,7 @@ msgstr "" msgid "Getting channels" msgstr "" -#: internet/digitallyimportedservicebase.cpp:111 +#: internet/digitallyimportedservicebase.cpp:103 msgid "Getting streams" msgstr "" @@ -2736,7 +2736,7 @@ msgstr "" msgid "Only show the first" msgstr "" -#: internet/digitallyimportedservicebase.cpp:182 +#: internet/digitallyimportedservicebase.cpp:174 #, qt-format msgid "Open %1 in browser" msgstr "" @@ -3146,7 +3146,7 @@ msgstr "" msgid "Refresh station list" msgstr "" -#: internet/digitallyimportedservicebase.cpp:185 +#: internet/digitallyimportedservicebase.cpp:177 msgid "Refresh streams" msgstr ""