Ticket #883 (closed defect: fixed)

Opened 5 years ago

Last modified 23 months ago

Google E-Mail Notification

Reported by: knuckles@… Owned by: nk
Priority: highest Milestone: 0.6
Component: None Version: 0.4
Severity: trivial Keywords:
Cc: dakilla@… Blocked By:
OS: Blocking:

Description

I was just running gajim --verbose and noticed that the google server sends a notification of new e-mail on the gmail account.

It would be nice to have a popup or a server message window warning that there is new mail.

This is what the google server sends:

DEBUG: socket       got   <iq to="knuckles@gmail.com/SuSE/GajimEC8801FB" id="2F5723BB" type="set"><new-mail xmlns="google:mail:notify"/></iq>
DEBUG: dispatcher   ok    Got iq stanza
DEBUG: dispatcher   ok    Dispatching iq stanza with type->set props->[u'google:mail:notify'] id->2F5723BB

And currently, gajim is "trying" to answer like this:

DEBUG: socket       sent  <iq to="knuckles@gmail.com/SuSE/GajimEC8801FB" type="error" id="2F5723BB" from="knuckles@gmail.com/SuSE/GajimEC8801FB"><new-mail xmlns="google:mail:notify" /><error code="501" type="cancel"><feature-not-implemented xmlns="urn:ietf:params:xml:ns:xmpp-stanzas" /><text xmlns="urn:ietf:params:xml:ns:xmpp-stanzas">The feature requested is not implemented by the recipient or server and therefore cannot be processed.</text></error></iq>
DEBUG: socket       got   <iq to="knuckles@gmail.com/SuSE/GajimEC8801FB" type="error" id="2F5723BB" from="knuckles@gmail.com/SuSE/GajimEC8801FB"><new-mail xmlns="google:mail:notify"/><error code="501" type="cancel"><feature-not-implemented xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/><text xmlns="urn:ietf:params:xml:ns:xmpp-stanzas">The feature requested is not implemented by the recipient or server and therefore cannot be processed.</text></error></iq>
DEBUG: dispatcher   ok    Got iq stanza
DEBUG: dispatcher   ok    Dispatching iq stanza with type->error props->[u'google:mail:notify', u'jabber:client'] id->2F5723BB

Attachments

gmail.svg (10.8 KB) - added by knuckles@… 5 years ago.
My crappy attempt at a gmail icon for dbus notifications. (svg)
gmail.png (6.8 KB) - added by nk 5 years ago.
gtalk.png (5.2 KB) - added by nk 5 years ago.
new_gmail_v3.patch (5.5 KB) - added by knuckles@… 5 years ago.
new_gmail_v4.patch (7.1 KB) - added by knuckles@… 5 years ago.
latest latest version
new_gmail_v5.patch (7.1 KB) - added by knuckles@… 5 years ago.
latest latest latest version

Change History

Changed 5 years ago by nk

  • owner changed from asterix to nk

Changed 5 years ago by nk

  • priority changed from normal to low
  • component changed from xmpppy to dialogs

do you still get it? I use GTalk and I do not see it now that I test

Changed 5 years ago by knuckles@…

Yeah, I asked a friend to e-mail me just now and i'm still getting it. (Same format as before, too.)

Changed 5 years ago by nk

ok so that is sent once a new mail arrives.. so I just show waht?

"You just received a new e-mail message?" in popupnotification (bottom right of screen?)

we can also use libgmail to facilitate GMail Support.. :)

Changed 5 years ago by knuckles@…

Yeah, I think that would be nice, maybe add the account too, in case the user has more than one google talk accounts on, "You have new e-mail on knuckles@…" (and maybe offer a link for gmail.google.com)?

Of course, using libgmail to add even more things would be extra nice.

Changed 5 years ago by nk

you get the notify thing when you have no unread messages and you get a new message?

I cannot get this stanza :|

moreover libgmail does not login (tried normal and cvs) at least for me! :%:

Changed 5 years ago by knuckles@…

I've been testing, and I think you only get this stanza when you're online on google talk and a new e-mail on gmail arrives. Also, it sends a new e-mail warning for each new e-mail you get (not counting the ones you got from before). And you can get it if you have both some unread messages and no unread messages.

