# HG changeset patch # User nenolod # Date 1155261801 25200 # Node ID 51c1bf500d3fff994da83cba8ac3f6c35f525830 # Parent f4ece39e4252ce4827296b76f035038db0afdb45 [svn] - some experimental shit diff -r f4ece39e4252 -r 51c1bf500d3f ChangeLog --- a/ChangeLog Thu Aug 10 18:49:44 2006 -0700 +++ b/ChangeLog Thu Aug 10 19:03:21 2006 -0700 @@ -1,3 +1,16 @@ +2006-08-11 01:49:44 +0000 William Pitcock + revision [2020] + - saving now uses PlaylistContainer class. + Because there is no PlaylistContainer implementations yet, saving is presently broken. + + + Changes: Modified: + +9 -18 trunk/audacious/playlist.c + +1 -1 trunk/audacious/playlist.h + +1 -1 trunk/audacious/playlist_container.h + +7 -5 trunk/audacious/ui_playlist.c + + 2006-08-11 01:40:52 +0000 William Pitcock revision [2018] - further integration diff -r f4ece39e4252 -r 51c1bf500d3f audacious/Makefile --- a/audacious/Makefile Thu Aug 10 18:49:44 2006 -0700 +++ b/audacious/Makefile Thu Aug 10 19:03:21 2006 -0700 @@ -44,6 +44,7 @@ pluginenum.c \ playlist.c \ playlist_container.c \ + playlist_pls.c \ controlsocket.c \ dock.c \ playback.c \ diff -r f4ece39e4252 -r 51c1bf500d3f audacious/playlist.c --- a/audacious/playlist.c Thu Aug 10 18:49:44 2006 -0700 +++ b/audacious/playlist.c Thu Aug 10 19:03:21 2006 -0700 @@ -123,10 +123,6 @@ static guint playlist_load_ins(const gchar * filename, gint pos); -static void playlist_load_ins_file(const gchar * filename, - const gchar * playlist_name, gint pos, - const gchar * title, gint len); - static void playlist_generate_shuffle_list(void); static void playlist_generate_shuffle_list_nolock(void); @@ -1345,7 +1341,7 @@ return ret; } -static void +void playlist_load_ins_file(const gchar * filename_p, const gchar * playlist_name, gint pos, const gchar * title, gint len) @@ -1434,43 +1430,6 @@ } static guint -playlist_load_pls(const gchar * filename, gint pos) -{ - guint i, count, added_count = 0; - gchar key[10]; - gchar *line; - - g_return_val_if_fail(filename != NULL, 0); - - if (!str_has_suffix_nocase(filename, ".pls")) - return 0; - - if (!(line = read_ini_string(filename, "playlist", "NumberOfEntries"))) - return 0; - - count = atoi(line); - g_free(line); - - for (i = 1; i <= count; i++) { - g_snprintf(key, sizeof(key), "File%d", i); - if ((line = read_ini_string(filename, "playlist", key))) { - playlist_load_ins_file(line, filename, pos, NULL, -1); - added_count++; - - if (pos >= 0) - pos++; - - g_free(line); - } - } - - playlist_generate_shuffle_list(); - playlistwin_update_list(); - - return added_count; -} - -static guint playlist_load_m3u(const gchar * filename, gint pos) { FILE *file; @@ -1548,16 +1507,21 @@ static guint playlist_load_ins(const gchar * filename, gint pos) { - guint added_count; + PlaylistContainer *plc; + gchar *ext; g_return_val_if_fail(filename != NULL, 0); - /* .pls ? */ - if ((added_count = playlist_load_pls(filename, pos)) > 0) - return added_count; - - /* Assume .m3u */ - return playlist_load_m3u(filename, pos); + ext = strrchr(filename, '.') + 1; + plc = playlist_container_find(ext); + + g_return_val_if_fail(plc != NULL, 0); + g_return_val_if_fail(plc->plc_read != NULL, 0); + + playlist_generate_shuffle_list(); + playlistwin_update_list(); + + return 1; } GList * diff -r f4ece39e4252 -r 51c1bf500d3f audacious/playlist.h --- a/audacious/playlist.h Thu Aug 10 18:49:44 2006 -0700 +++ b/audacious/playlist.h Thu Aug 10 19:03:21 2006 -0700 @@ -171,4 +171,8 @@ extern PlaylistEntry *playlist_position; +extern void playlist_load_ins_file(const gchar * filename, + const gchar * playlist_name, gint pos, + const gchar * title, gint len); + #endif diff -r f4ece39e4252 -r 51c1bf500d3f audacious/playlist_pls.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/audacious/playlist_pls.c Thu Aug 10 19:03:21 2006 -0700 @@ -0,0 +1,100 @@ +/* + * Audacious: A cross-platform multimedia player + * Copyright (c) 2006 William Pitcock, Tony Vroon, George Averill, + * Giacomo Lozito, Derek Pomery and Yoshiki Yazawa. + * + * 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 + +#include +#include +#include +#include + +#include "playlist.h" +#include "playlist_container.h" + +static void +playlist_load_pls(const gchar * filename, gint pos) +{ + guint i, count, added_count = 0; + gchar key[10]; + gchar *line; + + g_return_val_if_fail(filename != NULL, 0); + + if (!str_has_suffix_nocase(filename, ".pls")) + return; + + if (!(line = read_ini_string(filename, "playlist", "NumberOfEntries"))) + return; + + count = atoi(line); + g_free(line); + + for (i = 1; i <= count; i++) { + g_snprintf(key, sizeof(key), "File%d", i); + if ((line = read_ini_string(filename, "playlist", key))) { + playlist_load_ins_file(line, filename, pos, NULL, -1); + added_count++; + + if (pos >= 0) + pos++; + + g_free(line); + } + } +} + +static void +playlist_save_pls(gchar *filename, gint pos) +{ + GList *node; + FILE *file = fopen(filename, "wb"); + + g_return_if_fail(file != NULL); + + g_fprintf(file, "[playlist]\n"); + g_fprintf(file, "NumberOfEntries=%d\n", playlist_get_length()); + + PLAYLIST_LOCK(); + + for (node = playlist_get(); node; node = g_list_next(node)) { + PlaylistEntry *entry = PLAYLIST_ENTRY(node->data); + + g_fprintf(file, "File%d=%s\n", g_list_position(playlist_get(), node) + 1, + entry->filename); + } + + PLAYLIST_UNLOCK(); + + fclose(file); +} + +PlaylistContainer plc_pls = { + .name = "Winamp .pls Playlist Format", + .ext = "pls", + .plc_read = playlist_load_pls, + .plc_write = playlist_save_pls, +}; +