Rename project from eos-parental-controls to malcontent
Rename the library from libeos-parental-controls to libmalcontent, and the client from eos-parental-controls-client to malcontent-client. This was done using the following mechanical edits, and no other changes: ``` git search-replace -f EPC///MCT git search-replace -f Epc///Mct git search-replace -f epc///mct git search-replace -f eos_parental_controls///malcontent git search-replace -f eos-parental-controls///malcontent git search-replace -f EosParentalControls///Malcontent git search-replace -f 'eos\\-parental\\-controls///malcontent' git search-replace -f 'Since: 0.1.0///Since: 0.2.0' ``` Note that the accounts-service extension interface has *not* been renamed, as that would revert people’s parental controls settings in existing deployments. Signed-off-by: Philip Withnall <withnall@endlessm.com>
This commit is contained in:
parent
c9889a3ce7
commit
03436eacf5
4
README
4
README
|
@ -1,7 +1,7 @@
|
||||||
eos-parental-controls
|
malcontent
|
||||||
=====================
|
=====================
|
||||||
|
|
||||||
eos-parental-controls implements support for restricting the abilities of
|
malcontent implements support for restricting the abilities of
|
||||||
non-administrator accounts on an Endless OS system. Typically, when this is
|
non-administrator accounts on an Endless OS system. Typically, when this is
|
||||||
used, a non-administrator account will be for a child using the system; and the
|
used, a non-administrator account will be for a child using the system; and the
|
||||||
administrator accounts will be for the parents.
|
administrator accounts will be for the parents.
|
||||||
|
|
|
@ -1,11 +0,0 @@
|
||||||
# Python program
|
|
||||||
install_data('eos-parental-controls-client.py',
|
|
||||||
install_dir: bindir,
|
|
||||||
install_mode: 'rwxr-xr-x',
|
|
||||||
rename: ['eos-parental-controls-client'],
|
|
||||||
)
|
|
||||||
|
|
||||||
# Documentation
|
|
||||||
install_man('docs/eos-parental-controls-client.8')
|
|
||||||
|
|
||||||
# TODO subdir('tests')
|
|
|
@ -1,62 +0,0 @@
|
||||||
libeos_parental_controls_api_version = '0'
|
|
||||||
libeos_parental_controls_api_name = 'eos-parental-controls-' + libeos_parental_controls_api_version
|
|
||||||
libeos_parental_controls_sources = [
|
|
||||||
'app-filter.c',
|
|
||||||
]
|
|
||||||
libeos_parental_controls_headers = [
|
|
||||||
'app-filter.h',
|
|
||||||
]
|
|
||||||
|
|
||||||
libeos_parental_controls_public_deps = [
|
|
||||||
dependency('gio-2.0', version: '>= 2.44'),
|
|
||||||
dependency('glib-2.0', version: '>= 2.54.2'),
|
|
||||||
dependency('gobject-2.0', version: '>= 2.54'),
|
|
||||||
]
|
|
||||||
libeos_parental_controls_private_deps = [
|
|
||||||
dependency('gio-unix-2.0', version: '>= 2.36'),
|
|
||||||
]
|
|
||||||
|
|
||||||
# FIXME: Would be good to use subdir here: https://github.com/mesonbuild/meson/issues/2969
|
|
||||||
libeos_parental_controls_include_subdir = join_paths(libeos_parental_controls_api_name, 'libeos-parental-controls')
|
|
||||||
|
|
||||||
libeos_parental_controls = library(libeos_parental_controls_api_name,
|
|
||||||
libeos_parental_controls_sources + libeos_parental_controls_headers,
|
|
||||||
dependencies: libeos_parental_controls_public_deps + libeos_parental_controls_private_deps,
|
|
||||||
include_directories: root_inc,
|
|
||||||
install: true,
|
|
||||||
version: meson.project_version(),
|
|
||||||
soversion: libeos_parental_controls_api_version,
|
|
||||||
)
|
|
||||||
libeos_parental_controls_dep = declare_dependency(
|
|
||||||
link_with: libeos_parental_controls,
|
|
||||||
include_directories: root_inc,
|
|
||||||
)
|
|
||||||
|
|
||||||
# Public library bits.
|
|
||||||
install_headers(libeos_parental_controls_headers,
|
|
||||||
subdir: libeos_parental_controls_include_subdir,
|
|
||||||
)
|
|
||||||
|
|
||||||
pkgconfig.generate(
|
|
||||||
libraries: [ libeos_parental_controls ],
|
|
||||||
subdirs: libeos_parental_controls_api_name,
|
|
||||||
version: meson.project_version(),
|
|
||||||
name: 'libeos-parental-controls',
|
|
||||||
filebase: libeos_parental_controls_api_name,
|
|
||||||
description: 'Library providing access to parental control settings.',
|
|
||||||
requires: libeos_parental_controls_public_deps,
|
|
||||||
requires_private: libeos_parental_controls_private_deps,
|
|
||||||
)
|
|
||||||
|
|
||||||
gnome.generate_gir(libeos_parental_controls,
|
|
||||||
sources: libeos_parental_controls_sources + libeos_parental_controls_headers,
|
|
||||||
nsversion: libeos_parental_controls_api_version,
|
|
||||||
namespace: 'EosParentalControls',
|
|
||||||
symbol_prefix: 'epc_',
|
|
||||||
identifier_prefix: 'Epc',
|
|
||||||
export_packages: 'libeos-parental-controls',
|
|
||||||
includes: ['GObject-2.0', 'Gio-2.0'],
|
|
||||||
install: true,
|
|
||||||
)
|
|
||||||
|
|
||||||
subdir('tests')
|
|
File diff suppressed because it is too large
Load Diff
|
@ -29,57 +29,57 @@
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* EpcAppFilterError:
|
* MctAppFilterError:
|
||||||
* @EPC_APP_FILTER_ERROR_INVALID_USER: Given user ID doesn’t exist
|
* @MCT_APP_FILTER_ERROR_INVALID_USER: Given user ID doesn’t exist
|
||||||
* @EPC_APP_FILTER_ERROR_PERMISSION_DENIED: Not authorized to query the app
|
* @MCT_APP_FILTER_ERROR_PERMISSION_DENIED: Not authorized to query the app
|
||||||
* filter for the given user
|
* filter for the given user
|
||||||
* @EPC_APP_FILTER_ERROR_INVALID_DATA: The data stored in the app filter for
|
* @MCT_APP_FILTER_ERROR_INVALID_DATA: The data stored in the app filter for
|
||||||
* a user is inconsistent or invalid
|
* a user is inconsistent or invalid
|
||||||
*
|
*
|
||||||
* Errors which can be returned by epc_get_app_filter_async().
|
* Errors which can be returned by mct_get_app_filter_async().
|
||||||
*
|
*
|
||||||
* Since: 0.1.0
|
* Since: 0.2.0
|
||||||
*/
|
*/
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
EPC_APP_FILTER_ERROR_INVALID_USER,
|
MCT_APP_FILTER_ERROR_INVALID_USER,
|
||||||
EPC_APP_FILTER_ERROR_PERMISSION_DENIED,
|
MCT_APP_FILTER_ERROR_PERMISSION_DENIED,
|
||||||
EPC_APP_FILTER_ERROR_INVALID_DATA,
|
MCT_APP_FILTER_ERROR_INVALID_DATA,
|
||||||
} EpcAppFilterError;
|
} MctAppFilterError;
|
||||||
|
|
||||||
GQuark epc_app_filter_error_quark (void);
|
GQuark mct_app_filter_error_quark (void);
|
||||||
#define EPC_APP_FILTER_ERROR epc_app_filter_error_quark ()
|
#define MCT_APP_FILTER_ERROR mct_app_filter_error_quark ()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* EpcAppFilterOarsValue:
|
* MctAppFilterOarsValue:
|
||||||
* @EPC_APP_FILTER_OARS_VALUE_UNKNOWN: Unknown value for the given
|
* @MCT_APP_FILTER_OARS_VALUE_UNKNOWN: Unknown value for the given
|
||||||
* section.
|
* section.
|
||||||
* @EPC_APP_FILTER_OARS_VALUE_NONE: No rating for the given section.
|
* @MCT_APP_FILTER_OARS_VALUE_NONE: No rating for the given section.
|
||||||
* @EPC_APP_FILTER_OARS_VALUE_MILD: Mild rating for the given section.
|
* @MCT_APP_FILTER_OARS_VALUE_MILD: Mild rating for the given section.
|
||||||
* @EPC_APP_FILTER_OARS_VALUE_MODERATE: Moderate rating for the given
|
* @MCT_APP_FILTER_OARS_VALUE_MODERATE: Moderate rating for the given
|
||||||
* section.
|
* section.
|
||||||
* @EPC_APP_FILTER_OARS_VALUE_INTENSE: Intense rating for the given
|
* @MCT_APP_FILTER_OARS_VALUE_INTENSE: Intense rating for the given
|
||||||
* section.
|
* section.
|
||||||
*
|
*
|
||||||
* Rating values of the intensity of a given section in an app or game.
|
* Rating values of the intensity of a given section in an app or game.
|
||||||
* These are directly equivalent to the values in the #AsContentRatingValue
|
* These are directly equivalent to the values in the #AsContentRatingValue
|
||||||
* enumeration in libappstream.
|
* enumeration in libappstream.
|
||||||
*
|
*
|
||||||
* Since: 0.1.0
|
* Since: 0.2.0
|
||||||
*/
|
*/
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
EPC_APP_FILTER_OARS_VALUE_UNKNOWN,
|
MCT_APP_FILTER_OARS_VALUE_UNKNOWN,
|
||||||
EPC_APP_FILTER_OARS_VALUE_NONE,
|
MCT_APP_FILTER_OARS_VALUE_NONE,
|
||||||
EPC_APP_FILTER_OARS_VALUE_MILD,
|
MCT_APP_FILTER_OARS_VALUE_MILD,
|
||||||
EPC_APP_FILTER_OARS_VALUE_MODERATE,
|
MCT_APP_FILTER_OARS_VALUE_MODERATE,
|
||||||
EPC_APP_FILTER_OARS_VALUE_INTENSE,
|
MCT_APP_FILTER_OARS_VALUE_INTENSE,
|
||||||
} EpcAppFilterOarsValue;
|
} MctAppFilterOarsValue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* EpcAppFilter:
|
* MctAppFilter:
|
||||||
*
|
*
|
||||||
* #EpcAppFilter is an opaque, immutable structure which contains a snapshot of
|
* #MctAppFilter is an opaque, immutable structure which contains a snapshot of
|
||||||
* the app filtering settings for a user at a given time. This includes a list
|
* 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.
|
* of apps which are explicitly banned or allowed to be run by that user.
|
||||||
*
|
*
|
||||||
|
@ -87,72 +87,72 @@ typedef enum
|
||||||
* are read-only for non-administrative users. The precise policy is set using
|
* are read-only for non-administrative users. The precise policy is set using
|
||||||
* polkit.
|
* polkit.
|
||||||
*
|
*
|
||||||
* Since: 0.1.0
|
* Since: 0.2.0
|
||||||
*/
|
*/
|
||||||
typedef struct _EpcAppFilter EpcAppFilter;
|
typedef struct _MctAppFilter MctAppFilter;
|
||||||
GType epc_app_filter_get_type (void);
|
GType mct_app_filter_get_type (void);
|
||||||
|
|
||||||
EpcAppFilter *epc_app_filter_ref (EpcAppFilter *filter);
|
MctAppFilter *mct_app_filter_ref (MctAppFilter *filter);
|
||||||
void epc_app_filter_unref (EpcAppFilter *filter);
|
void mct_app_filter_unref (MctAppFilter *filter);
|
||||||
|
|
||||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (EpcAppFilter, epc_app_filter_unref)
|
G_DEFINE_AUTOPTR_CLEANUP_FUNC (MctAppFilter, mct_app_filter_unref)
|
||||||
|
|
||||||
uid_t epc_app_filter_get_user_id (EpcAppFilter *filter);
|
uid_t mct_app_filter_get_user_id (MctAppFilter *filter);
|
||||||
gboolean epc_app_filter_is_path_allowed (EpcAppFilter *filter,
|
gboolean mct_app_filter_is_path_allowed (MctAppFilter *filter,
|
||||||
const gchar *path);
|
const gchar *path);
|
||||||
gboolean epc_app_filter_is_flatpak_ref_allowed (EpcAppFilter *filter,
|
gboolean mct_app_filter_is_flatpak_ref_allowed (MctAppFilter *filter,
|
||||||
const gchar *app_ref);
|
const gchar *app_ref);
|
||||||
gboolean epc_app_filter_is_flatpak_app_allowed (EpcAppFilter *filter,
|
gboolean mct_app_filter_is_flatpak_app_allowed (MctAppFilter *filter,
|
||||||
const gchar *app_id);
|
const gchar *app_id);
|
||||||
gboolean epc_app_filter_is_appinfo_allowed (EpcAppFilter *filter,
|
gboolean mct_app_filter_is_appinfo_allowed (MctAppFilter *filter,
|
||||||
GAppInfo *app_info);
|
GAppInfo *app_info);
|
||||||
|
|
||||||
const gchar **epc_app_filter_get_oars_sections (EpcAppFilter *filter);
|
const gchar **mct_app_filter_get_oars_sections (MctAppFilter *filter);
|
||||||
EpcAppFilterOarsValue epc_app_filter_get_oars_value (EpcAppFilter *filter,
|
MctAppFilterOarsValue mct_app_filter_get_oars_value (MctAppFilter *filter,
|
||||||
const gchar *oars_section);
|
const gchar *oars_section);
|
||||||
|
|
||||||
gboolean epc_app_filter_is_user_installation_allowed (EpcAppFilter *filter);
|
gboolean mct_app_filter_is_user_installation_allowed (MctAppFilter *filter);
|
||||||
gboolean epc_app_filter_is_system_installation_allowed (EpcAppFilter *filter);
|
gboolean mct_app_filter_is_system_installation_allowed (MctAppFilter *filter);
|
||||||
|
|
||||||
EpcAppFilter *epc_get_app_filter (GDBusConnection *connection,
|
MctAppFilter *mct_get_app_filter (GDBusConnection *connection,
|
||||||
uid_t user_id,
|
uid_t user_id,
|
||||||
gboolean allow_interactive_authorization,
|
gboolean allow_interactive_authorization,
|
||||||
GCancellable *cancellable,
|
GCancellable *cancellable,
|
||||||
GError **error);
|
GError **error);
|
||||||
void epc_get_app_filter_async (GDBusConnection *connection,
|
void mct_get_app_filter_async (GDBusConnection *connection,
|
||||||
uid_t user_id,
|
uid_t user_id,
|
||||||
gboolean allow_interactive_authorization,
|
gboolean allow_interactive_authorization,
|
||||||
GCancellable *cancellable,
|
GCancellable *cancellable,
|
||||||
GAsyncReadyCallback callback,
|
GAsyncReadyCallback callback,
|
||||||
gpointer user_data);
|
gpointer user_data);
|
||||||
EpcAppFilter *epc_get_app_filter_finish (GAsyncResult *result,
|
MctAppFilter *mct_get_app_filter_finish (GAsyncResult *result,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
|
||||||
gboolean epc_set_app_filter (GDBusConnection *connection,
|
gboolean mct_set_app_filter (GDBusConnection *connection,
|
||||||
uid_t user_id,
|
uid_t user_id,
|
||||||
EpcAppFilter *app_filter,
|
MctAppFilter *app_filter,
|
||||||
gboolean allow_interactive_authorization,
|
gboolean allow_interactive_authorization,
|
||||||
GCancellable *cancellable,
|
GCancellable *cancellable,
|
||||||
GError **error);
|
GError **error);
|
||||||
void epc_set_app_filter_async (GDBusConnection *connection,
|
void mct_set_app_filter_async (GDBusConnection *connection,
|
||||||
uid_t user_id,
|
uid_t user_id,
|
||||||
EpcAppFilter *app_filter,
|
MctAppFilter *app_filter,
|
||||||
gboolean allow_interactive_authorization,
|
gboolean allow_interactive_authorization,
|
||||||
GCancellable *cancellable,
|
GCancellable *cancellable,
|
||||||
GAsyncReadyCallback callback,
|
GAsyncReadyCallback callback,
|
||||||
gpointer user_data);
|
gpointer user_data);
|
||||||
gboolean epc_set_app_filter_finish (GAsyncResult *result,
|
gboolean mct_set_app_filter_finish (GAsyncResult *result,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* EpcAppFilterBuilder:
|
* MctAppFilterBuilder:
|
||||||
*
|
*
|
||||||
* #EpcAppFilterBuilder is a stack-allocated mutable structure used to build an
|
* #MctAppFilterBuilder is a stack-allocated mutable structure used to build an
|
||||||
* #EpcAppFilter instance. Use epc_app_filter_builder_init(), various method
|
* #MctAppFilter instance. Use mct_app_filter_builder_init(), various method
|
||||||
* calls to set properties of the app filter, and then
|
* calls to set properties of the app filter, and then
|
||||||
* epc_app_filter_builder_end(), to construct an #EpcAppFilter.
|
* mct_app_filter_builder_end(), to construct an #MctAppFilter.
|
||||||
*
|
*
|
||||||
* Since: 0.1.0
|
* Since: 0.2.0
|
||||||
*/
|
*/
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
|
@ -163,24 +163,24 @@ typedef struct
|
||||||
gboolean b1;
|
gboolean b1;
|
||||||
gpointer p2;
|
gpointer p2;
|
||||||
gpointer p3;
|
gpointer p3;
|
||||||
} EpcAppFilterBuilder;
|
} MctAppFilterBuilder;
|
||||||
|
|
||||||
GType epc_app_filter_builder_get_type (void);
|
GType mct_app_filter_builder_get_type (void);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* EPC_APP_FILTER_BUILDER_INIT:
|
* MCT_APP_FILTER_BUILDER_INIT:
|
||||||
*
|
*
|
||||||
* Initialise a stack-allocated #EpcAppFilterBuilder instance at declaration
|
* Initialise a stack-allocated #MctAppFilterBuilder instance at declaration
|
||||||
* time.
|
* time.
|
||||||
*
|
*
|
||||||
* This is typically used with g_auto():
|
* This is typically used with g_auto():
|
||||||
* |[
|
* |[
|
||||||
* g_auto(EpcAppFilterBuilder) builder = EPC_APP_FILTER_BUILDER_INIT ();
|
* g_auto(MctAppFilterBuilder) builder = MCT_APP_FILTER_BUILDER_INIT ();
|
||||||
* ]|
|
* ]|
|
||||||
*
|
*
|
||||||
* Since: 0.1.0
|
* Since: 0.2.0
|
||||||
*/
|
*/
|
||||||
#define EPC_APP_FILTER_BUILDER_INIT() \
|
#define MCT_APP_FILTER_BUILDER_INIT() \
|
||||||
{ \
|
{ \
|
||||||
g_ptr_array_new_with_free_func (g_free), \
|
g_ptr_array_new_with_free_func (g_free), \
|
||||||
g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL), \
|
g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL), \
|
||||||
|
@ -188,31 +188,31 @@ GType epc_app_filter_builder_get_type (void);
|
||||||
FALSE, \
|
FALSE, \
|
||||||
}
|
}
|
||||||
|
|
||||||
void epc_app_filter_builder_init (EpcAppFilterBuilder *builder);
|
void mct_app_filter_builder_init (MctAppFilterBuilder *builder);
|
||||||
void epc_app_filter_builder_clear (EpcAppFilterBuilder *builder);
|
void mct_app_filter_builder_clear (MctAppFilterBuilder *builder);
|
||||||
|
|
||||||
G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC (EpcAppFilterBuilder,
|
G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC (MctAppFilterBuilder,
|
||||||
epc_app_filter_builder_clear)
|
mct_app_filter_builder_clear)
|
||||||
|
|
||||||
EpcAppFilterBuilder *epc_app_filter_builder_new (void);
|
MctAppFilterBuilder *mct_app_filter_builder_new (void);
|
||||||
EpcAppFilterBuilder *epc_app_filter_builder_copy (EpcAppFilterBuilder *builder);
|
MctAppFilterBuilder *mct_app_filter_builder_copy (MctAppFilterBuilder *builder);
|
||||||
void epc_app_filter_builder_free (EpcAppFilterBuilder *builder);
|
void mct_app_filter_builder_free (MctAppFilterBuilder *builder);
|
||||||
|
|
||||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (EpcAppFilterBuilder, epc_app_filter_builder_free)
|
G_DEFINE_AUTOPTR_CLEANUP_FUNC (MctAppFilterBuilder, mct_app_filter_builder_free)
|
||||||
|
|
||||||
EpcAppFilter *epc_app_filter_builder_end (EpcAppFilterBuilder *builder);
|
MctAppFilter *mct_app_filter_builder_end (MctAppFilterBuilder *builder);
|
||||||
|
|
||||||
void epc_app_filter_builder_blacklist_path (EpcAppFilterBuilder *builder,
|
void mct_app_filter_builder_blacklist_path (MctAppFilterBuilder *builder,
|
||||||
const gchar *path);
|
const gchar *path);
|
||||||
void epc_app_filter_builder_blacklist_flatpak_ref (EpcAppFilterBuilder *builder,
|
void mct_app_filter_builder_blacklist_flatpak_ref (MctAppFilterBuilder *builder,
|
||||||
const gchar *app_ref);
|
const gchar *app_ref);
|
||||||
void epc_app_filter_builder_set_oars_value (EpcAppFilterBuilder *builder,
|
void mct_app_filter_builder_set_oars_value (MctAppFilterBuilder *builder,
|
||||||
const gchar *oars_section,
|
const gchar *oars_section,
|
||||||
EpcAppFilterOarsValue value);
|
MctAppFilterOarsValue value);
|
||||||
|
|
||||||
void epc_app_filter_builder_set_allow_user_installation (EpcAppFilterBuilder *builder,
|
void mct_app_filter_builder_set_allow_user_installation (MctAppFilterBuilder *builder,
|
||||||
gboolean allow_user_installation);
|
gboolean allow_user_installation);
|
||||||
void epc_app_filter_builder_set_allow_system_installation (EpcAppFilterBuilder *builder,
|
void mct_app_filter_builder_set_allow_system_installation (MctAppFilterBuilder *builder,
|
||||||
gboolean allow_system_installation);
|
gboolean allow_system_installation);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
|
@ -0,0 +1,62 @@
|
||||||
|
libmalcontent_api_version = '0'
|
||||||
|
libmalcontent_api_name = 'malcontent-' + libmalcontent_api_version
|
||||||
|
libmalcontent_sources = [
|
||||||
|
'app-filter.c',
|
||||||
|
]
|
||||||
|
libmalcontent_headers = [
|
||||||
|
'app-filter.h',
|
||||||
|
]
|
||||||
|
|
||||||
|
libmalcontent_public_deps = [
|
||||||
|
dependency('gio-2.0', version: '>= 2.44'),
|
||||||
|
dependency('glib-2.0', version: '>= 2.54.2'),
|
||||||
|
dependency('gobject-2.0', version: '>= 2.54'),
|
||||||
|
]
|
||||||
|
libmalcontent_private_deps = [
|
||||||
|
dependency('gio-unix-2.0', version: '>= 2.36'),
|
||||||
|
]
|
||||||
|
|
||||||
|
# FIXME: Would be good to use subdir here: https://github.com/mesonbuild/meson/issues/2969
|
||||||
|
libmalcontent_include_subdir = join_paths(libmalcontent_api_name, 'libmalcontent')
|
||||||
|
|
||||||
|
libmalcontent = library(libmalcontent_api_name,
|
||||||
|
libmalcontent_sources + libmalcontent_headers,
|
||||||
|
dependencies: libmalcontent_public_deps + libmalcontent_private_deps,
|
||||||
|
include_directories: root_inc,
|
||||||
|
install: true,
|
||||||
|
version: meson.project_version(),
|
||||||
|
soversion: libmalcontent_api_version,
|
||||||
|
)
|
||||||
|
libmalcontent_dep = declare_dependency(
|
||||||
|
link_with: libmalcontent,
|
||||||
|
include_directories: root_inc,
|
||||||
|
)
|
||||||
|
|
||||||
|
# Public library bits.
|
||||||
|
install_headers(libmalcontent_headers,
|
||||||
|
subdir: libmalcontent_include_subdir,
|
||||||
|
)
|
||||||
|
|
||||||
|
pkgconfig.generate(
|
||||||
|
libraries: [ libmalcontent ],
|
||||||
|
subdirs: libmalcontent_api_name,
|
||||||
|
version: meson.project_version(),
|
||||||
|
name: 'libmalcontent',
|
||||||
|
filebase: libmalcontent_api_name,
|
||||||
|
description: 'Library providing access to parental control settings.',
|
||||||
|
requires: libmalcontent_public_deps,
|
||||||
|
requires_private: libmalcontent_private_deps,
|
||||||
|
)
|
||||||
|
|
||||||
|
gnome.generate_gir(libmalcontent,
|
||||||
|
sources: libmalcontent_sources + libmalcontent_headers,
|
||||||
|
nsversion: libmalcontent_api_version,
|
||||||
|
namespace: 'Malcontent',
|
||||||
|
symbol_prefix: 'mct_',
|
||||||
|
identifier_prefix: 'Mct',
|
||||||
|
export_packages: 'libmalcontent',
|
||||||
|
includes: ['GObject-2.0', 'Gio-2.0'],
|
||||||
|
install: true,
|
||||||
|
)
|
||||||
|
|
||||||
|
subdir('tests')
|
|
@ -25,7 +25,7 @@
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
#include <gio/gdesktopappinfo.h>
|
#include <gio/gdesktopappinfo.h>
|
||||||
#include <gio/gio.h>
|
#include <gio/gio.h>
|
||||||
#include <libeos-parental-controls/app-filter.h>
|
#include <libmalcontent/app-filter.h>
|
||||||
#include <libglib-testing/dbus-queue.h>
|
#include <libglib-testing/dbus-queue.h>
|
||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@ -71,53 +71,53 @@ assert_strv_equal (const gchar * const *strv_a,
|
||||||
static void
|
static void
|
||||||
test_app_filter_error_quark (void)
|
test_app_filter_error_quark (void)
|
||||||
{
|
{
|
||||||
g_assert_cmpint (epc_app_filter_error_quark (), !=, 0);
|
g_assert_cmpint (mct_app_filter_error_quark (), !=, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Test that the #GType definitions for various types work. */
|
/* Test that the #GType definitions for various types work. */
|
||||||
static void
|
static void
|
||||||
test_app_filter_types (void)
|
test_app_filter_types (void)
|
||||||
{
|
{
|
||||||
g_type_ensure (epc_app_filter_get_type ());
|
g_type_ensure (mct_app_filter_get_type ());
|
||||||
g_type_ensure (epc_app_filter_builder_get_type ());
|
g_type_ensure (mct_app_filter_builder_get_type ());
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Test that ref() and unref() work on an #EpcAppFilter. */
|
/* Test that ref() and unref() work on an #MctAppFilter. */
|
||||||
static void
|
static void
|
||||||
test_app_filter_refs (void)
|
test_app_filter_refs (void)
|
||||||
{
|
{
|
||||||
g_auto(EpcAppFilterBuilder) builder = EPC_APP_FILTER_BUILDER_INIT ();
|
g_auto(MctAppFilterBuilder) builder = MCT_APP_FILTER_BUILDER_INIT ();
|
||||||
g_autoptr(EpcAppFilter) filter = NULL;
|
g_autoptr(MctAppFilter) filter = NULL;
|
||||||
|
|
||||||
/* Use an empty #EpcAppFilter. */
|
/* Use an empty #MctAppFilter. */
|
||||||
filter = epc_app_filter_builder_end (&builder);
|
filter = mct_app_filter_builder_end (&builder);
|
||||||
|
|
||||||
g_assert_nonnull (filter);
|
g_assert_nonnull (filter);
|
||||||
|
|
||||||
/* Call is_path_allowed() to check that the filter hasn’t been finalised. */
|
/* Call is_path_allowed() to check that the filter hasn’t been finalised. */
|
||||||
g_assert_true (epc_app_filter_is_path_allowed (filter, "/bin/false"));
|
g_assert_true (mct_app_filter_is_path_allowed (filter, "/bin/false"));
|
||||||
epc_app_filter_ref (filter);
|
mct_app_filter_ref (filter);
|
||||||
g_assert_true (epc_app_filter_is_path_allowed (filter, "/bin/false"));
|
g_assert_true (mct_app_filter_is_path_allowed (filter, "/bin/false"));
|
||||||
epc_app_filter_unref (filter);
|
mct_app_filter_unref (filter);
|
||||||
g_assert_true (epc_app_filter_is_path_allowed (filter, "/bin/false"));
|
g_assert_true (mct_app_filter_is_path_allowed (filter, "/bin/false"));
|
||||||
|
|
||||||
/* Final ref is dropped by g_autoptr(). */
|
/* Final ref is dropped by g_autoptr(). */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Fixture for tests which use an #EpcAppFilterBuilder. The builder can either
|
/* Fixture for tests which use an #MctAppFilterBuilder. The builder can either
|
||||||
* be heap- or stack-allocated. @builder will always be a valid pointer to it.
|
* be heap- or stack-allocated. @builder will always be a valid pointer to it.
|
||||||
*/
|
*/
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
EpcAppFilterBuilder *builder;
|
MctAppFilterBuilder *builder;
|
||||||
EpcAppFilterBuilder stack_builder;
|
MctAppFilterBuilder stack_builder;
|
||||||
} BuilderFixture;
|
} BuilderFixture;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
builder_set_up_stack (BuilderFixture *fixture,
|
builder_set_up_stack (BuilderFixture *fixture,
|
||||||
gconstpointer test_data)
|
gconstpointer test_data)
|
||||||
{
|
{
|
||||||
epc_app_filter_builder_init (&fixture->stack_builder);
|
mct_app_filter_builder_init (&fixture->stack_builder);
|
||||||
fixture->builder = &fixture->stack_builder;
|
fixture->builder = &fixture->stack_builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,7 +125,7 @@ static void
|
||||||
builder_tear_down_stack (BuilderFixture *fixture,
|
builder_tear_down_stack (BuilderFixture *fixture,
|
||||||
gconstpointer test_data)
|
gconstpointer test_data)
|
||||||
{
|
{
|
||||||
epc_app_filter_builder_clear (&fixture->stack_builder);
|
mct_app_filter_builder_clear (&fixture->stack_builder);
|
||||||
fixture->builder = NULL;
|
fixture->builder = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -133,7 +133,7 @@ static void
|
||||||
builder_set_up_stack2 (BuilderFixture *fixture,
|
builder_set_up_stack2 (BuilderFixture *fixture,
|
||||||
gconstpointer test_data)
|
gconstpointer test_data)
|
||||||
{
|
{
|
||||||
EpcAppFilterBuilder local_builder = EPC_APP_FILTER_BUILDER_INIT ();
|
MctAppFilterBuilder local_builder = MCT_APP_FILTER_BUILDER_INIT ();
|
||||||
memcpy (&fixture->stack_builder, &local_builder, sizeof (local_builder));
|
memcpy (&fixture->stack_builder, &local_builder, sizeof (local_builder));
|
||||||
fixture->builder = &fixture->stack_builder;
|
fixture->builder = &fixture->stack_builder;
|
||||||
}
|
}
|
||||||
|
@ -142,7 +142,7 @@ static void
|
||||||
builder_tear_down_stack2 (BuilderFixture *fixture,
|
builder_tear_down_stack2 (BuilderFixture *fixture,
|
||||||
gconstpointer test_data)
|
gconstpointer test_data)
|
||||||
{
|
{
|
||||||
epc_app_filter_builder_clear (&fixture->stack_builder);
|
mct_app_filter_builder_clear (&fixture->stack_builder);
|
||||||
fixture->builder = NULL;
|
fixture->builder = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -150,152 +150,152 @@ static void
|
||||||
builder_set_up_heap (BuilderFixture *fixture,
|
builder_set_up_heap (BuilderFixture *fixture,
|
||||||
gconstpointer test_data)
|
gconstpointer test_data)
|
||||||
{
|
{
|
||||||
fixture->builder = epc_app_filter_builder_new ();
|
fixture->builder = mct_app_filter_builder_new ();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
builder_tear_down_heap (BuilderFixture *fixture,
|
builder_tear_down_heap (BuilderFixture *fixture,
|
||||||
gconstpointer test_data)
|
gconstpointer test_data)
|
||||||
{
|
{
|
||||||
g_clear_pointer (&fixture->builder, epc_app_filter_builder_free);
|
g_clear_pointer (&fixture->builder, mct_app_filter_builder_free);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Test building a non-empty #EpcAppFilter using an #EpcAppFilterBuilder. */
|
/* Test building a non-empty #MctAppFilter using an #MctAppFilterBuilder. */
|
||||||
static void
|
static void
|
||||||
test_app_filter_builder_non_empty (BuilderFixture *fixture,
|
test_app_filter_builder_non_empty (BuilderFixture *fixture,
|
||||||
gconstpointer test_data)
|
gconstpointer test_data)
|
||||||
{
|
{
|
||||||
g_autoptr(EpcAppFilter) filter = NULL;
|
g_autoptr(MctAppFilter) filter = NULL;
|
||||||
g_autofree const gchar **sections = NULL;
|
g_autofree const gchar **sections = NULL;
|
||||||
|
|
||||||
epc_app_filter_builder_blacklist_path (fixture->builder, "/bin/true");
|
mct_app_filter_builder_blacklist_path (fixture->builder, "/bin/true");
|
||||||
epc_app_filter_builder_blacklist_path (fixture->builder, "/usr/bin/gnome-software");
|
mct_app_filter_builder_blacklist_path (fixture->builder, "/usr/bin/gnome-software");
|
||||||
|
|
||||||
epc_app_filter_builder_blacklist_flatpak_ref (fixture->builder,
|
mct_app_filter_builder_blacklist_flatpak_ref (fixture->builder,
|
||||||
"app/org.doom.Doom/x86_64/master");
|
"app/org.doom.Doom/x86_64/master");
|
||||||
|
|
||||||
epc_app_filter_builder_set_oars_value (fixture->builder, "drugs-alcohol",
|
mct_app_filter_builder_set_oars_value (fixture->builder, "drugs-alcohol",
|
||||||
EPC_APP_FILTER_OARS_VALUE_MILD);
|
MCT_APP_FILTER_OARS_VALUE_MILD);
|
||||||
epc_app_filter_builder_set_oars_value (fixture->builder, "language-humor",
|
mct_app_filter_builder_set_oars_value (fixture->builder, "language-humor",
|
||||||
EPC_APP_FILTER_OARS_VALUE_MODERATE);
|
MCT_APP_FILTER_OARS_VALUE_MODERATE);
|
||||||
epc_app_filter_builder_set_allow_user_installation (fixture->builder, TRUE);
|
mct_app_filter_builder_set_allow_user_installation (fixture->builder, TRUE);
|
||||||
epc_app_filter_builder_set_allow_system_installation (fixture->builder, FALSE);
|
mct_app_filter_builder_set_allow_system_installation (fixture->builder, FALSE);
|
||||||
|
|
||||||
filter = epc_app_filter_builder_end (fixture->builder);
|
filter = mct_app_filter_builder_end (fixture->builder);
|
||||||
|
|
||||||
g_assert_true (epc_app_filter_is_path_allowed (filter, "/bin/false"));
|
g_assert_true (mct_app_filter_is_path_allowed (filter, "/bin/false"));
|
||||||
g_assert_false (epc_app_filter_is_path_allowed (filter,
|
g_assert_false (mct_app_filter_is_path_allowed (filter,
|
||||||
"/usr/bin/gnome-software"));
|
"/usr/bin/gnome-software"));
|
||||||
|
|
||||||
g_assert_true (epc_app_filter_is_flatpak_ref_allowed (filter,
|
g_assert_true (mct_app_filter_is_flatpak_ref_allowed (filter,
|
||||||
"app/org.gnome.Ponies/x86_64/master"));
|
"app/org.gnome.Ponies/x86_64/master"));
|
||||||
g_assert_true (epc_app_filter_is_flatpak_app_allowed (filter, "org.gnome.Ponies"));
|
g_assert_true (mct_app_filter_is_flatpak_app_allowed (filter, "org.gnome.Ponies"));
|
||||||
g_assert_false (epc_app_filter_is_flatpak_ref_allowed (filter,
|
g_assert_false (mct_app_filter_is_flatpak_ref_allowed (filter,
|
||||||
"app/org.doom.Doom/x86_64/master"));
|
"app/org.doom.Doom/x86_64/master"));
|
||||||
g_assert_false (epc_app_filter_is_flatpak_app_allowed (filter, "org.doom.Doom"));
|
g_assert_false (mct_app_filter_is_flatpak_app_allowed (filter, "org.doom.Doom"));
|
||||||
|
|
||||||
g_assert_cmpint (epc_app_filter_get_oars_value (filter, "drugs-alcohol"), ==,
|
g_assert_cmpint (mct_app_filter_get_oars_value (filter, "drugs-alcohol"), ==,
|
||||||
EPC_APP_FILTER_OARS_VALUE_MILD);
|
MCT_APP_FILTER_OARS_VALUE_MILD);
|
||||||
g_assert_cmpint (epc_app_filter_get_oars_value (filter, "language-humor"), ==,
|
g_assert_cmpint (mct_app_filter_get_oars_value (filter, "language-humor"), ==,
|
||||||
EPC_APP_FILTER_OARS_VALUE_MODERATE);
|
MCT_APP_FILTER_OARS_VALUE_MODERATE);
|
||||||
g_assert_cmpint (epc_app_filter_get_oars_value (filter, "something-else"), ==,
|
g_assert_cmpint (mct_app_filter_get_oars_value (filter, "something-else"), ==,
|
||||||
EPC_APP_FILTER_OARS_VALUE_UNKNOWN);
|
MCT_APP_FILTER_OARS_VALUE_UNKNOWN);
|
||||||
|
|
||||||
sections = epc_app_filter_get_oars_sections (filter);
|
sections = mct_app_filter_get_oars_sections (filter);
|
||||||
const gchar * const expected_sections[] = { "drugs-alcohol", "language-humor", NULL };
|
const gchar * const expected_sections[] = { "drugs-alcohol", "language-humor", NULL };
|
||||||
assert_strv_equal ((const gchar * const *) sections, expected_sections);
|
assert_strv_equal ((const gchar * const *) sections, expected_sections);
|
||||||
|
|
||||||
g_assert_true (epc_app_filter_is_user_installation_allowed (filter));
|
g_assert_true (mct_app_filter_is_user_installation_allowed (filter));
|
||||||
g_assert_false (epc_app_filter_is_system_installation_allowed (filter));
|
g_assert_false (mct_app_filter_is_system_installation_allowed (filter));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Test building an empty #EpcAppFilter using an #EpcAppFilterBuilder. */
|
/* Test building an empty #MctAppFilter using an #MctAppFilterBuilder. */
|
||||||
static void
|
static void
|
||||||
test_app_filter_builder_empty (BuilderFixture *fixture,
|
test_app_filter_builder_empty (BuilderFixture *fixture,
|
||||||
gconstpointer test_data)
|
gconstpointer test_data)
|
||||||
{
|
{
|
||||||
g_autoptr(EpcAppFilter) filter = NULL;
|
g_autoptr(MctAppFilter) filter = NULL;
|
||||||
g_autofree const gchar **sections = NULL;
|
g_autofree const gchar **sections = NULL;
|
||||||
|
|
||||||
filter = epc_app_filter_builder_end (fixture->builder);
|
filter = mct_app_filter_builder_end (fixture->builder);
|
||||||
|
|
||||||
g_assert_true (epc_app_filter_is_path_allowed (filter, "/bin/false"));
|
g_assert_true (mct_app_filter_is_path_allowed (filter, "/bin/false"));
|
||||||
g_assert_true (epc_app_filter_is_path_allowed (filter,
|
g_assert_true (mct_app_filter_is_path_allowed (filter,
|
||||||
"/usr/bin/gnome-software"));
|
"/usr/bin/gnome-software"));
|
||||||
|
|
||||||
g_assert_true (epc_app_filter_is_flatpak_ref_allowed (filter,
|
g_assert_true (mct_app_filter_is_flatpak_ref_allowed (filter,
|
||||||
"app/org.gnome.Ponies/x86_64/master"));
|
"app/org.gnome.Ponies/x86_64/master"));
|
||||||
g_assert_true (epc_app_filter_is_flatpak_app_allowed (filter, "org.gnome.Ponies"));
|
g_assert_true (mct_app_filter_is_flatpak_app_allowed (filter, "org.gnome.Ponies"));
|
||||||
g_assert_true (epc_app_filter_is_flatpak_ref_allowed (filter,
|
g_assert_true (mct_app_filter_is_flatpak_ref_allowed (filter,
|
||||||
"app/org.doom.Doom/x86_64/master"));
|
"app/org.doom.Doom/x86_64/master"));
|
||||||
g_assert_true (epc_app_filter_is_flatpak_app_allowed (filter, "org.doom.Doom"));
|
g_assert_true (mct_app_filter_is_flatpak_app_allowed (filter, "org.doom.Doom"));
|
||||||
|
|
||||||
g_assert_cmpint (epc_app_filter_get_oars_value (filter, "drugs-alcohol"), ==,
|
g_assert_cmpint (mct_app_filter_get_oars_value (filter, "drugs-alcohol"), ==,
|
||||||
EPC_APP_FILTER_OARS_VALUE_UNKNOWN);
|
MCT_APP_FILTER_OARS_VALUE_UNKNOWN);
|
||||||
g_assert_cmpint (epc_app_filter_get_oars_value (filter, "language-humor"), ==,
|
g_assert_cmpint (mct_app_filter_get_oars_value (filter, "language-humor"), ==,
|
||||||
EPC_APP_FILTER_OARS_VALUE_UNKNOWN);
|
MCT_APP_FILTER_OARS_VALUE_UNKNOWN);
|
||||||
g_assert_cmpint (epc_app_filter_get_oars_value (filter, "something-else"), ==,
|
g_assert_cmpint (mct_app_filter_get_oars_value (filter, "something-else"), ==,
|
||||||
EPC_APP_FILTER_OARS_VALUE_UNKNOWN);
|
MCT_APP_FILTER_OARS_VALUE_UNKNOWN);
|
||||||
|
|
||||||
sections = epc_app_filter_get_oars_sections (filter);
|
sections = mct_app_filter_get_oars_sections (filter);
|
||||||
const gchar * const expected_sections[] = { NULL };
|
const gchar * const expected_sections[] = { NULL };
|
||||||
assert_strv_equal ((const gchar * const *) sections, expected_sections);
|
assert_strv_equal ((const gchar * const *) sections, expected_sections);
|
||||||
|
|
||||||
g_assert_true (epc_app_filter_is_user_installation_allowed (filter));
|
g_assert_true (mct_app_filter_is_user_installation_allowed (filter));
|
||||||
g_assert_false (epc_app_filter_is_system_installation_allowed (filter));
|
g_assert_false (mct_app_filter_is_system_installation_allowed (filter));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check that copying a cleared #EpcAppFilterBuilder works, and the copy can
|
/* Check that copying a cleared #MctAppFilterBuilder works, and the copy can
|
||||||
* then be initialised and used to build a filter. */
|
* then be initialised and used to build a filter. */
|
||||||
static void
|
static void
|
||||||
test_app_filter_builder_copy_empty (void)
|
test_app_filter_builder_copy_empty (void)
|
||||||
{
|
{
|
||||||
g_autoptr(EpcAppFilterBuilder) builder = epc_app_filter_builder_new ();
|
g_autoptr(MctAppFilterBuilder) builder = mct_app_filter_builder_new ();
|
||||||
g_autoptr(EpcAppFilterBuilder) builder_copy = NULL;
|
g_autoptr(MctAppFilterBuilder) builder_copy = NULL;
|
||||||
g_autoptr(EpcAppFilter) filter = NULL;
|
g_autoptr(MctAppFilter) filter = NULL;
|
||||||
|
|
||||||
epc_app_filter_builder_clear (builder);
|
mct_app_filter_builder_clear (builder);
|
||||||
builder_copy = epc_app_filter_builder_copy (builder);
|
builder_copy = mct_app_filter_builder_copy (builder);
|
||||||
|
|
||||||
epc_app_filter_builder_init (builder_copy);
|
mct_app_filter_builder_init (builder_copy);
|
||||||
epc_app_filter_builder_blacklist_path (builder_copy, "/bin/true");
|
mct_app_filter_builder_blacklist_path (builder_copy, "/bin/true");
|
||||||
filter = epc_app_filter_builder_end (builder_copy);
|
filter = mct_app_filter_builder_end (builder_copy);
|
||||||
|
|
||||||
g_assert_true (epc_app_filter_is_path_allowed (filter, "/bin/false"));
|
g_assert_true (mct_app_filter_is_path_allowed (filter, "/bin/false"));
|
||||||
g_assert_false (epc_app_filter_is_path_allowed (filter, "/bin/true"));
|
g_assert_false (mct_app_filter_is_path_allowed (filter, "/bin/true"));
|
||||||
|
|
||||||
g_assert_true (epc_app_filter_is_user_installation_allowed (filter));
|
g_assert_true (mct_app_filter_is_user_installation_allowed (filter));
|
||||||
g_assert_false (epc_app_filter_is_system_installation_allowed (filter));
|
g_assert_false (mct_app_filter_is_system_installation_allowed (filter));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check that copying a filled #EpcAppFilterBuilder works, and the copy can be
|
/* Check that copying a filled #MctAppFilterBuilder works, and the copy can be
|
||||||
* used to build a filter. */
|
* used to build a filter. */
|
||||||
static void
|
static void
|
||||||
test_app_filter_builder_copy_full (void)
|
test_app_filter_builder_copy_full (void)
|
||||||
{
|
{
|
||||||
g_autoptr(EpcAppFilterBuilder) builder = epc_app_filter_builder_new ();
|
g_autoptr(MctAppFilterBuilder) builder = mct_app_filter_builder_new ();
|
||||||
g_autoptr(EpcAppFilterBuilder) builder_copy = NULL;
|
g_autoptr(MctAppFilterBuilder) builder_copy = NULL;
|
||||||
g_autoptr(EpcAppFilter) filter = NULL;
|
g_autoptr(MctAppFilter) filter = NULL;
|
||||||
|
|
||||||
epc_app_filter_builder_blacklist_path (builder, "/bin/true");
|
mct_app_filter_builder_blacklist_path (builder, "/bin/true");
|
||||||
epc_app_filter_builder_set_allow_user_installation (builder, FALSE);
|
mct_app_filter_builder_set_allow_user_installation (builder, FALSE);
|
||||||
epc_app_filter_builder_set_allow_system_installation (builder, TRUE);
|
mct_app_filter_builder_set_allow_system_installation (builder, TRUE);
|
||||||
builder_copy = epc_app_filter_builder_copy (builder);
|
builder_copy = mct_app_filter_builder_copy (builder);
|
||||||
filter = epc_app_filter_builder_end (builder_copy);
|
filter = mct_app_filter_builder_end (builder_copy);
|
||||||
|
|
||||||
g_assert_true (epc_app_filter_is_path_allowed (filter, "/bin/false"));
|
g_assert_true (mct_app_filter_is_path_allowed (filter, "/bin/false"));
|
||||||
g_assert_false (epc_app_filter_is_path_allowed (filter, "/bin/true"));
|
g_assert_false (mct_app_filter_is_path_allowed (filter, "/bin/true"));
|
||||||
g_assert_false (epc_app_filter_is_user_installation_allowed (filter));
|
g_assert_false (mct_app_filter_is_user_installation_allowed (filter));
|
||||||
g_assert_true (epc_app_filter_is_system_installation_allowed (filter));
|
g_assert_true (mct_app_filter_is_system_installation_allowed (filter));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check that various configurations of a #GAppInfo are accepted or rejected
|
/* Check that various configurations of a #GAppInfo are accepted or rejected
|
||||||
* as appropriate by epc_app_filter_is_appinfo_allowed(). */
|
* as appropriate by mct_app_filter_is_appinfo_allowed(). */
|
||||||
static void
|
static void
|
||||||
test_app_filter_appinfo (void)
|
test_app_filter_appinfo (void)
|
||||||
{
|
{
|
||||||
g_auto(EpcAppFilterBuilder) builder = EPC_APP_FILTER_BUILDER_INIT ();
|
g_auto(MctAppFilterBuilder) builder = MCT_APP_FILTER_BUILDER_INIT ();
|
||||||
g_autoptr(EpcAppFilter) filter = NULL;
|
g_autoptr(MctAppFilter) filter = NULL;
|
||||||
const struct
|
const struct
|
||||||
{
|
{
|
||||||
gboolean expected_allowed;
|
gboolean expected_allowed;
|
||||||
|
@ -379,10 +379,10 @@ test_app_filter_appinfo (void)
|
||||||
"X-Flatpak-RenamedFrom=org.gnome.Nasty.desktop;\n" },
|
"X-Flatpak-RenamedFrom=org.gnome.Nasty.desktop;\n" },
|
||||||
};
|
};
|
||||||
|
|
||||||
epc_app_filter_builder_blacklist_path (&builder, "/bin/false");
|
mct_app_filter_builder_blacklist_path (&builder, "/bin/false");
|
||||||
epc_app_filter_builder_blacklist_flatpak_ref (&builder, "app/org.gnome.Nasty/x86_64/stable");
|
mct_app_filter_builder_blacklist_flatpak_ref (&builder, "app/org.gnome.Nasty/x86_64/stable");
|
||||||
|
|
||||||
filter = epc_app_filter_builder_end (&builder);
|
filter = mct_app_filter_builder_end (&builder);
|
||||||
|
|
||||||
for (gsize i = 0; i < G_N_ELEMENTS (vectors); i++)
|
for (gsize i = 0; i < G_N_ELEMENTS (vectors); i++)
|
||||||
{
|
{
|
||||||
|
@ -402,9 +402,9 @@ test_app_filter_appinfo (void)
|
||||||
g_assert_nonnull (appinfo);
|
g_assert_nonnull (appinfo);
|
||||||
|
|
||||||
if (vectors[i].expected_allowed)
|
if (vectors[i].expected_allowed)
|
||||||
g_assert_true (epc_app_filter_is_appinfo_allowed (filter, appinfo));
|
g_assert_true (mct_app_filter_is_appinfo_allowed (filter, appinfo));
|
||||||
else
|
else
|
||||||
g_assert_false (epc_app_filter_is_appinfo_allowed (filter, appinfo));
|
g_assert_false (mct_app_filter_is_appinfo_allowed (filter, appinfo));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -477,7 +477,7 @@ async_result_cb (GObject *obj,
|
||||||
/* Generic mock accountsservice implementation which returns the properties
|
/* Generic mock accountsservice implementation which returns the properties
|
||||||
* given in #GetAppFilterData.properties if queried for a UID matching
|
* given in #GetAppFilterData.properties if queried for a UID matching
|
||||||
* #GetAppFilterData.expected_uid. Intended to be used for writing ‘successful’
|
* #GetAppFilterData.expected_uid. Intended to be used for writing ‘successful’
|
||||||
* epc_get_app_filter() tests returning a variety of values. */
|
* mct_get_app_filter() tests returning a variety of values. */
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
uid_t expected_uid;
|
uid_t expected_uid;
|
||||||
|
@ -522,7 +522,7 @@ get_app_filter_server_cb (GtDBusQueue *queue,
|
||||||
g_variant_new_tuple (&properties_variant, 1));
|
g_variant_new_tuple (&properties_variant, 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Test that getting an #EpcAppFilter from the mock D-Bus service works. The
|
/* Test that getting an #MctAppFilter from the mock D-Bus service works. The
|
||||||
* @test_data is a boolean value indicating whether to do the call
|
* @test_data is a boolean value indicating whether to do the call
|
||||||
* synchronously (%FALSE) or asynchronously (%TRUE).
|
* synchronously (%FALSE) or asynchronously (%TRUE).
|
||||||
*
|
*
|
||||||
|
@ -532,7 +532,7 @@ static void
|
||||||
test_app_filter_bus_get (BusFixture *fixture,
|
test_app_filter_bus_get (BusFixture *fixture,
|
||||||
gconstpointer test_data)
|
gconstpointer test_data)
|
||||||
{
|
{
|
||||||
g_autoptr(EpcAppFilter) app_filter = NULL;
|
g_autoptr(MctAppFilter) app_filter = NULL;
|
||||||
g_autoptr(GError) local_error = NULL;
|
g_autoptr(GError) local_error = NULL;
|
||||||
gboolean test_async = GPOINTER_TO_UINT (test_data);
|
gboolean test_async = GPOINTER_TO_UINT (test_data);
|
||||||
const GetAppFilterData get_app_filter_data =
|
const GetAppFilterData get_app_filter_data =
|
||||||
|
@ -553,17 +553,17 @@ test_app_filter_bus_get (BusFixture *fixture,
|
||||||
{
|
{
|
||||||
g_autoptr(GAsyncResult) result = NULL;
|
g_autoptr(GAsyncResult) result = NULL;
|
||||||
|
|
||||||
epc_get_app_filter_async (gt_dbus_queue_get_client_connection (fixture->queue),
|
mct_get_app_filter_async (gt_dbus_queue_get_client_connection (fixture->queue),
|
||||||
fixture->valid_uid,
|
fixture->valid_uid,
|
||||||
FALSE, NULL, async_result_cb, &result);
|
FALSE, NULL, async_result_cb, &result);
|
||||||
|
|
||||||
while (result == NULL)
|
while (result == NULL)
|
||||||
g_main_context_iteration (NULL, TRUE);
|
g_main_context_iteration (NULL, TRUE);
|
||||||
app_filter = epc_get_app_filter_finish (result, &local_error);
|
app_filter = mct_get_app_filter_finish (result, &local_error);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
app_filter = epc_get_app_filter (gt_dbus_queue_get_client_connection (fixture->queue),
|
app_filter = mct_get_app_filter (gt_dbus_queue_get_client_connection (fixture->queue),
|
||||||
fixture->valid_uid,
|
fixture->valid_uid,
|
||||||
FALSE, NULL, &local_error);
|
FALSE, NULL, &local_error);
|
||||||
}
|
}
|
||||||
|
@ -572,13 +572,13 @@ test_app_filter_bus_get (BusFixture *fixture,
|
||||||
g_assert_nonnull (app_filter);
|
g_assert_nonnull (app_filter);
|
||||||
|
|
||||||
/* Check the app filter properties. */
|
/* Check the app filter properties. */
|
||||||
g_assert_cmpuint (epc_app_filter_get_user_id (app_filter), ==, fixture->valid_uid);
|
g_assert_cmpuint (mct_app_filter_get_user_id (app_filter), ==, fixture->valid_uid);
|
||||||
g_assert_false (epc_app_filter_is_flatpak_app_allowed (app_filter, "org.gnome.Builder"));
|
g_assert_false (mct_app_filter_is_flatpak_app_allowed (app_filter, "org.gnome.Builder"));
|
||||||
g_assert_true (epc_app_filter_is_flatpak_app_allowed (app_filter, "org.gnome.Chess"));
|
g_assert_true (mct_app_filter_is_flatpak_app_allowed (app_filter, "org.gnome.Chess"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Test that getting an #EpcAppFilter containing a whitelist from the mock D-Bus
|
/* Test that getting an #MctAppFilter containing a whitelist from the mock D-Bus
|
||||||
* service works, and that the #EpcAppFilter methods handle the whitelist
|
* service works, and that the #MctAppFilter methods handle the whitelist
|
||||||
* correctly.
|
* correctly.
|
||||||
*
|
*
|
||||||
* The mock D-Bus replies are generated in get_app_filter_server_cb(). */
|
* The mock D-Bus replies are generated in get_app_filter_server_cb(). */
|
||||||
|
@ -586,7 +586,7 @@ static void
|
||||||
test_app_filter_bus_get_whitelist (BusFixture *fixture,
|
test_app_filter_bus_get_whitelist (BusFixture *fixture,
|
||||||
gconstpointer test_data)
|
gconstpointer test_data)
|
||||||
{
|
{
|
||||||
g_autoptr(EpcAppFilter) app_filter = NULL;
|
g_autoptr(MctAppFilter) app_filter = NULL;
|
||||||
g_autoptr(GError) local_error = NULL;
|
g_autoptr(GError) local_error = NULL;
|
||||||
const GetAppFilterData get_app_filter_data =
|
const GetAppFilterData get_app_filter_data =
|
||||||
{
|
{
|
||||||
|
@ -606,7 +606,7 @@ test_app_filter_bus_get_whitelist (BusFixture *fixture,
|
||||||
gt_dbus_queue_set_server_func (fixture->queue, get_app_filter_server_cb,
|
gt_dbus_queue_set_server_func (fixture->queue, get_app_filter_server_cb,
|
||||||
(gpointer) &get_app_filter_data);
|
(gpointer) &get_app_filter_data);
|
||||||
|
|
||||||
app_filter = epc_get_app_filter (gt_dbus_queue_get_client_connection (fixture->queue),
|
app_filter = mct_get_app_filter (gt_dbus_queue_get_client_connection (fixture->queue),
|
||||||
fixture->valid_uid,
|
fixture->valid_uid,
|
||||||
FALSE, NULL, &local_error);
|
FALSE, NULL, &local_error);
|
||||||
|
|
||||||
|
@ -615,18 +615,18 @@ test_app_filter_bus_get_whitelist (BusFixture *fixture,
|
||||||
|
|
||||||
/* Check the app filter properties. The returned filter is a whitelist,
|
/* Check the app filter properties. The returned filter is a whitelist,
|
||||||
* whereas typically a blacklist is returned. */
|
* whereas typically a blacklist is returned. */
|
||||||
g_assert_cmpuint (epc_app_filter_get_user_id (app_filter), ==, fixture->valid_uid);
|
g_assert_cmpuint (mct_app_filter_get_user_id (app_filter), ==, fixture->valid_uid);
|
||||||
g_assert_false (epc_app_filter_is_flatpak_app_allowed (app_filter, "org.gnome.Builder"));
|
g_assert_false (mct_app_filter_is_flatpak_app_allowed (app_filter, "org.gnome.Builder"));
|
||||||
g_assert_true (epc_app_filter_is_flatpak_app_allowed (app_filter, "org.gnome.Whitelisted1"));
|
g_assert_true (mct_app_filter_is_flatpak_app_allowed (app_filter, "org.gnome.Whitelisted1"));
|
||||||
g_assert_true (epc_app_filter_is_flatpak_app_allowed (app_filter, "org.gnome.Whitelisted2"));
|
g_assert_true (mct_app_filter_is_flatpak_app_allowed (app_filter, "org.gnome.Whitelisted2"));
|
||||||
g_assert_true (epc_app_filter_is_flatpak_ref_allowed (app_filter, "app/org.gnome.Whitelisted1/x86_64/stable"));
|
g_assert_true (mct_app_filter_is_flatpak_ref_allowed (app_filter, "app/org.gnome.Whitelisted1/x86_64/stable"));
|
||||||
g_assert_false (epc_app_filter_is_flatpak_ref_allowed (app_filter, "app/org.gnome.Whitelisted1/x86_64/unknown"));
|
g_assert_false (mct_app_filter_is_flatpak_ref_allowed (app_filter, "app/org.gnome.Whitelisted1/x86_64/unknown"));
|
||||||
g_assert_true (epc_app_filter_is_path_allowed (app_filter, "/usr/bin/true"));
|
g_assert_true (mct_app_filter_is_path_allowed (app_filter, "/usr/bin/true"));
|
||||||
g_assert_false (epc_app_filter_is_path_allowed (app_filter, "/usr/bin/false"));
|
g_assert_false (mct_app_filter_is_path_allowed (app_filter, "/usr/bin/false"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Test that getting an #EpcAppFilter containing all possible OARS values from
|
/* Test that getting an #MctAppFilter containing all possible OARS values from
|
||||||
* the mock D-Bus service works, and that the #EpcAppFilter methods handle them
|
* the mock D-Bus service works, and that the #MctAppFilter methods handle them
|
||||||
* correctly.
|
* correctly.
|
||||||
*
|
*
|
||||||
* The mock D-Bus replies are generated in get_app_filter_server_cb(). */
|
* The mock D-Bus replies are generated in get_app_filter_server_cb(). */
|
||||||
|
@ -634,7 +634,7 @@ static void
|
||||||
test_app_filter_bus_get_all_oars_values (BusFixture *fixture,
|
test_app_filter_bus_get_all_oars_values (BusFixture *fixture,
|
||||||
gconstpointer test_data)
|
gconstpointer test_data)
|
||||||
{
|
{
|
||||||
g_autoptr(EpcAppFilter) app_filter = NULL;
|
g_autoptr(MctAppFilter) app_filter = NULL;
|
||||||
g_autoptr(GError) local_error = NULL;
|
g_autoptr(GError) local_error = NULL;
|
||||||
const GetAppFilterData get_app_filter_data =
|
const GetAppFilterData get_app_filter_data =
|
||||||
{
|
{
|
||||||
|
@ -656,7 +656,7 @@ test_app_filter_bus_get_all_oars_values (BusFixture *fixture,
|
||||||
gt_dbus_queue_set_server_func (fixture->queue, get_app_filter_server_cb,
|
gt_dbus_queue_set_server_func (fixture->queue, get_app_filter_server_cb,
|
||||||
(gpointer) &get_app_filter_data);
|
(gpointer) &get_app_filter_data);
|
||||||
|
|
||||||
app_filter = epc_get_app_filter (gt_dbus_queue_get_client_connection (fixture->queue),
|
app_filter = mct_get_app_filter (gt_dbus_queue_get_client_connection (fixture->queue),
|
||||||
fixture->valid_uid,
|
fixture->valid_uid,
|
||||||
FALSE, NULL, &local_error);
|
FALSE, NULL, &local_error);
|
||||||
|
|
||||||
|
@ -665,23 +665,23 @@ test_app_filter_bus_get_all_oars_values (BusFixture *fixture,
|
||||||
|
|
||||||
/* Check the OARS filter properties. Each OARS value should have been parsed
|
/* Check the OARS filter properties. Each OARS value should have been parsed
|
||||||
* correctly, except for the unknown `other` one. */
|
* correctly, except for the unknown `other` one. */
|
||||||
g_assert_cmpuint (epc_app_filter_get_user_id (app_filter), ==, fixture->valid_uid);
|
g_assert_cmpuint (mct_app_filter_get_user_id (app_filter), ==, fixture->valid_uid);
|
||||||
g_assert_cmpint (epc_app_filter_get_oars_value (app_filter, "violence-bloodshed"), ==,
|
g_assert_cmpint (mct_app_filter_get_oars_value (app_filter, "violence-bloodshed"), ==,
|
||||||
EPC_APP_FILTER_OARS_VALUE_NONE);
|
MCT_APP_FILTER_OARS_VALUE_NONE);
|
||||||
g_assert_cmpint (epc_app_filter_get_oars_value (app_filter, "violence-sexual"), ==,
|
g_assert_cmpint (mct_app_filter_get_oars_value (app_filter, "violence-sexual"), ==,
|
||||||
EPC_APP_FILTER_OARS_VALUE_MILD);
|
MCT_APP_FILTER_OARS_VALUE_MILD);
|
||||||
g_assert_cmpint (epc_app_filter_get_oars_value (app_filter, "violence-fantasy"), ==,
|
g_assert_cmpint (mct_app_filter_get_oars_value (app_filter, "violence-fantasy"), ==,
|
||||||
EPC_APP_FILTER_OARS_VALUE_MODERATE);
|
MCT_APP_FILTER_OARS_VALUE_MODERATE);
|
||||||
g_assert_cmpint (epc_app_filter_get_oars_value (app_filter, "violence-realistic"), ==,
|
g_assert_cmpint (mct_app_filter_get_oars_value (app_filter, "violence-realistic"), ==,
|
||||||
EPC_APP_FILTER_OARS_VALUE_INTENSE);
|
MCT_APP_FILTER_OARS_VALUE_INTENSE);
|
||||||
g_assert_cmpint (epc_app_filter_get_oars_value (app_filter, "language-profanity"), ==,
|
g_assert_cmpint (mct_app_filter_get_oars_value (app_filter, "language-profanity"), ==,
|
||||||
EPC_APP_FILTER_OARS_VALUE_UNKNOWN);
|
MCT_APP_FILTER_OARS_VALUE_UNKNOWN);
|
||||||
g_assert_cmpint (epc_app_filter_get_oars_value (app_filter, "unlisted-category"), ==,
|
g_assert_cmpint (mct_app_filter_get_oars_value (app_filter, "unlisted-category"), ==,
|
||||||
EPC_APP_FILTER_OARS_VALUE_UNKNOWN);
|
MCT_APP_FILTER_OARS_VALUE_UNKNOWN);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Test that getting an #EpcAppFilter containing only an `AppFilter` property
|
/* Test that getting an #MctAppFilter containing only an `AppFilter` property
|
||||||
* from the mock D-Bus service works, and that the #EpcAppFilter methods use
|
* from the mock D-Bus service works, and that the #MctAppFilter methods use
|
||||||
* appropriate defaults.
|
* appropriate defaults.
|
||||||
*
|
*
|
||||||
* The mock D-Bus replies are generated in get_app_filter_server_cb(). */
|
* The mock D-Bus replies are generated in get_app_filter_server_cb(). */
|
||||||
|
@ -689,7 +689,7 @@ static void
|
||||||
test_app_filter_bus_get_defaults (BusFixture *fixture,
|
test_app_filter_bus_get_defaults (BusFixture *fixture,
|
||||||
gconstpointer test_data)
|
gconstpointer test_data)
|
||||||
{
|
{
|
||||||
g_autoptr(EpcAppFilter) app_filter = NULL;
|
g_autoptr(MctAppFilter) app_filter = NULL;
|
||||||
g_autoptr(GError) local_error = NULL;
|
g_autoptr(GError) local_error = NULL;
|
||||||
const GetAppFilterData get_app_filter_data =
|
const GetAppFilterData get_app_filter_data =
|
||||||
{
|
{
|
||||||
|
@ -703,7 +703,7 @@ test_app_filter_bus_get_defaults (BusFixture *fixture,
|
||||||
gt_dbus_queue_set_server_func (fixture->queue, get_app_filter_server_cb,
|
gt_dbus_queue_set_server_func (fixture->queue, get_app_filter_server_cb,
|
||||||
(gpointer) &get_app_filter_data);
|
(gpointer) &get_app_filter_data);
|
||||||
|
|
||||||
app_filter = epc_get_app_filter (gt_dbus_queue_get_client_connection (fixture->queue),
|
app_filter = mct_get_app_filter (gt_dbus_queue_get_client_connection (fixture->queue),
|
||||||
fixture->valid_uid,
|
fixture->valid_uid,
|
||||||
FALSE, NULL, &local_error);
|
FALSE, NULL, &local_error);
|
||||||
|
|
||||||
|
@ -711,16 +711,16 @@ test_app_filter_bus_get_defaults (BusFixture *fixture,
|
||||||
g_assert_nonnull (app_filter);
|
g_assert_nonnull (app_filter);
|
||||||
|
|
||||||
/* Check the default values for the properties. */
|
/* Check the default values for the properties. */
|
||||||
g_assert_cmpuint (epc_app_filter_get_user_id (app_filter), ==, fixture->valid_uid);
|
g_assert_cmpuint (mct_app_filter_get_user_id (app_filter), ==, fixture->valid_uid);
|
||||||
oars_sections = epc_app_filter_get_oars_sections (app_filter);
|
oars_sections = mct_app_filter_get_oars_sections (app_filter);
|
||||||
g_assert_cmpuint (g_strv_length ((gchar **) oars_sections), ==, 0);
|
g_assert_cmpuint (g_strv_length ((gchar **) oars_sections), ==, 0);
|
||||||
g_assert_cmpint (epc_app_filter_get_oars_value (app_filter, "violence-bloodshed"), ==,
|
g_assert_cmpint (mct_app_filter_get_oars_value (app_filter, "violence-bloodshed"), ==,
|
||||||
EPC_APP_FILTER_OARS_VALUE_UNKNOWN);
|
MCT_APP_FILTER_OARS_VALUE_UNKNOWN);
|
||||||
g_assert_true (epc_app_filter_is_user_installation_allowed (app_filter));
|
g_assert_true (mct_app_filter_is_user_installation_allowed (app_filter));
|
||||||
g_assert_false (epc_app_filter_is_system_installation_allowed (app_filter));
|
g_assert_false (mct_app_filter_is_system_installation_allowed (app_filter));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Test that epc_get_app_filter() returns an appropriate error if the mock D-Bus
|
/* Test that mct_get_app_filter() returns an appropriate error if the mock D-Bus
|
||||||
* service reports that the given user cannot be found.
|
* service reports that the given user cannot be found.
|
||||||
*
|
*
|
||||||
* The mock D-Bus replies are generated inline. */
|
* The mock D-Bus replies are generated inline. */
|
||||||
|
@ -732,9 +732,9 @@ test_app_filter_bus_get_error_invalid_user (BusFixture *fixture,
|
||||||
g_autoptr(GError) local_error = NULL;
|
g_autoptr(GError) local_error = NULL;
|
||||||
g_autoptr(GDBusMethodInvocation) invocation = NULL;
|
g_autoptr(GDBusMethodInvocation) invocation = NULL;
|
||||||
g_autofree gchar *error_message = NULL;
|
g_autofree gchar *error_message = NULL;
|
||||||
g_autoptr(EpcAppFilter) app_filter = NULL;
|
g_autoptr(MctAppFilter) app_filter = NULL;
|
||||||
|
|
||||||
epc_get_app_filter_async (gt_dbus_queue_get_client_connection (fixture->queue),
|
mct_get_app_filter_async (gt_dbus_queue_get_client_connection (fixture->queue),
|
||||||
fixture->missing_uid,
|
fixture->missing_uid,
|
||||||
FALSE, NULL, async_result_cb, &result);
|
FALSE, NULL, async_result_cb, &result);
|
||||||
|
|
||||||
|
@ -755,14 +755,14 @@ test_app_filter_bus_get_error_invalid_user (BusFixture *fixture,
|
||||||
/* Get the get_app_filter() result. */
|
/* Get the get_app_filter() result. */
|
||||||
while (result == NULL)
|
while (result == NULL)
|
||||||
g_main_context_iteration (NULL, TRUE);
|
g_main_context_iteration (NULL, TRUE);
|
||||||
app_filter = epc_get_app_filter_finish (result, &local_error);
|
app_filter = mct_get_app_filter_finish (result, &local_error);
|
||||||
|
|
||||||
g_assert_error (local_error,
|
g_assert_error (local_error,
|
||||||
EPC_APP_FILTER_ERROR, EPC_APP_FILTER_ERROR_INVALID_USER);
|
MCT_APP_FILTER_ERROR, MCT_APP_FILTER_ERROR_INVALID_USER);
|
||||||
g_assert_null (app_filter);
|
g_assert_null (app_filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Test that epc_get_app_filter() returns an appropriate error if the mock D-Bus
|
/* Test that mct_get_app_filter() returns an appropriate error if the mock D-Bus
|
||||||
* service reports that the properties of the given user can’t be accessed due
|
* service reports that the properties of the given user can’t be accessed due
|
||||||
* to permissions.
|
* to permissions.
|
||||||
*
|
*
|
||||||
|
@ -776,9 +776,9 @@ test_app_filter_bus_get_error_permission_denied (BusFixture *fixture,
|
||||||
g_autoptr(GDBusMethodInvocation) invocation1 = NULL;
|
g_autoptr(GDBusMethodInvocation) invocation1 = NULL;
|
||||||
g_autoptr(GDBusMethodInvocation) invocation2 = NULL;
|
g_autoptr(GDBusMethodInvocation) invocation2 = NULL;
|
||||||
g_autofree gchar *object_path = NULL;
|
g_autofree gchar *object_path = NULL;
|
||||||
g_autoptr(EpcAppFilter) app_filter = NULL;
|
g_autoptr(MctAppFilter) app_filter = NULL;
|
||||||
|
|
||||||
epc_get_app_filter_async (gt_dbus_queue_get_client_connection (fixture->queue),
|
mct_get_app_filter_async (gt_dbus_queue_get_client_connection (fixture->queue),
|
||||||
fixture->valid_uid,
|
fixture->valid_uid,
|
||||||
FALSE, NULL, async_result_cb, &result);
|
FALSE, NULL, async_result_cb, &result);
|
||||||
|
|
||||||
|
@ -810,14 +810,14 @@ test_app_filter_bus_get_error_permission_denied (BusFixture *fixture,
|
||||||
/* Get the get_app_filter() result. */
|
/* Get the get_app_filter() result. */
|
||||||
while (result == NULL)
|
while (result == NULL)
|
||||||
g_main_context_iteration (NULL, TRUE);
|
g_main_context_iteration (NULL, TRUE);
|
||||||
app_filter = epc_get_app_filter_finish (result, &local_error);
|
app_filter = mct_get_app_filter_finish (result, &local_error);
|
||||||
|
|
||||||
g_assert_error (local_error,
|
g_assert_error (local_error,
|
||||||
EPC_APP_FILTER_ERROR, EPC_APP_FILTER_ERROR_PERMISSION_DENIED);
|
MCT_APP_FILTER_ERROR, MCT_APP_FILTER_ERROR_PERMISSION_DENIED);
|
||||||
g_assert_null (app_filter);
|
g_assert_null (app_filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Test that epc_get_app_filter() returns an appropriate error if the mock D-Bus
|
/* Test that mct_get_app_filter() returns an appropriate error if the mock D-Bus
|
||||||
* service replies with no app filter properties (implying that it hasn’t sent
|
* service replies with no app filter properties (implying that it hasn’t sent
|
||||||
* the property values because of permissions).
|
* the property values because of permissions).
|
||||||
*
|
*
|
||||||
|
@ -831,9 +831,9 @@ test_app_filter_bus_get_error_permission_denied_missing (BusFixture *fixture,
|
||||||
g_autoptr(GDBusMethodInvocation) invocation1 = NULL;
|
g_autoptr(GDBusMethodInvocation) invocation1 = NULL;
|
||||||
g_autoptr(GDBusMethodInvocation) invocation2 = NULL;
|
g_autoptr(GDBusMethodInvocation) invocation2 = NULL;
|
||||||
g_autofree gchar *object_path = NULL;
|
g_autofree gchar *object_path = NULL;
|
||||||
g_autoptr(EpcAppFilter) app_filter = NULL;
|
g_autoptr(MctAppFilter) app_filter = NULL;
|
||||||
|
|
||||||
epc_get_app_filter_async (gt_dbus_queue_get_client_connection (fixture->queue),
|
mct_get_app_filter_async (gt_dbus_queue_get_client_connection (fixture->queue),
|
||||||
fixture->valid_uid,
|
fixture->valid_uid,
|
||||||
FALSE, NULL, async_result_cb, &result);
|
FALSE, NULL, async_result_cb, &result);
|
||||||
|
|
||||||
|
@ -866,14 +866,14 @@ test_app_filter_bus_get_error_permission_denied_missing (BusFixture *fixture,
|
||||||
/* Get the get_app_filter() result. */
|
/* Get the get_app_filter() result. */
|
||||||
while (result == NULL)
|
while (result == NULL)
|
||||||
g_main_context_iteration (NULL, TRUE);
|
g_main_context_iteration (NULL, TRUE);
|
||||||
app_filter = epc_get_app_filter_finish (result, &local_error);
|
app_filter = mct_get_app_filter_finish (result, &local_error);
|
||||||
|
|
||||||
g_assert_error (local_error,
|
g_assert_error (local_error,
|
||||||
EPC_APP_FILTER_ERROR, EPC_APP_FILTER_ERROR_PERMISSION_DENIED);
|
MCT_APP_FILTER_ERROR, MCT_APP_FILTER_ERROR_PERMISSION_DENIED);
|
||||||
g_assert_null (app_filter);
|
g_assert_null (app_filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Test that epc_get_app_filter() returns an error if the mock D-Bus service
|
/* Test that mct_get_app_filter() returns an error if the mock D-Bus service
|
||||||
* reports an unrecognised error.
|
* reports an unrecognised error.
|
||||||
*
|
*
|
||||||
* The mock D-Bus replies are generated inline. */
|
* The mock D-Bus replies are generated inline. */
|
||||||
|
@ -884,9 +884,9 @@ test_app_filter_bus_get_error_unknown (BusFixture *fixture,
|
||||||
g_autoptr(GAsyncResult) result = NULL;
|
g_autoptr(GAsyncResult) result = NULL;
|
||||||
g_autoptr(GError) local_error = NULL;
|
g_autoptr(GError) local_error = NULL;
|
||||||
g_autoptr(GDBusMethodInvocation) invocation = NULL;
|
g_autoptr(GDBusMethodInvocation) invocation = NULL;
|
||||||
g_autoptr(EpcAppFilter) app_filter = NULL;
|
g_autoptr(MctAppFilter) app_filter = NULL;
|
||||||
|
|
||||||
epc_get_app_filter_async (gt_dbus_queue_get_client_connection (fixture->queue),
|
mct_get_app_filter_async (gt_dbus_queue_get_client_connection (fixture->queue),
|
||||||
fixture->valid_uid,
|
fixture->valid_uid,
|
||||||
FALSE, NULL, async_result_cb, &result);
|
FALSE, NULL, async_result_cb, &result);
|
||||||
|
|
||||||
|
@ -902,14 +902,14 @@ test_app_filter_bus_get_error_unknown (BusFixture *fixture,
|
||||||
g_dbus_method_invocation_return_dbus_error (invocation,
|
g_dbus_method_invocation_return_dbus_error (invocation,
|
||||||
"org.freedesktop.Accounts.Error.NewAndInterestingError",
|
"org.freedesktop.Accounts.Error.NewAndInterestingError",
|
||||||
"This is a fake error message "
|
"This is a fake error message "
|
||||||
"which libeos-parental-controls "
|
"which libmalcontent "
|
||||||
"will never have seen before, "
|
"will never have seen before, "
|
||||||
"but must still handle correctly");
|
"but must still handle correctly");
|
||||||
|
|
||||||
/* Get the get_app_filter() result. */
|
/* Get the get_app_filter() result. */
|
||||||
while (result == NULL)
|
while (result == NULL)
|
||||||
g_main_context_iteration (NULL, TRUE);
|
g_main_context_iteration (NULL, TRUE);
|
||||||
app_filter = epc_get_app_filter_finish (result, &local_error);
|
app_filter = mct_get_app_filter_finish (result, &local_error);
|
||||||
|
|
||||||
/* We don’t actually care what error is actually used here. */
|
/* We don’t actually care what error is actually used here. */
|
||||||
g_assert_error (local_error, G_IO_ERROR, G_IO_ERROR_DBUS_ERROR);
|
g_assert_error (local_error, G_IO_ERROR, G_IO_ERROR_DBUS_ERROR);
|
||||||
|
@ -1023,7 +1023,7 @@ set_app_filter_server_cb (GtDBusQueue *queue,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Test that setting an #EpcAppFilter on the mock D-Bus service works. The
|
/* Test that setting an #MctAppFilter on the mock D-Bus service works. The
|
||||||
* @test_data is a boolean value indicating whether to do the call
|
* @test_data is a boolean value indicating whether to do the call
|
||||||
* synchronously (%FALSE) or asynchronously (%TRUE).
|
* synchronously (%FALSE) or asynchronously (%TRUE).
|
||||||
*
|
*
|
||||||
|
@ -1034,8 +1034,8 @@ test_app_filter_bus_set (BusFixture *fixture,
|
||||||
gconstpointer test_data)
|
gconstpointer test_data)
|
||||||
{
|
{
|
||||||
gboolean success;
|
gboolean success;
|
||||||
g_auto(EpcAppFilterBuilder) builder = EPC_APP_FILTER_BUILDER_INIT ();
|
g_auto(MctAppFilterBuilder) builder = MCT_APP_FILTER_BUILDER_INIT ();
|
||||||
g_autoptr(EpcAppFilter) app_filter = NULL;
|
g_autoptr(MctAppFilter) app_filter = NULL;
|
||||||
g_autoptr(GError) local_error = NULL;
|
g_autoptr(GError) local_error = NULL;
|
||||||
gboolean test_async = GPOINTER_TO_UINT (test_data);
|
gboolean test_async = GPOINTER_TO_UINT (test_data);
|
||||||
const SetAppFilterData set_app_filter_data =
|
const SetAppFilterData set_app_filter_data =
|
||||||
|
@ -1049,14 +1049,14 @@ test_app_filter_bus_set (BusFixture *fixture,
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Build an app filter. */
|
/* Build an app filter. */
|
||||||
epc_app_filter_builder_blacklist_path (&builder, "/usr/bin/false");
|
mct_app_filter_builder_blacklist_path (&builder, "/usr/bin/false");
|
||||||
epc_app_filter_builder_blacklist_path (&builder, "/usr/bin/banned");
|
mct_app_filter_builder_blacklist_path (&builder, "/usr/bin/banned");
|
||||||
epc_app_filter_builder_blacklist_flatpak_ref (&builder, "app/org.gnome.Nasty/x86_64/stable");
|
mct_app_filter_builder_blacklist_flatpak_ref (&builder, "app/org.gnome.Nasty/x86_64/stable");
|
||||||
epc_app_filter_builder_set_oars_value (&builder, "violence-fantasy", EPC_APP_FILTER_OARS_VALUE_INTENSE);
|
mct_app_filter_builder_set_oars_value (&builder, "violence-fantasy", MCT_APP_FILTER_OARS_VALUE_INTENSE);
|
||||||
epc_app_filter_builder_set_allow_user_installation (&builder, TRUE);
|
mct_app_filter_builder_set_allow_user_installation (&builder, TRUE);
|
||||||
epc_app_filter_builder_set_allow_system_installation (&builder, TRUE);
|
mct_app_filter_builder_set_allow_system_installation (&builder, TRUE);
|
||||||
|
|
||||||
app_filter = epc_app_filter_builder_end (&builder);
|
app_filter = mct_app_filter_builder_end (&builder);
|
||||||
|
|
||||||
/* Set the mock service function and set the filter. */
|
/* Set the mock service function and set the filter. */
|
||||||
gt_dbus_queue_set_server_func (fixture->queue, set_app_filter_server_cb,
|
gt_dbus_queue_set_server_func (fixture->queue, set_app_filter_server_cb,
|
||||||
|
@ -1066,17 +1066,17 @@ test_app_filter_bus_set (BusFixture *fixture,
|
||||||
{
|
{
|
||||||
g_autoptr(GAsyncResult) result = NULL;
|
g_autoptr(GAsyncResult) result = NULL;
|
||||||
|
|
||||||
epc_set_app_filter_async (gt_dbus_queue_get_client_connection (fixture->queue),
|
mct_set_app_filter_async (gt_dbus_queue_get_client_connection (fixture->queue),
|
||||||
fixture->valid_uid, app_filter,
|
fixture->valid_uid, app_filter,
|
||||||
FALSE, NULL, async_result_cb, &result);
|
FALSE, NULL, async_result_cb, &result);
|
||||||
|
|
||||||
while (result == NULL)
|
while (result == NULL)
|
||||||
g_main_context_iteration (NULL, TRUE);
|
g_main_context_iteration (NULL, TRUE);
|
||||||
success = epc_set_app_filter_finish (result, &local_error);
|
success = mct_set_app_filter_finish (result, &local_error);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
success = epc_set_app_filter (gt_dbus_queue_get_client_connection (fixture->queue),
|
success = mct_set_app_filter (gt_dbus_queue_get_client_connection (fixture->queue),
|
||||||
fixture->valid_uid, app_filter,
|
fixture->valid_uid, app_filter,
|
||||||
FALSE, NULL, &local_error);
|
FALSE, NULL, &local_error);
|
||||||
}
|
}
|
||||||
|
@ -1085,7 +1085,7 @@ test_app_filter_bus_set (BusFixture *fixture,
|
||||||
g_assert_true (success);
|
g_assert_true (success);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Test that epc_set_app_filter() returns an appropriate error if the mock D-Bus
|
/* Test that mct_set_app_filter() returns an appropriate error if the mock D-Bus
|
||||||
* service reports that the given user cannot be found.
|
* service reports that the given user cannot be found.
|
||||||
*
|
*
|
||||||
* The mock D-Bus replies are generated inline. */
|
* The mock D-Bus replies are generated inline. */
|
||||||
|
@ -1094,17 +1094,17 @@ test_app_filter_bus_set_error_invalid_user (BusFixture *fixture,
|
||||||
gconstpointer test_data)
|
gconstpointer test_data)
|
||||||
{
|
{
|
||||||
gboolean success;
|
gboolean success;
|
||||||
g_auto(EpcAppFilterBuilder) builder = EPC_APP_FILTER_BUILDER_INIT ();
|
g_auto(MctAppFilterBuilder) builder = MCT_APP_FILTER_BUILDER_INIT ();
|
||||||
g_autoptr(EpcAppFilter) app_filter = NULL;
|
g_autoptr(MctAppFilter) app_filter = NULL;
|
||||||
g_autoptr(GAsyncResult) result = NULL;
|
g_autoptr(GAsyncResult) result = NULL;
|
||||||
g_autoptr(GError) local_error = NULL;
|
g_autoptr(GError) local_error = NULL;
|
||||||
g_autoptr(GDBusMethodInvocation) invocation = NULL;
|
g_autoptr(GDBusMethodInvocation) invocation = NULL;
|
||||||
g_autofree gchar *error_message = NULL;
|
g_autofree gchar *error_message = NULL;
|
||||||
|
|
||||||
/* Use the default app filter. */
|
/* Use the default app filter. */
|
||||||
app_filter = epc_app_filter_builder_end (&builder);
|
app_filter = mct_app_filter_builder_end (&builder);
|
||||||
|
|
||||||
epc_set_app_filter_async (gt_dbus_queue_get_client_connection (fixture->queue),
|
mct_set_app_filter_async (gt_dbus_queue_get_client_connection (fixture->queue),
|
||||||
fixture->missing_uid, app_filter,
|
fixture->missing_uid, app_filter,
|
||||||
FALSE, NULL, async_result_cb, &result);
|
FALSE, NULL, async_result_cb, &result);
|
||||||
|
|
||||||
|
@ -1125,14 +1125,14 @@ test_app_filter_bus_set_error_invalid_user (BusFixture *fixture,
|
||||||
/* Get the set_app_filter() result. */
|
/* Get the set_app_filter() result. */
|
||||||
while (result == NULL)
|
while (result == NULL)
|
||||||
g_main_context_iteration (NULL, TRUE);
|
g_main_context_iteration (NULL, TRUE);
|
||||||
success = epc_set_app_filter_finish (result, &local_error);
|
success = mct_set_app_filter_finish (result, &local_error);
|
||||||
|
|
||||||
g_assert_error (local_error,
|
g_assert_error (local_error,
|
||||||
EPC_APP_FILTER_ERROR, EPC_APP_FILTER_ERROR_INVALID_USER);
|
MCT_APP_FILTER_ERROR, MCT_APP_FILTER_ERROR_INVALID_USER);
|
||||||
g_assert_false (success);
|
g_assert_false (success);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Test that epc_set_app_filter() returns an appropriate error if the mock D-Bus
|
/* Test that mct_set_app_filter() returns an appropriate error if the mock D-Bus
|
||||||
* service replies with a permission denied error when setting properties.
|
* service replies with a permission denied error when setting properties.
|
||||||
*
|
*
|
||||||
* The mock D-Bus replies are generated in set_app_filter_server_cb(). */
|
* The mock D-Bus replies are generated in set_app_filter_server_cb(). */
|
||||||
|
@ -1141,8 +1141,8 @@ test_app_filter_bus_set_error_permission_denied (BusFixture *fixture,
|
||||||
gconstpointer test_data)
|
gconstpointer test_data)
|
||||||
{
|
{
|
||||||
gboolean success;
|
gboolean success;
|
||||||
g_auto(EpcAppFilterBuilder) builder = EPC_APP_FILTER_BUILDER_INIT ();
|
g_auto(MctAppFilterBuilder) builder = MCT_APP_FILTER_BUILDER_INIT ();
|
||||||
g_autoptr(EpcAppFilter) app_filter = NULL;
|
g_autoptr(MctAppFilter) app_filter = NULL;
|
||||||
g_autoptr(GError) local_error = NULL;
|
g_autoptr(GError) local_error = NULL;
|
||||||
const SetAppFilterData set_app_filter_data =
|
const SetAppFilterData set_app_filter_data =
|
||||||
{
|
{
|
||||||
|
@ -1153,21 +1153,21 @@ test_app_filter_bus_set_error_permission_denied (BusFixture *fixture,
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Use the default app filter. */
|
/* Use the default app filter. */
|
||||||
app_filter = epc_app_filter_builder_end (&builder);
|
app_filter = mct_app_filter_builder_end (&builder);
|
||||||
|
|
||||||
gt_dbus_queue_set_server_func (fixture->queue, set_app_filter_server_cb,
|
gt_dbus_queue_set_server_func (fixture->queue, set_app_filter_server_cb,
|
||||||
(gpointer) &set_app_filter_data);
|
(gpointer) &set_app_filter_data);
|
||||||
|
|
||||||
success = epc_set_app_filter (gt_dbus_queue_get_client_connection (fixture->queue),
|
success = mct_set_app_filter (gt_dbus_queue_get_client_connection (fixture->queue),
|
||||||
fixture->valid_uid, app_filter,
|
fixture->valid_uid, app_filter,
|
||||||
FALSE, NULL, &local_error);
|
FALSE, NULL, &local_error);
|
||||||
|
|
||||||
g_assert_error (local_error,
|
g_assert_error (local_error,
|
||||||
EPC_APP_FILTER_ERROR, EPC_APP_FILTER_ERROR_PERMISSION_DENIED);
|
MCT_APP_FILTER_ERROR, MCT_APP_FILTER_ERROR_PERMISSION_DENIED);
|
||||||
g_assert_false (success);
|
g_assert_false (success);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Test that epc_set_app_filter() returns an error if the mock D-Bus service
|
/* Test that mct_set_app_filter() returns an error if the mock D-Bus service
|
||||||
* reports an unrecognised error.
|
* reports an unrecognised error.
|
||||||
*
|
*
|
||||||
* The mock D-Bus replies are generated in set_app_filter_server_cb(). */
|
* The mock D-Bus replies are generated in set_app_filter_server_cb(). */
|
||||||
|
@ -1176,8 +1176,8 @@ test_app_filter_bus_set_error_unknown (BusFixture *fixture,
|
||||||
gconstpointer test_data)
|
gconstpointer test_data)
|
||||||
{
|
{
|
||||||
gboolean success;
|
gboolean success;
|
||||||
g_auto(EpcAppFilterBuilder) builder = EPC_APP_FILTER_BUILDER_INIT ();
|
g_auto(MctAppFilterBuilder) builder = MCT_APP_FILTER_BUILDER_INIT ();
|
||||||
g_autoptr(EpcAppFilter) app_filter = NULL;
|
g_autoptr(MctAppFilter) app_filter = NULL;
|
||||||
g_autoptr(GError) local_error = NULL;
|
g_autoptr(GError) local_error = NULL;
|
||||||
const SetAppFilterData set_app_filter_data =
|
const SetAppFilterData set_app_filter_data =
|
||||||
{
|
{
|
||||||
|
@ -1185,17 +1185,17 @@ test_app_filter_bus_set_error_unknown (BusFixture *fixture,
|
||||||
.error_index = 0,
|
.error_index = 0,
|
||||||
.dbus_error_name = "org.freedesktop.Accounts.Error.NewAndInterestingError",
|
.dbus_error_name = "org.freedesktop.Accounts.Error.NewAndInterestingError",
|
||||||
.dbus_error_message = "This is a fake error message which "
|
.dbus_error_message = "This is a fake error message which "
|
||||||
"libeos-parental-controls will never have seen "
|
"libmalcontent will never have seen "
|
||||||
"before, but must still handle correctly",
|
"before, but must still handle correctly",
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Use the default app filter. */
|
/* Use the default app filter. */
|
||||||
app_filter = epc_app_filter_builder_end (&builder);
|
app_filter = mct_app_filter_builder_end (&builder);
|
||||||
|
|
||||||
gt_dbus_queue_set_server_func (fixture->queue, set_app_filter_server_cb,
|
gt_dbus_queue_set_server_func (fixture->queue, set_app_filter_server_cb,
|
||||||
(gpointer) &set_app_filter_data);
|
(gpointer) &set_app_filter_data);
|
||||||
|
|
||||||
success = epc_set_app_filter (gt_dbus_queue_get_client_connection (fixture->queue),
|
success = mct_set_app_filter (gt_dbus_queue_get_client_connection (fixture->queue),
|
||||||
fixture->valid_uid, app_filter,
|
fixture->valid_uid, app_filter,
|
||||||
FALSE, NULL, &local_error);
|
FALSE, NULL, &local_error);
|
||||||
|
|
||||||
|
@ -1203,7 +1203,7 @@ test_app_filter_bus_set_error_unknown (BusFixture *fixture,
|
||||||
g_assert_false (success);
|
g_assert_false (success);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Test that epc_set_app_filter() returns an error if the mock D-Bus service
|
/* Test that mct_set_app_filter() returns an error if the mock D-Bus service
|
||||||
* reports an InvalidArgs error with a given one of its Set() calls.
|
* reports an InvalidArgs error with a given one of its Set() calls.
|
||||||
*
|
*
|
||||||
* @test_data contains a property index encoded with GINT_TO_POINTER(),
|
* @test_data contains a property index encoded with GINT_TO_POINTER(),
|
||||||
|
@ -1216,8 +1216,8 @@ test_app_filter_bus_set_error_invalid_property (BusFixture *fixture,
|
||||||
gconstpointer test_data)
|
gconstpointer test_data)
|
||||||
{
|
{
|
||||||
gboolean success;
|
gboolean success;
|
||||||
g_auto(EpcAppFilterBuilder) builder = EPC_APP_FILTER_BUILDER_INIT ();
|
g_auto(MctAppFilterBuilder) builder = MCT_APP_FILTER_BUILDER_INIT ();
|
||||||
g_autoptr(EpcAppFilter) app_filter = NULL;
|
g_autoptr(MctAppFilter) app_filter = NULL;
|
||||||
g_autoptr(GError) local_error = NULL;
|
g_autoptr(GError) local_error = NULL;
|
||||||
const SetAppFilterData set_app_filter_data =
|
const SetAppFilterData set_app_filter_data =
|
||||||
{
|
{
|
||||||
|
@ -1232,12 +1232,12 @@ test_app_filter_bus_set_error_invalid_property (BusFixture *fixture,
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Use the default app filter. */
|
/* Use the default app filter. */
|
||||||
app_filter = epc_app_filter_builder_end (&builder);
|
app_filter = mct_app_filter_builder_end (&builder);
|
||||||
|
|
||||||
gt_dbus_queue_set_server_func (fixture->queue, set_app_filter_server_cb,
|
gt_dbus_queue_set_server_func (fixture->queue, set_app_filter_server_cb,
|
||||||
(gpointer) &set_app_filter_data);
|
(gpointer) &set_app_filter_data);
|
||||||
|
|
||||||
success = epc_set_app_filter (gt_dbus_queue_get_client_connection (fixture->queue),
|
success = mct_set_app_filter (gt_dbus_queue_get_client_connection (fixture->queue),
|
||||||
fixture->valid_uid, app_filter,
|
fixture->valid_uid, app_filter,
|
||||||
FALSE, NULL, &local_error);
|
FALSE, NULL, &local_error);
|
||||||
|
|
|
@ -3,7 +3,7 @@ deps = [
|
||||||
dependency('gio-unix-2.0', version: '>= 2.44'),
|
dependency('gio-unix-2.0', version: '>= 2.44'),
|
||||||
dependency('glib-2.0', version: '>= 2.54.2'),
|
dependency('glib-2.0', version: '>= 2.54.2'),
|
||||||
dependency('gobject-2.0', version: '>= 2.44'),
|
dependency('gobject-2.0', version: '>= 2.44'),
|
||||||
libeos_parental_controls_dep,
|
libmalcontent_dep,
|
||||||
libglib_testing_dep,
|
libglib_testing_dep,
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -17,9 +17,9 @@ test_programs = [
|
||||||
]
|
]
|
||||||
|
|
||||||
installed_tests_metadir = join_paths(datadir, 'installed-tests',
|
installed_tests_metadir = join_paths(datadir, 'installed-tests',
|
||||||
'libeos-parental-controls-' + libeos_parental_controls_api_version)
|
'libmalcontent-' + libmalcontent_api_version)
|
||||||
installed_tests_execdir = join_paths(libexecdir, 'installed-tests',
|
installed_tests_execdir = join_paths(libexecdir, 'installed-tests',
|
||||||
'libeos-parental-controls-' + libeos_parental_controls_api_version)
|
'libmalcontent-' + libmalcontent_api_version)
|
||||||
|
|
||||||
foreach program: test_programs
|
foreach program: test_programs
|
||||||
test_conf = configuration_data()
|
test_conf = configuration_data()
|
|
@ -1,23 +1,23 @@
|
||||||
.\" Manpage for eos\-parental\-controls\-client.
|
.\" Manpage for malcontent\-client.
|
||||||
.\" Documentation is under the same licence as the eos\-parental\-controls
|
.\" Documentation is under the same licence as the malcontent
|
||||||
.\" package.
|
.\" package.
|
||||||
.TH man 8 "03 Oct 2018" "1.0" "eos\-parental\-controls\-client man page"
|
.TH man 8 "03 Oct 2018" "1.0" "malcontent\-client man page"
|
||||||
.\"
|
.\"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
.IX Header "NAME"
|
.IX Header "NAME"
|
||||||
eos\-parental\-controls\-client — Parental Controls Access Utility
|
malcontent\-client — Parental Controls Access Utility
|
||||||
.\"
|
.\"
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
.IX Header "SYNOPSIS"
|
.IX Header "SYNOPSIS"
|
||||||
.\"
|
.\"
|
||||||
\fBeos\-parental\-controls\-client get [\-q] [\-n] [\fPUSER\fB]
|
\fBmalcontent\-client get [\-q] [\-n] [\fPUSER\fB]
|
||||||
.PP
|
.PP
|
||||||
\fBeos\-parental\-controls\-client check [\-q] [\-n] [\fPUSER\fB] \fPPATH\fB
|
\fBmalcontent\-client check [\-q] [\-n] [\fPUSER\fB] \fPPATH\fB
|
||||||
.\"
|
.\"
|
||||||
.SH DESCRIPTION
|
.SH DESCRIPTION
|
||||||
.IX Header "DESCRIPTION"
|
.IX Header "DESCRIPTION"
|
||||||
.\"
|
.\"
|
||||||
\fBeos\-parental\-controls\-client\fP is a utility for querying and updating the
|
\fBmalcontent\-client\fP is a utility for querying and updating the
|
||||||
parental controls settings for users on the system. It will typically require
|
parental controls settings for users on the system. It will typically require
|
||||||
adminstrator access to do anything more than query the current user’s parental
|
adminstrator access to do anything more than query the current user’s parental
|
||||||
controls.
|
controls.
|
||||||
|
@ -66,7 +66,7 @@ authorization.)
|
||||||
.SH "ENVIRONMENT"
|
.SH "ENVIRONMENT"
|
||||||
.IX Header "ENVIRONMENT"
|
.IX Header "ENVIRONMENT"
|
||||||
.\"
|
.\"
|
||||||
\fBeos\-parental\-controls\-client\fP supports the standard GLib environment
|
\fBmalcontent\-client\fP supports the standard GLib environment
|
||||||
variables for debugging. These variables are \fBnot\fP intended to be used in
|
variables for debugging. These variables are \fBnot\fP intended to be used in
|
||||||
production:
|
production:
|
||||||
.\"
|
.\"
|
||||||
|
@ -79,7 +79,7 @@ debug output to be enabled.
|
||||||
.SH "EXIT STATUS"
|
.SH "EXIT STATUS"
|
||||||
.IX Header "EXIT STATUS"
|
.IX Header "EXIT STATUS"
|
||||||
.\"
|
.\"
|
||||||
\fBeos\-parental\-controls\-client\fP may return one of several error codes if it
|
\fBmalcontent\-client\fP may return one of several error codes if it
|
||||||
encounters problems.
|
encounters problems.
|
||||||
.\"
|
.\"
|
||||||
.IP "0" 4
|
.IP "0" 4
|
||||||
|
@ -90,7 +90,7 @@ given user.
|
||||||
.\"
|
.\"
|
||||||
.IP "1" 4
|
.IP "1" 4
|
||||||
.IX Item "1"
|
.IX Item "1"
|
||||||
An invalid option was passed to \fBeos\-parental\-controls\-client\fP on
|
An invalid option was passed to \fBmalcontent\-client\fP on
|
||||||
startup.
|
startup.
|
||||||
.\"
|
.\"
|
||||||
.IP "2" 4
|
.IP "2" 4
|
|
@ -21,8 +21,8 @@ import os
|
||||||
import pwd
|
import pwd
|
||||||
import sys
|
import sys
|
||||||
import gi
|
import gi
|
||||||
gi.require_version('EosParentalControls', '0') # noqa
|
gi.require_version('Malcontent', '0') # noqa
|
||||||
from gi.repository import EosParentalControls, GLib
|
from gi.repository import Malcontent, GLib
|
||||||
|
|
||||||
|
|
||||||
# Exit codes, which are a documented part of the API.
|
# Exit codes, which are a documented part of the API.
|
||||||
|
@ -37,7 +37,7 @@ def __get_app_filter(user_id, interactive):
|
||||||
|
|
||||||
If `interactive` is `True`, interactive polkit authorisation dialogues will
|
If `interactive` is `True`, interactive polkit authorisation dialogues will
|
||||||
be allowed. An exception will be raised on failure."""
|
be allowed. An exception will be raised on failure."""
|
||||||
return EosParentalControls.get_app_filter(
|
return Malcontent.get_app_filter(
|
||||||
connection=None, user_id=user_id,
|
connection=None, user_id=user_id,
|
||||||
allow_interactive_authorization=interactive, cancellable=None)
|
allow_interactive_authorization=interactive, cancellable=None)
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ def __set_app_filter(user_id, app_filter, interactive):
|
||||||
|
|
||||||
If `interactive` is `True`, interactive polkit authorisation dialogues will
|
If `interactive` is `True`, interactive polkit authorisation dialogues will
|
||||||
be allowed. An exception will be raised on failure."""
|
be allowed. An exception will be raised on failure."""
|
||||||
EosParentalControls.set_app_filter(
|
Malcontent.set_app_filter(
|
||||||
connection=None, user_id=user_id, app_filter=app_filter,
|
connection=None, user_id=user_id, app_filter=app_filter,
|
||||||
allow_interactive_authorization=interactive, cancellable=None)
|
allow_interactive_authorization=interactive, cancellable=None)
|
||||||
|
|
||||||
|
@ -98,16 +98,16 @@ def __lookup_user_id_or_error(user):
|
||||||
|
|
||||||
|
|
||||||
oars_value_mapping = {
|
oars_value_mapping = {
|
||||||
EosParentalControls.AppFilterOarsValue.UNKNOWN: "unknown",
|
Malcontent.AppFilterOarsValue.UNKNOWN: "unknown",
|
||||||
EosParentalControls.AppFilterOarsValue.NONE: "none",
|
Malcontent.AppFilterOarsValue.NONE: "none",
|
||||||
EosParentalControls.AppFilterOarsValue.MILD: "mild",
|
Malcontent.AppFilterOarsValue.MILD: "mild",
|
||||||
EosParentalControls.AppFilterOarsValue.MODERATE: "moderate",
|
Malcontent.AppFilterOarsValue.MODERATE: "moderate",
|
||||||
EosParentalControls.AppFilterOarsValue.INTENSE: "intense",
|
Malcontent.AppFilterOarsValue.INTENSE: "intense",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def __oars_value_to_string(value):
|
def __oars_value_to_string(value):
|
||||||
"""Convert an EosParentalControls.AppFilterOarsValue to a human-readable
|
"""Convert an Malcontent.AppFilterOarsValue to a human-readable
|
||||||
string."""
|
string."""
|
||||||
try:
|
try:
|
||||||
return oars_value_mapping[value]
|
return oars_value_mapping[value]
|
||||||
|
@ -117,7 +117,7 @@ def __oars_value_to_string(value):
|
||||||
|
|
||||||
def __oars_value_from_string(value_str):
|
def __oars_value_from_string(value_str):
|
||||||
"""Convert a human-readable string to an
|
"""Convert a human-readable string to an
|
||||||
EosParentalControls.AppFilterOarsValue."""
|
Malcontent.AppFilterOarsValue."""
|
||||||
for k, v in oars_value_mapping.items():
|
for k, v in oars_value_mapping.items():
|
||||||
if v == value_str:
|
if v == value_str:
|
||||||
return k
|
return k
|
||||||
|
@ -196,7 +196,7 @@ def command_set(user, allow_user_installation=True,
|
||||||
quiet=False, interactive=True):
|
quiet=False, interactive=True):
|
||||||
"""Set the app filter for the given user."""
|
"""Set the app filter for the given user."""
|
||||||
user_id = __lookup_user_id_or_error(user)
|
user_id = __lookup_user_id_or_error(user)
|
||||||
builder = EosParentalControls.AppFilterBuilder.new()
|
builder = Malcontent.AppFilterBuilder.new()
|
||||||
builder.set_allow_user_installation(allow_user_installation)
|
builder.set_allow_user_installation(allow_user_installation)
|
||||||
builder.set_allow_system_installation(allow_system_installation)
|
builder.set_allow_system_installation(allow_system_installation)
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
# Python program
|
||||||
|
install_data('malcontent-client.py',
|
||||||
|
install_dir: bindir,
|
||||||
|
install_mode: 'rwxr-xr-x',
|
||||||
|
rename: ['malcontent-client'],
|
||||||
|
)
|
||||||
|
|
||||||
|
# Documentation
|
||||||
|
install_man('docs/malcontent-client.8')
|
||||||
|
|
||||||
|
# TODO subdir('tests')
|
|
@ -1,7 +1,7 @@
|
||||||
<Project xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:foaf="http://xmlns.com/foaf/0.1/" xmlns="http://usefulinc.com/ns/doap#">
|
<Project xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:foaf="http://xmlns.com/foaf/0.1/" xmlns="http://usefulinc.com/ns/doap#">
|
||||||
<name xml:lang="en">eos-parental-controls</name>
|
<name xml:lang="en">malcontent</name>
|
||||||
<shortdesc xml:lang="en">eos-parental-controls provides restrictions for children on EOS</shortdesc>
|
<shortdesc xml:lang="en">malcontent provides restrictions for children on EOS</shortdesc>
|
||||||
<description xml:lang="en">eos-parental-controls implements support for restricting the abilities of non-administrator accounts on an Endless OS system.</description>
|
<description xml:lang="en">malcontent implements support for restricting the abilities of non-administrator accounts on an Endless OS system.</description>
|
||||||
<homepage rdf:resource="https://gitlab.freedesktop.org/pwithnall/malcontent"/>
|
<homepage rdf:resource="https://gitlab.freedesktop.org/pwithnall/malcontent"/>
|
||||||
<license rdf:resource="http://usefulinc.com/doap/licenses/lgpl"/>
|
<license rdf:resource="http://usefulinc.com/doap/licenses/lgpl"/>
|
||||||
<download-page rdf:resource="https://gitlab.freedesktop.org/pwithnall/malcontent"/>
|
<download-page rdf:resource="https://gitlab.freedesktop.org/pwithnall/malcontent"/>
|
|
@ -1,4 +1,4 @@
|
||||||
project('eos-parental-controls', 'c',
|
project('malcontent', 'c',
|
||||||
version : '0.1.0',
|
version : '0.1.0',
|
||||||
meson_version : '>= 0.47.0',
|
meson_version : '>= 0.47.0',
|
||||||
license: 'LGPLv2.1+',
|
license: 'LGPLv2.1+',
|
||||||
|
@ -119,5 +119,5 @@ test_env = [
|
||||||
]
|
]
|
||||||
|
|
||||||
subdir('accounts-service')
|
subdir('accounts-service')
|
||||||
subdir('eos-parental-controls-client')
|
subdir('malcontent-client')
|
||||||
subdir('libeos-parental-controls')
|
subdir('libmalcontent')
|
|
@ -1 +1 @@
|
||||||
i18n.gettext('eos-parental-controls', preset: 'glib')
|
i18n.gettext('malcontent', preset: 'glib')
|
Loading…
Reference in New Issue