[bluegray] extra gmail info (from field) in popup notification. Fixes #1982

This commit is contained in:
Yann Leboulanger 2006-07-02 18:39:43 +00:00
parent 169a69cca9
commit 88cf8b5c84
5 changed files with 40 additions and 4 deletions

View File

@ -125,6 +125,7 @@ class Config:
'after_nickname': [ opt_str, ':' ],
'send_os_info': [ opt_bool, True ],
'notify_on_new_gmail_email': [ opt_bool, True ],
'notify_on_new_gmail_email_extra': [ opt_bool, False ],
'usegpg': [ opt_bool, False, '', True ],
'use_gpg_agent': [ opt_bool, False ],
'change_roster_title': [ opt_bool, True, _('Add * and [n] in roster title?')],

View File

@ -1237,9 +1237,20 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco)
newmsgs = gm.getTag('mailbox').getAttr('total-matched')
if newmsgs != '0':
# there are new messages
gmail_messages_list = []
if gm.getTag('mailbox').getTag('mail-thread-info'):
gmail_messages = gm.getTag('mailbox').getTags('mail-thread-info')
for gmessage in gmail_messages:
gmail_from = gmessage.getTag('senders').getTag('sender').getAttr('address')
gmail_subject = gmessage.getTag('subject').getData()
gmail_snippet = gmessage.getTag('snippet').getData()
gmail_messages_list.append({ \
'From': gmail_from, \
'Subject': gmail_subject, \
'Snippet': gmail_snippet})
jid = gajim.get_jid_from_account(self.name)
gajim.log.debug(('You have %s new gmail e-mails on %s.') % (newmsgs, jid))
self.dispatch('GMAIL_NOTIFY', (jid, newmsgs))
self.dispatch('GMAIL_NOTIFY', (jid, newmsgs, gmail_messages_list))
raise common.xmpp.NodeProcessed
def _messageCB(self, con, msg):
@ -1713,7 +1724,7 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco)
# If it's a gmail account,
# inform the server that we want e-mail notifications
if gajim.get_server_from_jid(our_jid) == 'gmail.com':
if gajim.get_server_from_jid(our_jid) in gajim.gmail_domains:
gajim.log.debug(('%s is a gmail account. Setting option '
'to get e-mail notifications on the server.') % (our_jid))
iq = common.xmpp.Iq(typ = 'set', to = our_jid)

View File

@ -81,6 +81,8 @@ if LANG is None:
else:
LANG = LANG[:2] # en, fr, el etc..
gmail_domains = ['gmail.com', 'googlemail.com']
last_message_time = {} # list of time of the latest incomming message
# {acct1: {jid1: time1, jid2: time2}, }
encrypted_chats = {} # list of encrypted chats {acct1: [jid1, jid2], ..}

View File

@ -435,17 +435,28 @@ class PreferencesWindow:
# Notify user of new gmail e-mail messages,
# only show checkbox if user has a gtalk account
gmail_options_label = self.xml.get_widget('gmail_options_label')
notify_gmail_checkbutton = self.xml.get_widget('notify_gmail_checkbutton')
notify_gmail_extra_checkbutton = self.xml.get_widget('notify_gmail_extra_checkbutton')
gmail_options_label.set_no_show_all(True)
notify_gmail_checkbutton.set_no_show_all(True)
notify_gmail_extra_checkbutton.set_no_show_all(True)
for account in gajim.config.get_per('accounts'):
jid = gajim.get_jid_from_account(account)
if gajim.get_server_from_jid(jid) == 'gmail.com':
if gajim.get_server_from_jid(jid) in gajim.gmail_domains:
gmail_options_label.show()
st = gajim.config.get('notify_on_new_gmail_email')
notify_gmail_checkbutton.set_active(st)
notify_gmail_checkbutton.show()
st = gajim.config.get('notify_on_new_gmail_email_extra')
notify_gmail_extra_checkbutton.set_active(st)
notify_gmail_extra_checkbutton.show()
break
else:
gmail_options_label.hide()
notify_gmail_checkbutton.hide()
notify_gmail_extra_checkbutton.hide()
self.xml.signal_autoconnect(self)
@ -841,8 +852,11 @@ 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):
def on_notify_gmail_checkbutton_toggled(self, widget):
self.on_checkbutton_toggled(widget, 'notify_on_new_gmail_email')
def on_notify_gmail_extra_checkbutton_toggled(self, widget):
self.on_checkbutton_toggled(widget, 'notify_on_new_gmail_email_extra')
def fill_msg_treeview(self):
self.xml.get_widget('delete_msg_button').set_sensitive(False)

View File

@ -1026,12 +1026,20 @@ class Interface:
def handle_event_gmail_notify(self, account, array):
jid = array[0]
gmail_new_messages = int(array[1])
gmail_messages_list = array[2]
if gajim.config.get('notify_on_new_gmail_email'):
img = os.path.join(gajim.DATA_DIR, 'pixmaps', 'events',
'single_msg_recv.png') #FIXME: find a better image
title = _('New E-mail on %(gmail_mail_address)s') % \
{'gmail_mail_address': jid}
text = i18n.ngettext('You have %d new E-mail message', 'You have %d new E-mail messages', gmail_new_messages, gmail_new_messages, gmail_new_messages)
if gajim.config.get('notify_on_new_gmail_email_extra'):
for gmessage in gmail_messages_list:
# each message has a 'From', 'Subject' and 'Snippet' field
text += _('\nFrom: %(from_address)s') % \
{'from_address': gmessage['From']}
path = gtkgui_helpers.get_path_to_generic_or_avatar(img)
notify.popup(_('New E-mail'), jid, account, 'gmail',
path_to_image = path, title = title, text = text)