diff options
author | Srinivasa Ragavan <sragavan@novell.com> | 2007-12-05 23:11:26 +0800 |
---|---|---|
committer | Srinivasa Ragavan <sragavan@src.gnome.org> | 2007-12-05 23:11:26 +0800 |
commit | 08380ae64ec3d29f1335ce1d1a4a7b601be7903d (patch) | |
tree | 0ca7262699f9cbc0b70e559611b1ff6c54eec305 /e-util | |
parent | eeeb246bdd1de04ab60e46c95449137db5ef0d5f (diff) | |
download | gsoc2013-evolution-08380ae64ec3d29f1335ce1d1a4a7b601be7903d.tar gsoc2013-evolution-08380ae64ec3d29f1335ce1d1a4a7b601be7903d.tar.gz gsoc2013-evolution-08380ae64ec3d29f1335ce1d1a4a7b601be7903d.tar.bz2 gsoc2013-evolution-08380ae64ec3d29f1335ce1d1a4a7b601be7903d.tar.lz gsoc2013-evolution-08380ae64ec3d29f1335ce1d1a4a7b601be7903d.tar.xz gsoc2013-evolution-08380ae64ec3d29f1335ce1d1a4a7b601be7903d.tar.zst gsoc2013-evolution-08380ae64ec3d29f1335ce1d1a4a7b601be7903d.zip |
** Add basic support for crash recovery
2007-12-05 Srinivasa Ragavan <sragavan@novell.com>
** Add basic support for crash recovery
* apps_evolution_shell.schemas.in: Keys to recover and recovery dialog.
* e-shell.c: (e_shell_quit): Delete the lock while quitting.
* main.c: (show_recovery_warning), (idle_cb): Create lock and also show
the warning dialog.
svn path=/trunk/; revision=34652
Diffstat (limited to 'e-util')
-rw-r--r-- | e-util/ChangeLog | 7 | ||||
-rw-r--r-- | e-util/e-util.c | 49 | ||||
-rw-r--r-- | e-util/e-util.h | 4 |
3 files changed, 60 insertions, 0 deletions
diff --git a/e-util/ChangeLog b/e-util/ChangeLog index 06a841a3d7..1cd661efc8 100644 --- a/e-util/ChangeLog +++ b/e-util/ChangeLog @@ -1,3 +1,10 @@ +2007-12-05 Srinivasa Ragavan <sragavan@novell.com> + + * e-util.c: (get_lock_filename), (e_file_lock_create), + (e_file_lock_destroy), (e_file_lock_exists): Add utility functions for + startup-running lock create, check and delete. + * e-util.h: + 2007-12-04 Milan Crha <mcrha@redhat.com> ** Part of fix for bug #500210 diff --git a/e-util/e-util.c b/e-util/e-util.c index 625c617a8b..b1634bcfff 100644 --- a/e-util/e-util.c +++ b/e-util/e-util.c @@ -1017,3 +1017,52 @@ e_file_get_save_path (void) return (uri); } +/* Evolution Locks for crash recovery */ + +#define LOCK_FILE ".running" + +static const gchar * +get_lock_filename (void) +{ + static gchar *filename = NULL; + + if (G_UNLIKELY (filename == NULL)) + filename = g_build_filename (g_get_home_dir (), ".evolution", LOCK_FILE, NULL); + + return filename; +} + +gboolean +e_file_lock_create () +{ + const char *fname = get_lock_filename (); + gboolean status = FALSE; + + int fd = g_creat (fname, S_IRUSR|S_IWUSR); + if (fd == -1){ + g_warning ("Lock file '%s' creation failed, error %d\n", fname, errno); + } else { + status = TRUE; + close (fd); + } + + return status; +} + +void +e_file_lock_destroy () +{ + const char *fname = get_lock_filename (); + + if (g_unlink (fname) == -1){ + g_warning ("Lock destroy: failed to unlink file '%s'!",fname); + } +} + +gboolean +e_file_lock_exists () +{ + const char *fname = get_lock_filename (); + + return g_file_test (fname, G_FILE_TEST_EXISTS); +} diff --git a/e-util/e-util.h b/e-util/e-util.h index e3774c5852..b37f2abdb5 100644 --- a/e-util/e-util.h +++ b/e-util/e-util.h @@ -111,6 +111,10 @@ void e_file_update_save_path (gchar *uri, gboolean free); gchar * e_file_get_save_path (void); +gboolean e_file_lock_create (); +void e_file_lock_destroy (); +gboolean e_file_lock_exists (); + #ifdef __cplusplus } #endif /* __cplusplus */ |