[Knuckles] Google E-Mail Notification

This commit is contained in:
Yann Leboulanger 2006-01-07 10:56:31 +00:00
parent aad4e2cd71
commit 4dc704c399
8 changed files with 54 additions and 0 deletions

View File

@ -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?')],

View File

@ -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)

View File

@ -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

View File

@ -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)

View File

@ -909,6 +909,12 @@ class PopupNotificationWindow:
else:
txt = ''
event_description_label.set_markup('<span foreground="black">%s</span>' % 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('<span foreground="black">%s</span>' % 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

View File

@ -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,

View File

@ -6172,6 +6172,26 @@ Custom</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="notify_gmail_checkbutton">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Notify on new _Gmail e-mail (GoogleTalk users)</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="active">False</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="on_notify_gmail_checkbutton_toggled" last_modification_time="Wed, 06 Apr 2005 14:43:56 GMT"/>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
</widget>
</child>
</widget>

View File

@ -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