[dconf/wip/reorg: 1/7] service: Drop a level of variant wrapping



commit 213476252cbf171f6f65361e763cfab6614c407b
Author: Ryan Lortie <desrt desrt ca>
Date:   Sun Jul 1 12:24:25 2012 -0400

    service: Drop a level of variant wrapping
    
    Internally, the service was passing around GVariant values with an extra
    layer of variant wrapping (ie: how we received them off the wire).
    
    Stop doing that because it's pointless.

 service/dconf-rebuilder.c |    5 +----
 service/service.c         |   13 ++++++++-----
 2 files changed, 9 insertions(+), 9 deletions(-)
---
diff --git a/service/dconf-rebuilder.c b/service/dconf-rebuilder.c
index d7f4cb3..65271cd 100644
--- a/service/dconf-rebuilder.c
+++ b/service/dconf-rebuilder.c
@@ -97,12 +97,9 @@ dconf_rebuilder_put_item (DConfRebuilderState *state)
   if (state->values[state->index] != NULL)
     {
       gchar *fullname;
-      GVariant *ouch;
 
       fullname = g_strconcat (state->prefix, state->keys[state->index], NULL);
-      ouch = g_variant_get_variant (state->values[state->index]);
-      dconf_rebuilder_insert (state->table, fullname, ouch);
-      g_variant_unref (ouch);
+      dconf_rebuilder_insert (state->table, fullname, state->values[state->index]);
       g_free (fullname);
     }
 
diff --git a/service/service.c b/service/service.c
index 84ede50..3a87b63 100644
--- a/service/service.c
+++ b/service/service.c
@@ -95,7 +95,7 @@ emit_notify_signal (GDBusConnection  *connection,
 }
 
 static void
-unwrap_maybe (GVariant **ptr)
+unwrap_maybe_and_variant (GVariant **ptr)
 {
   GVariant *array, *child;
   gsize n_children;
@@ -109,11 +109,12 @@ unwrap_maybe (GVariant **ptr)
       child = NULL;
       break;
     case 1: default:
-      child = g_variant_get_child_value (array, 0);
+      g_variant_get_child (array, 0, "v", &child);
       break;
     case 2:
       {
         GVariant *untrusted;
+        GVariant *trusted;
         GVariant *ay;
 
         g_variant_get_child (array, 0, "v", &ay);
@@ -130,8 +131,10 @@ unwrap_maybe (GVariant **ptr)
                                              FALSE,
                                              (GDestroyNotify) g_variant_unref, ay);
         g_variant_ref_sink (untrusted);
-        child = g_variant_get_normal_form (untrusted);
+        trusted = g_variant_get_normal_form (untrusted);
         g_variant_unref (untrusted);
+
+        g_variant_get (trusted, "v", &child);
       }
     }
 
@@ -244,7 +247,7 @@ method_call (GDBusConnection       *connection,
       g_variant_get (parameters, "(@s av)", &keyvalue, &value);
       key = g_variant_get_string (keyvalue, &key_length);
       g_variant_unref (keyvalue);
-      unwrap_maybe (&value);
+      unwrap_maybe_and_variant (&value);
 
       if (key[0] != '/' || strstr (key, "//"))
         {
@@ -312,7 +315,7 @@ method_call (GDBusConnection       *connection,
       values = g_new (GVariant *, length);
       while (g_variant_iter_next (iter, "(&s av)", &keys[i], &values[i]))
         {
-          unwrap_maybe (&values[i]);
+          unwrap_maybe_and_variant (&values[i]);
 
           if (keys[i][0] == '/' || strstr (keys[i], "//") ||
               (i > 0 && !(strcmp (keys[i - 1], keys[i]) < 0)))



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]