Add Radio GFM
This commit is contained in:
parent
4447467570
commit
264d5ee0fa
@ -292,6 +292,7 @@
|
|||||||
<file>providers/myspace.png</file>
|
<file>providers/myspace.png</file>
|
||||||
<file>providers/podcast16.png</file>
|
<file>providers/podcast16.png</file>
|
||||||
<file>providers/podcast32.png</file>
|
<file>providers/podcast32.png</file>
|
||||||
|
<file>providers/radiogfm.png</file>
|
||||||
<file>providers/rockradio.png</file>
|
<file>providers/rockradio.png</file>
|
||||||
<file>providers/skydrive.png</file>
|
<file>providers/skydrive.png</file>
|
||||||
<file>providers/skyfm.png</file>
|
<file>providers/skyfm.png</file>
|
||||||
|
BIN
data/providers/radiogfm.png
Normal file
BIN
data/providers/radiogfm.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 744 B |
@ -32,7 +32,7 @@ public:
|
|||||||
|
|
||||||
typedef QList<T> ListType;
|
typedef QList<T> ListType;
|
||||||
|
|
||||||
CachedList(const char* settings_group, const QString& name,
|
CachedList(const QString& settings_group, const QString& name,
|
||||||
int cache_duration_secs)
|
int cache_duration_secs)
|
||||||
: settings_group_(settings_group),
|
: settings_group_(settings_group),
|
||||||
name_(name),
|
name_(name),
|
||||||
@ -92,7 +92,7 @@ public:
|
|||||||
const_iterator end() const { return data_.end(); }
|
const_iterator end() const { return data_.end(); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const char* settings_group_;
|
const QString settings_group_;
|
||||||
const QString name_;
|
const QString name_;
|
||||||
const int cache_duration_secs_;
|
const int cache_duration_secs_;
|
||||||
|
|
||||||
|
@ -18,14 +18,16 @@
|
|||||||
#include "somafmsearchprovider.h"
|
#include "somafmsearchprovider.h"
|
||||||
#include "internet/somafmservice.h"
|
#include "internet/somafmservice.h"
|
||||||
|
|
||||||
SomaFMSearchProvider::SomaFMSearchProvider(SomaFMService* service, Application* app, QObject* parent)
|
SomaFMSearchProvider::SomaFMSearchProvider(
|
||||||
|
SomaFMServiceBase* service, Application* app, QObject* parent)
|
||||||
: SimpleSearchProvider(app, parent),
|
: SimpleSearchProvider(app, parent),
|
||||||
service_(service)
|
service_(service)
|
||||||
{
|
{
|
||||||
Init("SomaFM", "somafm", QIcon(":/providers/somafm.png"), CanGiveSuggestions);
|
Init(service->name(), service->url_scheme(), service->icon(), CanGiveSuggestions);
|
||||||
set_result_limit(3);
|
set_result_limit(3);
|
||||||
set_max_suggestion_count(3);
|
set_max_suggestion_count(3);
|
||||||
icon_ = ScaleAndPad(QImage(":/providers/somafm.png"));
|
icon_ = ScaleAndPad(
|
||||||
|
service->icon().pixmap(service->icon().availableSizes()[0]).toImage());
|
||||||
|
|
||||||
connect(service, SIGNAL(StreamsChanged()), SLOT(MaybeRecreateItems()));
|
connect(service, SIGNAL(StreamsChanged()), SLOT(MaybeRecreateItems()));
|
||||||
|
|
||||||
@ -44,7 +46,7 @@ void SomaFMSearchProvider::RecreateItems() {
|
|||||||
|
|
||||||
foreach (const SomaFMService::Stream& stream, service_->Streams()) {
|
foreach (const SomaFMService::Stream& stream, service_->Streams()) {
|
||||||
Item item;
|
Item item;
|
||||||
item.metadata_ = stream.ToSong();
|
item.metadata_ = stream.ToSong(service_->name());
|
||||||
item.keyword_ = stream.title_;
|
item.keyword_ = stream.title_;
|
||||||
items << item;
|
items << item;
|
||||||
}
|
}
|
||||||
|
@ -20,11 +20,11 @@
|
|||||||
|
|
||||||
#include "simplesearchprovider.h"
|
#include "simplesearchprovider.h"
|
||||||
|
|
||||||
class SomaFMService;
|
class SomaFMServiceBase;
|
||||||
|
|
||||||
class SomaFMSearchProvider : public SimpleSearchProvider {
|
class SomaFMSearchProvider : public SimpleSearchProvider {
|
||||||
public:
|
public:
|
||||||
SomaFMSearchProvider(SomaFMService* service, Application* app, QObject* parent);
|
SomaFMSearchProvider(SomaFMServiceBase* service, Application* app, QObject* parent);
|
||||||
|
|
||||||
void LoadArtAsync(int id, const Result& result);
|
void LoadArtAsync(int id, const Result& result);
|
||||||
|
|
||||||
@ -32,7 +32,7 @@ protected:
|
|||||||
void RecreateItems();
|
void RecreateItems();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SomaFMService* service_;
|
SomaFMServiceBase* service_;
|
||||||
QImage icon_;
|
QImage icon_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -91,6 +91,7 @@ InternetModel::InternetModel(Application* app, QObject* parent)
|
|||||||
AddService(new JazzRadioService(app, this));
|
AddService(new JazzRadioService(app, this));
|
||||||
AddService(new MagnatuneService(app, this));
|
AddService(new MagnatuneService(app, this));
|
||||||
AddService(new PodcastService(app, this));
|
AddService(new PodcastService(app, this));
|
||||||
|
AddService(new RadioGFMService(app, this));
|
||||||
AddService(new RockRadioService(app, this));
|
AddService(new RockRadioService(app, this));
|
||||||
AddService(new SavedRadio(app, this));
|
AddService(new SavedRadio(app, this));
|
||||||
AddService(new SkyFmService(app, this));
|
AddService(new SkyFmService(app, this));
|
||||||
|
@ -37,25 +37,34 @@
|
|||||||
#include <QXmlStreamReader>
|
#include <QXmlStreamReader>
|
||||||
#include <QtDebug>
|
#include <QtDebug>
|
||||||
|
|
||||||
const char* SomaFMService::kServiceName = "SomaFM";
|
const int SomaFMServiceBase::kStreamsCacheDurationSecs =
|
||||||
const char* SomaFMService::kSettingsGroup = "SomaFM";
|
|
||||||
const char* SomaFMService::kChannelListUrl = "http://somafm.com/channels.xml";
|
|
||||||
const char* SomaFMService::kHomepage = "http://somafm.com";
|
|
||||||
const int SomaFMService::kStreamsCacheDurationSecs =
|
|
||||||
60 * 60 * 24 * 28; // 4 weeks
|
60 * 60 * 24 * 28; // 4 weeks
|
||||||
|
|
||||||
bool operator <(const SomaFMService::Stream& a,
|
bool operator <(const SomaFMServiceBase::Stream& a,
|
||||||
const SomaFMService::Stream& b) {
|
const SomaFMServiceBase::Stream& b) {
|
||||||
return a.title_.compare(b.title_, Qt::CaseInsensitive) < 0;
|
return a.title_.compare(b.title_, Qt::CaseInsensitive) < 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
SomaFMService::SomaFMService(Application* app, InternetModel* parent)
|
SomaFMServiceBase::SomaFMServiceBase(
|
||||||
: InternetService(kServiceName, app, parent, parent),
|
Application* app,
|
||||||
|
InternetModel* parent,
|
||||||
|
const QString& name,
|
||||||
|
const QUrl& channel_list_url,
|
||||||
|
const QUrl& homepage_url,
|
||||||
|
const QUrl& donate_page_url,
|
||||||
|
const QIcon& icon)
|
||||||
|
: InternetService(name, app, parent, parent),
|
||||||
|
url_scheme_(name.toLower().remove(' ')),
|
||||||
url_handler_(new SomaFMUrlHandler(app, this, this)),
|
url_handler_(new SomaFMUrlHandler(app, this, this)),
|
||||||
root_(NULL),
|
root_(NULL),
|
||||||
context_menu_(NULL),
|
context_menu_(NULL),
|
||||||
network_(new NetworkAccessManager(this)),
|
network_(new NetworkAccessManager(this)),
|
||||||
streams_(kSettingsGroup, "streams", kStreamsCacheDurationSecs)
|
streams_(name, "streams", kStreamsCacheDurationSecs),
|
||||||
|
name_(name),
|
||||||
|
channel_list_url_(channel_list_url),
|
||||||
|
homepage_url_(homepage_url),
|
||||||
|
donate_page_url_(donate_page_url),
|
||||||
|
icon_(icon)
|
||||||
{
|
{
|
||||||
ReloadSettings();
|
ReloadSettings();
|
||||||
|
|
||||||
@ -63,17 +72,17 @@ SomaFMService::SomaFMService(Application* app, InternetModel* parent)
|
|||||||
app_->global_search()->AddProvider(new SomaFMSearchProvider(this, app_, this));
|
app_->global_search()->AddProvider(new SomaFMSearchProvider(this, app_, this));
|
||||||
}
|
}
|
||||||
|
|
||||||
SomaFMService::~SomaFMService() {
|
SomaFMServiceBase::~SomaFMServiceBase() {
|
||||||
delete context_menu_;
|
delete context_menu_;
|
||||||
}
|
}
|
||||||
|
|
||||||
QStandardItem* SomaFMService::CreateRootItem() {
|
QStandardItem* SomaFMServiceBase::CreateRootItem() {
|
||||||
root_ = new QStandardItem(QIcon(":/providers/somafm.png"), kServiceName);
|
root_ = new QStandardItem(icon_, name_);
|
||||||
root_->setData(true, InternetModel::Role_CanLazyLoad);
|
root_->setData(true, InternetModel::Role_CanLazyLoad);
|
||||||
return root_;
|
return root_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SomaFMService::LazyPopulate(QStandardItem* item) {
|
void SomaFMServiceBase::LazyPopulate(QStandardItem* item) {
|
||||||
switch (item->data(InternetModel::Role_Type).toInt()) {
|
switch (item->data(InternetModel::Role_Type).toInt()) {
|
||||||
case InternetModel::Type_Service:
|
case InternetModel::Type_Service:
|
||||||
RefreshStreams();
|
RefreshStreams();
|
||||||
@ -84,19 +93,24 @@ void SomaFMService::LazyPopulate(QStandardItem* item) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SomaFMService::ShowContextMenu(const QPoint& global_pos) {
|
void SomaFMServiceBase::ShowContextMenu(const QPoint& global_pos) {
|
||||||
if (!context_menu_) {
|
if (!context_menu_) {
|
||||||
context_menu_ = new QMenu;
|
context_menu_ = new QMenu;
|
||||||
context_menu_->addActions(GetPlaylistActions());
|
context_menu_->addActions(GetPlaylistActions());
|
||||||
context_menu_->addAction(IconLoader::Load("download"), tr("Open %1 in browser").arg("somafm.com"), this, SLOT(Homepage()));
|
context_menu_->addAction(IconLoader::Load("download"), tr("Open %1 in browser").arg(homepage_url_.host()), this, SLOT(Homepage()));
|
||||||
context_menu_->addAction(IconLoader::Load("view-refresh"), tr("Refresh channels"), this, SLOT(RefreshStreams()));
|
|
||||||
|
if (!donate_page_url_.isEmpty()) {
|
||||||
|
context_menu_->addAction(IconLoader::Load("download"), tr("Donate"), this, SLOT(Donate()));
|
||||||
|
}
|
||||||
|
|
||||||
|
context_menu_->addAction(IconLoader::Load("view-refresh"), tr("Refresh channels"), this, SLOT(ForceRefreshStreams()));
|
||||||
}
|
}
|
||||||
|
|
||||||
context_menu_->popup(global_pos);
|
context_menu_->popup(global_pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SomaFMService::ForceRefreshStreams() {
|
void SomaFMServiceBase::ForceRefreshStreams() {
|
||||||
QNetworkReply* reply = network_->get(QNetworkRequest(QUrl(kChannelListUrl)));
|
QNetworkReply* reply = network_->get(QNetworkRequest(channel_list_url_));
|
||||||
int task_id = app_->task_manager()->StartTask(tr("Getting channels"));
|
int task_id = app_->task_manager()->StartTask(tr("Getting channels"));
|
||||||
|
|
||||||
NewClosure(reply, SIGNAL(finished()),
|
NewClosure(reply, SIGNAL(finished()),
|
||||||
@ -104,7 +118,7 @@ void SomaFMService::ForceRefreshStreams() {
|
|||||||
reply, task_id);
|
reply, task_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SomaFMService::RefreshStreamsFinished(QNetworkReply* reply, int task_id) {
|
void SomaFMServiceBase::RefreshStreamsFinished(QNetworkReply* reply, int task_id) {
|
||||||
app_->task_manager()->SetTaskFinished(task_id);
|
app_->task_manager()->SetTaskFinished(task_id);
|
||||||
reply->deleteLater();
|
reply->deleteLater();
|
||||||
|
|
||||||
@ -136,7 +150,7 @@ void SomaFMService::RefreshStreamsFinished(QNetworkReply* reply, int task_id) {
|
|||||||
emit StreamsChanged();
|
emit StreamsChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SomaFMService::ReadChannel(QXmlStreamReader& reader, StreamList* ret) {
|
void SomaFMServiceBase::ReadChannel(QXmlStreamReader& reader, StreamList* ret) {
|
||||||
Stream stream;
|
Stream stream;
|
||||||
|
|
||||||
while (!reader.atEnd()) {
|
while (!reader.atEnd()) {
|
||||||
@ -154,7 +168,7 @@ void SomaFMService::ReadChannel(QXmlStreamReader& reader, StreamList* ret) {
|
|||||||
stream.dj_ = reader.readElementText();
|
stream.dj_ = reader.readElementText();
|
||||||
} else if (reader.name() == "fastpls" && reader.attributes().value("format") == "mp3") {
|
} else if (reader.name() == "fastpls" && reader.attributes().value("format") == "mp3") {
|
||||||
QUrl url(reader.readElementText());
|
QUrl url(reader.readElementText());
|
||||||
url.setScheme("somafm");
|
url.setScheme(url_handler_->scheme());
|
||||||
|
|
||||||
stream.url_ = url;
|
stream.url_ = url;
|
||||||
} else {
|
} else {
|
||||||
@ -168,31 +182,40 @@ void SomaFMService::ReadChannel(QXmlStreamReader& reader, StreamList* ret) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Song SomaFMService::Stream::ToSong() const {
|
Song SomaFMServiceBase::Stream::ToSong(const QString& prefix) const {
|
||||||
|
QString song_title = title_.trimmed();
|
||||||
|
if (!song_title.startsWith(prefix)) {
|
||||||
|
song_title = prefix + " " + song_title;
|
||||||
|
}
|
||||||
|
|
||||||
Song ret;
|
Song ret;
|
||||||
ret.set_valid(true);
|
ret.set_valid(true);
|
||||||
ret.set_title("SomaFM " + title_);
|
ret.set_title(song_title);
|
||||||
ret.set_artist(dj_);
|
ret.set_artist(dj_);
|
||||||
ret.set_url(url_);
|
ret.set_url(url_);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SomaFMService::Homepage() {
|
void SomaFMServiceBase::Homepage() {
|
||||||
QDesktopServices::openUrl(QUrl(kHomepage));
|
QDesktopServices::openUrl(homepage_url_);
|
||||||
}
|
}
|
||||||
|
|
||||||
PlaylistItem::Options SomaFMService::playlistitem_options() const {
|
void SomaFMServiceBase::Donate() {
|
||||||
|
QDesktopServices::openUrl(donate_page_url_);
|
||||||
|
}
|
||||||
|
|
||||||
|
PlaylistItem::Options SomaFMServiceBase::playlistitem_options() const {
|
||||||
return PlaylistItem::PauseDisabled;
|
return PlaylistItem::PauseDisabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
SomaFMService::StreamList SomaFMService::Streams() {
|
SomaFMServiceBase::StreamList SomaFMServiceBase::Streams() {
|
||||||
if (IsStreamListStale()) {
|
if (IsStreamListStale()) {
|
||||||
metaObject()->invokeMethod(this, "ForceRefreshStreams", Qt::QueuedConnection);
|
metaObject()->invokeMethod(this, "ForceRefreshStreams", Qt::QueuedConnection);
|
||||||
}
|
}
|
||||||
return streams_;
|
return streams_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SomaFMService::RefreshStreams() {
|
void SomaFMServiceBase::RefreshStreams() {
|
||||||
if (IsStreamListStale()) {
|
if (IsStreamListStale()) {
|
||||||
ForceRefreshStreams();
|
ForceRefreshStreams();
|
||||||
return;
|
return;
|
||||||
@ -200,35 +223,59 @@ void SomaFMService::RefreshStreams() {
|
|||||||
PopulateStreams();
|
PopulateStreams();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SomaFMService::PopulateStreams() {
|
void SomaFMServiceBase::PopulateStreams() {
|
||||||
if (root_->hasChildren())
|
if (root_->hasChildren())
|
||||||
root_->removeRows(0, root_->rowCount());
|
root_->removeRows(0, root_->rowCount());
|
||||||
|
|
||||||
foreach (const Stream& stream, streams_) {
|
foreach (const Stream& stream, streams_) {
|
||||||
QStandardItem* item = new QStandardItem(QIcon(":last.fm/icon_radio.png"), QString());
|
QStandardItem* item = new QStandardItem(QIcon(":last.fm/icon_radio.png"), QString());
|
||||||
item->setText(stream.title_);
|
item->setText(stream.title_);
|
||||||
item->setData(QVariant::fromValue(stream.ToSong()), InternetModel::Role_SongMetadata);
|
item->setData(QVariant::fromValue(stream.ToSong(name_)), InternetModel::Role_SongMetadata);
|
||||||
item->setData(InternetModel::PlayBehaviour_SingleItem, InternetModel::Role_PlayBehaviour);
|
item->setData(InternetModel::PlayBehaviour_SingleItem, InternetModel::Role_PlayBehaviour);
|
||||||
|
|
||||||
root_->appendRow(item);
|
root_->appendRow(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QDataStream& operator<<(QDataStream& out, const SomaFMService::Stream& stream) {
|
QDataStream& operator<<(QDataStream& out, const SomaFMServiceBase::Stream& stream) {
|
||||||
out << stream.title_
|
out << stream.title_
|
||||||
<< stream.dj_
|
<< stream.dj_
|
||||||
<< stream.url_;
|
<< stream.url_;
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
QDataStream& operator>>(QDataStream& in, SomaFMService::Stream& stream) {
|
QDataStream& operator>>(QDataStream& in, SomaFMServiceBase::Stream& stream) {
|
||||||
in >> stream.title_
|
in >> stream.title_
|
||||||
>> stream.dj_
|
>> stream.dj_
|
||||||
>> stream.url_;
|
>> stream.url_;
|
||||||
return in;
|
return in;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SomaFMService::ReloadSettings() {
|
void SomaFMServiceBase::ReloadSettings() {
|
||||||
streams_.Load();
|
streams_.Load();
|
||||||
streams_.Sort();
|
streams_.Sort();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
SomaFMService::SomaFMService(Application* app, InternetModel* parent)
|
||||||
|
: SomaFMServiceBase(
|
||||||
|
app,
|
||||||
|
parent,
|
||||||
|
"SomaFM",
|
||||||
|
QUrl("http://somafm.com/channels.xml"),
|
||||||
|
QUrl("http://somafm.com"),
|
||||||
|
QUrl(),
|
||||||
|
QIcon(":providers/somafm.png")) {
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
RadioGFMService::RadioGFMService(Application* app, InternetModel* parent)
|
||||||
|
: SomaFMServiceBase(
|
||||||
|
app,
|
||||||
|
parent,
|
||||||
|
"Radio GFM",
|
||||||
|
QUrl("http://streams.radio-gfm.net/channels.xml"),
|
||||||
|
QUrl("http://www.radio-gfm.net"),
|
||||||
|
QUrl("http://www.radio-gfm.net/spenden"),
|
||||||
|
QIcon(":providers/radiogfm.png")) {
|
||||||
|
}
|
||||||
|
@ -29,12 +29,19 @@ class QNetworkAccessManager;
|
|||||||
class QNetworkReply;
|
class QNetworkReply;
|
||||||
class QMenu;
|
class QMenu;
|
||||||
|
|
||||||
class SomaFMService : public InternetService {
|
class SomaFMServiceBase : public InternetService {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SomaFMService(Application* app, InternetModel* parent);
|
SomaFMServiceBase(
|
||||||
~SomaFMService();
|
Application* app,
|
||||||
|
InternetModel* parent,
|
||||||
|
const QString& name,
|
||||||
|
const QUrl& channel_list_url,
|
||||||
|
const QUrl& homepage_url,
|
||||||
|
const QUrl& donate_page_url,
|
||||||
|
const QIcon& icon);
|
||||||
|
~SomaFMServiceBase();
|
||||||
|
|
||||||
enum ItemType {
|
enum ItemType {
|
||||||
Type_Stream = 2000,
|
Type_Stream = 2000,
|
||||||
@ -45,16 +52,15 @@ public:
|
|||||||
QString dj_;
|
QString dj_;
|
||||||
QUrl url_;
|
QUrl url_;
|
||||||
|
|
||||||
Song ToSong() const;
|
Song ToSong(const QString& prefix) const;
|
||||||
};
|
};
|
||||||
typedef QList<Stream> StreamList;
|
typedef QList<Stream> StreamList;
|
||||||
|
|
||||||
static const char* kServiceName;
|
|
||||||
static const char* kSettingsGroup;
|
|
||||||
static const char* kChannelListUrl;
|
|
||||||
static const char* kHomepage;
|
|
||||||
static const int kStreamsCacheDurationSecs;
|
static const int kStreamsCacheDurationSecs;
|
||||||
|
|
||||||
|
const QString& url_scheme() const { return url_scheme_; }
|
||||||
|
const QIcon& icon() const { return icon_; }
|
||||||
|
|
||||||
QStandardItem* CreateRootItem();
|
QStandardItem* CreateRootItem();
|
||||||
void LazyPopulate(QStandardItem* item);
|
void LazyPopulate(QStandardItem* item);
|
||||||
void ShowContextMenu(const QPoint& global_pos);
|
void ShowContextMenu(const QPoint& global_pos);
|
||||||
@ -76,12 +82,14 @@ private slots:
|
|||||||
void RefreshStreamsFinished(QNetworkReply* reply, int task_id);
|
void RefreshStreamsFinished(QNetworkReply* reply, int task_id);
|
||||||
|
|
||||||
void Homepage();
|
void Homepage();
|
||||||
|
void Donate();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void ReadChannel(QXmlStreamReader& reader, StreamList* ret);
|
void ReadChannel(QXmlStreamReader& reader, StreamList* ret);
|
||||||
void PopulateStreams();
|
void PopulateStreams();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
const QString url_scheme_;
|
||||||
SomaFMUrlHandler* url_handler_;
|
SomaFMUrlHandler* url_handler_;
|
||||||
|
|
||||||
QStandardItem* root_;
|
QStandardItem* root_;
|
||||||
@ -90,6 +98,22 @@ private:
|
|||||||
QNetworkAccessManager* network_;
|
QNetworkAccessManager* network_;
|
||||||
|
|
||||||
CachedList<Stream> streams_;
|
CachedList<Stream> streams_;
|
||||||
|
|
||||||
|
const QString name_;
|
||||||
|
const QUrl channel_list_url_;
|
||||||
|
const QUrl homepage_url_;
|
||||||
|
const QUrl donate_page_url_;
|
||||||
|
const QIcon icon_;
|
||||||
|
};
|
||||||
|
|
||||||
|
class SomaFMService : public SomaFMServiceBase {
|
||||||
|
public:
|
||||||
|
SomaFMService(Application* app, InternetModel* parent);
|
||||||
|
};
|
||||||
|
|
||||||
|
class RadioGFMService : public SomaFMServiceBase {
|
||||||
|
public:
|
||||||
|
RadioGFMService(Application* app, InternetModel* parent);
|
||||||
};
|
};
|
||||||
|
|
||||||
QDataStream& operator<<(QDataStream& out, const SomaFMService::Stream& stream);
|
QDataStream& operator<<(QDataStream& out, const SomaFMService::Stream& stream);
|
||||||
|
@ -28,7 +28,8 @@
|
|||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QTemporaryFile>
|
#include <QTemporaryFile>
|
||||||
|
|
||||||
SomaFMUrlHandler::SomaFMUrlHandler(Application* app, SomaFMService* service,
|
SomaFMUrlHandler::SomaFMUrlHandler(Application* app,
|
||||||
|
SomaFMServiceBase* service,
|
||||||
QObject* parent)
|
QObject* parent)
|
||||||
: UrlHandler(parent),
|
: UrlHandler(parent),
|
||||||
app_(app),
|
app_(app),
|
||||||
@ -37,6 +38,14 @@ SomaFMUrlHandler::SomaFMUrlHandler(Application* app, SomaFMService* service,
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString SomaFMUrlHandler::scheme() const {
|
||||||
|
return service_->url_scheme();
|
||||||
|
}
|
||||||
|
|
||||||
|
QIcon SomaFMUrlHandler::icon() const {
|
||||||
|
return service_->icon();
|
||||||
|
}
|
||||||
|
|
||||||
UrlHandler::LoadResult SomaFMUrlHandler::StartLoading(const QUrl& url) {
|
UrlHandler::LoadResult SomaFMUrlHandler::StartLoading(const QUrl& url) {
|
||||||
QUrl playlist_url = url;
|
QUrl playlist_url = url;
|
||||||
playlist_url.setScheme("http");
|
playlist_url.setScheme("http");
|
||||||
@ -57,7 +66,7 @@ void SomaFMUrlHandler::LoadPlaylistFinished() {
|
|||||||
task_id_ = 0;
|
task_id_ = 0;
|
||||||
|
|
||||||
QUrl original_url(reply->url());
|
QUrl original_url(reply->url());
|
||||||
original_url.setScheme("somafm");
|
original_url.setScheme(scheme());
|
||||||
|
|
||||||
if (reply->error() != QNetworkReply::NoError) {
|
if (reply->error() != QNetworkReply::NoError) {
|
||||||
// TODO: Error handling
|
// TODO: Error handling
|
||||||
@ -74,7 +83,7 @@ void SomaFMUrlHandler::LoadPlaylistFinished() {
|
|||||||
|
|
||||||
// Failed to get playlist?
|
// Failed to get playlist?
|
||||||
if (songs.count() == 0) {
|
if (songs.count() == 0) {
|
||||||
qLog(Error) << "Error loading soma.fm playlist";
|
qLog(Error) << "Error loading" << scheme() << "playlist";
|
||||||
emit AsyncLoadComplete(LoadResult(original_url, LoadResult::NoMoreTracks));
|
emit AsyncLoadComplete(LoadResult(original_url, LoadResult::NoMoreTracks));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -21,17 +21,20 @@
|
|||||||
#include "core/urlhandler.h"
|
#include "core/urlhandler.h"
|
||||||
|
|
||||||
class Application;
|
class Application;
|
||||||
class SomaFMService;
|
class SomaFMServiceBase;
|
||||||
|
|
||||||
|
|
||||||
class SomaFMUrlHandler : public UrlHandler {
|
class SomaFMUrlHandler : public UrlHandler {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SomaFMUrlHandler(Application* app, SomaFMService* service, QObject* parent);
|
SomaFMUrlHandler(
|
||||||
|
Application* app,
|
||||||
|
SomaFMServiceBase* service,
|
||||||
|
QObject* parent);
|
||||||
|
|
||||||
QString scheme() const { return "somafm"; }
|
QString scheme() const;
|
||||||
QIcon icon() const { return QIcon(":providers/somafm.png"); }
|
QIcon icon() const;
|
||||||
LoadResult StartLoading(const QUrl& url);
|
LoadResult StartLoading(const QUrl& url);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
@ -39,7 +42,7 @@ private slots:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
Application* app_;
|
Application* app_;
|
||||||
SomaFMService* service_;
|
SomaFMServiceBase* service_;
|
||||||
|
|
||||||
int task_id_;
|
int task_id_;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user