X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=gio%2Fgdbusutils.c;h=1ecc57b78e844b01e20f3fe9cb4e1879fa1f49b3;hb=6fcbc26e14f77401c3f2a389873b04299012c9fc;hp=35dc2170045a29142993b6cc791e3628ae1d22a6;hpb=6a45180c95baaddedafacf1780de2670c5a6a44a;p=platform%2Fupstream%2Fglib.git diff --git a/gio/gdbusutils.c b/gio/gdbusutils.c index 35dc217..1ecc57b 100644 --- a/gio/gdbusutils.c +++ b/gio/gdbusutils.c @@ -13,9 +13,7 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General - * Public License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place, Suite 330, - * Boston, MA 02111-1307, USA. + * Public License along with this library; if not, see . * * Author: David Zeuthen */ @@ -32,7 +30,7 @@ /** * SECTION:gdbusutils * @title: D-Bus Utilities - * @short_description: Various utilities related to D-Bus. + * @short_description: Various utilities related to D-Bus * @include: gio/gio.h * * Various utility routines related to D-Bus. @@ -355,7 +353,7 @@ g_dbus_is_guid (const gchar *string) /** * g_dbus_gvariant_to_gvalue: * @value: A #GVariant. - * @out_gvalue: Return location pointing to a zero-filled (uninitialized) #GValue. + * @out_gvalue: (out): Return location pointing to a zero-filled (uninitialized) #GValue. * * Converts a #GVariant to a #GValue. If @value is floating, it is consumed. * @@ -421,9 +419,9 @@ g_dbus_gvariant_to_gvalue (GVariant *value, g_value_set_uint64 (out_gvalue, g_variant_get_uint64 (value)); break; - case G_VARIANT_CLASS_HANDLE: - g_value_init (out_gvalue, G_TYPE_INT); - g_value_set_int (out_gvalue, g_variant_get_int32 (value)); + case G_VARIANT_CLASS_FLOAT: + g_value_init (out_gvalue, G_TYPE_FLOAT); + g_value_set_float (out_gvalue, g_variant_get_float (value)); break; case G_VARIANT_CLASS_DOUBLE: @@ -461,6 +459,12 @@ g_dbus_gvariant_to_gvalue (GVariant *value, g_value_take_boxed (out_gvalue, array); break; + case G_VARIANT_CLASS_OBJECT_PATH: + g_value_init (out_gvalue, G_TYPE_STRV); + array = g_variant_dup_objv (value, NULL); + g_value_take_boxed (out_gvalue, array); + break; + case G_VARIANT_CLASS_ARRAY: switch (g_variant_type_peek_string (type)[2]) { @@ -484,6 +488,7 @@ g_dbus_gvariant_to_gvalue (GVariant *value, } break; + case G_VARIANT_CLASS_HANDLE: case G_VARIANT_CLASS_VARIANT: case G_VARIANT_CLASS_MAYBE: case G_VARIANT_CLASS_TUPLE: @@ -497,86 +502,41 @@ g_dbus_gvariant_to_gvalue (GVariant *value, /** * g_dbus_gvalue_to_gvariant: - * @gvalue: A #GValue to convert to a #GVariant. - * @type: A #GVariantType. + * @gvalue: A #GValue to convert to a #GVariant + * @type: A #GVariantType * - * Converts a #GValue to a #GVariant of the type indicated by the @type parameter. + * Converts a #GValue to a #GVariant of the type indicated by the @type + * parameter. * * The conversion is using the following rules: - * - * #GValue / #GVariant conversion rules - * - * - * - * If the #GType for @gvalue is... - * ... then @type must be - * - * - * - * - * #G_TYPE_STRING - * 's', 'o', 'g' or 'ay' - * - * - * #G_TYPE_STRV - * 'as' or 'aay' - * - * - * #G_TYPE_BOOLEAN - * 'b' - * - * - * #G_TYPE_UCHAR - * 'y' - * - * - * #G_TYPE_INT - * 'i' or 'n' - * - * - * #G_TYPE_UINT - * 'u' or 'q' - * - * - * #G_TYPE_INT64 - * 'x' - * - * - * #G_TYPE_UINT64 - * 't' - * - * - * #G_TYPE_INT - * 'h' - * - * - * #G_TYPE_DOUBLE - * 'd' - * - * - * #G_TYPE_VARIANT - * Any #GVariantType - * - * - * - *
+ * + * - #G_TYPE_STRING: 's', 'o', 'g' or 'ay' + * - #G_TYPE_STRV: 'as', 'ao' or 'aay' + * - #G_TYPE_BOOLEAN: 'b' + * - #G_TYPE_UCHAR: 'y' + * - #G_TYPE_INT: 'i', 'n' + * - #G_TYPE_UINT: 'u', 'q' + * - #G_TYPE_INT64 'x' + * - #G_TYPE_UINT64: 't' + * - #G_TYPE_DOUBLE: 'd' + * - #G_TYPE_VARIANT: Any #GVariantType + * * This can fail if e.g. @gvalue is of type #G_TYPE_STRING and @type - * is 'i'. It will - * also fail for any #GType (including e.g. #G_TYPE_OBJECT and - * #G_TYPE_BOXED derived-types) not in the table above. + * is ['i'][G-VARIANT-TYPE-INT32:CAPS]. It will also fail for any #GType + * (including e.g. #G_TYPE_OBJECT and #G_TYPE_BOXED derived-types) not + * in the table above. * * Note that if @gvalue is of type #G_TYPE_VARIANT and its value is - * %NULL, the empty #GVariant instance (never - * %NULL) for @type is returned (e.g. 0 for scalar types, the empty - * string for string types, '/' for object path - * types, the empty array for any array type and so on). + * %NULL, the empty #GVariant instance (never %NULL) for @type is + * returned (e.g. 0 for scalar types, the empty string for string types, + * '/' for object path types, the empty array for any array type and so on). * * See the g_dbus_gvariant_to_gvalue() function for how to convert a * #GVariant to a #GValue. * - * Returns: A #GVariant (never floating) of #GVariantType - * @type holding the data from @gvalue or %NULL in case of - * failure. Free with g_variant_unref(). + * Returns: A #GVariant (never floating) of #GVariantType @type holding + * the data from @gvalue or %NULL in case of failure. Free with + * g_variant_unref(). * * Since: 2.30 */ @@ -638,8 +598,8 @@ g_dbus_gvalue_to_gvariant (const GValue *gvalue, ret = g_variant_ref_sink (g_variant_new_uint64 (g_value_get_uint64 (gvalue))); break; - case G_VARIANT_CLASS_HANDLE: - ret = g_variant_ref_sink (g_variant_new_handle (g_value_get_int (gvalue))); + case G_VARIANT_CLASS_FLOAT: + ret = g_variant_ref_sink (g_variant_new_float (g_value_get_float (gvalue))); break; case G_VARIANT_CLASS_DOUBLE: @@ -684,6 +644,13 @@ g_dbus_gvalue_to_gvariant (const GValue *gvalue, ret = g_variant_ref_sink (g_variant_new_strv (as, -1)); break; + case G_VARIANT_CLASS_OBJECT_PATH: + as = g_value_get_boxed (gvalue); + if (as == NULL) + as = empty_strv; + ret = g_variant_ref_sink (g_variant_new_objv (as, -1)); + break; + case G_VARIANT_CLASS_ARRAY: switch (g_variant_type_peek_string (type)[2]) { @@ -706,7 +673,7 @@ g_dbus_gvalue_to_gvariant (const GValue *gvalue, } break; - default: + case G_VARIANT_CLASS_HANDLE: case G_VARIANT_CLASS_VARIANT: case G_VARIANT_CLASS_MAYBE: case G_VARIANT_CLASS_TUPLE: