/dev/tomkiewicz/new-smileys: dfbba8ed898d: Smileys: better contr...

Tomasz Wasilczyk twasilczyk at pidgin.im
Fri Apr 4 18:23:54 EDT 2014


Changeset: dfbba8ed898df850b000f940b23dc727030c76c5
Author:	 Tomasz Wasilczyk <twasilczyk at pidgin.im>
Date:	 2014-04-05 00:23 +0200
Branch:	 default
URL: https://hg.pidgin.im/dev/tomkiewicz/new-smileys/rev/dfbba8ed898d

Description:

Smileys: better control over smiley lists priority

diffstat:

 libpurple/smiley-parser.c |  11 +++++++++--
 libpurple/smiley-parser.h |   6 +++---
 pidgin/gtkconv.c          |   2 +-
 3 files changed, 13 insertions(+), 6 deletions(-)

diffs (76 lines):

diff --git a/libpurple/smiley-parser.c b/libpurple/smiley-parser.c
--- a/libpurple/smiley-parser.c
+++ b/libpurple/smiley-parser.c
@@ -24,6 +24,8 @@
 #include "smiley-custom.h"
 #include "smiley-theme.h"
 
+#define DISPLAY_OUR_CUSTOM_SMILEYS_FOR_INCOMING_MESSAGES 1
+
 typedef struct
 {
 	PurpleConversation *conv;
@@ -44,7 +46,7 @@ static gboolean purple_smiley_parse_cb(G
 
 gchar *
 purple_smiley_parse(PurpleConversation *conv, const gchar *html_message,
-	PurpleSmileyParseCb cb, gpointer ui_data)
+	gboolean use_remote_smileys, PurpleSmileyParseCb cb, gpointer ui_data)
 {
 	PurpleSmileyTheme *theme;
 	PurpleSmileyList *theme_smileys = NULL, *remote_smileys = NULL;
@@ -56,7 +58,8 @@ purple_smiley_parse(PurpleConversation *
 		return g_strdup(html_message);
 
 	/* get remote smileys */
-	remote_smileys = purple_conversation_get_remote_smileys(conv);
+	if (use_remote_smileys)
+		remote_smileys = purple_conversation_get_remote_smileys(conv);
 	if (remote_smileys)
 		remote_trie = purple_smiley_list_get_trie(remote_smileys);
 	if (remote_trie && purple_trie_get_size(remote_trie) == 0)
@@ -68,6 +71,10 @@ purple_smiley_parse(PurpleConversation *
 	{
 		custom_trie = purple_smiley_list_get_trie(
 			purple_smiley_custom_get_list());
+#if !DISPLAY_OUR_CUSTOM_SMILEYS_FOR_INCOMING_MESSAGES
+		if (use_remote_smileys)
+			custom_trie = NULL;
+#endif
 	}
 	if (custom_trie && purple_trie_get_size(custom_trie) == 0)
 		custom_trie = NULL;
diff --git a/libpurple/smiley-parser.h b/libpurple/smiley-parser.h
--- a/libpurple/smiley-parser.h
+++ b/libpurple/smiley-parser.h
@@ -30,15 +30,15 @@ typedef void (*PurpleSmileyParseCb)(GStr
 /* XXX: this shouldn't be a conv for incoming messages - see
  * PurpleConversationPrivate#remote_smileys.
  * For outgoing, we could pass conv in ui_data (or something).
+ * Or maybe we should use two distinct functions?
  *
  * @ui_data is passed to @cb and #purple_smiley_theme_get_smileys.
  *
- * XXX: we might not want to display remote smileys for
- * outgoing messages. To be considered.
+ * @use_remote_smileys should be TRUE for incoming messages, FALSE for outgoing.
  */
 gchar *
 purple_smiley_parse(PurpleConversation *conv, const gchar *html_message,
-	PurpleSmileyParseCb cb, gpointer ui_data);
+	gboolean use_remote_smileys, PurpleSmileyParseCb cb, gpointer ui_data);
 
 GList *
 purple_smiley_find(PurpleSmileyList *smileys, const gchar *html_message);
diff --git a/pidgin/gtkconv.c b/pidgin/gtkconv.c
--- a/pidgin/gtkconv.c
+++ b/pidgin/gtkconv.c
@@ -6789,7 +6789,7 @@ pidgin_conv_write_conv(PurpleConversatio
 	gtkconv->last_flags = flags;
 	gtkconv->last_conversed = conv;
 
-	smileyed = purple_smiley_parse(conv, displaying,
+	smileyed = purple_smiley_parse(conv, displaying, (flags & PURPLE_MESSAGE_RECV),
 		pidgin_conv_write_smiley,
 		(gpointer)purple_account_get_protocol_name(account));
 	msg = replace_message_tokens(message_html, conv, name, alias, smileyed, flags, mtime);



More information about the Commits mailing list