annotate libpurple/protocols/jabber/google.c @ 26214:7988bbd25151

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