2010-11-23 12:42:19 +01:00
|
|
|
/* This file is part of Clementine.
|
|
|
|
Copyright 2010, David Sansome <me@davidsansome.com>
|
|
|
|
|
|
|
|
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-11-22 17:57:26 +01:00
|
|
|
#ifndef ICECASTSERVICE_H
|
|
|
|
#define ICECASTSERVICE_H
|
|
|
|
|
2012-10-12 14:12:19 +02:00
|
|
|
#include <QXmlStreamReader>
|
|
|
|
|
2010-11-23 23:36:00 +01:00
|
|
|
#include "icecastbackend.h"
|
2011-07-15 15:27:50 +02:00
|
|
|
#include "internetservice.h"
|
2010-11-22 17:57:26 +01:00
|
|
|
|
2010-11-23 23:36:00 +01:00
|
|
|
class IcecastFilterWidget;
|
|
|
|
class IcecastModel;
|
2010-11-22 17:57:26 +01:00
|
|
|
class NetworkAccessManager;
|
|
|
|
|
2010-11-24 20:41:17 +01:00
|
|
|
class QAction;
|
|
|
|
class QMenu;
|
2012-10-12 14:12:19 +02:00
|
|
|
class QNetworkReply;
|
2010-11-24 20:41:17 +01:00
|
|
|
|
2011-07-15 15:27:50 +02:00
|
|
|
class IcecastService : public InternetService {
|
2010-11-22 17:57:26 +01:00
|
|
|
Q_OBJECT
|
2014-02-07 16:34:20 +01:00
|
|
|
public:
|
2012-02-12 14:41:50 +01:00
|
|
|
IcecastService(Application* app, InternetModel* parent);
|
2010-11-22 17:57:26 +01:00
|
|
|
~IcecastService();
|
|
|
|
|
|
|
|
static const char* kServiceName;
|
|
|
|
static const char* kDirectoryUrl;
|
2010-11-24 20:41:17 +01:00
|
|
|
static const char* kHomepage;
|
2010-11-22 17:57:26 +01:00
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
enum ItemType { Type_Stream = 3000, Type_Genre, };
|
2010-11-22 17:57:26 +01:00
|
|
|
|
2011-01-09 19:27:41 +01:00
|
|
|
QStandardItem* CreateRootItem();
|
|
|
|
void LazyPopulate(QStandardItem* item);
|
2010-11-23 23:36:00 +01:00
|
|
|
|
2012-03-11 15:44:43 +01:00
|
|
|
void ShowContextMenu(const QPoint& global_pos);
|
2010-11-24 20:41:17 +01:00
|
|
|
|
2010-11-23 23:36:00 +01:00
|
|
|
QWidget* HeaderWidget() const;
|
2010-11-22 17:57:26 +01:00
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
private slots:
|
2010-11-22 17:57:26 +01:00
|
|
|
void LoadDirectory();
|
2010-11-24 20:41:17 +01:00
|
|
|
void Homepage();
|
2012-10-12 14:12:19 +02:00
|
|
|
void DownloadDirectoryFinished(QNetworkReply* reply);
|
2014-02-07 16:34:20 +01:00
|
|
|
void ParseDirectoryFinished(QFuture<IcecastBackend::StationList> future);
|
2010-11-24 20:41:17 +01:00
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
private:
|
2011-03-22 21:41:31 +01:00
|
|
|
void RequestDirectory(const QUrl& url);
|
2010-11-24 20:41:17 +01:00
|
|
|
void EnsureMenuCreated();
|
2010-11-23 23:36:00 +01:00
|
|
|
IcecastBackend::StationList ParseDirectory(QIODevice* device) const;
|
|
|
|
IcecastBackend::Station ReadStation(QXmlStreamReader* reader) const;
|
2010-11-22 17:57:26 +01:00
|
|
|
|
2011-01-09 19:27:41 +01:00
|
|
|
QStandardItem* root_;
|
2010-11-22 17:57:26 +01:00
|
|
|
NetworkAccessManager* network_;
|
2010-11-24 20:41:17 +01:00
|
|
|
QMenu* context_menu_;
|
2010-11-22 17:57:26 +01:00
|
|
|
|
2010-11-23 23:36:00 +01:00
|
|
|
IcecastBackend* backend_;
|
|
|
|
IcecastModel* model_;
|
|
|
|
IcecastFilterWidget* filter_;
|
|
|
|
|
2010-11-23 19:53:08 +01:00
|
|
|
int load_directory_task_id_;
|
2010-11-22 17:57:26 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|