annotate src/audacious/custom_uri.c @ 3621:2d6106656276

Notify playlist manager of more changes
author Kieran Clancy <clancy.kieran+audacious@gmail.com>
date Tue, 25 Sep 2007 20:38:40 +0930
parents a0c93cb34598
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3340
a0c93cb34598 Add functions for custom uri support of input plugins
Christian Birchinger <joker@netswarm.net>
parents:
diff changeset
1 /*
a0c93cb34598 Add functions for custom uri support of input plugins
Christian Birchinger <joker@netswarm.net>
parents:
diff changeset
2 * Audacious
a0c93cb34598 Add functions for custom uri support of input plugins
Christian Birchinger <joker@netswarm.net>
parents:
diff changeset
3 * Copyright (c) 2007 William Pitcock
a0c93cb34598 Add functions for custom uri support of input plugins
Christian Birchinger <joker@netswarm.net>
parents:
diff changeset
4 *
a0c93cb34598 Add functions for custom uri support of input plugins
Christian Birchinger <joker@netswarm.net>
parents:
diff changeset
5 * This program is free software; you can redistribute it and/or modify
a0c93cb34598 Add functions for custom uri support of input plugins
Christian Birchinger <joker@netswarm.net>
parents:
diff changeset
6 * it under the terms of the GNU General Public License as published by
a0c93cb34598 Add functions for custom uri support of input plugins
Christian Birchinger <joker@netswarm.net>
parents:
diff changeset
7 * the Free Software Foundation; under version 3 of the License.
a0c93cb34598 Add functions for custom uri support of input plugins
Christian Birchinger <joker@netswarm.net>
parents:
diff changeset
8 *
a0c93cb34598 Add functions for custom uri support of input plugins
Christian Birchinger <joker@netswarm.net>
parents:
diff changeset
9 * This program is distributed in the hope that it will be useful,
a0c93cb34598 Add functions for custom uri support of input plugins
Christian Birchinger <joker@netswarm.net>
parents:
diff changeset
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
a0c93cb34598 Add functions for custom uri support of input plugins
Christian Birchinger <joker@netswarm.net>
parents:
diff changeset
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
a0c93cb34598 Add functions for custom uri support of input plugins
Christian Birchinger <joker@netswarm.net>
parents:
diff changeset
12 * GNU General Public License for more details.
a0c93cb34598 Add functions for custom uri support of input plugins
Christian Birchinger <joker@netswarm.net>
parents:
diff changeset
13 *
a0c93cb34598 Add functions for custom uri support of input plugins
Christian Birchinger <joker@netswarm.net>
parents:
diff changeset
14 * You should have received a copy of the GNU General Public License
a0c93cb34598 Add functions for custom uri support of input plugins
Christian Birchinger <joker@netswarm.net>
parents:
diff changeset
15 * along with this program. If not, see <http://www.gnu.org/licenses>.
a0c93cb34598 Add functions for custom uri support of input plugins
Christian Birchinger <joker@netswarm.net>
parents:
diff changeset
16 *
a0c93cb34598 Add functions for custom uri support of input plugins
Christian Birchinger <joker@netswarm.net>
parents:
diff changeset
17 * The Audacious team does not consider modular code linking to
a0c93cb34598 Add functions for custom uri support of input plugins
Christian Birchinger <joker@netswarm.net>
parents:
diff changeset
18 * Audacious or using our public API to be a derived work.
a0c93cb34598 Add functions for custom uri support of input plugins
Christian Birchinger <joker@netswarm.net>
parents:
diff changeset
19 */
a0c93cb34598 Add functions for custom uri support of input plugins
Christian Birchinger <joker@netswarm.net>
parents:
diff changeset
20
a0c93cb34598 Add functions for custom uri support of input plugins
Christian Birchinger <joker@netswarm.net>
parents:
diff changeset
21 #include "custom_uri.h"
a0c93cb34598 Add functions for custom uri support of input plugins
Christian Birchinger <joker@netswarm.net>
parents:
diff changeset
22
a0c93cb34598 Add functions for custom uri support of input plugins
Christian Birchinger <joker@netswarm.net>
parents:
diff changeset
23 mowgli_dictionary_t *uri_type_dict = NULL;
a0c93cb34598 Add functions for custom uri support of input plugins
Christian Birchinger <joker@netswarm.net>
parents:
diff changeset
24
a0c93cb34598 Add functions for custom uri support of input plugins
Christian Birchinger <joker@netswarm.net>
parents:
diff changeset
25 void uri_set_plugin(const gchar *uri, InputPlugin *ip)
a0c93cb34598 Add functions for custom uri support of input plugins
Christian Birchinger <joker@netswarm.net>
parents:
diff changeset
26 {
a0c93cb34598 Add functions for custom uri support of input plugins
Christian Birchinger <joker@netswarm.net>
parents:
diff changeset
27 g_return_if_fail(uri != NULL);
a0c93cb34598 Add functions for custom uri support of input plugins
Christian Birchinger <joker@netswarm.net>
parents:
diff changeset
28 g_return_if_fail(ip != NULL);
a0c93cb34598 Add functions for custom uri support of input plugins
Christian Birchinger <joker@netswarm.net>
parents:
diff changeset
29
a0c93cb34598 Add functions for custom uri support of input plugins
Christian Birchinger <joker@netswarm.net>
parents:
diff changeset
30 if (uri_type_dict == NULL)
a0c93cb34598 Add functions for custom uri support of input plugins
Christian Birchinger <joker@netswarm.net>
parents:
diff changeset
31 uri_type_dict = mowgli_dictionary_create(strcasecmp);
a0c93cb34598 Add functions for custom uri support of input plugins
Christian Birchinger <joker@netswarm.net>
parents:
diff changeset
32 else if (mowgli_dictionary_find(uri_type_dict, uri))
a0c93cb34598 Add functions for custom uri support of input plugins
Christian Birchinger <joker@netswarm.net>
parents:
diff changeset
33 mowgli_dictionary_delete(uri_type_dict, uri);
a0c93cb34598 Add functions for custom uri support of input plugins
Christian Birchinger <joker@netswarm.net>
parents:
diff changeset
34 mowgli_dictionary_add(uri_type_dict, uri, ip);
a0c93cb34598 Add functions for custom uri support of input plugins
Christian Birchinger <joker@netswarm.net>
parents:
diff changeset
35 }
a0c93cb34598 Add functions for custom uri support of input plugins
Christian Birchinger <joker@netswarm.net>
parents:
diff changeset
36
a0c93cb34598 Add functions for custom uri support of input plugins
Christian Birchinger <joker@netswarm.net>
parents:
diff changeset
37 InputPlugin *uri_get_plugin(const gchar *filename)
a0c93cb34598 Add functions for custom uri support of input plugins
Christian Birchinger <joker@netswarm.net>
parents:
diff changeset
38 {
a0c93cb34598 Add functions for custom uri support of input plugins
Christian Birchinger <joker@netswarm.net>
parents:
diff changeset
39 gchar *uri, *pos;
a0c93cb34598 Add functions for custom uri support of input plugins
Christian Birchinger <joker@netswarm.net>
parents:
diff changeset
40 InputPlugin *ip;
a0c93cb34598 Add functions for custom uri support of input plugins
Christian Birchinger <joker@netswarm.net>
parents:
diff changeset
41
a0c93cb34598 Add functions for custom uri support of input plugins
Christian Birchinger <joker@netswarm.net>
parents:
diff changeset
42 if (filename == NULL)
a0c93cb34598 Add functions for custom uri support of input plugins
Christian Birchinger <joker@netswarm.net>
parents:
diff changeset
43 return NULL;
a0c93cb34598 Add functions for custom uri support of input plugins
Christian Birchinger <joker@netswarm.net>
parents:
diff changeset
44
a0c93cb34598 Add functions for custom uri support of input plugins
Christian Birchinger <joker@netswarm.net>
parents:
diff changeset
45 if (uri_type_dict == NULL)
a0c93cb34598 Add functions for custom uri support of input plugins
Christian Birchinger <joker@netswarm.net>
parents:
diff changeset
46 return NULL;
a0c93cb34598 Add functions for custom uri support of input plugins
Christian Birchinger <joker@netswarm.net>
parents:
diff changeset
47
a0c93cb34598 Add functions for custom uri support of input plugins
Christian Birchinger <joker@netswarm.net>
parents:
diff changeset
48 pos = strstr(filename, "://");
a0c93cb34598 Add functions for custom uri support of input plugins
Christian Birchinger <joker@netswarm.net>
parents:
diff changeset
49 if (pos)
a0c93cb34598 Add functions for custom uri support of input plugins
Christian Birchinger <joker@netswarm.net>
parents:
diff changeset
50 uri = g_strndup(filename, pos - filename + 3);
a0c93cb34598 Add functions for custom uri support of input plugins
Christian Birchinger <joker@netswarm.net>
parents:
diff changeset
51 else
a0c93cb34598 Add functions for custom uri support of input plugins
Christian Birchinger <joker@netswarm.net>
parents:
diff changeset
52 return NULL;
a0c93cb34598 Add functions for custom uri support of input plugins
Christian Birchinger <joker@netswarm.net>
parents:
diff changeset
53
a0c93cb34598 Add functions for custom uri support of input plugins
Christian Birchinger <joker@netswarm.net>
parents:
diff changeset
54 ip = mowgli_dictionary_retrieve(uri_type_dict, uri);
a0c93cb34598 Add functions for custom uri support of input plugins
Christian Birchinger <joker@netswarm.net>
parents:
diff changeset
55
a0c93cb34598 Add functions for custom uri support of input plugins
Christian Birchinger <joker@netswarm.net>
parents:
diff changeset
56 g_free(uri);
a0c93cb34598 Add functions for custom uri support of input plugins
Christian Birchinger <joker@netswarm.net>
parents:
diff changeset
57
a0c93cb34598 Add functions for custom uri support of input plugins
Christian Birchinger <joker@netswarm.net>
parents:
diff changeset
58 return ip;
a0c93cb34598 Add functions for custom uri support of input plugins
Christian Birchinger <joker@netswarm.net>
parents:
diff changeset
59 }