void gs_page_authenticate (GsPage *page, GsApp *app, const gchar *auth_id, GCancellable *cancellable, GsPageAuthCallback callback, gpointer user_data) { GsPagePrivate *priv = gs_page_get_instance_private (page); g_autoptr(GsPageHelper) helper = NULL; GtkWidget *dialog; g_autoptr(GError) error = NULL; helper = g_slice_new0 (GsPageHelper); helper->app = app != NULL ? g_object_ref (app) : NULL; helper->page = g_object_ref (page); helper->callback = callback; helper->callback_data = user_data; dialog = gs_auth_dialog_new (priv->plugin_loader, app, auth_id, &error); if (dialog == NULL) { g_warning ("%s", error->message); return; } gs_shell_modal_dialog_present (priv->shell, GTK_DIALOG (dialog)); g_signal_connect (dialog, "response", G_CALLBACK (gs_page_authenticate_cb), helper); g_steal_pointer (&helper); }
static void gs_page_app_removed_cb (GObject *source, GAsyncResult *res, gpointer user_data) { g_autoptr(GsPageHelper) helper = (GsPageHelper *) user_data; GsPluginLoader *plugin_loader = GS_PLUGIN_LOADER (source); GsPage *page = helper->page; GsPagePrivate *priv = gs_page_get_instance_private (page); gboolean ret; g_autoptr(GError) error = NULL; ret = gs_plugin_loader_app_action_finish (plugin_loader, res, &error); if (g_error_matches (error, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_CANCELLED)) { g_debug ("%s", error->message); return; } if (!ret) { /* try to authenticate then retry */ if (g_error_matches (error, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_AUTH_REQUIRED)) { g_autoptr(GError) error_local = NULL; GtkWidget *dialog; dialog = gs_auth_dialog_new (priv->plugin_loader, helper->app, gs_utils_get_error_value (error), &error_local); if (dialog == NULL) { g_warning ("%s", error_local->message); return; } gs_shell_modal_dialog_present (priv->shell, GTK_DIALOG (dialog)); g_signal_connect (dialog, "response", G_CALLBACK (gs_page_remove_authenticate_cb), g_steal_pointer (&helper)); return; } g_warning ("failed to remove: %s", error->message); return; } if (!gs_app_is_installed (helper->app) && GS_PAGE_GET_CLASS (page)->app_removed != NULL) { GS_PAGE_GET_CLASS (page)->app_removed (page, helper->app); } }