From 6c4ec7705ef218c940160b470d3eb70f504fbee8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jonathan=20Neusch=C3=A4fer?= Date: Wed, 27 Jul 2011 17:26:40 +0200 Subject: [PATCH] plugin: pass the plugin name to the callback --- src/plugin.c | 4 ++-- src/plugin.h | 4 +++- src/screen_lyrics.c | 1 + 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/plugin.c b/src/plugin.c index b575e8c..f578575 100644 --- a/src/plugin.c +++ b/src/plugin.c @@ -168,7 +168,7 @@ plugin_eof(struct plugin_cycle *cycle, struct plugin_pipe *p) } else { /* success: invoke the callback */ cycle->callback(cycle->pipe_stdout.data, true, - cycle->callback_data); + cycle->argv[0], cycle->callback_data); } } @@ -217,7 +217,7 @@ plugin_delayed_fail(gpointer data) assert(cycle->pipe_stderr.fd < 0); assert(cycle->pid < 0); - cycle->callback(cycle->all_errors, false, cycle->callback_data); + cycle->callback(cycle->all_errors, false, NULL, cycle->callback_data); return FALSE; } diff --git a/src/plugin.h b/src/plugin.h index ebe9b41..d82fc73 100644 --- a/src/plugin.h +++ b/src/plugin.h @@ -38,10 +38,12 @@ struct plugin_list { * messages on failure as determined by success * @param success result of the plugin cycle; true if result is meaningful * output, false if result contains error messages + * @param plugin_name the name of the plugin which succeeded; may become invalid + * once the callback returns (i.e. strdup it if you need it afterwards). * @param data the caller defined pointer passed to plugin_run() */ typedef void (*plugin_callback_t)(const GString *result, const bool success, - void *data); + const char *plugin_name, void *data); /** * This object represents a cycle through all available plugins, until diff --git a/src/screen_lyrics.c b/src/screen_lyrics.c index 7f5d47c..3dcddbf 100644 --- a/src/screen_lyrics.c +++ b/src/screen_lyrics.c @@ -165,6 +165,7 @@ screen_lyrics_set(const GString *str) static void screen_lyrics_callback(const GString *result, const bool success, + G_GNUC_UNUSED const char *plugin_name, G_GNUC_UNUSED void *data) { assert(current.loader != NULL); -- 2.30.2