summaryrefslogtreecommitdiff
path: root/glib
diff options
context:
space:
mode:
authorRobert McQueen <robot101@debian.org>2005-11-27 16:55:09 +0000
committerRobert McQueen <robot101@debian.org>2005-11-27 16:55:09 +0000
commit75d6182c05309031371ddf9e9103f5921afa0031 (patch)
tree51e3527328e202e006fccaca26ed757d89bfa34a /glib
parentc77c7e343b73bb9c14319679063a55e5cf1ee1d6 (diff)
downloaddbus-75d6182c05309031371ddf9e9103f5921afa0031.tar.gz
2005-11-27 Carlos Garcia Campos <carlosgc@gnome.org>
* glib/dbus-gobject.c: Append a GValue instead of a basic type in method return message for property getters
Diffstat (limited to 'glib')
-rw-r--r--glib/dbus-gobject.c41
-rw-r--r--glib/dbus-gvalue.c8
-rw-r--r--glib/dbus-gvalue.h1
3 files changed, 36 insertions, 14 deletions
diff --git a/glib/dbus-gobject.c b/glib/dbus-gobject.c
index 0a019cc2..3e30dc2e 100644
--- a/glib/dbus-gobject.c
+++ b/glib/dbus-gobject.c
@@ -690,25 +690,41 @@ get_object_property (DBusConnection *connection,
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 @@ get_object_property (DBusConnection *connection,
"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 @@ gobject_message_function (DBusConnection *connection,
dbus_message_iter_next (&iter);
}
else if (getter)
- {
+ {
ret = get_object_property (connection, message,
object, pspec);
}
@@ -1321,7 +1342,7 @@ gobject_message_function (DBusConnection *connection,
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;
diff --git a/glib/dbus-gvalue.c b/glib/dbus-gvalue.c
index 2f6371e3..7f4e822f 100644
--- a/glib/dbus-gvalue.c
+++ b/glib/dbus-gvalue.c
@@ -388,8 +388,8 @@ _dbus_gtype_to_signature (GType gtype)
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 @@ dbus_gvalue_to_signature (const GValue *val)
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 @@ marshal_variant (DBusMessageIter *iter,
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));
diff --git a/glib/dbus-gvalue.h b/glib/dbus-gvalue.h
index 3b41747e..1bfd719d 100644
--- a/glib/dbus-gvalue.h
+++ b/glib/dbus-gvalue.h
@@ -17,6 +17,7 @@ typedef struct {
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,