Changed 5 years ago by nk

ok I've got sth:

I SEND:
<iq type="get" id="13"><query xmlns="google:mail:notify"/></iq>

I RECV
<iq to="kourem@gmail.com/Gajim37869D60" id="13" type="result"><mailbox total-matched="4" result-time="1126472143832" xmlns="google:mail:notify"><mail-thread-info tid="1181191525400083174" participation="0" messages="1" date="1126472020727"><senders><sender address="trac@gajim.org" name="Gajim" originator="1" unread="1"/></senders><labels>^all|^i|^u|Gajim devel</labels><subject>[Trac_gajim] Re: [Gajim] #851: When entering Japanese text the "enter" key doesn't work properly</subject><snippet>851: When entering Japanese text the "enter" key doesn't work properly …</snippet></mail-thread-info><mail-thread-info tid="1181190304295089029" participation="0" messages="1" date="1126470855872"><senders><sender address="trac@gajim.org" name="Gajim" originator="1" unread="1"/></senders><labels>^all|^i|^u|Gajim devel</labels><subject>[Trac_gajim] [Gajim] #909: Feature request: console beep on event</subject><snippet>909: Feature request: console beep on event …</snippet></mail-thread-info><mail-thread-info tid="1181190247785326045" participation="0" messages="1" date="1126470802163"><senders><sender address="nk@gajim.org" originator="1" unread="1"/></senders><labels>^all|^i|^u|Gajim devel</labels><subject>[commit-gajim] [995545f0ad7e52065e575edf6727701645bd196d] - trunk/src/common</subject><snippet>Author: nk Date: 2005-09-11 22:33:10 +0200 (Sun, 11 Sep 2005) New Revision: 3602 Modified: trunk …</snippet></mail-thread-info><mail-thread-info tid="1181185848912588365" participation="2" messages="1" date="1126466606723"><senders><sender address="enaskitis@hotmail.com" originator="1" unread="1"/></senders><labels>^all|^i|^u</labels><subject>NYTimes.com: Japan's Rivalry With China Is Stirring a Crowded Sea</subject><snippet>The New York Times E-mail This This page was sent to you by: AAAAAAAAAAAA@AAAAAAAAAAAA INTERNATIONAL …</snippet></mail-thread-info></mailbox></iq>

Changed 5 years ago by nicfit

  • cc travis@… added

Changed 5 years ago by knuckles@…

  • version changed from 0.8.1 to svn

I've been working on a simple notification for this, but i'm doing something wrong because altough gajim shows the notification, it still sends back the error saying the iq is not supported like this:

DEBUG: socket       got   <iq to="knuckles@gmail.com/SuSE/Gajim135EA8A0" id="9323E53B" type="set"><new-mail xmlns="google:mail:notify"/></iq>
DEBUG: dispatcher   ok    Got iq stanza
DEBUG: dispatcher   ok    Dispatching iq stanza with type->set props->[u'google:mail:notify'] id->9323E53B
 !!! You got gmail !!!
DEBUG: socket       sent  <iq to="knuckles@gmail.com/SuSE/Gajim135EA8A0" type="error" id="9323E53B" from="knuckles@gmail.com/SuSE/Gajim135EA8A0"><new-mail xmlns="google:mail:notify" /><error code="501" type="cancel"><feature-not-implemented xmlns="urn:ietf:params:xml:ns:xmpp-stanzas" /><text xmlns="urn:ietf:params:xml:ns:xmpp-stanzas">The feature requested is not implemented by the recipient or server and therefore cannot be processed.</text></error></iq>
DEBUG: socket       got   <iq to="knuckles@gmail.com/SuSE/Gajim135EA8A0" type="error" id="9323E53B" from="knuckles@gmail.com/SuSE/Gajim135EA8A0"><new-mail xmlns="google:mail:notify"/><error code="501" type="cancel"><feature-not-implemented xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/><text xmlns="urn:ietf:params:xml:ns:xmpp-stanzas">The feature requested is not implemented by the recipient or server and therefore cannot be processed.</text></error></iq>
DEBUG: dispatcher   ok    Got iq stanza
DEBUG: dispatcher   ok    Dispatching iq stanza with type->error props->[u'google:mail:notify', u'jabber:client'] id->9323E53B

