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 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212
|
/*
* Copyright © 2014 Red Hat, Inc
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
* Authors:
* Alexander Larsson <alexl@redhat.com>
*/
#ifndef __FLATPAK_BUILTINS_UTILS_H__
#define __FLATPAK_BUILTINS_UTILS_H__
#include <glib.h>
#include <appstream.h>
#include "libglnx.h"
#include "flatpak-utils-private.h"
#include "flatpak-dir-private.h"
#include "flatpak-permission-dbus-generated.h"
/* AS_CHECK_VERSION was introduced in 0.14.0; we still support 0.12.0, so
* behave as though versions without this macro are arbitrarily old */
#ifndef AS_CHECK_VERSION
#define AS_CHECK_VERSION(major, minor, micro) (0)
#endif
/* Appstream data expires after a day */
#define FLATPAK_APPSTREAM_TTL 86400
typedef struct RemoteDirPair
{
gchar *remote_name;
FlatpakDir *dir;
} RemoteDirPair;
typedef struct RefDirPair
{
FlatpakDecomposed *ref;
FlatpakDir *dir;
} RefDirPair;
void ref_dir_pair_free (RefDirPair *pair);
RefDirPair * ref_dir_pair_new (FlatpakDecomposed *ref,
FlatpakDir *dir);
void remote_dir_pair_free (RemoteDirPair *pair);
RemoteDirPair * remote_dir_pair_new (const char *remote_name,
FlatpakDir *dir);
gboolean looks_like_branch (const char *branch);
GBytes * flatpak_load_gpg_keys (char **gpg_import,
GCancellable *cancellable,
GError **error);
FlatpakDir * flatpak_find_installed_pref (const char *pref,
FlatpakKinds kinds,
const char *default_arch,
const char *default_branch,
gboolean search_all,
gboolean search_user,
gboolean search_system,
char **search_installations,
FlatpakDecomposed **out_ref,
GCancellable *cancellable,
GError **error);
gboolean flatpak_resolve_duplicate_remotes (GPtrArray *dirs,
const char *remote_name,
FlatpakDir **out_dir,
GCancellable *cancellable,
GError **error);
gboolean flatpak_resolve_matching_refs (const char *remote_name,
FlatpakDir *dir,
gboolean assume_yes,
GPtrArray *refs,
const char *opt_search_ref,
char **out_ref,
GError **error);
gboolean flatpak_resolve_matching_installed_refs (gboolean assume_yes,
gboolean only_one,
GPtrArray *ref_dir_pairs,
const char *opt_search_ref,
GPtrArray *out_pairs,
GError **error);
gboolean flatpak_resolve_matching_remotes (GPtrArray *remote_dir_pairs,
const char *opt_search_ref,
RemoteDirPair **out_pair,
GError **error);
gboolean update_appstream (GPtrArray *dirs,
const char *remote,
const char *arch,
guint64 ttl,
gboolean quiet,
GCancellable *cancellable,
GError **error);
char ** get_permission_tables (XdpDbusPermissionStore *store);
gboolean reset_permissions_for_app (const char *app_id,
GError **error);
/* --columns handling */
typedef enum {
FLATPAK_ELLIPSIZE_MODE_NONE,
FLATPAK_ELLIPSIZE_MODE_START,
FLATPAK_ELLIPSIZE_MODE_MIDDLE,
FLATPAK_ELLIPSIZE_MODE_END,
} FlatpakEllipsizeMode;
typedef struct
{
const char *name;
const char *title; /* use N_() */
const char *desc; /* use N_() */
gboolean expand;
FlatpakEllipsizeMode ellipsize;
gboolean all;
gboolean def;
gboolean skip_unique_if_default;
} Column;
int find_column (Column *columns,
const char *name,
GError **error);
char *column_help (Column *columns);
Column *handle_column_args (Column *all_columns,
gboolean opt_show_all,
const char **opt_cols,
GError **error);
char * format_timestamp (guint64 timestamp);
char * ellipsize_string (const char *text,
int len);
char * ellipsize_string_full (const char *text,
int len,
FlatpakEllipsizeMode mode);
void print_aligned (int len,
const char *title,
const char *value);
void print_aligned_take (int len,
const char *title,
char *value);
AsComponent *metadata_find_component (AsMetadata *mdata,
const char *ref);
const char *component_get_version_latest (AsComponent *component);
gboolean flatpak_dir_load_appstream_data (FlatpakDir *self,
const gchar *remote_name,
const gchar *arch,
AsMetadata *mdata,
GCancellable *cancellable,
GError **error);
int cell_width (const char *text);
const char *cell_advance (const char *text,
int num);
void print_wrapped (int columns,
const char *text,
...) G_GNUC_PRINTF (2, 3);
FlatpakRemoteState * get_remote_state (FlatpakDir *dir,
const char *remote,
gboolean cached,
gboolean only_sideloaded,
const char *opt_arch,
const char **opt_sideload_repos,
GCancellable *cancellable,
GError **error);
gboolean ensure_remote_state_arch (FlatpakDir *dir,
FlatpakRemoteState *state,
const char *arch,
gboolean cached,
gboolean only_sideloaded,
GCancellable *cancellable,
GError **error);
gboolean ensure_remote_state_arch_for_ref (FlatpakDir *dir,
FlatpakRemoteState *state,
const char *ref,
gboolean cached,
gboolean only_sideloaded,
GCancellable *cancellable,
GError **error);
gboolean ensure_remote_state_all_arches (FlatpakDir *dir,
FlatpakRemoteState *state,
gboolean cached,
gboolean only_sideloaded,
GCancellable *cancellable,
GError **error);
#endif /* __FLATPAK_BUILTINS_UTILS_H__ */
|