[evolution-data-server] EBookBackend: Add a "shutdown" signal.
- From: Matthew Barnes <mbarnes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server] EBookBackend: Add a "shutdown" signal.
- Date: Thu, 15 Aug 2013 21:47:40 +0000 (UTC)
commit e4d5ad0ca046ab0b4541f762535b333e7d846234
Author: Matthew Barnes <mbarnes redhat com>
Date: Thu Aug 15 17:00:56 2013 -0400
EBookBackend: 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 EBookBackendClass, and therefore requires a
libedata-book soname bump.
addressbook/libedata-book/e-book-backend.c | 33 +++++++++++++++++++++++
addressbook/libedata-book/e-book-backend.h | 1 +
addressbook/libedata-book/e-data-book-factory.c | 27 ++++++++++++++++++
configure.ac | 2 +-
4 files changed, 62 insertions(+), 1 deletions(-)
---
diff --git a/addressbook/libedata-book/e-book-backend.c b/addressbook/libedata-book/e-book-backend.c
index fe03891..1344423 100644
--- a/addressbook/libedata-book/e-book-backend.c
+++ b/addressbook/libedata-book/e-book-backend.c
@@ -91,6 +91,7 @@ enum {
enum {
CLOSED,
+ SHUTDOWN,
LAST_SIGNAL
};
@@ -536,6 +537,19 @@ book_backend_notify_update (EBookBackend *backend,
}
static void
+book_backend_shutdown (EBookBackend *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
e_book_backend_class_init (EBookBackendClass *class)
{
GObjectClass *object_class;
@@ -556,6 +570,7 @@ e_book_backend_class_init (EBookBackendClass *class)
class->get_backend_property = book_backend_get_backend_property;
class->get_contact_list_uids_sync = book_backend_get_contact_list_uids_sync;
class->notify_update = book_backend_notify_update;
+ class->shutdown = book_backend_shutdown;
g_object_class_install_property (
object_class,
@@ -608,6 +623,24 @@ e_book_backend_class_init (EBookBackendClass *class)
NULL, NULL, NULL,
G_TYPE_NONE, 1,
G_TYPE_STRING);
+
+ /**
+ * EBookBackend::shutdown:
+ * @backend: the #EBookBackend which emitted the signal
+ *
+ * Emitted when the last client destroys its #EBookClient 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 (EBookBackendClass, shutdown),
+ NULL, NULL, NULL,
+ G_TYPE_NONE, 0);
}
static void
diff --git a/addressbook/libedata-book/e-book-backend.h b/addressbook/libedata-book/e-book-backend.h
index a4668d1..75761e8 100644
--- a/addressbook/libedata-book/e-book-backend.h
+++ b/addressbook/libedata-book/e-book-backend.h
@@ -214,6 +214,7 @@ struct _EBookBackendClass {
/* Signals */
void (*closed) (EBookBackend *backend,
const gchar *sender);
+ void (*shutdown) (EBookBackend *backend);
};
GType e_book_backend_get_type (void) G_GNUC_CONST;
diff --git a/addressbook/libedata-book/e-data-book-factory.c b/addressbook/libedata-book/e-data-book-factory.c
index 19a32d5..7017aa1 100644
--- a/addressbook/libedata-book/e-data-book-factory.c
+++ b/addressbook/libedata-book/e-data-book-factory.c
@@ -79,6 +79,25 @@ watched_names_value_free (gpointer value)
}
static void
+data_book_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_book_factory_toggle_notify_cb, data);
+
+ g_signal_emit_by_name (backend, "shutdown");
+
+ g_object_unref (backend);
+ }
+}
+
+static void
data_book_factory_connections_add (EDataBookFactory *factory,
const gchar *name,
EBookBackend *backend)
@@ -343,6 +362,14 @@ data_book_factory_open (EDataBookFactory *factory,
connection, object_path, error);
if (data_book != 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_book_factory_toggle_notify_cb,
+ NULL);
+
g_signal_connect_object (
backend, "closed",
G_CALLBACK (data_book_factory_closed_cb),
diff --git a/configure.ac b/configure.ac
index 872c7b4..cbf3441 100644
--- a/configure.ac
+++ b/configure.ac
@@ -118,7 +118,7 @@ LIBEDATACAL_CURRENT=22
LIBEDATACAL_REVISION=0
LIBEDATACAL_AGE=0
-LIBEDATABOOK_CURRENT=19
+LIBEDATABOOK_CURRENT=20
LIBEDATABOOK_REVISION=0
LIBEDATABOOK_AGE=0
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]