From 3622e520dda5f4b7c9cf6aee8aaadc1a50f21ba5 Mon Sep 17 00:00:00 2001 From: Jeffrey Stedfast Date: Wed, 12 Dec 2001 21:14:30 +0000 Subject: set the new-mail-notify command. 2001-12-12 Jeffrey Stedfast * mail-config.c (mail_config_set_new_mail_notification_command): set the new-mail-notify command. (mail_config_get_new_mail_notification_command): get the new-mail-notify command. (mail_config_set_new_mail_notification): set the new-mail-notification action. (mail_config_get_new_mail_notification): get the new-mail-notification action. (mail_config_write_on_exit): save the new-mail-notification settings. (config_read): Read in the new-mail-notification settings. * mail-ops.c (mail_execute_shell_command): New function to execute a shell command async. Will be used for playing sounds on new mail or whatever. svn path=/trunk/; revision=15005 --- mail/ChangeLog | 18 ++++++++++++++++++ mail/mail-config.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++------ mail/mail-config.h | 11 +++++++++++ mail/mail-ops.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ mail/mail-ops.h | 2 ++ 5 files changed, 134 insertions(+), 6 deletions(-) diff --git a/mail/ChangeLog b/mail/ChangeLog index ff41ed6419..09e7c657d4 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,3 +1,21 @@ +2001-12-12 Jeffrey Stedfast + + * mail-config.c (mail_config_set_new_mail_notification_command): + set the new-mail-notify command. + (mail_config_get_new_mail_notification_command): get the + new-mail-notify command. + (mail_config_set_new_mail_notification): set the + new-mail-notification action. + (mail_config_get_new_mail_notification): get the + new-mail-notification action. + (mail_config_write_on_exit): save the new-mail-notification + settings. + (config_read): Read in the new-mail-notification settings. + + * mail-ops.c (mail_execute_shell_command): New function to execute + a shell command async. Will be used for playing sounds on new mail + or whatever. + 2001-12-11 Jon Trowbridge * mail-identify.c (mail_identify_mime_part): Fixed for diff --git a/mail/mail-config.c b/mail/mail-config.c index 91acb931ab..819b251284 100644 --- a/mail/mail-config.c +++ b/mail/mail-config.c @@ -106,6 +106,9 @@ typedef struct { gboolean filter_log; char *filter_log_path; + + MailConfigNewMailNotification notify; + char *notify_command; } MailConfig; static MailConfig *config = NULL; @@ -607,6 +610,14 @@ config_read (void) config->filter_log_path = bonobo_config_get_string ( config->db, "/Mail/Filters/log_path", NULL); + + /* New Mail Notification */ + config->notify = bonobo_config_get_long_with_default ( + config->db, "/Mail/Notify/new_mail_notification", + MAIL_CONFIG_NEW_MAIL_NOTIFICATION_NONE, NULL); + + config->notify_command = bonobo_config_get_string ( + config->db, "/Mail/Notify/new_mail_notification_command", NULL); } #define bonobo_config_set_string_wrapper(db, path, val, ev) bonobo_config_set_string (db, path, val ? val : "", ev) @@ -886,7 +897,14 @@ mail_config_write_on_exit (void) bonobo_config_set_string_wrapper (config->db, "/Mail/Filters/log_path", config->filter_log_path, NULL); - + + /* New Mail Notification */ + bonobo_config_set_long (config->db, "/Mail/Notify/new_mail_notification", + config->notify, NULL); + + bonobo_config_set_string_wrapper (config->db, "/Mail/Notify/new_mail_notification_command", + config->notify_command, NULL); + if (config->threaded_hash) g_hash_table_foreach_remove (config->threaded_hash, hash_save_state, "Threads"); @@ -898,7 +916,7 @@ mail_config_write_on_exit (void) CORBA_exception_free (&ev); /* Passwords */ - + /* then we make sure the ones we want to remember are in the session cache */ accounts = mail_config_get_accounts (); @@ -919,21 +937,21 @@ mail_config_write_on_exit (void) g_free (passwd); } } - + /* then we clear out our component passwords */ e_passwords_clear_component_passwords (); - + /* then we remember them */ accounts = mail_config_get_accounts (); for ( ; accounts; accounts = accounts->next) { account = accounts->data; if (account->source->save_passwd && account->source->url) mail_session_remember_password (account->source->url); - + if (account->transport->save_passwd && account->transport->url) mail_session_remember_password (account->transport->url); } - + /* now do cleanup */ mail_config_clear (); } @@ -1610,6 +1628,30 @@ mail_config_set_default_charset (const char *charset) config->default_charset = g_strdup (charset); } +MailConfigNewMailNotification +mail_config_get_new_mail_notification (void) +{ + return config->notify; +} + +void +mail_config_set_new_mail_notification (MailConfigNewMailNotification type) +{ + config->notify = type; +} + +const char * +mail_config_get_new_mail_notification_command (void) +{ + return config->notify_command; +} + +void +mail_config_set_new_mail_notification_command (const char *command) +{ + g_free (config->notify_command); + config->notify_command = g_strdup (command); +} gboolean mail_config_find_account (const MailConfigAccount *account) diff --git a/mail/mail-config.h b/mail/mail-config.h index ce71d0e1ea..82f863dba3 100644 --- a/mail/mail-config.h +++ b/mail/mail-config.h @@ -87,6 +87,12 @@ typedef enum { MAIL_CONFIG_DISPLAY_MAX } MailConfigDisplayStyle; +typedef enum { + MAIL_CONFIG_NEW_MAIL_NOTIFICATION_NONE, + MAIL_CONFIG_NEW_MAIL_NOTIFICATION_BEEP, + MAIL_CONFIG_NEW_MAIL_NOTIFICATION_COMMAND, +} MailConfigNewMailNotification; + /* Identities */ MailConfigIdentity *identity_copy (const MailConfigIdentity *id); void identity_destroy (MailConfigIdentity *id); @@ -175,6 +181,11 @@ void mail_config_set_default_forward_style (MailConfigForwardS MailConfigDisplayStyle mail_config_get_message_display_style (void); void mail_config_set_message_display_style (MailConfigDisplayStyle style); +MailConfigNewMailNotification mail_config_get_new_mail_notification (void); +void mail_config_set_new_mail_notification (MailConfigNewMailNotification type); +const char *mail_config_get_new_mail_notification_command (void); +void mail_config_set_new_mail_notification_command (const char *command); + const char *mail_config_get_default_charset (void); void mail_config_set_default_charset (const char *charset); diff --git a/mail/mail-ops.c b/mail/mail-ops.c index 8626a5acbb..6bb3f5b5f0 100644 --- a/mail/mail-ops.c +++ b/mail/mail-ops.c @@ -30,6 +30,7 @@ /* #include */ #include +#include #include #include #include @@ -2170,3 +2171,57 @@ mail_store_set_offline (CamelStore *store, gboolean offline, e_thread_put(mail_thread_queued, (EMsg *)m); } + + +/* ** Execute Shell Command ***************************************************** */ + +struct _execute_shell_command_msg { + struct _mail_msg msg; + + char *command; +}; + +static char *execute_shell_command_desc (struct _mail_msg *mm, int done) +{ + struct _execute_shell_command_msg *m = (struct _execute_shell_command_msg *) mm; + char *msg; + + msg = g_strdup_printf (_("Executing shell command: %s"), m->command); + + return msg; +} + +static void execute_shell_command_do (struct _mail_msg *mm) +{ + struct _execute_shell_command_msg *m = (struct _execute_shell_command_msg *) mm; + + gnome_execute_shell (NULL, m->command); +} + +static void execute_shell_command_free (struct _mail_msg *mm) +{ + struct _execute_shell_command_msg *m = (struct _execute_shell_command_msg *) mm; + + g_free (m->command); +} + +static struct _mail_msg_op execute_shell_command_op = { + execute_shell_command_desc, + execute_shell_command_do, + NULL, + execute_shell_command_free, +}; + +void +mail_execute_shell_command (const char *command) +{ + struct _execute_shell_command_msg *m; + + if (command == NULL) + return; + + m = mail_msg_new (&execute_shell_command_op, NULL, sizeof (*m)); + m->command = g_strdup (command); + + e_thread_put (mail_thread_queued, (EMsg *) m); +} diff --git a/mail/mail-ops.h b/mail/mail-ops.h index b71ff4e09b..2f28807272 100644 --- a/mail/mail-ops.h +++ b/mail/mail-ops.h @@ -150,6 +150,8 @@ void mail_store_set_offline (CamelStore *store, gboolean offline, void (*done)(CamelStore *, void *data), void *data); +void mail_execute_shell_command (const char *command); + #ifdef __cplusplus } #endif /* __cplusplus */ -- cgit v1.2.3