summaryrefslogtreecommitdiff
path: root/src/fe-common/irc
diff options
context:
space:
mode:
authorTimo Sirainen <cras@irssi.org>2001-01-07 19:42:59 +0000
committercras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564>2001-01-07 19:42:59 +0000
commit1de2aade402c17e2049432acf7d93edbcc78482d (patch)
tree9f7a9b4e2335137916ae858185259cec4668201d /src/fe-common/irc
parente46e2b5e0939a39059258e7302401775203063f1 (diff)
downloadirssi-1de2aade402c17e2049432acf7d93edbcc78482d.zip
In core/module-formats.h: IRCTXT_ -> TXT_
Added "message irc ctcp" signal to print CTCPs git-svn-id: http://svn.irssi.org/repos/irssi/trunk@1094 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src/fe-common/irc')
-rw-r--r--src/fe-common/irc/fe-ctcp.c41
-rw-r--r--src/fe-common/irc/fe-irc-messages.c17
2 files changed, 37 insertions, 21 deletions
diff --git a/src/fe-common/irc/fe-ctcp.c b/src/fe-common/irc/fe-ctcp.c
index d0fc66b3..0af453b6 100644
--- a/src/fe-common/irc/fe-ctcp.c
+++ b/src/fe-common/irc/fe-ctcp.c
@@ -34,38 +34,44 @@
#include "window-items.h"
#include "printtext.h"
-static void ctcp_print(const char *pre, const char *data,
- IRC_SERVER_REC *server, const char *nick,
- const char *addr, const char *target)
+static void ctcp_print(IRC_SERVER_REC *server,
+ const char *prefix, const char *data,
+ const char *nick, const char *addr, const char *target)
{
char *str;
- g_return_if_fail(data != NULL);
-
- str = g_strconcat(pre, " ", data, NULL);
- printformat(server, ischannel(*target) ? target : nick, MSGLEVEL_CTCPS,
- IRCTXT_CTCP_REQUESTED, nick, addr, str, target);
+ str = *data == '\0' ? g_strdup(prefix) :
+ g_strconcat(prefix, " ", data, NULL);
+ signal_emit("message irc ctcp", 5, server, str, nick, addr, target);
g_free(str);
}
-static void ctcp_default_msg(IRC_SERVER_REC *server, const char *data, const char *nick, const char *addr, const char *target)
+static void ctcp_default_msg(IRC_SERVER_REC *server, const char *data,
+ const char *nick, const char *addr,
+ const char *target)
{
- ctcp_print("unknown CTCP", data, server, nick, addr, target);
+ ctcp_print(server, "unknown CTCP", data, nick, addr, target);
}
-static void ctcp_ping_msg(IRC_SERVER_REC *server, const char *data, const char *nick, const char *addr, const char *target)
+static void ctcp_ping_msg(IRC_SERVER_REC *server, const char *data,
+ const char *nick, const char *addr,
+ const char *target)
{
- ctcp_print("CTCP PING", data, server, nick, addr, target);
+ ctcp_print(server, "CTCP PING", data, nick, addr, target);
}
-static void ctcp_version_msg(IRC_SERVER_REC *server, const char *data, const char *nick, const char *addr, const char *target)
+static void ctcp_version_msg(IRC_SERVER_REC *server, const char *data,
+ const char *nick, const char *addr,
+ const char *target)
{
- ctcp_print("CTCP VERSION", data, server, nick, addr, target);
+ ctcp_print(server, "CTCP VERSION", data, nick, addr, target);
}
-static void ctcp_time_msg(IRC_SERVER_REC *server, const char *data, const char *nick, const char *addr, const char *target)
+static void ctcp_time_msg(IRC_SERVER_REC *server, const char *data,
+ const char *nick, const char *addr,
+ const char *target)
{
- ctcp_print("CTCP TIME", data, server, nick, addr, target);
+ ctcp_print(server, "CTCP TIME", data, nick, addr, target);
}
static void ctcp_default_reply(IRC_SERVER_REC *server, const char *data,
@@ -87,7 +93,8 @@ static void ctcp_default_reply(IRC_SERVER_REC *server, const char *data,
}
printformat(server, ischannel(*target) ? target : nick, MSGLEVEL_CTCPS,
- ischannel(*target) ? IRCTXT_CTCP_REPLY_CHANNEL : IRCTXT_CTCP_REPLY, ctcp, nick, ctcpdata, target);
+ ischannel(*target) ? IRCTXT_CTCP_REPLY_CHANNEL :
+ IRCTXT_CTCP_REPLY, ctcp, nick, ctcpdata, target);
g_free(ctcp);
}
diff --git a/src/fe-common/irc/fe-irc-messages.c b/src/fe-common/irc/fe-irc-messages.c
index 1d33c9c2..8c9707cf 100644
--- a/src/fe-common/irc/fe-irc-messages.c
+++ b/src/fe-common/irc/fe-irc-messages.c
@@ -25,9 +25,8 @@
#include "irc.h"
-/* FIXME: hmm. there's should be some better way to use other module's
- formats than this since now we can't use this module's formats.. */
#include "../core/module-formats.h"
+#include "module-formats.h"
#include "printtext.h"
#include "fe-messages.h"
@@ -45,7 +44,7 @@ static void sig_message_own_public(SERVER_REC *server, const char *msg,
printformat_module("fe-common/core", server, target+1,
MSGLEVEL_PUBLIC | MSGLEVEL_NOHILIGHT |
MSGLEVEL_NO_ACT,
- IRCTXT_OWN_MSG_CHANNEL,
+ TXT_OWN_MSG_CHANNEL,
server->nick, target, msg, nickmode);
signal_stop();
}
@@ -63,19 +62,29 @@ static void sig_message_irc_op_public(SERVER_REC *server, const char *msg,
optarget = g_strconcat("@", target, NULL);
printformat_module("fe-common/core", server, target,
MSGLEVEL_PUBLIC | MSGLEVEL_HILIGHT,
- IRCTXT_PUBMSG_ME_CHANNEL,
+ TXT_PUBMSG_ME_CHANNEL,
nick, optarget, msg, nickmode);
g_free(optarget);
}
+static void sig_message_irc_ctcp(IRC_SERVER_REC *server, const char *msg,
+ const char *nick, const char *addr,
+ const char *target)
+{
+ printformat(server, ischannel(*target) ? target : nick, MSGLEVEL_CTCPS,
+ IRCTXT_CTCP_REQUESTED, nick, addr, msg, target);
+}
+
void fe_irc_messages_init(void)
{
signal_add("message own_public", (SIGNAL_FUNC) sig_message_own_public);
signal_add("message irc op_public", (SIGNAL_FUNC) sig_message_irc_op_public);
+ signal_add("message irc ctcp", (SIGNAL_FUNC) sig_message_irc_ctcp);
}
void fe_irc_messages_deinit(void)
{
signal_remove("message own_public", (SIGNAL_FUNC) sig_message_own_public);
signal_remove("message irc op_public", (SIGNAL_FUNC) sig_message_irc_op_public);
+ signal_remove("message irc ctcp", (SIGNAL_FUNC) sig_message_irc_ctcp);
}