changeset 1860:5492b87ba9d0

Enable say_to ./resource message
author Mikael Berthe <mikael@lilotux.net>
date Sat, 03 Apr 2010 17:45:35 +0200
parents a20701a2840c
children 81822de0edf6
files mcabber/mcabber/commands.c
diffstat 1 files changed, 13 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mcabber/mcabber/commands.c	Sat Apr 03 17:07:27 2010 +0200
+++ b/mcabber/mcabber/commands.c	Sat Apr 03 17:45:35 2010 +0200
@@ -1496,8 +1496,10 @@
   char **paramlst;
   char *fjid, *msg;
   char *file = NULL;
+  char *xfjid = 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.");
@@ -1545,7 +1547,12 @@
   fjid = *paramlst;
   msg = *(paramlst+1);
 
-  if (!strcmp(fjid, ".")) {
+  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));
@@ -1554,6 +1561,10 @@
       free_arg_lst(paramlst);
       return;
     }
+    if (expandfjid) {
+      xfjid = g_strdup_printf("%s%c%s", fjid, JID_RESOURCE_SEPARATOR, res);
+      fjid = xfjid;
+    }
   } else if (check_jid_syntax(fjid)) {
     scr_LogPrint(LPRINT_NORMAL, "Please specify a valid Jabber ID.");
     free_arg_lst(paramlst);
@@ -1575,6 +1586,7 @@
 
   send_message_to(fjid, msg, NULL, msg_type, quiet);
 
+  g_free(xfjid);
   g_free(fjid);
   g_free(msg);
   free_arg_lst(paramlst);