Ticket #883: new_gmail_v5.patch
| File new_gmail_v5.patch, 7.1 KB (added by knuckles@…, 4 years ago) |
|---|
-
src/notify.py
48 48 import dbus.service 49 49 50 50 def notify(event_type, jid, account, msg_type = '', file_props = None, 51 path_to_image = None ):51 path_to_image = None, gmail_new_messages = None): 52 52 '''Notifies a user of an event. It first tries to a valid implementation of 53 53 the Desktop Notification Specification. If that fails, then we fall back to 54 54 the older style PopupNotificationWindow method.''' 55 55 if gajim.config.get('use_notif_daemon') and dbus_support.supported: 56 56 try: 57 57 DesktopNotification(event_type, jid, account, msg_type, file_props, 58 path_to_image )58 path_to_image, gmail_new_messages) 59 59 return 60 60 except dbus.dbus_bindings.DBusException, e: 61 61 # Connection to D-Bus failed, try popup … … 64 64 # This means that we sent the message incorrectly 65 65 gajim.log.debug(str(e)) 66 66 instance = dialogs.PopupNotificationWindow(event_type, jid, account, 67 msg_type, file_props )67 msg_type, file_props, gmail_new_messages) 68 68 gajim.interface.roster.popup_notification_windows.append(instance) 69 69 70 70 class NotificationResponseManager: … … 102 102 '''A DesktopNotification that interfaces with DBus via the Desktop 103 103 Notification specification''' 104 104 def __init__(self, event_type, jid, account, msg_type = '', 105 file_props = None, path_to_image = None ):105 file_props = None, path_to_image = None, gmail_new_messages = None): 106 106 self.account = account 107 107 self.jid = jid 108 108 self.msg_type = msg_type … … 197 197 else: 198 198 txt = '' 199 199 elif event_type == _('New E-mail'): 200 txt = _('You have new E-mail on %s.') % (jid) 200 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) 201 txt = _('%(new_mail_gajim_ui_msg)s on %(gmail_mail_address)s') % {'new_mail_gajim_ui_msg': text, 'gmail_mail_address': jid} 201 202 ntype = 'gmail.notify' 202 203 img = 'single_msg_recv.png' #FIXME: find a better image 203 204 else: -
src/dialogs.py
859 859 860 860 861 861 class PopupNotificationWindow: 862 def __init__(self, event_type, jid, account, msg_type = '', file_props = None ):862 def __init__(self, event_type, jid, account, msg_type = '', file_props = None, gmail_new_messages = None): 863 863 self.account = account 864 864 self.jid = jid 865 865 self.msg_type = msg_type … … 947 947 dodgerblue = gtk.gdk.color_parse('dodgerblue') 948 948 close_button.modify_bg(gtk.STATE_NORMAL, dodgerblue) 949 949 eventbox.modify_bg(gtk.STATE_NORMAL, dodgerblue) 950 txt = _('You have new E-mail on %s.') % (jid) 950 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) 951 txt = _('%(new_mail_gajim_ui_msg)s on %(gmail_mail_address)s') % {'new_mail_gajim_ui_msg': text, 'gmail_mail_address': jid} 951 952 event_description_label.set_markup('<span foreground="black">%s</span>' % txt) 952 953 # position the window to bottom-right of screen 953 954 window_width, self.window_height = self.window.get_size() -
src/gajim.py
834 834 notify.notify(_('File Transfer Error'), 835 835 jid, account, 'file-send-error', file_props) 836 836 837 def handle_event_gmail_notify(self, account, jid): 837 def handle_event_gmail_notify(self, account, array): 838 jid = array[0] 839 newmsgs = array[1] 838 840 if gajim.config.get('notify_on_new_gmail_email'): 839 notify.notify(_('New E-mail'), jid, account )841 notify.notify(_('New E-mail'), jid, account, 'gmail', gmail_new_messages = int(newmsgs)) 840 842 841 843 def save_avatar_files(self, jid, photo_decoded): 842 844 '''Save the decoded avatar to a separate file, and generate files for dbus notifications''' … … 1328 1330 ev = gajim.get_first_event(account, jid, typ) 1329 1331 # Open the window 1330 1332 self.roster.open_event(account, jid, ev) 1333 elif typ == message_control.TYPE_GMAIL: 1334 if gajim.config.get_per('accounts', account, 'savepass'): 1335 url = ('http://www.google.com/accounts/ServiceLoginAuth?service=mail&Email=%s&Passwd=%s&continue=https://mail.google.com/mail') % (gajim.config.get_per('accounts', account, 'name'),gajim.config.get_per('accounts', account, 'password')) 1336 else: 1337 url = ('http://mail.google.com/') 1338 helpers.launch_browser_mailer('url', url) 1331 1339 if w: 1332 1340 w.set_active_tab(jid) 1333 1341 w.window.present() -
src/common/connection.py
340 340 else: 341 341 self.dispatch('VCARD', vcard) 342 342 343 def _gMail CB(self, con, gm):343 def _gMailNewMailCB(self, con, gm): 344 344 """Called when we get notified of new mail messages in gmail account""" 345 345 if not gm.getTag('new-mail'): 346 346 return 347 347 if gm.getTag('new-mail').getNamespace() == common.xmpp.NS_GMAILNOTIFY: 348 # we'll now ask the server for the exact number of new messages 348 349 jid = gajim.get_jid_from_account(self.name) 349 gajim.log.debug(('Notifying user of new gmail e-mail on %s.') % (jid)) 350 self.dispatch('GMAIL_NOTIFY', jid) 350 gajim.log.debug(('Got notification of new gmail e-mail on %s. Asking the server for more info.') % (jid)) 351 iq = common.xmpp.Iq(typ = 'get') 352 iq.setAttr('id', '13') 353 query = iq.setTag('query') 354 query.setNamespace(common.xmpp.NS_GMAILNOTIFY) 355 self.to_be_sent.append(iq) 351 356 raise common.xmpp.NodeProcessed 357 358 def _gMailQueryCB(self, con, gm): 359 """Called when we receive results from Querying the server for mail messages in gmail account""" 360 if not gm.getTag('mailbox'): 361 return 362 if gm.getTag('mailbox').getNamespace() == common.xmpp.NS_GMAILNOTIFY: 363 newmsgs = gm.getTag('mailbox').getAttr('total-matched') 364 if newmsgs != '0': 365 # there are new messages 366 jid = gajim.get_jid_from_account(self.name) 367 gajim.log.debug(('User has %s new gmail e-mails on %s.') % (newmsgs, jid)) 368 self.dispatch('GMAIL_NOTIFY', (jid, newmsgs)) 369 raise common.xmpp.NodeProcessed 352 370 353 371 def _messageCB(self, con, msg): 354 372 """Called when we receive a message""" … … 1769 1787 common.xmpp.NS_PRIVATE) 1770 1788 con.RegisterHandler('iq', self._HttpAuthCB, 'get', 1771 1789 common.xmpp.NS_HTTP_AUTH) 1772 con.RegisterHandler('iq', self._gMail CB, 'set',1790 con.RegisterHandler('iq', self._gMailNewMailCB, 'set', 1773 1791 common.xmpp.NS_GMAILNOTIFY) 1792 con.RegisterHandler('iq', self._gMailQueryCB, 'result', 1793 common.xmpp.NS_GMAILNOTIFY) 1774 1794 con.RegisterHandler('iq', self._ErrorCB, 'error') 1775 1795 con.RegisterHandler('iq', self._IqCB) 1776 1796 con.RegisterHandler('iq', self._StanzaArrivedCB) -
src/message_control.py
24 24 TYPE_CHAT = 'chat' 25 25 TYPE_GC = 'gc' 26 26 TYPE_PM = 'pm' 27 TYPE_GMAIL = 'gmail' 27 28 28 29 #################### 29 30 # FIXME: Can't this stuff happen once?
