summaryrefslogtreecommitdiff
path: root/lib/xdg-app-installation.h
blob: 7a8bea5edb96433b80e8aaf4494ab2bcde084472 (plain)
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
213
214
215
216
217
218
219
220
221
/*
 * Copyright © 2015 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 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>
 */

#if !defined(__XDG_APP_H_INSIDE__) && !defined(XDG_APP_COMPILATION)
#error "Only <xdg-app.h> can be included directly."
#endif

#ifndef __XDG_APP_INSTALLATION_H__
#define __XDG_APP_INSTALLATION_H__

typedef struct _XdgAppInstallation XdgAppInstallation;

#include <gio/gio.h>
#include <xdg-app-installed-ref.h>
#include <xdg-app-remote.h>

#define XDG_APP_TYPE_INSTALLATION xdg_app_installation_get_type ()
#define XDG_APP_INSTALLATION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XDG_APP_TYPE_INSTALLATION, XdgAppInstallation))
#define XDG_APP_IS_INSTALLATION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XDG_APP_TYPE_INSTALLATION))

XDG_APP_EXTERN GType xdg_app_installation_get_type (void);

struct _XdgAppInstallation
{
  GObject parent;
};

typedef struct
{
  GObjectClass parent_class;
} XdgAppInstallationClass;

/**
 * XdgAppUpdateFlags:
 * @XDG_APP_UPDATE_FLAGS_NONE: Fetch remote builds and install the latest one (default)
 * @XDG_APP_UPDATE_FLAGS_NO_DEPLOY: Don't install any new builds that might be fetched
 * @XDG_APP_UPDATE_FLAGS_NO_PULL: Don't try to fetch new builds from the remote repo
 *
 * Flags to alter the behavior of xdg_app_installation_update().
 */
typedef enum {
  XDG_APP_UPDATE_FLAGS_NONE      = 0,
  XDG_APP_UPDATE_FLAGS_NO_DEPLOY = (1 << 0),
  XDG_APP_UPDATE_FLAGS_NO_PULL   = (1 << 1),
} XdgAppUpdateFlags;


#ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC
G_DEFINE_AUTOPTR_CLEANUP_FUNC (XdgAppInstallation, g_object_unref)
#endif

XDG_APP_EXTERN const char  *xdg_app_get_default_arch (void);

XDG_APP_EXTERN XdgAppInstallation *xdg_app_installation_new_system (GCancellable *cancellable,
                                                                    GError      **error);
XDG_APP_EXTERN XdgAppInstallation *xdg_app_installation_new_user (GCancellable *cancellable,
                                                                  GError      **error);
XDG_APP_EXTERN XdgAppInstallation *xdg_app_installation_new_for_path (GFile        *path,
                                                                      gboolean      user,
                                                                      GCancellable *cancellable,
                                                                      GError      **error);

/**
 * XdgAppProgressCallback:
 * @status: A status string, suitable for display
 * @progress: percentage of completion
 * @estimating: whether @progress is just an estimate
 * @user_data: User data passed to the caller
 *
 * The progress callback is called repeatedly during long-running operations
 * such as installations or updates, and can be used to update progress information
 * in a user interface.
 *
 * The callback occurs in the thread-default context of the caller.
 */
typedef void (*XdgAppProgressCallback)(const char *status,
                                       guint       progress,
                                       gboolean    estimating,
                                       gpointer    user_data);

XDG_APP_EXTERN gboolean             xdg_app_installation_get_is_user (XdgAppInstallation *self);
XDG_APP_EXTERN GFile               *xdg_app_installation_get_path (XdgAppInstallation *self);
XDG_APP_EXTERN gboolean             xdg_app_installation_launch (XdgAppInstallation *self,
                                                                 const char         *name,
                                                                 const char         *arch,
                                                                 const char         *branch,
                                                                 const char         *commit,
                                                                 GCancellable       *cancellable,
                                                                 GError            **error);
XDG_APP_EXTERN GFileMonitor        *xdg_app_installation_create_monitor (XdgAppInstallation *self,
                                                                         GCancellable       *cancellable,
                                                                         GError            **error);
XDG_APP_EXTERN GPtrArray           *xdg_app_installation_list_installed_refs (XdgAppInstallation *self,
                                                                              GCancellable       *cancellable,
                                                                              GError            **error);
XDG_APP_EXTERN GPtrArray           *xdg_app_installation_list_installed_refs_by_kind (XdgAppInstallation *self,
                                                                                      XdgAppRefKind       kind,
                                                                                      GCancellable       *cancellable,
                                                                                      GError            **error);
XDG_APP_EXTERN GPtrArray           *xdg_app_installation_list_installed_refs_for_update (XdgAppInstallation *self,
                                                                                         GCancellable       *cancellable,
                                                                                         GError            **error);
XDG_APP_EXTERN XdgAppInstalledRef * xdg_app_installation_get_installed_ref (XdgAppInstallation *self,
                                                                            XdgAppRefKind       kind,
                                                                            const char         *name,
                                                                            const char         *arch,
                                                                            const char         *branch,
                                                                            GCancellable       *cancellable,
                                                                            GError            **error);
