summaryrefslogtreecommitdiff
path: root/src/core/chat-commands.c
diff options
context:
space:
mode:
authorSebastian Thorarensen <sebth@naju.se>2014-06-13 06:39:02 +0200
committerSebastian Thorarensen <sebth@naju.se>2014-07-06 23:24:09 +0200
commite6147fb8f2764392dd685fd8b28f1d69527609cd (patch)
treef24e6037b6bd3ac4b1d73949e0f82325a31e26ac /src/core/chat-commands.c
parent43baf71efd8d7323a2d6ae939c3c6350fef70f72 (diff)
downloadirssi-e6147fb8f2764392dd685fd8b28f1d69527609cd.zip
Properly split long IRC messages
This commit adds handling of long IRC messages to the core. In contrast to the `splitlong.pl' plugin, multi-byte encoded and recoded messages are properly split. To allow for this, a new function has been added to the server struct: `split_message'. `split_message' returns a string array with the message splitted to substrings of a length that the server can handle. If a protocol module doesn't have any limit, it can simply return a singleton array with a copy of the message. The `MSG' chat command now calls `split_message' before `send_message', and emits `message own_public' / `message own_private' with each substring, so that the string splitting will be visible in the UI. `split_message' in the IRC module uses `recode_split' which in turn uses iconv to properly split multi-byte encoded (and recoded) messages.
Diffstat (limited to 'src/core/chat-commands.c')
-rw-r--r--src/core/chat-commands.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/src/core/chat-commands.c b/src/core/chat-commands.c
index 535bf9f8..e00e6b1a 100644
--- a/src/core/chat-commands.c
+++ b/src/core/chat-commands.c
@@ -378,12 +378,23 @@ static void cmd_msg(const char *data, SERVER_REC *server, WI_ITEM_REC *item)
}
}
if (target != NULL) {
- signal_emit("server sendmsg", 4, server, target, msg,
- GINT_TO_POINTER(target_type));
+ char **splitmsgs = server->split_message(server, target, msg);
+ char *m;
+ int n = 0;
+
+ while ((m = splitmsgs[n++])) {
+ signal_emit("server sendmsg", 4, server, target, m,
+ GINT_TO_POINTER(target_type));
+ signal_emit(target_type == SEND_TARGET_CHANNEL ?
+ "message own_public" :
+ "message own_private", 4, server, m,
+ target, origtarget);
+ }
+ g_strfreev(splitmsgs);
+ } else {
+ signal_emit("message own_private", 4, server, msg, target,
+ origtarget);
}
- signal_emit(target != NULL && target_type == SEND_TARGET_CHANNEL ?
- "message own_public" : "message own_private", 4,
- server, msg, target, origtarget);
if (free_ret && target != NULL) g_free(target);
cmd_params_free(free_arg);