pidgin/smileyparser.c

Sat, 17 Aug 2013 23:28:51 +0530

author
Ankit Vani <a@nevitus.org>
date
Sat, 17 Aug 2013 23:28:51 +0530
branch
soc.2013.gobjectification.plugins
changeset 36544
1bf8b6ef5aea
parent 36424
477889a0073c
child 36607
7ad7681dcfd8
permissions
-rw-r--r--

Renamed PurplePluginProtocolInfo to PurpleProtocol

32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32447
diff changeset
1 /* pidgin
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32447
diff changeset
2 *
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32447
diff changeset
3 * Pidgin is the legal property of its developers, whose names are too numerous
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32447
diff changeset
4 * to list here. Please refer to the COPYRIGHT file distributed with this
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32447
diff changeset
5 * source distribution.
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32447
diff changeset
6 *
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32447
diff changeset
7 * This program is free software; you can redistribute it and/or modify
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32447
diff changeset
8 * it under the terms of the GNU General Public License as published by
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32447
diff changeset
9 * the Free Software Foundation; either version 2 of the License, or
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32447
diff changeset
10 * (at your option) any later version.
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32447
diff changeset
11 *
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32447
diff changeset
12 * This program is distributed in the hope that it will be useful,
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32447
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32447
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32447
diff changeset
15 * GNU General Public License for more details.
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32447
diff changeset
16 *
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32447
diff changeset
17 * You should have received a copy of the GNU General Public License
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32447
diff changeset
18 * along with this program; if not, write to the Free Software
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32447
diff changeset
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32447
diff changeset
20 *
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32447
diff changeset
21 */
32447
19c015e19e7e added smileyparser code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
22
19c015e19e7e added smileyparser code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
23 #include <gtk/gtk.h>
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32447
diff changeset
24 #include <debug.h>
32447
19c015e19e7e added smileyparser code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
25 #include "smileyparser.h"
19c015e19e7e added smileyparser code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
26 #include <smiley.h>
19c015e19e7e added smileyparser code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
27 #include <string.h>
19c015e19e7e added smileyparser code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
28 #include "gtkthemes.h"
19c015e19e7e added smileyparser code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
29
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32447
diff changeset
30 static char *
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32447
diff changeset
31 get_fullpath(const char *filename)
32447
19c015e19e7e added smileyparser code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
32 {
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32447
diff changeset
33 if (g_path_is_absolute(filename))
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32447
diff changeset
34 return g_strdup(filename);
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32447
diff changeset
35 else
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32447
diff changeset
36 return g_build_path(g_get_current_dir(), filename, NULL);
32447
19c015e19e7e added smileyparser code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
37 }
19c015e19e7e added smileyparser code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
38
19c015e19e7e added smileyparser code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
39 static void
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32447
diff changeset
40 parse_for_shortcut_plaintext(const char *text, const char *shortcut, const char *file, GString *ret)
32447
19c015e19e7e added smileyparser code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
41 {
19c015e19e7e added smileyparser code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
42 const char *tmp = text;
19c015e19e7e added smileyparser code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
43
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32447
diff changeset
44 for (;*tmp;) {
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32447
diff changeset
45 const char *end = strstr(tmp, shortcut);
32447
19c015e19e7e added smileyparser code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
46 char *path;
19c015e19e7e added smileyparser code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
47 char *escaped_path;
19c015e19e7e added smileyparser code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
48
19c015e19e7e added smileyparser code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
49 if (end == NULL) {
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32447
diff changeset
50 g_string_append(ret, tmp);
32447
19c015e19e7e added smileyparser code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
51 break;
19c015e19e7e added smileyparser code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
52 }
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32447
diff changeset
53 path = get_fullpath(file);
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32447
diff changeset
54 escaped_path = g_markup_escape_text(path, -1);
32447
19c015e19e7e added smileyparser code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
55
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32447
diff changeset
56 g_string_append_len(ret, tmp, end-tmp);
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32447
diff changeset
57 g_string_append_printf(ret,"<img alt='%s' src='%s' />",
32447
19c015e19e7e added smileyparser code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
58 shortcut, escaped_path);
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32447
diff changeset
59 g_free(path);
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32447
diff changeset
60 g_free(escaped_path);
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32447
diff changeset
61 g_assert(strlen(tmp) >= strlen(shortcut));
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32447
diff changeset
62 tmp = end + strlen(shortcut);
32447
19c015e19e7e added smileyparser code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
63 }
19c015e19e7e added smileyparser code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
64 }
19c015e19e7e added smileyparser code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
65
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32447
diff changeset
66 static char *
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32447
diff changeset
67 parse_for_shortcut(const char *markup, const char *shortcut, const char *file)
32447
19c015e19e7e added smileyparser code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
68 {
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32447
diff changeset
69 GString* ret = g_string_new("");
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32447
diff changeset
70 char *local_markup = g_strdup(markup);
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32447
diff changeset
71 char *escaped_shortcut = g_markup_escape_text(shortcut, -1);
32447
19c015e19e7e added smileyparser code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
72
19c015e19e7e added smileyparser code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
73 char *temp = local_markup;
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32447
diff changeset
74
32447
19c015e19e7e added smileyparser code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
75 for (;*temp;) {
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32447
diff changeset
76 char *end = strchr(temp, '<');
32447
19c015e19e7e added smileyparser code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
77 char *end_of_tag;
19c015e19e7e added smileyparser code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
78
19c015e19e7e added smileyparser code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
79 if (!end) {
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32447
diff changeset
80 parse_for_shortcut_plaintext(temp, escaped_shortcut, file, ret);
32447
19c015e19e7e added smileyparser code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
81 break;
19c015e19e7e added smileyparser code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
82 }
19c015e19e7e added smileyparser code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
83
19c015e19e7e added smileyparser code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
84 *end = 0;
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32447
diff changeset
85 parse_for_shortcut_plaintext(temp, escaped_shortcut, file, ret);
32447
19c015e19e7e added smileyparser code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
86 *end = '<';
19c015e19e7e added smileyparser code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
87
19c015e19e7e added smileyparser code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
88 /* if this is well-formed, then there should be no '>' within
19c015e19e7e added smileyparser code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
89 * the tag. TODO: handle a comment tag better :( */
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32447
diff changeset
90 end_of_tag = strchr(end, '>');
32447
19c015e19e7e added smileyparser code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
91 if (!end_of_tag) {
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32447
diff changeset
92 g_string_append(ret, end);
32447
19c015e19e7e added smileyparser code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
93 break;
19c015e19e7e added smileyparser code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
94 }
19c015e19e7e added smileyparser code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
95
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32447
diff changeset
96 g_string_append_len(ret, end, end_of_tag - end + 1);
32447
19c015e19e7e added smileyparser code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
97
19c015e19e7e added smileyparser code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
98 temp = end_of_tag + 1;
19c015e19e7e added smileyparser code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
99 }
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32447
diff changeset
100 g_free(local_markup);
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32447
diff changeset
101 g_free(escaped_shortcut);
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32447
diff changeset
102 return g_string_free(ret, FALSE);
32447
19c015e19e7e added smileyparser code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
103 }
19c015e19e7e added smileyparser code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
104
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32447
diff changeset
105 static char *
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32447
diff changeset
106 parse_for_purple_smiley(const char *markup, PurpleSmiley *smiley)
32447
19c015e19e7e added smileyparser code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
107 {
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32447
diff changeset
108 char *file = purple_smiley_get_full_path(smiley);
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32447
diff changeset
109 char *ret = parse_for_shortcut(markup, purple_smiley_get_shortcut(smiley), file);
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32447
diff changeset
110 g_free(file);
32447
19c015e19e7e added smileyparser code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
111 return ret;
19c015e19e7e added smileyparser code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
112 }
19c015e19e7e added smileyparser code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
113
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32447
diff changeset
114 static char *
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32447
diff changeset
115 parse_for_smiley_list(const char *markup, GHashTable *smileys)
32447
19c015e19e7e added smileyparser code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
116 {
19c015e19e7e added smileyparser code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
117 GHashTableIter iter;
19c015e19e7e added smileyparser code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
118 char *key, *value;
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32447
diff changeset
119 char *ret = g_strdup(markup);
32447
19c015e19e7e added smileyparser code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
120
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32447
diff changeset
121 g_hash_table_iter_init(&iter, smileys);
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32447
diff changeset
122 while (g_hash_table_iter_next(&iter, (gpointer *)&key, (gpointer *)&value))
32447
19c015e19e7e added smileyparser code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
123 {
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32447
diff changeset
124 char *temp = parse_for_shortcut(ret, key, value);
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32447
diff changeset
125 g_free(ret);
32447
19c015e19e7e added smileyparser code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
126 ret = temp;
19c015e19e7e added smileyparser code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
127 }
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32447
diff changeset
128
32447
19c015e19e7e added smileyparser code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
129 return ret;
19c015e19e7e added smileyparser code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
130 }
19c015e19e7e added smileyparser code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
131
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32447
diff changeset
132 char *
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32447
diff changeset
133 smiley_parse_markup(const char *markup, const char *proto_id)
32447
19c015e19e7e added smileyparser code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
134 {
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32447
diff changeset
135 GList *smileys = purple_smileys_get_all();
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32447
diff changeset
136 char *temp = g_strdup(markup), *temp2;
32447
19c015e19e7e added smileyparser code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
137 struct smiley_list *list;
19c015e19e7e added smileyparser code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
138 const char *proto_name = "default";
19c015e19e7e added smileyparser code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
139
19c015e19e7e added smileyparser code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
140 if (proto_id != NULL) {
36544
1bf8b6ef5aea Renamed PurplePluginProtocolInfo to PurpleProtocol
Ankit Vani <a@nevitus.org>
parents: 36424
diff changeset
141 PurpleProtocol *protocol;
1bf8b6ef5aea Renamed PurplePluginProtocolInfo to PurpleProtocol
Ankit Vani <a@nevitus.org>
parents: 36424
diff changeset
142 protocol = purple_find_protocol_info(proto_id);
1bf8b6ef5aea Renamed PurplePluginProtocolInfo to PurpleProtocol
Ankit Vani <a@nevitus.org>
parents: 36424
diff changeset
143 proto_name = protocol->name;
32447
19c015e19e7e added smileyparser code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
144 }
19c015e19e7e added smileyparser code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
145
19c015e19e7e added smileyparser code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
146 /* unnecessarily slow, but lets manage for now. */
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32447
diff changeset
147 for (; smileys; smileys = g_list_next(smileys)) {
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32447
diff changeset
148 temp2 = parse_for_purple_smiley(temp, PURPLE_SMILEY(smileys->data));
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32447
diff changeset
149 g_free(temp);
32447
19c015e19e7e added smileyparser code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
150 temp = temp2;
19c015e19e7e added smileyparser code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
151 }
19c015e19e7e added smileyparser code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
152
19c015e19e7e added smileyparser code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
153 /* now for each theme smiley, observe that this does look nasty */
33539
12e93808f35d Fix some warnings in debug and conv windows
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 32513
diff changeset
154 if (!current_smiley_theme) {
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32447
diff changeset
155 purple_debug_warning("smiley", "theme does not exist\n");
32447
19c015e19e7e added smileyparser code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
156 return temp;
19c015e19e7e added smileyparser code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
157 }
19c015e19e7e added smileyparser code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
158
19c015e19e7e added smileyparser code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
159 for (list = current_smiley_theme->list; list; list = list->next) {
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32447
diff changeset
160 if (g_str_equal(list->sml, proto_name)) {
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32447
diff changeset
161 temp2 = parse_for_smiley_list(temp, list->files);
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32447
diff changeset
162 g_free(temp);
32447
19c015e19e7e added smileyparser code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
163 temp = temp2;
19c015e19e7e added smileyparser code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
164 }
19c015e19e7e added smileyparser code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
165 }
19c015e19e7e added smileyparser code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
166
19c015e19e7e added smileyparser code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
167 return temp;
19c015e19e7e added smileyparser code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
168 }
19c015e19e7e added smileyparser code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
169

mercurial