[dconf] test async commands with the cmdline tool
- From: Ryan Lortie <ryanl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dconf] test async commands with the cmdline tool
- Date: Mon, 24 May 2010 17:49:34 +0000 (UTC)
commit 6a259db1890a888bc3d55ecd635bfabce44a0fc1
Author: Ryan Lortie <desrt desrt ca>
Date: Mon May 24 13:48:40 2010 -0400
test async commands with the cmdline tool
fix a silly bug that the testing found
bin/dconf.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++++-
client/dconf-client.c | 2 +-
2 files changed, 51 insertions(+), 2 deletions(-)
---
diff --git a/bin/dconf.c b/bin/dconf.c
index c46a176..5252f4a 100644
--- a/bin/dconf.c
+++ b/bin/dconf.c
@@ -51,6 +51,48 @@ ensure (const gchar *type,
return TRUE;
}
+static void
+write_done (GObject *object,
+ GAsyncResult *result,
+ gpointer user_data)
+{
+ GError *error = NULL;
+
+ if (!dconf_client_write_finish (DCONF_CLIENT (object), result, NULL, &error))
+ g_error ("%s\n", error->message);
+
+ g_print ("done\n");
+}
+
+static void
+do_async_command (DConfClient *client,
+ int argc,
+ char **argv)
+{
+ const gchar *cmd;
+
+ cmd = shift (&argc, &argv);
+
+ if (g_strcmp0 (cmd, "write") == 0)
+ {
+ const gchar *key, *strval;
+ GVariant *value;
+
+ if (!grab_args (argc, argv, "key and value", NULL, 2, &key, &strval))
+ g_assert_not_reached ();
+
+ if (!ensure ("key", key, dconf_is_key, NULL))
+ g_assert_not_reached ();
+
+ value = g_variant_parse (NULL, strval, NULL, NULL, NULL);
+
+ g_assert (value != NULL);
+
+ return dconf_client_write_async (client, key, value,
+ NULL, write_done, NULL);
+ }
+}
+
static gboolean
do_sync_command (DConfClient *client,
int argc,
@@ -61,7 +103,14 @@ do_sync_command (DConfClient *client,
cmd = shift (&argc, &argv);
- if (g_strcmp0 (cmd, "read") == 0)
+ if (g_strcmp0 (cmd, "async") == 0)
+ {
+ do_async_command (client, argc, argv);
+ g_main_loop_run (g_main_loop_new (NULL, FALSE));
+ return TRUE;
+ }
+
+ else if (g_strcmp0 (cmd, "read") == 0)
{
const gchar *key;
GVariant *value;
diff --git a/client/dconf-client.c b/client/dconf-client.c
index 442ad9c..3a33397 100644
--- a/client/dconf-client.c
+++ b/client/dconf-client.c
@@ -100,7 +100,7 @@ dconf_client_async_op_complete (DConfClientAsyncOp *op,
g_object_unref (op->cancellable);
if (op->dcem.body)
- g_object_unref (op->dcem.body);
+ g_variant_unref (op->dcem.body);
if (in_idle)
g_simple_async_result_complete_in_idle (op->simple);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]