Mercurial > audlegacy
annotate src/audacious/pluginenum.c @ 3232:2453bf125b4f trunk
Automated merge with ssh://hg.atheme.org//hg/audacious
author | William Pitcock <nenolod@atheme-project.org> |
---|---|
date | Fri, 03 Aug 2007 20:39:42 -0500 |
parents | 06baa146fc1d 2619f4c62abe |
children | e21930ccd5a8 |
rev | line source |
---|---|
2313 | 1 /* Audacious - Cross-platform multimedia player |
2 * Copyright (C) 2005-2007 Audacious development team | |
3 * | |
4 * Based on BMP: | |
5 * Copyright (C) 2003-2004 BMP development team | |
6 * | |
7 * Based on XMMS: | |
8 * Copyright (C) 1998-2003 XMMS development team | |
9 * | |
10 * This program is free software; you can redistribute it and/or modify | |
11 * it under the terms of the GNU General Public License as published by | |
3121
3b6d316f8b09
GPL3 relicensing.
William Pitcock <nenolod@atheme-project.org>
parents:
2825
diff
changeset
|
12 * the Free Software Foundation; under version 3 of the License. |
2313 | 13 * |
14 * This program is distributed in the hope that it will be useful, | |
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 * GNU General Public License for more details. | |
18 * | |
19 * You should have received a copy of the GNU General Public License | |
3121
3b6d316f8b09
GPL3 relicensing.
William Pitcock <nenolod@atheme-project.org>
parents:
2825
diff
changeset
|
20 * 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
|
21 * |
f1c756f39e6c
Invoke "Plugins are not derived work" clause provided by GPL3.
William Pitcock <nenolod@atheme-project.org>
parents:
3121
diff
changeset
|
22 * 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
|
23 * Audacious or using our public API to be a derived work. |
2313 | 24 */ |
25 | |
26 #ifdef HAVE_CONFIG_H | |
27 # include "config.h" | |
28 #endif | |
29 | |
30 #ifndef SHARED_SUFFIX | |
31 # define SHARED_SUFFIX G_MODULE_SUFFIX | |
32 #endif | |
33 | |
34 #include "pluginenum.h" | |
35 | |
36 #include <glib.h> | |
37 #include <gmodule.h> | |
38 #include <glib/gprintf.h> | |
39 #include <string.h> | |
40 | |
41 #include "main.h" | |
42 #include "ui_main.h" | |
43 #include "playback.h" | |
44 #include "playlist.h" | |
2373
ad1d7687814c
[svn] made strings.h for existing strings.c, cleanups
mf0102
parents:
2313
diff
changeset
|
45 #include "strings.h" |
2313 | 46 #include "util.h" |
47 | |
48 #include "effect.h" | |
49 #include "general.h" | |
50 #include "input.h" | |
51 #include "output.h" | |
52 #include "visualization.h" | |
3227
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
53 #include "discovery.h" |
2313 | 54 const gchar *plugin_dir_list[] = { |
55 PLUGINSUBS, | |
56 NULL | |
57 }; | |
58 | |
59 GHashTable *plugin_matrix = NULL; | |
60 GList *lowlevel_list = NULL; | |
2623 | 61 extern GList *vfs_transports; |
62 | |
2313 | 63 static gint |
64 inputlist_compare_func(gconstpointer a, gconstpointer b) | |
65 { | |
66 const InputPlugin *ap = a, *bp = b; | |
2804 | 67 if(ap->description && bp->description) |
68 return strcasecmp(ap->description, bp->description); | |
69 else | |
70 return 0; | |
2313 | 71 } |
72 | |
73 static gint | |
74 outputlist_compare_func(gconstpointer a, gconstpointer b) | |
75 { | |
76 const OutputPlugin *ap = a, *bp = b; | |
2804 | 77 if(ap->description && bp->description) |
78 return strcasecmp(ap->description, bp->description); | |
79 else | |
80 return 0; | |
2313 | 81 } |
82 | |
83 static gint | |
84 effectlist_compare_func(gconstpointer a, gconstpointer b) | |
85 { | |
86 const EffectPlugin *ap = a, *bp = b; | |
2804 | 87 if(ap->description && bp->description) |
88 return strcasecmp(ap->description, bp->description); | |
89 else | |
90 return 0; | |
2313 | 91 } |
92 | |
93 static gint | |
94 generallist_compare_func(gconstpointer a, gconstpointer b) | |
95 { | |
96 const GeneralPlugin *ap = a, *bp = b; | |
2804 | 97 if(ap->description && bp->description) |
98 return strcasecmp(ap->description, bp->description); | |
99 else | |
100 return 0; | |
2313 | 101 } |
102 | |
103 static gint | |
104 vislist_compare_func(gconstpointer a, gconstpointer b) | |
105 { | |
106 const VisPlugin *ap = a, *bp = b; | |
2804 | 107 if(ap->description && bp->description) |
108 return strcasecmp(ap->description, bp->description); | |
109 else | |
110 return 0; | |
2313 | 111 } |
112 | |
3227
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
113 static gint |
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
114 discoverylist_compare_func(gconstpointer a, gconstpointer b) |
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
115 { |
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
116 const DiscoveryPlugin *ap = a, *bp = b; |
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
117 if(ap->description && bp->description) |
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
118 return strcasecmp(ap->description, bp->description); |
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
119 else |
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
120 return 0; |
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
121 } |
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
122 |
2313 | 123 static gboolean |
124 plugin_is_duplicate(const gchar * filename) | |
125 { | |
126 GList *l; | |
127 const gchar *basename = g_basename(filename); | |
128 | |
129 /* FIXME: messy stuff */ | |
130 | |
131 for (l = ip_data.input_list; l; l = g_list_next(l)) | |
132 if (!strcmp(basename, g_basename(INPUT_PLUGIN(l->data)->filename))) | |
133 return TRUE; | |
134 | |
135 for (l = op_data.output_list; l; l = g_list_next(l)) | |
136 if (!strcmp(basename, g_basename(OUTPUT_PLUGIN(l->data)->filename))) | |
137 return TRUE; | |
138 | |
139 for (l = ep_data.effect_list; l; l = g_list_next(l)) | |
140 if (!strcmp(basename, g_basename(EFFECT_PLUGIN(l->data)->filename))) | |
141 return TRUE; | |
142 | |
143 for (l = gp_data.general_list; l; l = g_list_next(l)) | |
144 if (!strcmp(basename, g_basename(GENERAL_PLUGIN(l->data)->filename))) | |
145 return TRUE; | |
146 | |
147 for (l = vp_data.vis_list; l; l = g_list_next(l)) | |
148 if (!strcmp(basename, g_basename(VIS_PLUGIN(l->data)->filename))) | |
149 return TRUE; | |
150 | |
151 for (l = lowlevel_list; l; l = g_list_next(l)) | |
3227
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
152 if (!strcmp(basename, g_basename(LOWLEVEL_PLUGIN(l->data)->filename))) |
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
153 return TRUE; |
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
154 |
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
155 for (l = dp_data.discovery_list; l; l = g_list_next(l)) |
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
156 if (!strcmp(basename, g_basename(DISCOVERY_PLUGIN(l->data)->filename))) |
2313 | 157 return TRUE; |
158 | |
159 return FALSE; | |
160 } | |
161 | |
162 | |
163 #define PLUGIN_GET_INFO(x) ((PluginGetInfoFunc)(x))() | |
164 typedef Plugin * (*PluginGetInfoFunc) (void); | |
165 | |
166 static void | |
167 input_plugin_init(Plugin * plugin) | |
168 { | |
169 InputPlugin *p = INPUT_PLUGIN(plugin); | |
170 | |
171 p->get_vis_type = input_get_vis_type; | |
172 p->add_vis_pcm = input_add_vis_pcm; | |
173 | |
174 /* Pretty const casts courtesy of XMMS's plugin.h legacy. Anyone | |
175 else thinks we could use a CONST macro to solve the warnings? | |
176 - descender */ | |
177 p->set_info = (void (*)(gchar *, gint, gint, gint, gint)) playlist_set_info_old_abi; | |
3165
8775dfc57ead
Remove mainwin_set_info_text() craq. Still some work to do.
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
178 p->set_info_text = input_set_info_text; |
8775dfc57ead
Remove mainwin_set_info_text() craq. Still some work to do.
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
179 p->set_status_buffering = input_set_status_buffering; |
2313 | 180 |
181 ip_data.input_list = g_list_append(ip_data.input_list, p); | |
182 | |
183 g_hash_table_replace(plugin_matrix, g_path_get_basename(p->filename), | |
184 GINT_TO_POINTER(1)); | |
185 } | |
186 | |
187 static void | |
188 output_plugin_init(Plugin * plugin) | |
189 { | |
190 OutputPlugin *p = OUTPUT_PLUGIN(plugin); | |
191 op_data.output_list = g_list_append(op_data.output_list, p); | |
192 } | |
193 | |
194 static void | |
195 effect_plugin_init(Plugin * plugin) | |
196 { | |
197 EffectPlugin *p = EFFECT_PLUGIN(plugin); | |
198 ep_data.effect_list = g_list_append(ep_data.effect_list, p); | |
199 } | |
200 | |
201 static void | |
202 general_plugin_init(Plugin * plugin) | |
203 { | |
204 GeneralPlugin *p = GENERAL_PLUGIN(plugin); | |
205 gp_data.general_list = g_list_append(gp_data.general_list, p); | |
206 } | |
207 | |
208 static void | |
209 vis_plugin_init(Plugin * plugin) | |
210 { | |
211 VisPlugin *p = VIS_PLUGIN(plugin); | |
212 p->disable_plugin = vis_disable_plugin; | |
213 vp_data.vis_list = g_list_append(vp_data.vis_list, p); | |
214 } | |
215 | |
3227
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
216 static void |
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
217 discovery_plugin_init(Plugin * plugin) |
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
218 { |
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
219 DiscoveryPlugin *p = DISCOVERY_PLUGIN(plugin); |
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
220 dp_data.discovery_list = g_list_append(dp_data.discovery_list, p); |
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
221 } |
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
222 |
2797
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
223 /*******************************************************************/ |
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
224 |
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
225 static void |
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
226 plugin2_dispose(GModule *module, const gchar *str, ...) |
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
227 { |
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
228 gchar buf[4096]; |
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
229 va_list va; |
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
230 |
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
231 va_start(va, str); |
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
232 vsnprintf(buf, 4096, str, va); |
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
233 va_end(va); |
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
234 |
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
235 g_print("*** %s\n", buf); |
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
236 g_module_close(module); |
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
237 } |
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
238 |
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
239 void |
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
240 plugin2_process(PluginHeader *header, GModule *module, const gchar *filename) |
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
241 { |
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
242 InputPlugin **ip_iter; |
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
243 OutputPlugin **op_iter; |
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
244 EffectPlugin **ep_iter; |
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
245 GeneralPlugin **gp_iter; |
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
246 VisPlugin **vp_iter; |
3227
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
247 DiscoveryPlugin **dp_iter; |
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
248 |
2797
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
249 |
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
250 if (header->magic != PLUGIN_MAGIC) |
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
251 return plugin2_dispose(module, "plugin <%s> discarded, invalid module magic", filename); |
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
252 |
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
253 if (header->api_version != __AUDACIOUS_PLUGIN_API__) |
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
254 return plugin2_dispose(module, "plugin <%s> discarded, wanting API version %d, we implement API version %d", |
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
255 filename, header->api_version, __AUDACIOUS_PLUGIN_API__); |
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
256 |
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
257 if (header->init) |
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
258 header->init(); |
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
259 |
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
260 header->priv_assoc = g_new0(Plugin, 1); |
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
261 header->priv_assoc->handle = module; |
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
262 header->priv_assoc->filename = g_strdup(filename); |
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
263 |
2799
febdfe7a482b
[svn] - improve plugin2 loader's robustness (e.g. make it not crash)
nenolod
parents:
2798
diff
changeset
|
264 if (header->ip_list) |
2797
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
265 { |
2799
febdfe7a482b
[svn] - improve plugin2 loader's robustness (e.g. make it not crash)
nenolod
parents:
2798
diff
changeset
|
266 for (ip_iter = header->ip_list; *ip_iter != NULL; ip_iter++) |
febdfe7a482b
[svn] - improve plugin2 loader's robustness (e.g. make it not crash)
nenolod
parents:
2798
diff
changeset
|
267 { |
febdfe7a482b
[svn] - improve plugin2 loader's robustness (e.g. make it not crash)
nenolod
parents:
2798
diff
changeset
|
268 PLUGIN(*ip_iter)->filename = g_strdup(filename); |
febdfe7a482b
[svn] - improve plugin2 loader's robustness (e.g. make it not crash)
nenolod
parents:
2798
diff
changeset
|
269 g_print("plugin2 '%s' provides InputPlugin <%p>\n", filename, *ip_iter); |
febdfe7a482b
[svn] - improve plugin2 loader's robustness (e.g. make it not crash)
nenolod
parents:
2798
diff
changeset
|
270 input_plugin_init(PLUGIN(*ip_iter)); |
febdfe7a482b
[svn] - improve plugin2 loader's robustness (e.g. make it not crash)
nenolod
parents:
2798
diff
changeset
|
271 } |
2797
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
272 } |
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
273 |
2799
febdfe7a482b
[svn] - improve plugin2 loader's robustness (e.g. make it not crash)
nenolod
parents:
2798
diff
changeset
|
274 if (header->op_list) |
2797
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
275 { |
2799
febdfe7a482b
[svn] - improve plugin2 loader's robustness (e.g. make it not crash)
nenolod
parents:
2798
diff
changeset
|
276 for (op_iter = header->op_list; *op_iter != NULL; op_iter++) |
febdfe7a482b
[svn] - improve plugin2 loader's robustness (e.g. make it not crash)
nenolod
parents:
2798
diff
changeset
|
277 { |
2801 | 278 PLUGIN(*op_iter)->filename = g_strdup(filename); |
2799
febdfe7a482b
[svn] - improve plugin2 loader's robustness (e.g. make it not crash)
nenolod
parents:
2798
diff
changeset
|
279 g_print("plugin2 '%s' provides OutputPlugin <%p>\n", filename, *op_iter); |
febdfe7a482b
[svn] - improve plugin2 loader's robustness (e.g. make it not crash)
nenolod
parents:
2798
diff
changeset
|
280 output_plugin_init(PLUGIN(*op_iter)); |
febdfe7a482b
[svn] - improve plugin2 loader's robustness (e.g. make it not crash)
nenolod
parents:
2798
diff
changeset
|
281 } |
2797
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
282 } |
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
283 |
2799
febdfe7a482b
[svn] - improve plugin2 loader's robustness (e.g. make it not crash)
nenolod
parents:
2798
diff
changeset
|
284 if (header->ep_list) |
2797
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
285 { |
2799
febdfe7a482b
[svn] - improve plugin2 loader's robustness (e.g. make it not crash)
nenolod
parents:
2798
diff
changeset
|
286 for (ep_iter = header->ep_list; *ep_iter != NULL; ep_iter++) |
febdfe7a482b
[svn] - improve plugin2 loader's robustness (e.g. make it not crash)
nenolod
parents:
2798
diff
changeset
|
287 { |
2801 | 288 PLUGIN(*ep_iter)->filename = g_strdup(filename); |
2799
febdfe7a482b
[svn] - improve plugin2 loader's robustness (e.g. make it not crash)
nenolod
parents:
2798
diff
changeset
|
289 g_print("plugin2 '%s' provides EffectPlugin <%p>\n", filename, *ep_iter); |
febdfe7a482b
[svn] - improve plugin2 loader's robustness (e.g. make it not crash)
nenolod
parents:
2798
diff
changeset
|
290 effect_plugin_init(PLUGIN(*ep_iter)); |
febdfe7a482b
[svn] - improve plugin2 loader's robustness (e.g. make it not crash)
nenolod
parents:
2798
diff
changeset
|
291 } |
2797
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
292 } |
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
293 |
2799
febdfe7a482b
[svn] - improve plugin2 loader's robustness (e.g. make it not crash)
nenolod
parents:
2798
diff
changeset
|
294 if (header->gp_list) |
2797
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
295 { |
2799
febdfe7a482b
[svn] - improve plugin2 loader's robustness (e.g. make it not crash)
nenolod
parents:
2798
diff
changeset
|
296 for (gp_iter = header->gp_list; *gp_iter != NULL; gp_iter++) |
febdfe7a482b
[svn] - improve plugin2 loader's robustness (e.g. make it not crash)
nenolod
parents:
2798
diff
changeset
|
297 { |
2801 | 298 PLUGIN(*gp_iter)->filename = g_strdup(filename); |
2799
febdfe7a482b
[svn] - improve plugin2 loader's robustness (e.g. make it not crash)
nenolod
parents:
2798
diff
changeset
|
299 g_print("plugin2 '%s' provides GeneralPlugin <%p>\n", filename, *gp_iter); |
febdfe7a482b
[svn] - improve plugin2 loader's robustness (e.g. make it not crash)
nenolod
parents:
2798
diff
changeset
|
300 general_plugin_init(PLUGIN(*gp_iter)); |
febdfe7a482b
[svn] - improve plugin2 loader's robustness (e.g. make it not crash)
nenolod
parents:
2798
diff
changeset
|
301 } |
2797
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
302 } |
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
303 |
2799
febdfe7a482b
[svn] - improve plugin2 loader's robustness (e.g. make it not crash)
nenolod
parents:
2798
diff
changeset
|
304 if (header->vp_list) |
2797
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
305 { |
2799
febdfe7a482b
[svn] - improve plugin2 loader's robustness (e.g. make it not crash)
nenolod
parents:
2798
diff
changeset
|
306 for (vp_iter = header->vp_list; *vp_iter != NULL; vp_iter++) |
febdfe7a482b
[svn] - improve plugin2 loader's robustness (e.g. make it not crash)
nenolod
parents:
2798
diff
changeset
|
307 { |
2801 | 308 PLUGIN(*vp_iter)->filename = g_strdup(filename); |
2799
febdfe7a482b
[svn] - improve plugin2 loader's robustness (e.g. make it not crash)
nenolod
parents:
2798
diff
changeset
|
309 g_print("plugin2 '%s' provides VisPlugin <%p>\n", filename, *vp_iter); |
febdfe7a482b
[svn] - improve plugin2 loader's robustness (e.g. make it not crash)
nenolod
parents:
2798
diff
changeset
|
310 vis_plugin_init(PLUGIN(*vp_iter)); |
febdfe7a482b
[svn] - improve plugin2 loader's robustness (e.g. make it not crash)
nenolod
parents:
2798
diff
changeset
|
311 } |
2797
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
312 } |
3227
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
313 |
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
314 if (header->dp_list) |
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
315 { |
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
316 for (dp_iter = header->dp_list; *dp_iter != NULL; dp_iter++) |
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
317 { |
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
318 PLUGIN(*dp_iter)->filename = g_strdup(filename); |
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
319 g_print("plugin2 '%s' provides DiscoveryPlugin <%p>\n", filename, *dp_iter); |
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
320 discovery_plugin_init(PLUGIN(*dp_iter)); |
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
321 } |
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
322 } |
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
323 |
2797
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
324 } |
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
325 |
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
326 void |
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
327 plugin2_unload(PluginHeader *header) |
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
328 { |
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
329 GModule *module; |
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
330 |
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
331 g_return_if_fail(header->priv_assoc != NULL); |
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
332 |
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
333 module = header->priv_assoc->handle; |
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
334 |
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
335 g_free(header->priv_assoc->filename); |
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
336 g_free(header->priv_assoc); |
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
337 |
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
338 if (header->fini) |
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
339 header->fini(); |
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
340 |
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
341 g_module_close(module); |
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
342 } |
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
343 |
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
344 /******************************************************************/ |
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
345 |
2313 | 346 static void |
347 add_plugin(const gchar * filename) | |
348 { | |
349 GModule *module; | |
350 gpointer func; | |
351 | |
352 if (plugin_is_duplicate(filename)) | |
353 return; | |
354 | |
2623 | 355 g_message("Loaded plugin (%s)", filename); |
356 | |
2313 | 357 if (!(module = g_module_open(filename, G_MODULE_BIND_LOCAL))) { |
358 printf("Failed to load plugin (%s): %s\n", | |
359 filename, g_module_error()); | |
360 return; | |
361 } | |
362 | |
2797
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
363 /* v2 plugin loading */ |
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
364 if (g_module_symbol(module, "get_plugin_info", &func)) |
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
365 { |
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
366 PluginHeader *(*header_func_p)() = func; |
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
367 PluginHeader *header; |
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
368 |
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
369 /* this should never happen. */ |
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
370 g_return_if_fail((header = header_func_p()) != NULL); |
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
371 |
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
372 plugin2_process(header, module, filename); |
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
373 return; |
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
374 } |
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
375 |
2313 | 376 printf("Invalid plugin (%s)\n", filename); |
377 g_module_close(module); | |
378 } | |
379 | |
380 static gboolean | |
381 scan_plugin_func(const gchar * path, const gchar * basename, gpointer data) | |
382 { | |
383 if (!str_has_suffix_nocase(basename, SHARED_SUFFIX)) | |
384 return FALSE; | |
385 | |
386 if (!g_file_test(path, G_FILE_TEST_IS_REGULAR)) | |
387 return FALSE; | |
388 | |
389 add_plugin(path); | |
390 | |
391 return FALSE; | |
392 } | |
393 | |
394 static void | |
395 scan_plugins(const gchar * path) | |
396 { | |
397 dir_foreach(path, scan_plugin_func, NULL, NULL); | |
398 } | |
399 | |
400 void | |
401 plugin_system_init(void) | |
402 { | |
403 gchar *dir, **disabled; | |
404 GList *node; | |
405 OutputPlugin *op; | |
406 InputPlugin *ip; | |
407 LowlevelPlugin *lp; | |
3227
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
408 DiscoveryPlugin *dp; |
2313 | 409 gint dirsel = 0, i = 0; |
410 | |
411 if (!g_module_supported()) { | |
412 report_error("Module loading not supported! Plugins will not be loaded.\n"); | |
413 return; | |
414 } | |
415 | |
2624
840fb578a834
[svn] - [security, backport to 1.3] fix improper comparisons of hashtables used by the plugin loader.
nenolod
parents:
2623
diff
changeset
|
416 plugin_matrix = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, |
2313 | 417 NULL); |
418 | |
419 #ifndef DISABLE_USER_PLUGIN_DIR | |
420 scan_plugins(bmp_paths[BMP_PATH_USER_PLUGIN_DIR]); | |
421 /* | |
3227
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
422 * This is in a separate lo |
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
423 * DiscoveryPlugin *dpop so if the user puts them in the |
2313 | 424 * wrong dir we'll still get them in the right order (home dir |
425 * first) - Zinx | |
426 */ | |
427 while (plugin_dir_list[dirsel]) { | |
428 dir = g_build_filename(bmp_paths[BMP_PATH_USER_PLUGIN_DIR], | |
429 plugin_dir_list[dirsel++], NULL); | |
430 scan_plugins(dir); | |
431 g_free(dir); | |
432 } | |
433 dirsel = 0; | |
434 #endif | |
435 | |
436 while (plugin_dir_list[dirsel]) { | |
437 dir = g_build_filename(PLUGIN_DIR, plugin_dir_list[dirsel++], NULL); | |
438 scan_plugins(dir); | |
439 g_free(dir); | |
440 } | |
441 | |
442 op_data.output_list = g_list_sort(op_data.output_list, outputlist_compare_func); | |
443 if (!op_data.current_output_plugin | |
444 && g_list_length(op_data.output_list)) { | |
445 op_data.current_output_plugin = op_data.output_list->data; | |
446 } | |
447 | |
448 ip_data.input_list = g_list_sort(ip_data.input_list, inputlist_compare_func); | |
449 | |
450 ep_data.effect_list = g_list_sort(ep_data.effect_list, effectlist_compare_func); | |
451 ep_data.enabled_list = NULL; | |
452 | |
453 gp_data.general_list = g_list_sort(gp_data.general_list, generallist_compare_func); | |
454 gp_data.enabled_list = NULL; | |
455 | |
456 vp_data.vis_list = g_list_sort(vp_data.vis_list, vislist_compare_func); | |
457 vp_data.enabled_list = NULL; | |
458 | |
3227
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
459 dp_data.discovery_list = g_list_sort(dp_data.discovery_list, discoverylist_compare_func); |
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
460 dp_data.enabled_list = NULL; |
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
461 |
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
462 |
2313 | 463 general_enable_from_stringified_list(cfg.enabled_gplugins); |
464 vis_enable_from_stringified_list(cfg.enabled_vplugins); | |
465 effect_enable_from_stringified_list(cfg.enabled_eplugins); | |
3227
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
466 discovery_enable_from_stringified_list(cfg.enabled_dplugins); |
2313 | 467 |
468 g_free(cfg.enabled_gplugins); | |
469 cfg.enabled_gplugins = NULL; | |
470 | |
471 g_free(cfg.enabled_vplugins); | |
472 cfg.enabled_vplugins = NULL; | |
473 | |
474 g_free(cfg.enabled_eplugins); | |
475 cfg.enabled_eplugins = NULL; | |
476 | |
3227
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
477 g_free(cfg.enabled_dplugins); |
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
478 cfg.enabled_dplugins = NULL; |
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
479 |
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
480 |
2313 | 481 for (node = op_data.output_list; node; node = g_list_next(node)) { |
482 op = OUTPUT_PLUGIN(node->data); | |
483 /* | |
484 * Only test basename to avoid problems when changing | |
485 * prefix. We will only see one plugin with the same | |
486 * basename, so this is usually what the user want. | |
487 */ | |
488 if (!strcmp(g_basename(cfg.outputplugin), g_basename(op->filename))) | |
489 op_data.current_output_plugin = op; | |
490 if (op->init) | |
491 op->init(); | |
492 } | |
493 | |
494 for (node = ip_data.input_list; node; node = g_list_next(node)) { | |
495 ip = INPUT_PLUGIN(node->data); | |
496 if (ip->init) | |
497 ip->init(); | |
498 } | |
499 | |
3227
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
500 for (node = dp_data.discovery_list; node; node = g_list_next(node)) { |
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
501 dp = DISCOVERY_PLUGIN(node->data); |
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
502 if (dp->init) |
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
503 dp->init(); |
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
504 } |
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
505 |
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
506 |
2313 | 507 for (node = lowlevel_list; node; node = g_list_next(node)) { |
508 lp = LOWLEVEL_PLUGIN(node->data); | |
509 if (lp->init) | |
510 lp->init(); | |
511 } | |
512 | |
513 if (cfg.disabled_iplugins) { | |
514 disabled = g_strsplit(cfg.disabled_iplugins, ":", 0); | |
515 while (disabled[i]) { | |
516 g_hash_table_replace(plugin_matrix, disabled[i], | |
517 GINT_TO_POINTER(FALSE)); | |
518 i++; | |
519 } | |
520 | |
521 g_free(disabled); | |
522 | |
523 g_free(cfg.disabled_iplugins); | |
524 cfg.disabled_iplugins = NULL; | |
525 } | |
526 } | |
527 | |
528 void | |
529 plugin_system_cleanup(void) | |
530 { | |
531 InputPlugin *ip; | |
532 OutputPlugin *op; | |
533 EffectPlugin *ep; | |
534 GeneralPlugin *gp; | |
535 VisPlugin *vp; | |
536 LowlevelPlugin *lp; | |
3227
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
537 DiscoveryPlugin *dp; |
2313 | 538 GList *node; |
539 | |
540 g_message("Shutting down plugin system"); | |
541 | |
542 if (playback_get_playing()) { | |
543 ip_data.stop = TRUE; | |
544 playback_stop(); | |
545 ip_data.stop = FALSE; | |
546 } | |
547 | |
2623 | 548 /* FIXME: race condition -nenolod */ |
549 op_data.current_output_plugin = NULL; | |
550 | |
2313 | 551 for (node = get_input_list(); node; node = g_list_next(node)) { |
552 ip = INPUT_PLUGIN(node->data); | |
553 if (ip && ip->cleanup) { | |
554 ip->cleanup(); | |
555 GDK_THREADS_LEAVE(); | |
556 while (g_main_context_iteration(NULL, FALSE)); | |
557 GDK_THREADS_ENTER(); | |
558 } | |
2797
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
559 |
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
560 if (ip->handle) |
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
561 g_module_close(ip->handle); |
2313 | 562 } |
563 | |
2623 | 564 if (ip_data.input_list != NULL) |
565 { | |
2313 | 566 g_list_free(ip_data.input_list); |
2623 | 567 ip_data.input_list = NULL; |
568 } | |
2313 | 569 |
570 for (node = get_output_list(); node; node = g_list_next(node)) { | |
571 op = OUTPUT_PLUGIN(node->data); | |
572 if (op && op->cleanup) { | |
573 op->cleanup(); | |
574 GDK_THREADS_LEAVE(); | |
575 while (g_main_context_iteration(NULL, FALSE)); | |
576 GDK_THREADS_ENTER(); | |
577 } | |
2797
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
578 |
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
579 if (op->handle) |
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
580 g_module_close(op->handle); |
2313 | 581 } |
582 | |
2623 | 583 if (op_data.output_list != NULL) |
584 { | |
2313 | 585 g_list_free(op_data.output_list); |
2623 | 586 op_data.output_list = NULL; |
587 } | |
2313 | 588 |
589 for (node = get_effect_list(); node; node = g_list_next(node)) { | |
590 ep = EFFECT_PLUGIN(node->data); | |
591 if (ep && ep->cleanup) { | |
592 ep->cleanup(); | |
593 GDK_THREADS_LEAVE(); | |
594 while (g_main_context_iteration(NULL, FALSE)); | |
595 GDK_THREADS_ENTER(); | |
596 } | |
2797
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
597 |
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
598 if (ep->handle) |
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
599 g_module_close(ep->handle); |
2313 | 600 } |
601 | |
2623 | 602 if (ep_data.effect_list != NULL) |
603 { | |
2313 | 604 g_list_free(ep_data.effect_list); |
2623 | 605 ep_data.effect_list = NULL; |
2313 | 606 } |
607 | |
608 for (node = get_general_list(); node; node = g_list_next(node)) { | |
609 gp = GENERAL_PLUGIN(node->data); | |
610 if (gp && gp->cleanup) { | |
611 gp->cleanup(); | |
612 GDK_THREADS_LEAVE(); | |
613 while (g_main_context_iteration(NULL, FALSE)); | |
614 GDK_THREADS_ENTER(); | |
615 } | |
2797
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
616 |
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
617 if (gp->handle) |
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
618 g_module_close(gp->handle); |
2313 | 619 } |
620 | |
2623 | 621 if (gp_data.general_list != NULL) |
622 { | |
2313 | 623 g_list_free(gp_data.general_list); |
2623 | 624 gp_data.general_list = NULL; |
2313 | 625 } |
626 | |
627 for (node = get_vis_list(); node; node = g_list_next(node)) { | |
628 vp = VIS_PLUGIN(node->data); | |
629 if (vp && vp->cleanup) { | |
630 vp->cleanup(); | |
631 GDK_THREADS_LEAVE(); | |
632 while (g_main_context_iteration(NULL, FALSE)); | |
633 GDK_THREADS_ENTER(); | |
634 } | |
2797
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
635 |
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
636 if (vp->handle) |
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
637 g_module_close(vp->handle); |
2313 | 638 } |
639 | |
2623 | 640 if (vp_data.vis_list != NULL) |
641 { | |
2313 | 642 g_list_free(vp_data.vis_list); |
2623 | 643 vp_data.vis_list = NULL; |
644 } | |
2313 | 645 |
3227
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
646 |
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
647 for (node = get_discovery_list(); node; node = g_list_next(node)) { |
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
648 dp = DISCOVERY_PLUGIN(node->data); |
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
649 if (dp && dp->cleanup) { |
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
650 dp->cleanup(); |
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
651 GDK_THREADS_LEAVE(); |
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
652 while (g_main_context_iteration(NULL, FALSE)); |
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
653 GDK_THREADS_ENTER(); |
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
654 } |
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
655 |
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
656 if (dp->handle) |
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
657 g_module_close(dp->handle); |
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
658 } |
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
659 |
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
660 if (dp_data.discovery_list != NULL) |
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
661 { |
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
662 g_list_free(dp_data.discovery_list); |
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
663 dp_data.discovery_list = NULL; |
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
664 } |
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
665 |
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
666 |
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
667 |
2313 | 668 for (node = lowlevel_list; node; node = g_list_next(node)) { |
669 lp = LOWLEVEL_PLUGIN(node->data); | |
670 if (lp && lp->cleanup) { | |
671 lp->cleanup(); | |
672 GDK_THREADS_LEAVE(); | |
673 while (g_main_context_iteration(NULL, FALSE)); | |
674 GDK_THREADS_ENTER(); | |
675 } | |
2797
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
676 |
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
677 if (lp->handle) |
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
678 g_module_close(lp->handle); |
2313 | 679 } |
680 | |
2623 | 681 if (lowlevel_list != NULL) |
682 { | |
2313 | 683 g_list_free(lowlevel_list); |
2623 | 684 lowlevel_list = NULL; |
685 } | |
686 | |
687 /* XXX: vfs will crash otherwise. -nenolod */ | |
688 if (vfs_transports != NULL) | |
689 { | |
690 g_list_free(vfs_transports); | |
691 vfs_transports = NULL; | |
692 } | |
2682
c3cd6e47faf6
[svn] - make the evil 'reload plugins' button behave a bit better
giacomo
parents:
2624
diff
changeset
|
693 |
c3cd6e47faf6
[svn] - make the evil 'reload plugins' button behave a bit better
giacomo
parents:
2624
diff
changeset
|
694 g_hash_table_destroy( plugin_matrix ); |
2313 | 695 } |