/pidgin/main: d18a48a68edf: Smiley parser: better symbol names

Tomasz Wasilczyk twasilczyk at pidgin.im
Tue Apr 8 08:11:27 EDT 2014


Changeset: d18a48a68edfc1a67dad25af07393c3298fecb90
Author:	 Tomasz Wasilczyk <twasilczyk at pidgin.im>
Date:	 2014-04-08 14:11 +0200
Branch:	 default
URL: https://hg.pidgin.im/pidgin/main/rev/d18a48a68edf

Description:

Smiley parser: better symbol names

diffstat:

 libpurple/protocols/jabber/message.c |   7 ++++---
 libpurple/protocols/msn/msn.c        |   2 +-
 libpurple/smiley-parser.c            |  31 +++++++++++++++----------------
 libpurple/smiley-parser.h            |  14 +++++++-------
 pidgin/gtkconv.c                     |   4 ++--
 5 files changed, 29 insertions(+), 29 deletions(-)

diffs (169 lines):

diff --git a/libpurple/protocols/jabber/message.c b/libpurple/protocols/jabber/message.c
--- a/libpurple/protocols/jabber/message.c
+++ b/libpurple/protocols/jabber/message.c
@@ -920,8 +920,8 @@ jabber_message_smileyfy_xhtml(JabberMess
 	if (!jabber_conv_support_custom_smileys(jm->js, conv, jm->to))
 		return NULL;
 
-	found_smileys = purple_smiley_find(purple_smiley_custom_get_list(),
-		xhtml, TRUE);
+	found_smileys = purple_smiley_parser_find(
+		purple_smiley_custom_get_list(), xhtml, TRUE);
 	if (!found_smileys)
 		return NULL;
 
@@ -990,7 +990,8 @@ jabber_message_smileyfy_xhtml(JabberMess
 
 	g_list_free(found_smileys);
 
-	smileyfied_xhtml = purple_smiley_parse_custom(xhtml,
+	smileyfied_xhtml = purple_smiley_parser_replace(
+		purple_smiley_custom_get_list(), xhtml,
 		jabber_message_smileyify_cb, NULL);
 
 	return smileyfied_xhtml;
diff --git a/libpurple/protocols/msn/msn.c b/libpurple/protocols/msn/msn.c
--- a/libpurple/protocols/msn/msn.c
+++ b/libpurple/protocols/msn/msn.c
@@ -1474,7 +1474,7 @@ static GSList* msn_msg_grab_emoticons(co
 	GList *smileys, *it;
 	MsnEmoticon *emoticon;
 
-	smileys = purple_smiley_find(purple_smiley_custom_get_list(),
+	smileys = purple_smiley_parser_find(purple_smiley_custom_get_list(),
 		msg, FALSE);
 
 	for (it = smileys; it; it = g_list_next(it)) {
diff --git a/libpurple/smiley-parser.c b/libpurple/smiley-parser.c
--- a/libpurple/smiley-parser.c
+++ b/libpurple/smiley-parser.c
@@ -84,7 +84,7 @@ purple_smiley_parse_cb(GString *out, con
  * To be reconsidered when we had PurpleDude-like objects.
  */
 gchar *
-purple_smiley_parse(PurpleConversation *conv, const gchar *html_message,
+purple_smiley_parser_smileify(PurpleConversation *conv, const gchar *html_message,
 	gboolean use_remote_smileys, PurpleSmileyParseCb cb, gpointer ui_data)
 {
 	PurpleSmileyTheme *theme;
@@ -157,34 +157,33 @@ purple_smiley_parse(PurpleConversation *
 }
 
 gchar *
-purple_smiley_parse_custom(const gchar *html_message, PurpleSmileyParseCb cb,
-	gpointer ui_data)
+purple_smiley_parser_replace(PurpleSmileyList *smileys,
+	const gchar *html_message, PurpleSmileyParseCb cb, gpointer ui_data)
 {
-	PurpleTrie *custom_trie = NULL;
-	GSList *tries = NULL;
-	GSList tries_sentry, tries_custom;
+	PurpleTrie *smileys_trie = NULL;
+	GSList trie_1, trie_2;
 	PurpleSmileyParseData parse_data;
 
 	if (html_message == NULL || html_message[0] == '\0')
 		return g_strdup(html_message);
 
-	custom_trie = purple_smiley_list_get_trie(
-		purple_smiley_custom_get_list());
-	if (!custom_trie || purple_trie_get_size(custom_trie) == 0)
+	if (smileys == NULL || purple_smiley_list_is_empty(smileys))
 		return g_strdup(html_message);
 
-	tries_sentry.data = html_sentry;
-	tries_custom.data = custom_trie;
-	tries_sentry.next = &tries_custom;
-	tries_custom.next = NULL;
-	tries = &tries_sentry;
+	smileys_trie = purple_smiley_list_get_trie(smileys);
+	g_return_val_if_fail(smileys_trie != NULL, NULL);
+
+	trie_1.data = html_sentry;
+	trie_2.data = smileys_trie;
+	trie_1.next = &trie_2;
+	trie_2.next = NULL;
 
 	parse_data.job.replace.conv = NULL;
 	parse_data.job.replace.cb = cb;
 	parse_data.job.replace.ui_data = ui_data;
 	parse_data.in_html_tag = FALSE;
 
-	return purple_trie_multi_replace(tries, html_message,
+	return purple_trie_multi_replace(&trie_1, html_message,
 		purple_smiley_parse_cb, &parse_data);
 }
 
@@ -209,7 +208,7 @@ smiley_find_cb(const gchar *word, gpoint
 }
 
 GList *
-purple_smiley_find(PurpleSmileyList *smileys, const gchar *message,
+purple_smiley_parser_find(PurpleSmileyList *smileys, const gchar *message,
 	gboolean is_html)
 {
 	PurpleTrie *smileys_trie;
diff --git a/libpurple/smiley-parser.h b/libpurple/smiley-parser.h
--- a/libpurple/smiley-parser.h
+++ b/libpurple/smiley-parser.h
@@ -56,7 +56,7 @@ typedef gboolean (*PurpleSmileyParseCb)(
 	PurpleConversation *conv, gpointer ui_data);
 
 /**
- * purple_smiley_parse:
+ * purple_smiley_parser_smileify:
  * @conv: the conversation of a message.
  * @html_message: the html message, or escaped plain message.
  * @use_remote_smileys: %TRUE if remote smileys of @conv should be parsed.
@@ -73,11 +73,11 @@ typedef gboolean (*PurpleSmileyParseCb)(
  *          done using it. Returns %NULL if and only if @html_message was %NULL.
  */
 gchar *
-purple_smiley_parse(PurpleConversation *conv, const gchar *html_message,
+purple_smiley_parser_smileify(PurpleConversation *conv, const gchar *html_message,
 	gboolean use_remote_smileys, PurpleSmileyParseCb cb, gpointer ui_data);
 
 /**
- * purple_smiley_parse_custom:
+ * purple_smiley_parser_replace:
  * @html_message:
  * @cb:
  * @ui_data:
@@ -87,11 +87,11 @@ purple_smiley_parse(PurpleConversation *
  * Returns: TODO
  */
 gchar *
-purple_smiley_parse_custom(const gchar *html_message, PurpleSmileyParseCb cb,
-	gpointer ui_data);
+purple_smiley_parser_replace(PurpleSmileyList *smileys,
+	const gchar *html_message, PurpleSmileyParseCb cb, gpointer ui_data);
 
 /**
- * purple_smiley_find:
+ * purple_smiley_parser_find:
  * @smileys: the list of smileys to find.
  * @message: the message.
  * @is_html: %TRUE if the message is HTML, %FALSE if it's plain, unescaped.
@@ -105,7 +105,7 @@ purple_smiley_parse_custom(const gchar *
  *          when no longer need it.
  */
 GList *
-purple_smiley_find(PurpleSmileyList *smileys, const gchar *message,
+purple_smiley_parser_find(PurpleSmileyList *smileys, const gchar *message,
 	gboolean is_html);
 
 /**
diff --git a/pidgin/gtkconv.c b/pidgin/gtkconv.c
--- a/pidgin/gtkconv.c
+++ b/pidgin/gtkconv.c
@@ -6794,8 +6794,8 @@ pidgin_conv_write_conv(PurpleConversatio
 	gtkconv->last_flags = flags;
 	gtkconv->last_conversed = conv;
 
-	smileyed = purple_smiley_parse(conv, displaying, (flags & PURPLE_MESSAGE_RECV),
-		pidgin_conv_write_smiley,
+	smileyed = purple_smiley_parser_smileify(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);
 	escape = pidgin_webview_quote_js_string(msg ? msg : "");



More information about the Commits mailing list