Mercurial > pidgin.yaz
comparison libpurple/protocols/oscar/oscar.c @ 30363:984cb1d0ea5d
Two small fixes to improve sending/receiving HTML-formatted messages
over ICQ.
* Treat all incoming messages as HTML because a) this is what the official
client does and b) we don't have a reliable way to check if a message is
HTML anyway.
* Wrap outgoing HTML in proper HTML tags to make ICQ6 happy.
This was tested with ICQ 6/7, Miranda, Trillian, QIP, and iChat.
author | ivan.komarov@soc.pidgin.im |
---|---|
date | Mon, 03 May 2010 20:49:14 +0000 |
parents | bb6e0a21823e |
children | 68a1c15e0db3 |
comparison
equal
deleted
inserted
replaced
30362:bb6e0a21823e | 30363:984cb1d0ea5d |
---|---|
1232 if (conn->cookie == NULL) | 1232 if (conn->cookie == NULL) |
1233 flap_connection_send_version(od, conn); | 1233 flap_connection_send_version(od, conn); |
1234 else | 1234 else |
1235 { | 1235 { |
1236 if (purple_account_get_bool(account, "use_clientlogin", OSCAR_DEFAULT_USE_CLIENTLOGIN)) | 1236 if (purple_account_get_bool(account, "use_clientlogin", OSCAR_DEFAULT_USE_CLIENTLOGIN)) |
1237 { | 1237 {3 |
1238 ClientInfo aiminfo = CLIENTINFO_PURPLE_AIM; | 1238 ClientInfo aiminfo = CLIENTINFO_PURPLE_AIM; |
1239 ClientInfo icqinfo = CLIENTINFO_PURPLE_ICQ; | 1239 ClientInfo icqinfo = CLIENTINFO_PURPLE_ICQ; |
1240 flap_connection_send_version_with_cookie_and_clientinfo(od, | 1240 flap_connection_send_version_with_cookie_and_clientinfo(od, |
1241 conn, conn->cookielen, conn->cookie, | 1241 conn, conn->cookielen, conn->cookie, |
1242 od->icq ? &icqinfo : &aiminfo, | 1242 od->icq ? &icqinfo : &aiminfo, |
2482 } | 2482 } |
2483 | 2483 |
2484 curpart = curpart->next; | 2484 curpart = curpart->next; |
2485 } | 2485 } |
2486 tmp = g_string_free(message, FALSE); | 2486 tmp = g_string_free(message, FALSE); |
2487 | |
2488 /* | |
2489 * If the message is from an ICQ user and to an ICQ user then escape any HTML, | |
2490 * because HTML is not sent over ICQ as a means to format a message. | |
2491 * So any HTML we receive is intended to be displayed. Also, \r\n must be | |
2492 * replaced with <br> | |
2493 * | |
2494 * Note: There *may* be some clients which send messages as HTML formatted - | |
2495 * they need to be special-cased somehow. | |
2496 * | |
2497 * Update: Newer ICQ clients have started sending IMs as HTML. We can | |
2498 * distinguish HTML IMs from non-HTML IMs by looking at the features. If | |
2499 * the features are "0x 01 06" then the message is plain text. If the | |
2500 * features are "0x 01" then the message is HTML. | |
2501 */ | |
2502 if (od->icq && oscar_util_valid_name_icq(userinfo->bn) | |
2503 && (args->featureslen != 1 || args->features[0] != 0x01)) | |
2504 { | |
2505 /* being recevied by ICQ from ICQ - escape HTML so it is displayed as sent */ | |
2506 gchar *tmp2 = g_markup_escape_text(tmp, -1); | |
2507 g_free(tmp); | |
2508 tmp = tmp2; | |
2509 tmp2 = purple_strreplace(tmp, "\r\n", "<br>"); | |
2510 g_free(tmp); | |
2511 tmp = tmp2; | |
2512 } | |
2513 | 2487 |
2514 /* | 2488 /* |
2515 * Convert iChat color tags to normal font tags. | 2489 * Convert iChat color tags to normal font tags. |
2516 */ | 2490 */ |
2517 if (purple_markup_find_tag("body", tmp, &start, &end, &attribs)) | 2491 if (purple_markup_find_tag("body", tmp, &start, &end, &attribs)) |
4785 if (oscar_util_valid_name_sms(name)) { | 4759 if (oscar_util_valid_name_sms(name)) { |
4786 /* Messaging an SMS (mobile) user--strip HTML */ | 4760 /* Messaging an SMS (mobile) user--strip HTML */ |
4787 tmp2 = purple_markup_strip_html(tmp1); | 4761 tmp2 = purple_markup_strip_html(tmp1); |
4788 is_html = FALSE; | 4762 is_html = FALSE; |
4789 } else { | 4763 } else { |
4790 tmp2 = g_strdup(tmp1); | 4764 /* ICQ 6 wants its HTML wrapped in these tags. Oblige it. */ |
4765 tmp2 = g_strdup_printf("<HTML><BODY>%s</BODY></HTML>", tmp1); | |
4791 is_html = TRUE; | 4766 is_html = TRUE; |
4792 } | 4767 } |
4793 g_free(tmp1); | 4768 g_free(tmp1); |
4794 tmp1 = tmp2; | 4769 tmp1 = tmp2; |
4795 | 4770 |