2 * Copyright © 2010 Codethink Limited
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General
15 * Public License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
17 * Boston, MA 02111-1307, USA.
19 * Authors: Ryan Lortie <desrt@desrt.ca>
22 #include "gapplicationimpl.h"
24 #include "gactiongroup.h"
25 #include "gapplication.h"
27 #include "gdbusconnection.h"
28 #include "gdbusintrospection.h"
29 #include "gdbuserror.h"
34 #include "gapplicationcommandline.h"
35 #include "gdbusmethodinvocation.h"
37 /* DBus Interface definition {{{1 */
39 static GDBusInterfaceInfo *
40 get_interface (const gchar *name)
42 static GDBusInterfaceInfo *org_gtk_Application;
43 static GDBusInterfaceInfo *org_gtk_private_CommandLine;
45 if (org_gtk_Application == NULL)
50 info = g_dbus_node_info_new_for_xml (
52 " <interface name='org.gtk.Application'>"
53 " <method name='Activate'>"
54 " <arg type='a{sv}' name='platform_data' direction='in'/>"
56 " <method name='Open'>"
57 " <arg type='as' name='uris' direction='in'/>"
58 " <arg type='s' name='hint' direction='in'/>"
59 " <arg type='a{sv}' name='platform_data' direction='in'/>"
61 " <method name='CommandLine'>"
62 " <arg type='o' name='path' direction='in'/>"
63 " <arg type='aay' name='arguments' direction='in'/>"
64 " <arg type='a{sv}' name='platform_data' direction='in'/>"
65 " <arg type='i' name='exit_status' direction='out'/>"
68 " <interface name='org.gtk.private.CommandLine'>"
69 " <method name='Print'>"
70 " <arg type='s' name='message' direction='in'/>"
72 " <method name='PrintError'>"
73 " <arg type='s' name='message' direction='in'/>"
79 g_error ("%s\n", error->message);
81 org_gtk_Application = g_dbus_node_info_lookup_interface (info, "org.gtk.Application");
82 g_assert (org_gtk_Application != NULL);
83 g_dbus_interface_info_ref (org_gtk_Application);
85 org_gtk_private_CommandLine = g_dbus_node_info_lookup_interface (info, "org.gtk.private.CommandLine");
86 g_assert (org_gtk_private_CommandLine != NULL);
87 g_dbus_interface_info_ref (org_gtk_private_CommandLine);
89 g_dbus_node_info_unref (info);
92 if (strcmp (name, "org.gtk.Application") == 0)
93 return org_gtk_Application;
95 return org_gtk_private_CommandLine;
98 /* GApplication implementation {{{1 */
99 struct _GApplicationImpl
101 GDBusConnection *session_bus;
102 const gchar *bus_name;
113 static GApplicationCommandLine *
114 g_dbus_command_line_new (GDBusMethodInvocation *invocation);
118 g_application_impl_method_call (GDBusConnection *connection,
120 const gchar *object_path,
121 const gchar *interface_name,
122 const gchar *method_name,
123 GVariant *parameters,
124 GDBusMethodInvocation *invocation,
127 GApplicationImpl *impl = user_data;
128 GApplicationClass *class;
130 class = G_APPLICATION_GET_CLASS (impl->app);
132 if (strcmp (method_name, "Activate") == 0)
134 GVariant *platform_data;
136 g_variant_get (parameters, "(@a{sv})", &platform_data);
137 class->before_emit (impl->app, platform_data);
138 g_signal_emit_by_name (impl->app, "activate");
139 class->after_emit (impl->app, platform_data);
140 g_variant_unref (platform_data);
142 g_dbus_method_invocation_return_value (invocation, NULL);
145 else if (strcmp (method_name, "Open") == 0)
147 GVariant *platform_data;
153 g_variant_get (parameters, "(@ass@a{sv})",
154 &array, &hint, &platform_data);
156 n = g_variant_n_children (array);
157 files = g_new (GFile *, n + 1);
159 for (i = 0; i < n; i++)
163 g_variant_get_child (array, i, "&s", &uri);
164 files[i] = g_file_new_for_uri (uri);
166 g_variant_unref (array);
169 class->before_emit (impl->app, platform_data);
170 g_signal_emit_by_name (impl->app, "open", files, n, hint);
171 class->after_emit (impl->app, platform_data);
173 g_variant_unref (platform_data);
175 for (i = 0; i < n; i++)
176 g_object_unref (files[i]);
179 g_dbus_method_invocation_return_value (invocation, NULL);
182 else if (strcmp (method_name, "CommandLine") == 0)
184 GApplicationCommandLine *cmdline;
185 GVariant *platform_data;
188 cmdline = g_dbus_command_line_new (invocation);
189 platform_data = g_variant_get_child_value (parameters, 2);
190 class->before_emit (impl->app, platform_data);
191 g_signal_emit_by_name (impl->app, "command-line", cmdline, &status);
192 g_application_command_line_set_exit_status (cmdline, status);
193 class->after_emit (impl->app, platform_data);
194 g_variant_unref (platform_data);
195 g_object_unref (cmdline);
198 g_assert_not_reached ();
202 g_application_impl_actions_method_call (GDBusConnection *connection,
204 const gchar *object_path,
205 const gchar *interface_name,
206 const gchar *method_name,
207 GVariant *parameters,
208 GDBusMethodInvocation *invocation,
211 GApplicationImpl *impl = user_data;
212 GActionGroup *action_group;
213 GApplicationClass *class;
215 class = G_APPLICATION_GET_CLASS (impl->app);
216 action_group = G_ACTION_GROUP (impl->app);
218 if (strcmp (method_name, "DescribeAll") == 0)
220 GVariantBuilder builder;
224 actions = g_action_group_list_actions (action_group);
225 g_variant_builder_init (&builder, G_VARIANT_TYPE ("(a(savbav))"));
226 g_variant_builder_open (&builder, G_VARIANT_TYPE ("a(savbav)"));
228 for (i = 0; actions[i]; i++)
231 g_variant_builder_open (&builder, G_VARIANT_TYPE ("(savbav)"));
234 g_variant_builder_add (&builder, "s", actions[i]);
237 g_variant_builder_open (&builder, G_VARIANT_TYPE ("av"));
239 const GVariantType *type;
241 type = g_action_group_get_action_parameter_type (action_group,
245 GVariantType *array_type;
247 array_type = g_variant_type_new_array (type);
248 g_variant_builder_open (&builder, G_VARIANT_TYPE_VARIANT);
249 g_variant_builder_open (&builder, array_type);
250 g_variant_builder_close (&builder);
251 g_variant_builder_close (&builder);
252 g_variant_type_free (array_type);
255 g_variant_builder_close (&builder);
259 gboolean enabled = g_action_group_get_action_enabled (action_group,
261 g_variant_builder_add (&builder, "b", enabled);
265 g_variant_builder_open (&builder, G_VARIANT_TYPE ("av"));
267 GVariant *state = g_action_group_get_action_state (action_group,
271 g_variant_builder_add (&builder, "v", state);
272 g_variant_unref (state);
275 g_variant_builder_close (&builder);
278 g_variant_builder_close (&builder);
280 g_variant_builder_close (&builder);
282 g_dbus_method_invocation_return_value (invocation,
283 g_variant_builder_end (&builder));
285 g_strfreev (actions);
288 else if (strcmp (method_name, "SetState") == 0)
290 const gchar *action_name;
291 GVariant *platform_data;
294 g_variant_get (parameters, "(&sv@a{sv})",
295 &action_name, &state, &platform_data);
297 class->before_emit (impl->app, platform_data);
298 g_action_group_change_action_state (action_group, action_name, state);
299 class->after_emit (impl->app, platform_data);
300 g_variant_unref (platform_data);
301 g_variant_unref (state);
303 g_dbus_method_invocation_return_value (invocation, NULL);
306 else if (strcmp (method_name, "Activate") == 0)
308 const gchar *action_name;
309 GVariant *platform_data;
312 GVariant *unboxed_parameter;
314 g_variant_get (parameters, "(&sav@a{sv})",
315 &action_name, ¶m, &platform_data);
316 parameter = g_variant_iter_next_value (param);
317 unboxed_parameter = parameter ? g_variant_get_variant (parameter) : NULL;
318 g_variant_iter_free (param);
320 class->before_emit (impl->app, platform_data);
321 g_action_group_activate_action (action_group, action_name, unboxed_parameter);
322 class->after_emit (impl->app, platform_data);
323 g_variant_unref (platform_data);
325 if (unboxed_parameter)
326 g_variant_unref (unboxed_parameter);
328 g_variant_unref (parameter);
330 g_dbus_method_invocation_return_value (invocation, NULL);
334 g_assert_not_reached ();
338 application_path_from_appid (const gchar *appid)
340 gchar *appid_path, *iter;
342 appid_path = g_strconcat ("/", appid, NULL);
343 for (iter = appid_path; *iter; iter++)
356 g_application_impl_destroy (GApplicationImpl *impl)
358 if (impl->session_bus)
361 g_dbus_connection_unregister_object (impl->session_bus,
364 g_dbus_connection_unregister_object (impl->session_bus,
367 g_dbus_connection_call (impl->session_bus,
368 "org.freedesktop.DBus",
369 "/org/freedesktop/DBus",
370 "org.freedesktop.DBus",
372 g_variant_new ("(s)",
375 G_DBUS_CALL_FLAGS_NONE,
376 -1, NULL, NULL, NULL);
378 g_object_unref (impl->session_bus);
379 g_free (impl->object_path);
383 g_assert (impl->object_path == NULL);
384 g_assert (impl->object_id == 0);
387 g_slice_free (GApplicationImpl, impl);
391 unwrap_fake_maybe (GVariant **value)
395 if (g_variant_n_children (*value))
396 g_variant_get_child (*value, 0, "v", &tmp);
400 g_variant_unref (*value);
404 static RemoteActionInfo *
405 remote_action_info_new_from_iter (GVariantIter *iter)
407 RemoteActionInfo *info;
408 GVariant *param_type;
413 if (!g_variant_iter_next (iter, "(s@avb@av)", &name,
414 ¶m_type, &enabled, &state))
417 unwrap_fake_maybe (¶m_type);
418 unwrap_fake_maybe (&state);
420 info = g_slice_new (RemoteActionInfo);
422 info->enabled = enabled;
425 if (param_type != NULL)
427 info->parameter_type = g_variant_type_copy (
428 g_variant_type_element (
429 g_variant_get_type (param_type)));
430 g_variant_unref (param_type);
433 info->parameter_type = NULL;
439 g_application_impl_action_signal (GDBusConnection *connection,
440 const gchar *sender_name,
441 const gchar *object_path,
442 const gchar *interface_name,
443 const gchar *signal_name,
444 GVariant *parameters,
447 GApplicationImpl *impl = user_data;
448 GActionGroup *action_group;
450 action_group = G_ACTION_GROUP (impl->app);
452 if (strcmp (signal_name, "Added") == 0 &&
453 g_variant_is_of_type (parameters, G_VARIANT_TYPE ("(a(savbav))")))
455 RemoteActionInfo *info;
458 g_variant_get_child (parameters, 0, "a(savbav)", &iter);
460 while ((info = remote_action_info_new_from_iter (iter)))
462 g_hash_table_replace (impl->actions, info->name, info);
463 g_action_group_action_added (action_group, info->name);
466 g_variant_iter_free (iter);
469 else if (strcmp (signal_name, "Removed") == 0 &&
470 g_variant_is_of_type (parameters, G_VARIANT_TYPE ("(as)")))
475 g_variant_get_child (parameters, 0, "as", &iter);
476 while (g_variant_iter_next (iter, "&s", &name))
477 if (g_hash_table_remove (impl->actions, name))
478 g_action_group_action_removed (action_group, name);
479 g_variant_iter_free (iter);
482 else if (strcmp (signal_name, "EnabledChanged") == 0 &&
483 g_variant_is_of_type (parameters, G_VARIANT_TYPE ("(sb)")))
485 RemoteActionInfo *info;
489 g_variant_get (parameters, "(&sb)", &name, &enabled);
490 info = g_hash_table_lookup (impl->actions, name);
492 if (info && enabled != info->enabled)
494 info->enabled = enabled;
495 g_action_group_action_enabled_changed (action_group,
501 else if (strcmp (signal_name, "StateChanged") == 0 &&
502 g_variant_is_of_type (parameters, G_VARIANT_TYPE ("(sv)")))
504 RemoteActionInfo *info;
508 g_variant_get (parameters, "(&sv)", &name, &state);
509 info = g_hash_table_lookup (impl->actions, name);
511 if (info && info->state &&
512 g_variant_is_of_type (state, g_variant_get_type (info->state)) &&
513 !g_variant_equal (state, info->state))
515 g_variant_unref (info->state);
516 info->state = g_variant_ref (state);
517 g_action_group_action_state_changed (action_group,
521 g_variant_unref (state);
526 g_application_impl_register (GApplication *application,
528 GApplicationFlags flags,
529 GHashTable **remote_actions,
530 GCancellable *cancellable,
533 const static GDBusInterfaceVTable vtable = {
534 g_application_impl_method_call
536 const static GDBusInterfaceVTable actions_vtable = {
537 g_application_impl_actions_method_call
539 GApplicationImpl *impl;
543 impl = g_slice_new0 (GApplicationImpl);
545 impl->app = application;
546 impl->bus_name = appid;
548 impl->session_bus = g_bus_get_sync (G_BUS_TYPE_SESSION, cancellable, NULL);
550 if (impl->session_bus == NULL)
552 /* If we can't connect to the session bus, proceed as a normal
553 * non-unique application.
555 *remote_actions = NULL;
559 impl->object_path = application_path_from_appid (appid);
561 /* Only try to be the primary instance if
562 * G_APPLICATION_IS_LAUNCHER was not specified.
564 if (~flags & G_APPLICATION_IS_LAUNCHER)
566 /* Attempt to become primary instance. */
568 g_dbus_connection_register_object (impl->session_bus,
570 get_interface ("org.gtk.Application"),
571 &vtable, impl, NULL, error);
573 if (impl->object_id == 0)
575 g_object_unref (impl->session_bus);
576 g_free (impl->object_path);
577 impl->session_bus = NULL;
578 impl->object_path = NULL;
580 g_slice_free (GApplicationImpl, impl);
585 g_dbus_connection_register_object (impl->session_bus,
587 (GDBusInterfaceInfo *)
592 if (impl->action_id == 0)
594 g_dbus_connection_unregister_object (impl->session_bus,
597 g_object_unref (impl->session_bus);
598 g_free (impl->object_path);
599 impl->session_bus = NULL;
600 impl->object_path = NULL;
602 g_slice_free (GApplicationImpl, impl);
606 /* DBUS_NAME_FLAG_DO_NOT_QUEUE: 0x4 */
607 reply = g_dbus_connection_call_sync (impl->session_bus,
608 "org.freedesktop.DBus",
609 "/org/freedesktop/DBus",
610 "org.freedesktop.DBus",
612 g_variant_new ("(su)",
615 G_VARIANT_TYPE ("(u)"),
616 0, -1, cancellable, error);
620 g_dbus_connection_unregister_object (impl->session_bus,
623 g_dbus_connection_unregister_object (impl->session_bus,
627 g_object_unref (impl->session_bus);
628 g_free (impl->object_path);
629 impl->session_bus = NULL;
630 impl->object_path = NULL;
632 g_slice_free (GApplicationImpl, impl);
636 g_variant_get (reply, "(u)", &rval);
637 g_variant_unref (reply);
639 /* DBUS_REQUEST_NAME_REPLY_EXISTS: 3 */
642 /* We are the primary instance. */
643 g_dbus_connection_emit_signal (impl->session_bus,
646 "org.gtk.Application",
648 g_variant_new ("(s)",
651 *remote_actions = NULL;
655 /* We didn't make it. Drop our service-side stuff. */
656 g_dbus_connection_unregister_object (impl->session_bus,
659 g_dbus_connection_unregister_object (impl->session_bus,
663 if (flags & G_APPLICATION_IS_SERVICE)
665 g_set_error (error, G_DBUS_ERROR, G_DBUS_ERROR_FAILED,
666 "Unable to acquire bus name `%s'", appid);
667 g_object_unref (impl->session_bus);
668 g_free (impl->object_path);
670 g_slice_free (GApplicationImpl, impl);
675 /* We are non-primary. Try to get the primary's list of actions.
676 * This also serves as a mechanism to ensure that the primary exists
677 * (ie: DBus service files installed correctly, etc).
680 g_dbus_connection_signal_subscribe (impl->session_bus, impl->bus_name,
681 "org.gtk.Actions", NULL,
682 impl->object_path, NULL,
683 G_DBUS_SIGNAL_FLAGS_NONE,
684 g_application_impl_action_signal,
687 reply = g_dbus_connection_call_sync (impl->session_bus, impl->bus_name,
688 impl->object_path, "org.gtk.Actions",
690 G_VARIANT_TYPE ("(a(savbav))"),
691 G_DBUS_CALL_FLAGS_NONE, -1,
696 /* The primary appears not to exist. Fail the registration. */
697 g_object_unref (impl->session_bus);
698 g_free (impl->object_path);
699 impl->session_bus = NULL;
700 impl->object_path = NULL;
702 g_slice_free (GApplicationImpl, impl);
706 /* Create and populate the hashtable */
708 RemoteActionInfo *info;
709 GVariant *descriptions;
712 *remote_actions = g_hash_table_new (g_str_hash, g_str_equal);
713 descriptions = g_variant_get_child_value (reply, 0);
714 g_variant_iter_init (&iter, descriptions);
716 while ((info = remote_action_info_new_from_iter (&iter)))
717 g_hash_table_insert (*remote_actions, info->name, info);
719 g_variant_unref (descriptions);
727 g_application_impl_activate (GApplicationImpl *impl,
728 GVariant *platform_data)
730 g_dbus_connection_call (impl->session_bus,
733 "org.gtk.Application",
735 g_variant_new ("(@a{sv})", platform_data),
736 NULL, 0, -1, NULL, NULL, NULL);
740 g_application_impl_open (GApplicationImpl *impl,
744 GVariant *platform_data)
746 GVariantBuilder builder;
749 g_variant_builder_init (&builder, G_VARIANT_TYPE ("(assa{sv})"));
750 g_variant_builder_open (&builder, G_VARIANT_TYPE_STRING_ARRAY);
751 for (i = 0; i < n_files; i++)
753 gchar *uri = g_file_get_uri (files[i]);
754 g_variant_builder_add (&builder, "s", uri);
757 g_variant_builder_close (&builder);
758 g_variant_builder_add (&builder, "s", hint);
759 g_variant_builder_add_value (&builder, platform_data);
761 g_dbus_connection_call (impl->session_bus,
764 "org.gtk.Application",
766 g_variant_builder_end (&builder),
767 NULL, 0, -1, NULL, NULL, NULL);
771 g_application_impl_cmdline_method_call (GDBusConnection *connection,
773 const gchar *object_path,
774 const gchar *interface_name,
775 const gchar *method_name,
776 GVariant *parameters,
777 GDBusMethodInvocation *invocation,
780 const gchar *message;
782 g_variant_get_child (parameters, 0, "&s", &message);
784 if (strcmp (method_name, "Print") == 0)
785 g_print ("%s", message);
786 else if (strcmp (method_name, "PrintError") == 0)
787 g_printerr ("%s", message);
789 g_assert_not_reached ();
791 g_dbus_method_invocation_return_value (invocation, NULL);
801 g_application_impl_cmdline_done (GObject *source,
802 GAsyncResult *result,
805 CommandLineData *data = user_data;
806 GError *error = NULL;
809 reply = g_dbus_connection_call_finish (G_DBUS_CONNECTION (source),
814 g_variant_get (reply, "(i)", &data->status);
815 g_variant_unref (reply);
820 g_printerr ("%s\n", error->message);
821 g_error_free (error);
825 g_main_loop_quit (data->loop);
829 g_application_impl_command_line (GApplicationImpl *impl,
831 GVariant *platform_data)
833 const static GDBusInterfaceVTable vtable = {
834 g_application_impl_cmdline_method_call
836 const gchar *object_path = "/org/gtk/Application/CommandLine";
837 GMainContext *context;
838 CommandLineData data;
841 context = g_main_context_new ();
842 data.loop = g_main_loop_new (context, FALSE);
843 g_main_context_push_thread_default (context);
845 object_id = g_dbus_connection_register_object (impl->session_bus,
847 get_interface ("org.gtk.private.CommandLine"),
848 &vtable, &data, NULL, NULL);
849 /* In theory we should try other paths... */
850 g_assert (object_id != 0);
852 g_dbus_connection_call (impl->session_bus,
855 "org.gtk.Application",
857 g_variant_new ("(o^aay@a{sv})", object_path,
858 arguments, platform_data),
859 G_VARIANT_TYPE ("(i)"), 0, G_MAXINT, NULL,
860 g_application_impl_cmdline_done, &data);
862 g_main_loop_run (data.loop);
864 g_main_context_pop_thread_default (context);
865 g_main_context_unref (context);
866 g_main_loop_unref (data.loop);
872 g_application_impl_change_action_state (GApplicationImpl *impl,
873 const gchar *action_name,
875 GVariant *platform_data)
877 g_dbus_connection_call (impl->session_bus,
882 g_variant_new ("(sv@a{sv})", action_name,
883 value, platform_data),
884 NULL, 0, -1, NULL, NULL, NULL);
888 g_application_impl_activate_action (GApplicationImpl *impl,
889 const gchar *action_name,
891 GVariant *platform_data)
896 parameter = g_variant_new_variant (parameter);
898 param = g_variant_new_array (G_VARIANT_TYPE_VARIANT,
899 ¶meter, parameter != NULL);
901 g_dbus_connection_call (impl->session_bus,
906 g_variant_new ("(s@av@a{sv})", action_name,
907 param, platform_data),
908 NULL, 0, -1, NULL, NULL, NULL);
912 g_application_impl_flush (GApplicationImpl *impl)
914 if (impl->session_bus)
915 g_dbus_connection_flush_sync (impl->session_bus, NULL, NULL);
919 /* GDBusCommandLine implementation {{{1 */
921 typedef GApplicationCommandLineClass GDBusCommandLineClass;
922 static GType g_dbus_command_line_get_type (void);
925 GApplicationCommandLine parent_instance;
926 GDBusMethodInvocation *invocation;
928 GDBusConnection *connection;
929 const gchar *bus_name;
930 const gchar *object_path;
934 G_DEFINE_TYPE (GDBusCommandLine,
936 G_TYPE_APPLICATION_COMMAND_LINE)
939 g_dbus_command_line_print_literal (GApplicationCommandLine *cmdline,
940 const gchar *message)
942 GDBusCommandLine *gdbcl = (GDBusCommandLine *) cmdline;
944 g_dbus_connection_call (gdbcl->connection,
947 "org.gtk.private.CommandLine", "Print",
948 g_variant_new ("(s)", message),
949 NULL, 0, -1, NULL, NULL, NULL);
953 g_dbus_command_line_printerr_literal (GApplicationCommandLine *cmdline,
954 const gchar *message)
956 GDBusCommandLine *gdbcl = (GDBusCommandLine *) cmdline;
958 g_dbus_connection_call (gdbcl->connection,
961 "org.gtk.private.CommandLine", "PrintError",
962 g_variant_new ("(s)", message),
963 NULL, 0, -1, NULL, NULL, NULL);
967 g_dbus_command_line_finalize (GObject *object)
969 GApplicationCommandLine *cmdline = G_APPLICATION_COMMAND_LINE (object);
970 GDBusCommandLine *gdbcl = (GDBusCommandLine *) object;
973 status = g_application_command_line_get_exit_status (cmdline);
975 g_dbus_method_invocation_return_value (gdbcl->invocation,
976 g_variant_new ("(i)", status));
977 g_object_unref (gdbcl->invocation);
979 G_OBJECT_CLASS (g_dbus_command_line_parent_class)
984 g_dbus_command_line_init (GDBusCommandLine *gdbcl)
989 g_dbus_command_line_class_init (GApplicationCommandLineClass *class)
991 GObjectClass *object_class = G_OBJECT_CLASS (class);
993 object_class->finalize = g_dbus_command_line_finalize;
994 class->printerr_literal = g_dbus_command_line_printerr_literal;
995 class->print_literal = g_dbus_command_line_print_literal;
998 static GApplicationCommandLine *
999 g_dbus_command_line_new (GDBusMethodInvocation *invocation)
1001 GDBusCommandLine *gdbcl;
1004 args = g_dbus_method_invocation_get_parameters (invocation);
1006 gdbcl = g_object_new (g_dbus_command_line_get_type (),
1007 "arguments", g_variant_get_child_value (args, 1),
1008 "platform-data", g_variant_get_child_value (args, 2),
1010 gdbcl->connection = g_dbus_method_invocation_get_connection (invocation);
1011 gdbcl->bus_name = g_dbus_method_invocation_get_sender (invocation);
1012 g_variant_get_child (args, 0, "&o", &gdbcl->object_path);
1013 gdbcl->invocation = g_object_ref (invocation);
1015 return G_APPLICATION_COMMAND_LINE (gdbcl);
1020 /* vim:set foldmethod=marker: */