Thu, 23 Mar 2017 21:01:15 +0300
Replace !strcmp() with purple_strequal()
Didn't touch finch/libgnt files
|
29914
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
1 | /** |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
2 | * Purple is the legal property of its developers, whose names are too numerous |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
3 | * to list here. Please refer to the COPYRIGHT file distributed with this |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
4 | * source distribution. |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
5 | * |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
6 | * This program is free software; you can redistribute it and/or modify |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
7 | * it under the terms of the GNU General Public License as published by |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
8 | * the Free Software Foundation; either version 2 of the License, or |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
9 | * (at your option) any later version. |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
10 | * |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
11 | * This program is distributed in the hope that it will be useful, |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
14 | * GNU General Public License for more details. |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
15 | * |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
16 | * You should have received a copy of the GNU General Public License |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
17 | * along with this program; if not, write to the Free Software |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
19 | */ |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
20 | |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
21 | #include "internal.h" |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
22 | #include "debug.h" |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
23 | #include "jabber.h" |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
24 | #include "gmail.h" |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
25 | |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
26 | static void |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
27 | jabber_gmail_parse(JabberStream *js, const char *from, |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
28 | JabberIqType type, const char *id, |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
29 | xmlnode *packet, gpointer nul) |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
30 | { |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
31 | xmlnode *child; |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
32 | xmlnode *message; |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
33 | const char *to, *url; |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
34 | const char *in_str; |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
35 | char *to_name; |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
36 | |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
37 | int i, count = 1, returned_count; |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
38 | |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
39 | const char **tos, **froms, **urls; |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
40 | char **subjects; |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
41 | |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
42 | if (type == JABBER_IQ_ERROR) |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
43 | return; |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
44 | |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
45 | child = xmlnode_get_child(packet, "mailbox"); |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
46 | if (!child) |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
47 | return; |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
48 | |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
49 | in_str = xmlnode_get_attrib(child, "total-matched"); |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
50 | if (in_str && *in_str) |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
51 | count = atoi(in_str); |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
52 | |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
53 | /* If Gmail doesn't tell us who the mail is to, let's use our JID */ |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
54 | to = xmlnode_get_attrib(packet, "to"); |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
55 | |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
56 | message = xmlnode_get_child(child, "mail-thread-info"); |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
57 | |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
58 | if (count == 0 || !message) { |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
59 | if (count > 0) { |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
60 | char *bare_jid = jabber_get_bare_jid(to); |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
61 | const char *default_tos[2] = { bare_jid }; |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
62 | |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
63 | purple_notify_emails(js->gc, count, FALSE, NULL, NULL, default_tos, NULL, NULL, NULL); |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
64 | g_free(bare_jid); |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
65 | } else { |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
66 | purple_notify_emails(js->gc, count, FALSE, NULL, NULL, NULL, NULL, NULL, NULL); |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
67 | } |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
68 | |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
69 | return; |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
70 | } |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
71 | |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
72 | /* Loop once to see how many messages were returned so we can allocate arrays |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
73 | * accordingly */ |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
74 | for (returned_count = 0; message; returned_count++, message=xmlnode_get_next_twin(message)); |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
75 | |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
76 | froms = g_new0(const char* , returned_count + 1); |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
77 | tos = g_new0(const char* , returned_count + 1); |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
78 | subjects = g_new0(char* , returned_count + 1); |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
79 | urls = g_new0(const char* , returned_count + 1); |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
80 | |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
81 | to = xmlnode_get_attrib(packet, "to"); |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
82 | to_name = jabber_get_bare_jid(to); |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
83 | url = xmlnode_get_attrib(child, "url"); |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
84 | if (!url || !*url) |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
85 | url = "http://www.gmail.com"; |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
86 | |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
87 | message= xmlnode_get_child(child, "mail-thread-info"); |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
88 | for (i=0; message; message = xmlnode_get_next_twin(message), i++) { |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
89 | xmlnode *sender_node, *subject_node; |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
90 | const char *from, *tid; |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
91 | char *subject; |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
92 | |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
93 | subject_node = xmlnode_get_child(message, "subject"); |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
94 | sender_node = xmlnode_get_child(message, "senders"); |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
95 | sender_node = xmlnode_get_child(sender_node, "sender"); |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
96 | |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
97 | while (sender_node && (!xmlnode_get_attrib(sender_node, "unread") || |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
29914
diff
changeset
|
98 | purple_strequal(xmlnode_get_attrib(sender_node, "unread"),"0"))) |
|
29914
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
99 | sender_node = xmlnode_get_next_twin(sender_node); |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
100 | |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
101 | if (!sender_node) { |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
102 | i--; |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
103 | continue; |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
104 | } |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
105 | |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
106 | from = xmlnode_get_attrib(sender_node, "name"); |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
107 | if (!from || !*from) |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
108 | from = xmlnode_get_attrib(sender_node, "address"); |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
109 | subject = xmlnode_get_data(subject_node); |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
110 | /* |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
111 | * url = xmlnode_get_attrib(message, "url"); |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
112 | */ |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
113 | tos[i] = (to_name != NULL ? to_name : ""); |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
114 | froms[i] = (from != NULL ? from : ""); |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
115 | subjects[i] = (subject != NULL ? subject : g_strdup("")); |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
116 | urls[i] = url; |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
117 | |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
118 | tid = xmlnode_get_attrib(message, "tid"); |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
119 | if (tid && |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
120 | (js->gmail_last_tid == NULL || strcmp(tid, js->gmail_last_tid) > 0)) { |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
121 | g_free(js->gmail_last_tid); |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
122 | js->gmail_last_tid = g_strdup(tid); |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
123 | } |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
124 | } |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
125 | |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
126 | if (i>0) |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
127 | purple_notify_emails(js->gc, count, count == i, (const char**) subjects, froms, tos, |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
128 | urls, NULL, NULL); |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
129 | |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
130 | g_free(to_name); |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
131 | g_free(tos); |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
132 | g_free(froms); |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
133 | for (i = 0; i < returned_count; i++) |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
134 | g_free(subjects[i]); |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
135 | g_free(subjects); |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
136 | g_free(urls); |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
137 | |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
138 | in_str = xmlnode_get_attrib(child, "result-time"); |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
139 | if (in_str && *in_str) { |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
140 | g_free(js->gmail_last_time); |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
141 | js->gmail_last_time = g_strdup(in_str); |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
142 | } |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
143 | } |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
144 | |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
145 | void |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
146 | jabber_gmail_poke(JabberStream *js, const char *from, JabberIqType type, |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
147 | const char *id, xmlnode *new_mail) |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
148 | { |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
149 | xmlnode *query; |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
150 | JabberIq *iq; |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
151 | |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
152 | /* bail if the user isn't interested */ |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
153 | if (!purple_account_get_check_mail(js->gc->account)) |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
154 | return; |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
155 | |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
156 | /* Is this an initial incoming mail notification? If so, send a request for more info */ |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
157 | if (type != JABBER_IQ_SET) |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
158 | return; |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
159 | |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
160 | /* Acknowledge the notification */ |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
161 | iq = jabber_iq_new(js, JABBER_IQ_RESULT); |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
162 | if (from) |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
163 | xmlnode_set_attrib(iq->node, "to", from); |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
164 | xmlnode_set_attrib(iq->node, "id", id); |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
165 | jabber_iq_send(iq); |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
166 | |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
167 | purple_debug_misc("jabber", |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
168 | "Got new mail notification. Sending request for more info\n"); |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
169 | |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
170 | iq = jabber_iq_new_query(js, JABBER_IQ_GET, NS_GOOGLE_MAIL_NOTIFY); |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
171 | jabber_iq_set_callback(iq, jabber_gmail_parse, NULL); |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
172 | query = xmlnode_get_child(iq->node, "query"); |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
173 | |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
174 | if (js->gmail_last_time) |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
175 | xmlnode_set_attrib(query, "newer-than-time", js->gmail_last_time); |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
176 | if (js->gmail_last_tid) |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
177 | xmlnode_set_attrib(query, "newer-than-tid", js->gmail_last_tid); |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
178 | |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
179 | jabber_iq_send(iq); |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
180 | return; |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
181 | } |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
182 | |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
183 | void jabber_gmail_init(JabberStream *js) { |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
184 | JabberIq *iq; |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
185 | xmlnode *usersetting, *mailnotifications; |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
186 | |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
187 | if (!purple_account_get_check_mail(purple_connection_get_account(js->gc))) |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
188 | return; |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
189 | |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
190 | /* |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
191 | * Quoting http://code.google.com/apis/talk/jep_extensions/usersettings.html: |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
192 | * To ensure better compatibility with other clients, rather than |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
193 | * setting this value to "false" to turn off notifications, it is |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
194 | * recommended that a client set this to "true" and filter incoming |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
195 | * email notifications itself. |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
196 | */ |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
197 | iq = jabber_iq_new(js, JABBER_IQ_SET); |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
198 | usersetting = xmlnode_new_child(iq->node, "usersetting"); |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
199 | xmlnode_set_namespace(usersetting, "google:setting"); |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
200 | mailnotifications = xmlnode_new_child(usersetting, "mailnotifications"); |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
201 | xmlnode_set_attrib(mailnotifications, "value", "true"); |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
202 | jabber_iq_send(iq); |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
203 | |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
204 | iq = jabber_iq_new_query(js, JABBER_IQ_GET, NS_GOOGLE_MAIL_NOTIFY); |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
205 | jabber_iq_set_callback(iq, jabber_gmail_parse, NULL); |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
206 | jabber_iq_send(iq); |
|
a4ed5999f6d0
Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff
changeset
|
207 | } |