| 37 xmlnode *message, *sender_node, *subject_node; |
37 xmlnode *message, *sender_node, *subject_node; |
| 38 const char *from, *to, *url, *tid; |
38 const char *from, *to, *url, *tid; |
| 39 char *subject; |
39 char *subject; |
| 40 const char *in_str; |
40 const char *in_str; |
| 41 char *to_name; |
41 char *to_name; |
| |
42 char *default_tos[1]; |
| |
43 |
| 42 int i, count = 1, returned_count; |
44 int i, count = 1, returned_count; |
| 43 |
45 |
| 44 const char **tos, **froms, **urls; |
46 const char **tos, **froms, **urls; |
| 45 char **subjects; |
47 char **subjects; |
| 46 |
48 |
| 53 |
55 |
| 54 in_str = xmlnode_get_attrib(child, "total-matched"); |
56 in_str = xmlnode_get_attrib(child, "total-matched"); |
| 55 if (in_str && *in_str) |
57 if (in_str && *in_str) |
| 56 count = atoi(in_str); |
58 count = atoi(in_str); |
| 57 |
59 |
| 58 if (count == 0) |
60 /* If Gmail doesn't tell us who the mail is to, let's use our JID */ |
| 59 return; |
61 to = xmlnode_get_attrib(packet, "to"); |
| |
62 default_tos[0] = jabber_get_bare_jid(to); |
| |
63 |
| |
64 if (count == 0) { |
| |
65 purple_notify_emails(js->gc, count, FALSE, NULL, NULL, default_tos, NULL, NULL, NULL); |
| |
66 g_free(default_tos[0]); |
| |
67 return; |
| |
68 } |
| 60 |
69 |
| 61 message = xmlnode_get_child(child, "mail-thread-info"); |
70 message = xmlnode_get_child(child, "mail-thread-info"); |
| |
71 if (!message) { |
| |
72 purple_notify_emails(js->gc, count, FALSE, NULL, NULL, default_tos, NULL, NULL, NULL); |
| |
73 g_free(default_tos[0]); |
| |
74 return; |
| |
75 } |
| 62 |
76 |
| 63 /* Loop once to see how many messages were returned so we can allocate arrays |
77 /* Loop once to see how many messages were returned so we can allocate arrays |
| 64 * accordingly */ |
78 * accordingly */ |
| 65 if (!message) |
|
| 66 return; |
|
| 67 for (returned_count = 0; message; returned_count++, message=xmlnode_get_next_twin(message)); |
79 for (returned_count = 0; message; returned_count++, message=xmlnode_get_next_twin(message)); |
| 68 |
80 |
| 69 froms = g_new0(const char* , returned_count); |
81 froms = g_new0(const char* , returned_count); |
| 70 tos = g_new0(const char* , returned_count); |
82 tos = g_new0(const char* , returned_count); |
| 71 subjects = g_new0(char* , returned_count); |
83 subjects = g_new0(char* , returned_count); |
| 113 } |
125 } |
| 114 |
126 |
| 115 if (i>0) |
127 if (i>0) |
| 116 purple_notify_emails(js->gc, count, count == i, (const char**) subjects, froms, tos, |
128 purple_notify_emails(js->gc, count, count == i, (const char**) subjects, froms, tos, |
| 117 urls, NULL, NULL); |
129 urls, NULL, NULL); |
| |
130 else |
| |
131 purple_notify_emails(js->gc, count, FALSE, NULL, NULL, default_tos, NULL, NULL, NULL); |
| |
132 |
| 118 |
133 |
| 119 g_free(to_name); |
134 g_free(to_name); |
| 120 g_free(tos); |
135 g_free(tos); |
| |
136 g_free(default_tos[0]); |
| 121 g_free(froms); |
137 g_free(froms); |
| 122 for (; i > 0; i--) |
138 for (; i > 0; i--) |
| 123 g_free(subjects[i - 1]); |
139 g_free(subjects[i - 1]); |
| 124 g_free(subjects); |
140 g_free(subjects); |
| 125 g_free(urls); |
141 g_free(urls); |