2010-03-24 00:11:46 +01:00
|
|
|
/* This file is part of Clementine.
|
2010-11-20 14:27:10 +01:00
|
|
|
Copyright 2010, David Sansome <me@davidsansome.com>
|
2010-03-24 00:11:46 +01: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/>.
|
|
|
|
*/
|
|
|
|
|
2010-01-18 03:23:55 +01:00
|
|
|
#ifndef SOMAFMSERVICE_H
|
|
|
|
#define SOMAFMSERVICE_H
|
|
|
|
|
2010-02-10 14:15:18 +01:00
|
|
|
#include <QXmlStreamReader>
|
|
|
|
|
2011-07-15 15:27:50 +02:00
|
|
|
#include "internetservice.h"
|
2011-11-06 01:00:26 +01:00
|
|
|
#include "core/cachedlist.h"
|
2010-01-18 03:23:55 +01:00
|
|
|
|
2011-04-28 17:10:28 +02:00
|
|
|
class SomaFMUrlHandler;
|
|
|
|
|
2010-01-18 03:23:55 +01:00
|
|
|
class QNetworkAccessManager;
|
2012-02-13 21:44:04 +01:00
|
|
|
class QNetworkReply;
|
2010-01-18 03:49:07 +01:00
|
|
|
class QMenu;
|
2010-01-18 03:23:55 +01:00
|
|
|
|
2011-07-15 15:27:50 +02:00
|
|
|
class SomaFMService : public InternetService {
|
2010-01-18 03:23:55 +01:00
|
|
|
Q_OBJECT
|
|
|
|
|
2011-11-06 01:00:26 +01:00
|
|
|
public:
|
2012-02-12 14:41:50 +01:00
|
|
|
SomaFMService(Application* app, InternetModel* parent);
|
2010-01-18 03:49:07 +01:00
|
|
|
~SomaFMService();
|
2010-01-18 03:23:55 +01:00
|
|
|
|
|
|
|
enum ItemType {
|
|
|
|
Type_Stream = 2000,
|
|
|
|
};
|
|
|
|
|
2011-11-06 01:00:26 +01:00
|
|
|
struct Stream {
|
|
|
|
QString title_;
|
|
|
|
QString dj_;
|
|
|
|
QUrl url_;
|
|
|
|
|
|
|
|
Song ToSong() const;
|
|
|
|
};
|
|
|
|
typedef QList<Stream> StreamList;
|
|
|
|
|
2010-01-18 03:23:55 +01:00
|
|
|
static const char* kServiceName;
|
2011-11-06 01:00:26 +01:00
|
|
|
static const char* kSettingsGroup;
|
2010-01-18 03:23:55 +01:00
|
|
|
static const char* kChannelListUrl;
|
2010-01-18 03:49:07 +01:00
|
|
|
static const char* kHomepage;
|
2011-11-06 01:00:26 +01:00
|
|
|
static const int kStreamsCacheDurationSecs;
|
2010-01-18 03:23:55 +01:00
|
|
|
|
2011-01-09 19:27:41 +01:00
|
|
|
QStandardItem* CreateRootItem();
|
|
|
|
void LazyPopulate(QStandardItem* item);
|
2012-03-11 15:44:43 +01:00
|
|
|
void ShowContextMenu(const QPoint& global_pos);
|
2010-01-18 03:23:55 +01:00
|
|
|
|
2010-05-18 22:43:10 +02:00
|
|
|
PlaylistItem::Options playlistitem_options() const;
|
2011-04-28 17:10:28 +02:00
|
|
|
QNetworkAccessManager* network() const { return network_; }
|
2010-01-18 03:23:55 +01:00
|
|
|
|
2011-11-06 01:00:26 +01:00
|
|
|
void ReloadSettings();
|
|
|
|
|
|
|
|
bool IsStreamListStale() const { return streams_.IsStale(); }
|
|
|
|
StreamList Streams();
|
|
|
|
|
|
|
|
signals:
|
|
|
|
void StreamsChanged();
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
void ForceRefreshStreams();
|
|
|
|
void RefreshStreams();
|
|
|
|
void RefreshStreamsFinished(QNetworkReply* reply, int task_id);
|
2010-01-18 03:23:55 +01:00
|
|
|
|
2010-01-18 03:49:07 +01:00
|
|
|
void Homepage();
|
|
|
|
|
2011-11-06 01:00:26 +01:00
|
|
|
private:
|
|
|
|
void ReadChannel(QXmlStreamReader& reader, StreamList* ret);
|
|
|
|
void PopulateStreams();
|
2010-01-18 03:23:55 +01:00
|
|
|
|
2011-11-06 01:00:26 +01:00
|
|
|
private:
|
2011-04-28 17:10:28 +02:00
|
|
|
SomaFMUrlHandler* url_handler_;
|
|
|
|
|
2011-01-09 19:27:41 +01:00
|
|
|
QStandardItem* root_;
|
2010-01-18 03:49:07 +01:00
|
|
|
QMenu* context_menu_;
|
2010-01-18 03:23:55 +01:00
|
|
|
|
|
|
|
QNetworkAccessManager* network_;
|
2011-11-06 01:00:26 +01:00
|
|
|
|
|
|
|
CachedList<Stream> streams_;
|
2010-01-18 03:23:55 +01:00
|
|
|
};
|
|
|
|
|
2011-11-06 01:00:26 +01:00
|
|
|
QDataStream& operator<<(QDataStream& out, const SomaFMService::Stream& stream);
|
|
|
|
QDataStream& operator>>(QDataStream& in, SomaFMService::Stream& stream);
|
|
|
|
Q_DECLARE_METATYPE(SomaFMService::Stream)
|
|
|
|
|
2010-01-18 03:23:55 +01:00
|
|
|
#endif // SOMAFMSERVICE_H
|