extsay-ng/extsayng.c
changeset 30 7738b1e4714d
parent 29 b6fb487c2658
child 31 816373e58b6c
equal deleted inserted replaced
29:b6fb487c2658 30:7738b1e4714d
    97 }
    97 }
    98 
    98 
    99 static void do_extsayng(gchar *args)
    99 static void do_extsayng(gchar *args)
   100 {
   100 {
   101   gboolean expandfjid = FALSE;
   101   gboolean expandfjid = FALSE;
   102   char *xfjid = NULL;
   102   gchar *fjid;
   103   char *res_utf8 = NULL, *fjid_utf8 = NULL;
       
   104 
   103 
   105   if (args && !strncmp(args, "." JID_RESOURCE_SEPARATORSTR, 2))
   104   if (args && !strncmp(args, "." JID_RESOURCE_SEPARATORSTR, 2))
   106     expandfjid = TRUE;
   105     expandfjid = TRUE;
   107 
   106 
   108   if (!args || !*args || expandfjid || !g_strcmp0(args, ".")) {
   107   if (!args || !*args || expandfjid || !g_strcmp0(args, ".")) {
   121       return;
   120       return;
   122     }
   121     }
   123 
   122 
   124     args = (gchar*)buddy_getjid(bud);
   123     args = (gchar*)buddy_getjid(bud);
   125     if (expandfjid && *res) {
   124     if (expandfjid && *res) {
   126       res_utf8 = to_utf8(res);
   125       char *res_utf8 = to_utf8(res);
   127       xfjid = g_strdup_printf("%s%c%s", args, JID_RESOURCE_SEPARATOR, res_utf8);
   126       fjid = g_strdup_printf("%s%c%s", args, JID_RESOURCE_SEPARATOR, res_utf8);
   128       args = xfjid;
   127       g_free(res_utf8);
   129     }
   128     }
   130   } else {
   129   } else {
   131     args = fjid_utf8 = to_utf8(args);
   130     fjid = to_utf8(args);
   132   }
   131   }
   133 
   132 
   134   if (check_jid_syntax(args))
   133   if (check_jid_syntax(fjid))
   135     scr_LogPrint(LPRINT_NORMAL, "Please specify a valid Jabber ID.");
   134     scr_LogPrint(LPRINT_NORMAL, "Please specify a valid Jabber ID.");
   136   else
   135   else
   137     screen_run_script(args); // Launch helper script with resulting JID
   136     screen_run_script(fjid); // Launch helper script with resulting JID
   138 
   137 
   139   g_free(res_utf8);
   138   g_free(fjid);
   140   g_free(fjid_utf8);
       
   141   g_free(xfjid);
       
   142 }
   139 }
   143 
   140 
   144 static void extsayng_init(void)
   141 static void extsayng_init(void)
   145 {
   142 {
   146   cmd_add("extsay", "Use external editor to write a message",
   143   cmd_add("extsay", "Use external editor to write a message",