From 1cca6b24335a9de963ced4b6127f4558ed19cf48 Mon Sep 17 00:00:00 2001 From: Jeffrey Stedfast Date: Tue, 8 Jan 2002 00:48:54 +0000 Subject: Renamed. (mail_config_get_new_mail_notify_sound_file): Renamed. 2002-01-07 Jeffrey Stedfast * mail-config.c (mail_config_set_new_mail_notify_sound_file): Renamed. (mail_config_get_new_mail_notify_sound_file): Renamed. * mail-accounts.c (notify_radio_toggled): Replace EXEC with PLAY_SOUND. (construct): renamed the exec_command stuff to play_sound. * main.c (main): Init and shutdown gnome_sound. * mail-ops.c (fetch_mail_fetch): Don't do any new-mail notification here. (filter_folder_filter): call camel_filter_driver_flush. * mail-session.c (main_get_filter_driver): Set the filter-driver exec_func here instead. * mail-ops.c (mail_fetch_mail): Don't set the filter-driver exec_func here. svn path=/trunk/; revision=15263 --- mail/mail-session.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'mail/mail-session.c') diff --git a/mail/mail-session.c b/mail/mail-session.c index f8265a12ea..98d5968364 100644 --- a/mail/mail-session.c +++ b/mail/mail-session.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -40,6 +41,7 @@ #include "mail-session.h" #include "mail-tools.h" #include "mail-mt.h" +#include "mail-ops.h" #include "e-util/e-passwords.h" #include "e-util/e-msgport.h" @@ -806,6 +808,15 @@ get_folder (CamelFilterDriver *d, const char *uri, void *data, CamelException *e return mail_tool_uri_to_folder (uri, 0, ex); } +static void +session_play_sound (CamelFilterDriver *driver, const char *filename, gpointer user_data) +{ + if (!filename || !*filename) + gdk_beep (); + else + gnome_sound_play (filename); +} + static CamelFilterDriver * main_get_filter_driver (CamelSession *session, const char *type, CamelException *ex) { @@ -838,6 +849,9 @@ main_get_filter_driver (CamelSession *session, const char *type, CamelException camel_filter_driver_set_logfile (driver, ms->filter_logfile); } + camel_filter_driver_set_shell_exec_func (driver, mail_execute_shell_command, NULL); + camel_filter_driver_set_play_sound_func (driver, session_play_sound, NULL); + fsearch = g_string_new (""); faction = g_string_new (""); @@ -852,6 +866,31 @@ main_get_filter_driver (CamelSession *session, const char *type, CamelException fsearch->str, faction->str); } + /* FIXME: we need a way to distinguish between filtering new + mail and re-filtering a folder because both use the + "incoming" filter type */ + if (mail_config_get_new_mail_notify () && !strcmp (type, "incoming")) { + g_string_truncate (faction, 0); + + g_string_append (faction, "(only-once \"new-mail-notification\" "); + + switch (mail_config_get_new_mail_notify ()) { + case MAIL_CONFIG_NOTIFY_BEEP: + g_string_append (faction, "\"(beep)\""); + break; + case MAIL_CONFIG_NOTIFY_PLAY_SOUND: + g_string_sprintfa (faction, "\"(play-sound \\\"%s\\\")\"", + mail_config_get_new_mail_notify_sound_file ()); + break; + default: + break; + } + + g_string_append (faction, ")"); + + camel_filter_driver_add_rule (driver, "new-mail-notification", "(begin #t)", faction->str); + } + g_string_free (fsearch, TRUE); g_string_free (faction, TRUE); -- cgit