XDG_APP_EXTERN XdgAppInstalledRef * xdg_app_installation_get_current_installed_app (XdgAppInstallation *self,
                                                                                    const char         *name,
                                                                                    GCancellable       *cancellable,
                                                                                    GError            **error);
XDG_APP_EXTERN GPtrArray           *xdg_app_installation_list_remotes (XdgAppInstallation *self,
                                                                       GCancellable       *cancellable,
                                                                       GError            **error);
XDG_APP_EXTERN XdgAppRemote        *xdg_app_installation_get_remote_by_name (XdgAppInstallation *self,
                                                                             const gchar        *name,
                                                                             GCancellable       *cancellable,
                                                                             GError            **error);
XDG_APP_EXTERN char *              xdg_app_installation_load_app_overrides (XdgAppInstallation *self,
                                                                            const char         *app_id,
                                                                            GCancellable       *cancellable,
                                                                            GError            **error);
XDG_APP_EXTERN XdgAppInstalledRef * xdg_app_installation_install (XdgAppInstallation    *self,
                                                                  const char            *remote_name,
                                                                  XdgAppRefKind          kind,
                                                                  const char            *name,
                                                                  const char            *arch,
                                                                  const char            *branch,
                                                                  XdgAppProgressCallback progress,
                                                                  gpointer               progress_data,
                                                                  GCancellable          *cancellable,
                                                                  GError               **error);
XDG_APP_EXTERN XdgAppInstalledRef * xdg_app_installation_update (XdgAppInstallation    *self,
                                                                 XdgAppUpdateFlags      flags,
                                                                 XdgAppRefKind          kind,
                                                                 const char            *name,
                                                                 const char            *arch,
                                                                 const char            *branch,
                                                                 XdgAppProgressCallback progress,
                                                                 gpointer               progress_data,
                                                                 GCancellable          *cancellable,
                                                                 GError               **error);
XDG_APP_EXTERN XdgAppInstalledRef * xdg_app_installation_install_bundle (XdgAppInstallation    *self,
                                                                         GFile                 *file,
                                                                         XdgAppProgressCallback progress,
                                                                         gpointer               progress_data,
                                                                         GCancellable          *cancellable,
                                                                         GError               **error);
XDG_APP_EXTERN gboolean             xdg_app_installation_uninstall (XdgAppInstallation    *self,
                                                                    XdgAppRefKind          kind,
                                                                    const char            *name,
                                                                    const char            *arch,
                                                                    const char            *branch,
                                                                    XdgAppProgressCallback progress,
                                                                    gpointer               progress_data,
                                                                    GCancellable          *cancellable,
                                                                    GError               **error);

XDG_APP_EXTERN gboolean          xdg_app_installation_fetch_remote_size_sync (XdgAppInstallation *self,
                                                                              const char         *remote_name,
                                                                              const char         *commit,
                                                                              guint64            *download_size,
                                                                              guint64            *installed_size,
                                                                              GCancellable       *cancellable,
                                                                              GError            **error);
XDG_APP_EXTERN gboolean          xdg_app_installation_fetch_remote_size_sync2 (XdgAppInstallation *self,
                                                                               const char         *remote_name,
                                                                               XdgAppRef          *ref,
                                                                               guint64            *download_size,
                                                                               guint64            *installed_size,
                                                                               GCancellable       *cancellable,
                                                                               GError            **error);
XDG_APP_EXTERN GBytes        *   xdg_app_installation_fetch_remote_metadata_sync (XdgAppInstallation *self,
                                                                                  const char         *remote_name,
                                                                                  const char         *commit,
                                                                                  GCancellable       *cancellable,
                                                                                  GError            **error);
XDG_APP_EXTERN GBytes        *   xdg_app_installation_fetch_remote_metadata_sync2 (XdgAppInstallation *self,
                                                                                   const char         *remote_name,
                                                                                   XdgAppRef          *ref,
                                                                                   GCancellable       *cancellable,
                                                                                   GError            **error);
XDG_APP_EXTERN GPtrArray    *    xdg_app_installation_list_remote_refs_sync (XdgAppInstallation *self,
                                                                             const char         *remote_name,
                                                                             GCancellable       *cancellable,
                                                                             GError            **error);
XDG_APP_EXTERN XdgAppRemoteRef  *xdg_app_installation_fetch_remote_ref_sync (XdgAppInstallation *self,
                                                                             const char         *remote_name,
                                                                             XdgAppRefKind       kind,
                                                                             const char         *name,
                                                                             const char         *arch,
                                                                             const char         *branch,
                                                                             GCancellable       *cancellable,
                                                                             GError            **error);
XDG_APP_EXTERN gboolean          xdg_app_installation_update_appstream_sync (XdgAppInstallation *self,
                                                                             const char         *remote_name,
                                                                             const char         *arch,
                                                                             gboolean           *out_changed,
                                                                             GCancellable       *cancellable,
                                                                             GError            **error);

#endif /* __XDG_APP_INSTALLATION_H__ */