From ac1f3775990561224c69543f7fbcf31e62fd0109 Mon Sep 17 00:00:00 2001 From: trialuser02 Date: Sat, 22 Dec 2012 09:22:05 +0000 Subject: refactoring git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@3085 90c681e8-e032-0410-971d-27865f9a5e38 --- src/plugins/PlayListFormats/CMakeLists.txt | 3 + src/plugins/PlayListFormats/PlaylistFormats.pro | 6 + src/plugins/PlayListFormats/m3u/CMakeLists.txt | 49 ++++++ src/plugins/PlayListFormats/m3u/m3u.pro | 33 ++++ .../PlayListFormats/m3u/m3uplaylistformat.cpp | 78 ++++++++++ .../PlayListFormats/m3u/m3uplaylistformat.h | 48 ++++++ src/plugins/PlayListFormats/pls/CMakeLists.txt | 49 ++++++ src/plugins/PlayListFormats/pls/pls.pro | 35 +++++ .../PlayListFormats/pls/plsplaylistformat.cpp | 103 +++++++++++++ .../PlayListFormats/pls/plsplaylistformat.h | 48 ++++++ src/plugins/PlayListFormats/xspf/CMakeLists.txt | 54 +++++++ src/plugins/PlayListFormats/xspf/xspf.pro | 36 +++++ .../PlayListFormats/xspf/xspfplaylistformat.cpp | 166 +++++++++++++++++++++ .../PlayListFormats/xspf/xspfplaylistformat.h | 48 ++++++ src/plugins/PlaylistFormats/CMakeLists.txt | 3 - src/plugins/PlaylistFormats/PlaylistFormats.pro | 6 - src/plugins/PlaylistFormats/m3u/CMakeLists.txt | 49 ------ src/plugins/PlaylistFormats/m3u/m3u.pro | 33 ---- .../PlaylistFormats/m3u/m3uplaylistformat.cpp | 78 ---------- .../PlaylistFormats/m3u/m3uplaylistformat.h | 48 ------ src/plugins/PlaylistFormats/pls/CMakeLists.txt | 49 ------ src/plugins/PlaylistFormats/pls/pls.pro | 35 ----- .../PlaylistFormats/pls/plsplaylistformat.cpp | 103 ------------- .../PlaylistFormats/pls/plsplaylistformat.h | 48 ------ src/plugins/PlaylistFormats/xspf/CMakeLists.txt | 54 ------- src/plugins/PlaylistFormats/xspf/xspf.pro | 36 ----- .../PlaylistFormats/xspf/xspfplaylistformat.cpp | 166 --------------------- .../PlaylistFormats/xspf/xspfplaylistformat.h | 48 ------ 28 files changed, 756 insertions(+), 756 deletions(-) create mode 100644 src/plugins/PlayListFormats/CMakeLists.txt create mode 100644 src/plugins/PlayListFormats/PlaylistFormats.pro create mode 100644 src/plugins/PlayListFormats/m3u/CMakeLists.txt create mode 100644 src/plugins/PlayListFormats/m3u/m3u.pro create mode 100644 src/plugins/PlayListFormats/m3u/m3uplaylistformat.cpp create mode 100644 src/plugins/PlayListFormats/m3u/m3uplaylistformat.h create mode 100644 src/plugins/PlayListFormats/pls/CMakeLists.txt create mode 100644 src/plugins/PlayListFormats/pls/pls.pro create mode 100644 src/plugins/PlayListFormats/pls/plsplaylistformat.cpp create mode 100644 src/plugins/PlayListFormats/pls/plsplaylistformat.h create mode 100644 src/plugins/PlayListFormats/xspf/CMakeLists.txt create mode 100644 src/plugins/PlayListFormats/xspf/xspf.pro create mode 100644 src/plugins/PlayListFormats/xspf/xspfplaylistformat.cpp create mode 100644 src/plugins/PlayListFormats/xspf/xspfplaylistformat.h delete mode 100644 src/plugins/PlaylistFormats/CMakeLists.txt delete mode 100644 src/plugins/PlaylistFormats/PlaylistFormats.pro delete mode 100644 src/plugins/PlaylistFormats/m3u/CMakeLists.txt delete mode 100644 src/plugins/PlaylistFormats/m3u/m3u.pro delete mode 100644 src/plugins/PlaylistFormats/m3u/m3uplaylistformat.cpp delete mode 100644 src/plugins/PlaylistFormats/m3u/m3uplaylistformat.h delete mode 100644 src/plugins/PlaylistFormats/pls/CMakeLists.txt delete mode 100644 src/plugins/PlaylistFormats/pls/pls.pro delete mode 100644 src/plugins/PlaylistFormats/pls/plsplaylistformat.cpp delete mode 100644 src/plugins/PlaylistFormats/pls/plsplaylistformat.h delete mode 100644 src/plugins/PlaylistFormats/xspf/CMakeLists.txt delete mode 100644 src/plugins/PlaylistFormats/xspf/xspf.pro delete mode 100644 src/plugins/PlaylistFormats/xspf/xspfplaylistformat.cpp delete mode 100644 src/plugins/PlaylistFormats/xspf/xspfplaylistformat.h (limited to 'src/plugins') diff --git a/src/plugins/PlayListFormats/CMakeLists.txt b/src/plugins/PlayListFormats/CMakeLists.txt new file mode 100644 index 000000000..5fd89ff62 --- /dev/null +++ b/src/plugins/PlayListFormats/CMakeLists.txt @@ -0,0 +1,3 @@ +add_subdirectory(m3u) +add_subdirectory(pls) +add_subdirectory(xspf) diff --git a/src/plugins/PlayListFormats/PlaylistFormats.pro b/src/plugins/PlayListFormats/PlaylistFormats.pro new file mode 100644 index 000000000..f214cffff --- /dev/null +++ b/src/plugins/PlayListFormats/PlaylistFormats.pro @@ -0,0 +1,6 @@ +TEMPLATE = subdirs + +SUBDIRS += m3u pls xspf + + + diff --git a/src/plugins/PlayListFormats/m3u/CMakeLists.txt b/src/plugins/PlayListFormats/m3u/CMakeLists.txt new file mode 100644 index 000000000..f7a18fb07 --- /dev/null +++ b/src/plugins/PlayListFormats/m3u/CMakeLists.txt @@ -0,0 +1,49 @@ +project(libm3uplaylistformat) + +cmake_minimum_required(VERSION 2.4.7) + +if(COMMAND cmake_policy) +cmake_policy(SET CMP0003 NEW) +endif(COMMAND cmake_policy) + + +# qt plugin +ADD_DEFINITIONS( -Wall ) +ADD_DEFINITIONS(${QT_DEFINITIONS}) +ADD_DEFINITIONS(-DQT_PLUGIN) +ADD_DEFINITIONS(-DQT_NO_DEBUG) +ADD_DEFINITIONS(-DQT_SHARED) +ADD_DEFINITIONS(-DQT_THREAD) + +include_directories(${CMAKE_CURRENT_BINARY_DIR}) + +SET(QT_INCLUDES + ${QT_INCLUDES} + ${CMAKE_CURRENT_SOURCE_DIR}/../../../ +) + +# libqmmpui +include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../../) +link_directories(${CMAKE_CURRENT_BINARY_DIR}/../../../qmmpui) + +SET(libm3uplaylistformat_SRCS + m3uplaylistformat.cpp +) + +SET(libm3uplaylistformat_MOC_HDRS + m3uplaylistformat.h +) + +QT4_ADD_RESOURCES(libm3uplaylistformat_RCC_SRCS ${libm3uplaylistformat_RCCS}) + +QT4_WRAP_CPP(libm3uplaylistformat_MOC_SRCS ${libm3uplaylistformat_MOC_HDRS}) + + +# Don't forget to include output directory, otherwise +# the UI file won't be wrapped! +include_directories(${CMAKE_CURRENT_BINARY_DIR}) + +ADD_LIBRARY(m3uplaylistformat MODULE ${libm3uplaylistformat_SRCS} ${libm3uplaylistformat_MOC_SRCS}) +add_dependencies(m3uplaylistformat qmmpui) +target_link_libraries(m3uplaylistformat ${QT_LIBRARIES} -lqmmpui) +install(TARGETS m3uplaylistformat DESTINATION ${LIB_DIR}/qmmp/PlaylistFormats) diff --git a/src/plugins/PlayListFormats/m3u/m3u.pro b/src/plugins/PlayListFormats/m3u/m3u.pro new file mode 100644 index 000000000..b4a435c7f --- /dev/null +++ b/src/plugins/PlayListFormats/m3u/m3u.pro @@ -0,0 +1,33 @@ +include(../../plugins.pri) + +CONFIG += release \ +warn_on \ +plugin \ + lib + +TARGET =$$PLUGINS_PREFIX/PlaylistFormats/m3uplaylistformat + +TEMPLATE = lib +QMAKE_LIBDIR += ../../../../lib + +INCLUDEPATH += ../../../../src + +HEADERS += m3uplaylistformat.h + +SOURCES += m3uplaylistformat.cpp + +unix { + isEmpty(LIB_DIR){ + LIB_DIR = /lib + } + target.path = $$LIB_DIR/qmmp/PlaylistFormats + INSTALLS += target + + QMAKE_CLEAN =$$PLUGINS_PREFIX/General/libm3uplaylistformat.so + LIBS += -lqmmpui +} + +win32 { + LIBS += -lqmmpui0 + QMAKE_LIBDIR += ../../../../bin +} diff --git a/src/plugins/PlayListFormats/m3u/m3uplaylistformat.cpp b/src/plugins/PlayListFormats/m3u/m3uplaylistformat.cpp new file mode 100644 index 000000000..8349f1274 --- /dev/null +++ b/src/plugins/PlayListFormats/m3u/m3uplaylistformat.cpp @@ -0,0 +1,78 @@ +/*************************************************************************** + * Copyright (C) 2008 by Ilya Kotov * + * forkotov02@hotmail.ru * + * * + * This program 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 2 of the License, or * + * (at your option) any later version. * + * * + * This program 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 this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * + ***************************************************************************/ + +#include +#include +#include "m3uplaylistformat.h" + +bool M3UPlaylistFormat::hasFormat(const QString &f) +{ + return m_supported_formats.contains(f); +} + +QStringList M3UPlaylistFormat::getExtensions() const +{ + return m_supported_formats; +} + +M3UPlaylistFormat::M3UPlaylistFormat() +{ + m_supported_formats << "m3u"; +} + +QStringList M3UPlaylistFormat::decode(const QString & contents) +{ + QStringList out; + QStringList splitted = contents.split("\n"); + if(splitted.isEmpty()) + return QStringList(); + + foreach(QString str, splitted) + { + str = str.trimmed (); + if (str.startsWith("#EXTM3U") || str.startsWith("#EXTINF:") || str.isEmpty()) + continue;//TODO: Let's skip it for now.. + else if (str.startsWith("#") || str.isEmpty()) + continue; + else + out << str; + } + return out; +} + +QString M3UPlaylistFormat::encode(const QList & contents) +{ + QStringList out; + out << QString("#EXTM3U"); + foreach(PlayListItem* f,contents) + { + QString info = "#EXTINF:" + QString::number(f->length()) + "," + f->value(Qmmp::TITLE); + out.append(info); + out.append(f->url()); + } + return out.join("\n"); +} + +QString M3UPlaylistFormat::name() const +{ + return "M3UPlaylistFormat"; +} + +Q_EXPORT_PLUGIN2(m3uplaylistformat,M3UPlaylistFormat) diff --git a/src/plugins/PlayListFormats/m3u/m3uplaylistformat.h b/src/plugins/PlayListFormats/m3u/m3uplaylistformat.h new file mode 100644 index 000000000..4a5414894 --- /dev/null +++ b/src/plugins/PlayListFormats/m3u/m3uplaylistformat.h @@ -0,0 +1,48 @@ +/*************************************************************************** + * Copyright (C) 2008 by Ilya Kotov * + * forkotov02@hotmail.ru * + * * + * This program 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 2 of the License, or * + * (at your option) any later version. * + * * + * This program 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 this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * + ***************************************************************************/ +#ifndef M3UPLAYLISTFORMAT_H +#define M3UPLAYLISTFORMAT_H + +#include +#include +#include +#include +#include + +/*! + * Class for M3U playlist format parsing + * @author Vladimir Kuznetsov + */ +class M3UPlaylistFormat : public QObject, public PlayListFormat +{ + Q_OBJECT + Q_INTERFACES(PlayListFormat) +public: + M3UPlaylistFormat(); + virtual QStringList getExtensions()const; + virtual bool hasFormat(const QString&); + virtual QStringList decode(const QString& contents); + virtual QString encode(const QList& contents); + virtual QString name()const; +protected: + QStringList m_supported_formats; +}; + +#endif diff --git a/src/plugins/PlayListFormats/pls/CMakeLists.txt b/src/plugins/PlayListFormats/pls/CMakeLists.txt new file mode 100644 index 000000000..29c49f73c --- /dev/null +++ b/src/plugins/PlayListFormats/pls/CMakeLists.txt @@ -0,0 +1,49 @@ +project(libplsplaylistformat) + +cmake_minimum_required(VERSION 2.4.7) + +if(COMMAND cmake_policy) +cmake_policy(SET CMP0003 NEW) +endif(COMMAND cmake_policy) + + +# qt plugin +ADD_DEFINITIONS( -Wall ) +ADD_DEFINITIONS(${QT_DEFINITIONS}) +ADD_DEFINITIONS(-DQT_PLUGIN) +ADD_DEFINITIONS(-DQT_NO_DEBUG) +ADD_DEFINITIONS(-DQT_SHARED) +ADD_DEFINITIONS(-DQT_THREAD) + +include_directories(${CMAKE_CURRENT_BINARY_DIR}) + +SET(QT_INCLUDES + ${QT_INCLUDES} + ${CMAKE_CURRENT_SOURCE_DIR}/../../../ +) + +# libqmmpui +include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../../) +link_directories(${CMAKE_CURRENT_BINARY_DIR}/../../../qmmpui) + +SET(libplsplaylistformat_SRCS + plsplaylistformat.cpp +) + +SET(libplsplaylistformat_MOC_HDRS + plsplaylistformat.h +) + +QT4_ADD_RESOURCES(libplsplaylistformat_RCC_SRCS ${libplsplaylistformat_RCCS}) + +QT4_WRAP_CPP(libplsplaylistformat_MOC_SRCS ${libplsplaylistformat_MOC_HDRS}) + + +# Don't forget to include output directory, otherwise +# the UI file won't be wrapped! +include_directories(${CMAKE_CURRENT_BINARY_DIR}) + +ADD_LIBRARY(plsplaylistformat MODULE ${libplsplaylistformat_SRCS} ${libplsplaylistformat_MOC_SRCS}) +add_dependencies(plsplaylistformat qmmpui) +target_link_libraries(plsplaylistformat ${QT_LIBRARIES} -lqmmpui) +install(TARGETS plsplaylistformat DESTINATION ${LIB_DIR}/qmmp/PlaylistFormats) diff --git a/src/plugins/PlayListFormats/pls/pls.pro b/src/plugins/PlayListFormats/pls/pls.pro new file mode 100644 index 000000000..006e0aa63 --- /dev/null +++ b/src/plugins/PlayListFormats/pls/pls.pro @@ -0,0 +1,35 @@ +include(../../plugins.pri) + +CONFIG += release \ +warn_on \ +plugin \ + lib + +TARGET =$$PLUGINS_PREFIX/PlaylistFormats/plsplaylistformat + + +TEMPLATE = lib +QMAKE_LIBDIR += ../../../../lib + +INCLUDEPATH += ../../../../src + +SOURCES += plsplaylistformat.cpp + +HEADERS += plsplaylistformat.h + +unix { + isEmpty(LIB_DIR){ + LIB_DIR = /lib + } + target.path = $$LIB_DIR/qmmp/PlaylistFormats + INSTALLS += target + + QMAKE_CLEAN =$$PLUGINS_PREFIX/PlaylistFormats/plsplaylistformat.so + LIBS += -lqmmpui +} + +win32 { + LIBS += -lqmmpui0 + QMAKE_LIBDIR += ../../../../bin +} + diff --git a/src/plugins/PlayListFormats/pls/plsplaylistformat.cpp b/src/plugins/PlayListFormats/pls/plsplaylistformat.cpp new file mode 100644 index 000000000..a251276d0 --- /dev/null +++ b/src/plugins/PlayListFormats/pls/plsplaylistformat.cpp @@ -0,0 +1,103 @@ +/*************************************************************************** + * Copyright (C) 2008 by Ilya Kotov * + * forkotov02@hotmail.ru * + * * + * This program 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 2 of the License, or * + * (at your option) any later version. * + * * + * This program 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 this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * + ***************************************************************************/ + +#include +#include + +#include "plsplaylistformat.h" + +bool PLSPlaylistFormat::hasFormat(const QString & f) +{ + foreach(QString s,m_supported_formats) + if (f == s) + return true; + + return false; +} + +QStringList PLSPlaylistFormat::getExtensions() const +{ + return m_supported_formats; +} + +PLSPlaylistFormat::PLSPlaylistFormat() +{ + m_supported_formats << "pls"; +} + +QString PLSPlaylistFormat::name() const +{ + return "PLSPlaylistFormat"; +} + + +QStringList PLSPlaylistFormat::decode(const QString & contents) +{ + QStringList out; + QStringList splitted = contents.split("\n"); + if (!splitted.isEmpty()) + { + if (splitted.takeAt(0).toLower().contains("[playlist]")) + { + foreach(QString str, splitted) + { + if (str.startsWith("File")) + { + QString unverified = str.remove(0,str.indexOf(QChar('=')) + 1); + unverified = unverified.trimmed(); + if (unverified.startsWith("http://")) + { + out << unverified; + } + else /*if (QFileInfo(unverified).exists())*/ + out << QFileInfo(unverified).absoluteFilePath(); + /*else + qWarning("File %s does not exist", qPrintable(unverified));*/ + } + } + return out; + } + } + else + qWarning("Error parsing PLS format"); + + return QStringList(); +} + +QString PLSPlaylistFormat::encode(const QList & contents) +{ + QStringList out; + out << QString("[playlist]"); + int counter = 1; + foreach(PlayListItem* f,contents) + { + QString begin = "File" + QString::number(counter) + "="; + out.append(begin + f->url()); + begin = "Title" + QString::number(counter) + "="; + out.append(begin + f->value(Qmmp::TITLE)); + begin = "Length" + QString::number(counter) + "="; + out.append(begin + QString::number(f->length())); + counter ++; + } + out << "NumberOfEntries=" + QString::number(contents.count()); + return out.join("\n"); +} + +Q_EXPORT_PLUGIN2(plsplaylistformat, PLSPlaylistFormat) diff --git a/src/plugins/PlayListFormats/pls/plsplaylistformat.h b/src/plugins/PlayListFormats/pls/plsplaylistformat.h new file mode 100644 index 000000000..4d770ee74 --- /dev/null +++ b/src/plugins/PlayListFormats/pls/plsplaylistformat.h @@ -0,0 +1,48 @@ +/*************************************************************************** + * Copyright (C) 2008 by Ilya Kotov * + * forkotov02@hotmail.ru * + * * + * This program 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 2 of the License, or * + * (at your option) any later version. * + * * + * This program 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 this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * + ***************************************************************************/ +#ifndef PLSPLAYLISTFORMAT_H +#define PLSPLAYLISTFORMAT_H + +#include +#include +#include +#include +#include + +/*! + * Class for PLS playlist format parsing + * @author Vladimir Kuznetsov + */ +class PLSPlaylistFormat : public QObject, public PlayListFormat +{ + Q_OBJECT + Q_INTERFACES(PlayListFormat) +public: + PLSPlaylistFormat(); + virtual QStringList getExtensions()const; + virtual bool hasFormat(const QString&); + virtual QStringList decode(const QString& contents); + virtual QString encode(const QList& contents); + virtual QString name()const; +protected: + QStringList m_supported_formats; +}; + +#endif diff --git a/src/plugins/PlayListFormats/xspf/CMakeLists.txt b/src/plugins/PlayListFormats/xspf/CMakeLists.txt new file mode 100644 index 000000000..f4a27ac22 --- /dev/null +++ b/src/plugins/PlayListFormats/xspf/CMakeLists.txt @@ -0,0 +1,54 @@ +project(libxspfplaylistformat) + +cmake_minimum_required(VERSION 2.4.7) + +if(COMMAND cmake_policy) +cmake_policy(SET CMP0003 NEW) +endif(COMMAND cmake_policy) + +SET(QT_USE_QTXML TRUE) + +INCLUDE(FindQt4) +INCLUDE(${QT_USE_FILE}) + +# qt plugin +ADD_DEFINITIONS( -Wall ) +ADD_DEFINITIONS(${QT_DEFINITIONS}) +ADD_DEFINITIONS(-DQT_PLUGIN) +ADD_DEFINITIONS(-DQT_NO_DEBUG) +ADD_DEFINITIONS(-DQT_SHARED) +ADD_DEFINITIONS(-DQT_THREAD) + +include_directories(${CMAKE_CURRENT_BINARY_DIR}) + +SET(QT_INCLUDES + ${QT_INCLUDES} + ${CMAKE_CURRENT_SOURCE_DIR}/../../../ +) + +# libqmmpui +include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../../) +link_directories(${CMAKE_CURRENT_BINARY_DIR}/../../../qmmpui) +link_directories(${CMAKE_CURRENT_BINARY_DIR}/../../../qmmp) + +SET(libxspfplaylistformat_SRCS + xspfplaylistformat.cpp +) + +SET(libxspfplaylistformat_MOC_HDRS + xspfplaylistformat.h +) + +QT4_ADD_RESOURCES(libxspfplaylistformat_RCC_SRCS ${libxspfplaylistformat_RCCS}) + +QT4_WRAP_CPP(libxspfplaylistformat_MOC_SRCS ${libxspfplaylistformat_MOC_HDRS}) + + +# Don't forget to include output directory, otherwise +# the UI file won't be wrapped! +include_directories(${CMAKE_CURRENT_BINARY_DIR}) + +ADD_LIBRARY(xspfplaylistformat MODULE ${libxspfplaylistformat_SRCS} ${libxspfplaylistformat_MOC_SRCS}) +add_dependencies(xspfplaylistformat qmmpui) +target_link_libraries(xspfplaylistformat ${QT_LIBRARIES} -lqmmpui -lqmmp) +install(TARGETS xspfplaylistformat DESTINATION ${LIB_DIR}/qmmp/PlaylistFormats) diff --git a/src/plugins/PlayListFormats/xspf/xspf.pro b/src/plugins/PlayListFormats/xspf/xspf.pro new file mode 100644 index 000000000..28a50ca44 --- /dev/null +++ b/src/plugins/PlayListFormats/xspf/xspf.pro @@ -0,0 +1,36 @@ +include(../../plugins.pri) + +CONFIG += release \ +warn_on \ +plugin \ + lib + +TARGET =$$PLUGINS_PREFIX/PlaylistFormats/xspfplaylistformat + + +TEMPLATE = lib +QMAKE_LIBDIR += ../../../../lib + +INCLUDEPATH += ../../../../src + +QT += xml + +SOURCES += xspfplaylistformat.cpp +HEADERS += xspfplaylistformat.h + +unix { + isEmpty(LIB_DIR){ + LIB_DIR = /lib + } + target.path = $$LIB_DIR/qmmp/PlaylistFormats + INSTALLS += target + + QMAKE_CLEAN =$$PLUGINS_PREFIX/PlaylistFormats/libxsplaylistformat.so + LIBS += -lqmmpui -lqmmp +} + +win32 { + LIBS += -lqmmpui0 -lqmmp0 + QMAKE_LIBDIR += ../../../../bin +} + diff --git a/src/plugins/PlayListFormats/xspf/xspfplaylistformat.cpp b/src/plugins/PlayListFormats/xspf/xspfplaylistformat.cpp new file mode 100644 index 000000000..2e1296b48 --- /dev/null +++ b/src/plugins/PlayListFormats/xspf/xspfplaylistformat.cpp @@ -0,0 +1,166 @@ +/*************************************************************************** + * Copyright (C) 2008-2009 by Ilya Kotov * + * forkotov02@hotmail.ru * + * * + * This program 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 2 of the License, or * + * (at your option) any later version. * + * * + * This program 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 this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * + ***************************************************************************/ + +#include +#include +#include +#include +#include + +#include + +#include "xspfplaylistformat.h" + +// Needs more work - it's better use libSpiff there and put it as plugin. + +QStringList XSPFPlaylistFormat::decode(const QString & contents) +{ + QStringList out; + QDomDocument doc; + QString errorMsg; + int errorCol; + int errorRow; + bool ok = doc.setContent(contents, &errorMsg, &errorRow, &errorCol); + + if (!ok) + qDebug("Parse Error: %s\tRow:%d\tCol%d", + qPrintable(errorMsg), errorRow, errorCol ); + + QDomElement rootElement = doc.firstChildElement("playlist"); + if (rootElement.isNull()) + qWarning("Error parsing XSPF: can't find 'playlist' element"); + + QDomElement tracklistElement = rootElement.firstChildElement("trackList"); + if (tracklistElement.isNull()) + qWarning("Error parsing XSPF: can't find 'trackList' element"); + + QDomElement child = tracklistElement.firstChildElement("track"); + + while (!child.isNull()) + { + QUrl url (child.firstChildElement("location").text()); + if (url.scheme() == "file") //remove scheme for local files only + out << QUrl::fromPercentEncoding(url.toString(QUrl::RemoveScheme).toAscii()); + else + out << url.toString(); + child = child.nextSiblingElement(); + } + + return out; +} + +// Needs more work - it's better use libSpiff there and put it as plugin. + +QString XSPFPlaylistFormat::encode(const QList & files) +{ + QDomDocument doc; + QDomElement root = doc.createElement("playlist"); + root.setAttribute("version",QString("1")); + root.setAttribute("xmlns",QString("http://xspf.org/ns/0/")); + + QDomElement creator = doc.createElement("creator"); + QDomText text = doc.createTextNode("qmmp-" + Qmmp::strVersion()); + creator.appendChild(text); + root.appendChild(creator); + + QDomElement tracklist = doc.createElement("trackList"); + + int counter = 1; + foreach(PlayListItem* f,files) + { + QDomElement track = doc.createElement("track"); + + QDomElement ch = doc.createElement("location"); + QDomText text; + if (f->url().contains("://")) + text = doc.createTextNode(QUrl::toPercentEncoding(f->url(), ":/")); + else //append protocol + text = doc.createTextNode(QUrl::toPercentEncoding(QString("file://") + + QFileInfo(f->url()).absoluteFilePath(), ":/")); + ch.appendChild(text); + track.appendChild(ch); + + ch = doc.createElement("title"); + text = doc.createTextNode(f->value(Qmmp::TITLE)); + ch.appendChild(text); + track.appendChild(ch); + + ch = doc.createElement("creator"); + text = doc.createTextNode(f->value(Qmmp::ARTIST)); + ch.appendChild(text); + track.appendChild(ch); + + ch = doc.createElement("annotation"); + text = doc.createTextNode(f->value(Qmmp::COMMENT)); + ch.appendChild(text); + track.appendChild(ch); + + ch = doc.createElement("album"); + text = doc.createTextNode(f->value(Qmmp::ALBUM)); + ch.appendChild(text); + track.appendChild(ch); + + ch = doc.createElement("trackNum"); + text = doc.createTextNode(QString::number(counter)); + ch.appendChild(text); + track.appendChild(ch); + + ch = doc.createElement("meta"); + ch.setAttribute("rel", "year"); + text = doc.createTextNode(f->value(Qmmp::YEAR)); + ch.appendChild(text); + track.appendChild(ch); + + tracklist.appendChild(track); + counter ++; + } + + root.appendChild(tracklist); + doc.appendChild( root ); + QString xml_header("\n"); + return doc.toString().prepend(xml_header); +} + +XSPFPlaylistFormat::XSPFPlaylistFormat() +{ + m_supported_formats << "xspf"; +} + +bool XSPFPlaylistFormat::hasFormat(const QString & f) +{ + foreach(QString s,m_supported_formats) + if (f == s) + return true; + + return false; +} + +QStringList XSPFPlaylistFormat::getExtensions() const +{ + return m_supported_formats; +} + + +QString XSPFPlaylistFormat::name() const +{ + return "XSPFPlaylistFormat"; +} + +Q_EXPORT_PLUGIN2(xspfplaylistformat,XSPFPlaylistFormat) diff --git a/src/plugins/PlayListFormats/xspf/xspfplaylistformat.h b/src/plugins/PlayListFormats/xspf/xspfplaylistformat.h new file mode 100644 index 000000000..2b72c8613 --- /dev/null +++ b/src/plugins/PlayListFormats/xspf/xspfplaylistformat.h @@ -0,0 +1,48 @@ +/*************************************************************************** + * Copyright (C) 2008 by Ilya Kotov * + * forkotov02@hotmail.ru * + * * + * This program 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 2 of the License, or * + * (at your option) any later version. * + * * + * This program 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 this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * + ***************************************************************************/ +#ifndef XSPFPLAYLISTFORMAT_H +#define XSPFPLAYLISTFORMAT_H + +#include +#include +#include +#include +#include + +/*! + * Class for XSPF playlist format parsing + * @author Vladimir Kuznetsov + */ +class XSPFPlaylistFormat : public QObject, public PlayListFormat +{ + Q_OBJECT + Q_INTERFACES(PlayListFormat) +public: + XSPFPlaylistFormat(); + virtual QStringList getExtensions()const; + virtual bool hasFormat(const QString&); + virtual QStringList decode(const QString& contents); + virtual QString encode(const QList& contents); + virtual QString name()const; +protected: + QStringList m_supported_formats; +}; + +#endif diff --git a/src/plugins/PlaylistFormats/CMakeLists.txt b/src/plugins/PlaylistFormats/CMakeLists.txt deleted file mode 100644 index 5fd89ff62..000000000 --- a/src/plugins/PlaylistFormats/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -add_subdirectory(m3u) -add_subdirectory(pls) -add_subdirectory(xspf) diff --git a/src/plugins/PlaylistFormats/PlaylistFormats.pro b/src/plugins/PlaylistFormats/PlaylistFormats.pro deleted file mode 100644 index f214cffff..000000000 --- a/src/plugins/PlaylistFormats/PlaylistFormats.pro +++ /dev/null @@ -1,6 +0,0 @@ -TEMPLATE = subdirs - -SUBDIRS += m3u pls xspf - - - diff --git a/src/plugins/PlaylistFormats/m3u/CMakeLists.txt b/src/plugins/PlaylistFormats/m3u/CMakeLists.txt deleted file mode 100644 index f7a18fb07..000000000 --- a/src/plugins/PlaylistFormats/m3u/CMakeLists.txt +++ /dev/null @@ -1,49 +0,0 @@ -project(libm3uplaylistformat) - -cmake_minimum_required(VERSION 2.4.7) - -if(COMMAND cmake_policy) -cmake_policy(SET CMP0003 NEW) -endif(COMMAND cmake_policy) - - -# qt plugin -ADD_DEFINITIONS( -Wall ) -ADD_DEFINITIONS(${QT_DEFINITIONS}) -ADD_DEFINITIONS(-DQT_PLUGIN) -ADD_DEFINITIONS(-DQT_NO_DEBUG) -ADD_DEFINITIONS(-DQT_SHARED) -ADD_DEFINITIONS(-DQT_THREAD) - -include_directories(${CMAKE_CURRENT_BINARY_DIR}) - -SET(QT_INCLUDES - ${QT_INCLUDES} - ${CMAKE_CURRENT_SOURCE_DIR}/../../../ -) - -# libqmmpui -include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../../) -link_directories(${CMAKE_CURRENT_BINARY_DIR}/../../../qmmpui) - -SET(libm3uplaylistformat_SRCS - m3uplaylistformat.cpp -) - -SET(libm3uplaylistformat_MOC_HDRS - m3uplaylistformat.h -) - -QT4_ADD_RESOURCES(libm3uplaylistformat_RCC_SRCS ${libm3uplaylistformat_RCCS}) - -QT4_WRAP_CPP(libm3uplaylistformat_MOC_SRCS ${libm3uplaylistformat_MOC_HDRS}) - - -# Don't forget to include output directory, otherwise -# the UI file won't be wrapped! -include_directories(${CMAKE_CURRENT_BINARY_DIR}) - -ADD_LIBRARY(m3uplaylistformat MODULE ${libm3uplaylistformat_SRCS} ${libm3uplaylistformat_MOC_SRCS}) -add_dependencies(m3uplaylistformat qmmpui) -target_link_libraries(m3uplaylistformat ${QT_LIBRARIES} -lqmmpui) -install(TARGETS m3uplaylistformat DESTINATION ${LIB_DIR}/qmmp/PlaylistFormats) diff --git a/src/plugins/PlaylistFormats/m3u/m3u.pro b/src/plugins/PlaylistFormats/m3u/m3u.pro deleted file mode 100644 index b4a435c7f..000000000 --- a/src/plugins/PlaylistFormats/m3u/m3u.pro +++ /dev/null @@ -1,33 +0,0 @@ -include(../../plugins.pri) - -CONFIG += release \ -warn_on \ -plugin \ - lib - -TARGET =$$PLUGINS_PREFIX/PlaylistFormats/m3uplaylistformat - -TEMPLATE = lib -QMAKE_LIBDIR += ../../../../lib - -INCLUDEPATH += ../../../../src - -HEADERS += m3uplaylistformat.h - -SOURCES += m3uplaylistformat.cpp - -unix { - isEmpty(LIB_DIR){ - LIB_DIR = /lib - } - target.path = $$LIB_DIR/qmmp/PlaylistFormats - INSTALLS += target - - QMAKE_CLEAN =$$PLUGINS_PREFIX/General/libm3uplaylistformat.so - LIBS += -lqmmpui -} - -win32 { - LIBS += -lqmmpui0 - QMAKE_LIBDIR += ../../../../bin -} diff --git a/src/plugins/PlaylistFormats/m3u/m3uplaylistformat.cpp b/src/plugins/PlaylistFormats/m3u/m3uplaylistformat.cpp deleted file mode 100644 index 8349f1274..000000000 --- a/src/plugins/PlaylistFormats/m3u/m3uplaylistformat.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2008 by Ilya Kotov * - * forkotov02@hotmail.ru * - * * - * This program 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 2 of the License, or * - * (at your option) any later version. * - * * - * This program 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 this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - ***************************************************************************/ - -#include -#include -#include "m3uplaylistformat.h" - -bool M3UPlaylistFormat::hasFormat(const QString &f) -{ - return m_supported_formats.contains(f); -} - -QStringList M3UPlaylistFormat::getExtensions() const -{ - return m_supported_formats; -} - -M3UPlaylistFormat::M3UPlaylistFormat() -{ - m_supported_formats << "m3u"; -} - -QStringList M3UPlaylistFormat::decode(const QString & contents) -{ - QStringList out; - QStringList splitted = contents.split("\n"); - if(splitted.isEmpty()) - return QStringList(); - - foreach(QString str, splitted) - { - str = str.trimmed (); - if (str.startsWith("#EXTM3U") || str.startsWith("#EXTINF:") || str.isEmpty()) - continue;//TODO: Let's skip it for now.. - else if (str.startsWith("#") || str.isEmpty()) - continue; - else - out << str; - } - return out; -} - -QString M3UPlaylistFormat::encode(const QList & contents) -{ - QStringList out; - out << QString("#EXTM3U"); - foreach(PlayListItem* f,contents) - { - QString info = "#EXTINF:" + QString::number(f->length()) + "," + f->value(Qmmp::TITLE); - out.append(info); - out.append(f->url()); - } - return out.join("\n"); -} - -QString M3UPlaylistFormat::name() const -{ - return "M3UPlaylistFormat"; -} - -Q_EXPORT_PLUGIN2(m3uplaylistformat,M3UPlaylistFormat) diff --git a/src/plugins/PlaylistFormats/m3u/m3uplaylistformat.h b/src/plugins/PlaylistFormats/m3u/m3uplaylistformat.h deleted file mode 100644 index 4a5414894..000000000 --- a/src/plugins/PlaylistFormats/m3u/m3uplaylistformat.h +++ /dev/null @@ -1,48 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2008 by Ilya Kotov * - * forkotov02@hotmail.ru * - * * - * This program 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 2 of the License, or * - * (at your option) any later version. * - * * - * This program 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 this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - ***************************************************************************/ -#ifndef M3UPLAYLISTFORMAT_H -#define M3UPLAYLISTFORMAT_H - -#include -#include -#include -#include -#include - -/*! - * Class for M3U playlist format parsing - * @author Vladimir Kuznetsov - */ -class M3UPlaylistFormat : public QObject, public PlayListFormat -{ - Q_OBJECT - Q_INTERFACES(PlayListFormat) -public: - M3UPlaylistFormat(); - virtual QStringList getExtensions()const; - virtual bool hasFormat(const QString&); - virtual QStringList decode(const QString& contents); - virtual QString encode(const QList& contents); - virtual QString name()const; -protected: - QStringList m_supported_formats; -}; - -#endif diff --git a/src/plugins/PlaylistFormats/pls/CMakeLists.txt b/src/plugins/PlaylistFormats/pls/CMakeLists.txt deleted file mode 100644 index 29c49f73c..000000000 --- a/src/plugins/PlaylistFormats/pls/CMakeLists.txt +++ /dev/null @@ -1,49 +0,0 @@ -project(libplsplaylistformat) - -cmake_minimum_required(VERSION 2.4.7) - -if(COMMAND cmake_policy) -cmake_policy(SET CMP0003 NEW) -endif(COMMAND cmake_policy) - - -# qt plugin -ADD_DEFINITIONS( -Wall ) -ADD_DEFINITIONS(${QT_DEFINITIONS}) -ADD_DEFINITIONS(-DQT_PLUGIN) -ADD_DEFINITIONS(-DQT_NO_DEBUG) -ADD_DEFINITIONS(-DQT_SHARED) -ADD_DEFINITIONS(-DQT_THREAD) - -include_directories(${CMAKE_CURRENT_BINARY_DIR}) - -SET(QT_INCLUDES - ${QT_INCLUDES} - ${CMAKE_CURRENT_SOURCE_DIR}/../../../ -) - -# libqmmpui -include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../../) -link_directories(${CMAKE_CURRENT_BINARY_DIR}/../../../qmmpui) - -SET(libplsplaylistformat_SRCS - plsplaylistformat.cpp -) - -SET(libplsplaylistformat_MOC_HDRS - plsplaylistformat.h -) - -QT4_ADD_RESOURCES(libplsplaylistformat_RCC_SRCS ${libplsplaylistformat_RCCS}) - -QT4_WRAP_CPP(libplsplaylistformat_MOC_SRCS ${libplsplaylistformat_MOC_HDRS}) - - -# Don't forget to include output directory, otherwise -# the UI file won't be wrapped! -include_directories(${CMAKE_CURRENT_BINARY_DIR}) - -ADD_LIBRARY(plsplaylistformat MODULE ${libplsplaylistformat_SRCS} ${libplsplaylistformat_MOC_SRCS}) -add_dependencies(plsplaylistformat qmmpui) -target_link_libraries(plsplaylistformat ${QT_LIBRARIES} -lqmmpui) -install(TARGETS plsplaylistformat DESTINATION ${LIB_DIR}/qmmp/PlaylistFormats) diff --git a/src/plugins/PlaylistFormats/pls/pls.pro b/src/plugins/PlaylistFormats/pls/pls.pro deleted file mode 100644 index 006e0aa63..000000000 --- a/src/plugins/PlaylistFormats/pls/pls.pro +++ /dev/null @@ -1,35 +0,0 @@ -include(../../plugins.pri) - -CONFIG += release \ -warn_on \ -plugin \ - lib - -TARGET =$$PLUGINS_PREFIX/PlaylistFormats/plsplaylistformat - - -TEMPLATE = lib -QMAKE_LIBDIR += ../../../../lib - -INCLUDEPATH += ../../../../src - -SOURCES += plsplaylistformat.cpp - -HEADERS += plsplaylistformat.h - -unix { - isEmpty(LIB_DIR){ - LIB_DIR = /lib - } - target.path = $$LIB_DIR/qmmp/PlaylistFormats - INSTALLS += target - - QMAKE_CLEAN =$$PLUGINS_PREFIX/PlaylistFormats/plsplaylistformat.so - LIBS += -lqmmpui -} - -win32 { - LIBS += -lqmmpui0 - QMAKE_LIBDIR += ../../../../bin -} - diff --git a/src/plugins/PlaylistFormats/pls/plsplaylistformat.cpp b/src/plugins/PlaylistFormats/pls/plsplaylistformat.cpp deleted file mode 100644 index a251276d0..000000000 --- a/src/plugins/PlaylistFormats/pls/plsplaylistformat.cpp +++ /dev/null @@ -1,103 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2008 by Ilya Kotov * - * forkotov02@hotmail.ru * - * * - * This program 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 2 of the License, or * - * (at your option) any later version. * - * * - * This program 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 this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - ***************************************************************************/ - -#include -#include - -#include "plsplaylistformat.h" - -bool PLSPlaylistFormat::hasFormat(const QString & f) -{ - foreach(QString s,m_supported_formats) - if (f == s) - return true; - - return false; -} - -QStringList PLSPlaylistFormat::getExtensions() const -{ - return m_supported_formats; -} - -PLSPlaylistFormat::PLSPlaylistFormat() -{ - m_supported_formats << "pls"; -} - -QString PLSPlaylistFormat::name() const -{ - return "PLSPlaylistFormat"; -} - - -QStringList PLSPlaylistFormat::decode(const QString & contents) -{ - QStringList out; - QStringList splitted = contents.split("\n"); - if (!splitted.isEmpty()) - { - if (splitted.takeAt(0).toLower().contains("[playlist]")) - { - foreach(QString str, splitted) - { - if (str.startsWith("File")) - { - QString unverified = str.remove(0,str.indexOf(QChar('=')) + 1); - unverified = unverified.trimmed(); - if (unverified.startsWith("http://")) - { - out << unverified; - } - else /*if (QFileInfo(unverified).exists())*/ - out << QFileInfo(unverified).absoluteFilePath(); - /*else - qWarning("File %s does not exist", qPrintable(unverified));*/ - } - } - return out; - } - } - else - qWarning("Error parsing PLS format"); - - return QStringList(); -} - -QString PLSPlaylistFormat::encode(const QList & contents) -{ - QStringList out; - out << QString("[playlist]"); - int counter = 1; - foreach(PlayListItem* f,contents) - { - QString begin = "File" + QString::number(counter) + "="; - out.append(begin + f->url()); - begin = "Title" + QString::number(counter) + "="; - out.append(begin + f->value(Qmmp::TITLE)); - begin = "Length" + QString::number(counter) + "="; - out.append(begin + QString::number(f->length())); - counter ++; - } - out << "NumberOfEntries=" + QString::number(contents.count()); - return out.join("\n"); -} - -Q_EXPORT_PLUGIN2(plsplaylistformat, PLSPlaylistFormat) diff --git a/src/plugins/PlaylistFormats/pls/plsplaylistformat.h b/src/plugins/PlaylistFormats/pls/plsplaylistformat.h deleted file mode 100644 index 4d770ee74..000000000 --- a/src/plugins/PlaylistFormats/pls/plsplaylistformat.h +++ /dev/null @@ -1,48 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2008 by Ilya Kotov * - * forkotov02@hotmail.ru * - * * - * This program 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 2 of the License, or * - * (at your option) any later version. * - * * - * This program 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 this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - ***************************************************************************/ -#ifndef PLSPLAYLISTFORMAT_H -#define PLSPLAYLISTFORMAT_H - -#include -#include -#include -#include -#include - -/*! - * Class for PLS playlist format parsing - * @author Vladimir Kuznetsov - */ -class PLSPlaylistFormat : public QObject, public PlayListFormat -{ - Q_OBJECT - Q_INTERFACES(PlayListFormat) -public: - PLSPlaylistFormat(); - virtual QStringList getExtensions()const; - virtual bool hasFormat(const QString&); - virtual QStringList decode(const QString& contents); - virtual QString encode(const QList& contents); - virtual QString name()const; -protected: - QStringList m_supported_formats; -}; - -#endif diff --git a/src/plugins/PlaylistFormats/xspf/CMakeLists.txt b/src/plugins/PlaylistFormats/xspf/CMakeLists.txt deleted file mode 100644 index f4a27ac22..000000000 --- a/src/plugins/PlaylistFormats/xspf/CMakeLists.txt +++ /dev/null @@ -1,54 +0,0 @@ -project(libxspfplaylistformat) - -cmake_minimum_required(VERSION 2.4.7) - -if(COMMAND cmake_policy) -cmake_policy(SET CMP0003 NEW) -endif(COMMAND cmake_policy) - -SET(QT_USE_QTXML TRUE) - -INCLUDE(FindQt4) -INCLUDE(${QT_USE_FILE}) - -# qt plugin -ADD_DEFINITIONS( -Wall ) -ADD_DEFINITIONS(${QT_DEFINITIONS}) -ADD_DEFINITIONS(-DQT_PLUGIN) -ADD_DEFINITIONS(-DQT_NO_DEBUG) -ADD_DEFINITIONS(-DQT_SHARED) -ADD_DEFINITIONS(-DQT_THREAD) - -include_directories(${CMAKE_CURRENT_BINARY_DIR}) - -SET(QT_INCLUDES - ${QT_INCLUDES} - ${CMAKE_CURRENT_SOURCE_DIR}/../../../ -) - -# libqmmpui -include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../../) -link_directories(${CMAKE_CURRENT_BINARY_DIR}/../../../qmmpui) -link_directories(${CMAKE_CURRENT_BINARY_DIR}/../../../qmmp) - -SET(libxspfplaylistformat_SRCS - xspfplaylistformat.cpp -) - -SET(libxspfplaylistformat_MOC_HDRS - xspfplaylistformat.h -) - -QT4_ADD_RESOURCES(libxspfplaylistformat_RCC_SRCS ${libxspfplaylistformat_RCCS}) - -QT4_WRAP_CPP(libxspfplaylistformat_MOC_SRCS ${libxspfplaylistformat_MOC_HDRS}) - - -# Don't forget to include output directory, otherwise -# the UI file won't be wrapped! -include_directories(${CMAKE_CURRENT_BINARY_DIR}) - -ADD_LIBRARY(xspfplaylistformat MODULE ${libxspfplaylistformat_SRCS} ${libxspfplaylistformat_MOC_SRCS}) -add_dependencies(xspfplaylistformat qmmpui) -target_link_libraries(xspfplaylistformat ${QT_LIBRARIES} -lqmmpui -lqmmp) -install(TARGETS xspfplaylistformat DESTINATION ${LIB_DIR}/qmmp/PlaylistFormats) diff --git a/src/plugins/PlaylistFormats/xspf/xspf.pro b/src/plugins/PlaylistFormats/xspf/xspf.pro deleted file mode 100644 index 28a50ca44..000000000 --- a/src/plugins/PlaylistFormats/xspf/xspf.pro +++ /dev/null @@ -1,36 +0,0 @@ -include(../../plugins.pri) - -CONFIG += release \ -warn_on \ -plugin \ - lib - -TARGET =$$PLUGINS_PREFIX/PlaylistFormats/xspfplaylistformat - - -TEMPLATE = lib -QMAKE_LIBDIR += ../../../../lib - -INCLUDEPATH += ../../../../src - -QT += xml - -SOURCES += xspfplaylistformat.cpp -HEADERS += xspfplaylistformat.h - -unix { - isEmpty(LIB_DIR){ - LIB_DIR = /lib - } - target.path = $$LIB_DIR/qmmp/PlaylistFormats - INSTALLS += target - - QMAKE_CLEAN =$$PLUGINS_PREFIX/PlaylistFormats/libxsplaylistformat.so - LIBS += -lqmmpui -lqmmp -} - -win32 { - LIBS += -lqmmpui0 -lqmmp0 - QMAKE_LIBDIR += ../../../../bin -} - diff --git a/src/plugins/PlaylistFormats/xspf/xspfplaylistformat.cpp b/src/plugins/PlaylistFormats/xspf/xspfplaylistformat.cpp deleted file mode 100644 index 2e1296b48..000000000 --- a/src/plugins/PlaylistFormats/xspf/xspfplaylistformat.cpp +++ /dev/null @@ -1,166 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2008-2009 by Ilya Kotov * - * forkotov02@hotmail.ru * - * * - * This program 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 2 of the License, or * - * (at your option) any later version. * - * * - * This program 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 this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - ***************************************************************************/ - -#include -#include -#include -#include -#include - -#include - -#include "xspfplaylistformat.h" - -// Needs more work - it's better use libSpiff there and put it as plugin. - -QStringList XSPFPlaylistFormat::decode(const QString & contents) -{ - QStringList out; - QDomDocument doc; - QString errorMsg; - int errorCol; - int errorRow; - bool ok = doc.setContent(contents, &errorMsg, &errorRow, &errorCol); - - if (!ok) - qDebug("Parse Error: %s\tRow:%d\tCol%d", - qPrintable(errorMsg), errorRow, errorCol ); - - QDomElement rootElement = doc.firstChildElement("playlist"); - if (rootElement.isNull()) - qWarning("Error parsing XSPF: can't find 'playlist' element"); - - QDomElement tracklistElement = rootElement.firstChildElement("trackList"); - if (tracklistElement.isNull()) - qWarning("Error parsing XSPF: can't find 'trackList' element"); - - QDomElement child = tracklistElement.firstChildElement("track"); - - while (!child.isNull()) - { - QUrl url (child.firstChildElement("location").text()); - if (url.scheme() == "file") //remove scheme for local files only - out << QUrl::fromPercentEncoding(url.toString(QUrl::RemoveScheme).toAscii()); - else - out << url.toString(); - child = child.nextSiblingElement(); - } - - return out; -} - -// Needs more work - it's better use libSpiff there and put it as plugin. - -QString XSPFPlaylistFormat::encode(const QList & files) -{ - QDomDocument doc; - QDomElement root = doc.createElement("playlist"); - root.setAttribute("version",QString("1")); - root.setAttribute("xmlns",QString("http://xspf.org/ns/0/")); - - QDomElement creator = doc.createElement("creator"); - QDomText text = doc.createTextNode("qmmp-" + Qmmp::strVersion()); - creator.appendChild(text); - root.appendChild(creator); - - QDomElement tracklist = doc.createElement("trackList"); - - int counter = 1; - foreach(PlayListItem* f,files) - { - QDomElement track = doc.createElement("track"); - - QDomElement ch = doc.createElement("location"); - QDomText text; - if (f->url().contains("://")) - text = doc.createTextNode(QUrl::toPercentEncoding(f->url(), ":/")); - else //append protocol - text = doc.createTextNode(QUrl::toPercentEncoding(QString("file://") + - QFileInfo(f->url()).absoluteFilePath(), ":/")); - ch.appendChild(text); - track.appendChild(ch); - - ch = doc.createElement("title"); - text = doc.createTextNode(f->value(Qmmp::TITLE)); - ch.appendChild(text); - track.appendChild(ch); - - ch = doc.createElement("creator"); - text = doc.createTextNode(f->value(Qmmp::ARTIST)); - ch.appendChild(text); - track.appendChild(ch); - - ch = doc.createElement("annotation"); - text = doc.createTextNode(f->value(Qmmp::COMMENT)); - ch.appendChild(text); - track.appendChild(ch); - - ch = doc.createElement("album"); - text = doc.createTextNode(f->value(Qmmp::ALBUM)); - ch.appendChild(text); - track.appendChild(ch); - - ch = doc.createElement("trackNum"); - text = doc.createTextNode(QString::number(counter)); - ch.appendChild(text); - track.appendChild(ch); - - ch = doc.createElement("meta"); - ch.setAttribute("rel", "year"); - text = doc.createTextNode(f->value(Qmmp::YEAR)); - ch.appendChild(text); - track.appendChild(ch); - - tracklist.appendChild(track); - counter ++; - } - - root.appendChild(tracklist); - doc.appendChild( root ); - QString xml_header("\n"); - return doc.toString().prepend(xml_header); -} - -XSPFPlaylistFormat::XSPFPlaylistFormat() -{ - m_supported_formats << "xspf"; -} - -bool XSPFPlaylistFormat::hasFormat(const QString & f) -{ - foreach(QString s,m_supported_formats) - if (f == s) - return true; - - return false; -} - -QStringList XSPFPlaylistFormat::getExtensions() const -{ - return m_supported_formats; -} - - -QString XSPFPlaylistFormat::name() const -{ - return "XSPFPlaylistFormat"; -} - -Q_EXPORT_PLUGIN2(xspfplaylistformat,XSPFPlaylistFormat) diff --git a/src/plugins/PlaylistFormats/xspf/xspfplaylistformat.h b/src/plugins/PlaylistFormats/xspf/xspfplaylistformat.h deleted file mode 100644 index 2b72c8613..000000000 --- a/src/plugins/PlaylistFormats/xspf/xspfplaylistformat.h +++ /dev/null @@ -1,48 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2008 by Ilya Kotov * - * forkotov02@hotmail.ru * - * * - * This program 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 2 of the License, or * - * (at your option) any later version. * - * * - * This program 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 this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - ***************************************************************************/ -#ifndef XSPFPLAYLISTFORMAT_H -#define XSPFPLAYLISTFORMAT_H - -#include -#include -#include -#include -#include - -/*! - * Class for XSPF playlist format parsing - * @author Vladimir Kuznetsov - */ -class XSPFPlaylistFormat : public QObject, public PlayListFormat -{ - Q_OBJECT - Q_INTERFACES(PlayListFormat) -public: - XSPFPlaylistFormat(); - virtual QStringList getExtensions()const; - virtual bool hasFormat(const QString&); - virtual QStringList decode(const QString& contents); - virtual QString encode(const QList& contents); - virtual QString name()const; -protected: - QStringList m_supported_formats; -}; - -#endif -- cgit v1.2.3-13-gbd6f