3009
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
1 /*
|
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
2 * Audacious
|
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
3 * Copyright (c) 2007 William Pitcock
|
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
4 *
|
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
5 * This program is free software; you can redistribute it and/or modify
|
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
6 * it under the terms of the GNU General Public License as published by
|
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
7 * the Free Software Foundation; under version 2 of the License.
|
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
8 *
|
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
9 * This program is distributed in the hope that it will be useful,
|
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
12 * GNU General Public License for more details.
|
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
13 *
|
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
14 * You should have received a copy of the GNU General Public License
|
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
15 * along with this program; if not, write to the Free Software
|
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
17 */
|
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
18
|
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
19 #include "mime.h"
|
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
20
|
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
21 mowgli_dictionary_t *mime_type_dict = NULL;
|
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
22
|
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
23 void mime_set_plugin(const gchar *mimetype, InputPlugin *ip)
|
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
24 {
|
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
25 g_return_if_fail(mimetype != NULL);
|
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
26 g_return_if_fail(ip != NULL);
|
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
27
|
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
28 if (mime_type_dict == NULL)
|
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
29 mime_type_dict = mowgli_dictionary_create(strcasecmp);
|
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
30
|
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
31 mowgli_dictionary_add(mime_type_dict, mimetype, ip);
|
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
32 }
|
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
33
|
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
34 InputPlugin *mime_get_plugin(const gchar *mimetype)
|
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
35 {
|
3015
02a62ac3d9c2
Handle metadata sources where there are no mimetype support yet implemented.
William Pitcock <nenolod@atheme-project.org>
diff
changeset
|
36 if (mimetype == NULL)
|
02a62ac3d9c2
Handle metadata sources where there are no mimetype support yet implemented.
William Pitcock <nenolod@atheme-project.org>
diff
changeset
|
37 return NULL;
|
02a62ac3d9c2
Handle metadata sources where there are no mimetype support yet implemented.
William Pitcock <nenolod@atheme-project.org>
diff
changeset
|
38
|
3009
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
39 if (mime_type_dict == NULL)
|
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
40 return NULL;
|
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
41
|
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
42 return mowgli_dictionary_retrieve(mime_type_dict, mimetype);
|
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
43 }
|