Wed, 19 Oct 2022 06:25:35 -0500
Back out the PurpleProtocol->login change that returned a PurpleConnection
This remains to be a good idea, but this implementation caused more issues than
it solved. I'm working on that better implementation, but we need to revert all
of this first, otherwise the new review request is going to be massive.
This reverts commits 3f96e2b2b03d, d567f89d6a9b, and 6ef5bb284651. These were
backed out manually due to some other commits that made automative backouts
difficult.
Testing Done:
Connected a demo, ircv3, and xmpp accounts without issue.
Reviewed at https://reviews.imfreedom.org/r/1937/
|
35358
7beae478c905
Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34413
diff
changeset
|
1 | /* purple |
|
7beae478c905
Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34413
diff
changeset
|
2 | * |
|
7beae478c905
Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34413
diff
changeset
|
3 | * Purple is the legal property of its developers, whose names are too numerous |
|
7beae478c905
Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34413
diff
changeset
|
4 | * to list here. Please refer to the COPYRIGHT file distributed with this |
|
7beae478c905
Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34413
diff
changeset
|
5 | * source distribution. |
|
7beae478c905
Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34413
diff
changeset
|
6 | * |
|
7beae478c905
Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34413
diff
changeset
|
7 | * Component written by Tomek Wasilczyk (http://www.wasilczyk.pl). |
|
7beae478c905
Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34413
diff
changeset
|
8 | * |
|
7beae478c905
Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34413
diff
changeset
|
9 | * This file is dual-licensed under the GPL2+ and the X11 (MIT) licences. |
|
7beae478c905
Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34413
diff
changeset
|
10 | * As a recipient of this file you may choose, which license to receive the |
|
7beae478c905
Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34413
diff
changeset
|
11 | * code under. As a contributor, you have to ensure the new code is |
|
7beae478c905
Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34413
diff
changeset
|
12 | * compatible with both. |
|
7beae478c905
Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34413
diff
changeset
|
13 | * |
|
7beae478c905
Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34413
diff
changeset
|
14 | * This program is free software; you can redistribute it and/or modify |
|
7beae478c905
Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34413
diff
changeset
|
15 | * it under the terms of the GNU General Public License as published by |
|
7beae478c905
Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34413
diff
changeset
|
16 | * the Free Software Foundation; either version 2 of the License, or |
|
7beae478c905
Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34413
diff
changeset
|
17 | * (at your option) any later version. |
|
7beae478c905
Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34413
diff
changeset
|
18 | * |
|
7beae478c905
Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34413
diff
changeset
|
19 | * This program is distributed in the hope that it will be useful, |
|
7beae478c905
Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34413
diff
changeset
|
20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
7beae478c905
Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34413
diff
changeset
|
21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
7beae478c905
Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34413
diff
changeset
|
22 | * GNU General Public License for more details. |
|
7beae478c905
Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34413
diff
changeset
|
23 | * |
|
7beae478c905
Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34413
diff
changeset
|
24 | * You should have received a copy of the GNU General Public License |
|
7beae478c905
Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34413
diff
changeset
|
25 | * along with this program; if not, write to the Free Software |
|
7beae478c905
Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34413
diff
changeset
|
26 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
|
7beae478c905
Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34413
diff
changeset
|
27 | */ |
|
34358
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
28 | #include "html.h" |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
29 | |
|
34359
7cf367cc1141
Gadu-Gadu: compile regular expressions only once per plugin load
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34358
diff
changeset
|
30 | typedef struct |
|
7cf367cc1141
Gadu-Gadu: compile regular expressions only once per plugin load
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34358
diff
changeset
|
31 | { |
|
7cf367cc1141
Gadu-Gadu: compile regular expressions only once per plugin load
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34358
diff
changeset
|
32 | 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
|
33 | 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
|
34 | 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
|
35 | 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
|
36 | } 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
|
37 | |
|
7cf367cc1141
Gadu-Gadu: compile regular expressions only once per plugin load
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34358
diff
changeset
|
38 | 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
|
39 | |
|
7cf367cc1141
Gadu-Gadu: compile regular expressions only once per plugin load
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34358
diff
changeset
|
40 | 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
|
41 | { |
|
7cf367cc1141
Gadu-Gadu: compile regular expressions only once per plugin load
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34358
diff
changeset
|
42 | 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
|
43 | "([a-z-]+)=\"([^\"]+)\"", |
|
7cf367cc1141
Gadu-Gadu: compile regular expressions only once per plugin load
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34358
diff
changeset
|
44 | 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
|
45 | 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
|
46 | "([a-z-]+): *([^;]+)", |
|
7cf367cc1141
Gadu-Gadu: compile regular expressions only once per plugin load
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34358
diff
changeset
|
47 | 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
|
48 | 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
|
49 | "^#([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
|
50 | 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
|
51 | 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
|
52 | "^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
|
53 | 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
|
54 | } |
|
7cf367cc1141
Gadu-Gadu: compile regular expressions only once per plugin load
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34358
diff
changeset
|
55 | |
|
7cf367cc1141
Gadu-Gadu: compile regular expressions only once per plugin load
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34358
diff
changeset
|
56 | 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
|
57 | { |
|
7cf367cc1141
Gadu-Gadu: compile regular expressions only once per plugin load
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34358
diff
changeset
|
58 | 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
|
59 | 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
|
60 | 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
|
61 | 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
|
62 | } |
|
7cf367cc1141
Gadu-Gadu: compile regular expressions only once per plugin load
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34358
diff
changeset
|
63 | |
|
34358
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
64 | 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
|
65 | { |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
66 | GMatchInfo *match; |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
67 | 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
|
68 | g_free, g_free); |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
69 | |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
70 | if (attribs_str == NULL) |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
71 | return attribs; |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
72 | |
|
34359
7cf367cc1141
Gadu-Gadu: compile regular expressions only once per plugin load
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34358
diff
changeset
|
73 | g_regex_match(global_data.re_html_attr, attribs_str, 0, &match); |
|
35360
29d788c72350
Style: fix gg braces (part 1)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35358
diff
changeset
|
74 | while (g_match_info_matches(match)) { |
|
34358
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
75 | g_hash_table_insert(attribs, |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
76 | g_match_info_fetch(match, 1), |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
77 | g_match_info_fetch(match, 2)); |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
78 | |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
79 | g_match_info_next(match, NULL); |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
80 | } |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
81 | g_match_info_free(match); |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
82 | |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
83 | return attribs; |
|
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 | |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
86 | 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
|
87 | { |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
88 | GMatchInfo *match; |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
89 | 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
|
90 | g_free, g_free); |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
91 | |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
92 | if (attribs_str == NULL) |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
93 | return attribs; |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
94 | |
|
34359
7cf367cc1141
Gadu-Gadu: compile regular expressions only once per plugin load
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34358
diff
changeset
|
95 | g_regex_match(global_data.re_css_attr, attribs_str, 0, &match); |
|
35360
29d788c72350
Style: fix gg braces (part 1)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35358
diff
changeset
|
96 | while (g_match_info_matches(match)) { |
|
34358
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
97 | g_hash_table_insert(attribs, |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
98 | g_match_info_fetch(match, 1), |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
99 | g_match_info_fetch(match, 2)); |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
100 | |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
101 | g_match_info_next(match, NULL); |
|
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 | g_match_info_free(match); |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
104 | |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
105 | return attribs; |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
106 | } |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
107 | |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
108 | 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
|
109 | { |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
110 | GMatchInfo *match; |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
111 | int color = -1; |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
112 | |
|
34359
7cf367cc1141
Gadu-Gadu: compile regular expressions only once per plugin load
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34358
diff
changeset
|
113 | g_regex_match(global_data.re_color_hex, str, 0, &match); |
|
35360
29d788c72350
Style: fix gg braces (part 1)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35358
diff
changeset
|
114 | if (g_match_info_matches(match)) { |
|
34358
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
115 | 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
|
116 | color = -1; |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
117 | } |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
118 | g_match_info_free(match); |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
119 | if (color >= 0) |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
120 | return color; |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
121 | |
|
34359
7cf367cc1141
Gadu-Gadu: compile regular expressions only once per plugin load
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34358
diff
changeset
|
122 | g_regex_match(global_data.re_color_rgb, str, 0, &match); |
|
35360
29d788c72350
Style: fix gg braces (part 1)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35358
diff
changeset
|
123 | if (g_match_info_matches(match)) { |
|
34358
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
124 | 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
|
125 | gchar *c_str; |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
126 | |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
127 | 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
|
128 | if (c_str) |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
129 | r = atoi(c_str); |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
130 | g_free(c_str); |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
131 | |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
132 | 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
|
133 | if (c_str) |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
134 | g = atoi(c_str); |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
135 | g_free(c_str); |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
136 | |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
137 | 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
|
138 | if (c_str) |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
139 | b = atoi(c_str); |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
140 | g_free(c_str); |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
141 | |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
142 | 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
|
143 | color = (r << 16) | (g << 8) | b; |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
144 | } |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
145 | g_match_info_free(match); |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
146 | if (color >= 0) |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
147 | return color; |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
148 | |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
149 | return -1; |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
150 | } |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
151 | |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
152 | 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
|
153 | { |
|
34413
a578366cd35e
Gadu-Gadu: fix sending links
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34365
diff
changeset
|
154 | 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
|
155 | return GGP_HTML_TAG_EOM; |
|
34413
a578366cd35e
Gadu-Gadu: fix sending links
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34365
diff
changeset
|
156 | 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
|
157 | return GGP_HTML_TAG_SPAN; |
|
34413
a578366cd35e
Gadu-Gadu: fix sending links
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34365
diff
changeset
|
158 | 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
|
159 | return GGP_HTML_TAG_DIV; |
|
34413
a578366cd35e
Gadu-Gadu: fix sending links
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34365
diff
changeset
|
160 | 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
|
161 | return GGP_HTML_TAG_BR; |
|
34413
a578366cd35e
Gadu-Gadu: fix sending links
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34365
diff
changeset
|
162 | 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
|
163 | return GGP_HTML_TAG_A; |
|
34413
a578366cd35e
Gadu-Gadu: fix sending links
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34365
diff
changeset
|
164 | 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
|
165 | return GGP_HTML_TAG_B; |
|
34413
a578366cd35e
Gadu-Gadu: fix sending links
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34365
diff
changeset
|
166 | 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
|
167 | return GGP_HTML_TAG_I; |
|
34413
a578366cd35e
Gadu-Gadu: fix sending links
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34365
diff
changeset
|
168 | 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
|
169 | return GGP_HTML_TAG_U; |
|
34413
a578366cd35e
Gadu-Gadu: fix sending links
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34365
diff
changeset
|
170 | 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
|
171 | return GGP_HTML_TAG_S; |
|
34413
a578366cd35e
Gadu-Gadu: fix sending links
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34365
diff
changeset
|
172 | 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
|
173 | return GGP_HTML_TAG_IMG; |
|
34413
a578366cd35e
Gadu-Gadu: fix sending links
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34365
diff
changeset
|
174 | 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
|
175 | return GGP_HTML_TAG_FONT; |
|
34413
a578366cd35e
Gadu-Gadu: fix sending links
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34365
diff
changeset
|
176 | 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
|
177 | return GGP_HTML_TAG_HR; |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
178 | return GGP_HTML_TAG_UNKNOWN; |
|
845e66c9a20d
Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
179 | } |