mirror of
https://github.com/flatpak/flatpak.git
synced 2026-01-26 14:13:26 +00:00
Extract FlatpakContext to a separate file
This is basically a code motion only, no changes to behaviour. Closes: #1374 Approved by: alexlarsson
This commit is contained in:
parent
d745b14d60
commit
447a8d0537
@ -39,6 +39,8 @@ libflatpak_common_la_SOURCES = \
|
||||
common/flatpak-dir.h \
|
||||
common/flatpak-run.c \
|
||||
common/flatpak-run.h \
|
||||
common/flatpak-context.c \
|
||||
common/flatpak-context.h \
|
||||
common/flatpak-portal-error.c \
|
||||
common/flatpak-portal-error.h \
|
||||
common/flatpak-utils.c \
|
||||
|
||||
@ -28,7 +28,6 @@ typedef enum {
|
||||
|
||||
typedef struct FlatpakDir FlatpakDir;
|
||||
typedef struct FlatpakDeploy FlatpakDeploy;
|
||||
typedef struct FlatpakContext FlatpakContext;
|
||||
typedef struct FlatpakOciRegistry FlatpakOciRegistry;
|
||||
typedef struct _FlatpakOciManifest FlatpakOciManifest;
|
||||
|
||||
|
||||
1654
common/flatpak-context.c
Normal file
1654
common/flatpak-context.c
Normal file
File diff suppressed because it is too large
Load Diff
116
common/flatpak-context.h
Normal file
116
common/flatpak-context.h
Normal file
@ -0,0 +1,116 @@
|
||||
/*
|
||||
* Copyright © 2014-2018 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_CONTEXT_H__
|
||||
#define __FLATPAK_CONTEXT_H__
|
||||
|
||||
#include "libglnx/libglnx.h"
|
||||
#include "dbus-proxy/flatpak-proxy.h"
|
||||
#include "flatpak-utils.h"
|
||||
|
||||
typedef struct FlatpakContext FlatpakContext;
|
||||
|
||||
typedef enum {
|
||||
FLATPAK_CONTEXT_SHARED_NETWORK = 1 << 0,
|
||||
FLATPAK_CONTEXT_SHARED_IPC = 1 << 1,
|
||||
} FlatpakContextShares;
|
||||
|
||||
/* In numerical order of more privs */
|
||||
typedef enum {
|
||||
FLATPAK_FILESYSTEM_MODE_READ_ONLY = 1,
|
||||
FLATPAK_FILESYSTEM_MODE_READ_WRITE = 2,
|
||||
FLATPAK_FILESYSTEM_MODE_CREATE = 3,
|
||||
} FlatpakFilesystemMode;
|
||||
|
||||
typedef enum {
|
||||
FLATPAK_CONTEXT_SOCKET_X11 = 1 << 0,
|
||||
FLATPAK_CONTEXT_SOCKET_WAYLAND = 1 << 1,
|
||||
FLATPAK_CONTEXT_SOCKET_PULSEAUDIO = 1 << 2,
|
||||
FLATPAK_CONTEXT_SOCKET_SESSION_BUS = 1 << 3,
|
||||
FLATPAK_CONTEXT_SOCKET_SYSTEM_BUS = 1 << 4,
|
||||
} FlatpakContextSockets;
|
||||
|
||||
typedef enum {
|
||||
FLATPAK_CONTEXT_DEVICE_DRI = 1 << 0,
|
||||
FLATPAK_CONTEXT_DEVICE_ALL = 1 << 1,
|
||||
FLATPAK_CONTEXT_DEVICE_KVM = 1 << 2,
|
||||
} FlatpakContextDevices;
|
||||
|
||||
typedef enum {
|
||||
FLATPAK_CONTEXT_FEATURE_DEVEL = 1 << 0,
|
||||
FLATPAK_CONTEXT_FEATURE_MULTIARCH = 1 << 1,
|
||||
} FlatpakContextFeatures;
|
||||
|
||||
struct FlatpakContext
|
||||
{
|
||||
FlatpakContextShares shares;
|
||||
FlatpakContextShares shares_valid;
|
||||
FlatpakContextSockets sockets;
|
||||
FlatpakContextSockets sockets_valid;
|
||||
FlatpakContextDevices devices;
|
||||
FlatpakContextDevices devices_valid;
|
||||
FlatpakContextFeatures features;
|
||||
FlatpakContextFeatures features_valid;
|
||||
GHashTable *env_vars;
|
||||
GHashTable *persistent;
|
||||
GHashTable *filesystems;
|
||||
GHashTable *session_bus_policy;
|
||||
GHashTable *system_bus_policy;
|
||||
GHashTable *generic_policy;
|
||||
};
|
||||
|
||||
extern const char *flatpak_context_sockets[];
|
||||
extern const char *flatpak_context_devices[];
|
||||
extern const char *flatpak_context_features[];
|
||||
extern const char *flatpak_context_shares[];
|
||||
|
||||
FlatpakContext *flatpak_context_new (void);
|
||||
void flatpak_context_free (FlatpakContext *context);
|
||||
void flatpak_context_merge (FlatpakContext *context,
|
||||
FlatpakContext *other);
|
||||
GOptionGroup *flatpak_context_get_options (FlatpakContext *context);
|
||||
void flatpak_context_complete (FlatpakContext *context,
|
||||
FlatpakCompletion *completion);
|
||||
gboolean flatpak_context_load_metadata (FlatpakContext *context,
|
||||
GKeyFile *metakey,
|
||||
GError **error);
|
||||
void flatpak_context_save_metadata (FlatpakContext *context,
|
||||
gboolean flatten,
|
||||
GKeyFile *metakey);
|
||||
void flatpak_context_allow_host_fs (FlatpakContext *context);
|
||||
void flatpak_context_set_session_bus_policy (FlatpakContext *context,
|
||||
const char *name,
|
||||
FlatpakPolicy policy);
|
||||
void flatpak_context_set_system_bus_policy (FlatpakContext *context,
|
||||
const char *name,
|
||||
FlatpakPolicy policy);
|
||||
void flatpak_context_to_args (FlatpakContext *context,
|
||||
GPtrArray *args);
|
||||
gboolean flatpak_context_get_needs_session_bus_proxy (FlatpakContext *context);
|
||||
gboolean flatpak_context_get_needs_system_bus_proxy (FlatpakContext *context);
|
||||
|
||||
FlatpakContext *flatpak_context_load_for_deploy (FlatpakDeploy *deploy,
|
||||
GError **error);
|
||||
FlatpakContext *flatpak_context_load_for_app (const char *app_id,
|
||||
GError **error);
|
||||
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (FlatpakContext, flatpak_context_free)
|
||||
|
||||
#endif /* __FLATPAK_CONTEXT_H__ */
|
||||
@ -25,6 +25,7 @@
|
||||
|
||||
#include "libglnx/libglnx.h"
|
||||
#include <flatpak-common-types.h>
|
||||
#include <flatpak-context.h>
|
||||
|
||||
#define FLATPAK_TYPE_DIR flatpak_dir_get_type ()
|
||||
#define FLATPAK_DIR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), FLATPAK_TYPE_DIR, FlatpakDir))
|
||||
|
||||
1502
common/flatpak-run.c
1502
common/flatpak-run.c
File diff suppressed because it is too large
Load Diff
@ -22,8 +22,8 @@
|
||||
#define __FLATPAK_RUN_H__
|
||||
|
||||
#include "libglnx/libglnx.h"
|
||||
#include "dbus-proxy/flatpak-proxy.h"
|
||||
#include "flatpak-common-types.h"
|
||||
#include "flatpak-context.h"
|
||||
#include "flatpak-utils.h"
|
||||
|
||||
gboolean flatpak_run_in_transient_unit (const char *app_id,
|
||||
@ -95,11 +95,6 @@ gboolean flatpak_run_in_transient_unit (const char *app_id,
|
||||
#define FLATPAK_METADATA_KEY_PRIORITY "priority"
|
||||
#define FLATPAK_METADATA_KEY_REF "ref"
|
||||
|
||||
extern const char *flatpak_context_sockets[];
|
||||
extern const char *flatpak_context_devices[];
|
||||
extern const char *flatpak_context_features[];
|
||||
extern const char *flatpak_context_shares[];
|
||||
|
||||
typedef struct {
|
||||
GPtrArray *argv;
|
||||
GArray *fds;
|
||||
@ -138,39 +133,6 @@ void flatpak_bwrap_add_bind_arg (FlatpakBwrap *bwrap,
|
||||
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (FlatpakBwrap, flatpak_bwrap_free)
|
||||
|
||||
|
||||
FlatpakContext *flatpak_context_new (void);
|
||||
void flatpak_context_free (FlatpakContext *context);
|
||||
void flatpak_context_merge (FlatpakContext *context,
|
||||
FlatpakContext *other);
|
||||
GOptionGroup *flatpak_context_get_options (FlatpakContext *context);
|
||||
void flatpak_context_complete (FlatpakContext *context,
|
||||
FlatpakCompletion *completion);
|
||||
gboolean flatpak_context_load_metadata (FlatpakContext *context,
|
||||
GKeyFile *metakey,
|
||||
GError **error);
|
||||
void flatpak_context_save_metadata (FlatpakContext *context,
|
||||
gboolean flatten,
|
||||
GKeyFile *metakey);
|
||||
void flatpak_context_allow_host_fs (FlatpakContext *context);
|
||||
void flatpak_context_set_session_bus_policy (FlatpakContext *context,
|
||||
const char *name,
|
||||
FlatpakPolicy policy);
|
||||
void flatpak_context_set_system_bus_policy (FlatpakContext *context,
|
||||
const char *name,
|
||||
FlatpakPolicy policy);
|
||||
void flatpak_context_to_args (FlatpakContext *context,
|
||||
GPtrArray *args);
|
||||
gboolean flatpak_context_get_needs_session_bus_proxy (FlatpakContext *context);
|
||||
gboolean flatpak_context_get_needs_system_bus_proxy (FlatpakContext *context);
|
||||
|
||||
FlatpakContext *flatpak_context_load_for_deploy (FlatpakDeploy *deploy,
|
||||
GError **error);
|
||||
FlatpakContext *flatpak_context_load_for_app (const char *app_id,
|
||||
GError **error);
|
||||
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (FlatpakContext, flatpak_context_free)
|
||||
|
||||
typedef enum {
|
||||
FLATPAK_RUN_FLAG_DEVEL = (1 << 0),
|
||||
FLATPAK_RUN_FLAG_BACKGROUND = (1 << 1),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user