diff options
author | Timo Sirainen <cras@irssi.org> | 2002-01-09 16:04:53 +0000 |
---|---|---|
committer | cras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564> | 2002-01-09 16:04:53 +0000 |
commit | 6e4730b65dfaa034f9160291df1307d849fe61c4 (patch) | |
tree | 92d6c21278b85b18d6d516fc84af49b6ec8465bf /src/fe-common/irc/dcc | |
parent | a01aab7a649b73cee3e7a73ade21498293f1a03e (diff) | |
download | irssi-6e4730b65dfaa034f9160291df1307d849fe61c4.zip |
Added "message dcc xxx" signals for printing DCC messages.
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@2298 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src/fe-common/irc/dcc')
-rw-r--r-- | src/fe-common/irc/dcc/Makefile.am | 3 | ||||
-rw-r--r-- | src/fe-common/irc/dcc/fe-dcc-chat-messages.c | 128 | ||||
-rw-r--r-- | src/fe-common/irc/dcc/fe-dcc-chat.c | 62 | ||||
-rw-r--r-- | src/fe-common/irc/dcc/module-formats.c | 3 | ||||
-rw-r--r-- | src/fe-common/irc/dcc/module-formats.h | 1 |
5 files changed, 157 insertions, 40 deletions
diff --git a/src/fe-common/irc/dcc/Makefile.am b/src/fe-common/irc/dcc/Makefile.am index ad487e95..dbe31f30 100644 --- a/src/fe-common/irc/dcc/Makefile.am +++ b/src/fe-common/irc/dcc/Makefile.am @@ -13,6 +13,7 @@ INCLUDES = \ libfe_irc_dcc_a_SOURCES = \ fe-dcc.c \ fe-dcc-chat.c \ + fe-dcc-chat-messages.c \ fe-dcc-get.c \ fe-dcc-send.c \ module-formats.c @@ -20,4 +21,4 @@ libfe_irc_dcc_a_SOURCES = \ noinst_HEADERS = \ module.h \ module-formats.h \ - fe-dcc.h
\ No newline at end of file + fe-dcc.h diff --git a/src/fe-common/irc/dcc/fe-dcc-chat-messages.c b/src/fe-common/irc/dcc/fe-dcc-chat-messages.c new file mode 100644 index 00000000..8da38fda --- /dev/null +++ b/src/fe-common/irc/dcc/fe-dcc-chat-messages.c @@ -0,0 +1,128 @@ +/* + fe-dcc-chat-messages.c : irssi + + Copyright (C) 2002 Timo Sirainen + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include "module.h" +#include "signals.h" +#include "levels.h" + +#include "irc-queries.h" +#include "dcc-chat.h" + +#include "module-formats.h" +#include "printtext.h" + +static void sig_message_dcc_own(CHAT_DCC_REC *dcc, const char *msg) +{ + QUERY_REC *query; + char *tag; + + tag = g_strconcat("=", dcc->id, NULL); + query = query_find(NULL, tag); + + printformat(NULL, tag, MSGLEVEL_DCCMSGS | MSGLEVEL_NOHILIGHT, + query != NULL ? IRCTXT_OWN_DCC_QUERY : + IRCTXT_OWN_DCC, dcc->mynick, dcc->id, msg); + g_free(tag); +} + +static void sig_message_dcc_own_action(CHAT_DCC_REC *dcc, const char *msg) +{ + QUERY_REC *query; + char *tag; + + tag = g_strconcat("=", dcc->id, NULL); + query = query_find(NULL, tag); + + printformat(NULL, tag, MSGLEVEL_DCCMSGS | MSGLEVEL_NOHILIGHT, + query != NULL ? IRCTXT_OWN_DCC_ACTION_QUERY : + IRCTXT_OWN_DCC_ACTION, dcc->mynick, dcc->id, msg); + g_free(tag); +} + +static void sig_message_dcc_own_ctcp(CHAT_DCC_REC *dcc, const char *cmd, + const char *data) +{ + char *tag; + + tag = g_strconcat("=", dcc->id, NULL); + + printformat(NULL, tag, MSGLEVEL_DCC, IRCTXT_OWN_DCC_CTCP, + dcc->id, cmd, data); + g_free(tag); +} + +static void sig_message_dcc(CHAT_DCC_REC *dcc, const char *msg) +{ + QUERY_REC *query; + char *tag; + + tag = g_strconcat("=", dcc->id, NULL); + + query = query_find(NULL, tag); + printformat(NULL, tag, MSGLEVEL_DCCMSGS, + query != NULL ? IRCTXT_DCC_MSG_QUERY : IRCTXT_DCC_MSG, + dcc->id, msg); + g_free(tag); +} + +static void sig_message_dcc_action(CHAT_DCC_REC *dcc, const char *msg) +{ + QUERY_REC *query; + char *tag; + + tag = g_strconcat("=", dcc->id, NULL); + + query = query_find(NULL, tag); + printformat(NULL, tag, MSGLEVEL_DCCMSGS | MSGLEVEL_ACTIONS, + query != NULL ? IRCTXT_ACTION_DCC_QUERY : + IRCTXT_ACTION_DCC, dcc->id, dcc->mynick, msg); + g_free(tag); +} + +static void sig_message_dcc_ctcp(CHAT_DCC_REC *dcc, const char *cmd, + const char *data) +{ + char *tag; + + tag = g_strconcat("=", dcc->id, NULL); + printformat(NULL, tag, MSGLEVEL_DCC, IRCTXT_DCC_CTCP, + dcc->id, cmd, data); + g_free(tag); +} + +void fe_dcc_chat_messages_init(void) +{ + signal_add("message dcc own", (SIGNAL_FUNC) sig_message_dcc_own); + signal_add("message dcc own_action", (SIGNAL_FUNC) sig_message_dcc_own_action); + signal_add("message dcc own_ctcp", (SIGNAL_FUNC) sig_message_dcc_own_ctcp); + signal_add("message dcc", (SIGNAL_FUNC) sig_message_dcc); + signal_add("message dcc action", (SIGNAL_FUNC) sig_message_dcc_action); + signal_add("message dcc ctcp", (SIGNAL_FUNC) sig_message_dcc_ctcp); +} + +void fe_dcc_chat_messages_deinit(void) +{ + signal_remove("message dcc own", (SIGNAL_FUNC) sig_message_dcc_own); + signal_remove("message dcc own_action", (SIGNAL_FUNC) sig_message_dcc_own_action); + signal_remove("message dcc own_ctcp", (SIGNAL_FUNC) sig_message_dcc_own_ctcp); + signal_remove("message dcc", (SIGNAL_FUNC) sig_message_dcc); + signal_remove("message dcc action", (SIGNAL_FUNC) sig_message_dcc_action); + signal_remove("message dcc ctcp", (SIGNAL_FUNC) sig_message_dcc_ctcp); +} diff --git a/src/fe-common/irc/dcc/fe-dcc-chat.c b/src/fe-common/irc/dcc/fe-dcc-chat.c index b1bad934..e57056e0 100644 --- a/src/fe-common/irc/dcc/fe-dcc-chat.c +++ b/src/fe-common/irc/dcc/fe-dcc-chat.c @@ -1,7 +1,7 @@ /* fe-dcc-chat.c : irssi - Copyright (C) 1999-2001 Timo Sirainen + Copyright (C) 1999-2002 Timo Sirainen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -35,6 +35,9 @@ #include "chat-completion.h" +void fe_dcc_chat_messages_init(void); +void fe_dcc_chat_messages_deinit(void); + static int autocreate_dccquery; static void dcc_request(CHAT_DCC_REC *dcc) @@ -95,17 +98,15 @@ static void dcc_chat_msg(CHAT_DCC_REC *dcc, const char *msg) else freemsg = NULL; - if (query_find(NULL, sender) == NULL) + if (query == NULL) completion_last_message_add(sender); - printformat(NULL, sender, MSGLEVEL_DCCMSGS, - query != NULL ? IRCTXT_DCC_MSG_QUERY : - IRCTXT_DCC_MSG, dcc->id, msg); + signal_emit("message dcc", 2, dcc, msg); g_free_not_null(freemsg); g_free(sender); } -static void dcc_chat_action(const char *msg, CHAT_DCC_REC *dcc) +static void dcc_chat_action(CHAT_DCC_REC *dcc, const char *msg) { char *sender; @@ -115,22 +116,16 @@ static void dcc_chat_action(const char *msg, CHAT_DCC_REC *dcc) sender = g_strconcat("=", dcc->id, NULL); if (query_find(NULL, sender) == NULL) completion_last_message_add(sender); - printformat(NULL, sender, MSGLEVEL_DCCMSGS | MSGLEVEL_ACTIONS, - IRCTXT_ACTION_DCC, dcc->id, msg); + + signal_emit("message dcc action", 2, dcc, msg); g_free(sender); } -static void dcc_chat_ctcp(const char *msg, CHAT_DCC_REC *dcc) +static void dcc_chat_ctcp(CHAT_DCC_REC *dcc, const char *cmd, const char *data) { - char *sender; - g_return_if_fail(IS_DCC_CHAT(dcc)); - g_return_if_fail(msg != NULL); - sender = g_strconcat("=", dcc->id, NULL); - printformat(NULL, sender, MSGLEVEL_DCC, - IRCTXT_DCC_CTCP, dcc->id, msg); - g_free(sender); + signal_emit("message dcc ctcp", 3, dcc, cmd, data); } static void dcc_error_ctcp(const char *type, const char *data, @@ -233,7 +228,6 @@ static void sig_dcc_list_print(CHAT_DCC_REC *dcc) static void cmd_msg(const char *data) { - QUERY_REC *query; CHAT_DCC_REC *dcc; char *text, *target; void *free_arg; @@ -254,13 +248,10 @@ static void cmd_msg(const char *data) printformat(NULL, NULL, MSGLEVEL_CLIENTERROR, IRCTXT_DCC_CHAT_NOT_FOUND, target+1); } else { - query = query_find(NULL, target); - - printformat(NULL, target, MSGLEVEL_DCCMSGS | MSGLEVEL_NOHILIGHT, - query != NULL ? IRCTXT_OWN_DCC_QUERY : - IRCTXT_OWN_DCC, dcc->mynick, target+1, text); - if (query == NULL) + if (query_find(NULL, target) == NULL) completion_last_message_add(target); + + signal_emit("message dcc own", 2, dcc, text); } cmd_params_free(free_arg); @@ -270,18 +261,13 @@ static void cmd_me(const char *data, SERVER_REC *server, WI_ITEM_REC *item) { CHAT_DCC_REC *dcc; - g_return_if_fail(data != NULL); - dcc = item_get_dcc(item); - if (dcc == NULL) return; - - printformat(NULL, item->name, MSGLEVEL_DCCMSGS | MSGLEVEL_NOHILIGHT, - IRCTXT_OWN_DCC_ACTION_QUERY, dcc->mynick, item->name, data); + if (dcc != NULL) + signal_emit("message dcc own_action", 2, dcc, data); } static void cmd_action(const char *data, SERVER_REC *server, WI_ITEM_REC *item) { - QUERY_REC *query; CHAT_DCC_REC *dcc; char *target, *text; void *free_arg; @@ -304,13 +290,10 @@ static void cmd_action(const char *data, SERVER_REC *server, WI_ITEM_REC *item) printformat(NULL, NULL, MSGLEVEL_CLIENTERROR, IRCTXT_DCC_CHAT_NOT_FOUND, target+1); } else { - query = query_find(NULL, target); - - printformat(NULL, target, MSGLEVEL_DCCMSGS | MSGLEVEL_NOHILIGHT, - query != NULL ? IRCTXT_OWN_DCC_ACTION_QUERY : - IRCTXT_OWN_DCC_ACTION, dcc->mynick, target, text); - if (query == NULL) + if (query_find(NULL, target) == NULL) completion_last_message_add(target); + + signal_emit("message dcc own_action", 2, dcc, text); } cmd_params_free(free_arg); } @@ -343,8 +326,7 @@ static void cmd_ctcp(const char *data, SERVER_REC *server) IRCTXT_DCC_CHAT_NOT_FOUND, target+1); } else { g_strup(ctcpcmd); - printformat(server, target, MSGLEVEL_DCC, IRCTXT_OWN_DCC_CTCP, - target, ctcpcmd, ctcpdata); + signal_emit("message dcc own_ctcp", 3, dcc, ctcpcmd, ctcpdata); } cmd_params_free(free_arg); @@ -361,6 +343,8 @@ static void read_settings(void) void fe_dcc_chat_init(void) { read_settings(); + fe_dcc_chat_messages_init(); + signal_add("dcc request", (SIGNAL_FUNC) dcc_request); signal_add("dcc connected", (SIGNAL_FUNC) dcc_connected); signal_add("dcc closed", (SIGNAL_FUNC) dcc_closed); @@ -383,6 +367,8 @@ void fe_dcc_chat_init(void) void fe_dcc_chat_deinit(void) { + fe_dcc_chat_messages_deinit(); + signal_remove("dcc request", (SIGNAL_FUNC) dcc_request); signal_remove("dcc connected", (SIGNAL_FUNC) dcc_connected); signal_remove("dcc closed", (SIGNAL_FUNC) dcc_closed); diff --git a/src/fe-common/irc/dcc/module-formats.c b/src/fe-common/irc/dcc/module-formats.c index 8f1aea81..d4858148 100644 --- a/src/fe-common/irc/dcc/module-formats.c +++ b/src/fe-common/irc/dcc/module-formats.c @@ -33,9 +33,10 @@ FORMAT_REC fecommon_irc_dcc_formats[] = { { "own_dcc_ctcp", "{ownctcp ctcp $0}$1 $2", 3, { 0, 0, 0 } }, { "dcc_msg", "{dccmsg dcc $0}$1", 2, { 0, 0 } }, { "action_dcc", "{dccaction $0}$1", 2, { 0, 0 } }, + { "action_dcc_query", "{dccaction $0}$1", 2, { 0, 0 } }, { "own_dcc_query", "{ownmsgnick {ownnick $0}}$2", 3, { 0, 0, 0 } }, { "dcc_msg_query", "{privmsgnick $0}$1", 2, { 0, 0 } }, - { "dcc_ctcp", "{dcc >>> DCC CTCP received from {hilight $0}: $1}", 2, { 0, 0 } }, + { "dcc_ctcp", "{dcc >>> DCC CTCP {hilight $1} received from {hilight $0}: $2}", 3, { 0, 0, 0 } }, { "dcc_chat", "{dcc DCC CHAT from {nick $0} [$1 port $2]}", 3, { 0, 0, 1 } }, { "dcc_chat_channel", "{dcc DCC CHAT from {nick $0} [$1 port $2] requested in channel {channel $3}}", 4, { 0, 0, 1, 0 } }, { "dcc_chat_not_found", "{dcc No DCC CHAT connection open to {nick $0}}", 1, { 0 } }, diff --git a/src/fe-common/irc/dcc/module-formats.h b/src/fe-common/irc/dcc/module-formats.h index bc783a04..23e948fd 100644 --- a/src/fe-common/irc/dcc/module-formats.h +++ b/src/fe-common/irc/dcc/module-formats.h @@ -11,6 +11,7 @@ enum { IRCTXT_OWN_DCC_CTCP, IRCTXT_DCC_MSG, IRCTXT_ACTION_DCC, + IRCTXT_ACTION_DCC_QUERY, IRCTXT_OWN_DCC_QUERY, IRCTXT_DCC_MSG_QUERY, IRCTXT_DCC_CTCP, |