diff options
author | Ryan Lortie <desrt@desrt.ca> | 2010-05-21 12:18:10 -0400 |
---|---|---|
committer | Ryan Lortie <desrt@desrt.ca> | 2010-05-21 12:18:43 -0400 |
commit | 86bff9e98374d13d74dd59316f8bc8575a7671e1 (patch) | |
tree | 0d9075c7fb1cd479bfbce7ce0fb93184d058fa23 /gsettings | |
parent | 128e53d2b39698efbf13f65c08ef27ef31403593 (diff) | |
download | dconf-86bff9e98374d13d74dd59316f8bc8575a7671e1.tar.gz |
factor-out common client-side code
Preparing for creating standalone client-side library.
Diffstat (limited to 'gsettings')
-rw-r--r-- | gsettings/Makefile.am | 6 | ||||
-rw-r--r-- | gsettings/dconfdatabase.c | 489 | ||||
-rw-r--r-- | gsettings/dconfdatabase.h | 55 | ||||
-rw-r--r-- | gsettings/dconfsettingsbackend.c | 353 |
4 files changed, 335 insertions, 568 deletions
diff --git a/gsettings/Makefile.am b/gsettings/Makefile.am index 00795cb..c19a92f 100644 --- a/gsettings/Makefile.am +++ b/gsettings/Makefile.am @@ -1,13 +1,13 @@ -AM_CFLAGS = $(gio_CFLAGS) -I$(top_srcdir)/gvdb +AM_CFLAGS = $(gio_CFLAGS) -I$(top_srcdir) giomodules_LTLIBRARIES = libdconfsettings.la libdconfsettings_la_LIBADD = $(gio_LIBS) libdconfsettings_la_LDFLAGS = -module -avoid-version -shared libdconfsettings_la_SOURCES = \ + ../client/dconf-client.h\ + ../client/dconf-client.c\ ../gvdb/gvdb-reader.c \ - dconfdatabase.h \ - dconfdatabase.c \ dconfsettingsbackend.c install-data-hook: diff --git a/gsettings/dconfdatabase.c b/gsettings/dconfdatabase.c deleted file mode 100644 index 44ce35a..0000000 --- a/gsettings/dconfdatabase.c +++ /dev/null @@ -1,489 +0,0 @@ -/* - * Copyright © 2010 Codethink Limited - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the licence, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Author: Ryan Lortie <desrt@desrt.ca> - */ - -#define G_SETTINGS_ENABLE_BACKEND -#include <gio/gsettingsbackend.h> -#include "dconfdatabase.h" - -#include <gio/gio.h> - -#include <string.h> -#include "gvdb-reader.h" - -typedef struct _Outstanding Outstanding; - -struct _DConfDatabase -{ - GStaticMutex lock; - - GDBusConnection *bus; - GvdbTable *value_table; - GSList *backends; - const gchar *context; - - Outstanding *outstanding; - guint64 anti_expose; -}; - -struct _Outstanding -{ - Outstanding *next; - - volatile guint32 serial; - - gchar *reset_path, *set_key; - GVariant *set_value; - - GTree *tree; -}; - -static volatile guint32 * -dconf_database_new_outstanding (DConfDatabase *database, - const gchar *reset_path, - const gchar *set_key, - GVariant *set_value, - GTree *tree) -{ - Outstanding *outstanding; - - outstanding = g_slice_new (Outstanding); - outstanding->serial = 0; - outstanding->reset_path = g_strdup (reset_path); - outstanding->set_key = g_strdup (set_key); - - if (set_value) - outstanding->set_value = g_variant_ref_sink (set_value); - else - outstanding->set_value = NULL; - - if (tree) - outstanding->tree = g_tree_ref (tree); - else - outstanding->tree = NULL; - - g_static_mutex_lock (&database->lock); - outstanding->next = database->outstanding; - database->outstanding = outstanding; - g_static_mutex_unlock (&database->lock); - - return &outstanding->serial; -} - -static gboolean -dconf_database_remove_outstanding (DConfDatabase *database, - GDBusMessage *message, - guint64 *anti_expose) -{ - gboolean found = FALSE; - Outstanding **node; - guint32 serial; - - if G_LIKELY (database->outstanding == NULL) - return FALSE; - - serial = g_dbus_message_get_reply_serial (message); - - if (serial == 0) - return FALSE; - - g_static_mutex_lock (&database->lock); - - /* this could be made more asymptotically efficient by using a queue - * or a double-linked list with a 'tail' pointer but the usual case - * here will be one outstanding item and very rarely more than a few. - * - * so we scan... - */ - for (node = &database->outstanding; *node; node = &(*node)->next) - if ((*node)->serial == serial) - { - Outstanding *tmp; - - tmp = *node; - *node = tmp->next; - - g_static_mutex_unlock (&database->lock); - - g_variant_get (g_dbus_message_get_body (message), "(t)", anti_expose); - - g_free (tmp->reset_path); - g_free (tmp->set_key); - - if (tmp->set_value) - g_variant_unref (tmp->set_value); - - if (tmp->tree) - g_tree_unref (tmp->tree); - - found = TRUE; - break; - } - - g_static_mutex_unlock (&database->lock); - - return found; -} - -static gboolean -dconf_database_scan_outstanding_tree (GTree *tree, - const gchar *key, - gsize key_length, - gpointer *value) -{ - gchar *mykey; - - mykey = g_alloca (key_length + 1); - memcpy (mykey, key, key_length + 1); - - while (!g_tree_lookup_extended (tree, mykey, NULL, value) && - --key_length) - { - while (mykey[key_length - 1] != '/') - key_length--; - - mykey[key_length] = '\0'; - } - - return key_length != 0; -} - -static gboolean -dconf_database_scan_outstanding (DConfDatabase *database, - const gchar *key, - GVariant **value) -{ - gboolean found = FALSE; - Outstanding *node; - gsize length; - - length = strlen (key); - - if G_LIKELY (database->outstanding == NULL) - return FALSE; - - g_static_mutex_lock (&database->lock); - - for (node = database->outstanding; node; node = node->next) - { - if (node->reset_path) - { - if (g_str_has_prefix (key, node->reset_path)) - { - *value = NULL; - found = TRUE; - break; - } - } - - else if (node->set_key) - { - if (strcmp (key, node->set_key) == 0) - { - if (node->set_value != NULL) - *value = g_variant_ref (node->set_value); - else - *value = NULL; - - found = TRUE; - break; - } - } - - else - { - gpointer result; - - if (dconf_database_scan_outstanding_tree (node->tree, key, - length, &result)) - { - if (result) - *value = g_variant_ref (result); - else - *value = NULL; - - found = TRUE; - break; - } - } - } - - g_static_mutex_unlock (&database->lock); - - return found; -} - -static void -dconf_database_reopen_file (DConfDatabase *database) -{ - gchar *filename; - - if (database->value_table != NULL) - gvdb_table_unref (database->value_table); - - filename = g_build_filename (g_get_user_config_dir (), "dconf", NULL); - database->value_table = gvdb_table_new (filename, FALSE, NULL); - g_free (filename); -} - -GVariant * -dconf_database_read (DConfDatabase *database, - const gchar *key) -{ - GVariant *value; - - if (dconf_database_scan_outstanding (database, key, &value)) - return value; - - if (database->value_table == NULL) - return NULL; - - dconf_database_reopen_file (database); - - return gvdb_table_get_value (database->value_table, key, NULL); -} - -static void -dconf_database_incoming_signal (DConfDatabase *database, - GDBusMessage *message) -{ - const gchar **keys; - const gchar *name; - gboolean is_path; - guint64 serial; - - if (strcmp (g_dbus_message_get_interface (message), - "ca.desrt.dconf.Writer") != 0 || - strcmp (g_dbus_message_get_member (message), "Notify") != 0) - return; - - g_variant_get (g_dbus_message_get_body (message), - "(t&s^a&s)", &serial, &name, &keys); - - is_path = g_str_has_suffix (name, "/"); - - if (serial != database->anti_expose) - { - GSList *node; - - if (keys[0] == NULL) - { - for (node = database->backends; node; node = node->next) - if (is_path) - g_settings_backend_path_changed (node->data, name, NULL); - else - g_settings_backend_changed (node->data, name, NULL); - } - else if (is_path) - { - for (node = database->backends; node; node = node->next) - g_settings_backend_keys_changed (node->data, name, keys, NULL); - } - } - - g_free (keys); -} - -static gboolean -dconf_database_filter_function (GDBusConnection *connection, - GDBusMessage *message, - gpointer user_data) -{ - DConfDatabase *database = user_data; - - switch (g_dbus_message_get_message_type (message)) - { - case G_DBUS_MESSAGE_TYPE_METHOD_RETURN: - return dconf_database_remove_outstanding (database, message, - &database->anti_expose); - - case G_DBUS_MESSAGE_TYPE_SIGNAL: - dconf_database_incoming_signal (database, message); - return FALSE; - - default: - return FALSE; - } -} - -GVariant * -fake_maybe (GVariant *value) -{ - GVariantBuilder builder; - - g_variant_builder_init (&builder, G_VARIANT_TYPE ("av")); - - if (value != NULL) - g_variant_builder_add (&builder, "v", value); - - return g_variant_builder_end (&builder); -} - -void -dconf_database_write_tree (DConfDatabase *database, - GTree *tree, - gpointer origin_tag) -{ - volatile guint32 *serial; - const gchar **keys; - GVariant **values; - gchar *path; - - serial = dconf_database_new_outstanding (database, NULL, NULL, NULL, tree); - g_settings_backend_flatten_tree (tree, &path, &keys, &values); - - { - GSList *node; - - for (node = database->backends; node; node = node->next) - g_settings_backend_keys_changed (node->data, path, - keys, origin_tag); - } - - { - GDBusMessage *message; - GVariantBuilder args; - gsize i; - - message = - g_dbus_message_new_method_call ("ca.desrt.dconf", "/", - "ca.desrt.dconf.Writer", "Write"); - - g_variant_builder_init (&args, G_VARIANT_TYPE ("(sa(sav))")); - g_variant_builder_add (&args, "s", path); - - g_variant_builder_open (&args, G_VARIANT_TYPE ("a(sav)")); - for (i = 0; keys[i]; i++) - g_variant_builder_add (&args, "(s@av)", keys[i], fake_maybe (values[i])); - - g_variant_builder_close (&args); - - g_dbus_message_set_body (message, - g_variant_builder_end (&args)); - g_dbus_connection_send_message (database->bus, - message, serial, NULL); - g_object_unref (message); - } - - g_free (path); - g_free (keys); - g_free (values); -} - -gchar ** -dconf_database_list (DConfDatabase *database, - const gchar *path, - gsize *length) -{ - gchar **result; - - result = gvdb_table_list (database->value_table, path); - - if (result) - *length = g_strv_length (result); - - return result; -} - -void -dconf_database_write (DConfDatabase *database, - const gchar *path_or_key, - GVariant *value, - gpointer origin_tag) -{ - volatile guint32 *serial; - GDBusMessage *message; - - serial = dconf_database_new_outstanding (database, NULL, - path_or_key, value, - NULL); - - message = g_dbus_message_new_method_call ("ca.desrt.dconf", "/", - "ca.desrt.dconf.Writer", "Write"); - g_dbus_message_set_body (message, g_variant_new ("(s@av)", path_or_key, - fake_maybe (value))); - g_dbus_connection_send_message (database->bus, message, serial, NULL); - g_object_unref (message); - - { - GSList *node; - - for (node = database->backends; node; node = node->next) - g_settings_backend_changed (node->data, path_or_key, origin_tag); - } -} - -static void -send_match_rule (DConfDatabase *database, - const gchar *method, - const gchar *name) -{ - GDBusMessage *message; - gchar *rule; - - rule = g_strdup_printf ("interface='ca.desrt.dconf.Writer'," - "arg1path='%s'", name); - message = g_dbus_message_new_method_call ("org.freedesktop.DBus", "/", - "org.freedesktop.DBus", method); - g_dbus_message_set_body (message, g_variant_new ("(s)", (rule))); - g_dbus_message_set_flags (message, G_DBUS_MESSAGE_FLAGS_NO_REPLY_EXPECTED); - g_dbus_connection_send_message (database->bus, message, NULL, NULL); - g_object_unref (message); - g_free (rule); -} - -void -dconf_database_subscribe (DConfDatabase *database, - const gchar *name) -{ - send_match_rule (database, "AddMatch", name); -} - -void -dconf_database_unsubscribe (DConfDatabase *database, - const gchar *name) -{ - send_match_rule (database, "RemoveMatch", name); -} - -DConfDatabase * -dconf_database_get_for_backend (gpointer backend) -{ - static gsize instance; - - if (g_once_init_enter (&instance)) - { - DConfDatabase *database; - - database = g_slice_new0 (DConfDatabase); - g_static_mutex_init (&database->lock); - database->outstanding = NULL; - database->backends = g_slist_prepend (database->backends, backend); - database->bus = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL); - g_dbus_connection_add_filter (database->bus, - dconf_database_filter_function, - database, NULL); - dconf_database_reopen_file (database); - - g_once_init_leave (&instance, (gsize) database); - } - - return (DConfDatabase *) instance; -} diff --git a/gsettings/dconfdatabase.h b/gsettings/dconfdatabase.h deleted file mode 100644 index 8e0586d..0000000 --- a/gsettings/dconfdatabase.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright © 2010 Codethink Limited - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the licence, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Author: Ryan Lortie <desrt@desrt.ca> - */ - -#ifndef _dconfdatabase_h_ -#define _dconfdatabase_h_ - -#include <glib.h> - -typedef struct _DConfDatabase DConfDatabase; - -G_GNUC_INTERNAL -DConfDatabase * dconf_database_get_for_backend (gpointer backend); - -G_GNUC_INTERNAL -GVariant * dconf_database_read (DConfDatabase *database, - const gchar *key); -G_GNUC_INTERNAL -gchar ** dconf_database_list (DConfDatabase *database, - const gchar *path, - gsize *length); -G_GNUC_INTERNAL -void dconf_database_write (DConfDatabase *database, - const gchar *path_or_key, - GVariant *value, - gpointer origin_tag); -G_GNUC_INTERNAL -void dconf_database_write_tree (DConfDatabase *database, - GTree *tree, - gpointer origin_tag); -G_GNUC_INTERNAL -void dconf_database_subscribe (DConfDatabase *database, - const gchar *name); -G_GNUC_INTERNAL -void dconf_database_unsubscribe (DConfDatabase *database, - const gchar *name); - -#endif diff --git a/gsettings/dconfsettingsbackend.c b/gsettings/dconfsettingsbackend.c index d5ef40d..0c49865 100644 --- a/gsettings/dconfsettingsbackend.c +++ b/gsettings/dconfsettingsbackend.c @@ -21,23 +21,226 @@ #define G_SETTINGS_ENABLE_BACKEND #include <gio/gsettingsbackend.h> +#include <client/dconf-client.h> #include <gio/gio.h> -#include "dconfdatabase.h" +#include <string.h> typedef GSettingsBackendClass DConfSettingsBackendClass; +typedef struct _Outstanding Outstanding; typedef struct { GSettingsBackend backend; + GStaticMutex lock; - DConfDatabase *database; + DConfClient *client; + + Outstanding *outstanding; + GDBusConnection *bus; + guint64 anti_expose; } DConfSettingsBackend; G_DEFINE_TYPE (DConfSettingsBackend, dconf_settings_backend, G_TYPE_SETTINGS_BACKEND) + +struct _Outstanding +{ + Outstanding *next; + + volatile guint32 serial; + + gchar *reset_path, *set_key; + GVariant *set_value; + + GTree *tree; +}; + +static volatile guint32 * +dconf_settings_backend_new_outstanding (DConfSettingsBackend *dcsb, + const gchar *set_key, + GVariant *set_value, + GTree *tree) +{ + Outstanding *outstanding; + + outstanding = g_slice_new (Outstanding); + outstanding->reset_path = NULL; + outstanding->set_key = NULL; + + if (!set_key || g_str_has_suffix (set_key, "/")) + { + g_assert (set_value == NULL); + outstanding->reset_path = g_strdup (set_key); + } + else + outstanding->set_key = g_strdup (set_key); + + outstanding->serial = 0; + + if (set_value) + outstanding->set_value = g_variant_ref_sink (set_value); + else + outstanding->set_value = NULL; + + if (tree) + outstanding->tree = g_tree_ref (tree); + else + outstanding->tree = NULL; + + g_static_mutex_lock (&dcsb->lock); + outstanding->next = dcsb->outstanding; + dcsb->outstanding = outstanding; + g_static_mutex_unlock (&dcsb->lock); + + return &outstanding->serial; +} + +static gboolean +dconf_settings_backend_remove_outstanding (DConfSettingsBackend *dcsb, + GDBusMessage *message, + guint64 *anti_expose) +{ + gboolean found = FALSE; + Outstanding **node; + guint32 serial; + + if G_LIKELY (dcsb->outstanding == NULL) + return FALSE; + + serial = g_dbus_message_get_reply_serial (message); + + if (serial == 0) + return FALSE; + + g_static_mutex_lock (&dcsb->lock); + + /* this could be made more asymptotically efficient by using a queue + * or a double-linked list with a 'tail' pointer but the usual case + * here will be one outstanding item and very rarely more than a few. + * + * so we scan... + */ + for (node = &dcsb->outstanding; *node; node = &(*node)->next) + if ((*node)->serial == serial) + { + Outstanding *tmp; + + tmp = *node; + *node = tmp->next; + + g_static_mutex_unlock (&dcsb->lock); + + g_variant_get (g_dbus_message_get_body (message), "(t)", anti_expose); + + g_free (tmp->reset_path); + g_free (tmp->set_key); + + if (tmp->set_value) + g_variant_unref (tmp->set_value); + + if (tmp->tree) + g_tree_unref (tmp->tree); + + found = TRUE; + break; + } + + g_static_mutex_unlock (&dcsb->lock); + + return found; +} + +static gboolean +dconf_settings_backend_scan_outstanding_tree (GTree *tree, + const gchar *key, + gsize key_length, + gpointer *value) +{ + gchar *mykey; + + mykey = g_alloca (key_length + 1); + memcpy (mykey, key, key_length + 1); + + while (!g_tree_lookup_extended (tree, mykey, NULL, value) && + --key_length) + { + while (mykey[key_length - 1] != '/') + key_length--; + + mykey[key_length] = '\0'; + } + + return key_length != 0; +} + +static gboolean +dconf_settings_backend_scan_outstanding (DConfSettingsBackend *backend, + const gchar *key, + GVariant **value) +{ + gboolean found = FALSE; + Outstanding *node; + gsize length; + + length = strlen (key); + + if G_LIKELY (backend->outstanding == NULL) + return FALSE; + + g_static_mutex_lock (&backend->lock); + + for (node = backend->outstanding; node; node = node->next) + { + if (node->reset_path) + { + if (g_str_has_prefix (key, node->reset_path)) + { + *value = NULL; + found = TRUE; + break; + } + } + + else if (node->set_key) + { + if (strcmp (key, node->set_key) == 0) + { + if (node->set_value != NULL) + *value = g_variant_ref (node->set_value); + else + *value = NULL; + + found = TRUE; + break; + } + } + + else + { + gpointer result; + + if (dconf_settings_backend_scan_outstanding_tree (node->tree, key, + length, &result)) + { + if (result) + *value = g_variant_ref (result); + else + *value = NULL; + + found = TRUE; + break; + } + } + } + + g_static_mutex_unlock (&backend->lock); + + return found; +} + static GVariant * dconf_settings_backend_read (GSettingsBackend *backend, const gchar *key, @@ -45,21 +248,68 @@ dconf_settings_backend_read (GSettingsBackend *backend, gboolean default_value) { DConfSettingsBackend *dcsb = (DConfSettingsBackend *) backend; + DConfClientReadType type; + + if (!default_value) + { + GVariant *value; - if (default_value) - return NULL; + if (dconf_settings_backend_scan_outstanding (dcsb, key, &value)) + return value; - return dconf_database_read (dcsb->database, key); + type = DCONF_CLIENT_READ_NORMAL; + } + else + type = DCONF_CLIENT_READ_RESET; + + return dconf_client_read (dcsb->client, key, expected_type, type); } -static gchar ** -dconf_settings_backend_list (GSettingsBackend *backend, - const gchar *path, - gsize *length) +static void +dconf_settings_backend_send (GDBusConnection *bus, + DConfClientMessage *dccm, + volatile guint32 *serial) { - DConfSettingsBackend *dcsb = (DConfSettingsBackend *) backend; + GDBusMessage *message; + + message = g_dbus_message_new_method_call (dccm->destination, + dccm->object_path, + dccm->interface, + dccm->method); + g_dbus_message_set_body (message, dccm->body); + + if (serial) + g_dbus_connection_send_message (bus, message, serial, NULL); + else + g_dbus_connection_send_message_with_reply_sync (bus, message, -1, + NULL, NULL, NULL); + + g_variant_unref (dccm->body); + g_object_unref (message); +} + +static gboolean +dconf_settings_backend_get_bus (GDBusConnection **bus, + DConfClientMessage *dccm) +{ + switch (dccm->bus_type) + { + case 'e': + *bus = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL); + break; + + case 'y': + *bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, NULL); + break; - return dconf_database_list (dcsb->database, path, length); + default: + g_assert_not_reached (); + } + + if (*bus == NULL && dccm->body) + g_variant_unref (dccm->body); + + return *bus != NULL; } static gboolean @@ -69,8 +319,27 @@ dconf_settings_backend_write (GSettingsBackend *backend, gpointer origin_tag) { DConfSettingsBackend *dcsb = (DConfSettingsBackend *) backend; + DConfClientMessage message; + volatile guint32 *serial; + GDBusConnection *bus; + + if (!dconf_client_write (dcsb->client, &message, path_or_key, value)) + return FALSE; - dconf_database_write (dcsb->database, path_or_key, value, origin_tag); + if (!dconf_settings_backend_get_bus (&bus, &message)) + return FALSE; + + serial = dconf_settings_backend_new_outstanding (dcsb, + path_or_key, + value, + NULL); + + dconf_settings_backend_send (bus, &message, serial); + + if (g_str_has_suffix (path_or_key, "/")) + g_settings_backend_changed_path (backend, path_or_key, origin_tag); + else + g_settings_backend_changed (backend, path_or_key, origin_tag); return TRUE; } @@ -81,10 +350,35 @@ dconf_settings_backend_write_tree (GSettingsBackend *backend, gpointer origin_tag) { DConfSettingsBackend *dcsb = (DConfSettingsBackend *) backend; + DConfClientMessage message; + volatile guint32 *serial; + GDBusConnection *bus; + const gchar **keys; + GVariant **values; + gchar *prefix; - dconf_database_write_tree (dcsb->database, tree, origin_tag); + g_settings_backend_flatten_tree (tree, &prefix, &keys, &values); - return TRUE; + if (dconf_client_write_many (dcsb->client, &message, prefix, keys, values)) + { + if (dconf_settings_backend_get_bus (&bus, &message)) + { + serial = dconf_settings_backend_new_outstanding (dcsb, NULL, + NULL, tree); + + dconf_settings_backend_send (bus, &message, serial); + + g_settings_backend_keys_changed (backend, prefix, keys, origin_tag); + + return TRUE; + } + } + + g_free (prefix); + g_free (values); + g_free (keys); + + return FALSE; } static void @@ -92,14 +386,21 @@ dconf_settings_backend_reset (GSettingsBackend *backend, const gchar *path_or_key, gpointer origin_tag) { - dconf_settings_backend_write (backend, path_or_key, NULL, origin_tag); + g_assert_not_reached (); } static gboolean dconf_settings_backend_get_writable (GSettingsBackend *backend, - const gchar *key) + const gchar *name) { - return TRUE; + DConfSettingsBackend *dcsb = (DConfSettingsBackend *) backend; + DConfClientMessage message; + GDBusConnection *bus; + + if (!dconf_client_is_writable (dcsb->client, &message, name)) + return FALSE; + + return dconf_settings_backend_get_bus (&bus, &message); } static void @@ -107,8 +408,13 @@ dconf_settings_backend_subscribe (GSettingsBackend *backend, const gchar *name) { DConfSettingsBackend *dcsb = (DConfSettingsBackend *) backend; + DConfClientMessage message; + GDBusConnection *bus; - dconf_database_subscribe (dcsb->database, name); + dconf_client_watch (dcsb->client, &message, name); + + if (dconf_settings_backend_get_bus (&bus, &message)) + dconf_settings_backend_send (bus, &message, NULL); } static void @@ -116,8 +422,13 @@ dconf_settings_backend_unsubscribe (GSettingsBackend *backend, const gchar *name) { DConfSettingsBackend *dcsb = (DConfSettingsBackend *) backend; + DConfClientMessage message; + GDBusConnection *bus; + + dconf_client_unwatch (dcsb->client, &message, name); - dconf_database_unsubscribe (dcsb->database, name); + if (dconf_settings_backend_get_bus (&bus, &message)) + dconf_settings_backend_send (bus, &message, NULL); } static void @@ -128,14 +439,14 @@ dconf_settings_backend_sync (GSettingsBackend *backend) static void dconf_settings_backend_init (DConfSettingsBackend *dcsb) { - dcsb->database = dconf_database_get_for_backend (dcsb); + dcsb->client = dconf_client_new (NULL); } static void dconf_settings_backend_class_init (GSettingsBackendClass *class) { class->read = dconf_settings_backend_read; - class->list = dconf_settings_backend_list; + // class->list = dconf_settings_backend_list; class->write = dconf_settings_backend_write; class->write_keys = dconf_settings_backend_write_tree; class->reset = dconf_settings_backend_reset; |