Mercurial > hg
comparison mcabber/src/jabglue.c @ 321:59193965f2cb
Convert status messages to/from UTF-8
author | Mikael Berthe <mikael@lilotux.net> |
---|---|
date | Fri, 15 Jul 2005 19:12:50 +0100 |
parents | db45371106a5 |
children | ff6fb51bfd78 |
comparison
equal
deleted
inserted
replaced
320:dce1dd4d0ca8 | 321:59193965f2cb |
---|---|
248 } | 248 } |
249 | 249 |
250 void jb_setstatus(enum imstatus st, const char *msg) | 250 void jb_setstatus(enum imstatus st, const char *msg) |
251 { | 251 { |
252 xmlnode x; | 252 xmlnode x; |
253 char *utf8_msg; | |
253 | 254 |
254 if (!online) return; | 255 if (!online) return; |
255 | 256 |
256 x = jutil_presnew(JPACKET__UNKNOWN, 0, 0); | 257 x = jutil_presnew(JPACKET__UNKNOWN, 0, 0); |
257 | 258 |
296 } | 297 } |
297 | 298 |
298 if (!msg) | 299 if (!msg) |
299 msg = settings_get_status_msg(st); | 300 msg = settings_get_status_msg(st); |
300 | 301 |
301 xmlnode_insert_cdata(xmlnode_insert_tag(x, "status"), msg, | 302 utf8_msg = utf8_encode(msg); |
303 xmlnode_insert_cdata(xmlnode_insert_tag(x, "status"), utf8_msg, | |
302 (unsigned) -1); | 304 (unsigned) -1); |
303 | 305 |
304 jab_send(jc, x); | 306 jab_send(jc, x); |
305 xmlnode_free(x); | 307 xmlnode_free(x); |
308 free(utf8_msg); | |
306 | 309 |
307 //sendvisibility(); ??? | 310 //sendvisibility(); ??? |
308 | 311 |
309 // We'll need to update the roster if we switch to/from offline because | 312 // We'll need to update the roster if we switch to/from offline because |
310 // we don't know the presences of buddies when offline... | 313 // we don't know the presences of buddies when offline... |
850 else if (!strcmp(ns, "xa")) ust = notavail; | 853 else if (!strcmp(ns, "xa")) ust = notavail; |
851 else if (!strcmp(ns, "chat")) ust = freeforchat; | 854 else if (!strcmp(ns, "chat")) ust = freeforchat; |
852 } | 855 } |
853 } | 856 } |
854 | 857 |
855 if (type && !strcmp(type, "unavailable")) { | 858 if (type && !strcmp(type, "unavailable")) |
856 ust = offline; | 859 ust = offline; |
857 } | |
858 | 860 |
859 if ((x = xmlnode_get_tag(packet->x, "status")) != NULL) | 861 if ((x = xmlnode_get_tag(packet->x, "status")) != NULL) |
860 p = xmlnode_get_data(x); | 862 p = utf8_decode(xmlnode_get_data(x)); |
861 else | 863 else |
862 p = NULL; | 864 p = NULL; |
863 | 865 |
864 r = jidtodisp(from); | 866 r = jidtodisp(from); |
865 // Call hk_statuschange() if status has changed or if the | 867 // Call hk_statuschange() if status has changed or if the |
866 // status message is different | 868 // status message is different |
867 m = roster_getstatusmsg(r); | 869 m = roster_getstatusmsg(r); |
868 if ((ust != roster_getstatus(r)) || (p && (!m || strcmp(p, m)))) | 870 if ((ust != roster_getstatus(r)) || (p && (!m || strcmp(p, m)))) |
869 hk_statuschange(r, 0, ust, p); | 871 hk_statuschange(r, 0, ust, p); |
870 g_free(r); | 872 g_free(r); |
873 if (p) free(p); | |
871 break; | 874 break; |
872 | 875 |
873 case JPACKET_S10N: | 876 case JPACKET_S10N: |
874 scr_LogPrint("Received (un)subscription packet (type=%s)", | 877 scr_LogPrint("Received (un)subscription packet (type=%s)", |
875 ((type) ? type : "")); | 878 ((type) ? type : "")); |