Mercurial > audlegacy
annotate src/audacious/pluginenum.c @ 3227:2619f4c62abe trunk
added Discovery plugin type
| author | Cristi Magherusan <majeru@atheme-project.org> |
|---|---|
| date | Fri, 03 Aug 2007 07:20:58 +0300 |
| parents | 8775dfc57ead |
| children | 2453bf125b4f |
| 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 |
|
3165
8775dfc57ead
Remove mainwin_set_info_text() craq. Still some work to do.
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
253 #if 0 |
|
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
|
254 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
|
255 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
|
256 filename, header->api_version, __AUDACIOUS_PLUGIN_API__); |
|
3165
8775dfc57ead
Remove mainwin_set_info_text() craq. Still some work to do.
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
257 #endif |
|
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
|
258 |
|
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 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
|
260 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
|
261 |
|
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 = 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
|
263 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
|
264 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
|
265 |
|
2799
febdfe7a482b
[svn] - improve plugin2 loader's robustness (e.g. make it not crash)
nenolod
parents:
2798
diff
changeset
|
266 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
|
267 { |
|
2799
febdfe7a482b
[svn] - improve plugin2 loader's robustness (e.g. make it not crash)
nenolod
parents:
2798
diff
changeset
|
268 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
|
269 { |
|
febdfe7a482b
[svn] - improve plugin2 loader's robustness (e.g. make it not crash)
nenolod
parents:
2798
diff
changeset
|
270 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
|
271 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
|
272 input_plugin_init(PLUGIN(*ip_iter)); |
|
febdfe7a482b
[svn] - improve plugin2 loader's robustness (e.g. make it not crash)
nenolod
parents:
2798
diff
changeset
|
273 } |
|
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
|
274 } |
|
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 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
|
277 { |
|
2799
febdfe7a482b
[svn] - improve plugin2 loader's robustness (e.g. make it not crash)
nenolod
parents:
2798
diff
changeset
|
278 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
|
279 { |
| 2801 | 280 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
|
281 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
|
282 output_plugin_init(PLUGIN(*op_iter)); |
|
febdfe7a482b
[svn] - improve plugin2 loader's robustness (e.g. make it not crash)
nenolod
parents:
2798
diff
changeset
|
283 } |
|
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
|
284 } |
|
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 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
|
287 { |
|
2799
febdfe7a482b
[svn] - improve plugin2 loader's robustness (e.g. make it not crash)
nenolod
parents:
2798
diff
changeset
|
288 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
|
289 { |
| 2801 | 290 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
|
291 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
|
292 effect_plugin_init(PLUGIN(*ep_iter)); |
|
febdfe7a482b
[svn] - improve plugin2 loader's robustness (e.g. make it not crash)
nenolod
parents:
2798
diff
changeset
|
293 } |
|
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
|
294 } |
|
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 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
|
297 { |
|
2799
febdfe7a482b
[svn] - improve plugin2 loader's robustness (e.g. make it not crash)
nenolod
parents:
2798
diff
changeset
|
298 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
|
299 { |
| 2801 | 300 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
|
301 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
|
302 general_plugin_init(PLUGIN(*gp_iter)); |
|
febdfe7a482b
[svn] - improve plugin2 loader's robustness (e.g. make it not crash)
nenolod
parents:
2798
diff
changeset
|
303 } |
|
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
|
304 } |
|
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 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
|
307 { |
|
2799
febdfe7a482b
[svn] - improve plugin2 loader's robustness (e.g. make it not crash)
nenolod
parents:
2798
diff
changeset
|
308 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
|
309 { |
| 2801 | 310 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
|
311 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
|
312 vis_plugin_init(PLUGIN(*vp_iter)); |
|
febdfe7a482b
[svn] - improve plugin2 loader's robustness (e.g. make it not crash)
nenolod
parents:
2798
diff
changeset
|
313 } |
|
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
|
314 } |
|
3227
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 if (header->dp_list) |
|
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 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
|
319 { |
|
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
320 PLUGIN(*dp_iter)->filename = g_strdup(filename); |
|
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
321 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
|
322 discovery_plugin_init(PLUGIN(*dp_iter)); |
|
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
323 } |
|
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
324 } |
|
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
325 |
|
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
|
326 } |
|
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 |
|
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 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
|
329 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
|
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 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
|
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 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
|
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 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
|
336 |
|
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 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
|
338 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
|
339 |
|
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 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
|
341 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
|
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 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
|
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 |
|
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
|
346 /******************************************************************/ |
|
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
|
347 |
| 2313 | 348 static void |
| 349 add_plugin(const gchar * filename) | |
| 350 { | |
| 351 GModule *module; | |
| 352 gpointer func; | |
| 353 | |
| 354 if (plugin_is_duplicate(filename)) | |
| 355 return; | |
| 356 | |
| 2623 | 357 g_message("Loaded plugin (%s)", filename); |
| 358 | |
| 2313 | 359 if (!(module = g_module_open(filename, G_MODULE_BIND_LOCAL))) { |
| 360 printf("Failed to load plugin (%s): %s\n", | |
| 361 filename, g_module_error()); | |
| 362 return; | |
| 363 } | |
| 364 | |
|
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
|
365 /* 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
|
366 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
|
367 { |
|
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 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
|
369 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
|
370 |
|
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 /* 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
|
372 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
|
373 |
|
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 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
|
375 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
|
376 } |
|
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
|
377 |
| 2313 | 378 printf("Invalid plugin (%s)\n", filename); |
| 379 g_module_close(module); | |
| 380 } | |
| 381 | |
| 382 static gboolean | |
| 383 scan_plugin_func(const gchar * path, const gchar * basename, gpointer data) | |
| 384 { | |
| 385 if (!str_has_suffix_nocase(basename, SHARED_SUFFIX)) | |
| 386 return FALSE; | |
| 387 | |
| 388 if (!g_file_test(path, G_FILE_TEST_IS_REGULAR)) | |
| 389 return FALSE; | |
| 390 | |
| 391 add_plugin(path); | |
| 392 | |
| 393 return FALSE; | |
| 394 } | |
| 395 | |
| 396 static void | |
| 397 scan_plugins(const gchar * path) | |
| 398 { | |
| 399 dir_foreach(path, scan_plugin_func, NULL, NULL); | |
| 400 } | |
| 401 | |
| 402 void | |
| 403 plugin_system_init(void) | |
| 404 { | |
| 405 gchar *dir, **disabled; | |
| 406 GList *node; | |
| 407 OutputPlugin *op; | |
| 408 InputPlugin *ip; | |
| 409 LowlevelPlugin *lp; | |
|
3227
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
410 DiscoveryPlugin *dp; |
| 2313 | 411 gint dirsel = 0, i = 0; |
| 412 | |
| 413 if (!g_module_supported()) { | |
| 414 report_error("Module loading not supported! Plugins will not be loaded.\n"); | |
| 415 return; | |
| 416 } | |
| 417 | |
|
2624
840fb578a834
[svn] - [security, backport to 1.3] fix improper comparisons of hashtables used by the plugin loader.
nenolod
parents:
2623
diff
changeset
|
418 plugin_matrix = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, |
| 2313 | 419 NULL); |
| 420 | |
| 421 #ifndef DISABLE_USER_PLUGIN_DIR | |
| 422 scan_plugins(bmp_paths[BMP_PATH_USER_PLUGIN_DIR]); | |
| 423 /* | |
|
3227
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
424 * This is in a separate lo |
|
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
425 * DiscoveryPlugin *dpop so if the user puts them in the |
| 2313 | 426 * wrong dir we'll still get them in the right order (home dir |
| 427 * first) - Zinx | |
| 428 */ | |
| 429 while (plugin_dir_list[dirsel]) { | |
| 430 dir = g_build_filename(bmp_paths[BMP_PATH_USER_PLUGIN_DIR], | |
| 431 plugin_dir_list[dirsel++], NULL); | |
| 432 scan_plugins(dir); | |
| 433 g_free(dir); | |
| 434 } | |
| 435 dirsel = 0; | |
| 436 #endif | |
| 437 | |
| 438 while (plugin_dir_list[dirsel]) { | |
| 439 dir = g_build_filename(PLUGIN_DIR, plugin_dir_list[dirsel++], NULL); | |
| 440 scan_plugins(dir); | |
| 441 g_free(dir); | |
| 442 } | |
| 443 | |
| 444 op_data.output_list = g_list_sort(op_data.output_list, outputlist_compare_func); | |
| 445 if (!op_data.current_output_plugin | |
| 446 && g_list_length(op_data.output_list)) { | |
| 447 op_data.current_output_plugin = op_data.output_list->data; | |
| 448 } | |
| 449 | |
| 450 ip_data.input_list = g_list_sort(ip_data.input_list, inputlist_compare_func); | |
| 451 | |
| 452 ep_data.effect_list = g_list_sort(ep_data.effect_list, effectlist_compare_func); | |
| 453 ep_data.enabled_list = NULL; | |
| 454 | |
| 455 gp_data.general_list = g_list_sort(gp_data.general_list, generallist_compare_func); | |
| 456 gp_data.enabled_list = NULL; | |
| 457 | |
| 458 vp_data.vis_list = g_list_sort(vp_data.vis_list, vislist_compare_func); | |
| 459 vp_data.enabled_list = NULL; | |
| 460 | |
|
3227
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
461 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
|
462 dp_data.enabled_list = NULL; |
|
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
463 |
|
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
464 |
| 2313 | 465 general_enable_from_stringified_list(cfg.enabled_gplugins); |
| 466 vis_enable_from_stringified_list(cfg.enabled_vplugins); | |
| 467 effect_enable_from_stringified_list(cfg.enabled_eplugins); | |
|
3227
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
468 discovery_enable_from_stringified_list(cfg.enabled_dplugins); |
| 2313 | 469 |
| 470 g_free(cfg.enabled_gplugins); | |
| 471 cfg.enabled_gplugins = NULL; | |
| 472 | |
| 473 g_free(cfg.enabled_vplugins); | |
| 474 cfg.enabled_vplugins = NULL; | |
| 475 | |
| 476 g_free(cfg.enabled_eplugins); | |
| 477 cfg.enabled_eplugins = NULL; | |
| 478 | |
|
3227
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
479 g_free(cfg.enabled_dplugins); |
|
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
480 cfg.enabled_dplugins = NULL; |
|
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
481 |
|
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
482 |
| 2313 | 483 for (node = op_data.output_list; node; node = g_list_next(node)) { |
| 484 op = OUTPUT_PLUGIN(node->data); | |
| 485 /* | |
| 486 * Only test basename to avoid problems when changing | |
| 487 * prefix. We will only see one plugin with the same | |
| 488 * basename, so this is usually what the user want. | |
| 489 */ | |
| 490 if (!strcmp(g_basename(cfg.outputplugin), g_basename(op->filename))) | |
| 491 op_data.current_output_plugin = op; | |
| 492 if (op->init) | |
| 493 op->init(); | |
| 494 } | |
| 495 | |
| 496 for (node = ip_data.input_list; node; node = g_list_next(node)) { | |
| 497 ip = INPUT_PLUGIN(node->data); | |
| 498 if (ip->init) | |
| 499 ip->init(); | |
| 500 } | |
| 501 | |
|
3227
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
502 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
|
503 dp = DISCOVERY_PLUGIN(node->data); |
|
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
504 if (dp->init) |
|
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
505 dp->init(); |
|
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
506 } |
|
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
507 |
|
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
508 |
| 2313 | 509 for (node = lowlevel_list; node; node = g_list_next(node)) { |
| 510 lp = LOWLEVEL_PLUGIN(node->data); | |
| 511 if (lp->init) | |
| 512 lp->init(); | |
| 513 } | |
| 514 | |
| 515 if (cfg.disabled_iplugins) { | |
| 516 disabled = g_strsplit(cfg.disabled_iplugins, ":", 0); | |
| 517 while (disabled[i]) { | |
| 518 g_hash_table_replace(plugin_matrix, disabled[i], | |
| 519 GINT_TO_POINTER(FALSE)); | |
| 520 i++; | |
| 521 } | |
| 522 | |
| 523 g_free(disabled); | |
| 524 | |
| 525 g_free(cfg.disabled_iplugins); | |
| 526 cfg.disabled_iplugins = NULL; | |
| 527 } | |
| 528 } | |
| 529 | |
| 530 void | |
| 531 plugin_system_cleanup(void) | |
| 532 { | |
| 533 InputPlugin *ip; | |
| 534 OutputPlugin *op; | |
| 535 EffectPlugin *ep; | |
| 536 GeneralPlugin *gp; | |
| 537 VisPlugin *vp; | |
| 538 LowlevelPlugin *lp; | |
|
3227
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
539 DiscoveryPlugin *dp; |
| 2313 | 540 GList *node; |
| 541 | |
| 542 g_message("Shutting down plugin system"); | |
| 543 | |
| 544 if (playback_get_playing()) { | |
| 545 ip_data.stop = TRUE; | |
| 546 playback_stop(); | |
| 547 ip_data.stop = FALSE; | |
| 548 } | |
| 549 | |
| 2623 | 550 /* FIXME: race condition -nenolod */ |
| 551 op_data.current_output_plugin = NULL; | |
| 552 | |
| 2313 | 553 for (node = get_input_list(); node; node = g_list_next(node)) { |
| 554 ip = INPUT_PLUGIN(node->data); | |
| 555 if (ip && ip->cleanup) { | |
| 556 ip->cleanup(); | |
| 557 GDK_THREADS_LEAVE(); | |
| 558 while (g_main_context_iteration(NULL, FALSE)); | |
| 559 GDK_THREADS_ENTER(); | |
| 560 } | |
|
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
|
561 |
|
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
|
562 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
|
563 g_module_close(ip->handle); |
| 2313 | 564 } |
| 565 | |
| 2623 | 566 if (ip_data.input_list != NULL) |
| 567 { | |
| 2313 | 568 g_list_free(ip_data.input_list); |
| 2623 | 569 ip_data.input_list = NULL; |
| 570 } | |
| 2313 | 571 |
| 572 for (node = get_output_list(); node; node = g_list_next(node)) { | |
| 573 op = OUTPUT_PLUGIN(node->data); | |
| 574 if (op && op->cleanup) { | |
| 575 op->cleanup(); | |
| 576 GDK_THREADS_LEAVE(); | |
| 577 while (g_main_context_iteration(NULL, FALSE)); | |
| 578 GDK_THREADS_ENTER(); | |
| 579 } | |
|
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
|
580 |
|
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
|
581 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
|
582 g_module_close(op->handle); |
| 2313 | 583 } |
| 584 | |
| 2623 | 585 if (op_data.output_list != NULL) |
| 586 { | |
| 2313 | 587 g_list_free(op_data.output_list); |
| 2623 | 588 op_data.output_list = NULL; |
| 589 } | |
| 2313 | 590 |
| 591 for (node = get_effect_list(); node; node = g_list_next(node)) { | |
| 592 ep = EFFECT_PLUGIN(node->data); | |
| 593 if (ep && ep->cleanup) { | |
| 594 ep->cleanup(); | |
| 595 GDK_THREADS_LEAVE(); | |
| 596 while (g_main_context_iteration(NULL, FALSE)); | |
| 597 GDK_THREADS_ENTER(); | |
| 598 } | |
|
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
|
599 |
|
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
|
600 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
|
601 g_module_close(ep->handle); |
| 2313 | 602 } |
| 603 | |
| 2623 | 604 if (ep_data.effect_list != NULL) |
| 605 { | |
| 2313 | 606 g_list_free(ep_data.effect_list); |
| 2623 | 607 ep_data.effect_list = NULL; |
| 2313 | 608 } |
| 609 | |
| 610 for (node = get_general_list(); node; node = g_list_next(node)) { | |
| 611 gp = GENERAL_PLUGIN(node->data); | |
| 612 if (gp && gp->cleanup) { | |
| 613 gp->cleanup(); | |
| 614 GDK_THREADS_LEAVE(); | |
| 615 while (g_main_context_iteration(NULL, FALSE)); | |
| 616 GDK_THREADS_ENTER(); | |
| 617 } | |
|
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
|
618 |
|
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
|
619 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
|
620 g_module_close(gp->handle); |
| 2313 | 621 } |
| 622 | |
| 2623 | 623 if (gp_data.general_list != NULL) |
| 624 { | |
| 2313 | 625 g_list_free(gp_data.general_list); |
| 2623 | 626 gp_data.general_list = NULL; |
| 2313 | 627 } |
| 628 | |
| 629 for (node = get_vis_list(); node; node = g_list_next(node)) { | |
| 630 vp = VIS_PLUGIN(node->data); | |
| 631 if (vp && vp->cleanup) { | |
| 632 vp->cleanup(); | |
| 633 GDK_THREADS_LEAVE(); | |
| 634 while (g_main_context_iteration(NULL, FALSE)); | |
| 635 GDK_THREADS_ENTER(); | |
| 636 } | |
|
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
|
637 |
|
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
|
638 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
|
639 g_module_close(vp->handle); |
| 2313 | 640 } |
| 641 | |
| 2623 | 642 if (vp_data.vis_list != NULL) |
| 643 { | |
| 2313 | 644 g_list_free(vp_data.vis_list); |
| 2623 | 645 vp_data.vis_list = NULL; |
| 646 } | |
| 2313 | 647 |
|
3227
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
648 |
|
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
649 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
|
650 dp = DISCOVERY_PLUGIN(node->data); |
|
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
651 if (dp && dp->cleanup) { |
|
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
652 dp->cleanup(); |
|
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
653 GDK_THREADS_LEAVE(); |
|
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
654 while (g_main_context_iteration(NULL, FALSE)); |
|
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
655 GDK_THREADS_ENTER(); |
|
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
656 } |
|
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
657 |
|
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
658 if (dp->handle) |
|
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
659 g_module_close(dp->handle); |
|
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
660 } |
|
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 if (dp_data.discovery_list != NULL) |
|
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
663 { |
|
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
664 g_list_free(dp_data.discovery_list); |
|
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
665 dp_data.discovery_list = NULL; |
|
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 |
|
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
668 |
|
2619f4c62abe
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
3165
diff
changeset
|
669 |
| 2313 | 670 for (node = lowlevel_list; node; node = g_list_next(node)) { |
| 671 lp = LOWLEVEL_PLUGIN(node->data); | |
| 672 if (lp && lp->cleanup) { | |
| 673 lp->cleanup(); | |
| 674 GDK_THREADS_LEAVE(); | |
| 675 while (g_main_context_iteration(NULL, FALSE)); | |
| 676 GDK_THREADS_ENTER(); | |
| 677 } | |
|
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
|
678 |
|
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
|
679 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
|
680 g_module_close(lp->handle); |
| 2313 | 681 } |
| 682 | |
| 2623 | 683 if (lowlevel_list != NULL) |
| 684 { | |
| 2313 | 685 g_list_free(lowlevel_list); |
| 2623 | 686 lowlevel_list = NULL; |
| 687 } | |
| 688 | |
| 689 /* XXX: vfs will crash otherwise. -nenolod */ | |
| 690 if (vfs_transports != NULL) | |
| 691 { | |
| 692 g_list_free(vfs_transports); | |
| 693 vfs_transports = NULL; | |
| 694 } | |
|
2682
c3cd6e47faf6
[svn] - make the evil 'reload plugins' button behave a bit better
giacomo
parents:
2624
diff
changeset
|
695 |
|
c3cd6e47faf6
[svn] - make the evil 'reload plugins' button behave a bit better
giacomo
parents:
2624
diff
changeset
|
696 g_hash_table_destroy( plugin_matrix ); |
| 2313 | 697 } |
