Mercurial > audlegacy
annotate src/audacious/playlist_container.c @ 3676:4920d6d4ac6e
Automated merge with ssh://hg.atheme.org//hg/audacious
author | William Pitcock <nenolod@atheme.org> |
---|---|
date | Sun, 30 Sep 2007 12:02:15 -0500 |
parents | 1f7c00c1de22 |
children | ae3ed045e5aa |
rev | line source |
---|---|
2313 | 1 /* |
2 * Audacious: A cross-platform multimedia player | |
3 * Copyright (c) 2006-2007 William Pitcock, Tony Vroon, George Averill, | |
4 * Giacomo Lozito, Derek Pomery and Yoshiki Yazawa. | |
5 * | |
6 * This program is free software; you can redistribute it and/or modify | |
7 * it under the terms of the GNU General Public License as published by | |
3121
3b6d316f8b09
GPL3 relicensing.
William Pitcock <nenolod@atheme-project.org>
parents:
2313
diff
changeset
|
8 * the Free Software Foundation; under version 3 of the License. |
2313 | 9 * |
10 * This program is distributed in the hope that it will be useful, | |
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 * GNU General Public License for more details. | |
14 * | |
15 * You should have received a copy of the GNU General Public License | |
3121
3b6d316f8b09
GPL3 relicensing.
William Pitcock <nenolod@atheme-project.org>
parents:
2313
diff
changeset
|
16 * along with this program. If not, see <http://www.gnu.org/licenses>. |
3123
f1c756f39e6c
Invoke "Plugins are not derived work" clause provided by GPL3.
William Pitcock <nenolod@atheme-project.org>
parents:
3121
diff
changeset
|
17 * |
f1c756f39e6c
Invoke "Plugins are not derived work" clause provided by GPL3.
William Pitcock <nenolod@atheme-project.org>
parents:
3121
diff
changeset
|
18 * The Audacious team does not consider modular code linking to |
f1c756f39e6c
Invoke "Plugins are not derived work" clause provided by GPL3.
William Pitcock <nenolod@atheme-project.org>
parents:
3121
diff
changeset
|
19 * Audacious or using our public API to be a derived work. |
2313 | 20 */ |
21 | |
22 #include <glib.h> | |
23 #include <string.h> | |
24 #include "playlist_container.h" | |
25 | |
26 /* | |
27 * PlaylistContainer objects handle the import and export of Playlist | |
28 * data. Basically, a PlaylistContainer acts as a filter for a PlaylistEntry. | |
29 */ | |
30 | |
31 static GList *registered_plcs = NULL; | |
32 | |
33 void playlist_container_register(PlaylistContainer *plc) | |
34 { | |
35 registered_plcs = g_list_append(registered_plcs, plc); | |
36 } | |
37 | |
38 void playlist_container_unregister(PlaylistContainer *plc) | |
39 { | |
40 registered_plcs = g_list_remove(registered_plcs, plc); | |
41 } | |
42 | |
3634 | 43 PlaylistContainer *playlist_container_find(gchar *ext) |
2313 | 44 { |
45 GList *node; | |
46 PlaylistContainer *plc; | |
47 | |
48 /* check ext neither is NULL nor 1 (in a consequence of optimization). */ | |
49 g_return_val_if_fail(ext != NULL && ext != (void *)1, NULL); | |
50 | |
51 for (node = registered_plcs; node != NULL; node = g_list_next(node)) { | |
52 plc = PLAYLIST_CONTAINER(node->data); | |
53 | |
54 if (!g_strcasecmp(plc->ext, ext)) | |
55 return plc; | |
56 } | |
57 | |
58 return NULL; | |
59 } | |
60 | |
3634 | 61 void playlist_container_read(gchar *filename, gint pos) |
2313 | 62 { |
3634 | 63 gchar *ext = strrchr(filename, '.') + 1; /* optimization: skip past the dot -nenolod */ |
2313 | 64 PlaylistContainer *plc = playlist_container_find(ext); |
65 | |
66 if (plc->plc_read == NULL) | |
67 return; | |
68 | |
69 plc->plc_read(filename, pos); | |
70 } | |
71 | |
3634 | 72 void playlist_container_write(gchar *filename, gint pos) |
2313 | 73 { |
3634 | 74 gchar *ext = strrchr(filename, '.') + 1; /* optimization: skip past the dot -nenolod */ |
2313 | 75 PlaylistContainer *plc = playlist_container_find(ext); |
76 | |
77 if (plc->plc_write == NULL) | |
78 return; | |
79 | |
80 plc->plc_write(filename, pos); | |
81 } | |
82 | |
3634 | 83 gboolean is_playlist_name(gchar *filename) |
2313 | 84 { |
3634 | 85 gchar *ext = strrchr(filename, '.') + 1; /* optimization: skip past the dot -nenolod */ |
2313 | 86 PlaylistContainer *plc = playlist_container_find(ext); |
87 | |
88 if (plc != NULL) | |
89 return TRUE; | |
90 | |
91 return FALSE; | |
92 } |