annotate src/audacious/mime.c @ 4561:cc6255f8b568

Suffix all type names in core with _
author Tomasz Mon <desowin@gmail.com>
date Mon, 19 May 2008 18:11:41 +0200
parents 31355fc2bb9a
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3009
9976e065e2f5 Mimetype system.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
1 /*
9976e065e2f5 Mimetype system.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
2 * Audacious
9976e065e2f5 Mimetype system.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
3 * Copyright (c) 2007 William Pitcock
9976e065e2f5 Mimetype system.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
4 *
9976e065e2f5 Mimetype system.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
5 * This program is free software; you can redistribute it and/or modify
9976e065e2f5 Mimetype system.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
6 * it under the terms of the GNU General Public License as published by
3121
3b6d316f8b09 GPL3 relicensing.
William Pitcock <nenolod@atheme-project.org>
parents: 3015
diff changeset
7 * the Free Software Foundation; under version 3 of the License.
3009
9976e065e2f5 Mimetype system.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
8 *
9976e065e2f5 Mimetype system.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
9 * This program is distributed in the hope that it will be useful,
9976e065e2f5 Mimetype system.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9976e065e2f5 Mimetype system.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9976e065e2f5 Mimetype system.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
12 * GNU General Public License for more details.
9976e065e2f5 Mimetype system.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
13 *
9976e065e2f5 Mimetype system.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
14 * You should have received a copy of the GNU General Public License
3121
3b6d316f8b09 GPL3 relicensing.
William Pitcock <nenolod@atheme-project.org>
parents: 3015
diff changeset
15 * 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
16 *
f1c756f39e6c Invoke "Plugins are not derived work" clause provided by GPL3.
William Pitcock <nenolod@atheme-project.org>
parents: 3121
diff changeset
17 * 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
18 * Audacious or using our public API to be a derived work.
3009
9976e065e2f5 Mimetype system.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
19 */
9976e065e2f5 Mimetype system.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
20
9976e065e2f5 Mimetype system.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
21 #include "mime.h"
9976e065e2f5 Mimetype system.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
22
9976e065e2f5 Mimetype system.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
23 mowgli_dictionary_t *mime_type_dict = NULL;
9976e065e2f5 Mimetype system.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
24
9976e065e2f5 Mimetype system.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
25 void mime_set_plugin(const gchar *mimetype, InputPlugin *ip)
9976e065e2f5 Mimetype system.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
26 {
3161
31355fc2bb9a - Assertion not being called anymore
mf0102 <0102@gmx.at>
parents: 3123
diff changeset
27 g_return_if_fail(mimetype != NULL);
31355fc2bb9a - Assertion not being called anymore
mf0102 <0102@gmx.at>
parents: 3123
diff changeset
28 g_return_if_fail(ip != NULL);
3009
9976e065e2f5 Mimetype system.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
29
3161
31355fc2bb9a - Assertion not being called anymore
mf0102 <0102@gmx.at>
parents: 3123
diff changeset
30 if (mime_type_dict == NULL)
31355fc2bb9a - Assertion not being called anymore
mf0102 <0102@gmx.at>
parents: 3123
diff changeset
31 mime_type_dict = mowgli_dictionary_create(strcasecmp);
31355fc2bb9a - Assertion not being called anymore
mf0102 <0102@gmx.at>
parents: 3123
diff changeset
32 else if (mowgli_dictionary_find(mime_type_dict, mimetype))
31355fc2bb9a - Assertion not being called anymore
mf0102 <0102@gmx.at>
parents: 3123
diff changeset
33 mowgli_dictionary_delete(mime_type_dict, mimetype);
31355fc2bb9a - Assertion not being called anymore
mf0102 <0102@gmx.at>
parents: 3123
diff changeset
34 mowgli_dictionary_add(mime_type_dict, mimetype, ip);
3009
9976e065e2f5 Mimetype system.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
35 }
9976e065e2f5 Mimetype system.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
36
9976e065e2f5 Mimetype system.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
37 InputPlugin *mime_get_plugin(const gchar *mimetype)
9976e065e2f5 Mimetype system.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
38 {
3161
31355fc2bb9a - Assertion not being called anymore
mf0102 <0102@gmx.at>
parents: 3123
diff changeset
39 if (mimetype == NULL)
31355fc2bb9a - Assertion not being called anymore
mf0102 <0102@gmx.at>
parents: 3123
diff changeset
40 return NULL;
3015
02a62ac3d9c2 Handle metadata sources where there are no mimetype support yet implemented.
William Pitcock <nenolod@atheme-project.org>
parents: 3009
diff changeset
41
3161
31355fc2bb9a - Assertion not being called anymore
mf0102 <0102@gmx.at>
parents: 3123
diff changeset
42 if (mime_type_dict == NULL)
31355fc2bb9a - Assertion not being called anymore
mf0102 <0102@gmx.at>
parents: 3123
diff changeset
43 return NULL;
3009
9976e065e2f5 Mimetype system.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
44
3161
31355fc2bb9a - Assertion not being called anymore
mf0102 <0102@gmx.at>
parents: 3123
diff changeset
45 return mowgli_dictionary_retrieve(mime_type_dict, mimetype);
3009
9976e065e2f5 Mimetype system.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
46 }