diff options
author | Yann Leboulanger <asterix@lagaule.org> | 2011-06-14 01:06:43 +0400 |
---|---|---|
committer | Yann Leboulanger <asterix@lagaule.org> | 2011-06-14 01:06:43 +0400 |
commit | d598cbb041d838ae18bdfa4480337f041c2b9484 (patch) | |
tree | 1d5c314fcbb79d7cff04a781d6320cea3e954a02 /src/notify.py | |
parent | 3927db7c5ce521270ac841a1677319a05ba4b330 (diff) |
remove old way of doing advanced notification.
Diffstat (limited to 'src/notify.py')
-rw-r--r-- | src/notify.py | 99 |
1 files changed, 8 insertions, 91 deletions
diff --git a/src/notify.py b/src/notify.py index 2e052cb74..ae95f70cc 100644 --- a/src/notify.py +++ b/src/notify.py @@ -57,12 +57,6 @@ def get_show_in_roster(event, account, contact, session=None): """ if event == 'gc_message_received': return True - num = get_advanced_notification(event, account, contact) - if num is not None: - if gajim.config.get_per('notifications', str(num), 'roster') == 'yes': - return True - if gajim.config.get_per('notifications', str(num), 'roster') == 'no': - return False if event == 'message_received': if session and session.control: return False @@ -72,73 +66,16 @@ def get_show_in_systray(event, account, contact, type_=None): """ Return True if this event must be shown in systray, else False """ - num = get_advanced_notification(event, account, contact) - if num is not None: - if gajim.config.get_per('notifications', str(num), 'systray') == 'yes': - return True - if gajim.config.get_per('notifications', str(num), 'systray') == 'no': - return False if type_ == 'printed_gc_msg' and not gajim.config.get( 'notify_on_all_muc_messages'): # it's not an highlighted message, don't show in systray return False return gajim.config.get('trayicon_notification_on_events') -def get_advanced_notification(event, account, contact): - """ - Returns the number of the first (top most) advanced notification else None - """ - num = 0 - notif = gajim.config.get_per('notifications', str(num)) - while notif: - recipient_ok = False - status_ok = False - tab_opened_ok = False - # test event - if gajim.config.get_per('notifications', str(num), 'event') == event: - # test recipient - recipient_type = gajim.config.get_per('notifications', str(num), - 'recipient_type') - recipients = gajim.config.get_per('notifications', str(num), - 'recipients').split() - if recipient_type == 'all': - recipient_ok = True - elif recipient_type == 'contact' and contact.jid in recipients: - recipient_ok = True - elif recipient_type == 'group': - for group in contact.groups: - if group in contact.groups: - recipient_ok = True - break - if recipient_ok: - # test status - our_status = gajim.SHOW_LIST[gajim.connections[account].connected] - status = gajim.config.get_per('notifications', str(num), 'status') - if status == 'all' or our_status in status.split(): - status_ok = True - if status_ok: - # test window_opened - tab_opened = gajim.config.get_per('notifications', str(num), - 'tab_opened') - if tab_opened == 'both': - tab_opened_ok = True - else: - chat_control = helpers.get_chat_control(account, contact) - if (chat_control and tab_opened == 'yes') or (not chat_control \ - and tab_opened == 'no'): - tab_opened_ok = True - if tab_opened_ok: - return num - - num += 1 - notif = gajim.config.get_per('notifications', str(num)) - -def notify(event, jid, account, parameters, advanced_notif_num=None): +def notify(event, jid, account, parameters): """ Check what type of notifications we want, depending on basic and the advanced configuration of notifications and do these notifications; - advanced_notif_num holds the number of the first (top most) advanced - notification """ # First, find what notifications we want do_popup = False @@ -164,15 +101,14 @@ def notify(event, jid, account, parameters, advanced_notif_num=None): if gajim.config.get_per('soundevents', 'contact_connected', 'enabled') and not gajim.block_signed_in_notifications[account] and \ not block_transport and helpers.allow_sound_notification(account, - event, advanced_notif_num): + event): do_sound = True elif event == 'contact_disconnected': status_message = parameters if helpers.allow_showing_notification(account, 'notify_on_signout'): do_popup = True if gajim.config.get_per('soundevents', 'contact_disconnected', - 'enabled') and helpers.allow_sound_notification(account, - event, advanced_notif_num): + 'enabled') and helpers.allow_sound_notification(account, event): do_sound = True elif event == 'new_message': message_type = parameters[0] @@ -187,26 +123,22 @@ def notify(event, jid, account, parameters, advanced_notif_num=None): message = '' focused = parameters[4] if helpers.allow_showing_notification(account, 'notify_on_new_message', - advanced_notif_num, is_first_message): + is_first_message): do_popup = True if is_first_message and helpers.allow_sound_notification(account, - 'first_message_received', advanced_notif_num): + 'first_message_received'): do_sound = True elif not is_first_message and focused and \ helpers.allow_sound_notification(account, - 'next_message_received_focused', advanced_notif_num): + 'next_message_received_focused'): do_sound = True elif not is_first_message and not focused and \ helpers.allow_sound_notification(account, - 'next_message_received_unfocused', advanced_notif_num): + 'next_message_received_unfocused'): do_sound = True else: print '*Event not implemeted yet*' - if advanced_notif_num is not None and gajim.config.get_per('notifications', - str(advanced_notif_num), 'run_command'): - do_cmd = True - # Do the wanted notifications if do_popup: if event in ('contact_connected', 'contact_disconnected', @@ -290,14 +222,7 @@ def notify(event, jid, account, parameters, advanced_notif_num=None): snd_file = None snd_event = None # If not snd_file, play the event if event == 'new_message': - if advanced_notif_num is not None and gajim.config.get_per( - 'notifications', str(advanced_notif_num), 'sound') == 'yes': - snd_file = gajim.config.get_per('notifications', - str(advanced_notif_num), 'sound_file') - elif advanced_notif_num is not None and gajim.config.get_per( - 'notifications', str(advanced_notif_num), 'sound') == 'no': - pass # do not set snd_event - elif is_first_message: + if is_first_message: snd_event = 'first_message_received' elif focused: snd_event = 'next_message_received_focused' @@ -310,14 +235,6 @@ def notify(event, jid, account, parameters, advanced_notif_num=None): if snd_event: helpers.play_sound(snd_event) - if do_cmd: - command = gajim.config.get_per('notifications', str(advanced_notif_num), - 'command') - try: - helpers.exec_command(command) - except Exception: - pass - def popup(event_type, jid, account, msg_type='', path_to_image=None, title=None, text=None): """ |