diff options
author | Valentin Batz <senneth@irssi.org> | 2004-12-20 13:59:15 +0000 |
---|---|---|
committer | vb <vb@dbcabf3a-b0e7-0310-adc4-f8d773084564> | 2004-12-20 13:59:15 +0000 |
commit | 7be7dd374c23054f379fdf8361b31d3f658953c0 (patch) | |
tree | 525c6f344817828c6a6aab58333f85d5c1b1458e /src/core | |
parent | 5f81451df63acf5a809b5a551bc1b1e3e63ccfa0 (diff) | |
download | irssi-7be7dd374c23054f379fdf8361b31d3f658953c0.zip |
Added <tag>/<target> support for recode.
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@3692 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/chat-commands.c | 2 | ||||
-rw-r--r-- | src/core/recode.c | 25 | ||||
-rw-r--r-- | src/core/recode.h | 4 |
3 files changed, 23 insertions, 8 deletions
diff --git a/src/core/chat-commands.c b/src/core/chat-commands.c index 06fe5ce2..c7cc87d8 100644 --- a/src/core/chat-commands.c +++ b/src/core/chat-commands.c @@ -402,7 +402,7 @@ static void cmd_msg(const char *data, SERVER_REC *server, WI_ITEM_REC *item) SEND_TARGET_CHANNEL : SEND_TARGET_NICK; } } - recoded = recode_out(msg, target); + recoded = recode_out(server, msg, target); if (target != NULL) { signal_emit("server sendmsg", 4, server, target, recoded, GINT_TO_POINTER(target_type)); diff --git a/src/core/recode.c b/src/core/recode.c index 11128635..78d0be55 100644 --- a/src/core/recode.c +++ b/src/core/recode.c @@ -65,13 +65,14 @@ static gboolean is_translit(const char *charset) return (pos != NULL); } -char *recode_in(const char *str, const char *target) +char *recode_in(const SERVER_REC *server, const char *str, const char *target) { #ifdef HAVE_GLIB2 const char *from = NULL; const char *to = NULL; char *translit_to = NULL; char *recoded = NULL; + char *tagtarget = NULL; gboolean term_is_utf8, str_is_utf8, translit; int len; @@ -83,7 +84,13 @@ char *recode_in(const char *str, const char *target) str_is_utf8 = g_utf8_validate(str, len, NULL); translit = settings_get_bool("recode_transliterate"); - if (target != NULL) + if (server != NULL) + tagtarget = server->tag == NULL ? NULL : + g_strdup_printf("%s/%s", server->tag, target); + if (tagtarget != NULL) + from = iconfig_get_str("conversions", tagtarget, NULL); + g_free(tagtarget); + if (target != NULL && from == NULL) from = iconfig_get_str("conversions", target, NULL); term_is_utf8 = recode_get_charset(&to); @@ -115,7 +122,7 @@ char *recode_in(const char *str, const char *target) #endif } -char *recode_out(const char *str, const char *target) +char *recode_out(const SERVER_REC *server, const char *str, const char *target) { #ifdef HAVE_GLIB2 char *recoded = NULL; @@ -133,8 +140,16 @@ char *recode_out(const char *str, const char *target) if (target) { const char *to = NULL; char *translit_to = NULL; - - to = iconfig_get_str("conversions", target, NULL); + char *tagtarget = NULL; + + if (server != NULL) + tagtarget = server->tag == NULL ? NULL : + g_strdup_printf("%s/%s", server->tag, target); + if (tagtarget != NULL) + to = iconfig_get_str("conversions", tagtarget, NULL); + else + to = iconfig_get_str("conversions", target, NULL); + g_free(tagtarget); if (to == NULL || *to == '\0') /* default outgoing charset if set */ to = settings_get_str("recode_out_default_charset"); diff --git a/src/core/recode.h b/src/core/recode.h index 2a50da9e..f6c59e7c 100644 --- a/src/core/recode.h +++ b/src/core/recode.h @@ -1,8 +1,8 @@ #ifndef __RECODE_H #define __RECODE_H -char *recode_in (const char *str, const char *target); -char *recode_out (const char *str, const char *target); +char *recode_in (const SERVER_REC *server, const char *str, const char *target); +char *recode_out (const SERVER_REC *server, const char *str, const char *target); gboolean is_valid_charset(const char *charset); void recode_init (void); |