Email notifications not working in Gmail. Fix added

Hi!

Email notifications from gmail were not working for me. I’ve tried this and then it works. Were they working for you before?

In http://code.google.com/apis/talk/jep_extensions/gmail.html#requestmail it says that to ask for email notifications you have to send something like:

<iq type=‘get’

to=‘romeo@gmail.com’ >… </iq>

But you send:

<iq type=‘get’

to=‘romeo’ >…</iq>

I’ve tried this fix and then they work. Were they working for you before?

=== modified file 'src/java/org/jivesoftware/openfire/gateway/protocols/xmpp/XMPPSession.java' *** src/java/org/jivesoftware/openfire/gateway/protocols/xmpp/XMPPSession.java  2007-09-16 04:41:09 +0000
+++ src/java/org/jivesoftware/openfire/gateway/protocols/xmpp/XMPPSession.java  2007-09-17 15:17:46 +0000
@@ -153,10 +153,19 @@
syncUsers(); if (getTransport().getType().equals(TransportType.gtalk) && JiveGlobals.getBooleanProperty("plugin.gateway.gtalk.mailnotifications", true)) {
* conn.sendPacket(new IQWithPacketExtension(getRegistration().getUsername(), new GoogleUserSettingExtension(false, true, false), IQ.Type.SET));
* conn.sendPacket(new IQWithPacketExtension(getRegistration().getUsername(), new GoogleRelayExtension()));
* conn.sendPacket(new IQWithPacketExtension(getRegistration().getUsername(), new GoogleMailNotifyExtension()));
* conn.sendPacket(new IQWithPacketExtension(getRegistration().getUsername(), new GoogleSharedStatusExtension()));
+
+                                String username_for_google = registration.getUsername();
+                                // In <iq> [http://code.google.com/apis/talk/jep_extensions/gmail.html#requestmail]
+                                // says that you have to use the full jid:
+                                // <iq type='get' to='romeo@gmail.com' >... </iq>
+                                if (registration.getUsername().indexOf("@") < 0 ) {
+                                    username_for_google = username_for_google + "@gmail.com";
+                                }
+
+                                conn.sendPacket(new IQWithPacketExtension(username_for_google, new GoogleUserSettingExtension(false, true, false), IQ.Type.SET));
+                                conn.sendPacket(new IQWithPacketExtension(username_for_google, new GoogleRelayExtension()));
+                                conn.sendPacket(new IQWithPacketExtension(username_for_google, new GoogleMailNotifyExtension()));
+                                conn.sendPacket(new IQWithPacketExtension(username_for_google, new GoogleSharedStatusExtension()));
mailCheck = new MailCheck();
timer.schedule(mailCheck, timerInterval, timerInterval);
}
@@ -403,10 +412,17 @@
*/ public void run() {
if (getTransport().getType().equals(TransportType.gtalk) && JiveGlobals.getBooleanProperty("plugin.gateway.gtalk.mailnotifications", true)) {
+                String username_for_google = registration.getUsername();
+                // In <iq> [http://code.google.com/apis/talk/jep_extensions/gmail.html#requestmail]
+                // says that you have to use the full jid:
+                // <iq type='get' to='romeo@gmail.com' >... </iq>
+                if (registration.getUsername().indexOf("@") < 0 ) {
+                    username_for_google = username_for_google + "@gmail.com";
+                }
GoogleMailNotifyExtension gmne = new GoogleMailNotifyExtension();
gmne.setNewerThanTime(listener.getLastGMailThreadDate());
gmne.setNewerThanTid(listener.getLastGMailThreadId());
* conn.sendPacket(new IQWithPacketExtension(getRegistration().getUsername(), gmne)); +                conn.sendPacket(new IQWithPacketExtension(username_for_google, gmne));
}
}
}

UPDATE: I’ve updated the format as suggested, with . Thanks!!

Hi!

Probably i am too dumb to use this. How can i post a patch here? I have seen some patches other times.

Thanks!!

I don’t really know how to post a patch, and yes, the notifications were working fine for me before. (except that I wasn’t able to do them the way I really wanted, perhaps what you found is -why- I couldn’t do it the way I wanted) Though I watched the XML traffic and never saw “just the username” like you are seeing. Hrm. Either way, maybe email the patch to me?

Hi,

you could use the here comes the code tags (without spaces between ‘{’ and ‘}’ if you want to post the patch more readable.

Some more or less known users have the right to create attachments, but if they abuse this feature it will be removed. New users will likely never have this right unless they work for Jivesoftware.

LG