Add FlatpakKinds flag and use instead of booleans

tingping/wmclass
Alexander Larsson 2016-10-14 11:20:53 +02:00
parent df6a5450c1
commit c23316cb5d
16 changed files with 134 additions and 109 deletions

View File

@ -297,7 +297,7 @@ flatpak_complete_build_init (FlatpakCompletion *completion)
user_dir = flatpak_dir_get_user ();
{
g_auto(GStrv) refs = flatpak_dir_find_installed_refs (user_dir, NULL, NULL, opt_arch,
FALSE, TRUE, &error);
FLATPAK_KINDS_RUNTIME, &error);
if (refs == NULL)
flatpak_completion_debug ("find local refs error: %s", error->message);
for (i = 0; refs != NULL && refs[i] != NULL; i++)
@ -311,7 +311,7 @@ flatpak_complete_build_init (FlatpakCompletion *completion)
system_dir = flatpak_dir_get_system ();
{
g_auto(GStrv) refs = flatpak_dir_find_installed_refs (system_dir, NULL, NULL, opt_arch,
FALSE, TRUE, &error);
FLATPAK_KINDS_RUNTIME, &error);
if (refs == NULL)
flatpak_completion_debug ("find local refs error: %s", error->message);
for (i = 0; refs != NULL && refs[i] != NULL; i++)
@ -328,7 +328,7 @@ flatpak_complete_build_init (FlatpakCompletion *completion)
user_dir = flatpak_dir_get_user ();
{
g_auto(GStrv) refs = flatpak_dir_find_installed_refs (user_dir, completion->argv[3], NULL, opt_arch,
FALSE, TRUE, &error);
FLATPAK_KINDS_RUNTIME, &error);
if (refs == NULL)
flatpak_completion_debug ("find local refs error: %s", error->message);
for (i = 0; refs != NULL && refs[i] != NULL; i++)
@ -342,7 +342,7 @@ flatpak_complete_build_init (FlatpakCompletion *completion)
system_dir = flatpak_dir_get_system ();
{
g_auto(GStrv) refs = flatpak_dir_find_installed_refs (system_dir, completion->argv[3], NULL, opt_arch,
FALSE, TRUE, &error);
FLATPAK_KINDS_RUNTIME, &error);
if (refs == NULL)
flatpak_completion_debug ("find local refs error: %s", error->message);
for (i = 0; refs != NULL && refs[i] != NULL; i++)

View File

@ -118,7 +118,7 @@ flatpak_complete_document_list (FlatpakCompletion *completion)
user_dir = flatpak_dir_get_user ();
{
g_auto(GStrv) refs = flatpak_dir_find_installed_refs (user_dir, NULL, NULL, NULL,
TRUE, FALSE, &error);
FLATPAK_KINDS_APP, &error);
if (refs == NULL)
flatpak_completion_debug ("find local refs error: %s", error->message);
for (i = 0; refs != NULL && refs[i] != NULL; i++)
@ -132,7 +132,7 @@ flatpak_complete_document_list (FlatpakCompletion *completion)
system_dir = flatpak_dir_get_system ();
{
g_auto(GStrv) refs = flatpak_dir_find_installed_refs (system_dir, NULL, NULL, NULL,
TRUE, FALSE, &error);
FLATPAK_KINDS_APP, &error);
if (refs == NULL)
flatpak_completion_debug ("find local refs error: %s", error->message);
for (i = 0; refs != NULL && refs[i] != NULL; i++)

View File

