1
0
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:
Timo Sirainen 2000-06-12 22:57:53 +00:00 committed by cras
parent 919abb2c6f
commit 18f3c74d68
19 changed files with 221 additions and 219 deletions

View File

@ -125,7 +125,7 @@ static void cmd_window_next(void)
{ {
int num; int num;
num = window_refnum_next(active_win->refnum); num = window_refnum_next(active_win->refnum, TRUE);
if (num < 1) num = windows_refnum_last(); if (num < 1) num = windows_refnum_last();
window_set_active(window_find_refnum(num)); window_set_active(window_find_refnum(num));
@ -135,8 +135,8 @@ static void cmd_window_prev(void)
{ {
int num; int num;
num = window_refnum_prev(active_win->refnum); num = window_refnum_prev(active_win->refnum, TRUE);
if (num < 1) num = window_refnum_next(0); if (num < 1) num = window_refnum_next(0, TRUE);
window_set_active(window_find_refnum(num)); window_set_active(window_find_refnum(num));
} }
@ -239,9 +239,9 @@ static void cmd_window_move_left(void)
{ {
int refnum; int refnum;
refnum = window_refnum_prev(active_win->refnum); refnum = window_refnum_prev(active_win->refnum, TRUE);
if (refnum != -1) { if (refnum != -1) {
window_set_refnum(active_win, active_win->refnum-1); window_set_refnum(active_win, refnum);
return; return;
} }
@ -252,9 +252,9 @@ static void cmd_window_move_right(void)
{ {
int refnum; int refnum;
refnum = window_refnum_next(active_win->refnum); refnum = window_refnum_next(active_win->refnum, TRUE);
if (refnum != -1) { if (refnum != -1) {
window_set_refnum(active_win, active_win->refnum+1); window_set_refnum(active_win, refnum);
return; return;
} }
@ -273,7 +273,7 @@ static void cmd_window_move(const char *data, SERVER_REC *server, WI_ITEM_REC *i
new_refnum = atoi(data); new_refnum = atoi(data);
if (new_refnum > active_win->refnum) { if (new_refnum > active_win->refnum) {
for (;;) { for (;;) {
refnum = window_refnum_next(active_win->refnum); refnum = window_refnum_next(active_win->refnum, FALSE);
if (refnum == -1 || refnum > new_refnum) if (refnum == -1 || refnum > new_refnum)
break; break;
@ -281,7 +281,7 @@ static void cmd_window_move(const char *data, SERVER_REC *server, WI_ITEM_REC *i
} }
} else { } else {
for (;;) { for (;;) {
refnum = window_refnum_prev(active_win->refnum); refnum = window_refnum_prev(active_win->refnum, FALSE);
if (refnum == -1 || refnum < new_refnum) if (refnum == -1 || refnum < new_refnum)
break; break;

View File

@ -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) void window_item_prev(WINDOW_REC *window)
{ {
WI_ITEM_REC *last; WI_ITEM_REC *last;

View File

@ -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_change_server(WI_ITEM_REC *item, void *server);
void window_item_set_active(WINDOW_REC *window, WI_ITEM_REC *item); 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_prev(WINDOW_REC *window);
void window_item_next(WINDOW_REC *window); void window_item_next(WINDOW_REC *window);

View File

@ -306,7 +306,7 @@ WINDOW_REC *window_find_item(WINDOW_REC *window, const char *name)
return MODULE_DATA(item); return MODULE_DATA(item);
} }
int window_refnum_prev(int refnum) int window_refnum_prev(int refnum, int wrap)
{ {
GSList *tmp; GSList *tmp;
int prev, max; int prev, max;
@ -317,14 +317,14 @@ int window_refnum_prev(int refnum)
if (rec->refnum < refnum && (prev == -1 || rec->refnum > prev)) if (rec->refnum < refnum && (prev == -1 || rec->refnum > prev))
prev = rec->refnum; prev = rec->refnum;
if (max == -1 || rec->refnum > max) if (wrap && (max == -1 || rec->refnum > max))
max = rec->refnum; max = rec->refnum;
} }
return prev != -1 ? prev : max; return prev != -1 ? prev : max;
} }
int window_refnum_next(int refnum) int window_refnum_next(int refnum, int wrap)
{ {
GSList *tmp; GSList *tmp;
int min, next; int min, next;
@ -335,7 +335,7 @@ int window_refnum_next(int refnum)
if (rec->refnum > refnum && (next == -1 || rec->refnum < next)) if (rec->refnum > refnum && (next == -1 || rec->refnum < next))
next = rec->refnum; next = rec->refnum;
if (min == -1 || rec->refnum < min) if (wrap && (min == -1 || rec->refnum < min))
min = rec->refnum; min = rec->refnum;
} }

View File

@ -69,8 +69,8 @@ WINDOW_REC *window_find_refnum(int refnum);
WINDOW_REC *window_find_name(const char *name); WINDOW_REC *window_find_name(const char *name);
WINDOW_REC *window_find_item(WINDOW_REC *window, const char *name); WINDOW_REC *window_find_item(WINDOW_REC *window, const char *name);
int window_refnum_prev(int refnum); int window_refnum_prev(int refnum, int wrap);
int window_refnum_next(int refnum); int window_refnum_next(int refnum, int wrap);
int windows_refnum_last(void); int windows_refnum_last(void);
void windows_init(void); void windows_init(void);

View File

@ -32,6 +32,7 @@ libfe_common_irc_la_SOURCES = \
noinst_HEADERS = \ noinst_HEADERS = \
completion.h \ completion.h \
fe-common-irc.h \ fe-common-irc.h \
fe-query.h \
irc-hilight-text.h \ irc-hilight-text.h \
module.h \ module.h \
module-formats.h module-formats.h

View File

@ -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); params = event_get_params(data, 2 | PARAM_FLAG_GETREST, &target, &msg);
if (*msg == 1)
{
/* ignore ctcp messages */
g_free(params);
return;
}
if (ischannel(*target)) if (ischannel(*target))
{ {
/* channel message */ /* channel message */

View File

@ -34,11 +34,15 @@
#include "ignore.h" #include "ignore.h"
#include "netsplit.h" #include "netsplit.h"
#include "fe-query.h"
#include "irc-hilight-text.h" #include "irc-hilight-text.h"
#include "windows.h" #include "windows.h"
#include "completion.h" #include "completion.h"
#define target_level(target) \
(ischannel((target)[0]) ? MSGLEVEL_PUBLIC : MSGLEVEL_MSGS)
static int beep_msg_level, beep_when_away; static int beep_msg_level, beep_when_away;
static void msg_beep_check(IRC_SERVER_REC *server, int level) static void msg_beep_check(IRC_SERVER_REC *server, int level)
@ -49,106 +53,79 @@ 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; 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;
NICK_REC *nickrec; NICK_REC *nickrec;
gboolean toyou; int for_me;
gchar *color; char *color, *nickmode;
chanrec = channel_find(server, target); 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); color = irc_hilight_find_nick(target, nick, addr);
nickrec = chanrec == NULL ? NULL : nicklist_find(chanrec, nick); nickrec = chanrec == NULL ? NULL : nicklist_find(chanrec, nick);
nickmode = !settings_get_bool("show_nickmode") || nickrec == NULL ? "" : nickmode = (!settings_get_bool("show_nickmode") || nickrec == NULL) ? "" :
nickrec->op ? "@" : nickrec->voice ? "+" : " "; (nickrec->op ? "@" : nickrec->voice ? "+" : " ");
window = chanrec == NULL ? NULL : window_item_window((WI_ITEM_REC *) chanrec); if (window_item_is_active((WI_ITEM_REC *) chanrec)) {
if (window != NULL && window->active == (WI_ITEM_REC *) chanrec)
{
/* message to active channel in window */ /* message to active channel in window */
if (color != NULL) if (color != NULL) {
{
/* highlighted nick */ /* highlighted nick */
printformat(server, target, MSGLEVEL_PUBLIC | MSGLEVEL_NOHILIGHT, printformat(server, target, MSGLEVEL_PUBLIC | MSGLEVEL_NOHILIGHT,
IRCTXT_PUBMSG_HILIGHT, color, nick, msg, nickmode); 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 } 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 */ /* message to not existing/active channel */
if (color != NULL) if (color != NULL) {
{
/* highlighted nick */ /* highlighted nick */
printformat(server, target, MSGLEVEL_PUBLIC | MSGLEVEL_NOHILIGHT, printformat(server, target, MSGLEVEL_PUBLIC | MSGLEVEL_NOHILIGHT,
IRCTXT_PUBMSG_HILIGHT_CHANNEL, color, nick, target, msg, nickmode); IRCTXT_PUBMSG_HILIGHT_CHANNEL, color, nick, target, msg, nickmode);
} } else {
else printformat(server, target, MSGLEVEL_PUBLIC | (for_me ? MSGLEVEL_NOHILIGHT : 0),
{ for_me ? IRCTXT_PUBMSG_ME_CHANNEL : IRCTXT_PUBMSG_CHANNEL,
printformat(server, target, MSGLEVEL_PUBLIC | (toyou ? MSGLEVEL_NOHILIGHT : 0),
toyou ? IRCTXT_PUBMSG_ME_CHANNEL : IRCTXT_PUBMSG_CHANNEL,
nick, target, msg, nickmode); nick, target, msg, nickmode);
} }
} }
g_free_not_null(color); g_free_not_null(color);
level = MSGLEVEL_PUBLIC;
} }
else
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;
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 (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 */ /* private message */
if (settings_get_bool("autocreate_query") && query_find(server, nick) == NULL) item = (WI_ITEM_REC *) privmsg_get_query(server, nick);
item = (WI_ITEM_REC *) query_create(server, nick, TRUE);
else
item = (WI_ITEM_REC *) query_find(server, nick);
printformat(server, nick, MSGLEVEL_MSGS, printformat(server, nick, MSGLEVEL_MSGS,
item == NULL ? IRCTXT_MSG_PRIVATE : IRCTXT_MSG_PRIVATE_QUERY, nick, addr == NULL ? "" : addr, msg); item == NULL ? IRCTXT_MSG_PRIVATE : IRCTXT_MSG_PRIVATE_QUERY, nick, addr, msg);
level = MSGLEVEL_MSGS; }
msg_beep_check(server, target_level(target));
} }
msg_beep_check(server, level);
g_free(params); g_free(params);
} }
/* we use "ctcp msg" here because "ctcp msg action" can be ignored with /* we use "ctcp msg" here because "ctcp msg action" can be ignored with
/IGNORE * CTCPS */ /IGNORE * CTCPS, and we don't want that.. */
static void ctcp_action_msg(gchar *data, IRC_SERVER_REC *server, gchar *nick, gchar *addr, gchar *target) 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; WI_ITEM_REC *item;
int level;
g_return_if_fail(data != NULL); g_return_if_fail(data != NULL);
@ -156,87 +133,69 @@ static void ctcp_action_msg(gchar *data, IRC_SERVER_REC *server, gchar *nick, gc
return; return;
data += 7; data += 7;
level = 0;
if (ignore_check(server, nick, addr, target, data, MSGLEVEL_ACTIONS)) if (ignore_check(server, nick, addr, target, data, MSGLEVEL_ACTIONS))
{ return;
/* ignored */
}
else if (ischannel(*target))
{
/* channel action */
channel = channel_find(server, target);
window = channel == NULL ? NULL : window_item_window((WI_ITEM_REC *) channel); if (ischannel(*target)) {
if (window != NULL && window->active == (WI_ITEM_REC *) channel) /* channel action */
{ item = (WI_ITEM_REC *) channel_find(server, target);
if (window_item_is_active(item)) {
/* message to active channel in window */ /* message to active channel in window */
printformat(server, target, MSGLEVEL_ACTIONS, printformat(server, target, MSGLEVEL_ACTIONS,
IRCTXT_ACTION_PUBLIC, nick, data); IRCTXT_ACTION_PUBLIC, nick, data);
} } else {
else
{
/* message to not existing/active channel */ /* message to not existing/active channel */
printformat(server, target, MSGLEVEL_ACTIONS, printformat(server, target, MSGLEVEL_ACTIONS,
IRCTXT_ACTION_PUBLIC_CHANNEL, nick, target, data); IRCTXT_ACTION_PUBLIC_CHANNEL, nick, target, data);
} }
level = MSGLEVEL_PUBLIC; } else {
}
else
{
/* private action */ /* private action */
if (settings_get_bool("autocreate_query") && query_find(server, nick) == NULL) item = (WI_ITEM_REC *) privmsg_get_query(server, nick);
item = (WI_ITEM_REC *) query_create(server, nick, TRUE);
else
item = (WI_ITEM_REC *) channel_find(server, nick);
printformat(server, nick, MSGLEVEL_ACTIONS, printformat(server, nick, MSGLEVEL_ACTIONS,
item == NULL ? IRCTXT_ACTION_PRIVATE : IRCTXT_ACTION_PRIVATE_QUERY, nick, addr == NULL ? "" : addr, data); item == NULL ? IRCTXT_ACTION_PRIVATE : IRCTXT_ACTION_PRIVATE_QUERY,
level = MSGLEVEL_MSGS; nick, addr == NULL ? "" : addr, data);
} }
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; char *params, *target, *msg;
int level; 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); params = event_get_params(data, 2 | PARAM_FLAG_GETREST, &target, &msg);
if (nick == NULL) nick = server->real_address; if (nick == NULL) {
nick = server->real_address == NULL ?
server->connrec->address :
server->real_address;
}
level = 0; if (addr == NULL) {
if (*msg == 1)
{
/* ctcp reply */
}
else if (addr == NULL)
{
/* notice from server */ /* notice from server */
if (nick == NULL || !ignore_check(server, nick, "", target, msg, MSGLEVEL_SNOTES)) if (*msg != 1 && !ignore_check(server, nick, "", target, msg, MSGLEVEL_SNOTES))
printformat(server, target, MSGLEVEL_SNOTES, IRCTXT_NOTICE_SERVER, nick == NULL ? "" : nick, msg); printformat(server, target, MSGLEVEL_SNOTES, IRCTXT_NOTICE_SERVER, nick, msg);
} } else {
else if (ischannel(*target) || (*target == '@' && ischannel(target[1]))) op_notice = *target == '@' && ischannel(target[1]);
{ if (op_notice) target++;
if (ischannel(*target)) {
/* notice in some channel */ /* notice in some channel */
if (!ignore_check(server, nick, addr, target, msg, MSGLEVEL_NOTICES)) if (!ignore_check(server, nick, addr, target, msg, MSGLEVEL_NOTICES))
printformat(server, target, MSGLEVEL_NOTICES, printformat(server, target, MSGLEVEL_NOTICES,
*target == '@' ? IRCTXT_NOTICE_PUBLIC_OPS : IRCTXT_NOTICE_PUBLIC, op_notice ? IRCTXT_NOTICE_PUBLIC_OPS : IRCTXT_NOTICE_PUBLIC,
nick, *target == '@' ? target+1 : target, msg); nick, target, msg);
level = MSGLEVEL_NOTICES; } else {
}
else
{
/* private notice */ /* private notice */
if (!ignore_check(server, nick, addr, NULL, msg, MSGLEVEL_NOTICES)) if (!ignore_check(server, nick, addr, NULL, msg, MSGLEVEL_NOTICES))
printformat(server, nick, MSGLEVEL_NOTICES, IRCTXT_NOTICE_PRIVATE, nick, addr, msg); printformat(server, nick, MSGLEVEL_NOTICES, IRCTXT_NOTICE_PRIVATE, nick, addr, msg);
level = MSGLEVEL_NOTICES; }
} }
msg_beep_check(server, level); msg_beep_check(server, addr == NULL ? MSGLEVEL_SNOTES : MSGLEVEL_NOTICES);
g_free(params); g_free(params);
} }
@ -468,12 +427,13 @@ static void event_wallops(const char *data, IRC_SERVER_REC *server, const char *
else { else {
/* Action in WALLOP */ /* Action in WALLOP */
int len; int len;
char *tmp;
data = g_strdup(data); tmp = g_strdup(data);
len = strlen(data); len = strlen(tmp);
if (data[len-1] == 1) data[len-1] = '\0'; if (tmp[len-1] == 1) tmp[len-1] = '\0';
printformat(server, NULL, MSGLEVEL_WALLOPS, IRCTXT_ACTION_WALLOPS, nick, data); printformat(server, NULL, MSGLEVEL_WALLOPS, IRCTXT_ACTION_WALLOPS, nick, tmp);
g_free(data); g_free(tmp);
} }
msg_beep_check(server, MSGLEVEL_WALLOPS); 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) static void event_connected(IRC_SERVER_REC *server)
{ {
char *nick; const char *nick;
g_return_if_fail(server != NULL); g_return_if_fail(server != NULL);
@ -632,7 +592,7 @@ void fe_events_init(void)
read_settings(); read_settings();
signal_add("event privmsg", (SIGNAL_FUNC) event_privmsg); 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("ctcp msg action", (SIGNAL_FUNC) sig_empty);
signal_add("event notice", (SIGNAL_FUNC) event_notice); signal_add("event notice", (SIGNAL_FUNC) event_notice);
signal_add("event join", (SIGNAL_FUNC) event_join); signal_add("event join", (SIGNAL_FUNC) event_join);
@ -665,7 +625,7 @@ void fe_events_init(void)
void fe_events_deinit(void) void fe_events_deinit(void)
{ {
signal_remove("event privmsg", (SIGNAL_FUNC) event_privmsg); 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("ctcp msg action", (SIGNAL_FUNC) sig_empty);
signal_remove("event notice", (SIGNAL_FUNC) event_notice); signal_remove("event notice", (SIGNAL_FUNC) event_notice);
signal_remove("event join", (SIGNAL_FUNC) event_join); signal_remove("event join", (SIGNAL_FUNC) event_join);

View File

@ -33,6 +33,7 @@
#include "channels.h" #include "channels.h"
#include "query.h" #include "query.h"
#include "fe-query.h"
#include "windows.h" #include "windows.h"
#include "window-items.h" #include "window-items.h"
@ -153,11 +154,7 @@ static void cmd_msg(gchar *data, IRC_SERVER_REC *server, WI_ITEM_REC *item)
else else
{ {
/* private message */ /* private message */
if (settings_get_bool("autocreate_query") && query_find(server, target) == NULL) item = (WI_ITEM_REC *) privmsg_get_query(server, target);
item = (WI_ITEM_REC *) query_create(server, target, FALSE);
else
item = (WI_ITEM_REC *) query_find(server, target);
printformat(server, target, MSGLEVEL_MSGS | MSGLEVEL_NOHILIGHT, printformat(server, target, MSGLEVEL_MSGS | MSGLEVEL_NOHILIGHT,
item == NULL ? IRCTXT_OWN_MSG_PRIVATE : IRCTXT_OWN_MSG_PRIVATE_QUERY, target, msg, server->nick); item == NULL ? IRCTXT_OWN_MSG_PRIVATE : IRCTXT_OWN_MSG_PRIVATE_QUERY, target, msg, server->nick);
} }

View File

@ -34,6 +34,18 @@
static int queryclose_tag, query_auto_close; 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) static void signal_query_created(QUERY_REC *query, gpointer automatic)
{ {
window_item_create((WI_ITEM_REC *) query, GPOINTER_TO_INT(automatic)); window_item_create((WI_ITEM_REC *) query, GPOINTER_TO_INT(automatic));

View 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

View File

@ -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); 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 */ /* get window and window item */
level = ischannel(*target) ? MSGLEVEL_PUBLIC : MSGLEVEL_MSGS; level = ischannel(*target) ? MSGLEVEL_PUBLIC : MSGLEVEL_MSGS;
item = window_item_find(server, ischannel(*target) ? target : nick); item = window_item_find(server, ischannel(*target) ? target : nick);

View File

@ -171,7 +171,7 @@ FORMAT_REC fecommon_irc_formats[] = {
{ NULL, "CTCPs", 0 }, { NULL, "CTCPs", 0 },
{ "ctcp_reply", "CTCP %_$0%_ reply from %_$1%_%K:%n $2", 3, { 0, 0, 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_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 } }, { "ctcp_requested", "%g>>> %_$0%_ %K[%g$1%K] %grequested %_$2%_ from %_$3", 4, { 0, 0, 0, 0 } },

View File

@ -39,9 +39,7 @@ static void event_privmsg(const char *data, IRC_SERVER_REC *server,
g_return_if_fail(data != NULL); g_return_if_fail(data != NULL);
params = event_get_params(data, 2 | PARAM_FLAG_GETREST, &target, &msg); params = event_get_params(data, 2 | PARAM_FLAG_GETREST, &target, &msg);
if (nick == NULL) nick = server->real_address; if (ischannel(*target)) {
if (*msg == 1 || ischannel(*target)) {
g_free(params); g_free(params);
return; return;
} }

View File

@ -156,6 +156,7 @@ static void event_privmsg(const char *data, IRC_SERVER_REC *server, const char *
if (ptr != NULL) *ptr = '\0'; if (ptr != NULL) *ptr = '\0';
signal_emit("ctcp msg", 5, msg, server, nick, addr, target); signal_emit("ctcp msg", 5, msg, server, nick, addr, target);
signal_stop();
} }
g_free(params); 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); 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 */ /* handle only ctcp replies */
if (*msg == 1) { 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'; if (ptr != NULL) *ptr = '\0';
signal_emit("ctcp reply", 5, msg, server, nick, addr, target); signal_emit("ctcp reply", 5, msg, server, nick, addr, target);
signal_stop();
} }
g_free(params); g_free(params);
@ -193,8 +195,8 @@ void ctcp_init(void)
settings_add_int("flood", "max_ctcp_queue", 5); settings_add_int("flood", "max_ctcp_queue", 5);
signal_add("server disconnected", (SIGNAL_FUNC) ctcp_deinit_server); signal_add("server disconnected", (SIGNAL_FUNC) ctcp_deinit_server);
signal_add("event privmsg", (SIGNAL_FUNC) event_privmsg); signal_add_first("event privmsg", (SIGNAL_FUNC) event_privmsg);
signal_add("event notice", (SIGNAL_FUNC) event_notice); signal_add_first("event notice", (SIGNAL_FUNC) event_notice);
signal_add("ctcp msg", (SIGNAL_FUNC) ctcp_msg); signal_add("ctcp msg", (SIGNAL_FUNC) ctcp_msg);
signal_add("ctcp reply", (SIGNAL_FUNC) ctcp_reply); signal_add("ctcp reply", (SIGNAL_FUNC) ctcp_reply);
signal_add("ctcp msg ping", (SIGNAL_FUNC) ctcp_ping); signal_add("ctcp msg ping", (SIGNAL_FUNC) ctcp_ping);

View File

@ -367,7 +367,9 @@ static void event_connected(const char *data, IRC_SERVER_REC *server, const char
if (server->real_address == NULL) { if (server->real_address == NULL) {
/* set the server address */ /* 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. */ /* last welcome message found - commands can be sent to server now. */

View File

@ -223,7 +223,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); params = event_get_params(data, 2 | PARAM_FLAG_GETREST, &target, &msg);
if (*msg != 1) {
if (!ischannel(*target)) { if (!ischannel(*target)) {
g_free_not_null(last_privmsg_from); g_free_not_null(last_privmsg_from);
last_privmsg_from = g_strdup(nick); last_privmsg_from = g_strdup(nick);
@ -231,7 +230,6 @@ static void event_privmsg(const char *data, IRC_SERVER_REC *server, const char *
g_free_not_null(last_public_from); g_free_not_null(last_public_from);
last_public_from = g_strdup(nick); last_public_from = g_strdup(nick);
} }
}
g_free(params); g_free(params);
} }

View File

@ -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); 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 */ /* save nick's address to query */
query = query_find(server, nick); query = query_find(server, nick);
if (query != NULL && (query->address == NULL || strcmp(query->address, addr) != 0)) { if (query != NULL && (query->address == NULL || strcmp(query->address, addr) != 0)) {

View File

@ -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(data != NULL);
g_return_if_fail(server != NULL); g_return_if_fail(server != NULL);
if (nick == NULL) { if (nick == NULL || addr == NULL) {
/* don't try to ignore server messages.. */ /* don't try to ignore server messages.. */
return; 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(data != NULL);
g_return_if_fail(server != NULL); g_return_if_fail(server != NULL);
if (nick == NULL) { if (nick == NULL || addr == NULL) {
/* don't try to ignore server messages.. */ /* don't try to ignore server messages.. */
return; return;
} }
params = event_get_params(data, 2, &target, &text); params = event_get_params(data, 2, &target, &text);
if (addr != NULL && !ignore_check(server, nick, addr, target, text, MSGLEVEL_NOTICES)) if (!ignore_check(server, nick, addr, target, text, MSGLEVEL_NOTICES))
flood_newmsg(server, MSGLEVEL_NOTICES | ischannel(*target) ? MSGLEVEL_PUBLIC : MSGLEVEL_MSGS, nick, addr, target); flood_newmsg(server, MSGLEVEL_NOTICES, nick, addr, target);
g_free(params); 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) static void read_settings(void)
{ {
int time; int time;
@ -255,6 +269,8 @@ static void read_settings(void)
flood_tag = g_timeout_add(time, (GSourceFunc) flood_timeout, NULL); flood_tag = g_timeout_add(time, (GSourceFunc) flood_timeout, NULL);
signal_add("event privmsg", (SIGNAL_FUNC) flood_privmsg); signal_add("event privmsg", (SIGNAL_FUNC) flood_privmsg);
signal_add("event notice", (SIGNAL_FUNC) flood_notice); 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); g_source_remove(flood_tag);
signal_remove("event privmsg", (SIGNAL_FUNC) flood_privmsg); signal_remove("event privmsg", (SIGNAL_FUNC) flood_privmsg);
signal_remove("event notice", (SIGNAL_FUNC) flood_notice); 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); signal_remove("setup changed", (SIGNAL_FUNC) read_settings);