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"
33 * SECTION:gdbusintrospection
34 * @title: D-Bus Introspection Data
35 * @short_description: Node and interface description data structures
38 * Various data structures and convenience routines to parse and
39 * generate D-Bus introspection XML. Introspection information is
40 * used when registering objects with g_dbus_connection_register_object().
42 * The format of D-BUs introspection XML is specified in the
43 * <link linkend="http://dbus.freedesktop.org/doc/dbus-specification.html#introspection-format">D-Bus specification</link>.
46 /* ---------------------------------------------------------------------------------------------------- */
48 /* See also https://bugzilla.gnome.org/show_bug.cgi?id=449565 ... */
49 #define _MY_DEFINE_BOXED_TYPE(TypeName, type_name) \
51 type_name##_get_type (void) \
53 static volatile gsize type_volatile = 0; \
54 if (g_once_init_enter (&type_volatile)) \
56 GType type = g_boxed_type_register_static (g_intern_static_string (#TypeName), \
57 (GBoxedCopyFunc) type_name##_ref, \
58 (GBoxedFreeFunc) type_name##_unref); \
59 g_once_init_leave (&type_volatile, type); \
61 return (GType) type_volatile; \
64 _MY_DEFINE_BOXED_TYPE (GDBusNodeInfo, g_dbus_node_info);
65 _MY_DEFINE_BOXED_TYPE (GDBusInterfaceInfo, g_dbus_interface_info);
66 _MY_DEFINE_BOXED_TYPE (GDBusMethodInfo, g_dbus_method_info);
67 _MY_DEFINE_BOXED_TYPE (GDBusSignalInfo, g_dbus_signal_info);
68 _MY_DEFINE_BOXED_TYPE (GDBusPropertyInfo, g_dbus_property_info);
69 _MY_DEFINE_BOXED_TYPE (GDBusArgInfo, g_dbus_arg_info);
70 _MY_DEFINE_BOXED_TYPE (GDBusAnnotationInfo, g_dbus_annotation_info);
72 /* ---------------------------------------------------------------------------------------------------- */
76 /* stuff we are currently collecting */
81 GPtrArray *properties;
82 GPtrArray *interfaces;
84 GPtrArray *annotations;
86 /* A list of GPtrArray's containing annotations */
87 GSList *annotations_stack;
89 /* A list of GPtrArray's containing interfaces */
90 GSList *interfaces_stack;
92 /* A list of GPtrArray's containing nodes */
95 /* Whether the direction was "in" for last parsed arg */
96 gboolean last_arg_was_in;
98 /* Number of args currently being collected; used for assigning
99 * names to args without a "name" attribute
105 /* ---------------------------------------------------------------------------------------------------- */
108 * g_dbus_node_info_ref:
109 * @info: A #GDBusNodeInfo
111 * If @info is statically allocated does nothing. Otherwise increases
112 * the reference count.
114 * Returns: The same @info.
119 g_dbus_node_info_ref (GDBusNodeInfo *info)
121 if (info->ref_count == -1)
123 g_atomic_int_inc (&info->ref_count);
128 * g_dbus_interface_info_ref:
129 * @info: A #GDBusInterfaceInfo
131 * If @info is statically allocated does nothing. Otherwise increases
132 * the reference count.
134 * Returns: The same @info.
139 g_dbus_interface_info_ref (GDBusInterfaceInfo *info)
141 if (info->ref_count == -1)
143 g_atomic_int_inc (&info->ref_count);
148 * g_dbus_method_info_ref:
149 * @info: A #GDBusMethodInfo
151 * If @info is statically allocated does nothing. Otherwise increases
152 * the reference count.
154 * Returns: The same @info.
159 g_dbus_method_info_ref (GDBusMethodInfo *info)
161 if (info->ref_count == -1)
163 g_atomic_int_inc (&info->ref_count);
168 * g_dbus_signal_info_ref:
169 * @info: A #GDBusSignalInfo
171 * If @info is statically allocated does nothing. Otherwise increases
172 * the reference count.
174 * Returns: The same @info.
179 g_dbus_signal_info_ref (GDBusSignalInfo *info)
181 if (info->ref_count == -1)
183 g_atomic_int_inc (&info->ref_count);
188 * g_dbus_property_info_ref:
189 * @info: A #GDBusPropertyInfo
191 * If @info is statically allocated does nothing. Otherwise increases
192 * the reference count.
194 * Returns: The same @info.
199 g_dbus_property_info_ref (GDBusPropertyInfo *info)
201 if (info->ref_count == -1)
203 g_atomic_int_inc (&info->ref_count);
208 * g_dbus_arg_info_ref:
209 * @info: A #GDBusArgInfo
211 * If @info is statically allocated does nothing. Otherwise increases
212 * the reference count.
214 * Returns: The same @info.
219 g_dbus_arg_info_ref (GDBusArgInfo *info)
221 if (info->ref_count == -1)
223 g_atomic_int_inc (&info->ref_count);
228 * g_dbus_annotation_info_ref:
229 * @info: A #GDBusNodeInfo
231 * If @info is statically allocated does nothing. Otherwise increases
232 * the reference count.
234 * Returns: The same @info.
238 GDBusAnnotationInfo *
239 g_dbus_annotation_info_ref (GDBusAnnotationInfo *info)
241 if (info->ref_count == -1)
243 g_atomic_int_inc (&info->ref_count);
247 /* ---------------------------------------------------------------------------------------------------- */
250 free_null_terminated_array (gpointer array, GDestroyNotify unref_func)
256 for (n = 0; p[n] != NULL; n++)
262 * g_dbus_annotation_info_unref:
263 * @info: A #GDBusAnnotationInfo.
265 * If @info is statically allocated, does nothing. Otherwise decreases
266 * the reference count of @info. When its reference count drops to 0,
267 * the memory used is freed.
272 g_dbus_annotation_info_unref (GDBusAnnotationInfo *info)
274 if (info->ref_count == -1)
276 if (g_atomic_int_dec_and_test (&info->ref_count))
279 g_free (info->value);
280 free_null_terminated_array (info->annotations, (GDestroyNotify) g_dbus_annotation_info_unref);
286 * g_dbus_arg_info_unref:
287 * @info: A #GDBusArgInfo.
289 * If @info is statically allocated, does nothing. Otherwise decreases
290 * the reference count of @info. When its reference count drops to 0,
291 * the memory used is freed.
296 g_dbus_arg_info_unref (GDBusArgInfo *info)
298 if (info->ref_count == -1)
300 if (g_atomic_int_dec_and_test (&info->ref_count))
303 g_free (info->signature);
304 free_null_terminated_array (info->annotations, (GDestroyNotify) g_dbus_annotation_info_unref);
310 * g_dbus_method_info_unref:
311 * @info: A #GDBusMethodInfo.
313 * If @info is statically allocated, does nothing. Otherwise decreases
314 * the reference count of @info. When its reference count drops to 0,
315 * the memory used is freed.
320 g_dbus_method_info_unref (GDBusMethodInfo *info)
322 if (info->ref_count == -1)
324 if (g_atomic_int_dec_and_test (&info->ref_count))
327 free_null_terminated_array (info->in_args, (GDestroyNotify) g_dbus_arg_info_unref);
328 free_null_terminated_array (info->out_args, (GDestroyNotify) g_dbus_arg_info_unref);
329 free_null_terminated_array (info->annotations, (GDestroyNotify) g_dbus_annotation_info_unref);
335 * g_dbus_signal_info_unref:
336 * @info: A #GDBusSignalInfo.
338 * If @info is statically allocated, does nothing. Otherwise decreases
339 * the reference count of @info. When its reference count drops to 0,
340 * the memory used is freed.
345 g_dbus_signal_info_unref (GDBusSignalInfo *info)
347 if (info->ref_count == -1)
349 if (g_atomic_int_dec_and_test (&info->ref_count))
352 free_null_terminated_array (info->args, (GDestroyNotify) g_dbus_arg_info_unref);
353 free_null_terminated_array (info->annotations, (GDestroyNotify) g_dbus_annotation_info_unref);
359 * g_dbus_property_info_unref:
360 * @info: A #GDBusPropertyInfo.
362 * If @info is statically allocated, does nothing. Otherwise decreases
363 * the reference count of @info. When its reference count drops to 0,
364 * the memory used is freed.
369 g_dbus_property_info_unref (GDBusPropertyInfo *info)
371 if (info->ref_count == -1)
373 if (g_atomic_int_dec_and_test (&info->ref_count))
376 g_free (info->signature);
377 free_null_terminated_array (info->annotations, (GDestroyNotify) g_dbus_annotation_info_unref);
383 * g_dbus_interface_info_unref:
384 * @info: A #GDBusInterfaceInfo.
386 * If @info is statically allocated, does nothing. Otherwise decreases
387 * the reference count of @info. When its reference count drops to 0,
388 * the memory used is freed.
393 g_dbus_interface_info_unref (GDBusInterfaceInfo *info)
395 if (info->ref_count == -1)
397 if (g_atomic_int_dec_and_test (&info->ref_count))
400 free_null_terminated_array (info->methods, (GDestroyNotify) g_dbus_method_info_unref);
401 free_null_terminated_array (info->signals, (GDestroyNotify) g_dbus_signal_info_unref);
402 free_null_terminated_array (info->properties, (GDestroyNotify) g_dbus_property_info_unref);
403 free_null_terminated_array (info->annotations, (GDestroyNotify) g_dbus_annotation_info_unref);
409 * g_dbus_node_info_unref:
410 * @info: A #GDBusNodeInfo.
412 * If @info is statically allocated, does nothing. Otherwise decreases
413 * the reference count of @info. When its reference count drops to 0,
414 * the memory used is freed.
419 g_dbus_node_info_unref (GDBusNodeInfo *info)
421 if (info->ref_count == -1)
423 if (g_atomic_int_dec_and_test (&info->ref_count))
426 free_null_terminated_array (info->interfaces, (GDestroyNotify) g_dbus_interface_info_unref);
427 free_null_terminated_array (info->nodes, (GDestroyNotify) g_dbus_node_info_unref);
428 free_null_terminated_array (info->annotations, (GDestroyNotify) g_dbus_annotation_info_unref);
433 /* ---------------------------------------------------------------------------------------------------- */
436 g_dbus_annotation_info_set (ParseData *data,
437 GDBusAnnotationInfo *info,
440 GDBusAnnotationInfo **embedded_annotations)
445 info->key = g_strdup (key);
448 info->value = g_strdup (value);
450 if (embedded_annotations != NULL)
451 info->annotations = embedded_annotations;
455 g_dbus_arg_info_set (ParseData *data,
458 const gchar *signature,
459 GDBusAnnotationInfo **annotations)
463 /* name may be NULL - TODO: compute name? */
465 info->name = g_strdup (name);
467 if (signature != NULL)
468 info->signature = g_strdup (signature);
470 if (annotations != NULL)
471 info->annotations = annotations;
475 g_dbus_method_info_set (ParseData *data,
476 GDBusMethodInfo *info,
479 GDBusArgInfo **in_args,
481 GDBusArgInfo **out_args,
482 GDBusAnnotationInfo **annotations)
487 info->name = g_strdup (name);
489 if (in_num_args != 0)
491 //info->in_num_args = in_num_args;
492 info->in_args = in_args;
495 if (out_num_args != 0)
497 //info->out_num_args = out_num_args;
498 info->out_args = out_args;
501 if (annotations != NULL)
502 info->annotations = annotations;
506 g_dbus_signal_info_set (ParseData *data,
507 GDBusSignalInfo *info,
511 GDBusAnnotationInfo **annotations)
516 info->name = g_strdup (name);
520 //info->num_args = num_args;
524 if (annotations != NULL)
526 info->annotations = annotations;
531 g_dbus_property_info_set (ParseData *data,
532 GDBusPropertyInfo *info,
534 const gchar *signature,
535 GDBusPropertyInfoFlags flags,
536 GDBusAnnotationInfo **annotations)
541 info->name = g_strdup (name);
543 if (flags != G_DBUS_PROPERTY_INFO_FLAGS_NONE)
546 if (signature != NULL)
548 info->signature = g_strdup (signature);
551 if (annotations != NULL)
553 info->annotations = annotations;
558 g_dbus_interface_info_set (ParseData *data,
559 GDBusInterfaceInfo *info,
562 GDBusMethodInfo **methods,
564 GDBusSignalInfo **signals,
565 guint num_properties,
566 GDBusPropertyInfo **properties,
567 GDBusAnnotationInfo **annotations)
573 info->name = g_strdup (name);
576 if (num_methods != 0)
578 //info->num_methods = num_methods;
579 info->methods = methods;
582 if (num_signals != 0)
584 //info->num_signals = num_signals;
585 info->signals = signals;
588 if (num_properties != 0)
590 //info->num_properties = num_properties;
591 info->properties = properties;
594 if (annotations != NULL)
596 info->annotations = annotations;
601 g_dbus_node_info_set (ParseData *data,
604 guint num_interfaces,
605 GDBusInterfaceInfo **interfaces,
607 GDBusNodeInfo **nodes,
608 GDBusAnnotationInfo **annotations)
614 info->path = g_strdup (path);
615 /* TODO: relative / absolute path snafu */
618 if (num_interfaces != 0)
620 //info->num_interfaces = num_interfaces;
621 info->interfaces = interfaces;
626 //info->num_nodes = num_nodes;
630 if (annotations != NULL)
632 info->annotations = annotations;
637 /* ---------------------------------------------------------------------------------------------------- */
640 g_dbus_annotation_info_generate_xml (const GDBusAnnotationInfo *info,
642 GString *string_builder)
646 g_string_append_printf (string_builder, "%*s<annotation name=\"%s\" value=\"%s\"",
651 if (info->annotations == NULL)
653 g_string_append (string_builder, "/>\n");
657 g_string_append (string_builder, ">\n");
659 for (n = 0; info->annotations != NULL && info->annotations[n] != NULL; n++)
660 g_dbus_annotation_info_generate_xml (info->annotations[n],
664 g_string_append_printf (string_builder, "%*s</annotation>\n",
671 g_dbus_arg_info_generate_xml (const GDBusArgInfo *info,
673 const gchar *extra_attributes,
674 GString *string_builder)
678 g_string_append_printf (string_builder, "%*s<arg type=\"%s\"",
682 if (info->name != NULL)
683 g_string_append_printf (string_builder, " name=\"%s\"", info->name);
685 if (extra_attributes != NULL)
686 g_string_append_printf (string_builder, " %s", extra_attributes);
688 if (info->annotations == NULL)
690 g_string_append (string_builder, "/>\n");
694 g_string_append (string_builder, ">\n");
696 for (n = 0; info->annotations != NULL && info->annotations[n] != NULL; n++)
697 g_dbus_annotation_info_generate_xml (info->annotations[n],
701 g_string_append_printf (string_builder, "%*s</arg>\n", indent, "");
707 g_dbus_method_info_generate_xml (const GDBusMethodInfo *info,
709 GString *string_builder)
713 g_string_append_printf (string_builder, "%*s<method name=\"%s\"",
717 if (info->annotations == NULL && info->in_args == NULL && info->out_args == NULL)
719 g_string_append (string_builder, "/>\n");
723 g_string_append (string_builder, ">\n");
725 for (n = 0; info->annotations != NULL && info->annotations[n] != NULL; n++)
726 g_dbus_annotation_info_generate_xml (info->annotations[n],
730 for (n = 0; info->in_args != NULL && info->in_args[n] != NULL; n++)
731 g_dbus_arg_info_generate_xml (info->in_args[n],
736 for (n = 0; info->out_args != NULL && info->out_args[n] != NULL; n++)
737 g_dbus_arg_info_generate_xml (info->out_args[n],
742 g_string_append_printf (string_builder, "%*s</method>\n", indent, "");
747 g_dbus_signal_info_generate_xml (const GDBusSignalInfo *info,
749 GString *string_builder)
753 g_string_append_printf (string_builder, "%*s<signal name=\"%s\"",
757 if (info->annotations == NULL && info->args == NULL)
759 g_string_append (string_builder, "/>\n");
763 g_string_append (string_builder, ">\n");
765 for (n = 0; info->annotations != NULL && info->annotations[n] != NULL; n++)
766 g_dbus_annotation_info_generate_xml (info->annotations[n],
770 for (n = 0; info->args != NULL && info->args[n] != NULL; n++)
771 g_dbus_arg_info_generate_xml (info->args[n],
776 g_string_append_printf (string_builder, "%*s</signal>\n", indent, "");
781 g_dbus_property_info_generate_xml (const GDBusPropertyInfo *info,
783 GString *string_builder)
786 const gchar *access_string;
788 if ((info->flags & G_DBUS_PROPERTY_INFO_FLAGS_READABLE) &&
789 (info->flags & G_DBUS_PROPERTY_INFO_FLAGS_WRITABLE))
791 access_string = "readwrite";
793 else if (info->flags & G_DBUS_PROPERTY_INFO_FLAGS_READABLE)
795 access_string = "read";
797 else if (info->flags & G_DBUS_PROPERTY_INFO_FLAGS_WRITABLE)
799 access_string = "write";
803 g_assert_not_reached ();
806 g_string_append_printf (string_builder, "%*s<property type=\"%s\" name=\"%s\" access=\"%s\"",
812 if (info->annotations == NULL)
814 g_string_append (string_builder, "/>\n");
818 g_string_append (string_builder, ">\n");
820 for (n = 0; info->annotations != NULL && info->annotations[n] != NULL; n++)
821 g_dbus_annotation_info_generate_xml (info->annotations[n],
825 g_string_append_printf (string_builder, "%*s</property>\n", indent, "");
831 * g_dbus_interface_info_generate_xml:
832 * @info: A #GDBusNodeInfo
833 * @indent: Indentation level.
834 * @string_builder: A #GString to to append XML data to.
836 * Appends an XML representation of @info (and its children) to @string_builder.
838 * This function is typically used for generating introspection XML
839 * documents at run-time for handling the
840 * <literal>org.freedesktop.DBus.Introspectable.Introspect</literal>
846 g_dbus_interface_info_generate_xml (const GDBusInterfaceInfo *info,
848 GString *string_builder)
852 g_string_append_printf (string_builder, "%*s<interface name=\"%s\">\n",
856 for (n = 0; info->annotations != NULL && info->annotations[n] != NULL; n++)
857 g_dbus_annotation_info_generate_xml (info->annotations[n],
861 for (n = 0; info->methods != NULL && info->methods[n] != NULL; n++)
862 g_dbus_method_info_generate_xml (info->methods[n],
866 for (n = 0; info->signals != NULL && info->signals[n] != NULL; n++)
867 g_dbus_signal_info_generate_xml (info->signals[n],
871 for (n = 0; info->properties != NULL && info->properties[n] != NULL; n++)
872 g_dbus_property_info_generate_xml (info->properties[n],
876 g_string_append_printf (string_builder, "%*s</interface>\n", indent, "");
880 * g_dbus_node_info_generate_xml:
881 * @info: A #GDBusNodeInfo.
882 * @indent: Indentation level.
883 * @string_builder: A #GString to to append XML data to.
885 * Appends an XML representation of @info (and its children) to @string_builder.
887 * This function is typically used for generating introspection XML documents at run-time for
888 * handling the <literal>org.freedesktop.DBus.Introspectable.Introspect</literal> method.
893 g_dbus_node_info_generate_xml (const GDBusNodeInfo *info,
895 GString *string_builder)
899 g_string_append_printf (string_builder, "%*s<node", indent, "");
900 if (info->path != NULL)
901 g_string_append_printf (string_builder, " name=\"%s\"", info->path);
903 if (info->interfaces == NULL && info->nodes == NULL && info->annotations == NULL)
905 g_string_append (string_builder, "/>\n");
909 g_string_append (string_builder, ">\n");
911 for (n = 0; info->annotations != NULL && info->annotations[n] != NULL; n++)
912 g_dbus_annotation_info_generate_xml (info->annotations[n],
916 for (n = 0; info->interfaces != NULL && info->interfaces[n] != NULL; n++)
917 g_dbus_interface_info_generate_xml (info->interfaces[n],
921 for (n = 0; info->nodes != NULL && info->nodes[n] != NULL; n++)
922 g_dbus_node_info_generate_xml (info->nodes[n],
926 g_string_append_printf (string_builder, "%*s</node>\n", indent, "");
930 /* ---------------------------------------------------------------------------------------------------- */
932 static GDBusAnnotationInfo **
933 parse_data_steal_annotations (ParseData *data,
934 guint *out_num_elements)
936 GDBusAnnotationInfo **ret;
937 if (out_num_elements != NULL)
938 *out_num_elements = data->annotations->len;
939 if (data->annotations == NULL)
943 g_ptr_array_add (data->annotations, NULL);
944 ret = (GDBusAnnotationInfo **) g_ptr_array_free (data->annotations, FALSE);
946 data->annotations = g_ptr_array_new ();
950 static GDBusArgInfo **
951 parse_data_steal_args (ParseData *data,
952 guint *out_num_elements)
955 if (out_num_elements != NULL)
956 *out_num_elements = data->args->len;
957 if (data->args == NULL)
961 g_ptr_array_add (data->args, NULL);
962 ret = (GDBusArgInfo **) g_ptr_array_free (data->args, FALSE);
964 data->args = g_ptr_array_new ();
968 static GDBusArgInfo **
969 parse_data_steal_out_args (ParseData *data,
970 guint *out_num_elements)
973 if (out_num_elements != NULL)
974 *out_num_elements = data->out_args->len;
975 if (data->out_args == NULL)
979 g_ptr_array_add (data->out_args, NULL);
980 ret = (GDBusArgInfo **) g_ptr_array_free (data->out_args, FALSE);
982 data->out_args = g_ptr_array_new ();
986 static GDBusMethodInfo **
987 parse_data_steal_methods (ParseData *data,
988 guint *out_num_elements)
990 GDBusMethodInfo **ret;
991 if (out_num_elements != NULL)
992 *out_num_elements = data->methods->len;
993 if (data->methods == NULL)
997 g_ptr_array_add (data->methods, NULL);
998 ret = (GDBusMethodInfo **) g_ptr_array_free (data->methods, FALSE);
1000 data->methods = g_ptr_array_new ();
1004 static GDBusSignalInfo **
1005 parse_data_steal_signals (ParseData *data,
1006 guint *out_num_elements)
1008 GDBusSignalInfo **ret;
1009 if (out_num_elements != NULL)
1010 *out_num_elements = data->signals->len;
1011 if (data->signals == NULL)
1015 g_ptr_array_add (data->signals, NULL);
1016 ret = (GDBusSignalInfo **) g_ptr_array_free (data->signals, FALSE);
1018 data->signals = g_ptr_array_new ();
1022 static GDBusPropertyInfo **
1023 parse_data_steal_properties (ParseData *data,
1024 guint *out_num_elements)
1026 GDBusPropertyInfo **ret;
1027 if (out_num_elements != NULL)
1028 *out_num_elements = data->properties->len;
1029 if (data->properties == NULL)
1033 g_ptr_array_add (data->properties, NULL);
1034 ret = (GDBusPropertyInfo **) g_ptr_array_free (data->properties, FALSE);
1036 data->properties = g_ptr_array_new ();
1040 static GDBusInterfaceInfo **
1041 parse_data_steal_interfaces (ParseData *data,
1042 guint *out_num_elements)
1044 GDBusInterfaceInfo **ret;
1045 if (out_num_elements != NULL)
1046 *out_num_elements = data->interfaces->len;
1047 if (data->interfaces == NULL)
1051 g_ptr_array_add (data->interfaces, NULL);
1052 ret = (GDBusInterfaceInfo **) g_ptr_array_free (data->interfaces, FALSE);
1054 data->interfaces = g_ptr_array_new ();
1058 static GDBusNodeInfo **
1059 parse_data_steal_nodes (ParseData *data,
1060 guint *out_num_elements)
1062 GDBusNodeInfo **ret;
1063 if (out_num_elements != NULL)
1064 *out_num_elements = data->nodes->len;
1065 if (data->nodes == NULL)
1069 g_ptr_array_add (data->nodes, NULL);
1070 ret = (GDBusNodeInfo **) g_ptr_array_free (data->nodes, FALSE);
1072 data->nodes = g_ptr_array_new ();
1076 /* ---------------------------------------------------------------------------------------------------- */
1079 parse_data_free_annotations (ParseData *data)
1081 if (data->annotations == NULL)
1083 g_ptr_array_foreach (data->annotations, (GFunc) g_dbus_annotation_info_unref, NULL);
1084 g_ptr_array_free (data->annotations, TRUE);
1085 data->annotations = NULL;
1089 parse_data_free_args (ParseData *data)
1091 if (data->args == NULL)
1093 g_ptr_array_foreach (data->args, (GFunc) g_dbus_arg_info_unref, NULL);
1094 g_ptr_array_free (data->args, TRUE);
1099 parse_data_free_out_args (ParseData *data)
1101 if (data->out_args == NULL)
1103 g_ptr_array_foreach (data->out_args, (GFunc) g_dbus_arg_info_unref, NULL);
1104 g_ptr_array_free (data->out_args, TRUE);
1105 data->out_args = NULL;
1109 parse_data_free_methods (ParseData *data)
1111 if (data->methods == NULL)
1113 g_ptr_array_foreach (data->methods, (GFunc) g_dbus_method_info_unref, NULL);
1114 g_ptr_array_free (data->methods, TRUE);
1115 data->methods = NULL;
1119 parse_data_free_signals (ParseData *data)
1121 if (data->signals == NULL)
1123 g_ptr_array_foreach (data->signals, (GFunc) g_dbus_signal_info_unref, NULL);
1124 g_ptr_array_free (data->signals, TRUE);
1125 data->signals = NULL;
1129 parse_data_free_properties (ParseData *data)
1131 if (data->properties == NULL)
1133 g_ptr_array_foreach (data->properties, (GFunc) g_dbus_property_info_unref, NULL);
1134 g_ptr_array_free (data->properties, TRUE);
1135 data->properties = NULL;
1139 parse_data_free_interfaces (ParseData *data)
1141 if (data->interfaces == NULL)
1143 g_ptr_array_foreach (data->interfaces, (GFunc) g_dbus_interface_info_unref, NULL);
1144 g_ptr_array_free (data->interfaces, TRUE);
1145 data->interfaces = NULL;
1149 parse_data_free_nodes (ParseData *data)
1151 if (data->nodes == NULL)
1153 g_ptr_array_foreach (data->nodes, (GFunc) g_dbus_node_info_unref, NULL);
1154 g_ptr_array_free (data->nodes, TRUE);
1158 /* ---------------------------------------------------------------------------------------------------- */
1160 static GDBusAnnotationInfo *
1161 parse_data_get_annotation (ParseData *data,
1162 gboolean create_new)
1165 g_ptr_array_add (data->annotations, g_new0 (GDBusAnnotationInfo, 1));
1166 return data->annotations->pdata[data->annotations->len - 1];
1169 static GDBusArgInfo *
1170 parse_data_get_arg (ParseData *data,
1171 gboolean create_new)
1174 g_ptr_array_add (data->args, g_new0 (GDBusArgInfo, 1));
1175 return data->args->pdata[data->args->len - 1];
1178 static GDBusArgInfo *
1179 parse_data_get_out_arg (ParseData *data,
1180 gboolean create_new)
1183 g_ptr_array_add (data->out_args, g_new0 (GDBusArgInfo, 1));
1184 return data->out_args->pdata[data->out_args->len - 1];
1187 static GDBusMethodInfo *
1188 parse_data_get_method (ParseData *data,
1189 gboolean create_new)
1192 g_ptr_array_add (data->methods, g_new0 (GDBusMethodInfo, 1));
1193 return data->methods->pdata[data->methods->len - 1];
1196 static GDBusSignalInfo *
1197 parse_data_get_signal (ParseData *data,
1198 gboolean create_new)
1201 g_ptr_array_add (data->signals, g_new0 (GDBusSignalInfo, 1));
1202 return data->signals->pdata[data->signals->len - 1];
1205 static GDBusPropertyInfo *
1206 parse_data_get_property (ParseData *data,
1207 gboolean create_new)
1210 g_ptr_array_add (data->properties, g_new0 (GDBusPropertyInfo, 1));
1211 return data->properties->pdata[data->properties->len - 1];
1214 static GDBusInterfaceInfo *
1215 parse_data_get_interface (ParseData *data,
1216 gboolean create_new)
1219 g_ptr_array_add (data->interfaces, g_new0 (GDBusInterfaceInfo, 1));
1220 return data->interfaces->pdata[data->interfaces->len - 1];
1223 static GDBusNodeInfo *
1224 parse_data_get_node (ParseData *data,
1225 gboolean create_new)
1228 g_ptr_array_add (data->nodes, g_new0 (GDBusNodeInfo, 1));
1229 return data->nodes->pdata[data->nodes->len - 1];
1232 /* ---------------------------------------------------------------------------------------------------- */
1235 parse_data_new (void)
1239 data = g_new0 (ParseData, 1);
1241 /* initialize arrays */
1242 parse_data_steal_annotations (data, NULL);
1243 parse_data_steal_args (data, NULL);
1244 parse_data_steal_out_args (data, NULL);
1245 parse_data_steal_methods (data, NULL);
1246 parse_data_steal_signals (data, NULL);
1247 parse_data_steal_properties (data, NULL);
1248 parse_data_steal_interfaces (data, NULL);
1249 parse_data_steal_nodes (data, NULL);
1255 parse_data_free (ParseData *data)
1259 /* free stack of annotation arrays */
1260 for (l = data->annotations_stack; l != NULL; l = l->next)
1262 GPtrArray *annotations = l->data;
1263 g_ptr_array_foreach (annotations, (GFunc) g_dbus_annotation_info_unref, NULL);
1264 g_ptr_array_free (annotations, TRUE);
1266 g_slist_free (data->annotations_stack);
1268 /* free stack of interface arrays */
1269 for (l = data->interfaces_stack; l != NULL; l = l->next)
1271 GPtrArray *interfaces = l->data;
1272 g_ptr_array_foreach (interfaces, (GFunc) g_dbus_interface_info_unref, NULL);
1273 g_ptr_array_free (interfaces, TRUE);
1275 g_slist_free (data->interfaces_stack);
1277 /* free stack of node arrays */
1278 for (l = data->nodes_stack; l != NULL; l = l->next)
1280 GPtrArray *nodes = l->data;
1281 g_ptr_array_foreach (nodes, (GFunc) g_dbus_node_info_unref, NULL);
1282 g_ptr_array_free (nodes, TRUE);
1284 g_slist_free (data->nodes_stack);
1286 /* free arrays (data->annotations, data->interfaces and data->nodes have been freed above) */
1287 parse_data_free_args (data);
1288 parse_data_free_out_args (data);
1289 parse_data_free_methods (data);
1290 parse_data_free_signals (data);
1291 parse_data_free_properties (data);
1296 /* ---------------------------------------------------------------------------------------------------- */
1299 parser_start_element (GMarkupParseContext *context,
1300 const gchar *element_name,
1301 const gchar **attribute_names,
1302 const gchar **attribute_values,
1306 ParseData *data = user_data;
1310 const gchar *access;
1311 const gchar *direction;
1320 stack = (GSList *) g_markup_parse_context_get_element_stack (context);
1322 /* ---------------------------------------------------------------------------------------------------- */
1323 if (strcmp (element_name, "node") == 0)
1325 if (!(g_slist_length (stack) >= 1 || strcmp (stack->next->data, "node") != 0))
1327 g_set_error_literal (error,
1329 G_MARKUP_ERROR_INVALID_CONTENT,
1330 "<node> elements can only be top-level or embedded in other <node> elements");
1334 if (!g_markup_collect_attributes (element_name,
1338 G_MARKUP_COLLECT_STRING | G_MARKUP_COLLECT_OPTIONAL, "name", &name,
1339 /* some hand-written introspection XML documents use this */
1340 G_MARKUP_COLLECT_STRING | G_MARKUP_COLLECT_OPTIONAL, "xmlns:doc", NULL,
1341 G_MARKUP_COLLECT_INVALID))
1344 g_dbus_node_info_set (data,
1345 parse_data_get_node (data, TRUE),
1351 /* push the currently retrieved interfaces and nodes on the stack and prepare new arrays */
1352 data->interfaces_stack = g_slist_prepend (data->interfaces_stack, data->interfaces);
1353 data->interfaces = NULL;
1354 parse_data_steal_interfaces (data, NULL);
1356 data->nodes_stack = g_slist_prepend (data->nodes_stack, data->nodes);
1358 parse_data_steal_nodes (data, NULL);
1361 /* ---------------------------------------------------------------------------------------------------- */
1362 else if (strcmp (element_name, "interface") == 0)
1364 if (g_slist_length (stack) < 2 || strcmp (stack->next->data, "node") != 0)
1366 g_set_error_literal (error,
1368 G_MARKUP_ERROR_INVALID_CONTENT,
1369 "<interface> elements can only be embedded in <node> elements");
1373 if (!g_markup_collect_attributes (element_name,
1377 G_MARKUP_COLLECT_STRING, "name", &name,
1378 G_MARKUP_COLLECT_INVALID))
1381 g_dbus_interface_info_set (data,
1382 parse_data_get_interface (data, TRUE),
1390 /* ---------------------------------------------------------------------------------------------------- */
1391 else if (strcmp (element_name, "method") == 0)
1393 if (g_slist_length (stack) < 2 || strcmp (stack->next->data, "interface") != 0)
1395 g_set_error_literal (error,
1397 G_MARKUP_ERROR_INVALID_CONTENT,
1398 "<method> elements can only be embedded in <interface> elements");
1402 if (!g_markup_collect_attributes (element_name,
1406 G_MARKUP_COLLECT_STRING, "name", &name,
1407 G_MARKUP_COLLECT_INVALID))
1410 g_dbus_method_info_set (data,
1411 parse_data_get_method (data, TRUE),
1420 /* ---------------------------------------------------------------------------------------------------- */
1421 else if (strcmp (element_name, "signal") == 0)
1423 if (g_slist_length (stack) < 2 || strcmp (stack->next->data, "interface") != 0)
1425 g_set_error_literal (error,
1427 G_MARKUP_ERROR_INVALID_CONTENT,
1428 "<signal> elements can only be embedded in <interface> elements");
1432 if (!g_markup_collect_attributes (element_name,
1436 G_MARKUP_COLLECT_STRING, "name", &name,
1437 G_MARKUP_COLLECT_INVALID))
1440 g_dbus_signal_info_set (data,
1441 parse_data_get_signal (data, TRUE),
1449 /* ---------------------------------------------------------------------------------------------------- */
1450 else if (strcmp (element_name, "property") == 0)
1452 GDBusPropertyInfoFlags flags;
1454 if (g_slist_length (stack) < 2 || strcmp (stack->next->data, "interface") != 0)
1456 g_set_error_literal (error,
1458 G_MARKUP_ERROR_INVALID_CONTENT,
1459 "<property> elements can only be embedded in <interface> elements");
1463 if (!g_markup_collect_attributes (element_name,
1467 G_MARKUP_COLLECT_STRING, "name", &name,
1468 G_MARKUP_COLLECT_STRING, "type", &type,
1469 G_MARKUP_COLLECT_STRING, "access", &access,
1470 G_MARKUP_COLLECT_INVALID))
1473 if (strcmp (access, "read") == 0)
1474 flags = G_DBUS_PROPERTY_INFO_FLAGS_READABLE;
1475 else if (strcmp (access, "write") == 0)
1476 flags = G_DBUS_PROPERTY_INFO_FLAGS_WRITABLE;
1477 else if (strcmp (access, "readwrite") == 0)
1478 flags = G_DBUS_PROPERTY_INFO_FLAGS_READABLE | G_DBUS_PROPERTY_INFO_FLAGS_WRITABLE;
1483 G_MARKUP_ERROR_INVALID_CONTENT,
1484 "Unknown value '%s' of access attribute for element <property>",
1489 g_dbus_property_info_set (data,
1490 parse_data_get_property (data, TRUE),
1497 /* ---------------------------------------------------------------------------------------------------- */
1498 else if (strcmp (element_name, "arg") == 0)
1503 if (g_slist_length (stack) < 2 ||
1504 (strcmp (stack->next->data, "method") != 0 &&
1505 strcmp (stack->next->data, "signal") != 0))
1507 g_set_error_literal (error,
1509 G_MARKUP_ERROR_INVALID_CONTENT,
1510 "<arg> elements can only be embedded in <method> or <signal> elements");
1514 if (!g_markup_collect_attributes (element_name,
1518 G_MARKUP_COLLECT_STRING | G_MARKUP_COLLECT_OPTIONAL, "name", &name,
1519 G_MARKUP_COLLECT_STRING | G_MARKUP_COLLECT_OPTIONAL, "direction", &direction,
1520 G_MARKUP_COLLECT_STRING, "type", &type,
1521 G_MARKUP_COLLECT_INVALID))
1525 if (direction != NULL)
1527 if (strcmp (direction, "in") == 0)
1529 else if (strcmp (direction, "out") == 0)
1535 G_MARKUP_ERROR_INVALID_CONTENT,
1536 "Unknown value '%s' of direction attribute",
1542 if (is_in && strcmp (stack->next->data, "signal") == 0)
1544 g_set_error_literal (error,
1546 G_MARKUP_ERROR_INVALID_CONTENT,
1547 "Only direction 'out' is allowed for <arg> elements embedded in <signal>");
1552 name_to_use = g_strdup_printf ("arg_%d", data->num_args);
1554 name_to_use = g_strdup (name);
1559 g_dbus_arg_info_set (data,
1560 parse_data_get_arg (data, TRUE),
1564 data->last_arg_was_in = TRUE;
1568 g_dbus_arg_info_set (data,
1569 parse_data_get_out_arg (data, TRUE),
1573 data->last_arg_was_in = FALSE;
1577 g_free (name_to_use);
1579 /* ---------------------------------------------------------------------------------------------------- */
1580 else if (strcmp (element_name, "annotation") == 0)
1582 if (g_slist_length (stack) < 2 ||
1583 (strcmp (stack->next->data, "node") != 0 &&
1584 strcmp (stack->next->data, "interface") != 0 &&
1585 strcmp (stack->next->data, "signal") != 0 &&
1586 strcmp (stack->next->data, "method") != 0 &&
1587 strcmp (stack->next->data, "property") != 0 &&
1588 strcmp (stack->next->data, "arg") != 0 &&
1589 strcmp (stack->next->data, "annotation") != 0))
1591 g_set_error_literal (error,
1593 G_MARKUP_ERROR_INVALID_CONTENT,
1594 "<annotation> elements can only be embedded in <node>, <interface>, <signal>, <method>, <property>, <arg> or <annotation> elements");
1598 if (!g_markup_collect_attributes (element_name,
1602 G_MARKUP_COLLECT_STRING, "name", &name,
1603 G_MARKUP_COLLECT_STRING, "value", &value,
1604 G_MARKUP_COLLECT_INVALID))
1607 g_dbus_annotation_info_set (data,
1608 parse_data_get_annotation (data, TRUE),
1613 /* ---------------------------------------------------------------------------------------------------- */
1616 /* don't bail on unknown elements; just ignore them */
1618 /* ---------------------------------------------------------------------------------------------------- */
1620 /* push the currently retrieved annotations on the stack and prepare a new one */
1621 data->annotations_stack = g_slist_prepend (data->annotations_stack, data->annotations);
1622 data->annotations = NULL;
1623 parse_data_steal_annotations (data, NULL);
1629 /* ---------------------------------------------------------------------------------------------------- */
1631 static GDBusAnnotationInfo **
1632 steal_annotations (ParseData *data)
1634 return parse_data_steal_annotations (data, NULL);
1639 parser_end_element (GMarkupParseContext *context,
1640 const gchar *element_name,
1644 ParseData *data = user_data;
1645 gboolean have_popped_annotations;
1647 have_popped_annotations = FALSE;
1649 if (strcmp (element_name, "node") == 0)
1652 guint num_interfaces;
1653 GDBusNodeInfo **nodes;
1654 GDBusInterfaceInfo **interfaces;
1656 nodes = parse_data_steal_nodes (data, &num_nodes);
1657 interfaces = parse_data_steal_interfaces (data, &num_interfaces);
1659 /* destroy the nodes, interfaces for scope we're exiting and and pop the nodes, interfaces from the
1660 * scope we're reentering
1662 parse_data_free_interfaces (data);
1663 data->interfaces = (GPtrArray *) data->interfaces_stack->data;
1664 data->interfaces_stack = g_slist_remove (data->interfaces_stack, data->interfaces_stack->data);
1666 parse_data_free_nodes (data);
1667 data->nodes = (GPtrArray *) data->nodes_stack->data;
1668 data->nodes_stack = g_slist_remove (data->nodes_stack, data->nodes_stack->data);
1670 g_dbus_node_info_set (data,
1671 parse_data_get_node (data, FALSE),
1677 steal_annotations (data));
1680 else if (strcmp (element_name, "interface") == 0)
1684 guint num_properties;
1685 GDBusMethodInfo **methods;
1686 GDBusSignalInfo **signals;
1687 GDBusPropertyInfo **properties;
1689 methods = parse_data_steal_methods (data, &num_methods);
1690 signals = parse_data_steal_signals (data, &num_signals);
1691 properties = parse_data_steal_properties (data, &num_properties);
1693 g_dbus_interface_info_set (data,
1694 parse_data_get_interface (data, FALSE),
1702 steal_annotations (data));
1705 else if (strcmp (element_name, "method") == 0)
1709 GDBusArgInfo **in_args;
1710 GDBusArgInfo **out_args;
1712 in_args = parse_data_steal_args (data, &in_num_args);
1713 out_args = parse_data_steal_out_args (data, &out_num_args);
1715 g_dbus_method_info_set (data,
1716 parse_data_get_method (data, FALSE),
1722 steal_annotations (data));
1724 else if (strcmp (element_name, "signal") == 0)
1727 GDBusArgInfo **args;
1729 args = parse_data_steal_out_args (data, &num_args);
1731 g_dbus_signal_info_set (data,
1732 parse_data_get_signal (data, FALSE),
1736 steal_annotations (data));
1738 else if (strcmp (element_name, "property") == 0)
1740 g_dbus_property_info_set (data,
1741 parse_data_get_property (data, FALSE),
1744 G_DBUS_PROPERTY_INFO_FLAGS_NONE,
1745 steal_annotations (data));
1747 else if (strcmp (element_name, "arg") == 0)
1749 g_dbus_arg_info_set (data,
1750 data->last_arg_was_in ? parse_data_get_arg (data, FALSE) : parse_data_get_out_arg (data, FALSE),
1753 steal_annotations (data));
1755 else if (strcmp (element_name, "annotation") == 0)
1757 GDBusAnnotationInfo **embedded_annotations;
1759 embedded_annotations = steal_annotations (data);
1761 /* destroy the annotations for scope we're exiting and and pop the annotations from the scope we're reentering */
1762 parse_data_free_annotations (data);
1763 data->annotations = (GPtrArray *) data->annotations_stack->data;
1764 data->annotations_stack = g_slist_remove (data->annotations_stack, data->annotations_stack->data);
1766 have_popped_annotations = TRUE;
1768 g_dbus_annotation_info_set (data,
1769 parse_data_get_annotation (data, FALSE),
1772 embedded_annotations);
1776 /* don't bail on unknown elements; just ignore them */
1779 if (!have_popped_annotations)
1781 /* destroy the annotations for scope we're exiting and and pop the annotations from the scope we're reentering */
1782 parse_data_free_annotations (data);
1783 data->annotations = (GPtrArray *) data->annotations_stack->data;
1784 data->annotations_stack = g_slist_remove (data->annotations_stack, data->annotations_stack->data);
1788 /* ---------------------------------------------------------------------------------------------------- */
1791 parser_error (GMarkupParseContext *context,
1798 g_markup_parse_context_get_position (context, &line_number, &char_number);
1800 g_prefix_error (&error, "%d:%d: ",
1805 /* ---------------------------------------------------------------------------------------------------- */
1808 * g_dbus_node_info_new_for_xml:
1809 * @xml_data: Valid D-Bus introspection XML.
1810 * @error: Return location for error.
1812 * Parses @xml_data and returns a #GDBusNodeInfo representing the data.
1814 * Returns: A #GDBusNodeInfo structure or %NULL if @error is set. Free
1815 * with g_dbus_node_info_unref().
1820 g_dbus_node_info_new_for_xml (const gchar *xml_data,
1824 GMarkupParseContext *context;
1825 GMarkupParser *parser;
1828 GDBusNodeInfo **ughret;
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 ughret = parse_data_steal_nodes (data, &num_nodes);
1859 G_MARKUP_ERROR_INVALID_CONTENT,
1860 "Expected a single node in introspection XML, found %d",
1864 for (n = 0; n < num_nodes; n++)
1866 for (n = 0; n < num_nodes; n++)
1867 g_dbus_node_info_unref (&(ret[n]));
1879 if (context != NULL)
1880 g_markup_parse_context_free (context);
1885 /* ---------------------------------------------------------------------------------------------------- */
1888 * g_dbus_annotation_info_lookup:
1889 * @annotations: A %NULL-terminated array of annotations or %NULL.
1890 * @name: The name of the annotation to look up.
1892 * Looks up the value of an annotation.
1894 * This cost of this function is O(n) in number of annotations.
1896 * Returns: The value or %NULL if not found. Do not free, it is owned by @annotations.
1901 g_dbus_annotation_info_lookup (const GDBusAnnotationInfo **annotations,
1908 for (n = 0; annotations != NULL && annotations[n] != NULL; n++)
1910 if (g_strcmp0 (annotations[n]->key, name) == 0)
1912 ret = annotations[n]->value;
1921 /* ---------------------------------------------------------------------------------------------------- */
1924 * g_dbus_interface_info_lookup_method:
1925 * @info: A #GDBusInterfaceInfo.
1926 * @name: A D-Bus method name (typically in CamelCase)
1928 * Looks up information about a method.
1930 * This cost of this function is O(n) in number of methods.
1932 * Returns: A #GDBusMethodInfo or %NULL if not found. Do not free, it is owned by @info.
1936 const GDBusMethodInfo *
1937 g_dbus_interface_info_lookup_method (const GDBusInterfaceInfo *info,
1941 const GDBusMethodInfo *result;
1943 for (n = 0; info->methods != NULL && info->methods[n] != NULL; n++)
1945 const GDBusMethodInfo *i = info->methods[n];
1947 if (g_strcmp0 (i->name, name) == 0)
1960 /* ---------------------------------------------------------------------------------------------------- */
1963 * g_dbus_interface_info_lookup_signal:
1964 * @info: A #GDBusInterfaceInfo.
1965 * @name: A D-Bus signal name (typically in CamelCase)
1967 * Looks up information about a signal.
1969 * This cost of this function is O(n) in number of signals.
1971 * Returns: A #GDBusSignalInfo or %NULL if not found. Do not free, it is owned by @info.
1975 const GDBusSignalInfo *
1976 g_dbus_interface_info_lookup_signal (const GDBusInterfaceInfo *info,
1980 const GDBusSignalInfo *result;
1982 for (n = 0; info->signals != NULL && info->signals[n] != NULL; n++)
1984 const GDBusSignalInfo *i = info->signals[n];
1986 if (g_strcmp0 (i->name, name) == 0)
1999 /* ---------------------------------------------------------------------------------------------------- */
2002 * g_dbus_interface_info_lookup_property:
2003 * @info: A #GDBusInterfaceInfo.
2004 * @name: A D-Bus property name (typically in CamelCase).
2006 * Looks up information about a property.
2008 * This cost of this function is O(n) in number of properties.
2010 * Returns: A #GDBusPropertyInfo or %NULL if not found. Do not free, it is owned by @info.
2014 const GDBusPropertyInfo *
2015 g_dbus_interface_info_lookup_property (const GDBusInterfaceInfo *info,
2019 const GDBusPropertyInfo *result;
2021 for (n = 0; info->properties != NULL && info->properties[n] != NULL; n++)
2023 const GDBusPropertyInfo *i = info->properties[n];
2025 if (g_strcmp0 (i->name, name) == 0)
2038 /* ---------------------------------------------------------------------------------------------------- */
2041 * g_dbus_node_info_lookup_interface:
2042 * @info: A #GDBusNodeInfo.
2043 * @name: A D-Bus interface name.
2045 * Looks up information about an interface.
2047 * This cost of this function is O(n) in number of interfaces.
2049 * Returns: A #GDBusInterfaceInfo or %NULL if not found. Do not free, it is owned by @info.
2053 const GDBusInterfaceInfo *
2054 g_dbus_node_info_lookup_interface (const GDBusNodeInfo *info,
2058 const GDBusInterfaceInfo *result;
2060 for (n = 0; info->interfaces != NULL && info->interfaces[n] != NULL; n++)
2062 const GDBusInterfaceInfo *i = info->interfaces[n];
2064 if (g_strcmp0 (i->name, name) == 0)