Add --xml to gdbus-tool to print raw introspected XML

Bug #621442.
This commit is contained in:
Christian Persch 2010-06-13 15:16:33 +02:00
parent fdb15058a4
commit 8c4e1fa0af
2 changed files with 17 additions and 7 deletions

View File

@ -22,6 +22,7 @@
</group> </group>
<arg choice="plain">--dest <replaceable>bus_name</replaceable></arg> <arg choice="plain">--dest <replaceable>bus_name</replaceable></arg>
<arg choice="plain">--object-path <replaceable>/path/to/object</replaceable></arg> <arg choice="plain">--object-path <replaceable>/path/to/object</replaceable></arg>
<arg choice="plain">--xml</arg>
</cmdsynopsis> </cmdsynopsis>
<cmdsynopsis> <cmdsynopsis>
<command>gdbus</command> <command>gdbus</command>

View File

@ -1155,11 +1155,13 @@ dump_node (GDBusConnection *c,
static gchar *opt_introspect_dest = NULL; static gchar *opt_introspect_dest = NULL;
static gchar *opt_introspect_object_path = NULL; static gchar *opt_introspect_object_path = NULL;
static gboolean opt_introspect_xml = FALSE;
static const GOptionEntry introspect_entries[] = static const GOptionEntry introspect_entries[] =
{ {
{ "dest", 'd', 0, G_OPTION_ARG_STRING, &opt_introspect_dest, N_("Destination name to introspect"), NULL}, { "dest", 'd', 0, G_OPTION_ARG_STRING, &opt_introspect_dest, N_("Destination name to introspect"), NULL},
{ "object-path", 'o', 0, G_OPTION_ARG_STRING, &opt_introspect_object_path, N_("Object path to introspect"), NULL}, { "object-path", 'o', 0, G_OPTION_ARG_STRING, &opt_introspect_object_path, N_("Object path to introspect"), NULL},
{ "xml", 'x', 0, G_OPTION_ARG_NONE, &opt_introspect_xml, N_("Print XML"), NULL},
{ NULL } { NULL }
}; };
@ -1325,6 +1327,12 @@ handle_introspect (gint *argc,
} }
g_variant_get (result, "(&s)", &xml_data); g_variant_get (result, "(&s)", &xml_data);
if (opt_introspect_xml)
{
g_print ("%s", xml_data);
}
else
{
error = NULL; error = NULL;
node = g_dbus_node_info_new_for_xml (xml_data, &error); node = g_dbus_node_info_new_for_xml (xml_data, &error);
if (node == NULL) if (node == NULL)
@ -1335,6 +1343,7 @@ handle_introspect (gint *argc,
} }
dump_node (c, opt_introspect_dest, node, 0, opt_introspect_object_path); dump_node (c, opt_introspect_dest, node, 0, opt_introspect_object_path);
}
ret = TRUE; ret = TRUE;