From a50143fdf896eab674d52604c2200b963962bc49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Helleu?= Date: Wed, 27 Jul 2022 22:07:24 +0200 Subject: irc: display an error message when using command /dcc without xfer plugin loaded --- src/plugins/irc/irc-command.c | 38 ++++++++++++++++++++++++++++++-------- src/plugins/xfer/xfer.c | 2 +- 2 files changed, 31 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/plugins/irc/irc-command.c b/src/plugins/irc/irc-command.c index 368c32f48..8b2692bcb 100644 --- a/src/plugins/irc/irc-command.c +++ b/src/plugins/irc/irc-command.c @@ -2072,13 +2072,13 @@ IRC_COMMAND_CALLBACK(dcc) weechat_infolist_new_var_string (item, "filename", argv_eol[3]); weechat_infolist_new_var_string (item, "local_address", str_address); weechat_infolist_new_var_integer (item, "socket", ptr_server->sock); - (void) weechat_hook_signal_send ("xfer_add", - WEECHAT_HOOK_SIGNAL_POINTER, - infolist); + rc = weechat_hook_signal_send ("xfer_add", + WEECHAT_HOOK_SIGNAL_POINTER, + infolist); } weechat_infolist_free (infolist); } - return WEECHAT_RC_OK; + goto end; } /* DCC CHAT */ @@ -2100,16 +2100,38 @@ IRC_COMMAND_CALLBACK(dcc) "irc.%s.%s", ptr_server->name, argv[2]); weechat_infolist_new_var_string (item, "charset_modifier", charset_modifier); weechat_infolist_new_var_string (item, "local_address", str_address); - (void) weechat_hook_signal_send ("xfer_add", - WEECHAT_HOOK_SIGNAL_POINTER, - infolist); + rc = weechat_hook_signal_send ("xfer_add", + WEECHAT_HOOK_SIGNAL_POINTER, + infolist); } weechat_infolist_free (infolist); } - return WEECHAT_RC_OK; + goto end; } WEECHAT_COMMAND_ERROR; + +end: + switch (rc) + { + case WEECHAT_RC_OK_EAT: + /* signal has been properly handled by the xfer plugin */ + break; + case WEECHAT_RC_ERROR: + weechat_printf ( + ptr_server->buffer, + _("%s%s: unable to create DCC"), + weechat_prefix ("error"), IRC_PLUGIN_NAME); + break; + default: + weechat_printf ( + ptr_server->buffer, + _("%s%s: unable to create DCC, please check that " + "the \"xfer\" plugin is loaded"), + weechat_prefix ("error"), IRC_PLUGIN_NAME); + break; + } + return WEECHAT_RC_OK; } /* diff --git a/src/plugins/xfer/xfer.c b/src/plugins/xfer/xfer.c index 4c114b81c..b1c5690d8 100644 --- a/src/plugins/xfer/xfer.c +++ b/src/plugins/xfer/xfer.c @@ -1443,7 +1443,7 @@ xfer_add_cb (const void *pointer, void *data, if (short_filename) free (short_filename); weechat_infolist_reset_item_cursor (infolist); - return WEECHAT_RC_OK; + return WEECHAT_RC_OK_EAT; error: if (filename2) -- cgit v1.2.3