1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-26 12:56:37 +02:00

Fixed FIFO pipe buffer detection, away message (301) now displayed in query if

exists, otherwise on server buffer
This commit is contained in:
Sebastien Helleu
2005-12-17 11:54:41 +00:00
parent d5b58ff068
commit 04fda8a314
14 changed files with 100 additions and 84 deletions
+28 -18
View File
@@ -741,8 +741,9 @@ exec_weechat_command (t_gui_window *window, t_irc_server *server, char *string)
*/
void
user_command (t_gui_window *window, t_irc_server *server, char *command)
user_command (t_gui_buffer *buffer, t_irc_server *server, char *command)
{
t_gui_window *ptr_window;
t_irc_nick *ptr_nick;
int plugin_args_length;
char *command_with_colors, *command_with_colors2, *plugin_args;
@@ -750,47 +751,56 @@ user_command (t_gui_window *window, t_irc_server *server, char *command)
if ((!command) || (!command[0]) || (command[0] == '\r') || (command[0] == '\n'))
return;
if ((command[0] == '/') && (command[1] != '/'))
if (!buffer)
{
/* WeeChat internal command (or IRC command) */
(void) exec_weechat_command (window, server, command);
buffer = gui_current_window->buffer;
ptr_window = gui_current_window;
}
else
{
ptr_window = gui_buffer_find_window (buffer);
if (!ptr_window)
ptr_window = gui_current_window;
}
if ((command[0] == '/') && (command[1] != '/'))
{
/* WeeChat internal command (or IRC command) */
(void) exec_weechat_command (ptr_window, server, command);
}
else
{
if (!window)
window = gui_current_window;
if ((command[0] == '/') && (command[1] == '/'))
command++;
if (server && (!BUFFER_IS_SERVER(window->buffer)))
if (server && (!BUFFER_IS_SERVER(buffer)))
{
command_with_colors = (cfg_irc_colors_send) ?
(char *)gui_color_encode ((unsigned char *)command) : NULL;
if (CHANNEL(window->buffer)->dcc_chat)
dcc_chat_sendf ((t_irc_dcc *)(CHANNEL(window->buffer)->dcc_chat),
if (CHANNEL(buffer)->dcc_chat)
dcc_chat_sendf ((t_irc_dcc *)(CHANNEL(buffer)->dcc_chat),
"%s\r\n",
(command_with_colors) ? command_with_colors : command);
else
server_sendf (server, "PRIVMSG %s :%s\r\n",
CHANNEL(window->buffer)->name,
CHANNEL(buffer)->name,
(command_with_colors) ?
command_with_colors : command);
command_with_colors2 = (command_with_colors) ?
(char *)gui_color_decode ((unsigned char *)command_with_colors, 1) : NULL;
if (CHANNEL(window->buffer)->type == CHANNEL_TYPE_PRIVATE)
if (CHANNEL(buffer)->type == CHANNEL_TYPE_PRIVATE)
{
gui_printf_type (window->buffer,
gui_printf_type (buffer,
MSG_TYPE_NICK,
"%s<%s%s%s> ",
GUI_COLOR(COLOR_WIN_CHAT_DARK),
GUI_COLOR(COLOR_WIN_NICK_SELF),
server->nick,
GUI_COLOR(COLOR_WIN_CHAT_DARK));
gui_printf_type (window->buffer,
gui_printf_type (buffer,
MSG_TYPE_MSG,
"%s%s\n",
GUI_COLOR(COLOR_WIN_CHAT),
@@ -799,12 +809,12 @@ user_command (t_gui_window *window, t_irc_server *server, char *command)
}
else
{
ptr_nick = nick_search (CHANNEL(window->buffer), server->nick);
ptr_nick = nick_search (CHANNEL(buffer), server->nick);
if (ptr_nick)
{
irc_display_nick (CHANNEL(window->buffer)->buffer, ptr_nick, NULL,
irc_display_nick (CHANNEL(buffer)->buffer, ptr_nick, NULL,
MSG_TYPE_NICK, 1, 1, 0);
gui_printf (CHANNEL(window->buffer)->buffer,
gui_printf (CHANNEL(buffer)->buffer,
"%s\n",
(command_with_colors2) ?
command_with_colors2 : command);
@@ -3176,7 +3186,7 @@ weechat_cmd_uptime (t_gui_window *window, int argc, char **argv)
sec,
ctime (&weechat_start_time));
string[strlen (string) - 1] = '\0';
user_command (window, SERVER(window->buffer), string);
user_command (window->buffer, SERVER(window->buffer), string);
}
else
{
+1 -1
View File
@@ -67,7 +67,7 @@ extern void alias_free_all ();
extern char **explode_string (char *, char *, int, int *);
extern void free_exploded_string (char **);
extern int exec_weechat_command (t_gui_window *, t_irc_server *, char *);
extern void user_command (t_gui_window *, t_irc_server *, char *);
extern void user_command (t_gui_buffer *, t_irc_server *, char *);
extern int weechat_cmd_alias (t_gui_window *, char *);
extern int weechat_cmd_buffer (t_gui_window *, int, char **);
extern int weechat_cmd_charset (t_gui_window *, int, char **);
+9 -13
View File
@@ -148,19 +148,16 @@ fifo_exec (char *text)
WEECHAT_WARNING, text);
return;
}
if (ptr_server)
if (ptr_server && pos)
{
if (pos)
ptr_channel = channel_search (ptr_server, pos + 1);
if (!ptr_channel)
{
ptr_channel = channel_search (ptr_server, pos + 1);
if (!ptr_channel)
{
irc_display_prefix (NULL, NULL, PREFIX_ERROR);
gui_printf (NULL,
_("%s channel \"%s\" not found (FIFO pipe data)\n"),
WEECHAT_WARNING, pos + 1);
return;
}
irc_display_prefix (NULL, NULL, PREFIX_ERROR);
gui_printf (NULL,
_("%s channel \"%s\" not found (FIFO pipe data)\n"),
WEECHAT_WARNING, pos + 1);
return;
}
}
}
@@ -174,8 +171,7 @@ fifo_exec (char *text)
ptr_buffer = gui_buffers;
}
user_command (gui_buffer_find_window (ptr_buffer),
ptr_server, pos_msg);
user_command (ptr_buffer, ptr_server, pos_msg);
}
/*
+1 -1
View File
@@ -108,7 +108,7 @@ gui_action_return (t_gui_window *window)
window->buffer->completion.position = -1;
window->buffer->ptr_history = NULL;
gui_draw_buffer_input (window->buffer, 0);
user_command (window, SERVER(window->buffer), command);
user_command (window->buffer, SERVER(window->buffer), command);
free (command);
}
}
+1 -1
View File
@@ -517,7 +517,7 @@ gui_key_pressed (char *key_str)
/* exact combo found => execute function or command */
gui_key_buffer[0] = '\0';
if (ptr_key->command)
user_command (gui_current_window,
user_command (gui_current_window->buffer,
SERVER(gui_current_window->buffer),
ptr_key->command);
else
+7 -2
View File
@@ -2537,6 +2537,8 @@ int
irc_cmd_recv_301 (t_irc_server *server, char *host, char *nick, char *arguments)
{
char *pos_nick, *pos_message;
t_irc_channel *ptr_channel;
t_gui_buffer *ptr_buffer;
/* make gcc happy */
(void) server;
@@ -2560,8 +2562,11 @@ irc_cmd_recv_301 (t_irc_server *server, char *host, char *nick, char *arguments)
if (!command_ignored)
{
irc_display_prefix (server, gui_current_window->buffer, PREFIX_INFO);
gui_printf (gui_current_window->buffer,
/* look for private buffer to display message */
ptr_channel = channel_search (server, pos_nick);
ptr_buffer = (ptr_channel) ? ptr_channel->buffer : server->buffer;
irc_display_prefix (server, ptr_buffer, PREFIX_INFO);
gui_printf (ptr_buffer,
_("%s%s%s is away: %s\n"),
GUI_COLOR(COLOR_WIN_CHAT_NICK),
pos_nick,
+3 -6
View File
@@ -290,14 +290,11 @@ weechat_plugin_exec_command (t_weechat_plugin *plugin,
plugin_find_server_channel (server, channel, &ptr_server, &ptr_channel);
if (ptr_server && ptr_channel)
user_command (gui_buffer_find_window (ptr_channel->buffer),
ptr_server, command);
user_command (ptr_channel->buffer, ptr_server, command);
else if (ptr_server && (ptr_server->buffer))
user_command (gui_buffer_find_window (ptr_server->buffer),
ptr_server, command);
user_command (ptr_server->buffer, ptr_server, command);
else
user_command (gui_buffer_find_window (gui_buffers),
NULL, command);
user_command (gui_buffers, NULL, command);
}
/*
+28 -18
View File
@@ -741,8 +741,9 @@ exec_weechat_command (t_gui_window *window, t_irc_server *server, char *string)
*/
void
user_command (t_gui_window *window, t_irc_server *server, char *command)
user_command (t_gui_buffer *buffer, t_irc_server *server, char *command)
{
t_gui_window *ptr_window;
t_irc_nick *ptr_nick;
int plugin_args_length;
char *command_with_colors, *command_with_colors2, *plugin_args;
@@ -750,47 +751,56 @@ user_command (t_gui_window *window, t_irc_server *server, char *command)
if ((!command) || (!command[0]) || (command[0] == '\r') || (command[0] == '\n'))
return;
if ((command[0] == '/') && (command[1] != '/'))
if (!buffer)
{
/* WeeChat internal command (or IRC command) */
(void) exec_weechat_command (window, server, command);
buffer = gui_current_window->buffer;
ptr_window = gui_current_window;
}
else
{
ptr_window = gui_buffer_find_window (buffer);
if (!ptr_window)
ptr_window = gui_current_window;
}
if ((command[0] == '/') && (command[1] != '/'))
{
/* WeeChat internal command (or IRC command) */
(void) exec_weechat_command (ptr_window, server, command);
}
else
{
if (!window)
window = gui_current_window;
if ((command[0] == '/') && (command[1] == '/'))
command++;
if (server && (!BUFFER_IS_SERVER(window->buffer)))
if (server && (!BUFFER_IS_SERVER(buffer)))
{
command_with_colors = (cfg_irc_colors_send) ?
(char *)gui_color_encode ((unsigned char *)command) : NULL;
if (CHANNEL(window->buffer)->dcc_chat)
dcc_chat_sendf ((t_irc_dcc *)(CHANNEL(window->buffer)->dcc_chat),
if (CHANNEL(buffer)->dcc_chat)
dcc_chat_sendf ((t_irc_dcc *)(CHANNEL(buffer)->dcc_chat),
"%s\r\n",
(command_with_colors) ? command_with_colors : command);
else
server_sendf (server, "PRIVMSG %s :%s\r\n",
CHANNEL(window->buffer)->name,
CHANNEL(buffer)->name,
(command_with_colors) ?
command_with_colors : command);
command_with_colors2 = (command_with_colors) ?
(char *)gui_color_decode ((unsigned char *)command_with_colors, 1) : NULL;
if (CHANNEL(window->buffer)->type == CHANNEL_TYPE_PRIVATE)
if (CHANNEL(buffer)->type == CHANNEL_TYPE_PRIVATE)
{
gui_printf_type (window->buffer,
gui_printf_type (buffer,
MSG_TYPE_NICK,
"%s<%s%s%s> ",
GUI_COLOR(COLOR_WIN_CHAT_DARK),
GUI_COLOR(COLOR_WIN_NICK_SELF),
server->nick,
GUI_COLOR(COLOR_WIN_CHAT_DARK));
gui_printf_type (window->buffer,
gui_printf_type (buffer,
MSG_TYPE_MSG,
"%s%s\n",
GUI_COLOR(COLOR_WIN_CHAT),
@@ -799,12 +809,12 @@ user_command (t_gui_window *window, t_irc_server *server, char *command)
}
else
{
ptr_nick = nick_search (CHANNEL(window->buffer), server->nick);
ptr_nick = nick_search (CHANNEL(buffer), server->nick);
if (ptr_nick)
{
irc_display_nick (CHANNEL(window->buffer)->buffer, ptr_nick, NULL,
irc_display_nick (CHANNEL(buffer)->buffer, ptr_nick, NULL,
MSG_TYPE_NICK, 1, 1, 0);
gui_printf (CHANNEL(window->buffer)->buffer,
gui_printf (CHANNEL(buffer)->buffer,
"%s\n",
(command_with_colors2) ?
command_with_colors2 : command);
@@ -3176,7 +3186,7 @@ weechat_cmd_uptime (t_gui_window *window, int argc, char **argv)
sec,
ctime (&weechat_start_time));
string[strlen (string) - 1] = '\0';
user_command (window, SERVER(window->buffer), string);
user_command (window->buffer, SERVER(window->buffer), string);
}
else
{
+1 -1
View File
@@ -67,7 +67,7 @@ extern void alias_free_all ();
extern char **explode_string (char *, char *, int, int *);
extern void free_exploded_string (char **);
extern int exec_weechat_command (t_gui_window *, t_irc_server *, char *);
extern void user_command (t_gui_window *, t_irc_server *, char *);
extern void user_command (t_gui_buffer *, t_irc_server *, char *);
extern int weechat_cmd_alias (t_gui_window *, char *);
extern int weechat_cmd_buffer (t_gui_window *, int, char **);
extern int weechat_cmd_charset (t_gui_window *, int, char **);
+9 -13
View File
@@ -148,19 +148,16 @@ fifo_exec (char *text)
WEECHAT_WARNING, text);
return;
}
if (ptr_server)
if (ptr_server && pos)
{
if (pos)
ptr_channel = channel_search (ptr_server, pos + 1);
if (!ptr_channel)
{
ptr_channel = channel_search (ptr_server, pos + 1);
if (!ptr_channel)
{
irc_display_prefix (NULL, NULL, PREFIX_ERROR);
gui_printf (NULL,
_("%s channel \"%s\" not found (FIFO pipe data)\n"),
WEECHAT_WARNING, pos + 1);
return;
}
irc_display_prefix (NULL, NULL, PREFIX_ERROR);
gui_printf (NULL,
_("%s channel \"%s\" not found (FIFO pipe data)\n"),
WEECHAT_WARNING, pos + 1);
return;
}
}
}
@@ -174,8 +171,7 @@ fifo_exec (char *text)
ptr_buffer = gui_buffers;
}
user_command (gui_buffer_find_window (ptr_buffer),
ptr_server, pos_msg);
user_command (ptr_buffer, ptr_server, pos_msg);
}
/*
+1 -1
View File
@@ -108,7 +108,7 @@ gui_action_return (t_gui_window *window)
window->buffer->completion.position = -1;
window->buffer->ptr_history = NULL;
gui_draw_buffer_input (window->buffer, 0);
user_command (window, SERVER(window->buffer), command);
user_command (window->buffer, SERVER(window->buffer), command);
free (command);
}
}
+1 -1
View File
@@ -517,7 +517,7 @@ gui_key_pressed (char *key_str)
/* exact combo found => execute function or command */
gui_key_buffer[0] = '\0';
if (ptr_key->command)
user_command (gui_current_window,
user_command (gui_current_window->buffer,
SERVER(gui_current_window->buffer),
ptr_key->command);
else
+7 -2
View File
@@ -2537,6 +2537,8 @@ int
irc_cmd_recv_301 (t_irc_server *server, char *host, char *nick, char *arguments)
{
char *pos_nick, *pos_message;
t_irc_channel *ptr_channel;
t_gui_buffer *ptr_buffer;
/* make gcc happy */
(void) server;
@@ -2560,8 +2562,11 @@ irc_cmd_recv_301 (t_irc_server *server, char *host, char *nick, char *arguments)
if (!command_ignored)
{
irc_display_prefix (server, gui_current_window->buffer, PREFIX_INFO);
gui_printf (gui_current_window->buffer,
/* look for private buffer to display message */
ptr_channel = channel_search (server, pos_nick);
ptr_buffer = (ptr_channel) ? ptr_channel->buffer : server->buffer;
irc_display_prefix (server, ptr_buffer, PREFIX_INFO);
gui_printf (ptr_buffer,
_("%s%s%s is away: %s\n"),
GUI_COLOR(COLOR_WIN_CHAT_NICK),
pos_nick,
+3 -6
View File
@@ -290,14 +290,11 @@ weechat_plugin_exec_command (t_weechat_plugin *plugin,
plugin_find_server_channel (server, channel, &ptr_server, &ptr_channel);
if (ptr_server && ptr_channel)
user_command (gui_buffer_find_window (ptr_channel->buffer),
ptr_server, command);
user_command (ptr_channel->buffer, ptr_server, command);
else if (ptr_server && (ptr_server->buffer))
user_command (gui_buffer_find_window (ptr_server->buffer),
ptr_server, command);
user_command (ptr_server->buffer, ptr_server, command);
else
user_command (gui_buffer_find_window (gui_buffers),
NULL, command);
user_command (gui_buffers, NULL, command);
}
/*