Sat, 22 Nov 2008 18:26:45 +0000
Sprinkle around more support for xml:lang on JabberIdentities
Change the IPC has_feature function to take a PurpleAccount and look up
the caps via the jbr
| 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; | |
|
20097
f5bef80db09e
applied changes from 19e3744fd4b392cdc631c9efe0ce658537070713
Richard Laager <rlaager@pidgin.im>
parents:
19859
diff
changeset
|
42 | char *default_tos[1]; |
|
f5bef80db09e
applied changes from 19e3744fd4b392cdc631c9efe0ce658537070713
Richard Laager <rlaager@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 | |
|
20097
f5bef80db09e
applied changes from 19e3744fd4b392cdc631c9efe0ce658537070713
Richard Laager <rlaager@pidgin.im>
parents:
19859
diff
changeset
|
60 | /* If Gmail doesn't tell us who the mail is to, let's use our JID */ |
|
f5bef80db09e
applied changes from 19e3744fd4b392cdc631c9efe0ce658537070713
Richard Laager <rlaager@pidgin.im>
parents:
19859
diff
changeset
|
61 | to = xmlnode_get_attrib(packet, "to"); |
|
f5bef80db09e
applied changes from 19e3744fd4b392cdc631c9efe0ce658537070713
Richard Laager <rlaager@pidgin.im>
parents:
19859
diff
changeset
|
62 | default_tos[0] = jabber_get_bare_jid(to); |
|
f5bef80db09e
applied changes from 19e3744fd4b392cdc631c9efe0ce658537070713
Richard Laager <rlaager@pidgin.im>
parents:
19859
diff
changeset
|
63 | |
|
20114
96e715e155e0
applied changes from 3fcc47961d378fa0cd4eeb00dc6923b16a3a4151
Richard Laager <rlaager@pidgin.im>
parents:
20107
diff
changeset
|
64 | message = xmlnode_get_child(child, "mail-thread-info"); |
| 15225 | 65 | |
|
20114
96e715e155e0
applied changes from 3fcc47961d378fa0cd4eeb00dc6923b16a3a4151
Richard Laager <rlaager@pidgin.im>
parents:
20107
diff
changeset
|
66 | if (count == 0 || !message) { |
|
20186
25fce12345fe
Don't display mail notifications for 0 new emails in Google Talk
Evan Schoenberg <evands@pidgin.im>
parents:
20114
diff
changeset
|
67 | if (count > 0) |
|
25fce12345fe
Don't display mail notifications for 0 new emails in Google Talk
Evan Schoenberg <evands@pidgin.im>
parents:
20114
diff
changeset
|
68 | purple_notify_emails(js->gc, count, FALSE, NULL, NULL, (const char**) default_tos, NULL, NULL, NULL); |
|
20097
f5bef80db09e
applied changes from 19e3744fd4b392cdc631c9efe0ce658537070713
Richard Laager <rlaager@pidgin.im>
parents:
19859
diff
changeset
|
69 | g_free(default_tos[0]); |
|
f5bef80db09e
applied changes from 19e3744fd4b392cdc631c9efe0ce658537070713
Richard Laager <rlaager@pidgin.im>
parents:
19859
diff
changeset
|
70 | return; |
|
f5bef80db09e
applied changes from 19e3744fd4b392cdc631c9efe0ce658537070713
Richard Laager <rlaager@pidgin.im>
parents:
19859
diff
changeset
|
71 | } |
| 18233 | 72 | |
| 15225 | 73 | /* Loop once to see how many messages were returned so we can allocate arrays |
| 74 | * accordingly */ | |
| 75 | for (returned_count = 0; message; returned_count++, message=xmlnode_get_next_twin(message)); | |
| 18233 | 76 | |
| 15225 | 77 | froms = g_new0(const char* , returned_count); |
| 78 | tos = g_new0(const char* , returned_count); | |
| 18739 | 79 | subjects = g_new0(char* , returned_count); |
| 15225 | 80 | urls = g_new0(const char* , returned_count); |
| 18233 | 81 | |
| 15225 | 82 | to = xmlnode_get_attrib(packet, "to"); |
| 83 | to_name = jabber_get_bare_jid(to); | |
| 84 | url = xmlnode_get_attrib(child, "url"); | |
| 85 | if (!url || !*url) | |
| 86 | url = "http://www.gmail.com"; | |
| 18233 | 87 | |
| 15225 | 88 | message= xmlnode_get_child(child, "mail-thread-info"); |
| 89 | for (i=0; message; message = xmlnode_get_next_twin(message), i++) { | |
| 90 | subject_node = xmlnode_get_child(message, "subject"); | |
| 91 | sender_node = xmlnode_get_child(message, "senders"); | |
| 92 | sender_node = xmlnode_get_child(sender_node, "sender"); | |
| 93 | ||
| 18233 | 94 | while (sender_node && (!xmlnode_get_attrib(sender_node, "unread") || |
| 15225 | 95 | !strcmp(xmlnode_get_attrib(sender_node, "unread"),"0"))) |
| 96 | sender_node = xmlnode_get_next_twin(sender_node); | |
| 18233 | 97 | |
| 15225 | 98 | if (!sender_node) { |
| 99 | i--; | |
| 100 | continue; | |
| 101 | } | |
| 18233 | 102 | |
| 15225 | 103 | from = xmlnode_get_attrib(sender_node, "name"); |
| 104 | if (!from || !*from) | |
| 105 | from = xmlnode_get_attrib(sender_node, "address"); | |
| 106 | subject = xmlnode_get_data(subject_node); | |
| 107 | /* | |
| 108 | * url = xmlnode_get_attrib(message, "url"); | |
| 109 | */ | |
| 110 | tos[i] = (to_name != NULL ? to_name : ""); | |
| 111 | froms[i] = (from != NULL ? from : ""); | |
| 18739 | 112 | subjects[i] = (subject != NULL ? subject : g_strdup("")); |
|
20225
684334efdc19
applied changes from d4b316d73ebaf93803ca2642e78b8821c3b5d5c7
Luke Schierer <lschiere@pidgin.im>
parents:
20209
diff
changeset
|
113 | urls[i] = url; |
| 18233 | 114 | |
| 15225 | 115 | tid = xmlnode_get_attrib(message, "tid"); |
| 18233 | 116 | if (tid && |
| 15225 | 117 | (js->gmail_last_tid == NULL || strcmp(tid, js->gmail_last_tid) > 0)) { |
| 118 | g_free(js->gmail_last_tid); | |
| 119 | js->gmail_last_tid = g_strdup(tid); | |
| 120 | } | |
| 121 | } | |
| 122 | ||
| 18233 | 123 | 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
|
124 | purple_notify_emails(js->gc, count, count == i, (const char**) subjects, froms, tos, |
| 18233 | 125 | urls, NULL, NULL); |
|
20114
96e715e155e0
applied changes from 3fcc47961d378fa0cd4eeb00dc6923b16a3a4151
Richard Laager <rlaager@pidgin.im>
parents:
20107
diff
changeset
|
126 | else |
|
20107
c2fafb2681d1
applied changes from 606266f42c25624ce35e54483778d855641806be
Richard Laager <rlaager@pidgin.im>
parents:
20097
diff
changeset
|
127 | purple_notify_emails(js->gc, count, FALSE, NULL, NULL, (const char**) default_tos, NULL, NULL, NULL); |
|
20097
f5bef80db09e
applied changes from 19e3744fd4b392cdc631c9efe0ce658537070713
Richard Laager <rlaager@pidgin.im>
parents:
19859
diff
changeset
|
128 | |
| 15261 | 129 | |
| 15225 | 130 | g_free(to_name); |
| 131 | g_free(tos); | |
|
20097
f5bef80db09e
applied changes from 19e3744fd4b392cdc631c9efe0ce658537070713
Richard Laager <rlaager@pidgin.im>
parents:
19859
diff
changeset
|
132 | g_free(default_tos[0]); |
| 15225 | 133 | 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
|
134 | 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
|
135 | g_free(subjects[i - 1]); |
| 15225 | 136 | g_free(subjects); |
| 137 | g_free(urls); | |
| 138 | ||
| 139 | in_str = xmlnode_get_attrib(child, "result-time"); | |
| 140 | if (in_str && *in_str) { | |
| 141 | g_free(js->gmail_last_time); | |
| 142 | js->gmail_last_time = g_strdup(in_str); | |
| 143 | } | |
| 144 | } | |
| 145 | ||
| 18233 | 146 | void |
| 147 | jabber_gmail_poke(JabberStream *js, xmlnode *packet) | |
| 15225 | 148 | { |
| 149 | const char *type; | |
| 150 | xmlnode *query; | |
| 151 | JabberIq *iq; | |
| 18233 | 152 | |
| 15225 | 153 | /* bail if the user isn't interested */ |
| 15884 | 154 | if (!purple_account_get_check_mail(js->gc->account)) |
| 15225 | 155 | return; |
| 156 | ||
| 157 | type = xmlnode_get_attrib(packet, "type"); | |
| 18233 | 158 | |
| 15225 | 159 | |
| 160 | /* Is this an initial incoming mail notification? If so, send a request for more info */ | |
| 161 | if (strcmp(type, "set") || !xmlnode_get_child(packet, "new-mail")) | |
| 162 | return; | |
| 163 | ||
| 15884 | 164 | purple_debug(PURPLE_DEBUG_MISC, "jabber", |
| 15225 | 165 | "Got new mail notification. Sending request for more info\n"); |
| 166 | ||
| 167 | iq = jabber_iq_new_query(js, JABBER_IQ_GET, "google:mail:notify"); | |
| 168 | jabber_iq_set_callback(iq, jabber_gmail_parse, NULL); | |
| 169 | query = xmlnode_get_child(iq->node, "query"); | |
| 170 | ||
| 171 | if (js->gmail_last_time) | |
| 172 | xmlnode_set_attrib(query, "newer-than-time", js->gmail_last_time); | |
| 173 | if (js->gmail_last_tid) | |
| 174 | xmlnode_set_attrib(query, "newer-than-tid", js->gmail_last_tid); | |
| 175 | ||
| 176 | jabber_iq_send(iq); | |
| 177 | return; | |
| 178 | } | |
| 179 | ||
| 180 | void jabber_gmail_init(JabberStream *js) { | |
| 181 | JabberIq *iq; | |
| 182 | ||
| 18233 | 183 | if (!purple_account_get_check_mail(js->gc->account)) |
| 15225 | 184 | return; |
| 185 | ||
| 186 | iq = jabber_iq_new_query(js, JABBER_IQ_GET, "google:mail:notify"); | |
| 187 | jabber_iq_set_callback(iq, jabber_gmail_parse, NULL); | |
| 188 | jabber_iq_send(iq); | |
| 189 | } | |
| 15265 | 190 | |
| 191 | void jabber_google_roster_init(JabberStream *js) | |
| 192 | { | |
| 193 | JabberIq *iq; | |
| 194 | xmlnode *query; | |
| 195 | ||
| 196 | iq = jabber_iq_new_query(js, JABBER_IQ_GET, "jabber:iq:roster"); | |
| 197 | query = xmlnode_get_child(iq->node, "query"); | |
| 18233 | 198 | |
| 15265 | 199 | xmlnode_set_attrib(query, "xmlns:gr", "google:roster"); |
| 200 | xmlnode_set_attrib(query, "gr:ext", "2"); | |
| 201 | ||
| 202 | jabber_iq_send(iq); | |
| 203 | } | |
| 204 | ||
| 205 | void jabber_google_roster_outgoing(JabberStream *js, xmlnode *query, xmlnode *item) | |
| 206 | { | |
| 15884 | 207 | PurpleAccount *account = purple_connection_get_account(js->gc); |
| 15265 | 208 | GSList *list = account->deny; |
| 209 | const char *jid = xmlnode_get_attrib(item, "jid"); | |
| 210 | char *jid_norm = g_strdup(jabber_normalize(account, jid)); | |
| 211 | ||
| 212 | while (list) { | |
| 213 | if (!strcmp(jid_norm, (char*)list->data)) { | |
| 214 | xmlnode_set_attrib(query, "xmlns:gr", "google:roster"); | |
| 215 | xmlnode_set_attrib(item, "gr:t", "B"); | |
| 216 | xmlnode_set_attrib(query, "xmlns:gr", "google:roster"); | |
| 217 | xmlnode_set_attrib(query, "gr:ext", "2"); | |
| 218 | return; | |
| 219 | } | |
| 220 | list = list->next; | |
| 221 | } | |
| 222 | ||
| 18739 | 223 | g_free(jid_norm); |
| 224 | ||
| 15265 | 225 | } |
| 226 | ||
|
15530
9355a1be068e
Make deleting Google Talk buddies work
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
227 | gboolean jabber_google_roster_incoming(JabberStream *js, xmlnode *item) |
| 15265 | 228 | { |
| 15884 | 229 | PurpleAccount *account = purple_connection_get_account(js->gc); |
| 15265 | 230 | GSList *list = account->deny; |
| 231 | const char *jid = xmlnode_get_attrib(item, "jid"); | |
| 232 | gboolean on_block_list = FALSE; | |
| 233 | ||
|
20209
c1bbdde1f373
applied changes from 6b5f1f48667171fe73de619dd8f80cacd231a2e2
Luke Schierer <lschiere@pidgin.im>
parents:
20186
diff
changeset
|
234 | char *jid_norm; |
| 15265 | 235 | |
| 236 | 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
|
237 | const char *subscription = xmlnode_get_attrib(item, "subscription"); |
| 18233 | 238 | |
| 17327 | 239 | 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
|
240 | /* 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
|
241 | * 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
|
242 | */ |
|
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
|
243 | 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
|
244 | } |
| 18233 | 245 | |
|
20209
c1bbdde1f373
applied changes from 6b5f1f48667171fe73de619dd8f80cacd231a2e2
Luke Schierer <lschiere@pidgin.im>
parents:
20186
diff
changeset
|
246 | jid_norm = g_strdup(jabber_normalize(account, jid)); |
|
c1bbdde1f373
applied changes from 6b5f1f48667171fe73de619dd8f80cacd231a2e2
Luke Schierer <lschiere@pidgin.im>
parents:
20186
diff
changeset
|
247 | |
| 15265 | 248 | while (list) { |
| 249 | if (!strcmp(jid_norm, (char*)list->data)) { | |
| 250 | on_block_list = TRUE; | |
| 251 | break; | |
| 252 | } | |
| 253 | list = list->next; | |
| 254 | } | |
| 18233 | 255 | |
|
15530
9355a1be068e
Make deleting Google Talk buddies work
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
256 | if (grt && (*grt == 'H' || *grt == 'h')) { |
| 15884 | 257 | PurpleBuddy *buddy = purple_find_buddy(account, jid_norm); |
|
20114
96e715e155e0
applied changes from 3fcc47961d378fa0cd4eeb00dc6923b16a3a4151
Richard Laager <rlaager@pidgin.im>
parents:
20107
diff
changeset
|
258 | if (buddy) |
|
96e715e155e0
applied changes from 3fcc47961d378fa0cd4eeb00dc6923b16a3a4151
Richard Laager <rlaager@pidgin.im>
parents:
20107
diff
changeset
|
259 | purple_blist_remove_buddy(buddy); |
| 18739 | 260 | g_free(jid_norm); |
|
15530
9355a1be068e
Make deleting Google Talk buddies work
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
261 | return FALSE; |
|
9355a1be068e
Make deleting Google Talk buddies work
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
262 | } |
| 18233 | 263 | |
| 15265 | 264 | if (!on_block_list && (grt && (*grt == 'B' || *grt == 'b'))) { |
| 15884 | 265 | purple_debug_info("jabber", "Blocking %s\n", jid_norm); |
| 266 | purple_privacy_deny_add(account, jid_norm, TRUE); | |
| 15265 | 267 | } else if (on_block_list && (!grt || (*grt != 'B' && *grt != 'b' ))){ |
| 15884 | 268 | purple_debug_info("jabber", "Unblocking %s\n", jid_norm); |
| 269 | purple_privacy_deny_remove(account, jid_norm, TRUE); | |
| 15265 | 270 | } |
| 18739 | 271 | |
| 272 | g_free(jid_norm); | |
|
15530
9355a1be068e
Make deleting Google Talk buddies work
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
273 | return TRUE; |
| 15265 | 274 | } |
| 275 | ||
| 18233 | 276 | void jabber_google_roster_add_deny(PurpleConnection *gc, const char *who) |
| 15265 | 277 | { |
| 278 | JabberStream *js; | |
| 279 | GSList *buddies; | |
| 280 | JabberIq *iq; | |
| 281 | xmlnode *query; | |
| 282 | xmlnode *item; | |
| 283 | xmlnode *group; | |
| 15884 | 284 | PurpleBuddy *b; |
| 15265 | 285 | JabberBuddy *jb; |
| 286 | ||
| 287 | js = (JabberStream*)(gc->proto_data); | |
| 18233 | 288 | |
| 15265 | 289 | if (!js || !js->server_caps & JABBER_CAP_GOOGLE_ROSTER) |
| 290 | return; | |
| 291 | ||
| 292 | jb = jabber_buddy_find(js, who, TRUE); | |
| 293 | ||
| 15884 | 294 | buddies = purple_find_buddies(js->gc->account, who); |
| 15265 | 295 | if(!buddies) |
| 296 | return; | |
| 18233 | 297 | |
| 15265 | 298 | b = buddies->data; |
| 299 | ||
| 300 | iq = jabber_iq_new_query(js, JABBER_IQ_SET, "jabber:iq:roster"); | |
| 18233 | 301 | |
| 15265 | 302 | query = xmlnode_get_child(iq->node, "query"); |
| 303 | item = xmlnode_new_child(query, "item"); | |
| 304 | ||
| 305 | while(buddies) { | |
| 15884 | 306 | PurpleGroup *g; |
| 15265 | 307 | |
| 308 | b = buddies->data; | |
| 15884 | 309 | g = purple_buddy_get_group(b); |
| 15265 | 310 | |
| 311 | group = xmlnode_new_child(item, "group"); | |
| 312 | xmlnode_insert_data(group, g->name, -1); | |
| 18233 | 313 | |
| 15265 | 314 | buddies = buddies->next; |
| 315 | } | |
| 316 | ||
| 317 | xmlnode_set_attrib(item, "jid", who); | |
| 318 | xmlnode_set_attrib(item, "name", b->alias ? b->alias : ""); | |
| 319 | xmlnode_set_attrib(item, "gr:t", "B"); | |
| 320 | xmlnode_set_attrib(query, "xmlns:gr", "google:roster"); | |
| 321 | xmlnode_set_attrib(query, "gr:ext", "2"); | |
| 322 | ||
| 323 | jabber_iq_send(iq); | |
| 324 | ||
| 325 | /* Synthesize a sign-off */ | |
| 326 | if (jb) { | |
| 327 | JabberBuddyResource *jbr; | |
| 328 | GList *l = jb->resources; | |
| 329 | while (l) { | |
| 330 | jbr = l->data; | |
|
15346
ef48613b5b9b
[gaim-migrate @ 18074]
Evan Schoenberg <evands@pidgin.im>
parents:
15265
diff
changeset
|
331 | if (jbr && jbr->name) |
|
ef48613b5b9b
[gaim-migrate @ 18074]
Evan Schoenberg <evands@pidgin.im>
parents:
15265
diff
changeset
|
332 | { |
| 15884 | 333 | 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
|
334 | jabber_buddy_remove_resource(jb, jbr->name); |
|
ef48613b5b9b
[gaim-migrate @ 18074]
Evan Schoenberg <evands@pidgin.im>
parents:
15265
diff
changeset
|
335 | } |
| 15265 | 336 | l = l->next; |
| 337 | } | |
| 338 | } | |
| 15884 | 339 | purple_prpl_got_user_status(purple_connection_get_account(gc), who, "offline", NULL); |
| 15265 | 340 | } |
| 341 | ||
| 15884 | 342 | void jabber_google_roster_rem_deny(PurpleConnection *gc, const char *who) |
| 15265 | 343 | { |
| 344 | JabberStream *js; | |
| 345 | GSList *buddies; | |
| 346 | JabberIq *iq; | |
| 347 | xmlnode *query; | |
| 348 | xmlnode *item; | |
| 349 | xmlnode *group; | |
| 15884 | 350 | PurpleBuddy *b; |
| 15265 | 351 | |
| 352 | g_return_if_fail(gc != NULL); | |
| 353 | g_return_if_fail(who != NULL); | |
| 18233 | 354 | |
| 15265 | 355 | js = (JabberStream*)(gc->proto_data); |
| 18233 | 356 | |
| 15265 | 357 | if (!js || !js->server_caps & JABBER_CAP_GOOGLE_ROSTER) |
| 358 | return; | |
| 18233 | 359 | |
| 15884 | 360 | buddies = purple_find_buddies(js->gc->account, who); |
| 15265 | 361 | if(!buddies) |
| 362 | return; | |
| 18233 | 363 | |
| 15265 | 364 | b = buddies->data; |
| 365 | ||
| 366 | iq = jabber_iq_new_query(js, JABBER_IQ_SET, "jabber:iq:roster"); | |
| 18233 | 367 | |
| 15265 | 368 | query = xmlnode_get_child(iq->node, "query"); |
| 369 | item = xmlnode_new_child(query, "item"); | |
| 370 | ||
| 371 | while(buddies) { | |
| 15884 | 372 | PurpleGroup *g; |
| 15265 | 373 | |
| 374 | b = buddies->data; | |
| 15884 | 375 | g = purple_buddy_get_group(b); |
| 15265 | 376 | |
| 377 | group = xmlnode_new_child(item, "group"); | |
| 378 | xmlnode_insert_data(group, g->name, -1); | |
| 18233 | 379 | |
| 15265 | 380 | buddies = buddies->next; |
| 381 | } | |
| 382 | ||
| 383 | xmlnode_set_attrib(item, "jid", who); | |
| 384 | xmlnode_set_attrib(item, "name", b->alias ? b->alias : ""); | |
| 385 | xmlnode_set_attrib(query, "xmlns:gr", "google:roster"); | |
| 386 | xmlnode_set_attrib(query, "gr:ext", "2"); | |
| 387 | ||
| 388 | jabber_iq_send(iq); | |
| 389 | ||
| 390 | /* See if he's online */ | |
| 391 | jabber_presence_subscription_set(js, who, "probe"); | |
| 392 | } | |
|
15587
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
393 | |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
394 | /* 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
|
395 | * 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
|
396 | * 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
|
397 | * 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
|
398 | * 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
|
399 | */ |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
400 | 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
|
401 | { |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
402 | const char *p; |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
403 | |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
404 | /* 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
|
405 | gboolean preceding_space = TRUE; |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
406 | |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
407 | 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
|
408 | gboolean in_tag = FALSE; |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
409 | |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
410 | 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
|
411 | |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
412 | GString *str; |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
413 | |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
414 | 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
|
415 | 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
|
416 | if (c == '*' && !in_tag) { |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
417 | 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
|
418 | *(p+1) == '\0' || |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
419 | *(p+1) == '<')) { |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
420 | bold_count++; |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
421 | in_bold = FALSE; |
|
16988
1aaf51bf0f23
Patch #265. Fix to Google Talk formatting
Sean Egan <seanegan@pidgin.im>
parents:
15884
diff
changeset
|
422 | } 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
|
423 | bold_count++; |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
424 | in_bold = TRUE; |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
425 | } |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
426 | preceding_space = TRUE; |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
427 | } 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
|
428 | 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
|
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 | italic_count++; |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
432 | in_italic = 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_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
|
434 | italic_count++; |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
435 | in_italic = 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 | in_tag = TRUE; |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
440 | } 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
|
441 | in_tag = FALSE; |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
442 | } else if (!in_tag) { |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
443 | 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
|
444 | preceding_space = TRUE; |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
445 | else |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
446 | preceding_space = FALSE; |
|
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 | } |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
449 | |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
450 | 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
|
451 | 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
|
452 | preceding_space = TRUE; |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
453 | |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
454 | 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
|
455 | gunichar c = g_utf8_get_char(p); |
| 18233 | 456 | |
|
15587
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
457 | 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
|
458 | 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
|
459 | 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
|
460 | } |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
461 | |
| 18233 | 462 | |
|
15587
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
463 | if (c == '*' && !in_tag) { |
| 18233 | 464 | if (in_bold && |
|
15587
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
465 | (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
|
466 | 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
|
467 | in_bold = FALSE; |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
468 | bold_count--; |
|
16988
1aaf51bf0f23
Patch #265. Fix to Google Talk formatting
Sean Egan <seanegan@pidgin.im>
parents:
15884
diff
changeset
|
469 | } 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
|
470 | 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
|
471 | bold_count--; |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
472 | in_bold = TRUE; |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
473 | } else { |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
474 | 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
|
475 | } |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
476 | preceding_space = TRUE; |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
477 | } 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
|
478 | if (in_italic && |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
479 | (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
|
480 | 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
|
481 | italic_count--; |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
482 | in_italic = FALSE; |
|
16988
1aaf51bf0f23
Patch #265. Fix to Google Talk formatting
Sean Egan <seanegan@pidgin.im>
parents:
15884
diff
changeset
|
483 | } 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
|
484 | 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
|
485 | italic_count--; |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
486 | in_italic = TRUE; |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
487 | } else { |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
488 | 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
|
489 | } |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
490 | preceding_space = TRUE; |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
491 | } 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
|
492 | 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
|
493 | in_tag = TRUE; |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
494 | } 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
|
495 | 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
|
496 | in_tag = FALSE; |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
497 | } else if (!in_tag) { |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
498 | 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
|
499 | 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
|
500 | preceding_space = TRUE; |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
501 | else |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
502 | preceding_space = FALSE; |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
503 | } else { |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
504 | 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
|
505 | } |
| 18233 | 506 | } |
|
15587
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
507 | 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
|
508 | } |
|
21195
fd63ef5027d7
Music support for Google Talk
Sean Egan <seanegan@pidgin.im>
parents:
20107
diff
changeset
|
509 | |
|
fd63ef5027d7
Music support for Google Talk
Sean Egan <seanegan@pidgin.im>
parents:
20107
diff
changeset
|
510 | void jabber_google_presence_incoming(JabberStream *js, const char *user, JabberBuddyResource *jbr) |
|
fd63ef5027d7
Music support for Google Talk
Sean Egan <seanegan@pidgin.im>
parents:
20107
diff
changeset
|
511 | { |
|
fd63ef5027d7
Music support for Google Talk
Sean Egan <seanegan@pidgin.im>
parents:
20107
diff
changeset
|
512 | if (!js->googletalk) |
|
fd63ef5027d7
Music support for Google Talk
Sean Egan <seanegan@pidgin.im>
parents:
20107
diff
changeset
|
513 | return; |
|
fd63ef5027d7
Music support for Google Talk
Sean Egan <seanegan@pidgin.im>
parents:
20107
diff
changeset
|
514 | if (jbr->status && !strncmp(jbr->status, "♫ ", strlen("♫ "))) { |
|
fd63ef5027d7
Music support for Google Talk
Sean Egan <seanegan@pidgin.im>
parents:
20107
diff
changeset
|
515 | purple_prpl_got_user_status(js->gc->account, user, "tune", |
|
fd63ef5027d7
Music support for Google Talk
Sean Egan <seanegan@pidgin.im>
parents:
20107
diff
changeset
|
516 | PURPLE_TUNE_TITLE, jbr->status + strlen("♫ "), NULL); |
|
fd63ef5027d7
Music support for Google Talk
Sean Egan <seanegan@pidgin.im>
parents:
20107
diff
changeset
|
517 | jbr->status = NULL; |
|
fd63ef5027d7
Music support for Google Talk
Sean Egan <seanegan@pidgin.im>
parents:
20107
diff
changeset
|
518 | } else { |
|
fd63ef5027d7
Music support for Google Talk
Sean Egan <seanegan@pidgin.im>
parents:
20107
diff
changeset
|
519 | purple_prpl_got_user_status_deactive(js->gc->account, user, "tune"); |
|
fd63ef5027d7
Music support for Google Talk
Sean Egan <seanegan@pidgin.im>
parents:
20107
diff
changeset
|
520 | } |
|
fd63ef5027d7
Music support for Google Talk
Sean Egan <seanegan@pidgin.im>
parents:
20107
diff
changeset
|
521 | } |
|
fd63ef5027d7
Music support for Google Talk
Sean Egan <seanegan@pidgin.im>
parents:
20107
diff
changeset
|
522 | |
|
fd63ef5027d7
Music support for Google Talk
Sean Egan <seanegan@pidgin.im>
parents:
20107
diff
changeset
|
523 | char *jabber_google_presence_outgoing(PurpleStatus *tune) |
|
fd63ef5027d7
Music support for Google Talk
Sean Egan <seanegan@pidgin.im>
parents:
20107
diff
changeset
|
524 | { |
|
21714
5956ea2cb4af
don't set the current tune title if it's NULL
Ka-Hing Cheung <khc@pidgin.im>
parents:
21204
diff
changeset
|
525 | const char *attr = purple_status_get_attr_string(tune, PURPLE_TUNE_TITLE); |
|
5956ea2cb4af
don't set the current tune title if it's NULL
Ka-Hing Cheung <khc@pidgin.im>
parents:
21204
diff
changeset
|
526 | return attr ? g_strdup_printf("♫ %s", attr) : g_strdup(""); |
|
21195
fd63ef5027d7
Music support for Google Talk
Sean Egan <seanegan@pidgin.im>
parents:
20107
diff
changeset
|
527 | } |