Thu, 20 Sep 2007 23:22:35 +0000
Music support for Google Talk
| 15225 | 1 | /** |
| 15884 | 2 | * Purple is the legal property of its developers, whose names are too numerous |
| 15225 | 3 | * to list here. Please refer to the COPYRIGHT file distributed with this |
| 4 | * source distribution. | |
| 5 | * | |
| 6 | * This program is free software; you can redistribute it and/or modify | |
| 7 | * it under the terms of the GNU General Public License as published by | |
| 8 | * the Free Software Foundation; either version 2 of the License, or | |
| 9 | * (at your option) any later version. | |
| 10 | * | |
| 11 | * This program is distributed in the hope that it will be useful, | |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 14 | * GNU General Public License for more details. | |
| 15 | * | |
| 16 | * You should have received a copy of the GNU General Public License | |
| 17 | * along with this program; if not, write to the Free Software | |
|
19859
71d37b57eff2
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19046
diff
changeset
|
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
| 15225 | 19 | */ |
| 20 | ||
| 21 | #include "internal.h" | |
| 22 | #include "debug.h" | |
|
15587
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
23 | #include "util.h" |
| 15265 | 24 | #include "privacy.h" |
| 25 | ||
| 26 | #include "buddy.h" | |
| 15225 | 27 | #include "google.h" |
| 28 | #include "jabber.h" | |
| 15265 | 29 | #include "presence.h" |
| 15225 | 30 | #include "iq.h" |
| 31 | ||
| 18233 | 32 | static void |
| 15225 | 33 | jabber_gmail_parse(JabberStream *js, xmlnode *packet, gpointer nul) |
| 34 | { | |
| 35 | const char *type = xmlnode_get_attrib(packet, "type"); | |
| 36 | xmlnode *child; | |
| 37 | xmlnode *message, *sender_node, *subject_node; | |
| 18739 | 38 | const char *from, *to, *url, *tid; |
| 39 | char *subject; | |
| 15225 | 40 | const char *in_str; |
| 41 | char *to_name; | |
|
20390
7e05fb12fca0
Show when Gmail count falls, instead of only when it rises. Fixes #1462
Sean Egan <seanegan@pidgin.im>
parents:
19859
diff
changeset
|
42 | char *default_tos[1]; |
|
7e05fb12fca0
Show when Gmail count falls, instead of only when it rises. Fixes #1462
Sean Egan <seanegan@pidgin.im>
parents:
19859
diff
changeset
|
43 | |
| 15225 | 44 | int i, count = 1, returned_count; |
| 18233 | 45 | |
| 18739 | 46 | const char **tos, **froms, **urls; |
| 47 | char **subjects; | |
| 18233 | 48 | |
| 15225 | 49 | if (strcmp(type, "result")) |
| 50 | return; | |
| 18233 | 51 | |
| 15225 | 52 | child = xmlnode_get_child(packet, "mailbox"); |
| 53 | if (!child) | |
| 54 | return; | |
| 55 | ||
| 56 | in_str = xmlnode_get_attrib(child, "total-matched"); | |
| 18233 | 57 | if (in_str && *in_str) |
| 15225 | 58 | count = atoi(in_str); |
| 18233 | 59 | |
|
20390
7e05fb12fca0
Show when Gmail count falls, instead of only when it rises. Fixes #1462
Sean Egan <seanegan@pidgin.im>
parents:
19859
diff
changeset
|
60 | /* If Gmail doesn't tell us who the mail is to, let's use our JID */ |
|
7e05fb12fca0
Show when Gmail count falls, instead of only when it rises. Fixes #1462
Sean Egan <seanegan@pidgin.im>
parents:
19859
diff
changeset
|
61 | to = xmlnode_get_attrib(packet, "to"); |
|
7e05fb12fca0
Show when Gmail count falls, instead of only when it rises. Fixes #1462
Sean Egan <seanegan@pidgin.im>
parents:
19859
diff
changeset
|
62 | default_tos[0] = jabber_get_bare_jid(to); |
|
7e05fb12fca0
Show when Gmail count falls, instead of only when it rises. Fixes #1462
Sean Egan <seanegan@pidgin.im>
parents:
19859
diff
changeset
|
63 | |
|
7e05fb12fca0
Show when Gmail count falls, instead of only when it rises. Fixes #1462
Sean Egan <seanegan@pidgin.im>
parents:
19859
diff
changeset
|
64 | if (count == 0) { |
| 20640 | 65 | purple_notify_emails(js->gc, count, FALSE, NULL, NULL, (const char**) default_tos, NULL, NULL, NULL); |
|
20390
7e05fb12fca0
Show when Gmail count falls, instead of only when it rises. Fixes #1462
Sean Egan <seanegan@pidgin.im>
parents:
19859
diff
changeset
|
66 | g_free(default_tos[0]); |
| 15225 | 67 | return; |
|
20390
7e05fb12fca0
Show when Gmail count falls, instead of only when it rises. Fixes #1462
Sean Egan <seanegan@pidgin.im>
parents:
19859
diff
changeset
|
68 | } |
| 15225 | 69 | |
| 70 | message = xmlnode_get_child(child, "mail-thread-info"); | |
|
20390
7e05fb12fca0
Show when Gmail count falls, instead of only when it rises. Fixes #1462
Sean Egan <seanegan@pidgin.im>
parents:
19859
diff
changeset
|
71 | if (!message) { |
| 20640 | 72 | purple_notify_emails(js->gc, count, FALSE, NULL, NULL, (const char**) default_tos, NULL, NULL, NULL); |
|
20390
7e05fb12fca0
Show when Gmail count falls, instead of only when it rises. Fixes #1462
Sean Egan <seanegan@pidgin.im>
parents:
19859
diff
changeset
|
73 | g_free(default_tos[0]); |
|
7e05fb12fca0
Show when Gmail count falls, instead of only when it rises. Fixes #1462
Sean Egan <seanegan@pidgin.im>
parents:
19859
diff
changeset
|
74 | return; |
|
7e05fb12fca0
Show when Gmail count falls, instead of only when it rises. Fixes #1462
Sean Egan <seanegan@pidgin.im>
parents:
19859
diff
changeset
|
75 | } |
| 18233 | 76 | |
| 15225 | 77 | /* Loop once to see how many messages were returned so we can allocate arrays |
| 78 | * accordingly */ | |
| 79 | for (returned_count = 0; message; returned_count++, message=xmlnode_get_next_twin(message)); | |
| 18233 | 80 | |
| 15225 | 81 | froms = g_new0(const char* , returned_count); |
| 82 | tos = g_new0(const char* , returned_count); | |
| 18739 | 83 | subjects = g_new0(char* , returned_count); |
| 15225 | 84 | urls = g_new0(const char* , returned_count); |
| 18233 | 85 | |
| 15225 | 86 | to = xmlnode_get_attrib(packet, "to"); |
| 87 | to_name = jabber_get_bare_jid(to); | |
| 88 | url = xmlnode_get_attrib(child, "url"); | |
| 89 | if (!url || !*url) | |
| 90 | url = "http://www.gmail.com"; | |
| 18233 | 91 | |
| 15225 | 92 | message= xmlnode_get_child(child, "mail-thread-info"); |
| 93 | for (i=0; message; message = xmlnode_get_next_twin(message), i++) { | |
| 94 | subject_node = xmlnode_get_child(message, "subject"); | |
| 95 | sender_node = xmlnode_get_child(message, "senders"); | |
| 96 | sender_node = xmlnode_get_child(sender_node, "sender"); | |
| 97 | ||
| 18233 | 98 | while (sender_node && (!xmlnode_get_attrib(sender_node, "unread") || |
| 15225 | 99 | !strcmp(xmlnode_get_attrib(sender_node, "unread"),"0"))) |
| 100 | sender_node = xmlnode_get_next_twin(sender_node); | |
| 18233 | 101 | |
| 15225 | 102 | if (!sender_node) { |
| 103 | i--; | |
| 104 | continue; | |
| 105 | } | |
| 18233 | 106 | |
| 15225 | 107 | from = xmlnode_get_attrib(sender_node, "name"); |
| 108 | if (!from || !*from) | |
| 109 | from = xmlnode_get_attrib(sender_node, "address"); | |
| 110 | subject = xmlnode_get_data(subject_node); | |
| 111 | /* | |
| 112 | * url = xmlnode_get_attrib(message, "url"); | |
| 113 | */ | |
| 114 | tos[i] = (to_name != NULL ? to_name : ""); | |
| 115 | froms[i] = (from != NULL ? from : ""); | |
| 18739 | 116 | subjects[i] = (subject != NULL ? subject : g_strdup("")); |
| 15225 | 117 | urls[i] = (url != NULL ? url : ""); |
| 18233 | 118 | |
| 15225 | 119 | tid = xmlnode_get_attrib(message, "tid"); |
| 18233 | 120 | if (tid && |
| 15225 | 121 | (js->gmail_last_tid == NULL || strcmp(tid, js->gmail_last_tid) > 0)) { |
| 122 | g_free(js->gmail_last_tid); | |
| 123 | js->gmail_last_tid = g_strdup(tid); | |
| 124 | } | |
| 125 | } | |
| 126 | ||
| 18233 | 127 | if (i>0) |
|
18740
1b1f72624316
Only display the "detailed" email notifications for gtalk if we really have all the details to show. Fixes #1813.
Daniel Atallah <datallah@pidgin.im>
parents:
18739
diff
changeset
|
128 | purple_notify_emails(js->gc, count, count == i, (const char**) subjects, froms, tos, |
| 18233 | 129 | urls, NULL, NULL); |
|
20390
7e05fb12fca0
Show when Gmail count falls, instead of only when it rises. Fixes #1462
Sean Egan <seanegan@pidgin.im>
parents:
19859
diff
changeset
|
130 | else |
| 20640 | 131 | purple_notify_emails(js->gc, count, FALSE, NULL, NULL, (const char**) default_tos, NULL, NULL, NULL); |
|
20390
7e05fb12fca0
Show when Gmail count falls, instead of only when it rises. Fixes #1462
Sean Egan <seanegan@pidgin.im>
parents:
19859
diff
changeset
|
132 | |
| 15261 | 133 | |
| 15225 | 134 | g_free(to_name); |
| 135 | g_free(tos); | |
|
20390
7e05fb12fca0
Show when Gmail count falls, instead of only when it rises. Fixes #1462
Sean Egan <seanegan@pidgin.im>
parents:
19859
diff
changeset
|
136 | g_free(default_tos[0]); |
| 15225 | 137 | g_free(froms); |
|
19046
4c4a79e7e21c
Fix a stupid crash (that I introduced) that occurs when parsing gmail notifications. Fixes #2323
Daniel Atallah <datallah@pidgin.im>
parents:
18740
diff
changeset
|
138 | for (; i > 0; i--) |
|
4c4a79e7e21c
Fix a stupid crash (that I introduced) that occurs when parsing gmail notifications. Fixes #2323
Daniel Atallah <datallah@pidgin.im>
parents:
18740
diff
changeset
|
139 | g_free(subjects[i - 1]); |
| 15225 | 140 | g_free(subjects); |
| 141 | g_free(urls); | |
| 142 | ||
| 143 | in_str = xmlnode_get_attrib(child, "result-time"); | |
| 144 | if (in_str && *in_str) { | |
| 145 | g_free(js->gmail_last_time); | |
| 146 | js->gmail_last_time = g_strdup(in_str); | |
| 147 | } | |
| 148 | } | |
| 149 | ||
| 18233 | 150 | void |
| 151 | jabber_gmail_poke(JabberStream *js, xmlnode *packet) | |
| 15225 | 152 | { |
| 153 | const char *type; | |
| 154 | xmlnode *query; | |
| 155 | JabberIq *iq; | |
| 18233 | 156 | |
| 15225 | 157 | /* bail if the user isn't interested */ |
| 15884 | 158 | if (!purple_account_get_check_mail(js->gc->account)) |
| 15225 | 159 | return; |
| 160 | ||
| 161 | type = xmlnode_get_attrib(packet, "type"); | |
| 18233 | 162 | |
| 15225 | 163 | |
| 164 | /* Is this an initial incoming mail notification? If so, send a request for more info */ | |
| 165 | if (strcmp(type, "set") || !xmlnode_get_child(packet, "new-mail")) | |
| 166 | return; | |
| 167 | ||
| 15884 | 168 | purple_debug(PURPLE_DEBUG_MISC, "jabber", |
| 15225 | 169 | "Got new mail notification. Sending request for more info\n"); |
| 170 | ||
| 171 | iq = jabber_iq_new_query(js, JABBER_IQ_GET, "google:mail:notify"); | |
| 172 | jabber_iq_set_callback(iq, jabber_gmail_parse, NULL); | |
| 173 | query = xmlnode_get_child(iq->node, "query"); | |
| 174 | ||
| 175 | if (js->gmail_last_time) | |
| 176 | xmlnode_set_attrib(query, "newer-than-time", js->gmail_last_time); | |
| 177 | if (js->gmail_last_tid) | |
| 178 | xmlnode_set_attrib(query, "newer-than-tid", js->gmail_last_tid); | |
| 179 | ||
| 180 | jabber_iq_send(iq); | |
| 181 | return; | |
| 182 | } | |
| 183 | ||
| 184 | void jabber_gmail_init(JabberStream *js) { | |
| 185 | JabberIq *iq; | |
| 186 | ||
| 18233 | 187 | if (!purple_account_get_check_mail(js->gc->account)) |
| 15225 | 188 | return; |
| 189 | ||
| 190 | iq = jabber_iq_new_query(js, JABBER_IQ_GET, "google:mail:notify"); | |
| 191 | jabber_iq_set_callback(iq, jabber_gmail_parse, NULL); | |
| 192 | jabber_iq_send(iq); | |
| 193 | } | |
| 15265 | 194 | |
| 195 | void jabber_google_roster_init(JabberStream *js) | |
| 196 | { | |
| 197 | JabberIq *iq; | |
| 198 | xmlnode *query; | |
| 199 | ||
| 200 | iq = jabber_iq_new_query(js, JABBER_IQ_GET, "jabber:iq:roster"); | |
| 201 | query = xmlnode_get_child(iq->node, "query"); | |
| 18233 | 202 | |
| 15265 | 203 | xmlnode_set_attrib(query, "xmlns:gr", "google:roster"); |
| 204 | xmlnode_set_attrib(query, "gr:ext", "2"); | |
| 205 | ||
| 206 | jabber_iq_send(iq); | |
| 207 | } | |
| 208 | ||
| 209 | void jabber_google_roster_outgoing(JabberStream *js, xmlnode *query, xmlnode *item) | |
| 210 | { | |
| 15884 | 211 | PurpleAccount *account = purple_connection_get_account(js->gc); |
| 15265 | 212 | GSList *list = account->deny; |
| 213 | const char *jid = xmlnode_get_attrib(item, "jid"); | |
| 214 | char *jid_norm = g_strdup(jabber_normalize(account, jid)); | |
| 215 | ||
| 216 | while (list) { | |
| 217 | if (!strcmp(jid_norm, (char*)list->data)) { | |
| 218 | xmlnode_set_attrib(query, "xmlns:gr", "google:roster"); | |
| 219 | xmlnode_set_attrib(item, "gr:t", "B"); | |
| 220 | xmlnode_set_attrib(query, "xmlns:gr", "google:roster"); | |
| 221 | xmlnode_set_attrib(query, "gr:ext", "2"); | |
| 222 | return; | |
| 223 | } | |
| 224 | list = list->next; | |
| 225 | } | |
| 226 | ||
| 18739 | 227 | g_free(jid_norm); |
| 228 | ||
| 15265 | 229 | } |
| 230 | ||
|
15530
9355a1be068e
Make deleting Google Talk buddies work
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
231 | gboolean jabber_google_roster_incoming(JabberStream *js, xmlnode *item) |
| 15265 | 232 | { |
| 15884 | 233 | PurpleAccount *account = purple_connection_get_account(js->gc); |
| 15265 | 234 | GSList *list = account->deny; |
| 235 | const char *jid = xmlnode_get_attrib(item, "jid"); | |
| 236 | gboolean on_block_list = FALSE; | |
| 237 | ||
| 238 | char *jid_norm = g_strdup(jabber_normalize(account, jid)); | |
| 239 | ||
| 240 | const char *grt = xmlnode_get_attrib_with_namespace(item, "t", "google:roster"); | |
|
17148
db0801f13aa8
If Google Talk tells you a roster item as a none subscription, we probably don't ever want to show it. Fixes #1189
Sean Egan <seanegan@pidgin.im>
parents:
16988
diff
changeset
|
241 | const char *subscription = xmlnode_get_attrib(item, "subscription"); |
| 18233 | 242 | |
| 17327 | 243 | if (!subscription || !strcmp(subscription, "none")) { |
|
17148
db0801f13aa8
If Google Talk tells you a roster item as a none subscription, we probably don't ever want to show it. Fixes #1189
Sean Egan <seanegan@pidgin.im>
parents:
16988
diff
changeset
|
244 | /* The Google Talk servers will automatically add people from your Gmail address book |
|
db0801f13aa8
If Google Talk tells you a roster item as a none subscription, we probably don't ever want to show it. Fixes #1189
Sean Egan <seanegan@pidgin.im>
parents:
16988
diff
changeset
|
245 | * with subscription=none. If we see someone with subscription=none, ignore them. |
|
db0801f13aa8
If Google Talk tells you a roster item as a none subscription, we probably don't ever want to show it. Fixes #1189
Sean Egan <seanegan@pidgin.im>
parents:
16988
diff
changeset
|
246 | */ |
|
db0801f13aa8
If Google Talk tells you a roster item as a none subscription, we probably don't ever want to show it. Fixes #1189
Sean Egan <seanegan@pidgin.im>
parents:
16988
diff
changeset
|
247 | return FALSE; |
|
db0801f13aa8
If Google Talk tells you a roster item as a none subscription, we probably don't ever want to show it. Fixes #1189
Sean Egan <seanegan@pidgin.im>
parents:
16988
diff
changeset
|
248 | } |
| 18233 | 249 | |
| 15265 | 250 | while (list) { |
| 251 | if (!strcmp(jid_norm, (char*)list->data)) { | |
| 252 | on_block_list = TRUE; | |
| 253 | break; | |
| 254 | } | |
| 255 | list = list->next; | |
| 256 | } | |
| 18233 | 257 | |
|
15530
9355a1be068e
Make deleting Google Talk buddies work
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
258 | if (grt && (*grt == 'H' || *grt == 'h')) { |
| 15884 | 259 | PurpleBuddy *buddy = purple_find_buddy(account, jid_norm); |
| 260 | purple_blist_remove_buddy(buddy); | |
| 18739 | 261 | g_free(jid_norm); |
|
15530
9355a1be068e
Make deleting Google Talk buddies work
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
262 | return FALSE; |
|
9355a1be068e
Make deleting Google Talk buddies work
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
263 | } |
| 18233 | 264 | |
| 15265 | 265 | if (!on_block_list && (grt && (*grt == 'B' || *grt == 'b'))) { |
| 15884 | 266 | purple_debug_info("jabber", "Blocking %s\n", jid_norm); |
| 267 | purple_privacy_deny_add(account, jid_norm, TRUE); | |
| 15265 | 268 | } else if (on_block_list && (!grt || (*grt != 'B' && *grt != 'b' ))){ |
| 15884 | 269 | purple_debug_info("jabber", "Unblocking %s\n", jid_norm); |
| 270 | purple_privacy_deny_remove(account, jid_norm, TRUE); | |
| 15265 | 271 | } |
| 18739 | 272 | |
| 273 | g_free(jid_norm); | |
|
15530
9355a1be068e
Make deleting Google Talk buddies work
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
274 | return TRUE; |
| 15265 | 275 | } |
| 276 | ||
| 18233 | 277 | void jabber_google_roster_add_deny(PurpleConnection *gc, const char *who) |
| 15265 | 278 | { |
| 279 | JabberStream *js; | |
| 280 | GSList *buddies; | |
| 281 | JabberIq *iq; | |
| 282 | xmlnode *query; | |
| 283 | xmlnode *item; | |
| 284 | xmlnode *group; | |
| 15884 | 285 | PurpleBuddy *b; |
| 15265 | 286 | JabberBuddy *jb; |
| 287 | ||
| 288 | js = (JabberStream*)(gc->proto_data); | |
| 18233 | 289 | |
| 15265 | 290 | if (!js || !js->server_caps & JABBER_CAP_GOOGLE_ROSTER) |
| 291 | return; | |
| 292 | ||
| 293 | jb = jabber_buddy_find(js, who, TRUE); | |
| 294 | ||
| 15884 | 295 | buddies = purple_find_buddies(js->gc->account, who); |
| 15265 | 296 | if(!buddies) |
| 297 | return; | |
| 18233 | 298 | |
| 15265 | 299 | b = buddies->data; |
| 300 | ||
| 301 | iq = jabber_iq_new_query(js, JABBER_IQ_SET, "jabber:iq:roster"); | |
| 18233 | 302 | |
| 15265 | 303 | query = xmlnode_get_child(iq->node, "query"); |
| 304 | item = xmlnode_new_child(query, "item"); | |
| 305 | ||
| 306 | while(buddies) { | |
| 15884 | 307 | PurpleGroup *g; |
| 15265 | 308 | |
| 309 | b = buddies->data; | |
| 15884 | 310 | g = purple_buddy_get_group(b); |
| 15265 | 311 | |
| 312 | group = xmlnode_new_child(item, "group"); | |
| 313 | xmlnode_insert_data(group, g->name, -1); | |
| 18233 | 314 | |
| 15265 | 315 | buddies = buddies->next; |
| 316 | } | |
| 317 | ||
| 318 | iq = jabber_iq_new_query(js, JABBER_IQ_SET, "jabber:iq:roster"); | |
| 319 | ||
| 320 | query = xmlnode_get_child(iq->node, "query"); | |
| 321 | item = xmlnode_new_child(query, "item"); | |
| 322 | ||
| 323 | xmlnode_set_attrib(item, "jid", who); | |
| 324 | xmlnode_set_attrib(item, "name", b->alias ? b->alias : ""); | |
| 325 | xmlnode_set_attrib(item, "gr:t", "B"); | |
| 326 | xmlnode_set_attrib(query, "xmlns:gr", "google:roster"); | |
| 327 | xmlnode_set_attrib(query, "gr:ext", "2"); | |
| 328 | ||
| 329 | jabber_iq_send(iq); | |
| 330 | ||
| 331 | /* Synthesize a sign-off */ | |
| 332 | if (jb) { | |
| 333 | JabberBuddyResource *jbr; | |
| 334 | GList *l = jb->resources; | |
| 335 | while (l) { | |
| 336 | jbr = l->data; | |
|
15346
ef48613b5b9b
[gaim-migrate @ 18074]
Evan Schoenberg <evands@pidgin.im>
parents:
15265
diff
changeset
|
337 | if (jbr && jbr->name) |
|
ef48613b5b9b
[gaim-migrate @ 18074]
Evan Schoenberg <evands@pidgin.im>
parents:
15265
diff
changeset
|
338 | { |
| 15884 | 339 | purple_debug(PURPLE_DEBUG_MISC, "jabber", "Removing resource %s\n", jbr->name); |
|
15346
ef48613b5b9b
[gaim-migrate @ 18074]
Evan Schoenberg <evands@pidgin.im>
parents:
15265
diff
changeset
|
340 | jabber_buddy_remove_resource(jb, jbr->name); |
|
ef48613b5b9b
[gaim-migrate @ 18074]
Evan Schoenberg <evands@pidgin.im>
parents:
15265
diff
changeset
|
341 | } |
| 15265 | 342 | l = l->next; |
| 343 | } | |
| 344 | } | |
| 15884 | 345 | purple_prpl_got_user_status(purple_connection_get_account(gc), who, "offline", NULL); |
| 15265 | 346 | } |
| 347 | ||
| 15884 | 348 | void jabber_google_roster_rem_deny(PurpleConnection *gc, const char *who) |
| 15265 | 349 | { |
| 350 | JabberStream *js; | |
| 351 | GSList *buddies; | |
| 352 | JabberIq *iq; | |
| 353 | xmlnode *query; | |
| 354 | xmlnode *item; | |
| 355 | xmlnode *group; | |
| 15884 | 356 | PurpleBuddy *b; |
| 15265 | 357 | |
| 358 | g_return_if_fail(gc != NULL); | |
| 359 | g_return_if_fail(who != NULL); | |
| 18233 | 360 | |
| 15265 | 361 | js = (JabberStream*)(gc->proto_data); |
| 18233 | 362 | |
| 15265 | 363 | if (!js || !js->server_caps & JABBER_CAP_GOOGLE_ROSTER) |
| 364 | return; | |
| 18233 | 365 | |
| 15884 | 366 | buddies = purple_find_buddies(js->gc->account, who); |
| 15265 | 367 | if(!buddies) |
| 368 | return; | |
| 18233 | 369 | |
| 15265 | 370 | b = buddies->data; |
| 371 | ||
| 372 | iq = jabber_iq_new_query(js, JABBER_IQ_SET, "jabber:iq:roster"); | |
| 18233 | 373 | |
| 15265 | 374 | query = xmlnode_get_child(iq->node, "query"); |
| 375 | item = xmlnode_new_child(query, "item"); | |
| 376 | ||
| 377 | while(buddies) { | |
| 15884 | 378 | PurpleGroup *g; |
| 15265 | 379 | |
| 380 | b = buddies->data; | |
| 15884 | 381 | g = purple_buddy_get_group(b); |
| 15265 | 382 | |
| 383 | group = xmlnode_new_child(item, "group"); | |
| 384 | xmlnode_insert_data(group, g->name, -1); | |
| 18233 | 385 | |
| 15265 | 386 | buddies = buddies->next; |
| 387 | } | |
| 388 | ||
| 389 | iq = jabber_iq_new_query(js, JABBER_IQ_SET, "jabber:iq:roster"); | |
| 390 | ||
| 391 | query = xmlnode_get_child(iq->node, "query"); | |
| 392 | item = xmlnode_new_child(query, "item"); | |
| 393 | ||
| 394 | xmlnode_set_attrib(item, "jid", who); | |
| 395 | xmlnode_set_attrib(item, "name", b->alias ? b->alias : ""); | |
| 396 | xmlnode_set_attrib(query, "xmlns:gr", "google:roster"); | |
| 397 | xmlnode_set_attrib(query, "gr:ext", "2"); | |
| 398 | ||
| 399 | jabber_iq_send(iq); | |
| 400 | ||
| 401 | /* See if he's online */ | |
| 402 | jabber_presence_subscription_set(js, who, "probe"); | |
| 403 | } | |
|
15587
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
404 | |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
405 | /* This does two passes on the string. The first pass goes through |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
406 | * and determine if all the structured text is properly balanced, and |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
407 | * how many instances of each there is. The second pass goes and converts |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
408 | * everything to HTML, depending on what's figured out by the first pass. |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
409 | * It will short circuit once it knows it has no more replacements to make |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
410 | */ |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
411 | char *jabber_google_format_to_html(const char *text) |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
412 | { |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
413 | const char *p; |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
414 | |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
415 | /* The start of the screen may be consdiered a space for this purpose */ |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
416 | gboolean preceding_space = TRUE; |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
417 | |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
418 | gboolean in_bold = FALSE, in_italic = FALSE; |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
419 | gboolean in_tag = FALSE; |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
420 | |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
421 | gint bold_count = 0, italic_count = 0; |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
422 | |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
423 | GString *str; |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
424 | |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
425 | for (p = text; *p != '\0'; p = g_utf8_next_char(p)) { |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
426 | gunichar c = g_utf8_get_char(p); |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
427 | if (c == '*' && !in_tag) { |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
428 | if (in_bold && (g_unichar_isspace(*(p+1)) || |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
429 | *(p+1) == '\0' || |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
430 | *(p+1) == '<')) { |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
431 | bold_count++; |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
432 | in_bold = FALSE; |
|
16988
1aaf51bf0f23
Patch #265. Fix to Google Talk formatting
Sean Egan <seanegan@pidgin.im>
parents:
15884
diff
changeset
|
433 | } else if (preceding_space && !in_bold && !g_unichar_isspace(*(p+1))) { |
|
15587
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
434 | bold_count++; |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
435 | in_bold = TRUE; |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
436 | } |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
437 | preceding_space = TRUE; |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
438 | } else if (c == '_' && !in_tag) { |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
439 | if (in_italic && (g_unichar_isspace(*(p+1)) || |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
440 | *(p+1) == '\0' || |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
441 | *(p+1) == '<')) { |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
442 | italic_count++; |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
443 | in_italic = FALSE; |
|
16988
1aaf51bf0f23
Patch #265. Fix to Google Talk formatting
Sean Egan <seanegan@pidgin.im>
parents:
15884
diff
changeset
|
444 | } else if (preceding_space && !in_italic && !g_unichar_isspace(*(p+1))) { |
|
15587
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
445 | italic_count++; |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
446 | in_italic = TRUE; |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
447 | } |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
448 | preceding_space = TRUE; |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
449 | } else if (c == '<' && !in_tag) { |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
450 | in_tag = TRUE; |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
451 | } else if (c == '>' && in_tag) { |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
452 | in_tag = FALSE; |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
453 | } else if (!in_tag) { |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
454 | if (g_unichar_isspace(c)) |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
455 | preceding_space = TRUE; |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
456 | else |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
457 | preceding_space = FALSE; |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
458 | } |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
459 | } |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
460 | |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
461 | str = g_string_new(NULL); |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
462 | in_bold = in_italic = in_tag = FALSE; |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
463 | preceding_space = TRUE; |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
464 | |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
465 | for (p = text; *p != '\0'; p = g_utf8_next_char(p)) { |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
466 | gunichar c = g_utf8_get_char(p); |
| 18233 | 467 | |
|
15587
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
468 | if (bold_count < 2 && italic_count < 2 && !in_bold && !in_italic) { |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
469 | g_string_append(str, p); |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
470 | return g_string_free(str, FALSE); |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
471 | } |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
472 | |
| 18233 | 473 | |
|
15587
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
474 | if (c == '*' && !in_tag) { |
| 18233 | 475 | if (in_bold && |
|
15587
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
476 | (g_unichar_isspace(*(p+1))||*(p+1)=='<')) { /* This is safe in UTF-8 */ |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
477 | str = g_string_append(str, "</b>"); |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
478 | in_bold = FALSE; |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
479 | bold_count--; |
|
16988
1aaf51bf0f23
Patch #265. Fix to Google Talk formatting
Sean Egan <seanegan@pidgin.im>
parents:
15884
diff
changeset
|
480 | } else if (preceding_space && bold_count > 1 && !g_unichar_isspace(*(p+1))) { |
|
15587
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
481 | str = g_string_append(str, "<b>"); |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
482 | bold_count--; |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
483 | in_bold = TRUE; |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
484 | } else { |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
485 | str = g_string_append_unichar(str, c); |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
486 | } |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
487 | preceding_space = TRUE; |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
488 | } else if (c == '_' && !in_tag) { |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
489 | if (in_italic && |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
490 | (g_unichar_isspace(*(p+1))||*(p+1)=='<')) { |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
491 | str = g_string_append(str, "</i>"); |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
492 | italic_count--; |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
493 | in_italic = FALSE; |
|
16988
1aaf51bf0f23
Patch #265. Fix to Google Talk formatting
Sean Egan <seanegan@pidgin.im>
parents:
15884
diff
changeset
|
494 | } else if (preceding_space && italic_count > 1 && !g_unichar_isspace(*(p+1))) { |
|
15587
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
495 | str = g_string_append(str, "<i>"); |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
496 | italic_count--; |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
497 | in_italic = TRUE; |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
498 | } else { |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
499 | str = g_string_append_unichar(str, c); |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
500 | } |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
501 | preceding_space = TRUE; |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
502 | } else if (c == '<' && !in_tag) { |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
503 | str = g_string_append_unichar(str, c); |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
504 | in_tag = TRUE; |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
505 | } else if (c == '>' && in_tag) { |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
506 | str = g_string_append_unichar(str, c); |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
507 | in_tag = FALSE; |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
508 | } else if (!in_tag) { |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
509 | str = g_string_append_unichar(str, c); |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
510 | if (g_unichar_isspace(c)) |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
511 | preceding_space = TRUE; |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
512 | else |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
513 | preceding_space = FALSE; |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
514 | } else { |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
515 | str = g_string_append_unichar(str, c); |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
516 | } |
| 18233 | 517 | } |
|
15587
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
518 | return g_string_free(str, FALSE); |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
519 | } |
|
21195
fd63ef5027d7
Music support for Google Talk
Sean Egan <seanegan@pidgin.im>
parents:
20640
diff
changeset
|
520 | |
|
fd63ef5027d7
Music support for Google Talk
Sean Egan <seanegan@pidgin.im>
parents:
20640
diff
changeset
|
521 | void jabber_google_presence_incoming(JabberStream *js, const char *user, JabberBuddyResource *jbr) |
|
fd63ef5027d7
Music support for Google Talk
Sean Egan <seanegan@pidgin.im>
parents:
20640
diff
changeset
|
522 | { |
|
fd63ef5027d7
Music support for Google Talk
Sean Egan <seanegan@pidgin.im>
parents:
20640
diff
changeset
|
523 | if (!js->googletalk) |
|
fd63ef5027d7
Music support for Google Talk
Sean Egan <seanegan@pidgin.im>
parents:
20640
diff
changeset
|
524 | return; |
|
fd63ef5027d7
Music support for Google Talk
Sean Egan <seanegan@pidgin.im>
parents:
20640
diff
changeset
|
525 | if (jbr->status && !strncmp(jbr->status, "♫ ", strlen("♫ "))) { |
|
fd63ef5027d7
Music support for Google Talk
Sean Egan <seanegan@pidgin.im>
parents:
20640
diff
changeset
|
526 | purple_prpl_got_user_status(js->gc->account, user, "tune", |
|
fd63ef5027d7
Music support for Google Talk
Sean Egan <seanegan@pidgin.im>
parents:
20640
diff
changeset
|
527 | PURPLE_TUNE_TITLE, jbr->status + strlen("♫ "), NULL); |
|
fd63ef5027d7
Music support for Google Talk
Sean Egan <seanegan@pidgin.im>
parents:
20640
diff
changeset
|
528 | jbr->status = NULL; |
|
fd63ef5027d7
Music support for Google Talk
Sean Egan <seanegan@pidgin.im>
parents:
20640
diff
changeset
|
529 | } else { |
|
fd63ef5027d7
Music support for Google Talk
Sean Egan <seanegan@pidgin.im>
parents:
20640
diff
changeset
|
530 | purple_prpl_got_user_status_deactive(js->gc->account, user, "tune"); |
|
fd63ef5027d7
Music support for Google Talk
Sean Egan <seanegan@pidgin.im>
parents:
20640
diff
changeset
|
531 | } |
|
fd63ef5027d7
Music support for Google Talk
Sean Egan <seanegan@pidgin.im>
parents:
20640
diff
changeset
|
532 | } |
|
fd63ef5027d7
Music support for Google Talk
Sean Egan <seanegan@pidgin.im>
parents:
20640
diff
changeset
|
533 | |
|
fd63ef5027d7
Music support for Google Talk
Sean Egan <seanegan@pidgin.im>
parents:
20640
diff
changeset
|
534 | char *jabber_google_presence_outgoing(PurpleStatus *tune) |
|
fd63ef5027d7
Music support for Google Talk
Sean Egan <seanegan@pidgin.im>
parents:
20640
diff
changeset
|
535 | { |
|
fd63ef5027d7
Music support for Google Talk
Sean Egan <seanegan@pidgin.im>
parents:
20640
diff
changeset
|
536 | char *ret = g_strdup_printf("♫ %s", purple_status_get_attr_string(tune, PURPLE_TUNE_TITLE)); |
|
fd63ef5027d7
Music support for Google Talk
Sean Egan <seanegan@pidgin.im>
parents:
20640
diff
changeset
|
537 | return ret; |
|
fd63ef5027d7
Music support for Google Talk
Sean Egan <seanegan@pidgin.im>
parents:
20640
diff
changeset
|
538 | } |