[evolution-data-server] ECalBackend: Add a "shutdown" signal.
- From: Matthew Barnes <mbarnes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server] ECalBackend: Add a "shutdown" signal.
- Date: Thu, 15 Aug 2013 21:47:45 +0000 (UTC)
commit 2bf185b72c4e4252ea566e0bd9eaa851e6e13531
Author: Matthew Barnes <mbarnes redhat com>
Date: Thu Aug 15 17:03:36 2013 -0400
ECalBackend: Add a "shutdown" signal.
The "shutdown" signal is emitted when the last client app destroys its
EClient proxy object for a backend. This signals the backend to begin
final cleanup tasks such as synchronizing data to permanent storage.
This increases the size of ECalBackendClass, and therefore requires a
libedata-cal soname bump.
calendar/libedata-cal/e-cal-backend.c | 33 ++++++++++++++++++++++++++++
calendar/libedata-cal/e-cal-backend.h | 1 +
calendar/libedata-cal/e-data-cal-factory.c | 27 ++++++++++++++++++++++
configure.ac | 2 +-
4 files changed, 62 insertions(+), 1 deletions(-)
---
diff --git a/calendar/libedata-cal/e-cal-backend.c b/calendar/libedata-cal/e-cal-backend.c
index 0446087..47a38ce 100644
--- a/calendar/libedata-cal/e-cal-backend.c
+++ b/calendar/libedata-cal/e-cal-backend.c
@@ -106,6 +106,7 @@ enum {
enum {
CLOSED,
+ SHUTDOWN,
LAST_SIGNAL
};
@@ -592,6 +593,19 @@ cal_backend_authenticate_sync (EBackend *backend,
}
static void
+cal_backend_shutdown (ECalBackend *backend)
+{
+ ESource *source;
+
+ source = e_backend_get_source (E_BACKEND (backend));
+
+ g_print (
+ "The %s instance for \"%s\" is shutting down.\n",
+ G_OBJECT_TYPE_NAME (backend),
+ e_source_get_display_name (source));
+}
+
+static void
cal_backend_add_cached_timezone (ETimezoneCache *cache,
icaltimezone *zone)
{
@@ -767,6 +781,7 @@ e_cal_backend_class_init (ECalBackendClass *class)
backend_class->authenticate_sync = cal_backend_authenticate_sync;
class->get_backend_property = cal_backend_get_backend_property;
+ class->shutdown = cal_backend_shutdown;
g_object_class_install_property (
object_class,
@@ -834,6 +849,24 @@ e_cal_backend_class_init (ECalBackendClass *class)
NULL, NULL, NULL,
G_TYPE_NONE, 1,
G_TYPE_STRING);
+
+ /**
+ * ECalBackend::shutdown:
+ * @backend: the #ECalBackend which emitted the signal
+ *
+ * Emitted when the last client destroys its #ECalClient for
+ * @backend. This signals the @backend to begin final cleanup
+ * tasks such as synchronizing data to permanent storage.
+ *
+ * Since: 3.10
+ **/
+ signals[SHUTDOWN] = g_signal_new (
+ "shutdown",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (ECalBackendClass, shutdown),
+ NULL, NULL, NULL,
+ G_TYPE_NONE, 0);
}
static void
diff --git a/calendar/libedata-cal/e-cal-backend.h b/calendar/libedata-cal/e-cal-backend.h
index eb9754f..0eb5d3d 100644
--- a/calendar/libedata-cal/e-cal-backend.h
+++ b/calendar/libedata-cal/e-cal-backend.h
@@ -208,6 +208,7 @@ struct _ECalBackendClass {
/* Signals */
void (*closed) (ECalBackend *backend,
const gchar *sender);
+ void (*shutdown) (ECalBackend *backend);
};
GType e_cal_backend_get_type (void) G_GNUC_CONST;
diff --git a/calendar/libedata-cal/e-data-cal-factory.c b/calendar/libedata-cal/e-data-cal-factory.c
index 61e7514..87cdc70 100644
--- a/calendar/libedata-cal/e-data-cal-factory.c
+++ b/calendar/libedata-cal/e-data-cal-factory.c
@@ -85,6 +85,25 @@ watched_names_value_free (gpointer value)
}
static void
+data_cal_factory_toggle_notify_cb (gpointer data,
+ GObject *backend,
+ gboolean is_last_ref)
+{
+ if (is_last_ref) {
+ /* Take a strong reference before removing the
+ * toggle reference, to keep the backend alive. */
+ g_object_ref (backend);
+
+ g_object_remove_toggle_ref (
+ backend, data_cal_factory_toggle_notify_cb, data);
+
+ g_signal_emit_by_name (backend, "shutdown");
+
+ g_object_unref (backend);
+ }
+}
+
+static void
data_cal_factory_connections_add (EDataCalFactory *factory,
const gchar *name,
ECalBackend *backend)
@@ -349,6 +368,14 @@ data_cal_factory_open (EDataCalFactory *factory,
connection, object_path, error);
if (data_cal != NULL) {
+ /* Install a toggle reference on the backend
+ * so we can signal it to shut down once all
+ * client connections are closed. */
+ g_object_add_toggle_ref (
+ G_OBJECT (backend),
+ data_cal_factory_toggle_notify_cb,
+ NULL);
+
g_signal_connect_object (
backend, "closed",
G_CALLBACK (data_cal_factory_closed_cb),
diff --git a/configure.ac b/configure.ac
index cbf3441..4bae0c9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -114,7 +114,7 @@ LIBECAL_CURRENT=16
LIBECAL_REVISION=0
LIBECAL_AGE=0
-LIBEDATACAL_CURRENT=22
+LIBEDATACAL_CURRENT=23
LIBEDATACAL_REVISION=0
LIBEDATACAL_AGE=0
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]