diff --git a/src/common/config.py b/src/common/config.py
index 5a72d14fb..5dd1e3f95 100644
--- a/src/common/config.py
+++ b/src/common/config.py
@@ -120,6 +120,7 @@ class Config:
'before_nickname': [ opt_str, '' ],
'after_nickname': [ opt_str, ':' ],
'send_os_info': [ opt_bool, True ],
+ 'notify_on_new_gmail_email': [ opt_bool, True ],
'usegpg': [ opt_bool, False ],
'use_gpg_agent': [ opt_bool, False ],
'change_roster_title': [ opt_bool, True, _('Add * and [n] in roster title?')],
diff --git a/src/common/connection.py b/src/common/connection.py
index 3f4840798..819c1ff53 100644
--- a/src/common/connection.py
+++ b/src/common/connection.py
@@ -316,6 +316,15 @@ class Connection:
else:
self.dispatch('VCARD', vcard)
+ def _gMailCB(self, con, gm):
+ """Called when we get notified of new mail messages in gmail account"""
+ if not gm.getTag('new-mail'):
+ return
+ if gm.getTag('new-mail').getNamespace() == common.xmpp.NS_GMAILNOTIFY:
+ jid = gajim.get_jid_from_account(self.name)
+ gajim.log.debug(('Notifying user of new gmail e-mail on %s.') % (jid))
+ self.dispatch('GMAIL_NOTIFY', jid)
+ raise common.xmpp.NodeProcessed
def _messageCB(self, con, msg):
"""Called when we receive a message"""
@@ -1706,6 +1715,8 @@ class Connection:
common.xmpp.NS_PRIVATE)
con.RegisterHandler('iq', self._HttpAuthCB, 'get',
common.xmpp.NS_HTTP_AUTH)
+ con.RegisterHandler('iq', self._gMailCB, 'set',
+ common.xmpp.NS_GMAILNOTIFY)
con.RegisterHandler('iq', self._ErrorCB, 'error')
con.RegisterHandler('iq', self._IqCB)
con.RegisterHandler('iq', self._StanzaArrivedCB)
diff --git a/src/common/xmpp/protocol.py b/src/common/xmpp/protocol.py
index bfe05b9d6..9d90fc6d9 100644
--- a/src/common/xmpp/protocol.py
+++ b/src/common/xmpp/protocol.py
@@ -63,6 +63,7 @@ NS_TIME ='jabber:iq:time'
NS_TLS ='urn:ietf:params:xml:ns:xmpp-tls'
NS_VACATION ='http://jabber.org/protocol/vacation'
NS_VCARD ='vcard-temp'
+NS_GMAILNOTIFY ='google:mail:notify'
NS_VCARD_UPDATE =NS_VCARD+':x:update'
NS_VERSION ='jabber:iq:version'
NS_ENCRYPTED ='jabber:x:encrypted' # JEP-0027
diff --git a/src/config.py b/src/config.py
index c692b02a1..a1ab72d8f 100644
--- a/src/config.py
+++ b/src/config.py
@@ -408,6 +408,10 @@ class PreferencesWindow:
# send os info
st = gajim.config.get('send_os_info')
self.xml.get_widget('send_os_info_checkbutton').set_active(st)
+
+ # Notify user of new gmail e-mail messages
+ st = gajim.config.get('notify_on_new_gmail_email')
+ self.xml.get_widget('notify_gmail_checkbutton').set_active(st)
self.xml.signal_autoconnect(self)
@@ -890,6 +894,9 @@ class PreferencesWindow:
def on_send_os_info_checkbutton_toggled(self, widget):
self.on_checkbutton_toggled(widget, 'send_os_info')
+
+ def on_notify_gmail_checkbutton_toggled(self, widget):
+ self.on_checkbutton_toggled(widget, 'notify_on_new_gmail_email')
def fill_msg_treeview(self):
self.xml.get_widget('delete_msg_button').set_sensitive(False)
diff --git a/src/dialogs.py b/src/dialogs.py
index 508147585..f66bb865a 100644
--- a/src/dialogs.py
+++ b/src/dialogs.py
@@ -909,6 +909,12 @@ class PopupNotificationWindow:
else:
txt = ''
event_description_label.set_markup('%s' % txt)
+ elif event_type == _('New E-mail'):
+ dodgerblue = gtk.gdk.color_parse('dodgerblue')
+ close_button.modify_bg(gtk.STATE_NORMAL, dodgerblue)
+ eventbox.modify_bg(gtk.STATE_NORMAL, dodgerblue)
+ txt = _('You have new E-mail on %s.') % (jid)
+ event_description_label.set_markup('%s' % txt)
# position the window to bottom-right of screen
window_width, self.window_height = self.window.get_size()
gajim.interface.roster.popups_notification_height += self.window_height
diff --git a/src/gajim.py b/src/gajim.py
index eaa7c249d..c342ab08b 100755
--- a/src/gajim.py
+++ b/src/gajim.py
@@ -800,6 +800,10 @@ class Interface:
if gajim.show_notification(account):
notify.notify(_('File Transfer Error'),
jid, account, 'file-send-error', file_props)
+
+ def handle_event_gmail_notify(self, account, jid):
+ if gajim.config.get('notify_on_new_gmail_email'):
+ notify.notify(_('New E-mail'), jid, account)
def add_event(self, account, jid, typ, args):
'''add an event to the awaiting_events var'''
@@ -1191,6 +1195,7 @@ class Interface:
'BOOKMARKS': self.handle_event_bookmarks,
'CON_TYPE': self.handle_event_con_type,
'FILE_REQUEST': self.handle_event_file_request,
+ 'GMAIL_NOTIFY': self.handle_event_gmail_notify,
'FILE_REQUEST_ERROR': self.handle_event_file_request_error,
'FILE_SEND_ERROR': self.handle_event_file_send_error,
'STANZA_ARRIVED': self.handle_event_stanza_arrived,
diff --git a/src/gtkgui.glade b/src/gtkgui.glade
index f761441c4..e7a20e6de 100644
--- a/src/gtkgui.glade
+++ b/src/gtkgui.glade
@@ -6172,6 +6172,26 @@ Custom
False
+
+
+
+ True
+ True
+ Notify on new _Gmail e-mail (GoogleTalk users)
+ True
+ GTK_RELIEF_NORMAL
+ True
+ False
+ False
+ True
+
+
+
+ 0
+ False
+ False
+
+
diff --git a/src/notify.py b/src/notify.py
index 3cb8dd037..24564c399 100644
--- a/src/notify.py
+++ b/src/notify.py
@@ -197,6 +197,9 @@ class DesktopNotification:
img = 'ft_stopped.png'
else:
txt = ''
+ elif event_type == _('New Email'):
+ txt = _('You have new E-mail on %s.') % (jid)
+ ntype = 'gmail.notify'
else:
# defaul failsafe values
img = 'chat_msg_recv.png' # img to display