dbus/glib dbus-gobject.c, 1.52, 1.53 dbus-gvalue.c, 1.23,
1.24 dbus-gvalue.h, 1.7, 1.8
Robert McQueen
robot101 at freedesktop.org
Sun Nov 27 08:55:11 PST 2005
Update of /cvs/dbus/dbus/glib
In directory gabe:/tmp/cvs-serv19141/glib
Modified Files:
dbus-gobject.c dbus-gvalue.c dbus-gvalue.h
Log Message:
2005-11-27 Carlos Garcia Campos <carlosgc at gnome.org>
* glib/dbus-gobject.c: Append a GValue instead of a basic type in
method return message for property getters
Index: dbus-gobject.c
===================================================================
RCS file: /cvs/dbus/dbus/glib/dbus-gobject.c,v
retrieving revision 1.52
retrieving revision 1.53
diff -u -d -r1.52 -r1.53
--- dbus-gobject.c 22 Nov 2005 20:37:00 -0000 1.52
+++ dbus-gobject.c 27 Nov 2005 16:55:09 -0000 1.53
@@ -690,25 +690,41 @@
GObject *object,
GParamSpec *pspec)
{
- GType value_type;
+ GType value_gtype;
GValue value = {0, };
+ gchar *variant_sig;
DBusMessage *ret;
- DBusMessageIter iter;
-
- value_type = G_PARAM_SPEC_VALUE_TYPE (pspec);
+ DBusMessageIter iter, subiter;
ret = dbus_message_new_method_return (message);
if (ret == NULL)
g_error ("out of memory");
- g_value_init (&value, value_type);
+
+ g_value_init (&value, pspec->value_type);
g_object_get_property (object, pspec->name, &value);
- value_type = G_VALUE_TYPE (&value);
+ variant_sig = _dbus_gvalue_to_signature (&value);
+ if (variant_sig == NULL)
+ {
+ value_gtype = G_VALUE_TYPE (&value);
+ g_warning ("Cannot marshal type \"%s\" in variant", g_type_name (value_gtype));
+ g_value_unset (&value);
+ return ret;
+ }
- dbus_message_iter_init_append (message, &iter);
+ dbus_message_iter_init_append (ret, &iter);
+ if (!dbus_message_iter_open_container (&iter,
+ DBUS_TYPE_VARIANT,
+ variant_sig,
+ &subiter))
+ {
+ g_free (variant_sig);
+ g_value_unset (&value);
+ return ret;
+ }
- if (!_dbus_gvalue_marshal (&iter, &value))
+ if (!_dbus_gvalue_marshal (&subiter, &value))
{
dbus_message_unref (ret);
ret = dbus_message_new_error (message,
@@ -716,6 +732,11 @@
"Can't convert GType of object property to a D-BUS type");
}
+ dbus_message_iter_close_container (&iter, &subiter);
+
+ g_value_unset (&value);
+ g_free (variant_sig);
+
return ret;
}
@@ -1307,7 +1328,7 @@
dbus_message_iter_next (&iter);
}
else if (getter)
- {
+ {
ret = get_object_property (connection, message,
object, pspec);
}
@@ -1321,7 +1342,7 @@
if (dbus_message_iter_get_arg_type (&iter) != DBUS_TYPE_INVALID)
g_warning ("Property get or set had too many arguments\n");
-
+
dbus_connection_send (connection, ret, NULL);
dbus_message_unref (ret);
return DBUS_HANDLER_RESULT_HANDLED;
Index: dbus-gvalue.c
===================================================================
RCS file: /cvs/dbus/dbus/glib/dbus-gvalue.c,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- dbus-gvalue.c 18 Oct 2005 04:38:04 -0000 1.23
+++ dbus-gvalue.c 27 Nov 2005 16:55:09 -0000 1.24
@@ -388,8 +388,8 @@
return ret;
}
-static char *
-dbus_gvalue_to_signature (const GValue *val)
+char *
+_dbus_gvalue_to_signature (const GValue *val)
{
GType gtype;
@@ -406,7 +406,7 @@
for (i = 0; i < array->n_values; i++)
{
char *sig;
- sig = dbus_gvalue_to_signature (g_value_array_get_nth (array, i));
+ sig = _dbus_gvalue_to_signature (g_value_array_get_nth (array, i));
g_string_append (str, sig);
g_free (sig);
}
@@ -1465,7 +1465,7 @@
real_value = g_value_get_boxed (value);
value_gtype = G_VALUE_TYPE (real_value);
- variant_sig = dbus_gvalue_to_signature (real_value);
+ variant_sig = _dbus_gvalue_to_signature (real_value);
if (variant_sig == NULL)
{
g_warning ("Cannot marshal type \"%s\" in variant", g_type_name (value_gtype));
Index: dbus-gvalue.h
===================================================================
RCS file: /cvs/dbus/dbus/glib/dbus-gvalue.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- dbus-gvalue.h 4 Aug 2005 15:49:30 -0000 1.7
+++ dbus-gvalue.h 27 Nov 2005 16:55:09 -0000 1.8
@@ -17,6 +17,7 @@
void _dbus_g_value_types_init (void);
char * _dbus_gtype_to_signature (GType type);
+char * _dbus_gvalue_to_signature (const GValue *val);
gboolean _dbus_gvalue_demarshal (DBusGValueMarshalCtx *context,
DBusMessageIter *iter,
More information about the dbus-commit
mailing list