diff options
-rw-r--r-- | po/cs.po | 6 | ||||
-rw-r--r-- | po/de.po | 6 | ||||
-rw-r--r-- | po/es.po | 6 | ||||
-rw-r--r-- | po/fr.po | 8 | ||||
-rw-r--r-- | po/hu.po | 6 | ||||
-rw-r--r-- | po/ru.po | 6 | ||||
-rw-r--r-- | po/weechat.pot | 6 | ||||
-rw-r--r-- | src/core/wee-string.c | 11 | ||||
-rw-r--r-- | src/gui/gui-chat.c | 20 | ||||
-rw-r--r-- | src/gui/gui-chat.h | 2 | ||||
-rw-r--r-- | src/gui/gui-color.c | 33 | ||||
-rw-r--r-- | src/gui/gui-color.h | 3 | ||||
-rw-r--r-- | src/gui/gui-nicklist.c | 6 | ||||
-rw-r--r-- | src/plugins/irc/irc-nick.h | 4 | ||||
-rw-r--r-- | src/plugins/irc/irc-protocol.c | 91 | ||||
-rw-r--r-- | src/plugins/irc/irc-server.c | 11 | ||||
-rw-r--r-- | src/plugins/logger/logger.c | 37 | ||||
-rw-r--r-- | src/plugins/plugin-api.c | 89 | ||||
-rw-r--r-- | src/plugins/scripts/script-api.c | 31 |
19 files changed, 313 insertions, 69 deletions
@@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.2.7-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2008-04-18 15:36+0200\n" +"POT-Creation-Date: 2008-04-19 10:27+0200\n" "PO-Revision-Date: 2007-09-06 12:44+0200\n" "Last-Translator: Jiri Golembiovsky <golemj@gmail.com>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -3715,6 +3715,10 @@ msgid "%sNicks %s%s%s: %s[%s%s%s]" msgstr "%sServer: %s%s %s[%s%s%s]\n" #, fuzzy, c-format +msgid "%sNicks %s%s%s: %s[%s%s]" +msgstr "%sServer: %s%s %s[%s%s%s]\n" + +#, fuzzy, c-format msgid "" "%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)" msgstr "" @@ -9,7 +9,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.2.7-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2008-04-18 15:36+0200\n" +"POT-Creation-Date: 2008-04-19 10:27+0200\n" "PO-Revision-Date: 2007-09-06 12:44+0200\n" "Last-Translator: Thomas Schuetz <i18n@internet-villa.de>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -3703,6 +3703,10 @@ msgid "%sNicks %s%s%s: %s[%s%s%s]" msgstr "%sServer: %s%s %s[%s%s%s]\n" #, fuzzy, c-format +msgid "%sNicks %s%s%s: %s[%s%s]" +msgstr "%sServer: %s%s %s[%s%s%s]\n" + +#, fuzzy, c-format msgid "" "%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)" msgstr "" @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.2.7-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2008-04-18 15:36+0200\n" +"POT-Creation-Date: 2008-04-19 10:27+0200\n" "PO-Revision-Date: 2007-09-19 12:09+0200\n" "Last-Translator: Roberto González Cardenete <robert.glez@gmail.com>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -3707,6 +3707,10 @@ msgid "%sNicks %s%s%s: %s[%s%s%s]" msgstr "%sServidor:%s%s %s[%s%s%s]\n" #, fuzzy, c-format +msgid "%sNicks %s%s%s: %s[%s%s]" +msgstr "%sServidor:%s%s %s[%s%s%s]\n" + +#, fuzzy, c-format msgid "" "%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)" msgstr "" @@ -6,8 +6,8 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.2.7-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2008-04-18 15:36+0200\n" -"PO-Revision-Date: 2008-04-18 15:36+0200\n" +"POT-Creation-Date: 2008-04-19 10:27+0200\n" +"PO-Revision-Date: 2008-04-19 10:28+0200\n" "Last-Translator: FlashCode <flashcode@flashtux.org>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" "MIME-Version: 1.0\n" @@ -3646,6 +3646,10 @@ msgid "%sNicks %s%s%s: %s[%s%s%s]" msgstr "%sPseudos %s%s%s: %s[%s%s%s]" #, c-format +msgid "%sNicks %s%s%s: %s[%s%s]" +msgstr "%sPseudos %s%s%s: %s[%s%s]" + +#, c-format msgid "" "%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)" msgstr "" @@ -12,7 +12,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.2.7-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2008-04-18 15:36+0200\n" +"POT-Creation-Date: 2008-04-19 10:27+0200\n" "PO-Revision-Date: 2007-10-10 18:07+0200\n" "Last-Translator: Andras Voroskoi <voroskoi@frugalware.org>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -3721,6 +3721,10 @@ msgid "%sNicks %s%s%s: %s[%s%s%s]" msgstr "%s Szerver: %s%s %s[%s%s%s]\n" #, fuzzy, c-format +msgid "%sNicks %s%s%s: %s[%s%s]" +msgstr "%s Szerver: %s%s %s[%s%s%s]\n" + +#, fuzzy, c-format msgid "" "%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)" msgstr "" @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.2.7-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2008-04-18 15:36+0200\n" +"POT-Creation-Date: 2008-04-19 10:27+0200\n" "PO-Revision-Date: 2007-09-06 12:44+0200\n" "Last-Translator: Pavel Shevchuk <stlwrt@gmail.com>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -3711,6 +3711,10 @@ msgid "%sNicks %s%s%s: %s[%s%s%s]" msgstr "%sСервер: %s%s %s[%s%s%s]\n" #, fuzzy, c-format +msgid "%sNicks %s%s%s: %s[%s%s]" +msgstr "%sСервер: %s%s %s[%s%s%s]\n" + +#, fuzzy, c-format msgid "" "%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)" msgstr "" diff --git a/po/weechat.pot b/po/weechat.pot index 2f7849a15..b878851c4 100644 --- a/po/weechat.pot +++ b/po/weechat.pot @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2008-04-18 15:36+0200\n" +"POT-Creation-Date: 2008-04-19 10:27+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Language-Team: LANGUAGE <LL@li.org>\n" @@ -3167,6 +3167,10 @@ msgid "%sNicks %s%s%s: %s[%s%s%s]" msgstr "" #, c-format +msgid "%sNicks %s%s%s: %s[%s%s]" +msgstr "" + +#, c-format msgid "" "%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)" msgstr "" diff --git a/src/core/wee-string.c b/src/core/wee-string.c index 1c6a33669..f3d05be67 100644 --- a/src/core/wee-string.c +++ b/src/core/wee-string.c @@ -992,15 +992,20 @@ void string_iconv_fprintf (FILE *file, char *data, ...) { va_list argptr; - static char buf[4096]; - char *buf2; + char *buf, *buf2; + + buf = malloc (128 * 1024); + if (!buf) + return; va_start (argptr, data); - vsnprintf (buf, sizeof (buf) - 1, data, argptr); + vsnprintf (buf, 128 * 1024, data, argptr); va_end (argptr); buf2 = string_iconv_from_internal (NULL, buf); fprintf (file, "%s", (buf2) ? buf2 : buf); + + free (buf); if (buf2) free (buf2); } diff --git a/src/gui/gui-chat.c b/src/gui/gui-chat.c index 42c08b144..921699d4e 100644 --- a/src/gui/gui-chat.c +++ b/src/gui/gui-chat.c @@ -794,7 +794,7 @@ void gui_chat_printf_date_tags (struct t_gui_buffer *buffer, time_t date, char *tags, char *message, ...) { - char buf[8192]; + char *buf; va_list argptr; time_t date_printed; int display_time; @@ -819,8 +819,12 @@ gui_chat_printf_date_tags (struct t_gui_buffer *buffer, time_t date, return; } + buf = malloc (GUI_CHAT_BUFFER_PRINTF_SIZE); + if (!buf) + return; + va_start (argptr, message); - vsnprintf (buf, sizeof (buf) - 1, message, argptr); + vsnprintf (buf, GUI_CHAT_BUFFER_PRINTF_SIZE, message, argptr); va_end (argptr); utf8_normalize (buf, '?'); @@ -896,6 +900,8 @@ gui_chat_printf_date_tags (struct t_gui_buffer *buffer, time_t date, gui_status_refresh_needed = 1; } } + + free (buf); } /* @@ -907,7 +913,7 @@ gui_chat_printf_date_tags (struct t_gui_buffer *buffer, time_t date, void gui_chat_printf_y (struct t_gui_buffer *buffer, int y, char *message, ...) { - char buf[8192]; + char *buf; va_list argptr; struct t_gui_line *ptr_line; @@ -944,8 +950,12 @@ gui_chat_printf_y (struct t_gui_buffer *buffer, int y, char *message, ...) else { /* with message: create line or merge content with existing line */ + buf = malloc (GUI_CHAT_BUFFER_PRINTF_SIZE); + if (!buf) + return; + va_start (argptr, message); - vsnprintf (buf, sizeof (buf) - 1, message, argptr); + vsnprintf (buf, GUI_CHAT_BUFFER_PRINTF_SIZE, message, argptr); va_end (argptr); utf8_normalize (buf, '?'); @@ -957,5 +967,7 @@ gui_chat_printf_y (struct t_gui_buffer *buffer, int y, char *message, ...) } else string_iconv_fprintf (stdout, "%s\n", buf); + + free (buf); } } diff --git a/src/gui/gui-chat.h b/src/gui/gui-chat.h index 685d9fb94..dcf0617f4 100644 --- a/src/gui/gui-chat.h +++ b/src/gui/gui-chat.h @@ -26,6 +26,8 @@ struct t_gui_window; struct t_gui_buffer; struct t_gui_line; +#define GUI_CHAT_BUFFER_PRINTF_SIZE (128*1024) + #define gui_chat_printf(buffer, argz...) \ gui_chat_printf_date_tags(buffer, 0, NULL, ##argz) diff --git a/src/gui/gui-color.c b/src/gui/gui-color.c index 2df69ca80..0cb4b5261 100644 --- a/src/gui/gui-color.c +++ b/src/gui/gui-color.c @@ -43,12 +43,12 @@ struct t_gui_color *gui_color[GUI_COLOR_NUM_COLORS]; /* GUI colors */ /* - * gui_color_search_config: search a color with configuration option name - * return color found (number >= 0), -1 if not found + * gui_color_search_config_int: search a color with configuration option name + * return color found (number >= 0), -1 if not found */ int -gui_color_search_config (char *color_name) +gui_color_search_config_int (char *color_name) { struct t_config_section *ptr_section; struct t_config_option *ptr_option; @@ -73,6 +73,33 @@ gui_color_search_config (char *color_name) } /* + * gui_color_search_config_str: search a color configuration name with number + * return color configuration name, NULL if not found + */ + +char * +gui_color_search_config_str (int color_number) +{ + struct t_config_section *ptr_section; + struct t_config_option *ptr_option; + + ptr_section = config_file_search_section (weechat_config_file, + "color"); + if (ptr_section) + { + for (ptr_option = ptr_section->options; ptr_option; + ptr_option = ptr_option->next_option) + { + if (ptr_option->min == color_number) + return ptr_option->name; + } + } + + /* color not found */ + return NULL; +} + +/* * gui_color_decode: parses a message and remove WeeChat color codes * After use, string returned has to be free() */ diff --git a/src/gui/gui-color.h b/src/gui/gui-color.h index e36660f08..513d77206 100644 --- a/src/gui/gui-color.h +++ b/src/gui/gui-color.h @@ -145,7 +145,8 @@ extern struct t_gui_color *gui_color[]; /* color functions */ -extern int gui_color_search_config (char *color_name); +extern int gui_color_search_config_int (char *color_name); +extern char *gui_color_search_config_str (int color_number); extern unsigned char *gui_color_decode (unsigned char *string); extern void gui_color_free (struct t_gui_color *color); diff --git a/src/gui/gui-nicklist.c b/src/gui/gui-nicklist.c index 63ab79fb1..b3b0cd1e9 100644 --- a/src/gui/gui-nicklist.c +++ b/src/gui/gui-nicklist.c @@ -163,7 +163,7 @@ gui_nicklist_add_group (struct t_gui_buffer *buffer, if (color) { - num_color = gui_color_search_config (color); + num_color = gui_color_search_config_int (color); if (num_color < 0) num_color = GUI_COLOR_NICKLIST; } @@ -310,7 +310,7 @@ gui_nicklist_add_nick (struct t_gui_buffer *buffer, if (color) { - num_color = gui_color_search_config (color); + num_color = gui_color_search_config_int (color); if (num_color < 0) num_color = GUI_COLOR_NICKLIST; } @@ -319,7 +319,7 @@ gui_nicklist_add_nick (struct t_gui_buffer *buffer, if (prefix_color) { - num_color_prefix = gui_color_search_config (prefix_color); + num_color_prefix = gui_color_search_config_int (prefix_color); if (num_color_prefix < 0) num_color_prefix = GUI_COLOR_NICKLIST; } diff --git a/src/plugins/irc/irc-nick.h b/src/plugins/irc/irc-nick.h index cd34d39d8..329cf87c5 100644 --- a/src/plugins/irc/irc-nick.h +++ b/src/plugins/irc/irc-nick.h @@ -56,6 +56,10 @@ struct t_irc_nick struct t_irc_nick *next_nick; /* link to next nick on channel */ }; +extern void irc_nick_get_gui_infos (struct t_gui_buffer *buffer, + struct t_irc_nick *nick, + char *prefix, int *color_prefix, + struct t_gui_nick_group **group); extern struct t_irc_nick *irc_nick_new (struct t_irc_server *server, struct t_irc_channel *channel, char *nick_name, int is_chanowner, diff --git a/src/plugins/irc/irc-protocol.c b/src/plugins/irc/irc-protocol.c index d1d592576..d4ac892d9 100644 --- a/src/plugins/irc/irc-protocol.c +++ b/src/plugins/irc/irc-protocol.c @@ -3975,20 +3975,22 @@ irc_protocol_cmd_353 (struct t_irc_server *server, char *command, } } } - - weechat_printf_tags ((ptr_channel && ptr_channel->nicks) ? - ptr_channel->buffer : server->buffer, - irc_protocol_tags (command, "irc_numeric"), - _("%sNicks %s%s%s: %s[%s%s%s]"), - weechat_prefix ("network"), - IRC_COLOR_CHAT_CHANNEL, - pos_channel, - IRC_COLOR_CHAT, - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT, - (argv_eol[args][0] == ':') ? - argv_eol[args] + 1 : argv_eol[args], - IRC_COLOR_CHAT_DELIMITERS); + + if (!ptr_channel) + { + weechat_printf_tags (server->buffer, + irc_protocol_tags (command, "irc_numeric"), + _("%sNicks %s%s%s: %s[%s%s%s]"), + weechat_prefix ("network"), + IRC_COLOR_CHAT_CHANNEL, + pos_channel, + IRC_COLOR_CHAT, + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT, + (argv_eol[args][0] == ':') ? + argv_eol[args] + 1 : argv_eol[args], + IRC_COLOR_CHAT_DELIMITERS); + } return WEECHAT_RC_OK; } @@ -4003,7 +4005,9 @@ irc_protocol_cmd_366 (struct t_irc_server *server, char *command, int highlight) { struct t_irc_channel *ptr_channel; - int num_nicks, num_op, num_halfop, num_voice, num_normal; + struct t_plugin_infolist *infolist; + int num_nicks, num_op, num_halfop, num_voice, num_normal, length, i; + char *string, *prefix; /* 366 message looks like: :server 366 mynick #channel :End of /NAMES list. @@ -4017,6 +4021,63 @@ irc_protocol_cmd_366 (struct t_irc_server *server, char *command, ptr_channel = irc_channel_search (server, argv[3]); if (ptr_channel && ptr_channel->nicks) { + /* display users on channel */ + infolist = weechat_infolist_get ("nicklist", ptr_channel->buffer, NULL); + if (infolist) + { + length = 0; + while (weechat_infolist_next (infolist)) + { + if (strcmp (weechat_infolist_string (infolist, "type"), + "nick") == 0) + { + length += + strlen (weechat_infolist_string (infolist, "prefix_color")) + + strlen (weechat_infolist_string (infolist, "prefix")) + + strlen (IRC_COLOR_CHAT) + + strlen (weechat_infolist_string (infolist, "name")) + 1; + } + } + string = malloc (length); + if (string) + { + string[0] = '\0'; + i = 0; + while (weechat_infolist_next (infolist)) + { + if (strcmp (weechat_infolist_string (infolist, "type"), + "nick") == 0) + { + if (i > 0) + strcat (string, " "); + prefix = weechat_infolist_string (infolist, "prefix"); + if (prefix[0] && (prefix[0] != ' ')) + { + strcat (string, + weechat_color (weechat_infolist_string (infolist, + "prefix_color"))); + strcat (string, prefix); + } + strcat (string, IRC_COLOR_CHAT); + strcat (string, weechat_infolist_string (infolist, "name")); + i++; + } + } + weechat_printf_tags (ptr_channel->buffer, + irc_protocol_tags (command, "irc_numeric"), + _("%sNicks %s%s%s: %s[%s%s]"), + weechat_prefix ("network"), + IRC_COLOR_CHAT_CHANNEL, + ptr_channel->name, + IRC_COLOR_CHAT, + IRC_COLOR_CHAT_DELIMITERS, + string, + IRC_COLOR_CHAT_DELIMITERS); + free (string); + } + weechat_infolist_free (infolist); + } + /* 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); diff --git a/src/plugins/irc/irc-server.c b/src/plugins/irc/irc-server.c index 3e0326a9d..eb12f0abe 100644 --- a/src/plugins/irc/irc-server.c +++ b/src/plugins/irc/irc-server.c @@ -1123,10 +1123,10 @@ irc_server_outqueue_send (struct t_irc_server *server) server->outqueue->message_after_mod); if (pos) pos[0] = '\r'; + irc_server_send (server, server->outqueue->message_after_mod, + strlen (server->outqueue->message_after_mod)); + server->last_user_message = time_now; } - irc_server_send (server, server->outqueue->message_after_mod, - strlen (server->outqueue->message_after_mod)); - server->last_user_message = time_now; irc_server_outqueue_free (server, server->outqueue); } } @@ -1687,12 +1687,11 @@ int irc_server_recv_cb (void *arg_server) { struct t_irc_server *server; - - server = (struct t_irc_server *)arg_server; - static char buffer[4096 + 2]; int num_read; + server = (struct t_irc_server *)arg_server; + if (!server) return WEECHAT_RC_ERROR; diff --git a/src/plugins/logger/logger.c b/src/plugins/logger/logger.c index df6be59f3..add0c81a3 100644 --- a/src/plugins/logger/logger.c +++ b/src/plugins/logger/logger.c @@ -283,7 +283,7 @@ void logger_write_line (struct t_logger_buffer *logger_buffer, char *format, ...) { va_list argptr; - char buf[4096], *charset, *message; + char *buf, *charset, *message; time_t seconds; struct tm *date_tmp; char buf_time[256]; @@ -304,9 +304,10 @@ logger_write_line (struct t_logger_buffer *logger_buffer, char *format, ...) logger_buffer->log_filename); free (logger_buffer->log_filename); logger_buffer->log_filename = NULL; + free (buf); return; } - + if (logger_option_info_lines) { seconds = time (NULL); @@ -326,19 +327,25 @@ logger_write_line (struct t_logger_buffer *logger_buffer, char *format, ...) free (message); } } - - va_start (argptr, format); - vsnprintf (buf, sizeof (buf) - 1, format, argptr); - va_end (argptr); - - message = (charset) ? - weechat_iconv_from_internal (charset, buf) : NULL; - - fprintf (logger_buffer->log_file, - "%s\n", (message) ? message : buf); - fflush (logger_buffer->log_file); - if (message) - free (message); + + buf = malloc (128 * 1024); + if (buf) + { + va_start (argptr, format); + vsnprintf (buf, 128 * 1024, format, argptr); + va_end (argptr); + + message = (charset) ? + weechat_iconv_from_internal (charset, buf) : NULL; + + fprintf (logger_buffer->log_file, + "%s\n", (message) ? message : buf); + fflush (logger_buffer->log_file); + if (message) + free (message); + + free (buf); + } } } diff --git a/src/plugins/plugin-api.c b/src/plugins/plugin-api.c index 8416d0fbb..e335dde8c 100644 --- a/src/plugins/plugin-api.c +++ b/src/plugins/plugin-api.c @@ -42,6 +42,7 @@ #include "../gui/gui-filter.h" #include "../gui/gui-infobar.h" #include "../gui/gui-keyboard.h" +#include "../gui/gui-nicklist.h" #include "../gui/gui-window.h" #include "plugin.h" #include "plugin-config.h" @@ -231,7 +232,7 @@ plugin_api_color (char *color_name) return GUI_NO_COLOR; /* name is a weechat color option ? => then return this color */ - num_color = gui_color_search_config (color_name); + num_color = gui_color_search_config_int (color_name); if (num_color >= 0) return GUI_COLOR(num_color); @@ -307,7 +308,7 @@ plugin_api_infobar_printf (struct t_weechat_plugin *plugin, int delay, buf2 = string_iconv_to_internal (plugin->charset, buf); if (color_name && color_name[0]) { - num_color = gui_color_search_config (color_name); + num_color = gui_color_search_config_int (color_name); if (num_color < 0) num_color = GUI_COLOR_INFOBAR; } @@ -511,6 +512,71 @@ plugin_api_infolist_get_add_buffer_line (struct t_plugin_infolist *infolist, } /* + * plugin_api_infolist_get_add_nicklist: add a nicklist + * return 1 if ok, 0 if error + */ + +int +plugin_api_infolist_get_add_nicklist (struct t_plugin_infolist *infolist, + struct t_gui_buffer *buffer) +{ + struct t_plugin_infolist_item *ptr_item; + struct t_gui_nick_group *ptr_group; + struct t_gui_nick *ptr_nick; + char prefix[2]; + + if (!infolist || !buffer) + return 0; + + ptr_group = NULL; + ptr_nick = NULL; + gui_nicklist_get_next_item (buffer, &ptr_group, &ptr_nick); + while (ptr_group || ptr_nick) + { + ptr_item = plugin_infolist_new_item (infolist); + if (!ptr_item) + return 0; + + if (ptr_nick) + { + if (!plugin_infolist_new_var_string (ptr_item, "type", "nick")) + return 0; + if (!plugin_infolist_new_var_string (ptr_item, "name", ptr_nick->name)) + return 0; + if (!plugin_infolist_new_var_string (ptr_item, "color", + gui_color_search_config_str (ptr_nick->color))) + return 0; + prefix[0] = ptr_nick->prefix; + prefix[1] = '\0'; + if (!plugin_infolist_new_var_string (ptr_item, "prefix", prefix)) + return 0; + if (!plugin_infolist_new_var_string (ptr_item, "prefix_color", + gui_color_search_config_str (ptr_nick->prefix_color))) + return 0; + if (!plugin_infolist_new_var_integer (ptr_item, "visible", ptr_nick->visible)) + return 0; + } + else + { + if (!plugin_infolist_new_var_string (ptr_item, "type", "group")) + return 0; + if (!plugin_infolist_new_var_string (ptr_item, "name", ptr_group->name)) + return 0; + if (!plugin_infolist_new_var_string (ptr_item, "color", + gui_color_search_config_str (ptr_group->color))) + return 0; + if (!plugin_infolist_new_var_integer (ptr_item, "visible", ptr_group->visible)) + return 0; + if (!plugin_infolist_new_var_integer (ptr_item, "level", ptr_group->level)) + return 0; + } + gui_nicklist_get_next_item (buffer, &ptr_group, &ptr_nick); + } + + return 1; +} + +/* * plugin_api_infolist_get_add_window: add a window in a list * return 1 if ok, 0 if error */ @@ -885,7 +951,24 @@ plugin_api_infolist_get (char *name, void *pointer, char *arguments) return ptr_infolist; } } - if (string_strcasecmp (name, "window") == 0) + else if (string_strcasecmp (name, "nicklist") == 0) + { + /* invalid buffer pointer ? */ + if (!pointer || (!gui_buffer_valid (pointer))) + return NULL; + + ptr_infolist = plugin_infolist_new (); + if (ptr_infolist) + { + if (!plugin_api_infolist_get_add_nicklist (ptr_infolist, pointer)) + { + plugin_infolist_free (ptr_infolist); + return NULL; + } + return ptr_infolist; + } + } + else if (string_strcasecmp (name, "window") == 0) { /* invalid window pointer ? */ if (pointer && (!gui_window_valid (pointer))) diff --git a/src/plugins/scripts/script-api.c b/src/plugins/scripts/script-api.c index be88a356b..0d89b1569 100644 --- a/src/plugins/scripts/script-api.c +++ b/src/plugins/scripts/script-api.c @@ -454,16 +454,21 @@ script_api_printf (struct t_weechat_plugin *weechat_plugin, struct t_gui_buffer *buffer, char *format, ...) { va_list argptr; - char buf[8192]; - char *buf2; + char *buf, *buf2; + + buf = malloc (128 * 1024); + if (!buf) + return; va_start (argptr, format); - vsnprintf (buf, sizeof (buf) - 1, format, argptr); + vsnprintf (buf, 128 * 1024, format, argptr); va_end (argptr); buf2 = (script->charset && script->charset[0]) ? weechat_iconv_to_internal (script->charset, buf) : NULL; weechat_printf (buffer, "%s", (buf2) ? buf2 : buf); + + free (buf); if (buf2) free (buf2); } @@ -479,17 +484,22 @@ script_api_printf_date_tags (struct t_weechat_plugin *weechat_plugin, time_t date, char *tags, char *format, ...) { va_list argptr; - char buf[8192]; - char *buf2; + char *buf, *buf2; + + buf = malloc (128 * 1024); + if (!buf) + return; va_start (argptr, format); - vsnprintf (buf, sizeof (buf) - 1, format, argptr); + vsnprintf (buf, 128 * 1024, format, argptr); va_end (argptr); buf2 = (script->charset && script->charset[0]) ? weechat_iconv_to_internal (script->charset, buf) : NULL; weechat_printf_date_tags (buffer, date, tags, "%s", (buf2) ? buf2 : buf); + + free (buf); if (buf2) free (buf2); } @@ -505,8 +515,11 @@ script_api_printf_y (struct t_weechat_plugin *weechat_plugin, char *format, ...) { va_list argptr; - char buf[8192]; - char *buf2; + char *buf, *buf2; + + buf = malloc (128 * 1024); + if (!buf) + return; va_start (argptr, format); vsnprintf (buf, sizeof (buf) - 1, format, argptr); @@ -515,6 +528,8 @@ script_api_printf_y (struct t_weechat_plugin *weechat_plugin, buf2 = (script->charset && script->charset[0]) ? weechat_iconv_to_internal (script->charset, buf) : NULL; weechat_printf_y (buffer, y, "%s", (buf2) ? buf2 : buf); + + free (buf); if (buf2) free (buf2); } |