X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=gio%2Fgapplicationimpl-dbus.c;h=15e66f2990b3e35ed9cb60db661ccc2fa1c41ae4;hb=cea9de93c8838099661f5b54462f9c4b6410bfc9;hp=5c948ccf703823a2e8d322100609c152a04b82e2;hpb=c5748328bee08e322997cc4703c372f6866a1693;p=platform%2Fupstream%2Fglib.git diff --git a/gio/gapplicationimpl-dbus.c b/gio/gapplicationimpl-dbus.c index 5c948cc..15e66f2 100644 --- a/gio/gapplicationimpl-dbus.c +++ b/gio/gapplicationimpl-dbus.c @@ -12,9 +12,7 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General - * Public License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place, Suite 330, - * Boston, MA 02111-1307, USA. + * Public License along with this library; if not, see . * * Authors: Ryan Lortie */ @@ -48,7 +46,7 @@ /* DBus Interface definition {{{1 */ /* For documentation of these interfaces, see - * https://live.gnome.org/GApplication/DBusAPI + * https://wiki.gnome.org/Projects/GLib/GApplication/DBusAPI */ static const gchar org_gtk_Application_xml[] = "" @@ -129,9 +127,6 @@ struct _GApplicationImpl static GApplicationCommandLine * g_dbus_command_line_new (GDBusMethodInvocation *invocation); -static void -g_dbus_command_line_return (GApplicationCommandLine *cmdline); - static GVariant * g_application_impl_get_property (GDBusConnection *connection, const gchar *sender, @@ -206,12 +201,20 @@ g_application_impl_method_call (GDBusConnection *connection, else if (strcmp (method_name, "Open") == 0) { + GApplicationFlags flags; GVariant *platform_data; const gchar *hint; GVariant *array; GFile **files; gint n, i; + flags = g_application_get_flags (impl->app); + if ((flags & G_APPLICATION_HANDLES_OPEN) == 0) + { + g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_NOT_SUPPORTED, "Application does not open files"); + return; + } + /* freedesktop interface has no hint parameter */ if (g_str_equal (interface_name, "org.freedesktop.Application")) { @@ -249,10 +252,19 @@ g_application_impl_method_call (GDBusConnection *connection, else if (strcmp (method_name, "CommandLine") == 0) { + GApplicationFlags flags; GApplicationCommandLine *cmdline; GVariant *platform_data; int status; + flags = g_application_get_flags (impl->app); + if ((flags & G_APPLICATION_HANDLES_COMMAND_LINE) == 0) + { + g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_NOT_SUPPORTED, + "Application does not handle command line arguments"); + return; + } + /* Only on the GtkApplication interface */ cmdline = g_dbus_command_line_new (invocation); @@ -262,8 +274,6 @@ g_application_impl_method_call (GDBusConnection *connection, g_application_command_line_set_exit_status (cmdline, status); class->after_emit (impl->app, platform_data); g_variant_unref (platform_data); - - g_dbus_command_line_return (cmdline); g_object_unref (cmdline); } else if (g_str_equal (method_name, "ActivateAction")) @@ -690,9 +700,9 @@ g_application_impl_cmdline_done (GObject *source, } int -g_application_impl_command_line (GApplicationImpl *impl, - gchar **arguments, - GVariant *platform_data) +g_application_impl_command_line (GApplicationImpl *impl, + const gchar * const *arguments, + GVariant *platform_data) { const static GDBusInterfaceVTable vtable = { g_application_impl_cmdline_method_call @@ -792,8 +802,6 @@ typedef struct GDBusConnection *connection; const gchar *bus_name; const gchar *object_path; - - gboolean returned; } GDBusCommandLine; @@ -859,29 +867,16 @@ g_dbus_command_line_get_stdin (GApplicationCommandLine *cmdline) } static void -g_dbus_command_line_return (GApplicationCommandLine *cmdline) +g_dbus_command_line_finalize (GObject *object) { - GDBusCommandLine *gdbcl = (GDBusCommandLine *) cmdline; + GApplicationCommandLine *cmdline = G_APPLICATION_COMMAND_LINE (object); + GDBusCommandLine *gdbcl = (GDBusCommandLine *) object; gint status; - if (gdbcl->returned) - return; - - gdbcl->returned = TRUE; - status = g_application_command_line_get_exit_status (cmdline); g_dbus_method_invocation_return_value (gdbcl->invocation, g_variant_new ("(i)", status)); -} - -static void -g_dbus_command_line_finalize (GObject *object) -{ - GApplicationCommandLine *cmdline = G_APPLICATION_COMMAND_LINE (object); - GDBusCommandLine *gdbcl = (GDBusCommandLine *) object; - - g_dbus_command_line_return (cmdline); g_object_unref (gdbcl->invocation); G_OBJECT_CLASS (g_dbus_command_line_parent_class) @@ -909,13 +904,19 @@ g_dbus_command_line_new (GDBusMethodInvocation *invocation) { GDBusCommandLine *gdbcl; GVariant *args; + GVariant *arguments, *platform_data; args = g_dbus_method_invocation_get_parameters (invocation); + arguments = g_variant_get_child_value (args, 1); + platform_data = g_variant_get_child_value (args, 2); gdbcl = g_object_new (g_dbus_command_line_get_type (), - "arguments", g_variant_get_child_value (args, 1), - "platform-data", g_variant_get_child_value (args, 2), + "arguments", arguments, + "platform-data", platform_data, NULL); + g_variant_unref (arguments); + g_variant_unref (platform_data); + gdbcl->connection = g_dbus_method_invocation_get_connection (invocation); gdbcl->bus_name = g_dbus_method_invocation_get_sender (invocation); g_variant_get_child (args, 0, "&o", &gdbcl->object_path);