[evolution-data-server] Add e_cal_backend_store_save().



commit a68f14d5573b72ada7e04d090af47f879455e0bc
Author: Matthew Barnes <mbarnes redhat com>
Date:   Wed Jan 9 11:53:32 2013 -0500

    Add e_cal_backend_store_save().
    
    This function cancels the automatic save delay and saves changes to
    disk immediately.  If no changes have been made since the last save,
    the function does nothing.

 calendar/libedata-cal/e-cal-backend-store.c        |   42 +++++++++++++++++---
 calendar/libedata-cal/e-cal-backend-store.h        |    1 +
 .../libedata-cal/libedata-cal-sections.txt         |    1 +
 3 files changed, 38 insertions(+), 6 deletions(-)
---
diff --git a/calendar/libedata-cal/e-cal-backend-store.c b/calendar/libedata-cal/e-cal-backend-store.c
index cd41f2b..084ce0b 100644
--- a/calendar/libedata-cal/e-cal-backend-store.c
+++ b/calendar/libedata-cal/e-cal-backend-store.c
@@ -477,21 +477,17 @@ cal_backend_store_dispose (GObject *object)
 {
 	ECalBackendStorePrivate *priv;
 	ETimezoneCache *timezone_cache;
-	gboolean save_needed = FALSE;
 
 	priv = E_CAL_BACKEND_STORE_GET_PRIVATE (object);
 
-	/* If a save is scheduled, cancel it and save now. */
+	/* Too late to save, we probably already
+	 * lost our weak ETimezoneCache reference. */
 	g_mutex_lock (&priv->save_timeout_lock);
 	if (priv->save_timeout_id > 0) {
 		g_source_remove (priv->save_timeout_id);
 		priv->save_timeout_id = 0;
-		save_needed = TRUE;
 	}
 	g_mutex_unlock (&priv->save_timeout_lock);
-	if (save_needed)
-		cal_backend_store_save_cache_now (
-			E_CAL_BACKEND_STORE (object));
 
 	timezone_cache = g_weak_ref_get (&priv->timezone_cache);
 	if (timezone_cache != NULL) {
@@ -1070,6 +1066,40 @@ e_cal_backend_store_load (ECalBackendStore *store)
 }
 
 /**
+ * e_cal_backend_store_save:
+ * @store: an #ECalBackendStore
+ *
+ * Changes to @store are normally saved to disk automatically after a
+ * short delay.  However when @store is about to be finalized, changes
+ * should be saved to disk immediately so they are not lost.
+ *
+ * This function cancels the automatic save delay and saves changes to
+ * disk immediately.  If no changes have been made since the last save,
+ * the function does nothing.
+ *
+ * Since: 3.8
+ **/
+void
+e_cal_backend_store_save (ECalBackendStore *store)
+{
+	gboolean save_needed = FALSE;
+
+	g_return_if_fail (E_IS_CAL_BACKEND_STORE (store));
+
+	/* If a save is scheduled, cancel it and save now. */
+	g_mutex_lock (&store->priv->save_timeout_lock);
+	if (store->priv->save_timeout_id > 0) {
+		g_source_remove (store->priv->save_timeout_id);
+		store->priv->save_timeout_id = 0;
+		save_needed = TRUE;
+	}
+	g_mutex_unlock (&store->priv->save_timeout_lock);
+
+	if (save_needed)
+		cal_backend_store_save_cache_now (store);
+}
+
+/**
  * e_cal_backend_store_clean:
  *
  * Since: 2.28
diff --git a/calendar/libedata-cal/e-cal-backend-store.h b/calendar/libedata-cal/e-cal-backend-store.h
index 7816cfd..0db8ece 100644
--- a/calendar/libedata-cal/e-cal-backend-store.h
+++ b/calendar/libedata-cal/e-cal-backend-store.h
@@ -107,6 +107,7 @@ ETimezoneCache *
 		e_cal_backend_store_ref_timezone_cache
 						(ECalBackendStore *store);
 gboolean	e_cal_backend_store_load	(ECalBackendStore *store);
+void		e_cal_backend_store_save	(ECalBackendStore *store);
 gboolean	e_cal_backend_store_is_loaded	(ECalBackendStore *store);
 gboolean	e_cal_backend_store_clean	(ECalBackendStore *store);
 ECalComponent *	e_cal_backend_store_get_component
diff --git a/docs/reference/calendar/libedata-cal/libedata-cal-sections.txt b/docs/reference/calendar/libedata-cal/libedata-cal-sections.txt
index d4bf314..72488f3 100644
--- a/docs/reference/calendar/libedata-cal/libedata-cal-sections.txt
+++ b/docs/reference/calendar/libedata-cal/libedata-cal-sections.txt
@@ -130,6 +130,7 @@ e_cal_backend_store_new
 e_cal_backend_store_get_path
 e_cal_backend_store_ref_timezone_cache
 e_cal_backend_store_load
+e_cal_backend_store_save
 e_cal_backend_store_is_loaded
 e_cal_backend_store_clean
 e_cal_backend_store_get_component



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]