enum {
CLOSED,
+ SHUTDOWN,
LAST_SIGNAL
};
}
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;
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,
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
}
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)
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),