# HG changeset patch # User Mikael Berthe # Date 1270313978 -7200 # Node ID b6fb487c26582eaebc239bd0cc0ea4aa0070e20b # Parent 1183c1f11a688bda43dd39d6439e823ce4067077 [extsay] Enable /extsay ./resourcename Also add some UTF-8 conversions and JID checks diff -r 1183c1f11a68 -r b6fb487c2658 extsay-ng/extsayng.c --- a/extsay-ng/extsayng.c Sat Apr 03 16:38:56 2010 +0200 +++ b/extsay-ng/extsayng.c Sat Apr 03 18:59:38 2010 +0200 @@ -20,6 +20,7 @@ #include #include +#include #include #include @@ -97,9 +98,17 @@ static void do_extsayng(gchar *args) { - gpointer bud; + gboolean expandfjid = FALSE; + char *xfjid = NULL; + char *res_utf8 = NULL, *fjid_utf8 = NULL; - if (!args || !*args || !g_strcmp0(args, ".")) { + if (args && !strncmp(args, "." JID_RESOURCE_SEPARATORSTR, 2)) + expandfjid = TRUE; + + if (!args || !*args || expandfjid || !g_strcmp0(args, ".")) { + const gchar *res = args+2; + gpointer bud; + if (!current_buddy) { scr_LogPrint(LPRINT_NORMAL, "Please select a buddy."); return; @@ -113,9 +122,23 @@ } args = (gchar*)buddy_getjid(bud); + if (expandfjid && *res) { + res_utf8 = to_utf8(res); + xfjid = g_strdup_printf("%s%c%s", args, JID_RESOURCE_SEPARATOR, res_utf8); + args = xfjid; + } + } else { + args = fjid_utf8 = to_utf8(args); } - screen_run_script(args); + if (check_jid_syntax(args)) + scr_LogPrint(LPRINT_NORMAL, "Please specify a valid Jabber ID."); + else + screen_run_script(args); // Launch helper script with resulting JID + + g_free(res_utf8); + g_free(fjid_utf8); + g_free(xfjid); } static void extsayng_init(void)