| 25 * SECTION:smiley-parser |
25 * SECTION:smiley-parser |
| 26 * @include:smiley-parser.h |
26 * @include:smiley-parser.h |
| 27 * @section_id: libpurple-smiley-parser |
27 * @section_id: libpurple-smiley-parser |
| 28 * @short_description: a efficient smiley processor |
28 * @short_description: a efficient smiley processor |
| 29 * @title: Smiley parser |
29 * @title: Smiley parser |
| |
30 * |
| |
31 * This module is a fast and easy method for searching (and optionally replacing) |
| |
32 * #PurpleSmiley's in a text. It may use all suitable smiley sets to smileyify |
| |
33 * the message in one step. The priority if always the following: remote |
| |
34 * smileys > local custom smileys > theme smileys. |
| 30 */ |
35 */ |
| 31 |
36 |
| 32 #include "purple.h" |
37 #include "purple.h" |
| 33 |
38 |
| |
39 /** |
| |
40 * PurpleSmileyParseCb: |
| |
41 * @out: the message buffer. |
| |
42 * @smiley: found smiley. |
| |
43 * @conv: the conversation of a message. |
| |
44 * @ui_data: the data being passed to #purple_smiley_parse. |
| |
45 * |
| |
46 * A replace callback for the found @smiley. It should append a HTML tag |
| |
47 * representing the @smiley to the @out string. It must not modify the |
| |
48 * @out string in other way than appending to its end. |
| |
49 */ |
| 34 typedef void (*PurpleSmileyParseCb)(GString *out, PurpleSmiley *smiley, |
50 typedef void (*PurpleSmileyParseCb)(GString *out, PurpleSmiley *smiley, |
| 35 PurpleConversation *conv, gpointer ui_data); |
51 PurpleConversation *conv, gpointer ui_data); |
| 36 |
52 |
| 37 /* XXX: this shouldn't be a conv for incoming messages - see |
53 /** |
| 38 * PurpleConversationPrivate#remote_smileys. |
54 * purple_smiley_parse: |
| 39 * For outgoing, we could pass conv in ui_data (or something). |
55 * @conv: the conversation of a message. |
| 40 * Or maybe we should use two distinct functions? |
56 * @html_message: the html message, or escaped plain message. |
| |
57 * @use_remote_smileys: %TRUE if remote smileys of @conv should be parsed. |
| |
58 * @cb: the callback to replace smiley text with an image. |
| |
59 * @ui_data: the user data to be passed to @cb and |
| |
60 * #purple_smiley_theme_get_smileys. |
| 41 * |
61 * |
| 42 * @ui_data is passed to @cb and #purple_smiley_theme_get_smileys. |
62 * Replaces all textual smiley representations with proper smiley images. |
| 43 * |
63 * |
| 44 * @use_remote_smileys should be TRUE for incoming messages, FALSE for outgoing. |
64 * The @use_remote_smileys parameter should be %TRUE for incoming messages, |
| |
65 * %FALSE for outgoing. |
| |
66 * |
| |
67 * Returns: (transfer full): the smileyifed message. Should be #g_free'd when |
| |
68 * done using it. Returns %NULL if and only if @html_message was %NULL. |
| 45 */ |
69 */ |
| 46 gchar * |
70 gchar * |
| 47 purple_smiley_parse(PurpleConversation *conv, const gchar *html_message, |
71 purple_smiley_parse(PurpleConversation *conv, const gchar *html_message, |
| 48 gboolean use_remote_smileys, PurpleSmileyParseCb cb, gpointer ui_data); |
72 gboolean use_remote_smileys, PurpleSmileyParseCb cb, gpointer ui_data); |
| 49 |
73 |
| |
74 /** |
| |
75 * purple_smiley_find: |
| |
76 * @smileys: the list of smileys to find. |
| |
77 * @message: the message. |
| |
78 * @is_html: %TRUE if the message is HTML, %FALSE if it's plain, unescaped. |
| |
79 * |
| |
80 * Searches for all smileys from the @smileys list present in @message. |
| |
81 * Each smiley is returned only once, regardless how many times it appeared in |
| |
82 * text. However, distinct smileys may share common image file (thus, their |
| |
83 * paths will be the same). |
| |
84 * |
| |
85 * Returns: (transfer container): the #GList of found smileys. Use #g_list_free |
| |
86 * when no longer need it. |
| |
87 */ |
| 50 GList * |
88 GList * |
| 51 purple_smiley_find(PurpleSmileyList *smileys, const gchar *message, |
89 purple_smiley_find(PurpleSmileyList *smileys, const gchar *message, |
| 52 gboolean is_html); |
90 gboolean is_html); |
| 53 |
91 |
| 54 #endif /* _PURPLE_SMILEY_PARSER_H_ */ |
92 #endif /* _PURPLE_SMILEY_PARSER_H_ */ |