@ -77,8 +77,9 @@ flatpak_builtin_info (int argc, char **argv, GCancellable *cancellable, GError *
char *branch = NULL;
const char *commit = NULL;
const char *origin = NULL;
gboolean is_app = FALSE;
gboolean first = TRUE;
FlatpakKinds kinds;
FlatpakKinds kind = 0;
context = g_option_context_new (_("NAME [BRANCH] - Get info about installed app and/or runtime"));
g_option_context_set_translation_domain (context, GETTEXT_PACKAGE);
@ -99,8 +100,7 @@ flatpak_builtin_info (int argc, char **argv, GCancellable *cancellable, GError *
if (!flatpak_split_partial_ref_arg (name, &opt_arch, &branch, error))
return FALSE;
if (!opt_app && !opt_runtime)
opt_app = opt_runtime = TRUE;
kinds = flatpak_kinds_from_bools (opt_app, opt_runtime);
if (!opt_user && !opt_system)
opt_user = opt_system = TRUE;
@ -113,7 +113,7 @@ flatpak_builtin_info (int argc, char **argv, GCancellable *cancellable, GError *
name,
branch,
opt_arch,
opt_app, opt_runtime, &is_app,
kinds, &kind,
&lookup_error);
if (ref)
dir = user_dir;
@ -127,7 +127,7 @@ flatpak_builtin_info (int argc, char **argv, GCancellable *cancellable, GError *
name,
branch,
opt_arch,
opt_app, opt_runtime, &is_app,
kinds, &kind,
lookup_error == NULL ? &lookup_error : NULL);
if (ref)
dir = system_dir;
@ -182,14 +182,14 @@ flatpak_complete_info (FlatpakCompletion *completion)
g_autoptr(FlatpakDir) user_dir = NULL;
g_autoptr(FlatpakDir) system_dir = NULL;
g_autoptr(GError) error = NULL;
FlatpakKinds kinds;
int i;
context = g_option_context_new ("");
if (!flatpak_option_context_parse (context, options, &completion->argc, &completion->argv, FLATPAK_BUILTIN_FLAG_NO_DIR, NULL, NULL, NULL))
return FALSE;
if (!opt_app && !opt_runtime)
opt_app = opt_runtime = TRUE;
kinds = flatpak_kinds_from_bools (opt_app, opt_runtime);
if (!opt_user && !opt_system)
opt_user = opt_system = TRUE;
@ -210,7 +210,7 @@ flatpak_complete_info (FlatpakCompletion *completion)
if (user_dir)
{
g_auto(GStrv) refs = flatpak_dir_find_installed_refs (user_dir, NULL, NULL, opt_arch,
opt_app, opt_runtime, &error);
kinds, &error);
if (refs == NULL)
flatpak_completion_debug ("find local refs error: %s", error->message);
for (i = 0; refs != NULL && refs[i] != NULL; i++)
@ -224,7 +224,7 @@ flatpak_complete_info (FlatpakCompletion *completion)
if (system_dir)
{
g_auto(GStrv) refs = flatpak_dir_find_installed_refs (system_dir, NULL, NULL, opt_arch,
opt_app, opt_runtime, &error);
kinds, &error);
if (refs == NULL)
flatpak_completion_debug ("find local refs error: %s", error->message);
for (i = 0; refs != NULL && refs[i] != NULL; i++)
@ -240,7 +240,7 @@ flatpak_complete_info (FlatpakCompletion *completion)
if (user_dir)
{
g_auto(GStrv) refs = flatpak_dir_find_installed_refs (user_dir, completion->argv[1], NULL, opt_arch,
opt_app, opt_runtime, &error);
kinds, &error);
if (refs == NULL)
flatpak_completion_debug ("find remote refs error: %s", error->message);
for (i = 0; refs != NULL && refs[i] != NULL; i++)
@ -253,7 +253,7 @@ flatpak_complete_info (FlatpakCompletion *completion)
if (user_dir)
{
g_auto(GStrv) refs = flatpak_dir_find_installed_refs (user_dir, completion->argv[1], NULL, opt_arch,
opt_app, opt_runtime, &error);
kinds, &error);
if (refs == NULL)
flatpak_completion_debug ("find remote refs error: %s", error->message);
for (i = 0; refs != NULL && refs[i] != NULL; i++)

View File

@ -271,7 +271,8 @@ flatpak_builtin_install (int argc, char **argv, GCancellable *cancellable, GErro
char *name;
char *branch = NULL;
g_autofree char *ref = NULL;
gboolean is_app;
FlatpakKinds kinds;
FlatpakKinds kind;
context = g_option_context_new (_("REPOSITORY NAME [BRANCH] - Install an application or runtime"));
g_option_context_set_translation_domain (context, GETTEXT_PACKAGE);
@ -296,14 +297,13 @@ flatpak_builtin_install (int argc, char **argv, GCancellable *cancellable, GErro
if (argc >= 4)
branch = argv[3];
kinds = flatpak_kinds_from_bools (opt_app, opt_runtime);
if (!flatpak_split_partial_ref_arg (name, &opt_arch, &branch, error))
return FALSE;
if (!opt_app && !opt_runtime)
opt_app = opt_runtime = TRUE;
ref = flatpak_dir_find_remote_ref (dir, repository, name, branch, opt_arch,
opt_app, opt_runtime, &is_app, cancellable, error);
kinds, &kind, cancellable, error);
if (ref == NULL)
return FALSE;
@ -325,14 +325,14 @@ flatpak_complete_install (FlatpakCompletion *completion)
g_autoptr(FlatpakDir) dir = NULL;
g_autoptr(GError) error = NULL;
g_auto(GStrv) refs = NULL;
FlatpakKinds kinds;
int i;
context = g_option_context_new ("");
if (!flatpak_option_context_parse (context, options, &completion->argc, &completion->argv, 0, &dir, NULL, NULL))
return FALSE;
if (!opt_app && !opt_runtime)
opt_app = opt_runtime = TRUE;
kinds = flatpak_kinds_from_bools (opt_app, opt_runtime);
flatpak_completion_debug ("install argc %d", completion->argc);
@ -356,7 +356,7 @@ flatpak_complete_install (FlatpakCompletion *completion)
case 2: /* Name */
refs = flatpak_dir_find_remote_refs (dir, completion->argv[1], NULL, NULL,
opt_arch, opt_app, opt_runtime,
opt_arch, kinds,
NULL, &error);
if (refs == NULL)
flatpak_completion_debug ("find remote refs error: %s", error->message);
@ -371,7 +371,7 @@ flatpak_complete_install (FlatpakCompletion *completion)
case 3: /* Branch */
refs = flatpak_dir_find_remote_refs (dir, completion->argv[1], completion->argv[2], NULL,
opt_arch, opt_app, opt_runtime,
opt_arch, kinds,
NULL, &error);
if (refs == NULL)
flatpak_completion_debug ("find remote refs error: %s", error->message);

View File

@ -77,7 +77,7 @@ flatpak_builtin_make_current_app (int argc, char **argv, GCancellable *cancellab
app,
branch,
opt_arch,
TRUE, FALSE, NULL,
FLATPAK_KINDS_APP, NULL,
error);
if (ref == NULL)
return FALSE;
@ -126,7 +126,7 @@ flatpak_complete_make_current_app (FlatpakCompletion *completion)
flatpak_complete_options (completion, user_entries);
refs = flatpak_dir_find_installed_refs (dir, NULL, NULL, opt_arch,
TRUE, FALSE, &error);
FLATPAK_KINDS_APP, &error);
if (refs == NULL)
flatpak_completion_debug ("find installed refs error: %s", error->message);
for (i = 0; refs != NULL && refs[i] != NULL; i++)
@ -139,7 +139,7 @@ flatpak_complete_make_current_app (FlatpakCompletion *completion)
case 2: /* Branch */
refs = flatpak_dir_find_installed_refs (dir, completion->argv[1], NULL, opt_arch,
TRUE, FALSE, &error);
FLATPAK_KINDS_APP, &error);
if (refs == NULL)
flatpak_completion_debug ("find installed refs error: %s", error->message);
for (i = 0; refs != NULL && refs[i] != NULL; i++)

View File

@ -125,7 +125,7 @@ flatpak_complete_override (FlatpakCompletion *completion)
user_dir = flatpak_dir_get_user ();
{
g_auto(GStrv) refs = flatpak_dir_find_installed_refs (user_dir, NULL, NULL, NULL,
TRUE, FALSE, &error);
FLATPAK_KINDS_APP, &error);
if (refs == NULL)
flatpak_completion_debug ("find local refs error: %s", error->message);
for (i = 0; refs != NULL && refs[i] != NULL; i++)
@ -139,7 +139,7 @@ flatpak_complete_override (FlatpakCompletion *completion)
system_dir = flatpak_dir_get_system ();
{
g_auto(GStrv) refs = flatpak_dir_find_installed_refs (system_dir, NULL, NULL, NULL,
TRUE, FALSE, &error);
FLATPAK_KINDS_APP, &error);
if (refs == NULL)
flatpak_completion_debug ("find local refs error: %s", error->message);
for (i = 0; refs != NULL && refs[i] != NULL; i++)

View File

@ -167,7 +167,7 @@ flatpak_complete_run (FlatpakCompletion *completion)
user_dir = flatpak_dir_get_user ();
{
g_auto(GStrv) refs = flatpak_dir_find_installed_refs (user_dir, NULL, NULL, opt_arch,
TRUE, FALSE, &error);
FLATPAK_KINDS_APP, &error);
if (refs == NULL)
flatpak_completion_debug ("find local refs error: %s", error->message);
for (i = 0; refs != NULL && refs[i] != NULL; i++)
@ -181,7 +181,7 @@ flatpak_complete_run (FlatpakCompletion *completion)
system_dir = flatpak_dir_get_system ();
{
g_auto(GStrv) refs = flatpak_dir_find_installed_refs (system_dir, NULL, NULL, opt_arch,
TRUE, FALSE, &error);
FLATPAK_KINDS_APP, &error);
if (refs == NULL)
flatpak_completion_debug ("find local refs error: %s", error->message);
for (i = 0; refs != NULL && refs[i] != NULL; i++)

View File

@ -57,9 +57,10 @@ flatpak_builtin_uninstall (int argc, char **argv, GCancellable *cancellable, GEr
char *name = NULL;
char *branch = NULL;
g_autofree char *ref = NULL;
gboolean is_app;
FlatpakHelperUninstallFlags flags = 0;
g_autoptr(GPtrArray) related = NULL;
FlatpakKinds kinds;
FlatpakKinds kind;
int i;
context = g_option_context_new (_("NAME [BRANCH] - Uninstall an application"));
@ -78,17 +79,16 @@ flatpak_builtin_uninstall (int argc, char **argv, GCancellable *cancellable, GEr
if (argc > 2)
branch = argv[2];
kinds = flatpak_kinds_from_bools (opt_app, opt_runtime);
if (!flatpak_split_partial_ref_arg (name, &opt_arch, &branch, error))
return FALSE;
if (!opt_app && !opt_runtime)
opt_app = opt_runtime = TRUE;
ref = flatpak_dir_find_installed_ref (dir,
name,
branch,
opt_arch,
opt_app, opt_runtime, &is_app,
kinds, &kind,
error);
if (ref == NULL)
return FALSE;
@ -151,14 +151,14 @@ flatpak_complete_uninstall (FlatpakCompletion *completion)
g_autoptr(FlatpakDir) dir = NULL;
g_autoptr(GError) error = NULL;
g_auto(GStrv) refs = NULL;
FlatpakKinds kinds;
int i;
context = g_option_context_new ("");
if (!flatpak_option_context_parse (context, options, &completion->argc, &completion->argv, 0, &dir, NULL, NULL))
return FALSE;
if (!opt_app && !opt_runtime)
opt_app = opt_runtime = TRUE;
kinds = flatpak_kinds_from_bools (opt_app, opt_runtime);
switch (completion->argc)
{
@ -169,7 +169,7 @@ flatpak_complete_uninstall (FlatpakCompletion *completion)
flatpak_complete_options (completion, user_entries);
refs = flatpak_dir_find_installed_refs (dir, NULL, NULL, opt_arch,
opt_app, opt_runtime, &error);
kinds, &error);
if (refs == NULL)
flatpak_completion_debug ("find installed refs error: %s", error->message);
for (i = 0; refs != NULL && refs[i] != NULL; i++)
@ -182,7 +182,7 @@ flatpak_complete_uninstall (FlatpakCompletion *completion)
case 2: /* Branch */
refs = flatpak_dir_find_installed_refs (dir, completion->argv[1], NULL, opt_arch,
opt_app, opt_runtime, &error);
kinds, &error);
if (refs == NULL)
flatpak_completion_debug ("find installed refs error: %s", error->message);
for (i = 0; refs != NULL && refs[i] != NULL; i++)

View File

@ -219,6 +219,7 @@ flatpak_builtin_update (int argc,
char *branch = NULL;
gboolean failed = FALSE;
gboolean found = FALSE;
FlatpakKinds kinds;
int i;
context = g_option_context_new (_("[NAME [BRANCH]] - Update an application or runtime"));
@ -238,8 +239,7 @@ flatpak_builtin_update (int argc,
if (opt_arch == NULL)
opt_arch = (char *)flatpak_get_arch ();
if (!opt_app && !opt_runtime)
opt_app = opt_runtime = TRUE;
kinds = flatpak_kinds_from_bools (opt_app, opt_runtime);
if (opt_appstream)
return update_appstream (dir, name, cancellable, error);
@ -247,7 +247,7 @@ flatpak_builtin_update (int argc,
if (!flatpak_split_partial_ref_arg (name, &opt_arch, &branch, error))
return FALSE;
if (opt_app)
if (kinds & FLATPAK_KINDS_APP)
{
g_auto(GStrv) refs = NULL;
@ -277,7 +277,7 @@ flatpak_builtin_update (int argc,
}
}
if (opt_runtime)
if (kinds & FLATPAK_KINDS_RUNTIME)
{
g_auto(GStrv) refs = NULL;
@ -332,14 +332,14 @@ flatpak_complete_update (FlatpakCompletion *completion)
g_autoptr(FlatpakDir) dir = NULL;
g_autoptr(GError) error = NULL;
g_auto(GStrv) refs = NULL;
FlatpakKinds kinds;
int i;
context = g_option_context_new ("");
if (!flatpak_option_context_parse (context, options, &completion->argc, &completion->argv, 0, &dir, NULL, NULL))
return FALSE;
if (!opt_app && !opt_runtime)
opt_app = opt_runtime = TRUE;
kinds = flatpak_kinds_from_bools (opt_app, opt_runtime);
switch (completion->argc)
{
@ -350,7 +350,7 @@ flatpak_complete_update (FlatpakCompletion *completion)
flatpak_complete_options (completion, user_entries);
refs = flatpak_dir_find_installed_refs (dir, NULL, NULL, opt_arch,
opt_app, opt_runtime, &error);
kinds, &error);
if (refs == NULL)
flatpak_completion_debug ("find local refs error: %s", error->message);
for (i = 0; refs != NULL && refs[i] != NULL; i++)
@ -363,7 +363,7 @@ flatpak_complete_update (FlatpakCompletion *completion)
case 2: /* Branch */
refs = flatpak_dir_find_installed_refs (dir, completion->argv[1], NULL, opt_arch,
opt_app, opt_runtime, &error);
kinds, &error);
if (refs == NULL)
flatpak_completion_debug ("find remote refs error: %s", error->message);
for (i = 0; refs != NULL && refs[i] != NULL; i++)

View File

@ -21,6 +21,11 @@
#ifndef __FLATPAK_COMMON_TYPES_H__
#define __FLATPAK_COMMON_TYPES_H__
typedef enum {
FLATPAK_KINDS_APP = 1 << 0,
FLATPAK_KINDS_RUNTIME = 1 << 1,
} FlatpakKinds;
typedef struct FlatpakDir FlatpakDir;
typedef struct FlatpakDeploy FlatpakDeploy;
typedef struct FlatpakContext FlatpakContext;

View File

@ -4291,8 +4291,7 @@ find_matching_refs (GHashTable *refs,
const char *opt_name,
const char *opt_branch,
const char *opt_arch,
gboolean app,
gboolean runtime,
FlatpakKinds kinds,
GError **error)
{
g_autoptr(GPtrArray) matched_refs = NULL;
@ -4334,8 +4333,8 @@ find_matching_refs (GHashTable *refs,
is_app = g_str_has_prefix (ref, "app/");
is_runtime = g_str_has_prefix (ref, "runtime/");
if ((!app && is_app) ||
(!runtime && is_runtime) ||
if ((!(kinds & FLATPAK_KINDS_APP) && is_app) ||
(!(kinds & FLATPAK_KINDS_RUNTIME) && is_runtime) ||
(!is_app && !is_runtime))
continue;
@ -4364,8 +4363,7 @@ find_matching_ref (GHashTable *refs,
const char *name,
const char *opt_branch,
const char *opt_arch,
gboolean app,
gboolean runtime,
FlatpakKinds kinds,
GError **error)
{
const char **arches = flatpak_get_arches ();
@ -4381,7 +4379,7 @@ find_matching_ref (GHashTable *refs,
g_autoptr(GPtrArray) matched_refs = NULL;
matched_refs = find_matching_refs (refs, name, opt_branch, arches[i],
app, runtime, error);
kinds, error);
if (matched_refs == NULL)
return NULL;
@ -4420,8 +4418,7 @@ flatpak_dir_find_remote_refs (FlatpakDir *self,
const char *name,
const char *opt_branch,
const char *opt_arch,
gboolean app,
gboolean runtime,
FlatpakKinds kinds,
GCancellable *cancellable,
GError **error)
{
@ -4436,7 +4433,7 @@ flatpak_dir_find_remote_refs (FlatpakDir *self,
return NULL;
matched_refs = find_matching_refs (remote_refs, name, opt_branch,
opt_arch, app, runtime, error);
opt_arch, kinds, error);
if (matched_refs == NULL)
return NULL;
@ -4450,9 +4447,8 @@ flatpak_dir_find_remote_ref (FlatpakDir *self,
const char *name,
const char *opt_branch,
const char *opt_arch,
gboolean app,
gboolean runtime,
gboolean *is_app,
FlatpakKinds kinds,
FlatpakKinds *out_kind,
GCancellable *cancellable,
GError **error)
{
@ -4468,7 +4464,7 @@ flatpak_dir_find_remote_ref (FlatpakDir *self,
return NULL;
remote_ref = find_matching_ref (remote_refs, name, opt_branch,
opt_arch, app, runtime, &my_error);
opt_arch, kinds, &my_error);
if (remote_ref == NULL)
{
if (g_error_matches (my_error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND))
@ -4481,8 +4477,13 @@ flatpak_dir_find_remote_ref (FlatpakDir *self,
}
else
{
if (is_app)
*is_app = g_str_has_prefix (remote_ref, "app/");
if (out_kind != NULL)
{
if (g_str_has_prefix (remote_ref, "app/"))
*out_kind = FLATPAK_KINDS_APP;
else
*out_kind = FLATPAK_KINDS_RUNTIME;
}
return g_steal_pointer (&remote_ref);
}
@ -4495,10 +4496,9 @@ flatpak_dir_find_remote_ref (FlatpakDir *self,
static GHashTable *
flatpak_dir_get_all_installed_refs (FlatpakDir *self,
gboolean app,
gboolean runtime,
GError **error)
flatpak_dir_get_all_installed_refs (FlatpakDir *self,
FlatpakKinds kinds,
GError **error)
{
g_autoptr(GHashTable) local_refs = NULL;
int i;
@ -4507,7 +4507,7 @@ flatpak_dir_get_all_installed_refs (FlatpakDir *self,
return NULL;
local_refs = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
if (app)
if (kinds & FLATPAK_KINDS_APP)
{
g_auto(GStrv) app_refs = NULL;
@ -4518,7 +4518,7 @@ flatpak_dir_get_all_installed_refs (FlatpakDir *self,
g_hash_table_insert (local_refs, g_strdup (app_refs[i]),
GINT_TO_POINTER (1));
}
if (runtime)
if (kinds & FLATPAK_KINDS_RUNTIME)
{
g_auto(GStrv) runtime_refs = NULL;
@ -4538,19 +4538,18 @@ flatpak_dir_find_installed_refs (FlatpakDir *self,
const char *opt_name,
const char *opt_branch,
const char *opt_arch,
gboolean app,
gboolean runtime,
FlatpakKinds kinds,
GError **error)
{
g_autoptr(GHashTable) local_refs = NULL;
GPtrArray *matched_refs;
local_refs = flatpak_dir_get_all_installed_refs (self, app, runtime, error);
local_refs = flatpak_dir_get_all_installed_refs (self, kinds, error);
if (local_refs == NULL)
return NULL;
matched_refs = find_matching_refs (local_refs, opt_name, opt_branch,
opt_arch, app, runtime, error);
opt_arch, kinds, error);
if (matched_refs == NULL)
return NULL;
@ -4560,25 +4559,24 @@ flatpak_dir_find_installed_refs (FlatpakDir *self,
}
char *
flatpak_dir_find_installed_ref (FlatpakDir *self,
const char *opt_name,
const char *opt_branch,
const char *opt_arch,
gboolean app,
gboolean runtime,
gboolean *is_app,
GError **error)
flatpak_dir_find_installed_ref (FlatpakDir *self,
const char *opt_name,
const char *opt_branch,
const char *opt_arch,
FlatpakKinds kinds,
FlatpakKinds *out_kind,
GError **error)
{
g_autofree char *local_ref = NULL;
g_autoptr(GHashTable) local_refs = NULL;
g_autoptr(GError) my_error = NULL;
local_refs = flatpak_dir_get_all_installed_refs (self, app, runtime, error);
local_refs = flatpak_dir_get_all_installed_refs (self, kinds, error);
if (local_refs == NULL)
return NULL;
local_ref = find_matching_ref (local_refs, opt_name, opt_branch,
opt_arch, app, runtime, &my_error);
opt_arch, kinds, &my_error);
if (local_ref == NULL)
{
if (g_error_matches (my_error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND))
@ -4591,8 +4589,13 @@ flatpak_dir_find_installed_ref (FlatpakDir *self,
}
else
{
if (is_app)
*is_app = g_str_has_prefix (local_ref, "app/");
if (out_kind != NULL)
{
if (g_str_has_prefix (local_ref, "app/"))
*out_kind = FLATPAK_KINDS_APP;
else
*out_kind = FLATPAK_KINDS_RUNTIME;
}
return g_steal_pointer (&local_ref);
}

View File

@ -158,9 +158,8 @@ char * flatpak_dir_find_remote_ref (FlatpakDir *self,
const char *name,
const char *opt_branch,
const char *opt_arch,
gboolean app,
gboolean runtime,
gboolean *is_app,
FlatpakKinds kinds,
FlatpakKinds *out_kind,
GCancellable *cancellable,
GError **error);
char ** flatpak_dir_find_remote_refs (FlatpakDir *self,
@ -168,25 +167,22 @@ char ** flatpak_dir_find_remote_refs (FlatpakDir *self,
const char *name,
const char *opt_branch,
const char *opt_arch,
gboolean app,
gboolean runtime,
FlatpakKinds kinds,
GCancellable *cancellable,
GError **error);
char * flatpak_dir_find_installed_ref (FlatpakDir *self,
const char *opt_name,
const char *opt_branch,
const char *opt_arch,
gboolean app,
gboolean runtime,
gboolean *is_app,
GError **error);
char ** flatpak_dir_find_installed_refs (FlatpakDir *self,
const char *opt_name,
const char *opt_branch,
const char *opt_arch,
gboolean app,
gboolean runtime,
GError **error);
char * flatpak_dir_find_installed_ref (FlatpakDir *self,
const char *opt_name,
const char *opt_branch,
const char *opt_arch,
FlatpakKinds kinds,
FlatpakKinds *out_kind,
GError **error);
char ** flatpak_dir_find_installed_refs (FlatpakDir *self,
const char *opt_name,
const char *opt_branch,
const char *opt_arch,
FlatpakKinds kinds,
GError **error);
FlatpakDeploy *flatpak_dir_load_deployed (FlatpakDir *self,
const char *ref,
const char *checksum,

View File

@ -44,6 +44,7 @@
#include "flatpak-run.h"
#include "flatpak-proxy.h"
#include "flatpak-utils.h"
#include "flatpak-dir.h"
#include "flatpak-systemd-dbus.h"
#define DEFAULT_SHELL "/bin/sh"

View File

@ -646,6 +646,23 @@ flatpak_decompose_ref (const char *full_ref,
return g_steal_pointer (&parts);
}
FlatpakKinds
flatpak_kinds_from_bools (gboolean app, gboolean runtime)
{
FlatpakKinds kinds = 0;
if (app)
kinds |= FLATPAK_KINDS_APP;
if (runtime)
kinds |= FLATPAK_KINDS_RUNTIME;
if (kinds == 0)
kinds = FLATPAK_KINDS_APP | FLATPAK_KINDS_RUNTIME;
return kinds;
}
gboolean
flatpak_split_partial_ref_arg (char *partial_ref,
char **inout_arch,

View File

@ -24,11 +24,11 @@
#include <string.h>
#include "libglnx/libglnx.h"
#include <flatpak-common-types.h>
#include <gio/gio.h>
#include <gio/gunixfdlist.h>
#include <libsoup/soup.h>
#include "flatpak-dbus.h"
#include "flatpak-dir.h"
#include <ostree.h>
typedef enum {
@ -89,6 +89,8 @@ gboolean flatpak_is_valid_branch (const char *string,
char **flatpak_decompose_ref (const char *ref,
GError **error);
FlatpakKinds flatpak_kinds_from_bools (gboolean app, gboolean runtime);
gboolean flatpak_split_partial_ref_arg (char *partial_ref,
char **inout_arch,
char **inout_branch,

View File

@ -17,6 +17,7 @@
#include "flatpak-db.h"
#include "flatpak-dbus.h"
#include "flatpak-utils.h"
#include "flatpak-dir.h"
#include "flatpak-portal-error.h"
#include "permission-store/permission-store-dbus.h"
#include "xdp-fuse.h"