Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
257a0dee
Commit
257a0dee
authored
Jan 27, 2013
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
playlist/*: convert to C++
parent
e995cd92
Hide whitespace changes
Inline
Side-by-side
Showing
25 changed files
with
290 additions
and
256 deletions
+290
-256
Makefile.am
Makefile.am
+15
-15
CommandLine.cxx
src/CommandLine.cxx
+1
-1
PlaylistPlugin.hxx
src/PlaylistPlugin.hxx
+3
-4
PlaylistPrint.cxx
src/PlaylistPrint.cxx
+1
-1
PlaylistQueue.cxx
src/PlaylistQueue.cxx
+1
-1
PlaylistRegistry.cxx
src/PlaylistRegistry.cxx
+8
-8
AsxPlaylistPlugin.cxx
src/playlist/AsxPlaylistPlugin.cxx
+46
-39
AsxPlaylistPlugin.hxx
src/playlist/AsxPlaylistPlugin.hxx
+3
-3
CuePlaylistPlugin.cxx
src/playlist/CuePlaylistPlugin.cxx
+21
-15
CuePlaylistPlugin.hxx
src/playlist/CuePlaylistPlugin.hxx
+3
-3
DespotifyPlaylistPlugin.cxx
src/playlist/DespotifyPlaylistPlugin.cxx
+1
-1
EmbeddedCuePlaylistPlugin.cxx
src/playlist/EmbeddedCuePlaylistPlugin.cxx
+1
-1
ExtM3uPlaylistPlugin.cxx
src/playlist/ExtM3uPlaylistPlugin.cxx
+24
-21
ExtM3uPlaylistPlugin.hxx
src/playlist/ExtM3uPlaylistPlugin.hxx
+3
-3
LastFMPlaylistPlugin.cxx
src/playlist/LastFMPlaylistPlugin.cxx
+1
-2
M3uPlaylistPlugin.cxx
src/playlist/M3uPlaylistPlugin.cxx
+21
-15
M3uPlaylistPlugin.hxx
src/playlist/M3uPlaylistPlugin.hxx
+3
-3
PlsPlaylistPlugin.cxx
src/playlist/PlsPlaylistPlugin.cxx
+22
-18
PlsPlaylistPlugin.hxx
src/playlist/PlsPlaylistPlugin.hxx
+3
-3
RssPlaylistPlugin.cxx
src/playlist/RssPlaylistPlugin.cxx
+43
-38
RssPlaylistPlugin.hxx
src/playlist/RssPlaylistPlugin.hxx
+3
-3
SoundCloudPlaylistPlugin.cxx
src/playlist/SoundCloudPlaylistPlugin.cxx
+1
-1
XspfPlaylistPlugin.cxx
src/playlist/XspfPlaylistPlugin.cxx
+58
-53
XspfPlaylistPlugin.hxx
src/playlist/XspfPlaylistPlugin.hxx
+3
-3
dump_playlist.cxx
test/dump_playlist.cxx
+1
-1
No files found.
Makefile.am
View file @
257a0dee
...
...
@@ -96,14 +96,6 @@ mpd_headers = \
src/page.h
\
src/Playlist.hxx
\
src/playlist_error.h
\
src/playlist_plugin.h
\
src/playlist/extm3u_playlist_plugin.h
\
src/playlist/m3u_playlist_plugin.h
\
src/playlist/pls_playlist_plugin.h
\
src/playlist/xspf_playlist_plugin.h
\
src/playlist/asx_playlist_plugin.h
\
src/playlist/rss_playlist_plugin.h
\
src/playlist/cue_playlist_plugin.h
\
src/poison.h
\
src/riff.h
\
src/aiff.h
\
...
...
@@ -919,13 +911,21 @@ endif
#
libplaylist_plugins_a_SOURCES
=
\
src/playlist/extm3u_playlist_plugin.c
\
src/playlist/m3u_playlist_plugin.c
\
src/playlist/pls_playlist_plugin.c
\
src/playlist/xspf_playlist_plugin.c
\
src/playlist/asx_playlist_plugin.c
\
src/playlist/rss_playlist_plugin.c
\
src/playlist/cue_playlist_plugin.c
\
src/PlaylistPlugin.hxx
\
src/playlist/ExtM3uPlaylistPlugin.cxx
\
src/playlist/ExtM3uPlaylistPlugin.hxx
\
src/playlist/M3uPlaylistPlugin.cxx
\
src/playlist/M3uPlaylistPlugin.hxx
\
src/playlist/PlsPlaylistPlugin.cxx
\
src/playlist/PlsPlaylistPlugin.hxx
\
src/playlist/XspfPlaylistPlugin.cxx
\
src/playlist/XspfPlaylistPlugin.hxx
\
src/playlist/AsxPlaylistPlugin.cxx
\
src/playlist/AsxPlaylistPlugin.hxx
\
src/playlist/RssPlaylistPlugin.cxx
\
src/playlist/RssPlaylistPlugin.hxx
\
src/playlist/CuePlaylistPlugin.cxx
\
src/playlist/CuePlaylistPlugin.hxx
\
src/playlist/EmbeddedCuePlaylistPlugin.cxx
\
src/playlist/EmbeddedCuePlaylistPlugin.hxx
\
src/PlaylistRegistry.cxx src/PlaylistRegistry.hxx
...
...
src/CommandLine.cxx
View file @
257a0dee
...
...
@@ -29,7 +29,7 @@
#include "InputRegistry.hxx"
#include "InputPlugin.hxx"
#include "PlaylistRegistry.hxx"
#include "
playlist_plugin.h
"
#include "
PlaylistPlugin.hxx
"
#include "mpd_error.h"
#include "glib_compat.h"
...
...
src/
playlist_plugin.h
→
src/
PlaylistPlugin.hxx
View file @
257a0dee
/*
* Copyright (C) 2003-201
1
The Music Player Daemon Project
* Copyright (C) 2003-201
3
The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
...
...
@@ -17,12 +17,11 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef MPD_PLAYLIST_PLUGIN_H
#define MPD_PLAYLIST_PLUGIN_H
#ifndef MPD_PLAYLIST_PLUGIN_H
XX
#define MPD_PLAYLIST_PLUGIN_H
XX
#include <glib.h>
#include <stdbool.h>
#include <stddef.h>
struct
config_param
;
...
...
src/PlaylistPrint.cxx
View file @
257a0dee
...
...
@@ -24,6 +24,7 @@
#include "PlaylistSong.hxx"
#include "Playlist.hxx"
#include "PlaylistRegistry.hxx"
#include "PlaylistPlugin.hxx"
#include "QueuePrint.hxx"
#include "SongPrint.hxx"
#include "DatabaseGlue.hxx"
...
...
@@ -32,7 +33,6 @@
#include "input_stream.h"
extern
"C"
{
#include "playlist_plugin.h"
#include "song.h"
}
...
...
src/PlaylistQueue.cxx
View file @
257a0dee
...
...
@@ -19,7 +19,7 @@
#include "config.h"
#include "PlaylistQueue.hxx"
#include "
playlist_plugin.h
"
#include "
PlaylistPlugin.hxx
"
#include "PlaylistAny.hxx"
#include "PlaylistSong.hxx"
#include "Playlist.hxx"
...
...
src/PlaylistRegistry.cxx
View file @
257a0dee
...
...
@@ -19,17 +19,17 @@
#include "config.h"
#include "PlaylistRegistry.hxx"
#include "
playlist_plugin.h
"
#include "playlist/
extm3u_playlist_plugin.h
"
#include "playlist/
m3u_playlist_plugin.h
"
#include "playlist/
xspf_playlist_plugin.h
"
#include "
PlaylistPlugin.hxx
"
#include "playlist/
ExtM3uPlaylistPlugin.hxx
"
#include "playlist/
M3uPlaylistPlugin.hxx
"
#include "playlist/
XspfPlaylistPlugin.hxx
"
#include "playlist/LastFMPlaylistPlugin.hxx"
#include "playlist/DespotifyPlaylistPlugin.hxx"
#include "playlist/SoundCloudPlaylistPlugin.hxx"
#include "playlist/
pls_playlist_plugin.h
"
#include "playlist/
asx_playlist_plugin.h
"
#include "playlist/
rss_playlist_plugin.h
"
#include "playlist/
cue_playlist_plugin.h
"
#include "playlist/
PlsPlaylistPlugin.hxx
"
#include "playlist/
AsxPlaylistPlugin.hxx
"
#include "playlist/
RssPlaylistPlugin.hxx
"
#include "playlist/
CuePlaylistPlugin.hxx
"
#include "playlist/EmbeddedCuePlaylistPlugin.hxx"
#include "input_stream.h"
...
...
src/playlist/
asx_playlist_plugin.c
→
src/playlist/
AsxPlaylistPlugin.cxx
View file @
257a0dee
/*
* Copyright (C) 2003-201
1
The Music Player Daemon Project
* Copyright (C) 2003-201
3
The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
...
...
@@ -18,8 +18,8 @@
*/
#include "config.h"
#include "
playlist/asx_playlist_plugin.h
"
#include "
playlist_plugin.h
"
#include "
AsxPlaylistPlugin.hxx
"
#include "
PlaylistPlugin.hxx
"
#include "input_stream.h"
#include "song.h"
#include "tag.h"
...
...
@@ -35,7 +35,7 @@
/**
* This is the state object for the GLib XML parser.
*/
struct
asx_p
arser
{
struct
AsxP
arser
{
/**
* The list of songs (in reverse order because that's faster
* while adding).
...
...
@@ -61,6 +61,11 @@ struct asx_parser {
* element.
*/
struct
song
*
song
;
AsxParser
()
:
songs
(
nullptr
),
state
(
ROOT
)
{}
};
static
const
gchar
*
...
...
@@ -81,19 +86,19 @@ asx_start_element(G_GNUC_UNUSED GMarkupParseContext *context,
const
gchar
**
attribute_values
,
gpointer
user_data
,
G_GNUC_UNUSED
GError
**
error
)
{
struct
asx_parser
*
parser
=
user_data
;
AsxParser
*
parser
=
(
AsxParser
*
)
user_data
;
switch
(
parser
->
state
)
{
case
ROOT
:
case
AsxParser
:
:
ROOT
:
if
(
g_ascii_strcasecmp
(
element_name
,
"entry"
)
==
0
)
{
parser
->
state
=
ENTRY
;
parser
->
state
=
AsxParser
::
ENTRY
;
parser
->
song
=
song_remote_new
(
"asx:"
);
parser
->
tag
=
TAG_NUM_OF_ITEM_TYPES
;
}
break
;
case
ENTRY
:
case
AsxParser
:
:
ENTRY
:
if
(
g_ascii_strcasecmp
(
element_name
,
"ref"
)
==
0
)
{
const
gchar
*
href
=
get_attribute
(
attribute_names
,
attribute_values
,
...
...
@@ -130,13 +135,13 @@ asx_end_element(G_GNUC_UNUSED GMarkupParseContext *context,
const
gchar
*
element_name
,
gpointer
user_data
,
G_GNUC_UNUSED
GError
**
error
)
{
struct
asx_parser
*
parser
=
user_data
;
AsxParser
*
parser
=
(
AsxParser
*
)
user_data
;
switch
(
parser
->
state
)
{
case
ROOT
:
case
AsxParser
:
:
ROOT
:
break
;
case
ENTRY
:
case
AsxParser
:
:
ENTRY
:
if
(
g_ascii_strcasecmp
(
element_name
,
"entry"
)
==
0
)
{
if
(
strcmp
(
parser
->
song
->
uri
,
"asx:"
)
!=
0
)
parser
->
songs
=
g_slist_prepend
(
parser
->
songs
,
...
...
@@ -144,7 +149,7 @@ asx_end_element(G_GNUC_UNUSED GMarkupParseContext *context,
else
song_free
(
parser
->
song
);
parser
->
state
=
ROOT
;
parser
->
state
=
AsxParser
::
ROOT
;
}
else
parser
->
tag
=
TAG_NUM_OF_ITEM_TYPES
;
...
...
@@ -157,13 +162,13 @@ asx_text(G_GNUC_UNUSED GMarkupParseContext *context,
const
gchar
*
text
,
gsize
text_len
,
gpointer
user_data
,
G_GNUC_UNUSED
GError
**
error
)
{
struct
asx_parser
*
parser
=
user_data
;
AsxParser
*
parser
=
(
AsxParser
*
)
user_data
;
switch
(
parser
->
state
)
{
case
ROOT
:
case
AsxParser
:
:
ROOT
:
break
;
case
ENTRY
:
case
AsxParser
:
:
ENTRY
:
if
(
parser
->
tag
!=
TAG_NUM_OF_ITEM_TYPES
)
{
if
(
parser
->
song
->
tag
==
NULL
)
parser
->
song
->
tag
=
tag_new
();
...
...
@@ -176,15 +181,17 @@ asx_text(G_GNUC_UNUSED GMarkupParseContext *context,
}
static
const
GMarkupParser
asx_parser
=
{
.
start_element
=
asx_start_element
,
.
end_element
=
asx_end_element
,
.
text
=
asx_text
,
asx_start_element
,
asx_end_element
,
asx_text
,
nullptr
,
nullptr
,
};
static
void
song_free_callback
(
gpointer
data
,
G_GNUC_UNUSED
gpointer
user_data
)
{
struct
song
*
song
=
data
;
struct
song
*
song
=
(
struct
song
*
)
data
;
song_free
(
song
);
}
...
...
@@ -192,9 +199,9 @@ song_free_callback(gpointer data, G_GNUC_UNUSED gpointer user_data)
static
void
asx_parser_destroy
(
gpointer
data
)
{
struct
asx_parser
*
parser
=
data
;
AsxParser
*
parser
=
(
AsxParser
*
)
data
;
if
(
parser
->
state
>=
ENTRY
)
if
(
parser
->
state
>=
AsxParser
::
ENTRY
)
song_free
(
parser
->
song
);
g_slist_foreach
(
parser
->
songs
,
song_free_callback
,
NULL
);
...
...
@@ -206,7 +213,7 @@ asx_parser_destroy(gpointer data)
*
*/
struct
asx_p
laylist
{
struct
AsxP
laylist
{
struct
playlist_provider
base
;
GSList
*
songs
;
...
...
@@ -215,11 +222,8 @@ struct asx_playlist {
static
struct
playlist_provider
*
asx_open_stream
(
struct
input_stream
*
is
)
{
struct
asx_parser
parser
=
{
.
songs
=
NULL
,
.
state
=
ROOT
,
};
struct
asx_playlist
*
playlist
;
AsxParser
parser
;
AsxPlaylist
*
playlist
;
GMarkupParseContext
*
context
;
char
buffer
[
1024
];
size_t
nbytes
;
...
...
@@ -264,9 +268,9 @@ asx_open_stream(struct input_stream *is)
return
NULL
;
}
/* create a #
asx_p
laylist object from the parsed song list */
/* create a #
AsxP
laylist object from the parsed song list */
playlist
=
g_new
(
struct
asx_p
laylist
,
1
);
playlist
=
g_new
(
AsxP
laylist
,
1
);
playlist_provider_init
(
&
playlist
->
base
,
&
asx_playlist_plugin
);
playlist
->
songs
=
g_slist_reverse
(
parser
.
songs
);
parser
.
songs
=
NULL
;
...
...
@@ -279,7 +283,7 @@ asx_open_stream(struct input_stream *is)
static
void
asx_close
(
struct
playlist_provider
*
_playlist
)
{
struct
asx_playlist
*
playlist
=
(
struct
asx_p
laylist
*
)
_playlist
;
AsxPlaylist
*
playlist
=
(
AsxP
laylist
*
)
_playlist
;
g_slist_foreach
(
playlist
->
songs
,
song_free_callback
,
NULL
);
g_slist_free
(
playlist
->
songs
);
...
...
@@ -289,13 +293,12 @@ asx_close(struct playlist_provider *_playlist)
static
struct
song
*
asx_read
(
struct
playlist_provider
*
_playlist
)
{
struct
asx_playlist
*
playlist
=
(
struct
asx_playlist
*
)
_playlist
;
struct
song
*
song
;
AsxPlaylist
*
playlist
=
(
AsxPlaylist
*
)
_playlist
;
if
(
playlist
->
songs
==
NULL
)
return
NULL
;
s
ong
=
playlist
->
songs
->
data
;
s
truct
song
*
song
=
(
struct
song
*
)
playlist
->
songs
->
data
;
playlist
->
songs
=
g_slist_remove
(
playlist
->
songs
,
song
);
return
song
;
...
...
@@ -312,12 +315,16 @@ static const char *const asx_mime_types[] = {
};
const
struct
playlist_plugin
asx_playlist_plugin
=
{
.
name
=
"asx"
,
"asx"
,
.
open_stream
=
asx_open_stream
,
.
close
=
asx_close
,
.
read
=
asx_read
,
nullptr
,
nullptr
,
nullptr
,
asx_open_stream
,
asx_close
,
asx_read
,
.
suffixes
=
asx_suffixes
,
.
mime_types
=
asx_mime_types
,
nullptr
,
asx_suffixes
,
asx_mime_types
,
};
src/playlist/
asx_playlist_plugin.h
→
src/playlist/
AsxPlaylistPlugin.hxx
View file @
257a0dee
/*
* Copyright (C) 2003-201
1
The Music Player Daemon Project
* Copyright (C) 2003-201
3
The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
...
...
@@ -17,8 +17,8 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef MPD_
PLAYLIST_ASX_PLAYLIST_PLUGIN_H
#define MPD_
PLAYLIST_ASX_PLAYLIST_PLUGIN_H
#ifndef MPD_
ASX_PLAYLIST_PLUGIN_HXX
#define MPD_
ASX_PLAYLIST_PLUGIN_HXX
extern
const
struct
playlist_plugin
asx_playlist_plugin
;
...
...
src/playlist/
cue_playlist_plugin.c
→
src/playlist/
CuePlaylistPlugin.cxx
View file @
257a0dee
/*
* Copyright (C) 2003-201
1
The Music Player Daemon Project
* Copyright (C) 2003-201
3
The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
...
...
@@ -18,13 +18,16 @@
*/
#include "config.h"
#include "
playlist/cue_playlist_plugin.h
"
#include "
playlist_plugin.h
"
#include "
CuePlaylistPlugin.hxx
"
#include "
PlaylistPlugin.hxx
"
#include "tag.h"
#include "song.h"
#include "cue/cue_parser.h"
#include "input_stream.h"
extern
"C"
{
#include "text_input_stream.h"
#include "cue/cue_parser.h"
}
#include <glib.h>
#include <assert.h>
...
...
@@ -33,7 +36,7 @@
#undef G_LOG_DOMAIN
#define G_LOG_DOMAIN "cue"
struct
cue_p
laylist
{
struct
CueP
laylist
{
struct
playlist_provider
base
;
struct
input_stream
*
is
;
...
...
@@ -44,21 +47,20 @@ struct cue_playlist {
static
struct
playlist_provider
*
cue_playlist_open_stream
(
struct
input_stream
*
is
)
{
struct
cue_playlist
*
playlist
=
g_new
(
struct
cue_p
laylist
,
1
);
CuePlaylist
*
playlist
=
g_new
(
CueP
laylist
,
1
);
playlist_provider_init
(
&
playlist
->
base
,
&
cue_playlist_plugin
);
playlist
->
is
=
is
;
playlist
->
tis
=
text_input_stream_new
(
is
);
playlist
->
parser
=
cue_parser_new
();
return
&
playlist
->
base
;
}
static
void
cue_playlist_close
(
struct
playlist_provider
*
_playlist
)
{
struct
cue_playlist
*
playlist
=
(
struct
cue_p
laylist
*
)
_playlist
;
CuePlaylist
*
playlist
=
(
CueP
laylist
*
)
_playlist
;
cue_parser_free
(
playlist
->
parser
);
text_input_stream_free
(
playlist
->
tis
);
...
...
@@ -68,7 +70,7 @@ cue_playlist_close(struct playlist_provider *_playlist)
static
struct
song
*
cue_playlist_read
(
struct
playlist_provider
*
_playlist
)
{
struct
cue_playlist
*
playlist
=
(
struct
cue_p
laylist
*
)
_playlist
;
CuePlaylist
*
playlist
=
(
CueP
laylist
*
)
_playlist
;
struct
song
*
song
=
cue_parser_get
(
playlist
->
parser
);
if
(
song
!=
NULL
)
...
...
@@ -97,12 +99,16 @@ static const char *const cue_playlist_mime_types[] = {
};
const
struct
playlist_plugin
cue_playlist_plugin
=
{
.
name
=
"cue"
,
"cue"
,
.
open_stream
=
cue_playlist_open_stream
,
.
close
=
cue_playlist_close
,
.
read
=
cue_playlist_read
,
nullptr
,
nullptr
,
nullptr
,
cue_playlist_open_stream
,
cue_playlist_close
,
cue_playlist_read
,
.
suffixes
=
cue_playlist_suffixes
,
.
mime_types
=
cue_playlist_mime_types
,
nullptr
,
cue_playlist_suffixes
,
cue_playlist_mime_types
,
};
src/playlist/
cue_playlist_plugin.h
→
src/playlist/
CuePlaylistPlugin.hxx
View file @
257a0dee
/*
* Copyright (C) 2003-201
1
The Music Player Daemon Project
* Copyright (C) 2003-201
3
The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
...
...
@@ -17,8 +17,8 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef MPD_
PLAYLIST_CUE_PLAYLIST_PLUGIN_H
#define MPD_
PLAYLIST_CUE_PLAYLIST_PLUGIN_H
#ifndef MPD_
CUE_PLAYLIST_PLUGIN_HXX
#define MPD_
CUE_PLAYLIST_PLUGIN_HXX
extern
const
struct
playlist_plugin
cue_playlist_plugin
;
...
...
src/playlist/DespotifyPlaylistPlugin.cxx
View file @
257a0dee
...
...
@@ -20,7 +20,7 @@
#include "config.h"
#include "DespotifyPlaylistPlugin.hxx"
#include "DespotifyUtils.hxx"
#include "
playlist_plugin.h
"
#include "
PlaylistPlugin.hxx
"
#include "PlaylistRegistry.hxx"
#include "conf.h"
#include "uri.h"
...
...
src/playlist/EmbeddedCuePlaylistPlugin.cxx
View file @
257a0dee
...
...
@@ -25,7 +25,7 @@
#include "config.h"
#include "EmbeddedCuePlaylistPlugin.hxx"
#include "
playlist_plugin.h
"
#include "
PlaylistPlugin.hxx
"
#include "tag.h"
#include "tag_handler.h"
#include "song.h"
...
...
src/playlist/
extm3u_playlist_plugin.c
→
src/playlist/
ExtM3uPlaylistPlugin.cxx
View file @
257a0dee
/*
* Copyright (C) 2003-201
1
The Music Player Daemon Project
* Copyright (C) 2003-201
3
The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
...
...
@@ -18,20 +18,22 @@
*/
#include "config.h"
#include "playlist/extm3u_playlist_plugin.h"
#include "playlist_plugin.h"
#include "text_input_stream.h"
#include "uri.h"
#include "ExtM3uPlaylistPlugin.hxx"
#include "PlaylistPlugin.hxx"
#include "song.h"
#include "tag.h"
#include "string_util.h"
extern
"C"
{
#include "text_input_stream.h"
}
#include <glib.h>
#include <string.h>
#include <stdlib.h>
struct
extm3u_p
laylist
{
struct
ExtM3uP
laylist
{
struct
playlist_provider
base
;
struct
text_input_stream
*
tis
;
...
...
@@ -40,13 +42,10 @@ struct extm3u_playlist {
static
struct
playlist_provider
*
extm3u_open_stream
(
struct
input_stream
*
is
)
{
struct
extm3u_playlist
*
playlist
;
const
char
*
line
;
playlist
=
g_new
(
struct
extm3u_playlist
,
1
);
ExtM3uPlaylist
*
playlist
=
g_new
(
ExtM3uPlaylist
,
1
);
playlist
->
tis
=
text_input_stream_new
(
is
);
line
=
text_input_stream_read
(
playlist
->
tis
);
const
char
*
line
=
text_input_stream_read
(
playlist
->
tis
);
if
(
line
==
NULL
||
strcmp
(
line
,
"#EXTM3U"
)
!=
0
)
{
/* no EXTM3U header: fall back to the plain m3u
plugin */
...
...
@@ -62,7 +61,7 @@ extm3u_open_stream(struct input_stream *is)
static
void
extm3u_close
(
struct
playlist_provider
*
_playlist
)
{
struct
extm3u_playlist
*
playlist
=
(
struct
extm3u_p
laylist
*
)
_playlist
;
ExtM3uPlaylist
*
playlist
=
(
ExtM3uP
laylist
*
)
_playlist
;
text_input_stream_free
(
playlist
->
tis
);
g_free
(
playlist
);
...
...
@@ -111,7 +110,7 @@ extm3u_parse_tag(const char *line)
static
struct
song
*
extm3u_read
(
struct
playlist_provider
*
_playlist
)
{
struct
extm3u_playlist
*
playlist
=
(
struct
extm3u_p
laylist
*
)
_playlist
;
ExtM3uPlaylist
*
playlist
=
(
ExtM3uP
laylist
*
)
_playlist
;
struct
tag
*
tag
=
NULL
;
const
char
*
line
;
struct
song
*
song
;
...
...
@@ -151,12 +150,16 @@ static const char *const extm3u_mime_types[] = {
};
const
struct
playlist_plugin
extm3u_playlist_plugin
=
{
.
name
=
"extm3u"
,
.
open_stream
=
extm3u_open_stream
,
.
close
=
extm3u_close
,
.
read
=
extm3u_read
,
.
suffixes
=
extm3u_suffixes
,
.
mime_types
=
extm3u_mime_types
,
"extm3u"
,
nullptr
,
nullptr
,
nullptr
,
extm3u_open_stream
,
extm3u_close
,
extm3u_read
,
nullptr
,
extm3u_suffixes
,
extm3u_mime_types
,
};
src/playlist/
extm3u_playlist_plugin.h
→
src/playlist/
ExtM3uPlaylistPlugin.hxx
View file @
257a0dee
/*
* Copyright (C) 2003-201
1
The Music Player Daemon Project
* Copyright (C) 2003-201
3
The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
...
...
@@ -17,8 +17,8 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef MPD_
PLAYLIST_EXTM3U_PLAYLIST_PLUGIN_H
#define MPD_
PLAYLIST_EXTM3U_PLAYLIST_PLUGIN_H
#ifndef MPD_
EXTM3U_PLAYLIST_PLUGIN_HXX
#define MPD_
EXTM3U_PLAYLIST_PLUGIN_HXX
extern
const
struct
playlist_plugin
extm3u_playlist_plugin
;
...
...
src/playlist/LastFMPlaylistPlugin.cxx
View file @
257a0dee
...
...
@@ -19,10 +19,9 @@
#include "config.h"
#include "LastFMPlaylistPlugin.hxx"
#include "
playlist_plugin.h
"
#include "
PlaylistPlugin.hxx
"
#include "PlaylistRegistry.hxx"
#include "conf.h"
#include "uri.h"
#include "song.h"
#include "input_stream.h"
...
...
src/playlist/
m3u_playlist_plugin.c
→
src/playlist/
M3uPlaylistPlugin.cxx
View file @
257a0dee
/*
* Copyright (C) 2003-201
1
The Music Player Daemon Project
* Copyright (C) 2003-201
3
The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
...
...
@@ -18,15 +18,17 @@
*/
#include "config.h"
#include "playlist/m3u_playlist_plugin.h"
#include "playlist_plugin.h"
#include "text_input_stream.h"
#include "uri.h"
#include "M3uPlaylistPlugin.hxx"
#include "PlaylistPlugin.hxx"
#include "song.h"
extern
"C"
{
#include "text_input_stream.h"
}
#include <glib.h>
struct
m3u_p
laylist
{
struct
M3uP
laylist
{
struct
playlist_provider
base
;
struct
text_input_stream
*
tis
;
...
...
@@ -35,7 +37,7 @@ struct m3u_playlist {
static
struct
playlist_provider
*
m3u_open_stream
(
struct
input_stream
*
is
)
{
struct
m3u_playlist
*
playlist
=
g_new
(
struct
m3u_p
laylist
,
1
);
M3uPlaylist
*
playlist
=
g_new
(
M3uP
laylist
,
1
);
playlist_provider_init
(
&
playlist
->
base
,
&
m3u_playlist_plugin
);
playlist
->
tis
=
text_input_stream_new
(
is
);
...
...
@@ -46,7 +48,7 @@ m3u_open_stream(struct input_stream *is)
static
void
m3u_close
(
struct
playlist_provider
*
_playlist
)
{
struct
m3u_playlist
*
playlist
=
(
struct
m3u_p
laylist
*
)
_playlist
;
M3uPlaylist
*
playlist
=
(
M3uP
laylist
*
)
_playlist
;
text_input_stream_free
(
playlist
->
tis
);
g_free
(
playlist
);
...
...
@@ -55,7 +57,7 @@ m3u_close(struct playlist_provider *_playlist)
static
struct
song
*
m3u_read
(
struct
playlist_provider
*
_playlist
)
{
struct
m3u_playlist
*
playlist
=
(
struct
m3u_p
laylist
*
)
_playlist
;
M3uPlaylist
*
playlist
=
(
M3uP
laylist
*
)
_playlist
;
const
char
*
line
;
do
{
...
...
@@ -81,12 +83,16 @@ static const char *const m3u_mime_types[] = {
};
const
struct
playlist_plugin
m3u_playlist_plugin
=
{
.
name
=
"m3u"
,
"m3u"
,
.
open_stream
=
m3u_open_stream
,
.
close
=
m3u_close
,
.
read
=
m3u_read
,
nullptr
,
nullptr
,
nullptr
,
m3u_open_stream
,
m3u_close
,
m3u_read
,
.
suffixes
=
m3u_suffixes
,
.
mime_types
=
m3u_mime_types
,
nullptr
,
m3u_suffixes
,
m3u_mime_types
,
};
src/playlist/
m3u_playlist_plugin.h
→
src/playlist/
M3uPlaylistPlugin.hxx
View file @
257a0dee
/*
* Copyright (C) 2003-201
1
The Music Player Daemon Project
* Copyright (C) 2003-201
3
The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
...
...
@@ -17,8 +17,8 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef MPD_
PLAYLIST_M3U_PLAYLIST_PLUGIN_H
#define MPD_
PLAYLIST_M3U_PLAYLIST_PLUGIN_H
#ifndef MPD_
M3U_PLAYLIST_PLUGIN_HXX
#define MPD_
M3U_PLAYLIST_PLUGIN_HXX
extern
const
struct
playlist_plugin
m3u_playlist_plugin
;
...
...
src/playlist/
pls_playlist_plugin.c
→
src/playlist/
PlsPlaylistPlugin.cxx
View file @
257a0dee
/*
* Copyright (C) 2003-201
1
The Music Player Daemon Project
* Copyright (C) 2003-201
3
The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
...
...
@@ -18,21 +18,22 @@
*/
#include "config.h"
#include "
playlist/pls_playlist_plugin.h
"
#include "
playlist_plugin.h
"
#include "
PlsPlaylistPlugin.hxx
"
#include "
PlaylistPlugin.hxx
"
#include "input_stream.h"
#include "uri.h"
#include "song.h"
#include "tag.h"
#include <glib.h>
struct
pls_p
laylist
{
struct
PlsP
laylist
{
struct
playlist_provider
base
;
GSList
*
songs
;
};
static
void
pls_parser
(
GKeyFile
*
keyfile
,
struct
pls_p
laylist
*
playlist
)
static
void
pls_parser
(
GKeyFile
*
keyfile
,
PlsP
laylist
*
playlist
)
{
gchar
*
key
;
gchar
*
value
;
...
...
@@ -111,7 +112,7 @@ pls_open_stream(struct input_stream *is)
char
buffer
[
1024
];
bool
success
;
GKeyFile
*
keyfile
;
struct
pls_p
laylist
*
playlist
;
PlsP
laylist
*
playlist
;
GString
*
kf_data
=
g_string_new
(
""
);
do
{
...
...
@@ -152,7 +153,7 @@ pls_open_stream(struct input_stream *is)
return
NULL
;
}
playlist
=
g_new
(
struct
pls_p
laylist
,
1
);
playlist
=
g_new
(
PlsP
laylist
,
1
);
playlist_provider_init
(
&
playlist
->
base
,
&
pls_playlist_plugin
);
playlist
->
songs
=
NULL
;
...
...
@@ -166,7 +167,7 @@ pls_open_stream(struct input_stream *is)
static
void
song_free_callback
(
gpointer
data
,
G_GNUC_UNUSED
gpointer
user_data
)
{
struct
song
*
song
=
data
;
struct
song
*
song
=
(
struct
song
*
)
data
;
song_free
(
song
);
}
...
...
@@ -174,7 +175,7 @@ song_free_callback(gpointer data, G_GNUC_UNUSED gpointer user_data)
static
void
pls_close
(
struct
playlist_provider
*
_playlist
)
{
struct
pls_playlist
*
playlist
=
(
struct
pls_p
laylist
*
)
_playlist
;
PlsPlaylist
*
playlist
=
(
PlsP
laylist
*
)
_playlist
;
g_slist_foreach
(
playlist
->
songs
,
song_free_callback
,
NULL
);
g_slist_free
(
playlist
->
songs
);
...
...
@@ -186,13 +187,12 @@ pls_close(struct playlist_provider *_playlist)
static
struct
song
*
pls_read
(
struct
playlist_provider
*
_playlist
)
{
struct
pls_playlist
*
playlist
=
(
struct
pls_playlist
*
)
_playlist
;
struct
song
*
song
;
PlsPlaylist
*
playlist
=
(
PlsPlaylist
*
)
_playlist
;
if
(
playlist
->
songs
==
NULL
)
return
NULL
;
s
ong
=
playlist
->
songs
->
data
;
s
truct
song
*
song
=
(
struct
song
*
)
playlist
->
songs
->
data
;
playlist
->
songs
=
g_slist_remove
(
playlist
->
songs
,
song
);
return
song
;
...
...
@@ -209,12 +209,16 @@ static const char *const pls_mime_types[] = {
};
const
struct
playlist_plugin
pls_playlist_plugin
=
{
.
name
=
"pls"
,
"pls"
,
.
open_stream
=
pls_open_stream
,
.
close
=
pls_close
,
.
read
=
pls_read
,
nullptr
,
nullptr
,
nullptr
,
pls_open_stream
,
pls_close
,
pls_read
,
.
suffixes
=
pls_suffixes
,
.
mime_types
=
pls_mime_types
,
nullptr
,
pls_suffixes
,
pls_mime_types
,
};
src/playlist/
pls_playlist_plugin.h
→
src/playlist/
PlsPlaylistPlugin.hxx
View file @
257a0dee
/*
* Copyright (C) 2003-201
1
The Music Player Daemon Project
* Copyright (C) 2003-201
3
The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
...
...
@@ -17,8 +17,8 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef MPD_PL
AYLIST_PLS_PLAYLIST_PLUGIN_H
#define MPD_PL
AYLIST_PLS_PLAYLIST_PLUGIN_H
#ifndef MPD_PL
S_PLAYLIST_PLUGIN_HXX
#define MPD_PL
S_PLAYLIST_PLUGIN_HXX
extern
const
struct
playlist_plugin
pls_playlist_plugin
;
...
...
src/playlist/
rss_playlist_plugin.c
→
src/playlist/
RssPlaylistPlugin.cxx
View file @
257a0dee
/*
* Copyright (C) 2003-201
1
The Music Player Daemon Project
* Copyright (C) 2003-201
3
The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
...
...
@@ -18,8 +18,8 @@
*/
#include "config.h"
#include "
playlist/rss_playlist_plugin.h
"
#include "
playlist_plugin.h
"
#include "
RssPlaylistPlugin.hxx
"
#include "
PlaylistPlugin.hxx
"
#include "input_stream.h"
#include "song.h"
#include "tag.h"
...
...
@@ -35,7 +35,7 @@
/**
* This is the state object for the GLib XML parser.
*/
struct
rss_p
arser
{
struct
RssP
arser
{
/**
* The list of songs (in reverse order because that's faster
* while adding).
...
...
@@ -61,6 +61,9 @@ struct rss_parser {
* element.
*/
struct
song
*
song
;
RssParser
()
:
songs
(
nullptr
),
state
(
ROOT
)
{}
};
static
const
gchar
*
...
...
@@ -81,19 +84,19 @@ rss_start_element(G_GNUC_UNUSED GMarkupParseContext *context,
const
gchar
**
attribute_values
,
gpointer
user_data
,
G_GNUC_UNUSED
GError
**
error
)
{
struct
rss_parser
*
parser
=
user_data
;
RssParser
*
parser
=
(
RssParser
*
)
user_data
;
switch
(
parser
->
state
)
{
case
ROOT
:
case
R
ssParser
:
:
R
OOT
:
if
(
g_ascii_strcasecmp
(
element_name
,
"item"
)
==
0
)
{
parser
->
state
=
ITEM
;
parser
->
state
=
RssParser
::
ITEM
;
parser
->
song
=
song_remote_new
(
"rss:"
);
parser
->
tag
=
TAG_NUM_OF_ITEM_TYPES
;
}
break
;
case
ITEM
:
case
RssParser
:
:
ITEM
:
if
(
g_ascii_strcasecmp
(
element_name
,
"enclosure"
)
==
0
)
{
const
gchar
*
href
=
get_attribute
(
attribute_names
,
attribute_values
,
...
...
@@ -128,13 +131,13 @@ rss_end_element(G_GNUC_UNUSED GMarkupParseContext *context,
const
gchar
*
element_name
,
gpointer
user_data
,
G_GNUC_UNUSED
GError
**
error
)
{
struct
rss_parser
*
parser
=
user_data
;
RssParser
*
parser
=
(
RssParser
*
)
user_data
;
switch
(
parser
->
state
)
{
case
ROOT
:
case
R
ssParser
:
:
R
OOT
:
break
;
case
ITEM
:
case
RssParser
:
:
ITEM
:
if
(
g_ascii_strcasecmp
(
element_name
,
"item"
)
==
0
)
{
if
(
strcmp
(
parser
->
song
->
uri
,
"rss:"
)
!=
0
)
parser
->
songs
=
g_slist_prepend
(
parser
->
songs
,
...
...
@@ -142,7 +145,7 @@ rss_end_element(G_GNUC_UNUSED GMarkupParseContext *context,
else
song_free
(
parser
->
song
);
parser
->
state
=
ROOT
;
parser
->
state
=
R
ssParser
::
R
OOT
;
}
else
parser
->
tag
=
TAG_NUM_OF_ITEM_TYPES
;
...
...
@@ -155,13 +158,13 @@ rss_text(G_GNUC_UNUSED GMarkupParseContext *context,
const
gchar
*
text
,
gsize
text_len
,
gpointer
user_data
,
G_GNUC_UNUSED
GError
**
error
)
{
struct
rss_parser
*
parser
=
user_data
;
RssParser
*
parser
=
(
RssParser
*
)
user_data
;
switch
(
parser
->
state
)
{
case
ROOT
:
case
R
ssParser
:
:
R
OOT
:
break
;
case
ITEM
:
case
RssParser
:
:
ITEM
:
if
(
parser
->
tag
!=
TAG_NUM_OF_ITEM_TYPES
)
{
if
(
parser
->
song
->
tag
==
NULL
)
parser
->
song
->
tag
=
tag_new
();
...
...
@@ -174,15 +177,17 @@ rss_text(G_GNUC_UNUSED GMarkupParseContext *context,
}
static
const
GMarkupParser
rss_parser
=
{
.
start_element
=
rss_start_element
,
.
end_element
=
rss_end_element
,
.
text
=
rss_text
,
rss_start_element
,
rss_end_element
,
rss_text
,
nullptr
,
nullptr
,
};
static
void
song_free_callback
(
gpointer
data
,
G_GNUC_UNUSED
gpointer
user_data
)
{
struct
song
*
song
=
data
;
struct
song
*
song
=
(
struct
song
*
)
data
;
song_free
(
song
);
}
...
...
@@ -190,9 +195,9 @@ song_free_callback(gpointer data, G_GNUC_UNUSED gpointer user_data)
static
void
rss_parser_destroy
(
gpointer
data
)
{
struct
rss_parser
*
parser
=
data
;
RssParser
*
parser
=
(
RssParser
*
)
data
;
if
(
parser
->
state
>=
ITEM
)
if
(
parser
->
state
>=
RssParser
::
ITEM
)
song_free
(
parser
->
song
);
g_slist_foreach
(
parser
->
songs
,
song_free_callback
,
NULL
);
...
...
@@ -204,7 +209,7 @@ rss_parser_destroy(gpointer data)
*
*/
struct
rss_p
laylist
{
struct
RssP
laylist
{
struct
playlist_provider
base
;
GSList
*
songs
;
...
...
@@ -213,11 +218,8 @@ struct rss_playlist {
static
struct
playlist_provider
*
rss_open_stream
(
struct
input_stream
*
is
)
{
struct
rss_parser
parser
=
{
.
songs
=
NULL
,
.
state
=
ROOT
,
};
struct
rss_playlist
*
playlist
;
RssParser
parser
;
RssPlaylist
*
playlist
;
GMarkupParseContext
*
context
;
char
buffer
[
1024
];
size_t
nbytes
;
...
...
@@ -264,7 +266,7 @@ rss_open_stream(struct input_stream *is)
/* create a #rss_playlist object from the parsed song list */
playlist
=
g_new
(
struct
rss_p
laylist
,
1
);
playlist
=
g_new
(
RssP
laylist
,
1
);
playlist_provider_init
(
&
playlist
->
base
,
&
rss_playlist_plugin
);
playlist
->
songs
=
g_slist_reverse
(
parser
.
songs
);
parser
.
songs
=
NULL
;
...
...
@@ -277,7 +279,7 @@ rss_open_stream(struct input_stream *is)
static
void
rss_close
(
struct
playlist_provider
*
_playlist
)
{
struct
rss_playlist
*
playlist
=
(
struct
rss_p
laylist
*
)
_playlist
;
RssPlaylist
*
playlist
=
(
RssP
laylist
*
)
_playlist
;
g_slist_foreach
(
playlist
->
songs
,
song_free_callback
,
NULL
);
g_slist_free
(
playlist
->
songs
);
...
...
@@ -287,13 +289,12 @@ rss_close(struct playlist_provider *_playlist)
static
struct
song
*
rss_read
(
struct
playlist_provider
*
_playlist
)
{
struct
rss_playlist
*
playlist
=
(
struct
rss_playlist
*
)
_playlist
;
struct
song
*
song
;
RssPlaylist
*
playlist
=
(
RssPlaylist
*
)
_playlist
;
if
(
playlist
->
songs
==
NULL
)
return
NULL
;
s
ong
=
playlist
->
songs
->
data
;
s
truct
song
*
song
=
(
struct
song
*
)
playlist
->
songs
->
data
;
playlist
->
songs
=
g_slist_remove
(
playlist
->
songs
,
song
);
return
song
;
...
...
@@ -311,12 +312,16 @@ static const char *const rss_mime_types[] = {
};
const
struct
playlist_plugin
rss_playlist_plugin
=
{
.
name
=
"rss"
,
"rss"
,
.
open_stream
=
rss_open_stream
,
.
close
=
rss_close
,
.
read
=
rss_read
,
nullptr
,
nullptr
,
nullptr
,
rss_open_stream
,
rss_close
,
rss_read
,
.
suffixes
=
rss_suffixes
,
.
mime_types
=
rss_mime_types
,
nullptr
,
rss_suffixes
,
rss_mime_types
,
};
src/playlist/
rss_playlist_plugin.h
→
src/playlist/
RssPlaylistPlugin.hxx
View file @
257a0dee
/*
* Copyright (C) 2003-201
1
The Music Player Daemon Project
* Copyright (C) 2003-201
3
The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
...
...
@@ -17,8 +17,8 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef MPD_
PLAYLIST_RSS_PLAYLIST_PLUGIN_H
#define MPD_
PLAYLIST_RSS_PLAYLIST_PLUGIN_H
#ifndef MPD_
RSS_PLAYLIST_PLUGIN_HXX
#define MPD_
RSS_PLAYLIST_PLUGIN_HXX
extern
const
struct
playlist_plugin
rss_playlist_plugin
;
...
...
src/playlist/SoundCloudPlaylistPlugin.cxx
View file @
257a0dee
...
...
@@ -19,9 +19,9 @@
#include "config.h"
#include "SoundCloudPlaylistPlugin.hxx"
#include "PlaylistPlugin.hxx"
#include "conf.h"
#include "input_stream.h"
#include "playlist_plugin.h"
#include "song.h"
#include "tag.h"
...
...
src/playlist/
xspf_playlist_plugin.c
→
src/playlist/
XspfPlaylistPlugin.cxx
View file @
257a0dee
/*
* Copyright (C) 2003-201
1
The Music Player Daemon Project
* Copyright (C) 2003-201
3
The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
...
...
@@ -18,8 +18,8 @@
*/
#include "config.h"
#include "
playlist/xspf_playlist_plugin.h
"
#include "
playlist_plugin.h
"
#include "
XspfPlaylistPlugin.hxx
"
#include "
PlaylistPlugin.hxx
"
#include "input_stream.h"
#include "uri.h"
#include "song.h"
...
...
@@ -36,7 +36,7 @@
/**
* This is the state object for the GLib XML parser.
*/
struct
xspf_p
arser
{
struct
XspfP
arser
{
/**
* The list of songs (in reverse order because that's faster
* while adding).
...
...
@@ -63,6 +63,9 @@ struct xspf_parser {
* element.
*/
struct
song
*
song
;
XspfParser
()
:
songs
(
nullptr
),
state
(
ROOT
)
{}
};
static
void
...
...
@@ -72,33 +75,33 @@ xspf_start_element(G_GNUC_UNUSED GMarkupParseContext *context,
G_GNUC_UNUSED
const
gchar
**
attribute_values
,
gpointer
user_data
,
G_GNUC_UNUSED
GError
**
error
)
{
struct
xspf_parser
*
parser
=
user_data
;
XspfParser
*
parser
=
(
XspfParser
*
)
user_data
;
switch
(
parser
->
state
)
{
case
ROOT
:
case
XspfParser
:
:
ROOT
:
if
(
strcmp
(
element_name
,
"playlist"
)
==
0
)
parser
->
state
=
PLAYLIST
;
parser
->
state
=
XspfParser
::
PLAYLIST
;
break
;
case
PLAYLIST
:
case
XspfParser
:
:
PLAYLIST
:
if
(
strcmp
(
element_name
,
"trackList"
)
==
0
)
parser
->
state
=
TRACKLIST
;
parser
->
state
=
XspfParser
::
TRACKLIST
;
break
;
case
TRACKLIST
:
case
XspfParser
:
:
TRACKLIST
:
if
(
strcmp
(
element_name
,
"track"
)
==
0
)
{
parser
->
state
=
TRACK
;
parser
->
state
=
XspfParser
::
TRACK
;
parser
->
song
=
NULL
;
parser
->
tag
=
TAG_NUM_OF_ITEM_TYPES
;
}
break
;
case
TRACK
:
case
XspfParser
:
:
TRACK
:
if
(
strcmp
(
element_name
,
"location"
)
==
0
)
parser
->
state
=
LOCATION
;
parser
->
state
=
XspfParser
::
LOCATION
;
else
if
(
strcmp
(
element_name
,
"title"
)
==
0
)
parser
->
tag
=
TAG_TITLE
;
else
if
(
strcmp
(
element_name
,
"creator"
)
==
0
)
...
...
@@ -114,7 +117,7 @@ xspf_start_element(G_GNUC_UNUSED GMarkupParseContext *context,
break
;
case
LOCATION
:
case
XspfParser
:
:
LOCATION
:
break
;
}
}
...
...
@@ -124,38 +127,38 @@ xspf_end_element(G_GNUC_UNUSED GMarkupParseContext *context,
const
gchar
*
element_name
,
gpointer
user_data
,
G_GNUC_UNUSED
GError
**
error
)
{
struct
xspf_parser
*
parser
=
user_data
;
XspfParser
*
parser
=
(
XspfParser
*
)
user_data
;
switch
(
parser
->
state
)
{
case
ROOT
:
case
XspfParser
:
:
ROOT
:
break
;
case
PLAYLIST
:
case
XspfParser
:
:
PLAYLIST
:
if
(
strcmp
(
element_name
,
"playlist"
)
==
0
)
parser
->
state
=
ROOT
;
parser
->
state
=
XspfParser
::
ROOT
;
break
;
case
TRACKLIST
:
case
XspfParser
:
:
TRACKLIST
:
if
(
strcmp
(
element_name
,
"tracklist"
)
==
0
)
parser
->
state
=
PLAYLIST
;
parser
->
state
=
XspfParser
::
PLAYLIST
;
break
;
case
TRACK
:
case
XspfParser
:
:
TRACK
:
if
(
strcmp
(
element_name
,
"track"
)
==
0
)
{
if
(
parser
->
song
!=
NULL
)
parser
->
songs
=
g_slist_prepend
(
parser
->
songs
,
parser
->
song
);
parser
->
state
=
TRACKLIST
;
parser
->
state
=
XspfParser
::
TRACKLIST
;
}
else
parser
->
tag
=
TAG_NUM_OF_ITEM_TYPES
;
break
;
case
LOCATION
:
parser
->
state
=
TRACK
;
case
XspfParser
:
:
LOCATION
:
parser
->
state
=
XspfParser
::
TRACK
;
break
;
}
}
...
...
@@ -165,15 +168,15 @@ xspf_text(G_GNUC_UNUSED GMarkupParseContext *context,
const
gchar
*
text
,
gsize
text_len
,
gpointer
user_data
,
G_GNUC_UNUSED
GError
**
error
)
{
struct
xspf_parser
*
parser
=
user_data
;
XspfParser
*
parser
=
(
XspfParser
*
)
user_data
;
switch
(
parser
->
state
)
{
case
ROOT
:
case
PLAYLIST
:
case
TRACKLIST
:
case
XspfParser
:
:
ROOT
:
case
XspfParser
:
:
PLAYLIST
:
case
XspfParser
:
:
TRACKLIST
:
break
;
case
TRACK
:
case
XspfParser
:
:
TRACK
:
if
(
parser
->
song
!=
NULL
&&
parser
->
tag
!=
TAG_NUM_OF_ITEM_TYPES
)
{
if
(
parser
->
song
->
tag
==
NULL
)
...
...
@@ -184,7 +187,7 @@ xspf_text(G_GNUC_UNUSED GMarkupParseContext *context,
break
;
case
LOCATION
:
case
XspfParser
:
:
LOCATION
:
if
(
parser
->
song
==
NULL
)
{
char
*
uri
=
g_strndup
(
text
,
text_len
);
parser
->
song
=
song_remote_new
(
uri
);
...
...
@@ -196,15 +199,17 @@ xspf_text(G_GNUC_UNUSED GMarkupParseContext *context,
}
static
const
GMarkupParser
xspf_parser
=
{
.
start_element
=
xspf_start_element
,
.
end_element
=
xspf_end_element
,
.
text
=
xspf_text
,
xspf_start_element
,
xspf_end_element
,
xspf_text
,
nullptr
,
nullptr
,
};
static
void
song_free_callback
(
gpointer
data
,
G_GNUC_UNUSED
gpointer
user_data
)
{
struct
song
*
song
=
data
;
struct
song
*
song
=
(
struct
song
*
)
data
;
song_free
(
song
);
}
...
...
@@ -212,9 +217,9 @@ song_free_callback(gpointer data, G_GNUC_UNUSED gpointer user_data)
static
void
xspf_parser_destroy
(
gpointer
data
)
{
struct
xspf_parser
*
parser
=
data
;
XspfParser
*
parser
=
(
XspfParser
*
)
data
;
if
(
parser
->
state
>=
TRACK
&&
parser
->
song
!=
NULL
)
if
(
parser
->
state
>=
XspfParser
::
TRACK
&&
parser
->
song
!=
NULL
)
song_free
(
parser
->
song
);
g_slist_foreach
(
parser
->
songs
,
song_free_callback
,
NULL
);
...
...
@@ -226,7 +231,7 @@ xspf_parser_destroy(gpointer data)
*
*/
struct
xspf_p
laylist
{
struct
XspfP
laylist
{
struct
playlist_provider
base
;
GSList
*
songs
;
...
...
@@ -235,11 +240,8 @@ struct xspf_playlist {
static
struct
playlist_provider
*
xspf_open_stream
(
struct
input_stream
*
is
)
{
struct
xspf_parser
parser
=
{
.
songs
=
NULL
,
.
state
=
ROOT
,
};
struct
xspf_playlist
*
playlist
;
XspfParser
parser
;
XspfPlaylist
*
playlist
;
GMarkupParseContext
*
context
;
char
buffer
[
1024
];
size_t
nbytes
;
...
...
@@ -286,7 +288,7 @@ xspf_open_stream(struct input_stream *is)
/* create a #xspf_playlist object from the parsed song list */
playlist
=
g_new
(
struct
xspf_p
laylist
,
1
);
playlist
=
g_new
(
XspfP
laylist
,
1
);
playlist_provider_init
(
&
playlist
->
base
,
&
xspf_playlist_plugin
);
playlist
->
songs
=
g_slist_reverse
(
parser
.
songs
);
parser
.
songs
=
NULL
;
...
...
@@ -299,7 +301,7 @@ xspf_open_stream(struct input_stream *is)
static
void
xspf_close
(
struct
playlist_provider
*
_playlist
)
{
struct
xspf_playlist
*
playlist
=
(
struct
xspf_p
laylist
*
)
_playlist
;
XspfPlaylist
*
playlist
=
(
XspfP
laylist
*
)
_playlist
;
g_slist_foreach
(
playlist
->
songs
,
song_free_callback
,
NULL
);
g_slist_free
(
playlist
->
songs
);
...
...
@@ -309,13 +311,12 @@ xspf_close(struct playlist_provider *_playlist)
static
struct
song
*
xspf_read
(
struct
playlist_provider
*
_playlist
)
{
struct
xspf_playlist
*
playlist
=
(
struct
xspf_playlist
*
)
_playlist
;
struct
song
*
song
;
XspfPlaylist
*
playlist
=
(
XspfPlaylist
*
)
_playlist
;
if
(
playlist
->
songs
==
NULL
)
return
NULL
;
s
ong
=
playlist
->
songs
->
data
;
s
truct
song
*
song
=
(
struct
song
*
)
playlist
->
songs
->
data
;
playlist
->
songs
=
g_slist_remove
(
playlist
->
songs
,
song
);
return
song
;
...
...
@@ -332,12 +333,16 @@ static const char *const xspf_mime_types[] = {
};
const
struct
playlist_plugin
xspf_playlist_plugin
=
{
.
name
=
"xspf"
,
"xspf"
,
.
open_stream
=
xspf_open_stream
,
.
close
=
xspf_close
,
.
read
=
xspf_read
,
nullptr
,
nullptr
,
nullptr
,
xspf_open_stream
,
xspf_close
,
xspf_read
,
.
suffixes
=
xspf_suffixes
,
.
mime_types
=
xspf_mime_types
,
nullptr
,
xspf_suffixes
,
xspf_mime_types
,
};
src/playlist/
xspf_playlist_plugin.h
→
src/playlist/
XspfPlaylistPlugin.hxx
View file @
257a0dee
/*
* Copyright (C) 2003-201
1
The Music Player Daemon Project
* Copyright (C) 2003-201
3
The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
...
...
@@ -17,8 +17,8 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef MPD_
PLAYLIST_XSPF_PLAYLIST_PLUGIN_H
#define MPD_
PLAYLIST_XSPF_PLAYLIST_PLUGIN_H
#ifndef MPD_
XSPF_PLAYLIST_PLUGIN_HXX
#define MPD_
XSPF_PLAYLIST_PLUGIN_HXX
extern
const
struct
playlist_plugin
xspf_playlist_plugin
;
...
...
test/dump_playlist.cxx
View file @
257a0dee
...
...
@@ -27,7 +27,7 @@
#include "InputInit.hxx"
#include "IOThread.hxx"
#include "PlaylistRegistry.hxx"
#include "
playlist_plugin.h
"
#include "
PlaylistPlugin.hxx
"
extern
"C"
{
#include "decoder_list.h"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment