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
|
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
* vi:set noexpandtab tabstop=8 shiftwidth=8:
*
* Copyright (C) 2017-2018 Richard Hughes <richard@hughsie.com>
*
* SPDX-License-Identifier: GPL-2.0+
*/
#include "config.h"
#include <string.h>
#include "gs-flatpak-app.h"
const gchar *
gs_flatpak_app_get_ref_name (GsApp *app)
{
return gs_app_get_metadata_item (app, "flatpak::RefName");
}
const gchar *
gs_flatpak_app_get_ref_arch (GsApp *app)
{
return gs_app_get_metadata_item (app, "flatpak::RefArch");
}
const gchar *
gs_flatpak_app_get_commit (GsApp *app)
{
return gs_app_get_metadata_item (app, "flatpak::Commit");
}
GsFlatpakAppFileKind
gs_flatpak_app_get_file_kind (GsApp *app)
{
GVariant *tmp = gs_app_get_metadata_variant (app, "flatpak::FileKind");
if (tmp == NULL)
return GS_FLATPAK_APP_FILE_KIND_UNKNOWN;
return g_variant_get_uint32 (tmp);
}
const gchar *
gs_flatpak_app_get_runtime_url (GsApp *app)
{
return gs_app_get_metadata_item (app, "flatpak::RuntimeUrl");
}
FlatpakRefKind
gs_flatpak_app_get_ref_kind (GsApp *app)
{
GVariant *tmp = gs_app_get_metadata_variant (app, "flatpak::RefKind");
if (tmp == NULL)
return FLATPAK_REF_KIND_APP;
return g_variant_get_uint32 (tmp);
}
const gchar *
gs_flatpak_app_get_ref_kind_as_str (GsApp *app)
{
FlatpakRefKind ref_kind = gs_flatpak_app_get_ref_kind (app);
if (ref_kind == FLATPAK_REF_KIND_APP)
return "app";
if (ref_kind == FLATPAK_REF_KIND_RUNTIME)
return "runtime";
return NULL;
}
const gchar *
gs_flatpak_app_get_object_id (GsApp *app)
{
return gs_app_get_metadata_item (app, "flatpak::ObjectID");
}
const gchar *
gs_flatpak_app_get_repo_gpgkey (GsApp *app)
{
return gs_app_get_metadata_item (app, "flatpak::RepoGpgKey");
}
const gchar *
gs_flatpak_app_get_repo_url (GsApp *app)
{
return gs_app_get_metadata_item (app, "flatpak::RepoUrl");
}
gchar *
gs_flatpak_app_get_ref_display (GsApp *app)
{
const gchar *ref_kind_as_str = gs_flatpak_app_get_ref_kind_as_str (app);
const gchar *ref_name = gs_flatpak_app_get_ref_name (app);
const gchar *ref_arch = gs_flatpak_app_get_ref_arch (app);
const gchar *ref_branch = gs_app_get_branch (app);
g_return_val_if_fail (ref_kind_as_str != NULL, NULL);
g_return_val_if_fail (ref_name != NULL, NULL);
g_return_val_if_fail (ref_arch != NULL, NULL);
g_return_val_if_fail (ref_branch != NULL, NULL);
return g_strdup_printf ("%s/%s/%s/%s",
ref_kind_as_str,
ref_name,
ref_arch,
ref_branch);
}
void
gs_flatpak_app_set_ref_name (GsApp *app, const gchar *val)
{
gs_app_set_metadata (app, "flatpak::RefName", val);
}
void
gs_flatpak_app_set_ref_arch (GsApp *app, const gchar *val)
{
gs_app_set_metadata (app, "flatpak::RefArch", val);
}
void
gs_flatpak_app_set_commit (GsApp *app, const gchar *val)
{
gs_app_set_metadata (app, "flatpak::Commit", val);
}
void
gs_flatpak_app_set_file_kind (GsApp *app, GsFlatpakAppFileKind file_kind)
{
g_autoptr(GVariant) tmp = g_variant_new_uint32 (file_kind);
gs_app_set_metadata_variant (app, "flatpak::FileKind", tmp);
}
void
gs_flatpak_app_set_runtime_url (GsApp *app, const gchar *val)
{
gs_app_set_metadata (app, "flatpak::RuntimeUrl", val);
}
void
gs_flatpak_app_set_ref_kind (GsApp *app, FlatpakRefKind ref_kind)
{
g_autoptr(GVariant) tmp = g_variant_new_uint32 (ref_kind);
gs_app_set_metadata_variant (app, "flatpak::RefKind", tmp);
}
void
gs_flatpak_app_set_object_id (GsApp *app, const gchar *val)
{
gs_app_set_metadata (app, "flatpak::ObjectID", val);
}
void
gs_flatpak_app_set_repo_gpgkey (GsApp *app, const gchar *val)
{
gs_app_set_metadata (app, "flatpak::RepoGpgKey", val);
}
void
gs_flatpak_app_set_repo_url (GsApp *app, const gchar *val)
{
gs_app_set_metadata (app, "flatpak::RepoUrl", val);
}
GsApp *
gs_flatpak_app_new (const gchar *id)
{
return GS_APP (g_object_new (GS_TYPE_APP, "id", id, NULL));
}
void
gs_flatpak_app_set_main_app_ref_name (GsApp *app, const gchar *main_app_ref)
{
gs_app_set_metadata (app, "flatpak::mainApp", main_app_ref);
}
const gchar *
gs_flatpak_app_get_main_app_ref_name (GsApp *app)
{
return gs_app_get_metadata_item (app, "flatpak::mainApp");
}
|