annotate audacious/playlist_container.c @ 1781:06882533bf8f trunk

[svn] - default skin.hints:mainwinVisWidth value
author nenolod
date Wed, 04 Oct 2006 03:41:41 -0700
parents 7ea3c9610ca0
children f18a5b617c34
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1548
d5be38600be5 [svn] - incomplete PlaylistContainer implementation
nenolod
parents:
diff changeset
1 /*
d5be38600be5 [svn] - incomplete PlaylistContainer implementation
nenolod
parents:
diff changeset
2 * Audacious: A cross-platform multimedia player
d5be38600be5 [svn] - incomplete PlaylistContainer implementation
nenolod
parents:
diff changeset
3 * Copyright (c) 2006 William Pitcock, Tony Vroon, George Averill,
d5be38600be5 [svn] - incomplete PlaylistContainer implementation
nenolod
parents:
diff changeset
4 * Giacomo Lozito, Derek Pomery and Yoshiki Yazawa.
d5be38600be5 [svn] - incomplete PlaylistContainer implementation
nenolod
parents:
diff changeset
5 *
d5be38600be5 [svn] - incomplete PlaylistContainer implementation
nenolod
parents:
diff changeset
6 * This program is free software; you can redistribute it and/or modify
d5be38600be5 [svn] - incomplete PlaylistContainer implementation
nenolod
parents:
diff changeset
7 * it under the terms of the GNU General Public License as published by
d5be38600be5 [svn] - incomplete PlaylistContainer implementation
nenolod
parents:
diff changeset
8 * the Free Software Foundation; either version 2 of the License, or
d5be38600be5 [svn] - incomplete PlaylistContainer implementation
nenolod
parents:
diff changeset
9 * (at your option) any later version.
d5be38600be5 [svn] - incomplete PlaylistContainer implementation
nenolod
parents:
diff changeset
10 *
d5be38600be5 [svn] - incomplete PlaylistContainer implementation
nenolod
parents:
diff changeset
11 * This program is distributed in the hope that it will be useful,
d5be38600be5 [svn] - incomplete PlaylistContainer implementation
nenolod
parents:
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
d5be38600be5 [svn] - incomplete PlaylistContainer implementation
nenolod
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
d5be38600be5 [svn] - incomplete PlaylistContainer implementation
nenolod
parents:
diff changeset
14 * GNU General Public License for more details.
d5be38600be5 [svn] - incomplete PlaylistContainer implementation
nenolod
parents:
diff changeset
15 *
d5be38600be5 [svn] - incomplete PlaylistContainer implementation
nenolod
parents:
diff changeset
16 * You should have received a copy of the GNU General Public License
d5be38600be5 [svn] - incomplete PlaylistContainer implementation
nenolod
parents:
diff changeset
17 * along with this program; if not, write to the Free Software
d5be38600be5 [svn] - incomplete PlaylistContainer implementation
nenolod
parents:
diff changeset
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
d5be38600be5 [svn] - incomplete PlaylistContainer implementation
nenolod
parents:
diff changeset
19 */
d5be38600be5 [svn] - incomplete PlaylistContainer implementation
nenolod
parents:
diff changeset
20
d5be38600be5 [svn] - incomplete PlaylistContainer implementation
nenolod
parents:
diff changeset
21 #include <glib.h>
1549
854016a03129 [svn] - more
nenolod
parents: 1548
diff changeset
22 #include <string.h>
1548
d5be38600be5 [svn] - incomplete PlaylistContainer implementation
nenolod
parents:
diff changeset
23 #include "playlist_container.h"
d5be38600be5 [svn] - incomplete PlaylistContainer implementation
nenolod
parents:
diff changeset
24
d5be38600be5 [svn] - incomplete PlaylistContainer implementation
nenolod
parents:
diff changeset
25 /*
d5be38600be5 [svn] - incomplete PlaylistContainer implementation
nenolod
parents:
diff changeset
26 * PlaylistContainer objects handle the import and export of Playlist
d5be38600be5 [svn] - incomplete PlaylistContainer implementation
nenolod
parents:
diff changeset
27 * data. Basically, a PlaylistContainer acts as a filter for a PlaylistEntry.
d5be38600be5 [svn] - incomplete PlaylistContainer implementation
nenolod
parents:
diff changeset
28 */
d5be38600be5 [svn] - incomplete PlaylistContainer implementation
nenolod
parents:
diff changeset
29
d5be38600be5 [svn] - incomplete PlaylistContainer implementation
nenolod
parents:
diff changeset
30 static GList *registered_plcs = NULL;
d5be38600be5 [svn] - incomplete PlaylistContainer implementation
nenolod
parents:
diff changeset
31
d5be38600be5 [svn] - incomplete PlaylistContainer implementation
nenolod
parents:
diff changeset
32 void playlist_container_register(PlaylistContainer *plc)
d5be38600be5 [svn] - incomplete PlaylistContainer implementation
nenolod
parents:
diff changeset
33 {
d5be38600be5 [svn] - incomplete PlaylistContainer implementation
nenolod
parents:
diff changeset
34 registered_plcs = g_list_append(registered_plcs, plc);
d5be38600be5 [svn] - incomplete PlaylistContainer implementation
nenolod
parents:
diff changeset
35 }
d5be38600be5 [svn] - incomplete PlaylistContainer implementation
nenolod
parents:
diff changeset
36
d5be38600be5 [svn] - incomplete PlaylistContainer implementation
nenolod
parents:
diff changeset
37 void playlist_container_unregister(PlaylistContainer *plc)
d5be38600be5 [svn] - incomplete PlaylistContainer implementation
nenolod
parents:
diff changeset
38 {
d5be38600be5 [svn] - incomplete PlaylistContainer implementation
nenolod
parents:
diff changeset
39 registered_plcs = g_list_remove(registered_plcs, plc);
d5be38600be5 [svn] - incomplete PlaylistContainer implementation
nenolod
parents:
diff changeset
40 }
1549
854016a03129 [svn] - more
nenolod
parents: 1548
diff changeset
41
854016a03129 [svn] - more
nenolod
parents: 1548
diff changeset
42 PlaylistContainer *playlist_container_find(char *ext)
854016a03129 [svn] - more
nenolod
parents: 1548
diff changeset
43 {
854016a03129 [svn] - more
nenolod
parents: 1548
diff changeset
44 GList *node;
854016a03129 [svn] - more
nenolod
parents: 1548
diff changeset
45 PlaylistContainer *plc;
854016a03129 [svn] - more
nenolod
parents: 1548
diff changeset
46
1606
7ea3c9610ca0 [svn] - playlist_container_find() must check if ext is 1, besides NULL.
yaz
parents: 1552
diff changeset
47 /* check ext neither is NULL nor 1 (in a consequence of optimization). */
7ea3c9610ca0 [svn] - playlist_container_find() must check if ext is 1, besides NULL.
yaz
parents: 1552
diff changeset
48 g_return_val_if_fail(ext != NULL && ext != (void *)1, NULL);
1549
854016a03129 [svn] - more
nenolod
parents: 1548
diff changeset
49
854016a03129 [svn] - more
nenolod
parents: 1548
diff changeset
50 for (node = registered_plcs; node != NULL; node = g_list_next(node)) {
854016a03129 [svn] - more
nenolod
parents: 1548
diff changeset
51 plc = PLAYLIST_CONTAINER(node->data);
854016a03129 [svn] - more
nenolod
parents: 1548
diff changeset
52
854016a03129 [svn] - more
nenolod
parents: 1548
diff changeset
53 if (!g_strcasecmp(plc->ext, ext))
854016a03129 [svn] - more
nenolod
parents: 1548
diff changeset
54 return plc;
854016a03129 [svn] - more
nenolod
parents: 1548
diff changeset
55 }
854016a03129 [svn] - more
nenolod
parents: 1548
diff changeset
56
854016a03129 [svn] - more
nenolod
parents: 1548
diff changeset
57 return NULL;
854016a03129 [svn] - more
nenolod
parents: 1548
diff changeset
58 }
854016a03129 [svn] - more
nenolod
parents: 1548
diff changeset
59
1550
be50c53aee09 [svn] - some minimal integration
nenolod
parents: 1549
diff changeset
60 void playlist_container_read(char *filename, gint pos)
1549
854016a03129 [svn] - more
nenolod
parents: 1548
diff changeset
61 {
854016a03129 [svn] - more
nenolod
parents: 1548
diff changeset
62 char *ext = strrchr(filename, '.') + 1; /* optimization: skip past the dot -nenolod */
854016a03129 [svn] - more
nenolod
parents: 1548
diff changeset
63 PlaylistContainer *plc = playlist_container_find(ext);
854016a03129 [svn] - more
nenolod
parents: 1548
diff changeset
64
854016a03129 [svn] - more
nenolod
parents: 1548
diff changeset
65 if (plc->plc_read == NULL)
1550
be50c53aee09 [svn] - some minimal integration
nenolod
parents: 1549
diff changeset
66 return;
1549
854016a03129 [svn] - more
nenolod
parents: 1548
diff changeset
67
1551
a4180850edfe [svn] - fix
nenolod
parents: 1550
diff changeset
68 plc->plc_read(filename, pos);
1549
854016a03129 [svn] - more
nenolod
parents: 1548
diff changeset
69 }
854016a03129 [svn] - more
nenolod
parents: 1548
diff changeset
70
1550
be50c53aee09 [svn] - some minimal integration
nenolod
parents: 1549
diff changeset
71 void playlist_container_write(char *filename, gint pos)
1549
854016a03129 [svn] - more
nenolod
parents: 1548
diff changeset
72 {
854016a03129 [svn] - more
nenolod
parents: 1548
diff changeset
73 char *ext = strrchr(filename, '.') + 1; /* optimization: skip past the dot -nenolod */
854016a03129 [svn] - more
nenolod
parents: 1548
diff changeset
74 PlaylistContainer *plc = playlist_container_find(ext);
854016a03129 [svn] - more
nenolod
parents: 1548
diff changeset
75
854016a03129 [svn] - more
nenolod
parents: 1548
diff changeset
76 if (plc->plc_write == NULL)
854016a03129 [svn] - more
nenolod
parents: 1548
diff changeset
77 return;
854016a03129 [svn] - more
nenolod
parents: 1548
diff changeset
78
1550
be50c53aee09 [svn] - some minimal integration
nenolod
parents: 1549
diff changeset
79 plc->plc_write(filename, pos);
1549
854016a03129 [svn] - more
nenolod
parents: 1548
diff changeset
80 }
1550
be50c53aee09 [svn] - some minimal integration
nenolod
parents: 1549
diff changeset
81
1552
aaca4aab4670 [svn] - further integration
nenolod
parents: 1551
diff changeset
82 gboolean is_playlist_name(char *filename)
aaca4aab4670 [svn] - further integration
nenolod
parents: 1551
diff changeset
83 {
aaca4aab4670 [svn] - further integration
nenolod
parents: 1551
diff changeset
84 char *ext = strrchr(filename, '.') + 1; /* optimization: skip past the dot -nenolod */
aaca4aab4670 [svn] - further integration
nenolod
parents: 1551
diff changeset
85 PlaylistContainer *plc = playlist_container_find(ext);
aaca4aab4670 [svn] - further integration
nenolod
parents: 1551
diff changeset
86
aaca4aab4670 [svn] - further integration
nenolod
parents: 1551
diff changeset
87 if (plc != NULL)
aaca4aab4670 [svn] - further integration
nenolod
parents: 1551
diff changeset
88 return TRUE;
aaca4aab4670 [svn] - further integration
nenolod
parents: 1551
diff changeset
89
aaca4aab4670 [svn] - further integration
nenolod
parents: 1551
diff changeset
90 return FALSE;
aaca4aab4670 [svn] - further integration
nenolod
parents: 1551
diff changeset
91 }