2018-09-28 10:11:11 +02:00
|
|
|
|
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
|
|
|
|
|
*
|
|
|
|
|
* Copyright © 2018 Endless Mobile, Inc.
|
|
|
|
|
*
|
|
|
|
|
* This library 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, write to the Free Software
|
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
|
*
|
|
|
|
|
* Authors:
|
|
|
|
|
* - Philip Withnall <withnall@endlessm.com>
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <gio/gio.h>
|
|
|
|
|
#include <glib.h>
|
|
|
|
|
#include <glib-object.h>
|
|
|
|
|
|
|
|
|
|
G_BEGIN_DECLS
|
|
|
|
|
|
|
|
|
|
/**
|
2019-02-26 18:43:56 +01:00
|
|
|
|
* MctAppFilterError:
|
|
|
|
|
* @MCT_APP_FILTER_ERROR_INVALID_USER: Given user ID doesn’t exist
|
|
|
|
|
* @MCT_APP_FILTER_ERROR_PERMISSION_DENIED: Not authorized to query the app
|
2018-09-28 10:11:11 +02:00
|
|
|
|
* filter for the given user
|
2019-02-26 18:43:56 +01:00
|
|
|
|
* @MCT_APP_FILTER_ERROR_INVALID_DATA: The data stored in the app filter for
|
2018-10-09 12:24:25 +02:00
|
|
|
|
* a user is inconsistent or invalid
|
2018-09-28 10:11:11 +02:00
|
|
|
|
*
|
2019-02-26 18:43:56 +01:00
|
|
|
|
* Errors which can be returned by mct_get_app_filter_async().
|
2018-09-28 10:11:11 +02:00
|
|
|
|
*
|
2019-02-26 18:43:56 +01:00
|
|
|
|
* Since: 0.2.0
|
2018-09-28 10:11:11 +02:00
|
|
|
|
*/
|
|
|
|
|
typedef enum
|
|
|
|
|
{
|
2019-02-26 18:43:56 +01:00
|
|
|
|
MCT_APP_FILTER_ERROR_INVALID_USER,
|
|
|
|
|
MCT_APP_FILTER_ERROR_PERMISSION_DENIED,
|
|
|
|
|
MCT_APP_FILTER_ERROR_INVALID_DATA,
|
|
|
|
|
} MctAppFilterError;
|
2018-09-28 10:11:11 +02:00
|
|
|
|
|
2019-02-26 18:43:56 +01:00
|
|
|
|
GQuark mct_app_filter_error_quark (void);
|
|
|
|
|
#define MCT_APP_FILTER_ERROR mct_app_filter_error_quark ()
|
2018-09-28 10:11:11 +02:00
|
|
|
|
|
2018-10-09 12:24:25 +02:00
|
|
|
|
/**
|
2019-02-26 18:43:56 +01:00
|
|
|
|
* MctAppFilterOarsValue:
|
|
|
|
|
* @MCT_APP_FILTER_OARS_VALUE_UNKNOWN: Unknown value for the given
|
2018-10-09 12:24:25 +02:00
|
|
|
|
* section.
|
2019-02-26 18:43:56 +01:00
|
|
|
|
* @MCT_APP_FILTER_OARS_VALUE_NONE: No rating for the given section.
|
|
|
|
|
* @MCT_APP_FILTER_OARS_VALUE_MILD: Mild rating for the given section.
|
|
|
|
|
* @MCT_APP_FILTER_OARS_VALUE_MODERATE: Moderate rating for the given
|
2018-10-09 12:24:25 +02:00
|
|
|
|
* section.
|
2019-02-26 18:43:56 +01:00
|
|
|
|
* @MCT_APP_FILTER_OARS_VALUE_INTENSE: Intense rating for the given
|
2018-10-09 12:24:25 +02:00
|
|
|
|
* section.
|
|
|
|
|
*
|
|
|
|
|
* Rating values of the intensity of a given section in an app or game.
|
|
|
|
|
* These are directly equivalent to the values in the #AsContentRatingValue
|
|
|
|
|
* enumeration in libappstream.
|
|
|
|
|
*
|
2019-02-26 18:43:56 +01:00
|
|
|
|
* Since: 0.2.0
|
2018-10-09 12:24:25 +02:00
|
|
|
|
*/
|
|
|
|
|
typedef enum
|
|
|
|
|
{
|
2019-02-26 18:43:56 +01:00
|
|
|
|
MCT_APP_FILTER_OARS_VALUE_UNKNOWN,
|
|
|
|
|
MCT_APP_FILTER_OARS_VALUE_NONE,
|
|
|
|
|
MCT_APP_FILTER_OARS_VALUE_MILD,
|
|
|
|
|
MCT_APP_FILTER_OARS_VALUE_MODERATE,
|
|
|
|
|
MCT_APP_FILTER_OARS_VALUE_INTENSE,
|
|
|
|
|
} MctAppFilterOarsValue;
|
2018-10-09 12:24:25 +02:00
|
|
|
|
|
2019-03-19 17:55:11 +01:00
|
|
|
|
/**
|
|
|
|
|
* MctGetAppFilterFlags:
|
|
|
|
|
* @MCT_GET_APP_FILTER_FLAGS_NONE: No flags set.
|
|
|
|
|
* @MCT_GET_APP_FILTER_FLAGS_INTERACTIVE: Allow interactive polkit dialogs when
|
|
|
|
|
* requesting authorization.
|
|
|
|
|
*
|
|
|
|
|
* Flags to control the behaviour of mct_get_app_filter() and
|
|
|
|
|
* mct_get_app_filter_async().
|
|
|
|
|
*
|
|
|
|
|
* Since: 0.3.0
|
|
|
|
|
*/
|
|
|
|
|
typedef enum
|
|
|
|
|
{
|
|
|
|
|
MCT_GET_APP_FILTER_FLAGS_NONE = 0,
|
|
|
|
|
MCT_GET_APP_FILTER_FLAGS_INTERACTIVE,
|
|
|
|
|
} MctGetAppFilterFlags;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* MctSetAppFilterFlags:
|
|
|
|
|
* @MCT_SET_APP_FILTER_FLAGS_NONE: No flags set.
|
|
|
|
|
* @MCT_SET_APP_FILTER_FLAGS_INTERACTIVE: Allow interactive polkit dialogs when
|
|
|
|
|
* requesting authorization.
|
|
|
|
|
*
|
|
|
|
|
* Flags to control the behaviour of mct_set_app_filter() and
|
|
|
|
|
* mct_set_app_filter_async().
|
|
|
|
|
*
|
|
|
|
|
* Since: 0.3.0
|
|
|
|
|
*/
|
|
|
|
|
typedef enum
|
|
|
|
|
{
|
|
|
|
|
MCT_SET_APP_FILTER_FLAGS_NONE = 0,
|
|
|
|
|
MCT_SET_APP_FILTER_FLAGS_INTERACTIVE,
|
|
|
|
|
} MctSetAppFilterFlags;
|
|
|
|
|
|
2018-09-28 10:11:11 +02:00
|
|
|
|
/**
|
2019-02-26 18:43:56 +01:00
|
|
|
|
* MctAppFilter:
|
2018-09-28 10:11:11 +02:00
|
|
|
|
*
|
2019-02-26 18:43:56 +01:00
|
|
|
|
* #MctAppFilter is an opaque, immutable structure which contains a snapshot of
|
2018-09-28 10:11:11 +02:00
|
|
|
|
* the app filtering settings for a user at a given time. This includes a list
|
|
|
|
|
* of apps which are explicitly banned or allowed to be run by that user.
|
|
|
|
|
*
|
|
|
|
|
* Typically, app filter settings can only be changed by the administrator, and
|
|
|
|
|
* are read-only for non-administrative users. The precise policy is set using
|
|
|
|
|
* polkit.
|
|
|
|
|
*
|
2019-02-26 18:43:56 +01:00
|
|
|
|
* Since: 0.2.0
|
2018-09-28 10:11:11 +02:00
|
|
|
|
*/
|
2019-02-26 18:43:56 +01:00
|
|
|
|
typedef struct _MctAppFilter MctAppFilter;
|
|
|
|
|
GType mct_app_filter_get_type (void);
|
2018-09-28 10:11:11 +02:00
|
|
|
|
|
2019-02-26 18:43:56 +01:00
|
|
|
|
MctAppFilter *mct_app_filter_ref (MctAppFilter *filter);
|
|
|
|
|
void mct_app_filter_unref (MctAppFilter *filter);
|
2018-09-28 10:11:11 +02:00
|
|
|
|
|
2019-02-26 18:43:56 +01:00
|
|
|
|
G_DEFINE_AUTOPTR_CLEANUP_FUNC (MctAppFilter, mct_app_filter_unref)
|
2018-09-28 10:11:11 +02:00
|
|
|
|
|
2019-02-26 18:43:56 +01:00
|
|
|
|
uid_t mct_app_filter_get_user_id (MctAppFilter *filter);
|
|
|
|
|
gboolean mct_app_filter_is_path_allowed (MctAppFilter *filter,
|
2018-10-12 06:59:04 +02:00
|
|
|
|
const gchar *path);
|
2019-02-26 18:43:56 +01:00
|
|
|
|
gboolean mct_app_filter_is_flatpak_ref_allowed (MctAppFilter *filter,
|
2018-11-08 18:54:22 +01:00
|
|
|
|
const gchar *app_ref);
|
2019-02-26 18:43:56 +01:00
|
|
|
|
gboolean mct_app_filter_is_flatpak_app_allowed (MctAppFilter *filter,
|
2018-11-14 16:17:18 +01:00
|
|
|
|
const gchar *app_id);
|
2019-02-26 18:43:56 +01:00
|
|
|
|
gboolean mct_app_filter_is_appinfo_allowed (MctAppFilter *filter,
|
2018-11-26 15:48:45 +01:00
|
|
|
|
GAppInfo *app_info);
|
2018-09-28 10:11:11 +02:00
|
|
|
|
|
2019-02-26 18:43:56 +01:00
|
|
|
|
const gchar **mct_app_filter_get_oars_sections (MctAppFilter *filter);
|
|
|
|
|
MctAppFilterOarsValue mct_app_filter_get_oars_value (MctAppFilter *filter,
|
2018-11-08 18:20:11 +01:00
|
|
|
|
const gchar *oars_section);
|
2018-10-09 12:24:25 +02:00
|
|
|
|
|
2019-02-26 18:43:56 +01:00
|
|
|
|
gboolean mct_app_filter_is_user_installation_allowed (MctAppFilter *filter);
|
|
|
|
|
gboolean mct_app_filter_is_system_installation_allowed (MctAppFilter *filter);
|
2018-11-13 12:30:19 +01:00
|
|
|
|
|
2019-02-26 18:43:56 +01:00
|
|
|
|
MctAppFilter *mct_get_app_filter (GDBusConnection *connection,
|
2018-10-31 12:01:44 +01:00
|
|
|
|
uid_t user_id,
|
2019-03-19 17:55:11 +01:00
|
|
|
|
MctGetAppFilterFlags flags,
|
2018-10-31 12:01:44 +01:00
|
|
|
|
GCancellable *cancellable,
|
|
|
|
|
GError **error);
|
2019-02-26 18:43:56 +01:00
|
|
|
|
void mct_get_app_filter_async (GDBusConnection *connection,
|
2018-09-28 10:11:11 +02:00
|
|
|
|
uid_t user_id,
|
2019-03-19 17:55:11 +01:00
|
|
|
|
MctGetAppFilterFlags flags,
|
2018-09-28 10:11:11 +02:00
|
|
|
|
GCancellable *cancellable,
|
|
|
|
|
GAsyncReadyCallback callback,
|
|
|
|
|
gpointer user_data);
|
2019-02-26 18:43:56 +01:00
|
|
|
|
MctAppFilter *mct_get_app_filter_finish (GAsyncResult *result,
|
2018-09-28 10:11:11 +02:00
|
|
|
|
GError **error);
|
|
|
|
|
|
2019-02-26 18:43:56 +01:00
|
|
|
|
gboolean mct_set_app_filter (GDBusConnection *connection,
|
2018-10-31 12:01:44 +01:00
|
|
|
|
uid_t user_id,
|
2019-02-26 18:43:56 +01:00
|
|
|
|
MctAppFilter *app_filter,
|
2019-03-19 17:55:11 +01:00
|
|
|
|
MctSetAppFilterFlags flags,
|
2018-10-31 12:01:44 +01:00
|
|
|
|
GCancellable *cancellable,
|
|
|
|
|
GError **error);
|
2019-02-26 18:43:56 +01:00
|
|
|
|
void mct_set_app_filter_async (GDBusConnection *connection,
|
2018-10-12 05:47:59 +02:00
|
|
|
|
uid_t user_id,
|
2019-02-26 18:43:56 +01:00
|
|
|
|
MctAppFilter *app_filter,
|
2019-03-19 17:55:11 +01:00
|
|
|
|
MctSetAppFilterFlags flags,
|
2018-10-12 05:47:59 +02:00
|
|
|
|
GCancellable *cancellable,
|
|
|
|
|
GAsyncReadyCallback callback,
|
|
|
|
|
gpointer user_data);
|
2019-02-26 18:43:56 +01:00
|
|
|
|
gboolean mct_set_app_filter_finish (GAsyncResult *result,
|
2018-10-12 05:47:59 +02:00
|
|
|
|
GError **error);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-02-26 18:43:56 +01:00
|
|
|
|
* MctAppFilterBuilder:
|
2018-10-12 05:47:59 +02:00
|
|
|
|
*
|
2019-02-26 18:43:56 +01:00
|
|
|
|
* #MctAppFilterBuilder is a stack-allocated mutable structure used to build an
|
|
|
|
|
* #MctAppFilter instance. Use mct_app_filter_builder_init(), various method
|
2018-10-12 05:47:59 +02:00
|
|
|
|
* calls to set properties of the app filter, and then
|
2019-02-26 18:43:56 +01:00
|
|
|
|
* mct_app_filter_builder_end(), to construct an #MctAppFilter.
|
2018-10-12 05:47:59 +02:00
|
|
|
|
*
|
2019-02-26 18:43:56 +01:00
|
|
|
|
* Since: 0.2.0
|
2018-10-12 05:47:59 +02:00
|
|
|
|
*/
|
|
|
|
|
typedef struct
|
|
|
|
|
{
|
|
|
|
|
/*< private >*/
|
|
|
|
|
gpointer p0;
|
|
|
|
|
gpointer p1;
|
2018-11-13 12:30:19 +01:00
|
|
|
|
gboolean b0;
|
2018-11-29 22:09:57 +01:00
|
|
|
|
gboolean b1;
|
2018-10-12 05:47:59 +02:00
|
|
|
|
gpointer p2;
|
|
|
|
|
gpointer p3;
|
2019-02-26 18:43:56 +01:00
|
|
|
|
} MctAppFilterBuilder;
|
2018-10-12 05:47:59 +02:00
|
|
|
|
|
2019-02-26 18:43:56 +01:00
|
|
|
|
GType mct_app_filter_builder_get_type (void);
|
2018-10-12 05:47:59 +02:00
|
|
|
|
|
|
|
|
|
/**
|
2019-02-26 18:43:56 +01:00
|
|
|
|
* MCT_APP_FILTER_BUILDER_INIT:
|
2018-10-12 05:47:59 +02:00
|
|
|
|
*
|
2019-02-26 18:43:56 +01:00
|
|
|
|
* Initialise a stack-allocated #MctAppFilterBuilder instance at declaration
|
2018-10-12 05:47:59 +02:00
|
|
|
|
* time.
|
|
|
|
|
*
|
|
|
|
|
* This is typically used with g_auto():
|
|
|
|
|
* |[
|
2019-02-26 18:43:56 +01:00
|
|
|
|
* g_auto(MctAppFilterBuilder) builder = MCT_APP_FILTER_BUILDER_INIT ();
|
2018-10-12 05:47:59 +02:00
|
|
|
|
* ]|
|
|
|
|
|
*
|
2019-02-26 18:43:56 +01:00
|
|
|
|
* Since: 0.2.0
|
2018-10-12 05:47:59 +02:00
|
|
|
|
*/
|
2019-02-26 18:43:56 +01:00
|
|
|
|
#define MCT_APP_FILTER_BUILDER_INIT() \
|
2018-10-12 05:47:59 +02:00
|
|
|
|
{ \
|
|
|
|
|
g_ptr_array_new_with_free_func (g_free), \
|
2018-11-13 12:30:19 +01:00
|
|
|
|
g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL), \
|
2018-11-29 22:09:57 +01:00
|
|
|
|
TRUE, \
|
2018-11-28 17:39:39 +01:00
|
|
|
|
FALSE, \
|
2018-10-12 05:47:59 +02:00
|
|
|
|
}
|
|
|
|
|
|
2019-02-26 18:43:56 +01:00
|
|
|
|
void mct_app_filter_builder_init (MctAppFilterBuilder *builder);
|
|
|
|
|
void mct_app_filter_builder_clear (MctAppFilterBuilder *builder);
|
2018-10-12 05:47:59 +02:00
|
|
|
|
|
2019-02-26 18:43:56 +01:00
|
|
|
|
G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC (MctAppFilterBuilder,
|
|
|
|
|
mct_app_filter_builder_clear)
|
2018-10-12 05:47:59 +02:00
|
|
|
|
|
2019-02-26 18:43:56 +01:00
|
|
|
|
MctAppFilterBuilder *mct_app_filter_builder_new (void);
|
|
|
|
|
MctAppFilterBuilder *mct_app_filter_builder_copy (MctAppFilterBuilder *builder);
|
|
|
|
|
void mct_app_filter_builder_free (MctAppFilterBuilder *builder);
|
2018-10-12 05:47:59 +02:00
|
|
|
|
|
2019-02-26 18:43:56 +01:00
|
|
|
|
G_DEFINE_AUTOPTR_CLEANUP_FUNC (MctAppFilterBuilder, mct_app_filter_builder_free)
|
2018-10-12 05:47:59 +02:00
|
|
|
|
|
2019-02-26 18:43:56 +01:00
|
|
|
|
MctAppFilter *mct_app_filter_builder_end (MctAppFilterBuilder *builder);
|
2018-10-12 05:47:59 +02:00
|
|
|
|
|
2019-02-26 18:43:56 +01:00
|
|
|
|
void mct_app_filter_builder_blacklist_path (MctAppFilterBuilder *builder,
|
2018-10-12 06:59:04 +02:00
|
|
|
|
const gchar *path);
|
2019-02-26 18:43:56 +01:00
|
|
|
|
void mct_app_filter_builder_blacklist_flatpak_ref (MctAppFilterBuilder *builder,
|
2018-10-12 06:59:04 +02:00
|
|
|
|
const gchar *app_ref);
|
2019-02-26 18:43:56 +01:00
|
|
|
|
void mct_app_filter_builder_set_oars_value (MctAppFilterBuilder *builder,
|
2018-10-12 06:59:04 +02:00
|
|
|
|
const gchar *oars_section,
|
2019-02-26 18:43:56 +01:00
|
|
|
|
MctAppFilterOarsValue value);
|
2018-10-12 05:47:59 +02:00
|
|
|
|
|
2019-02-26 18:43:56 +01:00
|
|
|
|
void mct_app_filter_builder_set_allow_user_installation (MctAppFilterBuilder *builder,
|
2018-11-29 22:09:57 +01:00
|
|
|
|
gboolean allow_user_installation);
|
2019-02-26 18:43:56 +01:00
|
|
|
|
void mct_app_filter_builder_set_allow_system_installation (MctAppFilterBuilder *builder,
|
2018-11-28 17:39:39 +01:00
|
|
|
|
gboolean allow_system_installation);
|
2018-11-13 12:30:19 +01:00
|
|
|
|
|
2018-09-28 10:11:11 +02:00
|
|
|
|
G_END_DECLS
|