app-manager/default_action.c
author J. Ali Harlow <ali@juiblex.co.uk>
Mon Aug 31 07:12:39 2020 +0100 (2020-08-31)
changeset 105 bbddb595e366
permissions -rw-r--r--
Added tag 0.6 for changeset 5cb36c12ac49
ali@103
     1
/*
ali@103
     2
 * Copyright (C) 2014, 2016, 2020  J. Ali Harlow <ali@juiblex.co.uk>
ali@103
     3
 *
ali@103
     4
 * This program is free software; you can redistribute it and/or modify
ali@103
     5
 * it under the terms of the GNU General Public License as published by
ali@103
     6
 * the Free Software Foundation; either version 2 of the License, or
ali@103
     7
 * (at your option) any later version.
ali@103
     8
 *
ali@103
     9
 * This program is distributed in the hope that it will be useful,
ali@103
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
ali@103
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
ali@103
    12
 * GNU General Public License for more details.
ali@103
    13
 *
ali@103
    14
 * You should have received a copy of the GNU General Public License along
ali@103
    15
 * with this program; if not, write to the Free Software Foundation, Inc.,
ali@103
    16
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
ali@103
    17
 */
ali@103
    18
ali@103
    19
#include "config.h"
ali@103
    20
#include <stdlib.h>
ali@103
    21
#include <string.h>
ali@103
    22
#include <errno.h>
ali@103
    23
#include <glib.h>
ali@103
    24
#include <gio/gio.h>
ali@103
    25
#include <gtk/gtk.h>
ali@103
    26
#include <plover/plover.h>
ali@103
    27
#include <plover/transaction.h>
ali@103
    28
#include <plover/packageset.h>
ali@103
    29
#include <plover-gtk/transactionhelper.h>
ali@103
    30
#include "app-manager.h"
ali@103
    31
ali@103
    32
gboolean default_action(const char *base)
ali@103
    33
{
ali@103
    34
    gchar *s;
ali@103
    35
    const char *prefix;
ali@103
    36
    GError *error=NULL;
ali@103
    37
    static PloverTransactionHelper *helper=NULL;
ali@103
    38
    if (!helper)
ali@103
    39
    {
ali@103
    40
	helper=plover_transaction_helper_new(ui);
ali@103
    41
	plover_transaction_helper_set_base_uri(helper,base);
ali@103
    42
	prefix=plover_transaction_helper_get_prefix(helper,&error);
ali@103
    43
	if (error)
ali@103
    44
	    g_clear_error(&error);
ali@103
    45
	else
ali@103
    46
	{
ali@103
    47
	    s=g_strconcat(prefix?prefix:"","/var/log/default-action",NULL);
ali@103
    48
	    plover_log_open(s);
ali@103
    49
	    g_free(s);
ali@103
    50
	}
ali@103
    51
	plover_transaction_helper_set_check_vendor(helper,TRUE);
ali@103
    52
	g_signal_connect(helper,"close",G_CALLBACK(gtk_main_quit),NULL);
ali@103
    53
    }
ali@103
    54
    if (!plover_transaction_helper_get_visible(helper))
ali@103
    55
    {
ali@103
    56
	if (!plover_transaction_helper_default_action_on_group(helper,"base",
ali@103
    57
	  &error))
ali@103
    58
	{
ali@103
    59
	    if (g_error_matches(error,PLOVER_GENERAL_ERROR,
ali@103
    60
	      PLOVER_GENERAL_ERROR_REQUIREMENTS_NOT_MET))
ali@103
    61
	    {
ali@103
    62
		g_error_free(error);
ali@103
    63
		error=g_error_new_literal(PLOVER_GENERAL_ERROR,
ali@103
    64
		  PLOVER_GENERAL_ERROR_REQUIREMENTS_NOT_MET,
ali@103
    65
		  "Software cannot be installed because of missing updates. "
ali@103
    66
		  "Installing all updates first should resolve this problem");
ali@103
    67
		plover_transaction_helper_set_error(helper,error,
ali@103
    68
		  "Software installation failed");
ali@103
    69
	    }
ali@103
    70
	    else
ali@103
    71
		plover_transaction_helper_set_error(helper,error,
ali@103
    72
		  "Software installation failed");
ali@103
    73
	    g_error_free(error);
ali@103
    74
	}
ali@103
    75
    }
ali@103
    76
    plover_transaction_helper_present(helper);
ali@103
    77
    return TRUE;
ali@103
    78
}