1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133
|
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
*
* Copyright (C) 2012-2025 Matthias Klumpp <matthias@tenstral.net>
* Copyright (C) 2007-2014 Richard Hughes <richard@hughsie.com>
*
* Licensed under the GNU General Public License Version 2
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the license, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <glib.h>
#include <glib/gi18n.h>
#include <packagekit-glib2/packagekit.h>
#include <packagekit-glib2/packagekit-private.h>
G_BEGIN_DECLS
/* exit codes */
#define PKGC_EXIT_SUCCESS 0
#define PKGC_EXIT_FAILURE 1
#define PKGC_EXIT_SYNTAX_ERROR 2
#define PKGC_EXIT_PERMISSION_DENIED 3
#define PKGC_EXIT_NOT_FOUND 4
#define PKGC_EXIT_TRANSACTION_FAILED 5
/* error domain */
#define PKGC_ERROR (pkgc_error_quark ())
/* default cache age (3 days) */
#define PKGC_DEFAULT_CACHE_AGE_SEC (3 * 24 * 60 * 60)
/**
* OutputMode:
* @PKGCLI_MODE_NORMAL: Normal output mode
* @PKGCLI_MODE_QUIET: Minimal output
* @PKGCLI_MODE_JSON: Output in JSON format
* @PKGCLI_MODE_VERBOSE: Verbose output
*/
typedef enum {
PKGCLI_MODE_NORMAL,
PKGCLI_MODE_QUIET,
PKGCLI_MODE_JSON,
PKGCLI_MODE_VERBOSE
} PkgcliMode;
/**
* PkgctlContext:
*
* Context structure for pkgcli
*/
typedef struct {
PkControl *control;
PkTaskText *task;
GCancellable *cancellable;
GMainLoop *loop;
PkProgressBar *progressbar;
GPtrArray *commands;
/* Automatic Flags */
gboolean simulate;
gboolean is_tty;
/* Global Options */
PkgcliMode output_mode;
gboolean no_color;
gboolean noninteractive;
gboolean only_download;
gboolean allow_downgrade;
gboolean allow_reinstall;
gboolean allow_untrusted;
guint cache_age;
PkBitfield filters;
gboolean user_filters_set;
/* State */
gint exit_code;
gboolean transaction_running;
} PkgcliContext;
/**
* PkgctlCommand:
*
* Structure defining a pkgcli command
*/
typedef struct PkgcliCommand PkgcliCommand;
struct PkgcliCommand {
gchar *name;
gchar *summary;
gchar *param_summary;
gint (*handler) (PkgcliContext *ctx,
PkgcliCommand *cmd,
gint argc,
gchar **argv);
};
GQuark pkgc_error_quark (void);
PkgcliContext *pkgc_context_new (void);
void pkgc_context_free (PkgcliContext *ctx);
gboolean pkgc_context_init (PkgcliContext *ctx, GError **error);
void pkgc_context_apply_settings (PkgcliContext *ctx);
void pkgc_context_register_command (PkgcliContext *ctx,
const gchar *name,
gint (*handler) (PkgcliContext *ctx,
PkgcliCommand *cmd,
gint argc,
gchar **argv),
const gchar *summary);
PkgcliCommand *pkgc_context_find_command (PkgcliContext *ctx, const char *name);
void pkgc_context_stop_progress_bar (PkgcliContext *ctx);
void pkgc_context_on_progress_cb (PkProgress *progress,
PkProgressType type,
gpointer user_data);
G_END_DECLS
|