diff options
author | Peter Williams <peterw@src.gnome.org> | 2000-08-11 03:34:50 +0800 |
---|---|---|
committer | Peter Williams <peterw@src.gnome.org> | 2000-08-11 03:34:50 +0800 |
commit | 09199ae2ea091126d0481e16ad16b3a0479c256b (patch) | |
tree | d3adf3737bb843b1dae5c7036af031784ffc2ca7 /mail | |
parent | 8d36ddc51a03541d41c7bc517fb84f8382d56254 (diff) | |
download | gsoc2013-evolution-09199ae2ea091126d0481e16ad16b3a0479c256b.tar gsoc2013-evolution-09199ae2ea091126d0481e16ad16b3a0479c256b.tar.gz gsoc2013-evolution-09199ae2ea091126d0481e16ad16b3a0479c256b.tar.bz2 gsoc2013-evolution-09199ae2ea091126d0481e16ad16b3a0479c256b.tar.lz gsoc2013-evolution-09199ae2ea091126d0481e16ad16b3a0479c256b.tar.xz gsoc2013-evolution-09199ae2ea091126d0481e16ad16b3a0479c256b.tar.zst gsoc2013-evolution-09199ae2ea091126d0481e16ad16b3a0479c256b.zip |
Show 'no new mail' correctly.
svn path=/trunk/; revision=4699
Diffstat (limited to 'mail')
-rw-r--r-- | mail/mail-ops.c | 43 | ||||
-rw-r--r-- | mail/mail-tools.c | 12 |
2 files changed, 46 insertions, 9 deletions
diff --git a/mail/mail-ops.c b/mail/mail-ops.c index bd080d7f01..555fd53ec9 100644 --- a/mail/mail-ops.c +++ b/mail/mail-ops.c @@ -45,6 +45,10 @@ typedef struct fetch_mail_input_s } fetch_mail_input_t; +typedef struct fetch_mail_data_s { + gboolean empty; +} fetch_mail_data_t; + static gchar *describe_fetch_mail (gpointer in_data, gboolean gerund); static void setup_fetch_mail (gpointer in_data, gpointer op_data, CamelException * ex); @@ -70,6 +74,7 @@ static void setup_fetch_mail (gpointer in_data, gpointer op_data, CamelException * ex) { fetch_mail_input_t *input = (fetch_mail_input_t *) in_data; + fetch_mail_data_t *data = (fetch_mail_data_t *) op_data; if (!input->source_url) { camel_exception_set (ex, CAMEL_EXCEPTION_INVALID_PARAM, @@ -87,16 +92,17 @@ setup_fetch_mail (gpointer in_data, gpointer op_data, CamelException * ex) return; } + data->empty = FALSE; camel_object_ref (CAMEL_OBJECT (input->destination)); } static void do_fetch_mail (gpointer in_data, gpointer op_data, CamelException * ex) { - fetch_mail_input_t *input; - CamelFolder *search_folder = NULL; + fetch_mail_input_t *input = (fetch_mail_input_t *) in_data; + fetch_mail_data_t *data = (fetch_mail_data_t *) op_data; - input = (fetch_mail_input_t *) in_data; + CamelFolder *search_folder = NULL; if (input->destination == NULL) { input->destination = mail_tool_get_local_inbox (ex); @@ -110,16 +116,27 @@ do_fetch_mail (gpointer in_data, gpointer op_data, CamelException * ex) input->keep_on_server, ex); if (search_folder == NULL) { - /* This happens with an IMAP source and on error */ + /* This happens with an IMAP source and on error + * and on "no new mail" + */ camel_object_unref (CAMEL_OBJECT (input->destination)); input->destination = NULL; + data->empty = TRUE; return; } - mail_tool_filter_contents_into (search_folder, input->destination, - TRUE, - input->hook_func, input->hook_data, - ex); + mail_tool_camel_lock_up (); + if (camel_folder_get_message_count (search_folder) == 0) { + data->empty = TRUE; + } else { + mail_tool_filter_contents_into (search_folder, input->destination, + TRUE, + input->hook_func, input->hook_data, + ex); + data->empty = FALSE; + } + mail_tool_camel_lock_down (); + camel_object_unref (CAMEL_OBJECT (search_folder)); } @@ -127,6 +144,14 @@ static void cleanup_fetch_mail (gpointer in_data, gpointer op_data, CamelException * ex) { fetch_mail_input_t *input = (fetch_mail_input_t *) in_data; + fetch_mail_data_t *data = (fetch_mail_data_t *) op_data; + + if (data->empty && !camel_exception_is_set (ex)) { + GtkWidget *dialog; + + dialog = gnome_ok_dialog ("There is no new mail."); + gnome_dialog_run_and_close (GNOME_DIALOG (dialog)); + } g_free (input->source_url); if (input->destination) @@ -135,7 +160,7 @@ cleanup_fetch_mail (gpointer in_data, gpointer op_data, CamelException * ex) static const mail_operation_spec op_fetch_mail = { describe_fetch_mail, - 0, + sizeof (fetch_mail_data_t), setup_fetch_mail, do_fetch_mail, cleanup_fetch_mail diff --git a/mail/mail-tools.c b/mail/mail-tools.c index 10e70a6a6f..2ae83229ef 100644 --- a/mail/mail-tools.c +++ b/mail/mail-tools.c @@ -156,6 +156,7 @@ mail_tool_do_movemail (const gchar *source_url, CamelException *ex) gchar *dest_path; const gchar *source; CamelFolder *ret; + struct stat sb; #ifndef MOVEMAIL_PATH int tmpfd; #endif @@ -195,6 +196,13 @@ mail_tool_do_movemail (const gchar *source_url, CamelException *ex) mail_tool_camel_lock_up(); camel_movemail (source, dest_path, ex); mail_tool_camel_lock_down(); + + if (stat (dest_path, &sb) < 0 || sb.st_size == 0) { + g_free (dest_path); + g_free (dest_url); + return NULL; + } + g_free (dest_path); if (camel_exception_is_set (ex)) { @@ -423,6 +431,10 @@ mail_tool_fetch_mail_into_searchable (const char *source_url, gboolean keep_on_s else spool_folder = mail_tool_get_inbox (source_url, ex); + /* No new mail */ + if (spool_folder == NULL) + return NULL; + if (camel_exception_is_set (ex)) goto cleanup; |