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:
Philip Withnall 2019-02-26 17:43:56 +00:00
parent c9889a3ce7
commit 03436eacf5
15 changed files with 630 additions and 630 deletions

1427
libmalcontent/app-filter.c Normal file

File diff suppressed because it is too large Load diff

218
libmalcontent/app-filter.h Normal file
View file

@ -0,0 +1,218 @@
/* -*- 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
/**
* MctAppFilterError:
* @MCT_APP_FILTER_ERROR_INVALID_USER: Given user ID doesnt exist
* @MCT_APP_FILTER_ERROR_PERMISSION_DENIED: Not authorized to query the app
* filter for the given user
* @MCT_APP_FILTER_ERROR_INVALID_DATA: The data stored in the app filter for
* a user is inconsistent or invalid
*
* Errors which can be returned by mct_get_app_filter_async().
*
* Since: 0.2.0
*/
typedef enum
{
MCT_APP_FILTER_ERROR_INVALID_USER,
MCT_APP_FILTER_ERROR_PERMISSION_DENIED,
MCT_APP_FILTER_ERROR_INVALID_DATA,
} MctAppFilterError;
GQuark mct_app_filter_error_quark (void);
#define MCT_APP_FILTER_ERROR mct_app_filter_error_quark ()
/**
* MctAppFilterOarsValue:
* @MCT_APP_FILTER_OARS_VALUE_UNKNOWN: Unknown value for the given
* section.
* @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
* section.
* @MCT_APP_FILTER_OARS_VALUE_INTENSE: Intense rating for the given
* 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.
*
* Since: 0.2.0
*/
typedef enum
{
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;
/**
* MctAppFilter:
*
* #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
* 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.
*
* Since: 0.2.0
*/
typedef struct _MctAppFilter MctAppFilter;
GType mct_app_filter_get_type (void);
MctAppFilter *mct_app_filter_ref (MctAppFilter *filter);
void mct_app_filter_unref (MctAppFilter *filter);
G_DEFINE_AUTOPTR_CLEANUP_FUNC (MctAppFilter, mct_app_filter_unref)
uid_t mct_app_filter_get_user_id (MctAppFilter *filter);
gboolean mct_app_filter_is_path_allowed (MctAppFilter *filter,
const gchar *path);
gboolean mct_app_filter_is_flatpak_ref_allowed (MctAppFilter *filter,
const gchar *app_ref);
gboolean mct_app_filter_is_flatpak_app_allowed (MctAppFilter *filter,
const gchar *app_id);
gboolean mct_app_filter_is_appinfo_allowed (MctAppFilter *filter,
GAppInfo *app_info);
const gchar **mct_app_filter_get_oars_sections (MctAppFilter *filter);
MctAppFilterOarsValue mct_app_filter_get_oars_value (MctAppFilter *filter,
const gchar *oars_section);
gboolean mct_app_filter_is_user_installation_allowed (MctAppFilter *filter);
gboolean mct_app_filter_is_system_installation_allowed (MctAppFilter *filter);
MctAppFilter *mct_get_app_filter (GDBusConnection *connection,
uid_t user_id,
gboolean allow_interactive_authorization,
GCancellable *cancellable,
GError **error);
void mct_get_app_filter_async (GDBusConnection *connection,
uid_t user_id,
gboolean allow_interactive_authorization,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
MctAppFilter *mct_get_app_filter_finish (GAsyncResult *result,
GError **error);
gboolean mct_set_app_filter (GDBusConnection *connection,
uid_t user_id,
MctAppFilter *app_filter,
gboolean allow_interactive_authorization,
GCancellable *cancellable,
GError **error);
void mct_set_app_filter_async (GDBusConnection *connection,
uid_t user_id,
MctAppFilter *app_filter,
gboolean allow_interactive_authorization,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
gboolean mct_set_app_filter_finish (GAsyncResult *result,
GError **error);
/**
* MctAppFilterBuilder:
*
* #MctAppFilterBuilder is a stack-allocated mutable structure used to build an
* #MctAppFilter instance. Use mct_app_filter_builder_init(), various method
* calls to set properties of the app filter, and then
* mct_app_filter_builder_end(), to construct an #MctAppFilter.
*
* Since: 0.2.0
*/
typedef struct
{
/*< private >*/
gpointer p0;
gpointer p1;
gboolean b0;
gboolean b1;
gpointer p2;
gpointer p3;
} MctAppFilterBuilder;
GType mct_app_filter_builder_get_type (void);
/**
* MCT_APP_FILTER_BUILDER_INIT:
*
* Initialise a stack-allocated #MctAppFilterBuilder instance at declaration
* time.
*
* This is typically used with g_auto():
* |[
* g_auto(MctAppFilterBuilder) builder = MCT_APP_FILTER_BUILDER_INIT ();
* ]|
*
* Since: 0.2.0
*/
#define MCT_APP_FILTER_BUILDER_INIT() \
{ \
g_ptr_array_new_with_free_func (g_free), \
g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL), \
TRUE, \
FALSE, \
}
void mct_app_filter_builder_init (MctAppFilterBuilder *builder);
void mct_app_filter_builder_clear (MctAppFilterBuilder *builder);
G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC (MctAppFilterBuilder,
mct_app_filter_builder_clear)
MctAppFilterBuilder *mct_app_filter_builder_new (void);
MctAppFilterBuilder *mct_app_filter_builder_copy (MctAppFilterBuilder *builder);
void mct_app_filter_builder_free (MctAppFilterBuilder *builder);
G_DEFINE_AUTOPTR_CLEANUP_FUNC (MctAppFilterBuilder, mct_app_filter_builder_free)
MctAppFilter *mct_app_filter_builder_end (MctAppFilterBuilder *builder);
void mct_app_filter_builder_blacklist_path (MctAppFilterBuilder *builder,
const gchar *path);
void mct_app_filter_builder_blacklist_flatpak_ref (MctAppFilterBuilder *builder,
const gchar *app_ref);
void mct_app_filter_builder_set_oars_value (MctAppFilterBuilder *builder,
const gchar *oars_section,
MctAppFilterOarsValue value);
void mct_app_filter_builder_set_allow_user_installation (MctAppFilterBuilder *builder,
gboolean allow_user_installation);
void mct_app_filter_builder_set_allow_system_installation (MctAppFilterBuilder *builder,
gboolean allow_system_installation);
G_END_DECLS

62
libmalcontent/meson.build Normal file
View file

@ -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')

View file

@ -0,0 +1,138 @@
/* -*- 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
/* Static definition of the AppFilter interface on org.freedesktop.Accounts.
* FIXME: Once we can depend on a new enough version of GLib, generate this
* from introspection XML using `gdbus-codegen --interface-info-{header,body}`. */
static const GDBusPropertyInfo app_filter_property_app_filter =
{
.ref_count = -1, /* static */
.name = (gchar *) "AppFilter",
.signature = (gchar *) "(bas)",
.flags = G_DBUS_PROPERTY_INFO_FLAGS_READABLE | G_DBUS_PROPERTY_INFO_FLAGS_WRITABLE,
.annotations = NULL,
};
static const GDBusPropertyInfo app_filter_property_oars_filter =
{
.ref_count = -1, /* static */
.name = (gchar *) "OarsFilter",
.signature = (gchar *) "(sa{ss})",
.flags = G_DBUS_PROPERTY_INFO_FLAGS_READABLE | G_DBUS_PROPERTY_INFO_FLAGS_WRITABLE,
.annotations = NULL,
};
static const GDBusPropertyInfo app_filter_property_allow_user_installation =
{
.ref_count = -1, /* static */
.name = (gchar *) "AllowUserInstallation",
.signature = (gchar *) "b",
.flags = G_DBUS_PROPERTY_INFO_FLAGS_READABLE | G_DBUS_PROPERTY_INFO_FLAGS_WRITABLE,
.annotations = NULL,
};
static const GDBusPropertyInfo app_filter_property_allow_system_installation =
{
.ref_count = -1, /* static */
.name = (gchar *) "AllowSystemInstallation",
.signature = (gchar *) "b",
.flags = G_DBUS_PROPERTY_INFO_FLAGS_READABLE | G_DBUS_PROPERTY_INFO_FLAGS_WRITABLE,
.annotations = NULL,
};
static const GDBusPropertyInfo *app_filter_properties[] =
{
(GDBusPropertyInfo *) &app_filter_property_app_filter,
(GDBusPropertyInfo *) &app_filter_property_oars_filter,
(GDBusPropertyInfo *) &app_filter_property_allow_user_installation,
(GDBusPropertyInfo *) &app_filter_property_allow_system_installation,
NULL,
};
static const GDBusInterfaceInfo app_filter_interface_info =
{
.ref_count = -1, /* static */
.name = (gchar *) "com.endlessm.ParentalControls.AppFilter",
.methods = NULL,
.signals = NULL,
.properties = (GDBusPropertyInfo **) &app_filter_properties,
.annotations = NULL,
};
static const GDBusArgInfo accounts_method_find_user_by_id_arg_user_id =
{
.ref_count = -1, /* static */
.name = (gchar *) "UserId",
.signature = (gchar *) "x",
.annotations = NULL,
};
static const GDBusArgInfo accounts_method_find_user_by_id_arg_object_path =
{
.ref_count = -1, /* static */
.name = (gchar *) "ObjectPath",
.signature = (gchar *) "o",
.annotations = NULL,
};
static const GDBusArgInfo *accounts_method_find_user_by_id_in_args[] =
{
(GDBusArgInfo *) &accounts_method_find_user_by_id_arg_user_id,
NULL,
};
static const GDBusArgInfo *accounts_method_find_user_by_id_out_args[] =
{
(GDBusArgInfo *) &accounts_method_find_user_by_id_arg_object_path,
NULL,
};
static const GDBusMethodInfo accounts_method_find_user_by_id =
{
.ref_count = -1, /* static */
.name = (gchar *) "FindUserById",
.in_args = (GDBusArgInfo **) &accounts_method_find_user_by_id_in_args,
.out_args = (GDBusArgInfo **) &accounts_method_find_user_by_id_out_args,
.annotations = NULL,
};
static const GDBusMethodInfo *accounts_methods[] =
{
(GDBusMethodInfo *) &accounts_method_find_user_by_id,
NULL,
};
static const GDBusInterfaceInfo accounts_interface_info =
{
.ref_count = -1, /* static */
.name = (gchar *) "org.freedesktop.Accounts",
.methods = (GDBusMethodInfo **) &accounts_methods,
.signals = NULL,
.properties = NULL,
.annotations = NULL,
};
G_END_DECLS

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,52 @@
deps = [
dependency('gio-2.0', version: '>= 2.44'),
dependency('gio-unix-2.0', version: '>= 2.44'),
dependency('glib-2.0', version: '>= 2.54.2'),
dependency('gobject-2.0', version: '>= 2.44'),
libmalcontent_dep,
libglib_testing_dep,
]
envs = test_env + [
'G_TEST_SRCDIR=' + meson.current_source_dir(),
'G_TEST_BUILDDIR=' + meson.current_build_dir(),
]
test_programs = [
['app-filter', ['accounts-service-iface.h'], deps],
]
installed_tests_metadir = join_paths(datadir, 'installed-tests',
'libmalcontent-' + libmalcontent_api_version)
installed_tests_execdir = join_paths(libexecdir, 'installed-tests',
'libmalcontent-' + libmalcontent_api_version)
foreach program: test_programs
test_conf = configuration_data()
test_conf.set('installed_tests_dir', installed_tests_execdir)
test_conf.set('program', program[0])
configure_file(
input: test_template,
output: program[0] + '.test',
install: enable_installed_tests,
install_dir: installed_tests_metadir,
configuration: test_conf,
)
exe = executable(
program[0],
[program[0] + '.c'] + program[1],
dependencies: program[2],
include_directories: root_inc,
install: enable_installed_tests,
install_dir: installed_tests_execdir,
)
test(
program[0],
exe,
env: envs,
args: ['--tap'],
)
endforeach