Support GValues of type G_TYPE_VARIANT
authorAlberto Mardegan <alberto.mardegan@canonical.com>
Wed, 17 Oct 2012 07:06:24 +0000 (10:06 +0300)
committerAlberto Mardegan <alberto.mardegan@canonical.com>
Wed, 17 Oct 2012 07:06:24 +0000 (10:06 +0300)
Allow passing more complex types to signon_auth_session_process() by
supporting GValues containing a GVariant.

http://code.google.com/p/accounts-sso/issues/detail?id=121

libsignon-glib/signon-utils.c

index 4321af2..aff590e 100644 (file)
@@ -103,9 +103,17 @@ GVariant *signon_hash_table_to_variant (const GHashTable *hash_table)
     while (g_hash_table_iter_next (&iter, (gpointer)&key, (gpointer)&value))
     {
         GVariant *val;
-        const GVariantType *type;
-        type = signon_gtype_to_variant_type (G_VALUE_TYPE (value));
-        val = g_dbus_gvalue_to_gvariant (value, type);
+
+        if (G_VALUE_TYPE (value) == G_TYPE_VARIANT)
+        {
+            val = g_value_get_variant (value);
+        }
+        else
+        {
+            const GVariantType *type;
+            type = signon_gtype_to_variant_type (G_VALUE_TYPE (value));
+            val = g_dbus_gvalue_to_gvariant (value, type);
+        }
         g_variant_builder_add (&builder, "{sv}", key, val);
     }
     return g_variant_builder_end (&builder);