changeset 27253:beb33c984100

Fix Google Mail notifications when they inexplicably weren't working. Fixes #3300. I don't really know why this is a setting, given that the server can reasonably determine a client's interest based on an initial request at login (which is what the google:mail:notify doc still says). Moreover, they explicitly say clients shouldn't set this setting to false.
author Paul Aurich <paul@darkrain42.org>
date Thu, 02 Jul 2009 22:27:13 +0000
parents ea9df9bfa921
children 988e8ee76731 357405dc8b2c
files ChangeLog libpurple/protocols/jabber/google.c
diffstat 2 files changed, 18 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Thu Jul 02 22:03:21 2009 +0000
+++ b/ChangeLog	Thu Jul 02 22:27:13 2009 +0000
@@ -70,6 +70,8 @@
 	  characters.
 	* Show emblem for mobile, handheld, and web clients and bots (if the other
 	  client supports it).
+	* Google Talk mail notifications should now work for people for whom they
+	  inexplicably did not.  (Thanks to yukam for determining the reason)
 
 	Yahoo:
 	* P2P file transfers.  (Sulabh Mahajan)
--- a/libpurple/protocols/jabber/google.c	Thu Jul 02 22:03:21 2009 +0000
+++ b/libpurple/protocols/jabber/google.c	Thu Jul 02 22:27:13 2009 +0000
@@ -939,10 +939,25 @@
 
 void jabber_gmail_init(JabberStream *js) {
 	JabberIq *iq;
+	xmlnode *usersetting, *mailnotifications;
 
-	if (!purple_account_get_check_mail(js->gc->account))
+	if (!purple_account_get_check_mail(purple_connection_get_account(js->gc)))
 		return;
 
+	/*
+	 * Quoting http://code.google.com/apis/talk/jep_extensions/usersettings.html:
+	 * To ensure better compatibility with other clients, rather than
+	 * setting this value to "false" to turn off notifications, it is
+	 * recommended that a client set this to "true" and filter incoming
+	 * email notifications itself.
+	 */
+	iq = jabber_iq_new(js, JABBER_IQ_SET);
+	usersetting = xmlnode_new_child(iq->node, "usersetting");
+	xmlnode_set_namespace(usersetting, "google:setting");
+	mailnotifications = xmlnode_new_child(usersetting, "mailnotifications");
+	xmlnode_set_attrib(mailnotifications, "value", "true");
+	jabber_iq_send(iq);
+
 	iq = jabber_iq_new_query(js, JABBER_IQ_GET, "google:mail:notify");
 	jabber_iq_set_callback(iq, jabber_gmail_parse, NULL);
 	jabber_iq_send(iq);