mirror of
https://github.com/irssi/irssi.git
synced 2024-12-04 14:46:39 -05:00
CTCP msgs/replies stops the "event privmsg" or "event notice" signals now
so you don't have to check for them anymore (unless you use signal_add_first()..). /WINDOW MOVE command had some bugs. CTCP reply to some channel didn't display the channel name. Several code cleanups. git-svn-id: http://svn.irssi.org/repos/irssi/trunk@327 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
parent
919abb2c6f
commit
18f3c74d68
@ -125,7 +125,7 @@ static void cmd_window_next(void)
|
||||
{
|
||||
int num;
|
||||
|
||||
num = window_refnum_next(active_win->refnum);
|
||||
num = window_refnum_next(active_win->refnum, TRUE);
|
||||
if (num < 1) num = windows_refnum_last();
|
||||
|
||||
window_set_active(window_find_refnum(num));
|
||||
@ -135,8 +135,8 @@ static void cmd_window_prev(void)
|
||||
{
|
||||
int num;
|
||||
|
||||
num = window_refnum_prev(active_win->refnum);
|
||||
if (num < 1) num = window_refnum_next(0);
|
||||
num = window_refnum_prev(active_win->refnum, TRUE);
|
||||
if (num < 1) num = window_refnum_next(0, TRUE);
|
||||
|
||||
window_set_active(window_find_refnum(num));
|
||||
}
|
||||
@ -239,9 +239,9 @@ static void cmd_window_move_left(void)
|
||||
{
|
||||
int refnum;
|
||||
|
||||
refnum = window_refnum_prev(active_win->refnum);
|
||||
refnum = window_refnum_prev(active_win->refnum, TRUE);
|
||||
if (refnum != -1) {
|
||||
window_set_refnum(active_win, active_win->refnum-1);
|
||||
window_set_refnum(active_win, refnum);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -252,9 +252,9 @@ static void cmd_window_move_right(void)
|
||||
{
|
||||
int refnum;
|
||||
|
||||
refnum = window_refnum_next(active_win->refnum);
|
||||
refnum = window_refnum_next(active_win->refnum, TRUE);
|
||||
if (refnum != -1) {
|
||||
window_set_refnum(active_win, active_win->refnum+1);
|
||||
window_set_refnum(active_win, refnum);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -273,7 +273,7 @@ static void cmd_window_move(const char *data, SERVER_REC *server, WI_ITEM_REC *i
|
||||
new_refnum = atoi(data);
|
||||
if (new_refnum > active_win->refnum) {
|
||||
for (;;) {
|
||||
refnum = window_refnum_next(active_win->refnum);
|
||||
refnum = window_refnum_next(active_win->refnum, FALSE);
|
||||
if (refnum == -1 || refnum > new_refnum)
|
||||
break;
|
||||
|
||||
@ -281,7 +281,7 @@ static void cmd_window_move(const char *data, SERVER_REC *server, WI_ITEM_REC *i
|
||||
}
|
||||
} else {
|
||||
for (;;) {
|
||||
refnum = window_refnum_prev(active_win->refnum);
|
||||
refnum = window_refnum_prev(active_win->refnum, FALSE);
|
||||
if (refnum == -1 || refnum < new_refnum)
|
||||
break;
|
||||
|
||||
|
@ -112,6 +112,22 @@ void window_item_set_active(WINDOW_REC *window, WI_ITEM_REC *item)
|
||||
}
|
||||
}
|
||||
|
||||
/* Return TRUE if `item' is the active window item in the window.
|
||||
`item' can be NULL. */
|
||||
int window_item_is_active(WI_ITEM_REC *item)
|
||||
{
|
||||
WINDOW_REC *window;
|
||||
|
||||
if (item == NULL)
|
||||
return FALSE;
|
||||
|
||||
window = window_item_window(item);
|
||||
if (window == NULL)
|
||||
return FALSE;
|
||||
|
||||
return window->active == item;
|
||||
}
|
||||
|
||||
void window_item_prev(WINDOW_REC *window)
|
||||
{
|
||||
WI_ITEM_REC *last;
|
||||
|
@ -13,6 +13,10 @@ WINDOW_REC *window_item_window(WI_ITEM_REC *item);
|
||||
void window_item_change_server(WI_ITEM_REC *item, void *server);
|
||||
|
||||
void window_item_set_active(WINDOW_REC *window, WI_ITEM_REC *item);
|
||||
/* Return TRUE if `item' is the active window item in the window.
|
||||
`item' can be NULL. */
|
||||
int window_item_is_active(WI_ITEM_REC *item);
|
||||
|
||||
void window_item_prev(WINDOW_REC *window);
|
||||
void window_item_next(WINDOW_REC *window);
|
||||
|
||||
|
@ -306,7 +306,7 @@ WINDOW_REC *window_find_item(WINDOW_REC *window, const char *name)
|
||||
return MODULE_DATA(item);
|
||||
}
|
||||
|
||||
int window_refnum_prev(int refnum)
|
||||
int window_refnum_prev(int refnum, int wrap)
|
||||
{
|
||||
GSList *tmp;
|
||||
int prev, max;
|
||||
@ -317,14 +317,14 @@ int window_refnum_prev(int refnum)
|
||||
|
||||
if (rec->refnum < refnum && (prev == -1 || rec->refnum > prev))
|
||||
prev = rec->refnum;
|
||||
if (max == -1 || rec->refnum > max)
|
||||
if (wrap && (max == -1 || rec->refnum > max))
|
||||
max = rec->refnum;
|
||||
}
|
||||
|
||||
return prev != -1 ? prev : max;
|
||||
}
|
||||
|
||||
int window_refnum_next(int refnum)
|
||||
int window_refnum_next(int refnum, int wrap)
|
||||
{
|
||||
GSList *tmp;
|
||||
int min, next;
|
||||
@ -335,7 +335,7 @@ int window_refnum_next(int refnum)
|
||||
|
||||
if (rec->refnum > refnum && (next == -1 || rec->refnum < next))
|
||||
next = rec->refnum;
|
||||
if (min == -1 || rec->refnum < min)
|
||||
if (wrap && (min == -1 || rec->refnum < min))
|
||||
min = rec->refnum;
|
||||
}
|
||||
|
||||
|
@ -69,8 +69,8 @@ WINDOW_REC *window_find_refnum(int refnum);
|
||||
WINDOW_REC *window_find_name(const char *name);
|
||||
WINDOW_REC *window_find_item(WINDOW_REC *window, const char *name);
|
||||
|
||||
int window_refnum_prev(int refnum);
|
||||
int window_refnum_next(int refnum);
|
||||
int window_refnum_prev(int refnum, int wrap);
|
||||
int window_refnum_next(int refnum, int wrap);
|
||||
int windows_refnum_last(void);
|
||||
|
||||
void windows_init(void);
|
||||
|
@ -32,6 +32,7 @@ libfe_common_irc_la_SOURCES = \
|
||||
noinst_HEADERS = \
|
||||
completion.h \
|
||||
fe-common-irc.h \
|
||||
fe-query.h \
|
||||
irc-hilight-text.h \
|
||||
module.h \
|
||||
module-formats.h
|
||||
|
@ -158,13 +158,6 @@ static void event_privmsg(gchar *data, IRC_SERVER_REC *server, gchar *nick)
|
||||
|
||||
params = event_get_params(data, 2 | PARAM_FLAG_GETREST, &target, &msg);
|
||||
|
||||
if (*msg == 1)
|
||||
{
|
||||
/* ignore ctcp messages */
|
||||
g_free(params);
|
||||
return;
|
||||
}
|
||||
|
||||
if (ischannel(*target))
|
||||
{
|
||||
/* channel message */
|
||||
|
@ -34,11 +34,15 @@
|
||||
#include "ignore.h"
|
||||
#include "netsplit.h"
|
||||
|
||||
#include "fe-query.h"
|
||||
#include "irc-hilight-text.h"
|
||||
#include "windows.h"
|
||||
|
||||
#include "completion.h"
|
||||
|
||||
#define target_level(target) \
|
||||
(ischannel((target)[0]) ? MSGLEVEL_PUBLIC : MSGLEVEL_MSGS)
|
||||
|
||||
static int beep_msg_level, beep_when_away;
|
||||
|
||||
static void msg_beep_check(IRC_SERVER_REC *server, int level)
|
||||
@ -49,195 +53,150 @@ static void msg_beep_check(IRC_SERVER_REC *server, int level)
|
||||
}
|
||||
}
|
||||
|
||||
static void event_privmsg(gchar *data, IRC_SERVER_REC *server, gchar *nick, gchar *addr)
|
||||
static void print_channel_msg(IRC_SERVER_REC *server, const char *msg, const char *nick, const char *addr, const char *target)
|
||||
{
|
||||
CHANNEL_REC *chanrec;
|
||||
WI_ITEM_REC *item;
|
||||
gchar *params, *target, *msg, *nickmode;
|
||||
int level;
|
||||
|
||||
g_return_if_fail(data != NULL);
|
||||
|
||||
params = event_get_params(data, 2 | PARAM_FLAG_GETREST, &target, &msg);
|
||||
if (nick == NULL) nick = server->real_address;
|
||||
|
||||
level = 0;
|
||||
if (*msg == 1)
|
||||
{
|
||||
/* ctcp message, handled in fe-ctcp.c */
|
||||
}
|
||||
else if (ignore_check(server, nick, addr, target, msg,
|
||||
ischannel(*target) ? MSGLEVEL_PUBLIC : MSGLEVEL_MSGS))
|
||||
{
|
||||
/* ignored */
|
||||
}
|
||||
else if (ischannel(*target))
|
||||
{
|
||||
/* message to some channel */
|
||||
WINDOW_REC *window;
|
||||
CHANNEL_REC *chanrec;
|
||||
NICK_REC *nickrec;
|
||||
gboolean toyou;
|
||||
gchar *color;
|
||||
int for_me;
|
||||
char *color, *nickmode;
|
||||
|
||||
chanrec = channel_find(server, target);
|
||||
toyou = irc_nick_match(server->nick, msg);
|
||||
for_me = irc_nick_match(server->nick, msg);
|
||||
color = irc_hilight_find_nick(target, nick, addr);
|
||||
|
||||
nickrec = chanrec == NULL ? NULL : nicklist_find(chanrec, nick);
|
||||
nickmode = !settings_get_bool("show_nickmode") || nickrec == NULL ? "" :
|
||||
nickrec->op ? "@" : nickrec->voice ? "+" : " ";
|
||||
nickmode = (!settings_get_bool("show_nickmode") || nickrec == NULL) ? "" :
|
||||
(nickrec->op ? "@" : nickrec->voice ? "+" : " ");
|
||||
|
||||
window = chanrec == NULL ? NULL : window_item_window((WI_ITEM_REC *) chanrec);
|
||||
if (window != NULL && window->active == (WI_ITEM_REC *) chanrec)
|
||||
{
|
||||
/* message to active channel in window */
|
||||
if (color != NULL)
|
||||
{
|
||||
/* highlighted nick */
|
||||
printformat(server, target, MSGLEVEL_PUBLIC | MSGLEVEL_NOHILIGHT,
|
||||
IRCTXT_PUBMSG_HILIGHT, color, nick, msg, nickmode);
|
||||
}
|
||||
else
|
||||
{
|
||||
printformat(server, target, MSGLEVEL_PUBLIC | (toyou ? MSGLEVEL_NOHILIGHT : 0),
|
||||
toyou ? IRCTXT_PUBMSG_ME : IRCTXT_PUBMSG, nick, msg, nickmode);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* message to not existing/active channel */
|
||||
if (color != NULL)
|
||||
{
|
||||
/* highlighted nick */
|
||||
printformat(server, target, MSGLEVEL_PUBLIC | MSGLEVEL_NOHILIGHT,
|
||||
IRCTXT_PUBMSG_HILIGHT_CHANNEL, color, nick, target, msg, nickmode);
|
||||
}
|
||||
else
|
||||
{
|
||||
printformat(server, target, MSGLEVEL_PUBLIC | (toyou ? MSGLEVEL_NOHILIGHT : 0),
|
||||
toyou ? IRCTXT_PUBMSG_ME_CHANNEL : IRCTXT_PUBMSG_CHANNEL,
|
||||
nick, target, msg, nickmode);
|
||||
}
|
||||
if (window_item_is_active((WI_ITEM_REC *) chanrec)) {
|
||||
/* message to active channel in window */
|
||||
if (color != NULL) {
|
||||
/* highlighted nick */
|
||||
printformat(server, target, MSGLEVEL_PUBLIC | MSGLEVEL_NOHILIGHT,
|
||||
IRCTXT_PUBMSG_HILIGHT, color, nick, msg, nickmode);
|
||||
} else {
|
||||
printformat(server, target, MSGLEVEL_PUBLIC | (for_me ? MSGLEVEL_NOHILIGHT : 0),
|
||||
for_me ? IRCTXT_PUBMSG_ME : IRCTXT_PUBMSG, nick, msg, nickmode);
|
||||
}
|
||||
} else {
|
||||
/* message to not existing/active channel */
|
||||
if (color != NULL) {
|
||||
/* highlighted nick */
|
||||
printformat(server, target, MSGLEVEL_PUBLIC | MSGLEVEL_NOHILIGHT,
|
||||
IRCTXT_PUBMSG_HILIGHT_CHANNEL, color, nick, target, msg, nickmode);
|
||||
} else {
|
||||
printformat(server, target, MSGLEVEL_PUBLIC | (for_me ? MSGLEVEL_NOHILIGHT : 0),
|
||||
for_me ? IRCTXT_PUBMSG_ME_CHANNEL : IRCTXT_PUBMSG_CHANNEL,
|
||||
nick, target, msg, nickmode);
|
||||
}
|
||||
}
|
||||
|
||||
g_free_not_null(color);
|
||||
level = MSGLEVEL_PUBLIC;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* private message */
|
||||
if (settings_get_bool("autocreate_query") && query_find(server, nick) == NULL)
|
||||
item = (WI_ITEM_REC *) query_create(server, nick, TRUE);
|
||||
else
|
||||
item = (WI_ITEM_REC *) query_find(server, nick);
|
||||
}
|
||||
|
||||
printformat(server, nick, MSGLEVEL_MSGS,
|
||||
item == NULL ? IRCTXT_MSG_PRIVATE : IRCTXT_MSG_PRIVATE_QUERY, nick, addr == NULL ? "" : addr, msg);
|
||||
level = MSGLEVEL_MSGS;
|
||||
}
|
||||
static void event_privmsg(const char *data, IRC_SERVER_REC *server, const char *nick, const char *addr)
|
||||
{
|
||||
WI_ITEM_REC *item;
|
||||
char *params, *target, *msg;
|
||||
|
||||
msg_beep_check(server, level);
|
||||
g_return_if_fail(data != NULL);
|
||||
|
||||
g_free(params);
|
||||
params = event_get_params(data, 2 | PARAM_FLAG_GETREST, &target, &msg);
|
||||
if (nick == NULL) nick = server->real_address;
|
||||
if (addr == NULL) addr = "";
|
||||
|
||||
if (!ignore_check(server, nick, addr, target, msg, target_level(target))) {
|
||||
if (ischannel(*target)) {
|
||||
/* message to channel */
|
||||
print_channel_msg(server, nick, addr, target, msg);
|
||||
} else {
|
||||
/* private message */
|
||||
item = (WI_ITEM_REC *) privmsg_get_query(server, nick);
|
||||
printformat(server, nick, MSGLEVEL_MSGS,
|
||||
item == NULL ? IRCTXT_MSG_PRIVATE : IRCTXT_MSG_PRIVATE_QUERY, nick, addr, msg);
|
||||
}
|
||||
msg_beep_check(server, target_level(target));
|
||||
}
|
||||
|
||||
g_free(params);
|
||||
}
|
||||
|
||||
/* we use "ctcp msg" here because "ctcp msg action" can be ignored with
|
||||
/IGNORE * CTCPS */
|
||||
static void ctcp_action_msg(gchar *data, IRC_SERVER_REC *server, gchar *nick, gchar *addr, gchar *target)
|
||||
/IGNORE * CTCPS, and we don't want that.. */
|
||||
static void ctcp_msg_check_action(gchar *data, IRC_SERVER_REC *server, gchar *nick, gchar *addr, gchar *target)
|
||||
{
|
||||
WINDOW_REC *window;
|
||||
CHANNEL_REC *channel;
|
||||
WI_ITEM_REC *item;
|
||||
int level;
|
||||
WI_ITEM_REC *item;
|
||||
|
||||
g_return_if_fail(data != NULL);
|
||||
g_return_if_fail(data != NULL);
|
||||
|
||||
if (g_strncasecmp(data, "ACTION ", 7) != 0)
|
||||
return;
|
||||
data += 7;
|
||||
if (g_strncasecmp(data, "ACTION ", 7) != 0)
|
||||
return;
|
||||
data += 7;
|
||||
|
||||
level = 0;
|
||||
if (ignore_check(server, nick, addr, target, data, MSGLEVEL_ACTIONS))
|
||||
{
|
||||
/* ignored */
|
||||
}
|
||||
else if (ischannel(*target))
|
||||
{
|
||||
/* channel action */
|
||||
channel = channel_find(server, target);
|
||||
if (ignore_check(server, nick, addr, target, data, MSGLEVEL_ACTIONS))
|
||||
return;
|
||||
|
||||
window = channel == NULL ? NULL : window_item_window((WI_ITEM_REC *) channel);
|
||||
if (window != NULL && window->active == (WI_ITEM_REC *) channel)
|
||||
{
|
||||
/* message to active channel in window */
|
||||
printformat(server, target, MSGLEVEL_ACTIONS,
|
||||
IRCTXT_ACTION_PUBLIC, nick, data);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* message to not existing/active channel */
|
||||
printformat(server, target, MSGLEVEL_ACTIONS,
|
||||
IRCTXT_ACTION_PUBLIC_CHANNEL, nick, target, data);
|
||||
if (ischannel(*target)) {
|
||||
/* channel action */
|
||||
item = (WI_ITEM_REC *) channel_find(server, target);
|
||||
|
||||
if (window_item_is_active(item)) {
|
||||
/* message to active channel in window */
|
||||
printformat(server, target, MSGLEVEL_ACTIONS,
|
||||
IRCTXT_ACTION_PUBLIC, nick, data);
|
||||
} else {
|
||||
/* message to not existing/active channel */
|
||||
printformat(server, target, MSGLEVEL_ACTIONS,
|
||||
IRCTXT_ACTION_PUBLIC_CHANNEL, nick, target, data);
|
||||
}
|
||||
} else {
|
||||
/* private action */
|
||||
item = (WI_ITEM_REC *) privmsg_get_query(server, nick);
|
||||
printformat(server, nick, MSGLEVEL_ACTIONS,
|
||||
item == NULL ? IRCTXT_ACTION_PRIVATE : IRCTXT_ACTION_PRIVATE_QUERY,
|
||||
nick, addr == NULL ? "" : addr, data);
|
||||
}
|
||||
level = MSGLEVEL_PUBLIC;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* private action */
|
||||
if (settings_get_bool("autocreate_query") && query_find(server, nick) == NULL)
|
||||
item = (WI_ITEM_REC *) query_create(server, nick, TRUE);
|
||||
else
|
||||
item = (WI_ITEM_REC *) channel_find(server, nick);
|
||||
|
||||
printformat(server, nick, MSGLEVEL_ACTIONS,
|
||||
item == NULL ? IRCTXT_ACTION_PRIVATE : IRCTXT_ACTION_PRIVATE_QUERY, nick, addr == NULL ? "" : addr, data);
|
||||
level = MSGLEVEL_MSGS;
|
||||
}
|
||||
|
||||
msg_beep_check(server, level);
|
||||
msg_beep_check(server, target_level(target));
|
||||
}
|
||||
|
||||
static void event_notice(gchar *data, IRC_SERVER_REC *server, gchar *nick, gchar *addr)
|
||||
static void event_notice(const char *data, IRC_SERVER_REC *server, const char *nick, const char *addr)
|
||||
{
|
||||
char *params, *target, *msg;
|
||||
int level;
|
||||
char *params, *target, *msg;
|
||||
int op_notice;
|
||||
|
||||
g_return_if_fail(data != NULL);
|
||||
g_return_if_fail(data != NULL);
|
||||
|
||||
params = event_get_params(data, 2 | PARAM_FLAG_GETREST, &target, &msg);
|
||||
if (nick == NULL) nick = server->real_address;
|
||||
params = event_get_params(data, 2 | PARAM_FLAG_GETREST, &target, &msg);
|
||||
if (nick == NULL) {
|
||||
nick = server->real_address == NULL ?
|
||||
server->connrec->address :
|
||||
server->real_address;
|
||||
}
|
||||
|
||||
level = 0;
|
||||
if (*msg == 1)
|
||||
{
|
||||
/* ctcp reply */
|
||||
}
|
||||
else if (addr == NULL)
|
||||
{
|
||||
/* notice from server */
|
||||
if (nick == NULL || !ignore_check(server, nick, "", target, msg, MSGLEVEL_SNOTES))
|
||||
printformat(server, target, MSGLEVEL_SNOTES, IRCTXT_NOTICE_SERVER, nick == NULL ? "" : nick, msg);
|
||||
}
|
||||
else if (ischannel(*target) || (*target == '@' && ischannel(target[1])))
|
||||
{
|
||||
/* notice in some channel */
|
||||
if (!ignore_check(server, nick, addr, target, msg, MSGLEVEL_NOTICES))
|
||||
printformat(server, target, MSGLEVEL_NOTICES,
|
||||
*target == '@' ? IRCTXT_NOTICE_PUBLIC_OPS : IRCTXT_NOTICE_PUBLIC,
|
||||
nick, *target == '@' ? target+1 : target, msg);
|
||||
level = MSGLEVEL_NOTICES;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* private notice */
|
||||
if (!ignore_check(server, nick, addr, NULL, msg, MSGLEVEL_NOTICES))
|
||||
printformat(server, nick, MSGLEVEL_NOTICES, IRCTXT_NOTICE_PRIVATE, nick, addr, msg);
|
||||
level = MSGLEVEL_NOTICES;
|
||||
}
|
||||
if (addr == NULL) {
|
||||
/* notice from server */
|
||||
if (*msg != 1 && !ignore_check(server, nick, "", target, msg, MSGLEVEL_SNOTES))
|
||||
printformat(server, target, MSGLEVEL_SNOTES, IRCTXT_NOTICE_SERVER, nick, msg);
|
||||
} else {
|
||||
op_notice = *target == '@' && ischannel(target[1]);
|
||||
if (op_notice) target++;
|
||||
|
||||
msg_beep_check(server, level);
|
||||
if (ischannel(*target)) {
|
||||
/* notice in some channel */
|
||||
if (!ignore_check(server, nick, addr, target, msg, MSGLEVEL_NOTICES))
|
||||
printformat(server, target, MSGLEVEL_NOTICES,
|
||||
op_notice ? IRCTXT_NOTICE_PUBLIC_OPS : IRCTXT_NOTICE_PUBLIC,
|
||||
nick, target, msg);
|
||||
} else {
|
||||
/* private notice */
|
||||
if (!ignore_check(server, nick, addr, NULL, msg, MSGLEVEL_NOTICES))
|
||||
printformat(server, nick, MSGLEVEL_NOTICES, IRCTXT_NOTICE_PRIVATE, nick, addr, msg);
|
||||
}
|
||||
}
|
||||
|
||||
g_free(params);
|
||||
msg_beep_check(server, addr == NULL ? MSGLEVEL_SNOTES : MSGLEVEL_NOTICES);
|
||||
g_free(params);
|
||||
}
|
||||
|
||||
static void event_join(const char *data, IRC_SERVER_REC *server, const char *nick, const char *addr)
|
||||
@ -468,12 +427,13 @@ static void event_wallops(const char *data, IRC_SERVER_REC *server, const char *
|
||||
else {
|
||||
/* Action in WALLOP */
|
||||
int len;
|
||||
char *tmp;
|
||||
|
||||
data = g_strdup(data);
|
||||
len = strlen(data);
|
||||
if (data[len-1] == 1) data[len-1] = '\0';
|
||||
printformat(server, NULL, MSGLEVEL_WALLOPS, IRCTXT_ACTION_WALLOPS, nick, data);
|
||||
g_free(data);
|
||||
tmp = g_strdup(data);
|
||||
len = strlen(tmp);
|
||||
if (tmp[len-1] == 1) tmp[len-1] = '\0';
|
||||
printformat(server, NULL, MSGLEVEL_WALLOPS, IRCTXT_ACTION_WALLOPS, nick, tmp);
|
||||
g_free(tmp);
|
||||
}
|
||||
msg_beep_check(server, MSGLEVEL_WALLOPS);
|
||||
}
|
||||
@ -488,7 +448,7 @@ static void channel_sync(CHANNEL_REC *channel)
|
||||
|
||||
static void event_connected(IRC_SERVER_REC *server)
|
||||
{
|
||||
char *nick;
|
||||
const char *nick;
|
||||
|
||||
g_return_if_fail(server != NULL);
|
||||
|
||||
@ -632,7 +592,7 @@ void fe_events_init(void)
|
||||
|
||||
read_settings();
|
||||
signal_add("event privmsg", (SIGNAL_FUNC) event_privmsg);
|
||||
signal_add("ctcp msg", (SIGNAL_FUNC) ctcp_action_msg);
|
||||
signal_add("ctcp msg", (SIGNAL_FUNC) ctcp_msg_check_action);
|
||||
signal_add("ctcp msg action", (SIGNAL_FUNC) sig_empty);
|
||||
signal_add("event notice", (SIGNAL_FUNC) event_notice);
|
||||
signal_add("event join", (SIGNAL_FUNC) event_join);
|
||||
@ -665,7 +625,7 @@ void fe_events_init(void)
|
||||
void fe_events_deinit(void)
|
||||
{
|
||||
signal_remove("event privmsg", (SIGNAL_FUNC) event_privmsg);
|
||||
signal_remove("ctcp msg", (SIGNAL_FUNC) ctcp_action_msg);
|
||||
signal_remove("ctcp msg", (SIGNAL_FUNC) ctcp_msg_check_action);
|
||||
signal_remove("ctcp msg action", (SIGNAL_FUNC) sig_empty);
|
||||
signal_remove("event notice", (SIGNAL_FUNC) event_notice);
|
||||
signal_remove("event join", (SIGNAL_FUNC) event_join);
|
||||
|
@ -33,6 +33,7 @@
|
||||
#include "channels.h"
|
||||
#include "query.h"
|
||||
|
||||
#include "fe-query.h"
|
||||
#include "windows.h"
|
||||
#include "window-items.h"
|
||||
|
||||
@ -153,11 +154,7 @@ static void cmd_msg(gchar *data, IRC_SERVER_REC *server, WI_ITEM_REC *item)
|
||||
else
|
||||
{
|
||||
/* private message */
|
||||
if (settings_get_bool("autocreate_query") && query_find(server, target) == NULL)
|
||||
item = (WI_ITEM_REC *) query_create(server, target, FALSE);
|
||||
else
|
||||
item = (WI_ITEM_REC *) query_find(server, target);
|
||||
|
||||
item = (WI_ITEM_REC *) privmsg_get_query(server, target);
|
||||
printformat(server, target, MSGLEVEL_MSGS | MSGLEVEL_NOHILIGHT,
|
||||
item == NULL ? IRCTXT_OWN_MSG_PRIVATE : IRCTXT_OWN_MSG_PRIVATE_QUERY, target, msg, server->nick);
|
||||
}
|
||||
|
@ -34,6 +34,18 @@
|
||||
|
||||
static int queryclose_tag, query_auto_close;
|
||||
|
||||
/* Return query where to put the private message. */
|
||||
QUERY_REC *privmsg_get_query(IRC_SERVER_REC *server, const char *nick)
|
||||
{
|
||||
QUERY_REC *query;
|
||||
|
||||
query = query_find(server, nick);
|
||||
if (query == NULL && settings_get_bool("autocreate_query"))
|
||||
query = query_create(server, nick, TRUE);
|
||||
|
||||
return query;
|
||||
}
|
||||
|
||||
static void signal_query_created(QUERY_REC *query, gpointer automatic)
|
||||
{
|
||||
window_item_create((WI_ITEM_REC *) query, GPOINTER_TO_INT(automatic));
|
||||
|
7
src/fe-common/irc/fe-query.h
Normal file
7
src/fe-common/irc/fe-query.h
Normal file
@ -0,0 +1,7 @@
|
||||
#ifndef __FE_QUERY_H
|
||||
#define __FE_QUERY_H
|
||||
|
||||
/* Return query where to put the private message. */
|
||||
QUERY_REC *privmsg_get_query(IRC_SERVER_REC *server, const char *nick);
|
||||
|
||||
#endif
|
@ -42,12 +42,6 @@ static void event_privmsg(const char *data, IRC_SERVER_REC *server, const char *
|
||||
|
||||
params = event_get_params(data, 2 | PARAM_FLAG_GETREST, &target, &msg);
|
||||
|
||||
if (*msg == 1) {
|
||||
/* don't hilight CTCPs */
|
||||
g_free(params);
|
||||
return;
|
||||
}
|
||||
|
||||
/* get window and window item */
|
||||
level = ischannel(*target) ? MSGLEVEL_PUBLIC : MSGLEVEL_MSGS;
|
||||
item = window_item_find(server, ischannel(*target) ? target : nick);
|
||||
|
@ -171,7 +171,7 @@ FORMAT_REC fecommon_irc_formats[] = {
|
||||
{ NULL, "CTCPs", 0 },
|
||||
|
||||
{ "ctcp_reply", "CTCP %_$0%_ reply from %_$1%_%K:%n $2", 3, { 0, 0, 0 } },
|
||||
{ "ctcp_reply_channel", "CTCP %_$0%_ reply from %_$1%_ in channel %_$4%_%K:%n $2", 4, { 0, 0, 0, 0 } },
|
||||
{ "ctcp_reply_channel", "CTCP %_$0%_ reply from %_$1%_ in channel %_$3%_%K:%n $2", 4, { 0, 0, 0, 0 } },
|
||||
{ "ctcp_ping_reply", "CTCP %_PING%_ reply from %_$0%_: $1.$2 seconds", 3, { 0, 2, 2 } },
|
||||
{ "ctcp_requested", "%g>>> %_$0%_ %K[%g$1%K] %grequested %_$2%_ from %_$3", 4, { 0, 0, 0, 0 } },
|
||||
|
||||
|
@ -39,9 +39,7 @@ static void event_privmsg(const char *data, IRC_SERVER_REC *server,
|
||||
g_return_if_fail(data != NULL);
|
||||
|
||||
params = event_get_params(data, 2 | PARAM_FLAG_GETREST, &target, &msg);
|
||||
if (nick == NULL) nick = server->real_address;
|
||||
|
||||
if (*msg == 1 || ischannel(*target)) {
|
||||
if (ischannel(*target)) {
|
||||
g_free(params);
|
||||
return;
|
||||
}
|
||||
|
@ -156,6 +156,7 @@ static void event_privmsg(const char *data, IRC_SERVER_REC *server, const char *
|
||||
if (ptr != NULL) *ptr = '\0';
|
||||
|
||||
signal_emit("ctcp msg", 5, msg, server, nick, addr, target);
|
||||
signal_stop();
|
||||
}
|
||||
|
||||
g_free(params);
|
||||
@ -167,7 +168,7 @@ static void event_notice(const char *data, IRC_SERVER_REC *server, const char *n
|
||||
|
||||
g_return_if_fail(data != NULL);
|
||||
|
||||
params = event_get_params(data, 2, &target, &msg); /* Channel or nick name */
|
||||
params = event_get_params(data, 2, &target, &msg);
|
||||
|
||||
/* handle only ctcp replies */
|
||||
if (*msg == 1) {
|
||||
@ -175,6 +176,7 @@ static void event_notice(const char *data, IRC_SERVER_REC *server, const char *n
|
||||
if (ptr != NULL) *ptr = '\0';
|
||||
|
||||
signal_emit("ctcp reply", 5, msg, server, nick, addr, target);
|
||||
signal_stop();
|
||||
}
|
||||
|
||||
g_free(params);
|
||||
@ -193,8 +195,8 @@ void ctcp_init(void)
|
||||
settings_add_int("flood", "max_ctcp_queue", 5);
|
||||
|
||||
signal_add("server disconnected", (SIGNAL_FUNC) ctcp_deinit_server);
|
||||
signal_add("event privmsg", (SIGNAL_FUNC) event_privmsg);
|
||||
signal_add("event notice", (SIGNAL_FUNC) event_notice);
|
||||
signal_add_first("event privmsg", (SIGNAL_FUNC) event_privmsg);
|
||||
signal_add_first("event notice", (SIGNAL_FUNC) event_notice);
|
||||
signal_add("ctcp msg", (SIGNAL_FUNC) ctcp_msg);
|
||||
signal_add("ctcp reply", (SIGNAL_FUNC) ctcp_reply);
|
||||
signal_add("ctcp msg ping", (SIGNAL_FUNC) ctcp_ping);
|
||||
|
@ -367,7 +367,9 @@ static void event_connected(const char *data, IRC_SERVER_REC *server, const char
|
||||
|
||||
if (server->real_address == NULL) {
|
||||
/* set the server address */
|
||||
server->real_address = g_strdup(from);
|
||||
server->real_address = from == NULL ?
|
||||
g_strdup(server->connrec->address) : /* shouldn't happen.. */
|
||||
g_strdup(from);
|
||||
}
|
||||
|
||||
/* last welcome message found - commands can be sent to server now. */
|
||||
|
@ -223,14 +223,12 @@ static void event_privmsg(const char *data, IRC_SERVER_REC *server, const char *
|
||||
|
||||
params = event_get_params(data, 2 | PARAM_FLAG_GETREST, &target, &msg);
|
||||
|
||||
if (*msg != 1) {
|
||||
if (!ischannel(*target)) {
|
||||
g_free_not_null(last_privmsg_from);
|
||||
last_privmsg_from = g_strdup(nick);
|
||||
} else {
|
||||
g_free_not_null(last_public_from);
|
||||
last_public_from = g_strdup(nick);
|
||||
}
|
||||
if (!ischannel(*target)) {
|
||||
g_free_not_null(last_privmsg_from);
|
||||
last_privmsg_from = g_strdup(nick);
|
||||
} else {
|
||||
g_free_not_null(last_public_from);
|
||||
last_public_from = g_strdup(nick);
|
||||
}
|
||||
|
||||
g_free(params);
|
||||
|
@ -113,7 +113,7 @@ static void event_privmsg(const char *data, IRC_SERVER_REC *server, const char *
|
||||
|
||||
params = event_get_params(data, 2 | PARAM_FLAG_GETREST, &target, &msg);
|
||||
|
||||
if (addr != NULL && *msg != 1 && !ischannel(*target)) {
|
||||
if (addr != NULL && !ischannel(*target)) {
|
||||
/* save nick's address to query */
|
||||
query = query_find(server, nick);
|
||||
if (query != NULL && (query->address == NULL || strcmp(query->address, addr) != 0)) {
|
||||
|
@ -195,7 +195,7 @@ static void flood_privmsg(const char *data, IRC_SERVER_REC *server, const char *
|
||||
g_return_if_fail(data != NULL);
|
||||
g_return_if_fail(server != NULL);
|
||||
|
||||
if (nick == NULL) {
|
||||
if (nick == NULL || addr == NULL) {
|
||||
/* don't try to ignore server messages.. */
|
||||
return;
|
||||
}
|
||||
@ -223,18 +223,32 @@ static void flood_notice(const char *data, IRC_SERVER_REC *server, const char *n
|
||||
g_return_if_fail(data != NULL);
|
||||
g_return_if_fail(server != NULL);
|
||||
|
||||
if (nick == NULL) {
|
||||
if (nick == NULL || addr == NULL) {
|
||||
/* don't try to ignore server messages.. */
|
||||
return;
|
||||
}
|
||||
|
||||
params = event_get_params(data, 2, &target, &text);
|
||||
if (addr != NULL && !ignore_check(server, nick, addr, target, text, MSGLEVEL_NOTICES))
|
||||
flood_newmsg(server, MSGLEVEL_NOTICES | ischannel(*target) ? MSGLEVEL_PUBLIC : MSGLEVEL_MSGS, nick, addr, target);
|
||||
if (!ignore_check(server, nick, addr, target, text, MSGLEVEL_NOTICES))
|
||||
flood_newmsg(server, MSGLEVEL_NOTICES, nick, addr, target);
|
||||
|
||||
g_free(params);
|
||||
}
|
||||
|
||||
static void flood_ctcp(const char *data, IRC_SERVER_REC *server, const char *nick, const char *addr, const char *target)
|
||||
{
|
||||
g_return_if_fail(data != NULL);
|
||||
g_return_if_fail(server != NULL);
|
||||
|
||||
if (nick == NULL || addr == NULL) {
|
||||
/* don't try to ignore server messages.. */
|
||||
return;
|
||||
}
|
||||
|
||||
if (!ignore_check(server, nick, addr, target, data, MSGLEVEL_CTCPS))
|
||||
flood_newmsg(server, MSGLEVEL_CTCPS, nick, addr, target);
|
||||
}
|
||||
|
||||
static void read_settings(void)
|
||||
{
|
||||
int time;
|
||||
@ -255,6 +269,8 @@ static void read_settings(void)
|
||||
flood_tag = g_timeout_add(time, (GSourceFunc) flood_timeout, NULL);
|
||||
signal_add("event privmsg", (SIGNAL_FUNC) flood_privmsg);
|
||||
signal_add("event notice", (SIGNAL_FUNC) flood_notice);
|
||||
signal_add("ctcp msg", (SIGNAL_FUNC) flood_ctcp);
|
||||
signal_add("ctcp reply", (SIGNAL_FUNC) flood_ctcp);
|
||||
}
|
||||
}
|
||||
|
||||
@ -280,6 +296,8 @@ void irc_flood_deinit(void)
|
||||
g_source_remove(flood_tag);
|
||||
signal_remove("event privmsg", (SIGNAL_FUNC) flood_privmsg);
|
||||
signal_remove("event notice", (SIGNAL_FUNC) flood_notice);
|
||||
signal_remove("ctcp msg", (SIGNAL_FUNC) flood_ctcp);
|
||||
signal_remove("ctcp reply", (SIGNAL_FUNC) flood_ctcp);
|
||||
}
|
||||
|
||||
signal_remove("setup changed", (SIGNAL_FUNC) read_settings);
|
||||
|
Loading…
Reference in New Issue
Block a user