summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorColin Walters <walters@verbum.org>2005-06-29 23:52:35 +0000
committerColin Walters <walters@verbum.org>2005-06-29 23:52:35 +0000
commitb3c42d226438fd0fda2db19b92944dec5e226d3f (patch)
tree84b3cb764378b48856d762fc6aaf3457fe0b88aa
parentd8dd432f39c560ad58cbb65182d6550013ea85af (diff)
2005-06-29 Colin Walters <walters@verbum.org>
* dbus/dbus-glib.h: Delete DBUS_TYPE_G_PROXY_ARRAY. Add DBUS_TYPE_G_OBJECT_PATH. * glib/dbus-gvalue.c (dbus_g_value_types_init): Remove marshallers for G_TYPE_OBJECT and DBUS_TYPE_G_PROXY_ARRAY (the latter should be handled more generically). Add DBUS_TYPE_G_OBJECT_PATH. (dbus_g_object_path_get_g_type): New function. (dbus_gtype_from_signature_iter): Map DBUS_TYPE_OBJECT_PATH to DBUS_TYPE_G_OBJECT_PATH by default. (demarshal_proxy): Remove unused name variable. (demarshal_object_path, marshal_object_path): New functions. (demarshal_proxy_array, marshal_proxy_array): Delete. * glib/dbus-binding-tool-glib.c (dbus_g_type_get_c_name): Map DBUS_TYPE_G_OBJECT_PATH to char *. (dbus_g_type_get_lookup_function): Map builtin DBUS_TYPE_G_OBJECT_PATH. * test/glib/test-dbus-glib.c * test/glib/test-service-glib.c (my_object_objpath): Adapt tests to new object path marshalling.
-rw-r--r--ChangeLog24
-rw-r--r--dbus/dbus-glib.h6
-rw-r--r--glib/dbus-binding-tool-glib.c5
-rw-r--r--glib/dbus-gvalue.c164
-rw-r--r--test/glib/test-dbus-glib.c38
-rw-r--r--test/glib/test-service-glib.c8
6 files changed, 122 insertions, 123 deletions
diff --git a/ChangeLog b/ChangeLog
index 450dcedd..bce59c68 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,27 @@
+2005-06-29 Colin Walters <walters@verbum.org>
+
+ * dbus/dbus-glib.h: Delete DBUS_TYPE_G_PROXY_ARRAY. Add
+ DBUS_TYPE_G_OBJECT_PATH.
+
+ * glib/dbus-gvalue.c (dbus_g_value_types_init): Remove marshallers
+ for G_TYPE_OBJECT and DBUS_TYPE_G_PROXY_ARRAY (the latter should
+ be handled more generically). Add DBUS_TYPE_G_OBJECT_PATH.
+ (dbus_g_object_path_get_g_type): New function.
+ (dbus_gtype_from_signature_iter): Map DBUS_TYPE_OBJECT_PATH
+ to DBUS_TYPE_G_OBJECT_PATH by default.
+ (demarshal_proxy): Remove unused name variable.
+ (demarshal_object_path, marshal_object_path): New functions.
+ (demarshal_proxy_array, marshal_proxy_array): Delete.
+
+ * glib/dbus-binding-tool-glib.c (dbus_g_type_get_c_name): Map
+ DBUS_TYPE_G_OBJECT_PATH to char *.
+ (dbus_g_type_get_lookup_function): Map builtin
+ DBUS_TYPE_G_OBJECT_PATH.
+
+ * test/glib/test-dbus-glib.c
+ * test/glib/test-service-glib.c (my_object_objpath):
+ Adapt tests to new object path marshalling.
+
2005-06-29 John (J5) Palmieri <johnp@redhat.com>
* configure.in: force check for Python >= 2.4
diff --git a/dbus/dbus-glib.h b/dbus/dbus-glib.h
index 901b5720..5e791e01 100644
--- a/dbus/dbus-glib.h
+++ b/dbus/dbus-glib.h
@@ -177,13 +177,13 @@ typedef struct _DBusGValue DBusGValue;
#define DBUS_TYPE_G_STRING_STRING_HASHTABLE (dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_STRING))
-/* D-BUS-specific types */
-#define DBUS_TYPE_G_PROXY_ARRAY (dbus_g_type_get_collection ("GPtrArray", DBUS_TYPE_G_PROXY))
-
/* Generic recursive value */
GType dbus_g_value_get_g_type (void) G_GNUC_CONST;
#define DBUS_TYPE_G_VALUE (dbus_g_value_get_g_type ())
+GType dbus_g_object_path_get_g_type (void) G_GNUC_CONST;
+#define DBUS_TYPE_G_OBJECT_PATH (dbus_g_object_path_get_g_type ())
+
void dbus_g_value_open (DBusGValue *value,
DBusGValueIterator *iter);
diff --git a/glib/dbus-binding-tool-glib.c b/glib/dbus-binding-tool-glib.c
index 373faaff..4a33176b 100644
--- a/glib/dbus-binding-tool-glib.c
+++ b/glib/dbus-binding-tool-glib.c
@@ -98,7 +98,8 @@ dbus_g_type_get_c_name (GType gtype)
if (dbus_g_type_is_map (gtype))
return "GHashTable";
- if (g_type_is_a (gtype, G_TYPE_STRING))
+ if (g_type_is_a (gtype, G_TYPE_STRING)
+ || g_type_is_a (gtype, DBUS_TYPE_G_OBJECT_PATH))
return "char *";
/* This one is even more hacky...we get an extra *
@@ -892,7 +893,7 @@ dbus_g_type_get_lookup_function (GType gtype)
MAP_KNOWN(G_TYPE_VALUE);
MAP_KNOWN(G_TYPE_STRV);
MAP_KNOWN(DBUS_TYPE_G_PROXY);
- MAP_KNOWN(DBUS_TYPE_G_PROXY_ARRAY);
+ MAP_KNOWN(DBUS_TYPE_G_OBJECT_PATH);
return NULL;
}
#undef MAP_FUNDAMENTAL
diff --git a/glib/dbus-gvalue.c b/glib/dbus-gvalue.c
index 72ad737f..d8ce3d2b 100644
--- a/glib/dbus-gvalue.c
+++ b/glib/dbus-gvalue.c
@@ -88,15 +88,15 @@ static gboolean demarshal_proxy (DBusGValueMarshalCtx *cont
DBusMessageIter *iter,
GValue *value,
GError **error);
-static gboolean marshal_object (DBusMessageIter *iter,
+static gboolean marshal_object_path (DBusMessageIter *iter,
GValue *value);
-static gboolean demarshal_object (DBusGValueMarshalCtx *context,
+static gboolean demarshal_object_path (DBusGValueMarshalCtx *context,
DBusMessageIter *iter,
GValue *value,
GError **error);
-static gboolean marshal_proxy_array (DBusMessageIter *iter,
+static gboolean marshal_object (DBusMessageIter *iter,
GValue *value);
-static gboolean demarshal_proxy_array (DBusGValueMarshalCtx *context,
+static gboolean demarshal_object (DBusGValueMarshalCtx *context,
DBusMessageIter *iter,
GValue *value,
GError **error);
@@ -395,32 +395,49 @@ dbus_g_value_types_init (void)
{
static const DBusGTypeMarshalVtable vtable = {
- marshal_object,
- demarshal_object
+ marshal_object_path,
+ demarshal_object_path
};
static const DBusGTypeMarshalData typedata = {
DBUS_TYPE_OBJECT_PATH_AS_STRING,
&vtable
};
- set_type_metadata (G_TYPE_OBJECT, &typedata);
+ set_type_metadata (DBUS_TYPE_G_OBJECT_PATH, &typedata);
}
{
static const DBusGTypeMarshalVtable vtable = {
- marshal_proxy_array,
- demarshal_proxy_array
+ marshal_object,
+ demarshal_object
};
static const DBusGTypeMarshalData typedata = {
- DBUS_TYPE_ARRAY_AS_STRING DBUS_TYPE_OBJECT_PATH_AS_STRING,
+ DBUS_TYPE_OBJECT_PATH_AS_STRING,
&vtable
};
- set_type_metadata (DBUS_TYPE_G_PROXY_ARRAY, &typedata);
+ set_type_metadata (G_TYPE_OBJECT, &typedata);
}
types_initialized = TRUE;
}
/**
+ * Get the GLib type ID for a DBusGObjectPath boxed type.
+ *
+ * @returns GLib type
+ */
+GType
+dbus_g_object_path_get_g_type (void)
+{
+ static GType type_id = 0;
+
+ if (!type_id)
+ type_id = g_boxed_type_register_static ("DBusGObjectPath",
+ (GBoxedCopyFunc) g_strdup,
+ (GBoxedFreeFunc) g_free);
+ return type_id;
+}
+
+/**
* Get the GLib type ID for a DBusGValue boxed type.
*
* @returns GLib type
@@ -592,7 +609,7 @@ dbus_gtype_from_signature_iter (DBusSignatureIter *iter, gboolean is_client)
if (dbus_typecode_maps_to_basic (current_type))
return basic_typecode_to_gtype (current_type);
else if (current_type == DBUS_TYPE_OBJECT_PATH)
- return is_client ? DBUS_TYPE_G_PROXY : G_TYPE_OBJECT;
+ return DBUS_TYPE_G_OBJECT_PATH;
else
{
DBusSignatureIter subiter;
@@ -827,7 +844,6 @@ demarshal_proxy (DBusGValueMarshalCtx *context,
GValue *value,
GError **error)
{
- const char *name;
DBusGProxy *new_proxy;
const char *objpath;
int current_type;
@@ -837,8 +853,6 @@ demarshal_proxy (DBusGValueMarshalCtx *context,
g_assert (context->proxy != NULL);
- name = dbus_g_proxy_get_bus_name (context->proxy);
-
dbus_message_iter_get_basic (iter, &objpath);
new_proxy = dbus_g_proxy_new_from_proxy (context->proxy, NULL, objpath);
@@ -848,6 +862,25 @@ demarshal_proxy (DBusGValueMarshalCtx *context,
}
static gboolean
+demarshal_object_path (DBusGValueMarshalCtx *context,
+ DBusMessageIter *iter,
+ GValue *value,
+ GError **error)
+{
+ const char *objpath;
+ int current_type;
+
+ current_type = dbus_message_iter_get_arg_type (iter);
+ g_assert (current_type == DBUS_TYPE_OBJECT_PATH);
+
+ dbus_message_iter_get_basic (iter, &objpath);
+
+ g_value_set_boxed_take_ownership (value, g_strdup (objpath));
+
+ return TRUE;
+}
+
+static gboolean
demarshal_object (DBusGValueMarshalCtx *context,
DBusMessageIter *iter,
GValue *value,
@@ -951,50 +984,6 @@ demarshal_garray_basic (DBusGValueMarshalCtx *context,
}
static gboolean
-demarshal_proxy_array (DBusGValueMarshalCtx *context,
- DBusMessageIter *iter,
- GValue *value,
- GError **error)
-{
- DBusMessageIter subiter;
- GPtrArray *ret;
- guint len;
- guint i;
- int current_type;
-
- g_assert (dbus_message_iter_get_arg_type (iter) == DBUS_TYPE_ARRAY);
-
- dbus_message_iter_recurse (iter, &subiter);
-
- len = dbus_message_iter_get_array_len (&subiter);
- g_assert (len >= 0);
- ret = g_ptr_array_sized_new (len);
-
- i = 0;
- while ((current_type = dbus_message_iter_get_arg_type (&subiter)) != DBUS_TYPE_INVALID)
- {
- GValue subval = {0, };
- g_assert (i < len);
-
- if (!demarshal_proxy (context, &subiter, &subval, error))
- {
- for (i = 0; i < ret->len; i++)
- g_object_unref (g_ptr_array_index (ret, i));
- g_ptr_array_free (ret, TRUE);
- return FALSE;
- }
-
- g_ptr_array_index (ret, i) = g_value_get_boxed (&subval);
- /* Don't unset value, now owned by ret */
-
- i++;
- }
- g_value_set_boxed_take_ownership (value, ret);
-
- return TRUE;
-}
-
-static gboolean
demarshal_ghashtable (DBusGValueMarshalCtx *context,
DBusMessageIter *iter,
GValue *value,
@@ -1393,6 +1382,23 @@ marshal_proxy (DBusMessageIter *iter,
}
static gboolean
+marshal_object_path (DBusMessageIter *iter,
+ GValue *value)
+{
+ const char *path;
+
+ g_assert (G_VALUE_TYPE (value) == DBUS_TYPE_G_OBJECT_PATH);
+
+ path = (const char*) g_value_get_boxed (value);
+
+ if (!dbus_message_iter_append_basic (iter,
+ DBUS_TYPE_OBJECT_PATH,
+ &path))
+ return FALSE;
+ return TRUE;
+}
+
+static gboolean
marshal_object (DBusMessageIter *iter,
GValue *value)
{
@@ -1413,46 +1419,6 @@ marshal_object (DBusMessageIter *iter,
return TRUE;
}
-static gboolean
-marshal_proxy_array (DBusMessageIter *iter,
- GValue *value)
-{
- DBusMessageIter subiter;
- GPtrArray *array;
- const char *subsignature_str;
- gboolean ret = FALSE;
- guint i;
-
- subsignature_str = dbus_gtype_to_signature (DBUS_TYPE_G_PROXY);
- g_assert (subsignature_str != NULL);
-
- array = g_value_get_boxed (value);
-
- if (!dbus_message_iter_open_container (iter,
- DBUS_TYPE_ARRAY,
- subsignature_str,
- &subiter))
- goto out;
-
- for (i = 0; i < array->len; i++)
- {
- GValue val = {0, };
-
- g_value_init (&val, DBUS_TYPE_G_PROXY);
- g_value_set_static_boxed (&val, g_ptr_array_index (array, i));
-
- marshal_proxy (&subiter, &val);
-
- g_value_unset (&val);
- }
-
- if (!dbus_message_iter_close_container (iter, &subiter))
- goto out;
- ret = TRUE;
- out:
- return ret;
-}
-
struct DBusGLibHashMarshalData
{
const char *entry_sig;
diff --git a/test/glib/test-dbus-glib.c b/test/glib/test-dbus-glib.c
index 178d819f..e8cb74af 100644
--- a/test/glib/test-dbus-glib.c
+++ b/test/glib/test-dbus-glib.c
@@ -749,11 +749,14 @@ main (int argc, char **argv)
{
guint val;
+ char *ret_path;
DBusGProxy *ret_proxy;
g_print ("Calling (wrapped) objpath\n");
- if (!org_freedesktop_DBus_Tests_MyObject_objpath (proxy, proxy, &ret_proxy, &error))
- lose_gerror ("Failed to complete (wrapped) Objpath call", error);
+ if (!dbus_g_proxy_call (proxy, "Objpath", &error,
+ DBUS_TYPE_G_PROXY, proxy, G_TYPE_INVALID,
+ DBUS_TYPE_G_PROXY, &ret_proxy, G_TYPE_INVALID))
+ lose_gerror ("Failed to complete Objpath call", error);
if (strcmp ("/org/freedesktop/DBus/Tests/MyTestObject2",
dbus_g_proxy_get_path (ret_proxy)) != 0)
lose ("(wrapped) objpath call returned unexpected proxy %s",
@@ -802,20 +805,25 @@ main (int argc, char **argv)
g_print ("Calling objpath again\n");
ret_proxy = NULL;
- if (!org_freedesktop_DBus_Tests_MyObject_objpath (proxy, proxy, &ret_proxy, &error))
- lose_gerror ("Failed to complete (wrapped) Objpath call 2", error);
- if (strcmp ("/org/freedesktop/DBus/Tests/MyTestObject2",
- dbus_g_proxy_get_path (ret_proxy)) != 0)
- lose ("(wrapped) objpath call 2 returned unexpected proxy %s",
- dbus_g_proxy_get_path (ret_proxy));
- {
- const char *iface = dbus_g_proxy_get_interface (ret_proxy);
- g_print ("returned proxy has interface \"%s\"\n",
- iface ? iface : "(NULL)");
- }
-
- dbus_g_proxy_set_interface (ret_proxy, "org.freedesktop.DBus.Tests.FooObject");
+ if (!dbus_g_proxy_call (proxy, "Objpath", &error,
+ DBUS_TYPE_G_OBJECT_PATH,
+ dbus_g_proxy_get_path (proxy),
+ G_TYPE_INVALID,
+ DBUS_TYPE_G_OBJECT_PATH,
+ &ret_path,
+ G_TYPE_INVALID))
+ lose_gerror ("Failed to complete (wrapped) Objpath call 2", error);
+ if (strcmp ("/org/freedesktop/DBus/Tests/MyTestObject2", ret_path) != 0)
+ lose ("(wrapped) objpath call 2 returned unexpected path %s",
+ ret_path);
+
+ ret_proxy = dbus_g_proxy_new_for_name_owner (connection,
+ "org.freedesktop.DBus.TestSuiteGLibService",
+ ret_path,
+ "org.freedesktop.DBus.Tests.FooObject",
+ &error);
+
val = 0;
if (!org_freedesktop_DBus_Tests_FooObject_get_value (ret_proxy, &val, &error))
lose_gerror ("Failed to complete (wrapped) GetValue call", error);
diff --git a/test/glib/test-service-glib.c b/test/glib/test-service-glib.c
index 315f1d65..9d5dfcc8 100644
--- a/test/glib/test-service-glib.c
+++ b/test/glib/test-service-glib.c
@@ -61,7 +61,7 @@ gboolean my_object_many_return (MyObject *obj, guint32 *arg0, char **arg1, gint3
gboolean my_object_recursive1 (MyObject *obj, GArray *array, guint32 *len_ret, GError **error);
gboolean my_object_recursive2 (MyObject *obj, guint32 reqlen, GArray **array, GError **error);
-gboolean my_object_objpath (MyObject *obj, GObject *in, GObject **arg1, GError **error);
+gboolean my_object_objpath (MyObject *obj, const char *in, char **arg1, GError **error);
gboolean my_object_stringify (MyObject *obj, GValue *value, char **ret, GError **error);
gboolean my_object_unstringify (MyObject *obj, const char *str, GValue *value, GError **error);
@@ -362,9 +362,9 @@ my_object_many_uppercase (MyObject *obj, const char * const *in, char ***out, GE
}
gboolean
-my_object_objpath (MyObject *obj, GObject *incoming, GObject **outgoing, GError **error)
+my_object_objpath (MyObject *obj, const char *incoming, char **outgoing, GError **error)
{
- if ((GObject*) obj != incoming)
+ if (strcmp (incoming, "/org/freedesktop/DBus/Tests/MyTestObject"))
{
g_set_error (error,
MY_OBJECT_ERROR,
@@ -372,7 +372,7 @@ my_object_objpath (MyObject *obj, GObject *incoming, GObject **outgoing, GError
"invalid incoming object");
return FALSE;
}
- *outgoing = g_object_ref (obj2);
+ *outgoing = g_strdup ("/org/freedesktop/DBus/Tests/MyTestObject2");
return TRUE;
}