[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

This commit is contained in:
Nikos Kouremenos 2005-11-21 10:36:56 +00:00
parent b66862d27e
commit ce6233814d
2 changed files with 12 additions and 5 deletions

View file

@ -45,6 +45,7 @@ class Config:
'notify_on_signout': [ opt_bool, False ], 'notify_on_signout': [ opt_bool, False ],
'notify_on_new_message': [ opt_bool, True ], 'notify_on_new_message': [ opt_bool, True ],
'autopopupaway': [ opt_bool, False ], 'autopopupaway': [ opt_bool, False ],
'use_notif_daemon': [ opt_bool, True , _('Use DBus and Notification-Daemon to show notifications') ],
'ignore_unknown_contacts': [ opt_bool, False ], 'ignore_unknown_contacts': [ opt_bool, False ],
'showoffline': [ opt_bool, False ], 'showoffline': [ opt_bool, False ],
'autoaway': [ opt_bool, True ], 'autoaway': [ opt_bool, True ],

View file

@ -42,10 +42,16 @@ _ = i18n._
def dbus_get_interface(): def dbus_get_interface():
try: try:
session_bus = dbus.SessionBus() interface = 'org.freedesktop.Notifications'
obj = session_bus.get_object('org.freedesktop.Notifications', path = '/org/freedesktop/Notifications'
'/org/freedesktop/Notifications') bus = dbus.SessionBus()
return dbus.Interface(obj, 'org.freedesktop.Notifications') 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: except Exception, e:
return None return None
except dbus.DBusException, e: 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)) [dbus.String(path)], [''], [''], True, dbus.UInt32(5))
def notify(event_type, jid, account, msg_type = '', file_props = None): 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: try:
dbus_notify(event_type, jid, account, msg_type, file_props) dbus_notify(event_type, jid, account, msg_type, file_props)
return return