comparison src/audacious/input.c @ 3437:3092a8b3fe34 trunk

Big plugin system changes (part 1 of who knows, it's still a big mess): - remove plugin_matrix, replacing it with a mowgli.dictionary of all loaded plugins pointing back to their handles - input_is_enabled() craq -> gboolean plugin::enabled (this craq was pointed out by ccr) - consolidate a lot of crap in ui_preferences.c (a LOT more to come) - introduce probably countless loads of bugs and SIGSEGVs. - you WILL need to recompile plugins after this, and some which do not use C99-style struct initialisers will likely fail to build.
author William Pitcock <nenolod@atheme.org>
date Fri, 07 Sep 2007 03:20:28 -0500
parents 820c2db12041
children b0f4ab42dd3b 95d6cbf21614
comparison
equal deleted inserted replaced
3436:a630ecae6708 3437:3092a8b3fe34
29 29
30 #include <glib.h> 30 #include <glib.h>
31 #include <glib/gi18n.h> 31 #include <glib/gi18n.h>
32 #include <gtk/gtk.h> 32 #include <gtk/gtk.h>
33 #include <string.h> 33 #include <string.h>
34
35 #include <mowgli.h>
34 36
35 #include "fft.h" 37 #include "fft.h"
36 #include "input.h" 38 #include "input.h"
37 #include "main.h" 39 #include "main.h"
38 #include "output.h" 40 #include "output.h"
91 get_input_list(void) 93 get_input_list(void)
92 { 94 {
93 return ip_data.input_list; 95 return ip_data.input_list;
94 } 96 }
95 97
96 98 /*
97 gboolean 99 * TODO: move this to utility as something like
98 input_is_enabled(const gchar * filename) 100 * plugin_generate_list(GList *plugin_list, gboolean enabled_state)
99 { 101 *
100 gchar *basename = g_path_get_basename(filename); 102 * -nenolod
101 gint enabled; 103 */
102
103 enabled = GPOINTER_TO_INT(g_hash_table_lookup(plugin_matrix, basename));
104 g_free(basename);
105
106 return enabled;
107 }
108
109 static void
110 disabled_iplugins_foreach_func(const gchar * name,
111 gboolean enabled,
112 GString * list)
113 {
114 g_return_if_fail(list != NULL);
115
116 if (enabled)
117 return;
118
119 if (list->len > 0)
120 g_string_append(list, ":");
121
122 g_string_append(list, name);
123 }
124
125 gchar * 104 gchar *
126 input_stringify_disabled_list(void) 105 input_stringify_disabled_list(void)
127 { 106 {
128 GString *disabled_list; 107 GList *node;
129 108 GString *list = g_string_new("");
130 disabled_list = g_string_new(""); 109
131 g_hash_table_foreach(plugin_matrix, 110 MOWGLI_ITER_FOREACH(node, ip_data.input_list)
132 (GHFunc) disabled_iplugins_foreach_func, 111 {
133 disabled_list); 112 Plugin *plugin = (Plugin *) node->data;
134 113 gchar *filename = g_path_get_basename(plugin->filename);
135 return g_string_free(disabled_list, FALSE); 114
115 if (plugin->enabled)
116 continue;
117
118 if (list->len > 0)
119 g_string_append(list, ":");
120
121 g_string_append(list, filename);
122 g_free(filename);
123 }
124
125 return g_string_free(list, FALSE);
136 } 126 }
137 127
138 void 128 void
139 free_vis_data(void) 129 free_vis_data(void)
140 { 130 {
369 if (tmp != NULL && g_ascii_isdigit(*(tmp + 1))) 359 if (tmp != NULL && g_ascii_isdigit(*(tmp + 1)))
370 *tmp = '\0'; 360 *tmp = '\0';
371 361
372 /* Check for plugins with custom URI:// strings */ 362 /* Check for plugins with custom URI:// strings */
373 /* cue:// cdda:// tone:// tact:// */ 363 /* cue:// cdda:// tone:// tact:// */
374 if ((ip = uri_get_plugin(filename)) != NULL && 364 if ((ip = uri_get_plugin(filename)) != NULL && ip->enabled)
375 input_is_enabled(ip->filename) == TRUE)
376 { 365 {
377 if (ip->is_our_file != NULL) 366 if (ip->is_our_file != NULL)
378 ret = ip->is_our_file(filename_proxy); 367 ret = ip->is_our_file(filename_proxy);
379 else 368 else
380 ret = 0; 369 ret = 0;
394 /* 383 /*
395 if (!g_strncasecmp(filename, "cue://", 6)) { 384 if (!g_strncasecmp(filename, "cue://", 6)) {
396 for (node = get_input_list(); node != NULL; node = g_list_next(node)) 385 for (node = get_input_list(); node != NULL; node = g_list_next(node))
397 { 386 {
398 ip = INPUT_PLUGIN(node->data); 387 ip = INPUT_PLUGIN(node->data);
399 if (!ip || !input_is_enabled(ip->filename)) 388 if (!ip || !ip->enabled)
400 continue; 389 continue;
401 if (ip->is_our_file != NULL) 390 if (ip->is_our_file != NULL)
402 ret = ip->is_our_file(filename_proxy); 391 ret = ip->is_our_file(filename_proxy);
403 else 392 else
404 ret = 0; 393 ret = 0;
428 use_ext_filter = 417 use_ext_filter =
429 (fd != NULL && (!g_strncasecmp(filename, "/", 1) || 418 (fd != NULL && (!g_strncasecmp(filename, "/", 1) ||
430 !g_strncasecmp(filename, "file://", 7))) ? TRUE : FALSE; 419 !g_strncasecmp(filename, "file://", 7))) ? TRUE : FALSE;
431 420
432 mimetype = vfs_get_metadata(fd, "content-type"); 421 mimetype = vfs_get_metadata(fd, "content-type");
433 if ((ip = mime_get_plugin(mimetype)) != NULL && 422 if ((ip = mime_get_plugin(mimetype)) != NULL && ip->enabled)
434 input_is_enabled(ip->filename) == TRUE)
435 { 423 {
436 if (ip->probe_for_tuple != NULL) 424 if (ip->probe_for_tuple != NULL)
437 { 425 {
438 Tuple *tuple = ip->probe_for_tuple(filename_proxy, fd); 426 Tuple *tuple = ip->probe_for_tuple(filename_proxy, fd);
439 427
484 472
485 for (node = get_input_list(); node != NULL; node = g_list_next(node)) 473 for (node = get_input_list(); node != NULL; node = g_list_next(node))
486 { 474 {
487 ip = INPUT_PLUGIN(node->data); 475 ip = INPUT_PLUGIN(node->data);
488 476
489 if (!ip || !input_is_enabled(ip->filename)) 477 if (!ip || !ip->enabled)
490 continue; 478 continue;
491 479
492 vfs_rewind(fd); 480 vfs_rewind(fd);
493 481
494 if (cfg.use_extension_probing == TRUE && ip->vfs_extensions != NULL && 482 if (cfg.use_extension_probing == TRUE && ip->vfs_extensions != NULL &&
762 continue; 750 continue;
763 751
764 if (!ip->scan_dir) 752 if (!ip->scan_dir)
765 continue; 753 continue;
766 754
767 if (!input_is_enabled(ip->filename)) 755 if (!ip->enabled)
768 continue; 756 continue;
769 757
770 if ((result = ip->scan_dir(path_proxy))) 758 if ((result = ip->scan_dir(path_proxy)))
771 break; 759 break;
772 } 760 }