changeset 1875:ad1f7e7c2745

Fix bug in /say_to introduced in changeset 5492b87ba9d0
author Myhailo Danylenko <isbear@ukrpost.net>
date Mon, 05 Apr 2010 23:07:42 +0200
parents 94936b487b6f
children 9f3d7430ba78
files mcabber/mcabber/commands.c
diffstat 1 files changed, 11 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/mcabber/mcabber/commands.c	Mon Apr 05 22:30:02 2010 +0200
+++ b/mcabber/mcabber/commands.c	Mon Apr 05 23:07:42 2010 +0200
@@ -1498,7 +1498,6 @@
   char *file = NULL;
   LmMessageSubType msg_type = LM_MESSAGE_SUB_TYPE_NOT_SET;
   bool quiet = FALSE;
-  bool expandfjid = FALSE;
 
   if (!xmpp_is_online()) {
     scr_LogPrint(LPRINT_NORMAL, "You are not connected.");
@@ -1527,6 +1526,7 @@
       free_arg_lst(oldparamlst);
       if (!*paramlst) {
         scr_LogPrint(LPRINT_NORMAL, "Wrong usage.");
+        free_arg_lst(paramlst);
         return;
       }
       file = g_strdup(*paramlst);
@@ -1540,31 +1540,23 @@
 
   if (!*paramlst) {
     scr_LogPrint(LPRINT_NORMAL, "Wrong usage.");
+    free_arg_lst(paramlst);
     return;
   }
 
   fjid = *paramlst;
   msg = *(paramlst+1);
 
-  if (!strncmp(fjid, "." JID_RESOURCE_SEPARATORSTR, 2))
-    expandfjid = TRUE;
-
-  if (expandfjid || !strcmp(fjid, ".")) {
-    const gchar *res = fjid+2;
-    fjid = NULL;
-    // Send the message to the current buddy
-    if (current_buddy)
-      fjid = (char*)buddy_getjid(BUDDATA(current_buddy));
-    if (!fjid) {
-      scr_LogPrint(LPRINT_NORMAL, "Please specify a Jabber ID.");
-      free_arg_lst(paramlst);
-      return;
-    }
-    if (expandfjid && *res) {
-      char *res_utf8 = to_utf8(res);
-      fjid = g_strdup_printf("%s%c%s", fjid, JID_RESOURCE_SEPARATOR, res_utf8);
+  if (fjid[0] == '.') {
+    const gchar *cjid = (current_buddy ? CURRENT_JID : NULL);
+    if (fjid[1] == '\0') {
+      fjid = g_strdup(cjid);
+    } else if (fjid[1] == JID_RESOURCE_SEPARATOR) {
+      char *res_utf8 = to_utf8(fjid+2);
+      fjid = g_strdup_printf("%s%c%s", cjid, JID_RESOURCE_SEPARATOR, res_utf8);
       g_free(res_utf8);
-    }
+    } else
+      fjid = to_utf8(fjid);
   } else
     fjid = to_utf8(fjid);