It's my first python patch, so it maybe rough, but I would appreciate some pointers. Also, the notification is added only to old-style dialogs, not dbus (I can add that too, but I can't get dbus-notification on my suse box to test it), and It doesn't respect the user options for notifications (because I don't use any of the other notifications, just this one).

Changed 5 years ago by knuckles@…

Ok, latest version of the patch, it now adds a setting in preferences/miscellaneous to activate/deactivate notifications, and no problems i think =).

Changed 5 years ago by asterix

  • status changed from new to closed
  • resolution set to fixed
  • milestone set to 0.10

Thx a lot, it's applied

Changed 5 years ago by nk

  • status changed from closed to reopened
  • resolution fixed deleted

this setting in UI should be only visible if a gmail account is listed in users' accounts and it should be in General tab

else it should be invisible as most don't use Gmail as their jabber server is super beta and sucks

Changed 5 years ago by asterix

move it to ACE ?

Changed 5 years ago by nk

yea, default to on, and for off move to ACE.

for GTalk it's super enough, as they still haven't fixed s2s.. [yeah yeah they will fix [by 2008 I guess..]]

Changed 5 years ago by asterix

  • status changed from reopened to closed
  • resolution set to fixed

Changed 5 years ago by nk

knuckles does it work there? it doesn't work here for sure ;) read my first comments

Changed 5 years ago by knuckles@…

Yeah, it works nicely.

Maybe it's because of this (from the link you posted):

Google’s proprietary settings:

<iq type=“set” to=“nikolas.coukouma@gmail.com” id=“8”>
  <usersetting xmlns=“google:setting”>
    <autoacceptsuggestions value=“true”/>
    <autoacceptrequests value=“false”/>
    <mailnotifications value=“true”/>
  </usersetting>
</iq>

Maybe you have them disabled?

Changed 5 years ago by anonymous

