From 8d1cc7f4635c1ab5cb9a7963b3dfebba56d87629 Mon Sep 17 00:00:00 2001 From: Ryan Lortie Date: Fri, 2 Dec 2011 16:22:13 -0500 Subject: [PATCH 1/1] Revert "Use an XML blob for gapplication interface info" This reverts commit 8013401f6e4edb01dd31b716c179806b55d4064b. --- gio/gapplicationimpl-dbus.c | 165 ++++++++++++++++++++++++++++---------------- 1 file changed, 107 insertions(+), 58 deletions(-) diff --git a/gio/gapplicationimpl-dbus.c b/gio/gapplicationimpl-dbus.c index 553cd4a..08db713 100644 --- a/gio/gapplicationimpl-dbus.c +++ b/gio/gapplicationimpl-dbus.c @@ -35,65 +35,112 @@ #include "gdbusmethodinvocation.h" /* DBus Interface definition {{{1 */ +static const GDBusArgInfo platform_data_arg = { -1, (gchar *) "platform_data", (gchar *) "a{sv}" }; -static GDBusInterfaceInfo * -get_interface (const gchar *name) -{ - static GDBusInterfaceInfo *org_gtk_Application; - static GDBusInterfaceInfo *org_gtk_private_CommandLine; +static const GDBusArgInfo open_uris_arg = { -1, (gchar *) "uris", (gchar *) "as" }; +static const GDBusArgInfo open_hint_arg = { -1, (gchar *) "hint", (gchar *) "s" }; - if (org_gtk_Application == NULL) - { - GError *error = NULL; - GDBusNodeInfo *info; - - info = g_dbus_node_info_new_for_xml ( - "" - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - "", &error); - - if (info == NULL) - g_error ("%s\n", error->message); - - org_gtk_Application = g_dbus_node_info_lookup_interface (info, "org.gtk.Application"); - g_assert (org_gtk_Application != NULL); - g_dbus_interface_info_ref (org_gtk_Application); - - org_gtk_private_CommandLine = g_dbus_node_info_lookup_interface (info, "org.gtk.private.CommandLine"); - g_assert (org_gtk_private_CommandLine != NULL); - g_dbus_interface_info_ref (org_gtk_private_CommandLine); - - g_dbus_node_info_unref (info); - } +static const GDBusArgInfo invoke_action_name_arg = { -1, (gchar *) "name", (gchar *) "s" }; +static const GDBusArgInfo invoke_action_args_arg = { -1, (gchar *) "args", (gchar *) "v" }; - if (strcmp (name, "org.gtk.Application") == 0) - return org_gtk_Application; - else - return org_gtk_private_CommandLine; -} +static const GDBusArgInfo cmdline_path_arg = { -1, (gchar *) "path", (gchar *) "o" }; +static const GDBusArgInfo cmdline_arguments_arg = { -1, (gchar *) "arguments", (gchar *) "aay" }; +static const GDBusArgInfo cmdline_exit_status_arg = { -1, (gchar *) "exit_status", (gchar *) "i" }; + +static const GDBusArgInfo *activate_in[] = { &platform_data_arg, NULL }; +static const GDBusArgInfo *activate_out[] = { NULL }; + +static const GDBusArgInfo *open_in[] = { &open_uris_arg, &open_hint_arg, &platform_data_arg, NULL }; +static const GDBusArgInfo *open_out[] = { NULL }; + +static const GDBusArgInfo *cmdline_in[] = { &cmdline_path_arg, &cmdline_arguments_arg, &platform_data_arg, NULL }; +static const GDBusArgInfo *cmdline_out[] = { &cmdline_exit_status_arg, NULL }; + +static const GDBusMethodInfo activate_method = { + -1, (gchar *) "Activate", + (GDBusArgInfo **) activate_in, + (GDBusArgInfo **) activate_out +}; + +static const GDBusMethodInfo open_method = { + -1, (gchar *) "Open", + (GDBusArgInfo **) open_in, + (GDBusArgInfo **) open_out +}; + +static const GDBusMethodInfo command_line_method = { + -1, (gchar *) "CommandLine", + (GDBusArgInfo **) cmdline_in, + (GDBusArgInfo **) cmdline_out +}; + +static const GDBusMethodInfo *application_methods[] = { + &activate_method, &open_method, &command_line_method, NULL +}; + +const GDBusInterfaceInfo org_gtk_Application = { + -1, (gchar *) "org.gtk.Application", + (GDBusMethodInfo **) application_methods +}; + +static const GDBusArgInfo list_arg = { -1, (gchar *) "list", (gchar *) "a(savbav)" }; +static const GDBusArgInfo *describe_all_out[] = { &list_arg, NULL }; + +static const GDBusArgInfo action_name_arg = { -1, (gchar *) "action_name", (gchar *) "s" }; +static const GDBusArgInfo value_arg = { -1, (gchar *) "value", (gchar *) "v" }; +static const GDBusArgInfo *set_action_state_in[] = { &action_name_arg, &value_arg, &platform_data_arg, NULL }; + +static const GDBusArgInfo parameter_arg = { -1, (gchar *) "parameter", (gchar *) "av" }; +static const GDBusArgInfo *activate_action_in[] = { &action_name_arg, ¶meter_arg, &platform_data_arg, NULL }; + +static const GDBusMethodInfo describe_all_method = { + -1, (gchar *) "DescribeAll", NULL, + (GDBusArgInfo **) describe_all_out +}; + +static const GDBusMethodInfo set_action_state_method = { + -1, (gchar *) "SetState", + (GDBusArgInfo **) set_action_state_in +}; + +static const GDBusMethodInfo activate_action_method = { + -1, (gchar *) "Activate", + (GDBusArgInfo **) activate_action_in +}; + +static const GDBusMethodInfo *actions_methods[] = { + &describe_all_method, &set_action_state_method, &activate_action_method, NULL +}; + +const GDBusInterfaceInfo org_gtk_Actions = { + -1, (gchar *) "org.gtk.Actions", + (GDBusMethodInfo **) actions_methods +}; + +static const GDBusArgInfo message_arg = { -1, (gchar *) "message", (gchar *) "s" }; +static const GDBusArgInfo *print_in[] = { &message_arg, NULL }; +static const GDBusArgInfo *print_out[] = { NULL }; + +static const GDBusMethodInfo stdout_method = { + -1, (gchar *) "Print", + (GDBusArgInfo **) print_in, + (GDBusArgInfo **) print_out +}; + +static const GDBusMethodInfo stderr_method = { + -1, (gchar *) "PrintError", + (GDBusArgInfo **) print_in, + (GDBusArgInfo **) print_out +}; + +static const GDBusMethodInfo *cmdline_methods[] = { + &stdout_method, &stderr_method, NULL +}; + +const GDBusInterfaceInfo org_gtk_private_Cmdline = { + -1, (gchar *) "org.gtk.private.CommandLine", + (GDBusMethodInfo **) cmdline_methods +}; /* GApplication implementation {{{1 */ struct _GApplicationImpl @@ -567,7 +614,8 @@ g_application_impl_register (GApplication *application, impl->object_id = g_dbus_connection_register_object (impl->session_bus, impl->object_path, - get_interface ("org.gtk.Application"), + (GDBusInterfaceInfo *) + &org_gtk_Application, &vtable, impl, NULL, error); if (impl->object_id == 0) @@ -844,7 +892,8 @@ g_application_impl_command_line (GApplicationImpl *impl, object_id = g_dbus_connection_register_object (impl->session_bus, object_path, - get_interface ("org.gtk.private.CommandLine"), + (GDBusInterfaceInfo *) + &org_gtk_private_Cmdline, &vtable, &data, NULL, NULL); /* In theory we should try other paths... */ g_assert (object_id != 0); -- 2.7.4