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