17 #include "xmms_configuration.h" 32 # include <memcheck.h> 37 #define get_module_ext(dir) g_build_filename (dir, "*.bundle", NULL) 39 #define get_module_ext(dir) g_module_build_path (dir, "*") 46 static GList *xmms_plugin_list;
53 static gboolean xmms_plugin_scan_directory (
const gchar *dir);
82 g_return_val_if_fail (plugin, NULL);
83 g_return_val_if_fail (key, NULL);
85 g_snprintf (path,
sizeof (path),
"%s.%s",
106 const gchar *default_value,
113 g_return_val_if_fail (plugin, NULL);
114 g_return_val_if_fail (name, NULL);
115 g_return_val_if_fail (default_value, NULL);
117 g_snprintf (fullpath,
sizeof (fullpath),
"%s.%s",
134 g_return_val_if_fail (plugin, 0);
147 g_return_val_if_fail (plugin, NULL);
160 g_return_val_if_fail (plugin, NULL);
173 g_return_val_if_fail (plugin, NULL);
186 g_return_val_if_fail (plugin, NULL);
197 xmms_plugin_add_builtin_plugins (
void)
205 xmms_plugin_load (&xmms_builtin_ringbuf, NULL);
206 xmms_plugin_load (&xmms_builtin_magic, NULL);
207 xmms_plugin_load (&xmms_builtin_converter, NULL);
208 xmms_plugin_load (&xmms_builtin_segment, NULL);
209 xmms_plugin_load (&xmms_builtin_visualization, NULL);
224 xmms_plugin_scan_directory (path);
226 xmms_plugin_add_builtin_plugins ();
245 VALGRIND_DO_LEAK_CHECK
249 while (xmms_plugin_list) {
262 xmms_plugin_list = g_list_delete_link (xmms_plugin_list,
276 XMMS_DBG (
"Loading plugin '%s'", desc->name);
278 switch (desc->type) {
294 if (desc->api_version != expected_ver) {
305 if (!xmms_plugin_setup (plugin, desc)) {
311 if (!desc->setup_func (plugin)) {
318 if (!verifier (plugin)) {
326 xmms_plugin_list = g_list_prepend (xmms_plugin_list, plugin);
336 xmms_plugin_scan_directory (
const gchar *dir)
348 XMMS_DBG (
"Scanning directory for plugins (%s)", temp);
350 pattern = g_path_get_basename (temp);
354 d = g_dir_open (dir, 0, NULL);
360 while ((name = g_dir_read_name (d))) {
362 if (!g_pattern_match_simple (pattern, name))
365 path = g_build_filename (dir, name, NULL);
366 if (!g_file_test (path, G_FILE_TEST_IS_REGULAR)) {
371 XMMS_DBG (
"Trying to load file: %s", path);
372 module = g_module_open (path, G_MODULE_BIND_LOCAL);
375 path, g_module_error ());
380 if (!g_module_symbol (module,
"XMMS_PLUGIN_DESC", &sym)) {
382 g_module_close (module);
389 g_module_close (module);
410 for (node = xmms_plugin_list; node; node = g_list_next (node)) {
414 if (!func (plugin, user_data))
423 } xmms_plugin_find_foreach_data_t;
426 xmms_plugin_find_foreach (
xmms_plugin_t *plugin, gpointer udata)
428 xmms_plugin_find_foreach_data_t *data = udata;
430 if (!g_ascii_strcasecmp (plugin->
shortname, data->name)) {
432 data->plugin = plugin;
447 xmms_plugin_find_foreach_data_t data = {name, NULL};
456 plugin->
type = desc->type;
458 plugin->
name = desc->name;
459 plugin->
version = desc->version;
469 g_module_close (plugin->
module);
#define xmms_object_unref(obj)
xmms_plugin_type_t xmms_plugin_type_get(const xmms_plugin_t *plugin)
xmms_config_property_t * xmms_plugin_config_property_register(xmms_plugin_t *plugin, const gchar *name, const gchar *default_value, xmms_object_handler_t cb, gpointer userdata)
#define get_module_ext(dir)
xmms_config_property_t * xmms_config_lookup(const gchar *path)
Look up a config key from the global config.
gboolean xmms_plugin_init(const gchar *path)
const gchar * xmms_plugin_shortname_get(const xmms_plugin_t *plugin)
G_BEGIN_DECLS struct xmms_plugin_desc_St xmms_plugin_desc_t
gboolean xmms_output_plugin_verify(xmms_plugin_t *_plugin)
const gchar * description
#define xmms_log_error(fmt,...)
#define XMMS_PLUGIN_SHORTNAME_MAX_LEN
const gchar * xmms_plugin_version_get(const xmms_plugin_t *plugin)
const char * xmms_plugin_description_get(const xmms_plugin_t *plugin)
void xmms_plugin_foreach(xmms_plugin_type_t type, xmms_plugin_foreach_func_t func, gpointer user_data)
void xmms_plugin_destroy(xmms_plugin_t *plugin)
#define xmms_object_ref(obj)
#define XMMS_DBG(fmt,...)
xmms_config_property_t * xmms_config_property_register(const gchar *path, const gchar *default_value, xmms_object_handler_t cb, gpointer userdata)
Register a new config property.
xmms_config_property_t * xmms_plugin_config_lookup(xmms_plugin_t *plugin, const gchar *key)
struct xmms_config_property_St xmms_config_property_t
#define XMMS_OUTPUT_API_VERSION
The current API version.
xmms_plugin_t * xmms_plugin_find(xmms_plugin_type_t type, const gchar *name)
const char * xmms_plugin_name_get(const xmms_plugin_t *plugin)
void xmms_plugin_shutdown()
xmms_plugin_t * xmms_output_plugin_new(void)
gboolean(* xmms_plugin_foreach_func_t)(xmms_plugin_t *, gpointer)
void(* xmms_object_handler_t)(xmms_object_t *object, xmmsv_t *data, gpointer userdata)