diff options
27 files changed, 1745 insertions, 1484 deletions
diff --git a/src/core/wee-command.c b/src/core/wee-command.c index 0ffb8a251..d0b93696a 100644 --- a/src/core/wee-command.c +++ b/src/core/wee-command.c @@ -1908,7 +1908,7 @@ command_init () " scroll 15 min down: /buffer scroll +15m\n" " scroll 20 msgs up: /buffer scroll -20\n" " jump to #weechat: /buffer #weechat"), - "move|close|list|notify|scroll|set|%S|%C %S|%C", + "move|close|list|notify|scroll|set|%b|%c %b|%c", command_buffer, NULL); hook_command (NULL, "builtin", N_("launch WeeChat builtin command (do not look at commands " @@ -1975,12 +1975,12 @@ command_init () "all plugins, then autoload plugins)\n" " unload: unload one or all plugins\n\n" "Without argument, /plugin command lists loaded plugins."), - "list|listfull|load|autoload|reload|unload %P", + "list|listfull|load|autoload|reload|unload %p", command_plugin, NULL); hook_command (NULL, "quit", N_("quit WeeChat"), "", "", - NULL, + "%q", command_quit, NULL); hook_command (NULL, "reload", N_("reload WeeChat and plugins configuration files from " diff --git a/src/core/wee-config.c b/src/core/wee-config.c index 191df3be5..d8dc7b43b 100644 --- a/src/core/wee-config.c +++ b/src/core/wee-config.c @@ -74,7 +74,6 @@ struct t_config_option *config_look_prefix_align_max; struct t_config_option *config_look_prefix_suffix; struct t_config_option *config_look_nick_completor; struct t_config_option *config_look_nick_completion_ignore; -struct t_config_option *config_look_nick_completion_smart; struct t_config_option *config_look_nick_complete_first; struct t_config_option *config_look_infobar; struct t_config_option *config_look_infobar_time_format; @@ -529,10 +528,6 @@ config_weechat_init () ptr_section, "look_nick_completion_ignore", "string", N_("chars ignored for nick completion"), NULL, 0, 0, "[]-^", NULL); - config_look_nick_completion_smart = config_file_new_option ( - ptr_section, "look_nick_completion_smart", "boolean", - N_("smart completion for nicks (completes with last speakers first)"), - NULL, 0, 0, "on", NULL); config_look_nick_complete_first = config_file_new_option ( ptr_section, "look_nick_complete_first", "boolean", N_("complete only with first nick found"), diff --git a/src/core/wee-config.h b/src/core/wee-config.h index f79135eac..040e74f81 100644 --- a/src/core/wee-config.h +++ b/src/core/wee-config.h @@ -68,7 +68,6 @@ extern struct t_config_option *config_look_prefix_align_max; extern struct t_config_option *config_look_prefix_suffix; extern struct t_config_option *config_look_nick_completor; extern struct t_config_option *config_look_nick_completion_ignore; -extern struct t_config_option *config_look_nick_completion_smart; extern struct t_config_option *config_look_nick_complete_first; extern struct t_config_option *config_look_infobar; extern struct t_config_option *config_look_infobar_time_format; diff --git a/src/core/wee-hook.c b/src/core/wee-hook.c index 033eddcf1..3f21e2e26 100644 --- a/src/core/wee-hook.c +++ b/src/core/wee-hook.c @@ -866,10 +866,13 @@ hook_completion (void *plugin, char *completion, */ void -hook_completion_exec (void *plugin, char *completion, void *list) +hook_completion_exec (void *plugin, char *completion, void *buffer, void *list) { struct t_hook *ptr_hook, *next_hook; + /* make C compiler happy */ + (void) plugin; + hook_exec_recursion++; ptr_hook = weechat_hooks; @@ -879,13 +882,12 @@ hook_completion_exec (void *plugin, char *completion, void *list) if ((ptr_hook->type == HOOK_TYPE_COMPLETION) && (!ptr_hook->running) - && (ptr_hook->plugin == plugin) && (string_strcasecmp (HOOK_COMPLETION(ptr_hook, completion), completion) == 0)) { ptr_hook->running = 1; (void) (HOOK_COMPLETION(ptr_hook, callback)) - (ptr_hook->callback_data, completion, list); + (ptr_hook->callback_data, completion, buffer, list); if (ptr_hook->type == HOOK_TYPE_COMPLETION) ptr_hook->running = 0; } @@ -895,7 +897,7 @@ hook_completion_exec (void *plugin, char *completion, void *list) if (hook_exec_recursion > 0) hook_exec_recursion--; - + if (hook_exec_recursion == 0) hook_remove_deleted (); } diff --git a/src/core/wee-hook.h b/src/core/wee-hook.h index ceb49998a..72f69e062 100644 --- a/src/core/wee-hook.h +++ b/src/core/wee-hook.h @@ -123,7 +123,7 @@ struct t_hook_config /* (NULL = hook for all options) */ }; -typedef int (t_hook_callback_completion)(void *, char *, void *); +typedef int (t_hook_callback_completion)(void *, char *, void *, void *); struct t_hook_completion { @@ -161,7 +161,7 @@ extern struct t_hook *hook_config (void *, char *, char *, extern void hook_config_exec (char *, char *, char *); extern struct t_hook *hook_completion (void *, char *, t_hook_callback_completion *, void *); -extern void hook_completion_exec (void *, char *, void *); +extern void hook_completion_exec (void *, char *, void *, void *); extern void unhook (struct t_hook *); extern void unhook_all_plugin (void *); diff --git a/src/gui/gui-completion.c b/src/gui/gui-completion.c index 555404648..32dd8015d 100644 --- a/src/gui/gui-completion.c +++ b/src/gui/gui-completion.c @@ -16,7 +16,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -/* completion.c: completes words according to context (cmd/nick) */ +/* gui-completion.c: completes words according to context */ #ifdef HAVE_CONFIG_H @@ -245,43 +245,38 @@ gui_completion_list_add (struct t_gui_completion *completion, char *word, } /* - * gui_completion_list_add_channel: add current channel to completion list + * gui_completion_list_add_buffers_names: add buffers names to completion list */ void -gui_completion_list_add_channel (struct t_gui_completion *completion) +gui_completion_list_add_buffers_names (struct t_gui_completion *completion) { - (void) completion; - /*if (completion->channel) - gui_completion_list_add (completion, - ((t_irc_channel *)(completion->channel))->name, - 0, WEELIST_POS_SORT);*/ + struct t_gui_buffer *ptr_buffer; + + for (ptr_buffer = gui_buffers; ptr_buffer; + ptr_buffer = ptr_buffer->next_buffer) + { + gui_completion_list_add (completion, ptr_buffer->name, + 0, WEELIST_POS_SORT); + } } /* - * gui_completion_list_add_channels: add server channels to completion list + * gui_completion_list_add_buffers_categories: add buffers categories to + * completion list */ void -gui_completion_list_add_channels (struct t_gui_completion *completion) +gui_completion_list_add_buffers_categories (struct t_gui_completion *completion) { - (void) completion; - /*t_irc_server *ptr_server; - t_irc_channel *ptr_channel; - - if (completion->server) + struct t_gui_buffer *ptr_buffer; + + for (ptr_buffer = gui_buffers; ptr_buffer; + ptr_buffer = ptr_buffer->next_buffer) { - for (ptr_server = irc_servers; ptr_server; - ptr_server = ptr_server->next_server) - { - for (ptr_channel = ptr_server->channels; - ptr_channel; ptr_channel = ptr_channel->next_channel) - { - gui_completion_list_add (completion, ptr_channel->name, - 0, WEELIST_POS_SORT); - } - } - }*/ + gui_completion_list_add (completion, ptr_buffer->category, + 0, WEELIST_POS_SORT); + } } /* @@ -400,25 +395,6 @@ gui_completion_list_add_command_hooks (struct t_gui_completion *completion) } /* - * gui_completion_list_add_irc_cmd_recv: add IRC command (received) to - * completion list - */ - -void -gui_completion_list_add_irc_cmd_recv (struct t_gui_completion *completion) -{ - (void) completion; - /*int i; - - for (i = 0; irc_commands[i].name; i++) - { - if (irc_commands[i].recv_function) - gui_completion_list_add(completion, irc_commands[i].name, - 0, WEELIST_POS_SORT); - }*/ -} - -/* * gui_completion_list_add_key_cmd: add key commands/functions to completion * list */ @@ -449,161 +425,6 @@ gui_completion_list_add_self_nick (struct t_gui_completion *completion) } /* - * gui_completion_list_add_server_nicks: add server nicks to completion list - */ - -void -gui_completion_list_add_server_nicks (struct t_gui_completion *completion) -{ - (void) completion; - /*t_irc_server *ptr_server; - t_irc_channel *ptr_channel; - t_irc_nick *ptr_nick; - - if (completion->server) - { - for (ptr_server = (t_irc_server *)(completion->server); ptr_server; - ptr_server = ptr_server->next_server) - { - for (ptr_channel = ptr_server->channels; ptr_channel; - ptr_channel = ptr_channel->next_channel) - { - if ((!completion->channel || (t_irc_channel *)(completion->channel) != ptr_channel) - && (ptr_channel->type == IRC_CHANNEL_TYPE_CHANNEL)) - { - for (ptr_nick = ptr_channel->nicks; ptr_nick; - ptr_nick = ptr_nick->next_nick) - { - gui_completion_list_add (completion, ptr_nick->nick, - 1, WEELIST_POS_SORT); - } - } - } - } - - // add current channel nicks at beginning - if (completion->channel && (((t_irc_channel *)(completion->channel))->type == IRC_CHANNEL_TYPE_CHANNEL)) - { - for (ptr_nick = ((t_irc_channel *)(completion->channel))->nicks; - ptr_nick; ptr_nick = ptr_nick->next_nick) - { - gui_completion_list_add (completion, ptr_nick->nick, - 1, WEELIST_POS_BEGINNING); - } - } - - // add self nick at the end - if (completion->server) - gui_completion_list_add (completion, - ((t_irc_server *)(completion->server))->nick, - 1, WEELIST_POS_END); - - completion->arg_is_nick = 1; - }*/ -} - -/* - * gui_completion_list_add_channel_nicks: add channel nicks to completion list - */ - -void -gui_completion_list_add_channel_nicks (struct t_gui_completion *completion) -{ - (void) completion; - /*t_irc_nick *ptr_nick; - struct t_weelist *ptr_weelist; - - if (completion->channel) - { - if (((t_irc_channel *)(completion->channel))->type == IRC_CHANNEL_TYPE_CHANNEL) - { - // add channel nicks - for (ptr_nick = ((t_irc_channel *)(completion->channel))->nicks; - ptr_nick; ptr_nick = ptr_nick->next_nick) - { - gui_completion_list_add (completion, ptr_nick->nick, - 1, WEELIST_POS_SORT); - } - - // add nicks speaking recently on this channel - if (CONFIG_BOOLEAN(config_look_nick_completion_smart)) - { - for (ptr_weelist = ((t_irc_channel *)(completion->channel))->nicks_speaking; - ptr_weelist; ptr_weelist = ptr_weelist->next_weelist) - { - if (irc_nick_search ((t_irc_channel *)(completion->channel), - ptr_weelist->data)) - gui_completion_list_add (completion, ptr_weelist->data, - 1, WEELIST_POS_BEGINNING); - } - } - - // add self nick at the end - if (completion->server) - gui_completion_list_add (completion, - ((t_irc_server *)(completion->server))->nick, - 1, WEELIST_POS_END); - } - if ((((t_irc_channel *)(completion->channel))->type == IRC_CHANNEL_TYPE_PRIVATE) - || (((t_irc_channel *)(completion->channel))->type == IRC_CHANNEL_TYPE_DCC_CHAT)) - { - gui_completion_list_add (completion, - ((t_irc_channel *)(completion->channel))->name, - 1, WEELIST_POS_SORT); - } - completion->arg_is_nick = 1; - }*/ -} - -/* - * gui_completion_list_add_channel_nicks_hosts: add channel nicks and hosts to completion list - */ - -void -gui_completion_list_add_channel_nicks_hosts (struct t_gui_completion *completion) -{ - (void) completion; - /*t_irc_nick *ptr_nick; - char *buf; - int length; - - if (completion->channel) - { - if (((t_irc_channel *)(completion->channel))->type == IRC_CHANNEL_TYPE_CHANNEL) - { - for (ptr_nick = ((t_irc_channel *)(completion->channel))->nicks; - ptr_nick; ptr_nick = ptr_nick->next_nick) - { - gui_completion_list_add (completion, ptr_nick->nick, - 1, WEELIST_POS_SORT); - if (ptr_nick->host) - { - length = strlen (ptr_nick->nick) + 1 + - strlen (ptr_nick->host) + 1; - buf = (char *) malloc (length); - if (buf) - { - snprintf (buf, length, "%s!%s", - ptr_nick->nick, ptr_nick->host); - gui_completion_list_add (completion, buf, - 1, WEELIST_POS_SORT); - free (buf); - } - } - } - } - if ((((t_irc_channel *)(completion->channel))->type == IRC_CHANNEL_TYPE_PRIVATE) - || (((t_irc_channel *)(completion->channel))->type == IRC_CHANNEL_TYPE_PRIVATE)) - { - gui_completion_list_add (completion, - ((t_irc_channel *)(completion->channel))->name, - 1, WEELIST_POS_SORT); - } - completion->arg_is_nick = 1; - }*/ -} - -/* * gui_completion_list_add_option: add config option to completion list */ @@ -644,19 +465,6 @@ gui_completion_list_add_plugin_option (struct t_gui_completion *completion) } /* - * gui_completion_list_add_part: add part message to completion list - */ - -void -gui_completion_list_add_part (struct t_gui_completion *completion) -{ - (void) completion; - /*if (config_irc_default_msg_part && config_irc_default_msg_part[0]) - gui_completion_list_add (completion, config_irc_default_msg_part, - 0, WEELIST_POS_SORT);*/ -} - -/* * gui_completion_list_add_plugin: add plugin name to completion list */ @@ -680,69 +488,11 @@ gui_completion_list_add_plugin (struct t_gui_completion *completion) void gui_completion_list_add_quit (struct t_gui_completion *completion) { - (void) completion; - /*if (config_irc_default_msg_quit && config_irc_default_msg_quit[0]) - gui_completion_list_add (completion, config_irc_default_msg_quit, - 0, WEELIST_POS_SORT);*/ -} - -/* - * gui_completion_list_add_server: add current server to completion list - */ - -void -gui_completion_list_add_server (struct t_gui_completion *completion) -{ - (void) completion; - /*if (completion->server) + if (CONFIG_STRING(config_look_default_msg_quit) + && CONFIG_STRING(config_look_default_msg_quit)[0]) gui_completion_list_add (completion, - ((t_irc_server *)(completion->server))->name, - 0, WEELIST_POS_SORT);*/ -} - -/* - * gui_completion_list_add_servers: add all servers to completion list - */ - -void -gui_completion_list_add_servers (struct t_gui_completion *completion) -{ - (void) completion; - /*t_irc_server *ptr_server; - - for (ptr_server = irc_servers; ptr_server; - ptr_server = ptr_server->next_server) - { - gui_completion_list_add (completion, ptr_server->name, + CONFIG_STRING(config_look_default_msg_quit), 0, WEELIST_POS_SORT); - }*/ -} - -/* - * gui_completion_list_add_topic: add topic to completion list - */ - -void -gui_completion_list_add_topic (struct t_gui_completion *completion) -{ - (void) completion; - /*char *string; - - if (completion->server && completion->channel - && ((t_irc_channel *)(completion->channel))->topic - && ((t_irc_channel *)(completion->channel))->topic[0]) - { - if (config_irc_colors_send) - string = (char *)gui_color_decode_for_user_entry ((unsigned char *)((t_irc_channel *)(completion->channel))->topic); - else - string = (char *)gui_color_decode ((unsigned char *)((t_irc_channel *)(completion->channel))->topic, 0, 0); - gui_completion_list_add (completion, - (string) ? - string : ((t_irc_channel *)(completion->channel))->topic, - 0, WEELIST_POS_SORT); - if (string) - free (string); - }*/ } /* @@ -868,6 +618,7 @@ gui_completion_custom (struct t_gui_completion *completion, { hook_completion_exec (plugin, custom_completion, + completion->buffer, completion->completion_list); } @@ -914,11 +665,11 @@ gui_completion_build_list_template (struct t_gui_completion *completion, break; case '*': /* repeat last completion (do nothing there) */ break; - case 'c': /* current channel */ - gui_completion_list_add_channel (completion); + case 'b': /* buffers names */ + gui_completion_list_add_buffers_names (completion); break; - case 'C': /* all channels */ - gui_completion_list_add_channels (completion); + case 'c': /* buffers categories */ + gui_completion_list_add_buffers_categories (completion); break; case 'f': /* filename */ gui_completion_list_add_filename (completion); @@ -932,40 +683,18 @@ gui_completion_build_list_template (struct t_gui_completion *completion, case 'm': /* self nickname */ gui_completion_list_add_self_nick (completion); break; - case 'M': /* nicks of current server (all open channels) */ - gui_completion_list_add_server_nicks (completion); - break; - case 'n': /* channel nicks */ - gui_completion_list_add_channel_nicks (completion); - completion->context = GUI_COMPLETION_NICK; - break; - case 'N': /* channel nicks and hosts */ - gui_completion_list_add_channel_nicks_hosts (completion); - break; case 'o': /* config option */ gui_completion_list_add_option (completion); break; case 'O': /* plugin option */ gui_completion_list_add_plugin_option (completion); break; - case 'p': /* part message */ - gui_completion_list_add_part (completion); - break; - case 'P': /* plugin name */ + case 'p': /* plugin name */ gui_completion_list_add_plugin (completion); break; case 'q': /* quit message */ gui_completion_list_add_quit (completion); break; - case 's': /* current server */ - gui_completion_list_add_server (completion); - break; - case 'S': /* all servers */ - gui_completion_list_add_servers (completion); - break; - case 't': /* topic */ - gui_completion_list_add_topic (completion); - break; case 'v': /* value of config option */ gui_completion_list_add_option_value (completion); break; diff --git a/src/gui/gui-infobar.c b/src/gui/gui-infobar.c index 8e3d78815..99391f8ce 100644 --- a/src/gui/gui-infobar.c +++ b/src/gui/gui-infobar.c @@ -34,7 +34,7 @@ #include "gui-window.h" -t_gui_infobar *gui_infobar; /* pointer to infobar content */ +struct t_gui_infobar *gui_infobar; /* pointer to infobar content */ /* @@ -46,14 +46,17 @@ gui_infobar_printf (int time_displayed, int color, char *message, ...) { static char buf[1024]; va_list argptr; - t_gui_infobar *ptr_infobar; + struct t_gui_infobar *ptr_infobar; char *buf2, *ptr_buf, *pos; + if (!message) + return; + va_start (argptr, message); vsnprintf (buf, sizeof (buf) - 1, message, argptr); va_end (argptr); - ptr_infobar = (t_gui_infobar *)malloc (sizeof (t_gui_infobar)); + ptr_infobar = (struct t_gui_infobar *)malloc (sizeof (struct t_gui_infobar)); if (ptr_infobar) { buf2 = (char *)gui_color_decode ((unsigned char *)buf); @@ -82,7 +85,7 @@ gui_infobar_printf (int time_displayed, int color, char *message, ...) void gui_infobar_remove () { - t_gui_infobar *new_infobar; + struct t_gui_infobar *new_infobar; if (gui_infobar) { diff --git a/src/gui/gui-infobar.h b/src/gui/gui-infobar.h index 57baa8f45..4e2c776ba 100644 --- a/src/gui/gui-infobar.h +++ b/src/gui/gui-infobar.h @@ -22,8 +22,6 @@ #include "gui-buffer.h" -typedef struct t_gui_infobar t_gui_infobar; - struct t_gui_infobar { int color; /* text color */ @@ -31,12 +29,12 @@ struct t_gui_infobar int remaining_time; /* delay (sec) before erasing this text */ /* if < 0, text is never erased (except */ /* by user action to erase it) */ - t_gui_infobar *next_infobar; /* next message for infobar */ + struct t_gui_infobar *next_infobar; /* next message for infobar */ }; /* infobar variables */ -extern t_gui_infobar *gui_infobar; +extern struct t_gui_infobar *gui_infobar; /* infobar functions */ diff --git a/src/plugins/alias/alias.c b/src/plugins/alias/alias.c index 238f40e3f..432d0480f 100644 --- a/src/plugins/alias/alias.c +++ b/src/plugins/alias/alias.c @@ -40,10 +40,6 @@ struct t_weechat_plugin *weechat_alias_plugin = NULL; struct t_config_file *alias_config_file = NULL; struct t_alias *alias_list = NULL; struct t_alias *last_alias = NULL; -struct t_hook *alias_command = NULL; -struct t_hook *unalias_command = NULL; -struct t_hook *config_reload = NULL; -struct t_hook *completion = NULL; /* @@ -692,18 +688,19 @@ unalias_command_cb (void *data, void *buffer, int argc, char **argv, } /* - * alias_completion_cb: callback for completion + * alias_completion_cb: callback for completion with list of aliases */ int -alias_completion_cb (void *data, char *completion, void *list) +alias_completion_cb (void *data, char *completion, void *buffer, void *list) { struct t_alias *ptr_alias; /* make C compiler happy */ (void) data; (void) completion; - + (void) buffer; + for (ptr_alias = alias_list; ptr_alias; ptr_alias = ptr_alias->next_alias) { @@ -732,39 +729,30 @@ weechat_plugin_init (struct t_weechat_plugin *plugin) } alias_config_read (); - alias_command = weechat_hook_command ("alias", - N_("create an alias for a command"), - N_("[alias_name [command [arguments]]]"), - N_("alias_name: name of alias\n" - " command: command name (many " - "commands can be separated by " - "semicolons)\n" - " arguments: arguments for " - "command\n\n" - "Note: in command, special " - "variables $1, $2,..,$9 " - "are replaced by arguments given " - "by user, and $* " - "is replaced by all arguments.\n" - "Variables $nick, $channel and " - "$server are " - "replaced by current nick/channel" - "/server."), - "%- %h", - &alias_command_cb, NULL); - - unalias_command = weechat_hook_command ("unalias", N_("remove an alias"), - N_("alias_name"), - N_("alias_name: name of alias to " - "remove"), - "%(alias)", - &unalias_command_cb, NULL); - - config_reload = weechat_hook_event ("config_reload", - &alias_config_reload_event_cb, NULL); - - completion = weechat_hook_completion ("alias", - &alias_completion_cb, NULL); + weechat_hook_command ("alias", + N_("create an alias for a command"), + N_("[alias_name [command [arguments]]]"), + N_("alias_name: name of alias\n" + " command: command name (many commands can be " + "separated by semicolons)\n" + " arguments: arguments for command\n\n" + "Note: in command, special variables " + "$1, $2,..,$9 are replaced by arguments given " + "by user, and $* is replaced by all arguments.\n" + "Variables $nick, $channel and $server are " + "replaced by current nick/channel/server."), + "%- %h", + &alias_command_cb, NULL); + + weechat_hook_command ("unalias", N_("remove an alias"), + N_("alias_name"), + N_("alias_name: name of alias to remove"), + "%(alias)", + &unalias_command_cb, NULL); + + weechat_hook_event ("config_reload", &alias_config_reload_event_cb, NULL); + + weechat_hook_completion ("alias", &alias_completion_cb, NULL); return WEECHAT_RC_OK; } @@ -777,12 +765,8 @@ int weechat_plugin_end () { alias_config_write (); - alias_free_all (); + alias_free_all (); weechat_config_free (alias_config_file); - weechat_unhook (alias_command); - weechat_unhook (unalias_command); - weechat_unhook (config_reload); - weechat_unhook (completion); return WEECHAT_RC_OK; } diff --git a/src/plugins/irc/CMakeLists.txt b/src/plugins/irc/CMakeLists.txt index 8ac26b42c..55f51066c 100644 --- a/src/plugins/irc/CMakeLists.txt +++ b/src/plugins/irc/CMakeLists.txt @@ -15,12 +15,14 @@ # SET(LIB_PROTOCOL_IRC_SRC irc.c irc.h irc-channel.c irc-channel.h irc-command.c -irc-command.h irc-config.c irc-config.h irc-server.c irc-server.h) +irc-command.h irc-completion.c irc-completion.h irc-config.c irc-config.h +irc-server.c irc-server.h) #SET(LIB_PROTOCOL_IRC_SRC irc.c irc.h irc-buffer.c irc-buffer.h irc-channel.c -#irc-channel.h irc-command.c irc-command.h irc-color.c irc-color.h irc-config.c -#irc-config.h irc-dcc.c irc-dcc.h irc-display.c irc-input.c irc-log.c irc-mode.c -#irc-nick.c irc-nick.h irc-protocol.c irc-protocol.h irc-server.c irc-server.h) +#irc-channel.h irc-command.c irc-command.h irc-completion.c irc-completion.h +#irc-color.c irc-color.h irc-config.c irc-config.h irc-dcc.c irc-dcc.h +#irc-display.c irc-input.c irc-log.c irc-mode.c irc-nick.c irc-nick.h +#irc-protocol.c irc-protocol.h irc-server.c irc-server.h) CHECK_INCLUDE_FILES("regex.h" HAVE_REGEX_H) CHECK_FUNCTION_EXISTS(regexec HAVE_REGEXEC) diff --git a/src/plugins/irc/Makefile.am b/src/plugins/irc/Makefile.am index dbdb02741..4b5cac65a 100644 --- a/src/plugins/irc/Makefile.am +++ b/src/plugins/irc/Makefile.am @@ -28,6 +28,8 @@ irc_la_SOURCES = irc.c \ irc-color.h \ irc-command.c \ irc-command.h \ + irc-completion.c \ + irc-completion.h \ irc-config.c \ irc-config.h \ irc-display.c \ diff --git a/src/plugins/irc/irc-command.c b/src/plugins/irc/irc-command.c index ce245987c..a0c064210 100644 --- a/src/plugins/irc/irc-command.c +++ b/src/plugins/irc/irc-command.c @@ -48,7 +48,7 @@ int irc_command_admin (void *data, void *buffer, int argc, char **argv, char **argv_eol) { - IRC_COMMAND_GET_SERVER(buffer); + IRC_GET_SERVER(buffer); if (!ptr_server || !ptr_server->is_connected) return WEECHAT_RC_ERROR; @@ -219,7 +219,8 @@ irc_command_amsg (void *data, void *buffer, int argc, char **argv, string = (char *)irc_color_decode ( (unsigned char *)argv_eol[1], 1, 0); weechat_printf (ptr_channel->buffer, "%s%s", - irc_nick_as_prefix (ptr_nick), + irc_nick_as_prefix (ptr_nick, + NULL, NULL), (string) ? string : argv_eol[1]); if (string) free (string); @@ -378,7 +379,7 @@ int irc_command_away (void *data, void *buffer, int argc, char **argv, char **argv_eol) { - IRC_COMMAND_GET_SERVER(buffer); + IRC_GET_SERVER(buffer); if (!ptr_server) return WEECHAT_RC_ERROR; @@ -415,7 +416,7 @@ irc_command_ban (void *data, void *buffer, int argc, char **argv, char *pos_channel; int pos_args; - IRC_COMMAND_GET_SERVER_CHANNEL(buffer); + IRC_GET_SERVER_CHANNEL(buffer); if (!ptr_server || !ptr_server->is_connected) return WEECHAT_RC_ERROR; @@ -529,7 +530,7 @@ irc_command_connect (void *data, void *buffer, int argc, char **argv, char *error; long number; - IRC_COMMAND_GET_SERVER(buffer); + IRC_GET_SERVER(buffer); /* make C compiler happy */ (void) data; @@ -677,7 +678,7 @@ irc_command_ctcp (void *data, void *buffer, int argc, char **argv, char *pos, *irc_cmd; struct timeval tv; - IRC_COMMAND_GET_SERVER(buffer); + IRC_GET_SERVER(buffer); if (!ptr_server || !ptr_server->is_connected) return WEECHAT_RC_ERROR; @@ -766,7 +767,7 @@ irc_command_cycle (void *data, void *buffer, int argc, char **argv, char **channels; int i, num_channels; - IRC_COMMAND_GET_SERVER_CHANNEL(buffer); + IRC_GET_SERVER_CHANNEL(buffer); if (!ptr_server || !ptr_server->is_connected) return WEECHAT_RC_ERROR; @@ -865,7 +866,7 @@ int irc_command_dcc (void *data, void *buffer, int argc, char **argv, char **argv_eol) { - IRC_COMMAND_GET_SERVER_CHANNEL(buffer); + IRC_GET_SERVER_CHANNEL(buffer); if (!ptr_server || !ptr_server->is_connected) return WEECHAT_RC_ERROR; @@ -930,7 +931,7 @@ int irc_command_dehalfop (void *data, void *buffer, int argc, char **argv, char **argv_eol) { - IRC_COMMAND_GET_SERVER_CHANNEL(buffer); + IRC_GET_SERVER_CHANNEL(buffer); if (!ptr_server || !ptr_server->is_connected) return WEECHAT_RC_ERROR; @@ -967,7 +968,7 @@ int irc_command_deop (void *data, void *buffer, int argc, char **argv, char **argv_eol) { - IRC_COMMAND_GET_SERVER_CHANNEL(buffer); + IRC_GET_SERVER_CHANNEL(buffer); if (!ptr_server || !ptr_server->is_connected) return WEECHAT_RC_ERROR; @@ -1004,7 +1005,7 @@ int irc_command_devoice (void *data, void *buffer, int argc, char **argv, char **argv_eol) { - IRC_COMMAND_GET_SERVER_CHANNEL(buffer); + IRC_GET_SERVER_CHANNEL(buffer); if (!ptr_server || !ptr_server->is_connected) return WEECHAT_RC_ERROR; @@ -1041,7 +1042,7 @@ int irc_command_die (void *data, void *buffer, int argc, char **argv, char **argv_eol) { - IRC_COMMAND_GET_SERVER(buffer); + IRC_GET_SERVER(buffer); if (!ptr_server || !ptr_server->is_connected) return WEECHAT_RC_ERROR; @@ -1133,7 +1134,7 @@ irc_command_disconnect (void *data, void *buffer, int argc, char **argv, { int i, disconnect_ok; - IRC_COMMAND_GET_SERVER(buffer); + IRC_GET_SERVER(buffer); /* make C compiler happy */ (void) data; @@ -1193,7 +1194,7 @@ int irc_command_halfop (void *data, void *buffer, int argc, char **argv, char **argv_eol) { - IRC_COMMAND_GET_SERVER_CHANNEL(buffer); + IRC_GET_SERVER_CHANNEL(buffer); if (!ptr_server || !ptr_server->is_connected) return WEECHAT_RC_ERROR; @@ -1230,7 +1231,7 @@ int irc_command_info (void *data, void *buffer, int argc, char **argv, char **argv_eol) { - IRC_COMMAND_GET_SERVER(buffer); + IRC_GET_SERVER(buffer); if (!ptr_server || !ptr_server->is_connected) return WEECHAT_RC_ERROR; @@ -1253,7 +1254,7 @@ int irc_command_invite (void *data, void *buffer, int argc, char **argv, char **argv_eol) { - IRC_COMMAND_GET_SERVER_CHANNEL(buffer); + IRC_GET_SERVER_CHANNEL(buffer); if (!ptr_server || !ptr_server->is_connected) return WEECHAT_RC_ERROR; @@ -1289,7 +1290,7 @@ int irc_command_ison (void *data, void *buffer, int argc, char **argv, char **argv_eol) { - IRC_COMMAND_GET_SERVER(buffer); + IRC_GET_SERVER(buffer); if (!ptr_server || !ptr_server->is_connected) return WEECHAT_RC_ERROR; @@ -1328,7 +1329,7 @@ int irc_command_join (void *data, void *buffer, int argc, char **argv, char **argv_eol) { - IRC_COMMAND_GET_SERVER(buffer); + IRC_GET_SERVER(buffer); if (!ptr_server || !ptr_server->is_connected) return WEECHAT_RC_ERROR; @@ -1356,7 +1357,7 @@ irc_command_kick (void *data, void *buffer, int argc, char **argv, { char *pos_channel, *pos_nick, *pos_comment; - IRC_COMMAND_GET_SERVER_CHANNEL(buffer); + IRC_GET_SERVER_CHANNEL(buffer); if (!ptr_server || !ptr_server->is_connected) return WEECHAT_RC_ERROR; @@ -1422,7 +1423,7 @@ irc_command_kickban (void *data, void *buffer, int argc, char **argv, { char *pos_channel, *pos_nick, *pos_comment; - IRC_COMMAND_GET_SERVER_CHANNEL(buffer); + IRC_GET_SERVER_CHANNEL(buffer); if (!ptr_server || !ptr_server->is_connected) return WEECHAT_RC_ERROR; @@ -1488,7 +1489,7 @@ int irc_command_kill (void *data, void *buffer, int argc, char **argv, char **argv_eol) { - IRC_COMMAND_GET_SERVER(buffer); + IRC_GET_SERVER(buffer); if (!ptr_server || !ptr_server->is_connected) return WEECHAT_RC_ERROR; @@ -1517,7 +1518,7 @@ int irc_command_links (void *data, void *buffer, int argc, char **argv, char **argv_eol) { - IRC_COMMAND_GET_SERVER(buffer); + IRC_GET_SERVER(buffer); if (!ptr_server || !ptr_server->is_connected) return WEECHAT_RC_ERROR; @@ -1544,7 +1545,7 @@ irc_command_list (void *data, void *buffer, int argc, char **argv, char buf[512]; int ret; - IRC_COMMAND_GET_SERVER(buffer); + IRC_GET_SERVER(buffer); if (!ptr_server || !ptr_server->is_connected) return WEECHAT_RC_ERROR; @@ -1602,7 +1603,7 @@ int irc_command_lusers (void *data, void *buffer, int argc, char **argv, char **argv_eol) { - IRC_COMMAND_GET_SERVER(buffer); + IRC_GET_SERVER(buffer); if (!ptr_server || !ptr_server->is_connected) return WEECHAT_RC_ERROR; @@ -1626,7 +1627,7 @@ int irc_command_me (void *data, void *buffer, int argc, char **argv, char **argv_eol) { - IRC_COMMAND_GET_SERVER_CHANNEL(buffer); + IRC_GET_SERVER_CHANNEL(buffer); if (!ptr_server || !ptr_server->is_connected) return WEECHAT_RC_ERROR; @@ -1672,7 +1673,7 @@ int irc_command_mode (void *data, void *buffer, int argc, char **argv, char **argv_eol) { - IRC_COMMAND_GET_SERVER(buffer); + IRC_GET_SERVER(buffer); if (!ptr_server || !ptr_server->is_connected) return WEECHAT_RC_ERROR; @@ -1698,7 +1699,7 @@ int irc_command_motd (void *data, void *buffer, int argc, char **argv, char **argv_eol) { - IRC_COMMAND_GET_SERVER(buffer); + IRC_GET_SERVER(buffer); if (!ptr_server || !ptr_server->is_connected) return WEECHAT_RC_ERROR; @@ -1728,7 +1729,7 @@ irc_command_msg (void *data, void *buffer, int argc, char **argv, struct t_irc_nick *ptr_nick; char *string; - IRC_COMMAND_GET_SERVER_CHANNEL(buffer); + IRC_GET_SERVER_CHANNEL(buffer); if (!ptr_server || !ptr_server->is_connected) return WEECHAT_RC_ERROR; @@ -1897,7 +1898,7 @@ int irc_command_names (void *data, void *buffer, int argc, char **argv, char **argv_eol) { - IRC_COMMAND_GET_SERVER_CHANNEL(buffer); + IRC_GET_SERVER_CHANNEL(buffer); if (!ptr_server || !ptr_server->is_connected) return WEECHAT_RC_ERROR; @@ -1961,7 +1962,7 @@ int irc_command_nick (void *data, void *buffer, int argc, char **argv, char **argv_eol) { - IRC_COMMAND_GET_SERVER(buffer); + IRC_GET_SERVER(buffer); if (!ptr_server) return WEECHAT_RC_ERROR; @@ -2007,7 +2008,7 @@ irc_command_notice (void *data, void *buffer, int argc, char **argv, { char *string; - IRC_COMMAND_GET_SERVER(buffer); + IRC_GET_SERVER(buffer); if (!ptr_server || !ptr_server->is_connected) return WEECHAT_RC_ERROR; @@ -2047,7 +2048,7 @@ int irc_command_op (void *data, void *buffer, int argc, char **argv, char **argv_eol) { - IRC_COMMAND_GET_SERVER_CHANNEL(buffer); + IRC_GET_SERVER_CHANNEL(buffer); if (!ptr_server || !ptr_server->is_connected) return WEECHAT_RC_ERROR; @@ -2084,7 +2085,7 @@ int irc_command_oper (void *data, void *buffer, int argc, char **argv, char **argv_eol) { - IRC_COMMAND_GET_SERVER(buffer); + IRC_GET_SERVER(buffer); if (!ptr_server || !ptr_server->is_connected) return WEECHAT_RC_ERROR; @@ -2112,7 +2113,7 @@ irc_command_part (void *data, void *buffer, int argc, char **argv, { char *channel_name, *pos_args, *ptr_arg, *buf, *version; - IRC_COMMAND_GET_SERVER_CHANNEL(buffer); + IRC_GET_SERVER_CHANNEL(buffer); if (!ptr_server || !ptr_server->is_connected) return WEECHAT_RC_ERROR; @@ -2196,7 +2197,7 @@ int irc_command_ping (void *data, void *buffer, int argc, char **argv, char **argv_eol) { - IRC_COMMAND_GET_SERVER(buffer); + IRC_GET_SERVER(buffer); if (!ptr_server || !ptr_server->is_connected) return WEECHAT_RC_ERROR; @@ -2222,7 +2223,7 @@ int irc_command_pong (void *data, void *buffer, int argc, char **argv, char **argv_eol) { - IRC_COMMAND_GET_SERVER(buffer); + IRC_GET_SERVER(buffer); if (!ptr_server) return WEECHAT_RC_ERROR; @@ -2250,7 +2251,7 @@ irc_command_query (void *data, void *buffer, int argc, char **argv, { char *string; - IRC_COMMAND_GET_SERVER_CHANNEL(buffer); + IRC_GET_SERVER_CHANNEL(buffer); if (!ptr_server || !ptr_server->is_connected) return WEECHAT_RC_ERROR; @@ -2312,7 +2313,7 @@ int irc_command_quote (void *data, void *buffer, int argc, char **argv, char **argv_eol) { - IRC_COMMAND_GET_SERVER(buffer); + IRC_GET_SERVER(buffer); if (!ptr_server)// || !ptr_server->is_connected) return WEECHAT_RC_ERROR; @@ -2371,7 +2372,7 @@ irc_command_reconnect (void *data, void *buffer, int argc, char **argv, { int i, nb_reconnect, reconnect_ok, all_servers, no_join; - IRC_COMMAND_GET_SERVER(buffer); + IRC_GET_SERVER(buffer); /* make C compiler happy */ (void) data; @@ -2444,7 +2445,7 @@ int irc_command_rehash (void *data, void *buffer, int argc, char **argv, char **argv_eol) { - IRC_COMMAND_GET_SERVER(buffer); + IRC_GET_SERVER(buffer); if (!ptr_server || !ptr_server->is_connected) return WEECHAT_RC_ERROR; @@ -2467,7 +2468,7 @@ int irc_command_restart (void *data, void *buffer, int argc, char **argv, char **argv_eol) { - IRC_COMMAND_GET_SERVER(buffer); + IRC_GET_SERVER(buffer); if (!ptr_server || !ptr_server->is_connected) return WEECHAT_RC_ERROR; @@ -2976,7 +2977,7 @@ int irc_command_service (void *data, void *buffer, int argc, char **argv, char **argv_eol) { - IRC_COMMAND_GET_SERVER(buffer); + IRC_GET_SERVER(buffer); if (!ptr_server || !ptr_server->is_connected) return WEECHAT_RC_ERROR; @@ -3002,7 +3003,7 @@ int irc_command_servlist (void *data, void *buffer, int argc, char **argv, char **argv_eol) { - IRC_COMMAND_GET_SERVER(buffer); + IRC_GET_SERVER(buffer); if (!ptr_server || !ptr_server->is_connected) return WEECHAT_RC_ERROR; @@ -3026,7 +3027,7 @@ int irc_command_squery (void *data, void *buffer, int argc, char **argv, char **argv_eol) { - IRC_COMMAND_GET_SERVER(buffer); + IRC_GET_SERVER(buffer); if (!ptr_server || !ptr_server->is_connected) return WEECHAT_RC_ERROR; @@ -3057,7 +3058,7 @@ int irc_command_squit (void *data, void *buffer, int argc, char **argv, char **argv_eol) { - IRC_COMMAND_GET_SERVER(buffer); + IRC_GET_SERVER(buffer); if (!ptr_server || !ptr_server->is_connected) return WEECHAT_RC_ERROR; @@ -3083,7 +3084,7 @@ int irc_command_stats (void *data, void *buffer, int argc, char **argv, char **argv_eol) { - IRC_COMMAND_GET_SERVER(buffer); + IRC_GET_SERVER(buffer); if (!ptr_server || !ptr_server->is_connected) return WEECHAT_RC_ERROR; @@ -3108,7 +3109,7 @@ int irc_command_summon (void *data, void *buffer, int argc, char **argv, char **argv_eol) { - IRC_COMMAND_GET_SERVER(buffer); + IRC_GET_SERVER(buffer); if (!ptr_server || !ptr_server->is_connected) return WEECHAT_RC_ERROR; @@ -3134,7 +3135,7 @@ int irc_command_time (void *data, void *buffer, int argc, char **argv, char **argv_eol) { - IRC_COMMAND_GET_SERVER(buffer); + IRC_GET_SERVER(buffer); if (!ptr_server || !ptr_server->is_connected) return WEECHAT_RC_ERROR; @@ -3160,7 +3161,7 @@ irc_command_topic (void *data, void *buffer, int argc, char **argv, { char *channel_name, *new_topic; - IRC_COMMAND_GET_SERVER_CHANNEL(buffer); + IRC_GET_SERVER_CHANNEL(buffer); if (!ptr_server || !ptr_server->is_connected) return WEECHAT_RC_ERROR; @@ -3221,7 +3222,7 @@ int irc_command_trace (void *data, void *buffer, int argc, char **argv, char **argv_eol) { - IRC_COMMAND_GET_SERVER(buffer); + IRC_GET_SERVER(buffer); if (!ptr_server || !ptr_server->is_connected) return WEECHAT_RC_ERROR; @@ -3248,7 +3249,7 @@ irc_command_unban (void *data, void *buffer, int argc, char **argv, char *pos_channel; int pos_args; - IRC_COMMAND_GET_SERVER_CHANNEL(buffer); + IRC_GET_SERVER_CHANNEL(buffer); if (!ptr_server || !ptr_server->is_connected) return WEECHAT_RC_ERROR; @@ -3311,7 +3312,7 @@ int irc_command_userhost (void *data, void *buffer, int argc, char **argv, char **argv_eol) { - IRC_COMMAND_GET_SERVER(buffer); + IRC_GET_SERVER(buffer); if (!ptr_server || !ptr_server->is_connected) return WEECHAT_RC_ERROR; @@ -3337,7 +3338,7 @@ int irc_command_users (void *data, void *buffer, int argc, char **argv, char **argv_eol) { - IRC_COMMAND_GET_SERVER(buffer); + IRC_GET_SERVER(buffer); if (!ptr_server || !ptr_server->is_connected) return WEECHAT_RC_ERROR; @@ -3361,7 +3362,7 @@ int irc_command_version (void *data, void *buffer, int argc, char **argv, char **argv_eol) { - IRC_COMMAND_GET_SERVER_CHANNEL(buffer); + IRC_GET_SERVER_CHANNEL(buffer); if (!ptr_server || !ptr_server->is_connected) return WEECHAT_RC_ERROR; @@ -3393,7 +3394,7 @@ int irc_command_voice (void *data, void *buffer, int argc, char **argv, char **argv_eol) { - IRC_COMMAND_GET_SERVER_CHANNEL(buffer); + IRC_GET_SERVER_CHANNEL(buffer); if (!ptr_server || !ptr_server->is_connected) return WEECHAT_RC_ERROR; @@ -3431,7 +3432,7 @@ int irc_command_wallops (void *data, void *buffer, int argc, char **argv, char **argv_eol) { - IRC_COMMAND_GET_SERVER(buffer); + IRC_GET_SERVER(buffer); if (!ptr_server || !ptr_server->is_connected) return WEECHAT_RC_ERROR; @@ -3457,7 +3458,7 @@ int irc_command_who (void *data, void *buffer, int argc, char **argv, char **argv_eol) { - IRC_COMMAND_GET_SERVER(buffer); + IRC_GET_SERVER(buffer); if (!ptr_server || !ptr_server->is_connected) return WEECHAT_RC_ERROR; @@ -3481,7 +3482,7 @@ int irc_command_whois (void *data, void *buffer, int argc, char **argv, char **argv_eol) { - IRC_COMMAND_GET_SERVER(buffer); + IRC_GET_SERVER(buffer); if (!ptr_server || !ptr_server->is_connected) return WEECHAT_RC_ERROR; @@ -3507,7 +3508,7 @@ int irc_command_whowas (void *data, void *buffer, int argc, char **argv, char **argv_eol) { - IRC_COMMAND_GET_SERVER(buffer); + IRC_GET_SERVER(buffer); if (!ptr_server || !ptr_server->is_connected) return WEECHAT_RC_ERROR; @@ -3563,7 +3564,7 @@ irc_command_init () N_("[channel] [nickname [nickname ...]]"), N_(" channel: channel for ban\n" "nickname: user or host to ban"), - "%N", &irc_command_ban, NULL); + "%(irc_channel_nicks_hosts)", &irc_command_ban, NULL); weechat_hook_command ("connect", N_("connect to server(s)"), N_("[-all [-nojoin] | servername [servername ...] " @@ -3579,7 +3580,7 @@ irc_command_init () "is 6667)\n" " ipv6: use IPv6 protocol\n" " ssl: use SSL protocol"), - "%S|-all|-nojoin|%*", &irc_command_connect, NULL); + "%(irc_servers)|-all|-nojoin|%*", &irc_command_connect, NULL); weechat_hook_command ("ctcp", N_("send a CTCP message (Client-To-Client Protocol)"), N_("receiver type [arguments]"), @@ -3587,14 +3588,15 @@ irc_command_init () " type: CTCP type (examples: \"version\", " "\"ping\", ..)\n" "arguments: arguments for CTCP"), - "%c|%n action|ping|version", &irc_command_ctcp, NULL); + "%(irc_channel)|%(irc_channel_nicks) action|ping|version", + &irc_command_ctcp, NULL); weechat_hook_command ("cycle", N_("leave and rejoin a channel"), N_("[channel[,channel]] [part_message]"), N_(" channel: channel name for cycle\n" "part_message: part message (displayed to other " "users)"), - "%p", &irc_command_cycle, NULL); + "%(irc_msg_part)", &irc_command_cycle, NULL); weechat_hook_command ("dcc", N_("starts DCC (file or chat) or close chat"), N_("action [nickname [file]]"), @@ -3602,7 +3604,8 @@ irc_command_init () "(chat)\n" "nickname: nickname to send file or chat\n" " file: filename (on local host)"), - "chat|send|close %n %f", &irc_command_dcc, NULL); + "chat|send|close %(irc_channel_nicks) %f", + &irc_command_dcc, NULL); weechat_hook_command ("dehalfop", N_("removes half channel operator status from " "nickname(s)"), @@ -3630,7 +3633,7 @@ irc_command_init () N_("[-all | servername [servername ...]]"), N_(" -all: disconnect from all servers\n" "servername: server name to disconnect"), - "%S|-all", &irc_command_disconnect, NULL); + "%(irc_servers)|-all", &irc_command_disconnect, NULL); weechat_hook_command ("halfop", N_("gives half channel operator status to " "nickname(s)"), @@ -3647,7 +3650,7 @@ irc_command_init () N_("nickname channel"), N_("nickname: nick to invite\n" " channel: channel to invite"), - "%n %c", &irc_command_invite, NULL); + "%(irc_channel_nicks) %(irc_channel)", &irc_command_invite, NULL); weechat_hook_command ("ison", N_("check if a nickname is currently on IRC"), N_("nickname [nickname ...]"), @@ -3658,27 +3661,27 @@ irc_command_init () N_("channel[,channel] [key[,key]]"), N_("channel: channel name to join\n" " key: key to join the channel"), - "%C", &irc_command_join, NULL); + "%(irc_channels)", &irc_command_join, NULL); weechat_hook_command ("kick", N_("forcibly remove a user from a channel"), N_("[channel] nickname [comment]"), N_(" channel: channel where user is\n" "nickname: nickname to kick\n" " comment: comment for kick"), - "%n %-", &irc_command_kick, NULL); + "%(irc_channel_nicks) %-", &irc_command_kick, NULL); weechat_hook_command ("kickban", N_("kicks and bans a nick from a channel"), N_("[channel] nickname [comment]"), N_(" channel: channel where user is\n" "nickname: nickname to kick and ban\n" " comment: comment for kick"), - "%n %-", &irc_command_kickban, NULL); + "%(irc_channel_nicks) %-", &irc_command_kickban, NULL); weechat_hook_command ("kill", N_("close client-server connection"), N_("nickname comment"), N_("nickname: nickname\n" " comment: comment for kill"), - "%n %-", &irc_command_kill, NULL); + "%(irc_channel_nicks) %-", &irc_command_kill, NULL); weechat_hook_command ("links", N_("list all servernames which are known by the " "server answering the query"), @@ -3734,7 +3737,7 @@ irc_command_init () " s: mark a user for receive server notices\n" " w: user receives wallops\n" " o: operator flag"), - "%c|%m", &irc_command_mode, NULL); + "%(irc_channel)|%m", &irc_command_mode, NULL); weechat_hook_command ("motd", N_("get the \"Message Of The Day\""), N_("[target]"), @@ -3751,7 +3754,7 @@ irc_command_init () N_("list nicknames on channels"), N_("[channel[,channel]]"), N_("channel: channel name"), - "%C|%*", &irc_command_names, NULL); + "%(irc_channels)|%*", &irc_command_names, NULL); weechat_hook_command ("nick", N_("change current nickname"), N_("[-all] nickname"), @@ -3764,7 +3767,7 @@ irc_command_init () N_("nickname text"), N_("nickname: user to send notice to\n" " text: text to send"), - "%n %-", &irc_command_notice, NULL); + "%(irc_channel_nicks) %-", &irc_command_notice, NULL); weechat_hook_command ("op", N_("gives channel operator status to nickname(s)"), N_("nickname [nickname]"), @@ -3782,7 +3785,7 @@ irc_command_init () N_(" channel: channel name to leave\n" "part_message: part message (displayed to other " "users)"), - "%p", &irc_command_part, NULL); + "%(irc_msg_part)", &irc_command_part, NULL); weechat_hook_command ("ping", N_("ping server"), N_("server1 [server2]"), @@ -3801,7 +3804,7 @@ irc_command_init () N_("nickname [text]"), N_("nickname: nickname for private conversation\n" " text: text to send"), - "%n %-", &irc_command_query, NULL); + "%(irc_channel_nicks) %-", &irc_command_query, NULL); weechat_hook_command ("quote", N_("send raw data to server without parsing"), N_("data"), @@ -3815,7 +3818,7 @@ irc_command_init () "servername: server name to reconnect\n" " -nojoin: do not join any channel (even if " "autojoin is enabled on server)"), - "%S|-all|-nojoin|%*", &irc_command_reconnect, NULL); + "%(irc_servers)|-all|-nojoin|%*", &irc_command_reconnect, NULL); weechat_hook_command ("rehash", N_("tell the server to reload its config file"), "", @@ -3876,7 +3879,8 @@ irc_command_init () " deloutq: delete messages out queue for all " "servers (all messages " "WeeChat is currently sending)"), - "add|copy|rename|keep|del|deloutq|list|listfull %S %S", + "add|copy|rename|keep|del|deloutq|list|listfull " + "%(irc_servers) %(irc_servers)", &irc_command_server, NULL); weechat_hook_command ("servlist", N_("list services currently connected to the " @@ -3924,7 +3928,7 @@ irc_command_init () "topic: new topic for " "channel (if topic is \"-delete\" then topic " "is deleted)"), - "%t|-delete %-", &irc_command_topic, NULL); + "%(irc_topic)|-delete %-", &irc_command_topic, NULL); weechat_hook_command ("trace", N_("find the route to specific server"), N_("[target]"), @@ -3940,7 +3944,7 @@ irc_command_init () N_("return a list of information about nicknames"), N_("nickname [nickname ...]"), N_("nickname: nickname"), - "%n", &irc_command_userhost, NULL); + "%(irc_channel_nicks)", &irc_command_userhost, NULL); weechat_hook_command ("users", N_("list of users logged into the server"), N_("[target]"), @@ -3952,7 +3956,7 @@ irc_command_init () N_("[server | nickname]"), N_(" server: server name\n" "nickname: nickname"), - "%n", &irc_command_version, NULL); + "%(irc_channel_nicks)", &irc_command_version, NULL); weechat_hook_command ("voice", N_("gives voice to nickname(s)"), N_("[nickname [nickname]]"), @@ -3971,7 +3975,7 @@ irc_command_init () N_("mask: only information which match this mask\n" " o: only operators are returned according to " "the mask supplied"), - "%C", &irc_command_who, NULL); + "%(irc_channels)", &irc_command_who, NULL); weechat_hook_command ("whois", N_("query information about user(s)"), N_("[server] nickname[,nickname]"), diff --git a/src/plugins/irc/irc-command.h b/src/plugins/irc/irc-command.h index e4821e6ea..d4c4eb66a 100644 --- a/src/plugins/irc/irc-command.h +++ b/src/plugins/irc/irc-command.h @@ -22,27 +22,6 @@ #include "irc-server.h" -#define IRC_COMMAND_GET_SERVER(__buffer) \ - struct t_weechat_plugin *buffer_plugin = NULL; \ - struct t_irc_server *ptr_server = NULL; \ - buffer_plugin = weechat_buffer_get (__buffer, "plugin"); \ - if (buffer_plugin == weechat_irc_plugin) \ - ptr_server = irc_server_search ( \ - weechat_buffer_get (__buffer, "category")); - -#define IRC_COMMAND_GET_SERVER_CHANNEL(__buffer) \ - struct t_weechat_plugin *buffer_plugin = NULL; \ - struct t_irc_server *ptr_server = NULL; \ - struct t_irc_channel *ptr_channel = NULL; \ - buffer_plugin = weechat_buffer_get (__buffer, "plugin"); \ - if (buffer_plugin == weechat_irc_plugin) \ - { \ - ptr_server = irc_server_search ( \ - weechat_buffer_get (__buffer, "category")); \ - ptr_channel = irc_channel_search ( \ - ptr_server, weechat_buffer_get (__buffer, "name")); \ - } - #define IRC_COMMAND_TOO_FEW_ARGUMENTS(__buffer, __command) \ weechat_printf (__buffer, \ _("%sirc: too few arguments for \"%s\" command"), \ @@ -50,7 +29,9 @@ return WEECHAT_RC_ERROR; +extern void irc_command_away_server (struct t_irc_server *, char *); extern void irc_command_join_server (struct t_irc_server *, char *); +extern void irc_command_mode_server (struct t_irc_server *, char *); extern void irc_command_quit_server (struct t_irc_server *, char *); extern void irc_command_init (); diff --git a/src/plugins/irc/irc-completion.c b/src/plugins/irc/irc-completion.c new file mode 100644 index 000000000..3e0eeb99f --- /dev/null +++ b/src/plugins/irc/irc-completion.c @@ -0,0 +1,341 @@ +/* + * Copyright (c) 2003-2007 by FlashCode <flashcode@flashtux.org> + * See README for License detail, AUTHORS for developers list. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +/* irc-command.c: IRC commands managment */ + + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <stdlib.h> +#include <stdio.h> +#include <string.h> + +#include "irc.h" +#include "irc-completion.h" +#include "irc-config.h" +#include "irc-server.h" +#include "irc-channel.h" +#include "irc-nick.h" + + +/* + * irc_completion_server_cb: callback for completion with current IRC server + */ + +int +irc_completion_server_cb (void *data, char *completion, void *buffer, + void *list) +{ + IRC_GET_SERVER(buffer); + + /* make C compiler happy */ + (void) data; + (void) completion; + + if (ptr_server) + weechat_list_add (list, ptr_server->name, "sort"); + + return WEECHAT_RC_OK; +} + +/* + * irc_completion_server_nicks_cb: callback for completion with nicks + * of all IRC servers + */ + +int +irc_completion_server_nicks_cb (void *data, char *completion, void *buffer, + void *list) +{ + struct t_irc_server *ptr_server2; + struct t_irc_channel *ptr_channel2; + struct t_irc_nick *ptr_nick; + + IRC_GET_SERVER_CHANNEL(buffer); + + /* make C compiler happy */ + (void) data; + (void) completion; + (void) buffer; + + if (ptr_server && ptr_channel) + { + for (ptr_server2 = irc_servers; ptr_server2; + ptr_server2 = ptr_server2->next_server) + { + for (ptr_channel2 = ptr_server2->channels; ptr_channel2; + ptr_channel2 = ptr_channel2->next_channel) + { + if ((ptr_channel2 != ptr_channel) + && (ptr_channel2->type == IRC_CHANNEL_TYPE_CHANNEL)) + { + for (ptr_nick = ptr_channel2->nicks; ptr_nick; + ptr_nick = ptr_nick->next_nick) + { + weechat_list_add (list, ptr_nick->nick, "sort"); + } + } + } + } + + /* add current channel nicks at beginning */ + if (ptr_channel && (ptr_channel->type == IRC_CHANNEL_TYPE_CHANNEL)) + { + for (ptr_nick = ptr_channel->nicks; ptr_nick; + ptr_nick = ptr_nick->next_nick) + { + weechat_list_add (list, ptr_nick->nick, "beginning"); + } + } + + /* add self nick at the end */ + weechat_list_add (list, ptr_server->nick, "end"); + } + + return WEECHAT_RC_OK; +} + +/* + * irc_completion_servers_cb: callback for completion with IRC servers + */ + +int +irc_completion_servers_cb (void *data, char *completion, void *buffer, + void *list) +{ + struct t_irc_server *ptr_server; + + /* make C compiler happy */ + (void) data; + (void) completion; + (void) buffer; + + for (ptr_server = irc_servers; ptr_server; + ptr_server = ptr_server->next_server) + { + weechat_list_add (list, ptr_server->name, "sort"); + } + + return WEECHAT_RC_OK; +} + +/* + * irc_completion_channel_cb: callback for completion with current IRC channel + */ + +int +irc_completion_channel_cb (void *data, char *completion, void *buffer, + void *list) +{ + IRC_GET_SERVER_CHANNEL(buffer); + + /* make C compiler happy */ + (void) data; + (void) completion; + + if (ptr_channel) + weechat_list_add (list, ptr_channel->name, "sort"); + + return WEECHAT_RC_OK; +} + +/* + * irc_completion_channel_nicks_cb: callback for completion with nicks + * of current IRC channel + */ + +int +irc_completion_channel_nicks_cb (void *data, char *completion, void *buffer, + void *list) +{ + struct t_irc_nick *ptr_nick; + char *nick; + int list_size, i; + + IRC_GET_SERVER_CHANNEL(buffer); + + /* make C compiler happy */ + (void) data; + (void) completion; + + if (ptr_channel) + { + if (ptr_channel->type == IRC_CHANNEL_TYPE_CHANNEL) + { + for (ptr_nick = ptr_channel->nicks; ptr_nick; + ptr_nick = ptr_nick->next_nick) + { + weechat_list_add (list, ptr_nick->nick, "sort"); + } + + /* add nicks speaking recently on this channel */ + if (weechat_config_boolean (irc_config_irc_nick_completion_smart)) + { + list_size = weechat_list_size (ptr_channel->nicks_speaking); + for (i = 0; i < list_size; i++) + { + nick = weechat_list_string (weechat_list_get (ptr_channel->nicks_speaking, i)); + if (nick && irc_nick_search (ptr_channel, nick)) + { + weechat_list_add (list, nick, "beginning"); + } + } + } + + /* add self nick at the end */ + weechat_list_add (list, ptr_server->nick, "end"); + } + if ((ptr_channel->type == IRC_CHANNEL_TYPE_PRIVATE) + || (ptr_channel->type == IRC_CHANNEL_TYPE_DCC_CHAT)) + { + weechat_list_add (list, ptr_channel->name, "sort"); + } + } + + return WEECHAT_RC_OK; +} + +/* + * irc_completion_channel_nicks_hosts_cb: callback for completion with nicks + * and hosts of current IRC channel + */ + +int +irc_completion_channel_nicks_hosts_cb (void *data, char *completion, void *buffer, + void *list) +{ + struct t_irc_nick *ptr_nick; + char *buf; + int length; + + IRC_GET_SERVER_CHANNEL(buffer); + + /* make C compiler happy */ + (void) data; + (void) completion; + + if (ptr_channel) + { + if (ptr_channel->type == IRC_CHANNEL_TYPE_CHANNEL) + { + for (ptr_nick = ptr_channel->nicks; ptr_nick; + ptr_nick = ptr_nick->next_nick) + { + weechat_list_add (list, ptr_nick->nick, "sort"); + if (ptr_nick->host) + { + length = strlen (ptr_nick->nick) + 1 + + strlen (ptr_nick->host) + 1; + buf = (char *) malloc (length); + if (buf) + { + snprintf (buf, length, "%s!%s", + ptr_nick->nick, ptr_nick->host); + weechat_list_add (list, buf, "sort"); + free (buf); + } + } + } + } + if ((ptr_channel->type == IRC_CHANNEL_TYPE_PRIVATE) + || (ptr_channel->type == IRC_CHANNEL_TYPE_DCC_CHAT)) + { + weechat_list_add (list, ptr_channel->name, "sort"); + } + } + + return WEECHAT_RC_OK; +} + +/* + * irc_completion_channel_topic_cb: callback for completion with topic of + * current IRC channel + */ + +int +irc_completion_channel_topic_cb (void *data, char *completion, void *buffer, + void *list) +{ + IRC_GET_SERVER_CHANNEL(buffer); + + /* make C compiler happy */ + (void) data; + (void) completion; + + if (ptr_channel && ptr_channel->topic && ptr_channel->topic[0]) + { + weechat_list_add (list, ptr_channel->topic, "sort"); + } + + return WEECHAT_RC_OK; +} + +/* + * irc_completion_channels_cb: callback for completion with IRC channels + */ + +int +irc_completion_channels_cb (void *data, char *completion, void *buffer, + void *list) +{ + struct t_irc_server *ptr_server; + struct t_irc_channel *ptr_channel; + + /* make C compiler happy */ + (void) data; + (void) completion; + (void) buffer; + + for (ptr_server = irc_servers; ptr_server; + ptr_server = ptr_server->next_server) + { + for (ptr_channel = ptr_server->channels; ptr_channel; + ptr_channel = ptr_channel->next_channel) + { + weechat_list_add (list, ptr_channel->name, "sort"); + } + } + + return WEECHAT_RC_OK; +} + +/* + * irc_completion_msg_part_cb: callback for completion with default part message + */ + +int +irc_completion_msg_part_cb (void *data, char *completion, void *buffer, + void *list) +{ + /* make C compiler happy */ + (void) data; + (void) completion; + (void) buffer; + + if (weechat_config_string (irc_config_irc_default_msg_part) + && weechat_config_string (irc_config_irc_default_msg_part)[0]) + { + weechat_list_add (list, + weechat_config_string (irc_config_irc_default_msg_part), + "sort"); + } + + return WEECHAT_RC_OK; +} diff --git a/src/plugins/irc/irc-completion.h b/src/plugins/irc/irc-completion.h new file mode 100644 index 000000000..c0d2b250c --- /dev/null +++ b/src/plugins/irc/irc-completion.h @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2003-2007 by FlashCode <flashcode@flashtux.org> + * See README for License detail, AUTHORS for developers list. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + + +#ifndef __WEECHAT_IRC_COMPLETION_H +#define __WEECHAT_IRC_COMPLETION_H 1 + +extern int irc_completion_server_cb (void *, char *, void *, void *); +extern int irc_completion_server_nicks_cb (void *, char *, void *, void *); +extern int irc_completion_servers_cb (void *, char *, void *, void *); +extern int irc_completion_channel_cb (void *, char *, void *, void *); +extern int irc_completion_channel_nicks_cb (void *, char *, void *, void *); +extern int irc_completion_channel_nicks_hosts_cb (void *, char *, void *, + void *); +extern int irc_completion_channel_topic_cb (void *, char *, void *, void *); +extern int irc_completion_channels_cb (void *, char *, void *, void *); +extern int irc_completion_msg_part_cb (void *, char *, void *, void *); + +#endif /* irc-completion.h */ diff --git a/src/plugins/irc/irc-config.c b/src/plugins/irc/irc-config.c index 4589ee9a9..7d8f9192d 100644 --- a/src/plugins/irc/irc-config.c +++ b/src/plugins/irc/irc-config.c @@ -44,6 +44,7 @@ struct t_config_option *irc_config_irc_one_server_buffer; struct t_config_option *irc_config_irc_open_near_server; struct t_config_option *irc_config_irc_nick_prefix; struct t_config_option *irc_config_irc_nick_suffix; +struct t_config_option *irc_config_irc_nick_completion_smart; struct t_config_option *irc_config_irc_display_away; struct t_config_option *irc_config_irc_show_away_once; struct t_config_option *irc_config_irc_default_msg_part; @@ -130,20 +131,20 @@ irc_config_change_one_server_buffer () void irc_config_change_away_check () { - if (irc_timer_check_away) + if (irc_hook_timer_check_away) { - weechat_unhook (irc_timer_check_away); - irc_timer_check_away = NULL; + weechat_unhook (irc_hook_timer_check_away); + irc_hook_timer_check_away = NULL; } if (weechat_config_integer (irc_config_irc_away_check) == 0) { /* reset away flag for all nicks/chans/servers */ //irc_server_remove_away (); } - /*irc_timer_check_away = weechat_hook_timer (weechat_config_integer (irc_config_irc_away_check) * 60 * 1000, - 0, - irc_server_timer_check_away, - NULL); + /*irc_hook_timer_check_away = weechat_hook_timer (weechat_config_integer (irc_config_irc_away_check) * 60 * 1000, + 0, + irc_server_timer_check_away, + NULL); */ } @@ -434,6 +435,10 @@ irc_config_init () ptr_section, "irc_nick_suffix", "string", N_("text to display after nick in chat window"), NULL, 0, 0, "", NULL); + irc_config_irc_nick_completion_smart = weechat_config_new_option ( + ptr_section, "irc_nick_completion_smart", "boolean", + N_("smart completion for nicks (completes with last speakers first)"), + NULL, 0, 0, "on", NULL); irc_config_irc_display_away = weechat_config_new_option ( ptr_section, "irc_display_away", "integer", N_("display message when (un)marking as away"), diff --git a/src/plugins/irc/irc-config.h b/src/plugins/irc/irc-config.h index 40aeb686b..b1cf9756e 100644 --- a/src/plugins/irc/irc-config.h +++ b/src/plugins/irc/irc-config.h @@ -32,6 +32,7 @@ struct t_config_option *irc_config_irc_one_server_buffer; struct t_config_option *irc_config_irc_open_near_server; struct t_config_option *irc_config_irc_nick_prefix; struct t_config_option *irc_config_irc_nick_suffix; +struct t_config_option *irc_config_irc_nick_completion_smart; struct t_config_option *irc_config_irc_display_away; struct t_config_option *irc_config_irc_show_away_once; struct t_config_option *irc_config_irc_default_msg_part; diff --git a/src/plugins/irc/irc-nick.c b/src/plugins/irc/irc-nick.c index d8dab8144..f1c6a6290 100644 --- a/src/plugins/irc/irc-nick.c +++ b/src/plugins/irc/irc-nick.c @@ -24,11 +24,13 @@ #endif #include <stdlib.h> +#include <stdio.h> #include <string.h> #include <limits.h> #include "irc.h" #include "irc-nick.h" +#include "irc-config.h" #include "irc-server.h" #include "irc-channel.h" @@ -423,9 +425,25 @@ irc_nick_set_away (struct t_irc_channel *channel, struct t_irc_nick *nick, */ char * -irc_nick_as_prefix (struct t_irc_nick *nick) +irc_nick_as_prefix (struct t_irc_nick *nick, char *nickname, char *force_color) { - static char result[10] = ""; + static char result[256]; + + snprintf (result, sizeof (result), "%s%s%s%s%s%s\t", + (weechat_config_string (irc_config_irc_nick_prefix) + && weechat_config_string (irc_config_irc_nick_prefix)[0]) ? + IRC_COLOR_CHAT_DELIMITERS : "", + (weechat_config_string (irc_config_irc_nick_prefix) + && weechat_config_string (irc_config_irc_nick_prefix)[0]) ? + weechat_config_string (irc_config_irc_nick_prefix) : "", + (force_color) ? force_color : ((nick) ? nick->color : IRC_COLOR_CHAT_NICK), + (nick) ? nick->nick : nickname, + (weechat_config_string (irc_config_irc_nick_suffix) + && weechat_config_string (irc_config_irc_nick_suffix)[0]) ? + IRC_COLOR_CHAT_DELIMITERS : "", + (weechat_config_string (irc_config_irc_nick_suffix) + && weechat_config_string (irc_config_irc_nick_suffix)[0]) ? + weechat_config_string (irc_config_irc_nick_suffix) : ""); return result; } diff --git a/src/plugins/irc/irc-nick.h b/src/plugins/irc/irc-nick.h index e083d2d35..698e01437 100644 --- a/src/plugins/irc/irc-nick.h +++ b/src/plugins/irc/irc-nick.h @@ -45,7 +45,7 @@ struct t_irc_nick char *host; /* full hostname */ int flags; /* chanowner/chanadmin (unrealircd), */ /* op, halfop, voice, away */ - int color; /* color for nickname in chat window */ + char *color; /* color for nickname in chat window */ struct t_irc_nick *prev_nick; /* link to previous nick on channel */ struct t_irc_nick *next_nick; /* link to next nick on channel */ }; @@ -62,7 +62,7 @@ extern void irc_nick_free_all (struct t_irc_channel *); extern struct t_irc_nick *irc_nick_search (struct t_irc_channel *, char *); extern void irc_nick_count (struct t_irc_channel *, int *, int *, int *, int *, int *); extern void irc_nick_set_away (struct t_irc_channel *, struct t_irc_nick *, int); -extern char *irc_nick_as_prefix (struct t_irc_nick *); +extern char *irc_nick_as_prefix (struct t_irc_nick *, char *, char *); extern void irc_nick_print_log (struct t_irc_nick *); #endif /* irc-nick.h */ diff --git a/src/plugins/irc/irc-protocol.c b/src/plugins/irc/irc-protocol.c index e3099489b..f9169391f 100644 --- a/src/plugins/irc/irc-protocol.c +++ b/src/plugins/irc/irc-protocol.c @@ -35,10 +35,13 @@ #endif #include <stdlib.h> +#include <stdio.h> #include <string.h> #include <ctype.h> #include <wctype.h> #include <sys/utsname.h> +#include <sys/time.h> +#include <time.h> #include "irc.h" #include "irc-protocol.h" @@ -660,6 +663,7 @@ irc_protocol_cmd_invite (struct t_irc_server *server, char *irc_message, char *h weechat_prefix ("error"), "", "invite"); return WEECHAT_RC_ERROR; } + return WEECHAT_RC_OK; } @@ -743,6 +747,7 @@ irc_protocol_cmd_join (struct t_irc_server *server, char *irc_message, char *hos /* redraw nicklist and status bar */ //gui_nicklist_draw (ptr_channel->buffer, 1, 1); //gui_status_draw (ptr_channel->buffer, 1); + return WEECHAT_RC_OK; } @@ -846,6 +851,7 @@ irc_protocol_cmd_kick (struct t_irc_server *server, char *irc_message, char *hos if (server->autorejoin) irc_command_join_server (server, ptr_channel->name); } + else { /* someone was kicked from channel (but not me) => remove only this nick */ @@ -857,6 +863,7 @@ irc_protocol_cmd_kick (struct t_irc_server *server, char *irc_message, char *hos //gui_status_draw (ptr_channel->buffer, 1); } } + return WEECHAT_RC_OK; } @@ -945,6 +952,7 @@ irc_protocol_cmd_kill (struct t_irc_server *server, char *irc_message, weechat_prefix ("error"), "kill"); return WEECHAT_RC_ERROR; } + return WEECHAT_RC_OK; } @@ -1046,6 +1054,7 @@ irc_protocol_cmd_mode (struct t_irc_server *server, char *irc_message, char *hos } irc_mode_user_set (server, pos_modes); } + return WEECHAT_RC_OK; } @@ -1162,11 +1171,14 @@ irc_protocol_cmd_notice (struct t_irc_server *server, char *irc_message, char *h struct timeval tv; long sec1, usec1, sec2, usec2, difftime; struct t_irc_channel *ptr_channel; - int highlight_displayed; + int highlight_displayed, look_infobar_delay_highlight; /* make C compiler happy */ (void) irc_message; + look_infobar_delay_highlight = weechat_config_integer ( + weechat_config_get ("look_infobar_delay_highlight")); + host2 = NULL; if (host) { @@ -1264,7 +1276,7 @@ irc_protocol_cmd_notice (struct t_irc_server *server, char *irc_message, char *h { weechat_printf (server->buffer, _("%sirc: cannot create new " - "private window \"%s\""), + "private buffer \"%s\""), weechat_prefix ("error"), nick); return WEECHAT_RC_ERROR; } @@ -1275,88 +1287,86 @@ irc_protocol_cmd_notice (struct t_irc_server *server, char *irc_message, char *h //gui_chat_draw_title (ptr_channel->buffer, 1); } - gui_chat_printf_type (ptr_channel->buffer, GUI_MSG_TYPE_NICK, - NULL, -1, "%s<", - GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS)); if (highlight || irc_protocol_is_highlight (pos, server->nick)) { - gui_chat_printf_type (ptr_channel->buffer, - GUI_MSG_TYPE_NICK | - GUI_MSG_TYPE_HIGHLIGHT, - NULL, -1, "%s%s", - GUI_COLOR(GUI_COLOR_CHAT_HIGHLIGHT), - nick); - if ( (cfg_look_infobar_delay_highlight > 0) - && (ptr_channel->buffer != gui_current_window->buffer) ) - gui_infobar_printf (cfg_look_infobar_delay_highlight, - GUI_COLOR_INFOBAR_HIGHLIGHT, - _("Private %s> %s"), - nick, pos); + weechat_printf (ptr_channel->buffer, + "%s%s", + irc_nick_as_prefix (NULL, nick, + IRC_COLOR_CHAT_HIGHLIGHT), + pos); + if ((look_infobar_delay_highlight > 0) + && (ptr_channel->buffer != weechat_current_buffer)) + weechat_infobar_printf (look_infobar_delay_highlight, + IRC_COLOR_INFOBAR_HIGHLIGHT, + _("Private %s> %s"), + nick, pos); highlight_displayed = 1; } else { - gui_chat_printf_type (ptr_channel->buffer, GUI_MSG_TYPE_NICK, - NULL, -1, "%s%s", - GUI_COLOR(GUI_COLOR_CHAT_NICK_OTHER), - nick); + weechat_printf (ptr_channel->buffer, + "%s%s", + irc_nick_as_prefix (NULL, nick, + IRC_COLOR_CHAT_NICK_OTHER), + pos); highlight_displayed = 0; } - gui_chat_printf_type (ptr_channel->buffer, GUI_MSG_TYPE_NICK, - NULL, -1, "%s> ", - GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS)); - gui_chat_printf_type (ptr_channel->buffer, GUI_MSG_TYPE_MSG, - NULL, -1, "%s%s\n", - GUI_COLOR(GUI_COLOR_CHAT), - pos); - if (highlight_displayed) - (void) plugin_msg_handler_exec (server->name, - "weechat_highlight", - irc_message); + //if (highlight_displayed) + // (void) plugin_msg_handler_exec (server->name, + // "weechat_highlight", + // irc_message); } else { if (host) { - gui_chat_printf_server (server->buffer, "%s%s", - GUI_COLOR(GUI_COLOR_CHAT_NICK), - nick); if (host2) - gui_chat_printf (server->buffer, " %s(%s%s%s)", - GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS), - GUI_COLOR(GUI_COLOR_CHAT_HOST), - host2, - GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS)); - gui_chat_printf (server->buffer, "%s: ", - GUI_COLOR(GUI_COLOR_CHAT)); - gui_chat_printf (server->buffer, "%s%s\n", - GUI_COLOR(GUI_COLOR_CHAT), - pos); + { + weechat_printf (server->buffer, + "%s%s %s(%s%s%s)%s: %s", + IRC_COLOR_CHAT_NICK, + nick, + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT_HOST, + host2, + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT, + pos); + } + else + { + weechat_printf (server->buffer, "%s%s%s: %s", + IRC_COLOR_CHAT_NICK, + nick, + IRC_COLOR_CHAT, + pos); + } } else - gui_chat_printf_server (server->buffer, "%s%s\n", - GUI_COLOR(GUI_COLOR_CHAT), - pos); + weechat_printf (server->buffer, "%s%s", + IRC_COLOR_CHAT, + pos); if ((nick) && (weechat_strcasecmp (nick, "nickserv") != 0) && (weechat_strcasecmp (nick, "chanserv") != 0) && (weechat_strcasecmp (nick, "memoserv") != 0)) { - if (gui_add_hotlist - && ((server->buffer->num_displayed == 0) - || (gui_buffer_is_scrolled (server->buffer)))) - { - gui_hotlist_add (GUI_HOTLIST_PRIVATE, NULL, - server->buffer, 0); - gui_status_draw (gui_current_window->buffer, 1); - } + //if (gui_add_hotlist + // && ((server->buffer->num_displayed == 0) + // || (gui_buffer_is_scrolled (server->buffer)))) + //{ + // gui_hotlist_add (GUI_HOTLIST_PRIVATE, NULL, + // server->buffer, 0); + // gui_status_draw (gui_current_window->buffer, 1); + //} } } } } } + return WEECHAT_RC_OK; } @@ -1380,10 +1390,10 @@ irc_protocol_cmd_part (struct t_irc_server *server, char *irc_message, char *hos /* no host => we can't identify sender of message! */ if (!host || !arguments) { - gui_chat_printf_error_nolog (server->buffer, - _("%s \"%s\" command received without " - "host or channel\n"), - weechat_prefix ("error"), "part"); + weechat_printf (server->buffer, + _("%sirc: \"%s\" command received without host or " + "channel"), + weechat_prefix ("error"), "part"); return WEECHAT_RC_ERROR; } @@ -1411,25 +1421,38 @@ irc_protocol_cmd_part (struct t_irc_server *server, char *irc_message, char *hos if (!ignore) { pos = strchr (host, '!'); - gui_chat_printf_quit (ptr_channel->buffer, - _("%s%s %s(%s%s%s)%s has left %s%s"), - GUI_COLOR(GUI_COLOR_CHAT_NICK), - nick, - GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS), - GUI_COLOR(GUI_COLOR_CHAT_HOST), - (pos) ? pos + 1 : "", - GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS), - GUI_COLOR(GUI_COLOR_CHAT), - GUI_COLOR(GUI_COLOR_CHAT_CHANNEL), - ptr_channel->name); if (pos_args && pos_args[0]) - gui_chat_printf (ptr_channel->buffer, " %s(%s%s%s)\n", - GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS), - GUI_COLOR(GUI_COLOR_CHAT), - pos_args, - GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS)); + { + weechat_printf (ptr_channel->buffer, + _("%s%s %s(%s%s%s)%s has left %s%s %s(%s%s%s)"), + IRC_COLOR_CHAT_NICK, + nick, + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT_HOST, + (pos) ? pos + 1 : "", + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT, + IRC_COLOR_CHAT_CHANNEL, + ptr_channel->name, + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT, + pos_args, + IRC_COLOR_CHAT_DELIMITERS); + } else - gui_chat_printf (ptr_channel->buffer, "\n"); + { + weechat_printf (ptr_channel->buffer, + _("%s%s %s(%s%s%s)%s has left %s%s"), + IRC_COLOR_CHAT_NICK, + nick, + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT_HOST, + (pos) ? pos + 1 : "", + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT, + IRC_COLOR_CHAT_CHANNEL, + ptr_channel->name); + } } /* part request was issued by local client ? */ @@ -1451,18 +1474,19 @@ irc_protocol_cmd_part (struct t_irc_server *server, char *irc_message, char *hos snprintf (join_string, join_length, "%s %s", ptr_channel->name, ptr_channel->key); - irc_cmd_join_server (server, join_string); + irc_command_join_server (server, join_string); free (join_string); } else - irc_cmd_join_server (server, ptr_channel->name); + irc_command_join_server (server, ptr_channel->name); } else - irc_cmd_join_server (server, ptr_channel->name); + irc_command_join_server (server, ptr_channel->name); } if (ptr_channel->close) { - gui_buffer_free (ptr_channel->buffer, 1); + weechat_buffer_close (ptr_channel->buffer); + ptr_channel->buffer = NULL; irc_channel_free (server, ptr_channel); ptr_channel = NULL; } @@ -1472,18 +1496,18 @@ irc_protocol_cmd_part (struct t_irc_server *server, char *irc_message, char *hos if (ptr_channel) { - gui_nicklist_draw (ptr_channel->buffer, 1, 1); - gui_status_draw (ptr_channel->buffer, 1); + //gui_nicklist_draw (ptr_channel->buffer, 1, 1); + //gui_status_draw (ptr_channel->buffer, 1); } - gui_input_draw (gui_current_window->buffer, 1); + //gui_input_draw (gui_current_window->buffer, 1); } } else { - gui_chat_printf_error_nolog (server->buffer, - _("%s channel \"%s\" not found for " - "\"%s\" command\n"), - weechat_prefix ("error"), arguments, "part"); + weechat_printf (server->buffer, + _("%sirc: channel \"%s\" not found for \"%s\" " + "command"), + weechat_prefix ("error"), arguments, "part"); return WEECHAT_RC_ERROR; } @@ -1543,25 +1567,27 @@ irc_protocol_cmd_pong (struct t_irc_server *server, char *irc_message, char *hos /* calculate lag (time diff with lag check) */ old_lag = server->lag; gettimeofday (&tv, NULL); - server->lag = (int) weechat_get_timeval_diff (&(server->lag_check_time), &tv); - if (old_lag != server->lag) - gui_status_draw (gui_current_window->buffer, 1); + server->lag = (int) weechat_timeval_diff (&(server->lag_check_time), &tv); + //if (old_lag != server->lag) + // gui_status_draw (gui_current_window->buffer, 1); /* schedule next lag check */ server->lag_check_time.tv_sec = 0; server->lag_check_time.tv_usec = 0; - server->lag_next_check = time (NULL) + irc_cfg_irc_lag_check; + server->lag_next_check = time (NULL) + + weechat_config_integer (irc_config_irc_lag_check); } + return WEECHAT_RC_OK; } /* - * irc_cmd_reply_version: send version in reply to "CTCP VERSION" request + * irc_protocol_reply_version: send version in reply to "CTCP VERSION" request */ void -irc_cmd_reply_version (struct t_irc_server *server, struct t_irc_channel *channel, - char *nick, char *message, int ignore) +irc_protocol_reply_version (struct t_irc_server *server, struct t_irc_channel *channel, + char *nick, char *message, int ignore) { char *pos; struct utsname *buf; @@ -1600,21 +1626,29 @@ irc_cmd_reply_version (struct t_irc_server *server, struct t_irc_channel *channe " compiled on %s%s", nick, "\01", PACKAGE_NAME, PACKAGE_VERSION, __DATE__, "\01"); - gui_chat_printf_server (ptr_buffer, - _("CTCP %sVERSION%s received from %s%s"), - GUI_COLOR(GUI_COLOR_CHAT_CHANNEL), - GUI_COLOR(GUI_COLOR_CHAT), - GUI_COLOR(GUI_COLOR_CHAT_NICK), - nick); if (pos) - gui_chat_printf (ptr_buffer, "%s: %s\n", - GUI_COLOR(GUI_COLOR_CHAT), - pos); + { + weechat_printf (ptr_buffer, + _("CTCP %sVERSION%s received from %s%s%s: %s"), + IRC_COLOR_CHAT_CHANNEL, + IRC_COLOR_CHAT, + IRC_COLOR_CHAT_NICK, + nick, + IRC_COLOR_CHAT, + pos); + } else - gui_chat_printf (ptr_buffer, "\n"); - (void) plugin_msg_handler_exec (server->name, - "weechat_ctcp", - irc_message); + { + weechat_printf (ptr_buffer, + _("CTCP %sVERSION%s received from %s%s"), + IRC_COLOR_CHAT_CHANNEL, + IRC_COLOR_CHAT, + IRC_COLOR_CHAT_NICK, + nick); + } + //(void) plugin_msg_handler_exec (server->name, + // "weechat_ctcp", + // irc_message); } } @@ -1630,7 +1664,7 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, char *irc_message, char * char *pos_file, *pos_addr, *pos_port, *pos_size, *pos_start_resume; /* for DCC */ struct t_irc_channel *ptr_channel; struct t_irc_nick *ptr_nick; - int highlight_displayed; + int highlight_displayed, look_infobar_delay_highlight; /* make C compiler happy */ (void) irc_message; @@ -1638,13 +1672,15 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, char *irc_message, char * /* no host => we can't identify sender of message! */ if (!host) { - gui_chat_printf_error_nolog (server->buffer, - _("%s \"%s\" command received without " - "host\n"), - weechat_prefix ("error"), "privmsg"); + weechat_printf (server->buffer, + _("%sirc: \"%s\" command received without host"), + weechat_prefix ("error"), "privmsg"); return WEECHAT_RC_ERROR; } + look_infobar_delay_highlight = weechat_config_integer ( + weechat_config_get ("look_infobar_delay_highlight")); + pos = strchr (host, '!'); if (pos) host2 = pos + 1; @@ -1678,39 +1714,34 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, char *irc_message, char * if (highlight || irc_protocol_is_highlight (pos, server->nick)) { - gui_chat_printf_type (ptr_channel->buffer, - GUI_MSG_TYPE_MSG | - GUI_MSG_TYPE_HIGHLIGHT, - cfg_look_prefix_action, - cfg_col_chat_prefix_action, - "%s%s", - GUI_COLOR(GUI_COLOR_CHAT_HIGHLIGHT), - nick); - if ( (cfg_look_infobar) - && (cfg_look_infobar_delay_highlight > 0) - && (ptr_channel->buffer != gui_current_window->buffer) ) - gui_infobar_printf (cfg_look_infobar_delay_highlight, - GUI_COLOR_INFOBAR_HIGHLIGHT, - _("Channel %s: * %s %s"), - ptr_channel->name, nick, pos); - gui_chat_printf (ptr_channel->buffer, " %s%s\n", - GUI_COLOR(GUI_COLOR_CHAT), pos); - (void) plugin_msg_handler_exec (server->name, - "weechat_highlight", - irc_message); + weechat_printf (ptr_channel->buffer, + "%s%s%s %s%s", + weechat_prefix ("action"), + IRC_COLOR_CHAT_HIGHLIGHT, + nick, + IRC_COLOR_CHAT, + pos); + if ((look_infobar_delay_highlight > 0) + && (ptr_channel->buffer != weechat_current_buffer)) + weechat_infobar_printf (look_infobar_delay_highlight, + "color_infobar_highlight", + _("Channel %s: * %s %s"), + ptr_channel->name, + nick, + pos); + //(void) plugin_msg_handler_exec (server->name, + // "weechat_highlight", + // irc_message); } else { - gui_chat_printf_type (ptr_channel->buffer, - GUI_MSG_TYPE_MSG, - NULL, -1, - "%s%s", - GUI_COLOR(GUI_COLOR_CHAT_NICK), - cfg_look_prefix_action, - cfg_col_chat_prefix_action, - nick); - gui_chat_printf (ptr_channel->buffer, " %s%s\n", - GUI_COLOR(GUI_COLOR_CHAT), pos); + weechat_printf (ptr_channel->buffer, + "%s%s%s %s%s", + weechat_prefix ("action"), + IRC_COLOR_CHAT_NICK, + nick, + IRC_COLOR_CHAT, + pos); } irc_channel_add_nick_speaking (ptr_channel, nick); } @@ -1724,14 +1755,14 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, char *irc_message, char * pos2[0] = '\0'; if (!ignore) { - gui_chat_printf_server (ptr_channel->buffer, - _("Received a CTCP %sSOUND%s " - "\"%s\" from %s%s\n"), - GUI_COLOR(GUI_COLOR_CHAT_CHANNEL), - GUI_COLOR(GUI_COLOR_CHAT), - pos, - GUI_COLOR(GUI_COLOR_CHAT_NICK), - nick); + weechat_printf (ptr_channel->buffer, + _("Received a CTCP %sSOUND%s \"%s\" " + "from %s%s"), + IRC_COLOR_CHAT_CHANNEL, + IRC_COLOR_CHAT, + pos, + IRC_COLOR_CHAT_NICK, + nick); } return WEECHAT_RC_OK; } @@ -1753,19 +1784,18 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, char *irc_message, char * else irc_server_sendf (server, "NOTICE %s :\01PING\01", nick); - gui_chat_printf_server (ptr_channel->buffer, - _("CTCP %sPING%s received from " - "%s%s\n"), - GUI_COLOR(GUI_COLOR_CHAT_CHANNEL), - GUI_COLOR(GUI_COLOR_CHAT), - GUI_COLOR(GUI_COLOR_CHAT_NICK), - nick); + weechat_printf (ptr_channel->buffer, + _("CTCP %sPING%s received from %s%s"), + IRC_COLOR_CHAT_CHANNEL, + IRC_COLOR_CHAT, + IRC_COLOR_CHAT_NICK, + nick); return WEECHAT_RC_OK; } if (strncmp (pos, "\01VERSION", 8) == 0) { - irc_cmd_reply_version (server, ptr_channel, nick, - pos, ignore); + irc_protocol_reply_version (server, ptr_channel, nick, + pos, ignore); return WEECHAT_RC_OK; } @@ -1787,20 +1817,30 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, char *irc_message, char * } if (!ignore) { - gui_chat_printf_server (ptr_channel->buffer, - _("Unknown CTCP %s%s%s " - "received from %s%s"), - GUI_COLOR(GUI_COLOR_CHAT_CHANNEL), - pos, - GUI_COLOR(GUI_COLOR_CHAT), - GUI_COLOR(GUI_COLOR_CHAT_NICK), - nick); if (pos2) - gui_chat_printf (ptr_channel->buffer, "%s: %s\n", - GUI_COLOR(GUI_COLOR_CHAT), - pos2); + { + weechat_printf (ptr_channel->buffer, + _("Unknown CTCP %s%s%s received " + "from %s%s%s: %s"), + IRC_COLOR_CHAT_CHANNEL, + pos, + IRC_COLOR_CHAT, + IRC_COLOR_CHAT_NICK, + nick, + IRC_COLOR_CHAT, + pos2); + } else - gui_chat_printf (ptr_channel->buffer, "\n"); + { + weechat_printf (ptr_channel->buffer, + _("Unknown CTCP %s%s%s " + "received from %s%s"), + IRC_COLOR_CHAT_CHANNEL, + pos, + IRC_COLOR_CHAT, + IRC_COLOR_CHAT_NICK, + nick); + } } return WEECHAT_RC_OK; } @@ -1811,45 +1851,43 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, char *irc_message, char * ptr_nick = irc_nick_search (ptr_channel, nick); if (highlight || irc_protocol_is_highlight (pos, server->nick)) { - irc_display_nick (ptr_channel->buffer, ptr_nick, - (ptr_nick) ? NULL : nick, - GUI_MSG_TYPE_NICK | GUI_MSG_TYPE_HIGHLIGHT, - 1, GUI_COLOR(GUI_COLOR_CHAT_HIGHLIGHT), 0); - if ( (cfg_look_infobar) - && (cfg_look_infobar_delay_highlight > 0) - && (ptr_channel->buffer != gui_current_window->buffer) ) - gui_infobar_printf (cfg_look_infobar_delay_highlight, - GUI_COLOR_INFOBAR_HIGHLIGHT, - _("Channel %s: %s> %s"), - ptr_channel->name, nick, pos); - gui_chat_printf_type (ptr_channel->buffer, - GUI_MSG_TYPE_MSG, - NULL, -1, - "%s\n", pos); - (void) plugin_msg_handler_exec (server->name, - "weechat_highlight", - irc_message); + weechat_printf (ptr_channel->buffer, + "%s%s", + irc_nick_as_prefix (ptr_nick, + (ptr_nick) ? NULL : nick, + IRC_COLOR_CHAT_HIGHLIGHT), + pos); + if ((look_infobar_delay_highlight > 0) + && (ptr_channel->buffer != weechat_current_buffer)) + weechat_infobar_printf (look_infobar_delay_highlight, + "color_infobar_highlight", + _("Channel %s: %s> %s"), + ptr_channel->name, + nick, + pos); + //(void) plugin_msg_handler_exec (server->name, + // "weechat_highlight", + // irc_message); } else { - irc_display_nick (ptr_channel->buffer, ptr_nick, - (ptr_nick) ? NULL : nick, - GUI_MSG_TYPE_NICK, 1, NULL, 0); - gui_chat_printf_type (ptr_channel->buffer, - GUI_MSG_TYPE_MSG, - NULL, -1, - "%s\n", pos); + weechat_printf (ptr_channel->buffer, + "%s%s", + irc_nick_as_prefix (ptr_nick, + (ptr_nick) ? NULL : nick, + NULL), + pos); } irc_channel_add_nick_speaking (ptr_channel, nick); } } else { - gui_chat_printf_error_nolog (server->buffer, - _("%s channel \"%s\" not found " - "for \"%s\" command\n"), - weechat_prefix ("error"), arguments, - "privmsg"); + weechat_printf (server->buffer, + _("%sirc: channel \"%s\" not found for \"%s\" " + "command"), + weechat_prefix ("error"), + arguments, "privmsg"); return WEECHAT_RC_ERROR; } } @@ -1869,7 +1907,7 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, char *irc_message, char * /* version asked by another user => answer with WeeChat version */ if (strncmp (pos, "\01VERSION", 8) == 0) { - irc_cmd_reply_version (server, NULL, nick, pos, ignore); + irc_protocol_reply_version (server, NULL, nick, pos, ignore); return WEECHAT_RC_OK; } @@ -1894,16 +1932,15 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, char *irc_message, char * else irc_server_sendf (server, "NOTICE %s :\01PING\01", nick); - gui_chat_printf_server (server->buffer, - _("CTCP %sPING%s received from " - "%s%s\n"), - GUI_COLOR(GUI_COLOR_CHAT_CHANNEL), - GUI_COLOR(GUI_COLOR_CHAT), - GUI_COLOR(GUI_COLOR_CHAT_NICK), - nick); - (void) plugin_msg_handler_exec (server->name, - "weechat_ctcp", - irc_message); + weechat_printf (server->buffer, + _("CTCP %sPING%s received from %s%s"), + IRC_COLOR_CHAT_CHANNEL, + IRC_COLOR_CHAT, + IRC_COLOR_CHAT_NICK, + nick); + //(void) plugin_msg_handler_exec (server->name, + // "weechat_ctcp", + // irc_message); } return WEECHAT_RC_OK; } @@ -1915,10 +1952,9 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, char *irc_message, char * pos2 = strchr (pos + 1, '\01'); if (!pos2) { - gui_chat_printf_error_nolog (server->buffer, - _("%s cannot parse \"%s\" " - "command\n"), - weechat_prefix ("error"), "privmsg"); + weechat_printf (server->buffer, + _("%sirc: cannot parse \"%s\" command"), + weechat_prefix ("error"), "privmsg"); return WEECHAT_RC_ERROR; } pos2[0] = '\0'; @@ -1934,10 +1970,9 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, char *irc_message, char * pos_size = strrchr (pos_file, ' '); if (!pos_size) { - gui_chat_printf_error_nolog (server->buffer, - _("%s cannot parse " - "\"%s\" command\n"), - weechat_prefix ("error"), "privmsg"); + weechat_printf (server->buffer, + _("%sirc: cannot parse \"%s\" command"), + weechat_prefix ("error"), "privmsg"); return WEECHAT_RC_ERROR; } pos2 = pos_size; @@ -1950,10 +1985,9 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, char *irc_message, char * pos_port = strrchr (pos_file, ' '); if (!pos_port) { - gui_chat_printf_error_nolog (server->buffer, - _("%s cannot parse " - "\"%s\" command\n"), - weechat_prefix ("error"), "privmsg"); + weechat_printf (server->buffer, + _("%sirc: cannot parse \"%s\" command"), + weechat_prefix ("error"), "privmsg"); return WEECHAT_RC_ERROR; } pos2 = pos_port; @@ -1966,10 +2000,9 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, char *irc_message, char * pos_addr = strrchr (pos_file, ' '); if (!pos_addr) { - gui_chat_printf_error_nolog (server->buffer, - _("%s cannot parse " - "\"%s\" command\n"), - weechat_prefix ("error"), "privmsg"); + weechat_printf (server->buffer, + _("%sirc: cannot parse \"%s\" command"), + weechat_prefix ("error"), "privmsg"); return WEECHAT_RC_ERROR; } pos2 = pos_addr; @@ -1978,13 +2011,13 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, char *irc_message, char * pos2--; pos2[1] = '\0'; - irc_dcc_add (server, IRC_DCC_FILE_RECV, - strtoul (pos_addr, NULL, 10), - atoi (pos_port), nick, -1, pos_file, NULL, - strtoul (pos_size, NULL, 10)); - (void) plugin_msg_handler_exec (server->name, - "weechat_dcc", - irc_message); + //irc_dcc_add (server, IRC_DCC_FILE_RECV, + // strtoul (pos_addr, NULL, 10), + // atoi (pos_port), nick, -1, pos_file, NULL, + // strtoul (pos_size, NULL, 10)); + //(void) plugin_msg_handler_exec (server->name, + // "weechat_dcc", + // irc_message); } return WEECHAT_RC_OK; } @@ -1996,10 +2029,9 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, char *irc_message, char * pos2 = strchr (pos + 1, '\01'); if (!pos2) { - gui_chat_printf_error_nolog (server->buffer, - _("%s cannot parse \"%s\" " - "command\n"), - weechat_prefix ("error"), "privmsg"); + weechat_printf (server->buffer, + _("%sirc: cannot parse \"%s\" command"), + weechat_prefix ("error"), "privmsg"); return WEECHAT_RC_ERROR; } pos2[0] = '\0'; @@ -2015,10 +2047,9 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, char *irc_message, char * pos_start_resume = strrchr (pos_file, ' '); if (!pos_start_resume) { - gui_chat_printf_error_nolog (server->buffer, - _("%s cannot parse " - "\"%s\" command\n"), - weechat_prefix ("error"), "privmsg"); + weechat_printf (server->buffer, + _("%sirc: cannot parse \"%s\" command"), + weechat_prefix ("error"), "privmsg"); return WEECHAT_RC_ERROR; } pos2 = pos_start_resume; @@ -2031,10 +2062,9 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, char *irc_message, char * pos_port = strrchr (pos_file, ' '); if (!pos_port) { - gui_chat_printf_error_nolog (server->buffer, - _("%s cannot parse " - "\"%s\" command\n"), - weechat_prefix ("error"), "privmsg"); + weechat_printf (server->buffer, + _("%sirc: cannot parse \"%s\" command"), + weechat_prefix ("error"), "privmsg"); return WEECHAT_RC_ERROR; } pos2 = pos_port; @@ -2043,11 +2073,11 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, char *irc_message, char * pos2--; pos2[1] = '\0'; - irc_dcc_accept_resume (server, pos_file, atoi (pos_port), - strtoul (pos_start_resume, NULL, 10)); - (void) plugin_msg_handler_exec (server->name, - "weechat_dcc", - irc_message); + //irc_dcc_accept_resume (server, pos_file, atoi (pos_port), + // strtoul (pos_start_resume, NULL, 10)); + //(void) plugin_msg_handler_exec (server->name, + // "weechat_dcc", + // irc_message); } return WEECHAT_RC_OK; } @@ -2059,10 +2089,9 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, char *irc_message, char * pos2 = strchr (pos + 1, '\01'); if (!pos2) { - gui_chat_printf_error_nolog (server->buffer, - _("%s cannot parse " - "\"%s\" command\n"), - weechat_prefix ("error"), "privmsg"); + weechat_printf (server->buffer, + _("%sirc: cannot parse \"%s\" command"), + weechat_prefix ("error"), "privmsg"); return WEECHAT_RC_ERROR; } pos2[0] = '\0'; @@ -2078,10 +2107,9 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, char *irc_message, char * pos_start_resume = strrchr (pos_file, ' '); if (!pos_start_resume) { - gui_chat_printf_error_nolog (server->buffer, - _("%s cannot parse " - "\"%s\" command\n"), - weechat_prefix ("error"), "privmsg"); + weechat_printf (server->buffer, + _("%sirc: cannot parse \"%s\" command"), + weechat_prefix ("error"), "privmsg"); return WEECHAT_RC_ERROR; } pos2 = pos_start_resume; @@ -2094,10 +2122,9 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, char *irc_message, char * pos_port = strrchr (pos_file, ' '); if (!pos_port) { - gui_chat_printf_error_nolog (server->buffer, - _("%s cannot parse " - "\"%s\" command\n"), - weechat_prefix ("error"), "privmsg"); + weechat_printf (server->buffer, + _("%sirc: cannot parse \"%s\" command"), + weechat_prefix ("error"), "privmsg"); return WEECHAT_RC_ERROR; } pos2 = pos_port; @@ -2106,11 +2133,11 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, char *irc_message, char * pos2--; pos2[1] = '\0'; - irc_dcc_start_resume (server, pos_file, atoi (pos_port), - strtoul (pos_start_resume, NULL, 10)); - (void) plugin_msg_handler_exec (server->name, - "weechat_dcc", - irc_message); + //irc_dcc_start_resume (server, pos_file, atoi (pos_port), + // strtoul (pos_start_resume, NULL, 10)); + //(void) plugin_msg_handler_exec (server->name, + // "weechat_dcc", + // irc_message); } return WEECHAT_RC_OK; } @@ -2122,10 +2149,9 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, char *irc_message, char * pos2 = strchr (pos + 1, '\01'); if (!pos2) { - gui_chat_printf_error_nolog (server->buffer, - _("%s cannot parse " - "\"%s\" command\n"), - weechat_prefix ("error"), "privmsg"); + weechat_printf (server->buffer, + _("%sirc: cannot parse \"%s\" command"), + weechat_prefix ("error"), "privmsg"); return WEECHAT_RC_ERROR; } pos2[0] = '\0'; @@ -2141,10 +2167,9 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, char *irc_message, char * pos_addr = strchr (pos_file, ' '); if (!pos_addr) { - gui_chat_printf_error_nolog (server->buffer, - _("%s cannot parse " - "\"%s\" command\n"), - weechat_prefix ("error"), "privmsg"); + weechat_printf (server->buffer, + _("%sirc: cannot parse \"%s\" command"), + weechat_prefix ("error"), "privmsg"); return WEECHAT_RC_ERROR; } pos_addr[0] = '\0'; @@ -2156,10 +2181,9 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, char *irc_message, char * pos_port = strchr (pos_addr, ' '); if (!pos_port) { - gui_chat_printf_error_nolog (server->buffer, - _("%s cannot parse " - "\"%s\" command\n"), - weechat_prefix ("error"), "privmsg"); + weechat_printf (server->buffer, + _("%sirc: cannot parse \"%s\" command"), + weechat_prefix ("error"), "privmsg"); return WEECHAT_RC_ERROR; } pos_port[0] = '\0'; @@ -2169,24 +2193,23 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, char *irc_message, char * if (weechat_strcasecmp (pos_file, "chat") != 0) { - gui_chat_printf_error_nolog (server->buffer, - _("%s unknown DCC CHAT " - "type received from "), - weechat_prefix ("error")); - gui_chat_printf (server->buffer, "%s%s%s: \"%s\"\n", - GUI_COLOR(GUI_COLOR_CHAT_NICK), - nick, - GUI_COLOR(GUI_COLOR_CHAT), - pos_file); + weechat_printf (server->buffer, + _("%sirc: unknown DCC CHAT type " + "received from %s%s%s: \"%s\""), + weechat_prefix ("error"), + IRC_COLOR_CHAT_NICK, + nick, + IRC_COLOR_CHAT, + pos_file); return WEECHAT_RC_ERROR; } - irc_dcc_add (server, IRC_DCC_CHAT_RECV, - strtoul (pos_addr, NULL, 10), - atoi (pos_port), nick, -1, NULL, NULL, 0); - (void) plugin_msg_handler_exec (server->name, - "weechat_dcc", - irc_message); + //irc_dcc_add (server, IRC_DCC_CHAT_RECV, + // strtoul (pos_addr, NULL, 10), + // atoi (pos_port), nick, -1, NULL, NULL, 0); + //(void) plugin_msg_handler_exec (server->name, + // "weechat_dcc", + // irc_message); } return WEECHAT_RC_OK; } @@ -2205,18 +2228,17 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, char *irc_message, char * nick, 0); if (!ptr_channel) { - gui_chat_printf_error_nolog (server->buffer, - _("%s cannot create " - "new private " - "window \"%s\"\n"), - weechat_prefix ("error"), nick); + weechat_printf (server->buffer, + _("%sirc: cannot create new " + "private buffer \"%s\""), + weechat_prefix ("error"), nick); return WEECHAT_RC_ERROR; } } if (!ptr_channel->topic) { ptr_channel->topic = strdup (host2); - gui_chat_draw_title (ptr_channel->buffer, 1); + //gui_chat_draw_title (ptr_channel->buffer, 1); } pos += 8; @@ -2225,42 +2247,36 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, char *irc_message, char * pos2[0] = '\0'; if (highlight || irc_protocol_is_highlight (pos, server->nick)) { - gui_chat_printf_type (ptr_channel->buffer, - GUI_MSG_TYPE_MSG | - GUI_MSG_TYPE_HIGHLIGHT, - cfg_look_prefix_action, - cfg_col_chat_prefix_action, - "%s%s", - GUI_COLOR(GUI_COLOR_CHAT_HIGHLIGHT), - nick); - if ( (cfg_look_infobar) - && (cfg_look_infobar_delay_highlight > 0) - && (ptr_channel->buffer != gui_current_window->buffer) ) - gui_infobar_printf (cfg_look_infobar_delay_highlight, - GUI_COLOR_INFOBAR_HIGHLIGHT, - _("Channel %s: * %s %s"), - ptr_channel->name, nick, pos); - gui_chat_printf (ptr_channel->buffer, " %s%s\n", - GUI_COLOR(GUI_COLOR_CHAT), pos); - (void) plugin_msg_handler_exec (server->name, - "weechat_highlight", - irc_message); + weechat_printf (ptr_channel->buffer, + "%s%s%s %s%s", + weechat_prefix ("action"), + IRC_COLOR_CHAT_HIGHLIGHT, + nick, + IRC_COLOR_CHAT, + pos); + if ((look_infobar_delay_highlight > 0) + && (ptr_channel->buffer != weechat_current_buffer)) + weechat_infobar_printf (look_infobar_delay_highlight, + "look_infobar_highlight", + _("Channel %s: * %s %s"), + ptr_channel->name, + nick, pos); + //(void) plugin_msg_handler_exec (server->name, + // "weechat_highlight", + // irc_message); } else { - gui_chat_printf_type (ptr_channel->buffer, - GUI_MSG_TYPE_MSG, - NULL, -1, - "%s%s", - GUI_COLOR(GUI_COLOR_CHAT_NICK), - cfg_look_prefix_action, - cfg_col_chat_prefix_action, - nick); - gui_chat_printf (ptr_channel->buffer, " %s%s\n", - GUI_COLOR(GUI_COLOR_CHAT), pos); - (void) plugin_msg_handler_exec (server->name, - "weechat_pv", - irc_message); + weechat_printf (ptr_channel->buffer, + "%s%s%s %s%s", + weechat_prefix ("action"), + IRC_COLOR_CHAT_NICK, + nick, + IRC_COLOR_CHAT, + pos); + //(void) plugin_msg_handler_exec (server->name, + // "weechat_pv", + // irc_message); } } } @@ -2284,23 +2300,33 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, char *irc_message, char * if (!pos2[0]) pos2 = NULL; } - gui_chat_printf_server (server->buffer, - _("Unknown CTCP %s%s%s " - "received from %s%s"), - GUI_COLOR(GUI_COLOR_CHAT_CHANNEL), - pos, - GUI_COLOR(GUI_COLOR_CHAT), - GUI_COLOR(GUI_COLOR_CHAT_NICK), - nick); if (pos2) - gui_chat_printf (server->buffer, "%s: %s\n", - GUI_COLOR(GUI_COLOR_CHAT), - pos2); + { + weechat_printf (server->buffer, + _("Unknown CTCP %s%s%s received " + "from %s%s%s: %s"), + IRC_COLOR_CHAT_CHANNEL, + pos, + IRC_COLOR_CHAT, + IRC_COLOR_CHAT_NICK, + nick, + IRC_COLOR_CHAT, + pos2); + } else - gui_chat_printf (server->buffer, "\n"); - (void) plugin_msg_handler_exec (server->name, - "weechat_ctcp", - irc_message); + { + weechat_printf (server->buffer, + _("Unknown CTCP %s%s%s received " + "from %s%s"), + IRC_COLOR_CHAT_CHANNEL, + pos, + IRC_COLOR_CHAT, + IRC_COLOR_CHAT_NICK, + nick); + } + //(void) plugin_msg_handler_exec (server->name, + // "weechat_ctcp", + // irc_message); } return WEECHAT_RC_OK; } @@ -2315,68 +2341,66 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, char *irc_message, char * nick, 0); if (!ptr_channel) { - gui_chat_printf_error_nolog (server->buffer, - _("%s cannot " - "create new " - "private " - "window " - "\"%s\"\n"), - weechat_prefix ("error"), - nick); + weechat_printf (server->buffer, + _("%s cannot create new " + "private buffer \"%s\""), + weechat_prefix ("error"), + nick); return WEECHAT_RC_ERROR; } } if (!ptr_channel->topic) { ptr_channel->topic = strdup (host2); - gui_chat_draw_title (ptr_channel->buffer, 1); + //gui_chat_draw_title (ptr_channel->buffer, 1); } if (highlight || irc_protocol_is_highlight (pos, server->nick)) { - irc_display_nick (ptr_channel->buffer, NULL, nick, - GUI_MSG_TYPE_NICK | GUI_MSG_TYPE_HIGHLIGHT, 1, - GUI_COLOR(GUI_COLOR_CHAT_HIGHLIGHT), 0); - if ((cfg_look_infobar_delay_highlight > 0) - && (ptr_channel->buffer != gui_current_window->buffer)) - gui_infobar_printf (cfg_look_infobar_delay_highlight, - GUI_COLOR_INFOBAR_HIGHLIGHT, - _("Private %s> %s"), - nick, pos); + weechat_printf (ptr_channel->buffer, + "%s%s", + irc_nick_as_prefix (NULL, + nick, + IRC_COLOR_CHAT_HIGHLIGHT), + pos); + if ((look_infobar_delay_highlight > 0) + && (ptr_channel->buffer != weechat_current_buffer)) + weechat_infobar_printf (look_infobar_delay_highlight, + "color_infobar_highlight", + _("Private %s> %s"), + nick, pos); highlight_displayed = 1; } else { - irc_display_nick (ptr_channel->buffer, NULL, nick, - GUI_MSG_TYPE_NICK, 1, - GUI_COLOR(GUI_COLOR_CHAT_NICK_OTHER), 0); + weechat_printf (ptr_channel->buffer, + "%s%s", + irc_nick_as_prefix (NULL, + nick, + IRC_COLOR_CHAT_NICK_OTHER), + pos); highlight_displayed = 0; } - gui_chat_printf_type (ptr_channel->buffer, - GUI_MSG_TYPE_MSG, - NULL, -1, - "%s%s\n", - GUI_COLOR(GUI_COLOR_CHAT), - pos); - (void) plugin_msg_handler_exec (server->name, - "weechat_pv", - irc_message); - if (highlight_displayed) - (void) plugin_msg_handler_exec (server->name, - "weechat_highlight", - irc_message); + //(void) plugin_msg_handler_exec (server->name, + // "weechat_pv", + // irc_message); + //if (highlight_displayed) + // (void) plugin_msg_handler_exec (server->name, + // "weechat_highlight", + // irc_message); } } } } else { - gui_chat_printf_error_nolog (server->buffer, - _("%s cannot parse \"%s\" command\n"), - weechat_prefix ("error"), "privmsg"); + weechat_printf (server->buffer, + _("%sirc: cannot parse \"%s\" command"), + weechat_prefix ("error"), "privmsg"); return WEECHAT_RC_ERROR; } } + return WEECHAT_RC_OK; } @@ -2399,10 +2423,9 @@ irc_protocol_cmd_quit (struct t_irc_server *server, char *irc_message, char *hos /* no host => we can't identify sender of message! */ if (!host) { - gui_chat_printf_error_nolog (server->buffer, - _("%s \"%s\" command received without " - "host\n"), - weechat_prefix ("error"), "quit"); + weechat_printf (server->buffer, + _("irc:%s \"%s\" command received without host"), + weechat_prefix ("error"), "quit"); return WEECHAT_RC_ERROR; } @@ -2425,24 +2448,22 @@ irc_protocol_cmd_quit (struct t_irc_server *server, char *irc_message, char *hos if (!ignore) { pos = strchr (host, '!'); - gui_chat_printf_quit (ptr_channel->buffer, - _("%s%s %s(%s%s%s)%s has quit"), - GUI_COLOR(GUI_COLOR_CHAT_NICK), - nick, - GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS), - GUI_COLOR(GUI_COLOR_CHAT_HOST), - (pos) ? pos + 1 : "", - GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS), - GUI_COLOR(GUI_COLOR_CHAT)); - gui_chat_printf (ptr_channel->buffer, - " %s(%s%s%s)\n", - GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS), - GUI_COLOR(GUI_COLOR_CHAT), - arguments, - GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS)); + weechat_printf (ptr_channel->buffer, + _("%s%s %s(%s%s%s)%s has quit %s(%s%s%s)"), + IRC_COLOR_CHAT_NICK, + nick, + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT_HOST, + (pos) ? pos + 1 : "", + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT, + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT, + arguments, + IRC_COLOR_CHAT_DELIMITERS); } - gui_nicklist_draw (ptr_channel->buffer, 1, 1); - gui_status_draw (ptr_channel->buffer, 1); + //gui_nicklist_draw (ptr_channel->buffer, 1, 1); + //gui_status_draw (ptr_channel->buffer, 1); } } @@ -2455,8 +2476,10 @@ irc_protocol_cmd_quit (struct t_irc_server *server, char *irc_message, char *hos */ int -irc_protocol_cmd_server_mode_reason (struct t_irc_server *server, char *irc_message, char *host, - char *nick, char *arguments, int ignore, int highlight) +irc_protocol_cmd_server_mode_reason (struct t_irc_server *server, + char *irc_message, char *host, + char *nick, char *arguments, int ignore, + int highlight) { char *ptr_msg; @@ -2487,10 +2510,12 @@ irc_protocol_cmd_server_mode_reason (struct t_irc_server *server, char *irc_mess ptr_msg++; } - gui_chat_printf_server (server->buffer, "%s%s: %s\n", - GUI_COLOR(GUI_COLOR_CHAT), arguments, - (ptr_msg) ? ptr_msg : ""); + weechat_printf (server->buffer, + "%s: %s", + arguments, + (ptr_msg) ? ptr_msg : ""); } + return WEECHAT_RC_OK; } @@ -2525,9 +2550,11 @@ irc_protocol_cmd_server_msg (struct t_irc_server *server, char *irc_message, if (arguments[0] == ':') arguments++; - gui_chat_printf_server (server->buffer, "%s%s\n", - GUI_COLOR(GUI_COLOR_CHAT), arguments); + weechat_printf (server->buffer, + "%s", + arguments); } + return WEECHAT_RC_OK; } @@ -2550,9 +2577,9 @@ irc_protocol_cmd_topic (struct t_irc_server *server, char *irc_message, char *ho if (!irc_channel_is_channel (arguments)) { - gui_chat_printf_error_nolog (server->buffer, - _("%s \"%s\" command received without channel\n"), - weechat_prefix ("error"), "topic"); + weechat_printf (server->buffer, + _("%sirc: \"%s\" command received without channel"), + weechat_prefix ("error"), "topic"); return WEECHAT_RC_ERROR; } @@ -2576,24 +2603,28 @@ irc_protocol_cmd_topic (struct t_irc_server *server, char *irc_message, char *ho { if (pos) { - gui_chat_printf_info (buffer, - _("%s%s%s has changed topic for %s%s%s to:"), - GUI_COLOR(GUI_COLOR_CHAT_NICK), - nick, - GUI_COLOR(GUI_COLOR_CHAT), - GUI_COLOR(GUI_COLOR_CHAT_CHANNEL), - arguments, - GUI_COLOR(GUI_COLOR_CHAT)); - gui_chat_printf (buffer, " \"%s%s\"\n", pos, GUI_NO_COLOR); + weechat_printf (buffer, + _("%s%s%s%s has changed topic for %s%s%s to: " + "\"%s%s\""), + weechat_prefix ("info"), + IRC_COLOR_CHAT_NICK, + nick, + IRC_COLOR_CHAT, + IRC_COLOR_CHAT_CHANNEL, + arguments, + IRC_COLOR_CHAT, + pos, + IRC_COLOR_CHAT); } else - gui_chat_printf_info (buffer, - _("%s%s%s has unset topic for %s%s\n"), - GUI_COLOR(GUI_COLOR_CHAT_NICK), - nick, - GUI_COLOR(GUI_COLOR_CHAT), - GUI_COLOR(GUI_COLOR_CHAT_CHANNEL), - arguments); + weechat_printf (buffer, + _("%s%s%s%s has unset topic for %s%s"), + weechat_prefix ("info"), + IRC_COLOR_CHAT_NICK, + nick, + IRC_COLOR_CHAT, + IRC_COLOR_CHAT_CHANNEL, + arguments); } if (ptr_channel) @@ -2604,7 +2635,7 @@ irc_protocol_cmd_topic (struct t_irc_server *server, char *irc_message, char *ho ptr_channel->topic = strdup (pos); else ptr_channel->topic = strdup (""); - gui_chat_draw_title (ptr_channel->buffer, 1); + //gui_chat_draw_title (ptr_channel->buffer, 1); } return WEECHAT_RC_OK; @@ -2627,12 +2658,12 @@ irc_protocol_cmd_wallops (struct t_irc_server *server, char *irc_message, char * { if (arguments[0] == ':') arguments++; - gui_chat_printf_server (server->buffer, - _("WALLOPS from %s%s%s: %s\n"), - GUI_COLOR(GUI_COLOR_CHAT_NICK), - nick, - GUI_COLOR(GUI_COLOR_CHAT), - arguments); + weechat_printf (server->buffer, + _("WALLOPS from %s%s%s: %s"), + IRC_COLOR_CHAT_NICK, + nick, + IRC_COLOR_CHAT, + arguments); } return WEECHAT_RC_OK; @@ -2664,7 +2695,8 @@ irc_protocol_cmd_001 (struct t_irc_server *server, char *irc_message, char *host /* connection to IRC server is ok! */ server->is_connected = 1; - server->lag_next_check = time (NULL) + irc_cfg_irc_lag_check; + server->lag_next_check = time (NULL) + + weechat_config_integer (irc_config_irc_lag_check); /* set away message if user was away (before disconnection for example) */ if (server->away_message && server->away_message[0]) @@ -2672,7 +2704,7 @@ irc_protocol_cmd_001 (struct t_irc_server *server, char *irc_message, char *host away_msg = strdup (server->away_message); if (away_msg) { - irc_cmd_away_server (server, away_msg); + irc_command_away_server (server, away_msg); free (away_msg); } } @@ -2681,18 +2713,18 @@ irc_protocol_cmd_001 (struct t_irc_server *server, char *irc_message, char *host if (server->command && server->command[0]) { /* splitting command on ';' which can be escaped with '\;' */ - commands = weechat_split_command (server->command, ';'); + commands = weechat_string_split_command (server->command, ';'); if (commands) { for (ptr = commands; *ptr; ptr++) { vars_replaced = irc_protocol_replace_vars (server, NULL, *ptr); - protocol_input_data (gui_window_search_by_buffer (server->buffer), - (vars_replaced) ? vars_replaced : *ptr, 0); + weechat_command (server->buffer, + (vars_replaced) ? vars_replaced : *ptr); if (vars_replaced) free (vars_replaced); } - weechat_free_splitted_command (commands); + weechat_string_free_splitted_command (commands); } if (server->command_delay > 0) @@ -2703,8 +2735,8 @@ irc_protocol_cmd_001 (struct t_irc_server *server, char *irc_message, char *host else irc_server_autojoin_channels (server); - gui_status_draw (server->buffer, 1); - gui_input_draw (server->buffer, 1); + //gui_status_draw (server->buffer, 1); + //gui_input_draw (server->buffer, 1); return WEECHAT_RC_OK; } @@ -2773,22 +2805,22 @@ irc_protocol_cmd_221 (struct t_irc_server *server, char *irc_message, char *host if (!ignore) { - gui_chat_printf_server (server->buffer, - _("User mode for %s%s%s is %s[%s%s%s]\n"), - GUI_COLOR(GUI_COLOR_CHAT_NICK), - arguments, - GUI_COLOR(GUI_COLOR_CHAT), - GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS), - GUI_COLOR(GUI_COLOR_CHAT), - pos_mode, - GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS)); + weechat_printf (server->buffer, + _("User mode for %s%s%s is %s[%s%s%s]"), + IRC_COLOR_CHAT_NICK, + arguments, + IRC_COLOR_CHAT, + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT, + pos_mode, + IRC_COLOR_CHAT_DELIMITERS); } } else { - gui_chat_printf_error_nolog (server->buffer, - _("%s cannot parse \"%s\" command\n"), - weechat_prefix ("error"), "221"); + weechat_printf (server->buffer, + _("%sirc: cannot parse \"%s\" command"), + weechat_prefix ("error"), "221"); return WEECHAT_RC_ERROR; } @@ -2833,17 +2865,19 @@ irc_protocol_cmd_301 (struct t_irc_server *server, char *irc_message, char *host { /* look for private buffer to display message */ ptr_channel = irc_channel_search (server, pos_nick); - if (!irc_cfg_irc_show_away_once || !ptr_channel || - !(ptr_channel->away_message) || - (strcmp (ptr_channel->away_message, pos_message) != 0)) + if (!weechat_config_boolean (irc_config_irc_show_away_once) + || !ptr_channel + || !(ptr_channel->away_message) + || (strcmp (ptr_channel->away_message, pos_message) != 0)) { ptr_buffer = (ptr_channel) ? ptr_channel->buffer : server->buffer; - gui_chat_printf_info (ptr_buffer, - _("%s%s%s is away: %s\n"), - GUI_COLOR(GUI_COLOR_CHAT_NICK), - pos_nick, - GUI_COLOR(GUI_COLOR_CHAT), - pos_message); + weechat_printf (ptr_buffer, + _("%s%s%s%s is away: %s"), + weechat_prefix ("info"), + IRC_COLOR_CHAT_NICK, + pos_nick, + IRC_COLOR_CHAT, + pos_message); if (ptr_channel) { if (ptr_channel->away_message) @@ -2854,6 +2888,7 @@ irc_protocol_cmd_301 (struct t_irc_server *server, char *irc_message, char *host } } } + return WEECHAT_RC_OK; } @@ -2899,13 +2934,13 @@ irc_protocol_cmd_302 (struct t_irc_server *server, char *irc_message, char *host ptr_next++; } - gui_chat_printf_server (server->buffer, - "%s%s%s=%s%s\n", - GUI_COLOR(GUI_COLOR_CHAT_NICK), - arguments, - GUI_COLOR(GUI_COLOR_CHAT), - GUI_COLOR(GUI_COLOR_CHAT_HOST), - pos_host); + weechat_printf (server->buffer, + "%s%s%s=%s%s", + IRC_COLOR_CHAT_NICK, + arguments, + IRC_COLOR_CHAT, + IRC_COLOR_CHAT_HOST, + pos_host); } else ptr_next = NULL; @@ -2915,6 +2950,7 @@ irc_protocol_cmd_302 (struct t_irc_server *server, char *irc_message, char *host } } } + return WEECHAT_RC_OK; } @@ -2936,7 +2972,8 @@ irc_protocol_cmd_303 (struct t_irc_server *server, char *irc_message, char *host if (!ignore) { - gui_chat_printf_server (server->buffer, _("Users online: ")); + weechat_printf (server->buffer, + _("Users online: ")); arguments = strchr (arguments, ' '); if (arguments) @@ -2955,16 +2992,17 @@ irc_protocol_cmd_303 (struct t_irc_server *server, char *irc_message, char *host while (ptr_next[0] == ' ') ptr_next++; } - gui_chat_printf (server->buffer, "%s%s ", - GUI_COLOR(GUI_COLOR_CHAT_NICK), - arguments); + weechat_printf (server->buffer, + "%s%s ", + IRC_COLOR_CHAT_NICK, + arguments); arguments = ptr_next; if (arguments && !arguments[0]) arguments = NULL; } } - gui_chat_printf (server->buffer, "\n"); } + return WEECHAT_RC_OK; } @@ -2976,7 +3014,7 @@ int irc_protocol_cmd_305 (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight) { - struct t_gui_window *ptr_window; + //struct t_gui_window *ptr_window; /* make C compiler happy */ (void) irc_message; @@ -2993,11 +3031,12 @@ irc_protocol_cmd_305 (struct t_irc_server *server, char *irc_message, char *host arguments++; if (arguments[0] == ':') arguments++; - gui_chat_printf_server (server->buffer, "%s\n", arguments); + weechat_printf (server->buffer, "%s", arguments); } } server->is_away = 0; server->away_time = 0; + /* for (ptr_window = gui_windows; ptr_window; ptr_window = ptr_window->next_window) { @@ -3005,6 +3044,8 @@ irc_protocol_cmd_305 (struct t_irc_server *server, char *irc_message, char *host && (IRC_BUFFER_SERVER(ptr_window->buffer) == server)) gui_status_draw (ptr_window->buffer, 1); } + */ + return WEECHAT_RC_OK; } @@ -3016,7 +3057,7 @@ int irc_protocol_cmd_306 (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight) { - struct t_gui_window *ptr_window; + //struct t_gui_window *ptr_window; /* make C compiler happy */ (void) irc_message; @@ -3033,11 +3074,12 @@ irc_protocol_cmd_306 (struct t_irc_server *server, char *irc_message, char *host arguments++; if (arguments[0] == ':') arguments++; - gui_chat_printf_server (server->buffer, "%s\n", arguments); + weechat_printf (server->buffer, "%s", arguments); } } server->is_away = 1; server->away_time = time (NULL); + /* for (ptr_window = gui_windows; ptr_window; ptr_window = ptr_window->next_window) { @@ -3051,6 +3093,8 @@ irc_protocol_cmd_306 (struct t_irc_server *server, char *irc_message, char *host } } } + */ + return WEECHAT_RC_OK; } @@ -3087,16 +3131,18 @@ irc_protocol_cmd_whois_nick_msg (struct t_irc_server *server, char *irc_message, if (pos_msg[0] == ':') pos_msg++; - gui_chat_printf_server (server->buffer, "%s[%s%s%s] %s%s\n", - GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS), - GUI_COLOR(GUI_COLOR_CHAT_NICK), - pos_nick, - GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS), - GUI_COLOR(GUI_COLOR_CHAT), - pos_msg); + weechat_printf (server->buffer, + "%s[%s%s%s] %s%s", + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT_NICK, + pos_nick, + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT, + pos_msg); } } } + return WEECHAT_RC_OK; } @@ -3124,15 +3170,16 @@ irc_protocol_cmd_310 (struct t_irc_server *server, char *irc_message, char *host while (pos_nick[0] == ' ') pos_nick++; - gui_chat_printf_server (server->buffer, - _("%s[%s%s%s]%s help mode (+h)\n"), - GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS), - GUI_COLOR(GUI_COLOR_CHAT_NICK), - pos_nick, - GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS), - GUI_COLOR(GUI_COLOR_CHAT)); + weechat_printf (server->buffer, + _("%s[%s%s%s]%s help mode (+h)"), + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT_NICK, + pos_nick, + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT); } } + return WEECHAT_RC_OK; } @@ -3187,23 +3234,24 @@ irc_protocol_cmd_311 (struct t_irc_server *server, char *irc_message, char *host if (pos_realname[0] == ':') pos_realname++; - gui_chat_printf_server (server->buffer, - "%s[%s%s%s] (%s%s@%s%s)%s: %s\n", - GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS), - GUI_COLOR(GUI_COLOR_CHAT_NICK), - pos_nick, - GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS), - GUI_COLOR(GUI_COLOR_CHAT_HOST), - pos_user, - pos_host, - GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS), - GUI_COLOR(GUI_COLOR_CHAT), - pos_realname); + weechat_printf (server->buffer, + "%s[%s%s%s] (%s%s@%s%s)%s: %s", + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT_NICK, + pos_nick, + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT_HOST, + pos_user, + pos_host, + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT, + pos_realname); } } } } } + return WEECHAT_RC_OK; } @@ -3247,18 +3295,18 @@ irc_protocol_cmd_312 (struct t_irc_server *server, char *irc_message, char *host if (pos_serverinfo[0] == ':') pos_serverinfo++; - gui_chat_printf_server (server->buffer, - "%s[%s%s%s] %s%s %s(%s%s%s)\n", - GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS), - GUI_COLOR(GUI_COLOR_CHAT_NICK), - pos_nick, - GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS), - GUI_COLOR(GUI_COLOR_CHAT), - pos_server, - GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS), - GUI_COLOR(GUI_COLOR_CHAT), - pos_serverinfo, - GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS)); + weechat_printf (server->buffer, + "%s[%s%s%s] %s%s %s(%s%s%s)", + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT_NICK, + pos_nick, + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT, + pos_server, + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT, + pos_serverinfo, + IRC_COLOR_CHAT_DELIMITERS); } } } @@ -3320,17 +3368,17 @@ irc_protocol_cmd_314 (struct t_irc_server *server, char *irc_message, char *host if (pos_realname[0] == ':') pos_realname++; - gui_chat_printf_server (server->buffer, - _("%s%s %s(%s%s@%s%s)%s was %s\n"), - GUI_COLOR(GUI_COLOR_CHAT_NICK), - pos_nick, - GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS), - GUI_COLOR(GUI_COLOR_CHAT_HOST), - pos_user, - pos_host, - GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS), - GUI_COLOR(GUI_COLOR_CHAT), - pos_realname); + weechat_printf (server->buffer, + _("%s%s %s(%s%s@%s%s)%s was %s"), + IRC_COLOR_CHAT_NICK, + pos_nick, + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT_HOST, + pos_user, + pos_host, + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT, + pos_realname); } } } @@ -3378,19 +3426,20 @@ irc_protocol_cmd_315 (struct t_irc_server *server, char *irc_message, char *host } if (!ignore) { - gui_chat_printf_server (server->buffer, - "%s%s %s%s\n", - GUI_COLOR(GUI_COLOR_CHAT_CHANNEL), - arguments, - GUI_COLOR(GUI_COLOR_CHAT), - pos); + weechat_printf (server->buffer, + "%s%s %s%s", + IRC_COLOR_CHAT_CHANNEL, + arguments, + IRC_COLOR_CHAT, + pos); } } else { if (!ignore) - gui_chat_printf_server (server->buffer, "%s\n", arguments); + weechat_printf (server->buffer, "%s", arguments); } + return WEECHAT_RC_OK; } @@ -3444,43 +3493,70 @@ irc_protocol_cmd_317 (struct t_irc_server *server, char *irc_message, char *host min = ((idle_time % (60 * 60 * 24)) % (60 * 60)) / 60; sec = ((idle_time % (60 * 60 * 24)) % (60 * 60)) % 60; - gui_chat_printf_server (server->buffer, - _("%s[%s%s%s]%s idle: "), - GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS), - GUI_COLOR(GUI_COLOR_CHAT_NICK), - pos_nick, - GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS), - GUI_COLOR(GUI_COLOR_CHAT)); + datetime = (time_t)(atol (pos_signon)); if (day > 0) - gui_chat_printf (server->buffer, "%s%d %s%s, ", - GUI_COLOR(GUI_COLOR_CHAT_CHANNEL), - day, - GUI_COLOR(GUI_COLOR_CHAT), - (day > 1) ? _("days") : _("day")); - - datetime = (time_t)(atol (pos_signon)); - gui_chat_printf (server->buffer, - _("%s%02d %s%s %s%02d %s%s %s%02d %s%s, signon at: %s%s"), - GUI_COLOR(GUI_COLOR_CHAT_CHANNEL), - hour, - GUI_COLOR(GUI_COLOR_CHAT), - (hour > 1) ? _("hours") : _("hour"), - GUI_COLOR(GUI_COLOR_CHAT_CHANNEL), - min, - GUI_COLOR(GUI_COLOR_CHAT), - (min > 1) ? _("minutes") : _("minute"), - GUI_COLOR(GUI_COLOR_CHAT_CHANNEL), - sec, - GUI_COLOR(GUI_COLOR_CHAT), - (sec > 1) ? _("seconds") : _("second"), - GUI_COLOR(GUI_COLOR_CHAT_CHANNEL), - ctime (&datetime)); + { + weechat_printf (server->buffer, + _("%s[%s%s%s]%s idle: %s%d %s%s, " + "%s%02d %s%s %s%02d %s%s %s%02d " + "%s%s, signon at: %s%s"), + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT_NICK, + pos_nick, + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT, + IRC_COLOR_CHAT_CHANNEL, + day, + IRC_COLOR_CHAT, + (day > 1) ? _("days") : _("day"), + IRC_COLOR_CHAT_CHANNEL, + hour, + IRC_COLOR_CHAT, + (hour > 1) ? _("hours") : _("hour"), + IRC_COLOR_CHAT_CHANNEL, + min, + IRC_COLOR_CHAT, + (min > 1) ? _("minutes") : _("minute"), + IRC_COLOR_CHAT_CHANNEL, + sec, + IRC_COLOR_CHAT, + (sec > 1) ? _("seconds") : _("second"), + IRC_COLOR_CHAT_CHANNEL, + ctime (&datetime)); + } + else + { + weechat_printf (server->buffer, + _("%s[%s%s%s]%s idle: %s%02d %s%s " + "%s%02d %s%s %s%02d %s%s, " + "signon at: %s%s"), + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT_NICK, + pos_nick, + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT, + IRC_COLOR_CHAT_CHANNEL, + hour, + IRC_COLOR_CHAT, + (hour > 1) ? _("hours") : _("hour"), + IRC_COLOR_CHAT_CHANNEL, + min, + IRC_COLOR_CHAT, + (min > 1) ? _("minutes") : _("minute"), + IRC_COLOR_CHAT_CHANNEL, + sec, + IRC_COLOR_CHAT, + (sec > 1) ? _("seconds") : _("second"), + IRC_COLOR_CHAT_CHANNEL, + ctime (&datetime)); + } } } } } } + return WEECHAT_RC_OK; } @@ -3492,8 +3568,7 @@ int irc_protocol_cmd_319 (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight) { - char *pos_nick, *pos_channel, *pos; - int color; + char *pos_nick, *pos_channel, *pos, *color; /* make C compiler happy */ (void) irc_message; @@ -3518,13 +3593,13 @@ irc_protocol_cmd_319 (struct t_irc_server *server, char *irc_message, char *host if (pos_channel[0] == ':') pos_channel++; - gui_chat_printf_server (server->buffer, - _("%s[%s%s%s]%s Channels: "), - GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS), - GUI_COLOR(GUI_COLOR_CHAT_NICK), - pos_nick, - GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS), - GUI_COLOR(GUI_COLOR_CHAT)); + weechat_printf (server->buffer, + _("%s[%s%s%s]%s Channels: "), + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT_NICK, + pos_nick, + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT); while (pos_channel && pos_channel[0]) { if (irc_mode_nick_prefix_allowed (server, pos_channel[0])) @@ -3532,32 +3607,32 @@ irc_protocol_cmd_319 (struct t_irc_server *server, char *irc_message, char *host switch (pos_channel[0]) { case '@': /* op */ - color = GUI_COLOR_NICKLIST_PREFIX1; + color = IRC_COLOR_NICKLIST_PREFIX1; break; case '~': /* channel owner */ - color = GUI_COLOR_NICKLIST_PREFIX1; + color = IRC_COLOR_NICKLIST_PREFIX1; break; case '&': /* channel admin */ - color = GUI_COLOR_NICKLIST_PREFIX1; + color = IRC_COLOR_NICKLIST_PREFIX1; break; case '!': /* channel admin (2) */ - color = GUI_COLOR_NICKLIST_PREFIX1; + color = IRC_COLOR_NICKLIST_PREFIX1; break; case '%': /* half-op */ - color = GUI_COLOR_NICKLIST_PREFIX2; + color = IRC_COLOR_NICKLIST_PREFIX2; break; case '+': /* voice */ - color = GUI_COLOR_NICKLIST_PREFIX3; + color = IRC_COLOR_NICKLIST_PREFIX3; break; case '-': /* channel user */ - color = GUI_COLOR_NICKLIST_PREFIX4; + color = IRC_COLOR_NICKLIST_PREFIX4; break; default: - color = GUI_COLOR_CHAT; + color = IRC_COLOR_CHAT; break; } - gui_chat_printf (server->buffer, "%s%c", - GUI_COLOR(color), pos_channel[0]); + weechat_printf (server->buffer, "%s%c", + color, pos_channel[0]); pos_channel++; } @@ -3569,15 +3644,16 @@ irc_protocol_cmd_319 (struct t_irc_server *server, char *irc_message, char *host while (pos[0] == ' ') pos++; } - gui_chat_printf (server->buffer, "%s%s%s", - GUI_COLOR(GUI_COLOR_CHAT_CHANNEL), - pos_channel, - (pos && pos[0]) ? " " : "\n"); + weechat_printf (server->buffer, "%s%s%s", + IRC_COLOR_CHAT_CHANNEL, + pos_channel, + (pos && pos[0]) ? " " : ""); pos_channel = pos; } } } } + return WEECHAT_RC_OK; } @@ -3610,8 +3686,9 @@ irc_protocol_cmd_321 (struct t_irc_server *server, char *irc_message, char *host else pos = arguments; - gui_chat_printf_server (server->buffer, "%s\n", pos); + weechat_printf (server->buffer, "%s", pos); } + return WEECHAT_RC_OK; } @@ -3647,11 +3724,12 @@ irc_protocol_cmd_322 (struct t_irc_server *server, char *irc_message, char *host if (server->cmd_list_regexp) { if (regexec (server->cmd_list_regexp, pos, 0, NULL, 0) == 0) - gui_chat_printf_server (server->buffer, "%s\n", pos); + weechat_printf (server->buffer, "%s", pos); } else - gui_chat_printf_server (server->buffer, "%s\n", pos); + weechat_printf (server->buffer, "%s", pos); } + return WEECHAT_RC_OK; } @@ -3684,8 +3762,9 @@ irc_protocol_cmd_323 (struct t_irc_server *server, char *irc_message, char *host else pos = arguments; - gui_chat_printf_server (server->buffer, "%s\n", pos); + weechat_printf (server->buffer, "%s", pos); } + return WEECHAT_RC_OK; } @@ -3753,10 +3832,11 @@ irc_protocol_cmd_324 (struct t_irc_server *server, char *irc_message, char *host ptr_channel->modes = NULL; } } - gui_status_draw (ptr_channel->buffer, 1); + //gui_status_draw (ptr_channel->buffer, 1); } } } + return WEECHAT_RC_OK; } @@ -3807,25 +3887,26 @@ irc_protocol_cmd_327 (struct t_irc_server *server, char *irc_message, char *host pos_other++; } - gui_chat_printf_server (server->buffer, - "%s[%s%s%s] %s%s %s %s%s%s%s%s%s\n", - GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS), - GUI_COLOR(GUI_COLOR_CHAT_NICK), - pos_nick, - GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS), - GUI_COLOR(GUI_COLOR_CHAT_HOST), - pos_host1, - pos_host2, - GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS), - (pos_other) ? "(" : "", - GUI_COLOR(GUI_COLOR_CHAT), - (pos_other) ? pos_other : "", - GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS), - (pos_other) ? ")" : ""); + weechat_printf (server->buffer, + "%s[%s%s%s] %s%s %s %s%s%s%s%s%s", + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT_NICK, + pos_nick, + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT_HOST, + pos_host1, + pos_host2, + IRC_COLOR_CHAT_DELIMITERS, + (pos_other) ? "(" : "", + IRC_COLOR_CHAT, + (pos_other) ? pos_other : "", + IRC_COLOR_CHAT_DELIMITERS, + (pos_other) ? ")" : ""); } } } } + return WEECHAT_RC_OK; } @@ -3863,39 +3944,41 @@ irc_protocol_cmd_329 (struct t_irc_server *server, char *irc_message, char *host ptr_channel = irc_channel_search (server, pos_channel); if (!ptr_channel) { - gui_chat_printf_error_nolog (server->buffer, - _("%s channel \"%s\" not found for " - "\"%s\" command\n"), - weechat_prefix ("error"), pos_channel, "329"); + weechat_printf (server->buffer, + _("%sirc: channel \"%s\" not found for " + "\"%s\" command"), + weechat_prefix ("error"), pos_channel, "329"); return WEECHAT_RC_ERROR; } if (!ignore && (ptr_channel->display_creation_date)) { datetime = (time_t)(atol (pos_date)); - gui_chat_printf_info (ptr_channel->buffer, - _("Channel created on %s"), - ctime (&datetime)); + weechat_printf (ptr_channel->buffer, + _("%sChannel created on %s"), + weechat_prefix ("info"), + ctime (&datetime)); } ptr_channel->display_creation_date = 0; } else { - gui_chat_printf_error_nolog (server->buffer, - _("%s cannot identify date/time for " - "\"%s\" command\n"), - weechat_prefix ("error"), "329"); + weechat_printf (server->buffer, + _("%sirc: cannot identify date/time for \"%s\" " + "command"), + weechat_prefix ("error"), "329"); return WEECHAT_RC_ERROR; } } else { - gui_chat_printf_error_nolog (server->buffer, - _("%s cannot identify channel for " - "\"%s\" command\n"), - weechat_prefix ("error"), "329"); + weechat_printf (server->buffer, + _("%sirc: cannot identify channel for \"%s\" " + "command"), + weechat_prefix ("error"), "329"); return WEECHAT_RC_ERROR; } + return WEECHAT_RC_OK; } @@ -3931,20 +4014,25 @@ irc_protocol_cmd_331 (struct t_irc_server *server, char *irc_message, char *host } else { - gui_chat_printf_error_nolog (server->buffer, - _("%s channel \"%s\" not found for " - "\"%s\" command\n"), - weechat_prefix ("error"), "", "331"); + weechat_printf (server->buffer, + _("%sirc: channel \"%s\" not found for \"%s\" " + "command"), + weechat_prefix ("error"), "", "331"); return WEECHAT_RC_ERROR; } ptr_channel = irc_channel_search (server, pos_channel); if (!ignore) - gui_chat_printf_info ((ptr_channel) ? ptr_channel->buffer : NULL, - _("No topic set for %s%s\n"), - GUI_COLOR(GUI_COLOR_CHAT_CHANNEL), - pos_channel); + { + weechat_printf ((ptr_channel) ? + ptr_channel->buffer : server->buffer, + _("%sNo topic set for %s%s"), + weechat_prefix ("info"), + IRC_COLOR_CHAT_CHANNEL, + pos_channel); + } } + return WEECHAT_RC_OK; } @@ -3992,25 +4080,29 @@ irc_protocol_cmd_332 (struct t_irc_server *server, char *irc_message, char *host if (!ignore) { - gui_chat_printf_info (ptr_buffer, _("Topic for %s%s%s is: "), - GUI_COLOR(GUI_COLOR_CHAT_CHANNEL), - pos, - GUI_COLOR(GUI_COLOR_CHAT)); - gui_chat_printf (ptr_buffer, "\"%s%s\"\n", pos2, GUI_NO_COLOR); + weechat_printf (ptr_buffer, + _("%sTopic for %s%s%s is: \"%s%s\""), + weechat_prefix ("info"), + IRC_COLOR_CHAT_CHANNEL, + pos, + IRC_COLOR_CHAT, + pos2, + IRC_COLOR_CHAT); } - if (ptr_channel) - gui_chat_draw_title (ptr_buffer, 1); + //if (ptr_channel) + // gui_chat_draw_title (ptr_buffer, 1); } } else { - gui_chat_printf_error_nolog (server->buffer, - _("%s cannot identify channel for \"%s\" " - "command\n"), - weechat_prefix ("error"), "332"); + weechat_printf (server->buffer, + _("%sirc: cannot identify channel for \"%s\" " + "command"), + weechat_prefix ("error"), "332"); return WEECHAT_RC_ERROR; } + return WEECHAT_RC_OK; } @@ -4060,12 +4152,13 @@ irc_protocol_cmd_333 (struct t_irc_server *server, char *irc_message, char *host if (!ignore) { datetime = (time_t)(atol (pos_date)); - gui_chat_printf_info (ptr_buffer, - _("Topic set by %s%s%s, %s"), - GUI_COLOR(GUI_COLOR_CHAT_NICK), - pos_nick, - GUI_COLOR(GUI_COLOR_CHAT), - ctime (&datetime)); + weechat_printf (ptr_buffer, + _("%sTopic set by %s%s%s, %s"), + weechat_prefix ("info"), + IRC_COLOR_CHAT_NICK, + pos_nick, + IRC_COLOR_CHAT, + ctime (&datetime)); } } else @@ -4076,12 +4169,13 @@ irc_protocol_cmd_333 (struct t_irc_server *server, char *irc_message, char *host } else { - gui_chat_printf_error_nolog (server->buffer, - _("%s cannot identify channel for \"%s\" " - "command\n"), - weechat_prefix ("error"), "333"); + weechat_printf (server->buffer, + _("%sirc: cannot identify channel for \"%s\" " + "command"), + weechat_prefix ("error"), "333"); return WEECHAT_RC_ERROR; } + return WEECHAT_RC_OK; } @@ -4125,22 +4219,23 @@ irc_protocol_cmd_338 (struct t_irc_server *server, char *irc_message, char *host if (pos_message[0] == ':') pos_message++; - gui_chat_printf_server (server->buffer, - "%s[%s%s%s] %s%s %s%s %s%s\n", - GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS), - GUI_COLOR(GUI_COLOR_CHAT_NICK), - pos_nick, - GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS), - GUI_COLOR(GUI_COLOR_CHAT_NICK), - pos_nick, - GUI_COLOR(GUI_COLOR_CHAT), - pos_message, - GUI_COLOR(GUI_COLOR_CHAT_HOST), - pos_host); + weechat_printf (server->buffer, + "%s[%s%s%s] %s%s %s%s %s%s\n", + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT_NICK, + pos_nick, + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT_NICK, + pos_nick, + IRC_COLOR_CHAT, + pos_message, + IRC_COLOR_CHAT_HOST, + pos_host); } } } } + return WEECHAT_RC_OK; } @@ -4180,36 +4275,37 @@ irc_protocol_cmd_341 (struct t_irc_server *server, char *irc_message, char *host if (pos_channel[0] == ':') pos_channel++; - gui_chat_printf_server (server->buffer, - _("%s%s%s has invited %s%s%s on %s%s\n"), - GUI_COLOR(GUI_COLOR_CHAT_NICK), - arguments, - GUI_COLOR(GUI_COLOR_CHAT), - GUI_COLOR(GUI_COLOR_CHAT_NICK), - pos_nick, - GUI_COLOR(GUI_COLOR_CHAT), - GUI_COLOR(GUI_COLOR_CHAT_CHANNEL), - pos_channel); - gui_status_draw (gui_current_window->buffer, 1); + weechat_printf (server->buffer, + _("%s%s%s has invited %s%s%s on %s%s"), + IRC_COLOR_CHAT_NICK, + arguments, + IRC_COLOR_CHAT, + IRC_COLOR_CHAT_NICK, + pos_nick, + IRC_COLOR_CHAT, + IRC_COLOR_CHAT_CHANNEL, + pos_channel); + //gui_status_draw (gui_current_window->buffer, 1); } } else { - gui_chat_printf_error_nolog (server->buffer, - _("%s cannot identify channel for \"%s\" " - "command\n"), - weechat_prefix ("error"), "341"); + weechat_printf (server->buffer, + _("%sirc: cannot identify channel for \"%s\" " + "command"), + weechat_prefix ("error"), "341"); return WEECHAT_RC_ERROR; } } else { - gui_chat_printf_error_nolog (server->buffer, - _("%s cannot identify nickname for \"%s\" " - "command\n"), - weechat_prefix ("error"), "341"); + weechat_printf (server->buffer, + _("%sirc: cannot identify nickname for \"%s\" " + "command"), + weechat_prefix ("error"), "341"); return WEECHAT_RC_ERROR; } + return WEECHAT_RC_OK; } @@ -4244,16 +4340,17 @@ irc_protocol_cmd_344 (struct t_irc_server *server, char *irc_message, char *host while (pos_host[0] == ' ') pos_host++; - gui_chat_printf_server (server->buffer, - _("Channel reop %s%s%s: %s%s\n"), - GUI_COLOR(GUI_COLOR_CHAT_CHANNEL), - pos_channel, - GUI_COLOR(GUI_COLOR_CHAT), - GUI_COLOR(GUI_COLOR_CHAT_HOST), - pos_host); + weechat_printf (server->buffer, + _("Channel reop %s%s%s: %s%s"), + IRC_COLOR_CHAT_CHANNEL, + pos_channel, + IRC_COLOR_CHAT, + IRC_COLOR_CHAT_HOST, + pos_host); } } } + return WEECHAT_RC_OK; } @@ -4287,18 +4384,21 @@ irc_protocol_cmd_345 (struct t_irc_server *server, char *irc_message, char *host pos[0] = '\0'; pos++; if (!ignore) - gui_chat_printf_server (server->buffer, - "%s%s %s%s\n", - GUI_COLOR(GUI_COLOR_CHAT_CHANNEL), - arguments, - GUI_COLOR(GUI_COLOR_CHAT), - pos); + { + weechat_printf (server->buffer, + "%s%s %s%s", + IRC_COLOR_CHAT_CHANNEL, + arguments, + IRC_COLOR_CHAT, + pos); + } } else { if (!ignore) - gui_chat_printf_server (server->buffer, "%s\n", arguments); + weechat_printf (server->buffer, "%s", arguments); } + return WEECHAT_RC_OK; } @@ -4325,9 +4425,9 @@ irc_protocol_cmd_348 (struct t_irc_server *server, char *irc_message, char *host pos_channel = strchr (arguments, ' '); if (!pos_channel) { - gui_chat_printf_error_nolog (server->buffer, - _("%s cannot parse \"%s\" command\n"), - weechat_prefix ("error"), "348"); + weechat_printf (server->buffer, + _("%sirc: cannot parse \"%s\" command"), + weechat_prefix ("error"), "348"); return WEECHAT_RC_ERROR; } pos_channel[0] = '\0'; @@ -4339,9 +4439,9 @@ irc_protocol_cmd_348 (struct t_irc_server *server, char *irc_message, char *host pos_exception = strchr (pos_channel, ' '); if (!pos_exception) { - gui_chat_printf_error_nolog (server->buffer, - _("%s cannot parse \"%s\" command\n"), - weechat_prefix ("error"), "348"); + weechat_printf (server->buffer, + _("%sirc: cannot parse \"%s\" command"), + weechat_prefix ("error"), "348"); return WEECHAT_RC_ERROR; } pos_exception[0] = '\0'; @@ -4376,48 +4476,48 @@ irc_protocol_cmd_348 (struct t_irc_server *server, char *irc_message, char *host if (!ignore) { - gui_chat_printf_info (buffer, - _("%s[%s%s%s]%s exception %s%s%s"), - GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS), - GUI_COLOR(GUI_COLOR_CHAT_CHANNEL), - pos_channel, - GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS), - GUI_COLOR(GUI_COLOR_CHAT), - GUI_COLOR(GUI_COLOR_CHAT_HOST), - pos_exception, - GUI_COLOR(GUI_COLOR_CHAT)); + weechat_printf (buffer, + _("%s%s[%s%s%s]%s exception %s%s%s"), + weechat_prefix ("info"), + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT_CHANNEL, + pos_channel, + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT, + IRC_COLOR_CHAT_HOST, + pos_exception, + IRC_COLOR_CHAT); if (pos_user) { pos = strchr (pos_user, '!'); if (pos) { pos[0] = '\0'; - gui_chat_printf (buffer, - _(" by %s%s %s(%s%s%s)"), - GUI_COLOR(GUI_COLOR_CHAT_NICK), - pos_user, - GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS), - GUI_COLOR(GUI_COLOR_CHAT_HOST), - pos + 1, - GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS)); + weechat_printf (buffer, + _(" by %s%s %s(%s%s%s)"), + IRC_COLOR_CHAT_NICK, + pos_user, + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT_HOST, + pos + 1, + IRC_COLOR_CHAT_DELIMITERS); } else - gui_chat_printf (buffer, - _(" by %s%s"), - GUI_COLOR(GUI_COLOR_CHAT_NICK), - pos_user); + weechat_printf (buffer, + _(" by %s%s"), + IRC_COLOR_CHAT_NICK, + pos_user); } if (pos_date) { datetime = (time_t)(atol (pos_date)); - gui_chat_printf_nolog (buffer, NULL, -1, - "%s, %s", - GUI_COLOR(GUI_COLOR_CHAT), - ctime (&datetime)); + weechat_printf (buffer, + "%s, %s", + IRC_COLOR_CHAT, + ctime (&datetime)); } - else - gui_chat_printf_nolog (buffer, NULL, -1, "\n"); } + return WEECHAT_RC_OK; } @@ -4442,9 +4542,9 @@ irc_protocol_cmd_349 (struct t_irc_server *server, char *irc_message, char *host pos_channel = strchr (arguments, ' '); if (!pos_channel) { - gui_chat_printf_error_nolog (server->buffer, - _("%s cannot parse \"%s\" command\n"), - weechat_prefix ("error"), "349"); + weechat_printf (server->buffer, + _("%sirc: cannot parse \"%s\" command"), + weechat_prefix ("error"), "349"); return WEECHAT_RC_ERROR; } pos_channel[0] = '\0'; @@ -4455,9 +4555,9 @@ irc_protocol_cmd_349 (struct t_irc_server *server, char *irc_message, char *host pos_msg = strchr (pos_channel, ' '); if (!pos_msg) { - gui_chat_printf_error_nolog (server->buffer, - _("%s cannot parse \"%s\" command\n"), - weechat_prefix ("error"), "349"); + weechat_printf (server->buffer, + _("%sirc: cannot parse \"%s\" command"), + weechat_prefix ("error"), "349"); return WEECHAT_RC_ERROR; } pos_msg[0] = '\0'; @@ -4472,15 +4572,16 @@ irc_protocol_cmd_349 (struct t_irc_server *server, char *irc_message, char *host if (!ignore) { - gui_chat_printf_info (buffer, - "%s[%s%s%s] %s%s\n", - GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS), - GUI_COLOR(GUI_COLOR_CHAT_CHANNEL), - pos_channel, - GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS), - GUI_COLOR(GUI_COLOR_CHAT), - pos_msg); + weechat_printf (buffer, + "%s[%s%s%s] %s%s", + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT_CHANNEL, + pos_channel, + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT, + pos_msg); } + return WEECHAT_RC_OK; } @@ -4520,10 +4621,11 @@ irc_protocol_cmd_351 (struct t_irc_server *server, char *irc_message, char *host if (!ignore) { if (pos2) - gui_chat_printf_server (server->buffer, "%s %s\n", pos, pos2); + weechat_printf (server->buffer, "%s %s", pos, pos2); else - gui_chat_printf_server (server->buffer, "%s\n", pos); + weechat_printf (server->buffer, "%s", pos); } + return WEECHAT_RC_OK; } @@ -4624,25 +4726,25 @@ irc_protocol_cmd_352 (struct t_irc_server *server, char *irc_message, char *host if (!ignore) { - gui_chat_printf_server (server->buffer, - _("%s%s%s on %s%s%s " - "%s %s %s%s@%s " - "%s(%s%s%s)\n"), - GUI_COLOR(GUI_COLOR_CHAT_NICK), - pos_nick, - GUI_COLOR(GUI_COLOR_CHAT), - GUI_COLOR(GUI_COLOR_CHAT_CHANNEL), - pos_channel, - GUI_COLOR(GUI_COLOR_CHAT), - pos_attr, - pos_hopcount, - GUI_COLOR(GUI_COLOR_CHAT_HOST), - pos_user, - pos_host, - GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS), - GUI_COLOR(GUI_COLOR_CHAT), - pos_realname, - GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS)); + weechat_printf (server->buffer, + _("%s%s%s on %s%s%s " + "%s %s %s%s@%s " + "%s(%s%s%s)"), + IRC_COLOR_CHAT_NICK, + pos_nick, + IRC_COLOR_CHAT, + IRC_COLOR_CHAT_CHANNEL, + pos_channel, + IRC_COLOR_CHAT, + pos_attr, + pos_hopcount, + IRC_COLOR_CHAT_HOST, + pos_user, + pos_host, + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT, + pos_realname, + IRC_COLOR_CHAT_DELIMITERS); } } } @@ -4652,6 +4754,7 @@ irc_protocol_cmd_352 (struct t_irc_server *server, char *irc_message, char *host } } } + return WEECHAT_RC_OK; } @@ -4663,10 +4766,10 @@ int irc_protocol_cmd_353 (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight) { - char *pos, *pos_nick; + char *pos, *pos_nick, *color; int is_chanowner, is_chanadmin, is_chanadmin2, is_op, is_halfop; int has_voice, is_chanuser; - int prefix_found, color; + int prefix_found; struct t_irc_channel *ptr_channel; struct t_gui_buffer *ptr_buffer; @@ -4707,9 +4810,9 @@ irc_protocol_cmd_353 (struct t_irc_server *server, char *irc_message, char *host pos++; if (pos[0] != ':') { - gui_chat_printf_error_nolog (server->buffer, - _("%s cannot parse \"%s\" command\n"), - weechat_prefix ("error"), "353"); + weechat_printf (server->buffer, + _("%sirc: cannot parse \"%s\" command"), + weechat_prefix ("error"), "353"); return WEECHAT_RC_ERROR; } @@ -4717,12 +4820,12 @@ irc_protocol_cmd_353 (struct t_irc_server *server, char *irc_message, char *host if (!ignore && !ptr_channel) { /* display users on channel */ - gui_chat_printf_server (ptr_buffer, - _("Nicks %s%s%s: %s["), - GUI_COLOR(GUI_COLOR_CHAT_CHANNEL), - arguments, - GUI_COLOR(GUI_COLOR_CHAT), - GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS)); + weechat_printf (ptr_buffer, + _("Nicks %s%s%s: %s["), + IRC_COLOR_CHAT_CHANNEL, + arguments, + IRC_COLOR_CHAT, + IRC_COLOR_CHAT_DELIMITERS); } pos++; @@ -4750,39 +4853,39 @@ irc_protocol_cmd_353 (struct t_irc_server *server, char *irc_message, char *host { case '@': /* op */ is_op = 1; - color = GUI_COLOR_NICKLIST_PREFIX1; + color = IRC_COLOR_NICKLIST_PREFIX1; break; case '~': /* channel owner */ is_chanowner = 1; - color = GUI_COLOR_NICKLIST_PREFIX1; + color = IRC_COLOR_NICKLIST_PREFIX1; break; case '&': /* channel admin */ is_chanadmin = 1; - color = GUI_COLOR_NICKLIST_PREFIX1; + color = IRC_COLOR_NICKLIST_PREFIX1; break; case '!': /* channel admin (2) */ is_chanadmin2 = 1; - color = GUI_COLOR_NICKLIST_PREFIX1; + color = IRC_COLOR_NICKLIST_PREFIX1; break; case '%': /* half-op */ is_halfop = 1; - color = GUI_COLOR_NICKLIST_PREFIX2; + color = IRC_COLOR_NICKLIST_PREFIX2; break; case '+': /* voice */ has_voice = 1; - color = GUI_COLOR_NICKLIST_PREFIX3; + color = IRC_COLOR_NICKLIST_PREFIX3; break; case '-': /* channel user */ is_chanuser = 1; - color = GUI_COLOR_NICKLIST_PREFIX4; + color = IRC_COLOR_NICKLIST_PREFIX4; break; default: - color = GUI_COLOR_CHAT; + color = IRC_COLOR_CHAT; break; } if (!ignore && !ptr_channel) - gui_chat_printf (ptr_buffer, "%s%c", - GUI_COLOR(color), pos[0]); + weechat_printf (ptr_buffer, "%s%c", + color, pos[0]); } if (prefix_found) pos++; @@ -4800,44 +4903,44 @@ irc_protocol_cmd_353 (struct t_irc_server *server, char *irc_message, char *host is_chanowner, is_chanadmin, is_chanadmin2, is_op, is_halfop, has_voice, is_chanuser)) { - gui_chat_printf_error_nolog (server->buffer, - _("%s cannot create nick \"%s\" " - "for channel \"%s\"\n"), - weechat_prefix ("error"), pos_nick, - ptr_channel->name); + weechat_printf (server->buffer, + _("%sirc: cannot create nick \"%s\" " + "for channel \"%s\""), + weechat_prefix ("error"), pos_nick, + ptr_channel->name); } } else { if (!ignore) { - gui_chat_printf (ptr_buffer, "%s%s", - GUI_COLOR(GUI_COLOR_CHAT), pos_nick); + weechat_printf (ptr_buffer, "%s%s", + IRC_COLOR_CHAT, pos_nick); if (pos && pos[0]) - gui_chat_printf (ptr_buffer, " "); + weechat_printf (ptr_buffer, " "); } } } } if (ptr_channel) { - gui_nicklist_draw (ptr_channel->buffer, 1, 1); - gui_status_draw (ptr_channel->buffer, 1); + //gui_nicklist_draw (ptr_channel->buffer, 1, 1); + //gui_status_draw (ptr_channel->buffer, 1); } else { if (!ignore) - gui_chat_printf (ptr_buffer, "%s]\n", - GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS)); + weechat_printf (ptr_buffer, "%s]", IRC_COLOR_CHAT_DELIMITERS); } } else { - gui_chat_printf_error_nolog (server->buffer, - _("%s cannot parse \"%s\" command\n"), - weechat_prefix ("error"), "353"); + weechat_printf (server->buffer, + _("%sirc: cannot parse \"%s\" command"), + weechat_prefix ("error"), "353"); return WEECHAT_RC_ERROR; } + return WEECHAT_RC_OK; } @@ -4851,7 +4954,7 @@ irc_protocol_cmd_366 (struct t_irc_server *server, char *irc_message, char *host { char *pos, *pos2; struct t_irc_channel *ptr_channel; - struct t_irc_nick *ptr_nick; + //struct t_irc_nick *ptr_nick; int num_nicks, num_op, num_halfop, num_voice, num_normal; /* make C compiler happy */ @@ -4881,74 +4984,78 @@ irc_protocol_cmd_366 (struct t_irc_server *server, char *irc_message, char *host if (!ignore) { /* display users on channel */ - gui_chat_printf_server (ptr_channel->buffer, - _("Nicks %s%s%s: %s["), - GUI_COLOR(GUI_COLOR_CHAT_CHANNEL), - ptr_channel->name, - GUI_COLOR(GUI_COLOR_CHAT), - GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS)); + weechat_printf (ptr_channel->buffer, + _("Nicks %s%s%s: %s["), + IRC_COLOR_CHAT_CHANNEL, + ptr_channel->name, + IRC_COLOR_CHAT, + IRC_COLOR_CHAT_DELIMITERS); + /* for (ptr_nick = ptr_channel->nicks; ptr_nick; ptr_nick = ptr_nick->next_nick) { irc_display_nick (ptr_channel->buffer, ptr_nick, NULL, GUI_MSG_TYPE_MSG, 0, - GUI_COLOR(GUI_COLOR_CHAT), 1); + IRC_COLOR_CHAT, 1); if (ptr_nick != ptr_channel->last_nick) gui_chat_printf (ptr_channel->buffer, " "); } - gui_chat_printf (ptr_channel->buffer, "%s]\n", - GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS)); + */ + weechat_printf (ptr_channel->buffer, "%s]", + IRC_COLOR_CHAT_DELIMITERS); /* display number of nicks, ops, halfops & voices on the channel */ irc_nick_count (ptr_channel, &num_nicks, &num_op, &num_halfop, &num_voice, &num_normal); - gui_chat_printf_info (ptr_channel->buffer, - _("Channel %s%s%s: %s%d%s %s %s(%s%d%s %s, " - "%s%d%s %s, %s%d%s %s, %s%d%s %s%s)\n"), - GUI_COLOR(GUI_COLOR_CHAT_CHANNEL), - ptr_channel->name, - GUI_COLOR(GUI_COLOR_CHAT), - GUI_COLOR(GUI_COLOR_CHAT_CHANNEL), - num_nicks, - GUI_COLOR(GUI_COLOR_CHAT), - (num_nicks > 1) ? _("nicks") : _("nick"), - GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS), - GUI_COLOR(GUI_COLOR_CHAT_CHANNEL), - num_op, - GUI_COLOR(GUI_COLOR_CHAT), - (num_op > 1) ? _("ops") : _("op"), - GUI_COLOR(GUI_COLOR_CHAT_CHANNEL), - num_halfop, - GUI_COLOR(GUI_COLOR_CHAT), - (num_halfop > 1) ? _("halfops") : _("halfop"), - GUI_COLOR(GUI_COLOR_CHAT_CHANNEL), - num_voice, - GUI_COLOR(GUI_COLOR_CHAT), - (num_voice > 1) ? _("voices") : _("voice"), - GUI_COLOR(GUI_COLOR_CHAT_CHANNEL), - num_normal, - GUI_COLOR(GUI_COLOR_CHAT), - _("normal"), - GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS)); + weechat_printf (ptr_channel->buffer, + _("%sChannel %s%s%s: %s%d%s %s %s(%s%d%s %s, " + "%s%d%s %s, %s%d%s %s, %s%d%s %s%s)\n"), + weechat_prefix ("info"), + IRC_COLOR_CHAT_CHANNEL, + ptr_channel->name, + IRC_COLOR_CHAT, + IRC_COLOR_CHAT_CHANNEL, + num_nicks, + IRC_COLOR_CHAT, + (num_nicks > 1) ? _("nicks") : _("nick"), + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT_CHANNEL, + num_op, + IRC_COLOR_CHAT, + (num_op > 1) ? _("ops") : _("op"), + IRC_COLOR_CHAT_CHANNEL, + num_halfop, + IRC_COLOR_CHAT, + (num_halfop > 1) ? _("halfops") : _("halfop"), + IRC_COLOR_CHAT_CHANNEL, + num_voice, + IRC_COLOR_CHAT, + (num_voice > 1) ? _("voices") : _("voice"), + IRC_COLOR_CHAT_CHANNEL, + num_normal, + IRC_COLOR_CHAT, + _("normal"), + IRC_COLOR_CHAT_DELIMITERS); } - irc_cmd_mode_server (server, ptr_channel->name); + irc_command_mode_server (server, ptr_channel->name); irc_channel_check_away (server, ptr_channel, 1); } else { if (!ignore) { - gui_chat_printf_info (gui_current_window->buffer, - "%s%s%s: %s\n", - GUI_COLOR(GUI_COLOR_CHAT_CHANNEL), - pos, - GUI_COLOR(GUI_COLOR_CHAT), - pos2); + weechat_printf (server->buffer, + "%s%s%s: %s", + IRC_COLOR_CHAT_CHANNEL, + pos, + IRC_COLOR_CHAT, + pos2); } return WEECHAT_RC_OK; } } } + return WEECHAT_RC_OK; } @@ -4975,9 +5082,9 @@ irc_protocol_cmd_367 (struct t_irc_server *server, char *irc_message, char *host pos_channel = strchr (arguments, ' '); if (!pos_channel) { - gui_chat_printf_error_nolog (server->buffer, - _("%s cannot parse \"%s\" command\n"), - weechat_prefix ("error"), "367"); + weechat_printf (server->buffer, + _("%sirc: cannot parse \"%s\" command"), + weechat_prefix ("error"), "367"); return WEECHAT_RC_ERROR; } pos_channel[0] = '\0'; @@ -4989,9 +5096,9 @@ irc_protocol_cmd_367 (struct t_irc_server *server, char *irc_message, char *host pos_ban = strchr (pos_channel, ' '); if (!pos_ban) { - gui_chat_printf_error_nolog (server->buffer, - _("%s cannot parse \"%s\" command\n"), - weechat_prefix ("error"), "367"); + weechat_printf (server->buffer, + _("%sirc: cannot parse \"%s\" command"), + weechat_prefix ("error"), "367"); return WEECHAT_RC_ERROR; } pos_ban[0] = '\0'; @@ -5027,55 +5134,55 @@ irc_protocol_cmd_367 (struct t_irc_server *server, char *irc_message, char *host { if (pos_user) { - gui_chat_printf_info_nolog (buffer, - _("%s[%s%s%s] %s%s%s banned by "), - GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS), - GUI_COLOR(GUI_COLOR_CHAT_CHANNEL), - pos_channel, - GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS), - GUI_COLOR(GUI_COLOR_CHAT_HOST), - pos_ban, - GUI_COLOR(GUI_COLOR_CHAT)); + weechat_printf (buffer, + _("%s[%s%s%s] %s%s%s banned by "), + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT_CHANNEL, + pos_channel, + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT_HOST, + pos_ban, + IRC_COLOR_CHAT); pos = strchr (pos_user, '!'); if (pos) { pos[0] = '\0'; - gui_chat_printf (buffer, - "%s%s %s(%s%s%s)", - GUI_COLOR(GUI_COLOR_CHAT_NICK), - pos_user, - GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS), - GUI_COLOR(GUI_COLOR_CHAT_HOST), - pos + 1, - GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS)); + weechat_printf (buffer, + "%s%s %s(%s%s%s)", + IRC_COLOR_CHAT_NICK, + pos_user, + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT_HOST, + pos + 1, + IRC_COLOR_CHAT_DELIMITERS); } else - gui_chat_printf (buffer, - "%s%s", - GUI_COLOR(GUI_COLOR_CHAT_NICK), - pos_user); + weechat_printf (buffer, + "%s%s", + IRC_COLOR_CHAT_NICK, + pos_user); if (pos_date) { datetime = (time_t)(atol (pos_date)); - gui_chat_printf (buffer, - "%s, %s", - GUI_COLOR(GUI_COLOR_CHAT), - ctime (&datetime)); + weechat_printf (buffer, + "%s, %s", + IRC_COLOR_CHAT, + ctime (&datetime)); } - else - gui_chat_printf (buffer, "\n"); } else - gui_chat_printf_info_nolog (buffer, - _("%s[%s%s%s] %s%s%s banned\n"), - GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS), - GUI_COLOR(GUI_COLOR_CHAT_CHANNEL), - pos_channel, - GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS), - GUI_COLOR(GUI_COLOR_CHAT_HOST), - pos_ban, - GUI_COLOR(GUI_COLOR_CHAT)); - } + weechat_printf (buffer, + _("%s%s[%s%s%s] %s%s%s banned"), + weechat_prefix ("info"), + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT_CHANNEL, + pos_channel, + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT_HOST, + pos_ban, + IRC_COLOR_CHAT); + } + return WEECHAT_RC_OK; } @@ -5100,9 +5207,9 @@ irc_protocol_cmd_368 (struct t_irc_server *server, char *irc_message, char *host pos_channel = strchr (arguments, ' '); if (!pos_channel) { - gui_chat_printf_error_nolog (server->buffer, - _("%s cannot parse \"%s\" command\n"), - weechat_prefix ("error"), "368"); + weechat_printf (server->buffer, + _("%sirc: cannot parse \"%s\" command"), + weechat_prefix ("error"), "368"); return WEECHAT_RC_ERROR; } pos_channel[0] = '\0'; @@ -5113,9 +5220,9 @@ irc_protocol_cmd_368 (struct t_irc_server *server, char *irc_message, char *host pos_msg = strchr (pos_channel, ' '); if (!pos_msg) { - gui_chat_printf_error_nolog (server->buffer, - _("%s cannot parse \"%s\" command\n"), - weechat_prefix ("error"), "368"); + weechat_printf (server->buffer, + _("%sirc: cannot parse \"%s\" command"), + weechat_prefix ("error"), "368"); return WEECHAT_RC_ERROR; } pos_msg[0] = '\0'; @@ -5130,15 +5237,17 @@ irc_protocol_cmd_368 (struct t_irc_server *server, char *irc_message, char *host if (!ignore) { - gui_chat_printf_info_nolog (buffer, - "%s[%s%s%s] %s%s\n", - GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS), - GUI_COLOR(GUI_COLOR_CHAT_CHANNEL), - pos_channel, - GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS), - GUI_COLOR(GUI_COLOR_CHAT), - pos_msg); - } + weechat_printf (buffer, + "%s%s[%s%s%s] %s%s", + weechat_prefix ("info"), + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT_CHANNEL, + pos_channel, + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT, + pos_msg); + } + return WEECHAT_RC_OK; } @@ -5159,9 +5268,11 @@ irc_protocol_cmd_432 (struct t_irc_server *server, char *irc_message, char *host { if (strcmp (server->nick, server->nick1) == 0) { - gui_chat_printf_info (server->buffer, - _("%s: trying 2nd nickname \"%s\"\n"), - PACKAGE_NAME, server->nick2); + weechat_printf (server->buffer, + _("%sirc: nickname \"%s\" is invalid, " + "trying 2nd nickname \"%s\""), + weechat_prefix ("info"), server->nick, + server->nick2); free (server->nick); server->nick = strdup (server->nick2); } @@ -5169,9 +5280,11 @@ irc_protocol_cmd_432 (struct t_irc_server *server, char *irc_message, char *host { if (strcmp (server->nick, server->nick2) == 0) { - gui_chat_printf_info (server->buffer, - _("%s: trying 3rd nickname \"%s\"\n"), - PACKAGE_NAME, server->nick3); + weechat_printf (server->buffer, + _("%sirc: nickname \"%s\" is invalid, " + "trying 3rd nickname \"%s\""), + weechat_prefix ("info"), server->nick, + server->nick3); free (server->nick); server->nick = strdup (server->nick3); } @@ -5179,19 +5292,21 @@ irc_protocol_cmd_432 (struct t_irc_server *server, char *irc_message, char *host { if (strcmp (server->nick, server->nick3) == 0) { - gui_chat_printf_info (server->buffer, - _("%s: all declared nicknames are already in " - "use or invalid, closing connection with " - "server!\n"), - PACKAGE_NAME); + weechat_printf (server->buffer, + _("%sirc: all declared nicknames are " + "already in use or invalid, closing " + "connection with server!"), + weechat_prefix ("error")); irc_server_disconnect (server, 1); return WEECHAT_RC_OK; } else { - gui_chat_printf_info (server->buffer, - _("%s: trying 1st nickname \"%s\"\n"), - PACKAGE_NAME, server->nick1); + weechat_printf (server->buffer, + _("%sirc: nickname \"%s\" is invalid, " + "trying 1st nickname \"%s\""), + weechat_prefix ("info"), server->nick, + server->nick1); free (server->nick); server->nick = strdup (server->nick1); } @@ -5199,6 +5314,7 @@ irc_protocol_cmd_432 (struct t_irc_server *server, char *irc_message, char *host } irc_server_sendf (server, "NICK %s", server->nick); } + return WEECHAT_RC_OK; } @@ -5216,10 +5332,11 @@ irc_protocol_cmd_433 (struct t_irc_server *server, char *irc_message, char *host { if (strcmp (server->nick, server->nick1) == 0) { - gui_chat_printf_info (server->buffer, - _("%s: nickname \"%s\" is already in use, " - "trying 2nd nickname \"%s\"\n"), - PACKAGE_NAME, server->nick, server->nick2); + weechat_printf (server->buffer, + _("%sirc: nickname \"%s\" is already in use, " + "trying 2nd nickname \"%s\""), + weechat_prefix ("info"), server->nick, + server->nick2); free (server->nick); server->nick = strdup (server->nick2); } @@ -5227,10 +5344,10 @@ irc_protocol_cmd_433 (struct t_irc_server *server, char *irc_message, char *host { if (strcmp (server->nick, server->nick2) == 0) { - gui_chat_printf_info (server->buffer, - _("%s: nickname \"%s\" is already in use, " - "trying 3rd nickname \"%s\"\n"), - PACKAGE_NAME, server->nick, server->nick3); + weechat_printf (server->buffer, + _("%sirc: nickname \"%s\" is already in use, " + "trying 3rd nickname \"%s\""), + PACKAGE_NAME, server->nick, server->nick3); free (server->nick); server->nick = strdup (server->nick3); } @@ -5238,18 +5355,19 @@ irc_protocol_cmd_433 (struct t_irc_server *server, char *irc_message, char *host { if (strcmp (server->nick, server->nick3) == 0) { - gui_chat_printf_error (server->buffer, - _("%s: all declared nicknames are already in use, " - "closing connection with server!\n"), - PACKAGE_NAME); + weechat_printf (server->buffer, + _("%sirc: all declared nicknames are " + "already in use, closing connection " + "with server!"), + weechat_prefix ("error")); irc_server_disconnect (server, 1); return WEECHAT_RC_OK; } else { - gui_chat_printf_info (server->buffer, - _("%s: nickname \"%s\" is already in use, " - "trying 1st nickname \"%s\"\n"), + weechat_printf (server->buffer, + _("%sirc: nickname \"%s\" is already in use, " + "trying 1st nickname \"%s\""), PACKAGE_NAME, server->nick, server->nick1); free (server->nick); server->nick = strdup (server->nick1); @@ -5295,18 +5413,19 @@ irc_protocol_cmd_438 (struct t_irc_server *server, char *irc_message, char *host { pos2[0] = '\0'; pos2 += 2; - gui_chat_printf_server (server->buffer, - "%s (%s => %s)\n", - pos2, arguments, pos); + weechat_printf (server->buffer, + "%s (%s => %s)", + pos2, arguments, pos); } else - gui_chat_printf_server (server->buffer, - "%s (%s)\n", - pos, arguments); + weechat_printf (server->buffer, + "%s (%s)", + pos, arguments); } else - gui_chat_printf_server (server->buffer, "%s\n", arguments); + weechat_printf (server->buffer, "%s", arguments); } + return WEECHAT_RC_OK; } @@ -5343,16 +5462,17 @@ irc_protocol_cmd_671 (struct t_irc_server *server, char *irc_message, char *host if (pos_message[0] == ':') pos_message++; - gui_chat_printf_server (server->buffer, - "%s[%s%s%s] %s%s\n", - GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS), - GUI_COLOR(GUI_COLOR_CHAT_NICK), - pos_nick, - GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS), - GUI_COLOR(GUI_COLOR_CHAT), - pos_message); + weechat_printf (server->buffer, + "%s[%s%s%s] %s%s", + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT_NICK, + pos_nick, + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT, + pos_message); } } } + return WEECHAT_RC_OK; } diff --git a/src/plugins/irc/irc-server.c b/src/plugins/irc/irc-server.c index e47e869c6..2896cdf80 100644 --- a/src/plugins/irc/irc-server.c +++ b/src/plugins/irc/irc-server.c @@ -49,6 +49,7 @@ #include "irc-channel.h" #include "irc-config.h" #include "irc-nick.h" +#include "irc-protocol.h" struct t_irc_server *irc_servers = NULL; @@ -1227,7 +1228,7 @@ irc_server_msgq_flush () irc_server_parse_message (ptr_msg, &host, &command, &args); - /*switch (irc_protocol_recv_command (irc_recv_msgq->server, + switch (irc_protocol_recv_command (irc_recv_msgq->server, ptr_msg, host, command, args)) { @@ -1254,7 +1255,7 @@ irc_server_msgq_flush () command, host, args); break; } - */ + if (host) free (host); if (command) diff --git a/src/plugins/irc/irc.c b/src/plugins/irc/irc.c index 35cb7d3e5..cf7a298c0 100644 --- a/src/plugins/irc/irc.c +++ b/src/plugins/irc/irc.c @@ -31,6 +31,7 @@ #include "irc.h" #include "irc-command.h" +#include "irc-completion.h" #include "irc-config.h" #include "irc-server.h" @@ -41,8 +42,8 @@ char plugin_description[] = "IRC (Internet Relay Chat)"; struct t_weechat_plugin *weechat_irc_plugin = NULL; -struct t_hook *irc_timer = NULL; -struct t_hook *irc_timer_check_away = NULL; +struct t_hook *irc_hook_timer = NULL; +struct t_hook *irc_hook_timer_check_away = NULL; #ifdef HAVE_GNUTLS gnutls_certificate_credentials gnutls_xcred; /* gnutls client credentials */ @@ -163,10 +164,25 @@ weechat_plugin_init (struct t_weechat_plugin *plugin) irc_command_init (); + /* hook events */ weechat_hook_event ("config_reload", &irc_config_reload_cb, NULL); - weechat_hook_event ("quit", &irc_quit_cb, NULL); + /* hook completions */ + weechat_hook_completion ("irc_server", &irc_completion_server_cb, NULL); + weechat_hook_completion ("irc_server_nicks", + &irc_completion_server_nicks_cb, NULL); + weechat_hook_completion ("irc_servers", &irc_completion_servers_cb, NULL); + weechat_hook_completion ("irc_channel", &irc_completion_channel_cb, NULL); + weechat_hook_completion ("irc_channel_nicks", + &irc_completion_channel_nicks_cb, NULL); + weechat_hook_completion ("irc_channel_nicks_hosts", + &irc_completion_channel_nicks_hosts_cb, NULL); + weechat_hook_completion ("irc_channel_topic", + &irc_completion_channel_topic_cb, NULL); + weechat_hook_completion ("irc_channels", &irc_completion_channels_cb, NULL); + weechat_hook_completion ("irc_msg_part", &irc_completion_msg_part_cb, NULL); + //irc_server_auto_connect (1, 0); /* @@ -190,23 +206,12 @@ weechat_plugin_init (struct t_weechat_plugin *plugin) int weechat_plugin_end () { - if (irc_timer) - { - weechat_unhook (irc_timer); - irc_timer = NULL; - } - if (irc_timer_check_away) - { - weechat_unhook (irc_timer_check_away); - irc_timer_check_away = NULL; - } + irc_config_write (); - //irc_server_disconnect_all (); + irc_server_disconnect_all (); //irc_dcc_end (); - //irc_server_free_all (); + irc_server_free_all (); - irc_config_write (); - #ifdef HAVE_GNUTLS /* GnuTLS end */ gnutls_certificate_free_credentials (gnutls_xcred); diff --git a/src/plugins/irc/irc.h b/src/plugins/irc/irc.h index 9087a7529..c859c0760 100644 --- a/src/plugins/irc/irc.h +++ b/src/plugins/irc/irc.h @@ -28,15 +28,44 @@ #define weechat_plugin weechat_irc_plugin +#define IRC_GET_SERVER(__buffer) \ + struct t_weechat_plugin *buffer_plugin = NULL; \ + struct t_irc_server *ptr_server = NULL; \ + buffer_plugin = weechat_buffer_get (__buffer, "plugin"); \ + if (buffer_plugin == weechat_irc_plugin) \ + ptr_server = irc_server_search ( \ + weechat_buffer_get (__buffer, "category")); + +#define IRC_GET_SERVER_CHANNEL(__buffer) \ + struct t_weechat_plugin *buffer_plugin = NULL; \ + struct t_irc_server *ptr_server = NULL; \ + struct t_irc_channel *ptr_channel = NULL; \ + buffer_plugin = weechat_buffer_get (__buffer, "plugin"); \ + if (buffer_plugin == weechat_irc_plugin) \ + { \ + ptr_server = irc_server_search ( \ + weechat_buffer_get (__buffer, "category")); \ + ptr_channel = irc_channel_search ( \ + ptr_server, weechat_buffer_get (__buffer, "name")); \ + } + #define IRC_COLOR_CHAT weechat_color("color_chat") #define IRC_COLOR_CHAT_CHANNEL weechat_color("color_chat_channel") #define IRC_COLOR_CHAT_DELIMITERS weechat_color("color_chat_delimiters") +#define IRC_COLOR_CHAT_HIGHLIGHT weechat_color("color_chat_highlight") #define IRC_COLOR_CHAT_HOST weechat_color("color_chat_host") #define IRC_COLOR_CHAT_NICK weechat_color("color_chat_nick") +#define IRC_COLOR_CHAT_NICK_OTHER weechat_color("color_chat_nick_other") #define IRC_COLOR_CHAT_SERVER weechat_color("color_chat_server") +#define IRC_COLOR_INFOBAR_HIGHLIGHT weechat_color("color_infobar_highlight") +#define IRC_COLOR_NICKLIST_PREFIX1 weechat_color("color_nicklist_prefix1") +#define IRC_COLOR_NICKLIST_PREFIX2 weechat_color("color_nicklist_prefix2") +#define IRC_COLOR_NICKLIST_PREFIX3 weechat_color("color_nicklist_prefix3") +#define IRC_COLOR_NICKLIST_PREFIX4 weechat_color("color_nicklist_prefix4") +#define IRC_COLOR_NICKLIST_PREFIX5 weechat_color("color_nicklist_prefix5") extern struct t_weechat_plugin *weechat_irc_plugin; -extern struct t_hook *irc_timer_check_away; +extern struct t_hook *irc_hook_timer_check_away; extern gnutls_certificate_credentials gnutls_xcred; diff --git a/src/plugins/plugin-api.c b/src/plugins/plugin-api.c index 85d87b952..f957b7b2d 100644 --- a/src/plugins/plugin-api.c +++ b/src/plugins/plugin-api.c @@ -1235,33 +1235,35 @@ plugin_api_log_printf (struct t_weechat_plugin *plugin, char *format, ...) } /* - * plugin_api_print_infobar: print a message in infobar + * plugin_api_infobar_printf: print a message in infobar */ void -plugin_api_print_infobar (struct t_weechat_plugin *plugin, int time_displayed, - char *message, ...) +plugin_api_infobar_printf (struct t_weechat_plugin *plugin, int time_displayed, + char *color_name, char *format, ...) { - (void) plugin; - (void) time_displayed; - (void) message; - - /*va_list argptr; + va_list argptr; static char buf[1024]; char *buf2; + int num_color; - if (!plugin || (time_displayed < 0) || !message) + if (!plugin || (time_displayed < 0) || !format) return; - va_start (argptr, message); - vsnprintf (buf, sizeof (buf) - 1, message, argptr); + va_start (argptr, format); + vsnprintf (buf, sizeof (buf) - 1, format, argptr); va_end (argptr); buf2 = string_iconv_to_internal (plugin->charset, buf); - gui_infobar_printf (time_displayed, GUI_COLOR_WIN_INFOBAR, "%s", + num_color = gui_color_search_config (color_name); + if (num_color < 0) + num_color = GUI_COLOR_INFOBAR; + gui_infobar_printf (time_displayed, + num_color, + "%s", (buf2) ? buf2 : buf); if (buf2) - free (buf2);*/ + free (buf2); } /* @@ -1284,7 +1286,7 @@ plugin_api_infobar_remove (struct t_weechat_plugin *plugin, int how_many) how_many--; } } - gui_infobar_draw (gui_current_window->buffer, 1); + //gui_infobar_draw (gui_current_window->buffer, 1); } /* @@ -1402,7 +1404,7 @@ plugin_api_hook_config (struct t_weechat_plugin *plugin, char *config_type, struct t_hook * plugin_api_hook_completion (struct t_weechat_plugin *plugin, char *completion, - int (*callback)(void *, char *, void *), + int (*callback)(void *, char *, void *, void *), void *data) { if (plugin && callback) diff --git a/src/plugins/plugin-api.h b/src/plugins/plugin-api.h index 1f7a227eb..e67cd0680 100644 --- a/src/plugins/plugin-api.h +++ b/src/plugins/plugin-api.h @@ -136,8 +136,8 @@ extern void plugin_api_printf (struct t_weechat_plugin *, void *, extern void plugin_api_printf_date (struct t_weechat_plugin *, void *, time_t, char *, ...); extern void plugin_api_log_printf (struct t_weechat_plugin *, char *, ...); -extern void plugin_api_print_infobar (struct t_weechat_plugin *, int, - char *, ...); +extern void plugin_api_infobar_printf (struct t_weechat_plugin *, int, char *, + char *, ...); extern void plugin_api_infobar_remove (struct t_weechat_plugin *, int); /* hooks */ @@ -165,7 +165,7 @@ extern struct t_hook *plugin_api_hook_config (struct t_weechat_plugin *, void *); extern struct t_hook *plugin_api_hook_completion (struct t_weechat_plugin *, char *, - int (*)(void *, char *, void *), + int (*)(void *, char *, void *, void *), void *); extern void plugin_api_unhook (struct t_weechat_plugin *, void *); extern void plugin_api_unhook_all (struct t_weechat_plugin *); diff --git a/src/plugins/plugin.c b/src/plugins/plugin.c index b085195e5..a625a1eb5 100644 --- a/src/plugins/plugin.c +++ b/src/plugins/plugin.c @@ -296,7 +296,7 @@ plugin_load (char *filename) new_plugin->printf = &plugin_api_printf; new_plugin->printf_date = &plugin_api_printf_date; new_plugin->log_printf = &plugin_api_log_printf; - new_plugin->print_infobar = &plugin_api_print_infobar; + new_plugin->infobar_printf = &plugin_api_infobar_printf; new_plugin->infobar_remove = &plugin_api_infobar_remove; new_plugin->hook_command = &plugin_api_hook_command; diff --git a/src/plugins/weechat-plugin.h b/src/plugins/weechat-plugin.h index da2ae45d3..136fade94 100644 --- a/src/plugins/weechat-plugin.h +++ b/src/plugins/weechat-plugin.h @@ -151,7 +151,8 @@ struct t_weechat_plugin void (*printf_date) (struct t_weechat_plugin *, void *, time_t, char *, ...); void (*log_printf) (struct t_weechat_plugin *, char *, ...); - void (*print_infobar) (struct t_weechat_plugin *, int, char *, ...); + void (*infobar_printf) (struct t_weechat_plugin *, int, char *, + char *, ...); void (*infobar_remove) (struct t_weechat_plugin *, int); /* hooks */ @@ -173,7 +174,7 @@ struct t_weechat_plugin int (*)(void *, char *, char *, char *), void *); struct t_hook *(*hook_completion) (struct t_weechat_plugin *, char *, - int (*)(void *, char *, void *), + int (*)(void *, char *, void *, void *), void *); void (*unhook) (struct t_weechat_plugin *, void *); void (*unhook_all) (struct t_weechat_plugin *); @@ -392,6 +393,11 @@ struct t_weechat_plugin ##__argz) #define weechat_log_printf(__argz...) \ weechat_plugin->log_printf(weechat_plugin, ##__argz) +#define weechat_infobar_printf(__delay, __color, __argz...) \ + weechat_plugin->infobar_printf(weechat_plugin, __delay, __color, \ + ##__argz) +#define weechat_infobar_remove(__number) \ + weechat_plugin->infobar_remove(weechat_plugin, __number) /* hooks */ #define weechat_hook_command(__command, __description, __args, \ |