comparison mcabber/mcabber/commands.c @ 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 81822de0edf6
children 7d72b7d2d93a
comparison
equal deleted inserted replaced
1874:94936b487b6f 1875:ad1f7e7c2745
1496 char **paramlst; 1496 char **paramlst;
1497 char *fjid, *msg; 1497 char *fjid, *msg;
1498 char *file = NULL; 1498 char *file = NULL;
1499 LmMessageSubType msg_type = LM_MESSAGE_SUB_TYPE_NOT_SET; 1499 LmMessageSubType msg_type = LM_MESSAGE_SUB_TYPE_NOT_SET;
1500 bool quiet = FALSE; 1500 bool quiet = FALSE;
1501 bool expandfjid = FALSE;
1502 1501
1503 if (!xmpp_is_online()) { 1502 if (!xmpp_is_online()) {
1504 scr_LogPrint(LPRINT_NORMAL, "You are not connected."); 1503 scr_LogPrint(LPRINT_NORMAL, "You are not connected.");
1505 return; 1504 return;
1506 } 1505 }
1525 char **oldparamlst = paramlst; 1524 char **oldparamlst = paramlst;
1526 paramlst = split_arg(*(oldparamlst+1), 2, 1); // filename, jid 1525 paramlst = split_arg(*(oldparamlst+1), 2, 1); // filename, jid
1527 free_arg_lst(oldparamlst); 1526 free_arg_lst(oldparamlst);
1528 if (!*paramlst) { 1527 if (!*paramlst) {
1529 scr_LogPrint(LPRINT_NORMAL, "Wrong usage."); 1528 scr_LogPrint(LPRINT_NORMAL, "Wrong usage.");
1529 free_arg_lst(paramlst);
1530 return; 1530 return;
1531 } 1531 }
1532 file = g_strdup(*paramlst); 1532 file = g_strdup(*paramlst);
1533 // One more parameter shift... 1533 // One more parameter shift...
1534 oldparamlst = paramlst; 1534 oldparamlst = paramlst;
1538 break; 1538 break;
1539 } 1539 }
1540 1540
1541 if (!*paramlst) { 1541 if (!*paramlst) {
1542 scr_LogPrint(LPRINT_NORMAL, "Wrong usage."); 1542 scr_LogPrint(LPRINT_NORMAL, "Wrong usage.");
1543 free_arg_lst(paramlst);
1543 return; 1544 return;
1544 } 1545 }
1545 1546
1546 fjid = *paramlst; 1547 fjid = *paramlst;
1547 msg = *(paramlst+1); 1548 msg = *(paramlst+1);
1548 1549
1549 if (!strncmp(fjid, "." JID_RESOURCE_SEPARATORSTR, 2)) 1550 if (fjid[0] == '.') {
1550 expandfjid = TRUE; 1551 const gchar *cjid = (current_buddy ? CURRENT_JID : NULL);
1551 1552 if (fjid[1] == '\0') {
1552 if (expandfjid || !strcmp(fjid, ".")) { 1553 fjid = g_strdup(cjid);
1553 const gchar *res = fjid+2; 1554 } else if (fjid[1] == JID_RESOURCE_SEPARATOR) {
1554 fjid = NULL; 1555 char *res_utf8 = to_utf8(fjid+2);
1555 // Send the message to the current buddy 1556 fjid = g_strdup_printf("%s%c%s", cjid, JID_RESOURCE_SEPARATOR, res_utf8);
1556 if (current_buddy)
1557 fjid = (char*)buddy_getjid(BUDDATA(current_buddy));
1558 if (!fjid) {
1559 scr_LogPrint(LPRINT_NORMAL, "Please specify a Jabber ID.");
1560 free_arg_lst(paramlst);
1561 return;
1562 }
1563 if (expandfjid && *res) {
1564 char *res_utf8 = to_utf8(res);
1565 fjid = g_strdup_printf("%s%c%s", fjid, JID_RESOURCE_SEPARATOR, res_utf8);
1566 g_free(res_utf8); 1557 g_free(res_utf8);
1567 } 1558 } else
1559 fjid = to_utf8(fjid);
1568 } else 1560 } else
1569 fjid = to_utf8(fjid); 1561 fjid = to_utf8(fjid);
1570 1562
1571 if (check_jid_syntax(fjid)) { 1563 if (check_jid_syntax(fjid)) {
1572 scr_LogPrint(LPRINT_NORMAL, "Please specify a valid Jabber ID."); 1564 scr_LogPrint(LPRINT_NORMAL, "Please specify a valid Jabber ID.");