From 26b659ae9e2434e2e3d3d76a8c012591cf041b21 Mon Sep 17 00:00:00 2001 From: Sebastien Helleu Date: Tue, 4 Dec 2007 18:01:28 +0100 Subject: Added "config_reload" event, fixed some bugs in hook execution --- src/plugins/alias/alias.c | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/alias/alias.c b/src/plugins/alias/alias.c index 372006688..22d7c8277 100644 --- a/src/plugins/alias/alias.c +++ b/src/plugins/alias/alias.c @@ -37,6 +37,7 @@ static struct t_alias *alias_list = NULL; static struct t_alias *last_alias = NULL; static struct t_hook *alias_command = NULL; static struct t_hook *unalias_command = NULL; +static struct t_hook *config_reload = NULL; /* @@ -527,14 +528,30 @@ alias_config_read () } /* - * alias_config_reaload: reload alias configuration file + * alias_config_reaload_event_cb: reload alias configuration file */ static int -alias_config_reload () +alias_config_reload_event_cb (void *data, char *event, void *pointer) { + /* make C compiler happy */ + (void) data; + (void) event; + (void) pointer; + alias_free_all (); - return weechat_config_reload (alias_config_file); + if (weechat_config_reload (alias_config_file) == 0) + { + weechat_printf (NULL, + _("%sAlias configuration file reloaded"), + weechat_prefix ("info")); + return PLUGIN_RC_SUCCESS; + } + weechat_printf (NULL, + _("%sAlias: failed to reload alias configuration " + "file"), + weechat_prefix ("error")); + return PLUGIN_RC_FAILED; } /* @@ -711,6 +728,9 @@ weechat_plugin_init (struct t_weechat_plugin *plugin) "remove"), "%h", unalias_command_cb, NULL); + + config_reload = weechat_hook_event ("config_reload", + alias_config_reload_event_cb, NULL); return PLUGIN_RC_SUCCESS; } @@ -727,5 +747,7 @@ weechat_plugin_end () weechat_config_free (alias_config_file); weechat_unhook (alias_command); weechat_unhook (unalias_command); + weechat_unhook (config_reload); + return PLUGIN_RC_SUCCESS; } -- cgit v1.2.3