Mercurial > pidgin
changeset 12618:204bd8fac61f
[gaim-migrate @ 14954]
SF Patch #1355796 from Sadrul
This fixes the custom smiley bug where your text gets smilies from the other party in the conversation.
This is a bit of a hack, but it fix things until such time as the smiley tree stuff can be reworked.
" From the kwiki:
If someone uses an MSN smiley, it shows up when I type
the textual representation of it. For example, someone
set a smiley (a rainbow flashy question mark) for ? and
it showed up (on my side, I have no idea about theirs)
for every ? I typed. /luke as I understand this report,
the problem is that the custom smiley should be
restricted to exactly one conversation but is in fact
spanning the account/
* (sadrul) It appears what happens is, the custom
smiley is added to the smiley-tree for that
conversation-imhtml. So whenever any new message is
going to be added to the imhtml, it looks up the
smiley-tree first, and since the "?" (or anything else)
matches the smiley, it converts it to the smiley. At
first glance, it seems the fix would be non-trivial. It
will probably be necessary to distinguish between
custom-smileys (and also messages added to the imhtml)
of the sender and the receiver.
==== end ====
What this patch does is, it temporarily replaces the
smiley-tree for the conversation-imhtml with the
smiley-tree of the conversation-entrybox. I think this
will work because the smiley-trees of both these
imhtml-s are initially the same. When a custom smiley
is received, it is added the smiley-tree of the
conversation-imhtml. So temporarily restoring the
smiley-tree with the original smiley-tree (that in
conv-entrybox) should fix the problem."
committer: Tailor Script <tailor@pidgin.im>
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Thu, 22 Dec 2005 04:07:21 +0000 |
parents | 49499dec9346 |
children | dc995f73c101 |
files | src/conversation.c src/conversation.h src/gtkconv.c src/protocols/msn/slp.c |
diffstat | 4 files changed, 72 insertions(+), 33 deletions(-) [+] |
line wrap: on
line diff
--- a/src/conversation.c Thu Dec 22 04:07:00 2005 +0000 +++ b/src/conversation.c Thu Dec 22 04:07:21 2005 +0000 @@ -1139,7 +1139,8 @@ gboolean gaim_conv_custom_smiley_add(GaimConversation *conv, const char *smile, - const char *cksum_type, const char *chksum) + const char *cksum_type, const char *chksum, + gboolean remote) { if (conv == NULL || smile == NULL || !*smile) { return FALSE; @@ -1148,7 +1149,7 @@ /* TODO: check if the icon is in the cache and return false if so */ /* TODO: add an icon cache (that doesn't suck) */ if (conv->ui_ops != NULL && conv->ui_ops->custom_smiley_add !=NULL) { - return conv->ui_ops->custom_smiley_add(conv, smile); + return conv->ui_ops->custom_smiley_add(conv, smile, remote); } else { gaim_debug_info("conversation", "Could not find add custom smiley function"); return FALSE;
--- a/src/conversation.h Thu Dec 22 04:07:00 2005 +0000 +++ b/src/conversation.h Thu Dec 22 04:07:21 2005 +0000 @@ -164,7 +164,7 @@ gboolean (*has_focus)(GaimConversation *conv); /* Custom Smileys */ - gboolean (*custom_smiley_add)(GaimConversation *conv, const char *smile); + gboolean (*custom_smiley_add)(GaimConversation *conv, const char *smile, gboolean remote); void (*custom_smiley_write)(GaimConversation *conv, const char *smile, const guchar *data, gsize size); void (*custom_smiley_close)(GaimConversation *conv, const char *smile); @@ -769,6 +769,7 @@ * @param smile The text associated with the smiley * @param cksum_type The type of checksum. * @param chksum The checksum, as a NUL terminated base64 string. + * @param remote @c TRUE if the custom smiley is set by the remote user (buddy). * @return @c TRUE if an icon is expected, else FALSE. Note that * it is an error to never call gaim_conv_custom_smiley_close if * this function returns @c TRUE, but an error to call it if @@ -776,7 +777,8 @@ */ gboolean gaim_conv_custom_smiley_add(GaimConversation *conv, const char *smile, - const char *cksum_type, const char *chksum); + const char *cksum_type, const char *chksum, + gboolean remote); /**
--- a/src/gtkconv.c Thu Dec 22 04:07:00 2005 +0000 +++ b/src/gtkconv.c Thu Dec 22 04:07:21 2005 +0000 @@ -4473,6 +4473,20 @@ * escaped entities making the string longer */ int tag_start_offset = alias ? (strlen(alias_escaped) - strlen(alias)) : 0; int tag_end_offset = 0; + GtkSmileyTree *tree = NULL; + GHashTable *smiley_data = NULL; + + if (flags & GAIM_MESSAGE_SEND) + { + /* Temporarily revert to the original smiley-data to avoid showing up + * custom smileys of the buddy when sending message + */ + tree = GTK_IMHTML(gtkconv->imhtml)->default_smilies; + GTK_IMHTML(gtkconv->imhtml)->default_smilies = + GTK_IMHTML(gtkconv->entry)->default_smilies; + smiley_data = GTK_IMHTML(gtkconv->imhtml)->smiley_data; + GTK_IMHTML(gtkconv->imhtml)->smiley_data = GTK_IMHTML(gtkconv->entry)->smiley_data; + } if (flags & GAIM_MESSAGE_WHISPER) { str = g_malloc(1024); @@ -4616,6 +4630,13 @@ gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), with_font_tag, gtk_font_options | gtk_font_options_all); + if (flags & GAIM_MESSAGE_SEND) + { + /* Restore the smiley-data */ + GTK_IMHTML(gtkconv->imhtml)->default_smilies = tree; + GTK_IMHTML(gtkconv->imhtml)->smiley_data = smiley_data; + } + g_free(with_font_tag); g_free(new_message); } @@ -4959,35 +4980,12 @@ } static gboolean -gaim_gtkconv_custom_smiley_add(GaimConversation *conv, const char *smile) -{ - GaimGtkConversation *gtkconv; +add_custom_smiley_for_imhtml(GtkIMHtml *imhtml, const char *sml, const char *smile) +{ GtkIMHtmlSmiley *smiley; GdkPixbufLoader *loader; - struct smiley_list *list; - const char *sml = NULL, *conv_sml; - - if (!conv || !smile || !*smile) { - return FALSE; - } - - /* If smileys are off, return false */ - if (gaim_gtkthemes_smileys_disabled()) - return FALSE; - - /* If possible add this smiley to the current theme. - * The addition is only temporary: custom smilies aren't saved to disk. */ - conv_sml = gaim_account_get_protocol_name(conv->account); - gtkconv = GAIM_GTK_CONVERSATION(conv); - - for (list = (struct smiley_list *)current_smiley_theme->list; list; list = list->next) { - if (!strcmp(list->sml, conv_sml)) { - sml = list->sml; - break; - } - } - - smiley = gtk_imhtml_smiley_get(GTK_IMHTML(gtkconv->imhtml), sml, smile); + + smiley = gtk_imhtml_smiley_get(imhtml, sml, smile); if (smiley) { @@ -4999,6 +4997,7 @@ * the smiley we are about to receive */ g_object_unref(G_OBJECT(smiley->icon)); + /* XXX: Is it necessary to _unref the loader first? */ smiley->loader = gdk_pixbuf_loader_new(); smiley->icon = NULL; @@ -5022,7 +5021,44 @@ g_signal_connect(smiley->loader, "area_prepared", G_CALLBACK(gaim_gtkconv_custom_smiley_allocated), smiley); g_signal_connect(smiley->loader, "closed", G_CALLBACK(gaim_gtkconv_custom_smiley_closed), smiley); - gtk_imhtml_associate_smiley(GTK_IMHTML(gtkconv->imhtml), sml, smiley); + gtk_imhtml_associate_smiley(imhtml, sml, smiley); + + return TRUE; +} + +static gboolean +gaim_gtkconv_custom_smiley_add(GaimConversation *conv, const char *smile, gboolean remote) +{ + GaimGtkConversation *gtkconv; + struct smiley_list *list; + const char *sml = NULL, *conv_sml; + + if (!conv || !smile || !*smile) { + return FALSE; + } + + /* If smileys are off, return false */ + if (gaim_gtkthemes_smileys_disabled()) + return FALSE; + + /* If possible add this smiley to the current theme. + * The addition is only temporary: custom smilies aren't saved to disk. */ + conv_sml = gaim_account_get_protocol_name(conv->account); + gtkconv = GAIM_GTK_CONVERSATION(conv); + + for (list = (struct smiley_list *)current_smiley_theme->list; list; list = list->next) { + if (!strcmp(list->sml, conv_sml)) { + sml = list->sml; + break; + } + } + + if (!add_custom_smiley_for_imhtml(GTK_IMHTML(gtkconv->imhtml), sml, smile)) + return FALSE; + + if (!remote) /* If it's a local custom smiley, then add it for the entry */ + if (!add_custom_smiley_for_imhtml(GTK_IMHTML(gtkconv->entry), sml, smile)) + return FALSE; return TRUE; }
--- a/src/protocols/msn/slp.c Thu Dec 22 04:07:00 2005 +0000 +++ b/src/protocols/msn/slp.c Thu Dec 22 04:07:21 2005 +0000 @@ -831,7 +831,7 @@ conv = gaim_conversation_new(GAIM_CONV_TYPE_IM, session->account, who); } - if (gaim_conv_custom_smiley_add(conv, smile, "sha1", sha1c)) { + if (gaim_conv_custom_smiley_add(conv, smile, "sha1", sha1c, TRUE)) { msn_slplink_request_object(slplink, smile, got_emoticon, NULL, obj); }