Ticket #883: new_gmail_v4.patch
| File new_gmail_v4.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 … … 195 195 else: 196 196 txt = '' 197 197 elif event_type == _('New E-mail'): 198 txt = _('You have new E-mail on %s.') % (jid) 198 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) 199 txt = _('%(new_mail_gajim_ui_msg)s on %(gmail_mail_address)s') % {'new_mail_gajim_ui_msg': text, 'gmail_mail_address': jid} 199 200 ntype = 'gmail.notify' 200 201 img = 'single_msg_recv.png' #FIXME: find a better image 201 202 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
864 864 notify.notify(_('File Transfer Error'), 865 865 jid, account, 'file-send-error', file_props) 866 866 867 def handle_event_gmail_notify(self, account, jid): 867 def handle_event_gmail_notify(self, account, array): 868 jid = array[0] 869 newmsgs = array[1] 868 870 if gajim.config.get('notify_on_new_gmail_email'): 869 notify.notify(_('New E-mail'), jid, account )871 notify.notify(_('New E-mail'), jid, account, gmail_new_messages = int(newmsgs)) 870 872 871 873 def add_event(self, account, jid, typ, args): 872 874 '''add an event to the awaiting_events var''' … … 1335 1337 ev = gajim.get_first_event(account, jid, typ) 1336 1338 # Open the window 1337 1339 self.roster.open_event(account, jid, ev) 1340 elif typ == message_control.TYPE_GMAIL: 1341 if gajim.config.get_per('accounts', account, 'savepass'): 1342 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')) 1343 else: 1344 url = ('http://mail.google.com/') 1345 helpers.launch_browser_mailer('url', url) 1338 1346 if w: 1339 1347 w.set_active_tab(jid) 1340 1348 w.window.present() -
src/common/connection.py
331 331 else: 332 332 self.dispatch('VCARD', vcard) 333 333 334 def _gMail CB(self, con, gm):334 def _gMailNewMailCB(self, con, gm): 335 335 """Called when we get notified of new mail messages in gmail account""" 336 336 if not gm.getTag('new-mail'): 337 337 return 338 338 if gm.getTag('new-mail').getNamespace() == common.xmpp.NS_GMAILNOTIFY: 339 # we'll now ask the server for the exact number of new messages 339 340 jid = gajim.get_jid_from_account(self.name) 340 gajim.log.debug(('Notifying user of new gmail e-mail on %s.') % (jid)) 341 self.dispatch('GMAIL_NOTIFY', jid) 341 gajim.log.debug(('Got notification of new gmail e-mail on %s. Asking the server for more info.') % (jid)) 342 iq = common.xmpp.Iq(typ = 'get') 343 iq.setAttr('id', '13') 344 query = iq.setTag('query') 345 query.setNamespace(common.xmpp.NS_GMAILNOTIFY) 346 self.to_be_sent.append(iq) 342 347 raise common.xmpp.NodeProcessed 348 349 def _gMailQueryCB(self, con, gm): 350 """Called when we receive results from Querying the server for mail messages in gmail account""" 351 if not gm.getTag('mailbox'): 352 return 353 if gm.getTag('mailbox').getNamespace() == common.xmpp.NS_GMAILNOTIFY: 354 newmsgs = gm.getTag('mailbox').getAttr('total-matched') 355 if newmsgs != '0': 356 # there are new messages 357 jid = gajim.get_jid_from_account(self.name) 358 gajim.log.debug(('User has %s new gmail e-mails on %s.') % (newmsgs, jid)) 359 self.dispatch('GMAIL_NOTIFY', (jid, newmsgs)) 360 raise common.xmpp.NodeProcessed 343 361 344 362 def _messageCB(self, con, msg): 345 363 """Called when we receive a message""" … … 1760 1778 common.xmpp.NS_PRIVATE) 1761 1779 con.RegisterHandler('iq', self._HttpAuthCB, 'get', 1762 1780 common.xmpp.NS_HTTP_AUTH) 1763 con.RegisterHandler('iq', self._gMail CB, 'set',1781 con.RegisterHandler('iq', self._gMailNewMailCB, 'set', 1764 1782 common.xmpp.NS_GMAILNOTIFY) 1783 con.RegisterHandler('iq', self._gMailQueryCB, 'result', 1784 common.xmpp.NS_GMAILNOTIFY) 1765 1785 con.RegisterHandler('iq', self._ErrorCB, 'error') 1766 1786 con.RegisterHandler('iq', self._IqCB) 1767 1787 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?
