Smileys: add PurpleConversation to the parser callback

Fri, 04 Apr 2014 18:28:58 +0200

author
Tomasz Wasilczyk <twasilczyk@pidgin.im>
date
Fri, 04 Apr 2014 18:28:58 +0200
changeset 35752
77cec2a188ee
parent 35751
25ad1e702bf3
child 35753
222e69060b4a

Smileys: add PurpleConversation to the parser callback

libpurple/smiley-parser.c file | annotate | diff | comparison | revisions
libpurple/smiley-parser.h file | annotate | diff | comparison | revisions
pidgin/gtkconv.c file | annotate | diff | comparison | revisions
--- a/libpurple/smiley-parser.c	Fri Apr 04 18:17:06 2014 +0200
+++ b/libpurple/smiley-parser.c	Fri Apr 04 18:28:58 2014 +0200
@@ -26,6 +26,7 @@
 
 typedef struct
 {
+	PurpleConversation *conv;
 	PurpleSmileyParseCb cb;
 	gpointer ui_data;
 } PurpleSmileyParseData;
@@ -59,7 +60,7 @@
 	PurpleSmileyParseData *parse_data = _parse_data;
 	PurpleSmiley *smiley = _smiley;
 
-	parse_data->cb(out, smiley, parse_data->ui_data);
+	parse_data->cb(out, smiley, parse_data->conv, parse_data->ui_data);
 
 	return TRUE;
 }
@@ -125,9 +126,7 @@
 			tries = &tries_theme;
 	}
 
-	/* XXX: should we parse custom smileys,
-	 * if protocol doesn't support it? */
-
+	parse_data.conv = conv;
 	parse_data.cb = cb;
 	parse_data.ui_data = ui_data;
 
--- a/libpurple/smiley-parser.h	Fri Apr 04 18:17:06 2014 +0200
+++ b/libpurple/smiley-parser.h	Fri Apr 04 18:28:58 2014 +0200
@@ -25,7 +25,7 @@
 #include "purple.h"
 
 typedef void (*PurpleSmileyParseCb)(GString *out, PurpleSmiley *smiley,
-	gpointer ui_data);
+	PurpleConversation *conv, gpointer ui_data);
 
 gboolean
 purple_smiley_parse_escape(void);
@@ -33,6 +33,8 @@
 /* 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).
+ *
+ * @ui_data is passed to @cb and #purple_smiley_theme_get_smileys.
  */
 gchar *
 purple_smiley_parse(PurpleConversation *conv, const gchar *message,
--- a/pidgin/gtkconv.c	Fri Apr 04 18:17:06 2014 +0200
+++ b/pidgin/gtkconv.c	Fri Apr 04 18:28:58 2014 +0200
@@ -6584,11 +6584,8 @@
 
 static void
 pidgin_conv_write_smiley(GString *out, PurpleSmiley *smiley,
-	gpointer _proto_name)
-{
-#if 0
-	const gchar *proto_name = _proto_name;
-#endif
+	PurpleConversation *conv, gpointer _proto_name)
+{
 	gchar *escaped_shortcut;
 	const gchar *path = purple_smiley_get_path(smiley);
 
@@ -6609,7 +6606,6 @@
 			PURPLE_STORED_IMAGE_PROTOCOL "%d\" />",
 			escaped_shortcut, escaped_shortcut, imgid);
 	} else {
-		/* TODO: remove this background, maybe put something into css file? */
 		g_string_append_printf(out,
 			"<span class=\"emoticon pending\">%s</span>",
 			escaped_shortcut);

mercurial