~jtaylor/ubuntu/oneiric/gajim/multiple-CVE

« back to all changes in this revision

Viewing changes to src/notify.py

  • Committer: Bazaar Package Importer
  • Author(s): Nafallo Bjälevik
  • Date: 2008-12-17 12:08:19 UTC
  • mfrom: (1.1.11 upstream)
  • Revision ID: james.westby@ubuntu.com-20081217120819-20o3ibfc8fc1r1vk
Tags: 0.12-0ubuntu1
* New upstream release:
  + Fix text rendering in notifications
  + Better sessions support
  + Better auto-away support
  + Fix banshee support
  + Quodlibet support
  + Fix GSSAPI authentification
  + Those translations have been temporarily removed because they are outdated:
    Breton (br), Greek (el), Dutch (nl), Portugese (pt). 
* debian/control:
  - Added python-kerberos (>= 1.1) to Recommends for the GSSAPI auth.

Show diffs side-by-side

added added

removed removed

Lines of Context:
320
320
        '''Notifies a user of an event. It first tries to a valid implementation of
321
321
        the Desktop Notification Specification. If that fails, then we fall back to
322
322
        the older style PopupNotificationWindow method.'''
 
323
 
 
324
        # default image
 
325
        if not path_to_image:
 
326
                path_to_image = os.path.abspath(
 
327
                        os.path.join(gajim.DATA_DIR, 'pixmaps', 'events',
 
328
                                'chat_msg_recv.png')) # img to display
 
329
 
 
330
        # Try Growl first, as we might have D-Bus and notification daemon running
 
331
        # on OS X for some reason.
 
332
        if USER_HAS_GROWL:
 
333
                osx.growler.notify(event_type, jid, account, msg_type, path_to_image,
 
334
                        title, text)
 
335
                return
 
336
 
 
337
        # Try to show our popup via D-Bus and notification daemon
323
338
        if gajim.config.get('use_notif_daemon') and dbus_support.supported:
324
339
                try:
325
340
                        DesktopNotification(event_type, jid, account, msg_type,
326
 
                                path_to_image, title, text)
 
341
                                path_to_image, title, gobject.markup_escape_text(text))
327
342
                        return  # sucessfully did D-Bus Notification procedure!
328
343
                except dbus.DBusException, e:
329
344
                        # Connection to D-Bus failed
331
346
                except TypeError, e:
332
347
                        # This means that we sent the message incorrectly
333
348
                        gajim.log.debug(str(e))
334
 
        # we failed to speak to notification daemon via D-Bus
335
 
        if USER_HAS_PYNOTIFY: # try via libnotify
 
349
 
 
350
        # Ok, that failed. Let's try pynotify, which also uses notification daemon
 
351
        if gajim.config.get('use_notif_daemon') and USER_HAS_PYNOTIFY:
336
352
                if not text and event_type == 'new_message':
337
353
                        # empty text for new_message means do_preview = False
338
 
                        text = gajim.get_name_from_jid(account, jid) # default value of text
 
354
                        # -> default value for text
 
355
                        _text = gobject.markup_escape_text(
 
356
                                gajim.get_name_from_jid(account, jid))
 
357
                else:
 
358
                        _text = gobject.markup_escape_text(text)
 
359
 
339
360
                if not title:
340
 
                        title = event_type
341
 
                # default image
342
 
                if not path_to_image:
343
 
                        path_to_image = os.path.abspath(
344
 
                                os.path.join(gajim.DATA_DIR, 'pixmaps', 'events',
345
 
                                        'chat_msg_recv.png')) # img to display
346
 
 
347
 
 
348
 
                notification = pynotify.Notification(title, text)
 
361
                        _title = ''
 
362
                else:
 
363
                        _title = title
 
364
 
 
365
                notification = pynotify.Notification(_title, _text)
349
366
                timeout = gajim.config.get('notification_timeout') * 1000 # make it ms
350
367
                notification.set_timeout(timeout)
351
368
 
364
381
                except gobject.GError, e:
365
382
                        # Connection to notification-daemon failed, see #2893
366
383
                        gajim.log.debug(str(e))
367
 
        # try os/x growl
368
 
        if USER_HAS_GROWL:
369
 
                osx.growler.notify(event_type, jid, account, msg_type, path_to_image,
370
 
                        title, text)
371
 
                return
372
384
 
373
 
        # go old style
 
385
        # Either nothing succeeded or the user wants old-style notifications
374
386
        instance = dialogs.PopupNotificationWindow(event_type, jid, account,
375
387
                msg_type, path_to_image, title, text)
376
388
        gajim.interface.roster.popup_notification_windows.append(instance)
517
529
                if version > [0, 3]:
518
530
                        if gajim.interface.systray_enabled and \
519
531
                        gajim.config.get('attach_notifications_to_systray'):
520
 
                                x, y = gajim.interface.systray.img_tray.window.get_position()
 
532
                                x, y = gajim.interface.systray.img_tray.window.get_origin()
521
533
                                x_, y_, width, height, depth = \
522
534
                                        gajim.interface.systray.img_tray.window.get_geometry()
523
535
                                pos_x = x + (width / 2)