From ce6233814d73e2e5c32d7315a84742f8d88a4e4b Mon Sep 17 00:00:00 2001 From: Nikos Kouremenos Date: Mon, 21 Nov 2005 10:36:56 +0000 Subject: [PATCH] [lorien420] if dbus is there, but notif-daemon is not running, use old style notifications. (I cannot test this as release of notif-daemon is not being listed even if it running). Lorie said devel is ok --- src/common/config.py | 1 + src/notify.py | 16 +++++++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/common/config.py b/src/common/config.py index 2e44d5bd1..94cfe68b0 100644 --- a/src/common/config.py +++ b/src/common/config.py @@ -45,6 +45,7 @@ class Config: 'notify_on_signout': [ opt_bool, False ], 'notify_on_new_message': [ opt_bool, True ], 'autopopupaway': [ opt_bool, False ], + 'use_notif_daemon': [ opt_bool, True , _('Use DBus and Notification-Daemon to show notifications') ], 'ignore_unknown_contacts': [ opt_bool, False ], 'showoffline': [ opt_bool, False ], 'autoaway': [ opt_bool, True ], diff --git a/src/notify.py b/src/notify.py index 71d9bfc0b..a0fc5b886 100644 --- a/src/notify.py +++ b/src/notify.py @@ -42,10 +42,16 @@ _ = i18n._ def dbus_get_interface(): try: - session_bus = dbus.SessionBus() - obj = session_bus.get_object('org.freedesktop.Notifications', - '/org/freedesktop/Notifications') - return dbus.Interface(obj, 'org.freedesktop.Notifications') + interface = 'org.freedesktop.Notifications' + path = '/org/freedesktop/Notifications' + bus = dbus.SessionBus() + obj = bus.get_object('org.freedesktop.DBus', '/org/freedesktop/DBus') + dbus_iface = dbus.Interface(obj, 'org.freedesktop.DBus') + avail = dbus_iface.ListNames() + if not interface in avail: + return None + obj = bus.get_object(interface, path) + return dbus.Interface(obj, interface) except Exception, e: return None except dbus.DBusException, e: @@ -148,7 +154,7 @@ def dbus_notify(event_type, jid, account, msg_type = '', file_props = None): [dbus.String(path)], [''], [''], True, dbus.UInt32(5)) def notify(event_type, jid, account, msg_type = '', file_props = None): - if dbus_available(): + if dbus_available() and gajim.config.get('use_notif_daemon'): try: dbus_notify(event_type, jid, account, msg_type, file_props) return