aboutsummaryrefslogtreecommitdiffstats
path: root/composer
diff options
context:
space:
mode:
authorLarry Ewing <lewing@ximian.com>2001-07-06 13:23:59 +0800
committerLarry Ewing <lewing@src.gnome.org>2001-07-06 13:23:59 +0800
commitaf72fc9468d136ae29e93e4341d04ba3c9c082aa (patch)
tree7458d4d9262e5dc04f3173a53a1b1d6b81b666fb /composer
parentccbc3a36887e4ab7e442c649ddae53f6e964f40f (diff)
downloadgsoc2013-evolution-af72fc9468d136ae29e93e4341d04ba3c9c082aa.tar
gsoc2013-evolution-af72fc9468d136ae29e93e4341d04ba3c9c082aa.tar.gz
gsoc2013-evolution-af72fc9468d136ae29e93e4341d04ba3c9c082aa.tar.bz2
gsoc2013-evolution-af72fc9468d136ae29e93e4341d04ba3c9c082aa.tar.lz
gsoc2013-evolution-af72fc9468d136ae29e93e4341d04ba3c9c082aa.tar.xz
gsoc2013-evolution-af72fc9468d136ae29e93e4341d04ba3c9c082aa.tar.zst
gsoc2013-evolution-af72fc9468d136ae29e93e4341d04ba3c9c082aa.zip
make sure we only remove the file if we think we saved it properly.
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 that we will restart next time since we stop the timer when there are no active composers. (destroy): move this to the beginning of the destroy process. (autosave_save_draft): add a return value indicating success. (autosave_manager_register): go ahead and ask next time. svn path=/trunk/; revision=10839
Diffstat (limited to 'composer')
-rw-r--r--composer/ChangeLog11
-rw-r--r--composer/e-msg-composer.c32
2 files changed, 33 insertions, 10 deletions
diff --git a/composer/ChangeLog b/composer/ChangeLog
index d7e8368d43..eb37427bb9 100644
--- a/composer/ChangeLog
+++ b/composer/ChangeLog
@@ -1,3 +1,14 @@
+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
+ that we will restart next time since we stop the timer when there
+ are no active composers.
+ (destroy): move this to the beginning of the destroy process.
+ (autosave_save_draft): add a return value indicating success.
+ (autosave_manager_register): go ahead and ask next time.
+
2001-07-05 Larry Ewing <lewing@ximian.com>
* e-msg-composer.c: add ask argment.
diff --git a/composer/e-msg-composer.c b/composer/e-msg-composer.c
index 4996b9fa3c..e5d710ceaa 100644
--- a/composer/e-msg-composer.c
+++ b/composer/e-msg-composer.c
@@ -1023,13 +1023,14 @@ struct _AutosaveManager {
static AutosaveManager *am = NULL;
-static void
+static gboolean
autosave_save_draft (EMsgComposer *composer)
{
CamelMimeMessage *msg;
CamelStream *stream;
char *file;
gint fd;
+ gboolean success = TRUE;
fd = composer->autosave_fd;
file = composer->autosave_file;
@@ -1037,7 +1038,7 @@ autosave_save_draft (EMsgComposer *composer)
if (fd == -1) {
e_notice (GTK_WINDOW (composer), GNOME_MESSAGE_BOX_ERROR,
_("Error accessing file: %s"), file);
- return;
+ return FALSE;
}
msg = e_msg_composer_get_message_draft (composer);
@@ -1045,19 +1046,19 @@ autosave_save_draft (EMsgComposer *composer)
if (msg == NULL) {
e_notice (GTK_WINDOW (composer), GNOME_MESSAGE_BOX_ERROR,
_("Unable to retrieve message from editor"));
- return;
+ return FALSE;
}
if (lseek (fd, (off_t)0, SEEK_SET) == -1) {
e_notice (GTK_WINDOW (composer), GNOME_MESSAGE_BOX_ERROR,
_("Unable to seek on file: %s\n%s"), file, strerror(errno));
- return;
+ return FALSE;
}
if (ftruncate (fd, (off_t)0) == -1) {
e_notice (GTK_WINDOW (composer), GNOME_MESSAGE_BOX_ERROR,
_("Unable to truncate file: %s\n%s"), file, strerror(errno));
- return;
+ return FALSE;
}
/* this does an lseek so we don't have to */
@@ -1066,11 +1067,14 @@ autosave_save_draft (EMsgComposer *composer)
|| camel_stream_flush((CamelStream *)stream) == -1) {
e_notice (GTK_WINDOW (composer), GNOME_MESSAGE_BOX_ERROR,
_("Error autosaving message: %s\n %s"), file, strerror(errno));
-
+
+ success = FALSE;
}
/* set the fd to -1 in the stream so camel doesn't close it we want to keep it open */
CAMEL_STREAM_FS (stream)->fd = -1;
camel_object_unref((CamelObject *)stream);
+
+ return success;
}
static EMsgComposer *
@@ -1205,8 +1209,10 @@ autosave_manager_start (AutosaveManager *am)
static void
autosave_manager_stop (AutosaveManager *am)
{
- if (am->id)
+ if (am->id) {
gtk_timeout_remove (am->id);
+ am->id = 0;
+ }
}
AutosaveManager *
@@ -1233,8 +1239,10 @@ autosave_manager_register (AutosaveManager *am, EMsgComposer *composer)
key = g_basename (composer->autosave_file);
g_hash_table_insert (am->table, key, composer);
if (am->ask) {
+ /* keep recursion out of our bedrooms. */
am->ask = FALSE;
autosave_manager_query_load_orphans (am, composer);
+ am->ask = TRUE;
}
}
@@ -1246,8 +1254,12 @@ autosave_manager_unregister (AutosaveManager *am, EMsgComposer *composer)
{
g_hash_table_remove (am->table, g_basename (composer->autosave_file));
+ /* only remove the file if we can successfully save it */
+ /* FIXME this test could probably be more efficient */
+ if (autosave_save_draft (composer)) {
+ unlink (composer->autosave_file);
+ }
close (composer->autosave_fd);
- unlink (composer->autosave_file);
g_free (composer->autosave_file);
if (g_hash_table_size (am->table) == 0)
@@ -1859,6 +1871,8 @@ destroy (GtkObject *object)
composer = E_MSG_COMPOSER (object);
+ autosave_manager_unregister (am, composer);
+
CORBA_exception_init (&ev);
if (composer->config_db) {
@@ -1895,8 +1909,6 @@ destroy (GtkObject *object)
g_free (composer->charset);
- autosave_manager_unregister (am, composer);
-
CORBA_exception_init (&ev);
if (composer->persist_stream_interface != CORBA_OBJECT_NIL) {