1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/app-manager/default_action.c Tue Jun 29 10:08:58 2021 +0100
1.3 @@ -0,0 +1,78 @@
1.4 +/*
1.5 + * Copyright (C) 2014, 2016, 2020 J. Ali Harlow <ali@juiblex.co.uk>
1.6 + *
1.7 + * This program is free software; you can redistribute it and/or modify
1.8 + * it under the terms of the GNU General Public License as published by
1.9 + * the Free Software Foundation; either version 2 of the License, or
1.10 + * (at your option) any later version.
1.11 + *
1.12 + * This program is distributed in the hope that it will be useful,
1.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1.15 + * GNU General Public License for more details.
1.16 + *
1.17 + * You should have received a copy of the GNU General Public License along
1.18 + * with this program; if not, write to the Free Software Foundation, Inc.,
1.19 + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
1.20 + */
1.21 +
1.22 +#include "config.h"
1.23 +#include <stdlib.h>
1.24 +#include <string.h>
1.25 +#include <errno.h>
1.26 +#include <glib.h>
1.27 +#include <gio/gio.h>
1.28 +#include <gtk/gtk.h>
1.29 +#include <plover/plover.h>
1.30 +#include <plover/transaction.h>
1.31 +#include <plover/packageset.h>
1.32 +#include <plover-gtk/transactionhelper.h>
1.33 +#include "app-manager.h"
1.34 +
1.35 +gboolean default_action(const char *base)
1.36 +{
1.37 + gchar *s;
1.38 + const char *prefix;
1.39 + GError *error=NULL;
1.40 + static PloverTransactionHelper *helper=NULL;
1.41 + if (!helper)
1.42 + {
1.43 + helper=plover_transaction_helper_new(ui);
1.44 + plover_transaction_helper_set_base_uri(helper,base);
1.45 + prefix=plover_transaction_helper_get_prefix(helper,&error);
1.46 + if (error)
1.47 + g_clear_error(&error);
1.48 + else
1.49 + {
1.50 + s=g_strconcat(prefix?prefix:"","/var/log/default-action",NULL);
1.51 + plover_log_open(s);
1.52 + g_free(s);
1.53 + }
1.54 + plover_transaction_helper_set_check_vendor(helper,TRUE);
1.55 + g_signal_connect(helper,"close",G_CALLBACK(gtk_main_quit),NULL);
1.56 + }
1.57 + if (!plover_transaction_helper_get_visible(helper))
1.58 + {
1.59 + if (!plover_transaction_helper_default_action_on_group(helper,"base",
1.60 + &error))
1.61 + {
1.62 + if (g_error_matches(error,PLOVER_GENERAL_ERROR,
1.63 + PLOVER_GENERAL_ERROR_REQUIREMENTS_NOT_MET))
1.64 + {
1.65 + g_error_free(error);
1.66 + error=g_error_new_literal(PLOVER_GENERAL_ERROR,
1.67 + PLOVER_GENERAL_ERROR_REQUIREMENTS_NOT_MET,
1.68 + "Software cannot be installed because of missing updates. "
1.69 + "Installing all updates first should resolve this problem");
1.70 + plover_transaction_helper_set_error(helper,error,
1.71 + "Software installation failed");
1.72 + }
1.73 + else
1.74 + plover_transaction_helper_set_error(helper,error,
1.75 + "Software installation failed");
1.76 + g_error_free(error);
1.77 + }
1.78 + }
1.79 + plover_transaction_helper_present(helper);
1.80 + return TRUE;
1.81 +}