Sat, 04 Sep 2010 15:47:59 +0000
jabber: set priority on remote candidates for Google-style vv
|
29914
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
1 | /** |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
2 | * Purple is the legal property of its developers, whose names are too numerous |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
3 | * to list here. Please refer to the COPYRIGHT file distributed with this |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
4 | * source distribution. |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
5 | * |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
6 | * This program is free software; you can redistribute it and/or modify |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
7 | * it under the terms of the GNU General Public License as published by |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
8 | * the Free Software Foundation; either version 2 of the License, or |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
9 | * (at your option) any later version. |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
10 | * |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
11 | * This program is distributed in the hope that it will be useful, |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
14 | * GNU General Public License for more details. |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
15 | * |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
16 | * You should have received a copy of the GNU General Public License |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
17 | * along with this program; if not, write to the Free Software |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
19 | */ |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
20 | |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
21 | #include "internal.h" |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
22 | #include "debug.h" |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
23 | |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
24 | #include "google.h" |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
25 | #include "jabber.h" |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
26 | #include "chat.h" |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
27 | |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
28 | /* This does two passes on the string. The first pass goes through |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
29 | * and determine if all the structured text is properly balanced, and |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
30 | * how many instances of each there is. The second pass goes and converts |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
31 | * everything to HTML, depending on what's figured out by the first pass. |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
32 | * It will short circuit once it knows it has no more replacements to make |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
33 | */ |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
34 | char *jabber_google_format_to_html(const char *text) |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
35 | { |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
36 | const char *p; |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
37 | |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
38 | /* The start of the screen may be consdiered a space for this purpose */ |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
39 | gboolean preceding_space = TRUE; |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
40 | |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
41 | gboolean in_bold = FALSE, in_italic = FALSE; |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
42 | gboolean in_tag = FALSE; |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
43 | |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
44 | gint bold_count = 0, italic_count = 0; |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
45 | |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
46 | GString *str; |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
47 | |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
48 | for (p = text; *p != '\0'; p = g_utf8_next_char(p)) { |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
49 | gunichar c = g_utf8_get_char(p); |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
50 | if (c == '*' && !in_tag) { |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
51 | if (in_bold && (g_unichar_isspace(*(p+1)) || |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
52 | *(p+1) == '\0' || |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
53 | *(p+1) == '<')) { |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
54 | bold_count++; |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
55 | in_bold = FALSE; |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
56 | } else if (preceding_space && !in_bold && !g_unichar_isspace(*(p+1))) { |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
57 | bold_count++; |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
58 | in_bold = TRUE; |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
59 | } |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
60 | preceding_space = TRUE; |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
61 | } else if (c == '_' && !in_tag) { |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
62 | if (in_italic && (g_unichar_isspace(*(p+1)) || |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
63 | *(p+1) == '\0' || |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
64 | *(p+1) == '<')) { |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
65 | italic_count++; |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
66 | in_italic = FALSE; |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
67 | } else if (preceding_space && !in_italic && !g_unichar_isspace(*(p+1))) { |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
68 | italic_count++; |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
69 | in_italic = TRUE; |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
70 | } |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
71 | preceding_space = TRUE; |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
72 | } else if (c == '<' && !in_tag) { |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
73 | in_tag = TRUE; |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
74 | } else if (c == '>' && in_tag) { |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
75 | in_tag = FALSE; |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
76 | } else if (!in_tag) { |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
77 | if (g_unichar_isspace(c)) |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
78 | preceding_space = TRUE; |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
79 | else |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
80 | preceding_space = FALSE; |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
81 | } |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
82 | } |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
83 | |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
84 | str = g_string_new(NULL); |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
85 | in_bold = in_italic = in_tag = FALSE; |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
86 | preceding_space = TRUE; |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
87 | |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
88 | for (p = text; *p != '\0'; p = g_utf8_next_char(p)) { |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
89 | gunichar c = g_utf8_get_char(p); |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
90 | |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
91 | if (bold_count < 2 && italic_count < 2 && !in_bold && !in_italic) { |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
92 | g_string_append(str, p); |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
93 | return g_string_free(str, FALSE); |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
94 | } |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
95 | |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
96 | |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
97 | if (c == '*' && !in_tag) { |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
98 | if (in_bold && |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
99 | (g_unichar_isspace(*(p+1))||*(p+1)=='<')) { /* This is safe in UTF-8 */ |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
100 | str = g_string_append(str, "</b>"); |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
101 | in_bold = FALSE; |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
102 | bold_count--; |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
103 | } else if (preceding_space && bold_count > 1 && !g_unichar_isspace(*(p+1))) { |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
104 | str = g_string_append(str, "<b>"); |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
105 | bold_count--; |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
106 | in_bold = TRUE; |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
107 | } else { |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
108 | str = g_string_append_unichar(str, c); |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
109 | } |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
110 | preceding_space = TRUE; |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
111 | } else if (c == '_' && !in_tag) { |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
112 | if (in_italic && |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
113 | (g_unichar_isspace(*(p+1))||*(p+1)=='<')) { |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
114 | str = g_string_append(str, "</i>"); |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
115 | italic_count--; |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
116 | in_italic = FALSE; |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
117 | } else if (preceding_space && italic_count > 1 && !g_unichar_isspace(*(p+1))) { |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
118 | str = g_string_append(str, "<i>"); |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
119 | italic_count--; |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
120 | in_italic = TRUE; |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
121 | } else { |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
122 | str = g_string_append_unichar(str, c); |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
123 | } |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
124 | preceding_space = TRUE; |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
125 | } else if (c == '<' && !in_tag) { |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
126 | str = g_string_append_unichar(str, c); |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
127 | in_tag = TRUE; |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
128 | } else if (c == '>' && in_tag) { |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
129 | str = g_string_append_unichar(str, c); |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
130 | in_tag = FALSE; |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
131 | } else if (!in_tag) { |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
132 | str = g_string_append_unichar(str, c); |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
133 | if (g_unichar_isspace(c)) |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
134 | preceding_space = TRUE; |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
135 | else |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
136 | preceding_space = FALSE; |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
137 | } else { |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
138 | str = g_string_append_unichar(str, c); |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
139 | } |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
140 | } |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
141 | return g_string_free(str, FALSE); |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
142 | } |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
143 | |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
144 | |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
145 | |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
146 | void google_buddy_node_chat(PurpleBlistNode *node, gpointer data) |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
147 | { |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
148 | PurpleBuddy *buddy; |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
149 | PurpleConnection *gc; |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
150 | JabberStream *js; |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
151 | JabberChat *chat; |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
152 | gchar *room; |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
153 | gchar *uuid = purple_uuid_random(); |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
154 | |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
155 | g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node)); |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
156 | |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
157 | buddy = PURPLE_BUDDY(node); |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
158 | gc = purple_account_get_connection(purple_buddy_get_account(buddy)); |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
159 | g_return_if_fail(gc != NULL); |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
160 | js = purple_connection_get_protocol_data(gc); |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
161 | |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
162 | room = g_strdup_printf("private-chat-%s", uuid); |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
163 | chat = jabber_join_chat(js, room, GOOGLE_GROUPCHAT_SERVER, js->user->node, |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
164 | NULL, NULL); |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
165 | if (chat) { |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
166 | chat->muc = TRUE; |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
167 | jabber_chat_invite(gc, chat->id, "", purple_buddy_get_name(buddy)); |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
168 | } |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
169 | |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
170 | g_free(room); |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
171 | g_free(uuid); |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
172 | } |