comparison mcabber/mcabber/commands.c @ 1860:5492b87ba9d0

Enable say_to ./resource message
author Mikael Berthe <mikael@lilotux.net>
date Sat, 03 Apr 2010 17:45:35 +0200
parents f6e137fe9d6d
children 81822de0edf6
comparison
equal deleted inserted replaced
1859:a20701a2840c 1860:5492b87ba9d0
1494 static void do_say_to(char *arg) 1494 static void do_say_to(char *arg)
1495 { 1495 {
1496 char **paramlst; 1496 char **paramlst;
1497 char *fjid, *msg; 1497 char *fjid, *msg;
1498 char *file = NULL; 1498 char *file = NULL;
1499 char *xfjid = NULL;
1499 LmMessageSubType msg_type = LM_MESSAGE_SUB_TYPE_NOT_SET; 1500 LmMessageSubType msg_type = LM_MESSAGE_SUB_TYPE_NOT_SET;
1500 bool quiet = FALSE; 1501 bool quiet = FALSE;
1502 bool expandfjid = FALSE;
1501 1503
1502 if (!xmpp_is_online()) { 1504 if (!xmpp_is_online()) {
1503 scr_LogPrint(LPRINT_NORMAL, "You are not connected."); 1505 scr_LogPrint(LPRINT_NORMAL, "You are not connected.");
1504 return; 1506 return;
1505 } 1507 }
1543 } 1545 }
1544 1546
1545 fjid = *paramlst; 1547 fjid = *paramlst;
1546 msg = *(paramlst+1); 1548 msg = *(paramlst+1);
1547 1549
1548 if (!strcmp(fjid, ".")) { 1550 if (!strncmp(fjid, "." JID_RESOURCE_SEPARATORSTR, 2))
1551 expandfjid = TRUE;
1552
1553 if (expandfjid || !strcmp(fjid, ".")) {
1554 const gchar *res = fjid+2;
1555 fjid = NULL;
1549 // Send the message to the current buddy 1556 // Send the message to the current buddy
1550 if (current_buddy) 1557 if (current_buddy)
1551 fjid = (char*)buddy_getjid(BUDDATA(current_buddy)); 1558 fjid = (char*)buddy_getjid(BUDDATA(current_buddy));
1552 if (!fjid) { 1559 if (!fjid) {
1553 scr_LogPrint(LPRINT_NORMAL, "Please specify a Jabber ID."); 1560 scr_LogPrint(LPRINT_NORMAL, "Please specify a Jabber ID.");
1554 free_arg_lst(paramlst); 1561 free_arg_lst(paramlst);
1555 return; 1562 return;
1563 }
1564 if (expandfjid) {
1565 xfjid = g_strdup_printf("%s%c%s", fjid, JID_RESOURCE_SEPARATOR, res);
1566 fjid = xfjid;
1556 } 1567 }
1557 } else if (check_jid_syntax(fjid)) { 1568 } else if (check_jid_syntax(fjid)) {
1558 scr_LogPrint(LPRINT_NORMAL, "Please specify a valid Jabber ID."); 1569 scr_LogPrint(LPRINT_NORMAL, "Please specify a valid Jabber ID.");
1559 free_arg_lst(paramlst); 1570 free_arg_lst(paramlst);
1560 return; 1571 return;
1573 g_free(file); 1584 g_free(file);
1574 } 1585 }
1575 1586
1576 send_message_to(fjid, msg, NULL, msg_type, quiet); 1587 send_message_to(fjid, msg, NULL, msg_type, quiet);
1577 1588
1589 g_free(xfjid);
1578 g_free(fjid); 1590 g_free(fjid);
1579 g_free(msg); 1591 g_free(msg);
1580 free_arg_lst(paramlst); 1592 free_arg_lst(paramlst);
1581 } 1593 }
1582 1594