static gboolean handle_prepare_print (XdpPrint *object, GDBusMethodInvocation *invocation, const gchar *arg_parent_window, const gchar *arg_title, GVariant *arg_settings, GVariant *arg_page_setup, GVariant *arg_options) { Request *request = request_from_invocation (invocation); const char *app_id = xdp_app_info_get_id (request->app_info); g_autoptr(GError) error = NULL; g_autoptr(XdpImplRequest) impl_request = NULL; GVariantBuilder opt_builder; if (xdp_impl_lockdown_get_disable_printing (lockdown)) { g_debug ("Printing disabled"); g_dbus_method_invocation_return_error (invocation, XDG_DESKTOP_PORTAL_ERROR, XDG_DESKTOP_PORTAL_ERROR_NOT_ALLOWED, "Printing disabled"); return TRUE; } REQUEST_AUTOLOCK (request); impl_request = xdp_impl_request_proxy_new_sync (g_dbus_proxy_get_connection (G_DBUS_PROXY (impl)), G_DBUS_PROXY_FLAGS_NONE, g_dbus_proxy_get_name (G_DBUS_PROXY (impl)), request->id, NULL, &error); if (!impl_request) { g_dbus_method_invocation_return_gerror (invocation, error); return TRUE; } request_set_impl_request (request, impl_request); request_export (request, g_dbus_method_invocation_get_connection (invocation)); g_variant_builder_init (&opt_builder, G_VARIANT_TYPE_VARDICT); xdp_filter_options (arg_options, &opt_builder, prepare_print_options, G_N_ELEMENTS (prepare_print_options)); xdp_impl_print_call_prepare_print (impl, request->id, app_id, arg_parent_window, arg_title, arg_settings, arg_page_setup, g_variant_builder_end (&opt_builder), NULL, prepare_print_done, g_object_ref (request)); xdp_print_complete_prepare_print (object, invocation, request->id); return TRUE; }
static gboolean handle_save_file (XdpFileChooser *object, GDBusMethodInvocation *invocation, const gchar *arg_parent_window, const gchar *arg_title, GVariant *arg_options) { Request *request = request_from_invocation (invocation); const char *app_id = request->app_id; g_autoptr(GError) error = NULL; XdpImplRequest *impl_request; GVariantBuilder options; REQUEST_AUTOLOCK (request); g_variant_builder_init (&options, G_VARIANT_TYPE_VARDICT); xdp_filter_options (arg_options, &options, save_file_options, G_N_ELEMENTS (save_file_options)); impl_request = xdp_impl_request_proxy_new_sync (g_dbus_proxy_get_connection (G_DBUS_PROXY (impl)), G_DBUS_PROXY_FLAGS_NONE, g_dbus_proxy_get_name (G_DBUS_PROXY (impl)), request->id, NULL, &error); if (!impl_request) { g_dbus_method_invocation_return_gerror (invocation, error); return TRUE; } g_object_set_data (G_OBJECT (request), "for-save", GINT_TO_POINTER (TRUE)); request_set_impl_request (request, impl_request); request_export (request, g_dbus_method_invocation_get_connection (invocation)); xdp_impl_file_chooser_call_save_file (impl, request->id, app_id, arg_parent_window, arg_title, g_variant_builder_end (&options), NULL, save_file_done, g_object_ref (request)); xdp_file_chooser_complete_open_file (object, invocation, request->id); return TRUE; }
static gboolean handle_open_file (XdpFileChooser *object, GDBusMethodInvocation *invocation, const gchar *arg_parent_window, const gchar *arg_title, GVariant *arg_options) { Request *request = request_from_invocation (invocation); const char *app_id = request->app_id; g_autoptr(GError) error = NULL; g_autoptr(XdpImplRequest) impl_request = NULL; GVariantBuilder options; g_autoptr(GVariant) value = NULL; REQUEST_AUTOLOCK (request); value = g_variant_lookup_value (arg_options, "filters", NULL); if (value != NULL) { if (!check_filters (value, &error)) { g_prefix_error (&error, "invalid filters: "); g_dbus_method_invocation_return_gerror (invocation, error); return TRUE; } g_variant_unref (value); value = NULL; } value = g_variant_lookup_value (arg_options, "choices", NULL); if (value != NULL) { if (!check_choices (value, &error)) { g_prefix_error (&error, "invalid choices: "); g_dbus_method_invocation_return_gerror (invocation, error); return TRUE; } g_variant_unref (value); value = NULL; } g_variant_builder_init (&options, G_VARIANT_TYPE_VARDICT); xdp_filter_options (arg_options, &options, open_file_options, G_N_ELEMENTS (open_file_options)); impl_request = xdp_impl_request_proxy_new_sync (g_dbus_proxy_get_connection (G_DBUS_PROXY (impl)), G_DBUS_PROXY_FLAGS_NONE, g_dbus_proxy_get_name (G_DBUS_PROXY (impl)), request->id, NULL, &error); if (!impl_request) { g_dbus_method_invocation_return_gerror (invocation, error); return TRUE; } request_set_impl_request (request, impl_request); request_export (request, g_dbus_method_invocation_get_connection (invocation)); xdp_impl_file_chooser_call_open_file (impl, request->id, app_id, arg_parent_window, arg_title, g_variant_builder_end (&options), NULL, open_file_done, g_object_ref (request)); xdp_file_chooser_complete_open_file (object, invocation, request->id); return TRUE; }