diff options
Diffstat (limited to 'composer')
-rw-r--r-- | composer/ChangeLog | 8 | ||||
-rw-r--r-- | composer/e-msg-composer.c | 38 |
2 files changed, 33 insertions, 13 deletions
diff --git a/composer/ChangeLog b/composer/ChangeLog index eb37427bb9..193d2c5bf5 100644 --- a/composer/ChangeLog +++ b/composer/ChangeLog @@ -1,5 +1,13 @@ 2001-07-06 Larry Ewing <lewing@ximian.com> + * e-msg-composer.c (autosave_manager_query_load_orphans): only ask + if there are actually contents in the file. Asking about an + emptry fil is not very useful. + (autosave_load_draft): add some sanity chacks. + (autosave_run_foreach_cb): remove debugging warning. + +2001-07-06 Larry Ewing <lewing@ximian.com> + * e-msg-composer.c (autosave_manager_unregister): make sure we only remove the file if we think we saved it properly. (autosave_manager_stop): make sure we set the timeout back to 0 so diff --git a/composer/e-msg-composer.c b/composer/e-msg-composer.c index e5d710ceaa..0c49e8ff35 100644 --- a/composer/e-msg-composer.c +++ b/composer/e-msg-composer.c @@ -1084,8 +1084,15 @@ autosave_load_draft (const char *filename) CamelMimeMessage *msg; EMsgComposer *composer; + g_return_val_if_fail (filename != NULL, NULL); + g_warning ("autosave load filename = \"%s\"", filename); + stream = camel_stream_fs_new_with_name (filename, O_RDONLY, 0); + + if (stream == NULL) + return NULL; + msg = camel_mime_message_new (); camel_data_wrapper_construct_from_stream (CAMEL_DATA_WRAPPER (msg), stream); unlink (filename); @@ -1128,33 +1135,38 @@ autosave_manager_query_load_orphans (AutosaveManager *am, EMsgComposer *composer struct dirent *d; GSList *match = NULL; gint len = strlen (AUTOSAVE_SEED); - gint pre_len; gint ok; - /* length of the seed minus the XXXXXX */ - pre_len = len - 6; - dir = opendir (g_get_home_dir()); if (!dir) { return; } while ((d = readdir (dir))) { - if ((!strncmp (d->d_name, AUTOSAVE_SEED, pre_len) ) + if ((!strncmp (d->d_name, AUTOSAVE_SEED, len - 6)) && (strlen (d->d_name) == len) && (!autosave_is_owned (am, d->d_name))) { + char *filename = g_strdup_printf ("%s/%s", g_get_home_dir(), d->d_name); + struct stat st; + + /* + * check if the file has any length, It is a valid case if it doesn't + * so we simply don't ask then. + */ + if (stat (filename, &st) < 0 || st.st_size == 0) + continue; + dialog = gnome_ok_cancel_dialog_parented (_("Evolution has detected an editor buffer from a previous session.\n" "Would you like to recover this buffer?"), autosave_query_cb, &ok, GTK_WINDOW (composer)); gnome_dialog_run_and_close (GNOME_DIALOG (dialog)); - if (ok) { - match = g_slist_prepend (match, - g_strdup_printf ("%s/%s", - g_get_home_dir(), - d->d_name)); - } + if (ok) + match = g_slist_prepend (match, filename); + else + g_free (filename); + } } @@ -1164,7 +1176,7 @@ autosave_manager_query_load_orphans (AutosaveManager *am, EMsgComposer *composer EMsgComposer *composer; composer = autosave_load_draft (filename); - + g_free (filename); g_slist_free_1 (match); match = next; @@ -1175,7 +1187,7 @@ static void autosave_run_foreach_cb (gpointer key, gpointer value, gpointer data) { EMsgComposer *composer = E_MSG_COMPOSER (value); - g_warning ("autosave"); + autosave_save_draft (composer); } |