Mon, 16 Sep 2013 11:58:46 +0200
Gadu-Gadu: don't Werror
|
34358
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
1 | #include "html.h" |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
2 | |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
3 | #include <debug.h> |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
4 | |
|
34359
7cf367cc1141
Gadu-Gadu: compile regular expressions only once per plugin load
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34358
diff
changeset
|
5 | typedef struct |
|
7cf367cc1141
Gadu-Gadu: compile regular expressions only once per plugin load
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34358
diff
changeset
|
6 | { |
|
7cf367cc1141
Gadu-Gadu: compile regular expressions only once per plugin load
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34358
diff
changeset
|
7 | GRegex *re_html_attr; |
|
7cf367cc1141
Gadu-Gadu: compile regular expressions only once per plugin load
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34358
diff
changeset
|
8 | GRegex *re_css_attr; |
|
7cf367cc1141
Gadu-Gadu: compile regular expressions only once per plugin load
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34358
diff
changeset
|
9 | GRegex *re_color_hex; |
|
7cf367cc1141
Gadu-Gadu: compile regular expressions only once per plugin load
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34358
diff
changeset
|
10 | GRegex *re_color_rgb; |
|
7cf367cc1141
Gadu-Gadu: compile regular expressions only once per plugin load
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34358
diff
changeset
|
11 | } ggp_html_global_data; |
|
7cf367cc1141
Gadu-Gadu: compile regular expressions only once per plugin load
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34358
diff
changeset
|
12 | |
|
7cf367cc1141
Gadu-Gadu: compile regular expressions only once per plugin load
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34358
diff
changeset
|
13 | static ggp_html_global_data global_data; |
|
7cf367cc1141
Gadu-Gadu: compile regular expressions only once per plugin load
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34358
diff
changeset
|
14 | |
|
7cf367cc1141
Gadu-Gadu: compile regular expressions only once per plugin load
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34358
diff
changeset
|
15 | void ggp_html_setup(void) |
|
7cf367cc1141
Gadu-Gadu: compile regular expressions only once per plugin load
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34358
diff
changeset
|
16 | { |
|
7cf367cc1141
Gadu-Gadu: compile regular expressions only once per plugin load
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34358
diff
changeset
|
17 | global_data.re_html_attr = g_regex_new( |
|
7cf367cc1141
Gadu-Gadu: compile regular expressions only once per plugin load
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34358
diff
changeset
|
18 | "([a-z-]+)=\"([^\"]+)\"", |
|
7cf367cc1141
Gadu-Gadu: compile regular expressions only once per plugin load
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34358
diff
changeset
|
19 | G_REGEX_OPTIMIZE, 0, NULL); |
|
7cf367cc1141
Gadu-Gadu: compile regular expressions only once per plugin load
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34358
diff
changeset
|
20 | global_data.re_css_attr = g_regex_new( |
|
7cf367cc1141
Gadu-Gadu: compile regular expressions only once per plugin load
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34358
diff
changeset
|
21 | "([a-z-]+): *([^;]+)", |
|
7cf367cc1141
Gadu-Gadu: compile regular expressions only once per plugin load
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34358
diff
changeset
|
22 | G_REGEX_OPTIMIZE, 0, NULL); |
|
7cf367cc1141
Gadu-Gadu: compile regular expressions only once per plugin load
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34358
diff
changeset
|
23 | global_data.re_color_hex = g_regex_new( |
|
7cf367cc1141
Gadu-Gadu: compile regular expressions only once per plugin load
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34358
diff
changeset
|
24 | "^#([0-9a-fA-F]+){6}$", |
|
7cf367cc1141
Gadu-Gadu: compile regular expressions only once per plugin load
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34358
diff
changeset
|
25 | G_REGEX_OPTIMIZE, 0, NULL); |
|
7cf367cc1141
Gadu-Gadu: compile regular expressions only once per plugin load
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34358
diff
changeset
|
26 | global_data.re_color_rgb = g_regex_new( |
|
7cf367cc1141
Gadu-Gadu: compile regular expressions only once per plugin load
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34358
diff
changeset
|
27 | "^rgb\\(([0-9]+), *([0-9]+), *([0-9]+)\\)$", |
|
7cf367cc1141
Gadu-Gadu: compile regular expressions only once per plugin load
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34358
diff
changeset
|
28 | G_REGEX_OPTIMIZE, 0, NULL); |
|
7cf367cc1141
Gadu-Gadu: compile regular expressions only once per plugin load
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34358
diff
changeset
|
29 | } |
|
7cf367cc1141
Gadu-Gadu: compile regular expressions only once per plugin load
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34358
diff
changeset
|
30 | |
|
7cf367cc1141
Gadu-Gadu: compile regular expressions only once per plugin load
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34358
diff
changeset
|
31 | void ggp_html_cleanup(void) |
|
7cf367cc1141
Gadu-Gadu: compile regular expressions only once per plugin load
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34358
diff
changeset
|
32 | { |
|
7cf367cc1141
Gadu-Gadu: compile regular expressions only once per plugin load
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34358
diff
changeset
|
33 | g_regex_unref(global_data.re_html_attr); |
|
7cf367cc1141
Gadu-Gadu: compile regular expressions only once per plugin load
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34358
diff
changeset
|
34 | g_regex_unref(global_data.re_css_attr); |
|
7cf367cc1141
Gadu-Gadu: compile regular expressions only once per plugin load
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34358
diff
changeset
|
35 | g_regex_unref(global_data.re_color_hex); |
|
7cf367cc1141
Gadu-Gadu: compile regular expressions only once per plugin load
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34358
diff
changeset
|
36 | g_regex_unref(global_data.re_color_rgb); |
|
7cf367cc1141
Gadu-Gadu: compile regular expressions only once per plugin load
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34358
diff
changeset
|
37 | } |
|
7cf367cc1141
Gadu-Gadu: compile regular expressions only once per plugin load
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34358
diff
changeset
|
38 | |
|
34358
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
39 | GHashTable * ggp_html_tag_attribs(const gchar *attribs_str) |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
40 | { |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
41 | GMatchInfo *match; |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
42 | GHashTable *attribs = g_hash_table_new_full(g_str_hash, g_str_equal, |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
43 | g_free, g_free); |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
44 | |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
45 | if (attribs_str == NULL) |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
46 | return attribs; |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
47 | |
|
34359
7cf367cc1141
Gadu-Gadu: compile regular expressions only once per plugin load
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34358
diff
changeset
|
48 | g_regex_match(global_data.re_html_attr, attribs_str, 0, &match); |
|
34358
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
49 | while (g_match_info_matches(match)) |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
50 | { |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
51 | g_hash_table_insert(attribs, |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
52 | g_match_info_fetch(match, 1), |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
53 | g_match_info_fetch(match, 2)); |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
54 | |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
55 | g_match_info_next(match, NULL); |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
56 | } |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
57 | g_match_info_free(match); |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
58 | |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
59 | return attribs; |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
60 | } |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
61 | |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
62 | GHashTable * ggp_html_css_attribs(const gchar *attribs_str) |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
63 | { |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
64 | GMatchInfo *match; |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
65 | GHashTable *attribs = g_hash_table_new_full(g_str_hash, g_str_equal, |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
66 | g_free, g_free); |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
67 | |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
68 | if (attribs_str == NULL) |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
69 | return attribs; |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
70 | |
|
34359
7cf367cc1141
Gadu-Gadu: compile regular expressions only once per plugin load
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34358
diff
changeset
|
71 | g_regex_match(global_data.re_css_attr, attribs_str, 0, &match); |
|
34358
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
72 | while (g_match_info_matches(match)) |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
73 | { |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
74 | g_hash_table_insert(attribs, |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
75 | g_match_info_fetch(match, 1), |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
76 | g_match_info_fetch(match, 2)); |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
77 | |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
78 | g_match_info_next(match, NULL); |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
79 | } |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
80 | g_match_info_free(match); |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
81 | |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
82 | return attribs; |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
83 | } |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
84 | |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
85 | int ggp_html_decode_color(const gchar *str) |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
86 | { |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
87 | GMatchInfo *match; |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
88 | int color = -1; |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
89 | |
|
34359
7cf367cc1141
Gadu-Gadu: compile regular expressions only once per plugin load
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34358
diff
changeset
|
90 | g_regex_match(global_data.re_color_hex, str, 0, &match); |
|
34358
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
91 | if (g_match_info_matches(match)) |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
92 | { |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
93 | if (sscanf(str + 1, "%x", &color) != 1) |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
94 | color = -1; |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
95 | } |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
96 | g_match_info_free(match); |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
97 | if (color >= 0) |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
98 | return color; |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
99 | |
|
34359
7cf367cc1141
Gadu-Gadu: compile regular expressions only once per plugin load
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34358
diff
changeset
|
100 | g_regex_match(global_data.re_color_rgb, str, 0, &match); |
|
34358
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
101 | if (g_match_info_matches(match)) |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
102 | { |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
103 | int r = -1, g = -1, b = -1; |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
104 | gchar *c_str; |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
105 | |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
106 | c_str = g_match_info_fetch(match, 1); |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
107 | if (c_str) |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
108 | r = atoi(c_str); |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
109 | g_free(c_str); |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
110 | |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
111 | c_str = g_match_info_fetch(match, 2); |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
112 | if (c_str) |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
113 | g = atoi(c_str); |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
114 | g_free(c_str); |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
115 | |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
116 | c_str = g_match_info_fetch(match, 3); |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
117 | if (c_str) |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
118 | b = atoi(c_str); |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
119 | g_free(c_str); |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
120 | |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
121 | if (r >= 0 && r < 256 && g >= 0 && g < 256 && b >= 0 && b < 256) |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
122 | color = (r << 16) | (g << 8) | b; |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
123 | } |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
124 | g_match_info_free(match); |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
125 | if (color >= 0) |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
126 | return color; |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
127 | |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
128 | return -1; |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
129 | } |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
130 | |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
131 | ggp_html_tag ggp_html_parse_tag(const gchar *tag_str) |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
132 | { |
|
34413
a578366cd35e
Gadu-Gadu: fix sending links
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34365
diff
changeset
|
133 | if (0 == g_ascii_strcasecmp(tag_str, "eom")) |
|
34358
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
134 | return GGP_HTML_TAG_EOM; |
|
34413
a578366cd35e
Gadu-Gadu: fix sending links
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34365
diff
changeset
|
135 | if (0 == g_ascii_strcasecmp(tag_str, "span")) |
|
34358
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
136 | return GGP_HTML_TAG_SPAN; |
|
34413
a578366cd35e
Gadu-Gadu: fix sending links
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34365
diff
changeset
|
137 | if (0 == g_ascii_strcasecmp(tag_str, "div")) |
|
34358
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
138 | return GGP_HTML_TAG_DIV; |
|
34413
a578366cd35e
Gadu-Gadu: fix sending links
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34365
diff
changeset
|
139 | if (0 == g_ascii_strcasecmp(tag_str, "br")) |
|
34358
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
140 | return GGP_HTML_TAG_BR; |
|
34413
a578366cd35e
Gadu-Gadu: fix sending links
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34365
diff
changeset
|
141 | if (0 == g_ascii_strcasecmp(tag_str, "a")) |
|
34360
c6bd55f526f9
Gadu-Gadu: code polishing for messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34359
diff
changeset
|
142 | return GGP_HTML_TAG_A; |
|
34413
a578366cd35e
Gadu-Gadu: fix sending links
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34365
diff
changeset
|
143 | if (0 == g_ascii_strcasecmp(tag_str, "b")) |
|
34358
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
144 | return GGP_HTML_TAG_B; |
|
34413
a578366cd35e
Gadu-Gadu: fix sending links
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34365
diff
changeset
|
145 | if (0 == g_ascii_strcasecmp(tag_str, "i")) |
|
34358
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
146 | return GGP_HTML_TAG_I; |
|
34413
a578366cd35e
Gadu-Gadu: fix sending links
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34365
diff
changeset
|
147 | if (0 == g_ascii_strcasecmp(tag_str, "u")) |
|
34358
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
148 | return GGP_HTML_TAG_U; |
|
34413
a578366cd35e
Gadu-Gadu: fix sending links
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34365
diff
changeset
|
149 | if (0 == g_ascii_strcasecmp(tag_str, "s")) |
|
34358
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
150 | return GGP_HTML_TAG_S; |
|
34413
a578366cd35e
Gadu-Gadu: fix sending links
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34365
diff
changeset
|
151 | if (0 == g_ascii_strcasecmp(tag_str, "img")) |
|
34365
25e4187ea5a7
Gadu-Gadu: outgoing images works again (not in conferences, yet)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34360
diff
changeset
|
152 | return GGP_HTML_TAG_IMG; |
|
34413
a578366cd35e
Gadu-Gadu: fix sending links
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34365
diff
changeset
|
153 | if (0 == g_ascii_strcasecmp(tag_str, "font")) |
|
34358
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
154 | return GGP_HTML_TAG_FONT; |
|
34413
a578366cd35e
Gadu-Gadu: fix sending links
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34365
diff
changeset
|
155 | if (0 == g_ascii_strcasecmp(tag_str, "hr")) |
|
34358
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
156 | return GGP_HTML_TAG_HR; |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
157 | return GGP_HTML_TAG_UNKNOWN; |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
158 | } |