diff options
Diffstat (limited to 'src/plugins/irc')
50 files changed, 2498 insertions, 1869 deletions
diff --git a/src/plugins/irc/CMakeLists.txt b/src/plugins/irc/CMakeLists.txt index 399dc89c4..b773dcf3e 100644 --- a/src/plugins/irc/CMakeLists.txt +++ b/src/plugins/irc/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org> +# Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org> # # This file is part of WeeChat, the extensible chat client. # diff --git a/src/plugins/irc/Makefile.am b/src/plugins/irc/Makefile.am index 85af3f343..a086e3edf 100644 --- a/src/plugins/irc/Makefile.am +++ b/src/plugins/irc/Makefile.am @@ -1,5 +1,5 @@ # -# Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org> +# Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org> # # This file is part of WeeChat, the extensible chat client. # diff --git a/src/plugins/irc/irc-bar-item.c b/src/plugins/irc/irc-bar-item.c index 740a6f6a9..fb599fb02 100644 --- a/src/plugins/irc/irc-bar-item.c +++ b/src/plugins/irc/irc-bar-item.c @@ -1,7 +1,7 @@ /* * irc-bar-item.c - bar items for IRC plugin * - * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org> + * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org> * * This file is part of WeeChat, the extensible chat client. * @@ -34,65 +34,12 @@ /* - * Returns content of bar item "away": bar item with away indicator. - */ - -char * -irc_bar_item_away (void *data, struct t_gui_bar_item *item, - struct t_gui_window *window, struct t_gui_buffer *buffer, - struct t_hashtable *extra_info) -{ - struct t_irc_server *server; - char *buf, *message; - int length; - - /* make C compiler happy */ - (void) data; - (void) item; - (void) window; - (void) extra_info; - - if (!buffer) - return NULL; - - buf = NULL; - - irc_buffer_get_server_and_channel (buffer, &server, NULL); - - if (server && server->is_away) - { - if (weechat_config_boolean (irc_config_look_item_away_message) - && server->away_message && server->away_message[0]) - { - message = strdup (server->away_message); - } - else - { - message = strdup (_("away")); - } - if (message) - { - length = strlen (message) + 64 + 1; - buf = malloc (length); - if (buf) - { - snprintf (buf, length, "%s%s", - IRC_COLOR_ITEM_AWAY, - message); - } - free (message); - } - } - - return buf; -} - -/* * Returns content of bar item "buffer_plugin": bar item with buffer plugin. */ char * -irc_bar_item_buffer_plugin (void *data, struct t_gui_bar_item *item, +irc_bar_item_buffer_plugin (const void *pointer, void *data, + struct t_gui_bar_item *item, struct t_gui_window *window, struct t_gui_buffer *buffer, struct t_hashtable *extra_info) @@ -104,6 +51,7 @@ irc_bar_item_buffer_plugin (void *data, struct t_gui_bar_item *item, struct t_irc_channel *channel; /* make C compiler happy */ + (void) pointer; (void) data; (void) item; (void) window; @@ -252,12 +200,14 @@ irc_bar_item_buffer_name_content (struct t_gui_buffer *buffer, int short_name) */ char * -irc_bar_item_buffer_name (void *data, struct t_gui_bar_item *item, +irc_bar_item_buffer_name (const void *pointer, void *data, + struct t_gui_bar_item *item, struct t_gui_window *window, struct t_gui_buffer *buffer, struct t_hashtable *extra_info) { /* make C compiler happy */ + (void) pointer; (void) data; (void) item; (void) window; @@ -272,12 +222,14 @@ irc_bar_item_buffer_name (void *data, struct t_gui_bar_item *item, */ char * -irc_bar_item_buffer_short_name (void *data, struct t_gui_bar_item *item, +irc_bar_item_buffer_short_name (const void *pointer, void *data, + struct t_gui_bar_item *item, struct t_gui_window *window, struct t_gui_buffer *buffer, struct t_hashtable *extra_info) { /* make C compiler happy */ + (void) pointer; (void) data; (void) item; (void) window; @@ -291,7 +243,8 @@ irc_bar_item_buffer_short_name (void *data, struct t_gui_bar_item *item, */ char * -irc_bar_item_buffer_modes (void *data, struct t_gui_bar_item *item, +irc_bar_item_buffer_modes (const void *pointer, void *data, + struct t_gui_bar_item *item, struct t_gui_window *window, struct t_gui_buffer *buffer, struct t_hashtable *extra_info) @@ -303,6 +256,7 @@ irc_bar_item_buffer_modes (void *data, struct t_gui_bar_item *item, struct t_irc_channel *channel; /* make C compiler happy */ + (void) pointer; (void) data; (void) item; (void) window; @@ -351,7 +305,8 @@ irc_bar_item_buffer_modes (void *data, struct t_gui_bar_item *item, */ char * -irc_bar_item_channel (void *data, struct t_gui_bar_item *item, +irc_bar_item_channel (const void *pointer, void *data, + struct t_gui_bar_item *item, struct t_gui_window *window, struct t_gui_buffer *buffer, struct t_hashtable *extra_info) { @@ -362,6 +317,7 @@ irc_bar_item_channel (void *data, struct t_gui_bar_item *item, struct t_irc_channel *channel; /* make C compiler happy */ + (void) pointer; (void) data; (void) item; (void) window; @@ -428,7 +384,8 @@ irc_bar_item_channel (void *data, struct t_gui_bar_item *item, */ char * -irc_bar_item_lag (void *data, struct t_gui_bar_item *item, +irc_bar_item_lag (const void *pointer, void *data, + struct t_gui_bar_item *item, struct t_gui_window *window, struct t_gui_buffer *buffer, struct t_hashtable *extra_info) { @@ -436,6 +393,7 @@ irc_bar_item_lag (void *data, struct t_gui_bar_item *item, struct t_irc_server *server; /* make C compiler happy */ + (void) pointer; (void) data; (void) item; (void) window; @@ -467,7 +425,8 @@ irc_bar_item_lag (void *data, struct t_gui_bar_item *item, */ char * -irc_bar_item_input_prompt (void *data, struct t_gui_bar_item *item, +irc_bar_item_input_prompt (const void *pointer, void *data, + struct t_gui_bar_item *item, struct t_gui_window *window, struct t_gui_buffer *buffer, struct t_hashtable *extra_info) @@ -479,6 +438,7 @@ irc_bar_item_input_prompt (void *data, struct t_gui_bar_item *item, int length; /* make C compiler happy */ + (void) pointer; (void) data; (void) item; (void) window; @@ -548,7 +508,8 @@ irc_bar_item_input_prompt (void *data, struct t_gui_bar_item *item, */ char * -irc_bar_item_nick_modes (void *data, struct t_gui_bar_item *item, +irc_bar_item_nick_modes (const void *pointer, void *data, + struct t_gui_bar_item *item, struct t_gui_window *window, struct t_gui_buffer *buffer, struct t_hashtable *extra_info) @@ -558,6 +519,7 @@ irc_bar_item_nick_modes (void *data, struct t_gui_bar_item *item, int length; /* make C compiler happy */ + (void) pointer; (void) data; (void) item; (void) window; @@ -587,7 +549,7 @@ irc_bar_item_nick_modes (void *data, struct t_gui_bar_item *item, */ struct t_hashtable * -irc_bar_item_focus_buffer_nicklist (void *data, +irc_bar_item_focus_buffer_nicklist (const void *pointer, void *data, struct t_hashtable *info) { long unsigned int value; @@ -609,6 +571,7 @@ irc_bar_item_focus_buffer_nicklist (void *data, IRC_BUFFER_GET_SERVER_CHANNEL(buffer); /* make C compiler happy */ + (void) pointer; (void) data; if (ptr_server && ptr_channel) @@ -633,10 +596,12 @@ irc_bar_item_focus_buffer_nicklist (void *data, */ int -irc_bar_item_buffer_switch (void *data, const char *signal, +irc_bar_item_buffer_switch (const void *pointer, void *data, + const char *signal, const char *type_data, void *signal_data) { /* make C compiler happy */ + (void) pointer; (void) data; (void) signal; (void) type_data; @@ -673,17 +638,26 @@ irc_bar_item_update_channel () void irc_bar_item_init () { - weechat_bar_item_new ("away", &irc_bar_item_away, NULL); - weechat_bar_item_new ("buffer_plugin", &irc_bar_item_buffer_plugin, NULL); - weechat_bar_item_new ("buffer_name", &irc_bar_item_buffer_name, NULL); - weechat_bar_item_new ("buffer_short_name", &irc_bar_item_buffer_short_name, NULL); - weechat_bar_item_new ("buffer_modes", &irc_bar_item_buffer_modes, NULL); - weechat_bar_item_new ("irc_channel", &irc_bar_item_channel, NULL); - weechat_bar_item_new ("lag", &irc_bar_item_lag, NULL); - weechat_bar_item_new ("input_prompt", &irc_bar_item_input_prompt, NULL); - weechat_bar_item_new ("irc_nick_modes", &irc_bar_item_nick_modes, NULL); + weechat_bar_item_new ("buffer_plugin", + &irc_bar_item_buffer_plugin, NULL, NULL); + weechat_bar_item_new ("buffer_name", + &irc_bar_item_buffer_name, NULL, NULL); + weechat_bar_item_new ("buffer_short_name", + &irc_bar_item_buffer_short_name, NULL, NULL); + weechat_bar_item_new ("buffer_modes", + &irc_bar_item_buffer_modes, NULL, NULL); + weechat_bar_item_new ("irc_channel", + &irc_bar_item_channel, NULL, NULL); + weechat_bar_item_new ("lag", + &irc_bar_item_lag, NULL, NULL); + weechat_bar_item_new ("input_prompt", + &irc_bar_item_input_prompt, NULL, NULL); + weechat_bar_item_new ("irc_nick_modes", + &irc_bar_item_nick_modes, NULL, NULL); + weechat_hook_focus ("buffer_nicklist", - &irc_bar_item_focus_buffer_nicklist, NULL); + &irc_bar_item_focus_buffer_nicklist, NULL, NULL); + weechat_hook_signal ("buffer_switch", - &irc_bar_item_buffer_switch, NULL); + &irc_bar_item_buffer_switch, NULL, NULL); } diff --git a/src/plugins/irc/irc-bar-item.h b/src/plugins/irc/irc-bar-item.h index 688e9f665..948abd75d 100644 --- a/src/plugins/irc/irc-bar-item.h +++ b/src/plugins/irc/irc-bar-item.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org> + * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org> * * This file is part of WeeChat, the extensible chat client. * diff --git a/src/plugins/irc/irc-buffer.c b/src/plugins/irc/irc-buffer.c index a1be1c361..bee87ed56 100644 --- a/src/plugins/irc/irc-buffer.c +++ b/src/plugins/irc/irc-buffer.c @@ -1,7 +1,7 @@ /* * irc-buffer.c - buffer functions for IRC plugin * - * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org> + * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org> * * This file is part of WeeChat, the extensible chat client. * @@ -112,13 +112,15 @@ irc_buffer_build_name (const char *server, const char *channel) */ int -irc_buffer_close_cb (void *data, struct t_gui_buffer *buffer) +irc_buffer_close_cb (const void *pointer, void *data, + struct t_gui_buffer *buffer) { struct t_irc_channel *next_channel; IRC_BUFFER_GET_SERVER_CHANNEL(buffer); /* make C compiler happy */ + (void) pointer; (void) data; if (buffer == irc_raw_buffer) @@ -175,15 +177,18 @@ irc_buffer_close_cb (void *data, struct t_gui_buffer *buffer) */ int -irc_buffer_nickcmp_cb (void *data, +irc_buffer_nickcmp_cb (const void *pointer, void *data, struct t_gui_buffer *buffer, const char *nick1, const char *nick2) { struct t_irc_server *server; - if (data) - server = (struct t_irc_server *)data; + /* make C compiler happy */ + (void) data; + + if (pointer) + server = (struct t_irc_server *)pointer; else irc_buffer_get_server_and_channel (buffer, &server, NULL); diff --git a/src/plugins/irc/irc-buffer.h b/src/plugins/irc/irc-buffer.h index e02ffea1e..c58dfe73e 100644 --- a/src/plugins/irc/irc-buffer.h +++ b/src/plugins/irc/irc-buffer.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org> + * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org> * * This file is part of WeeChat, the extensible chat client. * @@ -53,11 +53,11 @@ extern void irc_buffer_get_server_and_channel (struct t_gui_buffer *buffer, struct t_irc_channel **channel); extern const char *irc_buffer_build_name (const char *server, const char *channel); -extern int irc_buffer_close_cb (void *data, struct t_gui_buffer *buffer); -extern int irc_buffer_nickcmp_cb (void *data, +extern int irc_buffer_close_cb (const void *pointer, void *data, + struct t_gui_buffer *buffer); +extern int irc_buffer_nickcmp_cb (const void *pointer, void *data, struct t_gui_buffer *buffer, - const char *nick1, - const char *nick2); + const char *nick1, const char *nick2); extern struct t_gui_buffer *irc_buffer_search_server_lowest_number (); extern struct t_gui_buffer *irc_buffer_search_private_lowest_number (struct t_irc_server *server); diff --git a/src/plugins/irc/irc-channel.c b/src/plugins/irc/irc-channel.c index 11d0c4df1..019c94a0a 100644 --- a/src/plugins/irc/irc-channel.c +++ b/src/plugins/irc/irc-channel.c @@ -1,7 +1,7 @@ /* * irc-channel.c - channel and private chat management for IRC plugin * - * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org> + * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org> * * This file is part of WeeChat, the extensible chat client. * @@ -270,8 +270,8 @@ irc_channel_create_buffer (struct t_irc_server *server, weechat_current_buffer (), "number"); ptr_buffer = weechat_buffer_new (buffer_name, - &irc_input_data_cb, NULL, - &irc_buffer_close_cb, NULL); + &irc_input_data_cb, NULL, NULL, + &irc_buffer_close_cb, NULL, NULL); if (!ptr_buffer) return NULL; @@ -351,7 +351,7 @@ irc_channel_create_buffer (struct t_irc_server *server, weechat_buffer_set (ptr_buffer, "nicklist_display_groups", "0"); weechat_buffer_set_pointer (ptr_buffer, "nickcmp_callback", &irc_buffer_nickcmp_cb); - weechat_buffer_set_pointer (ptr_buffer, "nickcmp_callback_data", + weechat_buffer_set_pointer (ptr_buffer, "nickcmp_callback_pointer", server); } @@ -463,8 +463,7 @@ irc_channel_new (struct t_irc_server *server, int channel_type, 32, WEECHAT_HASHTABLE_STRING, WEECHAT_HASHTABLE_STRING, - NULL, - NULL); + NULL, NULL); new_channel->checking_whox = 0; new_channel->away_message = NULL; new_channel->has_quit_server = 0; @@ -655,7 +654,7 @@ irc_channel_remove_account (struct t_irc_server *server, { if (ptr_nick->account) free (ptr_nick->account); - ptr_nick->account = strdup ("*"); + ptr_nick->account = NULL; } } } @@ -1024,8 +1023,7 @@ irc_channel_join_smart_filtered_add (struct t_irc_channel *channel, 64, WEECHAT_HASHTABLE_STRING, WEECHAT_HASHTABLE_TIME, - NULL, - NULL); + NULL, NULL); } if (!channel->join_smart_filtered) return; @@ -1224,8 +1222,7 @@ irc_channel_join_smart_filtered_unmask (struct t_irc_channel *channel, hashtable = weechat_hashtable_new (4, WEECHAT_HASHTABLE_STRING, WEECHAT_HASHTABLE_STRING, - NULL, - NULL); + NULL, NULL); if (hashtable) { /* update tags in line (remove tag "irc_smart_filter") */ @@ -1280,15 +1277,17 @@ irc_channel_rejoin (struct t_irc_server *server, struct t_irc_channel *channel) */ int -irc_channel_autorejoin_cb (void *data, int remaining_calls) +irc_channel_autorejoin_cb (const void *pointer, void *data, + int remaining_calls) { struct t_irc_server *ptr_server, *ptr_server_found; struct t_irc_channel *ptr_channel_arg, *ptr_channel; /* make C compiler happy */ + (void) data; (void) remaining_calls; - ptr_channel_arg = (struct t_irc_channel *)data; + ptr_channel_arg = (struct t_irc_channel *)pointer; ptr_server_found = NULL; for (ptr_server = irc_servers; ptr_server; @@ -1338,8 +1337,9 @@ irc_channel_display_nick_back_in_pv (struct t_irc_server *server, { if (weechat_config_boolean (irc_config_look_display_pv_back)) { - weechat_printf_tags ( + weechat_printf_date_tags ( ptr_channel->buffer, + 0, "irc_nick_back", _("%s%s%s %s(%s%s%s)%s is back on server"), weechat_prefix ("join"), @@ -1435,11 +1435,13 @@ irc_channel_free_all (struct t_irc_server *server) */ struct t_hdata * -irc_channel_hdata_channel_cb (void *data, const char *hdata_name) +irc_channel_hdata_channel_cb (const void *pointer, void *data, + const char *hdata_name) { struct t_hdata *hdata; /* make C compiler happy */ + (void) pointer; (void) data; hdata = weechat_hdata_new (hdata_name, "prev_channel", "next_channel", @@ -1481,11 +1483,13 @@ irc_channel_hdata_channel_cb (void *data, const char *hdata_name) */ struct t_hdata * -irc_channel_hdata_channel_speaking_cb (void *data, const char *hdata_name) +irc_channel_hdata_channel_speaking_cb (const void *pointer, void *data, + const char *hdata_name) { struct t_hdata *hdata; /* make C compiler happy */ + (void) pointer; (void) data; hdata = weechat_hdata_new (hdata_name, "prev_nick", "next_nick", diff --git a/src/plugins/irc/irc-channel.h b/src/plugins/irc/irc-channel.h index 08f7f1e9b..5c8dd6a9e 100644 --- a/src/plugins/irc/irc-channel.h +++ b/src/plugins/irc/irc-channel.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org> + * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org> * * This file is part of WeeChat, the extensible chat client. * @@ -78,6 +78,11 @@ struct t_irc_channel extern int irc_channel_valid (struct t_irc_server *server, struct t_irc_channel *channel); +extern struct t_irc_channel *irc_channel_search (struct t_irc_server *server, + const char *channel_name); +extern struct t_gui_buffer *irc_channel_search_buffer (struct t_irc_server *server, + int channel_type, + const char *channel_name); extern struct t_gui_buffer *irc_channel_create_buffer (struct t_irc_server *server, int channel_type, const char *channel_name, @@ -98,8 +103,6 @@ extern void irc_channel_set_modes (struct t_irc_channel *channel, extern void irc_channel_free (struct t_irc_server *server, struct t_irc_channel *channel); extern void irc_channel_free_all (struct t_irc_server *server); -extern struct t_irc_channel *irc_channel_search (struct t_irc_server *server, - const char *channel_name); extern int irc_channel_is_channel (struct t_irc_server *server, const char *string); extern const char *irc_channel_get_auto_chantype (struct t_irc_server *server, @@ -148,13 +151,16 @@ extern void irc_channel_join_smart_filtered_unmask (struct t_irc_channel *channe const char *nick); extern void irc_channel_rejoin (struct t_irc_server *server, struct t_irc_channel *channel); -extern int irc_channel_autorejoin_cb (void *data, int remaining_calls); +extern int irc_channel_autorejoin_cb (const void *pointer, void *data, + int remaining_calls); extern void irc_channel_display_nick_back_in_pv (struct t_irc_server *server, struct t_irc_nick *nick, const char *nickname); -extern struct t_hdata *irc_channel_hdata_channel_cb (void *data, +extern struct t_hdata *irc_channel_hdata_channel_cb (const void *pointer, + void *data, const char *hdata_name); -extern struct t_hdata *irc_channel_hdata_channel_speaking_cb (void *data, +extern struct t_hdata *irc_channel_hdata_channel_speaking_cb (const void *pointer, + void *data, const char *hdata_name); extern int irc_channel_add_to_infolist (struct t_infolist *infolist, struct t_irc_channel *channel); diff --git a/src/plugins/irc/irc-color.c b/src/plugins/irc/irc-color.c index f5f4d2688..5f9c1e52e 100644 --- a/src/plugins/irc/irc-color.c +++ b/src/plugins/irc/irc-color.c @@ -1,7 +1,7 @@ /* * irc-color.c - IRC color decoding/encoding in messages * - * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org> + * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org> * * This file is part of WeeChat, the extensible chat client. * @@ -767,12 +767,14 @@ irc_color_decode_ansi (const char *string, int keep_colors) */ char * -irc_color_modifier_cb (void *data, const char *modifier, - const char *modifier_data, const char *string) +irc_color_modifier_cb (const void *pointer, void *data, + const char *modifier, const char *modifier_data, + const char *string) { int keep_colors; /* make C compiler happy */ + (void) pointer; (void) data; keep_colors = (modifier_data && (strcmp (modifier_data, "1") == 0)) ? 1 : 0; diff --git a/src/plugins/irc/irc-color.h b/src/plugins/irc/irc-color.h index cc8f58bf6..4bc9ffb8f 100644 --- a/src/plugins/irc/irc-color.h +++ b/src/plugins/irc/irc-color.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org> + * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org> * * This file is part of WeeChat, the extensible chat client. * @@ -106,7 +106,8 @@ struct t_irc_color_ansi_state extern char *irc_color_decode (const char *string, int keep_colors); extern char *irc_color_encode (const char *string, int keep_colors); -extern char *irc_color_modifier_cb (void *data, const char *modifier, +extern char *irc_color_modifier_cb (const void *pointer, void *data, + const char *modifier, const char *modifier_data, const char *string); extern char *irc_color_for_tags (const char *color); diff --git a/src/plugins/irc/irc-command.c b/src/plugins/irc/irc-command.c index 3edb5433a..41ce07719 100644 --- a/src/plugins/irc/irc-command.c +++ b/src/plugins/irc/irc-command.c @@ -1,7 +1,7 @@ /* * irc-command.c - IRC commands * - * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org> + * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org> * Copyright (C) 2006 Emmanuel Bouthenot <kolter@openics.org> * * This file is part of WeeChat, the extensible chat client. @@ -142,8 +142,7 @@ irc_command_mode_nicks (struct t_irc_server *server, nicks_sent = weechat_hashtable_new (128, WEECHAT_HASHTABLE_STRING, WEECHAT_HASHTABLE_STRING, - NULL, - NULL); + NULL, NULL); if (!nicks_sent) return; @@ -241,14 +240,13 @@ irc_command_mode_nicks (struct t_irc_server *server, * the server. */ -int -irc_command_admin (void *data, struct t_gui_buffer *buffer, int argc, - char **argv, char **argv_eol) +IRC_COMMAND_CALLBACK(admin) { IRC_BUFFER_GET_SERVER(buffer); IRC_COMMAND_CHECK_SERVER("admin", 1); /* make C compiler happy */ + (void) pointer; (void) data; (void) argv; @@ -390,9 +388,7 @@ irc_command_exec_all_channels (struct t_irc_server *server, * connected servers. */ -int -irc_command_allchan (void *data, struct t_gui_buffer *buffer, int argc, - char **argv, char **argv_eol) +IRC_COMMAND_CALLBACK(allchan) { int i, current_server; const char *ptr_exclude_channels, *ptr_command; @@ -400,6 +396,7 @@ irc_command_allchan (void *data, struct t_gui_buffer *buffer, int argc, IRC_BUFFER_GET_SERVER(buffer); /* make C compiler happy */ + (void) pointer; (void) data; WEECHAT_COMMAND_MIN_ARGS(2, ""); @@ -441,9 +438,7 @@ irc_command_allchan (void *data, struct t_gui_buffer *buffer, int argc, * connected servers. */ -int -irc_command_allpv (void *data, struct t_gui_buffer *buffer, int argc, - char **argv, char **argv_eol) +IRC_COMMAND_CALLBACK(allpv) { int i, current_server; const char *ptr_exclude_channels, *ptr_command; @@ -451,6 +446,7 @@ irc_command_allpv (void *data, struct t_gui_buffer *buffer, int argc, IRC_BUFFER_GET_SERVER(buffer); /* make C compiler happy */ + (void) pointer; (void) data; WEECHAT_COMMAND_MIN_ARGS(2, ""); @@ -593,14 +589,13 @@ irc_command_exec_all_servers (const char *exclude_servers, const char *command) * Callback for command "/allserv": executes a command on all connected servers. */ -int -irc_command_allserv (void *data, struct t_gui_buffer *buffer, int argc, - char **argv, char **argv_eol) +IRC_COMMAND_CALLBACK(allserv) { int i; const char *ptr_exclude_servers, *ptr_command; /* make C compiler happy */ + (void) pointer; (void) data; (void) buffer; @@ -645,8 +640,9 @@ irc_command_me_channel_display (struct t_irc_server *server, irc_color_decode (arguments, weechat_config_boolean (irc_config_network_colors_send)) : NULL; ptr_nick = irc_nick_search (server, channel, server->nick); - weechat_printf_tags ( + weechat_printf_date_tags ( channel->buffer, + 0, irc_protocol_tags ("privmsg", "irc_action,notify_none,no_highlight", server->nick, NULL), "%s%s%s%s%s%s%s", @@ -731,16 +727,17 @@ irc_command_display_away (struct t_irc_server *server, const char *string1, if ((ptr_channel->type == IRC_CHANNEL_TYPE_CHANNEL) || (ptr_channel->type == IRC_CHANNEL_TYPE_PRIVATE)) { - weechat_printf_tags (ptr_channel->buffer, - "away_info", - "%s[%s%s%s %s: %s%s]", - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT_NICK_SELF, - server->nick, - IRC_COLOR_RESET, - string1, - string2, - IRC_COLOR_CHAT_DELIMITERS); + weechat_printf_date_tags (ptr_channel->buffer, + 0, + "away_info", + "%s[%s%s%s %s: %s%s]", + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT_NICK_SELF, + server->nick, + IRC_COLOR_RESET, + string1, + string2, + IRC_COLOR_CHAT_DELIMITERS); } } } @@ -889,13 +886,12 @@ irc_command_away_server (struct t_irc_server *server, const char *arguments, * Callback for command "/away": toggles away status. */ -int -irc_command_away (void *data, struct t_gui_buffer *buffer, int argc, - char **argv, char **argv_eol) +IRC_COMMAND_CALLBACK(away) { IRC_BUFFER_GET_SERVER(buffer); /* make C compiler happy */ + (void) pointer; (void) data; if ((argc >= 2) && (weechat_strcasecmp (argv[1], "-all") == 0)) @@ -928,7 +924,8 @@ irc_command_away (void *data, struct t_gui_buffer *buffer, int argc, */ int -irc_command_run_away (void *data, struct t_gui_buffer *buffer, +irc_command_run_away (const void *pointer, void *data, + struct t_gui_buffer *buffer, const char *command) { int argc; @@ -939,7 +936,7 @@ irc_command_run_away (void *data, struct t_gui_buffer *buffer, if (argv && argv_eol) { - irc_command_away (data, buffer, argc, argv, argv_eol); + irc_command_away (pointer, data, buffer, argc, argv, argv_eol); } if (argv) @@ -993,9 +990,7 @@ irc_command_send_ban (struct t_irc_server *server, * Callback for command "/ban": bans nicks or hosts. */ -int -irc_command_ban (void *data, struct t_gui_buffer *buffer, int argc, - char **argv, char **argv_eol) +IRC_COMMAND_CALLBACK(ban) { char *pos_channel; int pos_args; @@ -1004,6 +999,7 @@ irc_command_ban (void *data, struct t_gui_buffer *buffer, int argc, IRC_COMMAND_CHECK_SERVER("ban", 1); /* make C compiler happy */ + (void) pointer; (void) data; (void) argv_eol; @@ -1072,6 +1068,47 @@ irc_command_ban (void *data, struct t_gui_buffer *buffer, int argc, } /* + * Callback for command "/cap": client capability negotiation. + * + * Docs on capability negotiation: + * https://tools.ietf.org/html/draft-mitchell-irc-capabilities-01 + * http://ircv3.net/specs/core/capability-negotiation-3.1.html + * http://ircv3.net/specs/core/capability-negotiation-3.2.html + */ + +IRC_COMMAND_CALLBACK(cap) +{ + IRC_BUFFER_GET_SERVER(buffer); + IRC_COMMAND_CHECK_SERVER("cap", 1); + + /* make C compiler happy */ + (void) pointer; + (void) data; + + if (argc > 1) + { + irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, + "CAP %s%s%s", + argv[1], + (argv_eol[2]) ? " :" : "", + (argv_eol[2]) ? argv_eol[2] : ""); + } + else + { + /* + * by default, show supported capabilities and capabilities currently + * enabled + */ + irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, + "CAP LS"); + irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, + "CAP LIST"); + } + + return WEECHAT_RC_OK; +} + +/* * Connects to one server. * * Returns: @@ -1123,9 +1160,7 @@ irc_command_connect_one_server (struct t_irc_server *server, * Callback for command "/connect": connects to server(s). */ -int -irc_command_connect (void *data, struct t_gui_buffer *buffer, int argc, - char **argv, char **argv_eol) +IRC_COMMAND_CALLBACK(connect) { int i, nb_connect, connect_ok, all_servers, all_opened, switch_address; int no_join, autoconnect; @@ -1134,6 +1169,7 @@ irc_command_connect (void *data, struct t_gui_buffer *buffer, int argc, IRC_BUFFER_GET_SERVER(buffer); /* make C compiler happy */ + (void) pointer; (void) data; (void) argv_eol; @@ -1320,73 +1356,109 @@ irc_command_connect (void *data, struct t_gui_buffer *buffer, int argc, * Callback for command "/ctcp": sends a CTCP message. */ -int -irc_command_ctcp (void *data, struct t_gui_buffer *buffer, int argc, - char **argv, char **argv_eol) +IRC_COMMAND_CALLBACK(ctcp) { - char *irc_cmd, str_time[512]; + char **targets, *ctcp_type, str_time[512]; + const char *ctcp_target, *ctcp_args; + int num_targets, arg_target, arg_type, arg_args, i; struct timeval tv; - IRC_BUFFER_GET_SERVER(buffer); - IRC_COMMAND_CHECK_SERVER("ctcp", 1); + IRC_BUFFER_GET_SERVER_CHANNEL(buffer); /* make C compiler happy */ + (void) pointer; (void) data; WEECHAT_COMMAND_MIN_ARGS(3, ""); - irc_cmd = strdup (argv[2]); - if (!irc_cmd) + arg_target = 1; + arg_type = 2; + arg_args = 3; + + if ((argc >= 5) && (weechat_strcasecmp (argv[1], "-server") == 0)) + { + ptr_server = irc_server_search (argv[2]); + ptr_channel = NULL; + arg_target = 3; + arg_type = 4; + arg_args = 5; + } + + IRC_COMMAND_CHECK_SERVER("ctcp", 1); + + targets = weechat_string_split (argv[arg_target], ",", 0, 0, &num_targets); + if (!targets) + WEECHAT_COMMAND_ERROR; + + ctcp_type = strdup (argv[arg_type]); + if (!ctcp_type) + { + weechat_string_free_split (targets); WEECHAT_COMMAND_ERROR; + } - weechat_string_toupper (irc_cmd); + weechat_string_toupper (ctcp_type); - if ((weechat_strcasecmp (argv[2], "ping") == 0) && !argv_eol[3]) + if ((strcmp (ctcp_type, "PING") == 0) && !argv_eol[arg_args]) { + /* generate argument for PING if not provided */ gettimeofday (&tv, NULL); snprintf (str_time, sizeof (str_time), "%ld %ld", (long)tv.tv_sec, (long)tv.tv_usec); - irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, - "PRIVMSG %s :\01PING %s\01", - argv[1], str_time); - weechat_printf ( - irc_msgbuffer_get_target_buffer ( - ptr_server, argv[1], NULL, "ctcp", NULL), - _("%sCTCP query to %s%s%s: %s%s%s%s%s"), - weechat_prefix ("network"), - irc_nick_color_for_msg (ptr_server, 0, NULL, argv[1]), - argv[1], - IRC_COLOR_RESET, - IRC_COLOR_CHAT_CHANNEL, - irc_cmd, - IRC_COLOR_RESET, - " ", - str_time); + ctcp_args = str_time; } else { - irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, - "PRIVMSG %s :\01%s%s%s\01", - argv[1], - irc_cmd, - (argv_eol[3]) ? " " : "", - (argv_eol[3]) ? argv_eol[3] : ""); - weechat_printf ( - irc_msgbuffer_get_target_buffer ( - ptr_server, argv[1], NULL, "ctcp", NULL), - _("%sCTCP query to %s%s%s: %s%s%s%s%s"), - weechat_prefix ("network"), - irc_nick_color_for_msg (ptr_server, 0, NULL, argv[1]), - argv[1], - IRC_COLOR_RESET, - IRC_COLOR_CHAT_CHANNEL, - irc_cmd, - IRC_COLOR_RESET, - (argv_eol[3]) ? " " : "", - (argv_eol[3]) ? argv_eol[3] : ""); - } - - free (irc_cmd); + ctcp_args = argv_eol[arg_args]; + } + + for (i = 0; i < num_targets; i++) + { + ctcp_target = targets[i]; + + if (strcmp (targets[i], "*") == 0) + { + if (!ptr_channel + || ((ptr_channel->type != IRC_CHANNEL_TYPE_CHANNEL) + && (ptr_channel->type != IRC_CHANNEL_TYPE_PRIVATE))) + { + weechat_printf ( + ptr_server->buffer, + _("%s%s: \"%s\" command can only be executed in a channel " + "or private buffer"), + weechat_prefix ("error"), IRC_PLUGIN_NAME, "ctcp *"); + ctcp_target = NULL; + } + else + ctcp_target = ptr_channel->name; + } + + if (ctcp_target) + { + irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, + "PRIVMSG %s :\01%s%s%s\01", + ctcp_target, + ctcp_type, + (ctcp_args) ? " " : "", + (ctcp_args) ? ctcp_args : ""); + weechat_printf ( + irc_msgbuffer_get_target_buffer ( + ptr_server, ctcp_target, NULL, "ctcp", NULL), + _("%sCTCP query to %s%s%s: %s%s%s%s%s"), + weechat_prefix ("network"), + irc_nick_color_for_msg (ptr_server, 0, NULL, ctcp_target), + ctcp_target, + IRC_COLOR_RESET, + IRC_COLOR_CHAT_CHANNEL, + ctcp_type, + IRC_COLOR_RESET, + (ctcp_args) ? " " : "", + (ctcp_args) ? ctcp_args : ""); + } + } + + free (ctcp_type); + weechat_string_free_split (targets); return WEECHAT_RC_OK; } @@ -1395,12 +1467,10 @@ irc_command_ctcp (void *data, struct t_gui_buffer *buffer, int argc, * Callback for command "/cycle": leaves and rejoins a channel. */ -int -irc_command_cycle (void *data, struct t_gui_buffer *buffer, int argc, - char **argv, char **argv_eol) +IRC_COMMAND_CALLBACK(cycle) { - char *channel_name, *pos_args, *buf; - const char *version, *ptr_arg, *msg_part; + char *channel_name, *pos_args, *msg; + const char *ptr_arg; char **channels; int i, num_channels; @@ -1408,6 +1478,7 @@ irc_command_cycle (void *data, struct t_gui_buffer *buffer, int argc, IRC_COMMAND_CHECK_SERVER("cycle", 1); /* make C compiler happy */ + (void) pointer; (void) data; (void) argv; @@ -1474,24 +1545,24 @@ irc_command_cycle (void *data, struct t_gui_buffer *buffer, int argc, ptr_channel->cycle = 1; } - msg_part = IRC_SERVER_OPTION_STRING(ptr_server, - IRC_SERVER_OPTION_DEFAULT_MSG_PART); - ptr_arg = (pos_args) ? pos_args : - ((msg_part && msg_part[0]) ? msg_part : NULL); - - if (ptr_arg) + msg = NULL; + ptr_arg = (pos_args) ? + pos_args : IRC_SERVER_OPTION_STRING(ptr_server, + IRC_SERVER_OPTION_MSG_PART); + if (ptr_arg && ptr_arg[0]) { - version = weechat_info_get ("version", ""); - buf = weechat_string_replace (ptr_arg, "%v", (version) ? version : ""); + msg = irc_server_get_default_msg (ptr_arg, ptr_server, channel_name); irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, - "PART %s :%s", channel_name, - (buf) ? buf : ptr_arg); - if (buf) - free (buf); + "PART %s :%s", channel_name, msg); } else + { irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, "PART %s", channel_name); + } + + if (msg) + free (msg); return WEECHAT_RC_OK; } @@ -1500,9 +1571,7 @@ irc_command_cycle (void *data, struct t_gui_buffer *buffer, int argc, * Callback for command "/dcc": DCC control (file or chat). */ -int -irc_command_dcc (void *data, struct t_gui_buffer *buffer, int argc, - char **argv, char **argv_eol) +IRC_COMMAND_CALLBACK(dcc) { struct sockaddr_storage addr; socklen_t length; @@ -1515,6 +1584,7 @@ irc_command_dcc (void *data, struct t_gui_buffer *buffer, int argc, IRC_COMMAND_CHECK_SERVER("dcc", 1); /* make C compiler happy */ + (void) pointer; (void) data; WEECHAT_COMMAND_MIN_ARGS(3, ""); @@ -1599,14 +1669,13 @@ irc_command_dcc (void *data, struct t_gui_buffer *buffer, int argc, * nickname(s). */ -int -irc_command_dehalfop (void *data, struct t_gui_buffer *buffer, int argc, - char **argv, char **argv_eol) +IRC_COMMAND_CALLBACK(dehalfop) { IRC_BUFFER_GET_SERVER_CHANNEL(buffer); IRC_COMMAND_CHECK_SERVER("dehalfop", 1); /* make C compiler happy */ + (void) pointer; (void) data; (void) argv_eol; @@ -1639,14 +1708,13 @@ irc_command_dehalfop (void *data, struct t_gui_buffer *buffer, int argc, * Callback for command "/deop": removes operator privileges from nickname(s). */ -int -irc_command_deop (void *data, struct t_gui_buffer *buffer, int argc, - char **argv, char **argv_eol) +IRC_COMMAND_CALLBACK(deop) { IRC_BUFFER_GET_SERVER_CHANNEL(buffer); IRC_COMMAND_CHECK_SERVER("deop", 1); /* make C compiler happy */ + (void) pointer; (void) data; (void) argv_eol; @@ -1679,14 +1747,13 @@ irc_command_deop (void *data, struct t_gui_buffer *buffer, int argc, * Callback for command "/devoice": removes voice from nickname(s). */ -int -irc_command_devoice (void *data, struct t_gui_buffer *buffer, int argc, - char **argv, char **argv_eol) +IRC_COMMAND_CALLBACK(devoice) { IRC_BUFFER_GET_SERVER_CHANNEL(buffer); IRC_COMMAND_CHECK_SERVER("devoice", 1); /* make C compiler happy */ + (void) pointer; (void) data; (void) argv_eol; @@ -1719,14 +1786,13 @@ irc_command_devoice (void *data, struct t_gui_buffer *buffer, int argc, * Callback for command "/die": shutdowns the server. */ -int -irc_command_die (void *data, struct t_gui_buffer *buffer, int argc, - char **argv, char **argv_eol) +IRC_COMMAND_CALLBACK(die) { IRC_BUFFER_GET_SERVER(buffer); IRC_COMMAND_CHECK_SERVER("die", 1); /* make C compiler happy */ + (void) pointer; (void) data; (void) argv; @@ -1751,29 +1817,28 @@ irc_command_die (void *data, struct t_gui_buffer *buffer, int argc, void irc_command_quit_server (struct t_irc_server *server, const char *arguments) { - const char *ptr_arg, *version, *msg_quit; - char *buf; + const char *ptr_arg; + char *msg; if (!server || !server->is_connected) return; - msg_quit = IRC_SERVER_OPTION_STRING(server, - IRC_SERVER_OPTION_DEFAULT_MSG_QUIT); - ptr_arg = (arguments) ? arguments : - ((msg_quit && msg_quit[0]) ? msg_quit : NULL); - - if (ptr_arg) + msg = NULL; + ptr_arg = (arguments) ? + arguments : IRC_SERVER_OPTION_STRING(server, + IRC_SERVER_OPTION_MSG_QUIT); + if (ptr_arg && ptr_arg[0]) { - version = weechat_info_get ("version", ""); - buf = weechat_string_replace (ptr_arg, "%v", - (version) ? version : ""); - irc_server_sendf (server, 0, NULL, "QUIT :%s", - (buf) ? buf : ptr_arg); - if (buf) - free (buf); + msg = irc_server_get_default_msg (ptr_arg, server, NULL); + irc_server_sendf (server, 0, NULL, "QUIT :%s", msg); } else + { irc_server_sendf (server, 0, NULL, "QUIT"); + } + + if (msg) + free (msg); } /* @@ -1821,9 +1886,7 @@ irc_command_disconnect_one_server (struct t_irc_server *server, * Callback for command "/disconnect": disconnects from server(s). */ -int -irc_command_disconnect (void *data, struct t_gui_buffer *buffer, int argc, - char **argv, char **argv_eol) +IRC_COMMAND_CALLBACK(disconnect) { int disconnect_ok; const char *reason; @@ -1831,6 +1894,7 @@ irc_command_disconnect (void *data, struct t_gui_buffer *buffer, int argc, IRC_BUFFER_GET_SERVER(buffer); /* make C compiler happy */ + (void) pointer; (void) data; reason = (argc > 2) ? argv_eol[2] : NULL; @@ -1897,14 +1961,13 @@ irc_command_disconnect (void *data, struct t_gui_buffer *buffer, int argc, * nickname(s). */ -int -irc_command_halfop (void *data, struct t_gui_buffer *buffer, int argc, - char **argv, char **argv_eol) +IRC_COMMAND_CALLBACK(halfop) { IRC_BUFFER_GET_SERVER_CHANNEL(buffer); IRC_COMMAND_CHECK_SERVER("halfop", 1); /* make C compiler happy */ + (void) pointer; (void) data; (void) argv_eol; @@ -1964,9 +2027,7 @@ irc_command_ignore_display (struct t_irc_ignore *ignore) * Callback for command "/ignore": adds or removes ignore. */ -int -irc_command_ignore (void *data, struct t_gui_buffer *buffer, int argc, - char **argv, char **argv_eol) +IRC_COMMAND_CALLBACK(ignore) { struct t_irc_ignore *ptr_ignore; char *mask, *regex, *regex2, *ptr_regex, *server, *channel, *error; @@ -1974,6 +2035,7 @@ irc_command_ignore (void *data, struct t_gui_buffer *buffer, int argc, long number; /* make C compiler happy */ + (void) pointer; (void) data; (void) buffer; (void) argv_eol; @@ -2126,14 +2188,13 @@ irc_command_ignore (void *data, struct t_gui_buffer *buffer, int argc, * Callback for command "/info": gets information describing the server. */ -int -irc_command_info (void *data, struct t_gui_buffer *buffer, int argc, - char **argv, char **argv_eol) +IRC_COMMAND_CALLBACK(info) { IRC_BUFFER_GET_SERVER(buffer); IRC_COMMAND_CHECK_SERVER("info", 1); /* make C compiler happy */ + (void) pointer; (void) data; (void) argv; @@ -2155,9 +2216,7 @@ irc_command_info (void *data, struct t_gui_buffer *buffer, int argc, * Callback for command "/invite": invites a nick on a channel. */ -int -irc_command_invite (void *data, struct t_gui_buffer *buffer, int argc, - char **argv, char **argv_eol) +IRC_COMMAND_CALLBACK(invite) { int i, arg_last_nick; char *ptr_channel_name; @@ -2166,6 +2225,7 @@ irc_command_invite (void *data, struct t_gui_buffer *buffer, int argc, IRC_COMMAND_CHECK_SERVER("invite", 1); /* make C compiler happy */ + (void) pointer; (void) data; (void) argv_eol; @@ -2220,14 +2280,13 @@ error: * Callback for command "/ison": checks if a nickname is currently on IRC. */ -int -irc_command_ison (void *data, struct t_gui_buffer *buffer, int argc, - char **argv, char **argv_eol) +IRC_COMMAND_CALLBACK(ison) { IRC_BUFFER_GET_SERVER(buffer); IRC_COMMAND_CHECK_SERVER("ison", 1); /* make C compiler happy */ + (void) pointer; (void) data; (void) argv; @@ -2384,9 +2443,7 @@ irc_command_join_server (struct t_irc_server *server, const char *arguments, * Callback for command "/join": joins a new channel. */ -int -irc_command_join (void *data, struct t_gui_buffer *buffer, int argc, - char **argv, char **argv_eol) +IRC_COMMAND_CALLBACK(join) { int i, arg_channels, noswitch; const char *ptr_type, *ptr_server_name, *ptr_channel_name; @@ -2394,6 +2451,7 @@ irc_command_join (void *data, struct t_gui_buffer *buffer, int argc, IRC_BUFFER_GET_SERVER_CHANNEL(buffer); /* make C compiler happy */ + (void) pointer; (void) data; noswitch = 0; @@ -2480,23 +2538,19 @@ irc_command_kick_channel (struct t_irc_server *server, const char *channel_name, const char *nick_name, const char *message) { - const char *msg_kick; - char *msg_vars_replaced; + const char *ptr_msg; + char *msg; - msg_kick = (message && message[0]) ? + msg = NULL; + ptr_msg = (message && message[0]) ? message : IRC_SERVER_OPTION_STRING(server, - IRC_SERVER_OPTION_DEFAULT_MSG_KICK); - if (msg_kick && msg_kick[0]) + IRC_SERVER_OPTION_MSG_KICK); + if (ptr_msg && ptr_msg[0]) { - msg_vars_replaced = irc_message_replace_vars (server, - channel_name, - msg_kick); + msg = irc_server_get_default_msg (ptr_msg, server, channel_name); irc_server_sendf (server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, "KICK %s %s :%s", - channel_name, nick_name, - (msg_vars_replaced) ? msg_vars_replaced : msg_kick); - if (msg_vars_replaced) - free (msg_vars_replaced); + channel_name, nick_name, msg); } else { @@ -2504,15 +2558,16 @@ irc_command_kick_channel (struct t_irc_server *server, "KICK %s %s", channel_name, nick_name); } + + if (msg) + free (msg); } /* * Callback for command "/kick": forcibly removes a user from a channel. */ -int -irc_command_kick (void *data, struct t_gui_buffer *buffer, int argc, - char **argv, char **argv_eol) +IRC_COMMAND_CALLBACK(kick) { char *pos_channel, *pos_nick, *pos_comment; @@ -2520,6 +2575,7 @@ irc_command_kick (void *data, struct t_gui_buffer *buffer, int argc, IRC_COMMAND_CHECK_SERVER("kick", 1); /* make C compiler happy */ + (void) pointer; (void) data; WEECHAT_COMMAND_MIN_ARGS(2, ""); @@ -2558,9 +2614,7 @@ irc_command_kick (void *data, struct t_gui_buffer *buffer, int argc, * bans it. */ -int -irc_command_kickban (void *data, struct t_gui_buffer *buffer, int argc, - char **argv, char **argv_eol) +IRC_COMMAND_CALLBACK(kickban) { char *pos_channel, *pos_nick, *nick_only, *pos_comment, *pos, *mask; int length; @@ -2569,6 +2623,7 @@ irc_command_kickban (void *data, struct t_gui_buffer *buffer, int argc, IRC_COMMAND_CHECK_SERVER("kickban", 1); /* make C compiler happy */ + (void) pointer; (void) data; WEECHAT_COMMAND_MIN_ARGS(2, ""); @@ -2653,14 +2708,13 @@ irc_command_kickban (void *data, struct t_gui_buffer *buffer, int argc, * Callback for command "/kill": closes client-server connection. */ -int -irc_command_kill (void *data, struct t_gui_buffer *buffer, int argc, - char **argv, char **argv_eol) +IRC_COMMAND_CALLBACK(kill) { IRC_BUFFER_GET_SERVER(buffer); IRC_COMMAND_CHECK_SERVER("kill", 1); /* make C compiler happy */ + (void) pointer; (void) data; WEECHAT_COMMAND_MIN_ARGS(2, ""); @@ -2684,14 +2738,13 @@ irc_command_kill (void *data, struct t_gui_buffer *buffer, int argc, * server answering the query. */ -int -irc_command_links (void *data, struct t_gui_buffer *buffer, int argc, - char **argv, char **argv_eol) +IRC_COMMAND_CALLBACK(links) { IRC_BUFFER_GET_SERVER(buffer); IRC_COMMAND_CHECK_SERVER("links", 1); /* make C compiler happy */ + (void) pointer; (void) data; (void) argv; @@ -2713,9 +2766,7 @@ irc_command_links (void *data, struct t_gui_buffer *buffer, int argc, * Callback for command "/list": lists channels and their topic. */ -int -irc_command_list (void *data, struct t_gui_buffer *buffer, int argc, - char **argv, char **argv_eol) +IRC_COMMAND_CALLBACK(list) { char buf[512], *ptr_channel_name, *ptr_server_name, *ptr_regex; int i, ret; @@ -2724,6 +2775,7 @@ irc_command_list (void *data, struct t_gui_buffer *buffer, int argc, IRC_COMMAND_CHECK_SERVER("list", 1); /* make C compiler happy */ + (void) pointer; (void) data; if (ptr_server->cmd_list_regexp) @@ -2817,14 +2869,13 @@ irc_command_list (void *data, struct t_gui_buffer *buffer, int argc, * network. */ -int -irc_command_lusers (void *data, struct t_gui_buffer *buffer, int argc, - char **argv, char **argv_eol) +IRC_COMMAND_CALLBACK(lusers) { IRC_BUFFER_GET_SERVER(buffer); IRC_COMMAND_CHECK_SERVER("lusers", 1); /* make C compiler happy */ + (void) pointer; (void) data; (void) argv; @@ -2846,14 +2897,13 @@ irc_command_lusers (void *data, struct t_gui_buffer *buffer, int argc, * Callback for command "/map": shows a graphical map of the IRC network. */ -int -irc_command_map (void *data, struct t_gui_buffer *buffer, int argc, - char **argv, char **argv_eol) +IRC_COMMAND_CALLBACK(map) { IRC_BUFFER_GET_SERVER(buffer); IRC_COMMAND_CHECK_SERVER("map", 1); /* make C compiler happy */ + (void) pointer; (void) data; (void) argv; @@ -2875,14 +2925,13 @@ irc_command_map (void *data, struct t_gui_buffer *buffer, int argc, * Callback for command "/me": sends a ctcp action to the current channel. */ -int -irc_command_me (void *data, struct t_gui_buffer *buffer, int argc, char **argv, - char **argv_eol) +IRC_COMMAND_CALLBACK(me) { IRC_BUFFER_GET_SERVER_CHANNEL(buffer); IRC_COMMAND_CHECK_SERVER("me", 1); /* make C compiler happy */ + (void) pointer; (void) data; (void) argv; @@ -2934,14 +2983,13 @@ irc_command_mode_server (struct t_irc_server *server, * Callback for command "/mode": changes mode for channel/nickname. */ -int -irc_command_mode (void *data, struct t_gui_buffer *buffer, int argc, - char **argv, char **argv_eol) +IRC_COMMAND_CALLBACK(mode) { IRC_BUFFER_GET_SERVER_CHANNEL(buffer); IRC_COMMAND_CHECK_SERVER("mode", 1); /* make C compiler happy */ + (void) pointer; (void) data; if (argc > 1) @@ -2991,14 +3039,13 @@ irc_command_mode (void *data, struct t_gui_buffer *buffer, int argc, * Callback for command "/motd": gets the "Message Of The Day". */ -int -irc_command_motd (void *data, struct t_gui_buffer *buffer, int argc, - char **argv, char **argv_eol) +IRC_COMMAND_CALLBACK(motd) { IRC_BUFFER_GET_SERVER(buffer); IRC_COMMAND_CHECK_SERVER("motd", 1); /* make C compiler happy */ + (void) pointer; (void) data; (void) argv; @@ -3020,17 +3067,17 @@ irc_command_motd (void *data, struct t_gui_buffer *buffer, int argc, * Callback for command "/msg": sends a message to a nick or channel. */ -int -irc_command_msg (void *data, struct t_gui_buffer *buffer, int argc, - char **argv, char **argv_eol) +IRC_COMMAND_CALLBACK(msg) { char **targets, *msg_pwd_hidden, *string; int num_targets, i, j, arg_target, arg_text, is_channel, status_msg; int hide_password; + struct t_irc_channel *ptr_channel2; IRC_BUFFER_GET_SERVER_CHANNEL(buffer); /* make C compiler happy */ + (void) pointer; (void) data; WEECHAT_COMMAND_MIN_ARGS(3, ""); @@ -3066,42 +3113,46 @@ irc_command_msg (void *data, struct t_gui_buffer *buffer, int argc, _("%s%s: \"%s\" command can only be executed in a channel " "or private buffer"), weechat_prefix ("error"), IRC_PLUGIN_NAME, "msg *"); - return WEECHAT_RC_OK; } - string = irc_color_decode (argv_eol[arg_text], - weechat_config_boolean (irc_config_network_colors_send)); - irc_input_user_message_display (ptr_channel->buffer, 0, - (string) ? string : argv_eol[arg_text]); - if (string) - free (string); + else + { + string = irc_color_decode ( + argv_eol[arg_text], + weechat_config_boolean (irc_config_network_colors_send)); + irc_input_user_message_display ( + ptr_channel->buffer, 0, + (string) ? string : argv_eol[arg_text]); + if (string) + free (string); - irc_server_sendf (ptr_server, - IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, - "PRIVMSG %s :%s", - ptr_channel->name, argv_eol[arg_text]); + irc_server_sendf (ptr_server, + IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, + "PRIVMSG %s :%s", + ptr_channel->name, argv_eol[arg_text]); + } } else { is_channel = 0; - ptr_channel = NULL; + ptr_channel2 = NULL; status_msg = 0; if (irc_server_prefix_char_statusmsg (ptr_server, targets[i][0]) && irc_channel_is_channel (ptr_server, targets[i] + 1)) { - ptr_channel = irc_channel_search (ptr_server, targets[i] + 1); + ptr_channel2 = irc_channel_search (ptr_server, targets[i] + 1); is_channel = 1; status_msg = 1; } else { - ptr_channel = irc_channel_search (ptr_server, targets[i]); - if (ptr_channel) + ptr_channel2 = irc_channel_search (ptr_server, targets[i]); + if (ptr_channel2) is_channel = 1; } if (is_channel) { - if (ptr_channel) + if (ptr_channel2) { string = irc_color_decode ( argv_eol[arg_text], @@ -3112,8 +3163,9 @@ irc_command_msg (void *data, struct t_gui_buffer *buffer, int argc, * message to channel ops/voiced * (to "@#channel" or "+#channel") */ - weechat_printf_tags ( - ptr_channel->buffer, + weechat_printf_date_tags ( + ptr_channel2->buffer, + 0, "notify_none,no_highlight", "%s%s%s -> %s%s%s: %s", weechat_prefix ("network"), @@ -3128,7 +3180,7 @@ irc_command_msg (void *data, struct t_gui_buffer *buffer, int argc, { /* standard message (to "#channel") */ irc_input_user_message_display ( - ptr_channel->buffer, + ptr_channel2->buffer, 0, (string) ? string : argv_eol[arg_text]); } @@ -3189,19 +3241,20 @@ irc_command_msg (void *data, struct t_gui_buffer *buffer, int argc, string = irc_color_decode ( argv_eol[arg_text], weechat_config_boolean (irc_config_network_colors_send)); - ptr_channel = irc_channel_search (ptr_server, - targets[i]); - if (ptr_channel) + ptr_channel2 = irc_channel_search (ptr_server, + targets[i]); + if (ptr_channel2) { irc_input_user_message_display ( - ptr_channel->buffer, + ptr_channel2->buffer, 0, (string) ? string : argv_eol[arg_text]); } else { - weechat_printf_tags ( + weechat_printf_date_tags ( ptr_server->buffer, + 0, irc_protocol_tags ( "privmsg", "notify_none,no_highlight", ptr_server->nick, NULL), @@ -3235,14 +3288,13 @@ irc_command_msg (void *data, struct t_gui_buffer *buffer, int argc, * Callback for command "/names": lists nicknames on channels. */ -int -irc_command_names (void *data, struct t_gui_buffer *buffer, int argc, - char **argv, char **argv_eol) +IRC_COMMAND_CALLBACK(names) { IRC_BUFFER_GET_SERVER_CHANNEL(buffer); IRC_COMMAND_CHECK_SERVER("names", 1); /* make C compiler happy */ + (void) pointer; (void) data; (void) argv; @@ -3292,14 +3344,13 @@ irc_send_nick_server (struct t_irc_server *server, const char *nickname) * Callback for command "/nick": changes nickname. */ -int -irc_command_nick (void *data, struct t_gui_buffer *buffer, int argc, - char **argv, char **argv_eol) +IRC_COMMAND_CALLBACK(nick) { IRC_BUFFER_GET_SERVER(buffer); IRC_COMMAND_CHECK_SERVER("nick", 0); /* make C compiler happy */ + (void) pointer; (void) data; (void) argv_eol; @@ -3325,9 +3376,7 @@ irc_command_nick (void *data, struct t_gui_buffer *buffer, int argc, * Callback for command "/notice": sends notice message. */ -int -irc_command_notice (void *data, struct t_gui_buffer *buffer, int argc, - char **argv, char **argv_eol) +IRC_COMMAND_CALLBACK(notice) { char *string, hash_key[32], *str_args; int arg_target, arg_text, number, is_channel; @@ -3337,6 +3386,7 @@ irc_command_notice (void *data, struct t_gui_buffer *buffer, int argc, IRC_BUFFER_GET_SERVER(buffer); /* make C compiler happy */ + (void) pointer; (void) data; WEECHAT_COMMAND_MIN_ARGS(3, ""); @@ -3382,10 +3432,11 @@ irc_command_notice (void *data, struct t_gui_buffer *buffer, int argc, string = irc_color_decode ( str_args, weechat_config_boolean (irc_config_network_colors_send)); - weechat_printf_tags ( + weechat_printf_date_tags ( irc_msgbuffer_get_target_buffer ( ptr_server, argv[arg_target], "notice", NULL, (ptr_channel) ? ptr_channel->buffer : NULL), + 0, "notify_none,no_highlight", "%s%s%s%s -> %s%s%s: %s", weechat_prefix ("network"), @@ -3411,9 +3462,7 @@ irc_command_notice (void *data, struct t_gui_buffer *buffer, int argc, * Callback for command "/notify": adds or removes notify. */ -int -irc_command_notify (void *data, struct t_gui_buffer *buffer, int argc, - char **argv, char **argv_eol) +IRC_COMMAND_CALLBACK(notify) { struct t_irc_notify *ptr_notify; int i, check_away; @@ -3421,6 +3470,7 @@ irc_command_notify (void *data, struct t_gui_buffer *buffer, int argc, IRC_BUFFER_GET_SERVER(buffer); /* make C compiler happy */ + (void) pointer; (void) data; (void) buffer; (void) argv_eol; @@ -3598,14 +3648,13 @@ irc_command_notify (void *data, struct t_gui_buffer *buffer, int argc, * Callback for command "/op": gives operator privileges to nickname(s). */ -int -irc_command_op (void *data, struct t_gui_buffer *buffer, int argc, char **argv, - char **argv_eol) +IRC_COMMAND_CALLBACK(op) { IRC_BUFFER_GET_SERVER_CHANNEL(buffer); IRC_COMMAND_CHECK_SERVER("op", 1); /* make C compiler happy */ + (void) pointer; (void) data; (void) argv_eol; @@ -3638,14 +3687,13 @@ irc_command_op (void *data, struct t_gui_buffer *buffer, int argc, char **argv, * Callback for command "/oper": gets oper privileges. */ -int -irc_command_oper (void *data, struct t_gui_buffer *buffer, int argc, - char **argv, char **argv_eol) +IRC_COMMAND_CALLBACK(oper) { IRC_BUFFER_GET_SERVER(buffer); IRC_COMMAND_CHECK_SERVER("oper", 1); /* make C compiler happy */ + (void) pointer; (void) data; (void) argv; @@ -3665,39 +3713,34 @@ void irc_command_part_channel (struct t_irc_server *server, const char *channel_name, const char *part_message) { - const char *ptr_arg, *version, *msg_part; - char *buf; - - msg_part = IRC_SERVER_OPTION_STRING(server, - IRC_SERVER_OPTION_DEFAULT_MSG_PART); - ptr_arg = (part_message) ? part_message : - ((msg_part && msg_part[0]) ? msg_part : NULL); + const char *ptr_arg; + char *msg; - if (ptr_arg) + msg = NULL; + ptr_arg = (part_message) ? + part_message : IRC_SERVER_OPTION_STRING(server, + IRC_SERVER_OPTION_MSG_PART); + if (ptr_arg && ptr_arg[0]) { - version = weechat_info_get ("version", ""); - buf = weechat_string_replace (ptr_arg, "%v", (version) ? version : ""); + msg = irc_server_get_default_msg (ptr_arg, server, channel_name); irc_server_sendf (server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, - "PART %s :%s", - channel_name, - (buf) ? buf : ptr_arg); - if (buf) - free (buf); + "PART %s :%s", channel_name, msg); } else { irc_server_sendf (server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, "PART %s", channel_name); } + + if (msg) + free (msg); } /* * Callback for command "/part": leaves a channel or close a private window. */ -int -irc_command_part (void *data, struct t_gui_buffer *buffer, int argc, - char **argv, char **argv_eol) +IRC_COMMAND_CALLBACK(part) { char *channel_name, *pos_args; @@ -3705,6 +3748,7 @@ irc_command_part (void *data, struct t_gui_buffer *buffer, int argc, IRC_COMMAND_CHECK_SERVER("part", 1); /* make C compiler happy */ + (void) pointer; (void) data; if (argc > 1) @@ -3764,14 +3808,13 @@ irc_command_part (void *data, struct t_gui_buffer *buffer, int argc, * Callback for command "/ping": pings a server. */ -int -irc_command_ping (void *data, struct t_gui_buffer *buffer, int argc, - char **argv, char **argv_eol) +IRC_COMMAND_CALLBACK(ping) { IRC_BUFFER_GET_SERVER(buffer); IRC_COMMAND_CHECK_SERVER("ping", 1); /* make C compiler happy */ + (void) pointer; (void) data; (void) argv; @@ -3787,14 +3830,13 @@ irc_command_ping (void *data, struct t_gui_buffer *buffer, int argc, * Callback for command "/pong": sends pong answer to a daemon. */ -int -irc_command_pong (void *data, struct t_gui_buffer *buffer, int argc, - char **argv, char **argv_eol) +IRC_COMMAND_CALLBACK(pong) { IRC_BUFFER_GET_SERVER(buffer); IRC_COMMAND_CHECK_SERVER("pong", 0); /* make C compiler happy */ + (void) pointer; (void) data; (void) argv; @@ -3810,9 +3852,7 @@ irc_command_pong (void *data, struct t_gui_buffer *buffer, int argc, * Callback for command "/query": starts private conversation with a nick. */ -int -irc_command_query (void *data, struct t_gui_buffer *buffer, int argc, - char **argv, char **argv_eol) +IRC_COMMAND_CALLBACK(query) { char *string, **nicks; int i, arg_nick, arg_text, num_nicks, noswitch; @@ -3820,6 +3860,7 @@ irc_command_query (void *data, struct t_gui_buffer *buffer, int argc, IRC_BUFFER_GET_SERVER_CHANNEL(buffer); /* make C compiler happy */ + (void) pointer; (void) data; WEECHAT_COMMAND_MIN_ARGS(2, ""); @@ -3928,9 +3969,7 @@ irc_command_query (void *data, struct t_gui_buffer *buffer, int argc, * Callback for command "/quiet": quiets nicks or hosts. */ -int -irc_command_quiet (void *data, struct t_gui_buffer *buffer, int argc, - char **argv, char **argv_eol) +IRC_COMMAND_CALLBACK(quiet) { char *pos_channel; int pos_args; @@ -3939,6 +3978,7 @@ irc_command_quiet (void *data, struct t_gui_buffer *buffer, int argc, IRC_COMMAND_CHECK_SERVER("quiet", 1); /* make C compiler happy */ + (void) pointer; (void) data; (void) argv_eol; @@ -4011,13 +4051,12 @@ irc_command_quiet (void *data, struct t_gui_buffer *buffer, int argc, * Callback for command "/quote": sends raw data to server. */ -int -irc_command_quote (void *data, struct t_gui_buffer *buffer, int argc, - char **argv, char **argv_eol) +IRC_COMMAND_CALLBACK(quote) { IRC_BUFFER_GET_SERVER(buffer); /* make C compiler happy */ + (void) pointer; (void) data; WEECHAT_COMMAND_MIN_ARGS(2, ""); @@ -4088,15 +4127,14 @@ irc_command_reconnect_one_server (struct t_irc_server *server, * Callback for command "/reconnect": reconnects to server(s). */ -int -irc_command_reconnect (void *data, struct t_gui_buffer *buffer, int argc, - char **argv, char **argv_eol) +IRC_COMMAND_CALLBACK(reconnect) { int i, nb_reconnect, reconnect_ok, all_servers, switch_address, no_join; IRC_BUFFER_GET_SERVER(buffer); /* make C compiler happy */ + (void) pointer; (void) data; (void) argv_eol; @@ -4177,14 +4215,13 @@ irc_command_reconnect (void *data, struct t_gui_buffer *buffer, int argc, * Callback for command "/rehash": tells the server to reload its config file. */ -int -irc_command_rehash (void *data, struct t_gui_buffer *buffer, int argc, - char **argv, char **argv_eol) +IRC_COMMAND_CALLBACK(rehash) { IRC_BUFFER_GET_SERVER(buffer); IRC_COMMAND_CHECK_SERVER("rehash", 1); /* make C compiler happy */ + (void) pointer; (void) data; (void) argv; @@ -4206,9 +4243,7 @@ irc_command_rehash (void *data, struct t_gui_buffer *buffer, int argc, * Callback for command "/remove": remove a user from a channel. */ -int -irc_command_remove (void *data, struct t_gui_buffer *buffer, int argc, - char **argv, char **argv_eol) +IRC_COMMAND_CALLBACK(remove) { const char *ptr_channel_name; char *msg_vars_replaced; @@ -4218,6 +4253,7 @@ irc_command_remove (void *data, struct t_gui_buffer *buffer, int argc, IRC_COMMAND_CHECK_SERVER("remove", 1); /* make C compiler happy */ + (void) pointer; (void) data; WEECHAT_COMMAND_MIN_ARGS(2, ""); @@ -4269,14 +4305,13 @@ irc_command_remove (void *data, struct t_gui_buffer *buffer, int argc, * Callback for command "/restart": tells the server to restart itself. */ -int -irc_command_restart (void *data, struct t_gui_buffer *buffer, int argc, - char **argv, char **argv_eol) +IRC_COMMAND_CALLBACK(restart) { IRC_BUFFER_GET_SERVER(buffer); IRC_COMMAND_CHECK_SERVER("restart", 1); /* make C compiler happy */ + (void) pointer; (void) data; (void) argv; @@ -4298,14 +4333,13 @@ irc_command_restart (void *data, struct t_gui_buffer *buffer, int argc, * Callback for command "/sajoin": forces a user to join channel(s). */ -int -irc_command_sajoin (void *data, struct t_gui_buffer *buffer, int argc, - char **argv, char **argv_eol) +IRC_COMMAND_CALLBACK(sajoin) { IRC_BUFFER_GET_SERVER_CHANNEL(buffer); IRC_COMMAND_CHECK_SERVER("sajoin", 1); /* make C compiler happy */ + (void) pointer; (void) data; WEECHAT_COMMAND_MIN_ARGS(3, ""); @@ -4321,14 +4355,13 @@ irc_command_sajoin (void *data, struct t_gui_buffer *buffer, int argc, * operator status. */ -int -irc_command_samode (void *data, struct t_gui_buffer *buffer, int argc, - char **argv, char **argv_eol) +IRC_COMMAND_CALLBACK(samode) { IRC_BUFFER_GET_SERVER_CHANNEL(buffer); IRC_COMMAND_CHECK_SERVER("samode", 1); /* make C compiler happy */ + (void) pointer; (void) data; if (argc > 1) @@ -4381,14 +4414,13 @@ irc_command_samode (void *data, struct t_gui_buffer *buffer, int argc, * Callback for command "/sanick": forces a user to use another nick. */ -int -irc_command_sanick (void *data, struct t_gui_buffer *buffer, int argc, - char **argv, char **argv_eol) +IRC_COMMAND_CALLBACK(sanick) { IRC_BUFFER_GET_SERVER_CHANNEL(buffer); IRC_COMMAND_CHECK_SERVER("sanick", 1); /* make C compiler happy */ + (void) pointer; (void) data; WEECHAT_COMMAND_MIN_ARGS(3, ""); @@ -4403,14 +4435,13 @@ irc_command_sanick (void *data, struct t_gui_buffer *buffer, int argc, * Callback for command "/sapart": forces a user to leave channel(s). */ -int -irc_command_sapart (void *data, struct t_gui_buffer *buffer, int argc, - char **argv, char **argv_eol) +IRC_COMMAND_CALLBACK(sapart) { IRC_BUFFER_GET_SERVER_CHANNEL(buffer); IRC_COMMAND_CHECK_SERVER("sapart", 1); /* make C compiler happy */ + (void) pointer; (void) data; WEECHAT_COMMAND_MIN_ARGS(3, ""); @@ -4425,14 +4456,13 @@ irc_command_sapart (void *data, struct t_gui_buffer *buffer, int argc, * Callback for command "/saquit": forces a user to quit server with a reason. */ -int -irc_command_saquit (void *data, struct t_gui_buffer *buffer, int argc, - char **argv, char **argv_eol) +IRC_COMMAND_CALLBACK(saquit) { IRC_BUFFER_GET_SERVER_CHANNEL(buffer); IRC_COMMAND_CHECK_SERVER("saquit", 1); /* make C compiler happy */ + (void) pointer; (void) data; WEECHAT_COMMAND_MIN_ARGS(3, ""); @@ -4490,7 +4520,7 @@ irc_command_display_server (struct t_irc_server *server, int with_detail) else weechat_printf (NULL, " ipv6 . . . . . . . . : %s%s", IRC_COLOR_CHAT_VALUE, - weechat_config_boolean (server->options[IRC_SERVER_OPTION_IPV6]) ? + (weechat_config_boolean (server->options[IRC_SERVER_OPTION_IPV6])) ? _("on") : _("off")); /* ssl */ if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_SSL])) @@ -4500,7 +4530,7 @@ irc_command_display_server (struct t_irc_server *server, int with_detail) else weechat_printf (NULL, " ssl. . . . . . . . . : %s%s", IRC_COLOR_CHAT_VALUE, - weechat_config_boolean (server->options[IRC_SERVER_OPTION_SSL]) ? + (weechat_config_boolean (server->options[IRC_SERVER_OPTION_SSL])) ? _("on") : _("off")); /* ssl_cert */ if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_SSL_CERT])) @@ -4542,7 +4572,7 @@ irc_command_display_server (struct t_irc_server *server, int with_detail) else weechat_printf (NULL, " ssl_verify . . . . . : %s%s", IRC_COLOR_CHAT_VALUE, - weechat_config_boolean (server->options[IRC_SERVER_OPTION_SSL_VERIFY]) ? + (weechat_config_boolean (server->options[IRC_SERVER_OPTION_SSL_VERIFY])) ? _("on") : _("off")); /* password */ if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_PASSWORD])) @@ -4618,7 +4648,7 @@ irc_command_display_server (struct t_irc_server *server, int with_detail) else weechat_printf (NULL, " autoconnect. . . . . : %s%s", IRC_COLOR_CHAT_VALUE, - weechat_config_boolean (server->options[IRC_SERVER_OPTION_AUTOCONNECT]) ? + (weechat_config_boolean (server->options[IRC_SERVER_OPTION_AUTOCONNECT])) ? _("on") : _("off")); /* autoreconnect */ if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_AUTORECONNECT])) @@ -4628,7 +4658,7 @@ irc_command_display_server (struct t_irc_server *server, int with_detail) else weechat_printf (NULL, " autoreconnect. . . . : %s%s", IRC_COLOR_CHAT_VALUE, - weechat_config_boolean (server->options[IRC_SERVER_OPTION_AUTORECONNECT]) ? + (weechat_config_boolean (server->options[IRC_SERVER_OPTION_AUTORECONNECT])) ? _("on") : _("off")); /* autoreconnect_delay */ if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_AUTORECONNECT_DELAY])) @@ -4648,6 +4678,16 @@ irc_command_display_server (struct t_irc_server *server, int with_detail) weechat_printf (NULL, " nicks. . . . . . . . : %s'%s'", IRC_COLOR_CHAT_VALUE, weechat_config_string (server->options[IRC_SERVER_OPTION_NICKS])); + /* nicks_alternate */ + if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_NICKS_ALTERNATE])) + weechat_printf (NULL, " nicks_alternate. . . : (%s)", + (IRC_SERVER_OPTION_BOOLEAN(server, IRC_SERVER_OPTION_NICKS_ALTERNATE)) ? + _("on") : _("off")); + else + weechat_printf (NULL, " nicks_alternate. . . : %s%s", + IRC_COLOR_CHAT_VALUE, + (weechat_config_boolean (server->options[IRC_SERVER_OPTION_NICKS_ALTERNATE])) ? + _("on") : _("off")); /* username */ if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_USERNAME])) weechat_printf (NULL, " username . . . . . . : ('%s')", @@ -4720,7 +4760,7 @@ irc_command_display_server (struct t_irc_server *server, int with_detail) else weechat_printf (NULL, " autorejoin . . . . . : %s%s", IRC_COLOR_CHAT_VALUE, - weechat_config_boolean (server->options[IRC_SERVER_OPTION_AUTOREJOIN]) ? + (weechat_config_boolean (server->options[IRC_SERVER_OPTION_AUTOREJOIN])) ? _("on") : _("off")); /* autorejoin_delay */ if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_AUTOREJOIN_DELAY])) @@ -4780,30 +4820,30 @@ irc_command_display_server (struct t_irc_server *server, int with_detail) weechat_printf (NULL, " away_check_max_nicks : %s%d", IRC_COLOR_CHAT_VALUE, weechat_config_integer (server->options[IRC_SERVER_OPTION_AWAY_CHECK_MAX_NICKS])); - /* default_msg_kick */ - if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_DEFAULT_MSG_KICK])) - weechat_printf (NULL, " default_msg_kick . . : ('%s')", - IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_DEFAULT_MSG_KICK)); + /* msg_kick */ + if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_MSG_KICK])) + weechat_printf (NULL, " msg_kick . . . . . . : ('%s')", + IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_MSG_KICK)); else - weechat_printf (NULL, " default_msg_kick . . : %s'%s'", + weechat_printf (NULL, " msg_kick . . . . . . : %s'%s'", IRC_COLOR_CHAT_VALUE, - weechat_config_string (server->options[IRC_SERVER_OPTION_DEFAULT_MSG_KICK])); - /* default_msg_part */ - if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_DEFAULT_MSG_PART])) - weechat_printf (NULL, " default_msg_part . . : ('%s')", - IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_DEFAULT_MSG_PART)); + weechat_config_string (server->options[IRC_SERVER_OPTION_MSG_KICK])); + /* msg_part */ + if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_MSG_PART])) + weechat_printf (NULL, " msg_part . . . . . . : ('%s')", + IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_MSG_PART)); else - weechat_printf (NULL, " default_msg_part . . : %s'%s'", + weechat_printf (NULL, " msg_part . . . . . . : %s'%s'", IRC_COLOR_CHAT_VALUE, - weechat_config_string (server->options[IRC_SERVER_OPTION_DEFAULT_MSG_PART])); - /* default_msg_quit */ - if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_DEFAULT_MSG_QUIT])) - weechat_printf (NULL, " default_msg_quit . . : ('%s')", - IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_DEFAULT_MSG_QUIT)); + weechat_config_string (server->options[IRC_SERVER_OPTION_MSG_PART])); + /* msg_quit */ + if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_MSG_QUIT])) + weechat_printf (NULL, " msg_quit . . . . . . : ('%s')", + IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_MSG_QUIT)); else - weechat_printf (NULL, " default_msg_quit . . : %s'%s'", + weechat_printf (NULL, " msg_quit . . . . . . : %s'%s'", IRC_COLOR_CHAT_VALUE, - weechat_config_string (server->options[IRC_SERVER_OPTION_DEFAULT_MSG_QUIT])); + weechat_config_string (server->options[IRC_SERVER_OPTION_MSG_QUIT])); /* notify */ if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_NOTIFY])) weechat_printf (NULL, " notify . . . . . . . : ('%s')", @@ -4853,9 +4893,7 @@ irc_command_display_server (struct t_irc_server *server, int with_detail) * Callback for command "/server": manages IRC servers. */ -int -irc_command_server (void *data, struct t_gui_buffer *buffer, int argc, - char **argv, char **argv_eol) +IRC_COMMAND_CALLBACK(server) { int i, detailed_list, one_server_found, length, count; struct t_irc_server *ptr_server2, *server_found, *new_server; @@ -4864,6 +4902,7 @@ irc_command_server (void *data, struct t_gui_buffer *buffer, int argc, IRC_BUFFER_GET_SERVER_CHANNEL(buffer); /* make C compiler happy */ + (void) pointer; (void) data; (void) buffer; @@ -5219,14 +5258,13 @@ irc_command_server (void *data, struct t_gui_buffer *buffer, int argc, * Callback for command "/service": registers a new service. */ -int -irc_command_service (void *data, struct t_gui_buffer *buffer, int argc, - char **argv, char **argv_eol) +IRC_COMMAND_CALLBACK(service) { IRC_BUFFER_GET_SERVER(buffer); IRC_COMMAND_CHECK_SERVER("service", 1); /* make C compiler happy */ + (void) pointer; (void) data; (void) argv; @@ -5243,14 +5281,13 @@ irc_command_service (void *data, struct t_gui_buffer *buffer, int argc, * network. */ -int -irc_command_servlist (void *data, struct t_gui_buffer *buffer, int argc, - char **argv, char **argv_eol) +IRC_COMMAND_CALLBACK(servlist) { IRC_BUFFER_GET_SERVER(buffer); IRC_COMMAND_CHECK_SERVER("servlist", 1); /* make C compiler happy */ + (void) pointer; (void) data; (void) argv; @@ -5272,14 +5309,13 @@ irc_command_servlist (void *data, struct t_gui_buffer *buffer, int argc, * Callback for command "/squery": delivers a message to a service. */ -int -irc_command_squery (void *data, struct t_gui_buffer *buffer, int argc, - char **argv, char **argv_eol) +IRC_COMMAND_CALLBACK(squery) { IRC_BUFFER_GET_SERVER(buffer); IRC_COMMAND_CHECK_SERVER("squery", 1); /* make C compiler happy */ + (void) pointer; (void) data; WEECHAT_COMMAND_MIN_ARGS(2, ""); @@ -5302,14 +5338,13 @@ irc_command_squery (void *data, struct t_gui_buffer *buffer, int argc, * Callback for command "/squit": disconnects server links. */ -int -irc_command_squit (void *data, struct t_gui_buffer *buffer, int argc, - char **argv, char **argv_eol) +IRC_COMMAND_CALLBACK(squit) { IRC_BUFFER_GET_SERVER(buffer); IRC_COMMAND_CHECK_SERVER("squit", 1); /* make C compiler happy */ + (void) pointer; (void) data; (void) argv; @@ -5324,14 +5359,13 @@ irc_command_squit (void *data, struct t_gui_buffer *buffer, int argc, * Callback for command "/stats": queries statistics about server. */ -int -irc_command_stats (void *data, struct t_gui_buffer *buffer, int argc, - char **argv, char **argv_eol) +IRC_COMMAND_CALLBACK(stats) { IRC_BUFFER_GET_SERVER(buffer); IRC_COMMAND_CHECK_SERVER("stats", 1); /* make C compiler happy */ + (void) pointer; (void) data; (void) argv; @@ -5354,14 +5388,13 @@ irc_command_stats (void *data, struct t_gui_buffer *buffer, int argc, * server a message asking them to please join IRC. */ -int -irc_command_summon (void *data, struct t_gui_buffer *buffer, int argc, - char **argv, char **argv_eol) +IRC_COMMAND_CALLBACK(summon) { IRC_BUFFER_GET_SERVER(buffer); IRC_COMMAND_CHECK_SERVER("summon", 1); /* make C compiler happy */ + (void) pointer; (void) data; (void) argv; @@ -5377,14 +5410,13 @@ irc_command_summon (void *data, struct t_gui_buffer *buffer, int argc, * Callback for command "/time": queries local time from server. */ -int -irc_command_time (void *data, struct t_gui_buffer *buffer, int argc, - char **argv, char **argv_eol) +IRC_COMMAND_CALLBACK(time) { IRC_BUFFER_GET_SERVER(buffer); IRC_COMMAND_CHECK_SERVER("time", 1); /* make C compiler happy */ + (void) pointer; (void) data; (void) argv; @@ -5406,9 +5438,7 @@ irc_command_time (void *data, struct t_gui_buffer *buffer, int argc, * Callback for command "/topic": gets/sets topic for a channel. */ -int -irc_command_topic (void *data, struct t_gui_buffer *buffer, int argc, - char **argv, char **argv_eol) +IRC_COMMAND_CALLBACK(topic) { char *channel_name, *new_topic, *new_topic_color; @@ -5416,6 +5446,7 @@ irc_command_topic (void *data, struct t_gui_buffer *buffer, int argc, IRC_COMMAND_CHECK_SERVER("topic", 1); /* make C compiler happy */ + (void) pointer; (void) data; (void) argv; @@ -5484,14 +5515,13 @@ irc_command_topic (void *data, struct t_gui_buffer *buffer, int argc, * Callback for command "/trace": finds the route to specific server. */ -int -irc_command_trace (void *data, struct t_gui_buffer *buffer, int argc, - char **argv, char **argv_eol) +IRC_COMMAND_CALLBACK(trace) { IRC_BUFFER_GET_SERVER(buffer); IRC_COMMAND_CHECK_SERVER("trace", 1); /* make C compiler happy */ + (void) pointer; (void) data; (void) argv; @@ -5513,9 +5543,7 @@ irc_command_trace (void *data, struct t_gui_buffer *buffer, int argc, * Callback for command "/unban": unbans nicks or hosts. */ -int -irc_command_unban (void *data, struct t_gui_buffer *buffer, int argc, - char **argv, char **argv_eol) +IRC_COMMAND_CALLBACK(unban) { char *pos_channel; int pos_args; @@ -5524,6 +5552,7 @@ irc_command_unban (void *data, struct t_gui_buffer *buffer, int argc, IRC_COMMAND_CHECK_SERVER("unban", 1); /* make C compiler happy */ + (void) pointer; (void) data; (void) argv_eol; @@ -5571,9 +5600,7 @@ irc_command_unban (void *data, struct t_gui_buffer *buffer, int argc, * Callback for command "/unquiet": unquiets nicks or hosts. */ -int -irc_command_unquiet (void *data, struct t_gui_buffer *buffer, int argc, - char **argv, char **argv_eol) +IRC_COMMAND_CALLBACK(unquiet) { char *pos_channel; int pos_args; @@ -5582,6 +5609,7 @@ irc_command_unquiet (void *data, struct t_gui_buffer *buffer, int argc, IRC_COMMAND_CHECK_SERVER("unquiet", 1); /* make C compiler happy */ + (void) pointer; (void) data; (void) argv_eol; @@ -5640,14 +5668,13 @@ irc_command_unquiet (void *data, struct t_gui_buffer *buffer, int argc, * nicknames. */ -int -irc_command_userhost (void *data, struct t_gui_buffer *buffer, int argc, - char **argv, char **argv_eol) +IRC_COMMAND_CALLBACK(userhost) { IRC_BUFFER_GET_SERVER(buffer); IRC_COMMAND_CHECK_SERVER("userhost", 1); /* make C compiler happy */ + (void) pointer; (void) data; (void) argv; @@ -5663,14 +5690,13 @@ irc_command_userhost (void *data, struct t_gui_buffer *buffer, int argc, * Callback for command "/users": list of users logged into the server. */ -int -irc_command_users (void *data, struct t_gui_buffer *buffer, int argc, - char **argv, char **argv_eol) +IRC_COMMAND_CALLBACK(users) { IRC_BUFFER_GET_SERVER(buffer); IRC_COMMAND_CHECK_SERVER("users", 1); /* make C compiler happy */ + (void) pointer; (void) data; (void) argv; @@ -5693,14 +5719,13 @@ irc_command_users (void *data, struct t_gui_buffer *buffer, int argc, * (current or specified). */ -int -irc_command_version (void *data, struct t_gui_buffer *buffer, int argc, - char **argv, char **argv_eol) +IRC_COMMAND_CALLBACK(version) { IRC_BUFFER_GET_SERVER_CHANNEL(buffer); IRC_COMMAND_CHECK_SERVER("version", 1); /* make C compiler happy */ + (void) pointer; (void) data; (void) argv_eol; @@ -5731,14 +5756,13 @@ irc_command_version (void *data, struct t_gui_buffer *buffer, int argc, * Callback for command "/voice": gives voice to nickname(s). */ -int -irc_command_voice (void *data, struct t_gui_buffer *buffer, int argc, - char **argv, char **argv_eol) +IRC_COMMAND_CALLBACK(voice) { IRC_BUFFER_GET_SERVER_CHANNEL(buffer); IRC_COMMAND_CHECK_SERVER("voice", 1); /* make C compiler happy */ + (void) pointer; (void) data; (void) argv_eol; @@ -5771,9 +5795,7 @@ irc_command_voice (void *data, struct t_gui_buffer *buffer, int argc, * Callback for command "/wallchops": sends a notice to channel ops. */ -int -irc_command_wallchops (void *data, struct t_gui_buffer *buffer, int argc, - char **argv, char **argv_eol) +IRC_COMMAND_CALLBACK(wallchops) { char *pos_channel; int pos_args; @@ -5784,6 +5806,7 @@ irc_command_wallchops (void *data, struct t_gui_buffer *buffer, int argc, IRC_COMMAND_CHECK_SERVER("wallchops", 1); /* make C compiler happy */ + (void) pointer; (void) data; WEECHAT_COMMAND_MIN_ARGS(2, ""); @@ -5883,14 +5906,13 @@ irc_command_wallchops (void *data, struct t_gui_buffer *buffer, int argc, * users who have set the 'w' user mode for themselves. */ -int -irc_command_wallops (void *data, struct t_gui_buffer *buffer, int argc, - char **argv, char **argv_eol) +IRC_COMMAND_CALLBACK(wallops) { IRC_BUFFER_GET_SERVER(buffer); IRC_COMMAND_CHECK_SERVER("wallops", 1); /* make C compiler happy */ + (void) pointer; (void) data; (void) argv; @@ -5907,14 +5929,13 @@ irc_command_wallops (void *data, struct t_gui_buffer *buffer, int argc, * information. */ -int -irc_command_who (void *data, struct t_gui_buffer *buffer, int argc, - char **argv, char **argv_eol) +IRC_COMMAND_CALLBACK(who) { IRC_BUFFER_GET_SERVER(buffer); IRC_COMMAND_CHECK_SERVER("who", 1); /* make C compiler happy */ + (void) pointer; (void) data; (void) argv; @@ -5936,9 +5957,7 @@ irc_command_who (void *data, struct t_gui_buffer *buffer, int argc, * Callback for command "/whois": queries information about user(s). */ -int -irc_command_whois (void *data, struct t_gui_buffer *buffer, int argc, - char **argv, char **argv_eol) +IRC_COMMAND_CALLBACK(whois) { int double_nick; const char *ptr_nick; @@ -5947,6 +5966,7 @@ irc_command_whois (void *data, struct t_gui_buffer *buffer, int argc, IRC_COMMAND_CHECK_SERVER("whois", 1); /* make C compiler happy */ + (void) pointer; (void) data; double_nick = weechat_config_boolean (irc_config_network_whois_double_nick); @@ -5988,14 +6008,13 @@ irc_command_whois (void *data, struct t_gui_buffer *buffer, int argc, * no longer exists. */ -int -irc_command_whowas (void *data, struct t_gui_buffer *buffer, int argc, - char **argv, char **argv_eol) +IRC_COMMAND_CALLBACK(whowas) { IRC_BUFFER_GET_SERVER(buffer); IRC_COMMAND_CHECK_SERVER("whowas", 1); /* make C compiler happy */ + (void) pointer; (void) data; (void) argv; @@ -6019,7 +6038,7 @@ irc_command_init () N_("find information about the administrator of the server"), N_("[<target>]"), N_("target: server name"), - NULL, &irc_command_admin, NULL); + NULL, &irc_command_admin, NULL, NULL); weechat_hook_command ( "allchan", N_("execute a command on all channels of all connected servers"), @@ -6039,7 +6058,7 @@ irc_command_init () " say 'hello' everywhere but not on #weechat and channels beginning " "with #linux:\n" " /allchan -exclude=#weechat,#linux* msg * hello"), - "-current", &irc_command_allchan, NULL); + "-current", &irc_command_allchan, NULL, NULL); weechat_hook_command ( "allpv", N_("execute a command on all private buffers of all connected servers"), @@ -6062,7 +6081,7 @@ irc_command_init () " /allpv -exclude=foo,bar* msg * hello\n" " close all private buffers:\n" " /allpv close"), - "-current", &irc_command_allpv, NULL); + "-current", &irc_command_allpv, NULL, NULL); weechat_hook_command ( "allserv", N_("execute a command on all connected servers"), @@ -6080,8 +6099,8 @@ irc_command_init () " /allserv away I'm away\n" " do a whois on my nick on all servers:\n" " /allserv whois $nick"), - NULL, &irc_command_allserv, NULL); - weechat_hook_command_run ("/away", &irc_command_run_away, NULL); + NULL, &irc_command_allserv, NULL, NULL); + weechat_hook_command_run ("/away", &irc_command_run_away, NULL, NULL); weechat_hook_command ( "ban", N_("ban nicks or hosts"), @@ -6089,8 +6108,40 @@ irc_command_init () N_("channel: channel name\n" " nick: nick or host\n" "\n" - "Without argument, this command display ban list for current channel."), - "%(irc_channel_nicks_hosts)", &irc_command_ban, NULL); + "Without argument, this command displays the ban list for current " + "channel."), + "%(irc_channel_nicks_hosts)", &irc_command_ban, NULL, NULL); + weechat_hook_command ( + "cap", + N_("client capability negotiation"), + N_("ls || list || req|ack [<capability> [<capability>...]]" + " || end"), + N_(" ls: list the capabilities supported by the server\n" + " list: list the capabilities currently enabled\n" + " req: request a capability\n" + " ack: acknowledge capabilities which require client-side " + "acknowledgement\n" + " end: end the capability negotiation\n" + "\n" + "Without argument, \"ls\" and \"list\" are sent.\n" + "\n" + "Capabilities supported by WeeChat are: " + "account-notify, away-notify, cap-notify, extended-join, " + "multi-prefix, server-time, userhost-in-names.\n" + "\n" + "The capabilities to automatically enable on servers can be set " + "in option irc.server_default.capabilities (or by server in " + "option irc.server.xxx.capabilities).\n" + "\n" + "Examples:\n" + " /cap\n" + " /cap req multi-prefix away-notify"), + "ls" + " || list" + " || req " IRC_COMMAND_CAP_SUPPORTED_COMPLETION + " || ack " IRC_COMMAND_CAP_SUPPORTED_COMPLETION + " || end", + &irc_command_cap, NULL, NULL); weechat_hook_command ( "connect", N_("connect to IRC server(s)"), @@ -6128,24 +6179,32 @@ irc_command_init () " /connect irc://nick@irc.oftc.net/#channel\n" " /connect -switch"), "%(irc_servers)|-all|-auto|-open|-nojoin|-switch|%*", - &irc_command_connect, NULL); + &irc_command_connect, NULL, NULL); weechat_hook_command ( "ctcp", N_("send a CTCP message (Client-To-Client Protocol)"), - N_("<target> <type> [<arguments>]"), - N_(" target: nick or channel name to send CTCP to\n" - " type: CTCP type (examples: \"version\", \"ping\", ..)\n" - "arguments: arguments for CTCP"), - "%(irc_channel)|%(nicks) action|clientinfo|finger|ping|source|time|" - "userinfo|version", - &irc_command_ctcp, NULL); + N_("[-server <server>] <target>[,<target>...] <type> [<arguments>]"), + N_(" server: send to this server (internal name)\n" + " target: nick or channel ('*' = current channel)\n" + " type: CTCP type (examples: \"version\", \"ping\", ..)\n" + "arguments: arguments for CTCP\n" + "\n" + "Examples:\n" + " /ctcp toto time\n" + " /ctcp toto version\n" + " /ctcp * version"), + "-server %(irc_servers) %(irc_channel)|%(nicks)|* " + IRC_COMMAND_CTCP_SUPPORTED_COMPLETION + " || %(irc_channel)|%(nicks)|* " + IRC_COMMAND_CTCP_SUPPORTED_COMPLETION, + &irc_command_ctcp, NULL, NULL); weechat_hook_command ( "cycle", N_("leave and rejoin a channel"), N_("[<channel>[,<channel>...]] [<message>]"), N_("channel: channel name\n" "message: part message (displayed to other users)"), - "%(irc_msg_part)", &irc_command_cycle, NULL); + "%(irc_msg_part)", &irc_command_cycle, NULL, NULL); weechat_hook_command ( "dcc", N_("start a DCC (file transfer or direct chat)"), @@ -6160,7 +6219,7 @@ irc_command_init () " /dcc send toto /home/foo/bar.txt"), "chat %(nicks)" " || send %(nicks) %(filename)", - &irc_command_dcc, NULL); + &irc_command_dcc, NULL, NULL); weechat_hook_command ( "dehalfop", N_("remove channel half-operator status from nick(s)"), @@ -6168,7 +6227,7 @@ irc_command_init () N_("nick: nick or mask (wildcard \"*\" is allowed)\n" " *: remove channel half-operator status from everybody on channel " "except yourself"), - "%(nicks)", &irc_command_dehalfop, NULL); + "%(nicks)", &irc_command_dehalfop, NULL, NULL); weechat_hook_command ( "deop", N_("remove channel operator status from nick(s)"), @@ -6176,20 +6235,20 @@ irc_command_init () N_("nick: nick or mask (wildcard \"*\" is allowed)\n" " *: remove channel operator status from everybody on channel " "except yourself"), - "%(nicks)|%*", &irc_command_deop, NULL); + "%(nicks)|%*", &irc_command_deop, NULL, NULL); weechat_hook_command ( "devoice", N_("remove voice from nick(s)"), N_("<nick> [<nick>...] || * -yes"), N_("nick: nick or mask (wildcard \"*\" is allowed)\n" " *: remove voice from everybody on channel"), - "%(nicks)|%*", &irc_command_devoice, NULL); + "%(nicks)|%*", &irc_command_devoice, NULL, NULL); weechat_hook_command ( "die", N_("shutdown the server"), N_("[<target>]"), N_("target: server name"), - NULL, &irc_command_die, NULL); + NULL, &irc_command_die, NULL, NULL); weechat_hook_command ( "disconnect", N_("disconnect from one or all IRC servers"), @@ -6200,14 +6259,14 @@ irc_command_init () "reconnecting\n" " reason: reason for the \"quit\""), "%(irc_servers)|-all|-pending", - &irc_command_disconnect, NULL); + &irc_command_disconnect, NULL, NULL); weechat_hook_command ( "halfop", N_("give channel half-operator status to nick(s)"), N_("<nick> [<nick>...] || * -yes"), N_("nick: nick or mask (wildcard \"*\" is allowed)\n" " *: give channel half-operator status to everybody on channel"), - "%(nicks)", &irc_command_halfop, NULL); + "%(nicks)", &irc_command_halfop, NULL, NULL); weechat_hook_command ( "ignore", N_("ignore nicks/hosts from servers or channels"), @@ -6238,26 +6297,26 @@ irc_command_init () "list" " || add %(irc_channel_nicks_hosts) %(irc_servers) %(irc_channels) %-" " || del -all|%(irc_ignores_numbers) %-", - &irc_command_ignore, NULL); + &irc_command_ignore, NULL, NULL); weechat_hook_command ( "info", N_("get information describing the server"), N_("[<target>]"), N_("target: server name"), - NULL, &irc_command_info, NULL); + NULL, &irc_command_info, NULL, NULL); weechat_hook_command ( "invite", N_("invite a nick on a channel"), N_("<nick> [<nick>...] [<channel>]"), N_(" nick: nick\n" "channel: channel name"), - "%(nicks) %(irc_server_channels)", &irc_command_invite, NULL); + "%(nicks) %(irc_server_channels)", &irc_command_invite, NULL, NULL); weechat_hook_command ( "ison", N_("check if a nick is currently on IRC"), N_("<nick> [<nick>...]"), N_("nick: nick"), - "%(nicks)|%*", &irc_command_ison, NULL); + "%(nicks)|%*", &irc_command_ison, NULL, NULL); weechat_hook_command ( "join", N_("join a channel"), @@ -6275,7 +6334,7 @@ irc_command_init () " /join -server freenode #weechat\n" " /join -noswitch #weechat"), "%(irc_channels)|-noswitch|-server|%(irc_servers)|%*", - &irc_command_join, NULL); + &irc_command_join, NULL, NULL); weechat_hook_command ( "kick", N_("kick a user out of a channel"), @@ -6284,7 +6343,7 @@ irc_command_init () " nick: nick\n" " reason: reason (special variables $nick, $channel and $server are " "replaced by their value)"), - "%(nicks) %(irc_msg_kick) %-", &irc_command_kick, NULL); + "%(nicks) %(irc_msg_kick) %-", &irc_command_kick, NULL, NULL); weechat_hook_command ( "kickban", N_("kick a user out of a channel and ban the host"), @@ -6301,14 +6360,14 @@ irc_command_init () " ban \"*!*@host.com\" and then kick \"toto\":\n" " /kickban toto!*@host.com"), "%(irc_channel_nicks_hosts) %(irc_msg_kick) %-", - &irc_command_kickban, NULL); + &irc_command_kickban, NULL, NULL); weechat_hook_command ( "kill", N_("close client-server connection"), N_("<nick> [<reason>]"), N_(" nick: nick\n" "reason: reason"), - "%(nicks) %-", &irc_command_kill, NULL); + "%(nicks) %-", &irc_command_kill, NULL, NULL); weechat_hook_command ( "links", N_("list all servernames which are known by the server answering the " @@ -6316,7 +6375,7 @@ irc_command_init () N_("[[<server>] <server_mask>]"), N_(" server: this server should answer the query\n" "server_mask: list of servers must match this mask"), - NULL, &irc_command_links, NULL); + NULL, &irc_command_links, NULL, NULL); weechat_hook_command ( "list", N_("list channels and their topic"), @@ -6336,26 +6395,26 @@ irc_command_init () " list all channels beginning with \"#weechat\" (can be very slow " "on large networks):\n" " /list -re #weechat.*"), - NULL, &irc_command_list, NULL); + NULL, &irc_command_list, NULL, NULL); weechat_hook_command ( "lusers", N_("get statistics about the size of the IRC network"), N_("[<mask> [<target>]]"), N_(" mask: servers matching the mask only\n" "target: server for forwarding request"), - NULL, &irc_command_lusers, NULL); + NULL, &irc_command_lusers, NULL, NULL); weechat_hook_command ( "map", N_("show a graphical map of the IRC network"), "", "", - NULL, &irc_command_map, NULL); + NULL, &irc_command_map, NULL, NULL); weechat_hook_command ( "me", N_("send a CTCP action to the current channel"), N_("<message>"), N_("message: message to send"), - NULL, &irc_command_me, NULL); + NULL, &irc_command_me, NULL, NULL); weechat_hook_command ( "mode", N_("change channel or user mode"), @@ -6390,13 +6449,13 @@ irc_command_init () " /mode #weechat +t\n" " become invisible on server:\n" " /mode nick +i"), - "%(irc_channel)|%(irc_server_nick)", &irc_command_mode, NULL); + "%(irc_channel)|%(irc_server_nick)", &irc_command_mode, NULL, NULL); weechat_hook_command ( "motd", N_("get the \"Message Of The Day\""), N_("[<target>]"), N_("target: server name"), - NULL, &irc_command_motd, NULL); + NULL, &irc_command_motd, NULL, NULL); weechat_hook_command ( "msg", N_("send message to a nick or channel"), @@ -6404,15 +6463,15 @@ irc_command_init () N_("server: send to this server (internal name)\n" "target: nick or channel (may be mask, '*' = current channel)\n" " text: text to send"), - "-server %(irc_servers) %(nicks)" - " || %(nicks)", - &irc_command_msg, NULL); + "-server %(irc_servers) %(nicks)|*" + " || %(nicks)|*", + &irc_command_msg, NULL, NULL); weechat_hook_command ( "names", N_("list nicks on channels"), N_("[<channel>[,<channel>...]]"), N_("channel: channel name"), - "%(irc_channels)", &irc_command_names, NULL); + "%(irc_channels)", &irc_command_names, NULL, NULL); weechat_hook_command ( "nick", N_("change current nick"), @@ -6421,7 +6480,7 @@ irc_command_init () "nick: new nick"), "-all %(irc_server_nick)" " || %(irc_server_nick)", - &irc_command_nick, NULL); + &irc_command_nick, NULL, NULL); weechat_hook_command ( "notice", N_("send notice message to user"), @@ -6431,7 +6490,7 @@ irc_command_init () " text: text to send"), "-server %(irc_servers) %(nicks)" " || %(nicks)", - &irc_command_notice, NULL); + &irc_command_notice, NULL, NULL); weechat_hook_command ( "notify", N_("add a notification for presence or away status of nicks on servers"), @@ -6457,42 +6516,42 @@ irc_command_init () " /notify add toto freenode -away"), "add %(irc_channel_nicks) %(irc_servers) -away %-" " || del -all|%(irc_notify_nicks) %(irc_servers) %-", - &irc_command_notify, NULL); + &irc_command_notify, NULL, NULL); weechat_hook_command ( "op", N_("give channel operator status to nick(s)"), N_("<nick> [<nick>...] || * -yes"), N_("nick: nick or mask (wildcard \"*\" is allowed)\n" " *: give channel operator status to everybody on channel"), - "%(nicks)|%*", &irc_command_op, NULL); + "%(nicks)|%*", &irc_command_op, NULL, NULL); weechat_hook_command ( "oper", N_("get operator privileges"), N_("<user> <password>"), N_(" user: user\n" "password: password"), - NULL, &irc_command_oper, NULL); + NULL, &irc_command_oper, NULL, NULL); weechat_hook_command ( "part", N_("leave a channel"), N_("[<channel>[,<channel>...]] [<message>]"), N_("channel: channel name to leave\n" "message: part message (displayed to other users)"), - "%(irc_msg_part)", &irc_command_part, NULL); + "%(irc_msg_part)", &irc_command_part, NULL, NULL); weechat_hook_command ( "ping", N_("send a ping to server"), N_("<server1> [<server2>]"), N_("server1: server\n" "server2: forward ping to this server"), - NULL, &irc_command_ping, NULL); + NULL, &irc_command_ping, NULL, NULL); weechat_hook_command ( "pong", N_("answer to a ping message"), N_("<daemon> [<daemon2>]"), N_(" daemon: daemon who has responded to Ping message\n" "daemon2: forward message to this daemon"), - NULL, &irc_command_pong, NULL); + NULL, &irc_command_pong, NULL, NULL); weechat_hook_command ( "query", N_("send a private message to a nick"), @@ -6503,7 +6562,7 @@ irc_command_init () " text: text to send"), "-noswitch|-server %(irc_servers) %(nicks)" " || %(nicks)", - &irc_command_query, NULL); + &irc_command_query, NULL, NULL); weechat_hook_command ( "quiet", N_("quiet nicks or hosts"), @@ -6511,16 +6570,16 @@ irc_command_init () N_("channel: channel name\n" " nick: nick or host\n" "\n" - "Without argument, this command display quiet list for current " - "channel."), - "%(irc_channel_nicks_hosts)", &irc_command_quiet, NULL); + "Without argument, this command displays the quiet list for " + "current channel."), + "%(irc_channel_nicks_hosts)", &irc_command_quiet, NULL, NULL); weechat_hook_command ( "quote", N_("send raw data to server without parsing"), N_("[-server <server>] <data>"), N_("server: send to this server (internal name)\n" " data: raw data to send"), - "-server %(irc_servers)", &irc_command_quote, NULL); + "-server %(irc_servers)", &irc_command_quote, NULL, NULL); weechat_hook_command ( "reconnect", N_("reconnect to server(s)"), @@ -6532,13 +6591,13 @@ irc_command_init () "server)\n" "-switch: switch to next server address"), "%(irc_servers)|-all|-nojoin|-switch|%*", - &irc_command_reconnect, NULL); + &irc_command_reconnect, NULL, NULL); weechat_hook_command ( "rehash", N_("tell the server to reload its config file"), N_("[<option>]"), N_("option: extra option, for some servers"), - NULL, &irc_command_rehash, NULL); + NULL, &irc_command_rehash, NULL, NULL); weechat_hook_command ( "remove", N_("force a user to leave a channel"), @@ -6547,55 +6606,55 @@ irc_command_init () " nick: nick\n" " reason: reason (special variables $nick, $channel and $server are " "replaced by their value)"), - "%(irc_channel)|%(nicks) %(nicks)", &irc_command_remove, NULL); + "%(irc_channel)|%(nicks) %(nicks)", &irc_command_remove, NULL, NULL); weechat_hook_command ( "restart", N_("tell the server to restart itself"), N_("[<target>]"), N_("target: server name"), - NULL, &irc_command_restart, NULL); + NULL, &irc_command_restart, NULL, NULL); weechat_hook_command ( "sajoin", N_("force a user to join channel(s)"), N_("<nick> <channel>[,<channel>...]"), N_(" nick: nick\n" "channel: channel name"), - "%(nicks) %(irc_server_channels)", &irc_command_sajoin, NULL); + "%(nicks) %(irc_server_channels)", &irc_command_sajoin, NULL, NULL); weechat_hook_command ( "samode", N_("change mode on channel, without having operator status"), N_("[<channel>] <mode>"), N_("channel: channel name\n" " mode: mode for channel"), - "%(irc_server_channels)", &irc_command_samode, NULL); + "%(irc_server_channels)", &irc_command_samode, NULL, NULL); weechat_hook_command ( "sanick", N_("force a user to use another nick"), N_("<nick> <new_nick>"), N_(" nick: nick\n" "new_nick: new nick"), - "%(nicks) %(nicks)", &irc_command_sanick, NULL); + "%(nicks) %(nicks)", &irc_command_sanick, NULL, NULL); weechat_hook_command ( "sapart", N_("force a user to leave channel(s)"), N_("<nick> <channel>[,<channel>...]"), N_(" nick: nick\n" "channel: channel name"), - "%(nicks) %(irc_server_channels)", &irc_command_sapart, NULL); + "%(nicks) %(irc_server_channels)", &irc_command_sapart, NULL, NULL); weechat_hook_command ( "saquit", N_("force a user to quit server with a reason"), N_("<nick> <reason>"), N_(" nick: nick\n" "reason: reason"), - "%(nicks)", &irc_command_saquit, NULL); + "%(nicks)", &irc_command_saquit, NULL, NULL); weechat_hook_command ( "service", N_("register a new service"), N_("<nick> <reserved> <distribution> <type> <reserved> <info>"), N_("distribution: visibility of service\n" " type: reserved for future usage"), - NULL, &irc_command_service, NULL); + NULL, &irc_command_service, NULL, NULL); weechat_hook_command ( "server", N_("list, add or remove IRC servers"), @@ -6648,35 +6707,35 @@ irc_command_init () " || deloutq" " || jump" " || raw", - &irc_command_server, NULL); + &irc_command_server, NULL, NULL); weechat_hook_command ( "servlist", N_("list services currently connected to the network"), N_("[<mask> [<type>]]"), N_("mask: list only services matching this mask\n" "type: list only services of this type"), - NULL, &irc_command_servlist, NULL); + NULL, &irc_command_servlist, NULL, NULL); weechat_hook_command ( "squery", N_("deliver a message to a service"), N_("<service> <text>"), N_("service: name of service\n" " text: text to send"), - NULL, &irc_command_squery, NULL); + NULL, &irc_command_squery, NULL, NULL); weechat_hook_command ( "squit", N_("disconnect server links"), N_("<server> <comment>"), N_( " server: server name\n" "comment: comment"), - NULL, &irc_command_squit, NULL); + NULL, &irc_command_squit, NULL, NULL); weechat_hook_command ( "stats", N_("query statistics about server"), N_("[<query> [<server>]]"), N_(" query: c/h/i/k/l/m/o/y/u (see RFC1459)\n" "server: server name"), - NULL, &irc_command_stats, NULL); + NULL, &irc_command_stats, NULL, NULL); weechat_hook_command ( "summon", N_("give users who are on a host running an IRC " @@ -6686,13 +6745,13 @@ irc_command_init () N_(" user: username\n" " target: server name\n" "channel: channel name"), - NULL, &irc_command_summon, NULL); + NULL, &irc_command_summon, NULL, NULL); weechat_hook_command ( "time", N_("query local time from server"), N_("[<target>]"), N_("target: query time from specified server"), - NULL, &irc_command_time, NULL); + NULL, &irc_command_time, NULL, NULL); weechat_hook_command ( "topic", N_("get/set channel topic"), @@ -6700,74 +6759,74 @@ irc_command_init () N_("channel: channel name\n" " topic: new topic\n" "-delete: delete channel topic"), - "%(irc_channel_topic)|-delete", &irc_command_topic, NULL); + "%(irc_channel_topic)|-delete", &irc_command_topic, NULL, NULL); weechat_hook_command ( "trace", N_("find the route to specific server"), N_("[<target>]"), N_("target: server name"), - NULL, &irc_command_trace, NULL); + NULL, &irc_command_trace, NULL, NULL); weechat_hook_command ( "unban", N_("unban nicks or hosts"), N_("[<channel>] <nick> [<nick>...]"), N_("channel: channel name\n" " nick: nick or host"), - NULL, &irc_command_unban, NULL); + NULL, &irc_command_unban, NULL, NULL); weechat_hook_command ( "unquiet", N_("unquiet nicks or hosts"), N_("[<channel>] <nick> [<nick>...]"), N_("channel: channel name\n" " nick: nick or host"), - "%(irc_channel_nicks_hosts)", &irc_command_unquiet, NULL); + "%(irc_channel_nicks_hosts)", &irc_command_unquiet, NULL, NULL); weechat_hook_command ( "userhost", N_("return a list of information about nicks"), N_("<nick> [<nick>...]"), N_("nick: nick"), - "%(nicks)", &irc_command_userhost, NULL); + "%(nicks)", &irc_command_userhost, NULL, NULL); weechat_hook_command ( "users", N_("list of users logged into the server"), N_("[<target>]"), N_("target: server name"), - NULL, &irc_command_users, NULL); + NULL, &irc_command_users, NULL, NULL); weechat_hook_command ( "version", N_("give the version info of nick or server (current or specified)"), N_("[<server>|<nick>]"), N_("server: server name\n" " nick: nick"), - "%(nicks)", &irc_command_version, NULL); + "%(nicks)", &irc_command_version, NULL, NULL); weechat_hook_command ( "voice", N_("give voice to nick(s)"), N_("<nick> [<nick>...]"), N_("nick: nick or mask (wildcard \"*\" is allowed)\n" " *: give voice to everybody on channel"), - "%(nicks)|%*", &irc_command_voice, NULL); + "%(nicks)|%*", &irc_command_voice, NULL, NULL); weechat_hook_command ( "wallchops", N_("send a notice to channel ops"), N_("[<channel>] <text>"), N_("channel: channel name\n" " text: text to send"), - NULL, &irc_command_wallchops, NULL); + NULL, &irc_command_wallchops, NULL, NULL); weechat_hook_command ( "wallops", N_("send a message to all currently connected users who have set the " "'w' user mode for themselves"), N_("<text>"), N_("text: text to send"), - NULL, &irc_command_wallops, NULL); + NULL, &irc_command_wallops, NULL, NULL); weechat_hook_command ( "who", N_("generate a query which returns a list of information"), N_("[<mask> [o]]"), N_("mask: only information which match this mask\n" " o: only operators are returned according to the mask supplied"), - "%(irc_channels)", &irc_command_who, NULL); + "%(irc_channels)", &irc_command_who, NULL, NULL); weechat_hook_command ( "whois", N_("query information about user(s)"), @@ -6781,7 +6840,7 @@ irc_command_init () "\n" "If option irc.network.whois_double_nick is enabled, two nicks are " "sent (if only one nick is given), to get idle time in answer."), - "%(nicks)", &irc_command_whois, NULL); + "%(nicks)", &irc_command_whois, NULL, NULL); weechat_hook_command ( "whowas", N_("ask for information about a nick which no longer exists"), @@ -6790,5 +6849,5 @@ irc_command_init () " count: number of replies to return (full search if negative " "number)\n" "target: reply should match this mask"), - "%(nicks)", &irc_command_whowas, NULL); + "%(nicks)", &irc_command_whowas, NULL, NULL); } diff --git a/src/plugins/irc/irc-command.h b/src/plugins/irc/irc-command.h index acedfa926..196394755 100644 --- a/src/plugins/irc/irc-command.h +++ b/src/plugins/irc/irc-command.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org> + * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org> * * This file is part of WeeChat, the extensible chat client. * @@ -23,6 +23,12 @@ struct t_irc_server; struct t_irc_channel; +#define IRC_COMMAND_CALLBACK(__command) \ + int \ + irc_command_##__command (const void *pointer, void *data, \ + struct t_gui_buffer *buffer, \ + int argc, char **argv, char **argv_eol) + #define IRC_COMMAND_CHECK_SERVER(__command, __check_connection) \ if (!ptr_server) \ { \ @@ -43,6 +49,15 @@ struct t_irc_channel; return WEECHAT_RC_OK; \ } +/* list of supported capabilities (for completion in command /cap) */ +#define IRC_COMMAND_CAP_SUPPORTED_COMPLETION \ + "account-notify|away-notify|cap-notify|extended-join|" \ + "multi-prefix|server-time|userhost-in-names|%*" + +/* list of supported CTCPs (for completion in command /ctcp) */ +#define IRC_COMMAND_CTCP_SUPPORTED_COMPLETION \ + "action|clientinfo|finger|ping|source|time|userinfo|version" + extern void irc_command_away_server (struct t_irc_server *server, const char *arguments, int reset_unread_marker); diff --git a/src/plugins/irc/irc-completion.c b/src/plugins/irc/irc-completion.c index 831429fe9..56b2bf21e 100644 --- a/src/plugins/irc/irc-completion.c +++ b/src/plugins/irc/irc-completion.c @@ -1,7 +1,7 @@ /* * irc-completion.c - completion for IRC commands * - * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org> + * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org> * * This file is part of WeeChat, the extensible chat client. * @@ -41,13 +41,15 @@ */ int -irc_completion_server_cb (void *data, const char *completion_item, +irc_completion_server_cb (const void *pointer, void *data, + const char *completion_item, struct t_gui_buffer *buffer, struct t_gui_completion *completion) { IRC_BUFFER_GET_SERVER(buffer); /* make C compiler happy */ + (void) pointer; (void) data; (void) completion_item; @@ -65,13 +67,15 @@ irc_completion_server_cb (void *data, const char *completion_item, */ int -irc_completion_server_nick_cb (void *data, const char *completion_item, +irc_completion_server_nick_cb (const void *pointer, void *data, + const char *completion_item, struct t_gui_buffer *buffer, struct t_gui_completion *completion) { IRC_BUFFER_GET_SERVER(buffer); /* make C compiler happy */ + (void) pointer; (void) data; (void) completion_item; @@ -89,30 +93,38 @@ irc_completion_server_nick_cb (void *data, const char *completion_item, */ int -irc_completion_server_channels_cb (void *data, const char *completion_item, +irc_completion_server_channels_cb (const void *pointer, void *data, + const char *completion_item, struct t_gui_buffer *buffer, struct t_gui_completion *completion) { - struct t_irc_channel *ptr_channel; + struct t_irc_channel *ptr_channel2; - IRC_BUFFER_GET_SERVER(buffer); + IRC_BUFFER_GET_SERVER_CHANNEL(buffer); /* make C compiler happy */ + (void) pointer; (void) data; (void) completion_item; - (void) buffer; if (ptr_server) { - for (ptr_channel = ptr_server->channels; ptr_channel; - ptr_channel = ptr_channel->next_channel) + for (ptr_channel2 = ptr_server->channels; ptr_channel2; + ptr_channel2 = ptr_channel2->next_channel) { - if (ptr_channel->type == IRC_CHANNEL_TYPE_CHANNEL) + if (ptr_channel2->type == IRC_CHANNEL_TYPE_CHANNEL) { - weechat_hook_completion_list_add (completion, ptr_channel->name, + weechat_hook_completion_list_add (completion, ptr_channel2->name, 0, WEECHAT_LIST_POS_SORT); } } + + /* add current channel first in list */ + if (ptr_channel) + { + weechat_hook_completion_list_add (completion, ptr_channel->name, + 0, WEECHAT_LIST_POS_BEGINNING); + } } return WEECHAT_RC_OK; @@ -123,7 +135,8 @@ irc_completion_server_channels_cb (void *data, const char *completion_item, */ int -irc_completion_server_privates_cb (void *data, const char *completion_item, +irc_completion_server_privates_cb (const void *pointer, void *data, + const char *completion_item, struct t_gui_buffer *buffer, struct t_gui_completion *completion) { @@ -132,9 +145,9 @@ irc_completion_server_privates_cb (void *data, const char *completion_item, IRC_BUFFER_GET_SERVER(buffer); /* make C compiler happy */ + (void) pointer; (void) data; (void) completion_item; - (void) buffer; if (ptr_server) { @@ -157,7 +170,8 @@ irc_completion_server_privates_cb (void *data, const char *completion_item, */ int -irc_completion_server_nicks_cb (void *data, const char *completion_item, +irc_completion_server_nicks_cb (const void *pointer, void *data, + const char *completion_item, struct t_gui_buffer *buffer, struct t_gui_completion *completion) { @@ -167,6 +181,7 @@ irc_completion_server_nicks_cb (void *data, const char *completion_item, IRC_BUFFER_GET_SERVER_CHANNEL(buffer); /* make C compiler happy */ + (void) pointer; (void) data; (void) completion_item; @@ -199,13 +214,15 @@ irc_completion_server_nicks_cb (void *data, const char *completion_item, */ int -irc_completion_servers_cb (void *data, const char *completion_item, +irc_completion_servers_cb (const void *pointer, void *data, + const char *completion_item, struct t_gui_buffer *buffer, struct t_gui_completion *completion) { struct t_irc_server *ptr_server; /* make C compiler happy */ + (void) pointer; (void) data; (void) completion_item; (void) buffer; @@ -225,13 +242,15 @@ irc_completion_servers_cb (void *data, const char *completion_item, */ int -irc_completion_channel_cb (void *data, const char *completion_item, +irc_completion_channel_cb (const void *pointer, void *data, + const char *completion_item, struct t_gui_buffer *buffer, struct t_gui_completion *completion) { IRC_BUFFER_GET_SERVER_CHANNEL(buffer); /* make C compiler happy */ + (void) pointer; (void) data; (void) completion_item; @@ -280,7 +299,8 @@ irc_completion_channel_nicks_add_speakers (struct t_gui_completion *completion, */ int -irc_completion_channel_nicks_cb (void *data, const char *completion_item, +irc_completion_channel_nicks_cb (const void *pointer, void *data, + const char *completion_item, struct t_gui_buffer *buffer, struct t_gui_completion *completion) { @@ -289,6 +309,7 @@ irc_completion_channel_nicks_cb (void *data, const char *completion_item, IRC_BUFFER_GET_SERVER_CHANNEL(buffer); /* make C compiler happy */ + (void) pointer; (void) data; (void) completion_item; @@ -345,7 +366,8 @@ irc_completion_channel_nicks_cb (void *data, const char *completion_item, */ int -irc_completion_channel_nicks_hosts_cb (void *data, const char *completion_item, +irc_completion_channel_nicks_hosts_cb (const void *pointer, void *data, + const char *completion_item, struct t_gui_buffer *buffer, struct t_gui_completion *completion) { @@ -356,6 +378,7 @@ irc_completion_channel_nicks_hosts_cb (void *data, const char *completion_item, IRC_BUFFER_GET_SERVER_CHANNEL(buffer); /* make C compiler happy */ + (void) pointer; (void) data; (void) completion_item; @@ -402,7 +425,8 @@ irc_completion_channel_nicks_hosts_cb (void *data, const char *completion_item, */ int -irc_completion_channel_topic_cb (void *data, const char *completion_item, +irc_completion_channel_topic_cb (const void *pointer, void *data, + const char *completion_item, struct t_gui_buffer *buffer, struct t_gui_completion *completion) { @@ -412,6 +436,7 @@ irc_completion_channel_topic_cb (void *data, const char *completion_item, IRC_BUFFER_GET_SERVER_CHANNEL(buffer); /* make C compiler happy */ + (void) pointer; (void) data; (void) completion_item; @@ -454,32 +479,71 @@ irc_completion_channel_topic_cb (void *data, const char *completion_item, */ int -irc_completion_channels_cb (void *data, const char *completion_item, +irc_completion_channels_cb (const void *pointer, void *data, + const char *completion_item, struct t_gui_buffer *buffer, struct t_gui_completion *completion) { - struct t_irc_server *ptr_server; - struct t_irc_channel *ptr_channel; + struct t_irc_server *ptr_server2; + struct t_irc_channel *ptr_channel2; + struct t_weelist *channels_current_server; + int i; + + IRC_BUFFER_GET_SERVER_CHANNEL(buffer); /* make C compiler happy */ + (void) pointer; (void) data; (void) completion_item; - (void) buffer; - for (ptr_server = irc_servers; ptr_server; - ptr_server = ptr_server->next_server) + channels_current_server = weechat_list_new (); + + for (ptr_server2 = irc_servers; ptr_server2; + ptr_server2 = ptr_server2->next_server) { - for (ptr_channel = ptr_server->channels; ptr_channel; - ptr_channel = ptr_channel->next_channel) + for (ptr_channel2 = ptr_server2->channels; ptr_channel2; + ptr_channel2 = ptr_channel2->next_channel) { - if (ptr_channel->type == IRC_CHANNEL_TYPE_CHANNEL) + if (ptr_channel2->type == IRC_CHANNEL_TYPE_CHANNEL) { - weechat_hook_completion_list_add (completion, ptr_channel->name, - 0, WEECHAT_LIST_POS_SORT); + if (ptr_server2 == ptr_server) + { + /* will be added later to completions */ + weechat_list_add (channels_current_server, + ptr_channel2->name, + WEECHAT_LIST_POS_SORT, + NULL); + } + else + { + weechat_hook_completion_list_add (completion, + ptr_channel2->name, + 0, + WEECHAT_LIST_POS_SORT); + } } } } + /* add channels of current server first in list */ + for (i = weechat_list_size (channels_current_server) - 1; i >= 0; i--) + { + weechat_hook_completion_list_add ( + completion, + weechat_list_string ( + weechat_list_get (channels_current_server, i)), + 0, + WEECHAT_LIST_POS_BEGINNING); + } + weechat_list_free (channels_current_server); + + /* add current channel first in list */ + if (ptr_channel) + { + weechat_hook_completion_list_add (completion, ptr_channel->name, + 0, WEECHAT_LIST_POS_BEGINNING); + } + return WEECHAT_RC_OK; } @@ -488,7 +552,8 @@ irc_completion_channels_cb (void *data, const char *completion_item, */ int -irc_completion_privates_cb (void *data, const char *completion_item, +irc_completion_privates_cb (const void *pointer, void *data, + const char *completion_item, struct t_gui_buffer *buffer, struct t_gui_completion *completion) { @@ -496,6 +561,7 @@ irc_completion_privates_cb (void *data, const char *completion_item, struct t_irc_channel *ptr_channel; /* make C compiler happy */ + (void) pointer; (void) data; (void) completion_item; (void) buffer; @@ -522,7 +588,8 @@ irc_completion_privates_cb (void *data, const char *completion_item, */ int -irc_completion_msg_kick_cb (void *data, const char *completion_item, +irc_completion_msg_kick_cb (const void *pointer, void *data, + const char *completion_item, struct t_gui_buffer *buffer, struct t_gui_completion *completion) { @@ -531,13 +598,14 @@ irc_completion_msg_kick_cb (void *data, const char *completion_item, IRC_BUFFER_GET_SERVER(buffer); /* make C compiler happy */ + (void) pointer; (void) data; (void) completion_item; if (ptr_server) { msg_kick = IRC_SERVER_OPTION_STRING(ptr_server, - IRC_SERVER_OPTION_DEFAULT_MSG_KICK); + IRC_SERVER_OPTION_MSG_KICK); if (msg_kick && msg_kick[0]) { weechat_hook_completion_list_add (completion, msg_kick, @@ -553,7 +621,8 @@ irc_completion_msg_kick_cb (void *data, const char *completion_item, */ int -irc_completion_msg_part_cb (void *data, const char *completion_item, +irc_completion_msg_part_cb (const void *pointer, void *data, + const char *completion_item, struct t_gui_buffer *buffer, struct t_gui_completion *completion) { @@ -562,13 +631,14 @@ irc_completion_msg_part_cb (void *data, const char *completion_item, IRC_BUFFER_GET_SERVER(buffer); /* make C compiler happy */ + (void) pointer; (void) data; (void) completion_item; if (ptr_server) { msg_part = IRC_SERVER_OPTION_STRING(ptr_server, - IRC_SERVER_OPTION_DEFAULT_MSG_PART); + IRC_SERVER_OPTION_MSG_PART); if (msg_part && msg_part[0]) { weechat_hook_completion_list_add (completion, msg_part, @@ -584,7 +654,8 @@ irc_completion_msg_part_cb (void *data, const char *completion_item, */ int -irc_completion_ignores_numbers_cb (void *data, const char *completion_item, +irc_completion_ignores_numbers_cb (const void *pointer, void *data, + const char *completion_item, struct t_gui_buffer *buffer, struct t_gui_completion *completion) { @@ -592,6 +663,7 @@ irc_completion_ignores_numbers_cb (void *data, const char *completion_item, char str_number[32]; /* make C compiler happy */ + (void) pointer; (void) data; (void) completion_item; (void) buffer; @@ -612,7 +684,8 @@ irc_completion_ignores_numbers_cb (void *data, const char *completion_item, */ int -irc_completion_notify_nicks_cb (void *data, const char *completion_item, +irc_completion_notify_nicks_cb (const void *pointer, void *data, + const char *completion_item, struct t_gui_buffer *buffer, struct t_gui_completion *completion) { @@ -621,6 +694,7 @@ irc_completion_notify_nicks_cb (void *data, const char *completion_item, IRC_BUFFER_GET_SERVER(buffer); /* make C compiler happy */ + (void) pointer; (void) data; (void) completion_item; @@ -659,50 +733,50 @@ irc_completion_init () { weechat_hook_completion ("irc_server", N_("current IRC server"), - &irc_completion_server_cb, NULL); + &irc_completion_server_cb, NULL, NULL); weechat_hook_completion ("irc_server_nick", N_("nick on current IRC server"), - &irc_completion_server_nick_cb, NULL); + &irc_completion_server_nick_cb, NULL, NULL); weechat_hook_completion ("irc_server_channels", N_("channels on current IRC server"), - &irc_completion_server_channels_cb, NULL); + &irc_completion_server_channels_cb, NULL, NULL); weechat_hook_completion ("irc_server_privates", N_("privates on current IRC server"), - &irc_completion_server_privates_cb, NULL); + &irc_completion_server_privates_cb, NULL, NULL); weechat_hook_completion ("irc_server_nicks", N_("nicks on all channels of current IRC server"), - &irc_completion_server_nicks_cb, NULL); + &irc_completion_server_nicks_cb, NULL, NULL); weechat_hook_completion ("irc_servers", N_("IRC servers (internal names)"), - &irc_completion_servers_cb, NULL); + &irc_completion_servers_cb, NULL, NULL); weechat_hook_completion ("irc_channel", N_("current IRC channel"), - &irc_completion_channel_cb, NULL); + &irc_completion_channel_cb, NULL, NULL); weechat_hook_completion ("nick", N_("nicks of current IRC channel"), - &irc_completion_channel_nicks_cb, NULL); + &irc_completion_channel_nicks_cb, NULL, NULL); weechat_hook_completion ("irc_channel_nicks_hosts", N_("nicks and hostnames of current IRC channel"), - &irc_completion_channel_nicks_hosts_cb, NULL); + &irc_completion_channel_nicks_hosts_cb, NULL, NULL); weechat_hook_completion ("irc_channel_topic", N_("topic of current IRC channel"), - &irc_completion_channel_topic_cb, NULL); + &irc_completion_channel_topic_cb, NULL, NULL); weechat_hook_completion ("irc_channels", N_("channels on all IRC servers"), - &irc_completion_channels_cb, NULL); + &irc_completion_channels_cb, NULL, NULL); weechat_hook_completion ("irc_privates", N_("privates on all IRC servers"), - &irc_completion_privates_cb, NULL); + &irc_completion_privates_cb, NULL, NULL); weechat_hook_completion ("irc_msg_kick", N_("default kick message"), - &irc_completion_msg_kick_cb, NULL); + &irc_completion_msg_kick_cb, NULL, NULL); weechat_hook_completion ("irc_msg_part", N_("default part message for IRC channel"), - &irc_completion_msg_part_cb, NULL); + &irc_completion_msg_part_cb, NULL, NULL); weechat_hook_completion ("irc_ignores_numbers", N_("numbers for defined ignores"), - &irc_completion_ignores_numbers_cb, NULL); + &irc_completion_ignores_numbers_cb, NULL, NULL); weechat_hook_completion ("irc_notify_nicks", N_("nicks in notify list"), - &irc_completion_notify_nicks_cb, NULL); + &irc_completion_notify_nicks_cb, NULL, NULL); } diff --git a/src/plugins/irc/irc-completion.h b/src/plugins/irc/irc-completion.h index aa2eb1a6f..20dacb576 100644 --- a/src/plugins/irc/irc-completion.h +++ b/src/plugins/irc/irc-completion.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org> + * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org> * * This file is part of WeeChat, the extensible chat client. * diff --git a/src/plugins/irc/irc-config.c b/src/plugins/irc/irc-config.c index 6828834fe..d4acd7ba3 100644 --- a/src/plugins/irc/irc-config.c +++ b/src/plugins/irc/irc-config.c @@ -1,7 +1,7 @@ /* * irc-config.c - IRC configuration options (file irc.conf) * - * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org> + * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org> * * This file is part of WeeChat, the extensible chat client. * @@ -75,7 +75,6 @@ struct t_config_option *irc_config_look_highlight_channel; struct t_config_option *irc_config_look_highlight_pv; struct t_config_option *irc_config_look_highlight_server; struct t_config_option *irc_config_look_highlight_tags_restrict; -struct t_config_option *irc_config_look_item_away_message; struct t_config_option *irc_config_look_item_channel_modes_hide_args; struct t_config_option *irc_config_look_item_display_server; struct t_config_option *irc_config_look_item_nick_modes; @@ -84,9 +83,6 @@ struct t_config_option *irc_config_look_join_auto_add_chantype; struct t_config_option *irc_config_look_msgbuffer_fallback; struct t_config_option *irc_config_look_new_channel_position; struct t_config_option *irc_config_look_new_pv_position; -struct t_config_option *irc_config_look_nick_color_force; -struct t_config_option *irc_config_look_nick_color_hash; -struct t_config_option *irc_config_look_nick_color_stop_chars; struct t_config_option *irc_config_look_nick_completion_smart; struct t_config_option *irc_config_look_nick_mode; struct t_config_option *irc_config_look_nick_mode_empty; @@ -114,7 +110,6 @@ struct t_config_option *irc_config_look_topic_strip_colors; /* IRC config, color section */ struct t_config_option *irc_config_color_input_nick; -struct t_config_option *irc_config_color_item_away; struct t_config_option *irc_config_color_item_channel_modes; struct t_config_option *irc_config_color_item_lag_counting; struct t_config_option *irc_config_color_item_lag_finished; @@ -131,7 +126,6 @@ struct t_config_option *irc_config_color_topic_old; /* IRC config, network section */ -struct t_config_option *irc_config_network_alternate_nick; struct t_config_option *irc_config_network_autoreconnect_delay_growing; struct t_config_option *irc_config_network_autoreconnect_delay_max; struct t_config_option *irc_config_network_ban_mask_default; @@ -145,6 +139,7 @@ struct t_config_option *irc_config_network_lag_reconnect; struct t_config_option *irc_config_network_lag_refresh_interval; struct t_config_option *irc_config_network_notify_check_ison; struct t_config_option *irc_config_network_notify_check_whois; +struct t_config_option *irc_config_network_sasl_fail_unavailable; struct t_config_option *irc_config_network_send_unknown_commands; struct t_config_option *irc_config_network_whois_double_nick; @@ -152,11 +147,9 @@ struct t_config_option *irc_config_network_whois_double_nick; struct t_config_option *irc_config_server_default[IRC_SERVER_NUM_OPTIONS]; -struct t_hook *irc_config_hook_config_nick_colors = NULL; -char **irc_config_nick_colors = NULL; -int irc_config_num_nick_colors = 0; +struct t_hook *irc_config_hook_config_nick_color_options = NULL; +struct t_hook *irc_config_hook_config_chat_nick_colors = NULL; struct t_hashtable *irc_config_hashtable_display_join_message = NULL; -struct t_hashtable *irc_config_hashtable_nick_color_force = NULL; struct t_hashtable *irc_config_hashtable_nick_prefixes = NULL; struct t_hashtable *irc_config_hashtable_color_mirc_remap = NULL; char **irc_config_nicks_hide_password = NULL; @@ -236,28 +229,6 @@ irc_config_compute_nick_colors () } /* - * Sets nick colors using option "weechat.color.chat_nick_colors". - */ - -void -irc_config_set_nick_colors () -{ - if (irc_config_nick_colors) - { - weechat_string_free_split (irc_config_nick_colors); - irc_config_nick_colors = NULL; - irc_config_num_nick_colors = 0; - } - - irc_config_nick_colors = - weechat_string_split ( - weechat_config_string ( - weechat_config_get ("weechat.color.chat_nick_colors")), - ",", 0, 0, - &irc_config_num_nick_colors); -} - -/* * Checks if channel modes arguments must be displayed or hidden * (according to option irc.look.item_channel_modes_hide_args). * @@ -297,19 +268,19 @@ irc_config_display_channel_modes_arguments (const char *modes) } /* - * Callback for changes on option "weechat.color.chat_nick_colors". + * Callback for changes on options changing nick colors. */ int -irc_config_change_nick_colors_cb (void *data, const char *option, - const char *value) +irc_config_change_nick_colors_cb (const void *pointer, void *data, + const char *option, const char *value) { /* make C compiler happy */ + (void) pointer; (void) data; (void) option; (void) value; - irc_config_set_nick_colors (); irc_config_compute_nick_colors (); return WEECHAT_RC_OK; @@ -320,10 +291,12 @@ irc_config_change_nick_colors_cb (void *data, const char *option, */ void -irc_config_change_look_color_nicks_in_nicklist (void *data, +irc_config_change_look_color_nicks_in_nicklist (const void *pointer, + void *data, struct t_config_option *option) { /* make C compiler happy */ + (void) pointer; (void) data; (void) option; @@ -335,10 +308,11 @@ irc_config_change_look_color_nicks_in_nicklist (void *data, */ void -irc_config_change_look_display_away (void *data, +irc_config_change_look_display_away (const void *pointer, void *data, struct t_config_option *option) { /* make C compiler happy */ + (void) pointer; (void) data; (void) option; @@ -360,13 +334,14 @@ irc_config_change_look_display_away (void *data, */ void -irc_config_change_look_display_join_message (void *data, +irc_config_change_look_display_join_message (const void *pointer, void *data, struct t_config_option *option) { char **items; int num_items, i; /* make C compiler happy */ + (void) pointer; (void) data; (void) option; @@ -376,8 +351,7 @@ irc_config_change_look_display_join_message (void *data, 32, WEECHAT_HASHTABLE_STRING, WEECHAT_HASHTABLE_STRING, - NULL, - NULL); + NULL, NULL); } else weechat_hashtable_remove_all (irc_config_hashtable_display_join_message); @@ -401,13 +375,14 @@ irc_config_change_look_display_join_message (void *data, */ void -irc_config_change_look_server_buffer (void *data, +irc_config_change_look_server_buffer (const void *pointer, void *data, struct t_config_option *option) { struct t_irc_server *ptr_server; struct t_gui_buffer *ptr_buffer; /* make C compiler happy */ + (void) pointer; (void) data; (void) option; @@ -447,7 +422,7 @@ irc_config_change_look_server_buffer (void *data, */ void -irc_config_change_look_pv_buffer (void *data, +irc_config_change_look_pv_buffer (const void *pointer, void *data, struct t_config_option *option) { struct t_irc_server *ptr_server; @@ -455,6 +430,7 @@ irc_config_change_look_pv_buffer (void *data, struct t_gui_buffer *ptr_buffer; /* make C compiler happy */ + (void) pointer; (void) data; (void) option; @@ -507,29 +483,16 @@ irc_config_change_look_pv_buffer (void *data, } /* - * Callback for changes on option "irc.look.item_away_message". - */ - -void -irc_config_change_look_item_away_message (void *data, - struct t_config_option *option) -{ - /* make C compiler happy */ - (void) data; - (void) option; - - weechat_bar_item_update ("away"); -} - -/* * Callback for changes on option "irc.look.item_channel_modes_hide_args". */ void -irc_config_change_look_item_channel_modes_hide_args (void *data, +irc_config_change_look_item_channel_modes_hide_args (const void *pointer, + void *data, struct t_config_option *option) { /* make C compiler happy */ + (void) pointer; (void) data; (void) option; @@ -541,13 +504,14 @@ irc_config_change_look_item_channel_modes_hide_args (void *data, */ void -irc_config_change_look_highlight_tags_restrict (void *data, +irc_config_change_look_highlight_tags_restrict (const void *pointer, void *data, struct t_config_option *option) { struct t_irc_server *ptr_server; struct t_irc_channel *ptr_channel; /* make C compiler happy */ + (void) pointer; (void) data; (void) option; @@ -574,78 +538,15 @@ irc_config_change_look_highlight_tags_restrict (void *data, } /* - * Callback for changes on option "irc.look.nick_color_force". - */ - -void -irc_config_change_look_nick_color_force (void *data, - struct t_config_option *option) -{ - char **items, *pos; - int num_items, i; - - /* make C compiler happy */ - (void) data; - (void) option; - - if (!irc_config_hashtable_nick_color_force) - { - irc_config_hashtable_nick_color_force = weechat_hashtable_new ( - 32, - WEECHAT_HASHTABLE_STRING, - WEECHAT_HASHTABLE_STRING, - NULL, - NULL); - } - else - weechat_hashtable_remove_all (irc_config_hashtable_nick_color_force); - - items = weechat_string_split ( - weechat_config_string (irc_config_look_nick_color_force), - ";", 0, 0, &num_items); - if (items) - { - for (i = 0; i < num_items; i++) - { - pos = strchr (items[i], ':'); - if (pos) - { - pos[0] = '\0'; - weechat_hashtable_set (irc_config_hashtable_nick_color_force, - items[i], - pos + 1); - } - } - weechat_string_free_split (items); - } - - irc_config_compute_nick_colors (); -} - -/* - * Callback for changes on options that change nick colors. - */ - -void -irc_config_change_look_nick_colors (void *data, - struct t_config_option *option) -{ - /* make C compiler happy */ - (void) data; - (void) option; - - irc_config_compute_nick_colors (); -} - -/* * Callback for changes on option "irc.look.item_display_server". */ void -irc_config_change_look_item_display_server (void *data, +irc_config_change_look_item_display_server (const void *pointer, void *data, struct t_config_option *option) { /* make C compiler happy */ + (void) pointer; (void) data; (void) option; @@ -659,12 +560,13 @@ irc_config_change_look_item_display_server (void *data, */ void -irc_config_change_look_nicks_hide_password (void *data, +irc_config_change_look_nicks_hide_password (const void *pointer, void *data, struct t_config_option *option) { const char *nicks_hide_password; /* make C compiler happy */ + (void) pointer; (void) data; (void) option; @@ -689,13 +591,14 @@ irc_config_change_look_nicks_hide_password (void *data, */ void -irc_config_change_look_topic_strip_colors (void *data, +irc_config_change_look_topic_strip_colors (const void *pointer, void *data, struct t_config_option *option) { struct t_irc_server *ptr_server; struct t_irc_channel *ptr_channel; /* make C compiler happy */ + (void) pointer; (void) data; (void) option; @@ -716,10 +619,11 @@ irc_config_change_look_topic_strip_colors (void *data, */ void -irc_config_change_bar_item_input_prompt (void *data, +irc_config_change_bar_item_input_prompt (const void *pointer, void *data, struct t_config_option *option) { /* make C compiler happy */ + (void) pointer; (void) data; (void) option; @@ -727,29 +631,15 @@ irc_config_change_bar_item_input_prompt (void *data, } /* - * Callback for changes on option "irc.color.item_away". - */ - -void -irc_config_change_color_item_away (void *data, - struct t_config_option *option) -{ - /* make C compiler happy */ - (void) data; - (void) option; - - weechat_bar_item_update ("away"); -} - -/* * Callback for changes on option "irc.color.item_channel_modes". */ void -irc_config_change_color_item_channel_modes (void *data, +irc_config_change_color_item_channel_modes (const void *pointer, void *data, struct t_config_option *option) { /* make C compiler happy */ + (void) pointer; (void) data; (void) option; @@ -762,10 +652,11 @@ irc_config_change_color_item_channel_modes (void *data, */ void -irc_config_change_color_item_lag (void *data, +irc_config_change_color_item_lag (const void *pointer, void *data, struct t_config_option *option) { /* make C compiler happy */ + (void) pointer; (void) data; (void) option; @@ -777,10 +668,11 @@ irc_config_change_color_item_lag (void *data, */ void -irc_config_change_color_item_nick_modes (void *data, +irc_config_change_color_item_nick_modes (const void *pointer, void *data, struct t_config_option *option) { /* make C compiler happy */ + (void) pointer; (void) data; (void) option; @@ -793,12 +685,14 @@ irc_config_change_color_item_nick_modes (void *data, */ void -irc_config_change_color_mirc_remap (void *data, struct t_config_option *option) +irc_config_change_color_mirc_remap (const void *pointer, void *data, + struct t_config_option *option) { char **items, *pos; int num_items, i; /* make C compiler happy */ + (void) pointer; (void) data; (void) option; @@ -808,8 +702,7 @@ irc_config_change_color_mirc_remap (void *data, struct t_config_option *option) 32, WEECHAT_HASHTABLE_STRING, WEECHAT_HASHTABLE_STRING, - NULL, - NULL); + NULL, NULL); } else weechat_hashtable_remove_all (irc_config_hashtable_color_mirc_remap); @@ -839,13 +732,14 @@ irc_config_change_color_mirc_remap (void *data, struct t_config_option *option) */ void -irc_config_change_color_nick_prefixes (void *data, +irc_config_change_color_nick_prefixes (const void *pointer, void *data, struct t_config_option *option) { char **items, *pos; int num_items, i; /* make C compiler happy */ + (void) pointer; (void) data; (void) option; @@ -855,8 +749,7 @@ irc_config_change_color_nick_prefixes (void *data, 32, WEECHAT_HASHTABLE_STRING, WEECHAT_HASHTABLE_STRING, - NULL, - NULL); + NULL, NULL); } else weechat_hashtable_remove_all (irc_config_hashtable_nick_prefixes); @@ -890,13 +783,14 @@ irc_config_change_color_nick_prefixes (void *data, */ void -irc_config_change_network_lag_check (void *data, +irc_config_change_network_lag_check (const void *pointer, void *data, struct t_config_option *option) { time_t time_next_check; struct t_irc_server *ptr_server; /* make C compiler happy */ + (void) pointer; (void) data; (void) option; @@ -916,10 +810,11 @@ irc_config_change_network_lag_check (void *data, */ void -irc_config_change_network_lag_min_show (void *data, +irc_config_change_network_lag_min_show (const void *pointer, void *data, struct t_config_option *option) { /* make C compiler happy */ + (void) pointer; (void) data; (void) option; @@ -931,10 +826,11 @@ irc_config_change_network_lag_min_show (void *data, */ void -irc_config_change_network_notify_check_ison (void *data, +irc_config_change_network_notify_check_ison (const void *pointer, void *data, struct t_config_option *option) { /* make C compiler happy */ + (void) pointer; (void) data; (void) option; @@ -946,10 +842,11 @@ irc_config_change_network_notify_check_ison (void *data, */ void -irc_config_change_network_notify_check_whois (void *data, - struct t_config_option *option) +irc_config_change_network_notify_check_whois (const void *pointer, void *data, + struct t_config_option *option) { /* make C compiler happy */ + (void) pointer; (void) data; (void) option; @@ -961,7 +858,8 @@ irc_config_change_network_notify_check_whois (void *data, */ void -irc_config_change_network_send_unknown_commands (void *data, +irc_config_change_network_send_unknown_commands (const void *pointer, + void *data, struct t_config_option *option) { char value[2]; @@ -969,6 +867,7 @@ irc_config_change_network_send_unknown_commands (void *data, struct t_irc_channel *ptr_channel; /* make C compiler happy */ + (void) pointer; (void) data; (void) option; @@ -1006,12 +905,16 @@ irc_config_change_network_send_unknown_commands (void *data, */ void -irc_config_server_default_change_cb (void *data, struct t_config_option *option) +irc_config_server_default_change_cb (const void *pointer, void *data, + struct t_config_option *option) { int index_option; struct t_irc_server *ptr_server; - index_option = irc_server_search_option (data); + /* make C compiler happy */ + (void) data; + + index_option = irc_server_search_option (pointer); if (index_option >= 0) { for (ptr_server = irc_servers; ptr_server; @@ -1086,7 +989,7 @@ irc_config_check_gnutls_priorities (const char *priorities) */ int -irc_config_server_check_value_cb (void *data, +irc_config_server_check_value_cb (const void *pointer, void *data, struct t_config_option *option, const char *value) { @@ -1099,9 +1002,10 @@ irc_config_server_check_value_cb (void *data, #endif /* HAVE_GNUTLS */ /* make C compiler happy */ + (void) data; (void) option; - index_option = irc_server_search_option (data); + index_option = irc_server_search_option (pointer); if (index_option >= 0) { switch (index_option) @@ -1217,13 +1121,17 @@ irc_config_server_check_value_cb (void *data, */ void -irc_config_server_change_cb (void *data, struct t_config_option *option) +irc_config_server_change_cb (const void *pointer, void *data, + struct t_config_option *option) { int index_option; char *name; struct t_irc_server *ptr_server; - index_option = irc_server_search_option (data); + /* make C compiler happy */ + (void) data; + + index_option = irc_server_search_option (pointer); if (index_option >= 0) { name = weechat_config_option_get_pointer (option, "name"); @@ -1272,11 +1180,12 @@ irc_config_server_change_cb (void *data, struct t_config_option *option) */ int -irc_config_server_default_check_notify (void *data, +irc_config_server_default_check_notify (const void *pointer, void *data, struct t_config_option *option, const char *value) { /* make C compiler happy */ + (void) pointer; (void) data; (void) option; @@ -1291,12 +1200,14 @@ irc_config_server_default_check_notify (void *data, */ int -irc_config_reload (void *data, struct t_config_file *config_file) +irc_config_reload (const void *pointer, void *data, + struct t_config_file *config_file) { int rc; struct t_irc_server *ptr_server, *next_server; /* make C compiler happy */ + (void) pointer; (void) data; for (ptr_server = irc_servers; ptr_server; @@ -1350,7 +1261,7 @@ irc_config_reload (void *data, struct t_config_file *config_file) */ int -irc_config_msgbuffer_create_option (void *data, +irc_config_msgbuffer_create_option (const void *pointer, void *data, struct t_config_file *config_file, struct t_config_section *section, const char *option_name, const char *value) @@ -1359,6 +1270,7 @@ irc_config_msgbuffer_create_option (void *data, int rc; /* make C compiler happy */ + (void) pointer; (void) data; rc = WEECHAT_CONFIG_OPTION_SET_ERROR; @@ -1387,7 +1299,7 @@ irc_config_msgbuffer_create_option (void *data, _("buffer used to display message received from IRC " "server"), "weechat|server|current|private", 0, 0, value, value, 0, - NULL, NULL, NULL, NULL, NULL, NULL); + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); rc = (ptr_option) ? WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE : WEECHAT_CONFIG_OPTION_SET_ERROR; @@ -1413,7 +1325,8 @@ irc_config_msgbuffer_create_option (void *data, */ int -irc_config_ctcp_create_option (void *data, struct t_config_file *config_file, +irc_config_ctcp_create_option (const void *pointer, void *data, + struct t_config_file *config_file, struct t_config_section *section, const char *option_name, const char *value) { @@ -1424,6 +1337,7 @@ irc_config_ctcp_create_option (void *data, struct t_config_file *config_file, const char *pos_name; /* make C compiler happy */ + (void) pointer; (void) data; rc = WEECHAT_CONFIG_OPTION_SET_ERROR; @@ -1467,7 +1381,7 @@ irc_config_ctcp_create_option (void *data, struct t_config_file *config_file, "$username (username on server), " "$realname (realname on server)"), NULL, 0, 0, default_value, value, 0, - NULL, NULL, NULL, NULL, NULL, NULL); + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); rc = (ptr_option) ? WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE : WEECHAT_CONFIG_OPTION_SET_ERROR; @@ -1497,7 +1411,7 @@ irc_config_ctcp_create_option (void *data, struct t_config_file *config_file, */ int -irc_config_ignore_read_cb (void *data, +irc_config_ignore_read_cb (const void *pointer, void *data, struct t_config_file *config_file, struct t_config_section *section, const char *option_name, const char *value) @@ -1506,6 +1420,7 @@ irc_config_ignore_read_cb (void *data, int argc; /* make C compiler happy */ + (void) pointer; (void) data; (void) config_file; (void) section; @@ -1535,12 +1450,14 @@ irc_config_ignore_read_cb (void *data, */ int -irc_config_ignore_write_cb (void *data, struct t_config_file *config_file, +irc_config_ignore_write_cb (const void *pointer, void *data, + struct t_config_file *config_file, const char *section_name) { struct t_irc_ignore *ptr_ignore; /* make C compiler happy */ + (void) pointer; (void) data; if (!weechat_config_write_line (config_file, section_name, NULL)) @@ -1575,12 +1492,16 @@ irc_config_server_new_option (struct t_config_file *config_file, const char *default_value, const char *value, int null_value_allowed, - int (*callback_check_value)(void *data, + int (*callback_check_value)(const void *pointer, + void *data, struct t_config_option *option, const char *value), + const void *callback_check_value_pointer, void *callback_check_value_data, - void (*callback_change)(void *data, + void (*callback_change)(const void *pointer, + void *data, struct t_config_option *option), + const void *callback_change_pointer, void *callback_change_data) { struct t_config_option *new_option; @@ -1594,13 +1515,18 @@ irc_config_server_new_option (struct t_config_file *config_file, config_file, section, option_name, "string", N_("list of hostname/port or IP/port for server (separated by " - "comma)"), + "comma) " + "(note: content is evaluated, see /help eval)"), NULL, 0, 0, default_value, value, null_value_allowed, - callback_check_value, callback_check_value_data, - callback_change, callback_change_data, - NULL, NULL); + callback_check_value, + callback_check_value_pointer, + callback_check_value_data, + callback_change, + callback_change_pointer, + callback_change_data, + NULL, NULL, NULL); break; case IRC_SERVER_OPTION_PROXY: new_option = weechat_config_new_option ( @@ -1611,9 +1537,13 @@ irc_config_server_new_option (struct t_config_file *config_file, NULL, 0, 0, default_value, value, null_value_allowed, - callback_check_value, callback_check_value_data, - callback_change, callback_change_data, - NULL, NULL); + callback_check_value, + callback_check_value_pointer, + callback_check_value_data, + callback_change, + callback_change_pointer, + callback_change_data, + NULL, NULL, NULL); break; case IRC_SERVER_OPTION_IPV6: new_option = weechat_config_new_option ( @@ -1624,9 +1554,13 @@ irc_config_server_new_option (struct t_config_file *config_file, NULL, 0, 0, default_value, value, null_value_allowed, - callback_check_value, callback_check_value_data, - callback_change, callback_change_data, - NULL, NULL); + callback_check_value, + callback_check_value_pointer, + callback_check_value_data, + callback_change, + callback_change_pointer, + callback_change_data, + NULL, NULL, NULL); break; case IRC_SERVER_OPTION_SSL: new_option = weechat_config_new_option ( @@ -1636,9 +1570,13 @@ irc_config_server_new_option (struct t_config_file *config_file, NULL, 0, 0, default_value, value, null_value_allowed, - callback_check_value, callback_check_value_data, - callback_change, callback_change_data, - NULL, NULL); + callback_check_value, + callback_check_value_pointer, + callback_check_value_data, + callback_change, + callback_change_pointer, + callback_change_data, + NULL, NULL, NULL); break; case IRC_SERVER_OPTION_SSL_CERT: new_option = weechat_config_new_option ( @@ -1650,9 +1588,13 @@ irc_config_server_new_option (struct t_config_file *config_file, NULL, 0, 0, default_value, value, null_value_allowed, - callback_check_value, callback_check_value_data, - callback_change, callback_change_data, - NULL, NULL); + callback_check_value, + callback_check_value_pointer, + callback_check_value_data, + callback_change, + callback_change_pointer, + callback_change_data, + NULL, NULL, NULL); break; case IRC_SERVER_OPTION_SSL_PRIORITIES: new_option = weechat_config_new_option ( @@ -1665,9 +1607,13 @@ irc_config_server_new_option (struct t_config_file *config_file, NULL, 0, 0, default_value, value, null_value_allowed, - callback_check_value, callback_check_value_data, - callback_change, callback_change_data, - NULL, NULL); + callback_check_value, + callback_check_value_pointer, + callback_check_value_data, + callback_change, + callback_change_pointer, + callback_change_data, + NULL, NULL, NULL); break; case IRC_SERVER_OPTION_SSL_DHKEY_SIZE: new_option = weechat_config_new_option ( @@ -1678,9 +1624,13 @@ irc_config_server_new_option (struct t_config_file *config_file, NULL, 0, INT_MAX, default_value, value, null_value_allowed, - callback_check_value, callback_check_value_data, - callback_change, callback_change_data, - NULL, NULL); + callback_check_value, + callback_check_value_pointer, + callback_check_value_data, + callback_change, + callback_change_pointer, + callback_change_data, + NULL, NULL, NULL); break; case IRC_SERVER_OPTION_SSL_FINGERPRINT: new_option = weechat_config_new_option ( @@ -1696,9 +1646,13 @@ irc_config_server_new_option (struct t_config_file *config_file, NULL, 0, 0, default_value, value, null_value_allowed, - callback_check_value, callback_check_value_data, - callback_change, callback_change_data, - NULL, NULL); + callback_check_value, + callback_check_value_pointer, + callback_check_value_data, + callback_change, + callback_change_pointer, + callback_change_data, + NULL, NULL, NULL); break; case IRC_SERVER_OPTION_SSL_VERIFY: new_option = weechat_config_new_option ( @@ -1708,9 +1662,13 @@ irc_config_server_new_option (struct t_config_file *config_file, NULL, 0, 0, default_value, value, null_value_allowed, - callback_check_value, callback_check_value_data, - callback_change, callback_change_data, - NULL, NULL); + callback_check_value, + callback_check_value_pointer, + callback_check_value_data, + callback_change, + callback_change_pointer, + callback_change_data, + NULL, NULL, NULL); break; case IRC_SERVER_OPTION_PASSWORD: new_option = weechat_config_new_option ( @@ -1721,9 +1679,13 @@ irc_config_server_new_option (struct t_config_file *config_file, NULL, 0, 0, default_value, value, null_value_allowed, - callback_check_value, callback_check_value_data, - callback_change, callback_change_data, - NULL, NULL); + callback_check_value, + callback_check_value_pointer, + callback_check_value_data, + callback_change, + callback_change_pointer, + callback_change_data, + NULL, NULL, NULL); break; case IRC_SERVER_OPTION_CAPABILITIES: new_option = weechat_config_new_option ( @@ -1731,16 +1693,19 @@ irc_config_server_new_option (struct t_config_file *config_file, option_name, "string", /* TRANSLATORS: please keep words "client capabilities" between brackets if translation is different (see fr.po) */ N_("comma-separated list of client capabilities to enable for " - "server if they are available; capabilities supported by " - "WeeChat are: account-notify, away-notify, extended-join, " - "multi-prefix, server-time, userhost-in-names (example: " - "\"away-notify,multi-prefix\")"), + "server if they are available (see /help cap for a list of " + "capabilities supported by WeeChat) " + "(example: \"away-notify,multi-prefix\")"), NULL, 0, 0, default_value, value, null_value_allowed, - callback_check_value, callback_check_value_data, - callback_change, callback_change_data, - NULL, NULL); + callback_check_value, + callback_check_value_pointer, + callback_check_value_data, + callback_change, + callback_change_pointer, + callback_change_data, + NULL, NULL, NULL); break; case IRC_SERVER_OPTION_SASL_MECHANISM: new_option = weechat_config_new_option ( @@ -1760,9 +1725,13 @@ irc_config_server_new_option (struct t_config_file *config_file, 0, 0, default_value, value, null_value_allowed, - callback_check_value, callback_check_value_data, - callback_change, callback_change_data, - NULL, NULL); + callback_check_value, + callback_check_value_pointer, + callback_check_value_data, + callback_change, + callback_change_pointer, + callback_change_data, + NULL, NULL, NULL); break; case IRC_SERVER_OPTION_SASL_USERNAME: new_option = weechat_config_new_option ( @@ -1774,9 +1743,13 @@ irc_config_server_new_option (struct t_config_file *config_file, NULL, 0, 0, default_value, value, null_value_allowed, - callback_check_value, callback_check_value_data, - callback_change, callback_change_data, - NULL, NULL); + callback_check_value, + callback_check_value_pointer, + callback_check_value_data, + callback_change, + callback_change_pointer, + callback_change_data, + NULL, NULL, NULL); break; case IRC_SERVER_OPTION_SASL_PASSWORD: new_option = weechat_config_new_option ( @@ -1789,9 +1762,13 @@ irc_config_server_new_option (struct t_config_file *config_file, NULL, 0, 0, default_value, value, null_value_allowed, - callback_check_value, callback_check_value_data, - callback_change, callback_change_data, - NULL, NULL); + callback_check_value, + callback_check_value_pointer, + callback_check_value_data, + callback_change, + callback_change_pointer, + callback_change_data, + NULL, NULL, NULL); break; case IRC_SERVER_OPTION_SASL_KEY: new_option = weechat_config_new_option ( @@ -1804,9 +1781,13 @@ irc_config_server_new_option (struct t_config_file *config_file, NULL, 0, 0, default_value, value, null_value_allowed, - callback_check_value, callback_check_value_data, - callback_change, callback_change_data, - NULL, NULL); + callback_check_value, + callback_check_value_pointer, + callback_check_value_data, + callback_change, + callback_change_pointer, + callback_change_data, + NULL, NULL, NULL); break; case IRC_SERVER_OPTION_SASL_TIMEOUT: new_option = weechat_config_new_option ( @@ -1817,9 +1798,13 @@ irc_config_server_new_option (struct t_config_file *config_file, NULL, 1, 3600, default_value, value, null_value_allowed, - callback_check_value, callback_check_value_data, - callback_change, callback_change_data, - NULL, NULL); + callback_check_value, + callback_check_value_pointer, + callback_check_value_data, + callback_change, + callback_change_pointer, + callback_change_data, + NULL, NULL, NULL); break; case IRC_SERVER_OPTION_SASL_FAIL: new_option = weechat_config_new_option ( @@ -1828,13 +1813,18 @@ irc_config_server_new_option (struct t_config_file *config_file, N_("action to perform if SASL authentication fails: " "\"continue\" to ignore the authentication problem, " "\"reconnect\" to schedule a reconnection to the server, " - "\"disconnect\" to disconnect from server"), + "\"disconnect\" to disconnect from server " + "(see also option irc.network.sasl_fail_unavailable)"), "continue|reconnect|disconnect", 0, 0, default_value, value, null_value_allowed, - callback_check_value, callback_check_value_data, - callback_change, callback_change_data, - NULL, NULL); + callback_check_value, + callback_check_value_pointer, + callback_check_value_data, + callback_change, + callback_change_pointer, + callback_change_data, + NULL, NULL, NULL); break; case IRC_SERVER_OPTION_AUTOCONNECT: new_option = weechat_config_new_option ( @@ -1844,9 +1834,13 @@ irc_config_server_new_option (struct t_config_file *config_file, NULL, 0, 0, default_value, value, null_value_allowed, - callback_check_value, callback_check_value_data, - callback_change, callback_change_data, - NULL, NULL); + callback_check_value, + callback_check_value_pointer, + callback_check_value_data, + callback_change, + callback_change_pointer, + callback_change_data, + NULL, NULL, NULL); break; case IRC_SERVER_OPTION_AUTORECONNECT: new_option = weechat_config_new_option ( @@ -1856,9 +1850,13 @@ irc_config_server_new_option (struct t_config_file *config_file, NULL, 0, 0, default_value, value, null_value_allowed, - callback_check_value, callback_check_value_data, - callback_change, callback_change_data, - NULL, NULL); + callback_check_value, + callback_check_value_pointer, + callback_check_value_data, + callback_change, + callback_change_pointer, + callback_change_data, + NULL, NULL, NULL); break; case IRC_SERVER_OPTION_AUTORECONNECT_DELAY: new_option = weechat_config_new_option ( @@ -1869,9 +1867,13 @@ irc_config_server_new_option (struct t_config_file *config_file, NULL, 1, 65535, default_value, value, null_value_allowed, - callback_check_value, callback_check_value_data, - callback_change, callback_change_data, - NULL, NULL); + callback_check_value, + callback_check_value_pointer, + callback_check_value_data, + callback_change, + callback_change_pointer, + callback_change_data, + NULL, NULL, NULL); break; case IRC_SERVER_OPTION_NICKS: new_option = weechat_config_new_option ( @@ -1882,9 +1884,33 @@ irc_config_server_new_option (struct t_config_file *config_file, NULL, 0, 0, default_value, value, null_value_allowed, - callback_check_value, callback_check_value_data, - callback_change, callback_change_data, - NULL, NULL); + callback_check_value, + callback_check_value_pointer, + callback_check_value_data, + callback_change, + callback_change_pointer, + callback_change_data, + NULL, NULL, NULL); + break; + case IRC_SERVER_OPTION_NICKS_ALTERNATE: + new_option = weechat_config_new_option ( + config_file, section, + option_name, "boolean", + N_("get an alternate nick when all the declared nicks are " + "already used on server: add some \"_\" until the nick has " + "a length of 9, and then replace last char (or the two " + "last chars) by a number from 1 to 99, until we find " + "a nick not used on server"), + NULL, 0, 0, + default_value, value, + null_value_allowed, + callback_check_value, + callback_check_value_pointer, + callback_check_value_data, + callback_change, + callback_change_pointer, + callback_change_data, + NULL, NULL, NULL); break; case IRC_SERVER_OPTION_USERNAME: new_option = weechat_config_new_option ( @@ -1895,9 +1921,13 @@ irc_config_server_new_option (struct t_config_file *config_file, NULL, 0, 0, default_value, value, null_value_allowed, - callback_check_value, callback_check_value_data, - callback_change, callback_change_data, - NULL, NULL); + callback_check_value, + callback_check_value_pointer, + callback_check_value_data, + callback_change, + callback_change_pointer, + callback_change_data, + NULL, NULL, NULL); break; case IRC_SERVER_OPTION_REALNAME: new_option = weechat_config_new_option ( @@ -1908,9 +1938,13 @@ irc_config_server_new_option (struct t_config_file *config_file, NULL, 0, 0, default_value, value, null_value_allowed, - callback_check_value, callback_check_value_data, - callback_change, callback_change_data, - NULL, NULL); + callback_check_value, + callback_check_value_pointer, + callback_check_value_data, + callback_change, + callback_change_pointer, + callback_change_data, + NULL, NULL, NULL); break; case IRC_SERVER_OPTION_LOCAL_HOSTNAME: new_option = weechat_config_new_option ( @@ -1921,9 +1955,13 @@ irc_config_server_new_option (struct t_config_file *config_file, NULL, 0, 0, default_value, value, null_value_allowed, - callback_check_value, callback_check_value_data, - callback_change, callback_change_data, - NULL, NULL); + callback_check_value, + callback_check_value_pointer, + callback_check_value_data, + callback_change, + callback_change_pointer, + callback_change_data, + NULL, NULL, NULL); break; case IRC_SERVER_OPTION_COMMAND: new_option = weechat_config_new_option ( @@ -1937,9 +1975,13 @@ irc_config_server_new_option (struct t_config_file *config_file, NULL, 0, 0, default_value, value, null_value_allowed, - callback_check_value, callback_check_value_data, - callback_change, callback_change_data, - NULL, NULL); + callback_check_value, + callback_check_value_pointer, + callback_check_value_data, + callback_change, + callback_change_pointer, + callback_change_data, + NULL, NULL, NULL); break; case IRC_SERVER_OPTION_COMMAND_DELAY: new_option = weechat_config_new_option ( @@ -1951,9 +1993,13 @@ irc_config_server_new_option (struct t_config_file *config_file, NULL, 0, 3600, default_value, value, null_value_allowed, - callback_check_value, callback_check_value_data, - callback_change, callback_change_data, - NULL, NULL); + callback_check_value, + callback_check_value_pointer, + callback_check_value_data, + callback_change, + callback_change_pointer, + callback_change_data, + NULL, NULL, NULL); break; case IRC_SERVER_OPTION_AUTOJOIN: new_option = weechat_config_new_option ( @@ -1970,9 +2016,13 @@ irc_config_server_new_option (struct t_config_file *config_file, NULL, 0, 0, default_value, value, null_value_allowed, - callback_check_value, callback_check_value_data, - callback_change, callback_change_data, - NULL, NULL); + callback_check_value, + callback_check_value_pointer, + callback_check_value_data, + callback_change, + callback_change_pointer, + callback_change_data, + NULL, NULL, NULL); break; case IRC_SERVER_OPTION_AUTOREJOIN: new_option = weechat_config_new_option ( @@ -1985,9 +2035,13 @@ irc_config_server_new_option (struct t_config_file *config_file, NULL, 0, 0, default_value, value, null_value_allowed, - callback_check_value, callback_check_value_data, - callback_change, callback_change_data, - NULL, NULL); + callback_check_value, + callback_check_value_pointer, + callback_check_value_data, + callback_change, + callback_change_pointer, + callback_change_data, + NULL, NULL, NULL); break; case IRC_SERVER_OPTION_AUTOREJOIN_DELAY: new_option = weechat_config_new_option ( @@ -1997,9 +2051,13 @@ irc_config_server_new_option (struct t_config_file *config_file, NULL, 0, 3600*24, default_value, value, null_value_allowed, - callback_check_value, callback_check_value_data, - callback_change, callback_change_data, - NULL, NULL); + callback_check_value, + callback_check_value_pointer, + callback_check_value_data, + callback_change, + callback_change_pointer, + callback_change_data, + NULL, NULL, NULL); break; case IRC_SERVER_OPTION_CONNECTION_TIMEOUT: new_option = weechat_config_new_option ( @@ -2012,9 +2070,13 @@ irc_config_server_new_option (struct t_config_file *config_file, NULL, 1, 3600, default_value, value, null_value_allowed, - callback_check_value, callback_check_value_data, - callback_change, callback_change_data, - NULL, NULL); + callback_check_value, + callback_check_value_pointer, + callback_check_value_data, + callback_change, + callback_change_pointer, + callback_change_data, + NULL, NULL, NULL); break; case IRC_SERVER_OPTION_ANTI_FLOOD_PRIO_HIGH: new_option = weechat_config_new_option ( @@ -2026,9 +2088,13 @@ irc_config_server_new_option (struct t_config_file *config_file, NULL, 0, 60, default_value, value, null_value_allowed, - callback_check_value, callback_check_value_data, - callback_change, callback_change_data, - NULL, NULL); + callback_check_value, + callback_check_value_pointer, + callback_check_value_data, + callback_change, + callback_change_pointer, + callback_change_data, + NULL, NULL, NULL); break; case IRC_SERVER_OPTION_ANTI_FLOOD_PRIO_LOW: new_option = weechat_config_new_option ( @@ -2040,9 +2106,13 @@ irc_config_server_new_option (struct t_config_file *config_file, NULL, 0, 60, default_value, value, null_value_allowed, - callback_check_value, callback_check_value_data, - callback_change, callback_change_data, - NULL, NULL); + callback_check_value, + callback_check_value_pointer, + callback_check_value_data, + callback_change, + callback_change_pointer, + callback_change_data, + NULL, NULL, NULL); break; case IRC_SERVER_OPTION_AWAY_CHECK: new_option = weechat_config_new_option ( @@ -2053,9 +2123,13 @@ irc_config_server_new_option (struct t_config_file *config_file, NULL, 0, 60 * 24 * 7, default_value, value, null_value_allowed, - callback_check_value, callback_check_value_data, - callback_change, callback_change_data, - NULL, NULL); + callback_check_value, + callback_check_value_pointer, + callback_check_value_data, + callback_change, + callback_change_pointer, + callback_change_data, + NULL, NULL, NULL); break; case IRC_SERVER_OPTION_AWAY_CHECK_MAX_NICKS: new_option = weechat_config_new_option ( @@ -2066,49 +2140,73 @@ irc_config_server_new_option (struct t_config_file *config_file, NULL, 0, 1000000, default_value, value, null_value_allowed, - callback_check_value, callback_check_value_data, - callback_change, callback_change_data, - NULL, NULL); + callback_check_value, + callback_check_value_pointer, + callback_check_value_data, + callback_change, + callback_change_pointer, + callback_change_data, + NULL, NULL, NULL); break; - case IRC_SERVER_OPTION_DEFAULT_MSG_KICK: + case IRC_SERVER_OPTION_MSG_KICK: new_option = weechat_config_new_option ( config_file, section, option_name, "string", N_("default kick message used by commands \"/kick\" and " - "\"/kickban\" (special variables $nick, $channel and $server " - "are replaced by their value)"), + "\"/kickban\" " + "(note: content is evaluated, see /help eval; special " + "variables ${nick}, ${channel} and ${server} are replaced " + "by their value)"), NULL, 0, 0, default_value, value, null_value_allowed, - callback_check_value, callback_check_value_data, - callback_change, callback_change_data, - NULL, NULL); + callback_check_value, + callback_check_value_pointer, + callback_check_value_data, + callback_change, + callback_change_pointer, + callback_change_data, + NULL, NULL, NULL); break; - case IRC_SERVER_OPTION_DEFAULT_MSG_PART: + case IRC_SERVER_OPTION_MSG_PART: new_option = weechat_config_new_option ( config_file, section, option_name, "string", - N_("default part message (leaving channel) (\"%v\" will be " - "replaced by WeeChat version in string)"), + N_("default part message (leaving channel) " + "(note: content is evaluated, see /help eval; special " + "variables ${nick}, ${channel} and ${server} are replaced " + "by their value; \"%v\" is replaced by WeeChat version if " + "there is no ${...} in string)"), NULL, 0, 0, default_value, value, null_value_allowed, - callback_check_value, callback_check_value_data, - callback_change, callback_change_data, - NULL, NULL); + callback_check_value, + callback_check_value_pointer, + callback_check_value_data, + callback_change, + callback_change_pointer, + callback_change_data, + NULL, NULL, NULL); break; - case IRC_SERVER_OPTION_DEFAULT_MSG_QUIT: + case IRC_SERVER_OPTION_MSG_QUIT: new_option = weechat_config_new_option ( config_file, section, option_name, "string", - N_("default quit message (disconnecting from server) (\"%v\" " - "will be replaced by WeeChat version in string)"), + N_("default quit message (disconnecting from server) " + "(note: content is evaluated, see /help eval; special " + "variables ${nick}, ${channel} and ${server} are replaced " + "by their value; \"%v\" is replaced by WeeChat version if " + "there is no ${...} in string)"), NULL, 0, 0, default_value, value, null_value_allowed, - callback_check_value, callback_check_value_data, - callback_change, callback_change_data, - NULL, NULL); + callback_check_value, + callback_check_value_pointer, + callback_check_value_data, + callback_change, + callback_change_pointer, + callback_change_data, + NULL, NULL, NULL); break; case IRC_SERVER_OPTION_NOTIFY: new_option = weechat_config_new_option ( @@ -2121,9 +2219,12 @@ irc_config_server_new_option (struct t_config_file *config_file, null_value_allowed, (section == irc_config_section_server_default) ? &irc_config_server_default_check_notify : callback_check_value, + callback_check_value_pointer, callback_check_value_data, - callback_change, callback_change_data, - NULL, NULL); + callback_change, + callback_change_pointer, + callback_change_data, + NULL, NULL, NULL); break; case IRC_SERVER_NUM_OPTIONS: break; @@ -2137,7 +2238,8 @@ irc_config_server_new_option (struct t_config_file *config_file, */ int -irc_config_server_read_cb (void *data, struct t_config_file *config_file, +irc_config_server_read_cb (const void *pointer, void *data, + struct t_config_file *config_file, struct t_config_section *section, const char *option_name, const char *value) { @@ -2146,6 +2248,7 @@ irc_config_server_read_cb (void *data, struct t_config_file *config_file, char *pos_option, *server_name; /* make C compiler happy */ + (void) pointer; (void) data; (void) config_file; (void) section; @@ -2213,13 +2316,15 @@ irc_config_server_read_cb (void *data, struct t_config_file *config_file, */ int -irc_config_server_write_cb (void *data, struct t_config_file *config_file, +irc_config_server_write_cb (const void *pointer, void *data, + struct t_config_file *config_file, const char *section_name) { struct t_irc_server *ptr_server; int i; /* make C compiler happy */ + (void) pointer; (void) data; if (!weechat_config_write_line (config_file, section_name, NULL)) @@ -2308,8 +2413,10 @@ irc_config_server_create_default_options (struct t_config_section *section) 0, &irc_config_server_check_value_cb, irc_server_options[i][0], + NULL, &irc_config_server_default_change_cb, - irc_server_options[i][0]); + irc_server_options[i][0], + NULL); } if (nicks) @@ -2337,38 +2444,31 @@ irc_config_init () 32, WEECHAT_HASHTABLE_STRING, WEECHAT_HASHTABLE_STRING, - NULL, - NULL); - irc_config_hashtable_nick_color_force = weechat_hashtable_new ( - 32, - WEECHAT_HASHTABLE_STRING, - WEECHAT_HASHTABLE_STRING, - NULL, - NULL); + NULL, NULL); irc_config_hashtable_nick_prefixes = weechat_hashtable_new ( 32, WEECHAT_HASHTABLE_STRING, WEECHAT_HASHTABLE_STRING, - NULL, - NULL); + NULL, NULL); irc_config_hashtable_color_mirc_remap = weechat_hashtable_new ( 32, WEECHAT_HASHTABLE_STRING, WEECHAT_HASHTABLE_STRING, - NULL, - NULL); + NULL, NULL); irc_config_file = weechat_config_new (IRC_CONFIG_NAME, - &irc_config_reload, NULL); + &irc_config_reload, NULL, NULL); if (!irc_config_file) return 0; /* look */ ptr_section = weechat_config_new_section (irc_config_file, "look", 0, 0, - NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, - NULL, NULL); + NULL, NULL, NULL, + NULL, NULL, NULL, + NULL, NULL, NULL, + NULL, NULL, NULL, + NULL, NULL, NULL); if (!ptr_section) { weechat_config_free (irc_config_file); @@ -2382,104 +2482,108 @@ irc_config_init () "when it is auto joined (with server option \"autojoin\"); " "this is useful to open channels with always the same buffer " "numbers on startup"), - NULL, 0, 0, "on", NULL, 0, NULL, NULL, - NULL, NULL, NULL, NULL); + NULL, 0, 0, "on", NULL, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); irc_config_look_buffer_open_before_join = weechat_config_new_option ( irc_config_file, ptr_section, "buffer_open_before_join", "boolean", N_("open channel buffer before the JOIN is received from server " "when it is manually joined (with /join command)"), - NULL, 0, 0, "off", NULL, 0, NULL, NULL, - NULL, NULL, NULL, NULL); + NULL, 0, 0, "off", NULL, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); irc_config_look_buffer_switch_autojoin = weechat_config_new_option ( irc_config_file, ptr_section, "buffer_switch_autojoin", "boolean", N_("auto switch to channel buffer when it is auto joined (with " "server option \"autojoin\")"), - NULL, 0, 0, "on", NULL, 0, NULL, NULL, - NULL, NULL, NULL, NULL); + NULL, 0, 0, "on", NULL, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); irc_config_look_buffer_switch_join = weechat_config_new_option ( irc_config_file, ptr_section, "buffer_switch_join", "boolean", N_("auto switch to channel buffer when it is manually joined " "(with /join command)"), - NULL, 0, 0, "on", NULL, 0, NULL, NULL, - NULL, NULL, NULL, NULL); + NULL, 0, 0, "on", NULL, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); irc_config_look_color_nicks_in_names = weechat_config_new_option ( irc_config_file, ptr_section, "color_nicks_in_names", "boolean", N_("use nick color in output of /names (or list of nicks displayed " "when joining a channel)"), - NULL, 0, 0, "off", NULL, 0, NULL, NULL, - NULL, NULL, NULL, NULL); + NULL, 0, 0, "off", NULL, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); irc_config_look_color_nicks_in_nicklist = weechat_config_new_option ( irc_config_file, ptr_section, "color_nicks_in_nicklist", "boolean", N_("use nick color in nicklist"), - NULL, 0, 0, "off", NULL, 0, NULL, NULL, - &irc_config_change_look_color_nicks_in_nicklist, NULL, NULL, NULL); + NULL, 0, 0, "off", NULL, 0, + NULL, NULL, NULL, + &irc_config_change_look_color_nicks_in_nicklist, NULL, NULL, + NULL, NULL, NULL); irc_config_look_color_nicks_in_server_messages = weechat_config_new_option ( irc_config_file, ptr_section, "color_nicks_in_server_messages", "boolean", N_("use nick color in messages from server"), - NULL, 0, 0, "on", NULL, 0, NULL, NULL, - NULL, NULL, NULL, NULL); + NULL, 0, 0, "on", NULL, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); irc_config_look_color_pv_nick_like_channel = weechat_config_new_option ( irc_config_file, ptr_section, "color_pv_nick_like_channel", "boolean", N_("use same nick color for channel and private"), - NULL, 0, 0, "on", NULL, 0, NULL, NULL, - NULL, NULL, NULL, NULL); + NULL, 0, 0, "on", NULL, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); irc_config_look_ctcp_time_format = weechat_config_new_option ( irc_config_file, ptr_section, "ctcp_time_format", "string", N_("time format used in answer to message CTCP TIME (see man strftime " "for date/time specifiers)"), - NULL, 0, 0, "%a, %d %b %Y %T %z", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL); + NULL, 0, 0, "%a, %d %b %Y %T %z", NULL, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); irc_config_look_display_away = weechat_config_new_option ( irc_config_file, ptr_section, "display_away", "integer", N_("display message when (un)marking as away (off: do not display/send " "anything, local: display locally, channel: send action to channels)"), - "off|local|channel", 0, 0, "local", NULL, 0, NULL, NULL, - &irc_config_change_look_display_away, NULL, - NULL, NULL); + "off|local|channel", 0, 0, "local", NULL, 0, + NULL, NULL, NULL, + &irc_config_change_look_display_away, NULL, NULL, + NULL, NULL, NULL); irc_config_look_display_ctcp_blocked = weechat_config_new_option ( irc_config_file, ptr_section, "display_ctcp_blocked", "boolean", N_("display CTCP message even if it is blocked"), - NULL, 0, 0, "on", NULL, 0, NULL, NULL, - NULL, NULL, NULL, NULL); + NULL, 0, 0, "on", NULL, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); irc_config_look_display_ctcp_reply = weechat_config_new_option ( irc_config_file, ptr_section, "display_ctcp_reply", "boolean", N_("display CTCP reply sent by WeeChat"), - NULL, 0, 0, "on", NULL, 0, NULL, NULL, - NULL, NULL, NULL, NULL); + NULL, 0, 0, "on", NULL, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); irc_config_look_display_ctcp_unknown = weechat_config_new_option ( irc_config_file, ptr_section, "display_ctcp_unknown", "boolean", N_("display CTCP message even if it is unknown CTCP"), - NULL, 0, 0, "on", NULL, 0, NULL, NULL, - NULL, NULL, NULL, NULL); + NULL, 0, 0, "on", NULL, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); irc_config_look_display_host_join = weechat_config_new_option ( irc_config_file, ptr_section, "display_host_join", "boolean", N_("display host in join messages"), - NULL, 0, 0, "on", NULL, 0, NULL, NULL, - NULL, NULL, NULL, NULL); + NULL, 0, 0, "on", NULL, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); irc_config_look_display_host_join_local = weechat_config_new_option ( irc_config_file, ptr_section, "display_host_join_local", "boolean", N_("display host in join messages from local client"), - NULL, 0, 0, "on", NULL, 0, NULL, NULL, - NULL, NULL, NULL, NULL); + NULL, 0, 0, "on", NULL, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); irc_config_look_display_host_quit = weechat_config_new_option ( irc_config_file, ptr_section, "display_host_quit", "boolean", N_("display host in part/quit messages"), - NULL, 0, 0, "on", NULL, 0, NULL, NULL, - NULL, NULL, NULL, NULL); + NULL, 0, 0, "on", NULL, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); irc_config_look_display_join_message = weechat_config_new_option ( irc_config_file, ptr_section, "display_join_message", "string", @@ -2487,25 +2591,29 @@ irc_config_init () "channel: 324 = channel modes, 329 = channel creation date, " "332 = topic, 333 = nick/date for topic, 353 = names on channel, " "366 = names count"), - NULL, 0, 0, "329,332,333,366", NULL, 0, NULL, NULL, - &irc_config_change_look_display_join_message, NULL, NULL, NULL); + NULL, 0, 0, "329,332,333,366", NULL, 0, + NULL, NULL, NULL, + &irc_config_change_look_display_join_message, NULL, NULL, + NULL, NULL, NULL); irc_config_look_display_old_topic = weechat_config_new_option ( irc_config_file, ptr_section, "display_old_topic", "boolean", N_("display old topic when channel topic is changed"), - NULL, 0, 0, "on", NULL, 0, NULL, NULL, - NULL, NULL, NULL, NULL); + NULL, 0, 0, "on", NULL, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); irc_config_look_display_pv_away_once = weechat_config_new_option ( irc_config_file, ptr_section, "display_pv_away_once", "boolean", N_("display remote away message only once in private"), - NULL, 0, 0, "on", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL); + NULL, 0, 0, "on", NULL, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); irc_config_look_display_pv_back = weechat_config_new_option ( irc_config_file, ptr_section, "display_pv_back", "boolean", N_("display a message in private when user is back (after quit on " "server)"), - NULL, 0, 0, "on", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL); + NULL, 0, 0, "on", NULL, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); irc_config_look_highlight_channel = weechat_config_new_option ( irc_config_file, ptr_section, "highlight_channel", "string", @@ -2516,7 +2624,8 @@ irc_config_init () "buffer property \"highlight_words\" only when buffer is created " "(it does not affect current buffers), an empty string disables " "default highlight on nick, examples: \"$nick\", \"(?-i)$nick\""), - NULL, 0, 0, "$nick", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL); + NULL, 0, 0, "$nick", NULL, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); irc_config_look_highlight_pv = weechat_config_new_option ( irc_config_file, ptr_section, "highlight_pv", "string", @@ -2527,7 +2636,8 @@ irc_config_init () "buffer property \"highlight_words\" only when buffer is created " "(it does not affect current buffers), an empty string disables " "default highlight on nick, examples: \"$nick\", \"(?-i)$nick\""), - NULL, 0, 0, "$nick", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL); + NULL, 0, 0, "$nick", NULL, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); irc_config_look_highlight_server = weechat_config_new_option ( irc_config_file, ptr_section, "highlight_server", "string", @@ -2538,7 +2648,8 @@ irc_config_init () "buffer property \"highlight_words\" only when buffer is created " "(it does not affect current buffers), an empty string disables " "default highlight on nick, examples: \"$nick\", \"(?-i)$nick\""), - NULL, 0, 0, "$nick", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL); + NULL, 0, 0, "$nick", NULL, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); irc_config_look_highlight_tags_restrict = weechat_config_new_option ( irc_config_file, ptr_section, "highlight_tags_restrict", "string", @@ -2547,14 +2658,10 @@ irc_config_init () "must be separated by a comma and \"+\" can be used to make a " "logical \"and\" between tags; wildcard \"*\" is allowed in tags; " "an empty value allows highlight on any tag"), - NULL, 0, 0, "irc_privmsg,irc_notice", NULL, 0, NULL, NULL, - &irc_config_change_look_highlight_tags_restrict, NULL, NULL, NULL); - irc_config_look_item_away_message = weechat_config_new_option ( - irc_config_file, ptr_section, - "item_away_message", "boolean", - N_("display server away message in away bar item"), - NULL, 0, 0, "on", NULL, 0, NULL, NULL, - &irc_config_change_look_item_away_message, NULL, NULL, NULL); + NULL, 0, 0, "irc_privmsg,irc_notice", NULL, 0, + NULL, NULL, NULL, + &irc_config_change_look_highlight_tags_restrict, NULL, NULL, + NULL, NULL, NULL); irc_config_look_item_channel_modes_hide_args = weechat_config_new_option ( irc_config_file, ptr_section, "item_channel_modes_hide_args", "string", @@ -2562,26 +2669,34 @@ irc_config_init () "channel modes (\"*\" to always hide all arguments, empty value to " "never hide arguments); example: \"kf\" to hide arguments if \"k\" " "or \"f\" are in channel modes"), - NULL, 0, 0, "k", NULL, 0, NULL, NULL, - &irc_config_change_look_item_channel_modes_hide_args, NULL, NULL, NULL); + NULL, 0, 0, "k", NULL, 0, + NULL, NULL, NULL, + &irc_config_change_look_item_channel_modes_hide_args, NULL, NULL, + NULL, NULL, NULL); irc_config_look_item_display_server = weechat_config_new_option ( irc_config_file, ptr_section, "item_display_server", "integer", N_("name of bar item where IRC server is displayed (for status bar)"), - "buffer_plugin|buffer_name", 0, 0, "buffer_plugin", NULL, 0, NULL, NULL, - &irc_config_change_look_item_display_server, NULL, NULL, NULL); + "buffer_plugin|buffer_name", 0, 0, "buffer_plugin", NULL, 0, + NULL, NULL, NULL, + &irc_config_change_look_item_display_server, NULL, NULL, + NULL, NULL, NULL); irc_config_look_item_nick_modes = weechat_config_new_option ( irc_config_file, ptr_section, "item_nick_modes", "boolean", N_("display nick modes in bar item \"input_prompt\""), - NULL, 0, 0, "on", NULL, 0, NULL, NULL, - &irc_config_change_bar_item_input_prompt, NULL, NULL, NULL); + NULL, 0, 0, "on", NULL, 0, + NULL, NULL, NULL, + &irc_config_change_bar_item_input_prompt, NULL, NULL, + NULL, NULL, NULL); irc_config_look_item_nick_prefix = weechat_config_new_option ( irc_config_file, ptr_section, "item_nick_prefix", "boolean", N_("display nick prefix in bar item \"input_prompt\""), - NULL, 0, 0, "on", NULL, 0, NULL, NULL, - &irc_config_change_bar_item_input_prompt, NULL, NULL, NULL); + NULL, 0, 0, "on", NULL, 0, + NULL, NULL, NULL, + &irc_config_change_bar_item_input_prompt, NULL, NULL, + NULL, NULL, NULL); irc_config_look_join_auto_add_chantype = weechat_config_new_option ( irc_config_file, ptr_section, "join_auto_add_chantype", "boolean", @@ -2589,15 +2704,15 @@ irc_config_init () "command /join if the channel name does not start with a valid " "channel type for the server; for example: \"/join weechat\" will " "in fact send: \"/join #weechat\""), - NULL, 0, 0, "off", NULL, 0, NULL, NULL, - NULL, NULL, NULL, NULL); + NULL, 0, 0, "off", NULL, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); irc_config_look_msgbuffer_fallback = weechat_config_new_option ( irc_config_file, ptr_section, "msgbuffer_fallback", "integer", N_("default target buffer for msgbuffer options when target is " "private and that private buffer is not found"), - "current|server", 0, 0, "current", NULL, 0, NULL, NULL, - NULL, NULL, NULL, NULL); + "current|server", 0, 0, "current", NULL, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); irc_config_look_new_channel_position = weechat_config_new_option ( irc_config_file, ptr_section, "new_channel_position", "integer", @@ -2605,8 +2720,8 @@ irc_config_init () "(none = default position (should be last buffer), " "next = current buffer + 1, near_server = after last channel/pv " "of server)"), - "none|next|near_server", 0, 0, "none", - NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL); + "none|next|near_server", 0, 0, "none", NULL, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); irc_config_look_new_pv_position = weechat_config_new_option ( irc_config_file, ptr_section, "new_pv_position", "integer", @@ -2614,58 +2729,33 @@ irc_config_init () "(none = default position (should be last buffer), " "next = current buffer + 1, near_server = after last channel/pv " "of server)"), - "none|next|near_server", 0, 0, "none", - NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL); - irc_config_look_nick_color_force = weechat_config_new_option ( - irc_config_file, ptr_section, - "nick_color_force", "string", - N_("force color for some nicks: hash computed with nickname " - "to find color will not be used for these nicks (format is: " - "\"nick1:color1;nick2:color2\"); look up for nicks is with " - "exact case then lower case, so it's possible to use only lower " - "case for nicks in this option"), - NULL, 0, 0, "", NULL, 0, NULL, NULL, - &irc_config_change_look_nick_color_force, NULL, NULL, NULL); - irc_config_look_nick_color_hash = weechat_config_new_option ( - irc_config_file, ptr_section, - "nick_color_hash", "integer", - N_("hash algorithm used to find the color for a nick: djb2 = variant " - "of djb2 (position of letters matters: anagrams of a nick have " - "different color), sum = sum of letters"), - "djb2|sum", 0, 0, "sum", NULL, 0, NULL, NULL, - &irc_config_change_look_nick_colors, NULL, NULL, NULL); - irc_config_look_nick_color_stop_chars = weechat_config_new_option ( - irc_config_file, ptr_section, - "nick_color_stop_chars", "string", - N_("chars used to stop in nick when computing color with letters of " - "nick (at least one char outside this list must be in string before " - "stopping) (example: nick \"|nick|away\" with \"|\" in chars will " - "return color of nick \"|nick\")"), - NULL, 0, 0, "_|[", NULL, 0, NULL, NULL, - &irc_config_change_look_nick_colors, NULL, NULL, NULL); + "none|next|near_server", 0, 0, "none", NULL, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); irc_config_look_nick_completion_smart = weechat_config_new_option ( irc_config_file, ptr_section, "nick_completion_smart", "integer", N_("smart completion for nicks (completes first with last speakers): " "speakers = all speakers (including highlights), " "speakers_highlights = only speakers with highlight"), - "off|speakers|speakers_highlights", 0, 0, "speakers", NULL, 0, NULL, NULL, - NULL, NULL, NULL, NULL); + "off|speakers|speakers_highlights", 0, 0, "speakers", NULL, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); irc_config_look_nick_mode = weechat_config_new_option ( irc_config_file, ptr_section, "nick_mode", "integer", N_("display nick mode (op, voice, ...) before nick (none = never, " "prefix = in prefix only (default), action = in action messages " "only, both = prefix + action messages)"), - "none|prefix|action|both", 0, 0, "prefix", - NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL); + "none|prefix|action|both", 0, 0, "prefix", NULL, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); irc_config_look_nick_mode_empty = weechat_config_new_option ( irc_config_file, ptr_section, "nick_mode_empty", "boolean", N_("display a space if nick mode is enabled but nick has no mode (not " "op, voice, ...)"), - NULL, 0, 0, "off", NULL, 0, NULL, NULL, - &irc_config_change_bar_item_input_prompt, NULL, NULL, NULL); + NULL, 0, 0, "off", NULL, 0, + NULL, NULL, NULL, + &irc_config_change_bar_item_input_prompt, NULL, NULL, + NULL, NULL, NULL); irc_config_look_nicks_hide_password = weechat_config_new_option ( irc_config_file, ptr_section, "nicks_hide_password", "string", @@ -2673,14 +2763,17 @@ irc_config_init () "when a message is sent, for example to hide password in message " "displayed by \"/msg nickserv identify password\", example: " "\"nickserv,nickbot\""), - NULL, 0, 0, "nickserv", NULL, 0, NULL, NULL, - &irc_config_change_look_nicks_hide_password, NULL, NULL, NULL); + NULL, 0, 0, "nickserv", NULL, 0, + NULL, NULL, NULL, + &irc_config_change_look_nicks_hide_password, NULL, NULL, + NULL, NULL, NULL); irc_config_look_notice_as_pv = weechat_config_new_option ( irc_config_file, ptr_section, "notice_as_pv", "integer", N_("display notices as private messages (if auto, use private buffer " "if found)"), - "auto|never|always", 0, 0, "auto", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL); + "auto|never|always", 0, 0, "auto", NULL, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); irc_config_look_notice_welcome_redirect = weechat_config_new_option ( irc_config_file, ptr_section, "notice_welcome_redirect", "boolean", @@ -2688,14 +2781,15 @@ irc_config_init () "buffer; such notices have the nick as target but a channel name in " "beginning of notice message, for example notices sent by freenode " "server which look like: \"[#channel] Welcome to this channel...\""), - NULL, 0, 0, "on", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL); + NULL, 0, 0, "on", NULL, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); irc_config_look_notice_welcome_tags = weechat_config_new_option ( irc_config_file, ptr_section, "notice_welcome_tags", "string", N_("comma separated list of tags used in a welcome notices redirected " "to a channel, for example: \"notify_private\""), - NULL, 0, 0, "", NULL, 0, NULL, NULL, - NULL, NULL, NULL, NULL); + NULL, 0, 0, "", NULL, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); irc_config_look_notify_tags_ison = weechat_config_new_option ( irc_config_file, ptr_section, "notify_tags_ison", "string", @@ -2703,8 +2797,8 @@ irc_config_init () "when a nick joins or quits server (result of command ison or " "monitor), for example: \"notify_message\", \"notify_private\" or " "\"notify_highlight\""), - NULL, 0, 0, "notify_message", NULL, 0, NULL, NULL, - NULL, NULL, NULL, NULL); + NULL, 0, 0, "notify_message", NULL, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); irc_config_look_notify_tags_whois = weechat_config_new_option ( irc_config_file, ptr_section, "notify_tags_whois", "string", @@ -2712,60 +2806,68 @@ irc_config_init () "when a nick away status changes (result of command whois), " "for example: \"notify_message\", \"notify_private\" or " "\"notify_highlight\""), - NULL, 0, 0, "notify_message", NULL, 0, NULL, NULL, - NULL, NULL, NULL, NULL); + NULL, 0, 0, "notify_message", NULL, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); irc_config_look_part_closes_buffer = weechat_config_new_option ( irc_config_file, ptr_section, "part_closes_buffer", "boolean", N_("close buffer when /part is issued on a channel"), - NULL, 0, 0, "off", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL); + NULL, 0, 0, "off", NULL, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); irc_config_look_pv_buffer = weechat_config_new_option ( irc_config_file, ptr_section, "pv_buffer", "integer", N_("merge private buffers"), - "independent|merge_by_server|merge_all", 0, 0, "independent", - NULL, 0, NULL, NULL, - &irc_config_change_look_pv_buffer, NULL, NULL, NULL); + "independent|merge_by_server|merge_all", 0, 0, "independent", NULL, 0, + NULL, NULL, NULL, + &irc_config_change_look_pv_buffer, NULL, NULL, + NULL, NULL, NULL); irc_config_look_pv_tags = weechat_config_new_option ( irc_config_file, ptr_section, "pv_tags", "string", N_("comma separated list of tags used in private messages, for example: " "\"notify_message\", \"notify_private\" or \"notify_highlight\""), - NULL, 0, 0, "notify_private", NULL, 0, NULL, NULL, - NULL, NULL, NULL, NULL); + NULL, 0, 0, "notify_private", NULL, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); irc_config_look_raw_messages = weechat_config_new_option ( irc_config_file, ptr_section, "raw_messages", "integer", N_("number of raw messages to save in memory when raw data buffer is " "closed (messages will be displayed when opening raw data buffer)"), - NULL, 0, 65535, "256", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL); + NULL, 0, 65535, "256", NULL, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); irc_config_look_server_buffer = weechat_config_new_option ( irc_config_file, ptr_section, "server_buffer", "integer", N_("merge server buffers"), "merge_with_core|merge_without_core|independent", 0, 0, "merge_with_core", - NULL, 0, NULL, NULL, - &irc_config_change_look_server_buffer, NULL, NULL, NULL); + NULL, 0, + NULL, NULL, NULL, + &irc_config_change_look_server_buffer, NULL, NULL, + NULL, NULL, NULL); irc_config_look_smart_filter = weechat_config_new_option ( irc_config_file, ptr_section, "smart_filter", "boolean", N_("filter join/part/quit/nick messages for a nick if not speaking " "for some minutes on channel (you must create a filter on tag " "\"irc_smart_filter\")"), - NULL, 0, 0, "on", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL); + NULL, 0, 0, "on", NULL, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); irc_config_look_smart_filter_delay = weechat_config_new_option ( irc_config_file, ptr_section, "smart_filter_delay", "integer", N_("delay for filtering join/part/quit messages (in minutes): if the " "nick did not speak during the last N minutes, the join/part/quit is " "filtered"), - NULL, 1, 60*24*7, "5", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL); + NULL, 1, 60*24*7, "5", NULL, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); irc_config_look_smart_filter_join = weechat_config_new_option ( irc_config_file, ptr_section, "smart_filter_join", "boolean", /* TRANSLATORS: please do not translate "join" */ N_("enable smart filter for \"join\" messages"), - NULL, 0, 0, "on", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL); + NULL, 0, 0, "on", NULL, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); irc_config_look_smart_filter_join_unmask = weechat_config_new_option ( irc_config_file, ptr_section, "smart_filter_join_unmask", "integer", @@ -2774,7 +2876,8 @@ irc_config_init () "minutes ago and then says something on channel (message, notice or " "update on topic), the join is unmasked, as well as nick changes " "after this join (0 = disable: never unmask a join)"), - NULL, 0, 60*24*7, "30", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL); + NULL, 0, 60*24*7, "30", NULL, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); irc_config_look_smart_filter_mode = weechat_config_new_option ( irc_config_file, ptr_section, "smart_filter_mode", "string", @@ -2784,38 +2887,46 @@ irc_config_init () "\"ovh\"), \"xyz\" to filter only modes x/y/z, \"-xyz\" to filter " "all modes but not x/y/z; examples: \"ovh\": filter modes o/v/h, " "\"-bkl\": filter all modes but not b/k/l"), - NULL, 0, 0, "+", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL); + NULL, 0, 0, "+", NULL, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); irc_config_look_smart_filter_nick = weechat_config_new_option ( irc_config_file, ptr_section, "smart_filter_nick", "boolean", /* TRANSLATORS: please do not translate "nick" */ N_("enable smart filter for \"nick\" messages (nick changes)"), - NULL, 0, 0, "on", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL); + NULL, 0, 0, "on", NULL, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); irc_config_look_smart_filter_quit = weechat_config_new_option ( irc_config_file, ptr_section, "smart_filter_quit", "boolean", /* TRANSLATORS: please do not translate "part" and "quit" */ N_("enable smart filter for \"part\" and \"quit\" messages"), - NULL, 0, 0, "on", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL); + NULL, 0, 0, "on", NULL, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); irc_config_look_temporary_servers = weechat_config_new_option ( irc_config_file, ptr_section, "temporary_servers", "boolean", N_("enable automatic addition of temporary servers with command " "/connect"), - NULL, 0, 0, "off", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL); + NULL, 0, 0, "off", NULL, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); irc_config_look_topic_strip_colors = weechat_config_new_option ( irc_config_file, ptr_section, "topic_strip_colors", "boolean", N_("strip colors in topic (used only when displaying buffer title)"), - NULL, 0, 0, "off", NULL, 0, NULL, NULL, - &irc_config_change_look_topic_strip_colors, NULL, NULL, NULL); + NULL, 0, 0, "off", NULL, 0, + NULL, NULL, NULL, + &irc_config_change_look_topic_strip_colors, NULL, NULL, + NULL, NULL, NULL); /* color */ ptr_section = weechat_config_new_section (irc_config_file, "color", 0, 0, - NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, - NULL, NULL); + NULL, NULL, NULL, + NULL, NULL, NULL, + NULL, NULL, NULL, + NULL, NULL, NULL, + NULL, NULL, NULL); if (!ptr_section) { weechat_config_free (irc_config_file); @@ -2826,51 +2937,55 @@ irc_config_init () irc_config_file, ptr_section, "input_nick", "color", N_("color for nick in input bar"), - NULL, -1, 0, "lightcyan", NULL, 0, NULL, NULL, - &irc_config_change_bar_item_input_prompt, NULL, NULL, NULL); - irc_config_color_item_away = weechat_config_new_option ( - irc_config_file, ptr_section, - "item_away", "color", - N_("color for away item"), - NULL, -1, 0, "yellow", NULL, 0, NULL, NULL, - &irc_config_change_color_item_away, NULL, NULL, NULL); + NULL, -1, 0, "lightcyan", NULL, 0, + NULL, NULL, NULL, + &irc_config_change_bar_item_input_prompt, NULL, NULL, + NULL, NULL, NULL); irc_config_color_item_channel_modes = weechat_config_new_option ( irc_config_file, ptr_section, "item_channel_modes", "color", N_("color for channel modes, near channel name"), - NULL, -1, 0, "default", NULL, 0, NULL, NULL, - &irc_config_change_color_item_channel_modes, NULL, NULL, NULL); + NULL, -1, 0, "default", NULL, 0, + NULL, NULL, NULL, + &irc_config_change_color_item_channel_modes, NULL, NULL, + NULL, NULL, NULL); irc_config_color_item_lag_counting = weechat_config_new_option ( irc_config_file, ptr_section, "item_lag_counting", "color", N_("color for lag indicator, when counting (pong not received from " "server, lag is increasing)"), - NULL, -1, 0, "default", NULL, 0, NULL, NULL, - &irc_config_change_color_item_lag, NULL, NULL, NULL); + NULL, -1, 0, "default", NULL, 0, + NULL, NULL, NULL, + &irc_config_change_color_item_lag, NULL, NULL, + NULL, NULL, NULL); irc_config_color_item_lag_finished = weechat_config_new_option ( irc_config_file, ptr_section, "item_lag_finished", "color", N_("color for lag indicator, when pong has been received from server"), - NULL, -1, 0, "yellow", NULL, 0, NULL, NULL, - &irc_config_change_color_item_lag, NULL, NULL, NULL); + NULL, -1, 0, "yellow", NULL, 0, + NULL, NULL, NULL, + &irc_config_change_color_item_lag, NULL, NULL, + NULL, NULL, NULL); irc_config_color_item_nick_modes = weechat_config_new_option ( irc_config_file, ptr_section, "item_nick_modes", "color", N_("color for nick modes in bar item \"input_prompt\""), - NULL, -1, 0, "default", NULL, 0, NULL, NULL, - &irc_config_change_color_item_nick_modes, NULL, NULL, NULL); + NULL, -1, 0, "default", NULL, 0, + NULL, NULL, NULL, + &irc_config_change_color_item_nick_modes, NULL, NULL, + NULL, NULL, NULL); irc_config_color_message_join = weechat_config_new_option ( irc_config_file, ptr_section, "message_join", "color", N_("color for text in join messages"), - NULL, -1, 0, "green", NULL, 0, NULL, NULL, - NULL, NULL, NULL, NULL); + NULL, -1, 0, "green", NULL, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); irc_config_color_message_quit = weechat_config_new_option ( irc_config_file, ptr_section, "message_quit", "color", N_("color for text in part/quit messages"), - NULL, -1, 0, "red", NULL, 0, NULL, NULL, - NULL, NULL, NULL, NULL); + NULL, -1, 0, "red", NULL, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); irc_config_color_mirc_remap = weechat_config_new_option ( irc_config_file, ptr_section, "mirc_remap", "string", @@ -2884,8 +2999,10 @@ irc_config_init () "4=lightred, 5=red, 6=magenta, 7=brown, 8=yellow, 9=lightgreen, " "10=cyan, 11=lightcyan, 12=lightblue, 13=lightmagenta, 14=gray, " "15=white"), - NULL, 0, 0, "1,-1:darkgray", NULL, 0, NULL, NULL, - &irc_config_change_color_mirc_remap, NULL, NULL, NULL); + NULL, 0, 0, "1,-1:darkgray", NULL, 0, + NULL, NULL, NULL, + &irc_config_change_color_mirc_remap, NULL, NULL, + NULL, NULL, NULL); irc_config_color_nick_prefixes = weechat_config_new_option ( irc_config_file, ptr_section, "nick_prefixes", "string", @@ -2894,74 +3011,70 @@ irc_config_init () "found, WeeChat will try with next modes received from server " "(\"PREFIX\"); a special mode \"*\" can be used as default color " "if no mode has been found in list)"), - NULL, 0, 0, "q:lightred;a:lightcyan;o:lightgreen;h:lightmagenta;" - "v:yellow;*:lightblue", NULL, 0, NULL, NULL, - &irc_config_change_color_nick_prefixes, NULL, NULL, NULL); + NULL, 0, 0, "y:lightred;q:lightred;a:lightcyan;o:lightgreen;" + "h:lightmagenta;v:yellow;*:lightblue", NULL, 0, + NULL, NULL, NULL, + &irc_config_change_color_nick_prefixes, NULL, NULL, + NULL, NULL, NULL); irc_config_color_notice = weechat_config_new_option ( irc_config_file, ptr_section, "notice", "color", N_("color for text \"Notice\" in notices"), - NULL, -1, 0, "green", NULL, 0, NULL, NULL, - NULL, NULL, NULL, NULL); + NULL, -1, 0, "green", NULL, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); irc_config_color_reason_quit = weechat_config_new_option ( irc_config_file, ptr_section, "reason_quit", "color", N_("color for reason in part/quit messages"), - NULL, -1, 0, "default", NULL, 0, NULL, NULL, - NULL, NULL, NULL, NULL); + NULL, -1, 0, "default", NULL, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); irc_config_color_topic_current = weechat_config_new_option ( irc_config_file, ptr_section, "topic_current", "color", N_("color for current channel topic (when joining a channel or " "using /topic)"), - NULL, -1, 0, "default", NULL, 0, NULL, NULL, - NULL, NULL, NULL, NULL); + NULL, -1, 0, "default", NULL, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); irc_config_color_topic_new = weechat_config_new_option ( irc_config_file, ptr_section, "topic_new", "color", N_("color for new channel topic (when topic is changed)"), - NULL, -1, 0, "white", NULL, 0, NULL, NULL, - NULL, NULL, NULL, NULL); + NULL, -1, 0, "white", NULL, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); irc_config_color_topic_old = weechat_config_new_option ( irc_config_file, ptr_section, "topic_old", "color", N_("color for old channel topic (when topic is changed)"), - NULL, -1, 0, "default", NULL, 0, NULL, NULL, - NULL, NULL, NULL, NULL); + NULL, -1, 0, "default", NULL, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); /* network */ ptr_section = weechat_config_new_section (irc_config_file, "network", 0, 0, - NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, - NULL, NULL); + NULL, NULL, NULL, + NULL, NULL, NULL, + NULL, NULL, NULL, + NULL, NULL, NULL, + NULL, NULL, NULL); if (!ptr_section) { weechat_config_free (irc_config_file); return 0; } - irc_config_network_alternate_nick = weechat_config_new_option ( - irc_config_file, ptr_section, - "alternate_nick", "boolean", - N_("get an alternate nick when the nick is already used on server: add " - "some \"_\" until the nick has a length of 9, and then replace last " - "char (or the two last chars) by a number from 1 to 99, until we " - "find a nick not used on server"), - NULL, 0, 0, "on", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL); irc_config_network_autoreconnect_delay_growing = weechat_config_new_option ( irc_config_file, ptr_section, "autoreconnect_delay_growing", "integer", N_("growing factor for autoreconnect delay to server (1 = always same " "delay, 2 = delay*2 for each retry, ..)"), - NULL, 1, 100, "2", NULL, 0, NULL, NULL, - NULL, NULL, NULL, NULL); + NULL, 1, 100, "2", NULL, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); irc_config_network_autoreconnect_delay_max = weechat_config_new_option ( irc_config_file, ptr_section, "autoreconnect_delay_max", "integer", N_("maximum autoreconnect delay to server (in seconds, 0 = no maximum)"), - NULL, 0, 3600 * 24 * 7, "600", NULL, 0, NULL, NULL, - NULL, NULL, NULL, NULL); + NULL, 0, 3600 * 24 * 7, "600", NULL, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); irc_config_network_ban_mask_default = weechat_config_new_option ( irc_config_file, ptr_section, "ban_mask_default", "string", @@ -2970,8 +3083,8 @@ irc_config_init () "(extracted from \"nick!user@host\"); $ident is the same as $user if " "$user does not start with \"~\", otherwise it is set to \"*\"; this " "default mask is used only if WeeChat knows the host for the nick"), - NULL, 0, 0, "*!$ident@$host", NULL, 0, NULL, NULL, - NULL, NULL, NULL, NULL); + NULL, 0, 0, "*!$ident@$host", NULL, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); irc_config_network_channel_encode = weechat_config_new_option ( irc_config_file, ptr_section, "channel_encode", "boolean", @@ -2979,89 +3092,115 @@ irc_config_init () "it is recommended to keep that off if you use only UTF-8 in " "channel names; you can enable this option if you are using an " "exotic charset like ISO in channel names"), - NULL, 0, 0, "off", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL); + NULL, 0, 0, "off", NULL, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); irc_config_network_colors_receive = weechat_config_new_option ( irc_config_file, ptr_section, "colors_receive", "boolean", N_("when off, colors codes are ignored in incoming messages"), - NULL, 0, 0, "on", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL); + NULL, 0, 0, "on", NULL, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); irc_config_network_colors_send = weechat_config_new_option ( irc_config_file, ptr_section, "colors_send", "boolean", N_("allow user to send colors with special codes (ctrl-c + a code and " "optional color: b=bold, cxx=color, cxx,yy=color+background, " "i=italic, o=disable color/attributes, r=reverse, u=underline)"), - NULL, 0, 0, "on", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL); + NULL, 0, 0, "on", NULL, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); irc_config_network_lag_check = weechat_config_new_option ( irc_config_file, ptr_section, "lag_check", "integer", N_("interval between two checks for lag (in seconds, 0 = never " "check)"), - NULL, 0, 3600 * 24 * 7, "60", NULL, 0, NULL, NULL, - &irc_config_change_network_lag_check, NULL, NULL, NULL); + NULL, 0, 3600 * 24 * 7, "60", NULL, 0, + NULL, NULL, NULL, + &irc_config_change_network_lag_check, NULL, NULL, + NULL, NULL, NULL); irc_config_network_lag_max = weechat_config_new_option ( irc_config_file, ptr_section, "lag_max", "integer", N_("maximum lag (in seconds): if this lag is reached, WeeChat will " "consider that the answer from server (pong) will never be received " "and will give up counting the lag (0 = never give up)"), - NULL, 0, 3600 * 24 * 7, "1800", NULL, 0, NULL, NULL, - NULL, NULL, NULL, NULL); + NULL, 0, 3600 * 24 * 7, "1800", NULL, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); irc_config_network_lag_min_show = weechat_config_new_option ( irc_config_file, ptr_section, "lag_min_show", "integer", N_("minimum lag to show (in milliseconds)"), - NULL, 0, 1000 * 3600 * 24, "500", NULL, 0, NULL, NULL, - &irc_config_change_network_lag_min_show, NULL, NULL, NULL); + NULL, 0, 1000 * 3600 * 24, "500", NULL, 0, + NULL, NULL, NULL, + &irc_config_change_network_lag_min_show, NULL, NULL, + NULL, NULL, NULL); irc_config_network_lag_reconnect = weechat_config_new_option ( irc_config_file, ptr_section, "lag_reconnect", "integer", N_("reconnect to server if lag is greater than or equal to this value " "(in seconds, 0 = never reconnect); this value must be less than or " "equal to irc.network.lag_max"), - NULL, 0, 3600 * 24 * 7, "0", NULL, 0, NULL, NULL, - NULL, NULL, NULL, NULL); + NULL, 0, 3600 * 24 * 7, "0", NULL, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); irc_config_network_lag_refresh_interval = weechat_config_new_option ( irc_config_file, ptr_section, "lag_refresh_interval", "integer", N_("interval between two refreshs of lag item, when lag is increasing " "(in seconds)"), - NULL, 1, 3600, "1", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL); + NULL, 1, 3600, "1", NULL, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); irc_config_network_notify_check_ison = weechat_config_new_option ( irc_config_file, ptr_section, "notify_check_ison", "integer", N_("interval between two checks for notify with IRC command \"ison\" " "(in minutes)"), - NULL, 1, 60 * 24 * 7, "1", NULL, 0, NULL, NULL, - &irc_config_change_network_notify_check_ison, NULL, NULL, NULL); + NULL, 1, 60 * 24 * 7, "1", NULL, 0, + NULL, NULL, NULL, + &irc_config_change_network_notify_check_ison, NULL, NULL, + NULL, NULL, NULL); irc_config_network_notify_check_whois = weechat_config_new_option ( irc_config_file, ptr_section, "notify_check_whois", "integer", N_("interval between two checks for notify with IRC command \"whois\" " "(in minutes)"), - NULL, 1, 60 * 24 * 7, "5", NULL, 0, NULL, NULL, - &irc_config_change_network_notify_check_whois, NULL, NULL, NULL); + NULL, 1, 60 * 24 * 7, "5", NULL, 0, + NULL, NULL, NULL, + &irc_config_change_network_notify_check_whois, NULL, NULL, + NULL, NULL, NULL); + irc_config_network_sasl_fail_unavailable = weechat_config_new_option ( + irc_config_file, ptr_section, + "sasl_fail_unavailable", "boolean", + N_("cause SASL authentication failure when SASL is requested but " + "unavailable on the server; when this option is enabled, it has " + "effect only if option \"sasl_fail\" is set to \"reconnect\" or " + "\"disconnect\" in the server"), + NULL, 0, 0, "on", NULL, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); irc_config_network_send_unknown_commands = weechat_config_new_option ( irc_config_file, ptr_section, "send_unknown_commands", "boolean", N_("send unknown commands to server"), - NULL, 0, 0, "off", NULL, 0, NULL, NULL, - &irc_config_change_network_send_unknown_commands, NULL, NULL, NULL); + NULL, 0, 0, "off", NULL, 0, + NULL, NULL, NULL, + &irc_config_change_network_send_unknown_commands, NULL, NULL, + NULL, NULL, NULL); irc_config_network_whois_double_nick = weechat_config_new_option ( irc_config_file, ptr_section, "whois_double_nick", "boolean", N_("double the nick in /whois command (if only one nick is given), to " "get idle time in answer; for example: \"/whois nick\" will send " "\"whois nick nick\""), - NULL, 0, 0, "off", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL); + NULL, 0, 0, "off", NULL, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); /* msgbuffer */ - ptr_section = weechat_config_new_section (irc_config_file, "msgbuffer", - 1, 1, - NULL, NULL, NULL, NULL, - NULL, NULL, - &irc_config_msgbuffer_create_option, NULL, - NULL, NULL); + ptr_section = weechat_config_new_section ( + irc_config_file, "msgbuffer", + 1, 1, + NULL, NULL, NULL, + NULL, NULL, NULL, + NULL, NULL, NULL, + &irc_config_msgbuffer_create_option, NULL, NULL, + NULL, NULL, NULL); if (!ptr_section) { weechat_config_free (irc_config_file); @@ -3070,12 +3209,14 @@ irc_config_init () irc_config_section_msgbuffer = ptr_section; /* CTCP */ - ptr_section = weechat_config_new_section (irc_config_file, "ctcp", - 1, 1, - NULL, NULL, NULL, NULL, - NULL, NULL, - &irc_config_ctcp_create_option, NULL, - NULL, NULL); + ptr_section = weechat_config_new_section ( + irc_config_file, "ctcp", + 1, 1, + NULL, NULL, NULL, + NULL, NULL, NULL, + NULL, NULL, NULL, + &irc_config_ctcp_create_option, NULL, NULL, + NULL, NULL, NULL); if (!ptr_section) { weechat_config_free (irc_config_file); @@ -3084,12 +3225,14 @@ irc_config_init () irc_config_section_ctcp = ptr_section; /* ignore */ - ptr_section = weechat_config_new_section (irc_config_file, "ignore", - 0, 0, - &irc_config_ignore_read_cb, NULL, - &irc_config_ignore_write_cb, NULL, - &irc_config_ignore_write_cb, NULL, - NULL, NULL, NULL, NULL); + ptr_section = weechat_config_new_section ( + irc_config_file, "ignore", + 0, 0, + &irc_config_ignore_read_cb, NULL, NULL, + &irc_config_ignore_write_cb, NULL, NULL, + &irc_config_ignore_write_cb, NULL, NULL, + NULL, NULL, NULL, + NULL, NULL, NULL); if (!ptr_section) { weechat_config_free (irc_config_file); @@ -3097,11 +3240,14 @@ irc_config_init () } /* server_default */ - ptr_section = weechat_config_new_section (irc_config_file, "server_default", - 0, 0, - NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, - NULL, NULL); + ptr_section = weechat_config_new_section ( + irc_config_file, "server_default", + 0, 0, + NULL, NULL, NULL, + NULL, NULL, NULL, + NULL, NULL, NULL, + NULL, NULL, NULL, + NULL, NULL, NULL); if (!ptr_section) { weechat_config_free (irc_config_file); @@ -3112,13 +3258,14 @@ irc_config_init () irc_config_server_create_default_options (ptr_section); /* server */ - ptr_section = weechat_config_new_section (irc_config_file, "server", - 0, 0, - &irc_config_server_read_cb, NULL, - &irc_config_server_write_cb, NULL, - NULL, NULL, - NULL, NULL, - NULL, NULL); + ptr_section = weechat_config_new_section ( + irc_config_file, "server", + 0, 0, + &irc_config_server_read_cb, NULL, NULL, + &irc_config_server_write_cb, NULL, NULL, + NULL, NULL, NULL, + NULL, NULL, NULL, + NULL, NULL, NULL); if (!ptr_section) { weechat_config_free (irc_config_file); @@ -3126,9 +3273,12 @@ irc_config_init () } irc_config_section_server = ptr_section; - irc_config_hook_config_nick_colors = weechat_hook_config ( + irc_config_hook_config_nick_color_options = weechat_hook_config ( + "weechat.look.nick_color_*", + &irc_config_change_nick_colors_cb, NULL, NULL); + irc_config_hook_config_chat_nick_colors = weechat_hook_config ( "weechat.color.chat_nick_colors", - &irc_config_change_nick_colors_cb, NULL); + &irc_config_change_nick_colors_cb, NULL, NULL); return 1; } @@ -3149,13 +3299,12 @@ irc_config_read () if (rc == WEECHAT_CONFIG_READ_OK) { irc_notify_new_for_all_servers (); - irc_config_change_look_display_join_message (NULL, NULL); - irc_config_change_look_nick_color_force (NULL, NULL); - irc_config_change_look_nicks_hide_password (NULL, NULL); - irc_config_change_color_nick_prefixes (NULL, NULL); - irc_config_change_color_mirc_remap (NULL, NULL); - irc_config_change_network_notify_check_ison (NULL, NULL); - irc_config_change_network_notify_check_whois (NULL, NULL); + irc_config_change_look_display_join_message (NULL, NULL, NULL); + irc_config_change_look_nicks_hide_password (NULL, NULL, NULL); + irc_config_change_color_nick_prefixes (NULL, NULL, NULL); + irc_config_change_color_mirc_remap (NULL, NULL, NULL); + irc_config_change_network_notify_check_ison (NULL, NULL, NULL); + irc_config_change_network_notify_check_whois (NULL, NULL, NULL); } return rc; @@ -3182,16 +3331,16 @@ irc_config_free () { weechat_config_free (irc_config_file); - if (irc_config_hook_config_nick_colors) + if (irc_config_hook_config_nick_color_options) { - weechat_unhook (irc_config_hook_config_nick_colors); - irc_config_hook_config_nick_colors = NULL; + weechat_unhook (irc_config_hook_config_nick_color_options); + irc_config_hook_config_nick_color_options = NULL; } - if (irc_config_nick_colors) + + if (irc_config_hook_config_chat_nick_colors) { - weechat_string_free_split (irc_config_nick_colors); - irc_config_nick_colors = NULL; - irc_config_num_nick_colors = 0; + weechat_unhook (irc_config_hook_config_chat_nick_colors); + irc_config_hook_config_chat_nick_colors = NULL; } if (irc_config_nicks_hide_password) @@ -3207,12 +3356,6 @@ irc_config_free () irc_config_hashtable_display_join_message = NULL; } - if (irc_config_hashtable_nick_color_force) - { - weechat_hashtable_free (irc_config_hashtable_nick_color_force); - irc_config_hashtable_nick_color_force = NULL; - } - if (irc_config_hashtable_nick_prefixes) { weechat_hashtable_free (irc_config_hashtable_nick_prefixes); diff --git a/src/plugins/irc/irc-config.h b/src/plugins/irc/irc-config.h index cd0a766b5..ca1f5b531 100644 --- a/src/plugins/irc/irc-config.h +++ b/src/plugins/irc/irc-config.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org> + * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org> * * This file is part of WeeChat, the extensible chat client. * @@ -62,12 +62,6 @@ enum t_irc_config_look_notice_as_pv IRC_CONFIG_LOOK_NOTICE_AS_PV_ALWAYS, }; -enum t_irc_config_look_nick_color_hash -{ - IRC_CONFIG_LOOK_NICK_COLOR_HASH_DJB2 = 0, - IRC_CONFIG_LOOK_NICK_COLOR_HASH_SUM, -}; - enum t_irc_config_look_nick_mode { IRC_CONFIG_LOOK_NICK_MODE_NONE = 0, @@ -120,7 +114,6 @@ extern struct t_config_option *irc_config_look_highlight_channel; extern struct t_config_option *irc_config_look_highlight_pv; extern struct t_config_option *irc_config_look_highlight_server; extern struct t_config_option *irc_config_look_highlight_tags_restrict; -extern struct t_config_option *irc_config_look_item_away_message; extern struct t_config_option *irc_config_look_item_channel_modes_hide_args; extern struct t_config_option *irc_config_look_item_display_server; extern struct t_config_option *irc_config_look_item_nick_modes; @@ -129,9 +122,6 @@ extern struct t_config_option *irc_config_look_join_auto_add_chantype; extern struct t_config_option *irc_config_look_msgbuffer_fallback; extern struct t_config_option *irc_config_look_new_channel_position; extern struct t_config_option *irc_config_look_new_pv_position; -extern struct t_config_option *irc_config_look_nick_color_force; -extern struct t_config_option *irc_config_look_nick_color_hash; -extern struct t_config_option *irc_config_look_nick_color_stop_chars; extern struct t_config_option *irc_config_look_nick_completion_smart; extern struct t_config_option *irc_config_look_nick_mode; extern struct t_config_option *irc_config_look_nick_mode_empty; @@ -157,7 +147,6 @@ extern struct t_config_option *irc_config_look_temporary_servers; extern struct t_config_option *irc_config_look_topic_strip_colors; extern struct t_config_option *irc_config_color_input_nick; -extern struct t_config_option *irc_config_color_item_away; extern struct t_config_option *irc_config_color_item_channel_modes; extern struct t_config_option *irc_config_color_item_lag_counting; extern struct t_config_option *irc_config_color_item_lag_finished; @@ -172,7 +161,6 @@ extern struct t_config_option *irc_config_color_topic_current; extern struct t_config_option *irc_config_color_topic_new; extern struct t_config_option *irc_config_color_topic_old; -extern struct t_config_option *irc_config_network_alternate_nick; extern struct t_config_option *irc_config_network_autoreconnect_delay_growing; extern struct t_config_option *irc_config_network_autoreconnect_delay_max; extern struct t_config_option *irc_config_network_ban_mask_default; @@ -186,27 +174,23 @@ extern struct t_config_option *irc_config_network_lag_reconnect; extern struct t_config_option *irc_config_network_lag_refresh_interval; extern struct t_config_option *irc_config_network_notify_check_ison; extern struct t_config_option *irc_config_network_notify_check_whois; +extern struct t_config_option *irc_config_network_sasl_fail_unavailable; extern struct t_config_option *irc_config_network_send_unknown_commands; extern struct t_config_option *irc_config_network_whois_double_nick; extern struct t_config_option *irc_config_server_default[]; -extern char **irc_config_nick_colors; -extern int irc_config_num_nick_colors; - extern struct t_hashtable *irc_config_hashtable_display_join_message; -extern struct t_hashtable *irc_config_hashtable_nick_color_force; extern struct t_hashtable *irc_config_hashtable_nick_prefixes; extern struct t_hashtable *irc_config_hashtable_color_mirc_remap; extern char **irc_config_nicks_hide_password; extern int irc_config_num_nicks_hide_password; -extern void irc_config_set_nick_colors (); extern int irc_config_display_channel_modes_arguments (const char *modes); -extern int irc_config_server_check_value_cb (void *data, +extern int irc_config_server_check_value_cb (const void *pointer, void *data, struct t_config_option *option, const char *value); -extern void irc_config_server_change_cb (void *data, +extern void irc_config_server_change_cb (const void *pointer, void *data, struct t_config_option *option); struct t_config_option *irc_config_server_new_option (struct t_config_file *config_file, struct t_config_section *section, @@ -215,12 +199,16 @@ struct t_config_option *irc_config_server_new_option (struct t_config_file *conf const char *default_value, const char *value, int null_value_allowed, - int (*callback_check_value)(void *data, + int (*callback_check_value)(const void *pointer, + void *data, struct t_config_option *option, const char *value), + const void *callback_check_value_pointer, void *callback_check_value_data, - void (*callback_change)(void *data, + void (*callback_change)(const void *pointer, + void *data, struct t_config_option *option), + const void *callback_change_pointer, void *callback_change_data); extern int irc_config_init (); extern int irc_config_read (); diff --git a/src/plugins/irc/irc-ctcp.c b/src/plugins/irc/irc-ctcp.c index 55d7c6b2e..5f2aeec95 100644 --- a/src/plugins/irc/irc-ctcp.c +++ b/src/plugins/irc/irc-ctcp.c @@ -1,7 +1,7 @@ /* * irc-ctcp.c - IRC CTCP protocol * - * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org> + * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org> * * This file is part of WeeChat, the extensible chat client. * @@ -291,10 +291,11 @@ irc_ctcp_reply_to_nick (struct t_irc_server *server, str_args_color = irc_color_decode (str_args, 1); if (!str_args_color) break; - weechat_printf_tags ( + weechat_printf_date_tags ( irc_msgbuffer_get_target_buffer ( server, nick, NULL, "ctcp", (channel) ? channel->buffer : NULL), + 0, irc_protocol_tags ( command, "irc_ctcp,irc_ctcp_reply,notify_none,no_highlight", diff --git a/src/plugins/irc/irc-ctcp.h b/src/plugins/irc/irc-ctcp.h index 179f2ed21..0febcd0cc 100644 --- a/src/plugins/irc/irc-ctcp.h +++ b/src/plugins/irc/irc-ctcp.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org> + * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org> * * This file is part of WeeChat, the extensible chat client. * diff --git a/src/plugins/irc/irc-debug.c b/src/plugins/irc/irc-debug.c index ea33f0a37..22e1c255c 100644 --- a/src/plugins/irc/irc-debug.c +++ b/src/plugins/irc/irc-debug.c @@ -1,7 +1,7 @@ /* * irc-debug.c - debug functions for IRC plugin * - * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org> + * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org> * * This file is part of WeeChat, the extensible chat client. * @@ -35,10 +35,12 @@ */ int -irc_debug_signal_debug_dump_cb (void *data, const char *signal, +irc_debug_signal_debug_dump_cb (const void *pointer, void *data, + const char *signal, const char *type_data, void *signal_data) { /* make C compiler happy */ + (void) pointer; (void) data; (void) signal; (void) type_data; @@ -69,5 +71,6 @@ irc_debug_signal_debug_dump_cb (void *data, const char *signal, void irc_debug_init () { - weechat_hook_signal ("debug_dump", &irc_debug_signal_debug_dump_cb, NULL); + weechat_hook_signal ("debug_dump", + &irc_debug_signal_debug_dump_cb, NULL, NULL); } diff --git a/src/plugins/irc/irc-debug.h b/src/plugins/irc/irc-debug.h index 199d9e7af..8daa12139 100644 --- a/src/plugins/irc/irc-debug.h +++ b/src/plugins/irc/irc-debug.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org> + * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org> * * This file is part of WeeChat, the extensible chat client. * diff --git a/src/plugins/irc/irc-ignore.c b/src/plugins/irc/irc-ignore.c index 2f18a4fea..0d69a9dfc 100644 --- a/src/plugins/irc/irc-ignore.c +++ b/src/plugins/irc/irc-ignore.c @@ -1,7 +1,7 @@ /* * irc-ignore.c - ignore (nicks/hosts) management for IRC plugin * - * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org> + * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org> * * This file is part of WeeChat, the extensible chat client. * @@ -308,11 +308,13 @@ irc_ignore_free_all () */ struct t_hdata * -irc_ignore_hdata_ignore_cb (void *data, const char *hdata_name) +irc_ignore_hdata_ignore_cb (const void *pointer, void *data, + const char *hdata_name) { struct t_hdata *hdata; /* make C compiler happy */ + (void) pointer; (void) data; hdata = weechat_hdata_new (hdata_name, "prev_ignore", "next_ignore", diff --git a/src/plugins/irc/irc-ignore.h b/src/plugins/irc/irc-ignore.h index 70d37c85f..0c6335e49 100644 --- a/src/plugins/irc/irc-ignore.h +++ b/src/plugins/irc/irc-ignore.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org> + * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org> * * This file is part of WeeChat, the extensible chat client. * @@ -51,7 +51,8 @@ extern int irc_ignore_check (struct t_irc_server *server, const char *host); extern void irc_ignore_free (struct t_irc_ignore *ignore); extern void irc_ignore_free_all (); -extern struct t_hdata *irc_ignore_hdata_ignore_cb (void *data, +extern struct t_hdata *irc_ignore_hdata_ignore_cb (const void *pointer, + void *data, const char *hdata_name); extern int irc_ignore_add_to_infolist (struct t_infolist *infolist, struct t_irc_ignore *ignore); diff --git a/src/plugins/irc/irc-info.c b/src/plugins/irc/irc-info.c index f905a6a4b..d4f75439d 100644 --- a/src/plugins/irc/irc-info.c +++ b/src/plugins/irc/irc-info.c @@ -1,7 +1,7 @@ /* * irc-info.c - info, infolist and hdata hooks for IRC plugin * - * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org> + * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org> * * This file is part of WeeChat, the extensible chat client. * @@ -64,7 +64,8 @@ irc_info_create_string_with_pointer (char **string, void *pointer) */ const char * -irc_info_info_irc_is_channel_cb (void *data, const char *info_name, +irc_info_info_irc_is_channel_cb (const void *pointer, void *data, + const char *info_name, const char *arguments) { char *pos_comma, *server; @@ -73,6 +74,7 @@ irc_info_info_irc_is_channel_cb (void *data, const char *info_name, struct t_irc_server *ptr_server; /* make C compiler happy */ + (void) pointer; (void) data; (void) info_name; @@ -99,12 +101,14 @@ irc_info_info_irc_is_channel_cb (void *data, const char *info_name, */ const char * -irc_info_info_irc_is_nick_cb (void *data, const char *info_name, +irc_info_info_irc_is_nick_cb (const void *pointer, void *data, + const char *info_name, const char *arguments) { static char str_true[2] = "1"; /* make C compiler happy */ + (void) pointer; (void) data; (void) info_name; @@ -118,12 +122,14 @@ irc_info_info_irc_is_nick_cb (void *data, const char *info_name, */ const char * -irc_info_info_irc_nick_cb (void *data, const char *info_name, +irc_info_info_irc_nick_cb (const void *pointer, void *data, + const char *info_name, const char *arguments) { struct t_irc_server *ptr_server; /* make C compiler happy */ + (void) pointer; (void) data; (void) info_name; @@ -142,10 +148,12 @@ irc_info_info_irc_nick_cb (void *data, const char *info_name, */ const char * -irc_info_info_irc_nick_from_host_cb (void *data, const char *info_name, +irc_info_info_irc_nick_from_host_cb (const void *pointer, void *data, + const char *info_name, const char *arguments) { /* make C compiler happy */ + (void) pointer; (void) data; (void) info_name; @@ -158,10 +166,12 @@ irc_info_info_irc_nick_from_host_cb (void *data, const char *info_name, */ const char * -irc_info_info_irc_nick_color_cb (void *data, const char *info_name, +irc_info_info_irc_nick_color_cb (const void *pointer, void *data, + const char *info_name, const char *arguments) { /* make C compiler happy */ + (void) pointer; (void) data; (void) info_name; @@ -174,10 +184,12 @@ irc_info_info_irc_nick_color_cb (void *data, const char *info_name, */ const char * -irc_info_info_irc_nick_color_name_cb (void *data, const char *info_name, +irc_info_info_irc_nick_color_name_cb (const void *pointer, void *data, + const char *info_name, const char *arguments) { /* make C compiler happy */ + (void) pointer; (void) data; (void) info_name; @@ -190,7 +202,8 @@ irc_info_info_irc_nick_color_name_cb (void *data, const char *info_name, */ const char * -irc_info_info_irc_buffer_cb (void *data, const char *info_name, +irc_info_info_irc_buffer_cb (const void *pointer, void *data, + const char *info_name, const char *arguments) { char *pos_comma, *pos_comma2, *server, *channel, *host; @@ -199,6 +212,7 @@ irc_info_info_irc_buffer_cb (void *data, const char *info_name, struct t_irc_channel *ptr_channel; /* make C compiler happy */ + (void) pointer; (void) data; (void) info_name; @@ -282,7 +296,8 @@ irc_info_info_irc_buffer_cb (void *data, const char *info_name, */ const char * -irc_info_info_irc_server_isupport_cb (void *data, const char *info_name, +irc_info_info_irc_server_isupport_cb (const void *pointer, void *data, + const char *info_name, const char *arguments) { char *pos_comma, *server; @@ -291,6 +306,7 @@ irc_info_info_irc_server_isupport_cb (void *data, const char *info_name, struct t_irc_server *ptr_server; /* make C compiler happy */ + (void) pointer; (void) data; (void) info_name; @@ -317,7 +333,8 @@ irc_info_info_irc_server_isupport_cb (void *data, const char *info_name, */ const char * -irc_info_info_irc_server_isupport_value_cb (void *data, const char *info_name, +irc_info_info_irc_server_isupport_value_cb (const void *pointer, void *data, + const char *info_name, const char *arguments) { char *pos_comma, *server; @@ -325,6 +342,7 @@ irc_info_info_irc_server_isupport_value_cb (void *data, const char *info_name, struct t_irc_server *ptr_server; /* make C compiler happy */ + (void) pointer; (void) data; (void) info_name; @@ -351,7 +369,7 @@ irc_info_info_irc_server_isupport_value_cb (void *data, const char *info_name, */ struct t_hashtable * -irc_info_info_hashtable_irc_message_parse_cb (void *data, +irc_info_info_hashtable_irc_message_parse_cb (const void *pointer, void *data, const char *info_name, struct t_hashtable *hashtable) { @@ -360,6 +378,7 @@ irc_info_info_hashtable_irc_message_parse_cb (void *data, struct t_hashtable *value; /* make C compiler happy */ + (void) pointer; (void) data; (void) info_name; @@ -383,7 +402,7 @@ irc_info_info_hashtable_irc_message_parse_cb (void *data, */ struct t_hashtable * -irc_info_info_hashtable_irc_message_split_cb (void *data, +irc_info_info_hashtable_irc_message_split_cb (const void *pointer, void *data, const char *info_name, struct t_hashtable *hashtable) { @@ -392,6 +411,7 @@ irc_info_info_hashtable_irc_message_split_cb (void *data, struct t_hashtable *value; /* make C compiler happy */ + (void) pointer; (void) data; (void) info_name; @@ -415,27 +435,29 @@ irc_info_info_hashtable_irc_message_split_cb (void *data, */ struct t_infolist * -irc_info_infolist_irc_server_cb (void *data, const char *infolist_name, - void *pointer, const char *arguments) +irc_info_infolist_irc_server_cb (const void *pointer, void *data, + const char *infolist_name, + void *obj_pointer, const char *arguments) { struct t_infolist *ptr_infolist; struct t_irc_server *ptr_server; /* make C compiler happy */ + (void) pointer; (void) data; (void) infolist_name; - if (pointer && !irc_server_valid (pointer)) + if (obj_pointer && !irc_server_valid (obj_pointer)) return NULL; ptr_infolist = weechat_infolist_new (); if (!ptr_infolist) return NULL; - if (pointer) + if (obj_pointer) { /* build list with only one server */ - if (!irc_server_add_to_infolist (ptr_infolist, pointer)) + if (!irc_server_add_to_infolist (ptr_infolist, obj_pointer)) { weechat_infolist_free (ptr_infolist); return NULL; @@ -469,8 +491,9 @@ irc_info_infolist_irc_server_cb (void *data, const char *infolist_name, */ struct t_infolist * -irc_info_infolist_irc_channel_cb (void *data, const char *infolist_name, - void *pointer, const char *arguments) +irc_info_infolist_irc_channel_cb (const void *pointer, void *data, + const char *infolist_name, + void *obj_pointer, const char *arguments) { struct t_infolist *ptr_infolist; struct t_irc_server *ptr_server; @@ -479,6 +502,7 @@ irc_info_infolist_irc_channel_cb (void *data, const char *infolist_name, int argc; /* make C compiler happy */ + (void) pointer; (void) data; (void) infolist_name; @@ -499,10 +523,10 @@ irc_info_infolist_irc_channel_cb (void *data, const char *infolist_name, weechat_string_free_split (argv); return NULL; } - if (!pointer && (argc >= 2)) + if (!obj_pointer && (argc >= 2)) { - pointer = irc_channel_search (ptr_server, argv[1]); - if (!pointer) + obj_pointer = irc_channel_search (ptr_server, argv[1]); + if (!obj_pointer) { weechat_string_free_split (argv); return NULL; @@ -514,17 +538,17 @@ irc_info_infolist_irc_channel_cb (void *data, const char *infolist_name, if (!ptr_server) return NULL; - if (pointer && !irc_channel_valid (ptr_server, pointer)) + if (obj_pointer && !irc_channel_valid (ptr_server, obj_pointer)) return NULL; ptr_infolist = weechat_infolist_new (); if (!ptr_infolist) return NULL; - if (pointer) + if (obj_pointer) { /* build list with only one channel */ - if (!irc_channel_add_to_infolist (ptr_infolist, pointer)) + if (!irc_channel_add_to_infolist (ptr_infolist, obj_pointer)) { weechat_infolist_free (ptr_infolist); return NULL; @@ -554,8 +578,9 @@ irc_info_infolist_irc_channel_cb (void *data, const char *infolist_name, */ struct t_infolist * -irc_info_infolist_irc_nick_cb (void *data, const char *infolist_name, - void *pointer, const char *arguments) +irc_info_infolist_irc_nick_cb (const void *pointer, void *data, + const char *infolist_name, + void *obj_pointer, const char *arguments) { struct t_infolist *ptr_infolist; struct t_irc_server *ptr_server; @@ -565,6 +590,7 @@ irc_info_infolist_irc_nick_cb (void *data, const char *infolist_name, int argc; /* make C compiler happy */ + (void) pointer; (void) data; (void) infolist_name; @@ -591,11 +617,11 @@ irc_info_infolist_irc_nick_cb (void *data, const char *infolist_name, weechat_string_free_split (argv); return NULL; } - if (!pointer && (argc >= 3)) + if (!obj_pointer && (argc >= 3)) { - pointer = irc_nick_search (ptr_server, ptr_channel, + obj_pointer = irc_nick_search (ptr_server, ptr_channel, argv[2]); - if (!pointer) + if (!obj_pointer) { weechat_string_free_split (argv); return NULL; @@ -607,18 +633,18 @@ irc_info_infolist_irc_nick_cb (void *data, const char *infolist_name, if (!ptr_server || !ptr_channel) return NULL; - if (pointer && !irc_nick_valid (ptr_channel, pointer)) + if (obj_pointer && !irc_nick_valid (ptr_channel, obj_pointer)) return NULL; ptr_infolist = weechat_infolist_new (); if (!ptr_infolist) return NULL; - if (pointer) + if (obj_pointer) { /* build list with only one nick */ if (!irc_nick_add_to_infolist (ptr_infolist, - pointer)) + obj_pointer)) { weechat_infolist_free (ptr_infolist); return NULL; @@ -649,28 +675,30 @@ irc_info_infolist_irc_nick_cb (void *data, const char *infolist_name, */ struct t_infolist * -irc_info_infolist_irc_ignore_cb (void *data, const char *infolist_name, - void *pointer, const char *arguments) +irc_info_infolist_irc_ignore_cb (const void *pointer, void *data, + const char *infolist_name, + void *obj_pointer, const char *arguments) { struct t_infolist *ptr_infolist; struct t_irc_ignore *ptr_ignore; /* make C compiler happy */ + (void) pointer; (void) data; (void) infolist_name; (void) arguments; - if (pointer && !irc_ignore_valid (pointer)) + if (obj_pointer && !irc_ignore_valid (obj_pointer)) return NULL; ptr_infolist = weechat_infolist_new (); if (!ptr_infolist) return NULL; - if (pointer) + if (obj_pointer) { /* build list with only one ignore */ - if (!irc_ignore_add_to_infolist (ptr_infolist, pointer)) + if (!irc_ignore_add_to_infolist (ptr_infolist, obj_pointer)) { weechat_infolist_free (ptr_infolist); return NULL; @@ -700,28 +728,30 @@ irc_info_infolist_irc_ignore_cb (void *data, const char *infolist_name, */ struct t_infolist * -irc_info_infolist_irc_notify_cb (void *data, const char *infolist_name, - void *pointer, const char *arguments) +irc_info_infolist_irc_notify_cb (const void *pointer, void *data, + const char *infolist_name, + void *obj_pointer, const char *arguments) { struct t_infolist *ptr_infolist; struct t_irc_server *ptr_server; struct t_irc_notify *ptr_notify; /* make C compiler happy */ + (void) pointer; (void) data; (void) infolist_name; - if (pointer && !irc_notify_valid (NULL, pointer)) + if (obj_pointer && !irc_notify_valid (NULL, obj_pointer)) return NULL; ptr_infolist = weechat_infolist_new (); if (!ptr_infolist) return NULL; - if (pointer) + if (obj_pointer) { /* build list with only one notify */ - if (!irc_notify_add_to_infolist (ptr_infolist, pointer)) + if (!irc_notify_add_to_infolist (ptr_infolist, obj_pointer)) { weechat_infolist_free (ptr_infolist); return NULL; @@ -760,15 +790,18 @@ irc_info_infolist_irc_notify_cb (void *data, const char *infolist_name, */ struct t_infolist * -irc_info_infolist_irc_color_weechat_cb (void *data, const char *infolist_name, - void *pointer, const char *arguments) +irc_info_infolist_irc_color_weechat_cb (const void *pointer, void *data, + const char *infolist_name, + void *obj_pointer, + const char *arguments) { struct t_infolist *ptr_infolist; /* make C compiler happy */ + (void) pointer; (void) data; (void) infolist_name; - (void) pointer; + (void) obj_pointer; (void) arguments; ptr_infolist = weechat_infolist_new (); @@ -796,47 +829,49 @@ irc_info_init () "irc_is_channel", N_("1 if string is a valid IRC channel name for server"), N_("server,channel (server is optional)"), - &irc_info_info_irc_is_channel_cb, NULL); + &irc_info_info_irc_is_channel_cb, NULL, NULL); weechat_hook_info ( "irc_is_nick", N_("1 if string is a valid IRC nick name"), N_("nickname"), - &irc_info_info_irc_is_nick_cb, NULL); + &irc_info_info_irc_is_nick_cb, NULL, NULL); weechat_hook_info ( "irc_nick", N_("get current nick on a server"), N_("server name"), - &irc_info_info_irc_nick_cb, NULL); + &irc_info_info_irc_nick_cb, NULL, NULL); weechat_hook_info ( "irc_nick_from_host", N_("get nick from IRC host"), N_("IRC host (like `:nick!name@server.com`)"), - &irc_info_info_irc_nick_from_host_cb, NULL); + &irc_info_info_irc_nick_from_host_cb, NULL, NULL); weechat_hook_info ( "irc_nick_color", - N_("get nick color code"), + N_("get nick color code " + "(*deprecated* since version 1.5, replaced by \"nick_color\")"), N_("nickname"), - &irc_info_info_irc_nick_color_cb, NULL); + &irc_info_info_irc_nick_color_cb, NULL, NULL); weechat_hook_info ( "irc_nick_color_name", - N_("get nick color name"), + N_("get nick color name " + "(*deprecated* since version 1.5, replaced by \"nick_color_name\")"), N_("nickname"), - &irc_info_info_irc_nick_color_name_cb, NULL); + &irc_info_info_irc_nick_color_name_cb, NULL, NULL); weechat_hook_info ( "irc_buffer", N_("get buffer pointer for an IRC server/channel/nick"), N_("server,channel,nick (channel and nicks are optional)"), - &irc_info_info_irc_buffer_cb, NULL); + &irc_info_info_irc_buffer_cb, NULL, NULL); weechat_hook_info ( "irc_server_isupport", N_("1 if server supports this feature (from IRC message 005)"), N_("server,feature"), - &irc_info_info_irc_server_isupport_cb, NULL); + &irc_info_info_irc_server_isupport_cb, NULL, NULL); weechat_hook_info ( "irc_server_isupport_value", N_("value of feature, if supported by server (from IRC message 005)"), N_("server,feature"), - &irc_info_info_irc_server_isupport_value_cb, NULL); + &irc_info_info_irc_server_isupport_value_cb, NULL, NULL); /* info_hashtable hooks */ weechat_hook_info_hashtable ( @@ -860,7 +895,7 @@ irc_info_init () "\"channel\" was not found), " "\"pos_text\": index of \"text\" message (\"-1\" if " "\"text\" was not found)"), - &irc_info_info_hashtable_irc_message_parse_cb, NULL); + &irc_info_info_hashtable_irc_message_parse_cb, NULL, NULL); weechat_hook_info_hashtable ( "irc_message_split", N_("split an IRC message (to fit in 512 bytes)"), @@ -869,7 +904,7 @@ irc_info_init () N_("\"msg1\" ... \"msgN\": messages to send (without final \"\\r\\n\"), " "\"args1\" ... \"argsN\": arguments of messages, \"count\": number " "of messages"), - &irc_info_info_hashtable_irc_message_split_cb, NULL); + &irc_info_info_hashtable_irc_message_split_cb, NULL, NULL); /* infolist hooks */ weechat_hook_infolist ( @@ -877,61 +912,61 @@ irc_info_init () N_("list of IRC servers"), N_("server pointer (optional)"), N_("server name (wildcard \"*\" is allowed) (optional)"), - &irc_info_infolist_irc_server_cb, NULL); + &irc_info_infolist_irc_server_cb, NULL, NULL); weechat_hook_infolist ( "irc_channel", N_("list of channels for an IRC server"), N_("channel pointer (optional)"), N_("server,channel (channel is optional)"), - &irc_info_infolist_irc_channel_cb, NULL); + &irc_info_infolist_irc_channel_cb, NULL, NULL); weechat_hook_infolist ( "irc_nick", N_("list of nicks for an IRC channel"), N_("nick pointer (optional)"), N_("server,channel,nick (nick is optional)"), - &irc_info_infolist_irc_nick_cb, NULL); + &irc_info_infolist_irc_nick_cb, NULL, NULL); weechat_hook_infolist ( "irc_ignore", N_("list of IRC ignores"), N_("ignore pointer (optional)"), NULL, - &irc_info_infolist_irc_ignore_cb, NULL); + &irc_info_infolist_irc_ignore_cb, NULL, NULL); weechat_hook_infolist ( "irc_notify", N_("list of notify"), N_("notify pointer (optional)"), N_("server name (wildcard \"*\" is allowed) (optional)"), - &irc_info_infolist_irc_notify_cb, NULL); + &irc_info_infolist_irc_notify_cb, NULL, NULL); weechat_hook_infolist ( "irc_color_weechat", N_("mapping between IRC color codes and WeeChat color names"), NULL, NULL, - &irc_info_infolist_irc_color_weechat_cb, NULL); + &irc_info_infolist_irc_color_weechat_cb, NULL, NULL); /* hdata hooks */ weechat_hook_hdata ( "irc_nick", N_("irc nick"), - &irc_nick_hdata_nick_cb, NULL); + &irc_nick_hdata_nick_cb, NULL, NULL); weechat_hook_hdata ( "irc_channel", N_("irc channel"), - &irc_channel_hdata_channel_cb, NULL); + &irc_channel_hdata_channel_cb, NULL, NULL); weechat_hook_hdata ( "irc_channel_speaking", N_("irc channel_speaking"), - &irc_channel_hdata_channel_speaking_cb, NULL); + &irc_channel_hdata_channel_speaking_cb, NULL, NULL); weechat_hook_hdata ( "irc_ignore", N_("irc ignore"), - &irc_ignore_hdata_ignore_cb, NULL); + &irc_ignore_hdata_ignore_cb, NULL, NULL); weechat_hook_hdata ( "irc_notify", N_("irc notify"), - &irc_notify_hdata_notify_cb, NULL); + &irc_notify_hdata_notify_cb, NULL, NULL); weechat_hook_hdata ( "irc_redirect_pattern", N_("pattern for irc redirect"), - &irc_redirect_hdata_redirect_pattern_cb, NULL); + &irc_redirect_hdata_redirect_pattern_cb, NULL, NULL); weechat_hook_hdata ( "irc_redirect", N_("irc redirect"), - &irc_redirect_hdata_redirect_cb, NULL); + &irc_redirect_hdata_redirect_cb, NULL, NULL); weechat_hook_hdata ( "irc_server", N_("irc server"), - &irc_server_hdata_server_cb, NULL); + &irc_server_hdata_server_cb, NULL, NULL); } diff --git a/src/plugins/irc/irc-info.h b/src/plugins/irc/irc-info.h index 888a1d93a..7f50323a8 100644 --- a/src/plugins/irc/irc-info.h +++ b/src/plugins/irc/irc-info.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org> + * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org> * * This file is part of WeeChat, the extensible chat client. * diff --git a/src/plugins/irc/irc-input.c b/src/plugins/irc/irc-input.c index f7e3b5af3..bad329b77 100644 --- a/src/plugins/irc/irc-input.c +++ b/src/plugins/irc/irc-input.c @@ -1,7 +1,7 @@ /* * irc-input.c - input data management for IRC buffers * - * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org> + * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org> * * This file is part of WeeChat, the extensible chat client. * @@ -98,8 +98,9 @@ irc_input_user_message_display (struct t_gui_buffer *buffer, int action, ptr_text = (text_decoded) ? text_decoded : ((text2) ? text2 : text); if (action) { - weechat_printf_tags ( + weechat_printf_date_tags ( buffer, + 0, irc_protocol_tags ( "privmsg", str_tags, (ptr_nick) ? ptr_nick->name : ptr_server->nick, @@ -114,8 +115,9 @@ irc_input_user_message_display (struct t_gui_buffer *buffer, int action, } else { - weechat_printf_tags ( + weechat_printf_date_tags ( buffer, + 0, irc_protocol_tags ( "privmsg", str_tags, (ptr_nick) ? ptr_nick->name : ptr_server->nick, @@ -189,7 +191,8 @@ irc_input_send_user_message (struct t_gui_buffer *buffer, int flags, */ int -irc_input_data (struct t_gui_buffer *buffer, const char *input_data, int flags) +irc_input_data (struct t_gui_buffer *buffer, const char *input_data, int flags, + int force_user_message) { const char *ptr_data; char *data_with_colors, *msg; @@ -207,7 +210,8 @@ irc_input_data (struct t_gui_buffer *buffer, const char *input_data, int flags) * if send unknown commands is enabled and that input data is a * command, then send this command to IRC server */ - if (weechat_config_boolean (irc_config_network_send_unknown_commands) + if (!force_user_message + && weechat_config_boolean (irc_config_network_send_unknown_commands) && !weechat_string_input_for_buffer (input_data)) { if (ptr_server) @@ -220,9 +224,13 @@ irc_input_data (struct t_gui_buffer *buffer, const char *input_data, int flags) if (ptr_channel) { - ptr_data = weechat_string_input_for_buffer (input_data); - if (!ptr_data) - ptr_data = input_data; + ptr_data = input_data; + if (!force_user_message) + { + ptr_data = weechat_string_input_for_buffer (input_data); + if (!ptr_data) + ptr_data = input_data; + } data_with_colors = irc_color_encode ( ptr_data, weechat_config_boolean (irc_config_network_colors_send)); @@ -253,13 +261,16 @@ irc_input_data (struct t_gui_buffer *buffer, const char *input_data, int flags) */ int -irc_input_data_cb (void *data, struct t_gui_buffer *buffer, +irc_input_data_cb (const void *pointer, void *data, + struct t_gui_buffer *buffer, const char *input_data) { /* make C compiler happy */ + (void) pointer; (void) data; - return irc_input_data (buffer, input_data, IRC_SERVER_SEND_OUTQ_PRIO_HIGH); + return irc_input_data (buffer, input_data, + IRC_SERVER_SEND_OUTQ_PRIO_HIGH, 0); } /* @@ -268,28 +279,32 @@ irc_input_data_cb (void *data, struct t_gui_buffer *buffer, * This signal can be used by other plugins/scripts, it simulates input or * command from user on an IRC buffer (it is used for example by Relay plugin). * - * Format of signal_data (string) is "server;channel;flags;tags;text" + * Format of signal_data (string) is "server;channel;options;tags;text" * server: server name (required) * channel: channel name (optional) - * flags: flags for irc_server_sendf() (optional) + * options: comma-separated list of options (optional): + * "priority_high": send with high priority (default) + * "priority_low": send with low priority + * "user_message": force user message (don't execute a command) * tags: tags for irc_server_sendf() (optional) * text: text or command (required). */ int -irc_input_send_cb (void *data, const char *signal, +irc_input_send_cb (const void *pointer, void *data, + const char *signal, const char *type_data, void *signal_data) { const char *ptr_string, *ptr_message; - char *pos_semicol1, *pos_semicol2, *pos_semicol3, *pos_semicol4, *error; - char *server, *channel, *flags, *tags; - long flags_value; - char *data_with_colors; + char *pos_semicol1, *pos_semicol2, *pos_semicol3, *pos_semicol4; + char *server, *channel, *options, *tags, *data_with_colors, **list_options; + int i, num_options, flags, force_user_message; struct t_irc_server *ptr_server; struct t_irc_channel *ptr_channel; struct t_gui_buffer *ptr_buffer; /* make C compiler happy */ + (void) pointer; (void) data; (void) signal; (void) type_data; @@ -298,7 +313,9 @@ irc_input_send_cb (void *data, const char *signal, server = NULL; channel = NULL; - flags = NULL; + options = NULL; + flags = IRC_SERVER_SEND_OUTQ_PRIO_HIGH; + force_user_message = 0; tags = NULL; ptr_message = NULL; ptr_server = NULL; @@ -324,8 +341,8 @@ irc_input_send_cb (void *data, const char *signal, { if (pos_semicol3 > pos_semicol2 + 1) { - flags = weechat_strndup (pos_semicol2 + 1, - pos_semicol3 - pos_semicol2 - 1); + options = weechat_strndup (pos_semicol2 + 1, + pos_semicol3 - pos_semicol2 - 1); } pos_semicol4 = strchr (pos_semicol3 + 1, ';'); if (pos_semicol4) @@ -341,13 +358,22 @@ irc_input_send_cb (void *data, const char *signal, } } - flags_value = IRC_SERVER_SEND_OUTQ_PRIO_HIGH; - if (flags) + if (options && options[0]) { - error = NULL; - flags_value = strtol (flags, &error, 10); - if (flags_value < 0) - flags_value = IRC_SERVER_SEND_OUTQ_PRIO_HIGH; + list_options = weechat_string_split (options, ",", 0, 0, &num_options); + if (list_options) + { + for (i = 0; i < num_options; i++) + { + if (strcmp (list_options[i], "priority_high") == 0) + flags = IRC_SERVER_SEND_OUTQ_PRIO_HIGH; + else if (strcmp (list_options[i], "priority_low") == 0) + flags = IRC_SERVER_SEND_OUTQ_PRIO_LOW; + else if (strcmp (list_options[i], "user_message") == 0) + force_user_message = 1; + } + weechat_string_free_split (list_options); + } } if (server && ptr_message) @@ -367,10 +393,11 @@ irc_input_send_cb (void *data, const char *signal, irc_server_set_send_default_tags (tags); /* send text to buffer, or execute command */ - if (weechat_string_input_for_buffer (ptr_message)) + if (force_user_message + || weechat_string_input_for_buffer (ptr_message)) { /* text as input */ - irc_input_data (ptr_buffer, ptr_message, flags_value); + irc_input_data (ptr_buffer, ptr_message, flags, 1); } else { @@ -394,8 +421,8 @@ irc_input_send_cb (void *data, const char *signal, free (server); if (channel) free (channel); - if (flags) - free (flags); + if (options) + free (options); if (tags) free (tags); diff --git a/src/plugins/irc/irc-input.h b/src/plugins/irc/irc-input.h index f4fc4bdb4..4d8315992 100644 --- a/src/plugins/irc/irc-input.h +++ b/src/plugins/irc/irc-input.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org> + * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org> * * This file is part of WeeChat, the extensible chat client. * @@ -24,9 +24,11 @@ struct t_gui_buffer; extern void irc_input_user_message_display (struct t_gui_buffer *buffer, int action, const char *text); -extern int irc_input_data_cb (void *data, struct t_gui_buffer *buffer, +extern int irc_input_data_cb (const void *pointer, void *data, + struct t_gui_buffer *buffer, const char *input_data); -extern int irc_input_send_cb (void *data, const char *signal, - const char *type_data, void *signal_data); +extern int irc_input_send_cb (const void *pointer, void *data, + const char *signal, const char *type_data, + void *signal_data); #endif /* WEECHAT_IRC_INPUT_H */ diff --git a/src/plugins/irc/irc-message.c b/src/plugins/irc/irc-message.c index e0c4dcf4f..5e1e1b604 100644 --- a/src/plugins/irc/irc-message.c +++ b/src/plugins/irc/irc-message.c @@ -1,7 +1,7 @@ /* * irc-message.c - functions for IRC messages * - * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org> + * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org> * * This file is part of WeeChat, the extensible chat client. * @@ -70,7 +70,7 @@ irc_message_parse (struct t_irc_server *server, const char *message, int *pos_command, int *pos_arguments, int *pos_channel, int *pos_text) { - const char *ptr_message, *pos, *pos2, *pos3, *pos4; + const char *ptr_message, *pos, *pos2, *pos3, *pos4, *ptr_channel_found; if (tags) *tags = NULL; @@ -96,6 +96,7 @@ irc_message_parse (struct t_irc_server *server, const char *message, *pos_channel = -1; if (pos_text) *pos_text = -1; + ptr_channel_found = NULL; if (!message) return; @@ -209,6 +210,7 @@ irc_message_parse (struct t_irc_server *server, const char *message, { if (irc_channel_is_channel (server, pos)) { + ptr_channel_found = pos; pos2 = strchr (pos, ' '); if (channel) { @@ -253,6 +255,7 @@ irc_message_parse (struct t_irc_server *server, const char *message, } if (irc_channel_is_channel (server, pos2)) { + ptr_channel_found = pos2; pos4 = strchr (pos2, ' '); if (channel) { @@ -277,13 +280,38 @@ irc_message_parse (struct t_irc_server *server, const char *message, *pos_text = pos4 - message; } } - else if ((channel && !*channel) - || (pos_channel && (*pos_channel < 0))) + else { - if (channel) - *channel = weechat_strndup (pos, pos3 - pos); - if (pos_channel) - *pos_channel = pos - message; + if (ptr_channel_found) + { + if (pos[0] == ':') + pos++; + if (text) + *text = strdup (pos); + if (pos_text) + *pos_text = pos - message; + } + else + { + if (channel) + *channel = weechat_strndup (pos, pos3 - pos); + if (pos_channel) + *pos_channel = pos - message; + pos4 = strchr (pos3, ' '); + if (pos4) + { + while (pos4[0] == ' ') + { + pos4++; + } + if (pos4[0] == ':') + pos4++; + if (text) + *text = strdup (pos4); + if (pos_text) + *pos_text = pos4 - message; + } + } } } } @@ -334,8 +362,7 @@ irc_message_parse_to_hashtable (struct t_irc_server *server, hashtable = weechat_hashtable_new (32, WEECHAT_HASHTABLE_STRING, WEECHAT_HASHTABLE_STRING, - NULL, - NULL); + NULL, NULL); if (!hashtable) return NULL; @@ -980,8 +1007,7 @@ irc_message_split (struct t_irc_server *server, const char *message) hashtable = weechat_hashtable_new (32, WEECHAT_HASHTABLE_STRING, WEECHAT_HASHTABLE_STRING, - NULL, - NULL); + NULL, NULL); if (!hashtable) return NULL; diff --git a/src/plugins/irc/irc-message.h b/src/plugins/irc/irc-message.h index 026595b7e..a4478115c 100644 --- a/src/plugins/irc/irc-message.h +++ b/src/plugins/irc/irc-message.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org> + * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org> * * This file is part of WeeChat, the extensible chat client. * diff --git a/src/plugins/irc/irc-mode.c b/src/plugins/irc/irc-mode.c index 163e9cdd7..a31d64388 100644 --- a/src/plugins/irc/irc-mode.c +++ b/src/plugins/irc/irc-mode.c @@ -1,7 +1,7 @@ /* * irc-mode.c - IRC channel/user modes management * - * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org> + * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org> * * This file is part of WeeChat, the extensible chat client. * diff --git a/src/plugins/irc/irc-mode.h b/src/plugins/irc/irc-mode.h index f6a498626..8dbd2220e 100644 --- a/src/plugins/irc/irc-mode.h +++ b/src/plugins/irc/irc-mode.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org> + * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org> * * This file is part of WeeChat, the extensible chat client. * diff --git a/src/plugins/irc/irc-msgbuffer.c b/src/plugins/irc/irc-msgbuffer.c index 0e58a417a..27708fccb 100644 --- a/src/plugins/irc/irc-msgbuffer.c +++ b/src/plugins/irc/irc-msgbuffer.c @@ -1,7 +1,7 @@ /* * irc-msgbuffer.c - target buffer for IRC messages * - * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org> + * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org> * * This file is part of WeeChat, the extensible chat client. * diff --git a/src/plugins/irc/irc-msgbuffer.h b/src/plugins/irc/irc-msgbuffer.h index 370c2dd92..a27e7daa2 100644 --- a/src/plugins/irc/irc-msgbuffer.h +++ b/src/plugins/irc/irc-msgbuffer.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org> + * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org> * * This file is part of WeeChat, the extensible chat client. * diff --git a/src/plugins/irc/irc-nick.c b/src/plugins/irc/irc-nick.c index 0877f331a..6f01f48d8 100644 --- a/src/plugins/irc/irc-nick.c +++ b/src/plugins/irc/irc-nick.c @@ -1,7 +1,7 @@ /* * irc-nick.c - nick management for IRC plugin * - * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org> + * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org> * * This file is part of WeeChat, the extensible chat client. * @@ -93,130 +93,6 @@ irc_nick_is_nick (const char *string) } /* - * Duplicates a nick and stops at first char in list (using option - * irc.look.nick_color_stop_chars). - * - * Note: result must be freed after use. - */ - -char * -irc_nick_strdup_for_color (const char *nickname) -{ - int char_size, other_char_seen; - char *result, *pos, utf_char[16]; - - result = malloc (strlen (nickname) + 1); - pos = result; - other_char_seen = 0; - while (nickname[0]) - { - char_size = weechat_utf8_char_size (nickname); - memcpy (utf_char, nickname, char_size); - utf_char[char_size] = '\0'; - - if (strstr (weechat_config_string (irc_config_look_nick_color_stop_chars), - utf_char)) - { - if (other_char_seen) - { - pos[0] = '\0'; - return result; - } - } - else - { - other_char_seen = 1; - } - memcpy (pos, utf_char, char_size); - pos += char_size; - - nickname += char_size; - } - pos[0] = '\0'; - return result; -} - -/* - * Hashes a nickname to find color. - * - * Returns a number which is the index of color in the nicks colors of option - * "weechat.color.chat_nick_colors". - */ - -int -irc_nick_hash_color (const char *nickname) -{ - unsigned long color; - const char *ptr_nick; - - if (!irc_config_nick_colors) - irc_config_set_nick_colors (); - - if (irc_config_num_nick_colors == 0) - return 0; - - ptr_nick = nickname; - color = 0; - - switch (weechat_config_integer (irc_config_look_nick_color_hash)) - { - case IRC_CONFIG_LOOK_NICK_COLOR_HASH_DJB2: - /* variant of djb2 hash */ - color = 5381; - while (ptr_nick && ptr_nick[0]) - { - color ^= (color << 5) + (color >> 2) + weechat_utf8_char_int (ptr_nick); - ptr_nick = weechat_utf8_next_char (ptr_nick); - } - break; - case IRC_CONFIG_LOOK_NICK_COLOR_HASH_SUM: - /* sum of letters */ - color = 0; - while (ptr_nick && ptr_nick[0]) - { - color += weechat_utf8_char_int (ptr_nick); - ptr_nick = weechat_utf8_next_char (ptr_nick); - } - break; - } - - return (color % irc_config_num_nick_colors); -} - -/* - * Gets forced color for a nick. - * - * Returns the name of color (for example: "green"), NULL if no color is forced - * for nick. - */ - -const char * -irc_nick_get_forced_color (const char *nickname) -{ - const char *forced_color; - char *nick_lower; - - if (!nickname) - return NULL; - - forced_color = weechat_hashtable_get (irc_config_hashtable_nick_color_force, - nickname); - if (forced_color) - return forced_color; - - nick_lower = strdup (nickname); - if (nick_lower) - { - weechat_string_tolower (nick_lower); - forced_color = weechat_hashtable_get (irc_config_hashtable_nick_color_force, - nick_lower); - free (nick_lower); - } - - return forced_color; -} - -/* * Finds a color code for a nick (according to nick letters). * * Returns a WeeChat color code (that can be used for display). @@ -225,34 +101,7 @@ irc_nick_get_forced_color (const char *nickname) const char * irc_nick_find_color (const char *nickname) { - int color; - char *nickname2; - const char *forced_color, *str_color; - - if (!irc_config_nick_colors) - irc_config_set_nick_colors (); - - if (irc_config_num_nick_colors == 0) - return weechat_color ("default"); - - /* look if color is forced */ - forced_color = irc_nick_get_forced_color (nickname); - if (forced_color) - { - forced_color = weechat_color (forced_color); - if (forced_color && forced_color[0]) - return forced_color; - } - - /* hash nickname to get color */ - nickname2 = irc_nick_strdup_for_color (nickname); - color = irc_nick_hash_color ((nickname2) ? nickname2 : nickname); - if (nickname2) - free (nickname2); - - /* return color */ - str_color = weechat_color (irc_config_nick_colors[color]); - return (str_color[0]) ? str_color : weechat_color("default"); + return weechat_info_get ("nick_color", nickname); } /* @@ -264,30 +113,7 @@ irc_nick_find_color (const char *nickname) const char * irc_nick_find_color_name (const char *nickname) { - int color; - char *nickname2; - const char *forced_color; - static char *default_color = "default"; - - if (!irc_config_nick_colors) - irc_config_set_nick_colors (); - - if (irc_config_num_nick_colors == 0) - return default_color; - - /* look if color is forced */ - forced_color = irc_nick_get_forced_color (nickname); - if (forced_color) - return forced_color; - - /* hash nickname to get color */ - nickname2 = irc_nick_strdup_for_color (nickname); - color = irc_nick_hash_color ((nickname2) ? nickname2 : nickname); - if (nickname2) - free (nickname2); - - /* return color name */ - return irc_config_nick_colors[color]; + return weechat_info_get ("nick_color_name", nickname); } /* @@ -626,7 +452,7 @@ irc_nick_nicklist_set_color_all () struct t_irc_nick * irc_nick_new (struct t_irc_server *server, struct t_irc_channel *channel, const char *nickname, const char *host, const char *prefixes, - int away, const char *account) + int away, const char *account, const char *realname) { struct t_irc_nick *new_nick, *ptr_nick; int length; @@ -650,6 +476,9 @@ irc_nick_new (struct t_irc_server *server, struct t_irc_channel *channel, if (ptr_nick->account) free (ptr_nick->account); ptr_nick->account = (account) ? strdup (account) : NULL; + if (ptr_nick->realname) + free (ptr_nick->realname); + ptr_nick->realname = (realname) ? strdup (realname) : NULL; /* add new nick in nicklist */ irc_nick_nicklist_add (server, channel, ptr_nick); @@ -665,6 +494,7 @@ irc_nick_new (struct t_irc_server *server, struct t_irc_channel *channel, new_nick->name = strdup (nickname); new_nick->host = (host) ? strdup (host) : NULL; new_nick->account = (account) ? strdup (account) : NULL; + new_nick->realname = (realname) ? strdup (realname) : NULL; length = strlen (irc_server_get_prefix_chars (server)); new_nick->prefixes = malloc (length + 1); if (!new_nick->name || !new_nick->prefixes) @@ -675,6 +505,8 @@ irc_nick_new (struct t_irc_server *server, struct t_irc_channel *channel, free (new_nick->host); if (new_nick->account) free (new_nick->account); + if (new_nick->realname) + free (new_nick->realname); if (new_nick->prefixes) free (new_nick->prefixes); free (new_nick); @@ -817,6 +649,8 @@ irc_nick_free (struct t_irc_server *server, struct t_irc_channel *channel, free (nick->prefixes); if (nick->account) free (nick->account); + if (nick->realname) + free (nick->realname); if (nick->color) free (nick->color); @@ -1120,11 +954,13 @@ irc_nick_default_ban_mask (struct t_irc_nick *nick) */ struct t_hdata * -irc_nick_hdata_nick_cb (void *data, const char *hdata_name) +irc_nick_hdata_nick_cb (const void *pointer, void *data, + const char *hdata_name) { struct t_hdata *hdata; /* make C compiler happy */ + (void) pointer; (void) data; hdata = weechat_hdata_new (hdata_name, "prev_nick", "next_nick", @@ -1137,6 +973,7 @@ irc_nick_hdata_nick_cb (void *data, const char *hdata_name) WEECHAT_HDATA_VAR(struct t_irc_nick, prefix, STRING, 0, NULL, NULL); WEECHAT_HDATA_VAR(struct t_irc_nick, away, INTEGER, 0, NULL, NULL); WEECHAT_HDATA_VAR(struct t_irc_nick, account, STRING, 0, NULL, NULL); + WEECHAT_HDATA_VAR(struct t_irc_nick, realname, STRING, 0, NULL, NULL); WEECHAT_HDATA_VAR(struct t_irc_nick, color, STRING, 0, NULL, NULL); WEECHAT_HDATA_VAR(struct t_irc_nick, prev_nick, POINTER, 0, NULL, hdata_name); WEECHAT_HDATA_VAR(struct t_irc_nick, next_nick, POINTER, 0, NULL, hdata_name); @@ -1177,6 +1014,8 @@ irc_nick_add_to_infolist (struct t_infolist *infolist, return 0; if (!weechat_infolist_new_var_string (ptr_item, "account", nick->account)) return 0; + if (!weechat_infolist_new_var_string (ptr_item, "realname", nick->realname)) + return 0; if (!weechat_infolist_new_var_string (ptr_item, "color", nick->color)) return 0; @@ -1197,6 +1036,7 @@ irc_nick_print_log (struct t_irc_nick *nick) weechat_log_printf (" prefix . . . . : '%s'", nick->prefix); weechat_log_printf (" away . . . . . : %d", nick->away); weechat_log_printf (" account. . . . : '%s'", nick->account); + weechat_log_printf (" realname . . . : '%s'", nick->realname); weechat_log_printf (" color. . . . . : '%s'", nick->color); weechat_log_printf (" prev_nick. . . : 0x%lx", nick->prev_nick); weechat_log_printf (" next_nick. . . : 0x%lx", nick->next_nick); diff --git a/src/plugins/irc/irc-nick.h b/src/plugins/irc/irc-nick.h index 3079a437b..b8109a7cc 100644 --- a/src/plugins/irc/irc-nick.h +++ b/src/plugins/irc/irc-nick.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org> + * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org> * * This file is part of WeeChat, the extensible chat client. * @@ -39,6 +39,7 @@ struct t_irc_nick /* prefixes) */ int away; /* 1 if nick is away */ char *account; /* account name of the user */ + char *realname; /* realname (aka gecos) of the user */ char *color; /* color for nickname */ struct t_irc_nick *prev_nick; /* link to previous nick on channel */ struct t_irc_nick *next_nick; /* link to next nick on channel */ @@ -47,8 +48,6 @@ struct t_irc_nick extern int irc_nick_valid (struct t_irc_channel *channel, struct t_irc_nick *nick); extern int irc_nick_is_nick (const char *string); -extern int irc_nick_config_colors_cb (void *data, const char *option, - const char *value); extern const char *irc_nick_find_color (const char *nickname); extern const char *irc_nick_find_color_name (const char *nickname); extern int irc_nick_is_op (struct t_irc_server *server, @@ -66,7 +65,8 @@ extern struct t_irc_nick *irc_nick_new (struct t_irc_server *server, const char *host, const char *prefixes, int away, - const char *account); + const char *account, + const char *realname); extern void irc_nick_change (struct t_irc_server *server, struct t_irc_channel *channel, struct t_irc_nick *nick, const char *new_nick); @@ -102,7 +102,8 @@ extern const char *irc_nick_color_for_msg (struct t_irc_server *server, extern const char * irc_nick_color_for_pv (struct t_irc_channel *channel, const char *nickname); extern char *irc_nick_default_ban_mask (struct t_irc_nick *nick); -extern struct t_hdata *irc_nick_hdata_nick_cb (void *data, +extern struct t_hdata *irc_nick_hdata_nick_cb (const void *pointer, + void *data, const char *hdata_name); extern int irc_nick_add_to_infolist (struct t_infolist *infolist, struct t_irc_nick *nick); diff --git a/src/plugins/irc/irc-notify.c b/src/plugins/irc/irc-notify.c index cb9a2e590..c58c668fe 100644 --- a/src/plugins/irc/irc-notify.c +++ b/src/plugins/irc/irc-notify.c @@ -1,7 +1,7 @@ /* * irc-notify.c - notify lists for IRC plugin * - * Copyright (C) 2010-2015 Sébastien Helleu <flashcode@flashtux.org> + * Copyright (C) 2010-2016 Sébastien Helleu <flashcode@flashtux.org> * * This file is part of WeeChat, the extensible chat client. * @@ -672,8 +672,9 @@ irc_notify_set_is_on_server (struct t_irc_notify *notify, const char *host, if (notify->is_on_server == is_on_server) return; - weechat_printf_tags ( + weechat_printf_date_tags ( notify->server->buffer, + 0, irc_notify_get_tags (irc_config_look_notify_tags_ison, (is_on_server) ? "join" : "quit", notify->nick), @@ -719,8 +720,9 @@ irc_notify_set_away_message (struct t_irc_notify *notify, if (!notify->away_message && away_message) { - weechat_printf_tags ( + weechat_printf_date_tags ( notify->server->buffer, + 0, irc_notify_get_tags ( irc_config_look_notify_tags_whois, "away", notify->nick), _("%snotify: %s%s%s is now away: \"%s\""), @@ -733,8 +735,9 @@ irc_notify_set_away_message (struct t_irc_notify *notify, } else if (notify->away_message && !away_message) { - weechat_printf_tags ( + weechat_printf_date_tags ( notify->server->buffer, + 0, irc_notify_get_tags ( irc_config_look_notify_tags_whois, "back", notify->nick), _("%snotify: %s%s%s is back"), @@ -746,8 +749,9 @@ irc_notify_set_away_message (struct t_irc_notify *notify, } else if (notify->away_message && away_message) { - weechat_printf_tags ( + weechat_printf_date_tags ( notify->server->buffer, + 0, irc_notify_get_tags ( irc_config_look_notify_tags_whois, "still_away", notify->nick), _("%snotify: %s%s%s is still away: \"%s\""), @@ -769,7 +773,7 @@ irc_notify_set_away_message (struct t_irc_notify *notify, */ int -irc_notify_hsignal_cb (void *data, const char *signal, +irc_notify_hsignal_cb (const void *pointer, void *data, const char *signal, struct t_hashtable *hashtable) { const char *error, *server, *pattern, *command, *output; @@ -781,6 +785,7 @@ irc_notify_hsignal_cb (void *data, const char *signal, struct t_irc_notify *ptr_notify; /* make C compiler happy */ + (void) pointer; (void) data; (void) signal; @@ -962,7 +967,7 @@ irc_notify_hsignal_cb (void *data, const char *signal, */ int -irc_notify_timer_ison_cb (void *data, int remaining_calls) +irc_notify_timer_ison_cb (const void *pointer, void *data, int remaining_calls) { char *message, hash_key[32]; const char *str_message; @@ -971,6 +976,7 @@ irc_notify_timer_ison_cb (void *data, int remaining_calls) struct t_hashtable *hashtable; /* make C compiler happy */ + (void) pointer; (void) data; (void) remaining_calls; @@ -1021,12 +1027,14 @@ irc_notify_timer_ison_cb (void *data, int remaining_calls) */ int -irc_notify_timer_whois_cb (void *data, int remaining_calls) +irc_notify_timer_whois_cb (const void *pointer, void *data, + int remaining_calls) { struct t_irc_server *ptr_server; struct t_irc_notify *ptr_notify, *ptr_next_notify; /* make C compiler happy */ + (void) pointer; (void) data; (void) remaining_calls; @@ -1067,11 +1075,13 @@ irc_notify_timer_whois_cb (void *data, int remaining_calls) */ struct t_hdata * -irc_notify_hdata_notify_cb (void *data, const char *hdata_name) +irc_notify_hdata_notify_cb (const void *pointer, void *data, + const char *hdata_name) { struct t_hdata *hdata; /* make C compiler happy */ + (void) pointer; (void) data; hdata = weechat_hdata_new (hdata_name, "prev_notify", "next_notify", @@ -1164,7 +1174,7 @@ irc_notify_hook_timer_ison () irc_notify_timer_ison = weechat_hook_timer ( 60 * 1000 * weechat_config_integer (irc_config_network_notify_check_ison), - 0, 0, &irc_notify_timer_ison_cb, NULL); + 0, 0, &irc_notify_timer_ison_cb, NULL, NULL); } /* @@ -1179,7 +1189,7 @@ irc_notify_hook_timer_whois () irc_notify_timer_whois = weechat_hook_timer ( 60 * 1000 * weechat_config_integer (irc_config_network_notify_check_whois), - 0, 0, &irc_notify_timer_whois_cb, NULL); + 0, 0, &irc_notify_timer_whois_cb, NULL, NULL); } /* @@ -1194,7 +1204,7 @@ irc_notify_init () irc_notify_hsignal = weechat_hook_hsignal ("irc_redirection_notify_*", &irc_notify_hsignal_cb, - NULL); + NULL, NULL); } /* diff --git a/src/plugins/irc/irc-notify.h b/src/plugins/irc/irc-notify.h index 19c310dba..f290cd0b0 100644 --- a/src/plugins/irc/irc-notify.h +++ b/src/plugins/irc/irc-notify.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010-2015 Sébastien Helleu <flashcode@flashtux.org> + * Copyright (C) 2010-2016 Sébastien Helleu <flashcode@flashtux.org> * * This file is part of WeeChat, the extensible chat client. * @@ -60,9 +60,12 @@ extern void irc_notify_set_is_on_server (struct t_irc_notify *notify, extern void irc_notify_free_all (struct t_irc_server *server); extern void irc_notify_display_list (struct t_irc_server *server); extern void irc_notify_send_monitor (struct t_irc_server *server); -extern int irc_notify_timer_ison_cb (void *data, int remaining_calls); -extern int irc_notify_timer_whois_cb (void *data, int remaining_calls); -extern struct t_hdata *irc_notify_hdata_notify_cb (void *data, +extern int irc_notify_timer_ison_cb (const void *pointer, void *data, + int remaining_calls); +extern int irc_notify_timer_whois_cb (const void *pointer, void *data, + int remaining_calls); +extern struct t_hdata *irc_notify_hdata_notify_cb (const void *pointer, + void *data, const char *hdata_name); extern int irc_notify_add_to_infolist (struct t_infolist *infolist, struct t_irc_notify *notify); diff --git a/src/plugins/irc/irc-protocol.c b/src/plugins/irc/irc-protocol.c index f3d7bff92..26f497d5d 100644 --- a/src/plugins/irc/irc-protocol.c +++ b/src/plugins/irc/irc-protocol.c @@ -1,7 +1,7 @@ /* * irc-protocol.c - implementation of IRC protocol (RFCs 1459/2810/2811/2812/2813) * - * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org> + * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org> * Copyright (C) 2006 Emmanuel Bouthenot <kolter@openics.org> * Copyright (C) 2014 Shawn Smith <ShawnSmith0828@gmail.com> * @@ -206,9 +206,12 @@ IRC_PROTOCOL_CALLBACK(account) { struct t_irc_channel *ptr_channel; struct t_irc_nick *ptr_nick; + char *pos_account; IRC_PROTOCOL_MIN_ARGS(3); + pos_account = (strcmp (argv[2], "*") != 0) ? argv[2] : NULL; + for (ptr_channel = server->channels; ptr_channel; ptr_channel = ptr_channel->next_channel) { @@ -217,8 +220,8 @@ IRC_PROTOCOL_CALLBACK(account) { if (ptr_nick->account) free (ptr_nick->account); - ptr_nick->account = (server->cap_account_notify) ? - strdup (argv[2]) : strdup ("*"); + ptr_nick->account = (server->cap_account_notify && pos_account) ? + strdup (pos_account) : NULL; } } @@ -337,12 +340,12 @@ IRC_PROTOCOL_CALLBACK(away) IRC_PROTOCOL_CALLBACK(cap) { - char *ptr_caps, **caps_supported, **caps_requested, *cap_option, *cap_req; - char str_msg_auth[512]; + char *ptr_caps, **caps_supported, **caps_requested, **caps_added; + char **caps_removed, *cap_option, *cap_req, str_msg_auth[512]; const char *ptr_cap_option; - int num_caps_supported, num_caps_requested; - int sasl_requested, sasl_to_do, sasl_mechanism; - int i, j, timeout, length; + int num_caps_supported, num_caps_requested, num_caps_added; + int num_caps_removed, sasl_requested, sasl_to_do, sasl_mechanism; + int sasl_fail, i, j, timeout, length; IRC_PROTOCOL_MIN_ARGS(4); @@ -363,9 +366,11 @@ IRC_PROTOCOL_CALLBACK(cap) { sasl_requested = irc_server_sasl_enabled (server); sasl_to_do = 0; - ptr_cap_option = IRC_SERVER_OPTION_STRING(server, - IRC_SERVER_OPTION_CAPABILITIES); - length = ((ptr_cap_option && ptr_cap_option[0]) ? strlen (ptr_cap_option) : 0) + 16; + ptr_cap_option = IRC_SERVER_OPTION_STRING( + server, + IRC_SERVER_OPTION_CAPABILITIES); + length = ((ptr_cap_option && ptr_cap_option[0]) ? + strlen (ptr_cap_option) : 0) + 16; cap_option = malloc (length); cap_req = malloc (length); if (cap_option && cap_req) @@ -422,8 +427,21 @@ IRC_PROTOCOL_CALLBACK(cap) { weechat_printf ( server->buffer, - _("%s%s: client capability: sasl not supported"), + _("%s%s: client capability: SASL not supported"), weechat_prefix ("network"), IRC_PLUGIN_NAME); + + if (weechat_config_boolean (irc_config_network_sasl_fail_unavailable)) + { + /* same handling as for sasl_end_fail */ + sasl_fail = IRC_SERVER_OPTION_INTEGER(server, IRC_SERVER_OPTION_SASL_FAIL); + if ((sasl_fail == IRC_SERVER_SASL_FAIL_RECONNECT) + || (sasl_fail == IRC_SERVER_SASL_FAIL_DISCONNECT)) + { + irc_server_disconnect ( + server, 0, + (sasl_fail == IRC_SERVER_SASL_FAIL_RECONNECT) ? 1 : 0); + } + } } } if (cap_option) @@ -442,7 +460,7 @@ IRC_PROTOCOL_CALLBACK(cap) server->buffer, date, NULL, _("%s%s: client capability, currently enabled: %s"), weechat_prefix ("network"), IRC_PLUGIN_NAME, ptr_caps); - } + } } else if (strcmp (argv[3], "ACK") == 0) { @@ -473,6 +491,10 @@ IRC_PROTOCOL_CALLBACK(cap) { server->cap_account_notify = 1; } + else if (strcmp (caps_supported[i], "extended-join") == 0) + { + server->cap_extended_join = 1; + } } weechat_string_free_split (caps_supported); } @@ -496,7 +518,7 @@ IRC_PROTOCOL_CALLBACK(cap) timeout * 1000, 0, 1, &irc_server_timer_sasl_cb, - server); + server, NULL); } } } @@ -514,6 +536,103 @@ IRC_PROTOCOL_CALLBACK(cap) irc_server_sendf (server, 0, NULL, "CAP END"); } } + else if (strcmp (argv[3], "NEW") == 0) + { + if (argc > 4) + { + ptr_caps = (argv_eol[4][0] == ':') ? argv_eol[4] + 1 : argv_eol[4]; + weechat_printf_date_tags ( + server->buffer, date, NULL, + _("%s%s: client capability, now available: %s"), + weechat_prefix ("network"), IRC_PLUGIN_NAME, ptr_caps); + + /* + * assume that we're not requesting any already-enabled + * capabilities + * TODO: SASL Reauthentication + */ + ptr_cap_option = IRC_SERVER_OPTION_STRING( + server, + IRC_SERVER_OPTION_CAPABILITIES); + length = ((ptr_cap_option && ptr_cap_option[0]) ? + strlen (ptr_cap_option) : 0) + 16; + cap_option = malloc (length); + cap_req = malloc (length); + if (cap_option && cap_req) + { + cap_option[0] = '\0'; + if (ptr_cap_option && ptr_cap_option[0]) + strcat (cap_option, ptr_cap_option); + cap_req[0] = '\0'; + caps_requested = weechat_string_split (cap_option, ",", 0, 0, + &num_caps_requested); + caps_added = weechat_string_split (ptr_caps, " ", 0, 0, + &num_caps_added); + if (caps_requested && caps_added) + { + for (i = 0; i < num_caps_requested; i++) + { + for (j = 0; j < num_caps_added; j++) + { + if (weechat_strcasecmp (caps_requested[i], + caps_added[j]) == 0) + { + if (cap_req[0]) + strcat (cap_req, " "); + strcat (cap_req, caps_added[j]); + } + } + } + } + if (caps_requested) + weechat_string_free_split (caps_requested); + if (caps_added) + weechat_string_free_split (caps_added); + if (cap_req[0]) + { + weechat_printf ( + server->buffer, + _("%s%s: client capability, requesting: %s"), + weechat_prefix ("network"), IRC_PLUGIN_NAME, + cap_req); + irc_server_sendf (server, 0, NULL, + "CAP REQ :%s", cap_req); + } + } + if (cap_option) + free (cap_option); + if (cap_req) + free (cap_req); + } + } + else if (strcmp (argv[3], "DEL") == 0) + { + if (argc > 4) + { + ptr_caps = (argv_eol[4][0] == ':') ? argv_eol[4] + 1 : argv_eol[4]; + weechat_printf_date_tags ( + server->buffer, date, NULL, + _("%s%s: client capability, removed: %s"), + weechat_prefix ("network"), IRC_PLUGIN_NAME, ptr_caps); + caps_removed = weechat_string_split (ptr_caps, " ", 0, 0, + &num_caps_removed); + if (caps_removed) + { + for (i = 0; i < num_caps_removed; i++) + { + if (strcmp (caps_removed[i], "away-notify") == 0) + { + server->cap_away_notify = 0; + } + else if (strcmp (caps_removed[i], "account-notify") == 0) + { + server->cap_account_notify = 0; + } + } + weechat_string_free_split (caps_removed); + } + } + } return WEECHAT_RC_OK; } @@ -648,7 +767,7 @@ IRC_PROTOCOL_CALLBACK(invite) * * With extended-join capability: * :nick!user@host JOIN :#channel * :real name - * *nick!user@host JOIN :#channel account :real name + * :nick!user@host JOIN :#channel account :real name */ IRC_PROTOCOL_CALLBACK(join) @@ -743,7 +862,8 @@ IRC_PROTOCOL_CALLBACK(join) /* add nick in channel */ ptr_nick = irc_nick_new (server, ptr_channel, nick, address, NULL, 0, - (pos_account) ? pos_account : "*"); + (pos_account) ? pos_account : NULL, + (pos_realname) ? pos_realname : NULL); /* rename the nick if it was in list with a different case */ irc_channel_nick_speaking_rename_if_present (server, ptr_channel, nick); @@ -915,7 +1035,7 @@ IRC_PROTOCOL_CALLBACK(kick) IRC_SERVER_OPTION_AUTOREJOIN_DELAY) * 1000, 0, 1, &irc_channel_autorejoin_cb, - ptr_channel); + ptr_channel, NULL); } } @@ -1179,7 +1299,7 @@ IRC_PROTOCOL_CALLBACK(nick) /* temporary disable hotlist */ weechat_buffer_set (NULL, "hotlist", "-"); - /* set host for nick if needed */ + /* set host in nick if needed */ if (!ptr_nick->host) ptr_nick->host = strdup (address); @@ -4068,7 +4188,7 @@ IRC_PROTOCOL_CALLBACK(352) ptr_nick = (ptr_channel) ? irc_nick_search (server, ptr_channel, argv[7]) : NULL; - /* update host for nick */ + /* update host in nick */ if (ptr_nick) { if (ptr_nick->host) @@ -4079,13 +4199,22 @@ IRC_PROTOCOL_CALLBACK(352) snprintf (ptr_nick->host, length, "%s@%s", argv[4], argv[5]); } - /* update away flag for nick */ + /* update away flag in nick */ if (ptr_channel && ptr_nick && pos_attr) { irc_nick_set_away (server, ptr_channel, ptr_nick, (pos_attr[0] == 'G') ? 1 : 0); } + /* update realname in nick */ + if (ptr_channel && ptr_nick && pos_realname) + { + if (ptr_nick->realname) + free (ptr_nick->realname); + ptr_nick->realname = (pos_realname && server->cap_extended_join) ? + strdup (pos_realname) : NULL; + } + /* display output of who (manual who from user) */ if (!ptr_channel || (ptr_channel->checking_whox <= 0)) { @@ -4196,7 +4325,7 @@ IRC_PROTOCOL_CALLBACK(353) if (ptr_channel && ptr_channel->nicks) { if (!irc_nick_new (server, ptr_channel, nickname, pos_host, - prefixes, 0, "*")) + prefixes, 0, NULL, NULL)) { weechat_printf ( server->buffer, @@ -4291,7 +4420,7 @@ IRC_PROTOCOL_CALLBACK(354) ptr_nick = (ptr_channel) ? irc_nick_search (server, ptr_channel, argv[7]) : NULL; - /* update host for nick */ + /* update host in nick */ if (ptr_nick) { if (ptr_nick->host) @@ -4305,7 +4434,7 @@ IRC_PROTOCOL_CALLBACK(354) snprintf (ptr_nick->host, length, "%s@%s", argv[4], argv[5]); } - /* update away flag for nick */ + /* update away flag in nick */ if (ptr_channel && ptr_nick) { if (pos_attr @@ -4326,14 +4455,24 @@ IRC_PROTOCOL_CALLBACK(354) } } - /* update account flag for nick */ + /* update account flag in nick */ if (ptr_nick) { if (ptr_nick->account) free (ptr_nick->account); ptr_nick->account = (ptr_channel && pos_account && server->cap_account_notify) ? - strdup (pos_account) : strdup ("*"); + strdup (pos_account) : NULL; + } + + /* update realname in nick */ + if (ptr_nick) + { + if (ptr_nick->realname) + free (ptr_nick->realname); + ptr_nick->realname = (ptr_channel && pos_realname + && server->cap_extended_join) ? + strdup (pos_realname) : NULL; } /* display output of who (manual who from user) */ @@ -4912,6 +5051,74 @@ IRC_PROTOCOL_CALLBACK(438) } /* + * Callback for the IRC message "470": forwarding to another channel. + * + * Message looks like: + * :server 470 mynick #channel ##channel :Forwarding to another channel + */ + +IRC_PROTOCOL_CALLBACK(470) +{ + struct t_gui_buffer *ptr_buffer; + struct t_gui_lines *own_lines; + const char *buffer_name, *short_name, *localvar_channel; + int lines_count; + + irc_protocol_cb_generic_error (server, + date, nick, address, host, command, + ignored, argc, argv, argv_eol); + + if ((argc >= 5) && !irc_channel_search (server, argv[3])) + { + ptr_buffer = irc_channel_search_buffer (server, + IRC_CHANNEL_TYPE_CHANNEL, + argv[3]); + if (ptr_buffer) + { + short_name = weechat_buffer_get_string (ptr_buffer, "short_name"); + localvar_channel = weechat_buffer_get_string (ptr_buffer, + "localvar_channel"); + if (!short_name + || (localvar_channel + && (strcmp (localvar_channel, short_name) == 0))) + { + /* + * update the short_name only if it was not changed by the + * user + */ + weechat_buffer_set (ptr_buffer, "short_name", argv[4]); + } + buffer_name = irc_buffer_build_name (server->name, argv[4]); + weechat_buffer_set (ptr_buffer, "name", buffer_name); + weechat_buffer_set (ptr_buffer, "localvar_set_channel", argv[4]); + + /* + * check if logger backlog should be displayed for the new channel + * name: it is displayed only if the buffer is currently completely + * empty (no messages at all) + */ + lines_count = 0; + own_lines = weechat_hdata_pointer (weechat_hdata_get ("buffer"), + ptr_buffer, "own_lines"); + if (own_lines) + { + lines_count = weechat_hdata_integer ( + weechat_hdata_get ("lines"), + own_lines, "lines_count"); + } + if (lines_count == 0) + { + (void) weechat_hook_signal_send ("logger_backlog", + WEECHAT_HOOK_SIGNAL_POINTER, + ptr_buffer); + } + } + } + + return WEECHAT_RC_OK; +} + +/* * Callback for the IRC message "728": quietlist. * * Message looks like: @@ -5177,8 +5384,13 @@ IRC_PROTOCOL_CALLBACK(733) IRC_PROTOCOL_CALLBACK(734) { + char *pos_args; + IRC_PROTOCOL_MIN_ARGS(5); + pos_args = (argc > 5) ? + ((argv_eol[5][0] == ':') ? argv_eol[5] + 1 : argv_eol[5]) : NULL; + weechat_printf_date_tags ( irc_msgbuffer_get_target_buffer ( server, NULL, command, "monitor", NULL), @@ -5186,7 +5398,7 @@ IRC_PROTOCOL_CALLBACK(734) irc_protocol_tags (command, "irc_numeric", NULL, NULL), "%s%s (%s)", weechat_prefix ("error"), - (argv_eol[5][0] == ':') ? argv_eol[5] + 1 : argv_eol[5], + (pos_args && pos_args[0]) ? pos_args : "", argv[3]); return WEECHAT_RC_OK; @@ -5324,8 +5536,7 @@ irc_protocol_get_message_tags (const char *tags) hashtable = weechat_hashtable_new (32, WEECHAT_HASHTABLE_STRING, WEECHAT_HASHTABLE_STRING, - NULL, - NULL); + NULL, NULL); if (!hashtable) return NULL; @@ -5544,7 +5755,7 @@ irc_protocol_recv_command (struct t_irc_server *server, { "464", /* password incorrect */ 1, 0, &irc_protocol_cb_generic_error }, { "465", /* you are banned from this server */ 1, 0, &irc_protocol_cb_generic_error }, { "467", /* channel key already set */ 1, 0, &irc_protocol_cb_generic_error }, - { "470", /* forwarding to another channel */ 1, 0, &irc_protocol_cb_generic_error }, + { "470", /* forwarding to another channel */ 1, 0, &irc_protocol_cb_470 }, { "471", /* channel is already full */ 1, 0, &irc_protocol_cb_generic_error }, { "472", /* unknown mode char to me */ 1, 0, &irc_protocol_cb_generic_error }, { "473", /* cannot join channel (invite only) */ 1, 0, &irc_protocol_cb_generic_error }, diff --git a/src/plugins/irc/irc-protocol.h b/src/plugins/irc/irc-protocol.h index c1f88d0d5..186a0729b 100644 --- a/src/plugins/irc/irc-protocol.h +++ b/src/plugins/irc/irc-protocol.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org> + * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org> * * This file is part of WeeChat, the extensible chat client. * diff --git a/src/plugins/irc/irc-raw.c b/src/plugins/irc/irc-raw.c index 598e2abee..fb560eea6 100644 --- a/src/plugins/irc/irc-raw.c +++ b/src/plugins/irc/irc-raw.c @@ -1,7 +1,7 @@ /* * irc-raw.c - functions for IRC raw data messages * - * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org> + * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org> * * This file is part of WeeChat, the extensible chat client. * @@ -72,9 +72,10 @@ irc_raw_open (int switch_to_buffer) IRC_RAW_BUFFER_NAME); if (!irc_raw_buffer) { - irc_raw_buffer = weechat_buffer_new (IRC_RAW_BUFFER_NAME, - &irc_input_data_cb, NULL, - &irc_buffer_close_cb, NULL); + irc_raw_buffer = weechat_buffer_new ( + IRC_RAW_BUFFER_NAME, + &irc_input_data_cb, NULL, NULL, + &irc_buffer_close_cb, NULL, NULL); /* failed to create buffer ? then return */ if (!irc_raw_buffer) @@ -229,71 +230,85 @@ irc_raw_message_add (struct t_irc_server *server, int flags, int pos_buf, pos_buf2, char_size, i; struct t_irc_raw_message *new_raw_message; - buf = weechat_iconv_to_internal (NULL, message); - buf2 = malloc ((strlen (buf) * 4) + 1); - if (buf2) + buf = NULL; + buf2 = NULL; + + if (flags & IRC_RAW_FLAG_BINARY) + { + buf = weechat_string_hex_dump (message, strlen (message), 16, + " > ", NULL); + snprintf (prefix, sizeof (prefix), " "); + } + else { - ptr_buf = (buf) ? (unsigned char *)buf : (unsigned char *)message; - pos_buf = 0; - pos_buf2 = 0; - while (ptr_buf[pos_buf]) + buf = weechat_iconv_to_internal (NULL, message); + buf2 = malloc ((strlen (buf) * 4) + 1); + if (buf2) { - if (ptr_buf[pos_buf] < 32) + ptr_buf = (buf) ? (unsigned char *)buf : (unsigned char *)message; + pos_buf = 0; + pos_buf2 = 0; + while (ptr_buf[pos_buf]) { - buf2[pos_buf2++] = '\\'; - buf2[pos_buf2++] = 'x'; - buf2[pos_buf2++] = hexa[ptr_buf[pos_buf] / 16]; - buf2[pos_buf2++] = hexa[ptr_buf[pos_buf] % 16]; - pos_buf++; - } - else - { - char_size = weechat_utf8_char_size ((const char *)(ptr_buf + pos_buf)); - for (i = 0; i < char_size; i++) + if ((ptr_buf[pos_buf] < 32) + || !weechat_utf8_is_valid ((const char *)(ptr_buf + pos_buf), + 1, NULL)) { - buf2[pos_buf2++] = ptr_buf[pos_buf++]; + buf2[pos_buf2++] = '\\'; + buf2[pos_buf2++] = 'x'; + buf2[pos_buf2++] = hexa[ptr_buf[pos_buf] / 16]; + buf2[pos_buf2++] = hexa[ptr_buf[pos_buf] % 16]; + pos_buf++; + } + else + { + char_size = weechat_utf8_char_size ((const char *)(ptr_buf + pos_buf)); + for (i = 0; i < char_size; i++) + { + buf2[pos_buf2++] = ptr_buf[pos_buf++]; + } } } + buf2[pos_buf2] = '\0'; } - buf2[pos_buf2] = '\0'; - } - /* build prefix with arrow */ - prefix_arrow[0] = '\0'; - switch (flags & (IRC_RAW_FLAG_RECV | IRC_RAW_FLAG_SEND - | IRC_RAW_FLAG_MODIFIED | IRC_RAW_FLAG_REDIRECT)) - { - case IRC_RAW_FLAG_RECV: - strcpy (prefix_arrow, IRC_RAW_PREFIX_RECV); - break; - case IRC_RAW_FLAG_RECV | IRC_RAW_FLAG_MODIFIED: - strcpy (prefix_arrow, IRC_RAW_PREFIX_RECV_MODIFIED); - break; - case IRC_RAW_FLAG_RECV | IRC_RAW_FLAG_REDIRECT: - strcpy (prefix_arrow, IRC_RAW_PREFIX_RECV_REDIRECT); - break; - case IRC_RAW_FLAG_SEND: - strcpy (prefix_arrow, IRC_RAW_PREFIX_SEND); - break; - case IRC_RAW_FLAG_SEND | IRC_RAW_FLAG_MODIFIED: - strcpy (prefix_arrow, IRC_RAW_PREFIX_SEND_MODIFIED); - break; - default: - if (flags & IRC_RAW_FLAG_RECV) + /* build prefix with arrow */ + prefix_arrow[0] = '\0'; + switch (flags & (IRC_RAW_FLAG_RECV | IRC_RAW_FLAG_SEND + | IRC_RAW_FLAG_MODIFIED | IRC_RAW_FLAG_REDIRECT)) + { + case IRC_RAW_FLAG_RECV: strcpy (prefix_arrow, IRC_RAW_PREFIX_RECV); - else + break; + case IRC_RAW_FLAG_RECV | IRC_RAW_FLAG_MODIFIED: + strcpy (prefix_arrow, IRC_RAW_PREFIX_RECV_MODIFIED); + break; + case IRC_RAW_FLAG_RECV | IRC_RAW_FLAG_REDIRECT: + strcpy (prefix_arrow, IRC_RAW_PREFIX_RECV_REDIRECT); + break; + case IRC_RAW_FLAG_SEND: strcpy (prefix_arrow, IRC_RAW_PREFIX_SEND); - break; - } + break; + case IRC_RAW_FLAG_SEND | IRC_RAW_FLAG_MODIFIED: + strcpy (prefix_arrow, IRC_RAW_PREFIX_SEND_MODIFIED); + break; + default: + if (flags & IRC_RAW_FLAG_RECV) + strcpy (prefix_arrow, IRC_RAW_PREFIX_RECV); + else + strcpy (prefix_arrow, IRC_RAW_PREFIX_SEND); + break; + } - snprintf (prefix, sizeof (prefix), "%s%s%s%s%s", - (server) ? weechat_color ("chat_server") : "", - (server) ? server->name : "", - (server) ? " " : "", - (flags & IRC_RAW_FLAG_SEND) ? - weechat_color ("chat_prefix_quit") : - weechat_color ("chat_prefix_join"), - prefix_arrow); + snprintf (prefix, sizeof (prefix), "%s%s%s%s%s", + (flags & IRC_RAW_FLAG_SEND) ? + weechat_color ("chat_prefix_quit") : + weechat_color ("chat_prefix_join"), + prefix_arrow, + (server) ? weechat_color ("chat_server") : "", + (server) ? " " : "", + (server) ? server->name : ""); + } new_raw_message = irc_raw_message_add_to_list (time (NULL), prefix, @@ -332,6 +347,20 @@ irc_raw_print (struct t_irc_server *server, int flags, if (weechat_config_integer (irc_config_look_raw_messages) == 0) irc_raw_message_free (new_raw_message); } + + if (weechat_irc_plugin->debug >= 2) + { + new_raw_message = irc_raw_message_add (server, + flags | IRC_RAW_FLAG_BINARY, + message); + if (new_raw_message) + { + if (irc_raw_buffer) + irc_raw_message_print (new_raw_message); + if (weechat_config_integer (irc_config_look_raw_messages) == 0) + irc_raw_message_free (new_raw_message); + } + } } /* diff --git a/src/plugins/irc/irc-raw.h b/src/plugins/irc/irc-raw.h index 0dc25d0ba..6d9b23d78 100644 --- a/src/plugins/irc/irc-raw.h +++ b/src/plugins/irc/irc-raw.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org> + * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org> * * This file is part of WeeChat, the extensible chat client. * @@ -32,6 +32,7 @@ #define IRC_RAW_FLAG_SEND 2 #define IRC_RAW_FLAG_MODIFIED 4 #define IRC_RAW_FLAG_REDIRECT 8 +#define IRC_RAW_FLAG_BINARY 16 struct t_irc_raw_message { diff --git a/src/plugins/irc/irc-redirect.c b/src/plugins/irc/irc-redirect.c index 576d6fd24..ab88a4469 100644 --- a/src/plugins/irc/irc-redirect.c +++ b/src/plugins/irc/irc-redirect.c @@ -1,7 +1,7 @@ /* * irc-redirect.c - redirection of IRC command output * - * Copyright (C) 2010-2015 Sébastien Helleu <flashcode@flashtux.org> + * Copyright (C) 2010-2016 Sébastien Helleu <flashcode@flashtux.org> * * This file is part of WeeChat, the extensible chat client. * @@ -436,8 +436,7 @@ irc_redirect_new_with_commands (struct t_irc_server *server, hash_cmd[i] = weechat_hashtable_new (32, WEECHAT_HASHTABLE_STRING, WEECHAT_HASHTABLE_INTEGER, - NULL, - NULL); + NULL, NULL); for (j = 0; j < num_items[i]; j++) { if (i < 3) @@ -732,8 +731,7 @@ irc_redirect_stop (struct t_irc_redirect *redirect, const char *error) hashtable = weechat_hashtable_new (32, WEECHAT_HASHTABLE_STRING, WEECHAT_HASHTABLE_STRING, - NULL, - NULL); + NULL, NULL); if (hashtable) { /* set error and output (main fields) */ @@ -993,11 +991,13 @@ irc_redirect_free_all (struct t_irc_server *server) */ struct t_hdata * -irc_redirect_hdata_redirect_pattern_cb (void *data, const char *hdata_name) +irc_redirect_hdata_redirect_pattern_cb (const void *pointer, void *data, + const char *hdata_name) { struct t_hdata *hdata; /* make C compiler happy */ + (void) pointer; (void) data; hdata = weechat_hdata_new (hdata_name, "prev_redirect", "next_redirect", @@ -1023,11 +1023,13 @@ irc_redirect_hdata_redirect_pattern_cb (void *data, const char *hdata_name) */ struct t_hdata * -irc_redirect_hdata_redirect_cb (void *data, const char *hdata_name) +irc_redirect_hdata_redirect_cb (const void *pointer, void *data, + const char *hdata_name) { struct t_hdata *hdata; /* make C compiler happy */ + (void) pointer; (void) data; hdata = weechat_hdata_new (hdata_name, "prev_redirect", "next_redirect", @@ -1237,7 +1239,8 @@ irc_redirect_print_log (struct t_irc_server *server) */ int -irc_redirect_pattern_hsignal_cb (void *data, const char *signal, +irc_redirect_pattern_hsignal_cb (const void *pointer, void *data, + const char *signal, struct t_hashtable *hashtable) { const char *pattern, *str_timeout, *cmd_start, *cmd_stop, *cmd_extra; @@ -1245,6 +1248,7 @@ irc_redirect_pattern_hsignal_cb (void *data, const char *signal, int number, timeout; /* make C compiler happy */ + (void) pointer; (void) data; (void) signal; @@ -1301,7 +1305,8 @@ irc_redirect_pattern_hsignal_cb (void *data, const char *signal, */ int -irc_redirect_command_hsignal_cb (void *data, const char *signal, +irc_redirect_command_hsignal_cb (const void *pointer, void *data, + const char *signal, struct t_hashtable *hashtable) { const char *server, *pattern, *redirect_signal, *str_count, *string; @@ -1311,6 +1316,7 @@ irc_redirect_command_hsignal_cb (void *data, const char *signal, int number, count, timeout; /* make C compiler happy */ + (void) pointer; (void) data; (void) signal; diff --git a/src/plugins/irc/irc-redirect.h b/src/plugins/irc/irc-redirect.h index b78db090a..632e4e840 100644 --- a/src/plugins/irc/irc-redirect.h +++ b/src/plugins/irc/irc-redirect.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010-2015 Sébastien Helleu <flashcode@flashtux.org> + * Copyright (C) 2010-2016 Sébastien Helleu <flashcode@flashtux.org> * * This file is part of WeeChat, the extensible chat client. * @@ -109,9 +109,11 @@ extern int irc_redirect_message (struct t_irc_server *server, const char *arguments); extern void irc_redirect_free (struct t_irc_redirect *redirect); extern void irc_redirect_free_all (struct t_irc_server *server); -extern struct t_hdata *irc_redirect_hdata_redirect_pattern_cb (void *data, +extern struct t_hdata *irc_redirect_hdata_redirect_pattern_cb (const void *pointer, + void *data, const char *hdata_name); -extern struct t_hdata *irc_redirect_hdata_redirect_cb (void *data, +extern struct t_hdata *irc_redirect_hdata_redirect_cb (const void *pointer, + void *data, const char *hdata_name); extern int irc_redirect_pattern_add_to_infolist (struct t_infolist *infolist, struct t_irc_redirect_pattern *redirect_pattern); @@ -119,9 +121,11 @@ extern int irc_redirect_add_to_infolist (struct t_infolist *infolist, struct t_irc_redirect *redirect); extern void irc_redirect_pattern_print_log (); extern void irc_redirect_print_log (struct t_irc_server *server); -extern int irc_redirect_pattern_hsignal_cb (void *data, const char *signal, +extern int irc_redirect_pattern_hsignal_cb (const void *pointer, void *data, + const char *signal, struct t_hashtable *hashtable); -extern int irc_redirect_command_hsignal_cb (void *data, const char *signal, +extern int irc_redirect_command_hsignal_cb (const void *pointer, void *data, + const char *signal, struct t_hashtable *hashtable); extern void irc_redirect_init (); extern void irc_redirect_end (); diff --git a/src/plugins/irc/irc-sasl.c b/src/plugins/irc/irc-sasl.c index 623d12a27..57f4050fc 100644 --- a/src/plugins/irc/irc-sasl.c +++ b/src/plugins/irc/irc-sasl.c @@ -1,7 +1,7 @@ /* * irc-sasl.c - SASL authentication with IRC server * - * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org> + * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org> * * This file is part of WeeChat, the extensible chat client. * @@ -343,6 +343,8 @@ irc_sasl_dh (const char *data_base64, /* decode data */ data = malloc (strlen (data_base64) + 1); + if (!data) + goto dhend; length_data = weechat_string_decode_base64 (data_base64, data); ptr_data = (unsigned char *)data; diff --git a/src/plugins/irc/irc-sasl.h b/src/plugins/irc/irc-sasl.h index 2677f5247..d3b61ddd9 100644 --- a/src/plugins/irc/irc-sasl.h +++ b/src/plugins/irc/irc-sasl.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org> + * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org> * * This file is part of WeeChat, the extensible chat client. * diff --git a/src/plugins/irc/irc-server.c b/src/plugins/irc/irc-server.c index 83759ee53..aa09d47c9 100644 --- a/src/plugins/irc/irc-server.c +++ b/src/plugins/irc/irc-server.c @@ -1,7 +1,7 @@ /* * irc-server.c - I/O communication with IRC servers * - * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org> + * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org> * Copyright (C) 2005-2010 Emmanuel Bouthenot <kolter@openics.org> * Copyright (C) 2012 Simon Arlott * @@ -40,6 +40,8 @@ #include <netdb.h> #include <arpa/inet.h> #include <netinet/in.h> +#include <arpa/nameser.h> +#include <resolv.h> #ifdef HAVE_GNUTLS #include <gnutls/gnutls.h> @@ -75,44 +77,45 @@ char *irc_server_sasl_fail_string[IRC_SERVER_NUM_SASL_FAIL] = { "continue", "reconnect", "disconnect" }; char *irc_server_options[IRC_SERVER_NUM_OPTIONS][2] = -{ { "addresses", "" }, - { "proxy", "" }, - { "ipv6", "on" }, - { "ssl", "off" }, - { "ssl_cert", "" }, - { "ssl_priorities", "NORMAL:-VERS-SSL3.0" }, - { "ssl_dhkey_size", "2048" }, - { "ssl_fingerprint", "" }, - { "ssl_verify", "on" }, - { "password", "" }, - { "capabilities", "" }, - { "sasl_mechanism", "plain" }, - { "sasl_username", "" }, - { "sasl_password", "" }, - { "sasl_key", "", }, - { "sasl_timeout", "15" }, - { "sasl_fail", "continue" }, - { "autoconnect", "off" }, - { "autoreconnect", "on" }, - { "autoreconnect_delay", "10" }, - { "nicks", "" }, - { "username", "" }, - { "realname", "" }, - { "local_hostname", "" }, - { "command", "" }, - { "command_delay", "0" }, - { "autojoin", "" }, - { "autorejoin", "off" }, - { "autorejoin_delay", "30" }, - { "connection_timeout", "60" }, - { "anti_flood_prio_high", "2" }, - { "anti_flood_prio_low", "2" }, - { "away_check", "0" }, - { "away_check_max_nicks", "25" }, - { "default_msg_kick", "" }, - { "default_msg_part", "WeeChat %v" }, - { "default_msg_quit", "WeeChat %v" }, - { "notify", "" }, +{ { "addresses", "" }, + { "proxy", "" }, + { "ipv6", "on" }, + { "ssl", "off" }, + { "ssl_cert", "" }, + { "ssl_priorities", "NORMAL:-VERS-SSL3.0" }, + { "ssl_dhkey_size", "2048" }, + { "ssl_fingerprint", "" }, + { "ssl_verify", "on" }, + { "password", "" }, + { "capabilities", "" }, + { "sasl_mechanism", "plain" }, + { "sasl_username", "" }, + { "sasl_password", "" }, + { "sasl_key", "", }, + { "sasl_timeout", "15" }, + { "sasl_fail", "continue" }, + { "autoconnect", "off" }, + { "autoreconnect", "on" }, + { "autoreconnect_delay", "10" }, + { "nicks", "" }, + { "nicks_alternate", "on" }, + { "username", "" }, + { "realname", "" }, + { "local_hostname", "" }, + { "command", "" }, + { "command_delay", "0" }, + { "autojoin", "" }, + { "autorejoin", "off" }, + { "autorejoin_delay", "30" }, + { "connection_timeout", "60" }, + { "anti_flood_prio_high", "2" }, + { "anti_flood_prio_low", "2" }, + { "away_check", "0" }, + { "away_check_max_nicks", "25" }, + { "msg_kick", "" }, + { "msg_part", "WeeChat ${info:version}" }, + { "msg_quit", "WeeChat ${info:version}" }, + { "notify", "" }, }; char *irc_server_casemapping_string[IRC_SERVER_NUM_CASEMAPPING] = @@ -407,7 +410,7 @@ void irc_server_set_addresses (struct t_irc_server *server, const char *addresses) { int i; - char *pos, *error; + char *pos, *error, *addresses_eval; long number; /* free data */ @@ -431,8 +434,11 @@ irc_server_set_addresses (struct t_irc_server *server, const char *addresses) /* set new addresses/ports */ if (addresses && addresses[0]) { + addresses_eval = weechat_string_eval_expression (addresses, + NULL, NULL, NULL); server->addresses_array = weechat_string_split ( - addresses, ",", 0, 0, &server->addresses_count); + (addresses_eval) ? addresses_eval : addresses, + ",", 0, 0, &server->addresses_count); server->ports_array = malloc ( server->addresses_count * sizeof (server->ports_array[0])); server->retry_array = malloc ( @@ -455,6 +461,8 @@ irc_server_set_addresses (struct t_irc_server *server, const char *addresses) } server->retry_array[i] = 0; } + if (addresses_eval) + free (addresses_eval); } } @@ -624,8 +632,8 @@ irc_server_get_alternate_nick (struct t_irc_server *server) /* now we have tried all nicks in list */ - /* if alternate nick is disabled, just return NULL */ - if (!weechat_config_boolean (irc_config_network_alternate_nick)) + /* if alternate nicks are disabled, just return NULL */ + if (!IRC_SERVER_OPTION_BOOLEAN(server, IRC_SERVER_OPTION_NICKS_ALTERNATE)) return NULL; /* use main nick and we will add "_" and then number if needed */ @@ -884,7 +892,7 @@ irc_server_get_prefix_mode_for_char (struct t_irc_server *server, * * For example mode 'o' can return '@'. * - * Returns return ' ' (space) if mode is not found. + * Returns a space if mode is not found. */ char @@ -944,6 +952,55 @@ irc_server_prefix_char_statusmsg (struct t_irc_server *server, } /* + * Gets an evaluated default_msg server option: replaces "%v" by WeeChat + * version if there's no ${...} in string, or just evaluates the string. + * + * Note: result must be freed after use. + */ + +char * +irc_server_get_default_msg (const char *default_msg, + struct t_irc_server *server, + const char *channel_name) +{ + const char *version; + struct t_hashtable *extra_vars; + char *msg; + + /* + * "%v" for version is deprecated since WeeChat 1.6, where + * an expression ${info:version} is preferred, so we replace + * the "%v" with version only if there's no "${...}" in string + */ + if (strstr (default_msg, "%v") && !strstr (default_msg, "${")) + { + version = weechat_info_get ("version", ""); + return weechat_string_replace (default_msg, "%v", + (version) ? version : ""); + } + + extra_vars = weechat_hashtable_new (32, + WEECHAT_HASHTABLE_STRING, + WEECHAT_HASHTABLE_POINTER, + NULL, + NULL); + if (extra_vars) + { + weechat_hashtable_set (extra_vars, "server", server->name); + weechat_hashtable_set (extra_vars, "channel", + (channel_name) ? channel_name : ""); + weechat_hashtable_set (extra_vars, "nick", server->nick); + } + + msg = weechat_string_eval_expression (default_msg, NULL, extra_vars, NULL); + + if (extra_vars) + weechat_hashtable_free (extra_vars); + + return msg; +} + +/* * Allocates a new server and adds it to the servers queue. * * Returns pointer to new server, NULL if error. @@ -1011,6 +1068,7 @@ irc_server_alloc (const char *name) new_server->nick_modes = NULL; new_server->cap_away_notify = 0; new_server->cap_account_notify = 0; + new_server->cap_extended_join = 0; new_server->isupport = NULL; new_server->prefix_modes = NULL; new_server->prefix_chars = NULL; @@ -1049,21 +1107,21 @@ irc_server_alloc (const char *name) new_server->notify_list = NULL; new_server->last_notify = NULL; new_server->notify_count = 0; - new_server->join_manual = weechat_hashtable_new (32, - WEECHAT_HASHTABLE_STRING, - WEECHAT_HASHTABLE_TIME, - NULL, - NULL); - new_server->join_channel_key = weechat_hashtable_new (32, - WEECHAT_HASHTABLE_STRING, - WEECHAT_HASHTABLE_STRING, - NULL, - NULL); - new_server->join_noswitch = weechat_hashtable_new (32, - WEECHAT_HASHTABLE_STRING, - WEECHAT_HASHTABLE_TIME, - NULL, - NULL); + new_server->join_manual = weechat_hashtable_new ( + 32, + WEECHAT_HASHTABLE_STRING, + WEECHAT_HASHTABLE_TIME, + NULL, NULL); + new_server->join_channel_key = weechat_hashtable_new ( + 32, + WEECHAT_HASHTABLE_STRING, + WEECHAT_HASHTABLE_STRING, + NULL, NULL); + new_server->join_noswitch = weechat_hashtable_new ( + 32, + WEECHAT_HASHTABLE_STRING, + WEECHAT_HASHTABLE_TIME, + NULL, NULL); new_server->buffer = NULL; new_server->buffer_as_string = NULL; new_server->channels = NULL; @@ -1073,26 +1131,31 @@ irc_server_alloc (const char *name) for (i = 0; i < IRC_SERVER_NUM_OPTIONS; i++) { length = strlen (new_server->name) + 1 + - strlen (irc_server_options[i][0]) + 1; + strlen (irc_server_options[i][0]) + + 512 + /* inherited option name (irc.server_default.xxx) */ + 1; option_name = malloc (length); if (option_name) { - snprintf (option_name, length, "%s.%s", + snprintf (option_name, length, "%s.%s << irc.server_default.%s", new_server->name, + irc_server_options[i][0], irc_server_options[i][0]); - new_server->options[i] = - irc_config_server_new_option (irc_config_file, - irc_config_section_server, - i, - option_name, - NULL, - NULL, - 1, - &irc_config_server_check_value_cb, - irc_server_options[i][0], - &irc_config_server_change_cb, - irc_server_options[i][0]); - irc_config_server_change_cb (irc_server_options[i][0], + new_server->options[i] = irc_config_server_new_option ( + irc_config_file, + irc_config_section_server, + i, + option_name, + NULL, + NULL, + 1, + &irc_config_server_check_value_cb, + irc_server_options[i][0], + NULL, + &irc_config_server_change_cb, + irc_server_options[i][0], + NULL); + irc_config_server_change_cb (irc_server_options[i][0], NULL, new_server->options[i]); free (option_name); } @@ -2278,8 +2341,7 @@ irc_server_sendf (struct t_irc_server *server, int flags, const char *tags, ret_hashtable = weechat_hashtable_new (32, WEECHAT_HASHTABLE_STRING, WEECHAT_HASHTABLE_STRING, - NULL, - NULL); + NULL, NULL); } rc = 1; @@ -2751,16 +2813,17 @@ irc_server_msgq_flush () */ int -irc_server_recv_cb (void *data, int fd) +irc_server_recv_cb (const void *pointer, void *data, int fd) { struct t_irc_server *server; static char buffer[4096 + 2]; int num_read, msgq_flush, end_recv; /* make C compiler happy */ + (void) data; (void) fd; - server = (struct t_irc_server *)data; + server = (struct t_irc_server *)pointer; if (!server) return WEECHAT_RC_ERROR; @@ -2854,14 +2917,16 @@ irc_server_recv_cb (void *data, int fd) */ int -irc_server_timer_connection_cb (void *data, int remaining_calls) +irc_server_timer_connection_cb (const void *pointer, void *data, + int remaining_calls) { struct t_irc_server *server; /* make C compiler happy */ + (void) data; (void) remaining_calls; - server = (struct t_irc_server *)data; + server = (struct t_irc_server *)pointer; if (!server) return WEECHAT_RC_ERROR; @@ -2887,15 +2952,16 @@ irc_server_timer_connection_cb (void *data, int remaining_calls) */ int -irc_server_timer_sasl_cb (void *data, int remaining_calls) +irc_server_timer_sasl_cb (const void *pointer, void *data, int remaining_calls) { struct t_irc_server *server; int sasl_fail; /* make C compiler happy */ + (void) data; (void) remaining_calls; - server = (struct t_irc_server *)data; + server = (struct t_irc_server *)pointer; if (!server) return WEECHAT_RC_ERROR; @@ -2905,7 +2971,7 @@ irc_server_timer_sasl_cb (void *data, int remaining_calls) if (!server->is_connected) { weechat_printf (server->buffer, - _("%s%s: sasl authentication timeout"), + _("%s%s: SASL authentication timeout"), weechat_prefix ("error"), IRC_PLUGIN_NAME); sasl_fail = IRC_SERVER_OPTION_INTEGER(server, IRC_SERVER_OPTION_SASL_FAIL); @@ -2929,7 +2995,8 @@ irc_server_timer_sasl_cb (void *data, int remaining_calls) */ void -irc_server_check_join_manual_cb (void *data, struct t_hashtable *hashtable, +irc_server_check_join_manual_cb (void *data, + struct t_hashtable *hashtable, const void *key, const void *value) { /* make C compiler happy */ @@ -2945,7 +3012,8 @@ irc_server_check_join_manual_cb (void *data, struct t_hashtable *hashtable, */ void -irc_server_check_join_noswitch_cb (void *data, struct t_hashtable *hashtable, +irc_server_check_join_noswitch_cb (void *data, + struct t_hashtable *hashtable, const void *key, const void *value) { /* make C compiler happy */ @@ -2983,7 +3051,7 @@ irc_server_check_join_smart_filtered_cb (void *data, */ int -irc_server_timer_cb (void *data, int remaining_calls) +irc_server_timer_cb (const void *pointer, void *data, int remaining_calls) { struct t_irc_server *ptr_server; struct t_irc_channel *ptr_channel; @@ -2993,6 +3061,7 @@ irc_server_timer_cb (void *data, int remaining_calls) int away_check; /* make C compiler happy */ + (void) pointer; (void) data; (void) remaining_calls; @@ -3327,7 +3396,13 @@ irc_server_login (struct t_irc_server *server) server, IRC_SERVER_OPTION_CAPABILITIES); if (password && password[0]) - irc_server_sendf (server, 0, NULL, "PASS %s", password); + { + irc_server_sendf ( + server, 0, NULL, + "PASS %s%s", + ((password[0] == ':') || (strchr (password, ' '))) ? ":" : "", + password); + } if (!server->nick) { @@ -3364,7 +3439,7 @@ irc_server_login (struct t_irc_server *server) IRC_SERVER_OPTION_INTEGER (server, IRC_SERVER_OPTION_CONNECTION_TIMEOUT) * 1000, 0, 1, &irc_server_timer_connection_cb, - server); + server, NULL); if (password) free (password); @@ -3414,13 +3489,17 @@ irc_server_switch_address (struct t_irc_server *server, int connection) */ int -irc_server_connect_cb (void *data, int status, int gnutls_rc, int sock, +irc_server_connect_cb (const void *pointer, void *data, + int status, int gnutls_rc, int sock, const char *error, const char *ip_address) { struct t_irc_server *server; const char *proxy; - server = (struct t_irc_server *)data; + /* make C compiler happy */ + (void) data; + + server = (struct t_irc_server *)pointer; proxy = IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_PROXY); @@ -3445,7 +3524,7 @@ irc_server_connect_cb (void *data, int status, int gnutls_rc, int sock, server->hook_fd = weechat_hook_fd (server->sock, 1, 0, 0, &irc_server_recv_cb, - server); + server, NULL); /* login to server */ irc_server_login (server); break; @@ -3590,8 +3669,9 @@ irc_server_connect_cb (void *data, int status, int gnutls_rc, int sock, case WEECHAT_HOOK_CONNECT_MEMORY_ERROR: weechat_printf ( server->buffer, - _("%s%s: not enough memory"), - weechat_prefix ("error"), IRC_PLUGIN_NAME); + _("%s%s: not enough memory (%s)"), + weechat_prefix ("error"), IRC_PLUGIN_NAME, + (error) ? error : "-"); if (error && error[0]) { weechat_printf ( @@ -3702,8 +3782,8 @@ irc_server_create_buffer (struct t_irc_server *server) snprintf (buffer_name, sizeof (buffer_name), "server.%s", server->name); server->buffer = weechat_buffer_new (buffer_name, - &irc_input_data_cb, NULL, - &irc_buffer_close_cb, NULL); + &irc_input_data_cb, NULL, NULL, + &irc_buffer_close_cb, NULL, NULL); if (!server->buffer) return NULL; @@ -3911,8 +3991,9 @@ irc_server_check_certificate_fingerprint (struct t_irc_server *server, { weechat_printf ( server->buffer, - _("%s%s: not enough memory"), - weechat_prefix ("error"), IRC_PLUGIN_NAME); + _("%s%s: not enough memory (%s)"), + weechat_prefix ("error"), IRC_PLUGIN_NAME, + "fingerprint"); } } @@ -3951,7 +4032,8 @@ irc_server_check_certificate_fingerprint (struct t_irc_server *server, #ifdef HAVE_GNUTLS int -irc_server_gnutls_callback (void *data, gnutls_session_t tls_session, +irc_server_gnutls_callback (const void *pointer, void *data, + gnutls_session_t tls_session, const gnutls_datum_t *req_ca, int nreq, const gnutls_pk_algorithm_t *pk_algos, int pk_algos_len, @@ -3982,6 +4064,7 @@ irc_server_gnutls_callback (void *data, gnutls_session_t tls_session, #endif /* LIBGNUTLS_VERSION_NUMBER >= 0x010706 */ /* make C compiler happy */ + (void) data; (void) req_ca; (void) nreq; (void) pk_algos; @@ -3989,10 +4072,10 @@ irc_server_gnutls_callback (void *data, gnutls_session_t tls_session, rc = 0; - if (!data) + if (!pointer) return -1; - server = (struct t_irc_server *) data; + server = (struct t_irc_server *) pointer; cert_temp_init = 0; cert_list = NULL; cert_list_len = 0; @@ -4402,8 +4485,9 @@ irc_server_connect (struct t_irc_server *server) { weechat_printf ( server->buffer, - _("%s%s: not enough memory"), - weechat_prefix ("error"), IRC_PLUGIN_NAME); + _("%s%s: not enough memory (%s)"), + weechat_prefix ("error"), IRC_PLUGIN_NAME, + "proxy"); return 0; } snprintf (option_name, length, "weechat.proxy.%s.type", proxy); @@ -4527,12 +4611,13 @@ irc_server_connect (struct t_irc_server *server) proxy_type ? weechat_config_integer (proxy_ipv6) : IRC_SERVER_OPTION_BOOLEAN(server, IRC_SERVER_OPTION_IPV6), server->current_retry, (server->ssl_connected) ? &server->gnutls_sess : NULL, - (server->ssl_connected) ? irc_server_gnutls_callback : NULL, + (server->ssl_connected) ? &irc_server_gnutls_callback : NULL, IRC_SERVER_OPTION_INTEGER(server, IRC_SERVER_OPTION_SSL_DHKEY_SIZE), IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_SSL_PRIORITIES), IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_LOCAL_HOSTNAME), &irc_server_connect_cb, - server); + server, + NULL); #else server->hook_connect = weechat_hook_connect ( proxy, @@ -4543,7 +4628,8 @@ irc_server_connect (struct t_irc_server *server) NULL, NULL, 0, NULL, IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_LOCAL_HOSTNAME), &irc_server_connect_cb, - server); + server, + NULL); #endif /* HAVE_GNUTLS */ /* send signal "irc_server_connecting" with server name */ @@ -4578,15 +4664,17 @@ irc_server_reconnect (struct t_irc_server *server) */ int -irc_server_auto_connect_timer_cb (void *data, int remaining_calls) +irc_server_auto_connect_timer_cb (const void *pointer, void *data, + int remaining_calls) { struct t_irc_server *ptr_server; - void *auto_connect; + int auto_connect; /* make C compiler happy */ + (void) data; (void) remaining_calls; - auto_connect = data; + auto_connect = (pointer) ? 1 : 0; for (ptr_server = irc_servers; ptr_server; ptr_server = ptr_server->next_server) @@ -4612,8 +4700,10 @@ irc_server_auto_connect_timer_cb (void *data, int remaining_calls) void irc_server_auto_connect (int auto_connect) { - weechat_hook_timer (1, 0, 1, &irc_server_auto_connect_timer_cb, - (auto_connect) ? (void *)1 : (void *)0); + weechat_hook_timer (1, 0, 1, + &irc_server_auto_connect_timer_cb, + (auto_connect) ? (void *)1 : (void *)0, + NULL); } /* @@ -4677,6 +4767,7 @@ irc_server_disconnect (struct t_irc_server *server, int switch_address, } server->cap_away_notify = 0; server->cap_account_notify = 0; + server->cap_extended_join = 0; server->is_away = 0; server->away_time = 0; server->lag = 0; @@ -5008,7 +5099,8 @@ irc_server_set_away (struct t_irc_server *server, const char *nick, int is_away) */ int -irc_server_xfer_send_ready_cb (void *data, const char *signal, +irc_server_xfer_send_ready_cb (const void *pointer, void *data, + const char *signal, const char *type_data, void *signal_data) { struct t_infolist *infolist; @@ -5020,6 +5112,7 @@ irc_server_xfer_send_ready_cb (void *data, const char *signal, int spaces_in_name, rc; /* make C compiler happy */ + (void) pointer; (void) data; (void) signal; (void) type_data; @@ -5041,6 +5134,7 @@ irc_server_xfer_send_ready_cb (void *data, const char *signal, "local_address"); if (local_address) { + res_init (); rc = getaddrinfo (local_address, NULL, NULL, &ainfo); if ((rc == 0) && ainfo && ainfo->ai_addr) { @@ -5109,7 +5203,8 @@ irc_server_xfer_send_ready_cb (void *data, const char *signal, */ int -irc_server_xfer_resume_ready_cb (void *data, const char *signal, +irc_server_xfer_resume_ready_cb (const void *pointer, void *data, + const char *signal, const char *type_data, void *signal_data) { struct t_infolist *infolist; @@ -5118,6 +5213,7 @@ irc_server_xfer_resume_ready_cb (void *data, const char *signal, int spaces_in_name; /* make C compiler happy */ + (void) pointer; (void) data; (void) signal; (void) type_data; @@ -5162,7 +5258,8 @@ irc_server_xfer_resume_ready_cb (void *data, const char *signal, */ int -irc_server_xfer_send_accept_resume_cb (void *data, const char *signal, +irc_server_xfer_send_accept_resume_cb (const void *pointer, void *data, + const char *signal, const char *type_data, void *signal_data) { @@ -5172,6 +5269,7 @@ irc_server_xfer_send_accept_resume_cb (void *data, const char *signal, int spaces_in_name; /* make C compiler happy */ + (void) pointer; (void) data; (void) signal; (void) type_data; @@ -5213,11 +5311,13 @@ irc_server_xfer_send_accept_resume_cb (void *data, const char *signal, */ struct t_hdata * -irc_server_hdata_server_cb (void *data, const char *hdata_name) +irc_server_hdata_server_cb (const void *pointer, void *data, + const char *hdata_name) { struct t_hdata *hdata; /* make C compiler happy */ + (void) pointer; (void) data; hdata = weechat_hdata_new (hdata_name, "prev_server", "next_server", @@ -5260,6 +5360,7 @@ irc_server_hdata_server_cb (void *data, const char *hdata_name) WEECHAT_HDATA_VAR(struct t_irc_server, nick_modes, STRING, 0, NULL, NULL); WEECHAT_HDATA_VAR(struct t_irc_server, cap_away_notify, INTEGER, 0, NULL, NULL); WEECHAT_HDATA_VAR(struct t_irc_server, cap_account_notify, INTEGER, 0, NULL, NULL); + WEECHAT_HDATA_VAR(struct t_irc_server, cap_extended_join, INTEGER, 0, NULL, NULL); WEECHAT_HDATA_VAR(struct t_irc_server, isupport, STRING, 0, NULL, NULL); WEECHAT_HDATA_VAR(struct t_irc_server, prefix_modes, STRING, 0, NULL, NULL); WEECHAT_HDATA_VAR(struct t_irc_server, prefix_chars, STRING, 0, NULL, NULL); @@ -5401,6 +5502,9 @@ irc_server_add_to_infolist (struct t_infolist *infolist, if (!weechat_infolist_new_var_string (ptr_item, "nicks", IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_NICKS))) return 0; + if (!weechat_infolist_new_var_integer (ptr_item, "nicks_alternate", + IRC_SERVER_OPTION_BOOLEAN(server, IRC_SERVER_OPTION_NICKS_ALTERNATE))) + return 0; if (!weechat_infolist_new_var_string (ptr_item, "username", IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_USERNAME))) return 0; @@ -5440,14 +5544,14 @@ irc_server_add_to_infolist (struct t_infolist *infolist, if (!weechat_infolist_new_var_integer (ptr_item, "away_check_max_nicks", IRC_SERVER_OPTION_INTEGER(server, IRC_SERVER_OPTION_AWAY_CHECK_MAX_NICKS))) return 0; - if (!weechat_infolist_new_var_string (ptr_item, "default_msg_kick", - IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_DEFAULT_MSG_KICK))) + if (!weechat_infolist_new_var_string (ptr_item, "msg_kick", + IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_MSG_KICK))) return 0; - if (!weechat_infolist_new_var_string (ptr_item, "default_msg_part", - IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_DEFAULT_MSG_PART))) + if (!weechat_infolist_new_var_string (ptr_item, "msg_part", + IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_MSG_PART))) return 0; - if (!weechat_infolist_new_var_string (ptr_item, "default_msg_quit", - IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_DEFAULT_MSG_QUIT))) + if (!weechat_infolist_new_var_string (ptr_item, "msg_quit", + IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_MSG_QUIT))) return 0; if (!weechat_infolist_new_var_integer (ptr_item, "temp_server", server->temp_server)) return 0; @@ -5479,6 +5583,8 @@ irc_server_add_to_infolist (struct t_infolist *infolist, return 0; if (!weechat_infolist_new_var_integer (ptr_item, "cap_account_notify", server->cap_account_notify)) return 0; + if (!weechat_infolist_new_var_integer (ptr_item, "cap_extended_join", server->cap_extended_join)) + return 0; if (!weechat_infolist_new_var_string (ptr_item, "isupport", server->isupport)) return 0; if (!weechat_infolist_new_var_string (ptr_item, "prefix_modes", server->prefix_modes)) @@ -5572,7 +5678,7 @@ irc_server_print_log () "on" : "off"); else weechat_log_printf (" ipv6 . . . . . . . . : %s", - weechat_config_boolean (ptr_server->options[IRC_SERVER_OPTION_IPV6]) ? + (weechat_config_boolean (ptr_server->options[IRC_SERVER_OPTION_IPV6])) ? "on" : "off"); /* ssl */ if (weechat_config_option_is_null (ptr_server->options[IRC_SERVER_OPTION_SSL])) @@ -5581,7 +5687,7 @@ irc_server_print_log () "on" : "off"); else weechat_log_printf (" ssl. . . . . . . . . : %s", - weechat_config_boolean (ptr_server->options[IRC_SERVER_OPTION_SSL]) ? + (weechat_config_boolean (ptr_server->options[IRC_SERVER_OPTION_SSL])) ? "on" : "off"); /* ssl_cert */ if (weechat_config_option_is_null (ptr_server->options[IRC_SERVER_OPTION_SSL_CERT])) @@ -5618,7 +5724,7 @@ irc_server_print_log () "on" : "off"); else weechat_log_printf (" ssl_verify . . . . . : %s", - weechat_config_boolean (ptr_server->options[IRC_SERVER_OPTION_SSL_VERIFY]) ? + (weechat_config_boolean (ptr_server->options[IRC_SERVER_OPTION_SSL_VERIFY])) ? "on" : "off"); /* password */ if (weechat_config_option_is_null (ptr_server->options[IRC_SERVER_OPTION_PASSWORD])) @@ -5672,7 +5778,7 @@ irc_server_print_log () "on" : "off"); else weechat_log_printf (" autoconnect. . . . . : %s", - weechat_config_boolean (ptr_server->options[IRC_SERVER_OPTION_AUTOCONNECT]) ? + (weechat_config_boolean (ptr_server->options[IRC_SERVER_OPTION_AUTOCONNECT])) ? "on" : "off"); /* autoreconnect */ if (weechat_config_option_is_null (ptr_server->options[IRC_SERVER_OPTION_AUTORECONNECT])) @@ -5681,7 +5787,7 @@ irc_server_print_log () "on" : "off"); else weechat_log_printf (" autoreconnect. . . . : %s", - weechat_config_boolean (ptr_server->options[IRC_SERVER_OPTION_AUTORECONNECT]) ? + (weechat_config_boolean (ptr_server->options[IRC_SERVER_OPTION_AUTORECONNECT])) ? "on" : "off"); /* autoreconnect_delay */ if (weechat_config_option_is_null (ptr_server->options[IRC_SERVER_OPTION_AUTORECONNECT_DELAY])) @@ -5697,6 +5803,15 @@ irc_server_print_log () else weechat_log_printf (" nicks. . . . . . . . : '%s'", weechat_config_string (ptr_server->options[IRC_SERVER_OPTION_NICKS])); + /* nicks_alternate */ + if (weechat_config_option_is_null (ptr_server->options[IRC_SERVER_OPTION_NICKS_ALTERNATE])) + weechat_log_printf (" nicks_alternate. . . : null (%s)", + (IRC_SERVER_OPTION_BOOLEAN(ptr_server, IRC_SERVER_OPTION_NICKS_ALTERNATE)) ? + "on" : "off"); + else + weechat_log_printf (" nicks_alternate. . . : %s", + (weechat_config_boolean (ptr_server->options[IRC_SERVER_OPTION_NICKS_ALTERNATE])) ? + "on" : "off"); /* username */ if (weechat_config_option_is_null (ptr_server->options[IRC_SERVER_OPTION_USERNAME])) weechat_log_printf (" username . . . . . . : null ('%s')", @@ -5744,7 +5859,7 @@ irc_server_print_log () "on" : "off"); else weechat_log_printf (" autorejoin . . . . . : %s", - weechat_config_boolean (ptr_server->options[IRC_SERVER_OPTION_AUTOREJOIN]) ? + (weechat_config_boolean (ptr_server->options[IRC_SERVER_OPTION_AUTOREJOIN])) ? "on" : "off"); /* autorejoin_delay */ if (weechat_config_option_is_null (ptr_server->options[IRC_SERVER_OPTION_AUTOREJOIN_DELAY])) @@ -5788,27 +5903,27 @@ irc_server_print_log () else weechat_log_printf (" away_check_max_nicks : %d", weechat_config_integer (ptr_server->options[IRC_SERVER_OPTION_AWAY_CHECK_MAX_NICKS])); - /* default_msg_kick */ - if (weechat_config_option_is_null (ptr_server->options[IRC_SERVER_OPTION_DEFAULT_MSG_KICK])) - weechat_log_printf (" default_msg_kick . . : null ('%s')", - IRC_SERVER_OPTION_STRING(ptr_server, IRC_SERVER_OPTION_DEFAULT_MSG_KICK)); + /* msg_kick */ + if (weechat_config_option_is_null (ptr_server->options[IRC_SERVER_OPTION_MSG_KICK])) + weechat_log_printf (" msg_kick . . . . . . : null ('%s')", + IRC_SERVER_OPTION_STRING(ptr_server, IRC_SERVER_OPTION_MSG_KICK)); else - weechat_log_printf (" default_msg_kick . . : '%s'", - weechat_config_string (ptr_server->options[IRC_SERVER_OPTION_DEFAULT_MSG_KICK])); - /* default_msg_part */ - if (weechat_config_option_is_null (ptr_server->options[IRC_SERVER_OPTION_DEFAULT_MSG_PART])) - weechat_log_printf (" default_msg_part . . : null ('%s')", - IRC_SERVER_OPTION_STRING(ptr_server, IRC_SERVER_OPTION_DEFAULT_MSG_PART)); + weechat_log_printf (" msg_kick . . . . . . : '%s'", + weechat_config_string (ptr_server->options[IRC_SERVER_OPTION_MSG_KICK])); + /* msg_part */ + if (weechat_config_option_is_null (ptr_server->options[IRC_SERVER_OPTION_MSG_PART])) + weechat_log_printf (" msg_part . . . . . . : null ('%s')", + IRC_SERVER_OPTION_STRING(ptr_server, IRC_SERVER_OPTION_MSG_PART)); else - weechat_log_printf (" default_msg_part . . : '%s'", - weechat_config_string (ptr_server->options[IRC_SERVER_OPTION_DEFAULT_MSG_PART])); - /* default_msg_quit */ - if (weechat_config_option_is_null (ptr_server->options[IRC_SERVER_OPTION_DEFAULT_MSG_QUIT])) - weechat_log_printf (" default_msg_quit . . : null ('%s')", - IRC_SERVER_OPTION_STRING(ptr_server, IRC_SERVER_OPTION_DEFAULT_MSG_QUIT)); + weechat_log_printf (" msg_part . . . . . . : '%s'", + weechat_config_string (ptr_server->options[IRC_SERVER_OPTION_MSG_PART])); + /* msg_quit */ + if (weechat_config_option_is_null (ptr_server->options[IRC_SERVER_OPTION_MSG_QUIT])) + weechat_log_printf (" msg_quit . . . . . . : null ('%s')", + IRC_SERVER_OPTION_STRING(ptr_server, IRC_SERVER_OPTION_MSG_QUIT)); else - weechat_log_printf (" default_msg_quit . . : '%s'", - weechat_config_string (ptr_server->options[IRC_SERVER_OPTION_DEFAULT_MSG_QUIT])); + weechat_log_printf (" msg_quit . . . . . . : '%s'", + weechat_config_string (ptr_server->options[IRC_SERVER_OPTION_MSG_QUIT])); /* other server variables */ weechat_log_printf (" temp_server. . . . . : %d", ptr_server->temp_server); weechat_log_printf (" reloading_from_config: %d", ptr_server->reloaded_from_config); @@ -5842,6 +5957,7 @@ irc_server_print_log () weechat_log_printf (" nick_modes . . . . . : '%s'", ptr_server->nick_modes); weechat_log_printf (" cap_away_notify. . . : %d", ptr_server->cap_away_notify); weechat_log_printf (" cap_account_notify . : %d", ptr_server->cap_account_notify); + weechat_log_printf (" cap_extended_join. . : %d", ptr_server->cap_extended_join); weechat_log_printf (" isupport . . . . . . : '%s'", ptr_server->isupport); weechat_log_printf (" prefix_modes . . . . : '%s'", ptr_server->prefix_modes); weechat_log_printf (" prefix_chars . . . . : '%s'", ptr_server->prefix_chars); diff --git a/src/plugins/irc/irc-server.h b/src/plugins/irc/irc-server.h index dd650c325..663b0d085 100644 --- a/src/plugins/irc/irc-server.h +++ b/src/plugins/irc/irc-server.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org> + * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org> * Copyright (C) 2012 Simon Arlott * * This file is part of WeeChat, the extensible chat client. @@ -57,13 +57,14 @@ enum t_irc_server_option IRC_SERVER_OPTION_SASL_MECHANISM,/* mechanism for SASL authentication */ IRC_SERVER_OPTION_SASL_USERNAME, /* username for SASL authentication */ IRC_SERVER_OPTION_SASL_PASSWORD, /* password for SASL authentication */ - IRC_SERVER_OPTION_SASL_KEY, /* key for ECDSA-NIST256P-CHALLENCE */ + IRC_SERVER_OPTION_SASL_KEY, /* key for ECDSA-NIST256P-CHALLENGE */ IRC_SERVER_OPTION_SASL_TIMEOUT, /* timeout for SASL authentication */ IRC_SERVER_OPTION_SASL_FAIL, /* action on SASL fail */ IRC_SERVER_OPTION_AUTOCONNECT, /* autoconnect to server at startup */ IRC_SERVER_OPTION_AUTORECONNECT, /* autoreconnect when disconnected */ IRC_SERVER_OPTION_AUTORECONNECT_DELAY, /* delay before trying again reco */ IRC_SERVER_OPTION_NICKS, /* nicknames (comma separated list) */ + IRC_SERVER_OPTION_NICKS_ALTERNATE, /* use alternate nicknames */ IRC_SERVER_OPTION_USERNAME, /* user name */ IRC_SERVER_OPTION_REALNAME, /* real name */ IRC_SERVER_OPTION_LOCAL_HOSTNAME,/* custom local hostname */ @@ -77,9 +78,9 @@ enum t_irc_server_option IRC_SERVER_OPTION_ANTI_FLOOD_PRIO_LOW, /* anti-flood (low priority) */ IRC_SERVER_OPTION_AWAY_CHECK, /* delay between away checks */ IRC_SERVER_OPTION_AWAY_CHECK_MAX_NICKS, /* max nicks for away check */ - IRC_SERVER_OPTION_DEFAULT_MSG_KICK, /* default kick message */ - IRC_SERVER_OPTION_DEFAULT_MSG_PART, /* default part message */ - IRC_SERVER_OPTION_DEFAULT_MSG_QUIT, /* default quit message */ + IRC_SERVER_OPTION_MSG_KICK, /* default kick message */ + IRC_SERVER_OPTION_MSG_PART, /* default part message */ + IRC_SERVER_OPTION_MSG_QUIT, /* default quit message */ IRC_SERVER_OPTION_NOTIFY, /* notify list */ /* number of server options */ IRC_SERVER_NUM_OPTIONS, @@ -186,6 +187,7 @@ struct t_irc_server char *nick_modes; /* nick modes */ int cap_away_notify; /* 1 if capability away-notify is enabled*/ int cap_account_notify; /* 1 if CAP account-notify is enabled */ + int cap_extended_join; /* 1 if CAP extended-join is enabled */ char *isupport; /* copy of message 005 (ISUPPORT) */ char *prefix_modes; /* prefix modes from msg 005 (eg "ohv") */ char *prefix_chars; /* prefix chars from msg 005 (eg "@%+") */ @@ -298,6 +300,9 @@ extern char irc_server_get_prefix_char_for_mode (struct t_irc_server *server, extern const char *irc_server_get_chanmodes (struct t_irc_server *server); extern int irc_server_prefix_char_statusmsg (struct t_irc_server *server, char prefix_char); +extern char *irc_server_get_default_msg (const char *default_msg, + struct t_irc_server *server, + const char *channel_name); extern struct t_irc_server *irc_server_alloc (const char *name); extern struct t_irc_server *irc_server_alloc_with_url (const char *irc_url); extern void irc_server_apply_command_line_options (struct t_irc_server *server, @@ -328,9 +333,11 @@ char *irc_server_fingerprint_str_sizes (); extern int irc_server_connect (struct t_irc_server *server); extern void irc_server_auto_connect (int auto_connect); extern void irc_server_autojoin_channels (); -extern int irc_server_recv_cb (void *data, int fd); -extern int irc_server_timer_sasl_cb (void *data, int remaining_calls); -extern int irc_server_timer_cb (void *data, int remaining_calls); +extern int irc_server_recv_cb (const void *pointer, void *data, int fd); +extern int irc_server_timer_sasl_cb (const void *pointer, void *data, + int remaining_calls); +extern int irc_server_timer_cb (const void *pointer, void *data, + int remaining_calls); extern void irc_server_outqueue_free_all (struct t_irc_server *server, int priority); extern int irc_server_get_channel_count (struct t_irc_server *server); @@ -345,14 +352,21 @@ extern void irc_server_disconnect (struct t_irc_server *server, int switch_address, int reconnect); extern void irc_server_disconnect_all (); extern void irc_server_free (struct t_irc_server *server); -extern int irc_server_xfer_send_ready_cb (void *data, const char *signal, - const char *type_data, void *signal_data); -extern int irc_server_xfer_resume_ready_cb (void *data, const char *signal, - const char *type_data, void *signal_data); -extern int irc_server_xfer_send_accept_resume_cb (void *data, const char *signal, +extern int irc_server_xfer_send_ready_cb (const void *pointer, void *data, + const char *signal, + const char *type_data, + void *signal_data); +extern int irc_server_xfer_resume_ready_cb (const void *pointer, void *data, + const char *signal, + const char *type_data, + void *signal_data); +extern int irc_server_xfer_send_accept_resume_cb (const void *pointer, + void *data, + const char *signal, const char *type_data, void *signal_data); -extern struct t_hdata *irc_server_hdata_server_cb (void *data, +extern struct t_hdata *irc_server_hdata_server_cb (const void *pointer, + void *data, const char *hdata_name); extern int irc_server_add_to_infolist (struct t_infolist *infolist, struct t_irc_server *server); diff --git a/src/plugins/irc/irc-upgrade.c b/src/plugins/irc/irc-upgrade.c index 2169df3bd..e5623eccf 100644 --- a/src/plugins/irc/irc-upgrade.c +++ b/src/plugins/irc/irc-upgrade.c @@ -1,7 +1,7 @@ /* * irc-upgrade.c - save/restore IRC plugin data when upgrading WeeChat * - * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org> + * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org> * * This file is part of WeeChat, the extensible chat client. * @@ -224,7 +224,8 @@ irc_upgrade_save () int rc; struct t_upgrade_file *upgrade_file; - upgrade_file = weechat_upgrade_new (IRC_UPGRADE_FILENAME, 1); + upgrade_file = weechat_upgrade_new (IRC_UPGRADE_FILENAME, + NULL, NULL, NULL); if (!upgrade_file) return 0; @@ -269,7 +270,7 @@ irc_upgrade_set_buffer_callbacks () if (ptr_server) { weechat_buffer_set_pointer (ptr_buffer, - "nickcmp_callback_data", + "nickcmp_callback_pointer", ptr_server); } } @@ -289,7 +290,7 @@ irc_upgrade_set_buffer_callbacks () */ int -irc_upgrade_read_cb (void *data, +irc_upgrade_read_cb (const void *pointer, void *data, struct t_upgrade_file *upgrade_file, int object_id, struct t_infolist *infolist) @@ -306,6 +307,7 @@ irc_upgrade_read_cb (void *data, struct t_gui_buffer *ptr_buffer; /* make C compiler happy */ + (void) pointer; (void) data; (void) upgrade_file; @@ -354,10 +356,12 @@ irc_upgrade_read_cb (void *data, if (sock >= 0) { irc_upgrade_current_server->sock = sock; - irc_upgrade_current_server->hook_fd = weechat_hook_fd (irc_upgrade_current_server->sock, - 1, 0, 0, - &irc_server_recv_cb, - irc_upgrade_current_server); + irc_upgrade_current_server->hook_fd = weechat_hook_fd ( + irc_upgrade_current_server->sock, + 1, 0, 0, + &irc_server_recv_cb, + irc_upgrade_current_server, + NULL); } irc_upgrade_current_server->is_connected = weechat_infolist_integer (infolist, "is_connected"); irc_upgrade_current_server->ssl_connected = weechat_infolist_integer (infolist, "ssl_connected"); @@ -373,6 +377,7 @@ irc_upgrade_read_cb (void *data, irc_upgrade_current_server->nick_modes = strdup (str); irc_upgrade_current_server->cap_away_notify = weechat_infolist_integer (infolist, "cap_away_notify"); irc_upgrade_current_server->cap_account_notify = weechat_infolist_integer (infolist, "cap_account_notify"); + irc_upgrade_current_server->cap_extended_join = weechat_infolist_integer (infolist, "cap_extended_join"); str = weechat_infolist_string (infolist, "isupport"); if (str) irc_upgrade_current_server->isupport = strdup (str); @@ -574,7 +579,8 @@ irc_upgrade_read_cb (void *data, weechat_infolist_string (infolist, "host"), weechat_infolist_string (infolist, "prefixes"), weechat_infolist_integer (infolist, "away"), - weechat_infolist_string (infolist, "account")); + weechat_infolist_string (infolist, "account"), + weechat_infolist_string (infolist, "realname")); if (ptr_nick) { /* @@ -732,12 +738,14 @@ irc_upgrade_load () irc_upgrade_set_buffer_callbacks (); - upgrade_file = weechat_upgrade_new (IRC_UPGRADE_FILENAME, 0); + upgrade_file = weechat_upgrade_new (IRC_UPGRADE_FILENAME, + &irc_upgrade_read_cb, NULL, NULL); if (!upgrade_file) return 0; - rc = weechat_upgrade_read (upgrade_file, &irc_upgrade_read_cb, NULL); + + rc = weechat_upgrade_read (upgrade_file); + weechat_upgrade_close (upgrade_file); return rc; } - diff --git a/src/plugins/irc/irc-upgrade.h b/src/plugins/irc/irc-upgrade.h index 17da632cd..0c9ab8730 100644 --- a/src/plugins/irc/irc-upgrade.h +++ b/src/plugins/irc/irc-upgrade.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org> + * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org> * * This file is part of WeeChat, the extensible chat client. * diff --git a/src/plugins/irc/irc.c b/src/plugins/irc/irc.c index 9222d3f88..a75c9b48a 100644 --- a/src/plugins/irc/irc.c +++ b/src/plugins/irc/irc.c @@ -1,7 +1,7 @@ /* * irc.c - IRC (Internet Relay Chat) plugin for WeeChat * - * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org> + * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org> * * This file is part of WeeChat, the extensible chat client. * @@ -64,12 +64,14 @@ int irc_signal_upgrade_received = 0; /* signal "upgrade" received ? */ */ int -irc_signal_quit_cb (void *data, const char *signal, const char *type_data, +irc_signal_quit_cb (const void *pointer, void *data, + const char *signal, const char *type_data, void *signal_data) { struct t_irc_server *ptr_server; /* make C compiler happy */ + (void) pointer; (void) data; (void) signal; @@ -92,13 +94,15 @@ irc_signal_quit_cb (void *data, const char *signal, const char *type_data, */ int -irc_signal_upgrade_cb (void *data, const char *signal, const char *type_data, +irc_signal_upgrade_cb (const void *pointer, void *data, + const char *signal, const char *type_data, void *signal_data) { struct t_irc_server *ptr_server; int quit, ssl_disconnected; /* make C compiler happy */ + (void) pointer; (void) data; (void) signal; (void) type_data; @@ -179,21 +183,32 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[]) /* hook some signals */ irc_debug_init (); - weechat_hook_signal ("quit", &irc_signal_quit_cb, NULL); - weechat_hook_signal ("upgrade", &irc_signal_upgrade_cb, NULL); - weechat_hook_signal ("xfer_send_ready", &irc_server_xfer_send_ready_cb, NULL); - weechat_hook_signal ("xfer_resume_ready", &irc_server_xfer_resume_ready_cb, NULL); - weechat_hook_signal ("xfer_send_accept_resume", &irc_server_xfer_send_accept_resume_cb, NULL); - weechat_hook_signal ("irc_input_send", &irc_input_send_cb, NULL); + weechat_hook_signal ("quit", + &irc_signal_quit_cb, NULL, NULL); + weechat_hook_signal ("upgrade", + &irc_signal_upgrade_cb, NULL, NULL); + weechat_hook_signal ("xfer_send_ready", + &irc_server_xfer_send_ready_cb, NULL, NULL); + weechat_hook_signal ("xfer_resume_ready", + &irc_server_xfer_resume_ready_cb, NULL, NULL); + weechat_hook_signal ("xfer_send_accept_resume", + &irc_server_xfer_send_accept_resume_cb, NULL, NULL); + weechat_hook_signal ("irc_input_send", + &irc_input_send_cb, NULL, NULL); /* hook hsignals for redirection */ - weechat_hook_hsignal ("irc_redirect_pattern", &irc_redirect_pattern_hsignal_cb, NULL); - weechat_hook_hsignal ("irc_redirect_command", &irc_redirect_command_hsignal_cb, NULL); + weechat_hook_hsignal ("irc_redirect_pattern", + &irc_redirect_pattern_hsignal_cb, NULL, NULL); + weechat_hook_hsignal ("irc_redirect_command", + &irc_redirect_command_hsignal_cb, NULL, NULL); /* modifiers */ - weechat_hook_modifier ("irc_color_decode", &irc_color_modifier_cb, NULL); - weechat_hook_modifier ("irc_color_encode", &irc_color_modifier_cb, NULL); - weechat_hook_modifier ("irc_color_decode_ansi", &irc_color_modifier_cb, NULL); + weechat_hook_modifier ("irc_color_decode", + &irc_color_modifier_cb, NULL, NULL); + weechat_hook_modifier ("irc_color_encode", + &irc_color_modifier_cb, NULL, NULL); + weechat_hook_modifier ("irc_color_decode_ansi", + &irc_color_modifier_cb, NULL, NULL); /* hook completions */ irc_completion_init (); @@ -245,7 +260,8 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[]) } irc_hook_timer = weechat_hook_timer (1 * 1000, 0, 0, - &irc_server_timer_cb, NULL); + &irc_server_timer_cb, + NULL, NULL); return WEECHAT_RC_OK; } diff --git a/src/plugins/irc/irc.h b/src/plugins/irc/irc.h index 1ee4d538b..3e4cce9f2 100644 --- a/src/plugins/irc/irc.h +++ b/src/plugins/irc/irc.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org> + * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org> * Copyright (C) 2006 Emmanuel Bouthenot <kolter@openics.org> * * This file is part of WeeChat, the extensible chat client. |