1 /* GDBus - GLib D-Bus Library
3 * Copyright (C) 2008-2010 Red Hat, Inc.
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General
16 * Public License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
18 * Boston, MA 02111-1307, USA.
20 * Author: David Zeuthen <davidz@redhat.com>
28 #include "gdbusintrospection.h"
34 * SECTION:gdbusintrospection
35 * @title: Introspection XML
36 * @short_description: Parse and Generate Introspection XML
39 * Various data structures and convenience routines to parse and
40 * generate D-Bus introspection XML. Introspection information is
41 * used when registering objects with g_dbus_connection_register_object().
43 * The format of D-BUs introspection XML is specified in the
44 * <link linkend="http://dbus.freedesktop.org/doc/dbus-specification.html#introspection-format">D-Bus specification</link>.
47 /* ---------------------------------------------------------------------------------------------------- */
49 /* See also https://bugzilla.gnome.org/show_bug.cgi?id=449565 ... */
50 #define _MY_DEFINE_BOXED_TYPE(TypeName, type_name) \
52 type_name##_get_type (void) \
54 static volatile gsize type_volatile = 0; \
55 if (g_once_init_enter (&type_volatile)) \
57 GType type = g_boxed_type_register_static (g_intern_static_string (#TypeName), \
58 (GBoxedCopyFunc) type_name##_ref, \
59 (GBoxedFreeFunc) type_name##_unref); \
60 g_once_init_leave (&type_volatile, type); \
62 return (GType) type_volatile; \
65 _MY_DEFINE_BOXED_TYPE (GDBusNodeInfo, g_dbus_node_info);
66 _MY_DEFINE_BOXED_TYPE (GDBusInterfaceInfo, g_dbus_interface_info);
67 _MY_DEFINE_BOXED_TYPE (GDBusMethodInfo, g_dbus_method_info);
68 _MY_DEFINE_BOXED_TYPE (GDBusSignalInfo, g_dbus_signal_info);
69 _MY_DEFINE_BOXED_TYPE (GDBusPropertyInfo, g_dbus_property_info);
70 _MY_DEFINE_BOXED_TYPE (GDBusArgInfo, g_dbus_arg_info);
71 _MY_DEFINE_BOXED_TYPE (GDBusAnnotationInfo, g_dbus_annotation_info);
73 /* ---------------------------------------------------------------------------------------------------- */
77 /* stuff we are currently collecting */
82 GPtrArray *properties;
83 GPtrArray *interfaces;
85 GPtrArray *annotations;
87 /* A list of GPtrArray's containing annotations */
88 GSList *annotations_stack;
90 /* A list of GPtrArray's containing interfaces */
91 GSList *interfaces_stack;
93 /* A list of GPtrArray's containing nodes */
96 /* Whether the direction was "in" for last parsed arg */
97 gboolean last_arg_was_in;
99 /* Number of args currently being collected; used for assigning
100 * names to args without a "name" attribute
106 /* ---------------------------------------------------------------------------------------------------- */
109 * g_dbus_node_info_ref:
110 * @info: A #GDBusNodeInfo
112 * If @info is statically allocated does nothing. Otherwise increases
113 * the reference count.
115 * Returns: The same @info.
120 g_dbus_node_info_ref (GDBusNodeInfo *info)
122 if (info->ref_count == -1)
124 g_atomic_int_inc (&info->ref_count);
129 * g_dbus_interface_info_ref:
130 * @info: A #GDBusInterfaceInfo
132 * If @info is statically allocated does nothing. Otherwise increases
133 * the reference count.
135 * Returns: The same @info.
140 g_dbus_interface_info_ref (GDBusInterfaceInfo *info)
142 if (info->ref_count == -1)
144 g_atomic_int_inc (&info->ref_count);
149 * g_dbus_method_info_ref:
150 * @info: A #GDBusMethodInfo
152 * If @info is statically allocated does nothing. Otherwise increases
153 * the reference count.
155 * Returns: The same @info.
160 g_dbus_method_info_ref (GDBusMethodInfo *info)
162 if (info->ref_count == -1)
164 g_atomic_int_inc (&info->ref_count);
169 * g_dbus_signal_info_ref:
170 * @info: A #GDBusSignalInfo
172 * If @info is statically allocated does nothing. Otherwise increases
173 * the reference count.
175 * Returns: The same @info.
180 g_dbus_signal_info_ref (GDBusSignalInfo *info)
182 if (info->ref_count == -1)
184 g_atomic_int_inc (&info->ref_count);
189 * g_dbus_property_info_ref:
190 * @info: A #GDBusPropertyInfo
192 * If @info is statically allocated does nothing. Otherwise increases
193 * the reference count.
195 * Returns: The same @info.
200 g_dbus_property_info_ref (GDBusPropertyInfo *info)
202 if (info->ref_count == -1)
204 g_atomic_int_inc (&info->ref_count);
209 * g_dbus_arg_info_ref:
210 * @info: A #GDBusArgInfo
212 * If @info is statically allocated does nothing. Otherwise increases
213 * the reference count.
215 * Returns: The same @info.
220 g_dbus_arg_info_ref (GDBusArgInfo *info)
222 if (info->ref_count == -1)
224 g_atomic_int_inc (&info->ref_count);
229 * g_dbus_annotation_info_ref:
230 * @info: A #GDBusNodeInfo
232 * If @info is statically allocated does nothing. Otherwise increases
233 * the reference count.
235 * Returns: The same @info.
239 GDBusAnnotationInfo *
240 g_dbus_annotation_info_ref (GDBusAnnotationInfo *info)
242 if (info->ref_count == -1)
244 g_atomic_int_inc (&info->ref_count);
248 /* ---------------------------------------------------------------------------------------------------- */
251 free_null_terminated_array (gpointer array, GDestroyNotify unref_func)
257 for (n = 0; p[n] != NULL; n++)
263 * g_dbus_annotation_info_unref:
264 * @info: A #GDBusAnnotationInfo.
266 * If @info is statically allocated, does nothing. Otherwise decreases
267 * the reference count of @info. When its reference count drops to 0,
268 * the memory used is freed.
273 g_dbus_annotation_info_unref (GDBusAnnotationInfo *info)
275 if (info->ref_count == -1)
277 if (g_atomic_int_dec_and_test (&info->ref_count))
280 g_free (info->value);
281 free_null_terminated_array (info->annotations, (GDestroyNotify) g_dbus_annotation_info_unref);
287 * g_dbus_arg_info_unref:
288 * @info: A #GDBusArgInfo.
290 * If @info is statically allocated, does nothing. Otherwise decreases
291 * the reference count of @info. When its reference count drops to 0,
292 * the memory used is freed.
297 g_dbus_arg_info_unref (GDBusArgInfo *info)
299 if (info->ref_count == -1)
301 if (g_atomic_int_dec_and_test (&info->ref_count))
304 g_free (info->signature);
305 free_null_terminated_array (info->annotations, (GDestroyNotify) g_dbus_annotation_info_unref);
311 * g_dbus_method_info_unref:
312 * @info: A #GDBusMethodInfo.
314 * If @info is statically allocated, does nothing. Otherwise decreases
315 * the reference count of @info. When its reference count drops to 0,
316 * the memory used is freed.
321 g_dbus_method_info_unref (GDBusMethodInfo *info)
323 if (info->ref_count == -1)
325 if (g_atomic_int_dec_and_test (&info->ref_count))
328 free_null_terminated_array (info->in_args, (GDestroyNotify) g_dbus_arg_info_unref);
329 free_null_terminated_array (info->out_args, (GDestroyNotify) g_dbus_arg_info_unref);
330 free_null_terminated_array (info->annotations, (GDestroyNotify) g_dbus_annotation_info_unref);
336 * g_dbus_signal_info_unref:
337 * @info: A #GDBusSignalInfo.
339 * If @info is statically allocated, does nothing. Otherwise decreases
340 * the reference count of @info. When its reference count drops to 0,
341 * the memory used is freed.
346 g_dbus_signal_info_unref (GDBusSignalInfo *info)
348 if (info->ref_count == -1)
350 if (g_atomic_int_dec_and_test (&info->ref_count))
353 free_null_terminated_array (info->args, (GDestroyNotify) g_dbus_arg_info_unref);
354 free_null_terminated_array (info->annotations, (GDestroyNotify) g_dbus_annotation_info_unref);
360 * g_dbus_property_info_unref:
361 * @info: A #GDBusPropertyInfo.
363 * If @info is statically allocated, does nothing. Otherwise decreases
364 * the reference count of @info. When its reference count drops to 0,
365 * the memory used is freed.
370 g_dbus_property_info_unref (GDBusPropertyInfo *info)
372 if (info->ref_count == -1)
374 if (g_atomic_int_dec_and_test (&info->ref_count))
377 g_free (info->signature);
378 free_null_terminated_array (info->annotations, (GDestroyNotify) g_dbus_annotation_info_unref);
384 * g_dbus_interface_info_unref:
385 * @info: A #GDBusInterfaceInfo.
387 * If @info is statically allocated, does nothing. Otherwise decreases
388 * the reference count of @info. When its reference count drops to 0,
389 * the memory used is freed.
394 g_dbus_interface_info_unref (GDBusInterfaceInfo *info)
396 if (info->ref_count == -1)
398 if (g_atomic_int_dec_and_test (&info->ref_count))
401 free_null_terminated_array (info->methods, (GDestroyNotify) g_dbus_method_info_unref);
402 free_null_terminated_array (info->signals, (GDestroyNotify) g_dbus_signal_info_unref);
403 free_null_terminated_array (info->properties, (GDestroyNotify) g_dbus_property_info_unref);
404 free_null_terminated_array (info->annotations, (GDestroyNotify) g_dbus_annotation_info_unref);
410 * g_dbus_node_info_unref:
411 * @info: A #GDBusNodeInfo.
413 * If @info is statically allocated, does nothing. Otherwise decreases
414 * the reference count of @info. When its reference count drops to 0,
415 * the memory used is freed.
420 g_dbus_node_info_unref (GDBusNodeInfo *info)
422 if (info->ref_count == -1)
424 if (g_atomic_int_dec_and_test (&info->ref_count))
427 free_null_terminated_array (info->interfaces, (GDestroyNotify) g_dbus_interface_info_unref);
428 free_null_terminated_array (info->nodes, (GDestroyNotify) g_dbus_node_info_unref);
429 free_null_terminated_array (info->annotations, (GDestroyNotify) g_dbus_annotation_info_unref);
434 /* ---------------------------------------------------------------------------------------------------- */
437 g_dbus_annotation_info_set (ParseData *data,
438 GDBusAnnotationInfo *info,
441 GDBusAnnotationInfo **embedded_annotations)
446 info->key = g_strdup (key);
449 info->value = g_strdup (value);
451 if (embedded_annotations != NULL)
452 info->annotations = embedded_annotations;
456 g_dbus_arg_info_set (ParseData *data,
459 const gchar *signature,
460 GDBusAnnotationInfo **annotations)
464 /* name may be NULL - TODO: compute name? */
466 info->name = g_strdup (name);
468 if (signature != NULL)
469 info->signature = g_strdup (signature);
471 if (annotations != NULL)
472 info->annotations = annotations;
476 g_dbus_method_info_set (ParseData *data,
477 GDBusMethodInfo *info,
480 GDBusArgInfo **in_args,
482 GDBusArgInfo **out_args,
483 GDBusAnnotationInfo **annotations)
488 info->name = g_strdup (name);
490 if (in_num_args != 0)
492 //info->in_num_args = in_num_args;
493 info->in_args = in_args;
496 if (out_num_args != 0)
498 //info->out_num_args = out_num_args;
499 info->out_args = out_args;
502 if (annotations != NULL)
503 info->annotations = annotations;
507 g_dbus_signal_info_set (ParseData *data,
508 GDBusSignalInfo *info,
512 GDBusAnnotationInfo **annotations)
517 info->name = g_strdup (name);
521 //info->num_args = num_args;
525 if (annotations != NULL)
527 info->annotations = annotations;
532 g_dbus_property_info_set (ParseData *data,
533 GDBusPropertyInfo *info,
535 const gchar *signature,
536 GDBusPropertyInfoFlags flags,
537 GDBusAnnotationInfo **annotations)
542 info->name = g_strdup (name);
544 if (flags != G_DBUS_PROPERTY_INFO_FLAGS_NONE)
547 if (signature != NULL)
549 info->signature = g_strdup (signature);
552 if (annotations != NULL)
554 info->annotations = annotations;
559 g_dbus_interface_info_set (ParseData *data,
560 GDBusInterfaceInfo *info,
563 GDBusMethodInfo **methods,
565 GDBusSignalInfo **signals,
566 guint num_properties,
567 GDBusPropertyInfo **properties,
568 GDBusAnnotationInfo **annotations)
574 info->name = g_strdup (name);
577 if (num_methods != 0)
579 //info->num_methods = num_methods;
580 info->methods = methods;
583 if (num_signals != 0)
585 //info->num_signals = num_signals;
586 info->signals = signals;
589 if (num_properties != 0)
591 //info->num_properties = num_properties;
592 info->properties = properties;
595 if (annotations != NULL)
597 info->annotations = annotations;
602 g_dbus_node_info_set (ParseData *data,
605 guint num_interfaces,
606 GDBusInterfaceInfo **interfaces,
608 GDBusNodeInfo **nodes,
609 GDBusAnnotationInfo **annotations)
615 info->path = g_strdup (path);
616 /* TODO: relative / absolute path snafu */
619 if (num_interfaces != 0)
621 //info->num_interfaces = num_interfaces;
622 info->interfaces = interfaces;
627 //info->num_nodes = num_nodes;
631 if (annotations != NULL)
633 info->annotations = annotations;
638 /* ---------------------------------------------------------------------------------------------------- */
641 g_dbus_annotation_info_generate_xml (const GDBusAnnotationInfo *info,
643 GString *string_builder)
647 g_string_append_printf (string_builder, "%*s<annotation name=\"%s\" value=\"%s\"",
652 if (info->annotations == NULL)
654 g_string_append (string_builder, "/>\n");
658 g_string_append (string_builder, ">\n");
660 for (n = 0; info->annotations != NULL && info->annotations[n] != NULL; n++)
661 g_dbus_annotation_info_generate_xml (info->annotations[n],
665 g_string_append_printf (string_builder, "%*s</annotation>\n",
672 g_dbus_arg_info_generate_xml (const GDBusArgInfo *info,
674 const gchar *extra_attributes,
675 GString *string_builder)
679 g_string_append_printf (string_builder, "%*s<arg type=\"%s\"",
683 if (info->name != NULL)
684 g_string_append_printf (string_builder, " name=\"%s\"", info->name);
686 if (extra_attributes != NULL)
687 g_string_append_printf (string_builder, " %s", extra_attributes);
689 if (info->annotations == NULL)
691 g_string_append (string_builder, "/>\n");
695 g_string_append (string_builder, ">\n");
697 for (n = 0; info->annotations != NULL && info->annotations[n] != NULL; n++)
698 g_dbus_annotation_info_generate_xml (info->annotations[n],
702 g_string_append_printf (string_builder, "%*s</arg>\n", indent, "");
708 g_dbus_method_info_generate_xml (const GDBusMethodInfo *info,
710 GString *string_builder)
714 g_string_append_printf (string_builder, "%*s<method name=\"%s\"",
718 if (info->annotations == NULL && info->in_args == NULL && info->out_args == NULL)
720 g_string_append (string_builder, "/>\n");
724 g_string_append (string_builder, ">\n");
726 for (n = 0; info->annotations != NULL && info->annotations[n] != NULL; n++)
727 g_dbus_annotation_info_generate_xml (info->annotations[n],
731 for (n = 0; info->in_args != NULL && info->in_args[n] != NULL; n++)
732 g_dbus_arg_info_generate_xml (info->in_args[n],
737 for (n = 0; info->out_args != NULL && info->out_args[n] != NULL; n++)
738 g_dbus_arg_info_generate_xml (info->out_args[n],
743 g_string_append_printf (string_builder, "%*s</method>\n", indent, "");
748 g_dbus_signal_info_generate_xml (const GDBusSignalInfo *info,
750 GString *string_builder)
754 g_string_append_printf (string_builder, "%*s<signal name=\"%s\"",
758 if (info->annotations == NULL && info->args == NULL)
760 g_string_append (string_builder, "/>\n");
764 g_string_append (string_builder, ">\n");
766 for (n = 0; info->annotations != NULL && info->annotations[n] != NULL; n++)
767 g_dbus_annotation_info_generate_xml (info->annotations[n],
771 for (n = 0; info->args != NULL && info->args[n] != NULL; n++)
772 g_dbus_arg_info_generate_xml (info->args[n],
777 g_string_append_printf (string_builder, "%*s</signal>\n", indent, "");
782 g_dbus_property_info_generate_xml (const GDBusPropertyInfo *info,
784 GString *string_builder)
787 const gchar *access_string;
789 if ((info->flags & G_DBUS_PROPERTY_INFO_FLAGS_READABLE) &&
790 (info->flags & G_DBUS_PROPERTY_INFO_FLAGS_WRITABLE))
792 access_string = "readwrite";
794 else if (info->flags & G_DBUS_PROPERTY_INFO_FLAGS_READABLE)
796 access_string = "read";
798 else if (info->flags & G_DBUS_PROPERTY_INFO_FLAGS_WRITABLE)
800 access_string = "write";
804 g_assert_not_reached ();
807 g_string_append_printf (string_builder, "%*s<property type=\"%s\" name=\"%s\" access=\"%s\"",
813 if (info->annotations == NULL)
815 g_string_append (string_builder, "/>\n");
819 g_string_append (string_builder, ">\n");
821 for (n = 0; info->annotations != NULL && info->annotations[n] != NULL; n++)
822 g_dbus_annotation_info_generate_xml (info->annotations[n],
826 g_string_append_printf (string_builder, "%*s</property>\n", indent, "");
832 * g_dbus_interface_info_generate_xml:
833 * @info: A #GDBusNodeInfo
834 * @indent: Indentation level.
835 * @string_builder: A #GString to to append XML data to.
837 * Appends an XML representation of @info (and its children) to @string_builder.
839 * This function is typically used for generating introspection XML
840 * documents at run-time for handling the
841 * <literal>org.freedesktop.DBus.Introspectable.Introspect</literal>
847 g_dbus_interface_info_generate_xml (const GDBusInterfaceInfo *info,
849 GString *string_builder)
853 g_string_append_printf (string_builder, "%*s<interface name=\"%s\">\n",
857 for (n = 0; info->annotations != NULL && info->annotations[n] != NULL; n++)
858 g_dbus_annotation_info_generate_xml (info->annotations[n],
862 for (n = 0; info->methods != NULL && info->methods[n] != NULL; n++)
863 g_dbus_method_info_generate_xml (info->methods[n],
867 for (n = 0; info->signals != NULL && info->signals[n] != NULL; n++)
868 g_dbus_signal_info_generate_xml (info->signals[n],
872 for (n = 0; info->properties != NULL && info->properties[n] != NULL; n++)
873 g_dbus_property_info_generate_xml (info->properties[n],
877 g_string_append_printf (string_builder, "%*s</interface>\n", indent, "");
881 * g_dbus_node_info_generate_xml:
882 * @info: A #GDBusNodeInfo.
883 * @indent: Indentation level.
884 * @string_builder: A #GString to to append XML data to.
886 * Appends an XML representation of @info (and its children) to @string_builder.
888 * This function is typically used for generating introspection XML documents at run-time for
889 * handling the <literal>org.freedesktop.DBus.Introspectable.Introspect</literal> method.
894 g_dbus_node_info_generate_xml (const GDBusNodeInfo *info,
896 GString *string_builder)
900 g_string_append_printf (string_builder, "%*s<node", indent, "");
901 if (info->path != NULL)
902 g_string_append_printf (string_builder, " name=\"%s\"", info->path);
904 if (info->interfaces == NULL && info->nodes == NULL && info->annotations == NULL)
906 g_string_append (string_builder, "/>\n");
910 g_string_append (string_builder, ">\n");
912 for (n = 0; info->annotations != NULL && info->annotations[n] != NULL; n++)
913 g_dbus_annotation_info_generate_xml (info->annotations[n],
917 for (n = 0; info->interfaces != NULL && info->interfaces[n] != NULL; n++)
918 g_dbus_interface_info_generate_xml (info->interfaces[n],
922 for (n = 0; info->nodes != NULL && info->nodes[n] != NULL; n++)
923 g_dbus_node_info_generate_xml (info->nodes[n],
927 g_string_append_printf (string_builder, "%*s</node>\n", indent, "");
931 /* ---------------------------------------------------------------------------------------------------- */
933 static GDBusAnnotationInfo **
934 parse_data_steal_annotations (ParseData *data,
935 guint *out_num_elements)
937 GDBusAnnotationInfo **ret;
938 if (out_num_elements != NULL)
939 *out_num_elements = data->annotations->len;
940 if (data->annotations == NULL)
944 g_ptr_array_add (data->annotations, NULL);
945 ret = (GDBusAnnotationInfo **) g_ptr_array_free (data->annotations, FALSE);
947 data->annotations = g_ptr_array_new ();
951 static GDBusArgInfo **
952 parse_data_steal_args (ParseData *data,
953 guint *out_num_elements)
956 if (out_num_elements != NULL)
957 *out_num_elements = data->args->len;
958 if (data->args == NULL)
962 g_ptr_array_add (data->args, NULL);
963 ret = (GDBusArgInfo **) g_ptr_array_free (data->args, FALSE);
965 data->args = g_ptr_array_new ();
969 static GDBusArgInfo **
970 parse_data_steal_out_args (ParseData *data,
971 guint *out_num_elements)
974 if (out_num_elements != NULL)
975 *out_num_elements = data->out_args->len;
976 if (data->out_args == NULL)
980 g_ptr_array_add (data->out_args, NULL);
981 ret = (GDBusArgInfo **) g_ptr_array_free (data->out_args, FALSE);
983 data->out_args = g_ptr_array_new ();
987 static GDBusMethodInfo **
988 parse_data_steal_methods (ParseData *data,
989 guint *out_num_elements)
991 GDBusMethodInfo **ret;
992 if (out_num_elements != NULL)
993 *out_num_elements = data->methods->len;
994 if (data->methods == NULL)
998 g_ptr_array_add (data->methods, NULL);
999 ret = (GDBusMethodInfo **) g_ptr_array_free (data->methods, FALSE);
1001 data->methods = g_ptr_array_new ();
1005 static GDBusSignalInfo **
1006 parse_data_steal_signals (ParseData *data,
1007 guint *out_num_elements)
1009 GDBusSignalInfo **ret;
1010 if (out_num_elements != NULL)
1011 *out_num_elements = data->signals->len;
1012 if (data->signals == NULL)
1016 g_ptr_array_add (data->signals, NULL);
1017 ret = (GDBusSignalInfo **) g_ptr_array_free (data->signals, FALSE);
1019 data->signals = g_ptr_array_new ();
1023 static GDBusPropertyInfo **
1024 parse_data_steal_properties (ParseData *data,
1025 guint *out_num_elements)
1027 GDBusPropertyInfo **ret;
1028 if (out_num_elements != NULL)
1029 *out_num_elements = data->properties->len;
1030 if (data->properties == NULL)
1034 g_ptr_array_add (data->properties, NULL);
1035 ret = (GDBusPropertyInfo **) g_ptr_array_free (data->properties, FALSE);
1037 data->properties = g_ptr_array_new ();
1041 static GDBusInterfaceInfo **
1042 parse_data_steal_interfaces (ParseData *data,
1043 guint *out_num_elements)
1045 GDBusInterfaceInfo **ret;
1046 if (out_num_elements != NULL)
1047 *out_num_elements = data->interfaces->len;
1048 if (data->interfaces == NULL)
1052 g_ptr_array_add (data->interfaces, NULL);
1053 ret = (GDBusInterfaceInfo **) g_ptr_array_free (data->interfaces, FALSE);
1055 data->interfaces = g_ptr_array_new ();
1059 static GDBusNodeInfo **
1060 parse_data_steal_nodes (ParseData *data,
1061 guint *out_num_elements)
1063 GDBusNodeInfo **ret;
1064 if (out_num_elements != NULL)
1065 *out_num_elements = data->nodes->len;
1066 if (data->nodes == NULL)
1070 g_ptr_array_add (data->nodes, NULL);
1071 ret = (GDBusNodeInfo **) g_ptr_array_free (data->nodes, FALSE);
1073 data->nodes = g_ptr_array_new ();
1077 /* ---------------------------------------------------------------------------------------------------- */
1080 parse_data_free_annotations (ParseData *data)
1082 if (data->annotations == NULL)
1084 g_ptr_array_foreach (data->annotations, (GFunc) g_dbus_annotation_info_unref, NULL);
1085 g_ptr_array_free (data->annotations, TRUE);
1086 data->annotations = NULL;
1090 parse_data_free_args (ParseData *data)
1092 if (data->args == NULL)
1094 g_ptr_array_foreach (data->args, (GFunc) g_dbus_arg_info_unref, NULL);
1095 g_ptr_array_free (data->args, TRUE);
1100 parse_data_free_out_args (ParseData *data)
1102 if (data->out_args == NULL)
1104 g_ptr_array_foreach (data->out_args, (GFunc) g_dbus_arg_info_unref, NULL);
1105 g_ptr_array_free (data->out_args, TRUE);
1106 data->out_args = NULL;
1110 parse_data_free_methods (ParseData *data)
1112 if (data->methods == NULL)
1114 g_ptr_array_foreach (data->methods, (GFunc) g_dbus_method_info_unref, NULL);
1115 g_ptr_array_free (data->methods, TRUE);
1116 data->methods = NULL;
1120 parse_data_free_signals (ParseData *data)
1122 if (data->signals == NULL)
1124 g_ptr_array_foreach (data->signals, (GFunc) g_dbus_signal_info_unref, NULL);
1125 g_ptr_array_free (data->signals, TRUE);
1126 data->signals = NULL;
1130 parse_data_free_properties (ParseData *data)
1132 if (data->properties == NULL)
1134 g_ptr_array_foreach (data->properties, (GFunc) g_dbus_property_info_unref, NULL);
1135 g_ptr_array_free (data->properties, TRUE);
1136 data->properties = NULL;
1140 parse_data_free_interfaces (ParseData *data)
1142 if (data->interfaces == NULL)
1144 g_ptr_array_foreach (data->interfaces, (GFunc) g_dbus_interface_info_unref, NULL);
1145 g_ptr_array_free (data->interfaces, TRUE);
1146 data->interfaces = NULL;
1150 parse_data_free_nodes (ParseData *data)
1152 if (data->nodes == NULL)
1154 g_ptr_array_foreach (data->nodes, (GFunc) g_dbus_node_info_unref, NULL);
1155 g_ptr_array_free (data->nodes, TRUE);
1159 /* ---------------------------------------------------------------------------------------------------- */
1161 static GDBusAnnotationInfo *
1162 parse_data_get_annotation (ParseData *data,
1163 gboolean create_new)
1166 g_ptr_array_add (data->annotations, g_new0 (GDBusAnnotationInfo, 1));
1167 return data->annotations->pdata[data->annotations->len - 1];
1170 static GDBusArgInfo *
1171 parse_data_get_arg (ParseData *data,
1172 gboolean create_new)
1175 g_ptr_array_add (data->args, g_new0 (GDBusArgInfo, 1));
1176 return data->args->pdata[data->args->len - 1];
1179 static GDBusArgInfo *
1180 parse_data_get_out_arg (ParseData *data,
1181 gboolean create_new)
1184 g_ptr_array_add (data->out_args, g_new0 (GDBusArgInfo, 1));
1185 return data->out_args->pdata[data->out_args->len - 1];
1188 static GDBusMethodInfo *
1189 parse_data_get_method (ParseData *data,
1190 gboolean create_new)
1193 g_ptr_array_add (data->methods, g_new0 (GDBusMethodInfo, 1));
1194 return data->methods->pdata[data->methods->len - 1];
1197 static GDBusSignalInfo *
1198 parse_data_get_signal (ParseData *data,
1199 gboolean create_new)
1202 g_ptr_array_add (data->signals, g_new0 (GDBusSignalInfo, 1));
1203 return data->signals->pdata[data->signals->len - 1];
1206 static GDBusPropertyInfo *
1207 parse_data_get_property (ParseData *data,
1208 gboolean create_new)
1211 g_ptr_array_add (data->properties, g_new0 (GDBusPropertyInfo, 1));
1212 return data->properties->pdata[data->properties->len - 1];
1215 static GDBusInterfaceInfo *
1216 parse_data_get_interface (ParseData *data,
1217 gboolean create_new)
1220 g_ptr_array_add (data->interfaces, g_new0 (GDBusInterfaceInfo, 1));
1221 return data->interfaces->pdata[data->interfaces->len - 1];
1224 static GDBusNodeInfo *
1225 parse_data_get_node (ParseData *data,
1226 gboolean create_new)
1229 g_ptr_array_add (data->nodes, g_new0 (GDBusNodeInfo, 1));
1230 return data->nodes->pdata[data->nodes->len - 1];
1233 /* ---------------------------------------------------------------------------------------------------- */
1236 parse_data_new (void)
1240 data = g_new0 (ParseData, 1);
1242 /* initialize arrays */
1243 parse_data_steal_annotations (data, NULL);
1244 parse_data_steal_args (data, NULL);
1245 parse_data_steal_out_args (data, NULL);
1246 parse_data_steal_methods (data, NULL);
1247 parse_data_steal_signals (data, NULL);
1248 parse_data_steal_properties (data, NULL);
1249 parse_data_steal_interfaces (data, NULL);
1250 parse_data_steal_nodes (data, NULL);
1256 parse_data_free (ParseData *data)
1260 /* free stack of annotation arrays */
1261 for (l = data->annotations_stack; l != NULL; l = l->next)
1263 GPtrArray *annotations = l->data;
1264 g_ptr_array_foreach (annotations, (GFunc) g_dbus_annotation_info_unref, NULL);
1265 g_ptr_array_free (annotations, TRUE);
1267 g_slist_free (data->annotations_stack);
1269 /* free stack of interface arrays */
1270 for (l = data->interfaces_stack; l != NULL; l = l->next)
1272 GPtrArray *interfaces = l->data;
1273 g_ptr_array_foreach (interfaces, (GFunc) g_dbus_interface_info_unref, NULL);
1274 g_ptr_array_free (interfaces, TRUE);
1276 g_slist_free (data->interfaces_stack);
1278 /* free stack of node arrays */
1279 for (l = data->nodes_stack; l != NULL; l = l->next)
1281 GPtrArray *nodes = l->data;
1282 g_ptr_array_foreach (nodes, (GFunc) g_dbus_node_info_unref, NULL);
1283 g_ptr_array_free (nodes, TRUE);
1285 g_slist_free (data->nodes_stack);
1287 /* free arrays (data->annotations, data->interfaces and data->nodes have been freed above) */
1288 parse_data_free_args (data);
1289 parse_data_free_out_args (data);
1290 parse_data_free_methods (data);
1291 parse_data_free_signals (data);
1292 parse_data_free_properties (data);
1297 /* ---------------------------------------------------------------------------------------------------- */
1300 parser_start_element (GMarkupParseContext *context,
1301 const gchar *element_name,
1302 const gchar **attribute_names,
1303 const gchar **attribute_values,
1307 ParseData *data = user_data;
1311 const gchar *access;
1312 const gchar *direction;
1321 stack = (GSList *) g_markup_parse_context_get_element_stack (context);
1323 /* ---------------------------------------------------------------------------------------------------- */
1324 if (strcmp (element_name, "node") == 0)
1326 if (!(g_slist_length (stack) >= 1 || strcmp (stack->next->data, "node") != 0))
1328 g_set_error_literal (error,
1330 G_MARKUP_ERROR_INVALID_CONTENT,
1331 "<node> elements can only be top-level or embedded in other <node> elements");
1335 if (!g_markup_collect_attributes (element_name,
1339 G_MARKUP_COLLECT_STRING | G_MARKUP_COLLECT_OPTIONAL, "name", &name,
1340 /* some hand-written introspection XML documents use this */
1341 G_MARKUP_COLLECT_STRING | G_MARKUP_COLLECT_OPTIONAL, "xmlns:doc", NULL,
1342 G_MARKUP_COLLECT_INVALID))
1345 g_dbus_node_info_set (data,
1346 parse_data_get_node (data, TRUE),
1352 /* push the currently retrieved interfaces and nodes on the stack and prepare new arrays */
1353 data->interfaces_stack = g_slist_prepend (data->interfaces_stack, data->interfaces);
1354 data->interfaces = NULL;
1355 parse_data_steal_interfaces (data, NULL);
1357 data->nodes_stack = g_slist_prepend (data->nodes_stack, data->nodes);
1359 parse_data_steal_nodes (data, NULL);
1362 /* ---------------------------------------------------------------------------------------------------- */
1363 else if (strcmp (element_name, "interface") == 0)
1365 if (g_slist_length (stack) < 2 || strcmp (stack->next->data, "node") != 0)
1367 g_set_error_literal (error,
1369 G_MARKUP_ERROR_INVALID_CONTENT,
1370 "<interface> elements can only be embedded in <node> elements");
1374 if (!g_markup_collect_attributes (element_name,
1378 G_MARKUP_COLLECT_STRING, "name", &name,
1379 G_MARKUP_COLLECT_INVALID))
1382 g_dbus_interface_info_set (data,
1383 parse_data_get_interface (data, TRUE),
1391 /* ---------------------------------------------------------------------------------------------------- */
1392 else if (strcmp (element_name, "method") == 0)
1394 if (g_slist_length (stack) < 2 || strcmp (stack->next->data, "interface") != 0)
1396 g_set_error_literal (error,
1398 G_MARKUP_ERROR_INVALID_CONTENT,
1399 "<method> elements can only be embedded in <interface> elements");
1403 if (!g_markup_collect_attributes (element_name,
1407 G_MARKUP_COLLECT_STRING, "name", &name,
1408 G_MARKUP_COLLECT_INVALID))
1411 g_dbus_method_info_set (data,
1412 parse_data_get_method (data, TRUE),
1421 /* ---------------------------------------------------------------------------------------------------- */
1422 else if (strcmp (element_name, "signal") == 0)
1424 if (g_slist_length (stack) < 2 || strcmp (stack->next->data, "interface") != 0)
1426 g_set_error_literal (error,
1428 G_MARKUP_ERROR_INVALID_CONTENT,
1429 "<signal> elements can only be embedded in <interface> elements");
1433 if (!g_markup_collect_attributes (element_name,
1437 G_MARKUP_COLLECT_STRING, "name", &name,
1438 G_MARKUP_COLLECT_INVALID))
1441 g_dbus_signal_info_set (data,
1442 parse_data_get_signal (data, TRUE),
1450 /* ---------------------------------------------------------------------------------------------------- */
1451 else if (strcmp (element_name, "property") == 0)
1453 GDBusPropertyInfoFlags flags;
1455 if (g_slist_length (stack) < 2 || strcmp (stack->next->data, "interface") != 0)
1457 g_set_error_literal (error,
1459 G_MARKUP_ERROR_INVALID_CONTENT,
1460 "<property> elements can only be embedded in <interface> elements");
1464 if (!g_markup_collect_attributes (element_name,
1468 G_MARKUP_COLLECT_STRING, "name", &name,
1469 G_MARKUP_COLLECT_STRING, "type", &type,
1470 G_MARKUP_COLLECT_STRING, "access", &access,
1471 G_MARKUP_COLLECT_INVALID))
1474 if (strcmp (access, "read") == 0)
1475 flags = G_DBUS_PROPERTY_INFO_FLAGS_READABLE;
1476 else if (strcmp (access, "write") == 0)
1477 flags = G_DBUS_PROPERTY_INFO_FLAGS_WRITABLE;
1478 else if (strcmp (access, "readwrite") == 0)
1479 flags = G_DBUS_PROPERTY_INFO_FLAGS_READABLE | G_DBUS_PROPERTY_INFO_FLAGS_WRITABLE;
1484 G_MARKUP_ERROR_INVALID_CONTENT,
1485 "Unknown value '%s' of access attribute for element <property>",
1490 g_dbus_property_info_set (data,
1491 parse_data_get_property (data, TRUE),
1498 /* ---------------------------------------------------------------------------------------------------- */
1499 else if (strcmp (element_name, "arg") == 0)
1504 if (g_slist_length (stack) < 2 ||
1505 (strcmp (stack->next->data, "method") != 0 &&
1506 strcmp (stack->next->data, "signal") != 0))
1508 g_set_error_literal (error,
1510 G_MARKUP_ERROR_INVALID_CONTENT,
1511 "<arg> elements can only be embedded in <method> or <signal> elements");
1515 if (!g_markup_collect_attributes (element_name,
1519 G_MARKUP_COLLECT_STRING | G_MARKUP_COLLECT_OPTIONAL, "name", &name,
1520 G_MARKUP_COLLECT_STRING | G_MARKUP_COLLECT_OPTIONAL, "direction", &direction,
1521 G_MARKUP_COLLECT_STRING, "type", &type,
1522 G_MARKUP_COLLECT_INVALID))
1526 if (direction != NULL)
1528 if (strcmp (direction, "in") == 0)
1530 else if (strcmp (direction, "out") == 0)
1536 G_MARKUP_ERROR_INVALID_CONTENT,
1537 "Unknown value '%s' of direction attribute",
1543 if (is_in && strcmp (stack->next->data, "signal") == 0)
1545 g_set_error_literal (error,
1547 G_MARKUP_ERROR_INVALID_CONTENT,
1548 "Only direction 'out' is allowed for <arg> elements embedded in <signal>");
1553 name_to_use = g_strdup_printf ("arg_%d", data->num_args);
1555 name_to_use = g_strdup (name);
1560 g_dbus_arg_info_set (data,
1561 parse_data_get_arg (data, TRUE),
1565 data->last_arg_was_in = TRUE;
1569 g_dbus_arg_info_set (data,
1570 parse_data_get_out_arg (data, TRUE),
1574 data->last_arg_was_in = FALSE;
1578 g_free (name_to_use);
1580 /* ---------------------------------------------------------------------------------------------------- */
1581 else if (strcmp (element_name, "annotation") == 0)
1583 if (g_slist_length (stack) < 2 ||
1584 (strcmp (stack->next->data, "node") != 0 &&
1585 strcmp (stack->next->data, "interface") != 0 &&
1586 strcmp (stack->next->data, "signal") != 0 &&
1587 strcmp (stack->next->data, "method") != 0 &&
1588 strcmp (stack->next->data, "property") != 0 &&
1589 strcmp (stack->next->data, "arg") != 0 &&
1590 strcmp (stack->next->data, "annotation") != 0))
1592 g_set_error_literal (error,
1594 G_MARKUP_ERROR_INVALID_CONTENT,
1595 "<annotation> elements can only be embedded in <node>, <interface>, <signal>, <method>, <property>, <arg> or <annotation> elements");
1599 if (!g_markup_collect_attributes (element_name,
1603 G_MARKUP_COLLECT_STRING, "name", &name,
1604 G_MARKUP_COLLECT_STRING, "value", &value,
1605 G_MARKUP_COLLECT_INVALID))
1608 g_dbus_annotation_info_set (data,
1609 parse_data_get_annotation (data, TRUE),
1614 /* ---------------------------------------------------------------------------------------------------- */
1617 /* don't bail on unknown elements; just ignore them */
1619 /* ---------------------------------------------------------------------------------------------------- */
1621 /* push the currently retrieved annotations on the stack and prepare a new one */
1622 data->annotations_stack = g_slist_prepend (data->annotations_stack, data->annotations);
1623 data->annotations = NULL;
1624 parse_data_steal_annotations (data, NULL);
1630 /* ---------------------------------------------------------------------------------------------------- */
1632 static GDBusAnnotationInfo **
1633 steal_annotations (ParseData *data)
1635 return parse_data_steal_annotations (data, NULL);
1640 parser_end_element (GMarkupParseContext *context,
1641 const gchar *element_name,
1645 ParseData *data = user_data;
1646 gboolean have_popped_annotations;
1648 have_popped_annotations = FALSE;
1650 if (strcmp (element_name, "node") == 0)
1653 guint num_interfaces;
1654 GDBusNodeInfo **nodes;
1655 GDBusInterfaceInfo **interfaces;
1657 nodes = parse_data_steal_nodes (data, &num_nodes);
1658 interfaces = parse_data_steal_interfaces (data, &num_interfaces);
1660 /* destroy the nodes, interfaces for scope we're exiting and and pop the nodes, interfaces from the
1661 * scope we're reentering
1663 parse_data_free_interfaces (data);
1664 data->interfaces = (GPtrArray *) data->interfaces_stack->data;
1665 data->interfaces_stack = g_slist_remove (data->interfaces_stack, data->interfaces_stack->data);
1667 parse_data_free_nodes (data);
1668 data->nodes = (GPtrArray *) data->nodes_stack->data;
1669 data->nodes_stack = g_slist_remove (data->nodes_stack, data->nodes_stack->data);
1671 g_dbus_node_info_set (data,
1672 parse_data_get_node (data, FALSE),
1678 steal_annotations (data));
1681 else if (strcmp (element_name, "interface") == 0)
1685 guint num_properties;
1686 GDBusMethodInfo **methods;
1687 GDBusSignalInfo **signals;
1688 GDBusPropertyInfo **properties;
1690 methods = parse_data_steal_methods (data, &num_methods);
1691 signals = parse_data_steal_signals (data, &num_signals);
1692 properties = parse_data_steal_properties (data, &num_properties);
1694 g_dbus_interface_info_set (data,
1695 parse_data_get_interface (data, FALSE),
1703 steal_annotations (data));
1706 else if (strcmp (element_name, "method") == 0)
1710 GDBusArgInfo **in_args;
1711 GDBusArgInfo **out_args;
1713 in_args = parse_data_steal_args (data, &in_num_args);
1714 out_args = parse_data_steal_out_args (data, &out_num_args);
1716 g_dbus_method_info_set (data,
1717 parse_data_get_method (data, FALSE),
1723 steal_annotations (data));
1725 else if (strcmp (element_name, "signal") == 0)
1728 GDBusArgInfo **args;
1730 args = parse_data_steal_out_args (data, &num_args);
1732 g_dbus_signal_info_set (data,
1733 parse_data_get_signal (data, FALSE),
1737 steal_annotations (data));
1739 else if (strcmp (element_name, "property") == 0)
1741 g_dbus_property_info_set (data,
1742 parse_data_get_property (data, FALSE),
1745 G_DBUS_PROPERTY_INFO_FLAGS_NONE,
1746 steal_annotations (data));
1748 else if (strcmp (element_name, "arg") == 0)
1750 g_dbus_arg_info_set (data,
1751 data->last_arg_was_in ? parse_data_get_arg (data, FALSE) : parse_data_get_out_arg (data, FALSE),
1754 steal_annotations (data));
1756 else if (strcmp (element_name, "annotation") == 0)
1758 GDBusAnnotationInfo **embedded_annotations;
1760 embedded_annotations = steal_annotations (data);
1762 /* destroy the annotations for scope we're exiting and and pop the annotations from the scope we're reentering */
1763 parse_data_free_annotations (data);
1764 data->annotations = (GPtrArray *) data->annotations_stack->data;
1765 data->annotations_stack = g_slist_remove (data->annotations_stack, data->annotations_stack->data);
1767 have_popped_annotations = TRUE;
1769 g_dbus_annotation_info_set (data,
1770 parse_data_get_annotation (data, FALSE),
1773 embedded_annotations);
1777 /* don't bail on unknown elements; just ignore them */
1780 if (!have_popped_annotations)
1782 /* destroy the annotations for scope we're exiting and and pop the annotations from the scope we're reentering */
1783 parse_data_free_annotations (data);
1784 data->annotations = (GPtrArray *) data->annotations_stack->data;
1785 data->annotations_stack = g_slist_remove (data->annotations_stack, data->annotations_stack->data);
1789 /* ---------------------------------------------------------------------------------------------------- */
1792 parser_error (GMarkupParseContext *context,
1799 g_markup_parse_context_get_position (context, &line_number, &char_number);
1801 g_prefix_error (&error, "%d:%d: ",
1806 /* ---------------------------------------------------------------------------------------------------- */
1809 * g_dbus_node_info_new_for_xml:
1810 * @xml_data: Valid D-Bus introspection XML.
1811 * @error: Return location for error.
1813 * Parses @xml_data and returns a #GDBusNodeInfo representing the data.
1815 * Returns: A #GDBusNodeInfo structure or %NULL if @error is set. Free
1816 * with g_dbus_node_info_unref().
1821 g_dbus_node_info_new_for_xml (const gchar *xml_data,
1825 GMarkupParseContext *context;
1826 GMarkupParser *parser;
1834 parser = g_new0 (GMarkupParser, 1);
1835 parser->start_element = parser_start_element;
1836 parser->end_element = parser_end_element;
1837 parser->error = parser_error;
1839 data = parse_data_new ();
1840 context = g_markup_parse_context_new (parser,
1843 (GDestroyNotify) parse_data_free);
1845 if (!g_markup_parse_context_parse (context,
1851 GDBusNodeInfo **ughret;
1852 ughret = parse_data_steal_nodes (data, &num_nodes);
1860 G_MARKUP_ERROR_INVALID_CONTENT,
1861 "Expected a single node in introspection XML, found %d",
1865 for (n = 0; n < num_nodes; n++)
1867 for (n = 0; n < num_nodes; n++)
1868 g_dbus_node_info_unref (&(ret[n]));
1880 if (context != NULL)
1881 g_markup_parse_context_free (context);
1886 /* ---------------------------------------------------------------------------------------------------- */
1889 * g_dbus_annotation_info_lookup:
1890 * @annotations: A %NULL-terminated array of annotations or %NULL.
1891 * @name: The name of the annotation to look up.
1893 * Looks up the value of an annotation.
1895 * This cost of this function is O(n) in number of annotations.
1897 * Returns: The value or %NULL if not found. Do not free, it is owned by @annotations.
1902 g_dbus_annotation_info_lookup (const GDBusAnnotationInfo **annotations,
1909 for (n = 0; annotations != NULL && annotations[n]->key != NULL; n++)
1911 if (g_strcmp0 (annotations[n]->key, name) == 0)
1913 ret = annotations[n]->value;
1922 /* ---------------------------------------------------------------------------------------------------- */
1925 * g_dbus_interface_info_lookup_method:
1926 * @info: A #GDBusInterfaceInfo.
1927 * @name: A D-Bus method name (typically in CamelCase)
1929 * Looks up information about a method.
1931 * This cost of this function is O(n) in number of methods.
1933 * Returns: A #GDBusMethodInfo or %NULL if not found. Do not free, it is owned by @info.
1937 const GDBusMethodInfo *
1938 g_dbus_interface_info_lookup_method (const GDBusInterfaceInfo *info,
1942 const GDBusMethodInfo *result;
1944 for (n = 0; info->methods != NULL && info->methods[n] != NULL; n++)
1946 const GDBusMethodInfo *i = info->methods[n];
1948 if (g_strcmp0 (i->name, name) == 0)
1961 /* ---------------------------------------------------------------------------------------------------- */
1964 * g_dbus_interface_info_lookup_signal:
1965 * @info: A #GDBusInterfaceInfo.
1966 * @name: A D-Bus signal name (typically in CamelCase)
1968 * Looks up information about a signal.
1970 * This cost of this function is O(n) in number of signals.
1972 * Returns: A #GDBusSignalInfo or %NULL if not found. Do not free, it is owned by @info.
1976 const GDBusSignalInfo *
1977 g_dbus_interface_info_lookup_signal (const GDBusInterfaceInfo *info,
1981 const GDBusSignalInfo *result;
1983 for (n = 0; info->signals != NULL && info->signals[n] != NULL; n++)
1985 const GDBusSignalInfo *i = info->signals[n];
1987 if (g_strcmp0 (i->name, name) == 0)
2000 /* ---------------------------------------------------------------------------------------------------- */
2003 * g_dbus_interface_info_lookup_property:
2004 * @info: A #GDBusInterfaceInfo.
2005 * @name: A D-Bus property name (typically in CamelCase).
2007 * Looks up information about a property.
2009 * This cost of this function is O(n) in number of properties.
2011 * Returns: A #GDBusPropertyInfo or %NULL if not found. Do not free, it is owned by @info.
2015 const GDBusPropertyInfo *
2016 g_dbus_interface_info_lookup_property (const GDBusInterfaceInfo *info,
2020 const GDBusPropertyInfo *result;
2022 for (n = 0; info->properties != NULL && info->properties[n] != NULL; n++)
2024 const GDBusPropertyInfo *i = info->properties[n];
2026 if (g_strcmp0 (i->name, name) == 0)
2039 /* ---------------------------------------------------------------------------------------------------- */
2042 * g_dbus_node_info_lookup_interface:
2043 * @info: A #GDBusNodeInfo.
2044 * @name: A D-Bus interface name.
2046 * Looks up information about an interface.
2048 * This cost of this function is O(n) in number of interfaces.
2050 * Returns: A #GDBusInterfaceInfo or %NULL if not found. Do not free, it is owned by @info.
2054 const GDBusInterfaceInfo *
2055 g_dbus_node_info_lookup_interface (const GDBusNodeInfo *info,
2059 const GDBusInterfaceInfo *result;
2061 for (n = 0; info->interfaces != NULL && info->interfaces[n] != NULL; n++)
2063 const GDBusInterfaceInfo *i = info->interfaces[n];
2065 if (g_strcmp0 (i->name, name) == 0)
2078 #define __G_DBUS_INTROSPECTION_C__
2079 #include "gioaliasdef.c"