Mercurial > audlegacy
annotate src/audacious/general.c @ 4667:2079f04c19e2
Use new Interface API.
| author | William Pitcock <nenolod@atheme.org> |
|---|---|
| date | Sun, 29 Jun 2008 00:45:55 -0500 |
| parents | 2b7a74fce100 |
| children |
| rev | line source |
|---|---|
| 2313 | 1 /* BMP - Cross-platform multimedia player |
| 2 * Copyright (C) 2003-2004 BMP development team. | |
| 3 * | |
| 4 * Based on XMMS: | |
| 5 * Copyright (C) 1998-2003 XMMS development team. | |
| 6 * | |
| 7 * This program is free software; you can redistribute it and/or modify | |
| 8 * 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
|
9 * the Free Software Foundation; under version 3 of the License. |
| 2313 | 10 * |
| 11 * This program is distributed in the hope that it will be useful, | |
| 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 14 * GNU General Public License for more details. | |
| 15 * | |
| 16 * 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
|
17 * 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
|
18 * |
|
f1c756f39e6c
Invoke "Plugins are not derived work" clause provided by GPL3.
William Pitcock <nenolod@atheme-project.org>
parents:
3121
diff
changeset
|
19 * 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
|
20 * Audacious or using our public API to be a derived work. |
| 2313 | 21 */ |
| 22 | |
| 23 #include <glib.h> | |
| 24 #include <string.h> | |
| 25 #include "plugin.h" | |
|
4266
2b7a74fce100
Implemented support for multiple subplugins inside a plugin (see bug #148) and PluginHeader finalization
stefano@zanga
parents:
3455
diff
changeset
|
26 #include "pluginenum.h" |
| 2313 | 27 #include "general.h" |
| 28 | |
| 29 GeneralPluginData gp_data = { | |
| 30 NULL, | |
| 31 NULL | |
| 32 }; | |
| 33 | |
| 34 GList * | |
| 35 get_general_list(void) | |
| 36 { | |
| 37 return gp_data.general_list; | |
| 38 } | |
| 39 | |
| 40 GList * | |
| 41 get_general_enabled_list(void) | |
| 42 { | |
| 43 return gp_data.enabled_list; | |
| 44 } | |
| 45 | |
| 46 static GeneralPlugin * | |
| 47 get_general_plugin(gint i) | |
| 48 { | |
| 49 GList *node = g_list_nth(get_general_list(), i); | |
| 50 | |
| 51 if (!node) | |
| 52 return NULL; | |
| 53 | |
| 54 return GENERAL_PLUGIN(node->data); | |
| 55 } | |
| 56 | |
| 57 void | |
| 58 enable_general_plugin(gint i, gboolean enable) | |
| 59 { | |
| 60 GeneralPlugin *plugin = get_general_plugin(i); | |
| 61 | |
| 62 if (!plugin) | |
| 63 return; | |
| 64 | |
|
3437
3092a8b3fe34
Big plugin system changes (part 1 of who knows, it's still a big mess):
William Pitcock <nenolod@atheme.org>
parents:
3123
diff
changeset
|
65 if (enable && !plugin->enabled) { |
| 2313 | 66 gp_data.enabled_list = g_list_append(gp_data.enabled_list, plugin); |
| 67 if (plugin->init) | |
|
4266
2b7a74fce100
Implemented support for multiple subplugins inside a plugin (see bug #148) and PluginHeader finalization
stefano@zanga
parents:
3455
diff
changeset
|
68 { |
|
2b7a74fce100
Implemented support for multiple subplugins inside a plugin (see bug #148) and PluginHeader finalization
stefano@zanga
parents:
3455
diff
changeset
|
69 plugin_set_current((Plugin *)plugin); |
| 2313 | 70 plugin->init(); |
|
4266
2b7a74fce100
Implemented support for multiple subplugins inside a plugin (see bug #148) and PluginHeader finalization
stefano@zanga
parents:
3455
diff
changeset
|
71 } |
| 2313 | 72 } |
|
3437
3092a8b3fe34
Big plugin system changes (part 1 of who knows, it's still a big mess):
William Pitcock <nenolod@atheme.org>
parents:
3123
diff
changeset
|
73 else if (!enable && plugin->enabled) { |
| 2313 | 74 gp_data.enabled_list = g_list_remove(gp_data.enabled_list, plugin); |
| 75 if (plugin->cleanup) | |
|
4266
2b7a74fce100
Implemented support for multiple subplugins inside a plugin (see bug #148) and PluginHeader finalization
stefano@zanga
parents:
3455
diff
changeset
|
76 { |
|
2b7a74fce100
Implemented support for multiple subplugins inside a plugin (see bug #148) and PluginHeader finalization
stefano@zanga
parents:
3455
diff
changeset
|
77 plugin_set_current((Plugin *)plugin); |
| 2313 | 78 plugin->cleanup(); |
|
4266
2b7a74fce100
Implemented support for multiple subplugins inside a plugin (see bug #148) and PluginHeader finalization
stefano@zanga
parents:
3455
diff
changeset
|
79 } |
| 2313 | 80 } |
|
3437
3092a8b3fe34
Big plugin system changes (part 1 of who knows, it's still a big mess):
William Pitcock <nenolod@atheme.org>
parents:
3123
diff
changeset
|
81 |
|
3092a8b3fe34
Big plugin system changes (part 1 of who knows, it's still a big mess):
William Pitcock <nenolod@atheme.org>
parents:
3123
diff
changeset
|
82 plugin->enabled = enable; |
| 2313 | 83 } |
| 84 | |
| 85 gchar * | |
| 86 general_stringify_enabled_list(void) | |
| 87 { | |
| 88 GString *enable_str; | |
| 89 gchar *name; | |
| 90 GList *node = get_general_enabled_list(); | |
| 91 | |
| 92 if (!node) | |
| 93 return NULL; | |
| 94 | |
| 95 name = g_path_get_basename(GENERAL_PLUGIN(node->data)->filename); | |
| 96 enable_str = g_string_new(name); | |
| 97 g_free(name); | |
| 98 | |
| 99 for (node = g_list_next(node); node; node = g_list_next(node)) { | |
| 100 name = g_path_get_basename(GENERAL_PLUGIN(node->data)->filename); | |
| 101 g_string_append_c(enable_str, ','); | |
| 102 g_string_append(enable_str, name); | |
| 103 g_free(name); | |
| 104 } | |
| 105 | |
| 106 return g_string_free(enable_str, FALSE); | |
| 107 } | |
| 108 | |
| 109 void | |
| 110 general_enable_from_stringified_list(const gchar * list_str) | |
| 111 { | |
| 112 gchar **list, **str; | |
| 113 GeneralPlugin *plugin; | |
| 114 | |
| 115 if (!list_str || !strcmp(list_str, "")) | |
| 116 return; | |
| 117 | |
| 118 list = g_strsplit(list_str, ",", 0); | |
| 119 | |
| 120 for (str = list; *str; str++) { | |
| 121 GList *node; | |
| 122 | |
| 123 for (node = get_general_list(); node; node = g_list_next(node)) { | |
| 124 gchar *base; | |
| 125 | |
| 126 base = g_path_get_basename(GENERAL_PLUGIN(node->data)->filename); | |
| 127 | |
| 128 if (!strcmp(*str, base)) { | |
| 129 plugin = GENERAL_PLUGIN(node->data); | |
|
3437
3092a8b3fe34
Big plugin system changes (part 1 of who knows, it's still a big mess):
William Pitcock <nenolod@atheme.org>
parents:
3123
diff
changeset
|
130 plugin->enabled = TRUE; |
|
3092a8b3fe34
Big plugin system changes (part 1 of who knows, it's still a big mess):
William Pitcock <nenolod@atheme.org>
parents:
3123
diff
changeset
|
131 |
| 2313 | 132 gp_data.enabled_list = g_list_append(gp_data.enabled_list, |
| 133 plugin); | |
| 134 if (plugin->init) | |
|
4266
2b7a74fce100
Implemented support for multiple subplugins inside a plugin (see bug #148) and PluginHeader finalization
stefano@zanga
parents:
3455
diff
changeset
|
135 { |
|
2b7a74fce100
Implemented support for multiple subplugins inside a plugin (see bug #148) and PluginHeader finalization
stefano@zanga
parents:
3455
diff
changeset
|
136 plugin_set_current((Plugin *)plugin); |
| 2313 | 137 plugin->init(); |
|
4266
2b7a74fce100
Implemented support for multiple subplugins inside a plugin (see bug #148) and PluginHeader finalization
stefano@zanga
parents:
3455
diff
changeset
|
138 } |
| 2313 | 139 } |
| 140 | |
| 141 g_free(base); | |
| 142 } | |
| 143 } | |
| 144 | |
| 145 g_strfreev(list); | |
| 146 } |
