1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-10 03:33:12 +02:00

Added "irc_highlight" setting, fixed crash when doing /part on an active DCC chat buffer

This commit is contained in:
Sebastien Helleu
2005-07-19 17:35:51 +00:00
parent 77d7b703de
commit 1230735c5f
20 changed files with 1530 additions and 1338 deletions
+1
View File
@@ -5,6 +5,7 @@ ChangeLog - 2005-07-19
Version 0.1.4 (under dev!):
* added "irc_highlight" setting, to get highlight with any word
* fixed auto-rejoin for channels with key
* fixed /ctcp command (now any command/data allowed)
* added /amsg command (send text to all channels of all connected servers)
+224 -216
View File
File diff suppressed because it is too large Load Diff
+224 -216
View File
File diff suppressed because it is too large Load Diff
+231 -223
View File
File diff suppressed because it is too large Load Diff
+5
View File
@@ -517,6 +517,7 @@ int cfg_irc_lag_check;
int cfg_irc_lag_min_show;
int cfg_irc_lag_disconnect;
int cfg_irc_fifo_pipe;
char *cfg_irc_highlight;
t_config_option weechat_options_irc[] =
{ { "irc_display_away", N_("display message to all channels when away"),
@@ -555,6 +556,10 @@ t_config_option weechat_options_irc[] =
N_("create a FIFO pipe for remote control"),
OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_FALSE,
NULL, NULL, &cfg_irc_fifo_pipe, NULL, config_change_fifo_pipe },
{ "irc_highlight", N_("list of words to highlight"),
N_("comma separated list of words to highlight (case sensitive comparison)"),
OPTION_TYPE_STRING, 0, 0, 0,
"", NULL, NULL, &cfg_irc_highlight, config_change_noop },
{ NULL, NULL, NULL, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL }
};
+1
View File
@@ -170,6 +170,7 @@ extern int cfg_irc_lag_check;
extern int cfg_irc_lag_min_show;
extern int cfg_irc_lag_disconnect;
extern int cfg_irc_fifo_pipe;
extern char *cfg_irc_highlight;
extern int cfg_dcc_auto_accept_files;
extern int cfg_dcc_auto_accept_chats;
+9 -9
View File
@@ -90,7 +90,15 @@ void
channel_free (t_irc_server *server, t_irc_channel *channel)
{
t_irc_channel *new_channels;
/* close DCC CHAT */
if ((t_irc_dcc *)(channel->dcc_chat) &&
(!DCC_ENDED(((t_irc_dcc *)(channel->dcc_chat))->status)))
{
dcc_close ((t_irc_dcc *)(channel->dcc_chat), DCC_ABORTED);
dcc_redraw (1);
}
/* remove channel from queue */
if (server->last_channel == channel)
server->last_channel = channel->prev_channel;
@@ -104,14 +112,6 @@ channel_free (t_irc_server *server, t_irc_channel *channel)
if (channel->next_channel)
(channel->next_channel)->prev_channel = channel->prev_channel;
/* close DCC CHAT */
if ((t_irc_dcc *)(channel->dcc_chat) &&
(!DCC_ENDED(((t_irc_dcc *)(channel->dcc_chat))->status)))
{
dcc_close ((t_irc_dcc *)(channel->dcc_chat), DCC_ABORTED);
dcc_redraw (1);
}
/* free data */
if (channel->name)
+1 -1
View File
@@ -998,7 +998,7 @@ dcc_chat_recv (t_irc_dcc *ptr_dcc)
gui_printf_type_color (ptr_dcc->channel->buffer,
MSG_TYPE_NICK,
COLOR_WIN_CHAT_DARK, "<");
if (strstr (ptr_buf, ptr_dcc->server->nick))
if (irc_is_highlight (ptr_buf, ptr_dcc->server->nick))
{
gui_printf_type_color (ptr_dcc->channel->buffer,
MSG_TYPE_NICK | MSG_TYPE_HIGHLIGHT,
+68 -4
View File
@@ -42,6 +42,70 @@
#include "../plugins/plugins.h"
/*
* irc_is_highlight: returns 1 if given message contains highlight (with given nick
* or at least one of string in "irc_higlight" setting
*/
int
irc_is_highlight (char *message, char *nick)
{
char *highlight, *pos, *pos_end;
int end, length;
/* empty message ? */
if (!message || !message[0])
return 0;
/* highlight by nickname */
if (strstr (message, nick))
return 1;
/* no highlight by nickname and "irc_highlight" is empty */
if (!cfg_irc_highlight || !cfg_irc_highlight[0])
return 0;
/* look in "irc_highlight" for highlight */
if ((highlight = strdup (cfg_irc_highlight)) == NULL)
return 0;
pos = highlight;
end = 0;
while (!end)
{
pos_end = strchr (pos, ',');
if (!pos_end)
{
pos_end = strchr (pos, '\0');
end = 1;
}
/* error parsing string! */
if (!pos_end)
{
free (highlight);
return 0;
}
length = pos_end - pos;
pos_end[0] = '\0';
if (length > 0)
{
/* highlight found! */
if (strstr (message, pos))
{
free (highlight);
return 1;
}
}
if (!end)
pos = pos_end + 1;
}
/* no highlight found with "irc_highlight" list */
free (highlight);
return 0;
}
/*
* irc_recv_command: executes action when receiving IRC command
* returns: 0 = all ok, command executed
@@ -1232,7 +1296,7 @@ irc_cmd_recv_privmsg (t_irc_server *server, char *host, char *arguments)
if (pos2)
pos2[0] = '\0';
irc_display_prefix (ptr_channel->buffer, PREFIX_ACTION_ME);
if (strstr (pos, server->nick))
if (irc_is_highlight (pos, server->nick))
{
gui_printf_type_color (ptr_channel->buffer,
MSG_TYPE_MSG | MSG_TYPE_HIGHLIGHT,
@@ -1271,7 +1335,7 @@ irc_cmd_recv_privmsg (t_irc_server *server, char *host, char *arguments)
else
{
ptr_nick = nick_search (ptr_channel, host);
if (strstr (pos, server->nick))
if (irc_is_highlight (pos, server->nick))
{
irc_display_nick (ptr_channel->buffer, ptr_nick,
(ptr_nick) ? NULL : host,
@@ -1714,7 +1778,7 @@ irc_cmd_recv_privmsg (t_irc_server *server, char *host, char *arguments)
if (pos2)
pos2[0] = '\0';
irc_display_prefix (ptr_channel->buffer, PREFIX_ACTION_ME);
if (strstr (pos, server->nick))
if (irc_is_highlight (pos, server->nick))
{
gui_printf_type_color (ptr_channel->buffer,
MSG_TYPE_MSG | MSG_TYPE_HIGHLIGHT,
@@ -1741,7 +1805,7 @@ irc_cmd_recv_privmsg (t_irc_server *server, char *host, char *arguments)
gui_printf_type_color (ptr_channel->buffer,
MSG_TYPE_NICK,
COLOR_WIN_CHAT_DARK, "<");
if (strstr (pos, server->nick))
if (irc_is_highlight (pos, server->nick))
{
gui_printf_type_color (ptr_channel->buffer,
MSG_TYPE_NICK | MSG_TYPE_HIGHLIGHT,
+1
View File
@@ -351,6 +351,7 @@ extern void irc_display_server (t_irc_server *ptr_server);
/* IRC protocol (irc-commands.c) */
extern int irc_is_highlight (char *, char *);
extern int irc_recv_command (t_irc_server *, char *, char *, char *, char *);
extern void irc_login (t_irc_server *);
/* IRC commands issued by user */
+1
View File
@@ -5,6 +5,7 @@ ChangeLog - 2005-07-19
Version 0.1.4 (under dev!):
* added "irc_highlight" setting, to get highlight with any word
* fixed auto-rejoin for channels with key
* fixed /ctcp command (now any command/data allowed)
* added /amsg command (send text to all channels of all connected servers)
+224 -216
View File
File diff suppressed because it is too large Load Diff
+224 -216
View File
File diff suppressed because it is too large Load Diff
+231 -223
View File
File diff suppressed because it is too large Load Diff
+5
View File
@@ -517,6 +517,7 @@ int cfg_irc_lag_check;
int cfg_irc_lag_min_show;
int cfg_irc_lag_disconnect;
int cfg_irc_fifo_pipe;
char *cfg_irc_highlight;
t_config_option weechat_options_irc[] =
{ { "irc_display_away", N_("display message to all channels when away"),
@@ -555,6 +556,10 @@ t_config_option weechat_options_irc[] =
N_("create a FIFO pipe for remote control"),
OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_FALSE,
NULL, NULL, &cfg_irc_fifo_pipe, NULL, config_change_fifo_pipe },
{ "irc_highlight", N_("list of words to highlight"),
N_("comma separated list of words to highlight (case sensitive comparison)"),
OPTION_TYPE_STRING, 0, 0, 0,
"", NULL, NULL, &cfg_irc_highlight, config_change_noop },
{ NULL, NULL, NULL, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL }
};
+1
View File
@@ -170,6 +170,7 @@ extern int cfg_irc_lag_check;
extern int cfg_irc_lag_min_show;
extern int cfg_irc_lag_disconnect;
extern int cfg_irc_fifo_pipe;
extern char *cfg_irc_highlight;
extern int cfg_dcc_auto_accept_files;
extern int cfg_dcc_auto_accept_chats;
+9 -9
View File
@@ -90,7 +90,15 @@ void
channel_free (t_irc_server *server, t_irc_channel *channel)
{
t_irc_channel *new_channels;
/* close DCC CHAT */
if ((t_irc_dcc *)(channel->dcc_chat) &&
(!DCC_ENDED(((t_irc_dcc *)(channel->dcc_chat))->status)))
{
dcc_close ((t_irc_dcc *)(channel->dcc_chat), DCC_ABORTED);
dcc_redraw (1);
}
/* remove channel from queue */
if (server->last_channel == channel)
server->last_channel = channel->prev_channel;
@@ -104,14 +112,6 @@ channel_free (t_irc_server *server, t_irc_channel *channel)
if (channel->next_channel)
(channel->next_channel)->prev_channel = channel->prev_channel;
/* close DCC CHAT */
if ((t_irc_dcc *)(channel->dcc_chat) &&
(!DCC_ENDED(((t_irc_dcc *)(channel->dcc_chat))->status)))
{
dcc_close ((t_irc_dcc *)(channel->dcc_chat), DCC_ABORTED);
dcc_redraw (1);
}
/* free data */
if (channel->name)
+1 -1
View File
@@ -998,7 +998,7 @@ dcc_chat_recv (t_irc_dcc *ptr_dcc)
gui_printf_type_color (ptr_dcc->channel->buffer,
MSG_TYPE_NICK,
COLOR_WIN_CHAT_DARK, "<");
if (strstr (ptr_buf, ptr_dcc->server->nick))
if (irc_is_highlight (ptr_buf, ptr_dcc->server->nick))
{
gui_printf_type_color (ptr_dcc->channel->buffer,
MSG_TYPE_NICK | MSG_TYPE_HIGHLIGHT,
+68 -4
View File
@@ -42,6 +42,70 @@
#include "../plugins/plugins.h"
/*
* irc_is_highlight: returns 1 if given message contains highlight (with given nick
* or at least one of string in "irc_higlight" setting
*/
int
irc_is_highlight (char *message, char *nick)
{
char *highlight, *pos, *pos_end;
int end, length;
/* empty message ? */
if (!message || !message[0])
return 0;
/* highlight by nickname */
if (strstr (message, nick))
return 1;
/* no highlight by nickname and "irc_highlight" is empty */
if (!cfg_irc_highlight || !cfg_irc_highlight[0])
return 0;
/* look in "irc_highlight" for highlight */
if ((highlight = strdup (cfg_irc_highlight)) == NULL)
return 0;
pos = highlight;
end = 0;
while (!end)
{
pos_end = strchr (pos, ',');
if (!pos_end)
{
pos_end = strchr (pos, '\0');
end = 1;
}
/* error parsing string! */
if (!pos_end)
{
free (highlight);
return 0;
}
length = pos_end - pos;
pos_end[0] = '\0';
if (length > 0)
{
/* highlight found! */
if (strstr (message, pos))
{
free (highlight);
return 1;
}
}
if (!end)
pos = pos_end + 1;
}
/* no highlight found with "irc_highlight" list */
free (highlight);
return 0;
}
/*
* irc_recv_command: executes action when receiving IRC command
* returns: 0 = all ok, command executed
@@ -1232,7 +1296,7 @@ irc_cmd_recv_privmsg (t_irc_server *server, char *host, char *arguments)
if (pos2)
pos2[0] = '\0';
irc_display_prefix (ptr_channel->buffer, PREFIX_ACTION_ME);
if (strstr (pos, server->nick))
if (irc_is_highlight (pos, server->nick))
{
gui_printf_type_color (ptr_channel->buffer,
MSG_TYPE_MSG | MSG_TYPE_HIGHLIGHT,
@@ -1271,7 +1335,7 @@ irc_cmd_recv_privmsg (t_irc_server *server, char *host, char *arguments)
else
{
ptr_nick = nick_search (ptr_channel, host);
if (strstr (pos, server->nick))
if (irc_is_highlight (pos, server->nick))
{
irc_display_nick (ptr_channel->buffer, ptr_nick,
(ptr_nick) ? NULL : host,
@@ -1714,7 +1778,7 @@ irc_cmd_recv_privmsg (t_irc_server *server, char *host, char *arguments)
if (pos2)
pos2[0] = '\0';
irc_display_prefix (ptr_channel->buffer, PREFIX_ACTION_ME);
if (strstr (pos, server->nick))
if (irc_is_highlight (pos, server->nick))
{
gui_printf_type_color (ptr_channel->buffer,
MSG_TYPE_MSG | MSG_TYPE_HIGHLIGHT,
@@ -1741,7 +1805,7 @@ irc_cmd_recv_privmsg (t_irc_server *server, char *host, char *arguments)
gui_printf_type_color (ptr_channel->buffer,
MSG_TYPE_NICK,
COLOR_WIN_CHAT_DARK, "<");
if (strstr (pos, server->nick))
if (irc_is_highlight (pos, server->nick))
{
gui_printf_type_color (ptr_channel->buffer,
MSG_TYPE_NICK | MSG_TYPE_HIGHLIGHT,
+1
View File
@@ -351,6 +351,7 @@ extern void irc_display_server (t_irc_server *ptr_server);
/* IRC protocol (irc-commands.c) */
extern int irc_is_highlight (char *, char *);
extern int irc_recv_command (t_irc_server *, char *, char *, char *, char *);
extern void irc_login (t_irc_server *);
/* IRC commands issued by user */