comparison mcabber/src/commands.c @ 1064:516b5f7d1023

Fix some UTF-8 related problems When the jid is invalid, it is displayed in the error messages. However, in non-UTF-8 locales the LPRINT_NOTUTF8 must be provided because we call scr_LogPrint() before the UTF-8 conversion.
author Mikael Berthe <mikael@lilotux.net>
date Fri, 01 Dec 2006 23:50:52 +0100
parents 875d2c9d399c
children 230dca34dbea
comparison
equal deleted inserted replaced
1063:4e62941df777 1064:516b5f7d1023
441 bjid = NULL; 441 bjid = NULL;
442 442
443 if (bjid) { 443 if (bjid) {
444 // The JID has been specified. Quick check... 444 // The JID has been specified. Quick check...
445 if (check_jid_syntax(bjid)) { 445 if (check_jid_syntax(bjid)) {
446 scr_LogPrint(LPRINT_NORMAL, "<%s> is not a valid Jabber ID.", bjid); 446 scr_LogPrint(LPRINT_NORMAL|LPRINT_NOTUTF8,
447 "<%s> is not a valid Jabber ID.", bjid);
447 } else { 448 } else {
448 // Find the buddy 449 // Find the buddy
449 GSList *roster_elt; 450 GSList *roster_elt;
450 roster_elt = roster_find(bjid, jidsearch, 451 roster_elt = roster_find(bjid, jidsearch,
451 ROSTER_TYPE_USER|ROSTER_TYPE_ROOM); 452 ROSTER_TYPE_USER|ROSTER_TYPE_ROOM);
744 fjid = NULL; 745 fjid = NULL;
745 746
746 if (fjid) { 747 if (fjid) {
747 // The JID has been specified. Quick check... 748 // The JID has been specified. Quick check...
748 if (check_jid_syntax(fjid)) { 749 if (check_jid_syntax(fjid)) {
749 scr_LogPrint(LPRINT_NORMAL, "<%s> is not a valid Jabber ID.", fjid); 750 scr_LogPrint(LPRINT_NORMAL|LPRINT_NOTUTF8,
751 "<%s> is not a valid Jabber ID.", fjid);
750 fjid = NULL; 752 fjid = NULL;
751 } else { 753 } else {
752 // Convert jid to lowercase 754 // Convert jid to lowercase
753 char *p = fjid; 755 char *p = fjid;
754 for ( ; *p && *p != JID_RESOURCE_SEPARATOR; p++) 756 for ( ; *p && *p != JID_RESOURCE_SEPARATOR; p++)
799 id = NULL; 801 id = NULL;
800 802
801 if (id) { 803 if (id) {
802 // The JID has been specified. Quick check... 804 // The JID has been specified. Quick check...
803 if (check_jid_syntax(id)) { 805 if (check_jid_syntax(id)) {
804 scr_LogPrint(LPRINT_NORMAL, "<%s> is not a valid Jabber ID.", id); 806 scr_LogPrint(LPRINT_NORMAL|LPRINT_NOTUTF8,
807 "<%s> is not a valid Jabber ID.", id);
805 id = NULL; 808 id = NULL;
806 } else { 809 } else {
807 mc_strtolower(id); 810 mc_strtolower(id);
808 // Actually an UTF-8 id isn't needed because only the bare jid will 811 // Actually an UTF-8 id isn't needed because only the bare jid will
809 // be used. 812 // be used.
918 if (!msg || !*msg) { 921 if (!msg || !*msg) {
919 scr_LogPrint(LPRINT_NORMAL, "You must specify a message."); 922 scr_LogPrint(LPRINT_NORMAL, "You must specify a message.");
920 return 1; 923 return 1;
921 } 924 }
922 if (check_jid_syntax((char*)fjid)) { 925 if (check_jid_syntax((char*)fjid)) {
923 scr_LogPrint(LPRINT_NORMAL, "<%s> is not a valid Jabber ID.", fjid); 926 scr_LogPrint(LPRINT_NORMAL|LPRINT_NOTUTF8,
927 "<%s> is not a valid Jabber ID.", fjid);
924 return 1; 928 return 1;
925 } 929 }
926 930
927 // We must use the bare jid in hk_message_out() 931 // We must use the bare jid in hk_message_out()
928 rp = strchr(fjid, JID_RESOURCE_SEPARATOR); 932 rp = strchr(fjid, JID_RESOURCE_SEPARATOR);
2321 if (!*arg) { 2325 if (!*arg) {
2322 // If no jid is provided, we use the current selected buddy 2326 // If no jid is provided, we use the current selected buddy
2323 arg = NULL; 2327 arg = NULL;
2324 } else { 2328 } else {
2325 if (check_jid_syntax(arg)) { 2329 if (check_jid_syntax(arg)) {
2326 scr_LogPrint(LPRINT_NORMAL, "<%s> is not a valid Jabber ID.", arg); 2330 scr_LogPrint(LPRINT_NORMAL|LPRINT_NOTUTF8,
2331 "<%s> is not a valid Jabber ID.", arg);
2327 free_arg_lst(paramlst); 2332 free_arg_lst(paramlst);
2328 return; 2333 return;
2329 } 2334 }
2330 } 2335 }
2331 } 2336 }
2426 fjid = NULL; 2431 fjid = NULL;
2427 2432
2428 if (fjid) { 2433 if (fjid) {
2429 // The JID has been specified. Quick check... 2434 // The JID has been specified. Quick check...
2430 if (check_jid_syntax(fjid)) { 2435 if (check_jid_syntax(fjid)) {
2431 scr_LogPrint(LPRINT_NORMAL, "<%s> is not a valid Jabber ID.", fjid); 2436 scr_LogPrint(LPRINT_NORMAL|LPRINT_NOTUTF8,
2437 "<%s> is not a valid Jabber ID.", fjid);
2432 fjid = NULL; 2438 fjid = NULL;
2433 } else { 2439 } else {
2434 // Convert jid to lowercase 2440 // Convert jid to lowercase
2435 char *p; 2441 char *p;
2436 for (p = fjid; *p && *p != JID_RESOURCE_SEPARATOR; p++) 2442 for (p = fjid; *p && *p != JID_RESOURCE_SEPARATOR; p++)