diff options
author | Ryan Lortie <desrt@desrt.ca> | 2010-07-19 13:52:33 -0400 |
---|---|---|
committer | Ryan Lortie <desrt@desrt.ca> | 2010-07-19 13:52:33 -0400 |
commit | 1e93f987b56bd157f74808e0d0eb4d274437ba68 (patch) | |
tree | 1add3f5ba93fe1555d6d51c2d6868b111b20527a /service | |
parent | 78084a0dbfd705f214f79f8e254a54f8cb1a391f (diff) | |
download | dconf-1e93f987b56bd157f74808e0d0eb4d274437ba68.tar.gz |
bring service API in line with the client
also, cache GDBusConnections in the client since GDBus doesn't keep them
alive for us.
Diffstat (limited to 'service')
-rw-r--r-- | service/dconf-interfaces.c | 8 | ||||
-rw-r--r-- | service/dconf-writer.c | 8 | ||||
-rw-r--r-- | service/dconf-writer.h | 1 | ||||
-rw-r--r-- | service/service.c | 37 |
4 files changed, 36 insertions, 18 deletions
diff --git a/service/dconf-interfaces.c b/service/dconf-interfaces.c index c50232d..87ecad1 100644 --- a/service/dconf-interfaces.c +++ b/service/dconf-interfaces.c @@ -24,16 +24,16 @@ static const GDBusArgInfo name_arg = { -1, (gchar *) "name", (gchar *) "s" }; static const GDBusArgInfo path_arg = { -1, (gchar *) "path", (gchar *) "s" }; static const GDBusArgInfo names_arg = { -1, (gchar *) "names", (gchar *) "as" }; -static const GDBusArgInfo serial_arg = { -1, (gchar *) "serial", (gchar *) "t" }; +static const GDBusArgInfo tag_arg = { -1, (gchar *) "tag", (gchar *) "s" }; static const GDBusArgInfo value_arg = { -1, (gchar *) "value", (gchar *) "av" }; static const GDBusArgInfo values_arg = { -1, (gchar *) "values", (gchar *) "a(sav)" }; static const GDBusArgInfo locked_arg = { -1, (gchar *) "locked", (gchar *) "b" }; static const GDBusArgInfo *write_in[] = { &name_arg, &value_arg, NULL }; -static const GDBusArgInfo *write_out[] = { &serial_arg, NULL }; +static const GDBusArgInfo *write_out[] = { &tag_arg, NULL }; static const GDBusArgInfo *many_in[] = { &path_arg, &values_arg, NULL }; -static const GDBusArgInfo *many_out[] = { &serial_arg, NULL }; -static const GDBusArgInfo *notify_args[] = { &path_arg, &names_arg, NULL }; +static const GDBusArgInfo *many_out[] = { &tag_arg, NULL }; +static const GDBusArgInfo *notify_args[] = { &path_arg, &names_arg, &tag_arg, NULL }; static const GDBusArgInfo *setlock_in[] = { &name_arg, &locked_arg, NULL }; static const GDBusArgInfo *setlock_out[] = { NULL }; diff --git a/service/dconf-writer.c b/service/dconf-writer.c index 00dac13..c4d21a7 100644 --- a/service/dconf-writer.c +++ b/service/dconf-writer.c @@ -35,6 +35,7 @@ static const gchar *dconf_writer_db_dir; struct OPAQUE_TYPE__DConfWriter { + gchar *name; gchar *path; gchar *shm; }; @@ -134,6 +135,12 @@ dconf_writer_set_lock (DConfWriter *writer, return TRUE; } +const gchar * +dconf_writer_get_name (DConfWriter *writer) +{ + return writer->name; +} + DConfWriter * dconf_writer_new (const gchar *name) { @@ -142,6 +149,7 @@ dconf_writer_new (const gchar *name) writer = g_slice_new (DConfWriter); writer->path = g_build_filename (dconf_writer_db_dir, name, NULL); writer->shm = g_build_filename (dconf_writer_shm_dir, name, NULL); + writer->name = g_strdup (name); return writer; } diff --git a/service/dconf-writer.h b/service/dconf-writer.h index 8dc1d9d..8c21f3b 100644 --- a/service/dconf-writer.h +++ b/service/dconf-writer.h @@ -30,6 +30,7 @@ const gchar * dconf_writer_get_shm_dir (void); gchar ** dconf_writer_list_existing (void); void dconf_writer_init (void); DConfWriter * dconf_writer_new (const gchar *name); +const gchar * dconf_writer_get_name (DConfWriter *writer); gboolean dconf_writer_write (DConfWriter *writer, const gchar *name, GVariant *value, diff --git a/service/service.c b/service/service.c index cab18e8..2c08a8e 100644 --- a/service/service.c +++ b/service/service.c @@ -21,6 +21,7 @@ #include <gio/gio.h> #include <string.h> +#include <stdio.h> #include "dconf-interfaces.h" #include "dconf-writer.h" @@ -29,7 +30,8 @@ static guint64 dconf_service_serial; static void emit_notify_signal (GDBusConnection *connection, - guint64 serial, + DConfWriter *writer, + const gchar *tag, const gchar *prefix, const gchar **keys, guint n_keys) @@ -37,6 +39,7 @@ emit_notify_signal (GDBusConnection *connection, GVariantBuilder builder; GVariant *items; gchar *path; + gchar *obj; g_variant_builder_init (&builder, G_VARIANT_TYPE ("as")); @@ -79,12 +82,15 @@ emit_notify_signal (GDBusConnection *connection, else path = g_strdup (prefix); + obj = g_strjoin (NULL, "/ca/desrt/dconf/Writer/", + dconf_writer_get_name (writer), NULL); g_dbus_connection_emit_signal (connection, NULL, "/", "ca.desrt.dconf.Writer", "Notify", - g_variant_new ("(ts@as)", - serial, path, items), + g_variant_new ("(s@ass)", + path, items, tag), NULL); g_free (path); + g_free (obj); } static void @@ -122,8 +128,9 @@ method_call (GDBusConnection *connection, const gchar *key; gsize key_length; GVariant *value; - guint64 serial; GVariant *none; + gchar tag[20]; + gchar *path; g_variant_get (parameters, "(@s@av)", &keyvalue, &value); key = g_variant_get_string (keyvalue, &key_length); @@ -157,15 +164,18 @@ method_call (GDBusConnection *connection, return; } - serial = dconf_service_serial++; + snprintf (tag, sizeof tag, "%"G_GUINT64_FORMAT, dconf_service_serial++); g_dbus_method_invocation_return_value (invocation, - g_variant_new ("(t)", serial)); + g_variant_new ("(s)", tag)); none = g_variant_new_array (G_VARIANT_TYPE_STRING, NULL, 0); - g_dbus_connection_emit_signal (connection, NULL, "/", + path = g_strjoin (NULL, "/ca/desrt/dconf/Writer/", + dconf_writer_get_name (writer), NULL); + g_dbus_connection_emit_signal (connection, NULL, path, "ca.desrt.dconf.Writer", "Notify", - g_variant_new ("(ts@as)", - serial, key, none), + g_variant_new ("(s@ass)", + key, none, tag), NULL); + g_free (path); } else if (strcmp (method_name, "Merge") == 0) @@ -175,7 +185,7 @@ method_call (GDBusConnection *connection, GVariantIter *iter; const gchar **keys; GVariant **values; - guint64 serial; + gchar tag[20]; gsize length; gint i = 0; gint j; @@ -218,11 +228,10 @@ method_call (GDBusConnection *connection, return; } - serial = dconf_service_serial++; - + snprintf (tag, sizeof tag, "%"G_GUINT64_FORMAT, dconf_service_serial++); g_dbus_method_invocation_return_value (invocation, - g_variant_new ("(t)", serial)); - emit_notify_signal (connection, serial, prefix, keys, i); + g_variant_new ("(s)", tag)); + emit_notify_signal (connection, writer, tag, prefix, keys, i); for (j = 0; j < i; j++) if (values[j] != NULL) |