Not working :(

I've tried playing with XML console, but:

<iq type=“set” to=“dakilla@…” id=“8”>

<usersetting xmlns=“ google:setting”>

<autoacceptsuggestions value=“true”/> <autoacceptrequests value=“false”/> <mailnotifications value=“true”/>

</usersetting>

</iq>

<stream:error> <invalid-xml xmlns="urn:ietf:params:xml:ns:xmpp-streams"/> </stream:error>

Changed 5 years ago by nk

  • status changed from closed to reopened
  • resolution fixed deleted

as I said again in my prev comment:

<iq type="get" id="13">
<query xmlns="google:mail:notify"/>
</iq>

replies, but even with this patch in, that is not catched. I reopen

Changed 5 years ago by knuckles@…

Try going to some windows computer and using the official google talk client to set the settings.

Also, nk, it's a different answer. When sending

<iq type="get" id="13">
<query xmlns="google:mail:notify"/>
</iq>

I get:

<iq to="knuckles@gmail.com/SuSE/Gajim5BA74086" id="13" type="result">
<mailbox total-matched="0" result-time="1137059328907" xmlns="google:mail:notify"/>
</iq>

And, my patch isn't for mailbox iq. My patch is for the simpler iq they send, the new-mail one:

<iq to="knuckles@gmail.com/SuSE/GajimEC8801FB" id="2F5723BB" type="set">
<new-mail xmlns="google:mail:notify"/></iq>

Changed 5 years ago by nk

use Gtalk client once, should not be needed. I bet they send an XML, we can do that too. are you on that?

Changed 5 years ago by knuckles@…

I think I can write a patch for mailbox iq too, it shouldn't be too hard (as it would just use most of the code of the new-mail patch).

As for what they send, I'll try to find out how to turn it on.

Changed 5 years ago by knuckles@…

My crappy attempt at a gmail icon for dbus notifications. (svg)

Changed 5 years ago by knuckles@…

Ok, so I'm beggining to understand a little better the inner workings on gajim, so I developed a new patch that processes the mailbox stuff and notifies the user how many new messages he has, and modified the new-mail code to send <iq type="get" id="13"><query xmlns=" google:mail:notify"/></iq> to the server, instead of notifying the user directly.

Also added a crappy icon, more like placeholder for something better.

I'll try playing with the stuff for enabling notifications next.

Changed 5 years ago by nk

Changed 5 years ago by nk

Changed 5 years ago by nk

have a look. I edited both from official logos

Changed 5 years ago by knuckles@…

Yeah, those are better, but aren't they copyrighted n stuff?

Well, It seems that I'm no longer getting the notifications too. Tried the gtalk client on another pc, and that worked, so don't know. But 'manually' asking for the info works. I stopped getting them after I started sending fake iq's to myself to test the notifications, so, maybe the server didn't like that I did that. Really strange...

Btw, does the mailbox stuff work for you now?

Changed 5 years ago by nk

what does Gtalk client send that we cannot send.

this shows why Google does not play fair. they have this feature and they do not open it, so we have to smell our figners as we say in Greece to find out wtf is going on.

I'm a bit mad now to think about their "copyright" and I can make a rectangle and a red M and that can't be copyrighted else I copyright the word copyright..

Changed 5 years ago by nk

as for the new patch, I have some quetions

that auto notify thing that you get is when you have new mails and since your patch does not enable that thing (perhaps Google knows how), but if it doesn't you should ask manually but I guess you only ask once? you should ask every 20 minutes (configurable via ACE) use gtk's timeout_add

another comment I have is about the way you do strings:

927 if msg_type == '1': 928 txt = _('You have 1 new E-mail message on %s.') % (jid) 929 else: 930 txt = _('You have %s new E-mail messages on %s.') % (msg_type, jid)

read  http://trac.gajim.org/wiki/CodingStandards especially rule 10 (notice the use of ngettext)

thanks

Changed 5 years ago by nk

if I manually send <iq type="get" id="13"><query xmlns=" google:mail:notify"/></iq>

I get a popup with very basic text (needs work) and if I click it it should open at least gmail.com (preferrably, do the login and all as the click in firefox's gmail notifier) and end up with inbox in <2 secs.

what is more, I clicked it and I now have a FOO (from FOO@…) contact in my roster.

last but not least, I get New E-mail title and message says:

You ahve 2 emails.. so one or two or three or four :D

I installed official gmail notifier to check how it's done. and I notice they also find my 2 messages and they do:

ICON in the left and in the right text:

1 of 2 - TIME_OF_MSG_ARRIVAL <BOLD>NAME_OF_THREAD (f.e. Yann, me, Travis etc..)</BOLD> (no of unread messages in thread) [max one line [I guess]]
<BOLD>SUBJECT</BOLD> (up to 2 lines)
<ITALIC>START OF MSG BODY</ITALIC> (with dots in the end, max one line [I guess])

and once I have the first window about one unread thread I get to wait 3 seconds and then it shows the second

their window design is perfect

their timing and such techniques are also nice as they use opacity and such neat stuff and they have matured to that auto slideshow thing (they used to have arrows). this is okay for them as you can right click and click Tell me again (and the slide show starts again)

what is more, you have to "Check Mail Now" to get the new message, which means they do the checking every FOO minutes and those minutes are not configured (I guess 20 mins or 15 mins make sense)

also worth to note, is that those windows are not clickable, but you can double click their trayicon to open the inbox (no user pass is asked in the browser) [to achieve this I guess we need to look the code of libgmail.sf.net or firefox's gmail notifier extension which is FLOSS]

I hope I gave most info needed for you. Good Luck!

Changed 5 years ago by nk

and they get that "new mail arrived" and popup immidiatelly, so ask google how to enable that too in xmpp this time :)

Changed 5 years ago by knuckles@…

I didn't understand how to use ngettext in this particular case. In a string like the example:

s = i18n.ngettext('You have %d message', 'You have %d messages', msgs, 'one', 'many') # use ngettext() and use %d not %s for intvars

, you only want to replace one thing. But what about in my case, that I want to replace three things? How do I do that with ngettext?

last but not least, I get New E-mail title and message says: You ahve 2 emails.. so one or two or three or four :D

What would you call it then? It's true, you do have "New E-Mail", and the description specifies how many. It wouldn't make sense if the tile was "2 new e-mail messages" and the description was "you have 2 new e-mail messages", that's kind of redundant. Look at all other notifications. They are general. "New Private Message, Contact Signed In, ... New E-Mail". I think it makes perfect sense.

As for all that notification and extra stuff, it would be very nice and etc, but I simply don't have the know-how and skills for any of that. This is my first gajim patch and first time using python. So I did what I could.

Changed 5 years ago by asterix

Nikos, I don't understand what you say. what knuckles did (correct me if I'm wrong) is: when we get the notification of a new mail, we ask gmail how many new mail we have, and when we get the answerm we show "X new mail" and I think it's good. Now about the 20 minutes thing, is it really usefull ? We show the number of new mail each time we get a new mail, so no need to ask betwen 2 new mail, the number won't change if we don't get new mail.

About the login thing, we're not Gmail client, so maybe on click open gmail.com is enough. Firefox can save login / pass so that user just have to press ok.

Changed 5 years ago by nk

ngettext() should be used because some langs (more than you imagine) have many plural forms and only ngettext is detected to hold such stuff

no_of_messages = int(msg_type)
txt = i18n.ngettext('You have %d new E-mail message.', 'You have %d new E-mail messages.', no_of_messages, no_of_messages, no_of_messages)

if you also need on jid replace that before passing to ngettext or use gettext' ngettext

about the rest you say, if you don't want to do more, then just follow the paradeigm correctly.

New Private Message is ONE event

New E-mail cna be more, so say sth like: New E-mail if *1* else New E-mails or just New E-mail(s) [a bit bad and lazy]

Yann, I agree on all, but on the basic idea you're wrong.

he sends (once): "HOW MANY" he gets (once): "you have 2 blablalblab"

he used to in the first patch just catch the notification which is better and SIMPLER but he did not find the way to say to GTalk server that "hey you f*cking propriatery server with undocumented features, I want this and that"

My guess was GTalk special XML or sth, and it's what I've asked from the patcher to find out.

Changed 5 years ago by nk

to keep "on jid" after that above code you do:

text = _('%(new_mail_gajim_ui_msg) on %(jid)') % {'new_mail_gajim_ui_msg': text, 'jid': jid}

Changed 5 years ago by knuckles@…

Ok, so I now use ngettext.

Changed 5 years ago by nk

ok nice work but I'm very sad to see that you did't just copy paste what I said and that you reduced it to:

txt = _('%s on %s.') % (txt, jid)

Gajim translators will not like you

Changed 5 years ago by nk

so you still ask server on messages, this should be done once on gajim startup.

then we should listen to the notification which server sends to Gtalk client but not to us and we should find out why.

I found this patch:  http://saaplugin.no-ip.info/jabber/jgmail.patch in  http://forums.miranda-im.org/showthread.php?t=5730

which even does the mail signin as far as I can see

he has both inboxrequest and enable notify where one reads:

void JabberEnableNotifications(ThreadData *info){
	if(CallService(MS_POPUP_QUERY, PUQS_GETSTATUS, 0)){//will enable notifications only if we have popups
		JabberSend( info->s, "<iq type='set' to='%s@%s' id='EnMailNotify'><usersetting xmlns='google:setting'><mailnotifications value='true'/></usersetting></iq>", info->username, info->server );
	}
}

I guess we now know what we should also send during the mailbox request.

that patch there adds:

+void JabberIqResultMailNotify( XmlNode *iqNode, void *userdata );
+void JabberRequestMailBox(HANDLE hConn);
+void JabberEnableNotifications(ThreadData *info);

have a look.

FWIW, that was the first result in Google search with query gtalk mail notification

Changed 5 years ago by knuckles@…

I used

txt = _('%s on %s.') % (txt, jid)

because when I used what you suggested, I got a TB saying he wanted an integer or something like that. I couldn't solve the problem, so modified that.

I didn't understand that you didn't like the way I reworked it, but I think it's better this way, because when you get new e-mail, google doesn't really specify how many. So, if you get 10 e-mails in a short timespan, google sends out just one notification. So, this new patch really asks the server *how many*. Don't you agree? Or should I change it back? I think this way is more useful.

Also, I tried the iq from that patch, and although the server answers, I still don't get notifications. Did you get any luck?

Changed 5 years ago by nk

text = _('%(new_mail_gajim_ui_msg)s on %(gmail_mail_address)s') % {'new_mail_gajim_ui_msg': text, 'gmail_mail_address': jid}

is the one.

no I like that you request mailbox. the thing is that you do once, but you should do everytime you get notify.

on click we should open:  http://www.google.com/accounts/ServiceLoginAuth?service=mail&Email=<username>&Pas swd=<password>&continue= https://mail.google.com/mail

we have a launch_browser_mail helpers.py method you can call

about sending xml to enable notifications, yes eventhough jabber server replies I get no notifications. I may miss sth, I will try contacting that Miranda guy who himself doesn't appear sure either but maybe now he knows.

<iq type='set' to='IROCK@gmail.com' id='MailNotify'>
 <usersetting xmlns='google:setting'>
  <mailnotifications value='true'/>
 </usersetting>
</iq>

<iq to="IROCK@gmail.com/Gajim8AC2E630" from="IROCK@gmail.com" id="MailNotify" type="result"/>

Changed 5 years ago by knuckles@…

Yeah, that's the same answer I get from the server, and still no luck.

Ok, new version of the patch, hope this time the text stuff is solved, and now when you click the notification, browser opened in gmail.

Changed 5 years ago by knuckles@…

Changed 5 years ago by nicfit

  • cc travis@… removed

Changed 5 years ago by nk

self.msg_type = msg_type = 'gmail'

why??

I commit this patch as is but I leave it open so the notify thing and the above are fixed

Changed 5 years ago by knuckles@…

That's because I kinda hack that and use the msg_type field to carry the # of new messages, instead of adding yet another parameter to all the functions called, and after I get the # of messages I set it right (so it can be detected when the popup is clicked). Do you want me to add a new parameter to the functions instead to carry that?

Changed 5 years ago by nk

do it 'gmail_new_mails' add a comment to say about it and eliminate the self.msg_type = msg_type and decide local or member var you will use.

alternatively add another param so it's not hacky at all and it's a great patch. so I don't commit. I wait :)

Changed 5 years ago by anonymous

  • cc dakilla@… added

Changed 5 years ago by knuckles@…

Ok I added another param, hope it's all ok now and not hacky =)

Changed 5 years ago by knuckles@…

latest latest version

Changed 5 years ago by nk

fails against latest trunk

I will commit this when it's okay but won't close this ticket until we have new on how to enable gmail:notify

Changed 5 years ago by knuckles@…

Ok, now it applies correctly, and also solved a bug with clicking the box (had forgot to set msgtype after removing my hack). Tested OK with dbus-notifications too.

Changed 5 years ago by knuckles@…

latest latest latest version

Changed 5 years ago by nk

ok good work. I commit *BUT* I still have to manually send:

<iq type="get" id="13"><query xmlns="google:mail:notify"/></iq>

this either should be done every 20 secs or we should find the way to enable those by default..

Changed 5 years ago by nk

hmm /me gets crazy..

now after I manually sent once the above. I get:

<iq to="kourem@…/Gajim9CD72AB2" id="D598D9F9" type="set"> <new-mail xmlns=" google:mail:notify"/> </iq>

<iq type="get" id="13"> <query xmlns=" google:mail:notify" /> </iq> and all works okay.. strange stuff

knuckles what do you think?

Changed 5 years ago by knuckles@…

  • status changed from reopened to closed
  • resolution set to fixed

Ok, latest patch asks server for notifications on startup, and also asks how many messages, and it's commited so ... bye and thanks for watching ;)

Add/Change #883 (Google E-Mail Notification)

Author


E-mail address and user name can be saved in the Preferences.


Change Properties
<Author field>
Action
as closed
The resolution will be deleted. Next status will be 'reopened'
Next status will be 'needinfo'
 
Note: See TracTickets for help on using tickets.