diff libpurple/protocols/jabber/google.c @ 20169:575d8c84ccba

Show when Gmail count falls, instead of only when it rises. Fixes #1462
author Sean Egan <seanegan@gmail.com>
date Wed, 19 Sep 2007 20:35:00 +0000
parents 44b4e8bd759b
children a5d366d614f5
line wrap: on
line diff
--- a/libpurple/protocols/jabber/google.c	Tue Sep 18 23:33:31 2007 +0000
+++ b/libpurple/protocols/jabber/google.c	Wed Sep 19 20:35:00 2007 +0000
@@ -39,6 +39,8 @@
 	char *subject;
 	const char *in_str;
 	char *to_name;
+	char *default_tos[1];
+
 	int i, count = 1, returned_count;
 
 	const char **tos, **froms, **urls;
@@ -55,15 +57,25 @@
 	if (in_str && *in_str)
 		count = atoi(in_str);
 
-	if (count == 0)
+	/* If Gmail doesn't tell us who the mail is to, let's use our JID */
+	to = xmlnode_get_attrib(packet, "to");
+	default_tos[0] = jabber_get_bare_jid(to);
+
+	if (count == 0) {
+		purple_notify_emails(js->gc, count, FALSE, NULL, NULL, default_tos, NULL, NULL, NULL);
+		g_free(default_tos[0]);
 		return;
+	}
 
 	message = xmlnode_get_child(child, "mail-thread-info");
+	if (!message) {
+		purple_notify_emails(js->gc, count, FALSE, NULL, NULL, default_tos, NULL, NULL, NULL);
+		g_free(default_tos[0]);
+		return;
+	}
 
 	/* Loop once to see how many messages were returned so we can allocate arrays
 	 * accordingly */
-	if (!message)
-		return;
 	for (returned_count = 0; message; returned_count++, message=xmlnode_get_next_twin(message));
 
 	froms    = g_new0(const char* , returned_count);
@@ -115,9 +127,13 @@
 	if (i>0)
 		purple_notify_emails(js->gc, count, count == i, (const char**) subjects, froms, tos,
 				urls, NULL, NULL);
+	else 
+		purple_notify_emails(js->gc, count, FALSE, NULL, NULL, default_tos, NULL, NULL, NULL);
+
 
 	g_free(to_name);
 	g_free(tos);
+	g_free(default_tos[0]);
 	g_free(froms);
 	for (; i > 0; i--)
 		g_free(subjects[i - 1]);