summaryrefslogtreecommitdiff
path: root/client/dconf-client.c
diff options
context:
space:
mode:
authorRyan Lortie <desrt@desrt.ca>2012-07-02 00:49:46 -0400
committerRyan Lortie <desrt@desrt.ca>2012-07-02 00:49:46 -0400
commit4eea8cb823c5a113d8209b04102f17f08df853d6 (patch)
tree5a8bb7d0c220e00981c0f0ba6e834ac8e1f6e584 /client/dconf-client.c
parent6a675a5bdef5949e2397b0d5ca9d0c8a36ccedfd (diff)
downloaddconf-4eea8cb823c5a113d8209b04102f17f08df853d6.tar.gz
Massively reorganise the client-side
This commit represents a rather complete rethinking of DConfEngine. - the different kinds of sources are now properly abstracted. This will make landing NFS support substantially easier. - there is now substantially more internal documentation - DConfEngineMessage is gone and replaced with ordinary function calls to be implemented by the D-Bus glue code - the GDBus glue has been factored out and is now shared between the client library and GSettings - the "outstanding" queue logic from the GSettings backend is now in the engine - all changes now go through a single API that accepts a (new) DConfChangeset object. Currently this only supports the current operations (ie: setting and resetting). In the future this object will also support the directory operations required by GSettingsList and will be the basis for the new approach to implementing the 'delayed' GSettingsBackend (which will be the method by which those two concepts can co-exist). The (internal) API of the engine changed substantially. This caused the following: - the libdconf client library has been rewritten in C. Most of the complicated aspects of it (that made it more convenience to use Vala) are now gone. - during the rewrite of libdconf, the DConfClient API changed a bit to look more like a proper GObject. It now makes GIO-style use of thread-default main contexts and uses GObject signals for notifications (instead of hand-rolled callbacks). - the GSettings backend has been substantially simplified (the "outstanding" logic is gone). No externally-visible changes. - the dbus-1 backend has taken a copy of the old engine code for now until it can be ported to the new engine and sufficiently tested. No externally-visible changes. - the dconf commandline tool and dconf-editor required minor changes to adjust to the DConfClient API changes There is a substantial amount of cleaning up and finishing of work to be done. There are many stubs remaining. There are likely still a large number of bugs.
Diffstat (limited to 'client/dconf-client.c')
-rw-r--r--client/dconf-client.c82
1 files changed, 36 insertions, 46 deletions
diff --git a/client/dconf-client.c b/client/dconf-client.c
index 1300269..ffc179e 100644
--- a/client/dconf-client.c
+++ b/client/dconf-client.c
@@ -23,10 +23,11 @@
#include "dconf-client.h"
#include "dconf-engine.h"
+#include <glib-object.h>
struct _DConfClient
{
- GObject parent_class;
+ GObject parent_instance;
DConfEngine *engine;
GMainContext *context;
@@ -39,7 +40,6 @@ enum
SIGNAL_CHANGED,
N_SIGNALS
};
-
static guint dconf_client_signals[N_SIGNALS];
static void
@@ -64,11 +64,11 @@ dconf_client_class_init (DConfClientClass *class)
{
class->finalize = dconf_client_finalize;
- dconf_client_signals[SIGNAL_CHANGED] =
- g_signal_new ("changed", DCONF_TYPE_CLIENT, G_SIGNAL_RUN_FIRST,
- 0, NULL, NULL, NULL, G_TYPE_NONE, 2,
- G_TYPE_STRING | G_SIGNAL_TYPE_STATIC_SCOPE,
- G_TYPE_STRV | G_SIGNAL_TYPE_STATIC_SCOPE);
+ dconf_client_signals[SIGNAL_CHANGED] = g_signal_new ("changed", DCONF_TYPE_CLIENT, G_SIGNAL_RUN_LAST,
+ 0, NULL, NULL, NULL, G_TYPE_NONE, 3,
+ G_TYPE_STRING | G_SIGNAL_TYPE_STATIC_SCOPE,
+ G_TYPE_STRV | G_SIGNAL_TYPE_STATIC_SCOPE,
+ G_TYPE_STRING | G_SIGNAL_TYPE_STATIC_SCOPE);
}
typedef struct
@@ -76,18 +76,21 @@ typedef struct
DConfClient *client;
gchar *prefix;
gchar **changes;
+ gchar *tag;
} DConfClientChange;
static gboolean
-dconf_engine_emit_changed (gpointer user_data)
+dconf_client_dispatch_change_signal (gpointer user_data)
{
DConfClientChange *change = user_data;
- g_signal_emit (change->client, dconf_client_signals[SIGNAL_CHANGED], 0, change->prefix, change->changes);
+ g_signal_emit (change->client, dconf_client_signals[SIGNAL_CHANGED], 0,
+ change->prefix, change->changes, change->tag);
+ g_object_unref (change->client);
g_free (change->prefix);
g_strfreev (change->changes);
- g_object_unref (change->client);
+ g_free (change->tag);
g_slice_free (DConfClientChange, change);
return G_SOURCE_REMOVE;
@@ -97,6 +100,7 @@ void
dconf_engine_change_notify (DConfEngine *engine,
const gchar *prefix,
const gchar * const *changes,
+ const gchar * tag,
gpointer user_data)
{
DConfClient *client = user_data;
@@ -105,13 +109,24 @@ dconf_engine_change_notify (DConfEngine *engine,
g_return_if_fail (DCONF_IS_CLIENT (client));
change = g_slice_new (DConfClientChange);
+ change->client = g_object_ref (client);
change->prefix = g_strdup (prefix);
change->changes = g_strdupv ((gchar **) changes);
- change->client = g_object_ref (client);
+ change->tag = g_strdup (tag);
- g_main_context_invoke (client->context,
- dconf_engine_emit_changed,
- change);
+ g_main_context_invoke (client->context, dconf_client_dispatch_change_signal, change);
+}
+
+DConfClient *
+dconf_client_new (void)
+{
+ DConfClient *client;
+
+ client = g_object_new (DCONF_TYPE_CLIENT, NULL);
+ client->engine = dconf_engine_new (client);
+ client->context = g_main_context_ref_thread_default ();
+
+ return client;
}
GVariant *
@@ -125,13 +140,12 @@ dconf_client_read (DConfClient *client,
gchar **
dconf_client_list (DConfClient *client,
- const gchar *dir)
+ const gchar *dir,
+ gint *length)
{
g_return_val_if_fail (DCONF_IS_CLIENT (client), NULL);
- return NULL;
-
- /*: return dconf_engine_list (client->engine, NULL, dir); */
+ return dconf_engine_list (client->engine, dir, length);
}
gboolean
@@ -143,18 +157,6 @@ dconf_client_is_writable (DConfClient *client,
return dconf_engine_is_writable (client->engine, key);
}
-static DConfChangeset *
-dconf_client_make_simple_change (const gchar *key,
- GVariant *value)
-{
- DConfChangeset *changeset;
-
- changeset = dconf_changeset_new ();
- dconf_changeset_set (changeset, key, value);
-
- return changeset;
-}
-
gboolean
dconf_client_write_fast (DConfClient *client,
const gchar *key,
@@ -166,7 +168,7 @@ dconf_client_write_fast (DConfClient *client,
g_return_val_if_fail (DCONF_IS_CLIENT (client), FALSE);
- changeset = dconf_client_make_simple_change (key, value);
+ changeset = dconf_changeset_new_write (key, value);
success = dconf_engine_change_fast (client->engine, changeset, error);
dconf_changeset_unref (changeset);
@@ -186,7 +188,7 @@ dconf_client_write_sync (DConfClient *client,
g_return_val_if_fail (DCONF_IS_CLIENT (client), FALSE);
- changeset = dconf_client_make_simple_change (key, value);
+ changeset = dconf_changeset_new_write (key, value);
success = dconf_engine_change_sync (client->engine, changeset, tag, error);
dconf_changeset_unref (changeset);
@@ -225,8 +227,8 @@ dconf_client_watch_fast (DConfClient *client,
}
void
-dconf_client_watch_sync (DConfClient *client,
- const gchar *path)
+dconf_client_watch_sync (DConfClient *client,
+ const gchar *path)
{
g_return_if_fail (DCONF_IS_CLIENT (client));
@@ -250,15 +252,3 @@ dconf_client_unwatch_sync (DConfClient *client,
dconf_engine_unwatch_sync (client->engine, path);
}
-
-DConfClient *
-dconf_client_new (void)
-{
- DConfClient *client;
-
- client = g_object_new (DCONF_TYPE_CLIENT, NULL);
- client->engine = dconf_engine_new (client);
- client->context = g_main_context_ref_thread_default ();
-
- return client;
-}