comparison mcabber/src/jabglue.c @ 523:fc6bc26f891e

Write UTF-9 conversion failures to the tracelog file
author Mikael Berthe <mikael@lilotux.net>
date Sat, 19 Nov 2005 18:12:37 +0100
parents cc8c969ab6e5
children d721b3502a77
comparison
equal deleted inserted replaced
522:fdd1637db7f3 523:fc6bc26f891e
689 gchar *group_noutf8 = NULL; 689 gchar *group_noutf8 = NULL;
690 690
691 buddyname = cleanalias; 691 buddyname = cleanalias;
692 if (name) { 692 if (name) {
693 name_noutf8 = from_utf8(name); 693 name_noutf8 = from_utf8(name);
694 if (name_noutf8) buddyname = name_noutf8; 694 if (name_noutf8)
695 buddyname = name_noutf8;
696 else
697 scr_LogPrint(LPRINT_LOG, "Decoding of buddy alias has failed: %s",
698 name);
695 } 699 }
696 700
697 if (group) 701 if (group) {
698 group_noutf8 = from_utf8(group); 702 group_noutf8 = from_utf8(group);
703 if (!group_noutf8)
704 scr_LogPrint(LPRINT_LOG, "Decoding of buddy group has failed: %s",
705 group);
706 }
699 707
700 roster_add_user(cleanalias, buddyname, group_noutf8, ROSTER_TYPE_USER); 708 roster_add_user(cleanalias, buddyname, group_noutf8, ROSTER_TYPE_USER);
701 if (name_noutf8) g_free(name_noutf8); 709 if (name_noutf8) g_free(name_noutf8);
702 if (group_noutf8) g_free(group_noutf8); 710 if (group_noutf8) g_free(group_noutf8);
703 g_free(cleanalias); 711 g_free(cleanalias);
715 gchar *buffer = from_utf8(body); 723 gchar *buffer = from_utf8(body);
716 724
717 jid = jidtodisp(from); 725 jid = jidtodisp(from);
718 726
719 if (!buffer && body) { 727 if (!buffer && body) {
720 scr_LogPrint(LPRINT_LOGNORM, "Decoding of message from <%s> has failed", 728 scr_LogPrint(LPRINT_NORMAL, "Decoding of message from <%s> has failed",
721 from); 729 from);
730 scr_LogPrint(LPRINT_LOG, "Decoding of message from <%s> has failed: %s",
731 from, body);
722 scr_WriteIncomingMessage(jid, "Cannot display message: " 732 scr_WriteIncomingMessage(jid, "Cannot display message: "
723 "UTF-8 conversion failure", 733 "UTF-8 conversion failure",
724 0, HBB_PREFIX_ERR | HBB_PREFIX_IN); 734 0, HBB_PREFIX_ERR | HBB_PREFIX_IN);
725 g_free(jid); 735 g_free(jid);
726 return; 736 return;
891 // reduce the string length 901 // reduce the string length
892 strcpy(r+1, s); 902 strcpy(r+1, s);
893 g_free(s); 903 g_free(s);
894 } else { 904 } else {
895 *(r+1) = 0; 905 *(r+1) = 0;
896 scr_LogPrint(LPRINT_LOGNORM, "Decoding of message sender has failed"); 906 scr_LogPrint(LPRINT_NORMAL, "Decoding of message sender has failed");
907 scr_LogPrint(LPRINT_LOG, "Decoding of message sender has failed: %s", m);
897 } 908 }
898 } 909 }
899 } 910 }
900 911
901 if (!from && packet->type != JPACKET_IQ) { 912 if (!from && packet->type != JPACKET_IQ) {
914 p = xmlnode_get_tag_data(packet->x, "subject"); 925 p = xmlnode_get_tag_data(packet->x, "subject");
915 if (p != NULL) { 926 if (p != NULL) {
916 if (type && !strcmp(type, TMSG_GROUPCHAT)) { // Room topic 927 if (type && !strcmp(type, TMSG_GROUPCHAT)) { // Room topic
917 gchar *mbuf; 928 gchar *mbuf;
918 gchar *subj_noutf8 = from_utf8(p); 929 gchar *subj_noutf8 = from_utf8(p);
930 if (!subj_noutf8)
931 scr_LogPrint(LPRINT_LOG,
932 "Decoding of room topic has failed: %s", p);
919 // Get the room (s) and the nickname (r) 933 // Get the room (s) and the nickname (r)
920 s = g_strdup(from); 934 s = g_strdup(from);
921 r = strchr(s, '/'); 935 r = strchr(s, '/');
922 if (r) *r++ = 0; 936 if (r) *r++ = 0;
923 else r = s; 937 else r = s;
1140 } 1154 }
1141 1155
1142 if (type && !strcmp(type, "unavailable")) 1156 if (type && !strcmp(type, "unavailable"))
1143 ust = offline; 1157 ust = offline;
1144 1158
1145 if ((x = xmlnode_get_tag(packet->x, "status")) != NULL) 1159 s = NULL;
1146 s = from_utf8(xmlnode_get_data(x)); 1160 p = xmlnode_get_tag_data(packet->x, "status");
1147 else 1161 if (p) {
1148 s = NULL; 1162 s = from_utf8(p);
1163 if (!s)
1164 scr_LogPrint(LPRINT_LOG,
1165 "Decoding of status message of <%s> has failed: %s",
1166 from, p);
1167 }
1149 1168
1150 // Call hk_statuschange() if status has changed or if the 1169 // Call hk_statuschange() if status has changed or if the
1151 // status message is different 1170 // status message is different
1152 rname = strchr(from, '/'); 1171 rname = strchr(from, '/');
1153 if (rname) rname++; 1172 if (rname) rname++;
1198 if (y && mbnewnick) { 1217 if (y && mbnewnick) {
1199 p = xmlnode_get_attrib(y, "code"); 1218 p = xmlnode_get_attrib(y, "code");
1200 if (p && !strcmp(p, "303")) { 1219 if (p && !strcmp(p, "303")) {
1201 gchar *mbuf; 1220 gchar *mbuf;
1202 gchar *newname_noutf8 = from_utf8(mbnewnick); 1221 gchar *newname_noutf8 = from_utf8(mbnewnick);
1222 if (!newname_noutf8)
1223 scr_LogPrint(LPRINT_LOG,
1224 "Decoding of new nickname has failed: %s",
1225 mbnewnick);
1203 mbuf = g_strdup_printf("%s is now known as %s", rname, 1226 mbuf = g_strdup_printf("%s is now known as %s", rname,
1204 (newname_noutf8 ? newname_noutf8 : "(?)")); 1227 (newname_noutf8 ? newname_noutf8 : "(?)"));
1205 scr_WriteIncomingMessage(r, mbuf, 0, 1228 scr_WriteIncomingMessage(r, mbuf, 0,
1206 HBB_PREFIX_INFO|HBB_PREFIX_NOFLAG); 1229 HBB_PREFIX_INFO|HBB_PREFIX_NOFLAG);
1207 if (log_muc_conf) hlog_write_message(r, 0, FALSE, mbuf); 1230 if (log_muc_conf) hlog_write_message(r, 0, FALSE, mbuf);