ali@103: /* ali@103: * Copyright (C) 2014, 2016, 2020 J. Ali Harlow ali@103: * ali@103: * This program is free software; you can redistribute it and/or modify ali@103: * it under the terms of the GNU General Public License as published by ali@103: * the Free Software Foundation; either version 2 of the License, or ali@103: * (at your option) any later version. ali@103: * ali@103: * This program is distributed in the hope that it will be useful, ali@103: * but WITHOUT ANY WARRANTY; without even the implied warranty of ali@103: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ali@103: * GNU General Public License for more details. ali@103: * ali@103: * You should have received a copy of the GNU General Public License along ali@103: * with this program; if not, write to the Free Software Foundation, Inc., ali@103: * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ali@103: */ ali@103: ali@103: #include "config.h" ali@103: #include ali@103: #include ali@103: #include ali@103: #include ali@103: #include ali@103: #include ali@103: #include ali@103: #include ali@103: #include ali@103: #include ali@103: #include "app-manager.h" ali@103: ali@103: gboolean default_action(const char *base) ali@103: { ali@103: gchar *s; ali@103: const char *prefix; ali@103: GError *error=NULL; ali@103: static PloverTransactionHelper *helper=NULL; ali@103: if (!helper) ali@103: { ali@103: helper=plover_transaction_helper_new(ui); ali@103: plover_transaction_helper_set_base_uri(helper,base); ali@103: prefix=plover_transaction_helper_get_prefix(helper,&error); ali@103: if (error) ali@103: g_clear_error(&error); ali@103: else ali@103: { ali@103: s=g_strconcat(prefix?prefix:"","/var/log/default-action",NULL); ali@103: plover_log_open(s); ali@103: g_free(s); ali@103: } ali@103: plover_transaction_helper_set_check_vendor(helper,TRUE); ali@103: g_signal_connect(helper,"close",G_CALLBACK(gtk_main_quit),NULL); ali@103: } ali@103: if (!plover_transaction_helper_get_visible(helper)) ali@103: { ali@103: if (!plover_transaction_helper_default_action_on_group(helper,"base", ali@103: &error)) ali@103: { ali@103: if (g_error_matches(error,PLOVER_GENERAL_ERROR, ali@103: PLOVER_GENERAL_ERROR_REQUIREMENTS_NOT_MET)) ali@103: { ali@103: g_error_free(error); ali@103: error=g_error_new_literal(PLOVER_GENERAL_ERROR, ali@103: PLOVER_GENERAL_ERROR_REQUIREMENTS_NOT_MET, ali@103: "Software cannot be installed because of missing updates. " ali@103: "Installing all updates first should resolve this problem"); ali@103: plover_transaction_helper_set_error(helper,error, ali@103: "Software installation failed"); ali@103: } ali@103: else ali@103: plover_transaction_helper_set_error(helper,error, ali@103: "Software installation failed"); ali@103: g_error_free(error); ali@103: } ali@103: } ali@103: plover_transaction_helper_present(helper); ali@103: return TRUE; ali@103: }