Mercurial > pidgin
changeset 8442:3d0178c4f390
[gaim-migrate @ 9172]
" This is that thing Sean told me to do. Well part of it.
We now are careful to send html to gtkimhtml when
sending a message, while still sending plain text to
those protocols that need it. We send the fancy html on
all the signals we emit though. Sean didn't say what to
do about those. I figure always sending html on signals
sounds good.
I'm not sure I like how I did this exactly, especially
with respect to whether it's the core or ui's job to
make sure the html prpl flag gets honored. But it
should be good enough for now.
Anyway, this fixes the "sending someone <> on
IRC/ICQ/MSN/etc shows up blank on my end!" problem.
All prpls need to pass html to the core now, as Sean
said in his email. I made msn, and gg comply. IRC was
cool enough to already be complying. Jabber is so cool
it actually takes html and isn't effected by this.
ICQ, OSCAR, Trepia, zephyr, and napster still need to
be fixed. (Note that it's not this patch that breaks
them, they're already broken in CVS). I think TOC uses
html and isn't effected.
I'm not bothering with the old ICQ prpl. I'm not sure
what's going on in trepia. I'm even less sure what's
going on in zephyr. I didn't even check if napster used
html or not.
For OSCAR, I'm hoping I can get KingAnt to fix it.
Normally I'd say, ICQ messages all need
gaim_escape_html called on them. But what about
receiving an ICQ messagefrom an AIM account, or vise versa?" -- marv yet
again
(00:48:48) LSchiere: marv: should i apply the patch sean asked for or
should i wait for him to look at it?
(00:49:17) marv: LSchiere: he talked like I should get it applied by
someone not him
(00:49:21) LSchiere: kay
(00:49:29) marv: he said i knew the appropriate people to talk to
(00:50:16) LSchiere: KingAnt: marv is making work for you
committer: Tailor Script <tailor@pidgin.im>
author | Luke Schierer <lschiere@pidgin.im> |
---|---|
date | Sun, 14 Mar 2004 05:42:56 +0000 |
parents | ea999c4a9a11 |
children | e401e0e2f0e1 |
files | src/conversation.c src/gtkconv.c src/protocols/gg/gg.c src/protocols/msn/msn.c src/protocols/msn/switchboard.c src/util.c src/util.h |
diffstat | 7 files changed, 76 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/src/conversation.c Sun Mar 14 05:39:37 2004 +0000 +++ b/src/conversation.c Sun Mar 14 05:42:56 2004 +0000 @@ -236,8 +236,15 @@ msgflags |= GAIM_MESSAGE_IMAGES; } - err = serv_send_im(gc, gaim_conversation_get_name(conv), - sent, imflags); + if (gc && gc->flags & GAIM_CONNECTION_HTML) { + err = serv_send_im(gc, gaim_conversation_get_name(conv), + sent, imflags); + } else { + gchar *tmp = gaim_unescape_html(sent); + err = serv_send_im(gc, gaim_conversation_get_name(conv), + tmp, imflags); + g_free(tmp); + } if ((err > 0) && (displayed != NULL)) gaim_conv_im_write(im, NULL, displayed, msgflags, time(NULL)); @@ -269,7 +276,13 @@ gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv))); if (sent != NULL && sent[0] != '\0') { - err = serv_chat_send(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv)), sent); + if (gc && gc->flags & GAIM_CONNECTION_HTML) { + err = serv_chat_send(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv)), sent); + } else { + gchar *tmp = gaim_unescape_html(sent); + err = serv_chat_send(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv)), tmp); + g_free(tmp); + } gaim_signal_emit(gaim_conversations_get_handle(), "sent-chat-msg", gaim_conversation_get_account(conv), sent,
--- a/src/gtkconv.c Sun Mar 14 05:39:37 2004 +0000 +++ b/src/gtkconv.c Sun Mar 14 05:42:56 2004 +0000 @@ -286,10 +286,8 @@ gtkconv = GAIM_GTK_CONVERSATION(conv); - if (gc && gc->flags & GAIM_CONNECTION_HTML) - buf = gtk_imhtml_get_markup(GTK_IMHTML(gtkconv->entry)); - else - buf = gtk_imhtml_get_text(GTK_IMHTML(gtkconv->entry)); + + buf = gtk_imhtml_get_markup(GTK_IMHTML(gtkconv->entry)); /* set_toggle(gtkconv->toolbar.bold, FALSE); set_toggle(gtkconv->toolbar.italic, FALSE);
--- a/src/protocols/gg/gg.c Sun Mar 14 05:39:37 2004 +0000 +++ b/src/protocols/gg/gg.c Sun Mar 14 05:42:56 2004 +0000 @@ -1,6 +1,6 @@ /* * gaim - Gadu-Gadu Protocol Plugin - * $Id: gg.c 8883 2004-01-25 22:15:42Z faceprint $ + * $Id: gg.c 9172 2004-03-14 05:42:56Z lschiere $ * * Copyright (C) 2001 Arkadiusz Mi¶kiewicz <misiek@pld.ORG.PL> * @@ -304,6 +304,7 @@ case GG_EVENT_MSG: { gchar *imsg; + gchar *jmsg; gchar user[20]; g_snprintf(user, sizeof(user), "%lu", e->event.msg.sender); @@ -311,9 +312,11 @@ break; imsg = charset_convert(e->event.msg.message, "CP1250", "UTF-8"); gaim_str_strip_cr(imsg); + jmsg = gaim_escape_html(imsg); /* e->event.msg.time - we don't know what this time is for */ - serv_got_im(gc, user, imsg, 0, time(NULL)); + serv_got_im(gc, user, jmsg, 0, time(NULL)); g_free(imsg); + g_free(jmsg); } break; case GG_EVENT_NOTIFY:
--- a/src/protocols/msn/msn.c Sun Mar 14 05:39:37 2004 +0000 +++ b/src/protocols/msn/msn.c Sun Mar 14 05:42:56 2004 +0000 @@ -562,9 +562,11 @@ * In MSN, you can't send messages to yourself, so * we'll fake like we received it ;) */ + gchar *fakemsg = gaim_escape_html(message); serv_got_typing_stopped(gc, (char *)who); - serv_got_im(gc, who, message, flags, + serv_got_im(gc, who, fakemsg, flags, time(NULL)); + g_free(fakemsg); } return 1; @@ -1035,7 +1037,7 @@ MsnSession *session = gc->proto_data; MsnSwitchBoard *swboard = msn_session_find_switch_with_id(session, id); MsnMessage *msg; - char *send; + char *send, *recv; if (swboard == NULL) return -EINVAL; @@ -1059,8 +1061,10 @@ msn_message_destroy(msg); + recv = gaim_escape_html(message); serv_got_chat_in(gc, id, gaim_account_get_username(account), - 0, message, time(NULL)); + 0, recv, time(NULL)); + g_free(recv); return 0; }
--- a/src/protocols/msn/switchboard.c Sun Mar 14 05:39:37 2004 +0000 +++ b/src/protocols/msn/switchboard.c Sun Mar 14 05:42:56 2004 +0000 @@ -329,7 +329,7 @@ char *body; const char *value; - body = g_strdup(msn_message_get_body(msg)); + body = gaim_escape_html(msn_message_get_body(msg)); if (!strcmp(servconn->msg_passport, "messenger@microsoft.com") && strstr(body, "immediate security update"))
--- a/src/util.c Sun Mar 14 05:39:37 2004 +0000 +++ b/src/util.c Sun Mar 14 05:42:56 2004 +0000 @@ -1351,6 +1351,39 @@ } +char * +gaim_unescape_html(const char *html) { + char *unescaped = NULL; + + if (html != NULL) { + const char *c = html; + GString *ret = g_string_new(""); + while (*c) { + if (!strncmp(c, "&", 5)) { + ret = g_string_append_c(ret, '&'); + c += 5; + } else if (!strncmp(c, "<", 4)) { + ret = g_string_append_c(ret, '<'); + c += 4; + } else if (!strncmp(c, ">", 4)) { + ret = g_string_append_c(ret, '>'); + c += 4; + } else if (!strncmp(c, """, 6)) { + ret = g_string_append_c(ret, '"'); + c += 6; + } else { + ret = g_string_append_c(ret, *c); + c++; + } + } + + unescaped = ret->str; + g_string_free(ret, FALSE); + } + return unescaped; + +} + /************************************************************************** * Path/Filename Functions **************************************************************************/
--- a/src/util.h Sun Mar 14 05:39:37 2004 +0000 +++ b/src/util.h Sun Mar 14 05:42:56 2004 +0000 @@ -276,6 +276,18 @@ */ char *gaim_escape_html(const char *html); +/** + * Unescapes HTML entities to their literal characters. + * For example "&" is replaced by '&' and so on. + * Actually only "&", """, "<" and ">" are currently + * supported. + * + * @param html The string in which to unescape any HTML entities + * + * @return the text with HTML entities literalized + */ +char *gaim_unescape_html(const char *html); + /*@}*/